aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/kdrive
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-06-28 22:07:26 +0000
committermarha <marha@users.sourceforge.net>2009-06-28 22:07:26 +0000
commit3562e78743202e43aec8727005182a2558117eca (patch)
tree8f9113a77d12470c5c851a2a8e4cb02e89df7d43 /xorg-server/hw/kdrive
downloadvcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.gz
vcxsrv-3562e78743202e43aec8727005182a2558117eca.tar.bz2
vcxsrv-3562e78743202e43aec8727005182a2558117eca.zip
Checked in the following released items:
xkeyboard-config-1.4.tar.gz ttf-bitstream-vera-1.10.tar.gz font-alias-1.0.1.tar.gz font-sun-misc-1.0.0.tar.gz font-sun-misc-1.0.0.tar.gz font-sony-misc-1.0.0.tar.gz font-schumacher-misc-1.0.0.tar.gz font-mutt-misc-1.0.0.tar.gz font-misc-misc-1.0.0.tar.gz font-misc-meltho-1.0.0.tar.gz font-micro-misc-1.0.0.tar.gz font-jis-misc-1.0.0.tar.gz font-isas-misc-1.0.0.tar.gz font-dec-misc-1.0.0.tar.gz font-daewoo-misc-1.0.0.tar.gz font-cursor-misc-1.0.0.tar.gz font-arabic-misc-1.0.0.tar.gz font-winitzki-cyrillic-1.0.0.tar.gz font-misc-cyrillic-1.0.0.tar.gz font-cronyx-cyrillic-1.0.0.tar.gz font-screen-cyrillic-1.0.1.tar.gz font-xfree86-type1-1.0.1.tar.gz font-adobe-utopia-type1-1.0.1.tar.gz font-ibm-type1-1.0.0.tar.gz font-bitstream-type1-1.0.0.tar.gz font-bitstream-speedo-1.0.0.tar.gz font-bh-ttf-1.0.0.tar.gz font-bh-type1-1.0.0.tar.gz font-bitstream-100dpi-1.0.0.tar.gz font-bh-lucidatypewriter-100dpi-1.0.0.tar.gz font-bh-100dpi-1.0.0.tar.gz font-adobe-utopia-100dpi-1.0.1.tar.gz font-adobe-100dpi-1.0.0.tar.gz font-util-1.0.1.tar.gz font-bitstream-75dpi-1.0.0.tar.gz font-bh-lucidatypewriter-75dpi-1.0.0.tar.gz font-adobe-utopia-75dpi-1.0.1.tar.gz font-bh-75dpi-1.0.0.tar.gz bdftopcf-1.0.1.tar.gz font-adobe-75dpi-1.0.0.tar.gz mkfontscale-1.0.6.tar.gz openssl-0.9.8k.tar.gz bigreqsproto-1.0.2.tar.gz xtrans-1.2.2.tar.gz resourceproto-1.0.2.tar.gz inputproto-1.4.4.tar.gz compositeproto-0.4.tar.gz damageproto-1.1.0.tar.gz zlib-1.2.3.tar.gz xkbcomp-1.0.5.tar.gz freetype-2.3.9.tar.gz pthreads-w32-2-8-0-release.tar.gz pixman-0.12.0.tar.gz kbproto-1.0.3.tar.gz evieext-1.0.2.tar.gz fixesproto-4.0.tar.gz recordproto-1.13.2.tar.gz randrproto-1.2.2.tar.gz scrnsaverproto-1.1.0.tar.gz renderproto-0.9.3.tar.gz xcmiscproto-1.1.2.tar.gz fontsproto-2.0.2.tar.gz xextproto-7.0.3.tar.gz xproto-7.0.14.tar.gz libXdmcp-1.0.2.tar.gz libxkbfile-1.0.5.tar.gz libfontenc-1.0.4.tar.gz libXfont-1.3.4.tar.gz libX11-1.1.5.tar.gz libXau-1.0.4.tar.gz libxcb-1.1.tar.gz xorg-server-1.5.3.tar.gz
Diffstat (limited to 'xorg-server/hw/kdrive')
-rw-r--r--xorg-server/hw/kdrive/Makefile.am42
-rw-r--r--xorg-server/hw/kdrive/Makefile.in714
-rw-r--r--xorg-server/hw/kdrive/ati/Makefile.am74
-rw-r--r--xorg-server/hw/kdrive/ati/Makefile.in757
-rw-r--r--xorg-server/hw/kdrive/ati/ati.c761
-rw-r--r--xorg-server/hw/kdrive/ati/ati.h409
-rw-r--r--xorg-server/hw/kdrive/ati/ati_cursor.c559
-rw-r--r--xorg-server/hw/kdrive/ati/ati_dma.c1037
-rw-r--r--xorg-server/hw/kdrive/ati/ati_dma.h141
-rw-r--r--xorg-server/hw/kdrive/ati/ati_draw.c918
-rw-r--r--xorg-server/hw/kdrive/ati/ati_draw.h93
-rw-r--r--xorg-server/hw/kdrive/ati/ati_microcode.c857
-rw-r--r--xorg-server/hw/kdrive/ati/ati_reg.h1927
-rw-r--r--xorg-server/hw/kdrive/ati/ati_stub.c77
-rw-r--r--xorg-server/hw/kdrive/ati/ati_video.c988
-rw-r--r--xorg-server/hw/kdrive/ati/r128_composite.c564
-rw-r--r--xorg-server/hw/kdrive/ati/radeon_composite.c875
-rw-r--r--xorg-server/hw/kdrive/chips/Makefile.am36
-rw-r--r--xorg-server/hw/kdrive/chips/Makefile.in717
-rw-r--r--xorg-server/hw/kdrive/chips/chips.c334
-rw-r--r--xorg-server/hw/kdrive/chips/chips.h117
-rw-r--r--xorg-server/hw/kdrive/chips/chipsdraw.c491
-rw-r--r--xorg-server/hw/kdrive/chips/chipsstub.c67
-rw-r--r--xorg-server/hw/kdrive/ephyr/Makefile.am91
-rw-r--r--xorg-server/hw/kdrive/ephyr/Makefile.in934
-rw-r--r--xorg-server/hw/kdrive/ephyr/README73
-rw-r--r--xorg-server/hw/kdrive/ephyr/XF86dri.c654
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyr.c1155
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyr.h202
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyr_draw.c524
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrdri.c291
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrdri.h75
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrdriext.c1443
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrdriext.h42
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrglxext.c732
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrglxext.h35
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrhostglx.c703
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrhostglx.h76
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrhostvideo.c1014
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrhostvideo.h238
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrinit.c345
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrlog.h67
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrvideo.c1278
-rw-r--r--xorg-server/hw/kdrive/ephyr/hostx.c1434
-rw-r--r--xorg-server/hw/kdrive/ephyr/hostx.h261
-rw-r--r--xorg-server/hw/kdrive/ephyr/os.c51
-rw-r--r--xorg-server/hw/kdrive/epson/Makefile.am36
-rw-r--r--xorg-server/hw/kdrive/epson/Makefile.in716
-rw-r--r--xorg-server/hw/kdrive/epson/epson13806.c604
-rw-r--r--xorg-server/hw/kdrive/epson/epson13806.h132
-rw-r--r--xorg-server/hw/kdrive/epson/epson13806draw.c649
-rw-r--r--xorg-server/hw/kdrive/epson/epson13806draw.h119
-rw-r--r--xorg-server/hw/kdrive/epson/epson13806reg.h183
-rw-r--r--xorg-server/hw/kdrive/epson/epson13806stub.c69
-rw-r--r--xorg-server/hw/kdrive/fake/Makefile.am31
-rw-r--r--xorg-server/hw/kdrive/fake/Makefile.in715
-rw-r--r--xorg-server/hw/kdrive/fake/fake.c484
-rw-r--r--xorg-server/hw/kdrive/fake/fake.h137
-rw-r--r--xorg-server/hw/kdrive/fake/fakeinit.c108
-rw-r--r--xorg-server/hw/kdrive/fake/kbd.c208
-rw-r--r--xorg-server/hw/kdrive/fake/mouse.c67
-rw-r--r--xorg-server/hw/kdrive/fake/os.c63
-rw-r--r--xorg-server/hw/kdrive/fbdev/Makefile.am29
-rw-r--r--xorg-server/hw/kdrive/fbdev/Makefile.in708
-rw-r--r--xorg-server/hw/kdrive/fbdev/fbdev.c821
-rw-r--r--xorg-server/hw/kdrive/fbdev/fbdev.h140
-rw-r--r--xorg-server/hw/kdrive/fbdev/fbinit.c103
-rw-r--r--xorg-server/hw/kdrive/i810/Makefile.am39
-rw-r--r--xorg-server/hw/kdrive/i810/Makefile.in721
-rw-r--r--xorg-server/hw/kdrive/i810/i810.c2112
-rw-r--r--xorg-server/hw/kdrive/i810/i810.h511
-rw-r--r--xorg-server/hw/kdrive/i810/i810_cursor.c435
-rw-r--r--xorg-server/hw/kdrive/i810/i810_reg.h695
-rw-r--r--xorg-server/hw/kdrive/i810/i810_video.c1136
-rw-r--r--xorg-server/hw/kdrive/i810/i810draw.c352
-rw-r--r--xorg-server/hw/kdrive/i810/i810draw.h46
-rw-r--r--xorg-server/hw/kdrive/i810/i810stub.c92
-rw-r--r--xorg-server/hw/kdrive/linux/Makefile.am34
-rw-r--r--xorg-server/hw/kdrive/linux/Makefile.in679
-rw-r--r--xorg-server/hw/kdrive/linux/agp.c354
-rw-r--r--xorg-server/hw/kdrive/linux/agp.h71
-rw-r--r--xorg-server/hw/kdrive/linux/bus.c134
-rw-r--r--xorg-server/hw/kdrive/linux/evdev.c536
-rw-r--r--xorg-server/hw/kdrive/linux/keyboard.c803
-rw-r--r--xorg-server/hw/kdrive/linux/klinux.h32
-rw-r--r--xorg-server/hw/kdrive/linux/linux.c484
-rw-r--r--xorg-server/hw/kdrive/linux/mouse.c1027
-rw-r--r--xorg-server/hw/kdrive/linux/ms.c183
-rw-r--r--xorg-server/hw/kdrive/linux/ps2.c187
-rw-r--r--xorg-server/hw/kdrive/linux/ts.c209
-rw-r--r--xorg-server/hw/kdrive/linux/tslib.c193
-rw-r--r--xorg-server/hw/kdrive/mach64/Makefile.am43
-rw-r--r--xorg-server/hw/kdrive/mach64/Makefile.in719
-rw-r--r--xorg-server/hw/kdrive/mach64/mach64.c433
-rw-r--r--xorg-server/hw/kdrive/mach64/mach64.h653
-rw-r--r--xorg-server/hw/kdrive/mach64/mach64draw.c590
-rw-r--r--xorg-server/hw/kdrive/mach64/mach64draw.h69
-rw-r--r--xorg-server/hw/kdrive/mach64/mach64stub.c75
-rw-r--r--xorg-server/hw/kdrive/mach64/mach64video.c994
-rw-r--r--xorg-server/hw/kdrive/mga/Makefile.am38
-rw-r--r--xorg-server/hw/kdrive/mga/Makefile.in720
-rw-r--r--xorg-server/hw/kdrive/mga/g400_common.h185
-rw-r--r--xorg-server/hw/kdrive/mga/g400_composite.c510
-rw-r--r--xorg-server/hw/kdrive/mga/mga.c240
-rw-r--r--xorg-server/hw/kdrive/mga/mga.h164
-rw-r--r--xorg-server/hw/kdrive/mga/mgadraw.c324
-rw-r--r--xorg-server/hw/kdrive/mga/mgastub.c64
-rw-r--r--xorg-server/hw/kdrive/neomagic/Makefile.am49
-rw-r--r--xorg-server/hw/kdrive/neomagic/Makefile.in723
-rw-r--r--xorg-server/hw/kdrive/neomagic/README15
-rw-r--r--xorg-server/hw/kdrive/neomagic/neo_draw.c210
-rw-r--r--xorg-server/hw/kdrive/neomagic/neomagic.c335
-rw-r--r--xorg-server/hw/kdrive/neomagic/neomagic.h210
-rw-r--r--xorg-server/hw/kdrive/neomagic/neomagicstub.c73
-rw-r--r--xorg-server/hw/kdrive/nvidia/Makefile.am39
-rw-r--r--xorg-server/hw/kdrive/nvidia/Makefile.in720
-rw-r--r--xorg-server/hw/kdrive/nvidia/nvidia.c361
-rw-r--r--xorg-server/hw/kdrive/nvidia/nvidia.h247
-rw-r--r--xorg-server/hw/kdrive/nvidia/nvidiadraw.c238
-rw-r--r--xorg-server/hw/kdrive/nvidia/nvidiadraw.h69
-rw-r--r--xorg-server/hw/kdrive/nvidia/nvidiastub.c65
-rw-r--r--xorg-server/hw/kdrive/pm2/Makefile.am37
-rw-r--r--xorg-server/hw/kdrive/pm2/Makefile.in717
-rw-r--r--xorg-server/hw/kdrive/pm2/glint_regs.h1370
-rw-r--r--xorg-server/hw/kdrive/pm2/pm2.c295
-rw-r--r--xorg-server/hw/kdrive/pm2/pm2.h162
-rw-r--r--xorg-server/hw/kdrive/pm2/pm2_draw.c318
-rw-r--r--xorg-server/hw/kdrive/pm2/pm2stub.c54
-rw-r--r--xorg-server/hw/kdrive/r128/Makefile.am36
-rw-r--r--xorg-server/hw/kdrive/r128/Makefile.in717
-rw-r--r--xorg-server/hw/kdrive/r128/r128.c250
-rw-r--r--xorg-server/hw/kdrive/r128/r128.h123
-rw-r--r--xorg-server/hw/kdrive/r128/r128draw.c296
-rw-r--r--xorg-server/hw/kdrive/r128/r128stub.c67
-rw-r--r--xorg-server/hw/kdrive/sdl/Makefile.am19
-rw-r--r--xorg-server/hw/kdrive/sdl/Makefile.in682
-rw-r--r--xorg-server/hw/kdrive/sdl/sdl.c455
-rw-r--r--xorg-server/hw/kdrive/sis300/Makefile.am51
-rw-r--r--xorg-server/hw/kdrive/sis300/Makefile.in725
-rw-r--r--xorg-server/hw/kdrive/sis300/sis.c311
-rw-r--r--xorg-server/hw/kdrive/sis300/sis.h160
-rw-r--r--xorg-server/hw/kdrive/sis300/sis_draw.c320
-rw-r--r--xorg-server/hw/kdrive/sis300/sis_reg.h902
-rw-r--r--xorg-server/hw/kdrive/sis300/sis_stub.c77
-rw-r--r--xorg-server/hw/kdrive/smi/Makefile.am41
-rw-r--r--xorg-server/hw/kdrive/smi/Makefile.in723
-rw-r--r--xorg-server/hw/kdrive/smi/smi.c343
-rw-r--r--xorg-server/hw/kdrive/smi/smi.h257
-rw-r--r--xorg-server/hw/kdrive/smi/smidraw.c340
-rw-r--r--xorg-server/hw/kdrive/smi/smidraw.h69
-rw-r--r--xorg-server/hw/kdrive/smi/smistub.c67
-rw-r--r--xorg-server/hw/kdrive/src/Makefile.am40
-rw-r--r--xorg-server/hw/kdrive/src/Makefile.in740
-rw-r--r--xorg-server/hw/kdrive/src/fourcc.h133
-rw-r--r--xorg-server/hw/kdrive/src/kaa.c1081
-rw-r--r--xorg-server/hw/kdrive/src/kaa.h120
-rw-r--r--xorg-server/hw/kdrive/src/kaapict.c719
-rw-r--r--xorg-server/hw/kdrive/src/kasync.c341
-rw-r--r--xorg-server/hw/kdrive/src/kcmap.c294
-rw-r--r--xorg-server/hw/kdrive/src/kcurscol.c94
-rw-r--r--xorg-server/hw/kdrive/src/kdrive.c1416
-rw-r--r--xorg-server/hw/kdrive/src/kdrive.h1000
-rw-r--r--xorg-server/hw/kdrive/src/kinfo.c173
-rw-r--r--xorg-server/hw/kdrive/src/kinput.c2513
-rw-r--r--xorg-server/hw/kdrive/src/kkeymap.c189
-rw-r--r--xorg-server/hw/kdrive/src/kmap.c178
-rw-r--r--xorg-server/hw/kdrive/src/kmode.c400
-rw-r--r--xorg-server/hw/kdrive/src/knoop.c251
-rw-r--r--xorg-server/hw/kdrive/src/koffscreen.c375
-rw-r--r--xorg-server/hw/kdrive/src/kshadow.c83
-rw-r--r--xorg-server/hw/kdrive/src/ktest.c76
-rw-r--r--xorg-server/hw/kdrive/src/kxv.c1954
-rw-r--r--xorg-server/hw/kdrive/src/kxv.h316
-rw-r--r--xorg-server/hw/kdrive/src/vga.c328
-rw-r--r--xorg-server/hw/kdrive/src/vga.h144
-rw-r--r--xorg-server/hw/kdrive/vesa/Makefile.am33
-rw-r--r--xorg-server/hw/kdrive/vesa/Makefile.in717
-rw-r--r--xorg-server/hw/kdrive/vesa/vbe.c706
-rw-r--r--xorg-server/hw/kdrive/vesa/vbe.h165
-rw-r--r--xorg-server/hw/kdrive/vesa/vesa.c1823
-rw-r--r--xorg-server/hw/kdrive/vesa/vesa.h295
-rw-r--r--xorg-server/hw/kdrive/vesa/vesainit.c92
-rw-r--r--xorg-server/hw/kdrive/vesa/vga.c242
-rw-r--r--xorg-server/hw/kdrive/vesa/vga.h59
-rw-r--r--xorg-server/hw/kdrive/vesa/vm86.c764
-rw-r--r--xorg-server/hw/kdrive/vesa/vm86.h180
-rw-r--r--xorg-server/hw/kdrive/via/Makefile.am37
-rw-r--r--xorg-server/hw/kdrive/via/Makefile.in716
-rw-r--r--xorg-server/hw/kdrive/via/via.c435
-rw-r--r--xorg-server/hw/kdrive/via/via.h129
-rw-r--r--xorg-server/hw/kdrive/via/via_regs.h154
-rw-r--r--xorg-server/hw/kdrive/via/viadraw.c499
-rw-r--r--xorg-server/hw/kdrive/via/viadraw.h45
-rw-r--r--xorg-server/hw/kdrive/via/viastub.c135
194 files changed, 80803 insertions, 0 deletions
diff --git a/xorg-server/hw/kdrive/Makefile.am b/xorg-server/hw/kdrive/Makefile.am
new file mode 100644
index 000000000..5803644d5
--- /dev/null
+++ b/xorg-server/hw/kdrive/Makefile.am
@@ -0,0 +1,42 @@
+if KDRIVEVESA
+VESA_SUBDIRS = vesa ati chips epson i810 mach64 mga nvidia pm2 r128 \
+ smi via
+endif
+
+if BUILD_KDRIVEFBDEVLIB
+FBDEV_SUBDIRS = fbdev
+endif
+
+if XFAKESERVER
+XFAKE_SUBDIRS = fake
+endif
+
+if XSDLSERVER
+XSDL_SUBDIRS = sdl
+endif
+
+if XEPHYR
+XEPHYR_SUBDIRS = ephyr
+endif
+
+if KDRIVELINUX
+LINUX_SUBDIRS = linux
+endif
+
+SERVER_SUBDIRS = \
+ $(XSDL_SUBDIRS) \
+ $(FBDEV_SUBDIRS) \
+ $(VESA_SUBDIRS) \
+ $(XEPHYR_SUBDIRS) \
+ $(XFAKE_SUBDIRS)
+
+SUBDIRS = \
+ src \
+ $(LINUX_SUBDIRS) \
+ $(SERVER_SUBDIRS)
+
+DIST_SUBDIRS = vesa ati chips epson i810 mach64 mga neomagic nvidia pm2 r128 \
+ smi via fbdev sdl ephyr src linux fake sis300
+
+relink:
+ @for i in $(SERVER_SUBDIRS) ; do make -C $$i relink ; done
diff --git a/xorg-server/hw/kdrive/Makefile.in b/xorg-server/hw/kdrive/Makefile.in
new file mode 100644
index 000000000..ad6f20668
--- /dev/null
+++ b/xorg-server/hw/kdrive/Makefile.in
@@ -0,0 +1,714 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = hw/kdrive
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-dvi-recursive install-exec-recursive \
+ install-html-recursive install-info-recursive \
+ install-pdf-recursive install-ps-recursive install-recursive \
+ installcheck-recursive installdirs-recursive pdf-recursive \
+ ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+@KDRIVEVESA_TRUE@VESA_SUBDIRS = vesa ati chips epson i810 mach64 mga nvidia pm2 r128 \
+@KDRIVEVESA_TRUE@ smi via
+
+@BUILD_KDRIVEFBDEVLIB_TRUE@FBDEV_SUBDIRS = fbdev
+@XFAKESERVER_TRUE@XFAKE_SUBDIRS = fake
+@XSDLSERVER_TRUE@XSDL_SUBDIRS = sdl
+@XEPHYR_TRUE@XEPHYR_SUBDIRS = ephyr
+@KDRIVELINUX_TRUE@LINUX_SUBDIRS = linux
+SERVER_SUBDIRS = \
+ $(XSDL_SUBDIRS) \
+ $(FBDEV_SUBDIRS) \
+ $(VESA_SUBDIRS) \
+ $(XEPHYR_SUBDIRS) \
+ $(XFAKE_SUBDIRS)
+
+SUBDIRS = \
+ src \
+ $(LINUX_SUBDIRS) \
+ $(SERVER_SUBDIRS)
+
+DIST_SUBDIRS = vesa ati chips epson i810 mach64 mga neomagic nvidia pm2 r128 \
+ smi via fbdev sdl ephyr src linux fake sis300
+
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ rev=''; for subdir in $$list; do \
+ if test "$$subdir" = "."; then :; else \
+ rev="$$subdir $$rev"; \
+ fi; \
+ done; \
+ rev="$$rev ."; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done && test -z "$$fail"
+tags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+ done
+ctags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+ list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ distdir=`$(am__cd) $(distdir) && pwd`; \
+ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
+ (cd $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$top_distdir" \
+ distdir="$$distdir/$$subdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-info: install-info-recursive
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-ps: install-ps-recursive
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \
+ install-strip
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+ all all-am check check-am clean clean-generic clean-libtool \
+ ctags ctags-recursive distclean distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs installdirs-am maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
+ uninstall uninstall-am
+
+
+relink:
+ @for i in $(SERVER_SUBDIRS) ; do make -C $$i relink ; done
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/ati/Makefile.am b/xorg-server/hw/kdrive/ati/Makefile.am
new file mode 100644
index 000000000..31462bb04
--- /dev/null
+++ b/xorg-server/hw/kdrive/ati/Makefile.am
@@ -0,0 +1,74 @@
+#if DRI
+#DRI_INCLUDES = -I$(top_srcdir)/dri \
+# -I$(top_srcdir)/drm
+#DRI_LIBS = $(top_builddir)/dri/libdri.a \
+# $(top_builddir)/drm/libdrm.a
+#DRI_SOURCES = ati_dri.c \
+# ati_dri.h \
+# ati_dripriv.h \
+# r128_common.h \
+# r128_sarea.h \
+# radeon_common.h \
+# radeon_sarea.h
+#endif
+
+if KDRIVEFBDEV
+FBDEV_INCLUDES =-I$(top_srcdir)/hw/kdrive/fbdev
+FBDEV_LIBS = $(top_builddir)/hw/kdrive/fbdev/libfbdev.a
+endif
+
+if KDRIVEVESA
+VESA_INCLUDES = -I$(top_srcdir)/hw/kdrive/vesa
+VESA_LIBS = $(top_builddir)/hw/kdrive/vesa/libvesa.a
+endif
+
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ $(DRI_INCLUDES) \
+ $(FBDEV_INCLUDES) \
+ $(VESA_INCLUDES) \
+ @KDRIVE_CFLAGS@
+
+bin_PROGRAMS = Xati
+
+noinst_LIBRARIES = libati.a
+
+libati_a_SOURCES = \
+ ati_cursor.c \
+ ati_dma.c \
+ ati_dma.h \
+ ati_draw.c \
+ ati_draw.h \
+ ati_microcode.c \
+ ati.c \
+ ati.h \
+ ati_reg.h \
+ r128_composite.c \
+ ati_video.c \
+ radeon_composite.c \
+ $(DRI_SOURCES)
+
+Xati_SOURCES = \
+ ati_stub.c
+
+ATI_LIBS = \
+ libati.a \
+ $(FBDEV_LIBS) \
+ $(VESA_LIBS) \
+ $(DRI_LIBS) \
+ @KDRIVE_LIBS@
+
+if GLX
+Xati_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
+Xati_LDADD = \
+ $(ATI_LIBS) \
+ @KDRIVE_LIBS@
+
+Xati_DEPENDENCIES = \
+ libati.a \
+ @KDRIVE_LOCAL_LIBS@
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/ati/Makefile.in b/xorg-server/hw/kdrive/ati/Makefile.in
new file mode 100644
index 000000000..b38d1a16e
--- /dev/null
+++ b/xorg-server/hw/kdrive/ati/Makefile.in
@@ -0,0 +1,757 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+#if DRI
+#DRI_INCLUDES = -I$(top_srcdir)/dri \
+# -I$(top_srcdir)/drm
+#DRI_LIBS = $(top_builddir)/dri/libdri.a \
+# $(top_builddir)/drm/libdrm.a
+#DRI_SOURCES = ati_dri.c \
+# ati_dri.h \
+# ati_dripriv.h \
+# r128_common.h \
+# r128_sarea.h \
+# radeon_common.h \
+# radeon_sarea.h
+#endif
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xati$(EXEEXT)
+subdir = hw/kdrive/ati
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libati_a_AR = $(AR) $(ARFLAGS)
+libati_a_LIBADD =
+am_libati_a_OBJECTS = ati_cursor.$(OBJEXT) ati_dma.$(OBJEXT) \
+ ati_draw.$(OBJEXT) ati_microcode.$(OBJEXT) ati.$(OBJEXT) \
+ r128_composite.$(OBJEXT) ati_video.$(OBJEXT) \
+ radeon_composite.$(OBJEXT)
+libati_a_OBJECTS = $(am_libati_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xati_OBJECTS = ati_stub.$(OBJEXT)
+Xati_OBJECTS = $(am_Xati_OBJECTS)
+am__DEPENDENCIES_1 = libati.a $(FBDEV_LIBS) $(VESA_LIBS)
+Xati_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xati_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libati_a_SOURCES) $(Xati_SOURCES)
+DIST_SOURCES = $(libati_a_SOURCES) $(Xati_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+@KDRIVEFBDEV_TRUE@FBDEV_INCLUDES = -I$(top_srcdir)/hw/kdrive/fbdev
+@KDRIVEFBDEV_TRUE@FBDEV_LIBS = $(top_builddir)/hw/kdrive/fbdev/libfbdev.a
+@KDRIVEVESA_TRUE@VESA_INCLUDES = -I$(top_srcdir)/hw/kdrive/vesa
+@KDRIVEVESA_TRUE@VESA_LIBS = $(top_builddir)/hw/kdrive/vesa/libvesa.a
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ $(DRI_INCLUDES) \
+ $(FBDEV_INCLUDES) \
+ $(VESA_INCLUDES) \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libati.a
+libati_a_SOURCES = \
+ ati_cursor.c \
+ ati_dma.c \
+ ati_dma.h \
+ ati_draw.c \
+ ati_draw.h \
+ ati_microcode.c \
+ ati.c \
+ ati.h \
+ ati_reg.h \
+ r128_composite.c \
+ ati_video.c \
+ radeon_composite.c \
+ $(DRI_SOURCES)
+
+Xati_SOURCES = \
+ ati_stub.c
+
+ATI_LIBS = \
+ libati.a \
+ $(FBDEV_LIBS) \
+ $(VESA_LIBS) \
+ $(DRI_LIBS) \
+ @KDRIVE_LIBS@
+
+@GLX_TRUE@Xati_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xati_LDADD = \
+ $(ATI_LIBS) \
+ @KDRIVE_LIBS@
+
+Xati_DEPENDENCIES = \
+ libati.a \
+ @KDRIVE_LOCAL_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/ati/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/ati/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libati.a: $(libati_a_OBJECTS) $(libati_a_DEPENDENCIES)
+ -rm -f libati.a
+ $(libati_a_AR) libati.a $(libati_a_OBJECTS) $(libati_a_LIBADD)
+ $(RANLIB) libati.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xati$(EXEEXT): $(Xati_OBJECTS) $(Xati_DEPENDENCIES)
+ @rm -f Xati$(EXEEXT)
+ $(Xati_LINK) $(Xati_OBJECTS) $(Xati_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ati.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ati_cursor.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ati_dma.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ati_draw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ati_microcode.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ati_stub.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ati_video.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/r128_composite.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/radeon_composite.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/ati/ati.c b/xorg-server/hw/kdrive/ati/ati.c
new file mode 100644
index 000000000..c4f67e171
--- /dev/null
+++ b/xorg-server/hw/kdrive/ati/ati.c
@@ -0,0 +1,761 @@
+/*
+ * Copyright © 2003 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "ati.h"
+#include "ati_reg.h"
+#if defined(USE_DRI) && defined(GLXEXT)
+#include "ati_sarea.h"
+#endif
+
+static Bool ATIIsAGP(ATICardInfo *atic);
+
+#define CAP_SERIESMASK 0xf
+#define CAP_R128 0x1 /* If it's a Rage 128 */
+#define CAP_R100 0x2 /* If it's an r100 series radeon. */
+#define CAP_R200 0x3 /* If it's an r200 series radeon. */
+#define CAP_R300 0x4 /* If it's an r300 series radeon. */
+
+#define CAP_FEATURESMASK 0xf0
+#define CAP_NOAGP 0x10 /* If it's a PCI-only card. */
+
+struct pci_id_entry ati_pci_ids[] = {
+ {0x1002, 0x4136, 0x2, "ATI Radeon RS100"},
+ {0x1002, 0x4137, 0x2, "ATI Radeon RS200"},
+ {0x1002, 0x4237, 0x2, "ATI Radeon RS250"},
+ {0x1002, 0x4144, 0x4, "ATI Radeon R300 AD"},
+ {0x1002, 0x4145, 0x4, "ATI Radeon R300 AE"},
+ {0x1002, 0x4146, 0x4, "ATI Radeon R300 AF"},
+ {0x1002, 0x4147, 0x4, "ATI Radeon R300 AG"},
+ {0x1002, 0x4148, 0x4, "ATI Radeon R350 AH"},
+ {0x1002, 0x4149, 0x4, "ATI Radeon R350 AI"},
+ {0x1002, 0x414a, 0x4, "ATI Radeon R350 AJ"},
+ {0x1002, 0x414b, 0x4, "ATI Radeon R350 AK"},
+ {0x1002, 0x4150, 0x4, "ATI Radeon RV350 AP"},
+ {0x1002, 0x4151, 0x4, "ATI Radeon RV350 AQ"},
+ {0x1002, 0x4152, 0x4, "ATI Radeon RV350 AR"},
+ {0x1002, 0x4153, 0x4, "ATI Radeon RV350 AS"},
+ {0x1002, 0x4154, 0x4, "ATI Radeon RV350 AT"},
+ {0x1002, 0x4156, 0x4, "ATI Radeon RV350 AV"},
+ {0x1002, 0x4242, 0x3, "ATI Radeon R200 BB"},
+ {0x1002, 0x4243, 0x3, "ATI Radeon R200 BC"},
+ {0x1002, 0x4336, 0x2, "ATI Radeon RS100"},
+ {0x1002, 0x4337, 0x2, "ATI Radeon RS200"},
+ {0x1002, 0x4437, 0x2, "ATI Radeon RS250"},
+ {0x1002, 0x4964, 0x2, "ATI Radeon RV250 Id"},
+ {0x1002, 0x4965, 0x2, "ATI Radeon RV250 Ie"},
+ {0x1002, 0x4966, 0x2, "ATI Radeon RV250 If"},
+ {0x1002, 0x4967, 0x2, "ATI Radeon R250 Ig"},
+ {0x1002, 0x4c45, 0x11, "ATI Rage 128 LE"},
+ {0x1002, 0x4c46, 0x1, "ATI Rage 128 LF"},
+ {0x1002, 0x4c57, 0x2, "ATI Radeon Mobiliy M7 RV200 LW (7500)"},
+ {0x1002, 0x4c58, 0x2, "ATI Radeon Mobiliy M7 RV200 LX (7500)"},
+ {0x1002, 0x4c59, 0x2, "ATI Radeon Mobility M6 LY"},
+ {0x1002, 0x4c5a, 0x2, "ATI Radeon Mobility M6 LZ"},
+ {0x1002, 0x4c64, 0x3, "ATI Radeon RV250 Ld"},
+ {0x1002, 0x4c65, 0x3, "ATI Radeon RV250 Le"},
+ {0x1002, 0x4c66, 0x3, "ATI Radeon Mobility M9 RV250 Lf"},
+ {0x1002, 0x4c67, 0x3, "ATI Radeon RV250 Lg"},
+ {0x1002, 0x4d46, 0x1, "ATI Rage 128 MF"},
+ {0x1002, 0x4d46, 0x1, "ATI Rage 128 ML"},
+ {0x1002, 0x4e44, 0x4, "ATI Radeon R300 ND"},
+ {0x1002, 0x4e45, 0x4, "ATI Radeon R300 NE"},
+ {0x1002, 0x4e46, 0x4, "ATI Radeon R300 NF"},
+ {0x1002, 0x4e47, 0x4, "ATI Radeon R300 NG"},
+ {0x1002, 0x4e48, 0x4, "ATI Radeon R350 NH"},
+ {0x1002, 0x4e49, 0x4, "ATI Radeon R350 NI"},
+ {0x1002, 0x4e4a, 0x4, "ATI Radeon R350 NJ"},
+ {0x1002, 0x4e4b, 0x4, "ATI Radeon R350 NK"},
+ {0x1002, 0x4e50, 0x4, "ATI Radeon Mobility RV350 NP"},
+ {0x1002, 0x4e51, 0x4, "ATI Radeon Mobility RV350 NQ"},
+ {0x1002, 0x4e52, 0x4, "ATI Radeon Mobility RV350 NR"},
+ {0x1002, 0x4e53, 0x4, "ATI Radeon Mobility RV350 NS"},
+ {0x1002, 0x4e54, 0x4, "ATI Radeon Mobility RV350 NT"},
+ {0x1002, 0x4e56, 0x4, "ATI Radeon Mobility RV350 NV"},
+ {0x1002, 0x5041, 0x1, "ATI Rage 128 PA"},
+ {0x1002, 0x5042, 0x1, "ATI Rage 128 PB"},
+ {0x1002, 0x5043, 0x1, "ATI Rage 128 PC"},
+ {0x1002, 0x5044, 0x11, "ATI Rage 128 PD"},
+ {0x1002, 0x5045, 0x1, "ATI Rage 128 PE"},
+ {0x1002, 0x5046, 0x1, "ATI Rage 128 PF"},
+ {0x1002, 0x5047, 0x1, "ATI Rage 128 PG"},
+ {0x1002, 0x5048, 0x1, "ATI Rage 128 PH"},
+ {0x1002, 0x5049, 0x1, "ATI Rage 128 PI"},
+ {0x1002, 0x504a, 0x1, "ATI Rage 128 PJ"},
+ {0x1002, 0x504b, 0x1, "ATI Rage 128 PK"},
+ {0x1002, 0x504c, 0x1, "ATI Rage 128 PL"},
+ {0x1002, 0x504d, 0x1, "ATI Rage 128 PM"},
+ {0x1002, 0x504e, 0x1, "ATI Rage 128 PN"},
+ {0x1002, 0x504f, 0x1, "ATI Rage 128 PO"},
+ {0x1002, 0x5050, 0x11, "ATI Rage 128 PP"},
+ {0x1002, 0x5051, 0x1, "ATI Rage 128 PQ"},
+ {0x1002, 0x5052, 0x11, "ATI Rage 128 PR"},
+ {0x1002, 0x5053, 0x1, "ATI Rage 128 PS"},
+ {0x1002, 0x5054, 0x1, "ATI Rage 128 PT"},
+ {0x1002, 0x5055, 0x1, "ATI Rage 128 PU"},
+ {0x1002, 0x5056, 0x1, "ATI Rage 128 PV"},
+ {0x1002, 0x5057, 0x1, "ATI Rage 128 PW"},
+ {0x1002, 0x5058, 0x1, "ATI Rage 128 PX"},
+ {0x1002, 0x5144, 0x2, "ATI Radeon R100 QD"},
+ {0x1002, 0x5145, 0x2, "ATI Radeon R100 QE"},
+ {0x1002, 0x5146, 0x2, "ATI Radeon R100 QF"},
+ {0x1002, 0x5147, 0x2, "ATI Radeon R100 QG"},
+ {0x1002, 0x5148, 0x3, "ATI Radeon R200 QH"},
+ {0x1002, 0x514c, 0x3, "ATI Radeon R200 QL"},
+ {0x1002, 0x514d, 0x3, "ATI Radeon R200 QM"},
+ {0x1002, 0x5157, 0x2, "ATI Radeon RV200 QW (7500)"},
+ {0x1002, 0x5158, 0x2, "ATI Radeon RV200 QX (7500)"},
+ {0x1002, 0x5159, 0x2, "ATI Radeon RV100 QY"},
+ {0x1002, 0x515a, 0x2, "ATI Radeon RV100 QZ"},
+ {0x1002, 0x5245, 0x11, "ATI Rage 128 RE"},
+ {0x1002, 0x5246, 0x1, "ATI Rage 128 RF"},
+ {0x1002, 0x5247, 0x1, "ATI Rage 128 RG"},
+ {0x1002, 0x524b, 0x11, "ATI Rage 128 RK"},
+ {0x1002, 0x524c, 0x1, "ATI Rage 128 RL"},
+ {0x1002, 0x5345, 0x1, "ATI Rage 128 SE"},
+ {0x1002, 0x5346, 0x1, "ATI Rage 128 SF"},
+ {0x1002, 0x5347, 0x1, "ATI Rage 128 SG"},
+ {0x1002, 0x5348, 0x1, "ATI Rage 128 SH"},
+ {0x1002, 0x534b, 0x1, "ATI Rage 128 SK"},
+ {0x1002, 0x534c, 0x1, "ATI Rage 128 SL"},
+ {0x1002, 0x534d, 0x1, "ATI Rage 128 SM"},
+ {0x1002, 0x534e, 0x1, "ATI Rage 128 SN"},
+ {0x1002, 0x5446, 0x1, "ATI Rage 128 TF"},
+ {0x1002, 0x544c, 0x1, "ATI Rage 128 TL"},
+ {0x1002, 0x5452, 0x1, "ATI Rage 128 TR"},
+ {0x1002, 0x5453, 0x1, "ATI Rage 128 TS"},
+ {0x1002, 0x5454, 0x1, "ATI Rage 128 TT"},
+ {0x1002, 0x5455, 0x1, "ATI Rage 128 TU"},
+ {0x1002, 0x5834, 0x3, "ATI Radeon RS300"},
+ {0x1002, 0x5835, 0x3, "ATI Radeon RS300 Mobility"},
+ {0x1002, 0x5941, 0x3, "ATI Radeon RV280 (9200)"},
+ {0x1002, 0x5961, 0x3, "ATI Radeon RV280 (9200 SE)"},
+ {0x1002, 0x5964, 0x3, "ATI Radeon RV280 (9200 SE)"},
+ {0x1002, 0x5c60, 0x3, "ATI Radeon RV280"},
+ {0x1002, 0x5c61, 0x3, "ATI Radeon RV280 Mobility"},
+ {0x1002, 0x5c62, 0x3, "ATI Radeon RV280"},
+ {0x1002, 0x5c63, 0x3, "ATI Radeon RV280 Mobility"},
+ {0x1002, 0x5c64, 0x3, "ATI Radeon RV280"},
+ {0, 0, 0, NULL}
+};
+
+static char *
+make_busid(KdCardAttr *attr)
+{
+ char *busid;
+
+ busid = xalloc(20);
+ if (busid == NULL)
+ return NULL;
+ snprintf(busid, 20, "pci:%04x:%02x:%02x.%d", attr->domain, attr->bus,
+ attr->slot, attr->func);
+ return busid;
+}
+
+static Bool
+ATICardInit(KdCardInfo *card)
+{
+ ATICardInfo *atic;
+ int i;
+ Bool initialized = FALSE;
+
+ atic = xcalloc(sizeof(ATICardInfo), 1);
+ if (atic == NULL)
+ return FALSE;
+
+#ifdef KDRIVEFBDEV
+ if (!initialized && fbdevInitialize(card, &atic->backend_priv.fbdev)) {
+ atic->use_fbdev = TRUE;
+ initialized = TRUE;
+ atic->backend_funcs.cardfini = fbdevCardFini;
+ atic->backend_funcs.scrfini = fbdevScreenFini;
+ atic->backend_funcs.initScreen = fbdevInitScreen;
+ atic->backend_funcs.finishInitScreen = fbdevFinishInitScreen;
+ atic->backend_funcs.createRes = fbdevCreateResources;
+ atic->backend_funcs.preserve = fbdevPreserve;
+ atic->backend_funcs.restore = fbdevRestore;
+ atic->backend_funcs.dpms = fbdevDPMS;
+ atic->backend_funcs.enable = fbdevEnable;
+ atic->backend_funcs.disable = fbdevDisable;
+ atic->backend_funcs.getColors = fbdevGetColors;
+ atic->backend_funcs.putColors = fbdevPutColors;
+#ifdef RANDR
+ atic->backend_funcs.randrSetConfig = fbdevRandRSetConfig;
+#endif
+ }
+#endif
+#ifdef KDRIVEVESA
+ if (!initialized && vesaInitialize(card, &atic->backend_priv.vesa)) {
+ atic->use_vesa = TRUE;
+ initialized = TRUE;
+ atic->backend_funcs.cardfini = vesaCardFini;
+ atic->backend_funcs.scrfini = vesaScreenFini;
+ atic->backend_funcs.initScreen = vesaInitScreen;
+ atic->backend_funcs.finishInitScreen = vesaFinishInitScreen;
+ atic->backend_funcs.createRes = vesaCreateResources;
+ atic->backend_funcs.preserve = vesaPreserve;
+ atic->backend_funcs.restore = vesaRestore;
+ atic->backend_funcs.dpms = vesaDPMS;
+ atic->backend_funcs.enable = vesaEnable;
+ atic->backend_funcs.disable = vesaDisable;
+ atic->backend_funcs.getColors = vesaGetColors;
+ atic->backend_funcs.putColors = vesaPutColors;
+#ifdef RANDR
+ atic->backend_funcs.randrSetConfig = vesaRandRSetConfig;
+#endif
+ }
+#endif
+
+ if (!initialized || !ATIMapReg(card, atic)) {
+ xfree(atic);
+ return FALSE;
+ }
+
+ atic->busid = make_busid(&card->attr);
+ if (atic->busid == NULL) {
+ xfree(atic);
+ return FALSE;
+ }
+
+#ifdef USE_DRI
+ /* We demand identification by busid, not driver name */
+ atic->drmFd = drmOpen(NULL, atic->busid);
+ if (atic->drmFd < 0)
+ ErrorF("Failed to open DRM, DRI disabled.\n");
+#endif /* USE_DRI */
+
+ card->driver = atic;
+
+ for (i = 0; ati_pci_ids[i].name != NULL; i++) {
+ if (ati_pci_ids[i].device == card->attr.deviceID) {
+ atic->pci_id = &ati_pci_ids[i];
+ break;
+ }
+ }
+
+ if ((atic->pci_id->caps & CAP_SERIESMASK) != CAP_R128)
+ atic->is_radeon = TRUE;
+ if ((atic->pci_id->caps & CAP_SERIESMASK) == CAP_R100)
+ atic->is_r100 = TRUE;
+ if ((atic->pci_id->caps & CAP_SERIESMASK) == CAP_R200)
+ atic->is_r200 = TRUE;
+ if ((atic->pci_id->caps & CAP_SERIESMASK) == CAP_R300)
+ atic->is_r300 = TRUE;
+
+ atic->is_agp = ATIIsAGP(atic);
+
+ ErrorF("Using ATI card: %s (%s) at %s\n", atic->pci_id->name,
+ atic->is_agp ? "AGP" : "PCI", atic->busid);
+
+ return TRUE;
+}
+
+static void
+ATICardFini(KdCardInfo *card)
+{
+ ATICardInfo *atic = (ATICardInfo *)card->driver;
+
+ ATIUnmapReg(card, atic);
+ atic->backend_funcs.cardfini(card);
+}
+
+/*
+ * Once screen->off_screen_base is set, this function
+ * allocates the remaining memory appropriately
+ */
+
+static void
+ATISetOffscreen (KdScreenInfo *screen)
+{
+ ATICardInfo(screen);
+#if defined(USE_DRI) && defined(GLXEXT)
+ ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver;
+ int l;
+#endif
+ int screen_size;
+ char *mmio = atic->reg_base;
+
+ /* check (and adjust) pitch */
+ if (mmio)
+ {
+ int byteStride = screen->fb[0].byteStride;
+ int bitStride;
+ int pixelStride;
+ int bpp = screen->fb[0].bitsPerPixel;
+
+ /*
+ * Ensure frame buffer is correctly aligned
+ */
+ if (byteStride & 0x3f)
+ {
+ byteStride = (byteStride + 0x3f) & ~0x3f;
+ bitStride = byteStride * 8;
+ pixelStride = bitStride / bpp;
+
+ screen->fb[0].byteStride = byteStride;
+ screen->fb[0].pixelStride = pixelStride;
+ }
+ }
+
+ screen_size = screen->fb[0].byteStride * screen->height;
+
+ screen->off_screen_base = screen_size;
+
+#if defined(USE_DRI) && defined(GLXEXT)
+ /* Reserve a static area for the back buffer the same size as the
+ * visible screen. XXX: This would be better initialized in ati_dri.c
+ * when GLX is set up, but the offscreen memory manager's allocations
+ * don't last through VT switches, while the kernel's understanding of
+ * offscreen locations does.
+ */
+ atis->frontOffset = 0;
+ atis->frontPitch = screen->fb[0].byteStride;
+
+ if (screen->off_screen_base + screen_size <= screen->memory_size) {
+ atis->backOffset = screen->off_screen_base;
+ atis->backPitch = screen->fb[0].byteStride;
+ screen->off_screen_base += screen_size;
+ }
+
+ /* Reserve the depth span for Rage 128 */
+ if (!atic->is_radeon && screen->off_screen_base +
+ screen->fb[0].byteStride <= screen->memory_size) {
+ atis->spanOffset = screen->off_screen_base;
+ screen->off_screen_base += screen->fb[0].byteStride;
+ }
+
+ /* Reserve the static depth buffer, which happens to be the same
+ * bitsPerPixel as the screen.
+ */
+ if (screen->off_screen_base + screen_size <= screen->memory_size) {
+ atis->depthOffset = screen->off_screen_base;
+ atis->depthPitch = screen->fb[0].byteStride;
+ screen->off_screen_base += screen_size;
+ }
+
+ /* Reserve approx. half of remaining offscreen memory for local
+ * textures. Round down to a whole number of texture regions.
+ */
+ atis->textureSize = (screen->memory_size - screen->off_screen_base) / 2;
+ l = ATILog2(atis->textureSize / ATI_NR_TEX_REGIONS);
+ if (l < ATI_LOG_TEX_GRANULARITY)
+ l = ATI_LOG_TEX_GRANULARITY;
+ atis->textureSize = (atis->textureSize >> l) << l;
+ if (atis->textureSize >= 512 * 1024) {
+ atis->textureOffset = screen->off_screen_base;
+ screen->off_screen_base += atis->textureSize;
+ } else {
+ /* Minimum texture size is for 2 256x256x32bpp textures */
+ atis->textureSize = 0;
+ }
+#endif /* USE_DRI && GLXEXT */
+}
+
+static void
+ATISetPitch (KdScreenInfo *screen)
+{
+ ATICardInfo(screen);
+#if defined(USE_DRI) && defined(GLXEXT)
+ ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver;
+ int l;
+#endif
+ char *mmio = atic->reg_base;
+
+ /* check (and adjust) pitch for radeon */
+ if (mmio)
+ {
+ int byteStride = screen->fb[0].byteStride;
+ int bitStride;
+ int pixelStride;
+ int bpp = screen->fb[0].bitsPerPixel;
+ CARD32 crtc_pitch;
+ CARD32 crtc2_pitch;
+#if 0
+ CARD32 crtc_ext_cntl;
+ CARD32 dac_cntl;
+#endif
+ bitStride = byteStride * 8;
+ pixelStride = bitStride / bpp;
+
+ crtc_pitch = (pixelStride >> 3);
+ crtc_pitch |= crtc_pitch << 16;
+ crtc2_pitch = (pixelStride >> 3);
+ crtc2_pitch |= crtc2_pitch << 16;
+#if 0
+ crtc_ext_cntl = MMIO_IN32 (mmio, ATI_REG_CRTC_EXT_CNTL);
+ dac_cntl = MMIO_IN32 (mmio, ATI_REG_DAC_CNTL);
+ /* Turn off the screen */
+ MMIO_OUT32 (mmio, ATI_REG_CRTC_EXT_CNTL,
+ crtc_ext_cntl |
+ ATI_CRTC_VSYNC_DIS |
+ ATI_CRTC_HSYNC_DIS |
+ ATI_CRTC_DISPLAY_DIS);
+ MMIO_OUT32 (mmio, ATI_REG_DAC_CNTL,
+ dac_cntl |
+ ATI_DAC_RANGE_CNTL |
+ ATI_DAC_BLANKING);
+#endif
+ MMIO_OUT32 (mmio, ATI_REG_CRTC_PITCH, crtc_pitch);
+ MMIO_OUT32 (mmio, ATI_REG_CRTC2_PITCH, crtc2_pitch);
+#if 0
+ /* Turn the screen back on */
+ MMIO_OUT32 (mmio, ATI_REG_CRTC_EXT_CNTL,
+ crtc_ext_cntl);
+ MMIO_OUT32 (mmio, ATI_REG_DAC_CNTL,
+ dac_cntl);
+#endif
+ }
+}
+
+static Bool
+ATIScreenInit(KdScreenInfo *screen)
+{
+ ATIScreenInfo *atis;
+ ATICardInfo(screen);
+ Bool success = FALSE;
+
+ atis = xcalloc(sizeof(ATIScreenInfo), 1);
+ if (atis == NULL)
+ return FALSE;
+
+ atis->atic = atic;
+ atis->screen = screen;
+ screen->driver = atis;
+
+ if (screen->fb[0].depth == 0)
+ screen->fb[0].depth = 16;
+#ifdef KDRIVEFBDEV
+ if (atic->use_fbdev) {
+ success = fbdevScreenInitialize(screen,
+ &atis->backend_priv.fbdev);
+ }
+#endif
+#ifdef KDRIVEVESA
+ if (atic->use_vesa) {
+ success = vesaScreenInitialize(screen,
+ &atis->backend_priv.vesa);
+ }
+#endif
+
+ if (!success) {
+ screen->driver = NULL;
+ xfree(atis);
+ return FALSE;
+ }
+
+ ATISetOffscreen (screen);
+
+ return TRUE;
+}
+
+#ifdef RANDR
+static Bool
+ATIRandRSetConfig (ScreenPtr pScreen,
+ Rotation randr,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ ATICardInfo *atic = screen->card->driver;
+ Bool ret;
+
+ ATIDrawDisable (pScreen);
+ ret = atic->backend_funcs.randrSetConfig(pScreen, randr, rate, pSize);
+ ATISetOffscreen (screen);
+ ATISetPitch (screen);
+ /*
+ * Set frame buffer mapping
+ */
+ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
+ pScreen->width,
+ pScreen->height,
+ screen->fb[0].depth,
+ screen->fb[0].bitsPerPixel,
+ screen->fb[0].byteStride,
+ screen->fb[0].frameBuffer);
+
+ ATIDrawEnable (pScreen);
+ return ret;
+}
+
+static Bool
+ATIRandRInit (ScreenPtr pScreen)
+{
+ rrScrPrivPtr pScrPriv;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+ pScrPriv->rrSetConfig = ATIRandRSetConfig;
+ return TRUE;
+}
+#endif
+
+static void
+ATIScreenFini(KdScreenInfo *screen)
+{
+ ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver;
+ ATICardInfo *atic = screen->card->driver;
+
+#ifdef XV
+ ATIFiniVideo(screen->pScreen);
+#endif
+
+ atic->backend_funcs.scrfini(screen);
+ xfree(atis);
+ screen->driver = 0;
+}
+
+Bool
+ATIMapReg(KdCardInfo *card, ATICardInfo *atic)
+{
+ atic->reg_base = (char *)KdMapDevice(ATI_REG_BASE(card),
+ ATI_REG_SIZE(card));
+
+ if (atic->reg_base == NULL)
+ return FALSE;
+
+ KdSetMappedMode(ATI_REG_BASE(card), ATI_REG_SIZE(card),
+ KD_MAPPED_MODE_REGISTERS);
+
+ return TRUE;
+}
+
+void
+ATIUnmapReg(KdCardInfo *card, ATICardInfo *atic)
+{
+ if (atic->reg_base) {
+ KdResetMappedMode(ATI_REG_BASE(card), ATI_REG_SIZE(card),
+ KD_MAPPED_MODE_REGISTERS);
+ KdUnmapDevice((void *)atic->reg_base, ATI_REG_SIZE(card));
+ atic->reg_base = 0;
+ }
+}
+
+static Bool
+ATIInitScreen(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+
+#ifdef XV
+ ATIInitVideo(pScreen);
+#endif
+ return atic->backend_funcs.initScreen(pScreen);
+}
+
+static Bool
+ATIFinishInitScreen(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+
+ if (!atic->backend_funcs.finishInitScreen(pScreen))
+ return FALSE;
+#ifdef RANDR
+ if (!ATIRandRInit (pScreen))
+ return FALSE;
+#endif
+ return TRUE;
+}
+
+static Bool
+ATICreateResources(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+
+ return atic->backend_funcs.createRes(pScreen);
+}
+
+static void
+ATIPreserve(KdCardInfo *card)
+{
+ ATICardInfo *atic = card->driver;
+ char *mmio = atic->reg_base;
+
+ atic->backend_funcs.preserve(card);
+ if (atic->is_radeon && mmio)
+ {
+ atic->crtc_pitch = MMIO_IN32(mmio, ATI_REG_CRTC_PITCH);
+ atic->crtc2_pitch = MMIO_IN32(mmio, ATI_REG_CRTC2_PITCH);
+
+ }
+}
+
+static void
+ATIRestore(KdCardInfo *card)
+{
+ ATICardInfo *atic = card->driver;
+ char *mmio = atic->reg_base;
+
+ if (mmio)
+ {
+ MMIO_OUT32(mmio, ATI_REG_CRTC_PITCH, atic->crtc_pitch);
+ MMIO_OUT32(mmio, ATI_REG_CRTC2_PITCH, atic->crtc2_pitch);
+ }
+ ATIUnmapReg(card, atic);
+
+ atic->backend_funcs.restore(card);
+}
+
+static Bool
+ATIDPMS(ScreenPtr pScreen, int mode)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+
+ return atic->backend_funcs.dpms(pScreen, mode);
+}
+
+static Bool
+ATIEnable(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+
+ if (!atic->backend_funcs.enable(pScreen))
+ return FALSE;
+
+ if ((atic->reg_base == NULL) && !ATIMapReg(pScreenPriv->screen->card,
+ atic))
+ return FALSE;
+
+ ATISetOffscreen (pScreenPriv->screen);
+
+ ATISetPitch (pScreenPriv->screen);
+
+ return TRUE;
+}
+
+static void
+ATIDisable(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+#if defined(USE_DRI) && defined(GLXEXT)
+ ATIScreenInfo(pScreenPriv);
+#endif /* USE_DRI && GLXEXT */
+ ATICardInfo(pScreenPriv);
+
+ ATIUnmapReg(pScreenPriv->card, atic);
+
+ atic->backend_funcs.disable(pScreen);
+}
+
+static void
+ATIGetColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+
+ atic->backend_funcs.getColors(pScreen, fb, n, pdefs);
+}
+
+static void
+ATIPutColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+
+ atic->backend_funcs.putColors(pScreen, fb, n, pdefs);
+}
+
+/* Compute log base 2 of val. */
+int
+ATILog2(int val)
+{
+ int bits;
+
+ for (bits = 0; val != 0; val >>= 1, ++bits)
+ ;
+ return bits - 1;
+}
+
+static Bool
+ATIIsAGP(ATICardInfo *atic)
+{
+ char *mmio = atic->reg_base;
+ CARD32 cap_ptr, cap_id;
+
+ if (mmio == NULL)
+ return FALSE;
+
+ if (MMIO_IN32(mmio, ATI_REG_PCI_CFG_STATUS) & ATI_CAP_LIST) {
+ cap_ptr = MMIO_IN32(mmio, ATI_REG_PCI_CFG_CAPABILITIES_PTR) &
+ ATI_CAP_PTR_MASK;
+ while (cap_ptr != ATI_CAP_ID_NULL) {
+ cap_id = MMIO_IN32(mmio, ATI_PCI_CFG_OFFSET + cap_ptr);
+ if ((cap_id & 0xff) == ATI_CAP_ID_AGP)
+ return TRUE;
+ cap_ptr = (cap_id >> 8) & ATI_CAP_PTR_MASK;
+ }
+ }
+
+ return FALSE;
+}
+
+/* This function is required to work around a hardware bug in some (all?)
+ * revisions of the R300. This workaround should be called after every
+ * CLOCK_CNTL_INDEX register access. If not, register reads afterward
+ * may not be correct.
+ */
+void R300CGWorkaround(ATIScreenInfo *atis) {
+ ATICardInfo *atic = atis->atic;
+ char *mmio = atic->reg_base;
+ CARD32 save;
+
+ save = MMIO_IN32(mmio, ATI_REG_CLOCK_CNTL_INDEX);
+ MMIO_OUT32(mmio, ATI_REG_CLOCK_CNTL_INDEX, save & ~(0x3f |
+ ATI_PLL_WR_EN));
+ MMIO_IN32(mmio, ATI_REG_CLOCK_CNTL_INDEX);
+ MMIO_OUT32(mmio, ATI_REG_CLOCK_CNTL_INDEX, save);
+}
+
+KdCardFuncs ATIFuncs = {
+ ATICardInit, /* cardinit */
+ ATIScreenInit, /* scrinit */
+ ATIInitScreen, /* initScreen */
+ ATIFinishInitScreen, /* finishInitScreen */
+ ATICreateResources, /* createRes */
+ ATIPreserve, /* preserve */
+ ATIEnable, /* enable */
+ ATIDPMS, /* dpms */
+ ATIDisable, /* disable */
+ ATIRestore, /* restore */
+ ATIScreenFini, /* scrfini */
+ ATICardFini, /* cardfini */
+
+ ATICursorInit, /* initCursor */
+ ATICursorEnable, /* enableCursor */
+ ATICursorDisable, /* disableCursor */
+ ATICursorFini, /* finiCursor */
+ ATIRecolorCursor, /* recolorCursor */
+
+ ATIDrawInit, /* initAccel */
+ ATIDrawEnable, /* enableAccel */
+ ATIDrawDisable, /* disableAccel */
+ ATIDrawFini, /* finiAccel */
+
+ ATIGetColors, /* getColors */
+ ATIPutColors, /* putColors */
+};
diff --git a/xorg-server/hw/kdrive/ati/ati.h b/xorg-server/hw/kdrive/ati/ati.h
new file mode 100644
index 000000000..3ff3e3ff3
--- /dev/null
+++ b/xorg-server/hw/kdrive/ati/ati.h
@@ -0,0 +1,409 @@
+/*
+ * Copyright © 2003 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _ATI_H_
+#define _ATI_H_
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+#ifdef KDRIVEFBDEV
+#include <fbdev.h>
+#endif
+#ifdef KDRIVEVESA
+#include <vesa.h>
+#endif
+
+#include "kxv.h"
+
+#undef XF86DRI
+#ifdef XF86DRI
+#define USE_DRI
+#include "xf86drm.h"
+#include "dri.h"
+#ifdef GLXEXT
+#include "GL/glxint.h"
+#include "GL/glxtokens.h"
+#include "ati_dripriv.h"
+#endif
+#endif
+
+#define ATI_REG_BASE(c) ((c)->attr.address[1])
+#define ATI_REG_SIZE(c) (0x4000)
+
+#ifdef __powerpc__
+
+static __inline__ void
+MMIO_OUT32(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ __asm__ __volatile__(
+ "stwbrx %1,%2,%3\n\t"
+ "eieio"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ CARD32
+MMIO_IN32(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned int val;
+ __asm__ __volatile__(
+ "lwbrx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+#else
+
+#define MMIO_OUT32(mmio, a, v) (*(VOL32 *)((mmio) + (a)) = (v))
+#define MMIO_IN32(mmio, a) (*(VOL32 *)((mmio) + (a)))
+
+#endif
+
+#define MMIO_OUT8(mmio, a, v) (*(VOL8 *)((mmio) + (a)) = (v))
+#define MMIO_IN8(mmio, a, v) (*(VOL8 *)((mmio) + (a)))
+
+#define INPLL(mmio, addr) \
+ (MMIO_OUT8(mmio, ATI_REG_CLOCK_CNTL_INDEX, addr), \
+ MMIO_IN32(mmio, ATI_REG_CLOCK_CNTL_DATA))
+
+#define OUTPLL(mmio, addr, val) do { \
+ MMIO_OUT8(mmio, ATI_REG_CLOCK_CNTL_INDEX, (addr) | ATI_PLL_WR_EN); \
+ MMIO_OUT32(mmio, ATI_REG_CLOCK_CNTL_DATA, val); \
+} while (0)
+
+typedef volatile CARD8 VOL8;
+typedef volatile CARD16 VOL16;
+typedef volatile CARD32 VOL32;
+
+struct pci_id_entry {
+ CARD16 vendor;
+ CARD16 device;
+ CARD8 caps;
+ char *name;
+};
+
+struct backend_funcs {
+ void (*cardfini)(KdCardInfo *);
+ void (*scrfini)(KdScreenInfo *);
+ Bool (*initScreen)(ScreenPtr);
+ Bool (*finishInitScreen)(ScreenPtr pScreen);
+ Bool (*createRes)(ScreenPtr);
+ void (*preserve)(KdCardInfo *);
+ void (*restore)(KdCardInfo *);
+ Bool (*dpms)(ScreenPtr, int);
+ Bool (*enable)(ScreenPtr);
+ void (*disable)(ScreenPtr);
+ void (*getColors)(ScreenPtr, int, int, xColorItem *);
+ void (*putColors)(ScreenPtr, int, int, xColorItem *);
+#ifdef RANDR
+ Bool (*randrSetConfig) (ScreenPtr, Rotation, int, RRScreenSizePtr);
+#endif
+};
+
+typedef struct _ATICardInfo {
+ union {
+#ifdef KDRIVEFBDEV
+ FbdevPriv fbdev;
+#endif
+#ifdef KDRIVEVESA
+ VesaCardPrivRec vesa;
+#endif
+ } backend_priv;
+ struct backend_funcs backend_funcs;
+
+ struct pci_id_entry *pci_id;
+ char *reg_base;
+ Bool is_radeon;
+ Bool is_r100;
+ Bool is_r200;
+ Bool is_r300;
+ Bool is_agp;
+ char *busid;
+ CARD32 crtc_pitch;
+ CARD32 crtc2_pitch;
+#ifdef USE_DRI
+ int drmFd;
+#endif /* USE_DRI */
+ Bool use_fbdev, use_vesa;
+} ATICardInfo;
+
+#define getATICardInfo(kd) ((ATICardInfo *) ((kd)->card->driver))
+#define ATICardInfo(kd) ATICardInfo *atic = getATICardInfo(kd)
+
+typedef struct _ATICursor {
+ int width, height;
+ int xhot, yhot;
+
+ Bool has_cursor;
+ CursorPtr pCursor;
+ Pixel source, mask;
+ KdOffscreenArea *area;
+} ATICursor;
+
+typedef struct _ATIPortPriv {
+ int brightness;
+ int saturation;
+ RegionRec clip;
+ CARD32 size;
+ KdOffscreenArea *off_screen;
+ DrawablePtr pDraw;
+ PixmapPtr pPixmap;
+
+ CARD32 src_offset;
+ CARD32 src_pitch;
+ CARD8 *src_addr;
+
+ int id;
+ int src_x1, src_y1, src_x2, src_y2;
+ int dst_x1, dst_y1, dst_x2, dst_y2;
+ int src_w, src_h, dst_w, dst_h;
+} ATIPortPrivRec, *ATIPortPrivPtr;
+
+typedef struct _dmaBuf {
+ int size;
+ int used;
+ void *address;
+#ifdef USE_DRI
+ drmBufPtr drmBuf;
+#endif
+} dmaBuf;
+
+typedef struct _ATIScreenInfo {
+ union {
+#ifdef KDRIVEFBDEV
+ FbdevScrPriv fbdev;
+#endif
+#ifdef KDRIVEVESA
+ VesaScreenPrivRec vesa;
+#endif
+ } backend_priv;
+ KaaScreenInfoRec kaa;
+
+ ATICardInfo *atic;
+ KdScreenInfo *screen;
+
+ int scratch_offset;
+ int scratch_next;
+ KdOffscreenArea *scratch_area;
+
+ ATICursor cursor;
+
+ KdVideoAdaptorPtr pAdaptor;
+ int num_texture_ports;
+
+ Bool using_pio; /* If we use decode DMA packets to MMIO. */
+ Bool using_pseudo; /* If we use MMIO to submit DMA packets. */
+ Bool using_dma; /* If we use non-DRI DMA to submit packets. */
+ Bool using_dri; /* If we use the DRM for DMA. */
+ Bool using_agp; /* If we are using AGP or not for DMA. */
+
+ KdOffscreenArea *dma_space; /* For "DMA" from framebuffer. */
+ void *agp_addr; /* Mapped AGP aperture */
+ int agp_size;
+ int agp_key; /* Key of AGP memory for DMA */
+ CARD32 *ring_addr; /* Beginning of ring buffer. */
+ int ring_write; /* Index of write ptr in ring. */
+ int ring_read; /* Index of read ptr in ring. */
+ int ring_len;
+
+
+ dmaBuf *indirectBuffer;
+ int indirectStart;
+
+ int mmio_avail;
+ int cce_pri_size;
+ int cce_pri_avail;
+
+#ifdef USE_DRI
+ Bool dma_started;
+
+ drmSize registerSize;
+ drmHandle registerHandle;
+ drmHandle fbHandle;
+
+ drmSize gartSize;
+ drmHandle agpMemHandle; /* Handle from drmAgpAlloc */
+ unsigned long gartOffset;
+ unsigned char *AGP; /* Map */
+ int agpMode;
+ drmSize pciSize;
+ drmHandle pciMemHandle;
+
+ /* ring buffer data */
+ unsigned long ringStart; /* Offset into AGP space */
+ drmHandle ringHandle; /* Handle from drmAddMap */
+ drmSize ringMapSize; /* Size of map */
+ int ringSize; /* Size of ring (MB) */
+ unsigned char *ring; /* Map */
+
+ unsigned long ringReadOffset; /* Offset into AGP space */
+ drmHandle ringReadPtrHandle; /* Handle from drmAddMap */
+ drmSize ringReadMapSize; /* Size of map */
+ unsigned char *ringReadPtr; /* Map */
+
+ /* vertex/indirect buffer data */
+ unsigned long bufStart; /* Offset into AGP space */
+ drmHandle bufHandle; /* Handle from drmAddMap */
+ drmSize bufMapSize; /* Size of map */
+ int bufSize; /* Size of buffers (MB) */
+ unsigned char *buf; /* Map */
+ int bufNumBufs; /* Number of buffers */
+ drmBufMapPtr buffers; /* Buffer map */
+
+ /* AGP Texture data */
+ unsigned long gartTexStart; /* Offset into AGP space */
+ drmHandle gartTexHandle; /* Handle from drmAddMap */
+ drmSize gartTexMapSize; /* Size of map */
+ int gartTexSize; /* Size of AGP tex space (MB) */
+ unsigned char *gartTex; /* Map */
+ int log2GARTTexGran;
+
+ int DMAusecTimeout; /* CCE timeout in usecs */
+
+ /* DRI screen private data */
+ int frontOffset;
+ int frontPitch;
+ int backOffset;
+ int backPitch;
+ int depthOffset;
+ int depthPitch;
+ int spanOffset;
+ int textureOffset;
+ int textureSize;
+ int log2TexGran;
+
+ int irqEnabled;
+
+ int serverContext;
+
+ DRIInfoPtr pDRIInfo;
+#ifdef GLXEXT
+ int numVisualConfigs;
+ __GLXvisualConfig *pVisualConfigs;
+ ATIConfigPrivPtr pVisualConfigsPriv;
+#endif /* GLXEXT */
+#endif /* USE_DRI */
+} ATIScreenInfo;
+
+#define getATIScreenInfo(kd) ((ATIScreenInfo *) ((kd)->screen->driver))
+#define ATIScreenInfo(kd) ATIScreenInfo *atis = getATIScreenInfo(kd)
+
+typedef union { float f; CARD32 i; } fi_type;
+
+/* Surely there's a better way to go about this */
+static inline CARD32
+ATIFloatAsInt(float val)
+{
+ fi_type fi;
+
+ fi.f = val;
+ return fi.i;
+}
+
+#define GET_FLOAT_BITS(x) ATIFloatAsInt(x)
+
+/* ati.c */
+Bool
+ATIMapReg(KdCardInfo *card, ATICardInfo *atic);
+
+void
+ATIUnmapReg(KdCardInfo *card, ATICardInfo *atic);
+
+void
+R300CGWorkaround(ATIScreenInfo *atis);
+
+/* ati_draw.c */
+void
+ATIDrawSetup(ScreenPtr pScreen);
+
+Bool
+ATIDrawInit(ScreenPtr pScreen);
+
+void
+ATIDrawEnable(ScreenPtr pScreen);
+
+void
+ATIDrawDisable(ScreenPtr pScreen);
+
+void
+ATIDrawFini(ScreenPtr pScreen);
+
+/* ati_dri.c */
+#ifdef USE_DRI
+Bool
+ATIDRIScreenInit(ScreenPtr pScreen);
+
+void
+ATIDRICloseScreen(ScreenPtr pScreen);
+
+void
+ATIDRIDMAStart(ATIScreenInfo *atis);
+
+void
+ATIDRIDMAStop(ATIScreenInfo *atis);
+
+void
+ATIDRIDMAReset(ATIScreenInfo *atis);
+
+void
+ATIDRIDispatchIndirect(ATIScreenInfo *atis, Bool discard);
+
+drmBufPtr
+ATIDRIGetBuffer(ATIScreenInfo *atis);
+
+#endif /* USE_DRI */
+
+/* ati_cursor.c */
+Bool
+ATICursorInit(ScreenPtr pScreen);
+
+void
+ATICursorEnable(ScreenPtr pScreen);
+
+void
+ATICursorDisable(ScreenPtr pScreen);
+
+void
+ATICursorFini(ScreenPtr pScreen);
+
+void
+ATIRecolorCursor(ScreenPtr pScreen, int ndef, xColorItem *pdef);
+
+int
+ATILog2(int val);
+
+/* ati_video.c */
+Bool
+ATIInitVideo(ScreenPtr pScreen);
+
+void
+ATIFiniVideo(ScreenPtr pScreen);
+
+extern KdCardFuncs ATIFuncs;
+
+#endif /* _ATI_H_ */
diff --git a/xorg-server/hw/kdrive/ati/ati_cursor.c b/xorg-server/hw/kdrive/ati/ati_cursor.c
new file mode 100644
index 000000000..d2ce686df
--- /dev/null
+++ b/xorg-server/hw/kdrive/ati/ati_cursor.c
@@ -0,0 +1,559 @@
+/*
+ * Copyright © 2004 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "ati.h"
+#include "ati_reg.h"
+#include "cursorstr.h"
+#include "ati_draw.h"
+
+static void
+ATIMoveCursor(ScreenPtr pScreen, int x, int y)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+ ATIScreenInfo(pScreenPriv);
+ ATICursor *pCurPriv = &atis->cursor;
+ CARD16 xoff, yoff;
+ char *mmio = atic->reg_base;
+ int stride = atic->is_radeon ? 256 : 16;
+
+ if (!pCurPriv->has_cursor)
+ return;
+
+ if (!pScreenPriv->enabled)
+ return;
+
+ x -= pCurPriv->xhot;
+ xoff = 0;
+ if (x < 0) {
+ xoff = -x;
+ x = 0;
+ }
+ y -= pCurPriv->yhot;
+ yoff = 0;
+ if (y < 0) {
+ yoff = -y;
+ y = 0;
+ }
+
+ MMIO_OUT32(mmio, ATI_REG_CUR_HORZ_VERT_OFF, ATI_CUR_LOCK |
+ (xoff << 16) | yoff);
+ MMIO_OUT32(mmio, ATI_REG_CUR_HORZ_VERT_POSN, ATI_CUR_LOCK |
+ (x << 16) | y);
+ MMIO_OUT32(mmio, ATI_REG_CUR_OFFSET, (pCurPriv->area->offset + yoff *
+ stride));
+}
+
+static void
+ClassicAllocCursorColors(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICursor *pCurPriv = &atis->cursor;
+ CursorPtr pCursor = pCurPriv->pCursor;
+
+ KdAllocateCursorPixels(pScreen, 0, pCursor, &pCurPriv->source,
+ &pCurPriv->mask);
+ switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
+ case 4:
+ pCurPriv->source |= pCurPriv->source << 4;
+ pCurPriv->mask |= pCurPriv->mask << 4;
+ /* FALLTHROUGH */
+ case 8:
+ pCurPriv->source |= pCurPriv->source << 8;
+ pCurPriv->mask |= pCurPriv->mask << 8;
+ /* FALLTHROUGH */
+ case 16:
+ pCurPriv->source |= pCurPriv->source << 16;
+ pCurPriv->mask |= pCurPriv->mask << 16;
+ }
+}
+
+static void
+ClassicSetCursorColors(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+ ATIScreenInfo(pScreenPriv);
+ ATICursor *pCurPriv = &atis->cursor;
+ char *mmio = atic->reg_base;
+
+ MMIO_OUT32(mmio, ATI_REG_CUR_CLR0, pCurPriv->mask);
+ MMIO_OUT32(mmio, ATI_REG_CUR_CLR1, pCurPriv->source);
+}
+
+static void
+ClassicRecolorCursor(ScreenPtr pScreen, int ndef, xColorItem *pdef)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICursor *pCurPriv = &atis->cursor;
+ CursorPtr pCursor = pCurPriv->pCursor;
+
+ if (!pCurPriv->has_cursor || !pCursor)
+ return;
+
+ if (!pScreenPriv->enabled)
+ return;
+
+ if (pdef) {
+ while (ndef != 0) {
+ if (pdef->pixel == pCurPriv->source ||
+ pdef->pixel == pCurPriv->mask)
+ break;
+ ndef--;
+ }
+
+ if (ndef == 0)
+ return;
+ }
+ ClassicAllocCursorColors(pScreen);
+ ClassicSetCursorColors(pScreen);
+}
+
+#define InvertBits32(v) do { \
+ v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
+ v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
+ v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
+} while (0)
+
+static void
+ClassicLoadCursor(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+ ATIScreenInfo(pScreenPriv);
+ ATICursor *pCurPriv = &atis->cursor;
+ CursorPtr pCursor = pCurPriv->pCursor;
+ CursorBitsPtr bits = pCursor->bits;
+ int h;
+ CARD32 *ram, *msk, *mskLine, *src, *srcLine;
+ int i;
+ int lwsrc;
+ CARD32 tmp;
+ char *mmio = atic->reg_base;
+
+ ClassicAllocCursorColors(pScreen);
+
+ pCurPriv->pCursor = pCursor;
+ pCurPriv->xhot = pCursor->bits->xhot;
+ pCurPriv->yhot = pCursor->bits->yhot;
+
+ /* Stick new image into cursor memory */
+ ram = (CARD32 *)(pScreenPriv->screen->memory_base +
+ pCurPriv->area->offset);
+ mskLine = (CARD32 *)bits->mask;
+ srcLine = (CARD32 *)bits->source;
+
+ h = bits->height;
+ if (h > ATI_CURSOR_HEIGHT)
+ h = ATI_CURSOR_HEIGHT;
+
+ lwsrc = BitmapBytePad(bits->width) / 4; /* words per line */
+
+ tmp = MMIO_IN32(mmio, ATI_REG_GEN_CNTL);
+ MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp & ~ATI_CRTC_CUR_EN);
+
+ for (i = 0; i < ATI_CURSOR_HEIGHT; i++) {
+ CARD32 m1, m2, s1, s2;
+
+ msk = mskLine;
+ src = srcLine;
+ mskLine += lwsrc;
+ srcLine += lwsrc;
+
+ if (i < h && 0 < lwsrc) {
+ m1 = ~*msk++;
+ s1 = *src++;
+ InvertBits32(m1);
+ InvertBits32(s1);
+ } else {
+ m1 = 0xffffffff;
+ s1 = 0x0;
+ }
+ if (i < h && 1 < lwsrc) {
+ m2 = ~*msk++;
+ s2 = *src++;
+ InvertBits32(m2);
+ InvertBits32(s2);
+ } else {
+ m2 = 0xffffffff;
+ s2 = 0x0;
+ }
+
+ *ram++ = m1;
+ *ram++ = m2;
+ *ram++ = s1;
+ *ram++ = s2;
+ }
+
+ /* Not sure why this is necessary, but it prevents some cursor
+ * corruption. Not even all of it.
+ */
+ for (i = 0; i < ATI_CURSOR_HEIGHT; i++) {
+ *ram++ = 0xffffffff;
+ *ram++ = 0xffffffff;
+ *ram++ = 0x0;
+ *ram++ = 0x0;
+ }
+
+ /* Enable the cursor */
+ tmp = MMIO_IN32(mmio, ATI_REG_GEN_CNTL);
+ MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp | ATI_CRTC_CUR_EN);
+
+ /* Set new color */
+ ClassicSetCursorColors(pScreen);
+
+}
+
+static void
+RadeonLoadCursor(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+ ATIScreenInfo(pScreenPriv);
+ ATICursor *pCurPriv = &atis->cursor;
+ CursorPtr pCursor = pCurPriv->pCursor;
+ CursorBitsPtr bits = pCursor->bits;
+ int h, w;
+ int x, y;
+ CARD32 *ram, *msk, *mskLine, *src, *srcLine;
+ int lwsrc;
+ CARD32 tmp;
+ char *mmio = atic->reg_base;
+
+ pCurPriv->pCursor = pCursor;
+ pCurPriv->xhot = pCursor->bits->xhot;
+ pCurPriv->yhot = pCursor->bits->yhot;
+
+ w = bits->width;
+ if (w > ATI_CURSOR_WIDTH)
+ w = ATI_CURSOR_WIDTH;
+
+ h = bits->height;
+ if (h > ATI_CURSOR_HEIGHT)
+ h = ATI_CURSOR_HEIGHT;
+
+ tmp = MMIO_IN32(mmio, 0x7c);
+ tmp = 0x00010f80;
+ MMIO_OUT32 (mmio, 0x7c, tmp);
+
+ tmp = MMIO_IN32(mmio, ATI_REG_GEN_CNTL);
+ tmp &= ~(ATI_CRTC_CUR_EN | ATI_CRTC_ICON_EN | ATI_CRTC_ARGB_EN);
+ MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp);
+
+ /* Stick new image into cursor memory */
+ ram = (CARD32 *)(pScreenPriv->screen->memory_base +
+ pCurPriv->area->offset);
+ if (pCursor->bits->argb)
+ {
+ srcLine = pCursor->bits->argb;
+ for (y = 0; y < h; y++)
+ {
+ src = srcLine;
+ srcLine += pCursor->bits->width;
+ for (x = 0; x < w; x++)
+ *ram++ = *src++;
+ for (; x < ATI_CURSOR_WIDTH; x++)
+ *ram++ = 0;
+ }
+ for (; y < ATI_CURSOR_HEIGHT; y++)
+ for (x = 0; x < ATI_CURSOR_WIDTH; x++)
+ *ram++ = 0;
+ }
+ else
+ {
+ CARD32 colors[4];
+
+ colors[0] = 0;
+ colors[1] = 0;
+ colors[2] = (((pCursor->backRed >> 8) << 16) |
+ ((pCursor->backGreen >> 8) << 8) |
+ ((pCursor->backBlue >> 8) << 0) |
+ 0xff000000);
+ colors[3] = (((pCursor->foreRed >> 8) << 16) |
+ ((pCursor->foreGreen >> 8) << 8) |
+ ((pCursor->foreBlue >> 8) << 0) |
+ 0xff000000);
+
+ mskLine = (CARD32 *)bits->mask;
+ srcLine = (CARD32 *)bits->source;
+
+ /* words per line */
+ lwsrc = BitmapBytePad(bits->width) / 4;
+
+ for (y = 0; y < ATI_CURSOR_HEIGHT; y++)
+ {
+ CARD32 m, s;
+
+ msk = mskLine;
+ src = srcLine;
+ mskLine += lwsrc;
+ srcLine += lwsrc;
+
+ for (x = 0; x < ATI_CURSOR_WIDTH / 32; x++)
+ {
+ int k;
+ if (y < h && x < lwsrc)
+ {
+ m = *msk++;
+ s = *src++;
+ }
+ else
+ {
+ m = 0x0;
+ s = 0x0;
+ }
+
+ for (k = 0; k < 32; k++)
+ {
+ CARD32 bits = (s & 1) | ((m & 1) << 1);
+ *ram++ = colors[bits];
+ s >>= 1;
+ m >>= 1;
+ }
+ }
+ }
+ }
+
+ /* Enable the cursor */
+ tmp &= ~(ATI_CRTC_ICON_EN);
+ tmp |= ATI_CRTC_ARGB_EN;
+ tmp |= ATI_CRTC_CUR_EN;
+ MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp);
+}
+
+static void
+ATIUnloadCursor(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+ char *mmio = atic->reg_base;
+ CARD32 tmp;
+
+ tmp = MMIO_IN32(mmio, ATI_REG_GEN_CNTL);
+ tmp &= ~(ATI_CRTC_CUR_EN | ATI_CRTC_ICON_EN | ATI_CRTC_ARGB_EN);
+ MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp);
+}
+
+static Bool
+ATIRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+ ATIScreenInfo(pScreenPriv);
+ ATICursor *pCurPriv = &atis->cursor;
+
+ if (!pScreenPriv->enabled)
+ return TRUE;
+
+ /* miRecolorCursor does this */
+ if (pCursor && pCurPriv->pCursor == pCursor)
+ {
+ int x, y;
+
+ miPointerPosition(&x, &y);
+ if (atic->is_radeon)
+ RadeonLoadCursor (pScreen);
+ else
+ ClassicLoadCursor(pScreen);
+ /* Move to new position */
+ ATIMoveCursor(pScreen, x, y);
+ }
+
+ return TRUE;
+}
+
+static Bool
+ATIUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+ return TRUE;
+}
+
+static void
+ATISetCursor(ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+ ATIScreenInfo(pScreenPriv);
+ ATICursor *pCurPriv = &atis->cursor;
+
+ pCurPriv->pCursor = pCursor;
+
+ if (!pScreenPriv->enabled)
+ return;
+
+ if (pCursor)
+ {
+ if (atic->is_radeon)
+ RadeonLoadCursor (pScreen);
+ else
+ ClassicLoadCursor(pScreen);
+ /* Move to new position */
+ ATIMoveCursor(pScreen, x, y);
+ }
+ else
+ ATIUnloadCursor(pScreen);
+}
+
+miPointerSpriteFuncRec ATIPointerSpriteFuncs = {
+ ATIRealizeCursor,
+ ATIUnrealizeCursor,
+ ATISetCursor,
+ ATIMoveCursor,
+};
+
+static void
+ATIQueryBestSize(int class, unsigned short *pwidth, unsigned short *pheight,
+ ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICursor *pCurPriv = &atis->cursor;
+
+ switch (class)
+ {
+ case CursorShape:
+ if (*pwidth > pCurPriv->width)
+ *pwidth = pCurPriv->width;
+ if (*pheight > pCurPriv->height)
+ *pheight = pCurPriv->height;
+ if (*pwidth > pScreen->width)
+ *pwidth = pScreen->width;
+ if (*pheight > pScreen->height)
+ *pheight = pScreen->height;
+ break;
+ default:
+ fbQueryBestSize(class, pwidth, pheight, pScreen);
+ break;
+ }
+}
+
+static void
+ATICursorSave(ScreenPtr pScreen, KdOffscreenArea *area)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICursor *pCurPriv = &atis->cursor;
+
+ pCurPriv->area = NULL;
+}
+
+void
+ATICursorEnable(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+ ATIScreenInfo(pScreenPriv);
+ ATICursor *pCurPriv = &atis->cursor;
+
+ if (!pCurPriv->has_cursor)
+ return;
+
+ if (pCurPriv->area == NULL) {
+ if (atic->is_radeon)
+ pCurPriv->area = KdOffscreenAlloc(pScreen,
+ ATI_CURSOR_HEIGHT * ATI_CURSOR_WIDTH * 4,
+ 128, TRUE, ATICursorSave, atis);
+ else
+ pCurPriv->area = KdOffscreenAlloc(pScreen,
+ ATI_CURSOR_HEIGHT * ATI_CURSOR_PITCH * 2,
+ 32, TRUE, ATICursorSave, atis);
+ }
+ if (pCurPriv->area == NULL)
+ FatalError("Couldn't allocate offscreen memory for cursor.\n");
+
+ if (pCurPriv->pCursor) {
+ int x, y;
+
+ miPointerPosition(&x, &y);
+ if (atic->is_radeon)
+ RadeonLoadCursor(pScreen);
+ else
+ ClassicLoadCursor(pScreen);
+ /* Move to new position */
+ ATIMoveCursor(pScreen, x, y);
+ }
+ else
+ ATIUnloadCursor(pScreen);
+}
+
+void
+ATICursorDisable(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICursor *pCurPriv = &atis->cursor;
+
+ if (!pScreenPriv->enabled || !pCurPriv->has_cursor)
+ return;
+
+ if (pCurPriv->pCursor)
+ ATIUnloadCursor(pScreen);
+}
+
+Bool
+ATICursorInit(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+ ATIScreenInfo(pScreenPriv);
+ ATICursor *pCurPriv = &atis->cursor;
+
+ pCurPriv->has_cursor = FALSE;
+
+ if (atic->reg_base == NULL)
+ return FALSE;
+
+ pCurPriv->width = ATI_CURSOR_WIDTH;
+ pCurPriv->height= ATI_CURSOR_HEIGHT;
+ pScreen->QueryBestSize = ATIQueryBestSize;
+ miPointerInitialize(pScreen, &ATIPointerSpriteFuncs,
+ &kdPointerScreenFuncs, FALSE);
+ pCurPriv->has_cursor = TRUE;
+ pCurPriv->pCursor = NULL;
+ return TRUE;
+}
+
+void
+ATIRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+
+ if (!atic->is_radeon)
+ ClassicRecolorCursor (pScreen, ndef, pdef);
+}
+
+void
+ATICursorFini(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICursor *pCurPriv = &atis->cursor;
+
+ pCurPriv->has_cursor = FALSE;
+ pCurPriv->pCursor = NULL;
+}
diff --git a/xorg-server/hw/kdrive/ati/ati_dma.c b/xorg-server/hw/kdrive/ati/ati_dma.c
new file mode 100644
index 000000000..b97d79b25
--- /dev/null
+++ b/xorg-server/hw/kdrive/ati/ati_dma.c
@@ -0,0 +1,1037 @@
+/*
+ * Copyright © 2004 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/time.h>
+
+#include "ati.h"
+#include "ati_reg.h"
+#include "ati_dma.h"
+#include "ati_draw.h"
+
+#ifdef USE_DRI
+#include "radeon_common.h"
+#include "r128_common.h"
+#include "ati_sarea.h"
+#endif /* USE_DRI */
+
+#include "agp.h"
+
+#define DEBUG_FIFO 0
+
+extern CARD32 r128_cce_microcode[];
+extern CARD32 radeon_cp_microcode[][2];
+extern CARD32 r200_cp_microcode[][2];
+extern CARD32 r300_cp_microcode[][2];
+
+#if DEBUG_FIFO
+static void
+ATIDebugFifo(ATIScreenInfo *atis)
+{
+ ATICardInfo *atic = atis->atic;
+ char *mmio = atic->reg_base;
+
+ if (atic->is_radeon) {
+ ErrorF("RADEON_REG_CP_CSQ_CNTL: 0x%08x\n",
+ MMIO_IN32(mmio, RADEON_REG_CP_CSQ_CNTL));
+ ErrorF("RADEON_REG_CP_CSQ_STAT: 0x%08x\n",
+ MMIO_IN32(mmio, RADEON_REG_CP_CSQ_STAT));
+ ErrorF("RADEON_REG_RBBM_STATUS: 0x%08x\n",
+ MMIO_IN32(mmio, RADEON_REG_RBBM_STATUS));
+ ErrorF("RADEON_REG_RB3D_DSTCACHE_CTLSTAT: 0x%08x\n",
+ MMIO_IN32(mmio, RADEON_REG_RB3D_DSTCACHE_CTLSTAT));
+ } else {
+ ErrorF("R128_REG_PM4_BUFFER_CNTL: 0x%08x\n",
+ MMIO_IN32(mmio, R128_REG_PM4_BUFFER_CNTL));
+ ErrorF("R128_REG_PM4_STAT: 0x%08x\n",
+ MMIO_IN32(mmio, R128_REG_PM4_STAT));
+ ErrorF("R128_REG_GUI_STAT: 0x%08x\n",
+ MMIO_IN32(mmio, R128_REG_GUI_STAT));
+ ErrorF("R128_REG_PC_NGUI_CTLSTAT: 0x%08x\n",
+ MMIO_IN32(mmio, R128_REG_PC_NGUI_CTLSTAT));
+ }
+}
+#endif
+
+static void
+ATIUploadMicrocode(ATIScreenInfo *atis)
+{
+ ATICardInfo *atic = atis->atic;
+ char *mmio = atic->reg_base;
+ int i;
+
+ MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_ADDR, 0);
+ if (atic->is_radeon && atic->is_r300) {
+ for (i = 0; i < 256; i++) {
+ MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAH,
+ r300_cp_microcode[i][1]);
+ MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAL,
+ r300_cp_microcode[i][0]);
+ }
+ } else if (atic->is_radeon && atic->is_r200) {
+ for (i = 0; i < 256; i++) {
+ MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAH,
+ r200_cp_microcode[i][1]);
+ MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAL,
+ r200_cp_microcode[i][0]);
+ }
+ } else if (atic->is_radeon && atic->is_r100) {
+ for (i = 0; i < 256; i++) {
+ MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAH,
+ radeon_cp_microcode[i][1]);
+ MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAL,
+ radeon_cp_microcode[i][0]);
+ }
+ } else {
+ for (i = 0; i < 256; i++) {
+ MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAH,
+ r128_cce_microcode[i * 2]);
+ MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAL,
+ r128_cce_microcode[i * 2 + 1]);
+ }
+ }
+}
+
+/* Required when reading from video memory after acceleration to make sure all
+ * data has been flushed to video memory from the pixel cache.
+ */
+static void
+ATIFlushPixelCache(ATIScreenInfo *atis)
+{
+ ATICardInfo *atic = atis->atic;
+ char *mmio = atic->reg_base;
+ CARD32 temp;
+ TIMEOUT_LOCALS;
+
+ if (atic->is_radeon) {
+ temp = MMIO_IN32(mmio, RADEON_REG_RB3D_DSTCACHE_CTLSTAT);
+ temp |= RADEON_RB3D_DC_FLUSH_ALL;
+ MMIO_OUT32(mmio, RADEON_REG_RB3D_DSTCACHE_CTLSTAT, temp);
+
+ WHILE_NOT_TIMEOUT(.2) {
+ if ((MMIO_IN32(mmio, RADEON_REG_RB3D_DSTCACHE_CTLSTAT) &
+ RADEON_RB3D_DC_BUSY) == 0)
+ break;
+ }
+ } else {
+ temp = MMIO_IN32(mmio, R128_REG_PC_NGUI_CTLSTAT);
+ temp |= R128_PC_FLUSH_ALL;
+ MMIO_OUT32(mmio, R128_REG_PC_NGUI_CTLSTAT, temp);
+
+ WHILE_NOT_TIMEOUT(.2) {
+ if ((MMIO_IN32(mmio, R128_REG_PC_NGUI_CTLSTAT) &
+ R128_PC_BUSY) != R128_PC_BUSY)
+ break;
+ }
+ }
+ if (TIMEDOUT())
+ ErrorF("Timeout flushing pixel cache.\n");
+}
+
+static void
+ATIEngineReset(ATIScreenInfo *atis)
+{
+ ATICardInfo *atic = atis->atic;
+ char *mmio = atic->reg_base;
+ CARD32 clockcntlindex, mclkcntl;
+
+#if DEBUG_FIFO
+ ErrorF("Engine Reset!\n");
+ ATIDebugFifo(atis);
+#endif
+
+ ATIFlushPixelCache(atis);
+
+ clockcntlindex = MMIO_IN32(mmio, ATI_REG_CLOCK_CNTL_INDEX);
+ if (atic->is_r300)
+ R300CGWorkaround(atis);
+
+ if (atic->is_radeon) {
+ CARD32 host_path_cntl;
+
+ mclkcntl = INPLL(mmio, RADEON_REG_MCLK_CNTL);
+
+ OUTPLL(mmio, RADEON_REG_MCLK_CNTL, mclkcntl |
+ RADEON_FORCEON_MCLKA |
+ RADEON_FORCEON_MCLKB |
+ RADEON_FORCEON_YCLKA |
+ RADEON_FORCEON_YCLKB |
+ RADEON_FORCEON_MC |
+ RADEON_FORCEON_AIC);
+
+ host_path_cntl = MMIO_IN32(mmio, RADEON_REG_HOST_PATH_CNTL);
+
+ if (atic->is_r300) {
+ MMIO_OUT32(mmio, RADEON_REG_RBBM_SOFT_RESET,
+ RADEON_SOFT_RESET_CP |
+ RADEON_SOFT_RESET_HI |
+ RADEON_SOFT_RESET_E2);
+ } else {
+ MMIO_OUT32(mmio, RADEON_REG_RBBM_SOFT_RESET,
+ RADEON_SOFT_RESET_CP |
+ RADEON_SOFT_RESET_SE |
+ RADEON_SOFT_RESET_RE |
+ RADEON_SOFT_RESET_PP |
+ RADEON_SOFT_RESET_E2 |
+ RADEON_SOFT_RESET_RB);
+ }
+ MMIO_IN32(mmio, RADEON_REG_RBBM_SOFT_RESET);
+ MMIO_OUT32(mmio, RADEON_REG_RBBM_SOFT_RESET, 0);
+
+ MMIO_OUT32(mmio, RADEON_REG_HOST_PATH_CNTL, host_path_cntl |
+ RADEON_HDP_SOFT_RESET);
+ MMIO_IN32(mmio, RADEON_REG_HOST_PATH_CNTL);
+ MMIO_OUT32(mmio, RADEON_REG_HOST_PATH_CNTL, host_path_cntl);
+
+ MMIO_OUT32(mmio, ATI_REG_CLOCK_CNTL_INDEX, clockcntlindex);
+ OUTPLL(mmio, RADEON_REG_MCLK_CNTL, mclkcntl);
+ if (atic->is_r300)
+ R300CGWorkaround(atis);
+ } else {
+ CARD32 temp;
+
+ mclkcntl = INPLL(mmio, R128_REG_MCLK_CNTL);
+
+ OUTPLL(mmio, R128_REG_MCLK_CNTL,
+ mclkcntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CP);
+
+ temp = MMIO_IN32(mmio, R128_REG_GEN_RESET_CNTL);
+ MMIO_OUT32(mmio, R128_REG_GEN_RESET_CNTL,
+ temp | R128_SOFT_RESET_GUI);
+ temp = MMIO_IN32(mmio, R128_REG_GEN_RESET_CNTL);
+ MMIO_OUT32(mmio, R128_REG_GEN_RESET_CNTL,
+ temp & ~R128_SOFT_RESET_GUI);
+ temp = MMIO_IN32(mmio, R128_REG_GEN_RESET_CNTL);
+
+ OUTPLL(mmio, R128_REG_MCLK_CNTL, mclkcntl);
+ MMIO_OUT32(mmio, ATI_REG_CLOCK_CNTL_INDEX, clockcntlindex);
+ }
+#ifdef USE_DRI
+ if (atis->using_dri) {
+ ATIDRIDMAReset(atis);
+ ATIDRIDMAStart(atis);
+ }
+#endif
+}
+
+static void
+ATIWaitAvailMMIO(ATIScreenInfo *atis, int n)
+{
+ ATICardInfo *atic = atis->atic;
+ char *mmio = atic->reg_base;
+ TIMEOUT_LOCALS;
+
+ if (atis->mmio_avail >= n) {
+ atis->mmio_avail -= n;
+ return;
+ }
+ if (atic->is_radeon) {
+ WHILE_NOT_TIMEOUT(.2) {
+ atis->mmio_avail = MMIO_IN32(mmio,
+ RADEON_REG_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK;
+ if (atis->mmio_avail >= n)
+ break;
+ }
+ } else {
+ WHILE_NOT_TIMEOUT(.2) {
+ atis->mmio_avail = MMIO_IN32(mmio, R128_REG_GUI_STAT) &
+ 0xfff;
+ if (atis->mmio_avail >= n)
+ break;
+ }
+ }
+ if (TIMEDOUT()) {
+ ErrorF("Timeout waiting for %d MMIO slots.\n", n);
+ ATIEngineReset(atis);
+ ATIDrawSetup(atis->screen->pScreen);
+ }
+ atis->mmio_avail -= n;
+}
+
+static int
+ATIGetAvailPrimary(ATIScreenInfo *atis)
+{
+ ATICardInfo *atic = atis->atic;
+ char *mmio = atic->reg_base;
+
+ if (atic->is_radeon) {
+ int csq_stat, diff;
+
+ csq_stat = MMIO_IN32(mmio, RADEON_REG_CP_CSQ_STAT);
+ if (atic->is_r200)
+ diff = ((csq_stat & R200_CSQ_WPTR_PRIMARY_MASK) >> 9) -
+ (csq_stat & R200_CSQ_RPTR_PRIMARY_MASK);
+ else
+ diff = ((csq_stat & RADEON_CSQ_WPTR_PRIMARY_MASK) >> 8) -
+ (csq_stat & RADEON_CSQ_RPTR_PRIMARY_MASK);
+
+ if (diff < 0)
+ return -diff;
+ else
+ return atis->cce_pri_size - diff;
+ } else {
+ return MMIO_IN32(mmio, R128_REG_PM4_STAT) &
+ R128_PM4_FIFOCNT_MASK;
+ }
+}
+
+static void
+ATIWaitAvailPrimary(ATIScreenInfo *atis, int n)
+{
+ TIMEOUT_LOCALS;
+
+ if (atis->cce_pri_avail >= n) {
+ atis->cce_pri_avail -= n;
+ return;
+ }
+
+ WHILE_NOT_TIMEOUT(.2) {
+ if (atis->cce_pri_avail >= n)
+ break;
+ atis->cce_pri_avail = ATIGetAvailPrimary(atis);
+ if (atis->cce_pri_avail >= n)
+ break;
+ }
+ if (TIMEDOUT()) {
+ ErrorF("Timeout waiting for %d CCE slots (%d avail).\n", n,
+ atis->cce_pri_avail);
+ ATIEngineReset(atis);
+ ATIDrawSetup(atis->screen->pScreen);
+ }
+ atis->cce_pri_avail -= n;
+}
+
+void
+ATIWaitIdle(ATIScreenInfo *atis)
+{
+ ATICardInfo *atic = atis->atic;
+ char *mmio = atic->reg_base;
+ TIMEOUT_LOCALS;
+
+ if (atis->indirectBuffer != NULL)
+ ATIFlushIndirect(atis, 0);
+
+#ifdef USE_DRI
+ if (atis->using_dri) {
+ int ret = 0;
+ int cmd = (atic->is_radeon ? DRM_RADEON_CP_IDLE :
+ DRM_R128_CCE_IDLE);
+ WHILE_NOT_TIMEOUT(2) {
+ ret = drmCommandNone(atic->drmFd, cmd);
+ if (ret != -EBUSY)
+ break;
+ }
+ if (TIMEDOUT()) {
+ ATIDebugFifo(atis);
+ FatalError("Timed out idling CCE (card hung)\n");
+ }
+ if (ret != 0)
+ ErrorF("Failed to idle DMA, returned %d\n", ret);
+ return;
+ }
+#endif
+
+ if (!atic->is_radeon && (atis->using_pseudo || atis->using_dma)) {
+ ATIWaitAvailPrimary(atis, atis->cce_pri_size);
+
+ WHILE_NOT_TIMEOUT(.2) {
+ if ((MMIO_IN32(mmio, R128_REG_PM4_STAT) &
+ (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE)) == 0)
+ break;
+ }
+ if (TIMEDOUT()) {
+ ErrorF("Timeout idling CCE, resetting...\n");
+ ATIEngineReset(atis);
+ ATIDrawSetup(atis->screen->pScreen);
+ }
+ }
+
+ /* Radeon CP idle is the same as MMIO idle. */
+ if (atis->using_pio || atic->is_radeon) {
+ /* Empty the fifo */
+ ATIWaitAvailMMIO(atis, 64);
+
+ if (atic->is_radeon) {
+ WHILE_NOT_TIMEOUT(.2) {
+ if ((MMIO_IN32(mmio, RADEON_REG_RBBM_STATUS) &
+ RADEON_RBBM_ACTIVE) == 0)
+ break;
+ }
+ } else {
+ WHILE_NOT_TIMEOUT(.2) {
+ if ((MMIO_IN32(mmio, R128_REG_GUI_STAT) &
+ R128_GUI_ACTIVE) == 0)
+ break;
+ }
+ }
+ if (TIMEDOUT()) {
+ ErrorF("Timeout idling accelerator, resetting...\n");
+ ATIEngineReset(atis);
+ ATIDrawSetup(atis->screen->pScreen);
+ }
+ }
+
+ ATIFlushPixelCache(atis);
+
+#if DEBUG_FIFO
+ ErrorF("Idle?\n");
+ ATIDebugFifo(atis);
+#endif
+}
+
+dmaBuf *
+ATIGetDMABuffer(ATIScreenInfo *atis)
+{
+ dmaBuf *buf;
+
+ buf = (dmaBuf *)xalloc(sizeof(dmaBuf));
+ if (buf == NULL)
+ return NULL;
+
+#ifdef USE_DRI
+ if (atis->using_dri) {
+ buf->drmBuf = ATIDRIGetBuffer(atis);
+ if (buf->drmBuf == NULL) {
+ xfree(buf);
+ return NULL;
+ }
+ buf->size = buf->drmBuf->total;
+ buf->used = buf->drmBuf->used;
+ buf->address = buf->drmBuf->address;
+ return buf;
+ }
+#endif /* USE_DRI */
+
+ if (atis->using_dma)
+ buf->size = atis->ring_len / 2;
+ else
+ buf->size = 512 * 1024;
+ buf->address = xalloc(buf->size);
+ if (buf->address == NULL) {
+ xfree(buf);
+ return NULL;
+ }
+ buf->used = 0;
+
+ return buf;
+}
+
+/* Decode a type-3 packet into MMIO register writes. Only some type-3 packets
+ * supported, and only partially.
+ */
+static void
+ATIDispatchPacket3MMIO(ATIScreenInfo *atis, CARD32 header, CARD32 *addr,
+ int count)
+{
+ ATICardInfo *atic = atis->atic;
+ char *mmio = atic->reg_base;
+ CARD32 settings;
+ int i = 0;
+
+ settings = addr[i++];
+
+ if ((settings & ATI_GMC_SRC_PITCH_OFFSET_CNTL) != 0)
+ MMIO_OUT32(mmio, ATI_REG_SRC_PITCH_OFFSET, addr[i++]);
+ if ((settings & ATI_GMC_DST_PITCH_OFFSET_CNTL) != 0)
+ MMIO_OUT32(mmio, ATI_REG_DST_PITCH_OFFSET, addr[i++]);
+ if ((settings & ATI_GMC_BRUSH_MASK) == ATI_GMC_BRUSH_SOLID_COLOR)
+ MMIO_OUT32(mmio, ATI_REG_DP_BRUSH_FRGD_CLR, addr[i++]);
+
+ switch (header & (ATI_CCE_PACKETTYPE_MASK |
+ ATI_CCE_PACKET3_IT_OPCODE_MASK))
+ {
+ case ATI_CCE_PACKET3_PAINT_MULTI:
+ while (i < count) {
+ MMIO_OUT32(mmio, ATI_REG_DST_Y_X,
+ (addr[i] >> 16) | (addr[i] << 16));
+ i++;
+ MMIO_OUT32(mmio, ATI_REG_DST_HEIGHT_WIDTH,
+ (addr[i] >> 16) | (addr[i] << 16));
+ i++;
+ }
+ break;
+ case ATI_CCE_PACKET3_BITBLT_MULTI:
+ while (i < count) {
+ MMIO_OUT32(mmio, ATI_REG_SRC_Y_X,
+ (addr[i] >> 16) | (addr[i] << 16));
+ i++;
+ MMIO_OUT32(mmio, ATI_REG_DST_Y_X,
+ (addr[i] >> 16) | (addr[i] << 16));
+ i++;
+ MMIO_OUT32(mmio, ATI_REG_DST_HEIGHT_WIDTH,
+ (addr[i] >> 16) | (addr[i] << 16));
+ i++;
+ }
+ break;
+ default:
+ ErrorF("Unsupported packet: 0x%x\n", header);
+ }
+}
+
+/* Dispatch packets by decoding them and writing to registers. Doesn't support
+ * the type 3 packets.
+ */
+static void
+ATIDispatchIndirectMMIO(ATIScreenInfo *atis)
+{
+ ATICardInfo *atic = atis->atic;
+ dmaBuf *buf = atis->indirectBuffer;
+ char *mmio = atic->reg_base;
+ CARD32 *addr;
+ CARD32 reg;
+ int i, n, count;
+
+ addr = (CARD32 *)((char *)buf->address + atis->indirectStart);
+ count = (buf->used - atis->indirectStart) / 4;
+
+ for (i = 0; i < count; i++) {
+ CARD32 header = addr[i];
+
+ switch (header & ATI_CCE_PACKETTYPE_MASK)
+ {
+ case ATI_CCE_PACKET0:
+ n = ((header & ATI_CCE_PACKET0_COUNT_MASK) >> 16) + 1;
+ reg = (header & ATI_CCE_PACKET0_REG_MASK) << 2;
+ ATIWaitAvailMMIO(atis, n);
+ while (n > 0) {
+ i++;
+ MMIO_OUT32(mmio, reg, addr[i]);
+ if ((header & ATI_CCE_PACKET0_ONE_REG_WR) == 0)
+ reg += 4;
+ n--;
+ }
+ break;
+ case ATI_CCE_PACKET1:
+ reg = (header & ATI_CCE_PACKET1_REG_1) << 2;
+ MMIO_OUT32(mmio, reg, addr[++i]);
+ reg = ((header & ATI_CCE_PACKET1_REG_2) >>
+ ATI_CCE_PACKET1_REG_2_SHIFT) << 2;
+ MMIO_OUT32(mmio, reg, addr[++i]);
+ break;
+ case ATI_CCE_PACKET2:
+ /* PACKET2 is a no-op packet. */
+ break;
+ case ATI_CCE_PACKET3:
+ n = ((header & ATI_CCE_PACKET3_COUNT_MASK) >> 16) + 1;
+ ATIDispatchPacket3MMIO(atis, header, &addr[i], n);
+ i += n;
+ break;
+ default:
+ ErrorF("Unsupported packet: 0x%x\n", addr[i]);
+ }
+ }
+}
+
+/* Dispatch packets by sending them through the MMIO aperture. */
+static void
+R128DispatchIndirectPDMA(ATIScreenInfo *atis)
+{
+ ATICardInfo *atic = atis->atic;
+ dmaBuf *buf = atis->indirectBuffer;
+ char *mmio = atic->reg_base;
+ CARD32 *addr;
+ int count;
+
+ addr = (CARD32 *)((char *)buf->address + atis->indirectStart);
+ count = (buf->used - atis->indirectStart) / 4;
+
+ while (count > 1) {
+ ATIWaitAvailPrimary(atis, 2);
+ MMIO_OUT32(mmio, R128_REG_PM4_FIFO_DATA_EVEN, *addr++);
+ MMIO_OUT32(mmio, R128_REG_PM4_FIFO_DATA_ODD, *addr++);
+ count -= 2;
+ }
+
+ /* Submit last DWORD if necessary. */
+ if (count != 0) {
+ ATIWaitAvailPrimary(atis, 2);
+ MMIO_OUT32(mmio, R128_REG_PM4_FIFO_DATA_EVEN, *addr++);
+ MMIO_OUT32(mmio, R128_REG_PM4_FIFO_DATA_ODD, ATI_CCE_PACKET2);
+ }
+}
+
+/* Dispatch packets by sending them through the MMIO aperture, using the
+ * primary CCE ring. */
+static void
+RadeonDispatchIndirectPDMA(ATIScreenInfo *atis)
+{
+ ATICardInfo *atic = atis->atic;
+ dmaBuf *buf = atis->indirectBuffer;
+ char *mmio = atic->reg_base;
+ CARD32 *addr;
+ int count, avail, reg, i;
+ TIMEOUT_LOCALS;
+
+ addr = (CARD32 *)((char *)buf->address + atis->indirectStart);
+ count = (buf->used - atis->indirectStart) / 4;
+
+ reg = RADEON_REG_CSQ_APER_PRIMARY;
+ WHILE_NOT_TIMEOUT(3) {
+ /* 3 seconds is empirical, using render_bench on an r100. */
+ if (count <= 0)
+ break;
+ avail = ATIGetAvailPrimary(atis);
+ for (i = 0; i < min(count, avail); i++) {
+ MMIO_OUT32(mmio, reg, *addr++);
+ if (reg == RADEON_REG_CSQ_APER_PRIMARY_END)
+ reg = RADEON_REG_CSQ_APER_PRIMARY;
+ else
+ reg += 4;
+ }
+ count -= i;
+ }
+ if (TIMEDOUT()) {
+ ErrorF("Timeout submitting packets, resetting...\n");
+ ATIEngineReset(atis);
+ ATIDrawSetup(atis->screen->pScreen);
+ }
+}
+
+
+/* Dispatch packets by writing them to the (primary) ring buffer, which happens
+ * to be in framebuffer memory.
+ */
+static void
+R128DispatchIndirectDMA(ATIScreenInfo *atis)
+{
+ ATICardInfo *atic = atis->atic;
+ dmaBuf *buf = atis->indirectBuffer;
+ char *mmio = atic->reg_base;
+ CARD32 *addr;
+ int count, ring_count;
+ TIMEOUT_LOCALS;
+
+ addr = (CARD32 *)((char *)buf->address + atis->indirectStart);
+ count = (buf->used - atis->indirectStart) / 4;
+ ring_count = atis->ring_len / 4;
+
+ WHILE_NOT_TIMEOUT(.2) {
+ if (count <= 0)
+ break;
+
+ atis->ring_addr[atis->ring_write++] = *addr++;
+ if (atis->ring_write >= ring_count)
+ atis->ring_write = 0;
+ while (atis->ring_write == atis->ring_read) {
+ atis->ring_read = MMIO_IN32(mmio, ATI_REG_CCE_RPTR);
+ }
+ count--;
+ }
+ if (TIMEDOUT()) {
+ ErrorF("Timeout submitting packets, resetting...\n");
+ ATIEngineReset(atis);
+ ATIDrawSetup(atis->screen->pScreen);
+ }
+
+ /* Workaround for some early Rage 128 ASIC spins where the CCE parser
+ * may read up to 32 DWORDS beyond the end of the ring buffer memory
+ * before wrapping around, if the ring buffer was empty and a <32 DWORD
+ * packet that wraps around the end of the ring buffer is submitted.
+ * To work around that, copy the beginning of the ring buffer past the
+ * end if that may happen.
+ */
+ if (atis->ring_write < 32)
+ memcpy(atis->ring_addr + ring_count, atis->ring_addr, 32 * 4);
+
+ /* Update write pointer */
+ MMIO_OUT32(mmio, ATI_REG_CCE_WPTR, atis->ring_write);
+}
+
+void
+ATIFlushIndirect(ATIScreenInfo *atis, Bool discard)
+{
+ ATICardInfo *atic = atis->atic;
+ dmaBuf *buf = atis->indirectBuffer;
+
+ if ((atis->indirectStart == buf->used) && !discard)
+ return;
+
+#if DEBUG_FIFO
+ ErrorF("Dispatching %d DWORDS\n", (buf->used - atis->indirectStart) /
+ 4);
+#endif
+
+#ifdef USE_DRI
+ if (atis->using_dri) {
+ buf->drmBuf->used = buf->used;
+ ATIDRIDispatchIndirect(atis, discard);
+ if (discard) {
+ buf->drmBuf = ATIDRIGetBuffer(atis);
+ buf->size = buf->drmBuf->total;
+ buf->used = buf->drmBuf->used;
+ buf->address = buf->drmBuf->address;
+ atis->indirectStart = 0;
+ } else {
+ /* Start on a double word boundary */
+ atis->indirectStart = buf->used = (buf->used + 7) & ~7;
+ }
+ return;
+ }
+#endif /* USE_DRI */
+
+ if (atis->using_dma && !atic->is_radeon)
+ R128DispatchIndirectDMA(atis);
+ else if (atis->using_pseudo) {
+ if (atic->is_radeon)
+ RadeonDispatchIndirectPDMA(atis);
+ else
+ R128DispatchIndirectPDMA(atis);
+ } else
+ ATIDispatchIndirectMMIO(atis);
+
+ buf->used = 0;
+ atis->indirectStart = 0;
+}
+
+static Bool
+ATIInitAGP(ScreenPtr pScreen, int size)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICardInfo(pScreenPriv);
+ AgpInfoPtr agp_info;
+ int screennum = atis->screen->mynum;
+
+ if (atic->is_radeon)
+ return FALSE;
+
+ if (!KdAgpGARTSupported())
+ return FALSE;
+
+ if (!KdAcquireGART(screennum))
+ return FALSE;
+
+ atis->agp_key = KdAllocateGARTMemory(screennum, size, 0, NULL);
+ if (atis->agp_key == -1) {
+ ErrorF("Failed to allocate %dKB GART memory\n", size/1024);
+ KdReleaseGART(screennum);
+ return FALSE;
+ }
+
+ if (!KdBindGARTMemory(screennum, atis->agp_key, 0)) {
+ ErrorF("Failed to bind GART memory\n");
+ KdReleaseGART(screennum);
+ return FALSE;
+ }
+
+ agp_info = KdGetAGPInfo(screennum);
+ if (agp_info == NULL) {
+ KdUnbindGARTMemory(screennum, atis->agp_key);
+ KdReleaseGART(screennum);
+ return FALSE;
+ }
+
+ atis->agp_addr = KdMapDevice(agp_info->base, agp_info->size);
+ if (atis->agp_addr == NULL) {
+ ErrorF("Failed to map GART memory\n");
+ KdUnbindGARTMemory(screennum, atis->agp_key);
+ KdReleaseGART(screennum);
+ free(agp_info);
+ return FALSE;
+ }
+ KdSetMappedMode(agp_info->base, agp_info->size,
+ KD_MAPPED_MODE_FRAMEBUFFER);
+
+ atis->agp_size = size;
+ free(agp_info);
+
+ return TRUE;
+}
+
+static void
+ATIFiniAGP(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ int screennum = atis->screen->mynum;
+
+ KdUnbindGARTMemory(screennum, atis->agp_key);
+ KdReleaseGART(screennum);
+ atis->agp_addr = NULL;
+ atis->agp_size = 0;
+}
+
+static Bool
+ATIPseudoDMAInit(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICardInfo(pScreenPriv);
+ char *mmio = atic->reg_base;
+
+ if (atic->is_r300)
+ return FALSE;
+
+ ATIUploadMicrocode(atis);
+ ATIEngineReset(atis);
+
+ if (atic->is_r200) {
+ MMIO_OUT32(mmio, RADEON_REG_CP_CSQ_CNTL,
+ RADEON_CSQ_PRIPIO_INDDIS);
+ atis->cce_pri_size = MMIO_IN32(mmio, RADEON_REG_CP_CSQ_CNTL) &
+ R200_CSQ_CNT_PRIMARY_MASK;
+ MMIO_OUT32(mmio, RADEON_REG_ME_CNTL, RADEON_ME_MODE_FREE_RUN);
+ } else if (atic->is_radeon) {
+ MMIO_OUT32(mmio, RADEON_REG_CP_CSQ_CNTL,
+ RADEON_CSQ_PRIPIO_INDDIS);
+ atis->cce_pri_size = MMIO_IN32(mmio, RADEON_REG_CP_CSQ_CNTL) &
+ RADEON_CSQ_CNT_PRIMARY_MASK;
+ MMIO_OUT32(mmio, RADEON_REG_ME_CNTL, RADEON_ME_MODE_FREE_RUN);
+ } else {
+ MMIO_OUT32(mmio, R128_REG_PM4_BUFFER_CNTL, R128_PM4_192PIO |
+ R128_PM4_BUFFER_CNTL_NOUPDATE);
+ atis->cce_pri_size = 192;
+ MMIO_OUT32(mmio, R128_REG_PM4_MICRO_CNTL,
+ R128_PM4_MICRO_FREERUN);
+ }
+
+ return TRUE;
+}
+
+static Bool
+ATIPseudoDMAFini(ScreenPtr pScreen)
+{ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICardInfo(pScreenPriv);
+ char *mmio = atic->reg_base;
+
+ if (atic->is_radeon) {
+ MMIO_OUT32(mmio, RADEON_REG_ME_CNTL, 0);
+ MMIO_OUT32(mmio, RADEON_REG_CP_CSQ_CNTL,
+ RADEON_CSQ_PRIDIS_INDDIS);
+ } else {
+ MMIO_OUT32(mmio, R128_REG_PM4_MICRO_CNTL, 0);
+ MMIO_OUT32(mmio, R128_REG_PM4_BUFFER_CNTL,
+ R128_PM4_NONPM4 | R128_PM4_BUFFER_CNTL_NOUPDATE);
+ }
+ atis->cce_pri_size = 0;
+
+ ATIEngineReset(atis);
+
+ return TRUE;
+}
+
+static Bool
+ATIDMAInit(ScreenPtr pScreen, Bool use_agp)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICardInfo(pScreenPriv);
+ char *mmio = atic->reg_base;
+ int dma_offset;
+ CARD32 tmp;
+
+ /* XXX: Not for radeons. Yet? */
+ if (atic->is_radeon)
+ return FALSE;
+
+ if (use_agp) {
+ if (1)
+ return FALSE; /* XXX */
+ /* Allocate a 1MB AGP space, but only use 128k + 128 for DMA.
+ * XXX: Should use the rest for things like scratch space.
+ */
+ if (!ATIInitAGP(pScreen, 1024 * 1024))
+ return FALSE;
+ atis->ring_addr = atis->agp_addr;
+ atis->ring_len = 128 * 1024;
+ dma_offset = R128_AGP_OFFSET;
+ } else {
+ if (1)
+ return FALSE; /* XXX */
+ /* Allocate a 128K buffer, plus 32 DWORDS to give space for the
+ * R128 ASIC bug workaround.
+ */
+ atis->dma_space = KdOffscreenAlloc(pScreen, 128 * 1024 + 128,
+ 128, TRUE, NULL, NULL);
+ if (atis->dma_space == NULL)
+ return FALSE;
+ atis->ring_addr = (CARD32 *)(atis->dma_space->offset +
+ pScreenPriv->screen->memory_base);
+ atis->ring_len = 128 * 1024;
+ dma_offset = atis->dma_space->offset;
+ }
+
+ ATIUploadMicrocode(atis);
+ ATIEngineReset(atis);
+
+ atis->ring_read = 0;
+ atis->ring_write = 0;
+
+ tmp = MMIO_IN32(mmio, ATI_REG_BUS_CNTL);
+ MMIO_OUT32(mmio, ATI_REG_BUS_CNTL, tmp & ~ATI_BUS_MASTER_DIS);
+
+ MMIO_OUT32(mmio, ATI_REG_CCE_RB_BASE, dma_offset);
+ MMIO_OUT32(mmio, ATI_REG_CCE_WPTR, atis->ring_write);
+ MMIO_OUT32(mmio, ATI_REG_CCE_RPTR, atis->ring_read);
+ MMIO_OUT32(mmio, ATI_REG_CCE_RPTR_ADDR, 0 /* XXX? */);
+
+ if (atic->is_r200) {
+ MMIO_OUT32(mmio, RADEON_REG_CP_CSQ_CNTL,
+ RADEON_CSQ_PRIBM_INDBM);
+ atis->cce_pri_size = MMIO_IN32(mmio, RADEON_REG_CP_CSQ_CNTL) &
+ R200_CSQ_CNT_PRIMARY_MASK;
+ MMIO_OUT32(mmio, RADEON_REG_ME_CNTL, RADEON_ME_MODE_FREE_RUN);
+ } else if (atic->is_radeon) {
+ MMIO_OUT32(mmio, RADEON_REG_CP_CSQ_CNTL,
+ RADEON_CSQ_PRIBM_INDBM);
+ atis->cce_pri_size = MMIO_IN32(mmio, RADEON_REG_CP_CSQ_CNTL) &
+ RADEON_CSQ_CNT_PRIMARY_MASK;
+ MMIO_OUT32(mmio, RADEON_REG_ME_CNTL, RADEON_ME_MODE_FREE_RUN);
+ } else {
+ MMIO_OUT32(mmio, R128_REG_PM4_BUFFER_WM_CNTL,
+ ((R128_WATERMARK_L/4) << R128_WMA_SHIFT) |
+ ((R128_WATERMARK_M/4) << R128_WMB_SHIFT) |
+ ((R128_WATERMARK_N/4) << R128_WMC_SHIFT) |
+ ((R128_WATERMARK_K/64) << R128_WB_WM_SHIFT));
+ /* The sample code reads from an undocumneted register
+ * (PM4_BUFFER_ADDR). Perhaps it's a write posting thing? Do
+ * a read in case that's it.
+ */
+ MMIO_IN32(mmio, R128_REG_PM4_BUFFER_CNTL);
+ if (use_agp) {
+ /* XXX Magic num */
+ MMIO_OUT32(mmio, R128_REG_PCI_GART_PAGE, 1);
+ MMIO_OUT32(mmio, R128_REG_PM4_BUFFER_CNTL,
+ ATILog2(atis->ring_len) |
+ R128_PM4_192BM |
+ R128_PM4_BUFFER_CNTL_NOUPDATE);
+ } else {
+ MMIO_OUT32(mmio, R128_REG_PM4_BUFFER_CNTL,
+ ATILog2(atis->ring_len) |
+ R128_PM4_192BM |
+ R128_PM4_BUFFER_CNTL_NOUPDATE |
+ R128_PM4_IN_FRAME_BUFFER);
+ }
+ atis->cce_pri_size = 192;
+ MMIO_IN32(mmio, R128_REG_PM4_BUFFER_CNTL);
+ MMIO_OUT32(mmio, R128_REG_PM4_MICRO_CNTL,
+ R128_PM4_MICRO_FREERUN);
+ }
+
+ return TRUE;
+}
+
+static Bool
+ATIDMAFini(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICardInfo(pScreenPriv);
+ char *mmio = atic->reg_base;
+
+ if (atic->is_radeon) {
+ MMIO_OUT32(mmio, RADEON_REG_ME_CNTL, 0);
+ MMIO_OUT32(mmio, RADEON_REG_CP_CSQ_CNTL,
+ RADEON_CSQ_PRIDIS_INDDIS);
+ } else {
+ MMIO_OUT32(mmio, ATI_REG_CCE_WPTR,
+ atis->ring_write | R128_PM4_BUFFER_DL_DONE);
+ MMIO_OUT32(mmio, R128_REG_PM4_MICRO_CNTL, 0);
+ MMIO_OUT32(mmio, R128_REG_PM4_BUFFER_CNTL,
+ R128_PM4_NONPM4 | R128_PM4_BUFFER_CNTL_NOUPDATE);
+ }
+ atis->cce_pri_size = 0;
+
+ ATIEngineReset(atis);
+
+ if (atis->using_agp)
+ ATIFiniAGP(pScreen);
+ else
+ KdOffscreenFree(pScreen, atis->dma_space);
+
+ return TRUE;
+}
+
+void
+ATIDMASetup(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+ ATIScreenInfo(pScreenPriv);
+
+#ifdef USE_DRI
+ if (atis->using_dri)
+ ATIDRIDMAStart(atis);
+#endif /* USE_DRI */
+
+ if (!atis->using_dri) {
+ atis->using_agp = FALSE;
+ if (atic->is_agp && ATIDMAInit(pScreen, TRUE)) {
+ atis->using_agp = TRUE;
+ atis->using_dma = TRUE;
+ } else if (ATIDMAInit(pScreen, FALSE)) {
+ atis->using_agp = FALSE;
+ atis->using_dma = TRUE;
+ } else if (ATIPseudoDMAInit(pScreen))
+ atis->using_pseudo = TRUE;
+ else
+ atis->using_pio = TRUE;
+ }
+
+ atis->indirectBuffer = ATIGetDMABuffer(atis);
+ if (atis->indirectBuffer == FALSE)
+ FatalError("Failed to allocate DMA buffer.\n");
+
+ if (atis->using_dri)
+ ErrorF("Initialized %s DRI DMA\n",
+ atis->using_agp ? "AGP" : "PCI");
+ else if (atis->using_dma && atis->using_agp)
+ ErrorF("Initialized AGP DMA\n");
+ else if (atis->using_dma)
+ ErrorF("Initialized framebuffer pseudo-DMA\n");
+ else if (atis->using_pseudo)
+ ErrorF("Initialized pseudo-DMA\n");
+ else if (atis->using_pio)
+ ErrorF("Initialized PIO\n");
+}
+
+void
+ATIDMATeardown(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+
+ ATIWaitIdle(atis);
+
+#ifdef USE_DRI
+ if (atis->using_dri)
+ ATIDRIDMAStop(atis);
+#endif /* USE_DRI */
+
+ if (atis->using_dma)
+ ATIDMAFini(pScreen);
+
+ if (atis->using_pseudo)
+ ATIPseudoDMAFini(pScreen);
+
+ if (atis->using_pio || atis->using_pseudo || atis->using_dma) {
+ xfree(atis->indirectBuffer->address);
+ xfree(atis->indirectBuffer);
+ }
+ atis->indirectBuffer = NULL;
+
+ atis->using_pio = FALSE;
+ atis->using_pseudo = FALSE;
+ atis->using_dma = FALSE;
+ atis->using_agp = FALSE;
+}
+
diff --git a/xorg-server/hw/kdrive/ati/ati_dma.h b/xorg-server/hw/kdrive/ati/ati_dma.h
new file mode 100644
index 000000000..4c2092b2c
--- /dev/null
+++ b/xorg-server/hw/kdrive/ati/ati_dma.h
@@ -0,0 +1,141 @@
+/*
+ * Copyright © 2004 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _ATI_DMA_H_
+#define _ATI_DMA_H_
+
+#define CCE_DEBUG 1
+
+#if !CCE_DEBUG
+#define DMA_PACKET0(reg, count) \
+ (ATI_CCE_PACKET0 | (((count) - 1) << 16) | ((reg) >> 2))
+#else
+#define DMA_PACKET0(reg, count) \
+ (__packet0count = (count), __reg = (reg), \
+ ATI_CCE_PACKET0 | (((count) - 1) << 16) | ((reg) >> 2))
+#endif
+#define DMA_PACKET1(reg1, reg2) \
+ (ATI_CCE_PACKET1 | \
+ (((reg2) >> 2) << ATI_CCE_PACKET1_REG_2_SHIFT) | ((reg1) >> 2))
+#define DMA_PACKET3(type, count) \
+ ((type) | (((count) - 1) << 16))
+
+#if !CCE_DEBUG
+
+#define RING_LOCALS CARD32 *__head; int __count
+#define BEGIN_DMA(n) \
+do { \
+ if ((atis->indirectBuffer->used + 4*(n)) > \
+ atis->indirectBuffer->size) { \
+ ATIFlushIndirect(atis, 1); \
+ } \
+ __head = (CARD32 *)((char *)atis->indirectBuffer->address + \
+ atis->indirectBuffer->used); \
+ __count = 0; \
+} while (0)
+#define END_DMA() do { \
+ atis->indirectBuffer->used += __count * 4; \
+} while (0)
+
+#else
+
+#define RING_LOCALS \
+ CARD32 *__head; int __count, __total, __reg, __packet0count
+#define BEGIN_DMA(n) \
+do { \
+ if ((atis->indirectBuffer->used + 4*(n)) > \
+ atis->indirectBuffer->size) { \
+ ATIFlushIndirect(atis, 1); \
+ } \
+ __head = (CARD32 *)((char *)atis->indirectBuffer->address + \
+ atis->indirectBuffer->used); \
+ __count = 0; \
+ __total = n; \
+ __reg = 0; \
+ __packet0count = 0; \
+} while (0)
+#define END_DMA() do { \
+ if (__count != __total) \
+ FatalError("count != total (%d vs %d) at %s:%d\n", \
+ __count, __total, __FILE__, __LINE__); \
+ atis->indirectBuffer->used += __count * 4; \
+} while (0)
+
+#endif
+
+#define OUT_RING(val) do { \
+ __head[__count++] = (val); \
+} while (0)
+
+#define OUT_RING_REG(reg, val) do { \
+ if (__reg != reg) \
+ FatalError("unexpected reg (0x%x vs 0x%x) at %s:%d\n", \
+ reg, __reg, __FILE__, __LINE__); \
+ if (__packet0count-- <= 0) \
+ FatalError("overrun of packet0 at %s:%d\n", \
+ __FILE__, __LINE__); \
+ __head[__count++] = (val); \
+ __reg += 4; \
+} while (0)
+
+#define OUT_RING_F(x) OUT_RING(GET_FLOAT_BITS(x))
+
+#define OUT_REG(reg, val) \
+do { \
+ OUT_RING(DMA_PACKET0(reg, 1)); \
+ OUT_RING(val); \
+} while (0)
+
+#define TIMEOUT_LOCALS struct timeval _target, _curtime
+
+static inline Bool
+tv_le(struct timeval *tv1, struct timeval *tv2)
+{
+ if (tv1->tv_sec < tv2->tv_sec ||
+ (tv1->tv_sec == tv2->tv_sec && tv1->tv_usec < tv2->tv_usec))
+ return TRUE;
+ else
+ return FALSE;
+}
+
+#define WHILE_NOT_TIMEOUT(_timeout) \
+ gettimeofday(&_target, NULL); \
+ _target.tv_usec += ((_timeout) * 1000000); \
+ _target.tv_sec += _target.tv_usec / 1000000; \
+ _target.tv_usec = _target.tv_usec % 1000000; \
+ while (gettimeofday(&_curtime, NULL), tv_le(&_curtime, &_target))
+
+#define TIMEDOUT() (!tv_le(&_curtime, &_target))
+
+dmaBuf *
+ATIGetDMABuffer(ATIScreenInfo *atis);
+
+void
+ATIFlushIndirect(ATIScreenInfo *atis, Bool discard);
+
+void
+ATIDMASetup(ScreenPtr pScreen);
+
+void
+ATIDMATeardown(ScreenPtr pScreen);
+
+#endif /* _ATI_DMA_H_ */
diff --git a/xorg-server/hw/kdrive/ati/ati_draw.c b/xorg-server/hw/kdrive/ati/ati_draw.c
new file mode 100644
index 000000000..c10fea471
--- /dev/null
+++ b/xorg-server/hw/kdrive/ati/ati_draw.c
@@ -0,0 +1,918 @@
+/*
+ * Copyright © 2003 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "ati.h"
+#include "ati_reg.h"
+#include "ati_dma.h"
+#include "ati_draw.h"
+#include "kaa.h"
+
+CARD8 ATISolidRop[16] = {
+ /* GXclear */ 0x00, /* 0 */
+ /* GXand */ 0xa0, /* src AND dst */
+ /* GXandReverse */ 0x50, /* src AND NOT dst */
+ /* GXcopy */ 0xf0, /* src */
+ /* GXandInverted*/ 0x0a, /* NOT src AND dst */
+ /* GXnoop */ 0xaa, /* dst */
+ /* GXxor */ 0x5a, /* src XOR dst */
+ /* GXor */ 0xfa, /* src OR dst */
+ /* GXnor */ 0x05, /* NOT src AND NOT dst */
+ /* GXequiv */ 0xa5, /* NOT src XOR dst */
+ /* GXinvert */ 0x55, /* NOT dst */
+ /* GXorReverse */ 0xf5, /* src OR NOT dst */
+ /* GXcopyInverted*/ 0x0f, /* NOT src */
+ /* GXorInverted */ 0xaf, /* NOT src OR dst */
+ /* GXnand */ 0x5f, /* NOT src OR NOT dst */
+ /* GXset */ 0xff, /* 1 */
+};
+
+CARD8 ATIBltRop[16] = {
+ /* GXclear */ 0x00, /* 0 */
+ /* GXand */ 0x88, /* src AND dst */
+ /* GXandReverse */ 0x44, /* src AND NOT dst */
+ /* GXcopy */ 0xcc, /* src */
+ /* GXandInverted*/ 0x22, /* NOT src AND dst */
+ /* GXnoop */ 0xaa, /* dst */
+ /* GXxor */ 0x66, /* src XOR dst */
+ /* GXor */ 0xee, /* src OR dst */
+ /* GXnor */ 0x11, /* NOT src AND NOT dst */
+ /* GXequiv */ 0x99, /* NOT src XOR dst */
+ /* GXinvert */ 0x55, /* NOT dst */
+ /* GXorReverse */ 0xdd, /* src OR NOT dst */
+ /* GXcopyInverted*/ 0x33, /* NOT src */
+ /* GXorInverted */ 0xbb, /* NOT src OR dst */
+ /* GXnand */ 0x77, /* NOT src OR NOT dst */
+ /* GXset */ 0xff, /* 1 */
+};
+
+int copydx, copydy;
+ATIScreenInfo *accel_atis;
+/* If is_24bpp is set, then we are using the accelerator in 8-bit mode due
+ * to it being broken for 24bpp, so coordinates have to be multiplied by 3.
+ */
+Bool is_24bpp;
+CARD32 settings, color, src_pitch_offset, dst_pitch_offset;
+
+int sample_count;
+float sample_offsets_x[255];
+float sample_offsets_y[255];
+
+#define DRAW_USING_PACKET3 0
+
+void
+ATIDrawSetup(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICardInfo(pScreenPriv);
+ RING_LOCALS;
+
+ /* XXX: this shouldn't be necessary, but fixes some R128 composite
+ * issues.
+ */
+ /*if (!atic->is_radeon) {
+ char *mmio = atic->reg_base;
+ ATIWaitIdle(atis);
+ MMIO_OUT32(mmio, R128_REG_PC_GUI_MODE,
+ R128_PC_BYPASS_EN);
+ }*/
+
+ BEGIN_DMA(2);
+ OUT_REG(ATI_REG_DEFAULT_SC_BOTTOM_RIGHT,
+ ATI_DEFAULT_SC_RIGHT_MAX | ATI_DEFAULT_SC_BOTTOM_MAX);
+ END_DMA();
+
+ if (!atic->is_radeon) {
+ /* Setup for R128 Composite */
+ BEGIN_DMA(12);
+ OUT_REG(R128_REG_SCALE_3D_CNTL,
+ R128_SCALE_3D_TEXMAP_SHADE |
+ R128_SCALE_PIX_REPLICATE |
+ R128_TEX_CACHE_SPLIT |
+ R128_TEX_MAP_ALPHA_IN_TEXTURE |
+ R128_TEX_CACHE_LINE_SIZE_4QW);
+ OUT_REG(R128_REG_SETUP_CNTL,
+ R128_COLOR_SOLID_COLOR |
+ R128_PRIM_TYPE_TRI |
+ R128_TEXTURE_ST_MULT_W |
+ R128_STARTING_VERTEX_1 |
+ R128_ENDING_VERTEX_3 |
+ R128_SUB_PIX_4BITS);
+ OUT_REG(R128_REG_PM4_VC_FPU_SETUP,
+ R128_FRONT_DIR_CCW |
+ R128_BACKFACE_CULL |
+ R128_FRONTFACE_SOLID |
+ R128_FPU_COLOR_SOLID |
+ R128_FPU_SUB_PIX_4BITS |
+ R128_FPU_MODE_3D |
+ R128_TRAP_BITS_DISABLE |
+ R128_XFACTOR_2 |
+ R128_YFACTOR_2 |
+ R128_FLAT_SHADE_VERTEX_OGL |
+ R128_FPU_ROUND_TRUNCATE |
+ R128_WM_SEL_8DW);
+ OUT_REG(R128_REG_PLANE_3D_MASK_C, 0xffffffff);
+ OUT_REG(R128_REG_CONSTANT_COLOR_C, 0xff000000);
+ OUT_REG(R128_REG_WINDOW_XY_OFFSET, 0x00000000);
+ END_DMA();
+ } else if (!atic->is_r300) {
+ /* Setup for R100/R200 Composite */
+ BEGIN_DMA(8);
+ OUT_REG(RADEON_REG_RE_TOP_LEFT, 0);
+ OUT_REG(RADEON_REG_RE_WIDTH_HEIGHT, 0xffffffff);
+ OUT_REG(RADEON_REG_RB3D_PLANEMASK, 0xffffffff);
+ OUT_REG(RADEON_REG_SE_CNTL,
+ RADEON_FFACE_CULL_CCW |
+ RADEON_FFACE_SOLID |
+ RADEON_VTX_PIX_CENTER_OGL);
+ END_DMA();
+
+ if (atic->is_r100) {
+ BEGIN_DMA(6);
+ OUT_REG(RADEON_REG_SE_CNTL_STATUS, RADEON_TCL_BYPASS);
+ OUT_REG(RADEON_REG_SE_COORD_FMT,
+ RADEON_VTX_XY_PRE_MULT_1_OVER_W0 |
+ RADEON_VTX_ST0_NONPARAMETRIC |
+ RADEON_VTX_ST1_NONPARAMETRIC |
+ RADEON_TEX1_W_ROUTING_USE_W0);
+ OUT_REG(RADEON_REG_RB3D_DSTCACHE_MODE,
+ RADEON_RB3D_DC_2D_CACHE_AUTOFLUSH |
+ RADEON_RB3D_DC_3D_CACHE_AUTOFLUSH);
+ END_DMA();
+ } else {
+ BEGIN_DMA(18);
+ /* XXX: The 0 below should be RADEON_TCL_BYPASS on
+ * RS300s.
+ */
+ OUT_REG(R200_REG_SE_VAP_CNTL_STATUS, 0);
+ OUT_REG(R200_REG_PP_CNTL_X, 0);
+ OUT_REG(R200_REG_PP_TXMULTI_CTL_0, 0);
+ OUT_REG(R200_REG_SE_VTX_STATE_CNTL, 0);
+ OUT_REG(R200_REG_RE_CNTL, 0);
+ /* XXX: VTX_ST_DENORMALIZED is illegal for the case of
+ * repeating textures.
+ */
+ OUT_REG(R200_REG_SE_VTE_CNTL, R200_VTX_ST_DENORMALIZED);
+ OUT_REG(R200_REG_SE_VAP_CNTL,
+ R200_VAP_FORCE_W_TO_ONE |
+ R200_VAP_VF_MAX_VTX_NUM);
+ OUT_REG(R200_REG_RE_AUX_SCISSOR_CNTL, 0);
+ OUT_REG(RADEON_REG_RB3D_DSTCACHE_MODE,
+ RADEON_RB3D_DC_2D_CACHE_AUTOFLUSH |
+ RADEON_RB3D_DC_3D_CACHE_AUTOFLUSH |
+ R200_RB3D_DC_2D_CACHE_AUTOFREE |
+ R200_RB3D_DC_3D_CACHE_AUTOFREE);
+ END_DMA();
+ }
+ }
+}
+
+static void
+ATIWaitMarker(ScreenPtr pScreen, int marker)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+
+ ENTER_DRAW(0);
+ ATIWaitIdle(atis);
+ LEAVE_DRAW(0);
+}
+
+void
+RadeonSwitchTo2D(ATIScreenInfo *atis)
+{
+ RING_LOCALS;
+
+ ENTER_DRAW(0);
+ BEGIN_DMA(4);
+ OUT_REG(RADEON_REG_RB3D_DSTCACHE_CTLSTAT, RADEON_RB3D_DC_FLUSH);
+ OUT_REG(ATI_REG_WAIT_UNTIL,
+ RADEON_WAIT_HOST_IDLECLEAN | RADEON_WAIT_3D_IDLECLEAN);
+ END_DMA();
+ LEAVE_DRAW(0);
+}
+
+void
+RadeonSwitchTo3D(ATIScreenInfo *atis)
+{
+ RING_LOCALS;
+
+ ENTER_DRAW(0);
+ BEGIN_DMA(4);
+ OUT_REG(RADEON_REG_RB3D_DSTCACHE_CTLSTAT, RADEON_RB3D_DC_FLUSH);
+ /* We must wait for 3d to idle, in case source was just written as a dest. */
+ OUT_REG(ATI_REG_WAIT_UNTIL,
+ RADEON_WAIT_HOST_IDLECLEAN | RADEON_WAIT_2D_IDLECLEAN | RADEON_WAIT_3D_IDLECLEAN);
+ END_DMA();
+ LEAVE_DRAW(0);
+}
+
+#if ATI_TRACE_DRAW
+void
+ATIEnterDraw (PixmapPtr pPix, char *function)
+{
+ if (pPix != NULL) {
+ KdScreenPriv(pPix->drawable.pScreen);
+ CARD32 offset;
+
+ offset = ((CARD8 *)pPix->devPrivate.ptr -
+ pScreenPriv->screen->memory_base);
+
+ ErrorF ("Enter %s 0x%x (%dx%dx%d/%d)\n", function, offset,
+ pPix->drawable.width, pPix->drawable.height, pPix->drawable.depth,
+ pPix->drawable.bitsPerPixel);
+ } else
+ ErrorF ("Enter %s\n", function);
+}
+
+void
+ATILeaveDraw (PixmapPtr pPix, char *function)
+{
+ if (pPix != NULL) {
+ KdScreenPriv(pPix->drawable.pScreen);
+ CARD32 offset;
+
+ offset = ((CARD8 *)pPix->devPrivate.ptr -
+ pScreenPriv->screen->memory_base);
+
+ ErrorF ("Leave %s 0x%x\n", function, offset);
+ } else
+ ErrorF ("Leave %s\n", function);
+}
+#endif
+
+/* Assumes that depth 15 and 16 can be used as depth 16, which is okay since we
+ * require src and dest datatypes to be equal.
+ */
+static Bool
+ATIGetDatatypeBpp(int bpp, CARD32 *type)
+{
+ switch (bpp) {
+ case 8:
+ *type = R128_DATATYPE_CI8;
+ return TRUE;
+ case 16:
+ *type = R128_DATATYPE_RGB565;
+ return TRUE;
+ case 24:
+ *type = R128_DATATYPE_CI8;
+ return TRUE;
+ case 32:
+ *type = R128_DATATYPE_ARGB8888;
+ return TRUE;
+ default:
+ ATI_FALLBACK(("Unsupported bpp: %d\n", bpp));
+ return FALSE;
+ }
+}
+
+Bool
+ATIGetOffsetPitch(ATIScreenInfo *atis, int bpp, CARD32 *pitch_offset,
+ int offset, int pitch)
+{
+ ATICardInfo *atic = atis->atic;
+
+ /* On the R128, depending on the bpp the screen can be set up so that it
+ * doesn't meet the pitchAlign requirement but can still be
+ * accelerated, so we check the specific pitch requirement of alignment
+ * to 8 pixels.
+ */
+ if (atic->is_radeon) {
+ if (pitch % atis->kaa.pitchAlign != 0)
+ ATI_FALLBACK(("Bad pitch 0x%08x\n", pitch));
+ *pitch_offset = ((pitch >> 6) << 22) | (offset >> 10);
+
+ } else {
+ if (pitch % bpp != 0)
+ ATI_FALLBACK(("Bad pitch 0x%08x\n", pitch));
+ *pitch_offset = ((pitch / bpp) << 21) | (offset >> 5);
+ }
+
+ if (offset % atis->kaa.offsetAlign != 0)
+ ATI_FALLBACK(("Bad offset 0x%08x\n", offset));
+
+ return TRUE;
+}
+
+Bool
+ATIGetPixmapOffsetPitch(PixmapPtr pPix, CARD32 *pitch_offset)
+{
+ KdScreenPriv(pPix->drawable.pScreen);
+ ATIScreenInfo(pScreenPriv);
+ CARD32 pitch, offset;
+ int bpp;
+
+ bpp = pPix->drawable.bitsPerPixel;
+ if (bpp == 24)
+ bpp = 8;
+
+ offset = ((CARD8 *)pPix->devPrivate.ptr -
+ pScreenPriv->screen->memory_base);
+ pitch = pPix->devKind;
+
+ return ATIGetOffsetPitch(atis, bpp, pitch_offset, offset, pitch);
+}
+
+static Bool
+ATIPrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg)
+{
+ KdScreenPriv(pPix->drawable.pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICardInfo(pScreenPriv);
+ CARD32 datatype;
+ RING_LOCALS;
+
+ is_24bpp = (pPix->drawable.bitsPerPixel == 24);
+ accel_atis = atis;
+
+ if (is_24bpp) {
+ /* Solid fills in fake-24bpp mode only work if the pixel color
+ * and planemask are all the same byte.
+ */
+ if ((fg & 0xffffff) != (((fg & 0xff) << 16) | ((fg >> 8) &
+ 0xffff)))
+ ATI_FALLBACK(("Can't do solid color 0x%08x in 24bpp\n",
+ fg));
+ if ((pm & 0xffffff) != (((pm & 0xff) << 16) | ((pm >> 8) &
+ 0xffff)))
+ ATI_FALLBACK(("Can't do planemask 0x%08x in 24bpp\n",
+ pm));
+ }
+
+ if (!ATIGetDatatypeBpp(pPix->drawable.bitsPerPixel, &datatype))
+ return FALSE;
+ if (!ATIGetPixmapOffsetPitch(pPix, &dst_pitch_offset))
+ return FALSE;
+
+ ENTER_DRAW(pPix);
+
+ if (atic->is_radeon)
+ RadeonSwitchTo2D(atis);
+
+ settings =
+ ATI_GMC_DST_PITCH_OFFSET_CNTL |
+ ATI_GMC_BRUSH_SOLID_COLOR |
+ (datatype << 8) |
+ ATI_GMC_SRC_DATATYPE_COLOR |
+ (ATISolidRop[alu] << 16) |
+ ATI_GMC_CLR_CMP_CNTL_DIS |
+ R128_GMC_AUX_CLIP_DIS;
+ color = fg;
+
+#if DRAW_USING_PACKET3
+ BEGIN_DMA(6);
+ OUT_REG(ATI_REG_DEFAULT_SC_BOTTOM_RIGHT,
+ ATI_DEFAULT_SC_RIGHT_MAX | ATI_DEFAULT_SC_BOTTOM_MAX);
+ OUT_REG(ATI_REG_DP_WRITE_MASK, pm);
+ OUT_REG(ATI_REG_DP_CNTL, ATI_DST_X_LEFT_TO_RIGHT |
+ ATI_DST_Y_TOP_TO_BOTTOM);
+ END_DMA();
+#else
+ BEGIN_DMA(12);
+ OUT_REG(ATI_REG_DEFAULT_SC_BOTTOM_RIGHT,
+ ATI_DEFAULT_SC_RIGHT_MAX | ATI_DEFAULT_SC_BOTTOM_MAX);
+ OUT_REG(ATI_REG_DST_PITCH_OFFSET, dst_pitch_offset);
+ OUT_REG(ATI_REG_DP_GUI_MASTER_CNTL, settings);
+ OUT_REG(ATI_REG_DP_BRUSH_FRGD_CLR, fg);
+ OUT_REG(ATI_REG_DP_WRITE_MASK, pm);
+ OUT_REG(ATI_REG_DP_CNTL, ATI_DST_X_LEFT_TO_RIGHT |
+ ATI_DST_Y_TOP_TO_BOTTOM);
+ END_DMA();
+#endif
+
+ LEAVE_DRAW(pPix);
+ return TRUE;
+}
+
+static void
+ATISolid(int x1, int y1, int x2, int y2)
+{
+ ENTER_DRAW(0);
+ ATIScreenInfo *atis = accel_atis;
+ RING_LOCALS;
+
+ if (is_24bpp) {
+ x1 *= 3;
+ x2 *= 3;
+ }
+#if DRAW_USING_PACKET3
+ BEGIN_DMA(6);
+ OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_PAINT_MULTI, 5));
+ OUT_RING(settings);
+ OUT_RING(dst_pitch_offset);
+ OUT_RING(color);
+ OUT_RING((x1 << 16) | y1);
+ OUT_RING(((x2 - x1) << 16) | (y2 - y1));
+ END_DMA();
+#else
+ BEGIN_DMA(3);
+ OUT_RING(DMA_PACKET0(ATI_REG_DST_Y_X, 2));
+ OUT_RING_REG(ATI_REG_DST_Y_X, (y1 << 16) | x1);
+ OUT_RING_REG(ATI_REG_DST_HEIGHT_WIDTH, ((y2 - y1) << 16) | (x2 - x1));
+ END_DMA();
+#endif
+ LEAVE_DRAW(0);
+}
+
+static void
+ATIDoneSolid(void)
+{
+ ENTER_DRAW(0);
+ LEAVE_DRAW(0);
+}
+
+static Bool
+ATIPrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu, Pixel pm)
+{
+ KdScreenPriv(pDst->drawable.pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICardInfo(pScreenPriv);
+ CARD32 datatype;
+ RING_LOCALS;
+
+ copydx = dx;
+ copydy = dy;
+ is_24bpp = pDst->drawable.bitsPerPixel == 24;
+ accel_atis = atis;
+
+ if (is_24bpp && ((pm & 0xffffff) != (((pm & 0xff) << 16) | ((pm >> 8) &
+ 0xffff))))
+ ATI_FALLBACK(("Can't do planemask 0x%08x in 24bpp\n", pm));
+
+ if (!ATIGetDatatypeBpp(pDst->drawable.bitsPerPixel, &datatype))
+ return FALSE;
+ if (!ATIGetPixmapOffsetPitch(pSrc, &src_pitch_offset))
+ return FALSE;
+ if (!ATIGetPixmapOffsetPitch(pDst, &dst_pitch_offset))
+ return FALSE;
+
+ ENTER_DRAW (pDst);
+ if (atic->is_radeon)
+ RadeonSwitchTo2D(atis);
+
+ settings =
+ ATI_GMC_SRC_PITCH_OFFSET_CNTL |
+ ATI_GMC_DST_PITCH_OFFSET_CNTL |
+ ATI_GMC_BRUSH_NONE |
+ (datatype << 8) |
+ ATI_GMC_SRC_DATATYPE_COLOR |
+ (ATIBltRop[alu] << 16) |
+ ATI_DP_SRC_SOURCE_MEMORY |
+ ATI_GMC_CLR_CMP_CNTL_DIS |
+ R128_GMC_AUX_CLIP_DIS;
+
+#if DRAW_USING_PACKET3
+ BEGIN_DMA(6);
+ OUT_REG(ATI_REG_DEFAULT_SC_BOTTOM_RIGHT,
+ ATI_DEFAULT_SC_RIGHT_MAX | ATI_DEFAULT_SC_BOTTOM_MAX);
+ OUT_REG(ATI_REG_DP_WRITE_MASK, pm);
+ OUT_REG(ATI_REG_DP_CNTL,
+ (dx >= 0 ? ATI_DST_X_LEFT_TO_RIGHT : 0) |
+ (dy >= 0 ? ATI_DST_Y_TOP_TO_BOTTOM : 0));
+ END_DMA();
+
+#else
+ BEGIN_DMA(12);
+ OUT_REG(ATI_REG_DEFAULT_SC_BOTTOM_RIGHT,
+ ATI_DEFAULT_SC_RIGHT_MAX | ATI_DEFAULT_SC_BOTTOM_MAX);
+ OUT_REG(ATI_REG_SRC_PITCH_OFFSET, src_pitch_offset);
+ OUT_REG(ATI_REG_DST_PITCH_OFFSET, dst_pitch_offset);
+ OUT_REG(ATI_REG_DP_GUI_MASTER_CNTL, settings);
+ OUT_REG(ATI_REG_DP_WRITE_MASK, pm);
+ OUT_REG(ATI_REG_DP_CNTL,
+ (dx >= 0 ? ATI_DST_X_LEFT_TO_RIGHT : 0) |
+ (dy >= 0 ? ATI_DST_Y_TOP_TO_BOTTOM : 0));
+ END_DMA();
+#endif
+ LEAVE_DRAW(pDst);
+
+ return TRUE;
+}
+
+static void
+ATICopy(int srcX, int srcY, int dstX, int dstY, int w, int h)
+{
+ ATIScreenInfo *atis = accel_atis;
+ RING_LOCALS;
+
+ if (is_24bpp) {
+ srcX *= 3;
+ dstX *= 3;
+ w *= 3;
+ }
+
+#if !DRAW_USING_PACKET3
+ if (copydx < 0) {
+ srcX += w - 1;
+ dstX += w - 1;
+ }
+
+ if (copydy < 0) {
+ srcY += h - 1;
+ dstY += h - 1;
+ }
+#endif
+
+#if DRAW_USING_PACKET3
+ BEGIN_DMA(7);
+ OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_BITBLT_MULTI, 6));
+ OUT_RING(settings);
+ OUT_RING(src_pitch_offset);
+ OUT_RING(dst_pitch_offset);
+ OUT_RING((srcX << 16) | srcY);
+ OUT_RING((dstX << 16) | dstY);
+ OUT_RING((w << 16) | h);
+ END_DMA();
+#else
+ BEGIN_DMA(4);
+ OUT_RING(DMA_PACKET0(ATI_REG_SRC_Y_X, 3));
+ OUT_RING_REG(ATI_REG_SRC_Y_X, (srcY << 16) | srcX);
+ OUT_RING_REG(ATI_REG_DST_Y_X, (dstY << 16) | dstX);
+ OUT_RING_REG(ATI_REG_DST_HEIGHT_WIDTH, (h << 16) | w);
+ END_DMA();
+#endif
+}
+
+static void
+ATIDoneCopy(void)
+{
+}
+
+static Bool
+ATIUploadToScreen(PixmapPtr pDst, char *src, int src_pitch)
+{
+ ScreenPtr pScreen = pDst->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICardInfo(pScreenPriv);
+ int width, height, bpp, i, dwords;
+ int dst_pitch, dst_offset;
+ CARD32 dst_pitch_offset, datatype;
+ Bool success;
+ RING_LOCALS;
+
+ ENTER_DRAW (pDst);
+
+ LEAVE_DRAW (pDst);
+ /* XXX: Hostdata uploads aren't working yet. */
+ return FALSE;
+
+ dst_offset = ((CARD8 *)pDst->devPrivate.ptr -
+ pScreenPriv->screen->memory_base);
+ dst_pitch = pDst->devKind;
+ width = pDst->drawable.width;
+ height = pDst->drawable.height;
+ bpp = pDst->drawable.bitsPerPixel;
+
+ success = ATIGetDatatypeBpp(bpp, &datatype);
+
+ if (bpp == 24) {
+ is_24bpp = TRUE;
+ bpp = 8;
+ } else
+ is_24bpp = FALSE;
+
+ if (!ATIGetOffsetPitch(atis, bpp, &dst_pitch_offset, dst_offset,
+ dst_pitch))
+ return FALSE;
+
+ if (src_pitch != (width * bpp / 8))
+ return FALSE;
+
+ /* No PACKET3 packets when in PIO mode. */
+ if (atis->using_pio)
+ return FALSE;
+
+ dwords = (width * height * (bpp / 8) + 3) / 4;
+
+ /* Flush pixel cache so nothing being written to the destination
+ * previously gets mixed up with the hostdata blit.
+ */
+ if (atic->is_radeon) {
+ BEGIN_DMA(4);
+ OUT_REG(RADEON_REG_RB3D_DSTCACHE_CTLSTAT, RADEON_RB3D_DC_FLUSH);
+ OUT_REG(ATI_REG_WAIT_UNTIL,
+ RADEON_WAIT_2D_IDLECLEAN |
+ RADEON_WAIT_3D_IDLECLEAN |
+ RADEON_WAIT_HOST_IDLECLEAN);
+ END_DMA();
+ } else {
+ BEGIN_DMA(2);
+ OUT_REG(R128_REG_PC_GUI_CTLSTAT,
+ R128_PC_FLUSH_GUI | R128_PC_RI_GUI);
+ END_DMA();
+ }
+
+ BEGIN_DMA(8);
+ OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_HOSTDATA_BLT, 7 + dwords));
+ OUT_RING(ATI_GMC_DST_PITCH_OFFSET_CNTL |
+ ATI_GMC_BRUSH_NONE |
+ (datatype << 8) |
+ ATI_GMC_SRC_DATATYPE_COLOR |
+ (ATISolidRop[GXcopy] << 16) |
+ ATI_DP_SRC_SOURCE_HOST_DATA |
+ ATI_GMC_CLR_CMP_CNTL_DIS |
+ R128_GMC_AUX_CLIP_DIS |
+ ATI_GMC_WR_MSK_DIS);
+ OUT_RING(dst_pitch_offset);
+ OUT_RING(0xffffffff);
+ OUT_RING(0xffffffff);
+ OUT_RING((0 << 16) | 0);
+ OUT_RING((height << 16) | width);
+ OUT_RING(dwords);
+ END_DMA();
+
+ for (i = 0; i < dwords; i++) {
+ BEGIN_DMA(1);
+ OUT_RING(((CARD32 *)src)[i]);
+ END_DMA();
+ }
+
+ if (atic->is_radeon) {
+ BEGIN_DMA(4);
+ OUT_REG(RADEON_REG_RB3D_DSTCACHE_CTLSTAT,
+ RADEON_RB3D_DC_FLUSH_ALL);
+ OUT_REG(ATI_REG_WAIT_UNTIL,
+ RADEON_WAIT_2D_IDLECLEAN |
+ RADEON_WAIT_HOST_IDLECLEAN);
+ END_DMA();
+ } else {
+ BEGIN_DMA(2);
+ OUT_REG(R128_REG_PC_GUI_CTLSTAT, R128_PC_FLUSH_GUI);
+ END_DMA();
+ }
+
+ kaaMarkSync(pScreen);
+
+ ErrorF("hostdata upload %d,%d %dbpp\n", width, height, bpp);
+
+ return TRUE;
+}
+
+
+static Bool
+ATIUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst)
+{
+ KdScreenPriv(pSrc->drawable.pScreen);
+ ATICardInfo(pScreenPriv);
+ ATIScreenInfo(pScreenPriv);
+ int dst_pitch, src_pitch, w, i, size, bytes;
+ unsigned char *dst, *src;
+ RING_LOCALS;
+
+ ENTER_DRAW(pSrc);
+ /* Align width to log 2, useful for R128 composite. This should be a
+ * KAA flag we check for (and supported in kaa.c in general) since many
+ * older bits of hardware are going to want POT pitches.
+ */
+ w = pSrc->drawable.width;
+ if (atis->kaa.flags & KAA_OFFSCREEN_ALIGN_POT)
+ w = 1 << (ATILog2(w - 1) + 1);
+ dst_pitch = (w * pSrc->drawable.bitsPerPixel / 8 +
+ atis->kaa.pitchAlign - 1) & ~(atis->kaa.pitchAlign - 1);
+
+ size = dst_pitch * pSrc->drawable.height;
+ if (size > atis->scratch_area->size)
+ ATI_FALLBACK(("Pixmap too large for scratch (%d,%d)\n",
+ pSrc->drawable.width, pSrc->drawable.height));
+
+ atis->scratch_next = (atis->scratch_next + atis->kaa.offsetAlign - 1) &
+ ~(atis->kaa.offsetAlign - 1);
+ if (atis->scratch_next + size > atis->scratch_area->offset +
+ atis->scratch_area->size) {
+ /* Only sync when we've used all of the scratch area. */
+ kaaWaitSync(pSrc->drawable.pScreen);
+ atis->scratch_next = atis->scratch_area->offset;
+ }
+ memcpy(pDst, pSrc, sizeof(*pDst));
+ pDst->devKind = dst_pitch;
+ pDst->devPrivate.ptr = pScreenPriv->screen->memory_base +
+ atis->scratch_next;
+ atis->scratch_next += size;
+
+ src = pSrc->devPrivate.ptr;
+ src_pitch = pSrc->devKind;
+ dst = pDst->devPrivate.ptr;
+ bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;
+
+ i = pSrc->drawable.height;
+ while (i--) {
+ memcpy(dst, src, bytes);
+ dst += dst_pitch;
+ src += src_pitch;
+ }
+
+ /* Flush the pixel cache */
+ if (atic->is_radeon) {
+ BEGIN_DMA(4);
+ OUT_REG(RADEON_REG_RB3D_DSTCACHE_CTLSTAT,
+ RADEON_RB3D_DC_FLUSH_ALL);
+ OUT_REG(ATI_REG_WAIT_UNTIL, RADEON_WAIT_HOST_IDLECLEAN);
+ END_DMA();
+ } else {
+ BEGIN_DMA(2);
+ OUT_REG(R128_REG_PC_GUI_CTLSTAT, R128_PC_FLUSH_ALL);
+ END_DMA();
+ }
+
+ LEAVE_DRAW(pSrc);
+ return TRUE;
+}
+
+static void
+ATIBlockHandler(pointer blockData, OSTimePtr timeout, pointer readmask)
+{
+ ScreenPtr pScreen = (ScreenPtr) blockData;
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+
+ /* When the server is going to sleep, make sure that all DMA data has
+ * been flushed.
+ */
+ if (atis->indirectBuffer)
+ ATIFlushIndirect(atis, 1);
+}
+
+static void
+ATIWakeupHandler(pointer blockData, int result, pointer readmask)
+{
+}
+
+Bool
+ATIDrawInit(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICardInfo(pScreenPriv);
+
+ ErrorF("Screen: %d/%d depth/bpp\n", pScreenPriv->screen->fb[0].depth,
+ pScreenPriv->screen->fb[0].bitsPerPixel);
+
+ RegisterBlockAndWakeupHandlers(ATIBlockHandler, ATIWakeupHandler,
+ pScreen);
+
+#ifdef USE_DRI
+ atis->using_dri = ATIDRIScreenInit(pScreen);
+#endif /* USE_DRI */
+
+ memset(&atis->kaa, 0, sizeof(KaaScreenInfoRec));
+ atis->kaa.waitMarker = ATIWaitMarker;
+ atis->kaa.PrepareSolid = ATIPrepareSolid;
+ atis->kaa.Solid = ATISolid;
+ atis->kaa.DoneSolid = ATIDoneSolid;
+ atis->kaa.PrepareCopy = ATIPrepareCopy;
+ atis->kaa.Copy = ATICopy;
+ atis->kaa.DoneCopy = ATIDoneCopy;
+ /* Other acceleration will be hooked in in DrawEnable depending on
+ * what type of DMA gets initialized.
+ */
+
+ atis->kaa.flags = KAA_OFFSCREEN_PIXMAPS;
+ if (atic->is_radeon) {
+ atis->kaa.offsetAlign = 1024;
+ atis->kaa.pitchAlign = 64;
+ } else {
+ /* Rage 128 compositing wants power-of-two pitches. */
+ atis->kaa.flags |= KAA_OFFSCREEN_ALIGN_POT;
+ atis->kaa.offsetAlign = 32;
+ /* Pitch alignment is in sets of 8 pixels, and we need to cover
+ * 32bpp, so 32 bytes.
+ */
+ atis->kaa.pitchAlign = 32;
+ }
+
+ kaaInitTrapOffsets(8, sample_offsets_x, sample_offsets_y, 0.0, 0.0);
+ sample_count = (1 << 8) - 1;
+
+ if (!kaaDrawInit(pScreen, &atis->kaa))
+ return FALSE;
+
+ return TRUE;
+}
+
+static void
+ATIScratchSave(ScreenPtr pScreen, KdOffscreenArea *area)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+
+ atis->scratch_area = NULL;
+}
+
+void
+ATIDrawEnable(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICardInfo(pScreenPriv);
+
+ ATIDMASetup(pScreen);
+ ATIDrawSetup(pScreen);
+
+ atis->scratch_area = NULL;
+ atis->kaa.PrepareBlend = NULL;
+ atis->kaa.Blend = NULL;
+ atis->kaa.DoneBlend = NULL;
+ atis->kaa.CheckComposite = NULL;
+ atis->kaa.PrepareComposite = NULL;
+ atis->kaa.Composite = NULL;
+ atis->kaa.DoneComposite = NULL;
+ atis->kaa.UploadToScreen = NULL;
+ atis->kaa.UploadToScratch = NULL;
+
+ /* We can't dispatch 3d commands in PIO mode. */
+ if (!atis->using_pio) {
+ if (!atic->is_radeon) {
+ atis->kaa.CheckComposite = R128CheckComposite;
+ atis->kaa.PrepareComposite = R128PrepareComposite;
+ atis->kaa.Composite = R128Composite;
+ atis->kaa.DoneComposite = R128DoneComposite;
+ } else if (atic->is_r100) {
+ atis->kaa.CheckComposite = R100CheckComposite;
+ atis->kaa.PrepareComposite = R100PrepareComposite;
+ atis->kaa.Composite = RadeonComposite;
+ atis->kaa.DoneComposite = RadeonDoneComposite;
+ } else if (atic->is_r200) {
+ atis->kaa.CheckComposite = R200CheckComposite;
+ atis->kaa.PrepareComposite = R200PrepareComposite;
+ atis->kaa.Composite = RadeonComposite;
+ atis->kaa.DoneComposite = RadeonDoneComposite;
+ }
+ }
+#ifdef USE_DRI
+ if (atis->using_dri) {
+ if (!atic->is_radeon) {
+ /*atis->kaa.PrepareTrapezoids = R128PrepareTrapezoids;
+ atis->kaa.Trapezoids = R128Trapezoids;
+ atis->kaa.DoneTrapezoids = R128DoneTrapezoids;*/
+ } else if (atic->is_r100 || atic->is_r200) {
+ atis->kaa.PrepareTrapezoids = RadeonPrepareTrapezoids;
+ atis->kaa.Trapezoids = RadeonTrapezoids;
+ atis->kaa.DoneTrapezoids = RadeonDoneTrapezoids;
+ }
+ }
+#endif /* USE_DRI */
+
+ atis->kaa.UploadToScreen = ATIUploadToScreen;
+
+ /* Reserve a scratch area. It'll be used for storing glyph data during
+ * Composite operations, because glyphs aren't in real pixmaps and thus
+ * can't be migrated.
+ */
+ atis->scratch_area = KdOffscreenAlloc(pScreen, 131072,
+ atis->kaa.offsetAlign, TRUE, ATIScratchSave, atis);
+ if (atis->scratch_area != NULL) {
+ atis->scratch_next = atis->scratch_area->offset;
+ atis->kaa.UploadToScratch = ATIUploadToScratch;
+ }
+
+ kaaMarkSync(pScreen);
+}
+
+void
+ATIDrawDisable(ScreenPtr pScreen)
+{
+ kaaWaitSync(pScreen);
+ ATIDMATeardown(pScreen);
+}
+
+void
+ATIDrawFini(ScreenPtr pScreen)
+{
+#ifdef USE_DRI
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ if (atis->using_dri) {
+ ATIDRICloseScreen(pScreen);
+ atis->using_dri = FALSE;
+ }
+#endif /* USE_DRI */
+
+ RemoveBlockAndWakeupHandlers(ATIBlockHandler, ATIWakeupHandler,
+ pScreen);
+
+ kaaDrawFini(pScreen);
+}
+
diff --git a/xorg-server/hw/kdrive/ati/ati_draw.h b/xorg-server/hw/kdrive/ati/ati_draw.h
new file mode 100644
index 000000000..98a130a7b
--- /dev/null
+++ b/xorg-server/hw/kdrive/ati/ati_draw.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright © 2004 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _ATI_DRAW_H_
+#define _ATI_DRAW_H_
+
+Bool ATIGetOffsetPitch(ATIScreenInfo *atis, int bpp, CARD32 *pitch_offset,
+ int offset, int pitch);
+Bool ATIGetPixmapOffsetPitch(PixmapPtr pPix, CARD32 *pitch_offset);
+
+Bool R128CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture);
+Bool R128PrepareComposite(int op, PicturePtr pSrcPicture,
+ PicturePtr pMaskPicture, PicturePtr pDstPicture, PixmapPtr pSrc,
+ PixmapPtr pMask, PixmapPtr pDst);
+void R128Composite(int srcX, int srcY, int maskX, int maskY, int dstX, int dstY,
+ int w, int h);
+void R128DoneComposite(void);
+
+Bool R128PrepareTrapezoids(PicturePtr pDstPicture, PixmapPtr pDst);
+void R128Trapezoids(KaaTrapezoid *traps, int ntraps);
+void R128DoneTrapezoids(void);
+
+Bool R100CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture);
+Bool R100PrepareComposite(int op, PicturePtr pSrcPicture,
+ PicturePtr pMaskPicture, PicturePtr pDstPicture, PixmapPtr pSrc,
+ PixmapPtr pMask, PixmapPtr pDst);
+Bool R200CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture);
+Bool R200PrepareComposite(int op, PicturePtr pSrcPicture,
+ PicturePtr pMaskPicture, PicturePtr pDstPicture, PixmapPtr pSrc,
+ PixmapPtr pMask, PixmapPtr pDst);
+void RadeonComposite(int srcX, int srcY, int maskX, int maskY, int dstX,
+ int dstY, int w, int h);
+void RadeonDoneComposite(void);
+
+Bool RadeonPrepareTrapezoids(PicturePtr pDstPicture, PixmapPtr pDst);
+void RadeonTrapezoids(KaaTrapezoid *traps, int ntraps);
+void RadeonDoneTrapezoids(void);
+
+void RadeonSwitchTo2D(ATIScreenInfo *atis);
+void RadeonSwitchTo3D(ATIScreenInfo *atis);
+void ATIWaitIdle(ATIScreenInfo *atis);
+
+#define ATI_TRACE_FALL 0
+#define ATI_TRACE_DRAW 0
+
+#if ATI_TRACE_FALL
+#define ATI_FALLBACK(x) \
+do { \
+ ErrorF("%s: ", __FUNCTION__); \
+ ErrorF x; \
+ return FALSE; \
+} while (0)
+#else
+#define ATI_FALLBACK(x) return FALSE
+#endif
+
+#if ATI_TRACE_DRAW
+#define ENTER_DRAW(pix) ATIEnterDraw(pix, __FUNCTION__)
+#define LEAVE_DRAW(pix) ATILeaveDraw(pix, __FUNCTION__)
+
+void
+ATIEnterDraw (PixmapPtr pPixmap, char *function);
+
+void
+ATILeaveDraw (PixmapPtr pPixmap, char *function);
+#else /* ATI_TRACE */
+#define ENTER_DRAW(pix)
+#define LEAVE_DRAW(pix)
+#endif /* !ATI_TRACE */
+
+#endif /* _ATI_DRAW_H_ */
diff --git a/xorg-server/hw/kdrive/ati/ati_microcode.c b/xorg-server/hw/kdrive/ati/ati_microcode.c
new file mode 100644
index 000000000..f8829e823
--- /dev/null
+++ b/xorg-server/hw/kdrive/ati/ati_microcode.c
@@ -0,0 +1,857 @@
+/* r128_cce.c -- ATI Rage 128 driver -*- linux-c -*-
+ * radeon_cp.c -- CP support for Radeon -*- linux-c -*-
+ *
+ * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
+/* CCE microcode (from ATI) */
+
+#include "ati.h"
+
+CARD32 r128_cce_microcode[] = {
+ 0, 276838400, 0, 268449792, 2, 142, 2, 145, 0, 1076765731, 0,
+ 1617039951, 0, 774592877, 0, 1987540286, 0, 2307490946U, 0,
+ 599558925, 0, 589505315, 0, 596487092, 0, 589505315, 1,
+ 11544576, 1, 206848, 1, 311296, 1, 198656, 2, 912273422, 11,
+ 262144, 0, 0, 1, 33559837, 1, 7438, 1, 14809, 1, 6615, 12, 28,
+ 1, 6614, 12, 28, 2, 23, 11, 18874368, 0, 16790922, 1, 409600, 9,
+ 30, 1, 147854772, 16, 420483072, 3, 8192, 0, 10240, 1, 198656,
+ 1, 15630, 1, 51200, 10, 34858, 9, 42, 1, 33559823, 2, 10276, 1,
+ 15717, 1, 15718, 2, 43, 1, 15936948, 1, 570480831, 1, 14715071,
+ 12, 322123831, 1, 33953125, 12, 55, 1, 33559908, 1, 15718, 2,
+ 46, 4, 2099258, 1, 526336, 1, 442623, 4, 4194365, 1, 509952, 1,
+ 459007, 3, 0, 12, 92, 2, 46, 12, 176, 1, 15734, 1, 206848, 1,
+ 18432, 1, 133120, 1, 100670734, 1, 149504, 1, 165888, 1,
+ 15975928, 1, 1048576, 6, 3145806, 1, 15715, 16, 2150645232U, 2,
+ 268449859, 2, 10307, 12, 176, 1, 15734, 1, 15735, 1, 15630, 1,
+ 15631, 1, 5253120, 6, 3145810, 16, 2150645232U, 1, 15864, 2, 82,
+ 1, 343310, 1, 1064207, 2, 3145813, 1, 15728, 1, 7817, 1, 15729,
+ 3, 15730, 12, 92, 2, 98, 1, 16168, 1, 16167, 1, 16002, 1, 16008,
+ 1, 15974, 1, 15975, 1, 15990, 1, 15976, 1, 15977, 1, 15980, 0,
+ 15981, 1, 10240, 1, 5253120, 1, 15720, 1, 198656, 6, 110, 1,
+ 180224, 1, 103824738, 2, 112, 2, 3145839, 0, 536885440, 1,
+ 114880, 14, 125, 12, 206975, 1, 33559995, 12, 198784, 0,
+ 33570236, 1, 15803, 0, 15804, 3, 294912, 1, 294912, 3, 442370,
+ 1, 11544576, 0, 811612160, 1, 12593152, 1, 11536384, 1,
+ 14024704, 7, 310382726, 0, 10240, 1, 14796, 1, 14797, 1, 14793,
+ 1, 14794, 0, 14795, 1, 268679168, 1, 9437184, 1, 268449792, 1,
+ 198656, 1, 9452827, 1, 1075854602, 1, 1075854603, 1, 557056, 1,
+ 114880, 14, 159, 12, 198784, 1, 1109409213, 12, 198783, 1,
+ 1107312059, 12, 198784, 1, 1109409212, 2, 162, 1, 1075854781, 1,
+ 1073757627, 1, 1075854780, 1, 540672, 1, 10485760, 6, 3145894,
+ 16, 274741248, 9, 168, 3, 4194304, 3, 4209949, 0, 0, 0, 256, 14,
+ 174, 1, 114857, 1, 33560007, 12, 176, 0, 10240, 1, 114858, 1,
+ 33560018, 1, 114857, 3, 33560007, 1, 16008, 1, 114874, 1,
+ 33560360, 1, 114875, 1, 33560154, 0, 15963, 0, 256, 0, 4096, 1,
+ 409611, 9, 188, 0, 10240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+CARD32 radeon_cp_microcode[][2] = {
+ { 0x21007000, 0000000000 },
+ { 0x20007000, 0000000000 },
+ { 0x000000b4, 0x00000004 },
+ { 0x000000b8, 0x00000004 },
+ { 0x6f5b4d4c, 0000000000 },
+ { 0x4c4c427f, 0000000000 },
+ { 0x5b568a92, 0000000000 },
+ { 0x4ca09c6d, 0000000000 },
+ { 0xad4c4c4c, 0000000000 },
+ { 0x4ce1af3d, 0000000000 },
+ { 0xd8afafaf, 0000000000 },
+ { 0xd64c4cdc, 0000000000 },
+ { 0x4cd10d10, 0000000000 },
+ { 0x000f0000, 0x00000016 },
+ { 0x362f242d, 0000000000 },
+ { 0x00000012, 0x00000004 },
+ { 0x000f0000, 0x00000016 },
+ { 0x362f282d, 0000000000 },
+ { 0x000380e7, 0x00000002 },
+ { 0x04002c97, 0x00000002 },
+ { 0x000f0001, 0x00000016 },
+ { 0x333a3730, 0000000000 },
+ { 0x000077ef, 0x00000002 },
+ { 0x00061000, 0x00000002 },
+ { 0x00000021, 0x0000001a },
+ { 0x00004000, 0x0000001e },
+ { 0x00061000, 0x00000002 },
+ { 0x00000021, 0x0000001a },
+ { 0x00004000, 0x0000001e },
+ { 0x00061000, 0x00000002 },
+ { 0x00000021, 0x0000001a },
+ { 0x00004000, 0x0000001e },
+ { 0x00000017, 0x00000004 },
+ { 0x0003802b, 0x00000002 },
+ { 0x040067e0, 0x00000002 },
+ { 0x00000017, 0x00000004 },
+ { 0x000077e0, 0x00000002 },
+ { 0x00065000, 0x00000002 },
+ { 0x000037e1, 0x00000002 },
+ { 0x040067e1, 0x00000006 },
+ { 0x000077e0, 0x00000002 },
+ { 0x000077e1, 0x00000002 },
+ { 0x000077e1, 0x00000006 },
+ { 0xffffffff, 0000000000 },
+ { 0x10000000, 0000000000 },
+ { 0x0003802b, 0x00000002 },
+ { 0x040067e0, 0x00000006 },
+ { 0x00007675, 0x00000002 },
+ { 0x00007676, 0x00000002 },
+ { 0x00007677, 0x00000002 },
+ { 0x00007678, 0x00000006 },
+ { 0x0003802c, 0x00000002 },
+ { 0x04002676, 0x00000002 },
+ { 0x00007677, 0x00000002 },
+ { 0x00007678, 0x00000006 },
+ { 0x0000002f, 0x00000018 },
+ { 0x0000002f, 0x00000018 },
+ { 0000000000, 0x00000006 },
+ { 0x00000030, 0x00000018 },
+ { 0x00000030, 0x00000018 },
+ { 0000000000, 0x00000006 },
+ { 0x01605000, 0x00000002 },
+ { 0x00065000, 0x00000002 },
+ { 0x00098000, 0x00000002 },
+ { 0x00061000, 0x00000002 },
+ { 0x64c0603e, 0x00000004 },
+ { 0x000380e6, 0x00000002 },
+ { 0x040025c5, 0x00000002 },
+ { 0x00080000, 0x00000016 },
+ { 0000000000, 0000000000 },
+ { 0x0400251d, 0x00000002 },
+ { 0x00007580, 0x00000002 },
+ { 0x00067581, 0x00000002 },
+ { 0x04002580, 0x00000002 },
+ { 0x00067581, 0x00000002 },
+ { 0x00000049, 0x00000004 },
+ { 0x00005000, 0000000000 },
+ { 0x000380e6, 0x00000002 },
+ { 0x040025c5, 0x00000002 },
+ { 0x00061000, 0x00000002 },
+ { 0x0000750e, 0x00000002 },
+ { 0x00019000, 0x00000002 },
+ { 0x00011055, 0x00000014 },
+ { 0x00000055, 0x00000012 },
+ { 0x0400250f, 0x00000002 },
+ { 0x0000504f, 0x00000004 },
+ { 0x000380e6, 0x00000002 },
+ { 0x040025c5, 0x00000002 },
+ { 0x00007565, 0x00000002 },
+ { 0x00007566, 0x00000002 },
+ { 0x00000058, 0x00000004 },
+ { 0x000380e6, 0x00000002 },
+ { 0x040025c5, 0x00000002 },
+ { 0x01e655b4, 0x00000002 },
+ { 0x4401b0e4, 0x00000002 },
+ { 0x01c110e4, 0x00000002 },
+ { 0x26667066, 0x00000018 },
+ { 0x040c2565, 0x00000002 },
+ { 0x00000066, 0x00000018 },
+ { 0x04002564, 0x00000002 },
+ { 0x00007566, 0x00000002 },
+ { 0x0000005d, 0x00000004 },
+ { 0x00401069, 0x00000008 },
+ { 0x00101000, 0x00000002 },
+ { 0x000d80ff, 0x00000002 },
+ { 0x0080006c, 0x00000008 },
+ { 0x000f9000, 0x00000002 },
+ { 0x000e00ff, 0x00000002 },
+ { 0000000000, 0x00000006 },
+ { 0x0000008f, 0x00000018 },
+ { 0x0000005b, 0x00000004 },
+ { 0x000380e6, 0x00000002 },
+ { 0x040025c5, 0x00000002 },
+ { 0x00007576, 0x00000002 },
+ { 0x00065000, 0x00000002 },
+ { 0x00009000, 0x00000002 },
+ { 0x00041000, 0x00000002 },
+ { 0x0c00350e, 0x00000002 },
+ { 0x00049000, 0x00000002 },
+ { 0x00051000, 0x00000002 },
+ { 0x01e785f8, 0x00000002 },
+ { 0x00200000, 0x00000002 },
+ { 0x0060007e, 0x0000000c },
+ { 0x00007563, 0x00000002 },
+ { 0x006075f0, 0x00000021 },
+ { 0x20007073, 0x00000004 },
+ { 0x00005073, 0x00000004 },
+ { 0x000380e6, 0x00000002 },
+ { 0x040025c5, 0x00000002 },
+ { 0x00007576, 0x00000002 },
+ { 0x00007577, 0x00000002 },
+ { 0x0000750e, 0x00000002 },
+ { 0x0000750f, 0x00000002 },
+ { 0x00a05000, 0x00000002 },
+ { 0x00600083, 0x0000000c },
+ { 0x006075f0, 0x00000021 },
+ { 0x000075f8, 0x00000002 },
+ { 0x00000083, 0x00000004 },
+ { 0x000a750e, 0x00000002 },
+ { 0x000380e6, 0x00000002 },
+ { 0x040025c5, 0x00000002 },
+ { 0x0020750f, 0x00000002 },
+ { 0x00600086, 0x00000004 },
+ { 0x00007570, 0x00000002 },
+ { 0x00007571, 0x00000002 },
+ { 0x00007572, 0x00000006 },
+ { 0x000380e6, 0x00000002 },
+ { 0x040025c5, 0x00000002 },
+ { 0x00005000, 0x00000002 },
+ { 0x00a05000, 0x00000002 },
+ { 0x00007568, 0x00000002 },
+ { 0x00061000, 0x00000002 },
+ { 0x00000095, 0x0000000c },
+ { 0x00058000, 0x00000002 },
+ { 0x0c607562, 0x00000002 },
+ { 0x00000097, 0x00000004 },
+ { 0x000380e6, 0x00000002 },
+ { 0x040025c5, 0x00000002 },
+ { 0x00600096, 0x00000004 },
+ { 0x400070e5, 0000000000 },
+ { 0x000380e6, 0x00000002 },
+ { 0x040025c5, 0x00000002 },
+ { 0x000380e5, 0x00000002 },
+ { 0x000000a8, 0x0000001c },
+ { 0x000650aa, 0x00000018 },
+ { 0x040025bb, 0x00000002 },
+ { 0x000610ab, 0x00000018 },
+ { 0x040075bc, 0000000000 },
+ { 0x000075bb, 0x00000002 },
+ { 0x000075bc, 0000000000 },
+ { 0x00090000, 0x00000006 },
+ { 0x00090000, 0x00000002 },
+ { 0x000d8002, 0x00000006 },
+ { 0x00007832, 0x00000002 },
+ { 0x00005000, 0x00000002 },
+ { 0x000380e7, 0x00000002 },
+ { 0x04002c97, 0x00000002 },
+ { 0x00007820, 0x00000002 },
+ { 0x00007821, 0x00000002 },
+ { 0x00007800, 0000000000 },
+ { 0x01200000, 0x00000002 },
+ { 0x20077000, 0x00000002 },
+ { 0x01200000, 0x00000002 },
+ { 0x20007000, 0x00000002 },
+ { 0x00061000, 0x00000002 },
+ { 0x0120751b, 0x00000002 },
+ { 0x8040750a, 0x00000002 },
+ { 0x8040750b, 0x00000002 },
+ { 0x00110000, 0x00000002 },
+ { 0x000380e5, 0x00000002 },
+ { 0x000000c6, 0x0000001c },
+ { 0x000610ab, 0x00000018 },
+ { 0x844075bd, 0x00000002 },
+ { 0x000610aa, 0x00000018 },
+ { 0x840075bb, 0x00000002 },
+ { 0x000610ab, 0x00000018 },
+ { 0x844075bc, 0x00000002 },
+ { 0x000000c9, 0x00000004 },
+ { 0x804075bd, 0x00000002 },
+ { 0x800075bb, 0x00000002 },
+ { 0x804075bc, 0x00000002 },
+ { 0x00108000, 0x00000002 },
+ { 0x01400000, 0x00000002 },
+ { 0x006000cd, 0x0000000c },
+ { 0x20c07000, 0x00000020 },
+ { 0x000000cf, 0x00000012 },
+ { 0x00800000, 0x00000006 },
+ { 0x0080751d, 0x00000006 },
+ { 0000000000, 0000000000 },
+ { 0x0000775c, 0x00000002 },
+ { 0x00a05000, 0x00000002 },
+ { 0x00661000, 0x00000002 },
+ { 0x0460275d, 0x00000020 },
+ { 0x00004000, 0000000000 },
+ { 0x01e00830, 0x00000002 },
+ { 0x21007000, 0000000000 },
+ { 0x6464614d, 0000000000 },
+ { 0x69687420, 0000000000 },
+ { 0x00000073, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0x00005000, 0x00000002 },
+ { 0x000380d0, 0x00000002 },
+ { 0x040025e0, 0x00000002 },
+ { 0x000075e1, 0000000000 },
+ { 0x00000001, 0000000000 },
+ { 0x000380e0, 0x00000002 },
+ { 0x04002394, 0x00000002 },
+ { 0x00005000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0x00000008, 0000000000 },
+ { 0x00000004, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+};
+
+CARD32 r200_cp_microcode[][2] = {
+ { 0x21007000, 0000000000 },
+ { 0x20007000, 0000000000 },
+ { 0x000000ab, 0x00000004 },
+ { 0x000000af, 0x00000004 },
+ { 0x66544a49, 0000000000 },
+ { 0x49494174, 0000000000 },
+ { 0x54517d83, 0000000000 },
+ { 0x498d8b64, 0000000000 },
+ { 0x49494949, 0000000000 },
+ { 0x49da493c, 0000000000 },
+ { 0x49989898, 0000000000 },
+ { 0xd34949d5, 0000000000 },
+ { 0x9dc90e11, 0000000000 },
+ { 0xce9b9b9b, 0000000000 },
+ { 0x000f0000, 0x00000016 },
+ { 0x352e232c, 0000000000 },
+ { 0x00000013, 0x00000004 },
+ { 0x000f0000, 0x00000016 },
+ { 0x352e272c, 0000000000 },
+ { 0x000f0001, 0x00000016 },
+ { 0x3239362f, 0000000000 },
+ { 0x000077ef, 0x00000002 },
+ { 0x00061000, 0x00000002 },
+ { 0x00000020, 0x0000001a },
+ { 0x00004000, 0x0000001e },
+ { 0x00061000, 0x00000002 },
+ { 0x00000020, 0x0000001a },
+ { 0x00004000, 0x0000001e },
+ { 0x00061000, 0x00000002 },
+ { 0x00000020, 0x0000001a },
+ { 0x00004000, 0x0000001e },
+ { 0x00000016, 0x00000004 },
+ { 0x0003802a, 0x00000002 },
+ { 0x040067e0, 0x00000002 },
+ { 0x00000016, 0x00000004 },
+ { 0x000077e0, 0x00000002 },
+ { 0x00065000, 0x00000002 },
+ { 0x000037e1, 0x00000002 },
+ { 0x040067e1, 0x00000006 },
+ { 0x000077e0, 0x00000002 },
+ { 0x000077e1, 0x00000002 },
+ { 0x000077e1, 0x00000006 },
+ { 0xffffffff, 0000000000 },
+ { 0x10000000, 0000000000 },
+ { 0x0003802a, 0x00000002 },
+ { 0x040067e0, 0x00000006 },
+ { 0x00007675, 0x00000002 },
+ { 0x00007676, 0x00000002 },
+ { 0x00007677, 0x00000002 },
+ { 0x00007678, 0x00000006 },
+ { 0x0003802b, 0x00000002 },
+ { 0x04002676, 0x00000002 },
+ { 0x00007677, 0x00000002 },
+ { 0x00007678, 0x00000006 },
+ { 0x0000002e, 0x00000018 },
+ { 0x0000002e, 0x00000018 },
+ { 0000000000, 0x00000006 },
+ { 0x0000002f, 0x00000018 },
+ { 0x0000002f, 0x00000018 },
+ { 0000000000, 0x00000006 },
+ { 0x01605000, 0x00000002 },
+ { 0x00065000, 0x00000002 },
+ { 0x00098000, 0x00000002 },
+ { 0x00061000, 0x00000002 },
+ { 0x64c0603d, 0x00000004 },
+ { 0x00080000, 0x00000016 },
+ { 0000000000, 0000000000 },
+ { 0x0400251d, 0x00000002 },
+ { 0x00007580, 0x00000002 },
+ { 0x00067581, 0x00000002 },
+ { 0x04002580, 0x00000002 },
+ { 0x00067581, 0x00000002 },
+ { 0x00000046, 0x00000004 },
+ { 0x00005000, 0000000000 },
+ { 0x00061000, 0x00000002 },
+ { 0x0000750e, 0x00000002 },
+ { 0x00019000, 0x00000002 },
+ { 0x00011055, 0x00000014 },
+ { 0x00000055, 0x00000012 },
+ { 0x0400250f, 0x00000002 },
+ { 0x0000504a, 0x00000004 },
+ { 0x00007565, 0x00000002 },
+ { 0x00007566, 0x00000002 },
+ { 0x00000051, 0x00000004 },
+ { 0x01e655b4, 0x00000002 },
+ { 0x4401b0dc, 0x00000002 },
+ { 0x01c110dc, 0x00000002 },
+ { 0x2666705d, 0x00000018 },
+ { 0x040c2565, 0x00000002 },
+ { 0x0000005d, 0x00000018 },
+ { 0x04002564, 0x00000002 },
+ { 0x00007566, 0x00000002 },
+ { 0x00000054, 0x00000004 },
+ { 0x00401060, 0x00000008 },
+ { 0x00101000, 0x00000002 },
+ { 0x000d80ff, 0x00000002 },
+ { 0x00800063, 0x00000008 },
+ { 0x000f9000, 0x00000002 },
+ { 0x000e00ff, 0x00000002 },
+ { 0000000000, 0x00000006 },
+ { 0x00000080, 0x00000018 },
+ { 0x00000054, 0x00000004 },
+ { 0x00007576, 0x00000002 },
+ { 0x00065000, 0x00000002 },
+ { 0x00009000, 0x00000002 },
+ { 0x00041000, 0x00000002 },
+ { 0x0c00350e, 0x00000002 },
+ { 0x00049000, 0x00000002 },
+ { 0x00051000, 0x00000002 },
+ { 0x01e785f8, 0x00000002 },
+ { 0x00200000, 0x00000002 },
+ { 0x00600073, 0x0000000c },
+ { 0x00007563, 0x00000002 },
+ { 0x006075f0, 0x00000021 },
+ { 0x20007068, 0x00000004 },
+ { 0x00005068, 0x00000004 },
+ { 0x00007576, 0x00000002 },
+ { 0x00007577, 0x00000002 },
+ { 0x0000750e, 0x00000002 },
+ { 0x0000750f, 0x00000002 },
+ { 0x00a05000, 0x00000002 },
+ { 0x00600076, 0x0000000c },
+ { 0x006075f0, 0x00000021 },
+ { 0x000075f8, 0x00000002 },
+ { 0x00000076, 0x00000004 },
+ { 0x000a750e, 0x00000002 },
+ { 0x0020750f, 0x00000002 },
+ { 0x00600079, 0x00000004 },
+ { 0x00007570, 0x00000002 },
+ { 0x00007571, 0x00000002 },
+ { 0x00007572, 0x00000006 },
+ { 0x00005000, 0x00000002 },
+ { 0x00a05000, 0x00000002 },
+ { 0x00007568, 0x00000002 },
+ { 0x00061000, 0x00000002 },
+ { 0x00000084, 0x0000000c },
+ { 0x00058000, 0x00000002 },
+ { 0x0c607562, 0x00000002 },
+ { 0x00000086, 0x00000004 },
+ { 0x00600085, 0x00000004 },
+ { 0x400070dd, 0000000000 },
+ { 0x000380dd, 0x00000002 },
+ { 0x00000093, 0x0000001c },
+ { 0x00065095, 0x00000018 },
+ { 0x040025bb, 0x00000002 },
+ { 0x00061096, 0x00000018 },
+ { 0x040075bc, 0000000000 },
+ { 0x000075bb, 0x00000002 },
+ { 0x000075bc, 0000000000 },
+ { 0x00090000, 0x00000006 },
+ { 0x00090000, 0x00000002 },
+ { 0x000d8002, 0x00000006 },
+ { 0x00005000, 0x00000002 },
+ { 0x00007821, 0x00000002 },
+ { 0x00007800, 0000000000 },
+ { 0x00007821, 0x00000002 },
+ { 0x00007800, 0000000000 },
+ { 0x01665000, 0x00000002 },
+ { 0x000a0000, 0x00000002 },
+ { 0x000671cc, 0x00000002 },
+ { 0x0286f1cd, 0x00000002 },
+ { 0x000000a3, 0x00000010 },
+ { 0x21007000, 0000000000 },
+ { 0x000000aa, 0x0000001c },
+ { 0x00065000, 0x00000002 },
+ { 0x000a0000, 0x00000002 },
+ { 0x00061000, 0x00000002 },
+ { 0x000b0000, 0x00000002 },
+ { 0x38067000, 0x00000002 },
+ { 0x000a00a6, 0x00000004 },
+ { 0x20007000, 0000000000 },
+ { 0x01200000, 0x00000002 },
+ { 0x20077000, 0x00000002 },
+ { 0x01200000, 0x00000002 },
+ { 0x20007000, 0000000000 },
+ { 0x00061000, 0x00000002 },
+ { 0x0120751b, 0x00000002 },
+ { 0x8040750a, 0x00000002 },
+ { 0x8040750b, 0x00000002 },
+ { 0x00110000, 0x00000002 },
+ { 0x000380dd, 0x00000002 },
+ { 0x000000bd, 0x0000001c },
+ { 0x00061096, 0x00000018 },
+ { 0x844075bd, 0x00000002 },
+ { 0x00061095, 0x00000018 },
+ { 0x840075bb, 0x00000002 },
+ { 0x00061096, 0x00000018 },
+ { 0x844075bc, 0x00000002 },
+ { 0x000000c0, 0x00000004 },
+ { 0x804075bd, 0x00000002 },
+ { 0x800075bb, 0x00000002 },
+ { 0x804075bc, 0x00000002 },
+ { 0x00108000, 0x00000002 },
+ { 0x01400000, 0x00000002 },
+ { 0x006000c4, 0x0000000c },
+ { 0x20c07000, 0x00000020 },
+ { 0x000000c6, 0x00000012 },
+ { 0x00800000, 0x00000006 },
+ { 0x0080751d, 0x00000006 },
+ { 0x000025bb, 0x00000002 },
+ { 0x000040c0, 0x00000004 },
+ { 0x0000775c, 0x00000002 },
+ { 0x00a05000, 0x00000002 },
+ { 0x00661000, 0x00000002 },
+ { 0x0460275d, 0x00000020 },
+ { 0x00004000, 0000000000 },
+ { 0x00007999, 0x00000002 },
+ { 0x00a05000, 0x00000002 },
+ { 0x00661000, 0x00000002 },
+ { 0x0460299b, 0x00000020 },
+ { 0x00004000, 0000000000 },
+ { 0x01e00830, 0x00000002 },
+ { 0x21007000, 0000000000 },
+ { 0x00005000, 0x00000002 },
+ { 0x00038042, 0x00000002 },
+ { 0x040025e0, 0x00000002 },
+ { 0x000075e1, 0000000000 },
+ { 0x00000001, 0000000000 },
+ { 0x000380d9, 0x00000002 },
+ { 0x04007394, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+};
+
+/* Microcode from http://volodya-project.sourceforge.net/ */
+
+CARD32 r300_cp_microcode[][2] = {
+ { 0x4200e000, 0000000000 },
+ { 0x4000e000, 0000000000 },
+ { 0x000000af, 0x00000008 },
+ { 0x000000b3, 0x00000008 },
+ { 0x6c5a504f, 0000000000 },
+ { 0x4f4f497a, 0000000000 },
+ { 0x5a578288, 0000000000 },
+ { 0x4f91906a, 0000000000 },
+ { 0x4f4f4f4f, 0000000000 },
+ { 0x4fe24f44, 0000000000 },
+ { 0x4f9c9c9c, 0000000000 },
+ { 0xdc4f4fde, 0000000000 },
+ { 0xa1cd4f4f, 0000000000 },
+ { 0xd29d9d9d, 0000000000 },
+ { 0x4f0f9fd7, 0000000000 },
+ { 0x000ca000, 0x00000004 },
+ { 0x000d0012, 0x00000038 },
+ { 0x0000e8b4, 0x00000004 },
+ { 0x000d0014, 0x00000038 },
+ { 0x0000e8b6, 0x00000004 },
+ { 0x000d0016, 0x00000038 },
+ { 0x0000e854, 0x00000004 },
+ { 0x000d0018, 0x00000038 },
+ { 0x0000e855, 0x00000004 },
+ { 0x000d001a, 0x00000038 },
+ { 0x0000e856, 0x00000004 },
+ { 0x000d001c, 0x00000038 },
+ { 0x0000e857, 0x00000004 },
+ { 0x000d001e, 0x00000038 },
+ { 0x0000e824, 0x00000004 },
+ { 0x000d0020, 0x00000038 },
+ { 0x0000e825, 0x00000004 },
+ { 0x000d0022, 0x00000038 },
+ { 0x0000e830, 0x00000004 },
+ { 0x000d0024, 0x00000038 },
+ { 0x0000f0c0, 0x00000004 },
+ { 0x000d0026, 0x00000038 },
+ { 0x0000f0c1, 0x00000004 },
+ { 0x000d0028, 0x00000038 },
+ { 0x0000f041, 0x00000004 },
+ { 0x000d002a, 0x00000038 },
+ { 0x0000f184, 0x00000004 },
+ { 0x000d002c, 0x00000038 },
+ { 0x0000f185, 0x00000004 },
+ { 0x000d002e, 0x00000038 },
+ { 0x0000f186, 0x00000004 },
+ { 0x000d0030, 0x00000038 },
+ { 0x0000f187, 0x00000004 },
+ { 0x000d0032, 0x00000038 },
+ { 0x0000f180, 0x00000004 },
+ { 0x000d0034, 0x00000038 },
+ { 0x0000f393, 0x00000004 },
+ { 0x000d0036, 0x00000038 },
+ { 0x0000f38a, 0x00000004 },
+ { 0x000d0038, 0x00000038 },
+ { 0x0000f38e, 0x00000004 },
+ { 0x0000e821, 0x00000004 },
+ { 0x0140a000, 0x00000004 },
+ { 0x00000043, 0x00000018 },
+ { 0x00cce800, 0x00000004 },
+ { 0x001b0001, 0x00000004 },
+ { 0x08004800, 0x00000004 },
+ { 0x001b0001, 0x00000004 },
+ { 0x08004800, 0x00000004 },
+ { 0x001b0001, 0x00000004 },
+ { 0x08004800, 0x00000004 },
+ { 0x0000003a, 0x00000008 },
+ { 0x0000a000, 0000000000 },
+ { 0x02c0a000, 0x00000004 },
+ { 0x000ca000, 0x00000004 },
+ { 0x00130000, 0x00000004 },
+ { 0x000c2000, 0x00000004 },
+ { 0xc980c045, 0x00000008 },
+ { 0x2000451d, 0x00000004 },
+ { 0x0000e580, 0x00000004 },
+ { 0x000ce581, 0x00000004 },
+ { 0x08004580, 0x00000004 },
+ { 0x000ce581, 0x00000004 },
+ { 0x0000004c, 0x00000008 },
+ { 0x0000a000, 0000000000 },
+ { 0x000c2000, 0x00000004 },
+ { 0x0000e50e, 0x00000004 },
+ { 0x00032000, 0x00000004 },
+ { 0x00022056, 0x00000028 },
+ { 0x00000056, 0x00000024 },
+ { 0x0800450f, 0x00000004 },
+ { 0x0000a050, 0x00000008 },
+ { 0x0000e565, 0x00000004 },
+ { 0x0000e566, 0x00000004 },
+ { 0x00000057, 0x00000008 },
+ { 0x03cca5b4, 0x00000004 },
+ { 0x05432000, 0x00000004 },
+ { 0x00022000, 0x00000004 },
+ { 0x4ccce063, 0x00000030 },
+ { 0x08274565, 0x00000004 },
+ { 0x00000063, 0x00000030 },
+ { 0x08004564, 0x00000004 },
+ { 0x0000e566, 0x00000004 },
+ { 0x0000005a, 0x00000008 },
+ { 0x00802066, 0x00000010 },
+ { 0x00202000, 0x00000004 },
+ { 0x001b00ff, 0x00000004 },
+ { 0x01000069, 0x00000010 },
+ { 0x001f2000, 0x00000004 },
+ { 0x001c00ff, 0x00000004 },
+ { 0000000000, 0x0000000c },
+ { 0x00000085, 0x00000030 },
+ { 0x0000005a, 0x00000008 },
+ { 0x0000e576, 0x00000004 },
+ { 0x000ca000, 0x00000004 },
+ { 0x00012000, 0x00000004 },
+ { 0x00082000, 0x00000004 },
+ { 0x1800650e, 0x00000004 },
+ { 0x00092000, 0x00000004 },
+ { 0x000a2000, 0x00000004 },
+ { 0x000f0000, 0x00000004 },
+ { 0x00400000, 0x00000004 },
+ { 0x00000079, 0x00000018 },
+ { 0x0000e563, 0x00000004 },
+ { 0x00c0e5f9, 0x000000c2 },
+ { 0x0000006e, 0x00000008 },
+ { 0x0000a06e, 0x00000008 },
+ { 0x0000e576, 0x00000004 },
+ { 0x0000e577, 0x00000004 },
+ { 0x0000e50e, 0x00000004 },
+ { 0x0000e50f, 0x00000004 },
+ { 0x0140a000, 0x00000004 },
+ { 0x0000007c, 0x00000018 },
+ { 0x00c0e5f9, 0x000000c2 },
+ { 0x0000007c, 0x00000008 },
+ { 0x0014e50e, 0x00000004 },
+ { 0x0040e50f, 0x00000004 },
+ { 0x00c0007f, 0x00000008 },
+ { 0x0000e570, 0x00000004 },
+ { 0x0000e571, 0x00000004 },
+ { 0x0000e572, 0x0000000c },
+ { 0x0000a000, 0x00000004 },
+ { 0x0140a000, 0x00000004 },
+ { 0x0000e568, 0x00000004 },
+ { 0x000c2000, 0x00000004 },
+ { 0x00000089, 0x00000018 },
+ { 0x000b0000, 0x00000004 },
+ { 0x18c0e562, 0x00000004 },
+ { 0x0000008b, 0x00000008 },
+ { 0x00c0008a, 0x00000008 },
+ { 0x000700e4, 0x00000004 },
+ { 0x00000097, 0x00000038 },
+ { 0x000ca099, 0x00000030 },
+ { 0x080045bb, 0x00000004 },
+ { 0x000c209a, 0x00000030 },
+ { 0x0800e5bc, 0000000000 },
+ { 0x0000e5bb, 0x00000004 },
+ { 0x0000e5bc, 0000000000 },
+ { 0x00120000, 0x0000000c },
+ { 0x00120000, 0x00000004 },
+ { 0x001b0002, 0x0000000c },
+ { 0x0000a000, 0x00000004 },
+ { 0x0000e821, 0x00000004 },
+ { 0x0000e800, 0000000000 },
+ { 0x0000e821, 0x00000004 },
+ { 0x0000e82e, 0000000000 },
+ { 0x02cca000, 0x00000004 },
+ { 0x00140000, 0x00000004 },
+ { 0x000ce1cc, 0x00000004 },
+ { 0x050de1cd, 0x00000004 },
+ { 0x000000a7, 0x00000020 },
+ { 0x4200e000, 0000000000 },
+ { 0x000000ae, 0x00000038 },
+ { 0x000ca000, 0x00000004 },
+ { 0x00140000, 0x00000004 },
+ { 0x000c2000, 0x00000004 },
+ { 0x00160000, 0x00000004 },
+ { 0x700ce000, 0x00000004 },
+ { 0x001400aa, 0x00000008 },
+ { 0x4000e000, 0000000000 },
+ { 0x02400000, 0x00000004 },
+ { 0x400ee000, 0x00000004 },
+ { 0x02400000, 0x00000004 },
+ { 0x4000e000, 0000000000 },
+ { 0x000c2000, 0x00000004 },
+ { 0x0240e51b, 0x00000004 },
+ { 0x0080e50a, 0x00000005 },
+ { 0x0080e50b, 0x00000005 },
+ { 0x00220000, 0x00000004 },
+ { 0x000700e4, 0x00000004 },
+ { 0x000000c1, 0x00000038 },
+ { 0x000c209a, 0x00000030 },
+ { 0x0880e5bd, 0x00000005 },
+ { 0x000c2099, 0x00000030 },
+ { 0x0800e5bb, 0x00000005 },
+ { 0x000c209a, 0x00000030 },
+ { 0x0880e5bc, 0x00000005 },
+ { 0x000000c4, 0x00000008 },
+ { 0x0080e5bd, 0x00000005 },
+ { 0x0000e5bb, 0x00000005 },
+ { 0x0080e5bc, 0x00000005 },
+ { 0x00210000, 0x00000004 },
+ { 0x02800000, 0x00000004 },
+ { 0x00c000c8, 0x00000018 },
+ { 0x4180e000, 0x00000040 },
+ { 0x000000ca, 0x00000024 },
+ { 0x01000000, 0x0000000c },
+ { 0x0100e51d, 0x0000000c },
+ { 0x000045bb, 0x00000004 },
+ { 0x000080c4, 0x00000008 },
+ { 0x0000f3ce, 0x00000004 },
+ { 0x0140a000, 0x00000004 },
+ { 0x00cc2000, 0x00000004 },
+ { 0x08c053cf, 0x00000040 },
+ { 0x00008000, 0000000000 },
+ { 0x0000f3d2, 0x00000004 },
+ { 0x0140a000, 0x00000004 },
+ { 0x00cc2000, 0x00000004 },
+ { 0x08c053d3, 0x00000040 },
+ { 0x00008000, 0000000000 },
+ { 0x0000f39d, 0x00000004 },
+ { 0x0140a000, 0x00000004 },
+ { 0x00cc2000, 0x00000004 },
+ { 0x08c0539e, 0x00000040 },
+ { 0x00008000, 0000000000 },
+ { 0x03c00830, 0x00000004 },
+ { 0x4200e000, 0000000000 },
+ { 0x0000a000, 0x00000004 },
+ { 0x200045e0, 0x00000004 },
+ { 0x0000e5e1, 0000000000 },
+ { 0x00000001, 0000000000 },
+ { 0x000700e1, 0x00000004 },
+ { 0x0800e394, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+ { 0000000000, 0000000000 },
+};
diff --git a/xorg-server/hw/kdrive/ati/ati_reg.h b/xorg-server/hw/kdrive/ati/ati_reg.h
new file mode 100644
index 000000000..3089cba04
--- /dev/null
+++ b/xorg-server/hw/kdrive/ati/ati_reg.h
@@ -0,0 +1,1927 @@
+/*
+ * Copyright © 2003 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Many of the Radeon and Rage 128 registers are the same.
+ * ATI_ should denote registers and values that are common for R128 and Radeon.
+ *
+ * The information in this file comes from many sources, including the Rage 128
+ * DDK, Rage 128 register reference, the XFree86 and kernel Rage 128 and Radeon
+ * register definition headers, and bits from the Radeon DDK and RV200 register
+ * specs supplied by others.
+ */
+
+#define ATI_REG_CLOCK_CNTL_INDEX 0x0008
+# define ATI_PLL_WR_EN (1 << 7)
+# define ATI_PLL_DIV_SEL (3 << 8)
+
+#define ATI_REG_CLOCK_CNTL_DATA 0x000c
+
+#define ATI_REG_BUS_CNTL 0x0030
+# define ATI_BUS_MASTER_DIS (1 << 6)
+
+#define ATI_REG_GEN_INT_CNTL 0x0040
+
+#define ATI_REG_GEN_CNTL 0x0050
+# define ATI_CRTC_DBL_SCAN_EN (1 << 0) /* 0x00000001 */
+# define ATI_CRTC_INTERLACE_EN (1 << 1) /* 0x00000002 */
+# define ATI_CRTC_CSYNC_EN (1 << 4) /* 0x00000010 */
+# define ATI_CRTC_PIX_WIDTH_MASK (7 << 8) /* 0x00000700 */
+# define ATI_CRTC_CUR_EN (1 << 16) /* 0x00010000 */
+# define ATI_CRTC_CUR_MODE_MASK (7 << 17) /* 0x000e0000 */
+# define ATI_CRTC_ICON_EN (1 << 20) /* 0x00100000 */
+# define ATI_CRTC_ARGB_EN (2 << 20) /* 0x00200000 */
+# define ATI_CRTC_EXT_DISP_EN (1 << 24) /* 0x01000000 */
+# define ATI_CRTC_EN (1 << 25) /* 0x02000000 */
+# define ATI_CRTC_DISP_REQ_EN_B (1 << 26) /* 0x04000000 */
+
+#define ATI_REG_CRTC_EXT_CNTL 0x0054
+# define ATI_CRTC_EN (1 << 25)
+# define ATI_CRTC_VGA_XOVERSCAN (1 << 0)
+# define ATI_VGA_ATI_LINEAR (1 << 3)
+# define ATI_XCRT_CNT_EN (1 << 6)
+# define ATI_CRTC_HSYNC_DIS (1 << 8)
+# define ATI_CRTC_VSYNC_DIS (1 << 9)
+# define ATI_CRTC_DISPLAY_DIS (1 << 10)
+# define RADEON_CRTC_SYNC_TRISTAT (1 << 11)
+# define ATI_CRTC_CRT_ON (1 << 15)
+# define R128_FP_OUT_EN (1 << 22)
+# define R128_FP_ACTIVE (1 << 23)
+
+#define ATI_REG_DAC_CNTL 0x0058
+# define ATI_DAC_RANGE_CNTL (3 << 0)
+# define ATI_DAC_BLANKING (1 << 2)
+# define R128_DAC_CRT_SEL_CRTC2 (1 << 4)
+# define ATI_DAC_CMP_EN (1 << 3)
+# define R128_DAC_PALETTE_ACC_CTL (1 << 5)
+# define ATI_DAC_CMP_OUTPUT (1 << 7)
+# define ATI_DAC_8BIT_EN (1 << 8)
+# define ATI_DAC_VGA_ADR_EN (1 << 13)
+# define ATI_DAC_PDWN (1 << 15)
+# define ATI_DAC_MASK_ALL (0xff << 24)
+
+#define ATI_REG_I2C_CNTL_1 0x0094
+
+#define R128_REG_GEN_RESET_CNTL 0x00f0
+# define R128_SOFT_RESET_GUI (1 << 0)
+# define R128_SOFT_RESET_VCLK (1 << 8)
+# define R128_SOFT_RESET_PCLK (1 << 9)
+# define R128_SOFT_RESET_DISPENG_XCLK (1 << 11)
+# define R128_SOFT_RESET_MEMCTLR_XCLK (1 << 12)
+
+#define RADEON_REG_RBBM_SOFT_RESET 0x00f0
+# define RADEON_SOFT_RESET_CP (1 << 0)
+# define RADEON_SOFT_RESET_HI (1 << 1)
+# define RADEON_SOFT_RESET_SE (1 << 2)
+# define RADEON_SOFT_RESET_RE (1 << 3)
+# define RADEON_SOFT_RESET_PP (1 << 4)
+# define RADEON_SOFT_RESET_E2 (1 << 5)
+# define RADEON_SOFT_RESET_RB (1 << 6)
+# define RADEON_SOFT_RESET_HDP (1 << 7)
+
+#define RADEON_REG_HOST_PATH_CNTL 0x0130
+# define RADEON_HDP_SOFT_RESET (1 << 26)
+
+#define ATI_REG_AGP_BASE 0x0170
+
+#define ATI_REG_AGP_CNTL 0x0174
+# define R128_AGP_APER_SIZE_256MB (0x00 << 0)
+# define R128_AGP_APER_SIZE_128MB (0x20 << 0)
+# define R128_AGP_APER_SIZE_64MB (0x30 << 0)
+# define R128_AGP_APER_SIZE_32MB (0x38 << 0)
+# define R128_AGP_APER_SIZE_16MB (0x3c << 0)
+# define R128_AGP_APER_SIZE_8MB (0x3e << 0)
+# define R128_AGP_APER_SIZE_4MB (0x3f << 0)
+# define R128_AGP_APER_SIZE_MASK (0x3f << 0)
+# define RADEON_PENDING_SLOTS_VAL 0x00060000
+# define RADEON_PENDING_SLOTS_SEL 0x00080000
+
+#define R128_REG_PCI_GART_PAGE 0x017c
+
+#define R128_REG_PC_NGUI_CTLSTAT 0x0184
+# define R128_PC_FLUSH_GUI (3 << 0)
+# define R128_PC_RI_GUI (1 << 2)
+# define R128_PC_FLUSH_ALL 0x00ff
+# define R128_PC_BUSY (1 << 31)
+
+#define R128_REG_VIPH_CONTROL 0x01d0
+
+#define ATI_REG_CRTC_H_TOTAL_DISP 0x0200
+#define ATI_REG_CRTC2_H_TOTAL_DISP 0x0300
+# define ATI_CRTC_H_TOTAL (0x01ff << 0)
+# define ATI_CRTC_H_TOTAL_SHIFT 0
+# define ATI_CRTC_H_DISP (0x00ff << 16)
+# define ATI_CRTC_H_DISP_SHIFT 16
+
+#define ATI_REG_CRTC_H_SYNC_STRT_WID 0x0204
+#define ATI_REG_CRTC2_H_SYNC_STRT_WID 0x0304
+# define RADEON_CRTC_H_SYNC_STRT_PIX (0x07 << 0)
+# define RADEON_CRTC_H_SYNC_STRT_CHAR (0x3ff << 3)
+# define RADEON_CRTC_H_SYNC_STRT_CHAR_SHIFT 3
+# define RADEON_CRTC_H_SYNC_WID (0x3f << 16)
+# define RADEON_CRTC_H_SYNC_WID_SHIFT 16
+# define RADEON_CRTC_H_SYNC_POL (1 << 23)
+
+#define ATI_REG_CRTC_OFFSET 0x0224
+#define ATI_REG_CRTC2_OFFSET 0x0324
+#define ATI_REG_CRTC_OFFSET_CNTL 0x0228
+#define ATI_REG_CRTC2_OFFSET_CNTL 0x0328
+#define ATI_REG_CRTC_PITCH 0x022c
+#define ATI_REG_CRTC2_PITCH 0x032c
+
+#define ATI_REG_OVR_CLR 0x0230
+#define ATI_REG_OVR_WID_LEFT_RIGHT 0x0234
+#define ATI_REG_OVR_WID_TOP_BOTTOM 0x0238
+
+#define ATI_REG_CUR_OFFSET 0x0260
+#define ATI_REG_CUR_HORZ_VERT_POSN 0x0264
+#define ATI_REG_CUR_HORZ_VERT_OFF 0x0268
+# define ATI_CUR_LOCK (1 << 31)
+# define ATI_CURSOR_WIDTH 64
+# define ATI_CURSOR_HEIGHT 64
+# define ATI_CURSOR_PITCH 16
+
+#define ATI_REG_CUR_CLR0 0x026c
+#define ATI_REG_CUR_CLR1 0x0270
+#define ATI_REG_OV0_SCALE_CNTL 0x0420
+#define ATI_REG_SUBPIC_CNTL 0x0540
+#define ATI_REG_CAP0_TRIG_CNTL 0x0950
+#define RADEON_REG_VIPH_CONTROL 0x0c50
+
+#define RADEON_REG_RBBM_STATUS 0x0e40
+# define RADEON_RBBM_FIFOCNT_MASK 0x007f
+# define RADEON_RBBM_ACTIVE (1 << 31)
+
+#define ATI_REG_CCE_RB_BASE 0x0700
+
+#define R128_REG_PM4_BUFFER_CNTL 0x0704
+# define R128_PM4_IN_FRAME_BUFFER (1 << 26)
+# define R128_PM4_BUFFER_CNTL_NOUPDATE (1 << 27)
+# define R128_PM4_NONPM4 (0 << 28)
+# define R128_PM4_192PIO (1 << 28)
+# define R128_PM4_192BM (2 << 28)
+# define R128_PM4_128PIO_64INDBM (3 << 28)
+# define R128_PM4_128BM_64INDBM (4 << 28)
+# define R128_PM4_64PIO_128INDBM (5 << 28)
+# define R128_PM4_64BM_128INDBM (6 << 28)
+# define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28)
+# define R128_PM4_64BM_64VCBM_64INDBM (8 << 28)
+# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28)
+
+#define RADEON_REG_CP_RB_CNTL 0x0704
+
+#define R128_REG_PM4_BUFFER_WM_CNTL 0x0708
+# define R128_WMA_SHIFT 0
+# define R128_WMB_SHIFT 8
+# define R128_WMC_SHIFT 16
+# define R128_WB_WM_SHIFT 24
+
+#define ATI_REG_CCE_RPTR_ADDR 0x070c
+#define ATI_REG_CCE_RPTR 0x0710
+#define ATI_REG_CCE_WPTR 0x0714
+# define R128_PM4_BUFFER_DL_DONE (1 << 31)
+
+#define R128_REG_PM4_VC_FPU_SETUP 0x071c
+# define R128_FRONT_DIR_CW (0 << 0)
+# define R128_FRONT_DIR_CCW (1 << 0)
+# define R128_FRONT_DIR_MASK (1 << 0)
+# define R128_BACKFACE_CULL (0 << 1)
+# define R128_BACKFACE_POINTS (1 << 1)
+# define R128_BACKFACE_LINES (2 << 1)
+# define R128_BACKFACE_SOLID (3 << 1)
+# define R128_BACKFACE_MASK (3 << 1)
+# define R128_FRONTFACE_CULL (0 << 3)
+# define R128_FRONTFACE_POINTS (1 << 3)
+# define R128_FRONTFACE_LINES (2 << 3)
+# define R128_FRONTFACE_SOLID (3 << 3)
+# define R128_FRONTFACE_MASK (3 << 3)
+# define R128_FPU_COLOR_SOLID (0 << 5)
+# define R128_FPU_COLOR_FLAT (1 << 5)
+# define R128_FPU_COLOR_GOURAUD (2 << 5)
+# define R128_FPU_COLOR_GOURAUD2 (3 << 5)
+# define R128_FPU_COLOR_MASK (3 << 5)
+# define R128_FPU_SUB_PIX_2BITS (0 << 7)
+# define R128_FPU_SUB_PIX_4BITS (1 << 7)
+# define R128_FPU_MODE_2D (0 << 8)
+# define R128_FPU_MODE_3D (1 << 8)
+# define R128_TRAP_BITS_DISABLE (1 << 9)
+# define R128_EDGE_ANTIALIAS (1 << 10)
+# define R128_SUPERSAMPLE (1 << 11)
+# define R128_XFACTOR_2 (0 << 12)
+# define R128_XFACTOR_4 (1 << 12)
+# define R128_YFACTOR_2 (0 << 13)
+# define R128_YFACTOR_4 (1 << 13)
+# define R128_FLAT_SHADE_VERTEX_D3D (0 << 14)
+# define R128_FLAT_SHADE_VERTEX_OGL (1 << 14)
+# define R128_FPU_ROUND_TRUNCATE (0 << 15)
+# define R128_FPU_ROUND_NEAREST (1 << 15)
+# define R128_WM_SEL_8DW (0 << 16)
+# define R128_WM_SEL_16DW (1 << 16)
+# define R128_WM_SEL_32DW (2 << 16)
+
+#define R128_REG_PM4_IW_INDOFF 0x0738
+#define R128_REG_PM4_IW_INDSIZE 0x073c
+
+#define RADEON_REG_CP_CSQ_CNTL 0x0740
+# define RADEON_CSQ_CNT_PRIMARY_MASK 0x000000ff
+# define RADEON_CSQ_CNT_INDIRECT_MASK 0x0000ff00
+# define R200_CSQ_CNT_PRIMARY_MASK 0x000001ff
+# define R200_CSQ_CNT_INDIRECT_MASK 0x0003fe00
+# define RADEON_CSQ_PRIDIS_INDDIS (0 << 28)
+# define RADEON_CSQ_PRIPIO_INDDIS (1 << 28)
+# define RADEON_CSQ_PRIBM_INDDIS (2 << 28)
+# define RADEON_CSQ_PRIPIO_INDBM (3 << 28)
+# define RADEON_CSQ_PRIBM_INDBM (4 << 28)
+# define RADEON_CSQ_PRIPIO_INDPIO (15 << 28)
+
+#define R128_REG_PM4_STAT 0x07b8
+# define R128_PM4_FIFOCNT_MASK 0x00000fff
+# define R128_PM4_BUSY (1 << 16)
+# define R128_PM4_GUI_ACTIVE (1 << 31)
+
+#define RADEON_REG_CP_STAT 0x07c0
+# define RADEON_CSQ_PRIMARY_BUSY (1 << 10)
+# define RADEON_CSQ_INDIRECT_BUSY (1 << 11)
+
+#define RADEON_REG_ME_CNTL 0x07d0
+# define RADEON_ME_MODE_FREE_RUN (1 << 30)
+
+#define ATI_REG_MICROCODE_RAM_ADDR 0x07d4
+#define ATI_REG_MICROCODE_RAM_RADDR 0x07d8
+#define ATI_REG_MICROCODE_RAM_DATAH 0x07dc
+#define ATI_REG_MICROCODE_RAM_DATAL 0x07e0
+#define R128_REG_PM4_BUFFER_ADDR 0x07f0
+
+#define RADEON_REG_CP_CSQ_STAT 0x07f8
+# define RADEON_CSQ_RPTR_PRIMARY_MASK (0xff << 0)
+# define RADEON_CSQ_WPTR_PRIMARY_MASK (0xff << 8)
+# define RADEON_CSQ_RPTR_INDIRECT_MASK (0xff << 16)
+# define RADEON_CSQ_WPTR_INDIRECT_MASK (0xff << 24)
+# define R200_CSQ_RPTR_PRIMARY_MASK (0x1ff << 0)
+# define R200_CSQ_WPTR_PRIMARY_MASK (0x1ff << 9)
+
+#define R128_REG_PM4_MICRO_CNTL 0x07fc
+# define R128_PM4_MICRO_FREERUN (1 << 30)
+
+#define RADEON_TV_MASTER_CNTL 0x0800
+# define RADEON_TV_MACROVISION (1 << 5)
+# define RADEON_TVCLK_ALWAYS_ON (1 << 30)
+
+#define R128_REG_BM_CHUNK_0_VAL 0x0a18
+# define R128_BM_PTR_FORCE_TO_PCI (1 << 21)
+# define R128_BM_PM4_RD_FORCE_TO_PCI (1 << 22)
+# define R128_BM_GLOBAL_FORCE_TO_PCI (1 << 23)
+
+/* Offset of the PCI config space mirror */
+#define ATI_PCI_CFG_OFFSET 0x0f00
+
+#define ATI_REG_PCI_CFG_STATUS 0x0f06
+# define ATI_CAP_LIST 0x0010
+
+#define ATI_REG_PCI_CFG_CAPABILITIES_PTR 0x0f34
+# define ATI_CAP_PTR_MASK 0x00fc
+# define ATI_CAP_ID_NULL 0x0000 /* End of capability list */
+# define ATI_CAP_ID_AGP 0x0002 /* AGP capability ID */
+
+#define R128_REG_AGP_STATUS 0x0f54 /* PCI */
+# define R128_AGP_1X_MODE 0x01
+# define R128_AGP_2X_MODE 0x02
+# define R128_AGP_4X_MODE 0x04
+# define R128_AGP_MODE_MASK 0x07
+
+#define R128_REG_AGP_COMMAND 0x0f58
+# define R128_AGP_ENABLE (1 << 8)
+
+#define RADEON_REG_AGP_STATUS 0x0f5c /* PCI */
+# define RADEON_AGP_1X_MODE 0x01
+# define RADEON_AGP_2X_MODE 0x02
+# define RADEON_AGP_4X_MODE 0x04
+# define RADEON_AGP_FW_MODE 0x10
+# define RADEON_AGP_MODE_MASK 0x17
+
+#define RADEON_REG_AGP_COMMAND 0x0f60
+# define RADEON_AGP_ENABLE (1 << 8)
+
+#define R128_REG_PM4_FIFO_DATA_EVEN 0x1000
+#define R128_REG_PM4_FIFO_DATA_ODD 0x1004
+
+#define RADEON_REG_CSQ_APER_PRIMARY 0x1000
+#define RADEON_REG_CSQ_APER_PRIMARY_END 0x11fc
+#define RADEON_REG_CSQ_APER_INDIRECT 0x1300
+#define RADEON_REG_CSQ_APER_INDIRECT_END 0x13fc
+#define ATI_REG_SRC_PITCH_OFFSET 0x1428
+#define ATI_REG_DST_PITCH_OFFSET 0x142c
+#define ATI_REG_SRC_Y_X 0x1434
+#define ATI_REG_DST_Y_X 0x1438
+#define ATI_REG_DST_HEIGHT_WIDTH 0x143c
+
+#define ATI_REG_DP_GUI_MASTER_CNTL 0x146c
+# define ATI_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0)
+# define ATI_GMC_DST_PITCH_OFFSET_CNTL (1 << 1)
+# define ATI_GMC_SRC_CLIPPING (1 << 2)
+# define ATI_GMC_DST_CLIPPING (1 << 3)
+# define ATI_GMC_BRUSH_SOLID_COLOR (13 << 4)
+# define ATI_GMC_BRUSH_NONE (15 << 4)
+# define ATI_GMC_BRUSH_MASK (15 << 4)
+# define ATI_GMC_DST_DATATYPE_MASK (0xf << 8)
+# define ATI_GMC_SRC_DATATYPE_COLOR (3 << 12)
+# define R128_GMC_CONVERSION_TEMP (1 << 15)
+# define R128_GMC_CONVERSION_TEMP_6500 (0 << 15)
+# define R128_GMC_CONVERSION_TEMP_9300 (1 << 15)
+# define ATI_GMC_ROP3_MASK (0xff << 16)
+# define ATI_DP_SRC_SOURCE_MEMORY (2 << 24)
+# define ATI_DP_SRC_SOURCE_HOST_DATA (3 << 24)
+# define R128_GMC_3D_FCN_EN (1 << 27)
+# define ATI_GMC_CLR_CMP_CNTL_DIS (1 << 28)
+# define R128_GMC_AUX_CLIP_DIS (1 << 29)
+# define ATI_GMC_WR_MSK_DIS (1 << 30)
+# define R128_GMC_LD_BRUSH_Y_X (1 << 31)
+
+#define ATI_REG_DP_BRUSH_FRGD_CLR 0x147c
+#define ATI_REG_DST_WIDTH_HEIGHT 0x1598
+#define ATI_REG_CLR_CMP_CNTL 0x15c0
+
+#define R128_REG_AUX_SC_CNTL 0x1660
+# define R128_AUX1_SC_ENB (1 << 0)
+# define R128_AUX1_SC_MODE_SUB (1 << 1)
+# define R128_AUX2_SC_ENB (1 << 0)
+# define R128_AUX2_SC_MODE_SUB (1 << 1)
+# define R128_AUX3_SC_ENB (1 << 0)
+# define R128_AUX3_SC_MODE_SUB (1 << 1)
+
+#define R128_REG_AUX1_SC_LEFT 0x1664
+#define R128_REG_AUX1_SC_RIGHT 0x1668
+#define R128_REG_AUX1_SC_TOP 0x166c
+#define R128_REG_AUX1_SC_BOTTOM 0x1670
+#define R128_REG_AUX2_SC_LEFT 0x1674
+#define R128_REG_AUX2_SC_RIGHT 0x1678
+#define R128_REG_AUX2_SC_TOP 0x167c
+#define R128_REG_AUX2_SC_BOTTOM 0x1680
+#define R128_REG_AUX3_SC_LEFT 0x1684
+#define R128_REG_AUX3_SC_RIGHT 0x1688
+#define R128_REG_AUX3_SC_TOP 0x168c
+#define R128_REG_AUX3_SC_BOTTOM 0x1690
+
+#define ATI_REG_DP_CNTL 0x16c0
+# define ATI_DST_X_LEFT_TO_RIGHT (1 << 0)
+# define ATI_DST_Y_TOP_TO_BOTTOM (1 << 1)
+
+#define ATI_REG_DP_MIX 0x16c8
+#define ATI_REG_DP_WRITE_MASK 0x16cc
+#define ATI_REG_DEFAULT_OFFSET 0x16e0
+#define ATI_REG_DEFAULT_PITCH 0x16e4
+
+#define ATI_REG_DEFAULT_SC_BOTTOM_RIGHT 0x16e8
+# define ATI_DEFAULT_SC_RIGHT_MAX 0x00001fff
+# define ATI_DEFAULT_SC_BOTTOM_MAX 0x1fff0000
+
+#define ATI_REG_SC_TOP_LEFT 0x16ec
+#define ATI_REG_SC_BOTTOM_RIGHT 0x16f0
+
+#define ATI_REG_WAIT_UNTIL 0x1720
+# define ATI_WAIT_CRTC_PFLIP (1 << 0)
+# define ATI_WAIT_RE_CRTC_VLINE (1 << 1)
+# define ATI_WAIT_FE_CRTC_VLINE (1 << 2)
+# define ATI_WAIT_CRTC_VLINE (1 << 3)
+# define ATI_WAIT_DMA_VIPH0_IDLE (1 << 4)
+# define ATI_WAIT_DMA_VIPH1_IDLE (1 << 5)
+# define ATI_WAIT_DMA_VIPH2_IDLE (1 << 6)
+# define ATI_WAIT_DMA_VIPH3_IDLE (1 << 7)
+# define ATI_WAIT_DMA_VID_IDLE (1 << 8)
+# define ATI_WAIT_DMA_GUI_IDLE (1 << 9)
+# define ATI_WAIT_CMDFIFO (1 << 10)
+# define ATI_WAIT_OV0_FLIP (1 << 11)
+# define RADEON_WAIT_OV0_SLICEDONE (1 << 12)
+# define RADEON_WAIT_2D_IDLE (1 << 14)
+# define RADEON_WAIT_3D_IDLE (1 << 15)
+# define RADEON_WAIT_2D_IDLECLEAN (1 << 16)
+# define RADEON_WAIT_3D_IDLECLEAN (1 << 17)
+# define RADEON_WAIT_HOST_IDLECLEAN (1 << 18)
+# define ATI_WAIT_CMDFIFO_ENTRIES (0x07f00000)
+# define RADEON_WAIT_BOTH_CRTC_PFLIP (1 << 30)
+# define RADEON_ENG_DISPLAY_SELECT (1 << 31)
+
+#define RADEON_REG_ISYNC_CNTL 0x1724
+#define ISYNC_ANY2D_IDLE3D 0x1
+#define ISYNC_ANY3D_IDLE2D 0x2
+
+#define R128_REG_GUI_STAT 0x1740
+# define R128_GUI_ACTIVE (1 << 31)
+
+#define R128_REG_PC_GUI_MODE 0x1744
+#define R128_PC_GUI_PRIORITY (1 << 0)
+#define R128_PC_RISE_DF_EN (1 << 1)
+#define R128_PC_FALL_DF_EN (1 << 2)
+#define R128_PC_BYPASS_EN (1 << 3)
+#define R128_PC_CACHE_SIZE (1 << 4)
+#define R128_PC_IGNORE_UNIFY (1 << 5)
+#define R128_PC_IGNORE_WRHINT (1 << 6)
+#define R128_PC_IGNORE_RDHINT (1 << 7)
+#define R128_PC_RISE_DP_EN (1 << 8)
+
+#define R128_REG_PC_GUI_CTLSTAT 0x1748
+/* bits match R128_REG_PC_NGUI_CTLSTAT */
+
+#define R128_REG_TEX_CNTL 0x1800
+#define R128_REG_SECONDARY_SCALE_OFFSET 0x1980
+#define R128_REG_SECONDARY_SCALE_PITCH 0x1980
+#define R128_REG_SECONDARY_SCALE_X_INC 0x1984
+#define R128_REG_SECONDARY_SCALE_Y_INC 0x1988
+#define R128_REG_SECONDARY_SCALE_HACC 0x198c
+#define R128_REG_SECONDARY_SCALE_VACC 0x1990
+#define R128_REG_SCALE_SRC_HEIGHT_WIDTH 0x1994
+#define R128_REG_SCALE_OFFSET_0 0x1998
+#define R128_REG_SCALE_PITCH 0x199c
+#define R128_REG_SCALE_X_INC 0x19a0
+#define R128_REG_SCALE_Y_INC 0x19a4
+#define R128_REG_SCALE_HACC 0x19a8
+#define R128_REG_SCALE_VACC 0x19ac
+#define R128_REG_SCALE_DST_X_Y 0x19b0
+#define R128_REG_SCALE_DST_HEIGHT_WIDTH 0x19b4
+
+#define R128_REG_SCALE_3D_CNTL 0x1a00
+# define R128_SCALE_DITHER_ERR_DIFF (0 << 1)
+# define R128_SCALE_DITHER_TABLE (1 << 1)
+# define R128_TEX_CACHE_SIZE_FULL (0 << 2)
+# define R128_TEX_CACHE_SIZE_HALF (1 << 2)
+# define R128_DITHER_INIT_CURR (0 << 3)
+# define R128_DITHER_INIT_RESET (1 << 3)
+# define R128_ROUND_24BIT (1 << 4)
+# define R128_TEX_CACHE_DISABLE (1 << 5)
+# define R128_SCALE_3D_NOOP (0 << 6)
+# define R128_SCALE_3D_SCALE (1 << 6)
+# define R128_SCALE_3D_TEXMAP_SHADE (2 << 6)
+# define R128_SCALE_PIX_BLEND (0 << 8)
+# define R128_SCALE_PIX_REPLICATE (1 << 8)
+# define R128_TEX_CACHE_SPLIT (1 << 9)
+# define R128_APPLE_YUV_MODE (1 << 10)
+# define R128_TEX_CACHE_PALLETE_MODE (1 << 11)
+# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12)
+# define R128_ALPHA_COMB_ADD_NCLAMP (1 << 12)
+# define R128_ALPHA_COMB_SUB_DST_SRC_CLAMP (2 << 12)
+# define R128_ALPHA_COMB_SUB_DST_SRC_NCLAMP (3 << 12)
+# define R128_FOG_TABLE (1 << 14)
+# define R128_SIGNED_DST_CLAMP (1 << 15)
+/* Alpha bits from R128_REG_MISC_3D_CNTL */
+# define R128_COMPOSITE_SHADOW_CMP_EQUAL (0 << 28)
+# define R128_COMPOSITE_SHADOW_CMP_NEQUAL (1 << 28)
+# define R128_COMPOSITE_SHADOW (1 << 29)
+# define R128_TEX_MAP_ALPHA_IN_TEXTURE (1 << 30)
+# define R128_TEX_CACHE_LINE_SIZE_8QW (0 << 31)
+# define R128_TEX_CACHE_LINE_SIZE_4QW (1 << 31)
+
+#define R128_REG_SCALE_3D_DATATYPE 0x1a20
+
+#define R128_REG_SETUP_CNTL 0x1bc4
+# define R128_DONT_START_TRIANGLE (1 << 0)
+# define R128_Z_BIAS (0 << 1)
+# define R128_DONT_START_ANY_ON (1 << 2)
+# define R128_COLOR_SOLID_COLOR (0 << 3)
+# define R128_COLOR_FLAT_VERT_1 (1 << 3)
+# define R128_COLOR_FLAT_VERT_2 (2 << 3)
+# define R128_COLOR_FLAT_VERT_3 (3 << 3)
+# define R128_COLOR_GOURAUD (4 << 3)
+# define R128_PRIM_TYPE_TRI (0 << 7)
+# define R128_PRIM_TYPE_LINE (1 << 7)
+# define R128_PRIM_TYPE_POINT (2 << 7)
+# define R128_PRIM_TYPE_POLY_EDGE (3 << 7)
+# define R128_TEXTURE_ST_MULT_W (0 << 9)
+# define R128_TEXTURE_ST_DIRECT (1 << 9)
+# define R128_STARTING_VERTEX_1 (1 << 14)
+# define R128_STARTING_VERTEX_2 (2 << 14)
+# define R128_STARTING_VERTEX_3 (3 << 14)
+# define R128_ENDING_VERTEX_1 (1 << 16)
+# define R128_ENDING_VERTEX_2 (2 << 16)
+# define R128_ENDING_VERTEX_3 (3 << 16)
+# define R128_SU_POLY_LINE_LAST (0 << 18)
+# define R128_SU_POLY_LINE_NOT_LAST (1 << 18)
+# define R128_SUB_PIX_2BITS (0 << 19)
+# define R128_SUB_PIX_4BITS (1 << 19)
+# define R128_SET_UP_CONTINUE (1 << 31)
+
+#define R128_REG_WINDOW_XY_OFFSET 0x1bcc
+
+#define RADEON_REG_RB3D_BLENDCNTL 0x1c20
+# define RADEON_COMB_FCN_MASK (3 << 12)
+# define RADEON_COMB_FCN_ADD_CLAMP (0 << 12)
+# define RADEON_COMB_FCN_ADD_NOCLAMP (1 << 12)
+# define RADEON_COMB_FCN_SUB_CLAMP (2 << 12)
+# define RADEON_COMB_FCN_SUB_NOCLAMP (3 << 12)
+# define R200_COMB_FCN_MIN (4 << 12)
+# define R200_COMB_FCN_MAX (5 << 12)
+# define R200_COMB_FCN_RSUB_CLAMP (6 << 12)
+# define R200_COMB_FCN_RSUB_NOCLAMP (7 << 12)
+# define RADEON_SBLEND_GL_ZERO (32 << 16)
+# define RADEON_SBLEND_GL_ONE (33 << 16)
+# define RADEON_SBLEND_GL_SRC_COLOR (34 << 16)
+# define RADEON_SBLEND_GL_INV_SRC_COLOR (35 << 16)
+# define RADEON_SBLEND_GL_DST_COLOR (36 << 16)
+# define RADEON_SBLEND_GL_INV_DST_COLOR (37 << 16)
+# define RADEON_SBLEND_GL_SRC_ALPHA (38 << 16)
+# define RADEON_SBLEND_GL_INV_SRC_ALPHA (39 << 16)
+# define RADEON_SBLEND_GL_DST_ALPHA (40 << 16)
+# define RADEON_SBLEND_GL_INV_DST_ALPHA (41 << 16)
+# define RADEON_SBLEND_GL_SRC_ALPHA_SATURATE (42 << 16)
+# define R200_SBLEND_GL_CONST_COLOR (43 << 16)
+# define R200_SBLEND_GL_ONE_MINUS_CONST_COLOR (44 << 16)
+# define R200_SBLEND_GL_CONST_ALPHA (45 << 16)
+# define R200_SBLEND_GL_ONE_MINUS_CONST_ALPHA (46 << 16)
+# define RADEON_SBLEND_MASK (63 << 16)
+# define RADEON_DBLEND_GL_ZERO (32 << 24)
+# define RADEON_DBLEND_GL_ONE (33 << 24)
+# define RADEON_DBLEND_GL_SRC_COLOR (34 << 24)
+# define RADEON_DBLEND_GL_INV_SRC_COLOR (35 << 24)
+# define RADEON_DBLEND_GL_DST_COLOR (36 << 24)
+# define RADEON_DBLEND_GL_INV_DST_COLOR (37 << 24)
+# define RADEON_DBLEND_GL_SRC_ALPHA (38 << 24)
+# define RADEON_DBLEND_GL_INV_SRC_ALPHA (39 << 24)
+# define RADEON_DBLEND_GL_DST_ALPHA (40 << 24)
+# define RADEON_DBLEND_GL_INV_DST_ALPHA (41 << 24)
+# define R200_DBLEND_GL_CONST_COLOR (43 << 24)
+# define R200_DBLEND_GL_ONE_MINUS_CONST_COLOR (44 << 24)
+# define R200_DBLEND_GL_CONST_ALPHA (45 << 24)
+# define R200_DBLEND_GL_ONE_MINUS_CONST_ALPHA (46 << 24)
+# define RADEON_DBLEND_MASK (63 << 24)
+
+#define RADEON_REG_PP_CNTL 0x1c38
+# define RADEON_STIPPLE_ENABLE (1 << 0)
+# define RADEON_SCISSOR_ENABLE (1 << 1)
+# define RADEON_PATTERN_ENABLE (1 << 2)
+# define RADEON_SHADOW_ENABLE (1 << 3)
+# define RADEON_TEX_ENABLE_MASK (0xf << 4)
+# define RADEON_TEX_0_ENABLE (1 << 4)
+# define RADEON_TEX_1_ENABLE (1 << 5)
+# define RADEON_TEX_2_ENABLE (1 << 6)
+# define RADEON_TEX_3_ENABLE (1 << 7)
+# define R200_TEX_4_ENABLE (1 << 8)
+# define R200_TEX_5_ENABLE (1 << 9)
+# define RADEON_TEX_BLEND_ENABLE_MASK (0xf << 12)
+# define RADEON_TEX_BLEND_0_ENABLE (1 << 12)
+# define RADEON_TEX_BLEND_1_ENABLE (1 << 13)
+# define RADEON_TEX_BLEND_2_ENABLE (1 << 14)
+# define RADEON_TEX_BLEND_3_ENABLE (1 << 15)
+# define R200_TEX_BLEND_4_ENABLE (1 << 16)
+# define R200_TEX_BLEND_5_ENABLE (1 << 17)
+# define R200_TEX_BLEND_6_ENABLE (1 << 18)
+# define RADEON_PLANAR_YUV_ENABLE (1 << 20)
+# define RADEON_SPECULAR_ENABLE (1 << 21)
+# define RADEON_FOG_ENABLE (1 << 22)
+# define RADEON_ALPHA_TEST_ENABLE (1 << 23)
+# define RADEON_ANTI_ALIAS_NONE (0 << 24)
+# define RADEON_ANTI_ALIAS_LINE (1 << 24)
+# define RADEON_ANTI_ALIAS_POLY (2 << 24)
+# define RADEON_ANTI_ALIAS_LINE_POLY (3 << 24)
+# define RADEON_BUMP_MAP_ENABLE (1 << 26)
+# define RADEON_BUMPED_MAP_T0 (0 << 27)
+# define RADEON_BUMPED_MAP_T1 (1 << 27)
+# define RADEON_BUMPED_MAP_T2 (2 << 27)
+# define RADEON_TEX_3D_ENABLE_0 (1 << 29)
+# define RADEON_TEX_3D_ENABLE_1 (1 << 30)
+# define RADEON_MC_ENABLE (1 << 31)
+
+#define RADEON_REG_RB3D_CNTL 0x1c3c
+# define RADEON_ALPHA_BLEND_ENABLE (1 << 0)
+# define RADEON_PLANE_MASK_ENABLE (1 << 1)
+# define RADEON_DITHER_ENABLE (1 << 2)
+# define RADEON_ROUND_ENABLE (1 << 3)
+# define RADEON_SCALE_DITHER_ENABLE (1 << 4)
+# define RADEON_DITHER_INIT (1 << 5)
+# define RADEON_ROP_ENABLE (1 << 6)
+# define RADEON_STENCIL_ENABLE (1 << 7)
+# define RADEON_Z_ENABLE (1 << 8)
+# define RADEON_DEPTH_XZ_OFFEST_ENABLE (1 << 9)
+# define RADEON_COLOR_FORMAT_ARGB1555 (3 << 10)
+# define RADEON_COLOR_FORMAT_RGB565 (4 << 10)
+# define RADEON_COLOR_FORMAT_ARGB8888 (6 << 10)
+# define RADEON_COLOR_FORMAT_RGB332 (7 << 10)
+# define RADEON_COLOR_FORMAT_Y8 (8 << 10)
+# define RADEON_COLOR_FORMAT_RGB8 (9 << 10)
+# define RADEON_COLOR_FORMAT_YUV422_VYUY (11 << 10)
+# define RADEON_COLOR_FORMAT_YUV422_YVYU (12 << 10)
+# define RADEON_COLOR_FORMAT_aYUV444 (14 << 10)
+# define RADEON_COLOR_FORMAT_ARGB4444 (15 << 10)
+# define RADEON_CLRCMP_FLIP_ENABLE (1 << 14)
+
+#define RADEON_REG_RB3D_COLOROFFSET 0x1c40
+# define RADEON_COLOROFFSET_MASK 0xfffffff0
+
+#define RADEON_REG_RE_WIDTH_HEIGHT 0x1c44
+
+#define RADEON_REG_RB3D_COLORPITCH 0x1c48
+# define RADEON_COLORPITCH_MASK 0x000001ff8
+# define RADEON_COLOR_TILE_ENABLE (1 << 16)
+# define RADEON_COLOR_MICROTILE_ENABLE (1 << 17)
+# define RADEON_COLOR_ENDIAN_NO_SWAP (0 << 18)
+# define RADEON_COLOR_ENDIAN_WORD_SWAP (1 << 18)
+# define RADEON_COLOR_ENDIAN_DWORD_SWAP (2 << 18)
+
+#define RADEON_REG_SE_CNTL 0x1c4c
+# define RADEON_FFACE_CULL_CW (0 << 0)
+# define RADEON_FFACE_CULL_CCW (1 << 0)
+# define RADEON_FFACE_CULL_DIR_MASK (1 << 0)
+# define RADEON_BFACE_CULL (0 << 1)
+# define RADEON_BFACE_SOLID (3 << 1)
+# define RADEON_FFACE_CULL (0 << 3)
+# define RADEON_FFACE_SOLID (3 << 3)
+# define RADEON_FFACE_CULL_MASK (3 << 3)
+# define RADEON_BADVTX_CULL_DISABLE (1 << 5)
+# define RADEON_FLAT_SHADE_VTX_0 (0 << 6)
+# define RADEON_FLAT_SHADE_VTX_1 (1 << 6)
+# define RADEON_FLAT_SHADE_VTX_2 (2 << 6)
+# define RADEON_FLAT_SHADE_VTX_LAST (3 << 6)
+# define RADEON_DIFFUSE_SHADE_SOLID (0 << 8)
+# define RADEON_DIFFUSE_SHADE_FLAT (1 << 8)
+# define RADEON_DIFFUSE_SHADE_GOURAUD (2 << 8)
+# define RADEON_DIFFUSE_SHADE_MASK (3 << 8)
+# define RADEON_ALPHA_SHADE_SOLID (0 << 10)
+# define RADEON_ALPHA_SHADE_FLAT (1 << 10)
+# define RADEON_ALPHA_SHADE_GOURAUD (2 << 10)
+# define RADEON_ALPHA_SHADE_MASK (3 << 10)
+# define RADEON_SPECULAR_SHADE_SOLID (0 << 12)
+# define RADEON_SPECULAR_SHADE_FLAT (1 << 12)
+# define RADEON_SPECULAR_SHADE_GOURAUD (2 << 12)
+# define RADEON_SPECULAR_SHADE_MASK (3 << 12)
+# define RADEON_FOG_SHADE_SOLID (0 << 14)
+# define RADEON_FOG_SHADE_FLAT (1 << 14)
+# define RADEON_FOG_SHADE_GOURAUD (2 << 14)
+# define RADEON_FOG_SHADE_MASK (3 << 14)
+# define RADEON_ZBIAS_ENABLE_POINT (1 << 16)
+# define RADEON_ZBIAS_ENABLE_LINE (1 << 17)
+# define RADEON_ZBIAS_ENABLE_TRI (1 << 18)
+# define RADEON_WIDELINE_ENABLE (1 << 20)
+# define RADEON_VPORT_XY_XFORM_ENABLE (1 << 24)
+# define RADEON_VPORT_Z_XFORM_ENABLE (1 << 25)
+# define RADEON_VTX_PIX_CENTER_D3D (0 << 27)
+# define RADEON_VTX_PIX_CENTER_OGL (1 << 27)
+# define RADEON_ROUND_MODE_TRUNC (0 << 28)
+# define RADEON_ROUND_MODE_ROUND (1 << 28)
+# define RADEON_ROUND_MODE_ROUND_EVEN (2 << 28)
+# define RADEON_ROUND_MODE_ROUND_ODD (3 << 28)
+# define RADEON_ROUND_PREC_16TH_PIX (0 << 30)
+# define RADEON_ROUND_PREC_8TH_PIX (1 << 30)
+# define RADEON_ROUND_PREC_4TH_PIX (2 << 30)
+# define RADEON_ROUND_PREC_HALF_PIX (3 << 30)
+
+#define R200_REG_RE_CNTL 0x1c50
+
+#define RADEON_REG_SE_COORD_FMT 0x1c50
+# define RADEON_VTX_XY_PRE_MULT_1_OVER_W0 (1 << 0)
+# define RADEON_VTX_Z_PRE_MULT_1_OVER_W0 (1 << 1)
+# define RADEON_VTX_ST0_NONPARAMETRIC (1 << 8)
+# define RADEON_VTX_ST1_NONPARAMETRIC (1 << 9)
+# define RADEON_VTX_ST2_NONPARAMETRIC (1 << 10)
+# define RADEON_VTX_ST3_NONPARAMETRIC (1 << 11)
+# define RADEON_VTX_W0_NORMALIZE (1 << 12)
+# define RADEON_VTX_W0_IS_NOT_1_OVER_W0 (1 << 16)
+# define RADEON_VTX_ST0_PRE_MULT_1_OVER_W0 (1 << 17)
+# define RADEON_VTX_ST1_PRE_MULT_1_OVER_W0 (1 << 19)
+# define RADEON_VTX_ST2_PRE_MULT_1_OVER_W0 (1 << 21)
+# define RADEON_VTX_ST3_PRE_MULT_1_OVER_W0 (1 << 23)
+# define RADEON_TEX1_W_ROUTING_USE_W0 (0 << 26)
+# define RADEON_TEX1_W_ROUTING_USE_Q1 (1 << 26)
+
+#define RADEON_REG_PP_TXFILTER_0 0x1c54
+#define RADEON_REG_PP_TXFILTER_1 0x1c6c
+#define RADEON_REG_PP_TXFILTER_2 0x1c84
+# define RADEON_MAG_FILTER_NEAREST (0 << 0)
+# define RADEON_MAG_FILTER_LINEAR (1 << 0)
+# define RADEON_MAG_FILTER_MASK (1 << 0)
+# define RADEON_MIN_FILTER_NEAREST (0 << 1)
+# define RADEON_MIN_FILTER_LINEAR (1 << 1)
+# define RADEON_MIN_FILTER_NEAREST_MIP_NEAREST (2 << 1)
+# define RADEON_MIN_FILTER_NEAREST_MIP_LINEAR (3 << 1)
+# define RADEON_MIN_FILTER_LINEAR_MIP_NEAREST (6 << 1)
+# define RADEON_MIN_FILTER_LINEAR_MIP_LINEAR (7 << 1)
+# define RADEON_MIN_FILTER_ANISO_NEAREST (8 << 1)
+# define RADEON_MIN_FILTER_ANISO_LINEAR (9 << 1)
+# define RADEON_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST (10 << 1)
+# define RADEON_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR (11 << 1)
+# define RADEON_MIN_FILTER_MASK (15 << 1)
+# define RADEON_MAX_ANISO_1_TO_1 (0 << 5)
+# define RADEON_MAX_ANISO_2_TO_1 (1 << 5)
+# define RADEON_MAX_ANISO_4_TO_1 (2 << 5)
+# define RADEON_MAX_ANISO_8_TO_1 (3 << 5)
+# define RADEON_MAX_ANISO_16_TO_1 (4 << 5)
+# define RADEON_MAX_ANISO_MASK (7 << 5)
+# define RADEON_LOD_BIAS_MASK (0xff << 8)
+# define RADEON_LOD_BIAS_SHIFT 8
+# define RADEON_MAX_MIP_LEVEL_MASK (0x0f << 16)
+# define RADEON_MAX_MIP_LEVEL_SHIFT 16
+# define RADEON_YUV_TO_RGB (1 << 20)
+# define RADEON_YUV_TEMPERATURE_COOL (0 << 21)
+# define RADEON_YUV_TEMPERATURE_HOT (1 << 21)
+# define RADEON_YUV_TEMPERATURE_MASK (1 << 21)
+# define RADEON_WRAPEN_S (1 << 22)
+# define RADEON_CLAMP_S_WRAP (0 << 23)
+# define RADEON_CLAMP_S_MIRROR (1 << 23)
+# define RADEON_CLAMP_S_CLAMP_LAST (2 << 23)
+# define RADEON_CLAMP_S_MIRROR_CLAMP_LAST (3 << 23)
+# define RADEON_CLAMP_S_CLAMP_BORDER (4 << 23)
+# define RADEON_CLAMP_S_MIRROR_CLAMP_BORDER (5 << 23)
+# define RADEON_CLAMP_S_CLAMP_GL (6 << 23)
+# define RADEON_CLAMP_S_MIRROR_CLAMP_GL (7 << 23)
+# define RADEON_CLAMP_S_MASK (7 << 23)
+# define RADEON_WRAPEN_T (1 << 26)
+# define RADEON_CLAMP_T_WRAP (0 << 27)
+# define RADEON_CLAMP_T_MIRROR (1 << 27)
+# define RADEON_CLAMP_T_CLAMP_LAST (2 << 27)
+# define RADEON_CLAMP_T_MIRROR_CLAMP_LAST (3 << 27)
+# define RADEON_CLAMP_T_CLAMP_BORDER (4 << 27)
+# define RADEON_CLAMP_T_MIRROR_CLAMP_BORDER (5 << 27)
+# define RADEON_CLAMP_T_CLAMP_GL (6 << 27)
+# define RADEON_CLAMP_T_MIRROR_CLAMP_GL (7 << 27)
+# define RADEON_CLAMP_T_MASK (7 << 27)
+# define RADEON_BORDER_MODE_OGL (0 << 31)
+# define RADEON_BORDER_MODE_D3D (1 << 31)
+
+#define RADEON_REG_PP_TXFORMAT_0 0x1c58
+#define RADEON_REG_PP_TXFORMAT_1 0x1c70
+#define RADEON_REG_PP_TXFORMAT_2 0x1c88
+# define RADEON_TXFORMAT_I8 (0 << 0)
+# define RADEON_TXFORMAT_AI88 (1 << 0)
+# define RADEON_TXFORMAT_RGB332 (2 << 0)
+# define RADEON_TXFORMAT_ARGB1555 (3 << 0)
+# define RADEON_TXFORMAT_RGB565 (4 << 0)
+# define RADEON_TXFORMAT_ARGB4444 (5 << 0)
+# define RADEON_TXFORMAT_ARGB8888 (6 << 0)
+# define RADEON_TXFORMAT_RGBA8888 (7 << 0)
+# define RADEON_TXFORMAT_Y8 (8 << 0)
+# define RADEON_TXFORMAT_AYUV444 (9 << 0)
+# define RADEON_TXFORMAT_VYUY422 (10 << 0)
+# define RADEON_TXFORMAT_YVYU422 (11 << 0)
+# define RADEON_TXFORMAT_DXT1 (12 << 0)
+# define RADEON_TXFORMAT_DXT23 (14 << 0)
+# define RADEON_TXFORMAT_DXT45 (15 << 0)
+# define RADEON_TXFORMAT_FORMAT_MASK (31 << 0)
+# define RADEON_TXFORMAT_FORMAT_SHIFT 0
+# define RADEON_TXFORMAT_APPLE_YUV_MODE (1 << 5)
+# define RADEON_TXFORMAT_ALPHA_IN_MAP (1 << 6)
+# define RADEON_TXFORMAT_NON_POWER2 (1 << 7)
+# define RADEON_TXFORMAT_WIDTH_MASK (15 << 8)
+# define RADEON_TXFORMAT_WIDTH_SHIFT 8
+# define RADEON_TXFORMAT_HEIGHT_MASK (15 << 12)
+# define RADEON_TXFORMAT_HEIGHT_SHIFT 12
+# define RADEON_TXFORMAT_F5_WIDTH_MASK (15 << 16)
+# define RADEON_TXFORMAT_F5_WIDTH_SHIFT 16
+# define RADEON_TXFORMAT_F5_HEIGHT_MASK (15 << 20)
+# define RADEON_TXFORMAT_F5_HEIGHT_SHIFT 20
+# define RADEON_TXFORMAT_ST_ROUTE_STQ0 (0 << 24)
+# define RADEON_TXFORMAT_ST_ROUTE_STQ1 (1 << 24)
+# define RADEON_TXFORMAT_ST_ROUTE_STQ2 (2 << 24)
+# define RADEON_TXFORMAT_ST_ROUTE_MASK (3 << 24)
+# define RADEON_TXFORMAT_ENDIAN_NO_SWAP (0 << 26)
+# define RADEON_TXFORMAT_ENDIAN_16BPP_SWAP (1 << 26)
+# define RADEON_TXFORMAT_ENDIAN_32BPP_SWAP (2 << 26)
+# define RADEON_TXFORMAT_ENDIAN_HALFDW_SWAP (3 << 26)
+# define RADEON_TXFORMAT_ALPHA_MASK_ENABLE (1 << 28)
+# define RADEON_TXFORMAT_CHROMA_KEY_ENABLE (1 << 29)
+# define RADEON_TXFORMAT_CUBIC_MAP_ENABLE (1 << 30)
+# define RADEON_TXFORMAT_PERSPECTIVE_ENABLE (1 << 31)
+
+#define RADEON_REG_PP_TXOFFSET_0 0x1c5c
+#define RADEON_REG_PP_TXOFFSET_1 0x1c74
+#define RADEON_REG_PP_TXOFFSET_2 0x1c8c
+# define RADEON_TXO_ENDIAN_NO_SWAP (0 << 0)
+# define RADEON_TXO_ENDIAN_BYTE_SWAP (1 << 0)
+# define RADEON_TXO_ENDIAN_WORD_SWAP (2 << 0)
+# define RADEON_TXO_ENDIAN_HALFDW_SWAP (3 << 0)
+# define RADEON_TXO_MACRO_LINEAR (0 << 2)
+# define RADEON_TXO_MACRO_TILE (1 << 2)
+# define RADEON_TXO_MICRO_LINEAR (0 << 3)
+# define RADEON_TXO_MICRO_TILE_X2 (1 << 3)
+# define RADEON_TXO_MICRO_TILE_OPT (2 << 3)
+# define RADEON_TXO_OFFSET_MASK 0xffffffe0
+# define RADEON_TXO_OFFSET_SHIFT 5
+
+#define RADEON_REG_PP_TXCBLEND_0 0x1c60
+#define RADEON_REG_PP_TXCBLEND_1 0x1c78
+#define RADEON_REG_PP_TXCBLEND_2 0x1c90
+# define RADEON_COLOR_ARG_A_SHIFT 0
+# define RADEON_COLOR_ARG_A_MASK (0x1f << 0)
+# define RADEON_COLOR_ARG_A_ZERO (0 << 0)
+# define RADEON_COLOR_ARG_A_CURRENT_COLOR (2 << 0)
+# define RADEON_COLOR_ARG_A_CURRENT_ALPHA (3 << 0)
+# define RADEON_COLOR_ARG_A_DIFFUSE_COLOR (4 << 0)
+# define RADEON_COLOR_ARG_A_DIFFUSE_ALPHA (5 << 0)
+# define RADEON_COLOR_ARG_A_SPECULAR_COLOR (6 << 0)
+# define RADEON_COLOR_ARG_A_SPECULAR_ALPHA (7 << 0)
+# define RADEON_COLOR_ARG_A_TFACTOR_COLOR (8 << 0)
+# define RADEON_COLOR_ARG_A_TFACTOR_ALPHA (9 << 0)
+# define RADEON_COLOR_ARG_A_T0_COLOR (10 << 0)
+# define RADEON_COLOR_ARG_A_T0_ALPHA (11 << 0)
+# define RADEON_COLOR_ARG_A_T1_COLOR (12 << 0)
+# define RADEON_COLOR_ARG_A_T1_ALPHA (13 << 0)
+# define RADEON_COLOR_ARG_A_T2_COLOR (14 << 0)
+# define RADEON_COLOR_ARG_A_T2_ALPHA (15 << 0)
+# define RADEON_COLOR_ARG_A_T3_COLOR (16 << 0)
+# define RADEON_COLOR_ARG_A_T3_ALPHA (17 << 0)
+# define RADEON_COLOR_ARG_B_SHIFT 5
+# define RADEON_COLOR_ARG_B_MASK (0x1f << 5)
+# define RADEON_COLOR_ARG_B_ZERO (0 << 5)
+# define RADEON_COLOR_ARG_B_CURRENT_COLOR (2 << 5)
+# define RADEON_COLOR_ARG_B_CURRENT_ALPHA (3 << 5)
+# define RADEON_COLOR_ARG_B_DIFFUSE_COLOR (4 << 5)
+# define RADEON_COLOR_ARG_B_DIFFUSE_ALPHA (5 << 5)
+# define RADEON_COLOR_ARG_B_SPECULAR_COLOR (6 << 5)
+# define RADEON_COLOR_ARG_B_SPECULAR_ALPHA (7 << 5)
+# define RADEON_COLOR_ARG_B_TFACTOR_COLOR (8 << 5)
+# define RADEON_COLOR_ARG_B_TFACTOR_ALPHA (9 << 5)
+# define RADEON_COLOR_ARG_B_T0_COLOR (10 << 5)
+# define RADEON_COLOR_ARG_B_T0_ALPHA (11 << 5)
+# define RADEON_COLOR_ARG_B_T1_COLOR (12 << 5)
+# define RADEON_COLOR_ARG_B_T1_ALPHA (13 << 5)
+# define RADEON_COLOR_ARG_B_T2_COLOR (14 << 5)
+# define RADEON_COLOR_ARG_B_T2_ALPHA (15 << 5)
+# define RADEON_COLOR_ARG_B_T3_COLOR (16 << 5)
+# define RADEON_COLOR_ARG_B_T3_ALPHA (17 << 5)
+# define RADEON_COLOR_ARG_C_SHIFT 10
+# define RADEON_COLOR_ARG_C_MASK (0x1f << 10)
+# define RADEON_COLOR_ARG_C_ZERO (0 << 10)
+# define RADEON_COLOR_ARG_C_CURRENT_COLOR (2 << 10)
+# define RADEON_COLOR_ARG_C_CURRENT_ALPHA (3 << 10)
+# define RADEON_COLOR_ARG_C_DIFFUSE_COLOR (4 << 10)
+# define RADEON_COLOR_ARG_C_DIFFUSE_ALPHA (5 << 10)
+# define RADEON_COLOR_ARG_C_SPECULAR_COLOR (6 << 10)
+# define RADEON_COLOR_ARG_C_SPECULAR_ALPHA (7 << 10)
+# define RADEON_COLOR_ARG_C_TFACTOR_COLOR (8 << 10)
+# define RADEON_COLOR_ARG_C_TFACTOR_ALPHA (9 << 10)
+# define RADEON_COLOR_ARG_C_T0_COLOR (10 << 10)
+# define RADEON_COLOR_ARG_C_T0_ALPHA (11 << 10)
+# define RADEON_COLOR_ARG_C_T1_COLOR (12 << 10)
+# define RADEON_COLOR_ARG_C_T1_ALPHA (13 << 10)
+# define RADEON_COLOR_ARG_C_T2_COLOR (14 << 10)
+# define RADEON_COLOR_ARG_C_T2_ALPHA (15 << 10)
+# define RADEON_COLOR_ARG_C_T3_COLOR (16 << 10)
+# define RADEON_COLOR_ARG_C_T3_ALPHA (17 << 10)
+# define RADEON_COMP_ARG_A (1 << 15)
+# define RADEON_COMP_ARG_A_SHIFT 15
+# define RADEON_COMP_ARG_B (1 << 16)
+# define RADEON_COMP_ARG_B_SHIFT 16
+# define RADEON_COMP_ARG_C (1 << 17)
+# define RADEON_COMP_ARG_C_SHIFT 17
+# define RADEON_BLEND_CTL_MASK (7 << 18)
+# define RADEON_BLEND_CTL_ADD (0 << 18)
+# define RADEON_BLEND_CTL_SUBTRACT (1 << 18)
+# define RADEON_BLEND_CTL_ADDSIGNED (2 << 18)
+# define RADEON_BLEND_CTL_BLEND (3 << 18)
+# define RADEON_BLEND_CTL_DOT3 (4 << 18)
+# define RADEON_SCALE_SHIFT 21
+# define RADEON_SCALE_MASK (3 << 21)
+# define RADEON_SCALE_1X (0 << 21)
+# define RADEON_SCALE_2X (1 << 21)
+# define RADEON_SCALE_4X (2 << 21)
+# define RADEON_CLAMP_TX (1 << 23)
+# define RADEON_T0_EQ_TCUR (1 << 24)
+# define RADEON_T1_EQ_TCUR (1 << 25)
+# define RADEON_T2_EQ_TCUR (1 << 26)
+# define RADEON_T3_EQ_TCUR (1 << 27)
+# define RADEON_COLOR_ARG_MASK 0x1f
+# define RADEON_COMP_ARG_SHIFT 15
+
+#define RADEON_REG_PP_TXABLEND_0 0x1c64
+#define RADEON_REG_PP_TXABLEND_1 0x1c7c
+#define RADEON_REG_PP_TXABLEND_2 0x1c94
+# define RADEON_ALPHA_ARG_A_SHIFT 0
+# define RADEON_ALPHA_ARG_A_MASK (0xf << 0)
+# define RADEON_ALPHA_ARG_A_ZERO (0 << 0)
+# define RADEON_ALPHA_ARG_A_CURRENT_ALPHA (1 << 0)
+# define RADEON_ALPHA_ARG_A_DIFFUSE_ALPHA (2 << 0)
+# define RADEON_ALPHA_ARG_A_SPECULAR_ALPHA (3 << 0)
+# define RADEON_ALPHA_ARG_A_TFACTOR_ALPHA (4 << 0)
+# define RADEON_ALPHA_ARG_A_T0_ALPHA (5 << 0)
+# define RADEON_ALPHA_ARG_A_T1_ALPHA (6 << 0)
+# define RADEON_ALPHA_ARG_A_T2_ALPHA (7 << 0)
+# define RADEON_ALPHA_ARG_A_T3_ALPHA (8 << 0)
+# define RADEON_ALPHA_ARG_B_SHIFT 4
+# define RADEON_ALPHA_ARG_B_MASK (0xf << 4)
+# define RADEON_ALPHA_ARG_B_ZERO (0 << 4)
+# define RADEON_ALPHA_ARG_B_CURRENT_ALPHA (1 << 4)
+# define RADEON_ALPHA_ARG_B_DIFFUSE_ALPHA (2 << 4)
+# define RADEON_ALPHA_ARG_B_SPECULAR_ALPHA (3 << 4)
+# define RADEON_ALPHA_ARG_B_TFACTOR_ALPHA (4 << 4)
+# define RADEON_ALPHA_ARG_B_T0_ALPHA (5 << 4)
+# define RADEON_ALPHA_ARG_B_T1_ALPHA (6 << 4)
+# define RADEON_ALPHA_ARG_B_T2_ALPHA (7 << 4)
+# define RADEON_ALPHA_ARG_B_T3_ALPHA (8 << 4)
+# define RADEON_ALPHA_ARG_C_SHIFT 8
+# define RADEON_ALPHA_ARG_C_MASK (0xf << 8)
+# define RADEON_ALPHA_ARG_C_ZERO (0 << 8)
+# define RADEON_ALPHA_ARG_C_CURRENT_ALPHA (1 << 8)
+# define RADEON_ALPHA_ARG_C_DIFFUSE_ALPHA (2 << 8)
+# define RADEON_ALPHA_ARG_C_SPECULAR_ALPHA (3 << 8)
+# define RADEON_ALPHA_ARG_C_TFACTOR_ALPHA (4 << 8)
+# define RADEON_ALPHA_ARG_C_T0_ALPHA (5 << 8)
+# define RADEON_ALPHA_ARG_C_T1_ALPHA (6 << 8)
+# define RADEON_ALPHA_ARG_C_T2_ALPHA (7 << 8)
+# define RADEON_ALPHA_ARG_C_T3_ALPHA (8 << 8)
+# define RADEON_DOT_ALPHA_DONT_REPLICATE (1 << 9)
+/* COMP_ARG, BLEND_CNTL, CLAMP_TX same as for CBLEND, T*_EQ_TCUR */
+# define RADEON_ALPHA_ARG_MASK 0xf
+
+#define RADEON_REG_PP_TFACTOR_0 0x1c68
+#define RADEON_REG_PP_TFACTOR_1 0x1c80
+#define RADEON_REG_PP_TFACTOR_2 0x1c98
+
+#define R128_REG_TEX_CNTL_C 0x1c9c
+# define R128_Z_ENABLE (1 << 0)
+# define R128_Z_WRITE_ENABLE (1 << 1)
+# define R128_STENCIL_ENABLE (1 << 3)
+# define R128_SHADE_ENABLE (0 << 4)
+# define R128_TEXMAP_ENABLE (1 << 4)
+# define R128_SEC_TEXMAP_ENABLE (1 << 5)
+# define R128_FOG_ENABLE (1 << 7)
+# define R128_DITHER_ENABLE (1 << 8)
+# define R128_ALPHA_ENABLE (1 << 9)
+# define R128_ALPHA_TEST_ENABLE (1 << 10)
+# define R128_SPEC_LIGHT_ENABLE (1 << 11)
+# define R128_TEX_CHROMA_KEY_ENABLE (1 << 12)
+# define R128_ALPHA_IN_TEX_COMPLETE_A (0 << 13)
+# define R128_ALPHA_IN_TEX_LSB_A (1 << 13)
+# define R128_LIGHT_DIS (0 << 14)
+# define R128_LIGHT_COPY (1 << 14)
+# define R128_LIGHT_MODULATE (2 << 14)
+# define R128_LIGHT_ADD (3 << 14)
+# define R128_LIGHT_BLEND_CONSTANT (4 << 14)
+# define R128_LIGHT_BLEND_TEXTURE (5 << 14)
+# define R128_LIGHT_BLEND_VERTEX (6 << 14)
+# define R128_LIGHT_BLEND_CONST_COLOR (7 << 14)
+# define R128_ALPHA_LIGHT_DIS (0 << 18)
+# define R128_ALPHA_LIGHT_COPY (1 << 18)
+# define R128_ALPHA_LIGHT_MODULATE (2 << 18)
+# define R128_ALPHA_LIGHT_ADD (3 << 18)
+# define R128_ANTI_ALIAS (1 << 21)
+# define R128_TEX_CACHE_FLUSH (1 << 23)
+# define R128_LOD_BIAS_SHIFT 24
+# define R128_LOD_BIAS_MASK (0xff << 24)
+
+#define R128_REG_MISC_3D_STATE_CNTL 0x1ca0
+# define R128_REF_ALPHA_MASK 0xff
+# define R128_MISC_SCALE_3D_NOOP (0 << 8)
+# define R128_MISC_SCALE_3D_SCALE (1 << 8)
+# define R128_MISC_SCALE_3D_TEXMAP_SHADE (2 << 8)
+# define R128_MISC_SCALE_PIX_BLEND (0 << 10)
+# define R128_MISC_SCALE_PIX_REPLICATE (1 << 10)
+# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12)
+# define R128_ALPHA_COMB_ADD_NO_CLAMP (1 << 12)
+# define R128_ALPHA_COMB_SUB_SRC_DST_CLAMP (2 << 12)
+# define R128_ALPHA_COMB_SUB_SRC_DST_NO_CLAMP (3 << 12)
+# define R128_FOG_VERTEX (0 << 14)
+# define R128_FOG_TABLE (1 << 14)
+# define R128_SBLEND_ZERO (0 << 16)
+# define R128_SBLEND_ONE (1 << 16)
+# define R128_SBLEND_SRCCOLOR (2 << 16)
+# define R128_SBLEND_INVSRCCOLOR (3 << 16)
+# define R128_SBLEND_SRC_ALPHA (4 << 16)
+# define R128_SBLEND_INV_SRC_ALPHA (5 << 16)
+# define R128_SBLEND_DST_ALPHA (6 << 16)
+# define R128_SBLEND_INV_DST_ALPHA (7 << 16)
+# define R128_SBLEND_DSTCOLOR (8 << 16)
+# define R128_SBLEND_INVDSTCOLOR (9 << 16)
+# define R128_SBLEND_SRC_ALPHASAT (10 << 16)
+# define R128_SBLEND_BOTHSRC_ALPHA (11 << 16)
+# define R128_SBLEND_BOTHINV_SRC_ALPHA (12 << 16)
+# define R128_SBLEND_MASK (15 << 16)
+# define R128_DBLEND_ZERO (0 << 20)
+# define R128_DBLEND_ONE (1 << 20)
+# define R128_DBLEND_SRCCOLOR (2 << 20)
+# define R128_DBLEND_INVSRCCOLOR (3 << 20)
+# define R128_DBLEND_SRC_ALPHA (4 << 20)
+# define R128_DBLEND_INV_SRC_ALPHA (5 << 20)
+# define R128_DBLEND_DST_ALPHA (6 << 20)
+# define R128_DBLEND_INV_DST_ALPHA (7 << 20)
+# define R128_DBLEND_DSTCOLOR (8 << 20)
+# define R128_DBLEND_INVDSTCOLOR (9 << 20)
+# define R128_DBLEND_SRC_ALPHASAT (10 << 20)
+# define R128_DBLEND_MASK (15 << 20)
+# define R128_ALPHA_TEST_NEVER (0 << 24)
+# define R128_ALPHA_TEST_LESS (1 << 24)
+# define R128_ALPHA_TEST_LESSEQUAL (2 << 24)
+# define R128_ALPHA_TEST_EQUAL (3 << 24)
+# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24)
+# define R128_ALPHA_TEST_GREATER (5 << 24)
+# define R128_ALPHA_TEST_NEQUAL (6 << 24)
+# define R128_ALPHA_TEST_ALWAYS (7 << 24)
+# define R128_ALPHA_TEST_MASK (7 << 24)
+
+#define R128_REG_PRIM_TEX_CNTL_C 0x1cb0
+#define R128_REG_SEC_TEX_CNTL_C 0x1d00
+# define R128_SEC_SELECT_PRIM_ST (0 << 0)
+# define R128_SEC_SELECT_SEC_ST (1 << 0)
+# define R128_MIN_BLEND_NEAREST (0 << 1)
+# define R128_MIN_BLEND_LINEAR (1 << 1)
+# define R128_MIN_BLEND_MIPNEAREST (2 << 1)
+# define R128_MIN_BLEND_MIPLINEAR (3 << 1)
+# define R128_MIN_BLEND_LINEARMIPNEAREST (4 << 1)
+# define R128_MIN_BLEND_LINEARMIPLINEAR (5 << 1)
+# define R128_MIN_BLEND_MASK (7 << 1)
+# define R128_MAG_BLEND_NEAREST (0 << 4)
+# define R128_MAG_BLEND_LINEAR (1 << 4)
+# define R128_MAG_BLEND_MASK (7 << 4)
+# define R128_MIP_MAP_DISABLE (1 << 7)
+# define R128_TEX_CLAMP_S_WRAP (0 << 8)
+# define R128_TEX_CLAMP_S_MIRROR (1 << 8)
+# define R128_TEX_CLAMP_S_CLAMP (2 << 8)
+# define R128_TEX_CLAMP_S_BORDER_COLOR (3 << 8)
+# define R128_TEX_CLAMP_S_MASK (3 << 8)
+# define R128_TEX_WRAP_S (1 << 10)
+# define R128_TEX_CLAMP_T_WRAP (0 << 11)
+# define R128_TEX_CLAMP_T_MIRROR (1 << 11)
+# define R128_TEX_CLAMP_T_CLAMP (2 << 11)
+# define R128_TEX_CLAMP_T_BORDER_COLOR (3 << 11)
+# define R128_TEX_CLAMP_T_MASK (3 << 11)
+# define R128_TEX_WRAP_T (1 << 13)
+# define R128_TEX_PERSPECTIVE_DISABLE (1 << 14)
+# define R128_TEX_DATATYPE_SHIFT 16
+# define R128_PALLETE_EITHER (0 << 20)
+# define R128_PALLETE_1 (1 << 20)
+# define R128_PALLETE_2 (2 << 20)
+# define R128_PSEUDOCOLOR_DT_RGB565 (0 << 24)
+# define R128_PSEUDOCOLOR_DT_ARGB1555 (1 << 24)
+# define R128_PSEUDOCOLOR_DT_ARGB4444 (2 << 24)
+
+#define R128_REG_PRIM_TEXTURE_COMBINE_CNTL_C 0x1cb4
+#define R128_REG_SEC_TEXTURE_COMBINE_CNTL_C 0x1d04
+# define R128_COMB_DIS (0 << 0)
+# define R128_COMB_COPY (1 << 0)
+# define R128_COMB_COPY_INP (2 << 0)
+# define R128_COMB_MODULATE (3 << 0)
+# define R128_COMB_MODULATE2X (4 << 0)
+# define R128_COMB_MODULATE4X (5 << 0)
+# define R128_COMB_ADD (6 << 0)
+# define R128_COMB_ADD_SIGNED (7 << 0)
+# define R128_COMB_BLEND_VERTEX (8 << 0)
+# define R128_COMB_BLEND_TEXTURE (9 << 0)
+# define R128_COMB_BLEND_CONST (10 << 0)
+# define R128_COMB_BLEND_PREMULT (11 << 0)
+# define R128_COMB_BLEND_PREV (12 << 0)
+# define R128_COMB_BLEND_PREMULT_INV (13 << 0)
+# define R128_COMB_ADD_SIGNED2X (14 << 0)
+# define R128_COMB_BLEND_CONST_COLOR (15 << 0)
+# define R128_COMB_MASK (15 << 0)
+# define R128_COLOR_FACTOR_CONST_COLOR (0 << 4)
+# define R128_COLOR_FACTOR_NCONST_COLOR (1 << 4)
+# define R128_COLOR_FACTOR_TEX (4 << 4)
+# define R128_COLOR_FACTOR_NTEX (5 << 4)
+# define R128_COLOR_FACTOR_ALPHA (6 << 4)
+# define R128_COLOR_FACTOR_NALPHA (7 << 4)
+# define R128_COLOR_FACTOR_PREV_COLOR (8 << 4)
+# define R128_COLOR_FACTOR_MASK (15 << 4)
+# define R128_COMB_FCN_MSB (1 << 8)
+# define R128_INPUT_FACTOR_CONST_COLOR (2 << 10)
+# define R128_INPUT_FACTOR_CONST_ALPHA (3 << 10)
+# define R128_INPUT_FACTOR_INT_COLOR (4 << 10)
+# define R128_INPUT_FACTOR_INT_ALPHA (5 << 10)
+# define R128_INPUT_FACTOR_PREV_COLOR (8 << 10) /* SEC only */
+# define R128_INPUT_FACTOR_PREV_ALPHA (9 << 10) /* SEC only */
+# define R128_INPUT_FACTOR_MASK (15 << 10)
+# define R128_COMB_ALPHA_DIS (0 << 14)
+# define R128_COMB_ALPHA_COPY (1 << 14)
+# define R128_COMB_ALPHA_COPY_INP (2 << 14)
+# define R128_COMB_ALPHA_MODULATE (3 << 14)
+# define R128_COMB_ALPHA_MODULATE2X (4 << 14)
+# define R128_COMB_ALPHA_MODULATE4X (5 << 14)
+# define R128_COMB_ALPHA_ADD (6 << 14)
+# define R128_COMB_ALPHA_ADD_SIGNED (7 << 14)
+# define R128_COMB_ALPHA_ADD_SIGNED2X (14 << 14)
+# define R128_COMB_ALPHA_MASK (15 << 14)
+# define R128_ALPHA_FACTOR_TEX_ALPHA (6 << 18)
+# define R128_ALPHA_FACTOR_NTEX_ALPHA (7 << 18)
+# define R128_ALPHA_FACTOR_MASK (15 << 18)
+# define R128_INP_FACTOR_A_CONST_ALPHA (1 << 25)
+# define R128_INP_FACTOR_A_INT_ALPHA (2 << 25)
+# define R128_INP_FACTOR_A_PREV_ALPHA (4 << 25) /* SEC only */
+# define R128_INP_FACTOR_A_MASK (7 << 25)
+
+#define R128_REG_TEX_SIZE_PITCH_C 0x1cb8
+# define R128_TEX_PITCH_SHIFT 0
+# define R128_TEX_SIZE_SHIFT 4
+# define R128_TEX_HEIGHT_SHIFT 8
+# define R128_TEX_MIN_SIZE_SHIFT 12
+# define R128_SEC_TEX_PITCH_SHIFT 16
+# define R128_SEC_TEX_SIZE_SHIFT 20
+# define R128_SEC_TEX_HEIGHT_SHIFT 24
+# define R128_SEC_TEX_MIN_SIZE_SHIFT 28
+# define R128_TEX_PITCH_MASK (0x0f << 0)
+# define R128_TEX_SIZE_MASK (0x0f << 4)
+# define R128_TEX_HEIGHT_MASK (0x0f << 8)
+# define R128_TEX_MIN_SIZE_MASK (0x0f << 12)
+# define R128_SEC_TEX_PITCH_MASK (0x0f << 16)
+# define R128_SEC_TEX_SIZE_MASK (0x0f << 20)
+# define R128_SEC_TEX_HEIGHT_MASK (0x0f << 24)
+# define R128_SEC_TEX_MIN_SIZE_MASK (0x0f << 28)
+# define R128_TEX_SIZE_PITCH_SHIFT 0
+# define R128_SEC_TEX_SIZE_PITCH_SHIFT 16
+# define R128_TEX_SIZE_PITCH_MASK (0xffff << 0)
+# define R128_SEC_TEX_SIZE_PITCH_MASK (0xffff << 16)
+
+#define R128_REG_PRIM_TEX_0_OFFSET_C 0x1cbc
+#define R128_REG_PRIM_TEX_1_OFFSET_C 0x1cc0
+#define R128_REG_PRIM_TEX_2_OFFSET_C 0x1cc4
+#define R128_REG_PRIM_TEX_3_OFFSET_C 0x1cc8
+#define R128_REG_PRIM_TEX_4_OFFSET_C 0x1ccc
+#define R128_REG_PRIM_TEX_5_OFFSET_C 0x1cd0
+#define R128_REG_PRIM_TEX_6_OFFSET_C 0x1cd4
+#define R128_REG_PRIM_TEX_7_OFFSET_C 0x1cd8
+#define R128_REG_PRIM_TEX_8_OFFSET_C 0x1cdc
+#define R128_REG_PRIM_TEX_9_OFFSET_C 0x1ce0
+#define R128_REG_PRIM_TEX_10_OFFSET_C 0x1ce4
+#define R128_REG_SEC_TEX_0_OFFSET_C 0x1d08
+#define R128_REG_SEC_TEX_1_OFFSET_C 0x1d0c
+#define R128_REG_SEC_TEX_2_OFFSET_C 0x1d10
+#define R128_REG_SEC_TEX_3_OFFSET_C 0x1d14
+#define R128_REG_SEC_TEX_4_OFFSET_C 0x1d18
+#define R128_REG_SEC_TEX_5_OFFSET_C 0x1d1c
+#define R128_REG_SEC_TEX_6_OFFSET_C 0x1d20
+#define R128_REG_SEC_TEX_7_OFFSET_C 0x1d24
+#define R128_REG_SEC_TEX_8_OFFSET_C 0x1d28
+#define R128_REG_SEC_TEX_9_OFFSET_C 0x1d2c
+#define R128_REG_SEC_TEX_10_OFFSET_C 0x1d30
+# define R128_TEX_NO_TILE (0 << 30)
+# define R128_TEX_TILED_BY_HOST (1 << 30)
+# define R128_TEX_TILED_BY_STORAGE (2 << 30)
+# define R128_TEX_TILED_BY_STORAGE2 (3 << 30)
+#define R128_REG_CONSTANT_COLOR_C 0x1d34
+# define R128_CONSTANT_BLUE_SHIFT 0
+# define R128_CONSTANT_GREEN_SHIFT 8
+# define R128_CONSTANT_RED_SHIFT 16
+# define R128_CONSTANT_ALPHA_SHIFT 24
+
+#define RADEON_REG_PP_TEX_SIZE_0 0x1d04 /* NPOT */
+#define RADEON_REG_PP_TEX_SIZE_1 0x1d0c /* NPOT */
+#define RADEON_REG_PP_TEX_SIZE_2 0x1d14 /* NPOT */
+# define RADEON_TEX_USIZE_MASK (0x7ff << 0)
+# define RADEON_TEX_USIZE_SHIFT 0
+# define RADEON_TEX_VSIZE_MASK (0x7ff << 16)
+# define RADEON_TEX_VSIZE_SHIFT 16
+# define RADEON_SIGNED_RGB_MASK (1 << 30)
+# define RADEON_SIGNED_RGB_SHIFT 30
+# define RADEON_SIGNED_ALPHA_MASK (1 << 31)
+# define RADEON_SIGNED_ALPHA_SHIFT 31
+
+#define RADEON_REG_PP_TEX_PITCH_0 0x1d08 /* NPOT */
+#define RADEON_REG_PP_TEX_PITCH_1 0x1d10 /* NPOT */
+#define RADEON_REG_PP_TEX_PITCH_2 0x1d18 /* NPOT */
+/* note: bits 13-5: 32 byte aligned stride of texture map */
+
+#define R128_REG_PLANE_3D_MASK_C 0x1d44
+
+#define RADEON_REG_RB3D_PLANEMASK 0x1d84
+
+#define R200_REG_SE_VAP_CNTL 0x2080
+# define R200_VAP_TCL_ENABLE 0x00000001
+# define R200_VAP_SINGLE_BUF_STATE_ENABLE 0x00000010
+# define R200_VAP_FORCE_W_TO_ONE 0x00010000
+# define R200_VAP_D3D_TEX_DEFAULT 0x00020000
+# define R200_VAP_VF_MAX_VTX_NUM__SHIFT 18
+# define R200_VAP_VF_MAX_VTX_NUM (9 << 18)
+# define R200_VAP_DX_CLIP_SPACE_DEF 0x00400000
+
+#define R200_REG_SE_VTX_FMT_0 0x2088
+# define R200_VTX_XY 0 /* always have xy */
+# define R200_VTX_Z0 (1 << 0)
+# define R200_VTX_W0 (1 << 1)
+# define R200_VTX_WEIGHT_COUNT_SHIFT (2)
+# define R200_VTX_PV_MATRIX_SEL (1 << 5)
+# define R200_VTX_N0 (1 << 6)
+# define R200_VTX_POINT_SIZE (1 << 7)
+# define R200_VTX_DISCRETE_FOG (1 << 8)
+# define R200_VTX_SHININESS_0 (1 << 9)
+# define R200_VTX_SHININESS_1 (1 << 10)
+# define R200_VTX_COLOR_NOT_PRESENT 0
+# define R200_VTX_PK_RGBA 1
+# define R200_VTX_FP_RGB 2
+# define R200_VTX_FP_RGBA 3
+# define R200_VTX_COLOR_MASK 3
+# define R200_VTX_COLOR_0_SHIFT 11
+# define R200_VTX_COLOR_1_SHIFT 13
+# define R200_VTX_COLOR_2_SHIFT 15
+# define R200_VTX_COLOR_3_SHIFT 17
+# define R200_VTX_COLOR_4_SHIFT 19
+# define R200_VTX_COLOR_5_SHIFT 21
+# define R200_VTX_COLOR_6_SHIFT 23
+# define R200_VTX_COLOR_7_SHIFT 25
+# define R200_VTX_XY1 (1 << 28)
+# define R200_VTX_Z1 (1 << 29)
+# define R200_VTX_W1 (1 << 30)
+# define R200_VTX_N1 (1 << 31)
+
+#define R200_REG_SE_VTX_FMT_1 0x208c
+# define R200_VTX_TEX0_COMP_CNT_SHIFT 0
+# define R200_VTX_TEX1_COMP_CNT_SHIFT 3
+# define R200_VTX_TEX2_COMP_CNT_SHIFT 6
+# define R200_VTX_TEX3_COMP_CNT_SHIFT 9
+# define R200_VTX_TEX4_COMP_CNT_SHIFT 12
+# define R200_VTX_TEX5_COMP_CNT_SHIFT 15
+
+#define R200_REG_SE_VTE_CNTL 0x20b0
+# define R200_VPORT_X_SCALE_ENA 0x00000001
+# define R200_VPORT_X_OFFSET_ENA 0x00000002
+# define R200_VPORT_Y_SCALE_ENA 0x00000004
+# define R200_VPORT_Y_OFFSET_ENA 0x00000008
+# define R200_VPORT_Z_SCALE_ENA 0x00000010
+# define R200_VPORT_Z_OFFSET_ENA 0x00000020
+# define R200_VTX_XY_FMT 0x00000100
+# define R200_VTX_Z_FMT 0x00000200
+# define R200_VTX_W0_FMT 0x00000400
+# define R200_VTX_W0_NORMALIZE 0x00000800
+# define R200_VTX_ST_DENORMALIZED 0x00001000
+
+#define R200_REG_SE_VAP_CNTL_STATUS 0x2140
+#define RADEON_REG_SE_CNTL_STATUS 0x2140
+# define RADEON_VC_NO_SWAP (0 << 0)
+# define RADEON_VC_16BIT_SWAP (1 << 0)
+# define RADEON_VC_32BIT_SWAP (2 << 0)
+# define RADEON_VC_HALF_DWORD_SWAP (3 << 0)
+# define RADEON_TCL_BYPASS (1 << 8)
+
+#define R200_REG_SE_VTX_STATE_CNTL 0x2180
+
+#define RADEON_REG_RE_TOP_LEFT 0x26c0
+
+#define R200_REG_RE_AUX_SCISSOR_CNTL 0x26f0
+
+#define R200_REG_PP_TXFILTER_0 0x2c00
+#define R200_REG_PP_TXFILTER_1 0x2c20
+#define R200_REG_PP_TXFILTER_2 0x2c40
+#define R200_REG_PP_TXFILTER_3 0x2c60
+#define R200_REG_PP_TXFILTER_4 0x2c80
+#define R200_REG_PP_TXFILTER_5 0x2ca0
+# define R200_MAG_FILTER_NEAREST (0 << 0)
+# define R200_MAG_FILTER_LINEAR (1 << 0)
+# define R200_MAG_FILTER_MASK (1 << 0)
+# define R200_MIN_FILTER_NEAREST (0 << 1)
+# define R200_MIN_FILTER_LINEAR (1 << 1)
+# define R200_MIN_FILTER_NEAREST_MIP_NEAREST (2 << 1)
+# define R200_MIN_FILTER_NEAREST_MIP_LINEAR (3 << 1)
+# define R200_MIN_FILTER_LINEAR_MIP_NEAREST (6 << 1)
+# define R200_MIN_FILTER_LINEAR_MIP_LINEAR (7 << 1)
+# define R200_MIN_FILTER_ANISO_NEAREST (8 << 1)
+# define R200_MIN_FILTER_ANISO_LINEAR (9 << 1)
+# define R200_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST (10 << 1)
+# define R200_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR (11 << 1)
+# define R200_MIN_FILTER_MASK (15 << 1)
+# define R200_MAX_ANISO_1_TO_1 (0 << 5)
+# define R200_MAX_ANISO_2_TO_1 (1 << 5)
+# define R200_MAX_ANISO_4_TO_1 (2 << 5)
+# define R200_MAX_ANISO_8_TO_1 (3 << 5)
+# define R200_MAX_ANISO_16_TO_1 (4 << 5)
+# define R200_MAX_ANISO_MASK (7 << 5)
+# define R200_MAX_MIP_LEVEL_MASK (0x0f << 16)
+# define R200_MAX_MIP_LEVEL_SHIFT 16
+# define R200_YUV_TO_RGB (1 << 20)
+# define R200_YUV_TEMPERATURE_COOL (0 << 21)
+# define R200_YUV_TEMPERATURE_HOT (1 << 21)
+# define R200_YUV_TEMPERATURE_MASK (1 << 21)
+# define R200_WRAPEN_S (1 << 22)
+# define R200_CLAMP_S_WRAP (0 << 23)
+# define R200_CLAMP_S_MIRROR (1 << 23)
+# define R200_CLAMP_S_CLAMP_LAST (2 << 23)
+# define R200_CLAMP_S_MIRROR_CLAMP_LAST (3 << 23)
+# define R200_CLAMP_S_CLAMP_BORDER (4 << 23)
+# define R200_CLAMP_S_MIRROR_CLAMP_BORDER (5 << 23)
+# define R200_CLAMP_S_CLAMP_GL (6 << 23)
+# define R200_CLAMP_S_MIRROR_CLAMP_GL (7 << 23)
+# define R200_CLAMP_S_MASK (7 << 23)
+# define R200_WRAPEN_T (1 << 26)
+# define R200_CLAMP_T_WRAP (0 << 27)
+# define R200_CLAMP_T_MIRROR (1 << 27)
+# define R200_CLAMP_T_CLAMP_LAST (2 << 27)
+# define R200_CLAMP_T_MIRROR_CLAMP_LAST (3 << 27)
+# define R200_CLAMP_T_CLAMP_BORDER (4 << 27)
+# define R200_CLAMP_T_MIRROR_CLAMP_BORDER (5 << 27)
+# define R200_CLAMP_T_CLAMP_GL (6 << 27)
+# define R200_CLAMP_T_MIRROR_CLAMP_GL (7 << 27)
+# define R200_CLAMP_T_MASK (7 << 27)
+# define R200_KILL_LT_ZERO (1 << 30)
+# define R200_BORDER_MODE_OGL (0 << 31)
+# define R200_BORDER_MODE_D3D (1 << 31)
+
+#define R200_REG_PP_TXFORMAT_0 0x2c04
+#define R200_REG_PP_TXFORMAT_1 0x2c24
+#define R200_REG_PP_TXFORMAT_2 0x2c44
+#define R200_REG_PP_TXFORMAT_3 0x2c64
+#define R200_REG_PP_TXFORMAT_4 0x2c84
+#define R200_REG_PP_TXFORMAT_5 0x2ca4
+# define R200_TXFORMAT_I8 (0 << 0)
+# define R200_TXFORMAT_AI88 (1 << 0)
+# define R200_TXFORMAT_RGB332 (2 << 0)
+# define R200_TXFORMAT_ARGB1555 (3 << 0)
+# define R200_TXFORMAT_RGB565 (4 << 0)
+# define R200_TXFORMAT_ARGB4444 (5 << 0)
+# define R200_TXFORMAT_ARGB8888 (6 << 0)
+# define R200_TXFORMAT_RGBA8888 (7 << 0)
+# define R200_TXFORMAT_Y8 (8 << 0)
+# define R200_TXFORMAT_AVYU4444 (9 << 0)
+# define R200_TXFORMAT_VYUY422 (10 << 0)
+# define R200_TXFORMAT_YVYU422 (11 << 0)
+# define R200_TXFORMAT_DXT1 (12 << 0)
+# define R200_TXFORMAT_DXT23 (14 << 0)
+# define R200_TXFORMAT_DXT45 (15 << 0)
+# define R200_TXFORMAT_FORMAT_MASK (31 << 0)
+# define R200_TXFORMAT_FORMAT_SHIFT 0
+# define R200_TXFORMAT_ALPHA_IN_MAP (1 << 6)
+# define R200_TXFORMAT_NON_POWER2 (1 << 7)
+# define R200_TXFORMAT_WIDTH_MASK (15 << 8)
+# define R200_TXFORMAT_WIDTH_SHIFT 8
+# define R200_TXFORMAT_HEIGHT_MASK (15 << 12)
+# define R200_TXFORMAT_HEIGHT_SHIFT 12
+# define R200_TXFORMAT_F5_WIDTH_MASK (15 << 16) /* cube face 5 */
+# define R200_TXFORMAT_F5_WIDTH_SHIFT 16
+# define R200_TXFORMAT_F5_HEIGHT_MASK (15 << 20)
+# define R200_TXFORMAT_F5_HEIGHT_SHIFT 20
+# define R200_TXFORMAT_ST_ROUTE_STQ0 (0 << 24)
+# define R200_TXFORMAT_ST_ROUTE_STQ1 (1 << 24)
+# define R200_TXFORMAT_ST_ROUTE_STQ2 (2 << 24)
+# define R200_TXFORMAT_ST_ROUTE_STQ3 (3 << 24)
+# define R200_TXFORMAT_ST_ROUTE_STQ4 (4 << 24)
+# define R200_TXFORMAT_ST_ROUTE_STQ5 (5 << 24)
+# define R200_TXFORMAT_ST_ROUTE_MASK (7 << 24)
+# define R200_TXFORMAT_ST_ROUTE_SHIFT 24
+# define R200_TXFORMAT_ALPHA_MASK_ENABLE (1 << 28)
+# define R200_TXFORMAT_CHROMA_KEY_ENABLE (1 << 29)
+# define R200_TXFORMAT_CUBIC_MAP_ENABLE (1 << 30)
+
+#define R200_REG_PP_TXFORMAT_X_0 0x2c08
+#define R200_REG_PP_TXFORMAT_X_1 0x2c28
+#define R200_REG_PP_TXFORMAT_X_2 0x2c48
+#define R200_REG_PP_TXFORMAT_X_3 0x2c68
+#define R200_REG_PP_TXFORMAT_X_4 0x2c88
+#define R200_REG_PP_TXFORMAT_X_5 0x2ca8
+# define R200_DEPTH_LOG2_MASK (0xf << 0)
+# define R200_DEPTH_LOG2_SHIFT 0
+# define R200_VOLUME_FILTER_SHIFT 4
+# define R200_VOLUME_FILTER_MASK (1 << 4)
+# define R200_VOLUME_FILTER_NEAREST (0 << 4)
+# define R200_VOLUME_FILTER_LINEAR (1 << 4)
+# define R200_WRAPEN_Q (1 << 8)
+# define R200_CLAMP_Q_WRAP (0 << 9)
+# define R200_CLAMP_Q_MIRROR (1 << 9)
+# define R200_CLAMP_Q_CLAMP_LAST (2 << 9)
+# define R200_CLAMP_Q_MIRROR_CLAMP_LAST (3 << 9)
+# define R200_CLAMP_Q_CLAMP_BORDER (4 << 9)
+# define R200_CLAMP_Q_MIRROR_CLAMP_BORDER (5 << 9)
+# define R200_CLAMP_Q_CLAMP_GL (6 << 9)
+# define R200_CLAMP_Q_MIRROR_CLAMP_GL (7 << 9)
+# define R200_CLAMP_Q_MASK (7 << 9)
+# define R200_MIN_MIP_LEVEL_MASK (0xff << 12)
+# define R200_MIN_MIP_LEVEL_SHIFT 12
+# define R200_TEXCOORD_NONPROJ (0 << 16)
+# define R200_TEXCOORD_CUBIC_ENV (1 << 16)
+# define R200_TEXCOORD_VOLUME (2 << 16)
+# define R200_TEXCOORD_PROJ (3 << 16)
+# define R200_TEXCOORD_DEPTH (4 << 16)
+# define R200_TEXCOORD_1D_PROJ (5 << 16)
+# define R200_TEXCOORD_1D (6 << 16)
+# define R200_TEXCOORD_ZERO (7 << 16)
+# define R200_TEXCOORD_MASK (7 << 16)
+# define R200_LOD_BIAS_MASK (0xfff80000)
+# define R200_LOD_BIAS_SHIFT 19
+
+#define R200_REG_PP_TXSIZE_0 0x2c0c /* NPOT only */
+#define R200_REG_PP_TXSIZE_1 0x2c2c /* NPOT only */
+#define R200_REG_PP_TXSIZE_2 0x2c4c /* NPOT only */
+#define R200_REG_PP_TXSIZE_3 0x2c6c /* NPOT only */
+#define R200_REG_PP_TXSIZE_4 0x2c8c /* NPOT only */
+#define R200_REG_PP_TXSIZE_5 0x2cac /* NPOT only */
+
+#define R200_REG_PP_TXPITCH_0 0x2c10 /* NPOT only */
+#define R200_REG_PP_TXPITCH_1 0x2c30 /* NPOT only */
+#define R200_REG_PP_TXPITCH_2 0x2c50 /* NPOT only */
+#define R200_REG_PP_TXPITCH_3 0x2c70 /* NPOT only */
+#define R200_REG_PP_TXPITCH_4 0x2c90 /* NPOT only */
+#define R200_REG_PP_TXPITCH_5 0x2cb0 /* NPOT only */
+
+#define R200_REG_PP_BORDER_COLOR_0 0x2c14
+#define R200_REG_PP_TXMULTI_CTL_0 0x2c1c
+
+#define R200_REG_PP_CNTL_X 0x2cc4
+
+#define R200_PP_TXOFFSET_0 0x2d00
+#define R200_PP_TXOFFSET_1 0x2d18
+#define R200_PP_TXOFFSET_2 0x2d30
+#define R200_PP_TXOFFSET_3 0x2d48
+#define R200_PP_TXOFFSET_4 0x2d60
+#define R200_PP_TXOFFSET_5 0x2d78
+# define R200_TXO_ENDIAN_NO_SWAP (0 << 0)
+# define R200_TXO_ENDIAN_BYTE_SWAP (1 << 0)
+# define R200_TXO_ENDIAN_WORD_SWAP (2 << 0)
+# define R200_TXO_ENDIAN_HALFDW_SWAP (3 << 0)
+# define R200_TXO_OFFSET_MASK 0xffffffe0
+# define R200_TXO_OFFSET_SHIFT 5
+
+#define R200_PP_CUBIC_OFFSET_F1_0 0x2d04
+#define R200_PP_CUBIC_OFFSET_F2_0 0x2d08
+#define R200_PP_CUBIC_OFFSET_F3_0 0x2d0c
+#define R200_PP_CUBIC_OFFSET_F4_0 0x2d10
+#define R200_PP_CUBIC_OFFSET_F5_0 0x2d14
+#define R200_PP_CUBIC_OFFSET_F1_1 0x2d1c
+#define R200_PP_CUBIC_OFFSET_F2_1 0x2d20
+#define R200_PP_CUBIC_OFFSET_F3_1 0x2d24
+#define R200_PP_CUBIC_OFFSET_F4_1 0x2d28
+#define R200_PP_CUBIC_OFFSET_F5_1 0x2d2c
+#define R200_PP_CUBIC_OFFSET_F1_2 0x2d34
+#define R200_PP_CUBIC_OFFSET_F2_2 0x2d38
+#define R200_PP_CUBIC_OFFSET_F3_2 0x2d3c
+#define R200_PP_CUBIC_OFFSET_F4_2 0x2d40
+#define R200_PP_CUBIC_OFFSET_F5_2 0x2d44
+#define R200_PP_CUBIC_OFFSET_F1_3 0x2d4c
+#define R200_PP_CUBIC_OFFSET_F2_3 0x2d50
+#define R200_PP_CUBIC_OFFSET_F3_3 0x2d54
+#define R200_PP_CUBIC_OFFSET_F4_3 0x2d58
+#define R200_PP_CUBIC_OFFSET_F5_3 0x2d5c
+#define R200_PP_CUBIC_OFFSET_F1_4 0x2d64
+#define R200_PP_CUBIC_OFFSET_F2_4 0x2d68
+#define R200_PP_CUBIC_OFFSET_F3_4 0x2d6c
+#define R200_PP_CUBIC_OFFSET_F4_4 0x2d70
+#define R200_PP_CUBIC_OFFSET_F5_4 0x2d74
+#define R200_PP_CUBIC_OFFSET_F1_5 0x2d7c
+#define R200_PP_CUBIC_OFFSET_F2_5 0x2d80
+#define R200_PP_CUBIC_OFFSET_F3_5 0x2d84
+#define R200_PP_CUBIC_OFFSET_F4_5 0x2d88
+#define R200_PP_CUBIC_OFFSET_F5_5 0x2d8c
+
+/* AKA PIXSHADER_I0_C0 */
+#define R200_REG_PP_TXCBLEND_0 0x2f00
+# define R200_TXC_ARG_A_ZERO (0)
+# define R200_TXC_ARG_A_CURRENT_COLOR (2)
+# define R200_TXC_ARG_A_CURRENT_ALPHA (3)
+# define R200_TXC_ARG_A_DIFFUSE_COLOR (4)
+# define R200_TXC_ARG_A_DIFFUSE_ALPHA (5)
+# define R200_TXC_ARG_A_SPECULAR_COLOR (6)
+# define R200_TXC_ARG_A_SPECULAR_ALPHA (7)
+# define R200_TXC_ARG_A_TFACTOR_COLOR (8)
+# define R200_TXC_ARG_A_TFACTOR_ALPHA (9)
+# define R200_TXC_ARG_A_R0_COLOR (10)
+# define R200_TXC_ARG_A_R0_ALPHA (11)
+# define R200_TXC_ARG_A_R1_COLOR (12)
+# define R200_TXC_ARG_A_R1_ALPHA (13)
+# define R200_TXC_ARG_A_R2_COLOR (14)
+# define R200_TXC_ARG_A_R2_ALPHA (15)
+# define R200_TXC_ARG_A_R3_COLOR (16)
+# define R200_TXC_ARG_A_R3_ALPHA (17)
+# define R200_TXC_ARG_A_R4_COLOR (18)
+# define R200_TXC_ARG_A_R4_ALPHA (19)
+# define R200_TXC_ARG_A_R5_COLOR (20)
+# define R200_TXC_ARG_A_R5_ALPHA (21)
+# define R200_TXC_ARG_A_TFACTOR1_COLOR (26)
+# define R200_TXC_ARG_A_TFACTOR1_ALPHA (27)
+# define R200_TXC_ARG_A_MASK (31 << 0)
+# define R200_TXC_ARG_A_SHIFT 0
+# define R200_TXC_ARG_B_ZERO (0 << 5)
+# define R200_TXC_ARG_B_CURRENT_COLOR (2 << 5)
+# define R200_TXC_ARG_B_CURRENT_ALPHA (3 << 5)
+# define R200_TXC_ARG_B_DIFFUSE_COLOR (4 << 5)
+# define R200_TXC_ARG_B_DIFFUSE_ALPHA (5 << 5)
+# define R200_TXC_ARG_B_SPECULAR_COLOR (6 << 5)
+# define R200_TXC_ARG_B_SPECULAR_ALPHA (7 << 5)
+# define R200_TXC_ARG_B_TFACTOR_COLOR (8 << 5)
+# define R200_TXC_ARG_B_TFACTOR_ALPHA (9 << 5)
+# define R200_TXC_ARG_B_R0_COLOR (10 << 5)
+# define R200_TXC_ARG_B_R0_ALPHA (11 << 5)
+# define R200_TXC_ARG_B_R1_COLOR (12 << 5)
+# define R200_TXC_ARG_B_R1_ALPHA (13 << 5)
+# define R200_TXC_ARG_B_R2_COLOR (14 << 5)
+# define R200_TXC_ARG_B_R2_ALPHA (15 << 5)
+# define R200_TXC_ARG_B_R3_COLOR (16 << 5)
+# define R200_TXC_ARG_B_R3_ALPHA (17 << 5)
+# define R200_TXC_ARG_B_R4_COLOR (18 << 5)
+# define R200_TXC_ARG_B_R4_ALPHA (19 << 5)
+# define R200_TXC_ARG_B_R5_COLOR (20 << 5)
+# define R200_TXC_ARG_B_R5_ALPHA (21 << 5)
+# define R200_TXC_ARG_B_TFACTOR1_COLOR (26 << 5)
+# define R200_TXC_ARG_B_TFACTOR1_ALPHA (27 << 5)
+# define R200_TXC_ARG_B_MASK (31 << 5)
+# define R200_TXC_ARG_B_SHIFT 5
+# define R200_TXC_ARG_C_ZERO (0 << 10)
+# define R200_TXC_ARG_C_CURRENT_COLOR (2 << 10)
+# define R200_TXC_ARG_C_CURRENT_ALPHA (3 << 10)
+# define R200_TXC_ARG_C_DIFFUSE_COLOR (4 << 10)
+# define R200_TXC_ARG_C_DIFFUSE_ALPHA (5 << 10)
+# define R200_TXC_ARG_C_SPECULAR_COLOR (6 << 10)
+# define R200_TXC_ARG_C_SPECULAR_ALPHA (7 << 10)
+# define R200_TXC_ARG_C_TFACTOR_COLOR (8 << 10)
+# define R200_TXC_ARG_C_TFACTOR_ALPHA (9 << 10)
+# define R200_TXC_ARG_C_R0_COLOR (10 << 10)
+# define R200_TXC_ARG_C_R0_ALPHA (11 << 10)
+# define R200_TXC_ARG_C_R1_COLOR (12 << 10)
+# define R200_TXC_ARG_C_R1_ALPHA (13 << 10)
+# define R200_TXC_ARG_C_R2_COLOR (14 << 10)
+# define R200_TXC_ARG_C_R2_ALPHA (15 << 10)
+# define R200_TXC_ARG_C_R3_COLOR (16 << 10)
+# define R200_TXC_ARG_C_R3_ALPHA (17 << 10)
+# define R200_TXC_ARG_C_R4_COLOR (18 << 10)
+# define R200_TXC_ARG_C_R4_ALPHA (19 << 10)
+# define R200_TXC_ARG_C_R5_COLOR (20 << 10)
+# define R200_TXC_ARG_C_R5_ALPHA (21 << 10)
+# define R200_TXC_ARG_C_TFACTOR1_COLOR (26 << 10)
+# define R200_TXC_ARG_C_TFACTOR1_ALPHA (27 << 10)
+# define R200_TXC_ARG_C_MASK (31 << 10)
+# define R200_TXC_ARG_C_SHIFT 10
+# define R200_TXC_COMP_ARG_A (1 << 16)
+# define R200_TXC_COMP_ARG_A_SHIFT (16)
+# define R200_TXC_BIAS_ARG_A (1 << 17)
+# define R200_TXC_SCALE_ARG_A (1 << 18)
+# define R200_TXC_NEG_ARG_A (1 << 19)
+# define R200_TXC_COMP_ARG_B (1 << 20)
+# define R200_TXC_COMP_ARG_B_SHIFT (20)
+# define R200_TXC_BIAS_ARG_B (1 << 21)
+# define R200_TXC_SCALE_ARG_B (1 << 22)
+# define R200_TXC_NEG_ARG_B (1 << 23)
+# define R200_TXC_COMP_ARG_C (1 << 24)
+# define R200_TXC_COMP_ARG_C_SHIFT (24)
+# define R200_TXC_BIAS_ARG_C (1 << 25)
+# define R200_TXC_SCALE_ARG_C (1 << 26)
+# define R200_TXC_NEG_ARG_C (1 << 27)
+# define R200_TXC_OP_MADD (0 << 28)
+# define R200_TXC_OP_CND0 (2 << 28)
+# define R200_TXC_OP_LERP (3 << 28)
+# define R200_TXC_OP_DOT3 (4 << 28)
+# define R200_TXC_OP_DOT4 (5 << 28)
+# define R200_TXC_OP_CONDITIONAL (6 << 28)
+# define R200_TXC_OP_DOT2_ADD (7 << 28)
+# define R200_TXC_OP_MASK (7 << 28)
+
+/* AKA PIXSHADER_I0_C1 */
+#define R200_REG_PP_TXCBLEND2_0 0x2f04
+# define R200_TXC_TFACTOR_SEL_SHIFT 0
+# define R200_TXC_TFACTOR_SEL_MASK 0x7
+# define R200_TXC_TFACTOR1_SEL_SHIFT 4
+# define R200_TXC_TFACTOR1_SEL_MASK (0x7 << 4)
+# define R200_TXC_SCALE_SHIFT 8
+# define R200_TXC_SCALE_MASK (7 << 8)
+# define R200_TXC_SCALE_1X (0 << 8)
+# define R200_TXC_SCALE_2X (1 << 8)
+# define R200_TXC_SCALE_4X (2 << 8)
+# define R200_TXC_SCALE_8X (3 << 8)
+# define R200_TXC_SCALE_INV2 (5 << 8)
+# define R200_TXC_SCALE_INV4 (6 << 8)
+# define R200_TXC_SCALE_INV8 (7 << 8)
+# define R200_TXC_CLAMP_SHIFT 12
+# define R200_TXC_CLAMP_MASK (3 << 12)
+# define R200_TXC_CLAMP_WRAP (0 << 12)
+# define R200_TXC_CLAMP_0_1 (1 << 12)
+# define R200_TXC_CLAMP_8_8 (2 << 12)
+# define R200_TXC_OUTPUT_REG_MASK (7 << 16)
+# define R200_TXC_OUTPUT_REG_NONE (0 << 16)
+# define R200_TXC_OUTPUT_REG_R0 (1 << 16)
+# define R200_TXC_OUTPUT_REG_R1 (2 << 16)
+# define R200_TXC_OUTPUT_REG_R2 (3 << 16)
+# define R200_TXC_OUTPUT_REG_R3 (4 << 16)
+# define R200_TXC_OUTPUT_REG_R4 (5 << 16)
+# define R200_TXC_OUTPUT_REG_R5 (6 << 16)
+# define R200_TXC_OUTPUT_MASK_MASK (7 << 20)
+# define R200_TXC_OUTPUT_MASK_RGB (0 << 20)
+# define R200_TXC_OUTPUT_MASK_RG (1 << 20)
+# define R200_TXC_OUTPUT_MASK_RB (2 << 20)
+# define R200_TXC_OUTPUT_MASK_R (3 << 20)
+# define R200_TXC_OUTPUT_MASK_GB (4 << 20)
+# define R200_TXC_OUTPUT_MASK_G (5 << 20)
+# define R200_TXC_OUTPUT_MASK_B (6 << 20)
+# define R200_TXC_OUTPUT_MASK_NONE (7 << 20)
+# define R200_TXC_REPL_NORMAL 0
+# define R200_TXC_REPL_RED 1
+# define R200_TXC_REPL_GREEN 2
+# define R200_TXC_REPL_BLUE 3
+# define R200_TXC_REPL_ARG_A_SHIFT 26
+# define R200_TXC_REPL_ARG_A_MASK (3 << 26)
+# define R200_TXC_REPL_ARG_B_SHIFT 28
+# define R200_TXC_REPL_ARG_B_MASK (3 << 28)
+# define R200_TXC_REPL_ARG_C_SHIFT 30
+# define R200_TXC_REPL_ARG_C_MASK (3 << 30)
+
+/* AKA PIXSHADER_I0_A0 */
+#define R200_REG_PP_TXABLEND_0 0x2f08
+# define R200_TXA_ARG_A_ZERO (0)
+# define R200_TXA_ARG_A_CURRENT_ALPHA (2) /* guess */
+# define R200_TXA_ARG_A_CURRENT_BLUE (3) /* guess */
+# define R200_TXA_ARG_A_DIFFUSE_ALPHA (4)
+# define R200_TXA_ARG_A_DIFFUSE_BLUE (5)
+# define R200_TXA_ARG_A_SPECULAR_ALPHA (6)
+# define R200_TXA_ARG_A_SPECULAR_BLUE (7)
+# define R200_TXA_ARG_A_TFACTOR_ALPHA (8)
+# define R200_TXA_ARG_A_TFACTOR_BLUE (9)
+# define R200_TXA_ARG_A_R0_ALPHA (10)
+# define R200_TXA_ARG_A_R0_BLUE (11)
+# define R200_TXA_ARG_A_R1_ALPHA (12)
+# define R200_TXA_ARG_A_R1_BLUE (13)
+# define R200_TXA_ARG_A_R2_ALPHA (14)
+# define R200_TXA_ARG_A_R2_BLUE (15)
+# define R200_TXA_ARG_A_R3_ALPHA (16)
+# define R200_TXA_ARG_A_R3_BLUE (17)
+# define R200_TXA_ARG_A_R4_ALPHA (18)
+# define R200_TXA_ARG_A_R4_BLUE (19)
+# define R200_TXA_ARG_A_R5_ALPHA (20)
+# define R200_TXA_ARG_A_R5_BLUE (21)
+# define R200_TXA_ARG_A_TFACTOR1_ALPHA (26)
+# define R200_TXA_ARG_A_TFACTOR1_BLUE (27)
+# define R200_TXA_ARG_A_MASK (31 << 0)
+# define R200_TXA_ARG_A_SHIFT 0
+# define R200_TXA_ARG_B_ZERO (0 << 5)
+# define R200_TXA_ARG_B_CURRENT_ALPHA (2 << 5) /* guess */
+# define R200_TXA_ARG_B_CURRENT_BLUE (3 << 5) /* guess */
+# define R200_TXA_ARG_B_DIFFUSE_ALPHA (4 << 5)
+# define R200_TXA_ARG_B_DIFFUSE_BLUE (5 << 5)
+# define R200_TXA_ARG_B_SPECULAR_ALPHA (6 << 5)
+# define R200_TXA_ARG_B_SPECULAR_BLUE (7 << 5)
+# define R200_TXA_ARG_B_TFACTOR_ALPHA (8 << 5)
+# define R200_TXA_ARG_B_TFACTOR_BLUE (9 << 5)
+# define R200_TXA_ARG_B_R0_ALPHA (10 << 5)
+# define R200_TXA_ARG_B_R0_BLUE (11 << 5)
+# define R200_TXA_ARG_B_R1_ALPHA (12 << 5)
+# define R200_TXA_ARG_B_R1_BLUE (13 << 5)
+# define R200_TXA_ARG_B_R2_ALPHA (14 << 5)
+# define R200_TXA_ARG_B_R2_BLUE (15 << 5)
+# define R200_TXA_ARG_B_R3_ALPHA (16 << 5)
+# define R200_TXA_ARG_B_R3_BLUE (17 << 5)
+# define R200_TXA_ARG_B_R4_ALPHA (18 << 5)
+# define R200_TXA_ARG_B_R4_BLUE (19 << 5)
+# define R200_TXA_ARG_B_R5_ALPHA (20 << 5)
+# define R200_TXA_ARG_B_R5_BLUE (21 << 5)
+# define R200_TXA_ARG_B_TFACTOR1_ALPHA (26 << 5)
+# define R200_TXA_ARG_B_TFACTOR1_BLUE (27 << 5)
+# define R200_TXA_ARG_B_MASK (31 << 5)
+# define R200_TXA_ARG_B_SHIFT 5
+# define R200_TXA_ARG_C_ZERO (0 << 10)
+# define R200_TXA_ARG_C_CURRENT_ALPHA (2 << 10) /* guess */
+# define R200_TXA_ARG_C_CURRENT_BLUE (3 << 10) /* guess */
+# define R200_TXA_ARG_C_DIFFUSE_ALPHA (4 << 10)
+# define R200_TXA_ARG_C_DIFFUSE_BLUE (5 << 10)
+# define R200_TXA_ARG_C_SPECULAR_ALPHA (6 << 10)
+# define R200_TXA_ARG_C_SPECULAR_BLUE (7 << 10)
+# define R200_TXA_ARG_C_TFACTOR_ALPHA (8 << 10)
+# define R200_TXA_ARG_C_TFACTOR_BLUE (9 << 10)
+# define R200_TXA_ARG_C_R0_ALPHA (10 << 10)
+# define R200_TXA_ARG_C_R0_BLUE (11 << 10)
+# define R200_TXA_ARG_C_R1_ALPHA (12 << 10)
+# define R200_TXA_ARG_C_R1_BLUE (13 << 10)
+# define R200_TXA_ARG_C_R2_ALPHA (14 << 10)
+# define R200_TXA_ARG_C_R2_BLUE (15 << 10)
+# define R200_TXA_ARG_C_R3_ALPHA (16 << 10)
+# define R200_TXA_ARG_C_R3_BLUE (17 << 10)
+# define R200_TXA_ARG_C_R4_ALPHA (18 << 10)
+# define R200_TXA_ARG_C_R4_BLUE (19 << 10)
+# define R200_TXA_ARG_C_R5_ALPHA (20 << 10)
+# define R200_TXA_ARG_C_R5_BLUE (21 << 10)
+# define R200_TXA_ARG_C_TFACTOR1_ALPHA (26 << 10)
+# define R200_TXA_ARG_C_TFACTOR1_BLUE (27 << 10)
+# define R200_TXA_ARG_C_MASK (31 << 10)
+# define R200_TXA_ARG_C_SHIFT 10
+# define R200_TXA_COMP_ARG_A (1 << 16)
+# define R200_TXA_COMP_ARG_A_SHIFT (16)
+# define R200_TXA_BIAS_ARG_A (1 << 17)
+# define R200_TXA_SCALE_ARG_A (1 << 18)
+# define R200_TXA_NEG_ARG_A (1 << 19)
+# define R200_TXA_COMP_ARG_B (1 << 20)
+# define R200_TXA_COMP_ARG_B_SHIFT (20)
+# define R200_TXA_BIAS_ARG_B (1 << 21)
+# define R200_TXA_SCALE_ARG_B (1 << 22)
+# define R200_TXA_NEG_ARG_B (1 << 23)
+# define R200_TXA_COMP_ARG_C (1 << 24)
+# define R200_TXA_COMP_ARG_C_SHIFT (24)
+# define R200_TXA_BIAS_ARG_C (1 << 25)
+# define R200_TXA_SCALE_ARG_C (1 << 26)
+# define R200_TXA_NEG_ARG_C (1 << 27)
+# define R200_TXA_OP_MADD (0 << 28)
+# define R200_TXA_OP_CND0 (2 << 28)
+# define R200_TXA_OP_LERP (3 << 28)
+# define R200_TXA_OP_CONDITIONAL (6 << 28)
+# define R200_TXA_OP_MASK (7 << 28)
+
+/* AKA PIXSHADER_I0_A1 */
+#define R200_REG_PP_TXABLEND2_0 0x2f0c
+# define R200_TXA_TFACTOR_SEL_SHIFT 0
+# define R200_TXA_TFACTOR_SEL_MASK 0x7
+# define R200_TXA_TFACTOR1_SEL_SHIFT 4
+# define R200_TXA_TFACTOR1_SEL_MASK (0x7 << 4)
+# define R200_TXA_SCALE_SHIFT 8
+# define R200_TXA_SCALE_MASK (7 << 8)
+# define R200_TXA_SCALE_1X (0 << 8)
+# define R200_TXA_SCALE_2X (1 << 8)
+# define R200_TXA_SCALE_4X (2 << 8)
+# define R200_TXA_SCALE_8X (3 << 8)
+# define R200_TXA_SCALE_INV2 (5 << 8)
+# define R200_TXA_SCALE_INV4 (6 << 8)
+# define R200_TXA_SCALE_INV8 (7 << 8)
+# define R200_TXA_CLAMP_SHIFT 12
+# define R200_TXA_CLAMP_MASK (3 << 12)
+# define R200_TXA_CLAMP_WRAP (0 << 12)
+# define R200_TXA_CLAMP_0_1 (1 << 12)
+# define R200_TXA_CLAMP_8_8 (2 << 12)
+# define R200_TXA_OUTPUT_REG_MASK (7 << 16)
+# define R200_TXA_OUTPUT_REG_NONE (0 << 16)
+# define R200_TXA_OUTPUT_REG_R0 (1 << 16)
+# define R200_TXA_OUTPUT_REG_R1 (2 << 16)
+# define R200_TXA_OUTPUT_REG_R2 (3 << 16)
+# define R200_TXA_OUTPUT_REG_R3 (4 << 16)
+# define R200_TXA_OUTPUT_REG_R4 (5 << 16)
+# define R200_TXA_OUTPUT_REG_R5 (6 << 16)
+# define R200_TXA_DOT_ALPHA (1 << 20)
+# define R200_TXA_REPL_NORMAL 0
+# define R200_TXA_REPL_RED 1
+# define R200_TXA_REPL_GREEN 2
+# define R200_TXA_REPL_ARG_A_SHIFT 26
+# define R200_TXA_REPL_ARG_A_MASK (3 << 26)
+# define R200_TXA_REPL_ARG_B_SHIFT 28
+# define R200_TXA_REPL_ARG_B_MASK (3 << 28)
+# define R200_TXA_REPL_ARG_C_SHIFT 30
+# define R200_TXA_REPL_ARG_C_MASK (3 << 30)
+
+#define RADEON_REG_RB2D_DSTCACHE_MODE 0x3428
+/* This is a read-only mirror of RADEON_REG_RB3D_DSTCACHE_MODE */
+
+#define RADEON_REG_RB2D_DSTCACHE_CTLSTAT 0x342C
+/* This is a read-only mirror of RADEON_REG_RB3D_DSTCACHE_CTLSTAT */
+
+#define RADEON_REG_RB3D_DSTCACHE_MODE 0x3258
+# define RADEON_RB3D_DC_CACHE_ENABLE (0)
+# define RADEON_RB3D_DC_2D_CACHE_DISABLE (1)
+# define RADEON_RB3D_DC_3D_CACHE_DISABLE (2)
+# define RADEON_RB3D_DC_CACHE_DISABLE (3)
+# define RADEON_RB3D_DC_2D_CACHE_LINESIZE_128 (1 << 2)
+# define RADEON_RB3D_DC_3D_CACHE_LINESIZE_128 (2 << 2)
+# define RADEON_RB3D_DC_2D_CACHE_AUTOFLUSH (1 << 8)
+# define RADEON_RB3D_DC_3D_CACHE_AUTOFLUSH (2 << 8)
+# define R200_RB3D_DC_2D_CACHE_AUTOFREE (1 << 10)
+# define R200_RB3D_DC_3D_CACHE_AUTOFREE (2 << 10)
+# define RADEON_RB3D_DC_FORCE_RMW (1 << 16)
+# define RADEON_RB3D_DC_DISABLE_RI_FILL (1 << 24)
+# define RADEON_RB3D_DC_DISABLE_RI_READ (1 << 25)
+# define RADEON_RB3D_DC_DISABLE_MASK_CHK (1 << 26)
+
+#define RADEON_REG_RB3D_DSTCACHE_CTLSTAT 0x325C
+# define RADEON_RB3D_DC_FLUSH (3 << 0)
+# define RADEON_RB3D_DC_FREE (3 << 2)
+# define RADEON_RB3D_DC_FLUSH_ALL 0xf
+# define RADEON_RB3D_DC_BUSY (1 << 31)
+
+/* PLL register defines */
+#define R128_REG_MCLK_CNTL 0x000f
+# define R128_FORCE_GCP (1 << 16)
+# define R128_FORCE_PIPE3D_CP (1 << 17)
+# define R128_FORCE_RCP (1 << 18)
+#define RADEON_REG_MCLK_CNTL 0x0012
+# define RADEON_FORCEON_MCLKA (1 << 16)
+# define RADEON_FORCEON_MCLKB (1 << 17)
+# define RADEON_FORCEON_YCLKA (1 << 18)
+# define RADEON_FORCEON_YCLKB (1 << 19)
+# define RADEON_FORCEON_MC (1 << 20)
+# define RADEON_FORCEON_AIC (1 << 21)
+
+/* CCE packet defines */
+
+#define ATI_CCE_PACKETTYPE_MASK 0xc0000000
+#define ATI_CCE_PACKET0 0x00000000
+#define ATI_CCE_PACKET0_COUNT_MASK 0x3fff0000
+#define ATI_CCE_PACKET0_ONE_REG_WR 0x00008000
+#define ATI_CCE_PACKET0_REG_MASK 0x000007ff
+#define ATI_CCE_PACKET1 0x40000000
+#define ATI_CCE_PACKET1_REG_1 0x000007ff
+#define ATI_CCE_PACKET1_REG_2 0x003ff800
+#define ATI_CCE_PACKET1_REG_2_SHIFT 10
+#define ATI_CCE_PACKET2 0x80000000
+#define ATI_CCE_PACKET3 0xc0000000
+#define ATI_CCE_PACKET3_COUNT_MASK 0x3fff0000
+#define ATI_CCE_PACKET3_IT_OPCODE_MASK 0x0000ff00
+#define ATI_CCE_PACKET3_NOP 0xc0001000
+#define ATI_CCE_PACKET3_NEXT_CHAR 0xc0001900
+#define ATI_CCE_PACKET3_PLY_NEXTSCAN 0xc0001d00
+#define ATI_CCE_PACKET3_SET_SCISSORS 0xc0001e00
+#define R128_CCE_PACKET3_SET_MODE_24BPP 0xc0001f00
+#define R128_CCE_PACKET3_3D_SAVE_CONTEXT 0xc0002000
+#define R128_CCE_PACKET3_3D_PLAY_CONTEXT 0xc0002100
+#define ATI_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM 0xc0002300
+#define RADEON_CP_PACKET3_LOAD_MICROCODE 0xc0002400
+#define ATI_CCE_PACKET3_3D_RNDR_GEN_PRIM 0xc0002500
+#define RADEON_CP_PACKET3_WAIT_FOR_IDLE 0xc0002600
+#define RADEON_CP_PACKET3_3D_DRAW_VBUF 0xc0002800
+#define RADEON_CP_PACKET3_3D_DRAW_IMMD 0xc0002900
+#define RADEON_CP_PACKET3_3D_DRAW_INDX 0xc0002a00
+#define ATI_CCE_PACKET3_LOAD_PALETTE 0xc0002c00
+#define R128_CCE_PACKET3_PURGE 0xc0002d00
+#define R128_CCE_PACKET3_NEXT_VERTEX_BUNDLE 0xc0002e00
+#define RADEON_CP_PACKET3_3D_LOAD_VBPNTR 0xc0002f00
+#define RADEON_CP_PACKET3_3D_CLEAR_ZMASK 0xc0003200
+#define R200_CP_PACKET3_3D_DRAW_IMMD_2 0xc0003500
+#define ATI_CCE_PACKET3_CNTL_PAINT 0xc0009100
+#define ATI_CCE_PACKET3_CNTL_BITBLT 0xc0009200
+#define ATI_CCE_PACKET3_CNTL_SMALLTEXT 0xc0009300
+#define ATI_CCE_PACKET3_HOSTDATA_BLT 0xc0009400
+#define ATI_CCE_PACKET3_CNTL_POLYLINE 0xc0009500
+#define R128_CCE_PACKET3_SCALE 0xc0009600
+#define R128_CCE_PACKET3_TRANS_SCALE 0xc0009700
+#define ATI_CCE_PACKET3_CNTL_POLYSCANLINES 0xc0009800
+#define ATI_CCE_PACKET3_PAINT_MULTI 0xc0009a00
+#define ATI_CCE_PACKET3_BITBLT_MULTI 0xc0009b00
+#define ATI_CCE_PACKET3_CNTL_TRANS_BITBLT 0xc0009c00
+
+#define RADEON_CP_VC_FRMT_XY 0x00000000
+#define RADEON_CP_VC_FRMT_W0 0x00000001
+#define RADEON_CP_VC_FRMT_FPCOLOR 0x00000002
+#define RADEON_CP_VC_FRMT_FPALPHA 0x00000004
+#define RADEON_CP_VC_FRMT_PKCOLOR 0x00000008
+#define RADEON_CP_VC_FRMT_FPSPEC 0x00000010
+#define RADEON_CP_VC_FRMT_FPFOG 0x00000020
+#define RADEON_CP_VC_FRMT_PKSPEC 0x00000040
+#define RADEON_CP_VC_FRMT_ST0 0x00000080
+#define RADEON_CP_VC_FRMT_ST1 0x00000100
+#define RADEON_CP_VC_FRMT_Q1 0x00000200
+#define RADEON_CP_VC_FRMT_ST2 0x00000400
+#define RADEON_CP_VC_FRMT_Q2 0x00000800
+#define RADEON_CP_VC_FRMT_ST3 0x00001000
+#define RADEON_CP_VC_FRMT_Q3 0x00002000
+#define RADEON_CP_VC_FRMT_Q0 0x00004000
+#define RADEON_CP_VC_FRMT_BLND_WEIGHT_CNT_MASK 0x00038000
+#define RADEON_CP_VC_FRMT_N0 0x00040000
+#define RADEON_CP_VC_FRMT_XY1 0x08000000
+#define RADEON_CP_VC_FRMT_Z1 0x10000000
+#define RADEON_CP_VC_FRMT_W1 0x20000000
+#define RADEON_CP_VC_FRMT_N1 0x40000000
+#define RADEON_CP_VC_FRMT_Z 0x80000000
+
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_NONE 0x00000000
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_POINT 0x00000001
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_LINE 0x00000002
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_LINE_STRIP 0x00000003
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_TYPE_2 0x00000007
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_RECT_LIST 0x00000008
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_3VRT_POINT_LIST 0x00000009
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_3VRT_LINE_LIST 0x0000000a
+#define RADEON_CP_VC_CNTL_PRIM_WALK_IND 0x00000010
+#define RADEON_CP_VC_CNTL_PRIM_WALK_LIST 0x00000020
+#define RADEON_CP_VC_CNTL_PRIM_WALK_RING 0x00000030
+#define RADEON_CP_VC_CNTL_COLOR_ORDER_BGRA 0x00000000
+#define RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA 0x00000040
+#define RADEON_CP_VC_CNTL_MAOS_ENABLE 0x00000080
+#define RADEON_CP_VC_CNTL_VTX_FMT_NON_RADEON_MODE 0x00000000
+#define RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE 0x00000100
+#define RADEON_CP_VC_CNTL_TCL_DISABLE 0x00000000
+#define RADEON_CP_VC_CNTL_TCL_ENABLE 0x00000200
+#define RADEON_CP_VC_CNTL_NUM_SHIFT 16
+
+#define R128_CCE_VC_FRMT_RHW 0x00000001
+#define R128_CCE_VC_FRMT_DIFFUSE_BGR 0x00000002
+#define R128_CCE_VC_FRMT_DIFFUSE_A 0x00000004
+#define R128_CCE_VC_FRMT_DIFFUSE_ARGB 0x00000008
+#define R128_CCE_VC_FRMT_SPEC_BGR 0x00000010
+#define R128_CCE_VC_FRMT_SPEC_F 0x00000020
+#define R128_CCE_VC_FRMT_SPEC_FRGB 0x00000040
+#define R128_CCE_VC_FRMT_S_T 0x00000080
+#define R128_CCE_VC_FRMT_S2_T2 0x00000100
+#define R128_CCE_VC_FRMT_RHW2 0x00000200
+
+#define R128_CCE_VC_CNTL_PRIM_TYPE_NONE 0x00000000
+#define R128_CCE_VC_CNTL_PRIM_TYPE_POINT 0x00000001
+#define R128_CCE_VC_CNTL_PRIM_TYPE_LINE 0x00000002
+#define R128_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE 0x00000003
+#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004
+#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005
+#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006
+#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 0x00000007
+#define R128_CCE_VC_CNTL_PRIM_WALK_IND 0x00000010
+#define R128_CCE_VC_CNTL_PRIM_WALK_LIST 0x00000020
+#define R128_CCE_VC_CNTL_PRIM_WALK_RING 0x00000030
+#define R128_CCE_VC_CNTL_NUM_SHIFT 16
+
+#define R128_DATATYPE_VQ 0
+#define R128_DATATYPE_CI4 1
+#define R128_DATATYPE_CI8 2
+#define R128_DATATYPE_ARGB1555 3
+#define R128_DATATYPE_RGB565 4
+#define R128_DATATYPE_RGB888 5
+#define R128_DATATYPE_ARGB8888 6
+#define R128_DATATYPE_RGB332 7
+#define R128_DATATYPE_Y8 8
+#define R128_DATATYPE_RGB8 9
+#define R128_DATATYPE_CI16 10
+#define R128_DATATYPE_VYUY_422 11
+#define R128_DATATYPE_YVYU_422 12
+#define R128_DATATYPE_AYUV_444 14
+#define R128_DATATYPE_ARGB4444 15
+
+#define R128_AGP_OFFSET 0x02000000
+
+#define R128_WATERMARK_L 16
+#define R128_WATERMARK_M 8
+#define R128_WATERMARK_N 8
+#define R128_WATERMARK_K 128
diff --git a/xorg-server/hw/kdrive/ati/ati_stub.c b/xorg-server/hw/kdrive/ati/ati_stub.c
new file mode 100644
index 000000000..f881b7f7b
--- /dev/null
+++ b/xorg-server/hw/kdrive/ati/ati_stub.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright © 2003 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "ati.h"
+#include "klinux.h"
+
+extern struct pci_id_entry ati_pci_ids[];
+
+void
+InitCard(char *name)
+{
+ struct pci_id_entry *id;
+ KdCardAttr attr;
+
+ for (id = ati_pci_ids; id->name != NULL; id++) {
+ int j = 0;
+ while (LinuxFindPci(id->vendor, id->device, j++, &attr))
+ KdCardInfoAdd(&ATIFuncs, &attr, 0);
+ }
+}
+
+void
+InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput(pScreenInfo, argc, argv);
+}
+
+void
+InitInput(int argc, char **argv)
+{
+ KdOsAddInputDrivers();
+ KdInitInput();
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+#ifdef KDRIVEVESA
+ vesaUseMsg();
+#endif
+}
+
+int
+ddxProcessArgument(int argc, char **argv, int i)
+{
+ int ret;
+
+#ifdef KDRIVEVESA
+ if (!(ret = vesaProcessArgument (argc, argv, i)))
+#endif
+ ret = KdProcessArgument(argc, argv, i);
+
+ return ret;
+}
diff --git a/xorg-server/hw/kdrive/ati/ati_video.c b/xorg-server/hw/kdrive/ati/ati_video.c
new file mode 100644
index 000000000..ca0ab464a
--- /dev/null
+++ b/xorg-server/hw/kdrive/ati/ati_video.c
@@ -0,0 +1,988 @@
+/*
+ * Copyright © 2004 Keith Packard
+ * Copyright © 2005 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Based on mach64video.c by Keith Packard.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "ati.h"
+#include "ati_dma.h"
+#include "ati_draw.h"
+#include "ati_reg.h"
+#include "kaa.h"
+
+#include <X11/extensions/Xv.h>
+#include "fourcc.h"
+
+#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
+
+static Atom xvBrightness, xvSaturation;
+
+extern CARD8 ATIBltRop[16];
+
+#define IMAGE_MAX_WIDTH 2048
+#define IMAGE_MAX_HEIGHT 2048
+
+static void
+ATIStopVideo(KdScreenInfo *screen, pointer data, Bool exit)
+{
+ ScreenPtr pScreen = screen->pScreen;
+ ATIPortPrivPtr pPortPriv = (ATIPortPrivPtr)data;
+
+ REGION_EMPTY(screen->pScreen, &pPortPriv->clip);
+
+ if (pPortPriv->off_screen) {
+ KdOffscreenFree (pScreen, pPortPriv->off_screen);
+ pPortPriv->off_screen = 0;
+ }
+}
+
+static int
+ATISetPortAttribute(KdScreenInfo *screen, Atom attribute, int value,
+ pointer data)
+{
+ return BadMatch;
+}
+
+static int
+ATIGetPortAttribute(KdScreenInfo *screen, Atom attribute, int *value,
+ pointer data)
+{
+ return BadMatch;
+}
+
+static void
+ATIQueryBestSize(KdScreenInfo *screen, Bool motion, short vid_w, short vid_h,
+ short drw_w, short drw_h, unsigned int *p_w, unsigned int *p_h,
+ pointer data)
+{
+ *p_w = drw_w;
+ *p_h = drw_h;
+}
+
+/* ATIClipVideo -
+
+ Takes the dst box in standard X BoxRec form (top and left
+ edges inclusive, bottom and right exclusive). The new dst
+ box is returned. The source boundaries are given (x1, y1
+ inclusive, x2, y2 exclusive) and returned are the new source
+ boundaries in 16.16 fixed point.
+*/
+
+static void
+ATIClipVideo(BoxPtr dst, INT32 *x1, INT32 *x2, INT32 *y1, INT32 *y2,
+ BoxPtr extents, INT32 width, INT32 height)
+{
+ INT32 vscale, hscale, delta;
+ int diff;
+
+ hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1);
+ vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1);
+
+ *x1 <<= 16; *x2 <<= 16;
+ *y1 <<= 16; *y2 <<= 16;
+
+ diff = extents->x1 - dst->x1;
+ if (diff > 0) {
+ dst->x1 = extents->x1;
+ *x1 += diff * hscale;
+ }
+ diff = dst->x2 - extents->x2;
+ if (diff > 0) {
+ dst->x2 = extents->x2;
+ *x2 -= diff * hscale;
+ }
+ diff = extents->y1 - dst->y1;
+ if (diff > 0) {
+ dst->y1 = extents->y1;
+ *y1 += diff * vscale;
+ }
+ diff = dst->y2 - extents->y2;
+ if (diff > 0) {
+ dst->y2 = extents->y2;
+ *y2 -= diff * vscale;
+ }
+
+ if (*x1 < 0) {
+ diff = (- *x1 + hscale - 1)/ hscale;
+ dst->x1 += diff;
+ *x1 += diff * hscale;
+ }
+ delta = *x2 - (width << 16);
+ if (delta > 0) {
+ diff = (delta + hscale - 1)/ hscale;
+ dst->x2 -= diff;
+ *x2 -= diff * hscale;
+ }
+ if (*y1 < 0) {
+ diff = (- *y1 + vscale - 1)/ vscale;
+ dst->y1 += diff;
+ *y1 += diff * vscale;
+ }
+ delta = *y2 - (height << 16);
+ if (delta > 0) {
+ diff = (delta + vscale - 1)/ vscale;
+ dst->y2 -= diff;
+ *y2 -= diff * vscale;
+ }
+}
+
+static void
+R128DisplayVideo(KdScreenInfo *screen, ATIPortPrivPtr pPortPriv)
+{
+ ScreenPtr pScreen = screen->pScreen;
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ CARD32 dstDatatype, srcDatatype;
+ CARD32 dst_offset, dst_pitch;
+ int dstxoff, dstyoff;
+ PixmapPtr pPixmap = pPortPriv->pPixmap;
+ int bpp = pPixmap->drawable.bitsPerPixel;
+ RING_LOCALS;
+
+ BoxPtr pBox = REGION_RECTS(&pPortPriv->clip);
+ int nBox = REGION_NUM_RECTS(&pPortPriv->clip);
+
+ if (pPortPriv->id == FOURCC_UYVY)
+ srcDatatype = R128_DATATYPE_YVYU_422;
+ else
+ srcDatatype = R128_DATATYPE_VYUY_422;
+
+ switch (bpp)
+ {
+ case 16:
+ if (pPixmap->drawable.depth == 15)
+ dstDatatype = R128_DATATYPE_ARGB1555;
+ else
+ dstDatatype = R128_DATATYPE_RGB565;
+ break;
+ case 32:
+ dstDatatype = R128_DATATYPE_ARGB8888;
+ break;
+ default:
+ return;
+ }
+
+ dst_offset = ((CARD8 *)pPixmap->devPrivate.ptr -
+ pScreenPriv->screen->memory_base);
+ dst_pitch = pPixmap->devKind;
+#ifdef COMPOSITE
+ dstxoff = -pPixmap->screen_x + pPixmap->drawable.x;
+ dstyoff = -pPixmap->screen_y + pPixmap->drawable.y;
+#else
+ dstxoff = 0;
+ dstyoff = 0;
+#endif
+
+ BEGIN_DMA(18);
+ OUT_REG(ATI_REG_DST_PITCH_OFFSET,
+ ((dst_pitch / bpp) << 21) | (dst_offset >> 5));
+ OUT_REG(ATI_REG_DP_GUI_MASTER_CNTL,
+ ATI_GMC_DST_PITCH_OFFSET_CNTL |
+ ATI_GMC_BRUSH_NONE |
+ (dstDatatype << 8) |
+ ATI_GMC_SRC_DATATYPE_COLOR |
+ (ATIBltRop[GXcopy] << 16) |
+ R128_GMC_3D_FCN_EN |
+ ATI_GMC_CLR_CMP_CNTL_DIS |
+ R128_GMC_AUX_CLIP_DIS);
+ OUT_REG(ATI_REG_DP_CNTL,
+ ATI_DST_X_LEFT_TO_RIGHT | ATI_DST_Y_TOP_TO_BOTTOM );
+ OUT_REG(R128_REG_SCALE_3D_CNTL,
+ R128_SCALE_3D_SCALE |
+ R128_SBLEND_ONE |
+ R128_DBLEND_ZERO);
+ OUT_REG(R128_REG_TEX_CNTL_C, R128_TEX_CACHE_FLUSH);
+ OUT_REG(R128_REG_SCALE_3D_DATATYPE, srcDatatype);
+
+ OUT_RING(DMA_PACKET0(R128_REG_SCALE_PITCH, 5));
+ OUT_RING_REG(R128_REG_SCALE_PITCH, pPortPriv->src_pitch / 16);
+ OUT_RING_REG(R128_REG_SCALE_X_INC,
+ (pPortPriv->src_w << 16) / pPortPriv->dst_w);
+ OUT_RING_REG(R128_REG_SCALE_Y_INC,
+ (pPortPriv->src_h << 16) / pPortPriv->dst_h);
+ OUT_RING_REG(R128_REG_SCALE_HACC, 0x0);
+ OUT_RING_REG(R128_REG_SCALE_VACC, 0x0);
+
+ END_DMA();
+
+ while (nBox--) {
+ int srcX, srcY, dstX, dstY, srcw, srch, dstw, dsth;
+
+ dstX = pBox->x1 + dstxoff;
+ dstY = pBox->y1 + dstyoff;
+ dstw = pBox->x2 - pBox->x1;
+ dsth = pBox->y2 - pBox->y1;
+ srcX = (pBox->x1 - pPortPriv->dst_x1) *
+ pPortPriv->src_w / pPortPriv->dst_w;
+ srcY = (pBox->y1 - pPortPriv->dst_y1) *
+ pPortPriv->src_h / pPortPriv->dst_h;
+ srcw = pPortPriv->src_w - srcX;
+ srch = pPortPriv->src_h - srcY;
+
+ BEGIN_DMA(6);
+ OUT_RING(DMA_PACKET0(R128_REG_SCALE_SRC_HEIGHT_WIDTH, 2));
+ OUT_RING_REG(R128_REG_SCALE_SRC_HEIGHT_WIDTH,
+ (srch << 16) | srcw);
+ OUT_RING_REG(R128_REG_SCALE_OFFSET_0, pPortPriv->src_offset +
+ srcY * pPortPriv->src_pitch + srcX * 2);
+
+ OUT_RING(DMA_PACKET0(R128_REG_SCALE_DST_X_Y, 2));
+ OUT_RING_REG(R128_REG_SCALE_DST_X_Y, (dstX << 16) | dstY);
+ OUT_RING_REG(R128_REG_SCALE_DST_HEIGHT_WIDTH,
+ (dsth << 16) | dstw);
+ END_DMA();
+ pBox++;
+ }
+#ifdef DAMAGEEXT
+ /* XXX: Shouldn't this be in kxv.c instead? */
+ DamageDamageRegion(pPortPriv->pDraw, &pPortPriv->clip);
+#endif
+ kaaMarkSync(pScreen);
+}
+
+union intfloat {
+ float f;
+ CARD32 i;
+};
+
+struct blend_vertex {
+ union intfloat x, y;
+ union intfloat s0, t0;
+};
+
+#define VTX_DWORD_COUNT 4
+
+#define VTX_OUT(vtx) \
+do { \
+ OUT_RING(vtx.x.i); \
+ OUT_RING(vtx.y.i); \
+ OUT_RING(vtx.s0.i); \
+ OUT_RING(vtx.t0.i); \
+} while (0)
+
+static void
+RadeonDisplayVideo(KdScreenInfo *screen, ATIPortPrivPtr pPortPriv)
+{
+ ScreenPtr pScreen = screen->pScreen;
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+ ATIScreenInfo(pScreenPriv);
+ struct blend_vertex vtx[4];
+ PixmapPtr pPixmap = pPortPriv->pPixmap;
+ CARD32 txformat;
+ CARD32 dst_offset, dst_pitch, dst_format;
+ int dstxoff, dstyoff, pixel_shift;
+ RING_LOCALS;
+
+ BoxPtr pBox = REGION_RECTS(&pPortPriv->clip);
+ int nBox = REGION_NUM_RECTS(&pPortPriv->clip);
+
+ switch (pPixmap->drawable.bitsPerPixel) {
+ case 16:
+ if (pPixmap->drawable.depth == 15)
+ dst_format = RADEON_COLOR_FORMAT_ARGB1555;
+ else
+ dst_format = RADEON_COLOR_FORMAT_RGB565;
+ pixel_shift = 1;
+ break;
+ case 32:
+ dst_format = RADEON_COLOR_FORMAT_ARGB8888;
+ pixel_shift = 2;
+ break;
+ default:
+ return;
+ }
+
+ dst_offset = ((CARD8 *)pPixmap->devPrivate.ptr -
+ pScreenPriv->screen->memory_base);
+ dst_pitch = pPixmap->devKind;
+
+#ifdef COMPOSITE
+ dstxoff = -pPixmap->screen_x + pPixmap->drawable.x;
+ dstyoff = -pPixmap->screen_y + pPixmap->drawable.y;
+#else
+ dstxoff = 0;
+ dstyoff = 0;
+#endif
+
+ /* Same for R100/R200 */
+ if (pPortPriv->id == FOURCC_UYVY)
+ txformat = RADEON_TXFORMAT_YVYU422;
+ else
+ txformat = RADEON_TXFORMAT_VYUY422;
+
+ txformat |= RADEON_TXFORMAT_NON_POWER2;
+
+ RadeonSwitchTo3D(atis);
+
+ BEGIN_DMA(8);
+
+ OUT_RING(DMA_PACKET0(RADEON_REG_PP_CNTL, 3));
+ OUT_RING_REG(RADEON_REG_PP_CNTL,
+ RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE);
+ OUT_RING_REG(RADEON_REG_RB3D_CNTL,
+ dst_format | RADEON_ALPHA_BLEND_ENABLE);
+ OUT_RING_REG(RADEON_REG_RB3D_COLOROFFSET, dst_offset);
+
+ OUT_REG(RADEON_REG_RB3D_COLORPITCH, dst_pitch >> pixel_shift);
+
+ OUT_REG(RADEON_REG_RB3D_BLENDCNTL,
+ RADEON_SBLEND_GL_ONE | RADEON_DBLEND_GL_ZERO);
+
+ END_DMA();
+
+ if (atic->is_r200) {
+ BEGIN_DMA(17);
+
+ OUT_REG(R200_REG_SE_VTX_FMT_0, R200_VTX_XY);
+ OUT_REG(R200_REG_SE_VTX_FMT_1,
+ (2 << R200_VTX_TEX0_COMP_CNT_SHIFT));
+
+ OUT_RING(DMA_PACKET0(R200_REG_PP_TXFILTER_0, 5));
+ OUT_RING_REG(R200_REG_PP_TXFILTER_0,
+ R200_MAG_FILTER_LINEAR |
+ R200_MIN_FILTER_LINEAR |
+ R200_YUV_TO_RGB);
+ OUT_RING_REG(R200_REG_PP_TXFORMAT_0, txformat);
+ OUT_RING_REG(R200_REG_PP_TXFORMAT_X_0, 0);
+ OUT_RING_REG(R200_REG_PP_TXSIZE_0,
+ (pPixmap->drawable.width - 1) |
+ ((pPixmap->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
+ OUT_RING_REG(R200_REG_PP_TXPITCH_0, pPortPriv->src_pitch - 32);
+
+ OUT_REG(R200_PP_TXOFFSET_0, pPortPriv->src_offset);
+
+ OUT_RING(DMA_PACKET0(R200_REG_PP_TXCBLEND_0, 4));
+ OUT_RING_REG(R200_REG_PP_TXCBLEND_0,
+ R200_TXC_ARG_A_ZERO |
+ R200_TXC_ARG_B_ZERO |
+ R200_TXC_ARG_C_R0_COLOR |
+ R200_TXC_OP_MADD);
+ OUT_RING_REG(R200_REG_PP_TXCBLEND2_0,
+ R200_TXC_CLAMP_0_1 | R200_TXC_OUTPUT_REG_R0);
+ OUT_RING_REG(R200_REG_PP_TXABLEND_0,
+ R200_TXA_ARG_A_ZERO |
+ R200_TXA_ARG_B_ZERO |
+ R200_TXA_ARG_C_R0_ALPHA |
+ R200_TXA_OP_MADD);
+ OUT_RING_REG(R200_REG_PP_TXABLEND2_0,
+ R200_TXA_CLAMP_0_1 | R200_TXA_OUTPUT_REG_R0);
+
+ END_DMA();
+ } else {
+// BEGIN_DMA(11);
+ BEGIN_DMA(9);
+
+ OUT_RING(DMA_PACKET0(RADEON_REG_PP_TXFILTER_0, 5));
+ OUT_RING_REG(RADEON_REG_PP_TXFILTER_0, RADEON_MAG_FILTER_LINEAR |
+ RADEON_MIN_FILTER_LINEAR |
+ RADEON_YUV_TO_RGB);
+ OUT_RING_REG(RADEON_REG_PP_TXFORMAT_0, txformat);
+ OUT_RING_REG(RADEON_REG_PP_TXOFFSET_0, pPortPriv->src_offset);
+ OUT_RING_REG(RADEON_REG_PP_TXCBLEND_0,
+ RADEON_COLOR_ARG_A_ZERO |
+ RADEON_COLOR_ARG_B_ZERO |
+ RADEON_COLOR_ARG_C_T0_COLOR |
+ RADEON_BLEND_CTL_ADD |
+ RADEON_CLAMP_TX);
+ OUT_RING_REG(RADEON_REG_PP_TXABLEND_0,
+ RADEON_ALPHA_ARG_A_ZERO |
+ RADEON_ALPHA_ARG_B_ZERO |
+ RADEON_ALPHA_ARG_C_T0_ALPHA |
+ RADEON_BLEND_CTL_ADD |
+ RADEON_CLAMP_TX);
+
+ OUT_RING(DMA_PACKET0(RADEON_REG_PP_TEX_SIZE_0, 2));
+ OUT_RING_REG(RADEON_REG_PP_TEX_SIZE_0,
+ (pPixmap->drawable.width - 1) |
+ ((pPixmap->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
+ OUT_RING_REG(RADEON_REG_PP_TEX_PITCH_0,
+ pPortPriv->src_pitch - 32);
+
+// OUT_RING_REG(ATI_REG_WAIT_UNTIL, ATI_WAIT_CRTC_VLINE);
+
+ END_DMA();
+ }
+
+ while (nBox--) {
+ float srcX, srcY, dstX, dstY, srcw, srch, dstw, dsth;
+
+ dstX = pBox->x1 + dstxoff;
+ dstY = pBox->y1 + dstyoff;
+ dstw = pBox->x2 - pBox->x1;
+ dsth = pBox->y2 - pBox->y1;
+ srcX = (pBox->x1 - pPortPriv->dst_x1) *
+ pPortPriv->src_w / pPortPriv->dst_w;
+ srcY = (pBox->y1 - pPortPriv->dst_y1) *
+ pPortPriv->src_h / pPortPriv->dst_h;
+ srcw = pPortPriv->src_w * (dstw / pPortPriv->dst_w);
+ srch = pPortPriv->src_h * (dsth / pPortPriv->dst_h);
+
+ /*
+ * rectangle:
+ *
+ * +---------2
+ * | |
+ * | |
+ * 0---------1
+ */
+
+ vtx[0].x.f = dstX;
+ vtx[0].y.f = dstY + dsth;
+ vtx[0].s0.f = srcX;
+ vtx[0].t0.f = srcY + srch;
+
+ vtx[1].x.f = dstX + dstw;
+ vtx[1].y.f = dstY + dsth;
+ vtx[1].s0.f = srcX + srcw;
+ vtx[1].t0.f = srcY + srch;
+
+ vtx[2].x.f = dstX + dstw;
+ vtx[2].y.f = dstY;
+ vtx[2].s0.f = srcX + srcw;
+ vtx[2].t0.f = srcY;
+
+ if (atic->is_r100) {
+ BEGIN_DMA(3 * VTX_DWORD_COUNT + 3);
+ OUT_RING(DMA_PACKET3(RADEON_CP_PACKET3_3D_DRAW_IMMD,
+ 3 * VTX_DWORD_COUNT + 2));
+ OUT_RING(RADEON_CP_VC_FRMT_XY |
+ RADEON_CP_VC_FRMT_ST0);
+ OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_RECT_LIST |
+ RADEON_CP_VC_CNTL_PRIM_WALK_RING |
+ RADEON_CP_VC_CNTL_MAOS_ENABLE |
+ RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
+ (3 << RADEON_CP_VC_CNTL_NUM_SHIFT));
+ } else {
+ BEGIN_DMA(3 * VTX_DWORD_COUNT + 2);
+ OUT_RING(DMA_PACKET3(R200_CP_PACKET3_3D_DRAW_IMMD_2,
+ 3 * VTX_DWORD_COUNT + 1));
+ OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_RECT_LIST |
+ RADEON_CP_VC_CNTL_PRIM_WALK_RING |
+ (3 << RADEON_CP_VC_CNTL_NUM_SHIFT));
+ }
+
+ VTX_OUT(vtx[0]);
+ VTX_OUT(vtx[1]);
+ VTX_OUT(vtx[2]);
+ END_DMA();
+
+ pBox++;
+ }
+#ifdef DAMAGEEXT
+ /* XXX: Shouldn't this be in kxv.c instead? */
+ DamageDamageRegion(pPortPriv->pDraw, &pPortPriv->clip);
+#endif
+ kaaMarkSync(pScreen);
+}
+
+static void
+ATIVideoSave(ScreenPtr pScreen, KdOffscreenArea *area)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATIPortPrivPtr pPortPriv = atis->pAdaptor->pPortPrivates[0].ptr;
+
+ if (pPortPriv->off_screen == area)
+ pPortPriv->off_screen = 0;
+}
+
+static int
+ATIPutImage(KdScreenInfo *screen, DrawablePtr pDraw,
+ short src_x, short src_y,
+ short drw_x, short drw_y,
+ short src_w, short src_h,
+ short drw_w, short drw_h,
+ int id,
+ unsigned char *buf,
+ short width,
+ short height,
+ Bool sync,
+ RegionPtr clipBoxes,
+ pointer data)
+{
+ ScreenPtr pScreen = screen->pScreen;
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+ ATIScreenInfo(pScreenPriv);
+ ATIPortPrivPtr pPortPriv = (ATIPortPrivPtr)data;
+ char *mmio = atic->reg_base;
+ INT32 x1, x2, y1, y2;
+ int randr = RR_Rotate_0 /* XXX */;
+ int srcPitch, srcPitch2, dstPitch;
+ int top, left, npixels, nlines, size;
+ BoxRec dstBox;
+ int dst_width = width, dst_height = height;
+ int rot_x1, rot_y1, rot_x2, rot_y2;
+ int dst_x1, dst_y1, dst_x2, dst_y2;
+ int rot_src_w, rot_src_h, rot_drw_w, rot_drw_h;
+
+ /* Clip */
+ x1 = src_x;
+ x2 = src_x + src_w;
+ y1 = src_y;
+ y2 = src_y + src_h;
+
+ dstBox.x1 = drw_x;
+ dstBox.x2 = drw_x + drw_w;
+ dstBox.y1 = drw_y;
+ dstBox.y2 = drw_y + drw_h;
+
+ ATIClipVideo(&dstBox, &x1, &x2, &y1, &y2,
+ REGION_EXTENTS(pScreen, clipBoxes), width, height);
+
+ src_w = (x2 - x1) >> 16;
+ src_h = (y2 - y1) >> 16;
+ drw_w = dstBox.x2 - dstBox.x1;
+ drw_h = dstBox.y2 - dstBox.y1;
+
+ if ((x1 >= x2) || (y1 >= y2))
+ return Success;
+
+ if (mmio == NULL)
+ return BadAlloc;
+
+ if (randr & (RR_Rotate_0|RR_Rotate_180)) {
+ dst_width = width;
+ dst_height = height;
+ rot_src_w = src_w;
+ rot_src_h = src_h;
+ rot_drw_w = drw_w;
+ rot_drw_h = drw_h;
+ } else {
+ dst_width = height;
+ dst_height = width;
+ rot_src_w = src_h;
+ rot_src_h = src_w;
+ rot_drw_w = drw_h;
+ rot_drw_h = drw_w;
+ }
+
+ switch (randr & RR_Rotate_All) {
+ case RR_Rotate_0:
+ default:
+ dst_x1 = dstBox.x1;
+ dst_y1 = dstBox.y1;
+ dst_x2 = dstBox.x2;
+ dst_y2 = dstBox.y2;
+ rot_x1 = x1;
+ rot_y1 = y1;
+ rot_x2 = x2;
+ rot_y2 = y2;
+ break;
+ case RR_Rotate_90:
+ dst_x1 = dstBox.y1;
+ dst_y1 = screen->height - dstBox.x2;
+ dst_x2 = dstBox.y2;
+ dst_y2 = screen->height - dstBox.x1;
+ rot_x1 = y1;
+ rot_y1 = (src_w << 16) - x2;
+ rot_x2 = y2;
+ rot_y2 = (src_w << 16) - x1;
+ break;
+ case RR_Rotate_180:
+ dst_x1 = screen->width - dstBox.x2;
+ dst_y1 = screen->height - dstBox.y2;
+ dst_x2 = screen->width - dstBox.x1;
+ dst_y2 = screen->height - dstBox.y1;
+ rot_x1 = (src_w << 16) - x2;
+ rot_y1 = (src_h << 16) - y2;
+ rot_x2 = (src_w << 16) - x1;
+ rot_y2 = (src_h << 16) - y1;
+ break;
+ case RR_Rotate_270:
+ dst_x1 = screen->width - dstBox.y2;
+ dst_y1 = dstBox.x1;
+ dst_x2 = screen->width - dstBox.y1;
+ dst_y2 = dstBox.x2;
+ rot_x1 = (src_h << 16) - y2;
+ rot_y1 = x1;
+ rot_x2 = (src_h << 16) - y1;
+ rot_y2 = x2;
+ break;
+ }
+
+ switch(id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ dstPitch = ((dst_width << 1) + 15) & ~15;
+ srcPitch = (width + 3) & ~3;
+ srcPitch2 = ((width >> 1) + 3) & ~3;
+ size = dstPitch * dst_height;
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ default:
+ dstPitch = ((dst_width << 1) + 15) & ~15;
+ srcPitch = (width << 1);
+ srcPitch2 = 0;
+ size = dstPitch * dst_height;
+ break;
+ }
+
+ if (pPortPriv->off_screen != NULL && size != pPortPriv->size) {
+ KdOffscreenFree(screen->pScreen, pPortPriv->off_screen);
+ pPortPriv->off_screen = 0;
+ }
+
+ if (pPortPriv->off_screen == NULL) {
+ pPortPriv->off_screen = KdOffscreenAlloc(screen->pScreen,
+ size * 2, 64, TRUE, ATIVideoSave, pPortPriv);
+ if (pPortPriv->off_screen == NULL)
+ return BadAlloc;
+ }
+
+
+ if (pDraw->type == DRAWABLE_WINDOW)
+ pPortPriv->pPixmap =
+ (*pScreen->GetWindowPixmap)((WindowPtr)pDraw);
+ else
+ pPortPriv->pPixmap = (PixmapPtr)pDraw;
+
+ /* Migrate the pixmap to offscreen if necessary. */
+ if (!kaaPixmapIsOffscreen(pPortPriv->pPixmap))
+ kaaMoveInPixmap(pPortPriv->pPixmap);
+
+ if (!kaaPixmapIsOffscreen(pPortPriv->pPixmap)) {
+ return BadAlloc;
+ }
+
+ pPortPriv->src_offset = pPortPriv->off_screen->offset;
+ pPortPriv->src_addr = (CARD8 *)(pScreenPriv->screen->memory_base +
+ pPortPriv->src_offset);
+ pPortPriv->src_pitch = dstPitch;
+ pPortPriv->size = size;
+ pPortPriv->pDraw = pDraw;
+
+ /* copy data */
+ top = rot_y1 >> 16;
+ left = (rot_x1 >> 16) & ~1;
+ npixels = ((((rot_x2 + 0xffff) >> 16) + 1) & ~1) - left;
+
+ /* Since we're probably overwriting the area that might still be used
+ * for the last PutImage request, wait for idle.
+ */
+ ATIWaitIdle(atis);
+
+ switch(id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ top &= ~1;
+ nlines = ((((rot_y2 + 0xffff) >> 16) + 1) & ~1) - top;
+ KdXVCopyPlanarData(screen, buf, pPortPriv->src_addr, randr,
+ srcPitch, srcPitch2, dstPitch, rot_src_w, rot_src_h,
+ height, top, left, nlines, npixels, id);
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ default:
+ nlines = ((rot_y2 + 0xffff) >> 16) - top;
+ KdXVCopyPackedData(screen, buf, pPortPriv->src_addr, randr,
+ srcPitch, dstPitch, rot_src_w, rot_src_h, top, left,
+ nlines, npixels);
+ break;
+ }
+
+ /* update cliplist */
+ if (!REGION_EQUAL(screen->pScreen, &pPortPriv->clip, clipBoxes)) {
+ REGION_COPY(screen->pScreen, &pPortPriv->clip, clipBoxes);
+ }
+
+ pPortPriv->id = id;
+ pPortPriv->src_x1 = rot_x1;
+ pPortPriv->src_y1 = rot_y1;
+ pPortPriv->src_x2 = rot_x2;
+ pPortPriv->src_y2 = rot_y2;
+ pPortPriv->src_w = rot_src_w;
+ pPortPriv->src_h = rot_src_h;
+ pPortPriv->dst_x1 = dst_x1;
+ pPortPriv->dst_y1 = dst_y1;
+ pPortPriv->dst_x2 = dst_x2;
+ pPortPriv->dst_y2 = dst_y2;
+ pPortPriv->dst_w = rot_drw_w;
+ pPortPriv->dst_h = rot_drw_h;
+
+ if (atic->is_radeon)
+ RadeonDisplayVideo(screen, pPortPriv);
+ else
+ R128DisplayVideo(screen, pPortPriv);
+
+ return Success;
+}
+
+static int
+ATIReputImage(KdScreenInfo *screen, DrawablePtr pDraw, short drw_x, short drw_y,
+ RegionPtr clipBoxes, pointer data)
+{
+ ScreenPtr pScreen = screen->pScreen;
+ KdScreenPriv(pScreen);
+ ATICardInfo(pScreenPriv);
+ ATIPortPrivPtr pPortPriv = (ATIPortPrivPtr)data;
+ BoxPtr pOldExtents = REGION_EXTENTS(screen->pScreen, &pPortPriv->clip);
+ BoxPtr pNewExtents = REGION_EXTENTS(screen->pScreen, clipBoxes);
+
+ if (pOldExtents->x1 != pNewExtents->x1 ||
+ pOldExtents->x2 != pNewExtents->x2 ||
+ pOldExtents->y1 != pNewExtents->y1 ||
+ pOldExtents->y2 != pNewExtents->y2)
+ return BadMatch;
+
+ if (pDraw->type == DRAWABLE_WINDOW)
+ pPortPriv->pPixmap =
+ (*pScreen->GetWindowPixmap)((WindowPtr)pDraw);
+ else
+ pPortPriv->pPixmap = (PixmapPtr)pDraw;
+
+ if (!kaaPixmapIsOffscreen(pPortPriv->pPixmap))
+ kaaMoveInPixmap(pPortPriv->pPixmap);
+
+ if (!kaaPixmapIsOffscreen(pPortPriv->pPixmap)) {
+ ErrorF("err\n");
+ return BadAlloc;
+ }
+
+
+ /* update cliplist */
+ if (!REGION_EQUAL(screen->pScreen, &pPortPriv->clip, clipBoxes))
+ REGION_COPY(screen->pScreen, &pPortPriv->clip, clipBoxes);
+
+ /* XXX: What do the drw_x and drw_y here mean for us? */
+
+ if (atic->is_radeon)
+ RadeonDisplayVideo(screen, pPortPriv);
+ else
+ R128DisplayVideo(screen, pPortPriv);
+
+ return Success;
+}
+
+static int
+ATIQueryImageAttributes(KdScreenInfo *screen, int id, unsigned short *w,
+ unsigned short *h, int *pitches, int *offsets)
+{
+ int size, tmp;
+
+ if (*w > IMAGE_MAX_WIDTH)
+ *w = IMAGE_MAX_WIDTH;
+ if (*h > IMAGE_MAX_HEIGHT)
+ *h = IMAGE_MAX_HEIGHT;
+
+ *w = (*w + 1) & ~1;
+ if (offsets)
+ offsets[0] = 0;
+
+ switch (id)
+ {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ *h = (*h + 1) & ~1;
+ size = (*w + 3) & ~3;
+ if (pitches)
+ pitches[0] = size;
+ size *= *h;
+ if (offsets)
+ offsets[1] = size;
+ tmp = ((*w >> 1) + 3) & ~3;
+ if (pitches)
+ pitches[1] = pitches[2] = tmp;
+ tmp *= (*h >> 1);
+ size += tmp;
+ if (offsets)
+ offsets[2] = size;
+ size += tmp;
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ default:
+ size = *w << 1;
+ if (pitches)
+ pitches[0] = size;
+ size *= *h;
+ break;
+ }
+
+ return size;
+}
+
+
+/* client libraries expect an encoding */
+static KdVideoEncodingRec DummyEncoding[1] =
+{
+ {
+ 0,
+ "XV_IMAGE",
+ IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT,
+ {1, 1}
+ }
+};
+
+#define NUM_FORMATS 3
+
+static KdVideoFormatRec Formats[NUM_FORMATS] =
+{
+ {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
+};
+
+#define NUM_ATTRIBUTES 0
+
+static KdAttributeRec Attributes[NUM_ATTRIBUTES] =
+{
+};
+
+#define NUM_IMAGES 4
+
+static KdImageRec Images[NUM_IMAGES] =
+{
+ XVIMAGE_YUY2,
+ XVIMAGE_YV12,
+ XVIMAGE_I420,
+ XVIMAGE_UYVY
+};
+
+static KdVideoAdaptorPtr
+ATISetupImageVideo(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ KdVideoAdaptorPtr adapt;
+ ATIPortPrivPtr pPortPriv;
+ int i;
+
+ atis->num_texture_ports = 16;
+
+ adapt = xcalloc(1, sizeof(KdVideoAdaptorRec) + atis->num_texture_ports *
+ (sizeof(ATIPortPrivRec) + sizeof(DevUnion)));
+ if (adapt == NULL)
+ return NULL;
+
+ adapt->type = XvWindowMask | XvInputMask | XvImageMask;
+ adapt->flags = VIDEO_CLIP_TO_VIEWPORT;
+ adapt->name = "ATI Texture Video";
+ adapt->nEncodings = 1;
+ adapt->pEncodings = DummyEncoding;
+ adapt->nFormats = NUM_FORMATS;
+ adapt->pFormats = Formats;
+ adapt->nPorts = atis->num_texture_ports;
+ adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
+
+ pPortPriv =
+ (ATIPortPrivPtr)(&adapt->pPortPrivates[atis->num_texture_ports]);
+
+ for (i = 0; i < atis->num_texture_ports; i++)
+ adapt->pPortPrivates[i].ptr = &pPortPriv[i];
+
+ adapt->nAttributes = NUM_ATTRIBUTES;
+ adapt->pAttributes = Attributes;
+ adapt->pImages = Images;
+ adapt->nImages = NUM_IMAGES;
+ adapt->PutVideo = NULL;
+ adapt->PutStill = NULL;
+ adapt->GetVideo = NULL;
+ adapt->GetStill = NULL;
+ adapt->StopVideo = ATIStopVideo;
+ adapt->SetPortAttribute = ATISetPortAttribute;
+ adapt->GetPortAttribute = ATIGetPortAttribute;
+ adapt->QueryBestSize = ATIQueryBestSize;
+ adapt->PutImage = ATIPutImage;
+ adapt->ReputImage = ATIReputImage;
+ adapt->QueryImageAttributes = ATIQueryImageAttributes;
+
+ /* gotta uninit this someplace */
+ REGION_INIT(pScreen, &pPortPriv->clip, NullBox, 0);
+
+ atis->pAdaptor = adapt;
+
+ xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
+ xvSaturation = MAKE_ATOM("XV_SATURATION");
+
+ return adapt;
+}
+
+Bool ATIInitVideo(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICardInfo(pScreenPriv);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL;
+ KdVideoAdaptorPtr newAdaptor = NULL;
+ int num_adaptors;
+
+ atis->pAdaptor = NULL;
+
+ if (atic->reg_base == NULL)
+ return FALSE;
+ if (atic->is_r300)
+ return FALSE;
+
+ num_adaptors = KdXVListGenericAdaptors(screen, &adaptors);
+
+ newAdaptor = ATISetupImageVideo(pScreen);
+
+ if (newAdaptor) {
+ if (!num_adaptors) {
+ num_adaptors = 1;
+ adaptors = &newAdaptor;
+ } else {
+ newAdaptors = xalloc((num_adaptors + 1) *
+ sizeof(KdVideoAdaptorPtr *));
+ if (newAdaptors) {
+ memcpy(newAdaptors, adaptors, num_adaptors *
+ sizeof(KdVideoAdaptorPtr));
+ newAdaptors[num_adaptors] = newAdaptor;
+ adaptors = newAdaptors;
+ num_adaptors++;
+ }
+ }
+ }
+
+ if (num_adaptors)
+ KdXVScreenInit(pScreen, adaptors, num_adaptors);
+
+ if (newAdaptors)
+ xfree(newAdaptors);
+
+ return TRUE;
+}
+
+void
+ATIFiniVideo(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ATIScreenInfo(pScreenPriv);
+ KdVideoAdaptorPtr adapt = atis->pAdaptor;
+ ATIPortPrivPtr pPortPriv;
+ int i;
+
+ if (!adapt)
+ return;
+
+ for (i = 0; i < atis->num_texture_ports; i++) {
+ pPortPriv = (ATIPortPrivPtr)(&adapt->pPortPrivates[i].ptr);
+ REGION_UNINIT(pScreen, &pPortPriv->clip);
+ }
+ xfree(adapt);
+ atis->pAdaptor = NULL;
+}
diff --git a/xorg-server/hw/kdrive/ati/r128_composite.c b/xorg-server/hw/kdrive/ati/r128_composite.c
new file mode 100644
index 000000000..0d18ebff7
--- /dev/null
+++ b/xorg-server/hw/kdrive/ati/r128_composite.c
@@ -0,0 +1,564 @@
+/*
+ * Copyright © 2003 Eric Anholt, Anders Carlsson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "ati.h"
+#include "ati_reg.h"
+#include "ati_dma.h"
+#include "ati_draw.h"
+
+extern ATIScreenInfo *accel_atis;
+extern int sample_count;
+extern float sample_offsets_x[255];
+extern float sample_offsets_y[255];
+extern CARD8 ATIBltRop[16];
+
+static int widths[2] = {1,1};
+static int heights[2] = {1,1};
+static Bool is_transform[2];
+static PictTransform *transform[2];
+
+struct blendinfo {
+ Bool dst_alpha;
+ Bool src_alpha;
+ CARD32 blendctl;
+};
+
+static struct blendinfo R128BlendOp[] = {
+ /* Clear */
+ {0, 0, R128_SBLEND_ZERO | R128_DBLEND_ZERO},
+ /* Src */
+ {0, 0, R128_SBLEND_ONE | R128_DBLEND_ZERO},
+ /* Dst */
+ {0, 0, R128_SBLEND_ZERO | R128_DBLEND_ONE},
+ /* Over */
+ {0, 1, R128_SBLEND_ONE | R128_DBLEND_INV_SRC_ALPHA},
+ /* OverReverse */
+ {1, 0, R128_SBLEND_INV_DST_ALPHA | R128_DBLEND_ONE},
+ /* In */
+ {1, 0, R128_SBLEND_DST_ALPHA | R128_DBLEND_ZERO},
+ /* InReverse */
+ {0, 1, R128_SBLEND_ZERO | R128_DBLEND_SRC_ALPHA},
+ /* Out */
+ {1, 0, R128_SBLEND_INV_DST_ALPHA | R128_DBLEND_ZERO},
+ /* OutReverse */
+ {0, 1, R128_SBLEND_ZERO | R128_DBLEND_INV_SRC_ALPHA},
+ /* Atop */
+ {1, 1, R128_SBLEND_DST_ALPHA | R128_DBLEND_INV_SRC_ALPHA},
+ /* AtopReverse */
+ {1, 1, R128_SBLEND_INV_DST_ALPHA | R128_DBLEND_SRC_ALPHA},
+ /* Xor */
+ {1, 1, R128_SBLEND_INV_DST_ALPHA | R128_DBLEND_INV_SRC_ALPHA},
+ /* Add */
+ {0, 0, R128_SBLEND_ONE | R128_DBLEND_ONE},
+};
+
+static Bool
+R128GetDatatypePict(CARD32 format, CARD32 *type)
+{
+ switch (format) {
+ case PICT_a1r5g5b5:
+ case PICT_x1r5g5b5:
+ *type = R128_DATATYPE_ARGB1555;
+ return TRUE;
+ case PICT_r5g6b5:
+ *type = R128_DATATYPE_RGB565;
+ return TRUE;
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+ *type = R128_DATATYPE_ARGB8888;
+ return TRUE;
+ default:
+ return FALSE;
+ }
+
+}
+
+static Bool
+R128CheckCompositeTexture(PicturePtr pPict)
+{
+ int w = pPict->pDrawable->width;
+ int h = pPict->pDrawable->height;
+
+ if (w > (1 << 10) || h > (1 << 10))
+ ATI_FALLBACK(("Picture w/h too large (%dx%d)\n", w, h));
+ if (pPict->repeat && ((w & (w - 1)) != 0 || (h & (h - 1)) != 0))
+ ATI_FALLBACK(("NPOT repeat unsupported (%dx%d)\n", w, h));
+
+ switch (pPict->format) {
+ case PICT_a8:
+ case PICT_a1r5g5b5:
+ case PICT_a4r4g4b4:
+ case PICT_r5g6b5:
+ case PICT_a8r8g8b8:
+ break;
+ default:
+ ATI_FALLBACK(("Unsupported picture format 0x%x\n",
+ pPict->format));
+ }
+
+ return TRUE;
+}
+
+Bool
+R128CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture)
+{
+ CARD32 dstDatatype;
+
+ if (op >= sizeof(R128BlendOp)/sizeof(R128BlendOp[0]))
+ ATI_FALLBACK(("Unsupported op 0x%x\n", op));
+ if (pDstPicture->format == PICT_a8) {
+ if (R128BlendOp[op].src_alpha || R128BlendOp[op].dst_alpha ||
+ pMaskPicture != NULL)
+ ATI_FALLBACK(("alpha blending unsupported with "
+ "A8 dst?\n"));
+ } else if (!R128GetDatatypePict(pDstPicture->format, &dstDatatype)) {
+ ATI_FALLBACK(("Unsupported dest format 0x%x\n",
+ pDstPicture->format));
+ }
+ if (pMaskPicture != NULL && pMaskPicture->componentAlpha &&
+ R128BlendOp[op].src_alpha)
+ ATI_FALLBACK(("Component alpha not supported with source alpha "
+ "blending.\n"));
+
+ if (!R128CheckCompositeTexture(pSrcPicture))
+ return FALSE;
+ if (pMaskPicture != NULL && !R128CheckCompositeTexture(pMaskPicture))
+ return FALSE;
+
+ return TRUE;
+}
+
+static Bool
+R128TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit, CARD32 *txsize,
+ CARD32 *tex_cntl_c)
+{
+ int w = pPict->pDrawable->width;
+ int h = pPict->pDrawable->height;
+ int bytepp, shift, l2w, l2h, l2p;
+ int pitch;
+
+ pitch = pPix->devKind;
+ if ((pitch & (pitch - 1)) != 0)
+ ATI_FALLBACK(("NPOT pitch 0x%x unsupported\n", pitch));
+
+ switch (pPict->format) {
+ case PICT_a8:
+ /* DATATYPE_RGB8 appears to expand the value into the alpha
+ * channel like we want. We then blank out the R,G,B channels
+ * as necessary using the combiners.
+ */
+ *tex_cntl_c = R128_DATATYPE_RGB8 << R128_TEX_DATATYPE_SHIFT;
+ break;
+ case PICT_a1r5g5b5:
+ *tex_cntl_c = R128_DATATYPE_ARGB1555 << R128_TEX_DATATYPE_SHIFT;
+ break;
+ case PICT_a4r4g4b4:
+ *tex_cntl_c = R128_DATATYPE_ARGB4444 << R128_TEX_DATATYPE_SHIFT;
+ break;
+ case PICT_r5g6b5:
+ *tex_cntl_c = R128_DATATYPE_RGB565 << R128_TEX_DATATYPE_SHIFT;
+ break;
+ case PICT_a8r8g8b8:
+ *tex_cntl_c = R128_DATATYPE_ARGB8888 << R128_TEX_DATATYPE_SHIFT;
+ break;
+ default:
+ return FALSE;
+ }
+ bytepp = PICT_FORMAT_BPP(pPict->format) / 8;
+
+ *tex_cntl_c |= R128_MIP_MAP_DISABLE;
+
+ if (pPict->filter == PictFilterBilinear)
+ *tex_cntl_c |= R128_MIN_BLEND_LINEAR | R128_MAG_BLEND_LINEAR;
+
+ if (unit == 0)
+ shift = 0;
+ else {
+ shift = 16;
+ *tex_cntl_c |= R128_SEC_SELECT_SEC_ST;
+ }
+
+ /* ATILog2 returns -1 for value of 0 */
+ l2w = ATILog2(w - 1) + 1;
+ l2h = ATILog2(h - 1) + 1;
+ l2p = ATILog2(pPix->devKind / bytepp);
+
+ if (pPict->repeat && w == 1 && h == 1)
+ l2p = 0;
+ else if (pPict->repeat && l2p != l2w)
+ ATI_FALLBACK(("Repeat not supported for pitch != width\n"));
+ l2w = l2p;
+
+ widths[unit] = 1 << l2w;
+ heights[unit] = 1 << l2h;
+ *txsize |= l2p << (R128_TEX_PITCH_SHIFT + shift);
+ *txsize |= ((l2w > l2h) ? l2w : l2h) << (R128_TEX_SIZE_SHIFT + shift);
+ *txsize |= l2h << (R128_TEX_HEIGHT_SHIFT + shift);
+
+ if (pPict->transform != 0) {
+ is_transform[unit] = TRUE;
+ transform[unit] = pPict->transform;
+ } else {
+ is_transform[unit] = FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool
+R128PrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
+{
+ KdScreenPriv(pDst->drawable.pScreen);
+ ATIScreenInfo(pScreenPriv);
+ CARD32 txsize = 0, prim_tex_cntl_c, sec_tex_cntl_c = 0, dstDatatype;
+ CARD32 dst_pitch_offset, color_factor, in_color_factor, alpha_comb;
+ CARD32 blend_cntl;
+ int i;
+ RING_LOCALS;
+
+ accel_atis = atis;
+
+ if (pDstPicture->format == PICT_a8)
+ dstDatatype = R128_DATATYPE_Y8;
+ else
+ R128GetDatatypePict(pDstPicture->format, &dstDatatype);
+
+ if (!R128TextureSetup(pSrcPicture, pSrc, 0, &txsize, &prim_tex_cntl_c))
+ return FALSE;
+ if (pMask != NULL && !R128TextureSetup(pMaskPicture, pMask, 1, &txsize,
+ &sec_tex_cntl_c))
+ return FALSE;
+ else if (pMask == NULL)
+ is_transform[1] = FALSE;
+
+ if (!ATIGetPixmapOffsetPitch(pDst, &dst_pitch_offset))
+ return FALSE;
+
+ blend_cntl = R128BlendOp[op].blendctl;
+ if (PICT_FORMAT_A(pDstPicture->format) == 0 &&
+ R128BlendOp[op].dst_alpha) {
+ if ((blend_cntl & R128_SBLEND_MASK) ==
+ R128_SBLEND_DST_ALPHA)
+ blend_cntl = (blend_cntl & ~R128_SBLEND_MASK) |
+ R128_SBLEND_ONE;
+ else if ((blend_cntl & R128_SBLEND_MASK) ==
+ R128_SBLEND_INV_DST_ALPHA)
+ blend_cntl = (blend_cntl & ~R128_SBLEND_MASK) |
+ R128_SBLEND_ZERO;
+ }
+
+ BEGIN_DMA(12);
+ OUT_REG(R128_REG_SCALE_3D_CNTL,
+ R128_SCALE_3D_TEXMAP_SHADE |
+ R128_SCALE_PIX_REPLICATE |
+ R128_TEX_CACHE_SPLIT |
+ R128_TEX_MAP_ALPHA_IN_TEXTURE |
+ R128_TEX_CACHE_LINE_SIZE_4QW);
+ OUT_REG(ATI_REG_DST_PITCH_OFFSET, dst_pitch_offset);
+ OUT_REG(ATI_REG_DP_GUI_MASTER_CNTL,
+ ATI_GMC_DST_PITCH_OFFSET_CNTL |
+ ATI_GMC_BRUSH_SOLID_COLOR |
+ (dstDatatype << 8) |
+ ATI_GMC_SRC_DATATYPE_COLOR |
+ (ATIBltRop[GXcopy] << 16) |
+ ATI_DP_SRC_SOURCE_MEMORY |
+ R128_GMC_3D_FCN_EN |
+ ATI_GMC_CLR_CMP_CNTL_DIS |
+ R128_GMC_AUX_CLIP_DIS |
+ ATI_GMC_WR_MSK_DIS);
+ OUT_REG(R128_REG_MISC_3D_STATE_CNTL,
+ R128_MISC_SCALE_3D_TEXMAP_SHADE |
+ R128_MISC_SCALE_PIX_REPLICATE |
+ R128_ALPHA_COMB_ADD_CLAMP |
+ blend_cntl);
+ OUT_REG(R128_REG_TEX_CNTL_C,
+ R128_TEXMAP_ENABLE |
+ ((pMask != NULL) ? R128_SEC_TEXMAP_ENABLE : 0) |
+ R128_ALPHA_ENABLE |
+ R128_TEX_CACHE_FLUSH);
+ OUT_REG(R128_REG_PC_GUI_CTLSTAT, R128_PC_FLUSH_GUI);
+ END_DMA();
+
+ /* IN operator: Without a mask, only the first texture unit is enabled.
+ * With a mask, we put the source in the first unit and have it pass
+ * through as input to the 2nd. The 2nd unit takes the incoming source
+ * pixel and modulates it with either the alpha or each of the channels
+ * in the mask, depending on componentAlpha.
+ */
+ BEGIN_DMA(15);
+ OUT_RING(DMA_PACKET0(R128_REG_PRIM_TEX_CNTL_C, 14));
+ OUT_RING_REG(R128_REG_PRIM_TEX_CNTL_C, prim_tex_cntl_c);
+
+ /* If this is the only stage and the dest is a8, route the alpha result
+ * to the color (red channel, in particular), too. Otherwise, be sure
+ * to zero out color channels of an a8 source.
+ */
+ if (pMaskPicture == NULL && pDstPicture->format == PICT_a8)
+ color_factor = R128_COLOR_FACTOR_ALPHA;
+ else if (pSrcPicture->format == PICT_a8)
+ color_factor = R128_COLOR_FACTOR_CONST_COLOR;
+ else
+ color_factor = R128_COLOR_FACTOR_TEX;
+
+ if (PICT_FORMAT_A(pSrcPicture->format) == 0)
+ alpha_comb = R128_COMB_ALPHA_COPY_INP;
+ else
+ alpha_comb = R128_COMB_ALPHA_DIS;
+
+ OUT_RING_REG(R128_REG_PRIM_TEXTURE_COMBINE_CNTL_C,
+ R128_COMB_COPY |
+ color_factor |
+ R128_INPUT_FACTOR_INT_COLOR |
+ alpha_comb |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_CONST_ALPHA);
+ OUT_RING_REG(R128_REG_TEX_SIZE_PITCH_C, txsize);
+ /* We could save some output by only writing the offset register that
+ * will actually be used. On the other hand, this is easy.
+ */
+ for (i = 0; i <= 10; i++) {
+ OUT_RING_REG(R128_REG_PRIM_TEX_0_OFFSET_C + 4 * i,
+ ((CARD8 *)pSrc->devPrivate.ptr -
+ pScreenPriv->screen->memory_base));
+ }
+ END_DMA();
+
+ if (pMask != NULL) {
+ BEGIN_DMA(14);
+ OUT_RING(DMA_PACKET0(R128_REG_SEC_TEX_CNTL_C, 13));
+ OUT_RING_REG(R128_REG_SEC_TEX_CNTL_C, sec_tex_cntl_c);
+
+ if (pDstPicture->format == PICT_a8) {
+ color_factor = R128_COLOR_FACTOR_ALPHA;
+ in_color_factor = R128_INPUT_FACTOR_PREV_ALPHA;
+ } else if (pMaskPicture->componentAlpha) {
+ color_factor = R128_COLOR_FACTOR_TEX;
+ in_color_factor = R128_INPUT_FACTOR_PREV_COLOR;
+ } else {
+ color_factor = R128_COLOR_FACTOR_ALPHA;
+ in_color_factor = R128_INPUT_FACTOR_PREV_COLOR;
+ }
+
+ OUT_RING_REG(R128_REG_SEC_TEXTURE_COMBINE_CNTL_C,
+ R128_COMB_MODULATE |
+ color_factor |
+ in_color_factor |
+ R128_COMB_ALPHA_MODULATE |
+ R128_ALPHA_FACTOR_TEX_ALPHA |
+ R128_INP_FACTOR_A_PREV_ALPHA);
+ for (i = 0; i <= 10; i++) {
+ OUT_RING_REG(R128_REG_SEC_TEX_0_OFFSET_C + 4 * i,
+ ((CARD8 *)pMask->devPrivate.ptr -
+ pScreenPriv->screen->memory_base));
+ }
+ END_DMA();
+ }
+
+ return TRUE;
+}
+#define VTX_RING_COUNT 8
+
+#define VTX_OUT(_dstX, _dstY, _srcX, _srcY, _maskX, _maskY) \
+do { \
+ OUT_RING_F((_dstX)); \
+ OUT_RING_F(((float)(_dstY)) + .125); \
+ OUT_RING_F(0.0); \
+ OUT_RING_F(1.0); \
+ OUT_RING_F((((float)(_srcX)) + 0.5) / (widths[0])); \
+ OUT_RING_F((((float)(_srcY)) + 0.5) / (heights[0])); \
+ OUT_RING_F((((float)(_maskX)) + 0.5) / (widths[1])); \
+ OUT_RING_F((((float)(_maskY)) + 0.5) / (heights[1])); \
+} while (0)
+
+void
+R128Composite(int srcX, int srcY, int maskX, int maskY, int dstX, int dstY,
+ int w, int h)
+{
+ ATIScreenInfo *atis = accel_atis;
+ int srcXend, srcYend, maskXend, maskYend;
+ PictVector v;
+ RING_LOCALS;
+
+ /*ErrorF("R128Composite (%d,%d) (%d,%d) (%d,%d) (%d,%d)\n",
+ srcX, srcY, maskX, maskY,dstX, dstY, w, h);*/
+
+ srcXend = srcX + w;
+ srcYend = srcY + h;
+ maskXend = maskX + w;
+ maskYend = maskY + h;
+ if (is_transform[0]) {
+ v.vector[0] = IntToxFixed(srcX);
+ v.vector[1] = IntToxFixed(srcY);
+ v.vector[2] = xFixed1;
+ PictureTransformPoint(transform[0], &v);
+ srcX = xFixedToInt(v.vector[0]);
+ srcY = xFixedToInt(v.vector[1]);
+ v.vector[0] = IntToxFixed(srcXend);
+ v.vector[1] = IntToxFixed(srcYend);
+ v.vector[2] = xFixed1;
+ PictureTransformPoint(transform[0], &v);
+ srcXend = xFixedToInt(v.vector[0]);
+ srcYend = xFixedToInt(v.vector[1]);
+ }
+ if (is_transform[1]) {
+ v.vector[0] = IntToxFixed(maskX);
+ v.vector[1] = IntToxFixed(maskY);
+ v.vector[2] = xFixed1;
+ PictureTransformPoint(transform[1], &v);
+ maskX = xFixedToInt(v.vector[0]);
+ maskY = xFixedToInt(v.vector[1]);
+ v.vector[0] = IntToxFixed(maskXend);
+ v.vector[1] = IntToxFixed(maskYend);
+ v.vector[2] = xFixed1;
+ PictureTransformPoint(transform[1], &v);
+ maskXend = xFixedToInt(v.vector[0]);
+ maskYend = xFixedToInt(v.vector[1]);
+ }
+
+ BEGIN_DMA(3 + 4 * VTX_RING_COUNT);
+ OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_3D_RNDR_GEN_PRIM,
+ 2 + 4 * VTX_RING_COUNT));
+ OUT_RING(R128_CCE_VC_FRMT_RHW |
+ R128_CCE_VC_FRMT_S_T |
+ R128_CCE_VC_FRMT_S2_T2);
+ OUT_RING(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN |
+ R128_CCE_VC_CNTL_PRIM_WALK_RING |
+ (4 << R128_CCE_VC_CNTL_NUM_SHIFT));
+
+ VTX_OUT(dstX, dstY, srcX, srcY, maskX, maskY);
+ VTX_OUT(dstX, dstY + h, srcX, srcYend, maskX, maskYend);
+ VTX_OUT(dstX + w, dstY + h, srcXend, srcYend, maskXend, maskYend);
+ VTX_OUT(dstX + w, dstY, srcXend, srcY, maskXend, maskY);
+
+ END_DMA();
+}
+
+void
+R128DoneComposite(void)
+{
+}
+
+Bool
+R128PrepareTrapezoids(PicturePtr pDstPicture, PixmapPtr pDst)
+{
+ KdScreenPriv(pDst->drawable.pScreen);
+ ATIScreenInfo(pScreenPriv);
+ CARD32 dst_pitch_offset;
+ RING_LOCALS;
+
+ accel_atis = atis;
+
+ if (!ATIGetPixmapOffsetPitch(pDst, &dst_pitch_offset))
+ return FALSE;
+
+ BEGIN_DMA(18);
+ OUT_REG(R128_REG_SCALE_3D_CNTL,
+ R128_SCALE_3D_TEXMAP_SHADE |
+ R128_SCALE_PIX_REPLICATE |
+ R128_TEX_CACHE_SPLIT |
+ R128_TEX_CACHE_LINE_SIZE_4QW);
+ OUT_REG(ATI_REG_DST_PITCH_OFFSET, dst_pitch_offset);
+ OUT_REG(ATI_REG_DP_GUI_MASTER_CNTL,
+ ATI_GMC_DST_PITCH_OFFSET_CNTL |
+ ATI_GMC_BRUSH_SOLID_COLOR |
+ (R128_DATATYPE_RGB8 << 8) |
+ ATI_GMC_SRC_DATATYPE_COLOR |
+ (ATIBltRop[GXcopy] << 16) |
+ ATI_DP_SRC_SOURCE_MEMORY |
+ R128_GMC_3D_FCN_EN |
+ ATI_GMC_CLR_CMP_CNTL_DIS |
+ ATI_GMC_WR_MSK_DIS);
+ OUT_REG(R128_REG_MISC_3D_STATE_CNTL,
+ R128_MISC_SCALE_3D_TEXMAP_SHADE |
+ R128_MISC_SCALE_PIX_REPLICATE |
+ R128_ALPHA_COMB_ADD_CLAMP |
+ R128BlendOp[PictOpAdd].blendctl);
+ OUT_REG(R128_REG_TEX_CNTL_C,
+ R128_ALPHA_ENABLE);
+ OUT_REG(R128_REG_PC_GUI_CTLSTAT, R128_PC_FLUSH_GUI);
+
+ OUT_RING(DMA_PACKET0(R128_REG_AUX_SC_CNTL, 5));
+ OUT_RING_REG(R128_REG_AUX_SC_CNTL, R128_AUX1_SC_ENB);
+ OUT_RING_REG(R128_REG_AUX1_SC_LEFT, 0);
+ OUT_RING_REG(R128_REG_AUX1_SC_RIGHT, pDst->drawable.width);
+ OUT_RING_REG(R128_REG_AUX1_SC_TOP, 0);
+ OUT_RING_REG(R128_REG_AUX1_SC_BOTTOM, pDst->drawable.height);
+ END_DMA();
+
+ return TRUE;
+}
+
+#define TRAP_VERT_RING_COUNT 4
+
+#define TRAP_VERT(_x, _y) \
+do { \
+ OUT_RING_F((_x) + sample_x); \
+ OUT_RING_F((_y) + 0.125 + sample_y); \
+ OUT_RING_F(0.0); \
+ OUT_RING(0x01010101); \
+} while (0)
+
+void
+R128Trapezoids(KaaTrapezoid *traps, int ntraps)
+{
+ ATIScreenInfo *atis = accel_atis;
+ RING_LOCALS;
+
+ while (ntraps > 0) {
+ int i, sample, count, vertcount;
+
+ count = 0xffff / 4 / sample_count;
+ if (count > ntraps)
+ count = ntraps;
+ vertcount = count * sample_count * 4;
+
+ BEGIN_DMA(3 + vertcount * TRAP_VERT_RING_COUNT);
+ OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_3D_RNDR_GEN_PRIM,
+ 2 + vertcount * TRAP_VERT_RING_COUNT));
+ OUT_RING(R128_CCE_VC_FRMT_DIFFUSE_ARGB);
+ OUT_RING(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN |
+ R128_CCE_VC_CNTL_PRIM_WALK_RING |
+ (vertcount << R128_CCE_VC_CNTL_NUM_SHIFT));
+
+ for (i = 0; i < count; i++) {
+ for (sample = 0; sample < sample_count; sample++) {
+ float sample_x = sample_offsets_x[sample];
+ float sample_y = sample_offsets_y[sample];
+ TRAP_VERT(traps[i].tl, traps[i].ty);
+ TRAP_VERT(traps[i].bl, traps[i].by);
+ TRAP_VERT(traps[i].br, traps[i].by);
+ TRAP_VERT(traps[i].tr, traps[i].ty);
+ }
+ }
+ END_DMA();
+
+ ntraps -= count;
+ traps += count;
+ }
+}
+
+void
+R128DoneTrapezoids(void)
+{
+}
diff --git a/xorg-server/hw/kdrive/ati/radeon_composite.c b/xorg-server/hw/kdrive/ati/radeon_composite.c
new file mode 100644
index 000000000..ddad343e3
--- /dev/null
+++ b/xorg-server/hw/kdrive/ati/radeon_composite.c
@@ -0,0 +1,875 @@
+/*
+ * Copyright © 2003 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "ati.h"
+#include "ati_reg.h"
+#include "ati_dma.h"
+#include "ati_draw.h"
+
+extern ATIScreenInfo *accel_atis;
+extern int sample_count;
+extern float sample_offsets_x[255];
+extern float sample_offsets_y[255];
+static Bool is_transform[2];
+static PictTransform *transform[2];
+
+struct blendinfo {
+ Bool dst_alpha;
+ Bool src_alpha;
+ CARD32 blend_cntl;
+};
+
+static struct blendinfo RadeonBlendOp[] = {
+ /* Clear */
+ {0, 0, RADEON_SBLEND_GL_ZERO | RADEON_DBLEND_GL_ZERO},
+ /* Src */
+ {0, 0, RADEON_SBLEND_GL_ONE | RADEON_DBLEND_GL_ZERO},
+ /* Dst */
+ {0, 0, RADEON_SBLEND_GL_ZERO | RADEON_DBLEND_GL_ONE},
+ /* Over */
+ {0, 1, RADEON_SBLEND_GL_ONE | RADEON_DBLEND_GL_INV_SRC_ALPHA},
+ /* OverReverse */
+ {1, 0, RADEON_SBLEND_GL_INV_DST_ALPHA | RADEON_DBLEND_GL_ONE},
+ /* In */
+ {1, 0, RADEON_SBLEND_GL_DST_ALPHA | RADEON_DBLEND_GL_ZERO},
+ /* InReverse */
+ {0, 1, RADEON_SBLEND_GL_ZERO | RADEON_DBLEND_GL_SRC_ALPHA},
+ /* Out */
+ {1, 0, RADEON_SBLEND_GL_INV_DST_ALPHA | RADEON_DBLEND_GL_ZERO},
+ /* OutReverse */
+ {0, 1, RADEON_SBLEND_GL_ZERO | RADEON_DBLEND_GL_INV_SRC_ALPHA},
+ /* Atop */
+ {1, 1, RADEON_SBLEND_GL_DST_ALPHA | RADEON_DBLEND_GL_INV_SRC_ALPHA},
+ /* AtopReverse */
+ {1, 1, RADEON_SBLEND_GL_INV_DST_ALPHA | RADEON_DBLEND_GL_SRC_ALPHA},
+ /* Xor */
+ {1, 1, RADEON_SBLEND_GL_INV_DST_ALPHA | RADEON_DBLEND_GL_INV_SRC_ALPHA},
+ /* Add */
+ {0, 0, RADEON_SBLEND_GL_ONE | RADEON_DBLEND_GL_ONE},
+};
+
+struct formatinfo {
+ int fmt;
+ Bool byte_swap;
+ CARD32 card_fmt;
+};
+
+/* Note on texture formats:
+ * TXFORMAT_Y8 expands to (Y,Y,Y,1). TXFORMAT_I8 expands to (I,I,I,I)
+ */
+static struct formatinfo R100TexFormats[] = {
+ {PICT_a8r8g8b8, 0, RADEON_TXFORMAT_ARGB8888 | RADEON_TXFORMAT_ALPHA_IN_MAP},
+ {PICT_x8r8g8b8, 0, RADEON_TXFORMAT_ARGB8888},
+ {PICT_a8b8g8r8, 1, RADEON_TXFORMAT_RGBA8888 | RADEON_TXFORMAT_ALPHA_IN_MAP},
+ {PICT_x8b8g8r8, 1, RADEON_TXFORMAT_RGBA8888},
+ {PICT_r5g6b5, 0, RADEON_TXFORMAT_RGB565},
+ {PICT_a1r5g5b5, 0, RADEON_TXFORMAT_ARGB1555 | RADEON_TXFORMAT_ALPHA_IN_MAP},
+ {PICT_x1r5g5b5, 0, RADEON_TXFORMAT_ARGB1555},
+ {PICT_a8, 0, RADEON_TXFORMAT_I8 | RADEON_TXFORMAT_ALPHA_IN_MAP},
+};
+
+static struct formatinfo R200TexFormats[] = {
+ {PICT_a8r8g8b8, 0, R200_TXFORMAT_ARGB8888 | R200_TXFORMAT_ALPHA_IN_MAP},
+ {PICT_x8r8g8b8, 0, R200_TXFORMAT_ARGB8888},
+ {PICT_a8r8g8b8, 1, R200_TXFORMAT_RGBA8888 | R200_TXFORMAT_ALPHA_IN_MAP},
+ {PICT_x8r8g8b8, 1, R200_TXFORMAT_RGBA8888},
+ {PICT_r5g6b5, 0, R200_TXFORMAT_RGB565},
+ {PICT_a1r5g5b5, 0, R200_TXFORMAT_ARGB1555 | R200_TXFORMAT_ALPHA_IN_MAP},
+ {PICT_x1r5g5b5, 0, R200_TXFORMAT_ARGB1555},
+ {PICT_a8, 0, R200_TXFORMAT_I8 | R200_TXFORMAT_ALPHA_IN_MAP},
+};
+
+/* Common Radeon setup code */
+
+static Bool
+RadeonGetDestFormat(PicturePtr pDstPicture, CARD32 *dst_format)
+{
+ switch (pDstPicture->format) {
+ case PICT_a8r8g8b8:
+ case PICT_x8r8g8b8:
+ *dst_format = RADEON_COLOR_FORMAT_ARGB8888;
+ break;
+ case PICT_r5g6b5:
+ *dst_format = RADEON_COLOR_FORMAT_RGB565;
+ break;
+ case PICT_a1r5g5b5:
+ case PICT_x1r5g5b5:
+ *dst_format = RADEON_COLOR_FORMAT_ARGB1555;
+ break;
+ case PICT_a8:
+ *dst_format = RADEON_COLOR_FORMAT_RGB8;
+ break;
+ default:
+ ATI_FALLBACK(("Unsupported dest format 0x%x\n",
+ pDstPicture->format));
+ }
+
+ return TRUE;
+}
+
+/* R100-specific code */
+
+static Bool
+R100CheckCompositeTexture(PicturePtr pPict, int unit)
+{
+ int w = pPict->pDrawable->width;
+ int h = pPict->pDrawable->height;
+ int i;
+
+ if ((w > 0x7ff) || (h > 0x7ff))
+ ATI_FALLBACK(("Picture w/h too large (%dx%d)\n", w, h));
+
+ for (i = 0; i < sizeof(R100TexFormats) / sizeof(R100TexFormats[0]); i++)
+ {
+ if (R100TexFormats[i].fmt == pPict->format)
+ break;
+ }
+ if (i == sizeof(R100TexFormats) / sizeof(R100TexFormats[0]))
+ ATI_FALLBACK(("Unsupported picture format 0x%x\n",
+ pPict->format));
+
+ if (pPict->repeat && ((w & (w - 1)) != 0 || (h & (h - 1)) != 0))
+ ATI_FALLBACK(("NPOT repeat unsupported (%dx%d)\n", w, h));
+
+ if (pPict->filter != PictFilterNearest &&
+ pPict->filter != PictFilterBilinear)
+ ATI_FALLBACK(("Unsupported filter 0x%x\n", pPict->filter));
+
+ return TRUE;
+}
+
+static Bool
+R100TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit)
+{
+ ATIScreenInfo *atis = accel_atis;
+ KdScreenPriv(pPix->drawable.pScreen);
+ CARD32 txfilter, txformat, txoffset, txpitch;
+ int w = pPict->pDrawable->width;
+ int h = pPict->pDrawable->height;
+ int i;
+ RING_LOCALS;
+
+ txpitch = pPix->devKind;
+ txoffset = ((CARD8 *)pPix->devPrivate.ptr -
+ pScreenPriv->screen->memory_base);
+
+ for (i = 0; i < sizeof(R100TexFormats) / sizeof(R100TexFormats[0]); i++)
+ {
+ if (R100TexFormats[i].fmt == pPict->format)
+ break;
+ }
+ txformat = R100TexFormats[i].card_fmt;
+ if (R100TexFormats[i].byte_swap)
+ txoffset |= RADEON_TXO_ENDIAN_BYTE_SWAP;
+
+ if (pPict->repeat) {
+ txformat |= ATILog2(w) << RADEON_TXFORMAT_WIDTH_SHIFT;
+ txformat |= ATILog2(h) << RADEON_TXFORMAT_HEIGHT_SHIFT;
+ } else
+ txformat |= RADEON_TXFORMAT_NON_POWER2;
+ txformat |= unit << 24; /* RADEON_TXFORMAT_ST_ROUTE_STQX */
+
+
+ if ((txoffset & 0x1f) != 0)
+ ATI_FALLBACK(("Bad texture offset 0x%x\n", txoffset));
+ if ((txpitch & 0x1f) != 0)
+ ATI_FALLBACK(("Bad texture pitch 0x%x\n", txpitch));
+
+ switch (pPict->filter) {
+ case PictFilterNearest:
+ txfilter = (RADEON_MAG_FILTER_NEAREST |
+ RADEON_MIN_FILTER_NEAREST);
+ break;
+ case PictFilterBilinear:
+ txfilter = (RADEON_MAG_FILTER_LINEAR |
+ RADEON_MIN_FILTER_LINEAR);
+ break;
+ default:
+ ATI_FALLBACK(("Bad filter 0x%x\n", pPict->filter));
+ }
+
+ BEGIN_DMA(7);
+ if (unit == 0) {
+ OUT_RING(DMA_PACKET0(RADEON_REG_PP_TXFILTER_0, 3));
+ OUT_RING_REG(RADEON_REG_PP_TXFILTER_0, txfilter);
+ OUT_RING_REG(RADEON_REG_PP_TXFORMAT_0, txformat);
+ OUT_RING_REG(RADEON_REG_PP_TXOFFSET_0, txoffset);
+ OUT_RING(DMA_PACKET0(RADEON_REG_PP_TEX_SIZE_0, 2));
+ OUT_RING_REG(RADEON_REG_PP_TEX_SIZE_0,
+ (pPix->drawable.width - 1) |
+ ((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
+ OUT_RING_REG(RADEON_REG_PP_TEX_PITCH_0, txpitch - 32);
+ } else {
+ OUT_RING(DMA_PACKET0(RADEON_REG_PP_TXFILTER_1, 3));
+ OUT_RING_REG(RADEON_REG_PP_TXFILTER_1, txfilter);
+ OUT_RING_REG(RADEON_REG_PP_TXFORMAT_1, txformat);
+ OUT_RING_REG(RADEON_REG_PP_TXOFFSET_1, txoffset);
+ OUT_RING(DMA_PACKET0(RADEON_REG_PP_TEX_SIZE_1, 2));
+ OUT_RING_REG(RADEON_REG_PP_TEX_SIZE_1,
+ (pPix->drawable.width - 1) |
+ ((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
+ OUT_RING_REG(RADEON_REG_PP_TEX_PITCH_1, txpitch - 32);
+ }
+ END_DMA();
+
+ if (pPict->transform != 0) {
+ is_transform[unit] = TRUE;
+ transform[unit] = pPict->transform;
+ } else {
+ is_transform[unit] = FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool
+R100CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture)
+{
+ CARD32 tmp1;
+
+ /* Check for unsupported compositing operations. */
+ if (op >= sizeof(RadeonBlendOp) / sizeof(RadeonBlendOp[0]))
+ ATI_FALLBACK(("Unsupported Composite op 0x%x\n", op));
+ if (pMaskPicture != NULL && pMaskPicture->componentAlpha &&
+ RadeonBlendOp[op].src_alpha)
+ ATI_FALLBACK(("Component alpha not supported with source "
+ "alpha blending.\n"));
+ if (pDstPicture->pDrawable->width >= (1 << 11) ||
+ pDstPicture->pDrawable->height >= (1 << 11))
+ ATI_FALLBACK(("Dest w/h too large (%d,%d).\n",
+ pDstPicture->pDrawable->width,
+ pDstPicture->pDrawable->height));
+
+ if (!R100CheckCompositeTexture(pSrcPicture, 0))
+ return FALSE;
+ if (pMaskPicture != NULL && !R100CheckCompositeTexture(pMaskPicture, 1))
+ return FALSE;
+
+ if (pDstPicture->componentAlpha)
+ return FALSE;
+
+ if (!RadeonGetDestFormat(pDstPicture, &tmp1))
+ return FALSE;
+
+ return TRUE;
+}
+
+Bool
+R100PrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
+{
+ KdScreenPriv(pDst->drawable.pScreen);
+ ATIScreenInfo(pScreenPriv);
+ CARD32 dst_format, dst_offset, dst_pitch;
+ CARD32 pp_cntl, blendcntl, cblend, ablend;
+ int pixel_shift;
+ RING_LOCALS;
+
+ accel_atis = atis;
+
+ RadeonGetDestFormat(pDstPicture, &dst_format);
+ pixel_shift = pDst->drawable.bitsPerPixel >> 4;
+
+ dst_offset = ((CARD8 *)pDst->devPrivate.ptr -
+ pScreenPriv->screen->memory_base);
+ dst_pitch = pDst->devKind;
+ if ((dst_offset & 0x0f) != 0)
+ ATI_FALLBACK(("Bad destination offset 0x%x\n", dst_offset));
+ if (((dst_pitch >> pixel_shift) & 0x7) != 0)
+ ATI_FALLBACK(("Bad destination pitch 0x%x\n", dst_pitch));
+
+ if (!R100TextureSetup(pSrcPicture, pSrc, 0))
+ return FALSE;
+ pp_cntl = RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE;
+
+ if (pMask != NULL) {
+ if (!R100TextureSetup(pMaskPicture, pMask, 1))
+ return FALSE;
+ pp_cntl |= RADEON_TEX_1_ENABLE;
+ } else {
+ is_transform[1] = FALSE;
+ }
+
+ ENTER_DRAW(pDst);
+
+ RadeonSwitchTo3D(atis);
+
+ BEGIN_DMA(12);
+
+ OUT_RING(DMA_PACKET0(RADEON_REG_PP_CNTL, 3));
+ OUT_RING_REG(RADEON_REG_PP_CNTL, pp_cntl);
+ OUT_RING_REG(RADEON_REG_RB3D_CNTL,
+ dst_format | RADEON_ALPHA_BLEND_ENABLE);
+ OUT_RING_REG(RADEON_REG_RB3D_COLOROFFSET, dst_offset);
+
+ OUT_REG(RADEON_REG_RB3D_COLORPITCH, dst_pitch >> pixel_shift);
+
+ /* IN operator: Multiply src by mask components or mask alpha.
+ * BLEND_CTL_ADD is A * B + C.
+ * If a picture is a8, we have to explicitly zero its color values.
+ * If the destination is a8, we have to route the alpha to red, I think.
+ */
+ cblend = RADEON_BLEND_CTL_ADD | RADEON_CLAMP_TX |
+ RADEON_COLOR_ARG_C_ZERO;
+ ablend = RADEON_BLEND_CTL_ADD | RADEON_CLAMP_TX |
+ RADEON_ALPHA_ARG_C_ZERO;
+
+ if (pDstPicture->format == PICT_a8)
+ cblend |= RADEON_COLOR_ARG_A_T0_ALPHA;
+ else if (pSrcPicture->format == PICT_a8)
+ cblend |= RADEON_COLOR_ARG_A_ZERO;
+ else
+ cblend |= RADEON_COLOR_ARG_A_T0_COLOR;
+ ablend |= RADEON_ALPHA_ARG_A_T0_ALPHA;
+
+ if (pMask) {
+ if (pMaskPicture->componentAlpha &&
+ pDstPicture->format != PICT_a8)
+ cblend |= RADEON_COLOR_ARG_B_T1_COLOR;
+ else
+ cblend |= RADEON_COLOR_ARG_B_T1_ALPHA;
+ ablend |= RADEON_ALPHA_ARG_B_T1_ALPHA;
+ } else {
+ cblend |= RADEON_COLOR_ARG_B_ZERO | RADEON_COMP_ARG_B;
+ ablend |= RADEON_ALPHA_ARG_B_ZERO | RADEON_COMP_ARG_B;
+ }
+
+ OUT_REG(RADEON_REG_PP_TXCBLEND_0, cblend);
+ OUT_REG(RADEON_REG_PP_TXABLEND_0, ablend);
+
+ /* Op operator. */
+ blendcntl = RadeonBlendOp[op].blend_cntl;
+ if (PICT_FORMAT_A(pDstPicture->format) == 0 &&
+ RadeonBlendOp[op].dst_alpha) {
+ if ((blendcntl & RADEON_SBLEND_MASK) ==
+ RADEON_SBLEND_GL_DST_ALPHA)
+ blendcntl = (blendcntl & ~RADEON_SBLEND_MASK) |
+ RADEON_SBLEND_GL_ONE;
+ else if ((blendcntl & RADEON_SBLEND_MASK) ==
+ RADEON_SBLEND_GL_INV_DST_ALPHA)
+ blendcntl = (blendcntl & ~RADEON_SBLEND_MASK) |
+ RADEON_SBLEND_GL_ZERO;
+ }
+ OUT_REG(RADEON_REG_RB3D_BLENDCNTL, blendcntl);
+ END_DMA();
+
+ LEAVE_DRAW(pDst);
+
+ return TRUE;
+}
+
+static Bool
+R200CheckCompositeTexture(PicturePtr pPict, int unit)
+{
+ int w = pPict->pDrawable->width;
+ int h = pPict->pDrawable->height;
+ int i;
+
+ if ((w > 0x7ff) || (h > 0x7ff))
+ ATI_FALLBACK(("Picture w/h too large (%dx%d)\n", w, h));
+
+ for (i = 0; i < sizeof(R200TexFormats) / sizeof(R200TexFormats[0]); i++)
+ {
+ if (R200TexFormats[i].fmt == pPict->format)
+ break;
+ }
+ if (i == sizeof(R200TexFormats) / sizeof(R200TexFormats[0]))
+ ATI_FALLBACK(("Unsupported picture format 0x%x\n",
+ pPict->format));
+
+ if (pPict->repeat && ((w & (w - 1)) != 0 || (h & (h - 1)) != 0))
+ ATI_FALLBACK(("NPOT repeat unsupported (%dx%d)\n", w, h));
+
+ if (pPict->filter != PictFilterNearest &&
+ pPict->filter != PictFilterBilinear)
+ ATI_FALLBACK(("Unsupported filter 0x%x\n", pPict->filter));
+
+ return TRUE;
+}
+
+static Bool
+R200TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit)
+{
+ ATIScreenInfo *atis = accel_atis;
+ KdScreenPriv(pPix->drawable.pScreen);
+ CARD32 txfilter, txformat, txoffset, txpitch;
+ int w = pPict->pDrawable->width;
+ int h = pPict->pDrawable->height;
+ int i;
+ RING_LOCALS;
+
+ txpitch = pPix->devKind;
+ txoffset = ((CARD8 *)pPix->devPrivate.ptr -
+ pScreenPriv->screen->memory_base);
+
+ for (i = 0; i < sizeof(R200TexFormats) / sizeof(R200TexFormats[0]); i++)
+ {
+ if (R200TexFormats[i].fmt == pPict->format)
+ break;
+ }
+ txformat = R200TexFormats[i].card_fmt;
+ if (R200TexFormats[i].byte_swap)
+ txoffset |= R200_TXO_ENDIAN_BYTE_SWAP;
+
+ if (pPict->repeat) {
+ txformat |= ATILog2(w) << R200_TXFORMAT_WIDTH_SHIFT;
+ txformat |= ATILog2(h) << R200_TXFORMAT_HEIGHT_SHIFT;
+ } else
+ txformat |= R200_TXFORMAT_NON_POWER2;
+ txformat |= unit << R200_TXFORMAT_ST_ROUTE_SHIFT;
+
+ if ((txoffset & 0x1f) != 0)
+ ATI_FALLBACK(("Bad texture offset 0x%x\n", txoffset));
+ if ((txpitch & 0x1f) != 0)
+ ATI_FALLBACK(("Bad texture pitch 0x%x\n", txpitch));
+
+ switch (pPict->filter) {
+ case PictFilterNearest:
+ txfilter = (R200_MAG_FILTER_NEAREST |
+ R200_MIN_FILTER_NEAREST);
+ break;
+ case PictFilterBilinear:
+ txfilter = (R200_MAG_FILTER_LINEAR |
+ R200_MIN_FILTER_LINEAR);
+ break;
+ default:
+ ATI_FALLBACK(("Bad filter 0x%x\n", pPict->filter));
+ }
+
+ if (unit == 0) {
+ BEGIN_DMA(6);
+ OUT_RING(DMA_PACKET0(R200_REG_PP_TXFILTER_0 + 0x20 * unit, 5));
+ OUT_RING_REG(R200_REG_PP_TXFILTER_0, txfilter);
+ OUT_RING_REG(R200_REG_PP_TXFORMAT_0, txformat);
+ OUT_RING_REG(R200_REG_PP_TXFORMAT_X_0, 0);
+ OUT_RING_REG(R200_REG_PP_TXSIZE_0,
+ (pPix->drawable.width - 1) |
+ ((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
+ OUT_RING_REG(R200_REG_PP_TXPITCH_0, txpitch - 32);
+ END_DMA();
+ } else {
+ BEGIN_DMA(6);
+ OUT_RING(DMA_PACKET0(R200_REG_PP_TXFILTER_1, 5));
+ OUT_RING_REG(R200_REG_PP_TXFILTER_1, txfilter);
+ OUT_RING_REG(R200_REG_PP_TXFORMAT_1, txformat);
+ OUT_RING_REG(R200_REG_PP_TXFORMAT_X_1, 0);
+ OUT_RING_REG(R200_REG_PP_TXSIZE_1,
+ (pPix->drawable.width - 1) |
+ ((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
+ OUT_RING_REG(R200_REG_PP_TXPITCH_1, txpitch - 32);
+ END_DMA();
+ }
+
+ BEGIN_DMA(2);
+ OUT_REG(R200_PP_TXOFFSET_0 + 0x18 * unit, txoffset);
+ END_DMA();
+
+ if (pPict->transform != 0) {
+ is_transform[unit] = TRUE;
+ transform[unit] = pPict->transform;
+ } else {
+ is_transform[unit] = FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool
+R200CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture)
+{
+ CARD32 tmp1;
+
+ /* Check for unsupported compositing operations. */
+ if (op >= sizeof(RadeonBlendOp) / sizeof(RadeonBlendOp[0]))
+ ATI_FALLBACK(("Unsupported Composite op 0x%x\n", op));
+ if (pMaskPicture != NULL && pMaskPicture->componentAlpha &&
+ RadeonBlendOp[op].src_alpha)
+ ATI_FALLBACK(("Component alpha not supported with source "
+ "alpha blending.\n"));
+
+ if (!R200CheckCompositeTexture(pSrcPicture, 0))
+ return FALSE;
+ if (pMaskPicture != NULL && !R200CheckCompositeTexture(pMaskPicture, 1))
+ return FALSE;
+
+ if (!RadeonGetDestFormat(pDstPicture, &tmp1))
+ return FALSE;
+
+ return TRUE;
+}
+
+Bool
+R200PrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
+{
+ KdScreenPriv(pDst->drawable.pScreen);
+ ATIScreenInfo(pScreenPriv);
+ CARD32 dst_format, dst_offset, dst_pitch;
+ CARD32 pp_cntl, blendcntl, cblend, ablend;
+ int pixel_shift;
+ RING_LOCALS;
+
+ RadeonGetDestFormat(pDstPicture, &dst_format);
+ pixel_shift = pDst->drawable.bitsPerPixel >> 4;
+
+ accel_atis = atis;
+
+ dst_offset = ((CARD8 *)pDst->devPrivate.ptr -
+ pScreenPriv->screen->memory_base);
+ dst_pitch = pDst->devKind;
+ if ((dst_offset & 0x0f) != 0)
+ ATI_FALLBACK(("Bad destination offset 0x%x\n", dst_offset));
+ if (((dst_pitch >> pixel_shift) & 0x7) != 0)
+ ATI_FALLBACK(("Bad destination pitch 0x%x\n", dst_pitch));
+
+ if (!R200TextureSetup(pSrcPicture, pSrc, 0))
+ return FALSE;
+ pp_cntl = RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE;
+
+ if (pMask != NULL) {
+ if (!R200TextureSetup(pMaskPicture, pMask, 1))
+ return FALSE;
+ pp_cntl |= RADEON_TEX_1_ENABLE;
+ } else {
+ is_transform[1] = FALSE;
+ }
+
+ RadeonSwitchTo3D(atis);
+
+ BEGIN_DMA(17);
+
+ OUT_RING(DMA_PACKET0(RADEON_REG_PP_CNTL, 3));
+ OUT_RING_REG(RADEON_REG_PP_CNTL, pp_cntl);
+ OUT_RING_REG(RADEON_REG_RB3D_CNTL, dst_format | RADEON_ALPHA_BLEND_ENABLE);
+ OUT_RING_REG(RADEON_REG_RB3D_COLOROFFSET, dst_offset);
+
+ OUT_REG(R200_REG_SE_VTX_FMT_0, R200_VTX_XY);
+ OUT_REG(R200_REG_SE_VTX_FMT_1,
+ (2 << R200_VTX_TEX0_COMP_CNT_SHIFT) |
+ (2 << R200_VTX_TEX1_COMP_CNT_SHIFT));
+
+ OUT_REG(RADEON_REG_RB3D_COLORPITCH, dst_pitch >> pixel_shift);
+
+ /* IN operator: Multiply src by mask components or mask alpha.
+ * BLEND_CTL_ADD is A * B + C.
+ * If a picture is a8, we have to explicitly zero its color values.
+ * If the destination is a8, we have to route the alpha to red, I think.
+ */
+ cblend = R200_TXC_OP_MADD | R200_TXC_ARG_C_ZERO;
+ ablend = R200_TXA_OP_MADD | R200_TXA_ARG_C_ZERO;
+
+ if (pDstPicture->format == PICT_a8)
+ cblend |= R200_TXC_ARG_A_R0_ALPHA;
+ else if (pSrcPicture->format == PICT_a8)
+ cblend |= R200_TXC_ARG_A_ZERO;
+ else
+ cblend |= R200_TXC_ARG_A_R0_COLOR;
+ ablend |= R200_TXA_ARG_A_R0_ALPHA;
+
+ if (pMask) {
+ if (pMaskPicture->componentAlpha &&
+ pDstPicture->format != PICT_a8)
+ cblend |= R200_TXC_ARG_B_R1_COLOR;
+ else
+ cblend |= R200_TXC_ARG_B_R1_ALPHA;
+ ablend |= R200_TXA_ARG_B_R1_ALPHA;
+ } else {
+ cblend |= R200_TXC_ARG_B_ZERO | R200_TXC_COMP_ARG_B;
+ ablend |= R200_TXA_ARG_B_ZERO | R200_TXA_COMP_ARG_B;
+ }
+
+ OUT_RING(DMA_PACKET0(R200_REG_PP_TXCBLEND_0, 4));
+ OUT_RING_REG(R200_REG_PP_TXCBLEND_0, cblend);
+ OUT_RING_REG(R200_REG_PP_TXCBLEND2_0,
+ R200_TXC_CLAMP_0_1 | R200_TXC_OUTPUT_REG_R0);
+ OUT_RING_REG(R200_REG_PP_TXABLEND_0, ablend);
+ OUT_RING_REG(R200_REG_PP_TXABLEND2_0,
+ R200_TXA_CLAMP_0_1 | R200_TXA_OUTPUT_REG_R0);
+
+ /* Op operator. */
+ blendcntl = RadeonBlendOp[op].blend_cntl;
+ if (PICT_FORMAT_A(pDstPicture->format) == 0 &&
+ RadeonBlendOp[op].dst_alpha) {
+ if ((blendcntl & RADEON_SBLEND_MASK) ==
+ RADEON_SBLEND_GL_DST_ALPHA)
+ blendcntl = (blendcntl & ~RADEON_SBLEND_MASK) |
+ RADEON_SBLEND_GL_ONE;
+ else if ((blendcntl & RADEON_SBLEND_MASK) ==
+ RADEON_SBLEND_GL_INV_DST_ALPHA)
+ blendcntl = (blendcntl & ~RADEON_SBLEND_MASK) |
+ RADEON_SBLEND_GL_ZERO;
+ }
+ OUT_REG(RADEON_REG_RB3D_BLENDCNTL, blendcntl);
+ END_DMA();
+
+ return TRUE;
+}
+
+union intfloat {
+ float f;
+ CARD32 i;
+};
+
+struct blend_vertex {
+ union intfloat x, y;
+ union intfloat s0, t0;
+ union intfloat s1, t1;
+};
+
+#define VTX_DWORD_COUNT 6
+
+#define VTX_OUT(_dstX, _dstY, _srcX, _srcY, _maskX, _maskY) \
+do { \
+ OUT_RING_F(_dstX); \
+ OUT_RING_F(_dstY); \
+ OUT_RING_F(_srcX); \
+ OUT_RING_F(_srcY); \
+ OUT_RING_F(_maskX); \
+ OUT_RING_F(_maskY); \
+} while (0)
+
+void
+RadeonComposite(int srcX, int srcY, int maskX, int maskY, int dstX, int dstY,
+ int w, int h)
+{
+ ATIScreenInfo *atis = accel_atis;
+ ATICardInfo *atic = atis->atic;
+ int srcXend, srcYend, maskXend, maskYend;
+ RING_LOCALS;
+ PictVector v;
+
+ ENTER_DRAW(0);
+
+ /*ErrorF("RadeonComposite (%d,%d) (%d,%d) (%d,%d) (%d,%d)\n",
+ srcX, srcY, maskX, maskY,dstX, dstY, w, h);*/
+
+ srcXend = srcX + w;
+ srcYend = srcY + h;
+ maskXend = maskX + w;
+ maskYend = maskY + h;
+ if (is_transform[0]) {
+ v.vector[0] = IntToxFixed(srcX);
+ v.vector[1] = IntToxFixed(srcY);
+ v.vector[2] = xFixed1;
+ PictureTransformPoint(transform[0], &v);
+ srcX = xFixedToInt(v.vector[0]);
+ srcY = xFixedToInt(v.vector[1]);
+ v.vector[0] = IntToxFixed(srcXend);
+ v.vector[1] = IntToxFixed(srcYend);
+ v.vector[2] = xFixed1;
+ PictureTransformPoint(transform[0], &v);
+ srcXend = xFixedToInt(v.vector[0]);
+ srcYend = xFixedToInt(v.vector[1]);
+ }
+ if (is_transform[1]) {
+ v.vector[0] = IntToxFixed(maskX);
+ v.vector[1] = IntToxFixed(maskY);
+ v.vector[2] = xFixed1;
+ PictureTransformPoint(transform[1], &v);
+ maskX = xFixedToInt(v.vector[0]);
+ maskY = xFixedToInt(v.vector[1]);
+ v.vector[0] = IntToxFixed(maskXend);
+ v.vector[1] = IntToxFixed(maskYend);
+ v.vector[2] = xFixed1;
+ PictureTransformPoint(transform[1], &v);
+ maskXend = xFixedToInt(v.vector[0]);
+ maskYend = xFixedToInt(v.vector[1]);
+ }
+
+ if (atic->is_r100) {
+ BEGIN_DMA(4 * VTX_DWORD_COUNT + 3);
+ OUT_RING(DMA_PACKET3(RADEON_CP_PACKET3_3D_DRAW_IMMD,
+ 4 * VTX_DWORD_COUNT + 2));
+ OUT_RING(RADEON_CP_VC_FRMT_XY |
+ RADEON_CP_VC_FRMT_ST0 |
+ RADEON_CP_VC_FRMT_ST1);
+ OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN |
+ RADEON_CP_VC_CNTL_PRIM_WALK_RING |
+ RADEON_CP_VC_CNTL_MAOS_ENABLE |
+ RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
+ (4 << RADEON_CP_VC_CNTL_NUM_SHIFT));
+ } else {
+ BEGIN_DMA(4 * VTX_DWORD_COUNT + 2);
+ OUT_RING(DMA_PACKET3(R200_CP_PACKET3_3D_DRAW_IMMD_2,
+ 4 * VTX_DWORD_COUNT + 1));
+ OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN |
+ RADEON_CP_VC_CNTL_PRIM_WALK_RING |
+ (4 << RADEON_CP_VC_CNTL_NUM_SHIFT));
+ }
+
+ VTX_OUT(dstX, dstY, srcX, srcY, maskX, maskY);
+ VTX_OUT(dstX, dstY + h, srcX, srcYend, maskX, maskYend);
+ VTX_OUT(dstX + w, dstY + h, srcXend, srcYend, maskXend, maskYend);
+ VTX_OUT(dstX + w, dstY, srcXend, srcY, maskXend, maskY);
+
+ LEAVE_DRAW(0);
+
+ END_DMA();
+}
+
+void
+RadeonDoneComposite(void)
+{
+ ENTER_DRAW(0);
+ LEAVE_DRAW(0);
+}
+
+Bool
+RadeonPrepareTrapezoids(PicturePtr pDstPicture, PixmapPtr pDst)
+{
+ KdScreenPriv(pDst->drawable.pScreen);
+ ATIScreenInfo(pScreenPriv);
+ ATICardInfo(pScreenPriv);
+ CARD32 dst_offset, dst_pitch;
+ int pixel_shift;
+ RING_LOCALS;
+
+ pixel_shift = pDst->drawable.bitsPerPixel >> 4;
+
+ accel_atis = atis;
+
+ dst_offset = ((CARD8 *)pDst->devPrivate.ptr -
+ pScreenPriv->screen->memory_base);
+ dst_pitch = pDst->devKind;
+ if ((dst_offset & 0x0f) != 0)
+ ATI_FALLBACK(("Bad destination offset 0x%x\n", dst_offset));
+ if (((dst_pitch >> pixel_shift) & 0x7) != 0)
+ ATI_FALLBACK(("Bad destination pitch 0x%x\n", dst_pitch));
+
+ RadeonSwitchTo3D(atis);
+
+ BEGIN_DMA(8);
+
+ OUT_RING(DMA_PACKET0(RADEON_REG_PP_CNTL, 5));
+ OUT_RING_REG(RADEON_REG_PP_CNTL, RADEON_TEX_BLEND_0_ENABLE);
+ OUT_RING_REG(RADEON_REG_RB3D_CNTL,
+ RADEON_COLOR_FORMAT_RGB8 | RADEON_ALPHA_BLEND_ENABLE);
+ OUT_RING_REG(RADEON_REG_RB3D_COLOROFFSET, dst_offset);
+ OUT_RING_REG(RADEON_REG_RE_WIDTH_HEIGHT,
+ ((pDst->drawable.height - 1) << 16) |
+ (pDst->drawable.width - 1));
+ OUT_RING_REG(RADEON_REG_RB3D_COLORPITCH, dst_pitch >> pixel_shift);
+ OUT_REG(RADEON_REG_RB3D_BLENDCNTL, RadeonBlendOp[PictOpAdd].blend_cntl);
+ END_DMA();
+
+ if (atic->is_r100) {
+ BEGIN_DMA(4);
+ OUT_RING(DMA_PACKET0(RADEON_REG_PP_TXCBLEND_0, 3));
+ OUT_RING_REG(RADEON_REG_PP_TXCBLEND_0,
+ RADEON_BLEND_CTL_ADD | RADEON_CLAMP_TX |
+ RADEON_COLOR_ARG_C_TFACTOR_ALPHA);
+ OUT_RING_REG(RADEON_REG_PP_TXABLEND_0,
+ RADEON_BLEND_CTL_ADD | RADEON_CLAMP_TX |
+ RADEON_ALPHA_ARG_C_TFACTOR_ALPHA);
+ OUT_RING_REG(RADEON_REG_PP_TFACTOR_0, 0x01000000);
+ END_DMA();
+ } else if (atic->is_r200) {
+ BEGIN_DMA(14);
+ OUT_REG(R200_REG_SE_VTX_FMT_0, R200_VTX_XY);
+ OUT_REG(R200_REG_SE_VTX_FMT_1, 0);
+ OUT_REG(R200_REG_PP_TXCBLEND_0,
+ R200_TXC_ARG_C_TFACTOR_COLOR);
+ OUT_REG(R200_REG_PP_TXABLEND_0,
+ R200_TXA_ARG_C_TFACTOR_ALPHA);
+ OUT_REG(R200_REG_PP_TXCBLEND2_0, R200_TXC_OUTPUT_REG_R0);
+ OUT_REG(R200_REG_PP_TXABLEND2_0, R200_TXA_OUTPUT_REG_R0);
+ OUT_REG(RADEON_REG_PP_TFACTOR_0, 0x01000000);
+ END_DMA();
+ }
+
+ return TRUE;
+}
+
+#define TRAP_VERT_RING_COUNT 2
+
+#define TRAP_VERT(_x, _y) \
+do { \
+ OUT_RING_F((_x) + sample_x); \
+ OUT_RING_F((_y) + sample_y); \
+} while (0)
+
+void
+RadeonTrapezoids(KaaTrapezoid *traps, int ntraps)
+{
+ ATIScreenInfo *atis = accel_atis;
+ ATICardInfo *atic = atis->atic;
+ RING_LOCALS;
+
+ while (ntraps > 0) {
+ int i, sample, count, vertcount;
+
+ count = 0xffff / 4 / sample_count;
+ if (count > ntraps)
+ count = ntraps;
+ vertcount = count * sample_count * 4;
+
+ if (atic->is_r100) {
+ BEGIN_DMA(3 + vertcount * TRAP_VERT_RING_COUNT);
+ OUT_RING(DMA_PACKET3(RADEON_CP_PACKET3_3D_DRAW_IMMD,
+ 2 + vertcount * TRAP_VERT_RING_COUNT));
+ OUT_RING(RADEON_CP_VC_FRMT_XY);
+ OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN |
+ RADEON_CP_VC_CNTL_PRIM_WALK_RING |
+ RADEON_CP_VC_CNTL_MAOS_ENABLE |
+ RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
+ (vertcount << RADEON_CP_VC_CNTL_NUM_SHIFT));
+ } else {
+ BEGIN_DMA(2 + vertcount * TRAP_VERT_RING_COUNT);
+ OUT_RING(DMA_PACKET3(R200_CP_PACKET3_3D_DRAW_IMMD_2,
+ 1 + vertcount * TRAP_VERT_RING_COUNT));
+ OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN |
+ RADEON_CP_VC_CNTL_PRIM_WALK_RING |
+ (vertcount << RADEON_CP_VC_CNTL_NUM_SHIFT));
+ }
+
+ for (i = 0; i < count; i++) {
+ for (sample = 0; sample < sample_count; sample++) {
+ float sample_x = sample_offsets_x[sample];
+ float sample_y = sample_offsets_y[sample];
+ TRAP_VERT(traps[i].tl, traps[i].ty);
+ TRAP_VERT(traps[i].bl, traps[i].by);
+ TRAP_VERT(traps[i].br, traps[i].by);
+ TRAP_VERT(traps[i].tr, traps[i].ty);
+ }
+ }
+ END_DMA();
+
+ ntraps -= count;
+ traps += count;
+ }
+}
+
+void
+RadeonDoneTrapezoids(void)
+{
+ ATIScreenInfo *atis = accel_atis;
+ RING_LOCALS;
+
+ BEGIN_DMA(2);
+ OUT_REG(RADEON_REG_RE_WIDTH_HEIGHT, 0xffffffff);
+ END_DMA();
+}
diff --git a/xorg-server/hw/kdrive/chips/Makefile.am b/xorg-server/hw/kdrive/chips/Makefile.am
new file mode 100644
index 000000000..46e176051
--- /dev/null
+++ b/xorg-server/hw/kdrive/chips/Makefile.am
@@ -0,0 +1,36 @@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_CFLAGS@
+
+bin_PROGRAMS = Xchips
+
+noinst_LIBRARIES = libchips.a
+
+libchips_a_SOURCES = \
+ chipsdraw.c \
+ chips.c \
+ chips.h
+
+Xchips_SOURCES = \
+ chipsstub.c
+
+CHIPS_LIBS = \
+ libchips.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a \
+ @KDRIVE_LIBS@
+
+if GLX
+Xchips_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
+Xchips_LDADD = \
+ $(CHIPS_LIBS) \
+ @KDRIVE_LIBS@
+
+Xchips_DEPENDENCIES = \
+ libchips.a \
+ @KDRIVE_LOCAL_LIBS@
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/chips/Makefile.in b/xorg-server/hw/kdrive/chips/Makefile.in
new file mode 100644
index 000000000..5e149cb4a
--- /dev/null
+++ b/xorg-server/hw/kdrive/chips/Makefile.in
@@ -0,0 +1,717 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xchips$(EXEEXT)
+subdir = hw/kdrive/chips
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libchips_a_AR = $(AR) $(ARFLAGS)
+libchips_a_LIBADD =
+am_libchips_a_OBJECTS = chipsdraw.$(OBJEXT) chips.$(OBJEXT)
+libchips_a_OBJECTS = $(am_libchips_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xchips_OBJECTS = chipsstub.$(OBJEXT)
+Xchips_OBJECTS = $(am_Xchips_OBJECTS)
+am__DEPENDENCIES_1 = libchips.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a
+Xchips_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xchips_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libchips_a_SOURCES) $(Xchips_SOURCES)
+DIST_SOURCES = $(libchips_a_SOURCES) $(Xchips_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libchips.a
+libchips_a_SOURCES = \
+ chipsdraw.c \
+ chips.c \
+ chips.h
+
+Xchips_SOURCES = \
+ chipsstub.c
+
+CHIPS_LIBS = \
+ libchips.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a \
+ @KDRIVE_LIBS@
+
+@GLX_TRUE@Xchips_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xchips_LDADD = \
+ $(CHIPS_LIBS) \
+ @KDRIVE_LIBS@
+
+Xchips_DEPENDENCIES = \
+ libchips.a \
+ @KDRIVE_LOCAL_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/chips/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/chips/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libchips.a: $(libchips_a_OBJECTS) $(libchips_a_DEPENDENCIES)
+ -rm -f libchips.a
+ $(libchips_a_AR) libchips.a $(libchips_a_OBJECTS) $(libchips_a_LIBADD)
+ $(RANLIB) libchips.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xchips$(EXEEXT): $(Xchips_OBJECTS) $(Xchips_DEPENDENCIES)
+ @rm -f Xchips$(EXEEXT)
+ $(Xchips_LINK) $(Xchips_OBJECTS) $(Xchips_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chips.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chipsdraw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chipsstub.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/chips/chips.c b/xorg-server/hw/kdrive/chips/chips.c
new file mode 100644
index 000000000..b419863eb
--- /dev/null
+++ b/xorg-server/hw/kdrive/chips/chips.c
@@ -0,0 +1,334 @@
+/*
+ * Copyright © 2001 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "chips.h"
+#include "kaa.h"
+#include <sys/io.h>
+
+#undef CHIPS_DEBUG
+
+static Bool
+chipsCardInit (KdCardInfo *card)
+{
+ ChipsCardInfo *chipsc;
+
+ chipsc = (ChipsCardInfo *) xalloc (sizeof (ChipsCardInfo));
+ if (!chipsc)
+ return FALSE;
+
+ iopl (3);
+
+ if (!vesaInitialize (card, &chipsc->vesa))
+ {
+ xfree (chipsc);
+ return FALSE;
+ }
+
+#ifdef USE_PCI
+ chipsc->window = (CARD32 *) (chipsc->cop_base + 0x10000);
+#else
+ chipsc->window = 0;
+#endif
+ card->driver = chipsc;
+
+ return TRUE;
+}
+
+static Bool
+chipsScreenInit (KdScreenInfo *screen)
+{
+ ChipsScreenInfo *chipss;
+ int screen_size, memory;
+
+ chipss = (ChipsScreenInfo *) xalloc (sizeof (ChipsScreenInfo));
+ if (!chipss)
+ return FALSE;
+ memset (chipss, '\0', sizeof (ChipsScreenInfo));
+ if (!vesaScreenInitialize (screen, &chipss->vesa))
+ {
+ xfree (chipss);
+ return FALSE;
+ }
+
+ if (chipss->vesa.mapping != VESA_LINEAR)
+ screen->dumb = TRUE;
+ if (!screen->dumb)
+ {
+ chipss->mmio_base = (CARD8 *) KdMapDevice (CHIPS_MMIO_BASE(chipss),
+ CHIPS_MMIO_SIZE(chipss));
+
+ if (chipss->mmio_base)
+ {
+ KdSetMappedMode (CHIPS_MMIO_BASE(chipss),
+ CHIPS_MMIO_SIZE(chipss),
+ KD_MAPPED_MODE_REGISTERS);
+ }
+ else
+ screen->dumb = TRUE;
+ }
+ else
+ chipss->mmio_base = 0;
+
+ chipss->screen = chipss->vesa.fb;
+ memory = chipss->vesa.fb_size;
+
+ screen_size = screen->fb[0].byteStride * screen->height;
+
+ if (chipss->screen && memory >= screen_size + 2048)
+ {
+ memory -= 2048;
+ chipss->cursor_base = chipss->screen + memory - 2048;
+ }
+ else
+ chipss->cursor_base = 0;
+ memory -= screen_size;
+ if (memory > screen->fb[0].byteStride)
+ {
+ chipss->off_screen = chipss->screen + screen_size;
+ chipss->off_screen_size = memory;
+ }
+ else
+ {
+ chipss->off_screen = 0;
+ chipss->off_screen_size = 0;
+ }
+ screen->driver = chipss;
+ return TRUE;
+}
+
+static Bool
+chipsInitScreen (ScreenPtr pScreen)
+{
+ return vesaInitScreen (pScreen);
+}
+
+#ifdef RANDR
+static Bool
+chipsRandRSetConfig (ScreenPtr pScreen,
+ Rotation rotation,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ kaaWaitSync (pScreen);
+
+ if (!vesaRandRSetConfig (pScreen, rotation, rate, pSize))
+ return FALSE;
+
+ return TRUE;
+}
+
+static void
+chipsRandRInit (ScreenPtr pScreen)
+{
+ rrScrPriv(pScreen);
+
+ pScrPriv->rrSetConfig = chipsRandRSetConfig;
+}
+#endif
+
+static Bool
+chipsFinishInitScreen (ScreenPtr pScreen)
+{
+ Bool ret;
+ ret = vesaFinishInitScreen (pScreen);
+#ifdef RANDR
+ chipsRandRInit (pScreen);
+#endif
+ return ret;
+}
+
+static Bool
+chipsCreateResources (ScreenPtr pScreen)
+{
+ return vesaCreateResources (pScreen);
+}
+
+CARD8
+chipsReadXR (ChipsScreenInfo *chipss, CARD8 index)
+{
+ CARD8 value;
+ outb (index, 0x3d6);
+ value = inb (0x3d7);
+ return value;
+}
+
+void
+chipsWriteXR (ChipsScreenInfo *chipss, CARD8 index, CARD8 value)
+{
+ outb (index, 0x3d6);
+ outb (value, 0x3d7);
+}
+
+#if 0
+static CARD8
+chipsReadFR (ChipsScreenInfo *chipss, CARD8 index)
+{
+ CARD8 value;
+ outb (index, 0x3d0);
+ value = inb (0x3d1);
+ return value;
+}
+
+static void
+chipsWriteFR (ChipsScreenInfo *chipss, CARD8 index, CARD8 value)
+{
+ outb (index, 0x3d0);
+ outb (value, 0x3d1);
+}
+
+static CARD8
+chipsReadSeq (ChipsScreenInfo *chipss, CARD8 index)
+{
+ CARD8 value;
+ outb (index, 0x3c4);
+ value = inb (0x3c5);
+ return value;
+}
+
+static void
+chipsWriteSeq (ChipsScreenInfo *chipss, CARD8 index, CARD8 value)
+{
+ outb (index, 0x3c4);
+ outb (value, 0x3c5);
+}
+#endif
+
+static void
+chipsPreserve (KdCardInfo *card)
+{
+ vesaPreserve(card);
+}
+
+static void
+chipsSetMMIO (ChipsCardInfo *chipsc)
+{
+}
+
+static void
+chipsResetMMIO (ChipsCardInfo *chipsc)
+{
+}
+
+static Bool
+chipsEnable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ ChipsCardInfo *chipsc = pScreenPriv->card->driver;
+
+ if (!vesaEnable (pScreen))
+ return FALSE;
+ chipsSetMMIO (chipsc);
+ return TRUE;
+}
+
+#if 0
+static Bool
+chipsDPMS (ScreenPtr pScreen, int mode)
+{
+ KdScreenPriv(pScreen);
+ chipsScreenInfo(pScreenPriv);
+
+ ErrorF ("seqreg 0x01 0x%x\n", chipsReadSeq (chipss, 0x1));
+ ErrorF ("dpmsreg XR61 0x%x\n", chipsReadXR (chipss, 0x61));
+ ErrorF ("dpmsreg XR73 0x%x\n", chipsReadXR (chipss, 0x73));
+
+ ErrorF ("flat panel FR05 0x%x\n", chipsReadFR (chipss, 0x5));
+ ErrorF ("flat panel XR52 0x%x\n", chipsReadXR (chipss, 0x52));
+ return TRUE;
+}
+#endif
+
+static void
+chipsDisable (ScreenPtr pScreen)
+{
+ vesaDisable (pScreen);
+}
+
+static void
+chipsRestore (KdCardInfo *card)
+{
+ ChipsCardInfo *chipsc = card->driver;
+
+ chipsResetMMIO (chipsc);
+ vesaRestore (card);
+}
+
+static void
+chipsScreenFini (KdScreenInfo *screen)
+{
+ ChipsScreenInfo *chipss = (ChipsScreenInfo *) screen->driver;
+
+ if (chipss->mmio_base)
+ {
+ KdUnmapDevice ((void *) chipss->mmio_base, CHIPS_MMIO_SIZE(chipss));
+ KdResetMappedMode (CHIPS_MMIO_BASE(chipss),
+ CHIPS_MMIO_SIZE(chipss),
+ KD_MAPPED_MODE_REGISTERS);
+ }
+ vesaScreenFini (screen);
+ xfree (chipss);
+ screen->driver = 0;
+}
+
+static void
+chipsCardFini (KdCardInfo *card)
+{
+ vesaCardFini (card);
+}
+
+#define chipsCursorInit (void *) 0
+#define chipsCursorEnable (void *) 0
+#define chipsCursorDisable (void *) 0
+#define chipsCursorFini (void *) 0
+#define chipsRecolorCursor (void *) 0
+
+KdCardFuncs chipsFuncs = {
+ chipsCardInit, /* cardinit */
+ chipsScreenInit, /* scrinit */
+ chipsInitScreen, /* initScreen */
+ chipsFinishInitScreen, /* finishInitScreen */
+ chipsCreateResources, /* createRes */
+ chipsPreserve, /* preserve */
+ chipsEnable, /* enable */
+ vesaDPMS, /* dpms */
+ chipsDisable, /* disable */
+ chipsRestore, /* restore */
+ chipsScreenFini, /* scrfini */
+ chipsCardFini, /* cardfini */
+
+ chipsCursorInit, /* initCursor */
+ chipsCursorEnable, /* enableCursor */
+ chipsCursorDisable, /* disableCursor */
+ chipsCursorFini, /* finiCursor */
+ chipsRecolorCursor, /* recolorCursor */
+
+ chipsDrawInit, /* initAccel */
+ chipsDrawEnable, /* enableAccel */
+ chipsDrawDisable, /* disableAccel */
+ chipsDrawFini, /* finiAccel */
+
+ vesaGetColors, /* getColors */
+ vesaPutColors, /* putColors */
+};
diff --git a/xorg-server/hw/kdrive/chips/chips.h b/xorg-server/hw/kdrive/chips/chips.h
new file mode 100644
index 000000000..6ad17fe25
--- /dev/null
+++ b/xorg-server/hw/kdrive/chips/chips.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _CHIPS_H_
+#define _CHIPS_H_
+#include <vesa.h>
+
+/*
+ * offset from ioport beginning
+ */
+
+#define HIQV
+#ifdef HIQV
+#define CHIPS_MMIO_BASE(c) ((c)->vesa.fb_phys + 0x400000)
+#else
+#define CHIPS_MMIO_BASE(c) ((c)->vesa.fb_phys + 0x200000)
+#endif
+#define CHIPS_MMIO_SIZE(c) (0x20000)
+
+typedef volatile CARD8 VOL8;
+typedef volatile CARD16 VOL16;
+typedef volatile CARD32 VOL32;
+
+typedef struct _chipsSave {
+ int dummy;
+} ChipsSave;
+
+typedef struct _chipsCardInfo {
+ VesaCardPrivRec vesa;
+ CARD32 *window;
+ Bool mmio;
+ ChipsSave save;
+} ChipsCardInfo;
+
+#define getChipsCardInfo(kd) ((ChipsCardInfo *) ((kd)->card->driver))
+#define chipsCardInfo(kd) ChipsCardInfo *chipsc = getChipsCardInfo(kd)
+
+typedef struct _chipsCursor {
+ int width, height;
+ int xhot, yhot;
+ Bool has_cursor;
+ CursorPtr pCursor;
+ Pixel source, mask;
+} ChipsCursor;
+
+#define CHIPS_CURSOR_WIDTH 64
+#define CHIPS_CURSOR_HEIGHT 64
+
+typedef struct _chipsScreenInfo {
+ VesaScreenPrivRec vesa;
+ CARD8 *mmio_base;
+ CARD8 *cursor_base;
+ CARD8 *screen;
+ CARD8 *off_screen;
+ int off_screen_size;
+ ChipsCursor cursor;
+ KaaScreenInfoRec kaa;
+} ChipsScreenInfo;
+
+#define getChipsScreenInfo(kd) ((ChipsScreenInfo *) ((kd)->screen->driver))
+#define chipsScreenInfo(kd) ChipsScreenInfo *chipss = getChipsScreenInfo(kd)
+
+Bool
+chipsDrawInit (ScreenPtr pScreen);
+
+void
+chipsDrawEnable (ScreenPtr pScreen);
+
+void
+chipsDrawDisable (ScreenPtr pScreen);
+
+void
+chipsDrawFini (ScreenPtr pScreen);
+
+CARD8
+chipsReadXR (ChipsScreenInfo *chipsc, CARD8 index);
+
+void
+chipsWriteXR (ChipsScreenInfo *chipsc, CARD8 index, CARD8 value);
+
+Bool
+chipsCursorInit (ScreenPtr pScreen);
+
+void
+chipsCursorEnable (ScreenPtr pScreen);
+
+void
+chipsCursorDisable (ScreenPtr pScreen);
+
+void
+chipsCursorFini (ScreenPtr pScreen);
+
+void
+chipsRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef);
+
+extern KdCardFuncs chipsFuncs;
+
+#endif /* _CHIPS_H_ */
diff --git a/xorg-server/hw/kdrive/chips/chipsdraw.c b/xorg-server/hw/kdrive/chips/chipsdraw.c
new file mode 100644
index 000000000..b1c35f901
--- /dev/null
+++ b/xorg-server/hw/kdrive/chips/chipsdraw.c
@@ -0,0 +1,491 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "chips.h"
+
+#include <X11/Xmd.h>
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mistruct.h"
+#include "dixfontstr.h"
+#include "fb.h"
+#include "migc.h"
+#include "miline.h"
+#include "kaa.h"
+
+CARD8 chipsBltRop[16] = {
+ /* GXclear */ 0x00, /* 0 */
+ /* GXand */ 0x88, /* src AND dst */
+ /* GXandReverse */ 0x44, /* src AND NOT dst */
+ /* GXcopy */ 0xcc, /* src */
+ /* GXandInverted*/ 0x22, /* NOT src AND dst */
+ /* GXnoop */ 0xaa, /* dst */
+ /* GXxor */ 0x66, /* src XOR dst */
+ /* GXor */ 0xee, /* src OR dst */
+ /* GXnor */ 0x11, /* NOT src AND NOT dst */
+ /* GXequiv */ 0x99, /* NOT src XOR dst */
+ /* GXinvert */ 0x55, /* NOT dst */
+ /* GXorReverse */ 0xdd, /* src OR NOT dst */
+ /* GXcopyInverted*/ 0x33, /* NOT src */
+ /* GXorInverted */ 0xbb, /* NOT src OR dst */
+ /* GXnand */ 0x77, /* NOT src OR NOT dst */
+ /* GXset */ 0xff, /* 1 */
+};
+
+CARD8 chipsSolidRop[16] = {
+ /* GXclear */ 0x00, /* 0 */
+ /* GXand */ 0xa0, /* src AND dst */
+ /* GXandReverse */ 0x50, /* src AND NOT dst */
+ /* GXcopy */ 0xf0, /* src */
+ /* GXandInverted*/ 0x0a, /* NOT src AND dst */
+ /* GXnoop */ 0xaa, /* dst */
+ /* GXxor */ 0x5a, /* src XOR dst */
+ /* GXor */ 0xfa, /* src OR dst */
+ /* GXnor */ 0x05, /* NOT src AND NOT dst */
+ /* GXequiv */ 0xa5, /* NOT src XOR dst */
+ /* GXinvert */ 0x55, /* NOT dst */
+ /* GXorReverse */ 0xf5, /* src OR NOT dst */
+ /* GXcopyInverted*/ 0x0f, /* NOT src */
+ /* GXorInverted */ 0xaf, /* NOT src OR dst */
+ /* GXnand */ 0x5f, /* NOT src OR NOT dst */
+ /* GXset */ 0xff, /* 1 */
+};
+
+/* Definitions for the Chips and Technology BitBLT engine communication. */
+/* These are done using Memory Mapped IO, of the registers */
+/* BitBLT modes for register 93D0. */
+
+#ifdef HIQV
+#define ctPATCOPY 0xF0
+#define ctLEFT2RIGHT 0x000
+#define ctRIGHT2LEFT 0x100
+#define ctTOP2BOTTOM 0x000
+#define ctBOTTOM2TOP 0x200
+#define ctSRCSYSTEM 0x400
+#define ctDSTSYSTEM 0x800
+#define ctSRCMONO 0x1000
+#define ctBGTRANSPARENT 0x22000
+#define ctCOLORTRANSENABLE 0x4000
+#define ctCOLORTRANSDISABLE 0x0
+#define ctCOLORTRANSDST 0x8000
+#define ctCOLORTRANSROP 0x0
+#define ctCOLORTRANSEQUAL 0x10000L
+#define ctCOLORTRANSNEQUAL 0x0
+#define ctPATMONO 0x40000L
+#define ctPATSOLID 0x80000L
+#define ctPATSTART0 0x000000L
+#define ctPATSTART1 0x100000L
+#define ctPATSTART2 0x200000L
+#define ctPATSTART3 0x300000L
+#define ctPATSTART4 0x400000L
+#define ctPATSTART5 0x500000L
+#define ctPATSTART6 0x600000L
+#define ctPATSTART7 0x700000L
+#define ctSRCFG 0x000000L /* Where is this for the 65550?? */
+#else
+#define ctPATCOPY 0xF0
+#define ctTOP2BOTTOM 0x100
+#define ctBOTTOM2TOP 0x000
+#define ctLEFT2RIGHT 0x200
+#define ctRIGHT2LEFT 0x000
+#define ctSRCFG 0x400
+#define ctSRCMONO 0x800
+#define ctPATMONO 0x1000
+#define ctBGTRANSPARENT 0x2000
+#define ctSRCSYSTEM 0x4000
+#define ctPATSOLID 0x80000L
+#define ctPATSTART0 0x00000L
+#define ctPATSTART1 0x10000L
+#define ctPATSTART2 0x20000L
+#define ctPATSTART3 0x30000L
+#define ctPATSTART4 0x40000L
+#define ctPATSTART5 0x50000L
+#define ctPATSTART6 0x60000L
+#define ctPATSTART7 0x70000L
+#endif
+
+#define chipsFillPix(bpp,pixel) {\
+ if (bpp == 8) \
+ { \
+ pixel = pixel & 0xff; \
+ } \
+ else if (bpp == 16) \
+ { \
+ pixel = pixel & 0xffff; \
+ } \
+}
+
+static VOL8 *mmio;
+static CARD32 byteStride;
+static CARD32 bytesPerPixel;
+static CARD32 pixelStride;
+
+static void
+chipsSet (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ chipsScreenInfo(pScreenPriv);
+
+ mmio = chipss->mmio_base;
+ byteStride = pScreenPriv->screen->fb[0].byteStride;
+ bytesPerPixel = pScreenPriv->screen->fb[0].bitsPerPixel >> 3;
+ pixelStride = pScreenPriv->screen->fb[0].pixelStride;
+}
+
+#ifdef HIQV
+#define CHIPS_BR0 0x00 /* offset */
+#define CHIPS_BR1 0x04 /* bg */
+#define CHIPS_BR2 0x08 /* fg */
+#define CHIPS_BR3 0x0c /* monochrome */
+#define CHIPS_BR4 0x10 /* bitblt */
+#define CHIPS_BR5 0x14 /* pattern addr */
+#define CHIPS_BR6 0x18 /* source addr */
+#define CHIPS_BR7 0x1c /* dst addr */
+#define CHIPS_BR8 0x20 /* dst w/h */
+#else
+#define CHIPS_DR0 0x83d0
+#define CHIPS_DR1 0x87d0
+#define CHIPS_DR2 0x8bd0
+#define CHIPS_DR3 0x8fd0
+#define CHIPS_DR4 0x93d0
+#define CHIPS_DR5 0x97d0
+#define CHIPS_DR6 0x9bd0
+#define CHIPS_DR7 0x9fd0
+#endif
+
+#define DBG(x)
+
+static void
+chipsPitch (int src, int dst)
+{
+ CARD32 p;
+
+ p = ((dst & 0xffff) << 16) | (src & 0xffff);
+ DBG(ErrorF ("\tpitch 0x%x\n", p));
+#ifdef HIQV
+ *(VOL32 *) (mmio + CHIPS_BR0) = p;
+#else
+ *(VOL32 *) (mmio + CHIPS_DR0) = p;
+#endif
+}
+
+static void
+chipsBg (Pixel bg)
+{
+ DBG(ErrorF ("\tbg 0x%x\n", bg));
+#ifdef HIQV
+ *(VOL32 *) (mmio + CHIPS_BR1) = bg & 0xffff;
+#else
+ *(VOL32 *) (mmio + CHIPS_DR2) = bg;
+#endif
+}
+
+static void
+chipsFg (Pixel fg)
+{
+ DBG(ErrorF ("\tfg 0x%x\n", fg));
+#ifdef HIQV
+ *(VOL32 *) (mmio + CHIPS_BR2) = fg;
+#else
+ *(VOL32 *) (mmio + CHIPS_DR3) = fg;
+#endif
+}
+
+static void
+chipsOp (CARD32 op)
+{
+ DBG(ErrorF ("\top 0x%x\n", op));
+#ifdef HIQV
+ *(VOL32 *) (mmio + CHIPS_BR4) = op;
+#else
+ *(VOL32 *) (mmio + CHIPS_DR4) = op;
+#endif
+}
+
+static void
+chipsRopSolid (int rop)
+{
+ CARD32 op;
+
+ op = chipsSolidRop[rop] | ctTOP2BOTTOM | ctLEFT2RIGHT | ctPATSOLID | ctPATMONO;
+ chipsOp (op);
+}
+
+static void
+chipsSrc (int addr)
+{
+ DBG(ErrorF ("\tsrc 0x%x\n", addr));
+#ifdef HIQV
+ *(VOL32 *) (mmio + CHIPS_BR6) = addr;
+#else
+ *(VOL32 *) (mmio + CHIPS_DR5) = addr;
+#endif
+}
+
+static void
+chipsDst (int addr)
+{
+ DBG(ErrorF ("\tdst 0x%x\n", addr));
+#ifdef HIQV
+ *(VOL32 *) (mmio + CHIPS_BR7) = addr;
+#else
+ *(VOL32 *) (mmio + CHIPS_DR6) = addr;
+#endif
+}
+
+static void
+chipsWidthHeightGo (int w, int h)
+{
+ DBG(ErrorF ("\twidth height %d/%d\n", w, h));
+#ifdef HIQV
+ *(VOL32 *) (mmio + CHIPS_BR8) = ((h & 0xffff) << 16) | (w & 0xffff);
+#else
+ *(VOL32 *) (mmio + CHIPS_DR7) = ((h & 0xffff) << 16) | (w & 0xffff);
+#endif
+}
+
+static void
+chipsWaitIdle (void)
+{
+#ifdef HIQV
+ int timeout = 0;
+ CARD8 tmp;
+ VOL32 *br4 = (VOL32 *) (mmio + CHIPS_BR4);
+
+ DBG(ErrorF ("\tBR4 0x%x 0x%x\n", mmio + CHIPS_BR4, *br4));
+ DBG(ErrorF ("\tXR20 0x%x\n", chipsReadXR (0, 0x20)));
+ for (;;)
+ {
+ if ((*br4 & 0x80000000) == 0)
+ break;
+ tmp = chipsReadXR (0, 0x20);
+ if ((tmp & 1) == 0)
+ break;
+ if (++timeout > 1000000)
+ {
+ ErrorF ("timeout\n");
+ tmp = chipsReadXR (0, 0x20);
+ chipsWriteXR (0, 0x20, tmp | 2);
+ sleep (1);
+ chipsWriteXR (0, 0x20, tmp);
+ sleep (1);
+ }
+ }
+#else
+ while (*(VOL32 *) (mmio + CHIPS_DR4) & 0x00100000)
+ ;
+#endif
+}
+
+static void
+chipsWaitMarker (ScreenPtr pScreen, int marker)
+{
+ chipsSet (pScreen);
+ chipsWaitIdle ();
+}
+
+static Bool
+chipsPrepareSolid (PixmapPtr pPixmap,
+ int alu,
+ Pixel pm,
+ Pixel fg)
+{
+ FbBits depthMask;
+
+ DBG(ErrorF ("PrepareSolid %d 0x%x\n", alu, fg));
+ depthMask = FbFullMask(pPixmap->drawable.depth);
+ if ((pm & depthMask) != depthMask)
+ return FALSE;
+ else
+ {
+ chipsSet (pPixmap->drawable.pScreen);
+ chipsWaitIdle ();
+ chipsFillPix(pPixmap->drawable.bitsPerPixel,fg);
+ chipsFg (fg);
+ chipsBg (fg);
+ chipsRopSolid (alu);
+ chipsPitch (byteStride, byteStride);
+ return TRUE;
+ }
+}
+
+static void
+chipsSolid (int x1, int y1, int x2, int y2)
+{
+ CARD32 dst;
+ int w, h;
+
+ DBG(ErrorF (" Solid %dx%d %dx%d\n", x1, y1, x2, y2));
+ dst = y1 * byteStride + x1 * bytesPerPixel;
+ w = (x2 - x1) * bytesPerPixel;
+ h = (y2 - y1);
+ chipsWaitIdle ();
+ chipsDst (dst);
+ chipsWidthHeightGo (w, h);
+}
+
+static void
+chipsDoneSolid (void)
+{
+}
+
+static CARD32 copyOp;
+
+static Bool
+chipsPrepareCopy (PixmapPtr pSrcPixmap,
+ PixmapPtr pDstPixmap,
+ int dx,
+ int dy,
+ int alu,
+ Pixel pm)
+{
+ FbBits depthMask;
+
+ DBG(ErrorF ("PrepareSolid %d 0x%x\n", alu, fg));
+ depthMask = FbFullMask(pDstPixmap->drawable.depth);
+ if ((pm & depthMask) != depthMask)
+ return FALSE;
+ else
+ {
+ copyOp = chipsBltRop[alu];
+ if (dy >= 0)
+ copyOp |= ctTOP2BOTTOM;
+ else
+ copyOp |= ctBOTTOM2TOP;
+ if (dx >= 0)
+ copyOp |= ctLEFT2RIGHT;
+ else
+ copyOp |= ctRIGHT2LEFT;
+ chipsSet (pDstPixmap->drawable.pScreen);
+ chipsWaitIdle ();
+ chipsOp (copyOp);
+ chipsPitch (byteStride, byteStride);
+ return TRUE;
+ }
+}
+
+static void
+chipsCopy (int srcX,
+ int srcY,
+ int dstX,
+ int dstY,
+ int w,
+ int h)
+{
+ int src, dst;
+ if ((copyOp & (ctTOP2BOTTOM|ctBOTTOM2TOP)) == ctBOTTOM2TOP)
+ {
+ src = (srcY + h - 1) * byteStride;
+ dst = (dstY + h - 1) * byteStride;
+ }
+ else
+ {
+ src = srcY * byteStride;
+ dst = dstY * byteStride;
+ }
+ if ((copyOp & (ctLEFT2RIGHT|ctRIGHT2LEFT)) == ctRIGHT2LEFT)
+ {
+ src = src + (srcX + w) * bytesPerPixel - 1;
+ dst = dst + (dstX + w) * bytesPerPixel - 1;
+ }
+ else
+ {
+ src = src + srcX * bytesPerPixel;
+ dst = dst + dstX * bytesPerPixel;
+ }
+ chipsWaitIdle ();
+ chipsSrc (src);
+ chipsDst (dst);
+ chipsWidthHeightGo (w * bytesPerPixel, h);
+}
+
+static void
+chipsDoneCopy (void)
+{
+}
+
+Bool
+chipsDrawInit (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ chipsScreenInfo(pScreenPriv);
+
+ switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
+ case 8:
+ case 16:
+ break;
+ default:
+ return FALSE;
+ }
+
+ memset(&chipss->kaa, 0, sizeof(KaaScreenInfoRec));
+ chipss->kaa.waitMarker = chipsWaitMarker;
+ chipss->kaa.PrepareSolid = chipsPrepareSolid;
+ chipss->kaa.Solid = chipsSolid;
+ chipss->kaa.DoneSolid = chipsDoneSolid;
+ chipss->kaa.PrepareCopy = chipsPrepareCopy;
+ chipss->kaa.Copy = chipsCopy;
+ chipss->kaa.DoneCopy = chipsDoneCopy;
+
+ if (!kaaDrawInit (pScreen, &chipss->kaa))
+ return FALSE;
+
+ return TRUE;
+}
+
+void
+chipsDrawEnable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ chipsScreenInfo(pScreenPriv);
+ CARD8 mode = 0x00;
+
+ switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
+ case 8:
+ mode = 0x00;
+ break;
+ case 16:
+ mode = 0x10;
+ break;
+ }
+ chipsSet (pScreen);
+ chipsWaitIdle ();
+ chipsWriteXR (chipss, 0x20, mode);
+
+ kaaMarkSync (pScreen);
+}
+
+void
+chipsDrawDisable (ScreenPtr pScreen)
+{
+}
+
+void
+chipsDrawFini (ScreenPtr pScreen)
+{
+}
+
diff --git a/xorg-server/hw/kdrive/chips/chipsstub.c b/xorg-server/hw/kdrive/chips/chipsstub.c
new file mode 100644
index 000000000..9024a7d44
--- /dev/null
+++ b/xorg-server/hw/kdrive/chips/chipsstub.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright 1999 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "chips.h"
+
+extern int chips_clk, chips_mclk;
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+
+ KdCardInfoAdd (&chipsFuncs, &attr, 0);
+}
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdOsAddInputDrivers ();
+ KdInitInput ();
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+ vesaUseMsg();
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ int ret;
+
+ if (!(ret = vesaProcessArgument (argc, argv, i)))
+ ret = KdProcessArgument(argc, argv, i);
+ return ret;
+}
diff --git a/xorg-server/hw/kdrive/ephyr/Makefile.am b/xorg-server/hw/kdrive/ephyr/Makefile.am
new file mode 100644
index 000000000..7a56d34a8
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/Makefile.am
@@ -0,0 +1,91 @@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@ \
+ -I$(srcdir)/../../../exa
+
+if XV
+ LIBXEPHYR_HOSTXV=libxephyr-hostxv.a
+else
+ LIBXEPHYR_HOSTXV=
+endif
+
+if XEPHYR_HAS_DRI
+ LIBXEPHYR_HOSTDRI=libxephyr-hostdri.a
+else
+ LIBXEPHYR_HOSTDRI=
+endif
+
+noinst_LIBRARIES = libxephyr-hostx.a $(LIBXEPHYR_HOSTXV) $(LIBXEPHYR_HOSTDRI) libxephyr.a
+
+bin_PROGRAMS = Xephyr
+
+libxephyr_hostx_a_SOURCES = \
+ hostx.c \
+ hostx.h
+
+libxephyr_hostxv_a_INCLUDES = @XEPHYR_INCS@
+
+if XV
+libxephyr_hostxv_a_SOURCES= \
+ ephyrhostvideo.c \
+ ephyrhostvideo.h
+endif
+
+if XEPHYR_HAS_DRI
+
+libxephyr_hostdri_a_SOURCES= \
+ephyrdriext.c \
+ephyrdriext.h \
+ephyrdri.c \
+ephyrdri.h \
+XF86dri.c \
+ephyrglxext.c \
+ephyrglxext.h \
+ephyrhostglx.c \
+ephyrhostglx.h
+
+libxephyr_hostdri_a_CFLAGS= \
+-I$(top_srcdir) \
+@LIBDRM_CFLAGS@ \
+@DRIPROTO_CFLAGS@
+
+endif
+
+libxephyr_a_SOURCES = \
+ ephyr.c \
+ ephyr_draw.c \
+ ephyrvideo.c \
+ os.c \
+ hostx.h \
+ ephyr.h \
+ ephyrlog.h
+
+libxephyr_a_CFLAGS = \
+-I$(top_srcdir) \
+@LIBDRM_CFLAGS@
+
+Xephyr_SOURCES = \
+ ephyrinit.c
+
+Xephyr_LDADD = \
+ libxephyr.a \
+ libxephyr-hostx.a \
+ $(LIBXEPHYR_HOSTXV) \
+ $(LIBXEPHYR_HOSTDRI) \
+ ../../../exa/libexa.la \
+ @KDRIVE_LIBS@ \
+ @XEPHYR_LIBS@ \
+ @LIBDRM_LIBS@ \
+ @XEPHYR_DRI_LIBS@
+
+Xephyr_DEPENDENCIES = \
+ libxephyr.a \
+ libxephyr-hostx.a \
+ $(LIBXEPHYR_HOSTXV) \
+ $(LIBXEPHYR_HOSTDRI) \
+ @KDRIVE_LOCAL_LIBS@
+
+Xephyr_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/ephyr/Makefile.in b/xorg-server/hw/kdrive/ephyr/Makefile.in
new file mode 100644
index 000000000..67efca081
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/Makefile.in
@@ -0,0 +1,934 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xephyr$(EXEEXT)
+subdir = hw/kdrive/ephyr
+DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libxephyr_hostdri_a_AR = $(AR) $(ARFLAGS)
+libxephyr_hostdri_a_LIBADD =
+am__libxephyr_hostdri_a_SOURCES_DIST = ephyrdriext.c ephyrdriext.h \
+ ephyrdri.c ephyrdri.h XF86dri.c ephyrglxext.c ephyrglxext.h \
+ ephyrhostglx.c ephyrhostglx.h
+@XEPHYR_HAS_DRI_TRUE@am_libxephyr_hostdri_a_OBJECTS = libxephyr_hostdri_a-ephyrdriext.$(OBJEXT) \
+@XEPHYR_HAS_DRI_TRUE@ libxephyr_hostdri_a-ephyrdri.$(OBJEXT) \
+@XEPHYR_HAS_DRI_TRUE@ libxephyr_hostdri_a-XF86dri.$(OBJEXT) \
+@XEPHYR_HAS_DRI_TRUE@ libxephyr_hostdri_a-ephyrglxext.$(OBJEXT) \
+@XEPHYR_HAS_DRI_TRUE@ libxephyr_hostdri_a-ephyrhostglx.$(OBJEXT)
+libxephyr_hostdri_a_OBJECTS = $(am_libxephyr_hostdri_a_OBJECTS)
+libxephyr_hostx_a_AR = $(AR) $(ARFLAGS)
+libxephyr_hostx_a_LIBADD =
+am_libxephyr_hostx_a_OBJECTS = hostx.$(OBJEXT)
+libxephyr_hostx_a_OBJECTS = $(am_libxephyr_hostx_a_OBJECTS)
+libxephyr_hostxv_a_AR = $(AR) $(ARFLAGS)
+libxephyr_hostxv_a_LIBADD =
+am__libxephyr_hostxv_a_SOURCES_DIST = ephyrhostvideo.c \
+ ephyrhostvideo.h
+@XV_TRUE@am_libxephyr_hostxv_a_OBJECTS = ephyrhostvideo.$(OBJEXT)
+libxephyr_hostxv_a_OBJECTS = $(am_libxephyr_hostxv_a_OBJECTS)
+libxephyr_a_AR = $(AR) $(ARFLAGS)
+libxephyr_a_LIBADD =
+am_libxephyr_a_OBJECTS = libxephyr_a-ephyr.$(OBJEXT) \
+ libxephyr_a-ephyr_draw.$(OBJEXT) \
+ libxephyr_a-ephyrvideo.$(OBJEXT) libxephyr_a-os.$(OBJEXT)
+libxephyr_a_OBJECTS = $(am_libxephyr_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xephyr_OBJECTS = ephyrinit.$(OBJEXT)
+Xephyr_OBJECTS = $(am_Xephyr_OBJECTS)
+@XV_TRUE@am__DEPENDENCIES_1 = libxephyr-hostxv.a
+@XEPHYR_HAS_DRI_TRUE@am__DEPENDENCIES_2 = libxephyr-hostdri.a
+Xephyr_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xephyr_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libxephyr_hostdri_a_SOURCES) $(libxephyr_hostx_a_SOURCES) \
+ $(libxephyr_hostxv_a_SOURCES) $(libxephyr_a_SOURCES) \
+ $(Xephyr_SOURCES)
+DIST_SOURCES = $(am__libxephyr_hostdri_a_SOURCES_DIST) \
+ $(libxephyr_hostx_a_SOURCES) \
+ $(am__libxephyr_hostxv_a_SOURCES_DIST) $(libxephyr_a_SOURCES) \
+ $(Xephyr_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@ \
+ -I$(srcdir)/../../../exa
+
+@XV_FALSE@LIBXEPHYR_HOSTXV =
+@XV_TRUE@LIBXEPHYR_HOSTXV = libxephyr-hostxv.a
+@XEPHYR_HAS_DRI_FALSE@LIBXEPHYR_HOSTDRI =
+@XEPHYR_HAS_DRI_TRUE@LIBXEPHYR_HOSTDRI = libxephyr-hostdri.a
+noinst_LIBRARIES = libxephyr-hostx.a $(LIBXEPHYR_HOSTXV) $(LIBXEPHYR_HOSTDRI) libxephyr.a
+libxephyr_hostx_a_SOURCES = \
+ hostx.c \
+ hostx.h
+
+libxephyr_hostxv_a_INCLUDES = @XEPHYR_INCS@
+@XV_TRUE@libxephyr_hostxv_a_SOURCES = \
+@XV_TRUE@ ephyrhostvideo.c \
+@XV_TRUE@ ephyrhostvideo.h
+
+@XEPHYR_HAS_DRI_TRUE@libxephyr_hostdri_a_SOURCES = \
+@XEPHYR_HAS_DRI_TRUE@ephyrdriext.c \
+@XEPHYR_HAS_DRI_TRUE@ephyrdriext.h \
+@XEPHYR_HAS_DRI_TRUE@ephyrdri.c \
+@XEPHYR_HAS_DRI_TRUE@ephyrdri.h \
+@XEPHYR_HAS_DRI_TRUE@XF86dri.c \
+@XEPHYR_HAS_DRI_TRUE@ephyrglxext.c \
+@XEPHYR_HAS_DRI_TRUE@ephyrglxext.h \
+@XEPHYR_HAS_DRI_TRUE@ephyrhostglx.c \
+@XEPHYR_HAS_DRI_TRUE@ephyrhostglx.h
+
+@XEPHYR_HAS_DRI_TRUE@libxephyr_hostdri_a_CFLAGS = \
+@XEPHYR_HAS_DRI_TRUE@-I$(top_srcdir) \
+@XEPHYR_HAS_DRI_TRUE@@LIBDRM_CFLAGS@ \
+@XEPHYR_HAS_DRI_TRUE@@DRIPROTO_CFLAGS@
+
+libxephyr_a_SOURCES = \
+ ephyr.c \
+ ephyr_draw.c \
+ ephyrvideo.c \
+ os.c \
+ hostx.h \
+ ephyr.h \
+ ephyrlog.h
+
+libxephyr_a_CFLAGS = \
+-I$(top_srcdir) \
+@LIBDRM_CFLAGS@
+
+Xephyr_SOURCES = \
+ ephyrinit.c
+
+Xephyr_LDADD = \
+ libxephyr.a \
+ libxephyr-hostx.a \
+ $(LIBXEPHYR_HOSTXV) \
+ $(LIBXEPHYR_HOSTDRI) \
+ ../../../exa/libexa.la \
+ @KDRIVE_LIBS@ \
+ @XEPHYR_LIBS@ \
+ @LIBDRM_LIBS@ \
+ @XEPHYR_DRI_LIBS@
+
+Xephyr_DEPENDENCIES = \
+ libxephyr.a \
+ libxephyr-hostx.a \
+ $(LIBXEPHYR_HOSTXV) \
+ $(LIBXEPHYR_HOSTDRI) \
+ @KDRIVE_LOCAL_LIBS@
+
+Xephyr_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/ephyr/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/ephyr/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libxephyr-hostdri.a: $(libxephyr_hostdri_a_OBJECTS) $(libxephyr_hostdri_a_DEPENDENCIES)
+ -rm -f libxephyr-hostdri.a
+ $(libxephyr_hostdri_a_AR) libxephyr-hostdri.a $(libxephyr_hostdri_a_OBJECTS) $(libxephyr_hostdri_a_LIBADD)
+ $(RANLIB) libxephyr-hostdri.a
+libxephyr-hostx.a: $(libxephyr_hostx_a_OBJECTS) $(libxephyr_hostx_a_DEPENDENCIES)
+ -rm -f libxephyr-hostx.a
+ $(libxephyr_hostx_a_AR) libxephyr-hostx.a $(libxephyr_hostx_a_OBJECTS) $(libxephyr_hostx_a_LIBADD)
+ $(RANLIB) libxephyr-hostx.a
+libxephyr-hostxv.a: $(libxephyr_hostxv_a_OBJECTS) $(libxephyr_hostxv_a_DEPENDENCIES)
+ -rm -f libxephyr-hostxv.a
+ $(libxephyr_hostxv_a_AR) libxephyr-hostxv.a $(libxephyr_hostxv_a_OBJECTS) $(libxephyr_hostxv_a_LIBADD)
+ $(RANLIB) libxephyr-hostxv.a
+libxephyr.a: $(libxephyr_a_OBJECTS) $(libxephyr_a_DEPENDENCIES)
+ -rm -f libxephyr.a
+ $(libxephyr_a_AR) libxephyr.a $(libxephyr_a_OBJECTS) $(libxephyr_a_LIBADD)
+ $(RANLIB) libxephyr.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xephyr$(EXEEXT): $(Xephyr_OBJECTS) $(Xephyr_DEPENDENCIES)
+ @rm -f Xephyr$(EXEEXT)
+ $(Xephyr_LINK) $(Xephyr_OBJECTS) $(Xephyr_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ephyrhostvideo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ephyrinit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hostx.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxephyr_a-ephyr.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxephyr_a-ephyr_draw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxephyr_a-ephyrvideo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxephyr_a-os.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxephyr_hostdri_a-XF86dri.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxephyr_hostdri_a-ephyrdri.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxephyr_hostdri_a-ephyrdriext.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxephyr_hostdri_a-ephyrglxext.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libxephyr_hostdri_a-ephyrhostglx.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+libxephyr_hostdri_a-ephyrdriext.o: ephyrdriext.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -MT libxephyr_hostdri_a-ephyrdriext.o -MD -MP -MF $(DEPDIR)/libxephyr_hostdri_a-ephyrdriext.Tpo -c -o libxephyr_hostdri_a-ephyrdriext.o `test -f 'ephyrdriext.c' || echo '$(srcdir)/'`ephyrdriext.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_hostdri_a-ephyrdriext.Tpo $(DEPDIR)/libxephyr_hostdri_a-ephyrdriext.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ephyrdriext.c' object='libxephyr_hostdri_a-ephyrdriext.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -c -o libxephyr_hostdri_a-ephyrdriext.o `test -f 'ephyrdriext.c' || echo '$(srcdir)/'`ephyrdriext.c
+
+libxephyr_hostdri_a-ephyrdriext.obj: ephyrdriext.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -MT libxephyr_hostdri_a-ephyrdriext.obj -MD -MP -MF $(DEPDIR)/libxephyr_hostdri_a-ephyrdriext.Tpo -c -o libxephyr_hostdri_a-ephyrdriext.obj `if test -f 'ephyrdriext.c'; then $(CYGPATH_W) 'ephyrdriext.c'; else $(CYGPATH_W) '$(srcdir)/ephyrdriext.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_hostdri_a-ephyrdriext.Tpo $(DEPDIR)/libxephyr_hostdri_a-ephyrdriext.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ephyrdriext.c' object='libxephyr_hostdri_a-ephyrdriext.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -c -o libxephyr_hostdri_a-ephyrdriext.obj `if test -f 'ephyrdriext.c'; then $(CYGPATH_W) 'ephyrdriext.c'; else $(CYGPATH_W) '$(srcdir)/ephyrdriext.c'; fi`
+
+libxephyr_hostdri_a-ephyrdri.o: ephyrdri.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -MT libxephyr_hostdri_a-ephyrdri.o -MD -MP -MF $(DEPDIR)/libxephyr_hostdri_a-ephyrdri.Tpo -c -o libxephyr_hostdri_a-ephyrdri.o `test -f 'ephyrdri.c' || echo '$(srcdir)/'`ephyrdri.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_hostdri_a-ephyrdri.Tpo $(DEPDIR)/libxephyr_hostdri_a-ephyrdri.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ephyrdri.c' object='libxephyr_hostdri_a-ephyrdri.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -c -o libxephyr_hostdri_a-ephyrdri.o `test -f 'ephyrdri.c' || echo '$(srcdir)/'`ephyrdri.c
+
+libxephyr_hostdri_a-ephyrdri.obj: ephyrdri.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -MT libxephyr_hostdri_a-ephyrdri.obj -MD -MP -MF $(DEPDIR)/libxephyr_hostdri_a-ephyrdri.Tpo -c -o libxephyr_hostdri_a-ephyrdri.obj `if test -f 'ephyrdri.c'; then $(CYGPATH_W) 'ephyrdri.c'; else $(CYGPATH_W) '$(srcdir)/ephyrdri.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_hostdri_a-ephyrdri.Tpo $(DEPDIR)/libxephyr_hostdri_a-ephyrdri.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ephyrdri.c' object='libxephyr_hostdri_a-ephyrdri.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -c -o libxephyr_hostdri_a-ephyrdri.obj `if test -f 'ephyrdri.c'; then $(CYGPATH_W) 'ephyrdri.c'; else $(CYGPATH_W) '$(srcdir)/ephyrdri.c'; fi`
+
+libxephyr_hostdri_a-XF86dri.o: XF86dri.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -MT libxephyr_hostdri_a-XF86dri.o -MD -MP -MF $(DEPDIR)/libxephyr_hostdri_a-XF86dri.Tpo -c -o libxephyr_hostdri_a-XF86dri.o `test -f 'XF86dri.c' || echo '$(srcdir)/'`XF86dri.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_hostdri_a-XF86dri.Tpo $(DEPDIR)/libxephyr_hostdri_a-XF86dri.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='XF86dri.c' object='libxephyr_hostdri_a-XF86dri.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -c -o libxephyr_hostdri_a-XF86dri.o `test -f 'XF86dri.c' || echo '$(srcdir)/'`XF86dri.c
+
+libxephyr_hostdri_a-XF86dri.obj: XF86dri.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -MT libxephyr_hostdri_a-XF86dri.obj -MD -MP -MF $(DEPDIR)/libxephyr_hostdri_a-XF86dri.Tpo -c -o libxephyr_hostdri_a-XF86dri.obj `if test -f 'XF86dri.c'; then $(CYGPATH_W) 'XF86dri.c'; else $(CYGPATH_W) '$(srcdir)/XF86dri.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_hostdri_a-XF86dri.Tpo $(DEPDIR)/libxephyr_hostdri_a-XF86dri.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='XF86dri.c' object='libxephyr_hostdri_a-XF86dri.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -c -o libxephyr_hostdri_a-XF86dri.obj `if test -f 'XF86dri.c'; then $(CYGPATH_W) 'XF86dri.c'; else $(CYGPATH_W) '$(srcdir)/XF86dri.c'; fi`
+
+libxephyr_hostdri_a-ephyrglxext.o: ephyrglxext.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -MT libxephyr_hostdri_a-ephyrglxext.o -MD -MP -MF $(DEPDIR)/libxephyr_hostdri_a-ephyrglxext.Tpo -c -o libxephyr_hostdri_a-ephyrglxext.o `test -f 'ephyrglxext.c' || echo '$(srcdir)/'`ephyrglxext.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_hostdri_a-ephyrglxext.Tpo $(DEPDIR)/libxephyr_hostdri_a-ephyrglxext.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ephyrglxext.c' object='libxephyr_hostdri_a-ephyrglxext.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -c -o libxephyr_hostdri_a-ephyrglxext.o `test -f 'ephyrglxext.c' || echo '$(srcdir)/'`ephyrglxext.c
+
+libxephyr_hostdri_a-ephyrglxext.obj: ephyrglxext.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -MT libxephyr_hostdri_a-ephyrglxext.obj -MD -MP -MF $(DEPDIR)/libxephyr_hostdri_a-ephyrglxext.Tpo -c -o libxephyr_hostdri_a-ephyrglxext.obj `if test -f 'ephyrglxext.c'; then $(CYGPATH_W) 'ephyrglxext.c'; else $(CYGPATH_W) '$(srcdir)/ephyrglxext.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_hostdri_a-ephyrglxext.Tpo $(DEPDIR)/libxephyr_hostdri_a-ephyrglxext.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ephyrglxext.c' object='libxephyr_hostdri_a-ephyrglxext.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -c -o libxephyr_hostdri_a-ephyrglxext.obj `if test -f 'ephyrglxext.c'; then $(CYGPATH_W) 'ephyrglxext.c'; else $(CYGPATH_W) '$(srcdir)/ephyrglxext.c'; fi`
+
+libxephyr_hostdri_a-ephyrhostglx.o: ephyrhostglx.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -MT libxephyr_hostdri_a-ephyrhostglx.o -MD -MP -MF $(DEPDIR)/libxephyr_hostdri_a-ephyrhostglx.Tpo -c -o libxephyr_hostdri_a-ephyrhostglx.o `test -f 'ephyrhostglx.c' || echo '$(srcdir)/'`ephyrhostglx.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_hostdri_a-ephyrhostglx.Tpo $(DEPDIR)/libxephyr_hostdri_a-ephyrhostglx.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ephyrhostglx.c' object='libxephyr_hostdri_a-ephyrhostglx.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -c -o libxephyr_hostdri_a-ephyrhostglx.o `test -f 'ephyrhostglx.c' || echo '$(srcdir)/'`ephyrhostglx.c
+
+libxephyr_hostdri_a-ephyrhostglx.obj: ephyrhostglx.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -MT libxephyr_hostdri_a-ephyrhostglx.obj -MD -MP -MF $(DEPDIR)/libxephyr_hostdri_a-ephyrhostglx.Tpo -c -o libxephyr_hostdri_a-ephyrhostglx.obj `if test -f 'ephyrhostglx.c'; then $(CYGPATH_W) 'ephyrhostglx.c'; else $(CYGPATH_W) '$(srcdir)/ephyrhostglx.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_hostdri_a-ephyrhostglx.Tpo $(DEPDIR)/libxephyr_hostdri_a-ephyrhostglx.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ephyrhostglx.c' object='libxephyr_hostdri_a-ephyrhostglx.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_hostdri_a_CFLAGS) $(CFLAGS) -c -o libxephyr_hostdri_a-ephyrhostglx.obj `if test -f 'ephyrhostglx.c'; then $(CYGPATH_W) 'ephyrhostglx.c'; else $(CYGPATH_W) '$(srcdir)/ephyrhostglx.c'; fi`
+
+libxephyr_a-ephyr.o: ephyr.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -MT libxephyr_a-ephyr.o -MD -MP -MF $(DEPDIR)/libxephyr_a-ephyr.Tpo -c -o libxephyr_a-ephyr.o `test -f 'ephyr.c' || echo '$(srcdir)/'`ephyr.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_a-ephyr.Tpo $(DEPDIR)/libxephyr_a-ephyr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ephyr.c' object='libxephyr_a-ephyr.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -c -o libxephyr_a-ephyr.o `test -f 'ephyr.c' || echo '$(srcdir)/'`ephyr.c
+
+libxephyr_a-ephyr.obj: ephyr.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -MT libxephyr_a-ephyr.obj -MD -MP -MF $(DEPDIR)/libxephyr_a-ephyr.Tpo -c -o libxephyr_a-ephyr.obj `if test -f 'ephyr.c'; then $(CYGPATH_W) 'ephyr.c'; else $(CYGPATH_W) '$(srcdir)/ephyr.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_a-ephyr.Tpo $(DEPDIR)/libxephyr_a-ephyr.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ephyr.c' object='libxephyr_a-ephyr.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -c -o libxephyr_a-ephyr.obj `if test -f 'ephyr.c'; then $(CYGPATH_W) 'ephyr.c'; else $(CYGPATH_W) '$(srcdir)/ephyr.c'; fi`
+
+libxephyr_a-ephyr_draw.o: ephyr_draw.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -MT libxephyr_a-ephyr_draw.o -MD -MP -MF $(DEPDIR)/libxephyr_a-ephyr_draw.Tpo -c -o libxephyr_a-ephyr_draw.o `test -f 'ephyr_draw.c' || echo '$(srcdir)/'`ephyr_draw.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_a-ephyr_draw.Tpo $(DEPDIR)/libxephyr_a-ephyr_draw.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ephyr_draw.c' object='libxephyr_a-ephyr_draw.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -c -o libxephyr_a-ephyr_draw.o `test -f 'ephyr_draw.c' || echo '$(srcdir)/'`ephyr_draw.c
+
+libxephyr_a-ephyr_draw.obj: ephyr_draw.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -MT libxephyr_a-ephyr_draw.obj -MD -MP -MF $(DEPDIR)/libxephyr_a-ephyr_draw.Tpo -c -o libxephyr_a-ephyr_draw.obj `if test -f 'ephyr_draw.c'; then $(CYGPATH_W) 'ephyr_draw.c'; else $(CYGPATH_W) '$(srcdir)/ephyr_draw.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_a-ephyr_draw.Tpo $(DEPDIR)/libxephyr_a-ephyr_draw.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ephyr_draw.c' object='libxephyr_a-ephyr_draw.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -c -o libxephyr_a-ephyr_draw.obj `if test -f 'ephyr_draw.c'; then $(CYGPATH_W) 'ephyr_draw.c'; else $(CYGPATH_W) '$(srcdir)/ephyr_draw.c'; fi`
+
+libxephyr_a-ephyrvideo.o: ephyrvideo.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -MT libxephyr_a-ephyrvideo.o -MD -MP -MF $(DEPDIR)/libxephyr_a-ephyrvideo.Tpo -c -o libxephyr_a-ephyrvideo.o `test -f 'ephyrvideo.c' || echo '$(srcdir)/'`ephyrvideo.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_a-ephyrvideo.Tpo $(DEPDIR)/libxephyr_a-ephyrvideo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ephyrvideo.c' object='libxephyr_a-ephyrvideo.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -c -o libxephyr_a-ephyrvideo.o `test -f 'ephyrvideo.c' || echo '$(srcdir)/'`ephyrvideo.c
+
+libxephyr_a-ephyrvideo.obj: ephyrvideo.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -MT libxephyr_a-ephyrvideo.obj -MD -MP -MF $(DEPDIR)/libxephyr_a-ephyrvideo.Tpo -c -o libxephyr_a-ephyrvideo.obj `if test -f 'ephyrvideo.c'; then $(CYGPATH_W) 'ephyrvideo.c'; else $(CYGPATH_W) '$(srcdir)/ephyrvideo.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_a-ephyrvideo.Tpo $(DEPDIR)/libxephyr_a-ephyrvideo.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ephyrvideo.c' object='libxephyr_a-ephyrvideo.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -c -o libxephyr_a-ephyrvideo.obj `if test -f 'ephyrvideo.c'; then $(CYGPATH_W) 'ephyrvideo.c'; else $(CYGPATH_W) '$(srcdir)/ephyrvideo.c'; fi`
+
+libxephyr_a-os.o: os.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -MT libxephyr_a-os.o -MD -MP -MF $(DEPDIR)/libxephyr_a-os.Tpo -c -o libxephyr_a-os.o `test -f 'os.c' || echo '$(srcdir)/'`os.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_a-os.Tpo $(DEPDIR)/libxephyr_a-os.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='os.c' object='libxephyr_a-os.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -c -o libxephyr_a-os.o `test -f 'os.c' || echo '$(srcdir)/'`os.c
+
+libxephyr_a-os.obj: os.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -MT libxephyr_a-os.obj -MD -MP -MF $(DEPDIR)/libxephyr_a-os.Tpo -c -o libxephyr_a-os.obj `if test -f 'os.c'; then $(CYGPATH_W) 'os.c'; else $(CYGPATH_W) '$(srcdir)/os.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libxephyr_a-os.Tpo $(DEPDIR)/libxephyr_a-os.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='os.c' object='libxephyr_a-os.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libxephyr_a_CFLAGS) $(CFLAGS) -c -o libxephyr_a-os.obj `if test -f 'os.c'; then $(CYGPATH_W) 'os.c'; else $(CYGPATH_W) '$(srcdir)/os.c'; fi`
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/ephyr/README b/xorg-server/hw/kdrive/ephyr/README
new file mode 100644
index 000000000..6d6a222ef
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/README
@@ -0,0 +1,73 @@
+Xephyr README
+=============
+
+
+What Is It ?
+============
+
+Xephyr is a a kdrive server that outputs to a window on a pre-existing
+'host' X display. Think Xnest but with support for modern extensions
+like composite, damage and randr.
+
+Unlike Xnest which is an X proxy, i.e. limited to the
+capabilities of the host X server, Xephyr is a real X server which
+uses the host X server window as "framebuffer" via fast SHM XImages.
+
+It also has support for 'visually' debugging what the server is
+painting.
+
+
+How To Use
+==========
+
+You probably want to run like;
+
+Xephyr :1 -ac -screen 800x600 &
+
+Then set DISPLAY=:1 and run whatever X apps you like.
+
+Use 'xrandr' to change to orientation/size.
+
+There is a '-parent' switch which works just like Xnests ( for use
+with things like matchbox-nest - http://matchbox.handhelds.org ).
+
+There is also a '-host-cursor' switch to set 'cursor acceleration' -
+The host's cursor is reused. This is only really there to aid
+debugging by avoiding server paints for the cursor. Performance
+improvement is negiable.
+
+Send a SIGUSR1 to the server ( eg kill -USR1 `pidof Xephyr` ) to
+toggle the debugging mode. In this mode red rectangles are painted to
+screen areas getting painted before painting the actual content. The
+delay between this can be altered by setting a XEPHYR_PAUSE env var to
+a value in micro seconds.
+
+
+Caveats
+=======
+
+ - Depth is limited to being the same as the host.
+ *Update* As of 8/11/2004. Xephyr can now do 8bpp & 16bpp
+ on 24bpp host.
+
+ - Rotated displays are currently updated via full blits. This
+ is slower than a normal oprientated display. Debug mode will
+ therefor not be of much use rotated.
+
+ - The '-host-cursor' cursor is static in its appearence.
+
+ - The build gets a warning about 'nanosleep'. I think the various '-D'
+ build flags are causing this. I havn't figured as yet how to work
+ round it. It doesn't appear to break anything however.
+
+ - Keyboard handling is basic but works.
+
+ - Mouse button 5 probably wont work.
+
+
+
+
+
+Matthew Allum <mallum@o-hand.com> 2004
+
+
diff --git a/xorg-server/hw/kdrive/ephyr/XF86dri.c b/xorg-server/hw/kdrive/ephyr/XF86dri.c
new file mode 100644
index 000000000..63e630c9c
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/XF86dri.c
@@ -0,0 +1,654 @@
+/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.13 2002/10/30 12:51:25 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Jens Owen <jens@tungstengraphics.com>
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+/*
+ * This file has been copied from the mesa source tree and a little bit
+ * modified by:
+ *
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+/*
+ * including some server headers (like kdrive-config.h)
+ * might define the macro _XSERVER64
+ * on 64 bits machines. That macro must _NOT_ be defined for Xlib
+ * client code, otherwise bad things happen.
+ * So let's undef that macro if necessary.
+ */
+#ifdef _XSERVER64
+#undef _XSERVER64
+#endif
+
+#ifdef XEPHYR_DRI
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <GL/glx.h>
+#include <X11/dri/xf86dri.h>
+#include <X11/dri/xf86dristr.h>
+#include "GL/internal/dri_interface.h"
+
+static XExtensionInfo _xf86dri_info_data;
+static XExtensionInfo *xf86dri_info = &_xf86dri_info_data;
+static char xf86dri_extension_name[] = XF86DRINAME;
+
+#define XF86DRICheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xf86dri_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *extCodes);
+static /* const */ XExtensionHooks xf86dri_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xf86dri_info,
+ xf86dri_extension_name,
+ &xf86dri_extension_hooks,
+ 0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info)
+
+
+/*****************************************************************************
+ * *
+ * public XFree86-DRI Extension routines *
+ * *
+ *****************************************************************************/
+
+#if 0
+#include <stdio.h>
+#define TRACE(msg) fprintf(stderr,"XF86DRI%s\n", msg);
+#else
+#define TRACE(msg)
+#endif
+
+Bool XF86DRIOpenFullScreen(Display *dpy, int screen, Drawable drawable);
+Bool XF86DRICloseFullScreen(Display *dpy, int screen, Drawable drawable);
+
+Bool XF86DRIQueryExtension (Display *dpy, int *event_basep, int *error_basep)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ TRACE("QueryExtension...");
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ TRACE("QueryExtension... return True");
+ return True;
+ } else {
+ TRACE("QueryExtension... return False");
+ return False;
+ }
+}
+
+Bool XF86DRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
+ Display* dpy;
+ int* majorVersion;
+ int* minorVersion;
+ int* patchVersion;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIQueryVersionReply rep;
+ xXF86DRIQueryVersionReq *req;
+
+ TRACE("QueryVersion...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return False");
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ *patchVersion = rep.patchVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return True");
+ return True;
+}
+
+Bool
+XF86DRIQueryDirectRenderingCapable (Display *dpy, int screen, Bool *isCapable)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIQueryDirectRenderingCapableReply rep;
+ xXF86DRIQueryDirectRenderingCapableReq *req;
+
+ TRACE("QueryDirectRenderingCapable...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIQueryDirectRenderingCapable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIQueryDirectRenderingCapable;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryDirectRenderingCapable... return False");
+ return False;
+ }
+ *isCapable = rep.isCapable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryDirectRenderingCapable... return True");
+ return True;
+}
+
+Bool
+XF86DRIOpenConnection (Display *dpy, int screen,
+ drm_handle_t *hSAREA,
+ char **busIdString)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIOpenConnectionReply rep;
+ xXF86DRIOpenConnectionReq *req;
+
+ TRACE("OpenConnection...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIOpenConnection, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIOpenConnection;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("OpenConnection... return False");
+ return False;
+ }
+
+ *hSAREA = rep.hSAREALow;
+ if (sizeof(drm_handle_t) == 8) {
+ int shift = 32; /* var to prevent warning on next line */
+ *hSAREA |= ((drm_handle_t) rep.hSAREAHigh) << shift;
+ }
+
+ if (rep.length) {
+ if (!(*busIdString = (char *)Xcalloc(rep.busIdStringLength + 1, 1))) {
+ _XEatData(dpy, ((rep.busIdStringLength+3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("OpenConnection... return False");
+ return False;
+ }
+ _XReadPad(dpy, *busIdString, rep.busIdStringLength);
+ } else {
+ *busIdString = NULL;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("OpenConnection... return True");
+ return True;
+}
+
+Bool XF86DRIAuthConnection(dpy, screen, magic)
+ Display* dpy;
+ int screen;
+ drm_magic_t magic;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIAuthConnectionReq *req;
+ xXF86DRIAuthConnectionReply rep;
+
+ TRACE("AuthConnection...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIAuthConnection, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIAuthConnection;
+ req->screen = screen;
+ req->magic = magic;
+ rep.authenticated = 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.authenticated) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("AuthConnection... return False");
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("AuthConnection... return True");
+ return True;
+}
+
+Bool XF86DRICloseConnection(dpy, screen)
+ Display* dpy;
+ int screen;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRICloseConnectionReq *req;
+
+ TRACE("CloseConnection...");
+
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRICloseConnection, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRICloseConnection;
+ req->screen = screen;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CloseConnection... return True");
+ return True;
+}
+
+Bool XF86DRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion,
+ ddxDriverMinorVersion, ddxDriverPatchVersion, clientDriverName)
+ Display* dpy;
+ int screen;
+ int* ddxDriverMajorVersion;
+ int* ddxDriverMinorVersion;
+ int* ddxDriverPatchVersion;
+ char** clientDriverName;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIGetClientDriverNameReply rep;
+ xXF86DRIGetClientDriverNameReq *req;
+
+ TRACE("GetClientDriverName...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIGetClientDriverName, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIGetClientDriverName;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetClientDriverName... return False");
+ return False;
+ }
+
+ *ddxDriverMajorVersion = rep.ddxDriverMajorVersion;
+ *ddxDriverMinorVersion = rep.ddxDriverMinorVersion;
+ *ddxDriverPatchVersion = rep.ddxDriverPatchVersion;
+
+ if (rep.length) {
+ if (!(*clientDriverName = (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) {
+ _XEatData(dpy, ((rep.clientDriverNameLength+3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetClientDriverName... return False");
+ return False;
+ }
+ _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength);
+ } else {
+ *clientDriverName = NULL;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetClientDriverName... return True");
+ return True;
+}
+
+Bool XF86DRICreateContextWithConfig(dpy, screen, configID, context,
+ hHWContext)
+ Display* dpy;
+ int screen;
+ int configID;
+ XID* context;
+ drm_context_t * hHWContext;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRICreateContextReply rep;
+ xXF86DRICreateContextReq *req;
+
+ TRACE("CreateContext...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRICreateContext, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRICreateContext;
+ req->visual = configID;
+ req->screen = screen;
+ *context = XAllocID(dpy);
+ req->context = *context;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateContext... return False");
+ return False;
+ }
+ *hHWContext = rep.hHWContext;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateContext... return True");
+ return True;
+}
+
+Bool XF86DRICreateContext(dpy, screen, visual, context, hHWContext)
+ Display* dpy;
+ int screen;
+ Visual* visual;
+ XID* context;
+ drm_context_t * hHWContext;
+{
+ return XF86DRICreateContextWithConfig( dpy, screen, visual->visualid,
+ context, hHWContext );
+}
+
+GLboolean XF86DRIDestroyContext( Display *dpy, int screen, XID context)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIDestroyContextReq *req;
+
+ TRACE("DestroyContext...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIDestroyContext, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIDestroyContext;
+ req->screen = screen;
+ req->context = context;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("DestroyContext... return True");
+ return True;
+}
+
+GLboolean
+XF86DRICreateDrawable (Display *dpy, int screen,
+ XID drawable, drm_drawable_t * hHWDrawable)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRICreateDrawableReply rep;
+ xXF86DRICreateDrawableReq *req;
+
+ TRACE("CreateDrawable...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRICreateDrawable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRICreateDrawable;
+ req->screen = screen;
+ req->drawable = drawable;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateDrawable... return False");
+ return False;
+ }
+ *hHWDrawable = rep.hHWDrawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateDrawable... return True");
+ return True;
+}
+
+static int noopErrorHandler(Display *dpy, XErrorEvent *xerr)
+{
+ return 0;
+}
+
+GLboolean XF86DRIDestroyDrawable( Display *dpy, int screen,
+ XID drawable )
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIDestroyDrawableReq *req;
+ int (*oldXErrorHandler)(Display *, XErrorEvent *);
+
+ TRACE("DestroyDrawable...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ /* This is called from the DRI driver, which used call it like this
+ *
+ * if (windowExists(drawable))
+ * destroyDrawable(drawable);
+ *
+ * which is a textbook race condition - the window may disappear
+ * from the server between checking for its existance and
+ * destroying it. Instead we change the semantics of
+ * __DRIinterfaceMethodsRec::destroyDrawable() to succeed even if
+ * the windows is gone, by wrapping the destroy call in an error
+ * handler. */
+
+ XSync(dpy, GL_FALSE);
+ oldXErrorHandler = XSetErrorHandler(noopErrorHandler);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIDestroyDrawable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIDestroyDrawable;
+ req->screen = screen;
+ req->drawable = drawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ XSetErrorHandler(oldXErrorHandler);
+
+ TRACE("DestroyDrawable... return True");
+ return True;
+}
+
+Bool XF86DRIGetDrawableInfo(Display* dpy, int screen, Drawable drawable,
+ 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 )
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIGetDrawableInfoReply rep;
+ xXF86DRIGetDrawableInfoReq *req=NULL;
+ int total_rects;
+
+ TRACE("GetDrawableInfo...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIGetDrawableInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIGetDrawableInfo;
+ req->screen = screen;
+ req->drawable = drawable;
+
+ if (!_XReply(dpy, (xReply *)&rep, 1, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return False");
+ return False;
+ }
+ *index = rep.drawableTableIndex;
+ *stamp = rep.drawableTableStamp;
+ *X = (int)rep.drawableX;
+ *Y = (int)rep.drawableY;
+ *W = (int)rep.drawableWidth;
+ *H = (int)rep.drawableHeight;
+ *numClipRects = rep.numClipRects;
+ total_rects = *numClipRects;
+
+ *backX = rep.backX;
+ *backY = rep.backY;
+ *numBackClipRects = rep.numBackClipRects;
+ total_rects += *numBackClipRects;
+
+#if 0
+ /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks
+ * backwards compatibility (Because of the >> 2 shift) but the fix
+ * enables multi-threaded apps to work.
+ */
+ if (rep.length != ((((SIZEOF(xXF86DRIGetDrawableInfoReply) -
+ SIZEOF(xGenericReply) +
+ total_rects * sizeof(drm_clip_rect_t)) + 3) & ~3) >> 2)) {
+ _XEatData(dpy, rep.length);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return False");
+ return False;
+ }
+#endif
+
+ if (*numClipRects) {
+ int len = sizeof(drm_clip_rect_t) * (*numClipRects);
+
+ *pClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
+ if (*pClipRects)
+ _XRead(dpy, (char*)*pClipRects, len);
+ } else {
+ *pClipRects = NULL;
+ }
+
+ if (*numBackClipRects) {
+ int len = sizeof(drm_clip_rect_t) * (*numBackClipRects);
+
+ *pBackClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
+ if (*pBackClipRects)
+ _XRead(dpy, (char*)*pBackClipRects, len);
+ } else {
+ *pBackClipRects = NULL;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return True");
+ return True;
+}
+
+Bool
+XF86DRIGetDeviceInfo (Display *dpy, int screen, drm_handle_t *hFrameBuffer,
+ int *fbOrigin, int *fbSize, int *fbStride,
+ int *devPrivateSize, void **pDevPrivate)
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIGetDeviceInfoReply rep;
+ xXF86DRIGetDeviceInfoReq *req;
+
+ TRACE("GetDeviceInfo...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIGetDeviceInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIGetDeviceInfo;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDeviceInfo... return False");
+ return False;
+ }
+
+ *hFrameBuffer = rep.hFrameBufferLow;
+ if (sizeof(drm_handle_t) == 8) {
+ int shift = 32; /* var to prevent warning on next line */
+ *hFrameBuffer |= ((drm_handle_t) rep.hFrameBufferHigh) << shift;
+ }
+
+ *fbOrigin = rep.framebufferOrigin;
+ *fbSize = rep.framebufferSize;
+ *fbStride = rep.framebufferStride;
+ *devPrivateSize = rep.devPrivateSize;
+
+ if (rep.length) {
+ if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) {
+ _XEatData(dpy, ((rep.devPrivateSize+3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDeviceInfo... return False");
+ return False;
+ }
+ _XRead(dpy, (char*)*pDevPrivate, rep.devPrivateSize);
+ } else {
+ *pDevPrivate = NULL;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDeviceInfo... return True");
+ return True;
+}
+
+Bool
+XF86DRIOpenFullScreen(Display *dpy, int screen, Drawable drawable)
+{
+ /* This function and the underlying X protocol are deprecated.
+ */
+ (void) dpy;
+ (void) screen;
+ (void) drawable;
+ return False;
+}
+
+Bool
+XF86DRICloseFullScreen(Display *dpy, int screen, Drawable drawable)
+{
+ /* This function and the underlying X protocol are deprecated.
+ */
+ (void) dpy;
+ (void) screen;
+ (void) drawable;
+ return True;
+}
+#endif /*EPHYR_DRI*/
+
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr.c b/xorg-server/hw/kdrive/ephyr/ephyr.c
new file mode 100644
index 000000000..b02f9903c
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyr.c
@@ -0,0 +1,1155 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2004 Nokia
+ *
+ * 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 Nokia not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Nokia makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "ephyr.h"
+
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "ephyrlog.h"
+
+#ifdef XEPHYR_DRI
+#include "ephyrdri.h"
+#include "ephyrdriext.h"
+#include "ephyrglxext.h"
+#endif /*XEPHYR_DRI*/
+
+extern int KdTsPhyScreen;
+#ifdef GLXEXT
+extern Bool noGlxVisualInit;
+#endif
+
+KdKeyboardInfo *ephyrKbd;
+KdPointerInfo *ephyrMouse;
+EphyrKeySyms ephyrKeySyms;
+Bool ephyrNoDRI=FALSE ;
+Bool ephyrNoXV=FALSE ;
+
+static int mouseState = 0;
+
+typedef struct _EphyrInputPrivate {
+ Bool enabled;
+} EphyrKbdPrivate, EphyrPointerPrivate;
+
+Bool EphyrWantGrayScale = 0;
+
+
+Bool
+ephyrInitialize (KdCardInfo *card, EphyrPriv *priv)
+{
+ OsSignal(SIGUSR1, hostx_handle_signal);
+
+ priv->base = 0;
+ priv->bytes_per_line = 0;
+ return TRUE;
+}
+
+Bool
+ephyrCardInit (KdCardInfo *card)
+{
+ EphyrPriv *priv;
+
+ priv = (EphyrPriv *) xalloc (sizeof (EphyrPriv));
+ if (!priv)
+ return FALSE;
+
+ if (!ephyrInitialize (card, priv))
+ {
+ xfree (priv);
+ return FALSE;
+ }
+ card->driver = priv;
+
+ return TRUE;
+}
+
+Bool
+ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv)
+{
+ int width = 640, height = 480;
+ unsigned long redMask, greenMask, blueMask;
+
+ if (hostx_want_screen_size(screen, &width, &height)
+ || !screen->width || !screen->height)
+ {
+ screen->width = width;
+ screen->height = height;
+ }
+
+ if (EphyrWantGrayScale)
+ screen->fb[0].depth = 8;
+
+ if (screen->fb[0].depth && screen->fb[0].depth != hostx_get_depth())
+ {
+ if (screen->fb[0].depth < hostx_get_depth()
+ && (screen->fb[0].depth == 24 || screen->fb[0].depth == 16
+ || screen->fb[0].depth == 8))
+ {
+ hostx_set_server_depth(screen, screen->fb[0].depth);
+ }
+ else
+ ErrorF("\nXephyr: requested screen depth not supported, setting to match hosts.\n");
+ }
+
+ screen->fb[0].depth = hostx_get_server_depth(screen);
+ screen->rate = 72;
+
+ if (screen->fb[0].depth <= 8)
+ {
+ if (EphyrWantGrayScale)
+ screen->fb[0].visuals = ((1 << StaticGray) | (1 << GrayScale));
+ else
+ screen->fb[0].visuals = ((1 << StaticGray) |
+ (1 << GrayScale) |
+ (1 << StaticColor) |
+ (1 << PseudoColor) |
+ (1 << TrueColor) |
+ (1 << DirectColor));
+
+ screen->fb[0].redMask = 0x00;
+ screen->fb[0].greenMask = 0x00;
+ screen->fb[0].blueMask = 0x00;
+ screen->fb[0].depth = 8;
+ screen->fb[0].bitsPerPixel = 8;
+ }
+ else
+ {
+ screen->fb[0].visuals = (1 << TrueColor);
+
+ if (screen->fb[0].depth <= 15)
+ {
+ screen->fb[0].depth = 15;
+ screen->fb[0].bitsPerPixel = 16;
+ }
+ else if (screen->fb[0].depth <= 16)
+ {
+ screen->fb[0].depth = 16;
+ screen->fb[0].bitsPerPixel = 16;
+ }
+ else
+ {
+ screen->fb[0].depth = 24;
+ screen->fb[0].bitsPerPixel = 32;
+ }
+
+ hostx_get_visual_masks (screen, &redMask, &greenMask, &blueMask);
+
+ screen->fb[0].redMask = (Pixel) redMask;
+ screen->fb[0].greenMask = (Pixel) greenMask;
+ screen->fb[0].blueMask = (Pixel) blueMask;
+
+ }
+
+ scrpriv->randr = screen->randr;
+
+ return ephyrMapFramebuffer (screen);
+}
+
+Bool
+ephyrScreenInit (KdScreenInfo *screen)
+{
+ EphyrScrPriv *scrpriv;
+
+ scrpriv = xalloc (sizeof (EphyrScrPriv));
+
+ if (!scrpriv)
+ return FALSE;
+
+ memset (scrpriv, 0, sizeof (EphyrScrPriv));
+ screen->driver = scrpriv;
+
+ if (!ephyrScreenInitialize (screen, scrpriv))
+ {
+ screen->driver = 0;
+ xfree (scrpriv);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+void*
+ephyrWindowLinear (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure)
+{
+ KdScreenPriv(pScreen);
+ EphyrPriv *priv = pScreenPriv->card->driver;
+
+ if (!pScreenPriv->enabled)
+ return 0;
+
+ *size = priv->bytes_per_line;
+ return priv->base + row * priv->bytes_per_line + offset;
+}
+
+Bool
+ephyrMapFramebuffer (KdScreenInfo *screen)
+{
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrPriv *priv = screen->card->driver;
+ KdPointerMatrix m;
+ int buffer_height;
+
+ EPHYR_LOG("screen->width: %d, screen->height: %d index=%d",
+ screen->width, screen->height, screen->mynum);
+
+ KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
+ KdSetPointerMatrix (&m);
+
+ priv->bytes_per_line = ((screen->width * screen->fb[0].bitsPerPixel + 31) >> 5) << 2;
+
+ /* point the framebuffer to the data in an XImage */
+ /* If fakexa is enabled, allocate a larger buffer so that fakexa has space to
+ * put offscreen pixmaps.
+ */
+ if (ephyrFuncs.initAccel == NULL)
+ buffer_height = screen->height;
+ else
+ buffer_height = 3 * screen->height;
+
+ priv->base = hostx_screen_init (screen, screen->width, screen->height, buffer_height);
+
+ screen->memory_base = (CARD8 *) (priv->base);
+ screen->memory_size = priv->bytes_per_line * buffer_height;
+ screen->off_screen_base = priv->bytes_per_line * screen->height;
+
+ if ((scrpriv->randr & RR_Rotate_0) && !(scrpriv->randr & RR_Reflect_All))
+ {
+ scrpriv->shadow = FALSE;
+
+ screen->fb[0].byteStride = priv->bytes_per_line;
+ screen->fb[0].pixelStride = screen->width;
+ screen->fb[0].frameBuffer = (CARD8 *) (priv->base);
+ }
+ else
+ {
+ /* Rotated/Reflected so we need to use shadow fb */
+ scrpriv->shadow = TRUE;
+
+ EPHYR_LOG("allocing shadow");
+
+ KdShadowFbAlloc (screen, 0,
+ scrpriv->randr & (RR_Rotate_90|RR_Rotate_270));
+ }
+
+ return TRUE;
+}
+
+void
+ephyrSetScreenSizes (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+
+ if (scrpriv->randr & (RR_Rotate_0|RR_Rotate_180))
+ {
+ pScreen->width = screen->width;
+ pScreen->height = screen->height;
+ pScreen->mmWidth = screen->width_mm;
+ pScreen->mmHeight = screen->height_mm;
+ }
+ else
+ {
+ pScreen->width = screen->height;
+ pScreen->height = screen->width;
+ pScreen->mmWidth = screen->height_mm;
+ pScreen->mmHeight = screen->width_mm;
+ }
+}
+
+Bool
+ephyrUnmapFramebuffer (KdScreenInfo *screen)
+{
+ EphyrScrPriv *scrpriv = screen->driver;
+
+ if (scrpriv->shadow)
+ KdShadowFbFree (screen, 0);
+
+ /* Note, priv->base will get freed when XImage recreated */
+
+ return TRUE;
+}
+
+void
+ephyrShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+
+ EPHYR_LOG("slow paint");
+
+ /* FIXME: Slow Rotated/Reflected updates could be much
+ * much faster efficiently updating via tranforming
+ * pBuf->pDamage regions
+ */
+ shadowUpdateRotatePacked(pScreen, pBuf);
+ hostx_paint_rect(screen, 0,0,0,0, screen->width, screen->height);
+}
+
+static void
+ephyrInternalDamageRedisplay (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ RegionPtr pRegion;
+
+ if (!scrpriv || !scrpriv->pDamage)
+ return;
+
+ pRegion = DamageRegion (scrpriv->pDamage);
+
+ if (REGION_NOTEMPTY (pScreen, pRegion))
+ {
+ int nbox;
+ BoxPtr pbox;
+
+ nbox = REGION_NUM_RECTS (pRegion);
+ pbox = REGION_RECTS (pRegion);
+
+ while (nbox--)
+ {
+ hostx_paint_rect(screen,
+ pbox->x1, pbox->y1,
+ pbox->x1, pbox->y1,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ pbox++;
+ }
+ DamageEmpty (scrpriv->pDamage);
+ }
+}
+
+static void
+ephyrInternalDamageBlockHandler (pointer data,
+ OSTimePtr pTimeout,
+ pointer pRead)
+{
+ ScreenPtr pScreen = (ScreenPtr) data;
+
+ ephyrInternalDamageRedisplay (pScreen);
+}
+
+static void
+ephyrInternalDamageWakeupHandler (pointer data, int i, pointer LastSelectMask)
+{
+ /* FIXME: Not needed ? */
+}
+
+Bool
+ephyrSetInternalDamage (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ PixmapPtr pPixmap = NULL;
+
+ scrpriv->pDamage = DamageCreate ((DamageReportFunc) 0,
+ (DamageDestroyFunc) 0,
+ DamageReportNone,
+ TRUE,
+ pScreen,
+ pScreen);
+
+ if (!RegisterBlockAndWakeupHandlers (ephyrInternalDamageBlockHandler,
+ ephyrInternalDamageWakeupHandler,
+ (pointer) pScreen))
+ return FALSE;
+
+ pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
+
+ DamageRegister (&pPixmap->drawable, scrpriv->pDamage);
+
+ return TRUE;
+}
+
+void
+ephyrUnsetInternalDamage (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ PixmapPtr pPixmap = NULL;
+
+ pPixmap = (*pScreen->GetScreenPixmap) (pScreen);
+ DamageUnregister (&pPixmap->drawable, scrpriv->pDamage);
+ DamageDestroy (scrpriv->pDamage);
+
+ RemoveBlockAndWakeupHandlers (ephyrInternalDamageBlockHandler,
+ ephyrInternalDamageWakeupHandler,
+ (pointer) pScreen);
+}
+
+#ifdef RANDR
+Bool
+ephyrRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ RRScreenSizePtr pSize;
+ Rotation randr;
+ int n = 0;
+
+ EPHYR_LOG("mark");
+
+ struct { int width, height; } sizes[] =
+ {
+ { 1600, 1200 },
+ { 1400, 1050 },
+ { 1280, 960 },
+ { 1280, 1024 },
+ { 1152, 864 },
+ { 1024, 768 },
+ { 832, 624 },
+ { 800, 600 },
+ { 720, 400 },
+ { 480, 640 },
+ { 640, 480 },
+ { 640, 400 },
+ { 320, 240 },
+ { 240, 320 },
+ { 160, 160 },
+ { 0, 0 }
+ };
+
+ *rotations = RR_Rotate_All|RR_Reflect_All;
+
+ if (!hostx_want_preexisting_window (screen)
+ && !hostx_want_fullscreen ()) /* only if no -parent switch */
+ {
+ while (sizes[n].width != 0 && sizes[n].height != 0)
+ {
+ RRRegisterSize (pScreen,
+ sizes[n].width,
+ sizes[n].height,
+ (sizes[n].width * screen->width_mm)/screen->width,
+ (sizes[n].height *screen->height_mm)/screen->height
+ );
+ n++;
+ }
+ }
+
+ pSize = RRRegisterSize (pScreen,
+ screen->width,
+ screen->height,
+ screen->width_mm,
+ screen->height_mm);
+
+ randr = KdSubRotation (scrpriv->randr, screen->randr);
+
+ RRSetCurrentConfig (pScreen, randr, 0, pSize);
+
+ return TRUE;
+}
+
+Bool
+ephyrRandRSetConfig (ScreenPtr pScreen,
+ Rotation randr,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ Bool wasEnabled = pScreenPriv->enabled;
+ EphyrScrPriv oldscr;
+ int oldwidth, oldheight, oldmmwidth, oldmmheight;
+ Bool oldshadow;
+ int newwidth, newheight;
+
+ if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
+ {
+ newwidth = pSize->width;
+ newheight = pSize->height;
+ }
+ else
+ {
+ newwidth = pSize->height;
+ newheight = pSize->width;
+ }
+
+ if (wasEnabled)
+ KdDisableScreen (pScreen);
+
+ oldscr = *scrpriv;
+
+ oldwidth = screen->width;
+ oldheight = screen->height;
+ oldmmwidth = pScreen->mmWidth;
+ oldmmheight = pScreen->mmHeight;
+ oldshadow = scrpriv->shadow;
+
+ /*
+ * Set new configuration
+ */
+
+ scrpriv->randr = KdAddRotation (screen->randr, randr);
+
+ KdOffscreenSwapOut (screen->pScreen);
+
+ ephyrUnmapFramebuffer (screen);
+
+ screen->width = newwidth;
+ screen->height = newheight;
+
+ if (!ephyrMapFramebuffer (screen))
+ goto bail4;
+
+ /* FIXME below should go in own call */
+
+ if (oldshadow)
+ KdShadowUnset (screen->pScreen);
+ else
+ ephyrUnsetInternalDamage(screen->pScreen);
+
+ if (scrpriv->shadow)
+ {
+ if (!KdShadowSet (screen->pScreen,
+ scrpriv->randr,
+ ephyrShadowUpdate,
+ ephyrWindowLinear))
+ goto bail4;
+ }
+ else
+ {
+ /* Without shadow fb ( non rotated ) we need
+ * to use damage to efficiently update display
+ * via signal regions what to copy from 'fb'.
+ */
+ if (!ephyrSetInternalDamage(screen->pScreen))
+ goto bail4;
+ }
+
+ ephyrSetScreenSizes (screen->pScreen);
+
+ /*
+ * Set frame buffer mapping
+ */
+ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
+ pScreen->width,
+ pScreen->height,
+ screen->fb[0].depth,
+ screen->fb[0].bitsPerPixel,
+ screen->fb[0].byteStride,
+ screen->fb[0].frameBuffer);
+
+ /* set the subpixel order */
+
+ KdSetSubpixelOrder (pScreen, scrpriv->randr);
+
+ if (wasEnabled)
+ KdEnableScreen (pScreen);
+
+ return TRUE;
+
+ bail4:
+ EPHYR_LOG("bailed");
+
+ ephyrUnmapFramebuffer (screen);
+ *scrpriv = oldscr;
+ (void) ephyrMapFramebuffer (screen);
+
+ pScreen->width = oldwidth;
+ pScreen->height = oldheight;
+ pScreen->mmWidth = oldmmwidth;
+ pScreen->mmHeight = oldmmheight;
+
+ if (wasEnabled)
+ KdEnableScreen (pScreen);
+ return FALSE;
+}
+
+Bool
+ephyrRandRInit (ScreenPtr pScreen)
+{
+ rrScrPrivPtr pScrPriv;
+
+ if (!RRScreenInit (pScreen))
+ return FALSE;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+ pScrPriv->rrGetInfo = ephyrRandRGetInfo;
+ pScrPriv->rrSetConfig = ephyrRandRSetConfig;
+ return TRUE;
+}
+#endif
+
+Bool
+ephyrCreateColormap (ColormapPtr pmap)
+{
+ return fbInitializeColormap (pmap);
+}
+
+Bool
+ephyrInitScreen (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+
+ EPHYR_LOG ("pScreen->myNum:%d\n", pScreen->myNum) ;
+ hostx_set_screen_number (screen, pScreen->myNum);
+ hostx_set_win_title (screen, "(ctrl+shift grabs mouse and keyboard)") ;
+ pScreen->CreateColormap = ephyrCreateColormap;
+
+#ifdef XV
+ if (!ephyrNoXV) {
+ if (!ephyrInitVideo (pScreen)) {
+ EPHYR_LOG_ERROR ("failed to initialize xvideo\n") ;
+ } else {
+ EPHYR_LOG ("initialized xvideo okay\n") ;
+ }
+ }
+#endif /*XV*/
+
+#ifdef XEPHYR_DRI
+ if (!ephyrNoDRI && !hostx_has_dri ()) {
+ EPHYR_LOG ("host x does not support DRI. Disabling DRI forwarding\n") ;
+ ephyrNoDRI = TRUE ;
+#ifdef GLXEXT
+ noGlxVisualInit = FALSE ;
+#endif
+ }
+ if (!ephyrNoDRI) {
+ ephyrDRIExtensionInit (pScreen) ;
+ ephyrHijackGLXExtension () ;
+ }
+#endif
+
+#ifdef GLXEXT
+ if (ephyrNoDRI) {
+ noGlxVisualInit = FALSE ;
+ }
+#endif
+
+ return TRUE;
+}
+
+Bool
+ephyrFinishInitScreen (ScreenPtr pScreen)
+{
+ /* FIXME: Calling this even if not using shadow.
+ * Seems harmless enough. But may be safer elsewhere.
+ */
+ if (!shadowSetup (pScreen))
+ return FALSE;
+
+#ifdef RANDR
+ if (!ephyrRandRInit (pScreen))
+ return FALSE;
+#endif
+
+ return TRUE;
+}
+
+Bool
+ephyrCreateResources (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+
+ EPHYR_LOG("mark pScreen=%p mynum=%d shadow=%d",
+ pScreen, pScreen->myNum, scrpriv->shadow);
+
+ if (scrpriv->shadow)
+ return KdShadowSet (pScreen,
+ scrpriv->randr,
+ ephyrShadowUpdate,
+ ephyrWindowLinear);
+ else
+ return ephyrSetInternalDamage(pScreen);
+}
+
+void
+ephyrPreserve (KdCardInfo *card)
+{
+}
+
+Bool
+ephyrEnable (ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+Bool
+ephyrDPMS (ScreenPtr pScreen, int mode)
+{
+ return TRUE;
+}
+
+void
+ephyrDisable (ScreenPtr pScreen)
+{
+}
+
+void
+ephyrRestore (KdCardInfo *card)
+{
+}
+
+void
+ephyrScreenFini (KdScreenInfo *screen)
+{
+ EphyrScrPriv *scrpriv = screen->driver;
+ if (scrpriv->shadow) {
+ KdShadowFbFree (screen, 0);
+ }
+ xfree(screen->driver);
+ screen->driver = NULL;
+}
+
+/*
+ * Port of Mark McLoughlin's Xnest fix for focus in + modifier bug.
+ * See https://bugs.freedesktop.org/show_bug.cgi?id=3030
+ */
+void
+ephyrUpdateModifierState(unsigned int state)
+{
+ DeviceIntPtr pkeydev;
+ KeyClassPtr keyc;
+ int i;
+ CARD8 mask;
+
+ pkeydev = inputInfo.keyboard;
+
+ if (!pkeydev)
+ return;
+
+ keyc = pkeydev->key;
+
+ state = state & 0xff;
+
+ if (keyc->state == state)
+ return;
+
+ for (i = 0, mask = 1; i < 8; i++, mask <<= 1)
+ {
+ int key;
+
+ /* Modifier is down, but shouldn't be */
+ if ((keyc->state & mask) && !(state & mask))
+ {
+ int count = keyc->modifierKeyCount[i];
+
+ for (key = 0; key < MAP_LENGTH; key++)
+ if (keyc->modifierMap[key] & mask)
+ {
+ int bit;
+ BYTE *kptr;
+
+ kptr = &keyc->down[key >> 3];
+ bit = 1 << (key & 7);
+
+ if (*kptr & bit && ephyrKbd &&
+ ((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
+ KdEnqueueKeyboardEvent(ephyrKbd, key, TRUE); /* release */
+
+ if (--count == 0)
+ break;
+ }
+ }
+
+ /* Modifier shoud be down, but isn't */
+ if (!(keyc->state & mask) && (state & mask))
+ for (key = 0; key < MAP_LENGTH; key++)
+ if (keyc->modifierMap[key] & mask)
+ {
+ if (keyc->modifierMap[key] & mask && ephyrKbd &&
+ ((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
+ KdEnqueueKeyboardEvent(ephyrKbd, key, FALSE); /* press */
+ break;
+ }
+ }
+}
+
+static void
+ephyrBlockSigio (void)
+{
+ sigset_t set;
+
+ sigemptyset (&set);
+ sigaddset (&set, SIGIO);
+ sigprocmask (SIG_BLOCK, &set, 0);
+}
+
+static void
+ephyrUnblockSigio (void)
+{
+ sigset_t set;
+
+ sigemptyset (&set);
+ sigaddset (&set, SIGIO);
+ sigprocmask (SIG_UNBLOCK, &set, 0);
+}
+
+static Bool
+ephyrCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
+{
+ return FALSE;
+}
+
+static void
+ephyrCrossScreen (ScreenPtr pScreen, Bool entering)
+{
+}
+
+int ephyrCurScreen; /*current event screen*/
+
+static void
+ephyrWarpCursor (ScreenPtr pScreen, int x, int y)
+{
+ ephyrBlockSigio ();
+ ephyrCurScreen = pScreen->myNum;
+ miPointerWarpCursor (pScreen, x, y);
+ ephyrUnblockSigio ();
+}
+
+miPointerScreenFuncRec ephyrPointerScreenFuncs =
+{
+ ephyrCursorOffScreen,
+ ephyrCrossScreen,
+ ephyrWarpCursor
+};
+
+#ifdef XEPHYR_DRI
+/**
+ * find if the remote window denoted by a_remote
+ * is paired with an internal Window within the Xephyr server.
+ * If the remove window is paired with an internal window, send an
+ * expose event to the client insterested in the internal window expose event.
+ *
+ * Pairing happens when a drawable inside Xephyr is associated with
+ * a GL surface in a DRI environment.
+ * Look at the function ProcXF86DRICreateDrawable in ephyrdriext.c to
+ * know a paired window is created.
+ *
+ * This is useful to make GL drawables (only windows for now) handle
+ * expose events and send those events to clients.
+ */
+static void
+ephyrExposePairedWindow (int a_remote)
+{
+ EphyrWindowPair *pair = NULL;
+ RegionRec reg;
+ ScreenPtr screen;
+
+ if (!findWindowPairFromRemote (a_remote, &pair)) {
+ EPHYR_LOG ("did not find a pair for this window\n");
+ return;
+ }
+ screen = pair->local->drawable.pScreen;
+ REGION_NULL (screen, &reg);
+ REGION_COPY (screen, &reg, &pair->local->clipList);
+ screen->WindowExposures (pair->local, &reg, NullRegion);
+ REGION_UNINIT (screen, &reg);
+}
+#endif /*XEPHYR_DRI*/
+
+void
+ephyrPoll(void)
+{
+ EphyrHostXEvent ev;
+
+ while (hostx_get_event(&ev))
+ {
+ switch (ev.type)
+ {
+ case EPHYR_EV_MOUSE_MOTION:
+ if (!ephyrMouse ||
+ !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled) {
+ EPHYR_LOG ("skipping mouse motion:%d\n", ephyrCurScreen) ;
+ continue;
+ }
+ {
+ if (ev.data.mouse_motion.screen >=0
+ && (ephyrCurScreen != ev.data.mouse_motion.screen))
+ {
+ EPHYR_LOG ("warping mouse cursor. "
+ "cur_screen%d, motion_screen:%d\n",
+ ephyrCurScreen, ev.data.mouse_motion.screen) ;
+ if (ev.data.mouse_motion.screen >= 0)
+ {
+ ephyrWarpCursor
+ (screenInfo.screens[ev.data.mouse_motion.screen],
+ ev.data.mouse_motion.x,
+ ev.data.mouse_motion.y );
+ }
+ }
+ else
+ {
+ int x=0, y=0;
+#ifdef XEPHYR_DRI
+ EphyrWindowPair *pair = NULL;
+#endif
+ EPHYR_LOG ("enqueuing mouse motion:%d\n", ephyrCurScreen) ;
+ x = ev.data.mouse_motion.x;
+ y = ev.data.mouse_motion.y;
+ EPHYR_LOG ("initial (x,y):(%d,%d)\n", x, y) ;
+#ifdef XEPHYR_DRI
+ EPHYR_LOG ("is this window peered by a gl drawable ?\n") ;
+ if (findWindowPairFromRemote (ev.data.mouse_motion.window,
+ &pair))
+ {
+ EPHYR_LOG ("yes, it is peered\n") ;
+ x += pair->local->drawable.x;
+ y += pair->local->drawable.y;
+ }
+ else
+ {
+ EPHYR_LOG ("no, it is not peered\n") ;
+ }
+ EPHYR_LOG ("final (x,y):(%d,%d)\n", x, y) ;
+#endif
+ KdEnqueuePointerEvent(ephyrMouse, mouseState, x, y, 0);
+ }
+ }
+ break;
+
+ case EPHYR_EV_MOUSE_PRESS:
+ if (!ephyrMouse ||
+ !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled) {
+ EPHYR_LOG ("skipping mouse press:%d\n", ephyrCurScreen) ;
+ continue;
+ }
+ EPHYR_LOG ("enqueuing mouse press:%d\n", ephyrCurScreen) ;
+ ephyrUpdateModifierState(ev.key_state);
+ mouseState |= ev.data.mouse_down.button_num;
+ KdEnqueuePointerEvent(ephyrMouse, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
+ break;
+
+ case EPHYR_EV_MOUSE_RELEASE:
+ if (!ephyrMouse ||
+ !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled)
+ continue;
+ ephyrUpdateModifierState(ev.key_state);
+ mouseState &= ~ev.data.mouse_up.button_num;
+ EPHYR_LOG ("enqueuing mouse release:%d\n", ephyrCurScreen) ;
+ KdEnqueuePointerEvent(ephyrMouse, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
+ break;
+
+ case EPHYR_EV_KEY_PRESS:
+ if (!ephyrKbd ||
+ !((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
+ continue;
+ ephyrUpdateModifierState(ev.key_state);
+ KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_down.scancode, FALSE);
+ break;
+
+ case EPHYR_EV_KEY_RELEASE:
+ if (!ephyrKbd ||
+ !((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
+ continue;
+ KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_up.scancode, TRUE);
+ break;
+
+#ifdef XEPHYR_DRI
+ case EPHYR_EV_EXPOSE:
+ /*
+ * We only receive expose events when the expose event have
+ * be generated for a drawable that is a host X window managed
+ * by Xephyr. Host X windows managed by Xephyr exists for instance
+ * when Xephyr is asked to create a GL drawable in a DRI environment.
+ */
+ ephyrExposePairedWindow (ev.data.expose.window);
+ break;
+#endif /*XEPHYR_DRI*/
+
+ default:
+ break;
+ }
+ }
+}
+
+void
+ephyrCardFini (KdCardInfo *card)
+{
+ EphyrPriv *priv = card->driver;
+ xfree (priv);
+}
+
+void
+ephyrGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ /* XXX Not sure if this is right */
+
+ EPHYR_LOG("mark");
+
+ while (n--)
+ {
+ pdefs->red = 0;
+ pdefs->green = 0;
+ pdefs->blue = 0;
+ pdefs++;
+ }
+
+}
+
+void
+ephyrPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ int min, max, p;
+
+ /* XXX Not sure if this is right */
+
+ min = 256;
+ max = 0;
+
+ while (n--)
+ {
+ p = pdefs->pixel;
+ if (p < min)
+ min = p;
+ if (p > max)
+ max = p;
+
+ hostx_set_cmap_entry(p,
+ pdefs->red >> 8,
+ pdefs->green >> 8,
+ pdefs->blue >> 8);
+ pdefs++;
+ }
+}
+
+/* Mouse calls */
+
+static Status
+MouseInit (KdPointerInfo *pi)
+{
+ pi->driverPrivate = (EphyrPointerPrivate *)
+ xcalloc(sizeof(EphyrPointerPrivate), 1);
+ ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
+ pi->nAxes = 3;
+ pi->nButtons = 32;
+ pi->name = KdSaveString("Xephyr virtual mouse");
+ ephyrMouse = pi;
+ return Success;
+}
+
+static Status
+MouseEnable (KdPointerInfo *pi)
+{
+ ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = TRUE;
+ return Success;
+}
+
+static void
+MouseDisable (KdPointerInfo *pi)
+{
+ ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
+ return;
+}
+
+static void
+MouseFini (KdPointerInfo *pi)
+{
+ ephyrMouse = NULL;
+ return;
+}
+
+KdPointerDriver EphyrMouseDriver = {
+ "ephyr",
+ MouseInit,
+ MouseEnable,
+ MouseDisable,
+ MouseFini,
+ NULL,
+};
+
+/* Keyboard */
+
+static Status
+EphyrKeyboardInit (KdKeyboardInfo *ki)
+{
+ ki->driverPrivate = (EphyrKbdPrivate *)
+ xcalloc(sizeof(EphyrKbdPrivate), 1);
+ hostx_load_keymap();
+ if (!ephyrKeySyms.map) {
+ ErrorF("Couldn't load keymap from host\n");
+ return BadAlloc;
+ }
+ ki->keySyms.minKeyCode = ephyrKeySyms.minKeyCode;
+ ki->keySyms.maxKeyCode = ephyrKeySyms.maxKeyCode;
+ ki->minScanCode = ki->keySyms.minKeyCode;
+ ki->maxScanCode = ki->keySyms.maxKeyCode;
+ ki->keySyms.mapWidth = ephyrKeySyms.mapWidth;
+ xfree(ki->keySyms.map);
+ ki->keySyms.map = ephyrKeySyms.map;
+ ki->name = KdSaveString("Xephyr virtual keyboard");
+ ephyrKbd = ki;
+ return Success;
+}
+
+static Status
+EphyrKeyboardEnable (KdKeyboardInfo *ki)
+{
+ ((EphyrKbdPrivate *)ki->driverPrivate)->enabled = TRUE;
+
+ return Success;
+}
+
+static void
+EphyrKeyboardDisable (KdKeyboardInfo *ki)
+{
+ ((EphyrKbdPrivate *)ki->driverPrivate)->enabled = FALSE;
+}
+
+static void
+EphyrKeyboardFini (KdKeyboardInfo *ki)
+{
+ /* not xfree: we call malloc from hostx.c. */
+ free(ki->keySyms.map);
+ ephyrKbd = NULL;
+ return;
+}
+
+static void
+EphyrKeyboardLeds (KdKeyboardInfo *ki, int leds)
+{
+}
+
+static void
+EphyrKeyboardBell (KdKeyboardInfo *ki, int volume, int frequency, int duration)
+{
+}
+
+
+KdKeyboardDriver EphyrKeyboardDriver = {
+ "ephyr",
+ EphyrKeyboardInit,
+ EphyrKeyboardEnable,
+ EphyrKeyboardLeds,
+ EphyrKeyboardBell,
+ EphyrKeyboardDisable,
+ EphyrKeyboardFini,
+ NULL,
+};
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr.h b/xorg-server/hw/kdrive/ephyr/ephyr.h
new file mode 100644
index 000000000..5d58a216c
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyr.h
@@ -0,0 +1,202 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@o-hand.com>
+ *
+ * Copyright © 2004 Nokia
+ *
+ * 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 Nokia not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Nokia makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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 _EPHYR_H_
+#define _EPHYR_H_
+#include <stdio.h>
+#include <unistd.h>
+#include <signal.h>
+#include <libgen.h>
+
+#include "os.h" /* for OsSignal() */
+#include "kdrive.h"
+#include "hostx.h"
+#include "exa.h"
+
+#ifdef RANDR
+#include "randrstr.h"
+#endif
+
+#include "damage.h"
+
+typedef struct _ephyrPriv {
+ CARD8 *base;
+ int bytes_per_line;
+} EphyrPriv;
+
+typedef struct _ephyrFakexaPriv {
+ ExaDriverPtr exa;
+ Bool is_synced;
+
+ /* The following are arguments and other information from Prepare* calls
+ * which are stored for use in the inner calls.
+ */
+ int op;
+ PicturePtr pSrcPicture, pMaskPicture, pDstPicture;
+ void *saved_ptrs[3];
+ PixmapPtr pDst, pSrc, pMask;
+ GCPtr pGC;
+} EphyrFakexaPriv;
+
+typedef struct _ephyrScrPriv {
+ Rotation randr;
+ Bool shadow;
+ PixmapPtr pShadow;
+ DamagePtr pDamage;
+ EphyrFakexaPriv *fakexa;
+} EphyrScrPriv;
+
+extern KdCardFuncs ephyrFuncs;
+extern KdKeyboardInfo *ephyrKbd;
+extern KdPointerInfo *ephyrMouse;
+
+extern miPointerScreenFuncRec ephyrPointerScreenFuncs;
+
+Bool
+ephyrInitialize (KdCardInfo *card, EphyrPriv *priv);
+
+Bool
+ephyrCardInit (KdCardInfo *card);
+
+Bool
+ephyrScreenInit (KdScreenInfo *screen);
+
+Bool
+ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv);
+
+Bool
+ephyrInitScreen (ScreenPtr pScreen);
+
+Bool
+ephyrFinishInitScreen (ScreenPtr pScreen);
+
+Bool
+ephyrCreateResources (ScreenPtr pScreen);
+
+void
+ephyrPreserve (KdCardInfo *card);
+
+Bool
+ephyrEnable (ScreenPtr pScreen);
+
+Bool
+ephyrDPMS (ScreenPtr pScreen, int mode);
+
+void
+ephyrDisable (ScreenPtr pScreen);
+
+void
+ephyrRestore (KdCardInfo *card);
+
+void
+ephyrScreenFini (KdScreenInfo *screen);
+
+void
+ephyrCardFini (KdCardInfo *card);
+
+void
+ephyrGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+
+void
+ephyrPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+
+Bool
+ephyrMapFramebuffer (KdScreenInfo *screen);
+
+void *
+ephyrWindowLinear (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure);
+
+void
+ephyrSetScreenSizes (ScreenPtr pScreen);
+
+Bool
+ephyrUnmapFramebuffer (KdScreenInfo *screen);
+
+void
+ephyrUnsetInternalDamage (ScreenPtr pScreen);
+
+Bool
+ephyrSetInternalDamage (ScreenPtr pScreen);
+
+Bool
+ephyrCreateColormap (ColormapPtr pmap);
+
+void
+ephyrPoll(void);
+
+#ifdef RANDR
+Bool
+ephyrRandRGetInfo (ScreenPtr pScreen, Rotation *rotations);
+
+Bool
+ephyrRandRSetConfig (ScreenPtr pScreen,
+ Rotation randr,
+ int rate,
+ RRScreenSizePtr pSize);
+Bool
+ephyrRandRInit (ScreenPtr pScreen);
+
+void
+ephyrShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf);
+
+#endif
+
+void
+ephyrUpdateModifierState(unsigned int state);
+
+extern KdPointerDriver EphyrMouseDriver;
+
+extern KdKeyboardDriver EphyrKeyboardDriver;
+
+extern KdOsFuncs EphyrOsFuncs;
+
+extern Bool ephyrCursorInit(ScreenPtr pScreen);
+
+extern void ephyrCursorEnable(ScreenPtr pScreen);
+
+/* ephyr_draw.c */
+
+Bool
+ephyrDrawInit(ScreenPtr pScreen);
+
+void
+ephyrDrawEnable(ScreenPtr pScreen);
+
+void
+ephyrDrawDisable(ScreenPtr pScreen);
+
+void
+ephyrDrawFini(ScreenPtr pScreen);
+
+/*ephyvideo.c*/
+
+Bool ephyrInitVideo(ScreenPtr pScreen) ;
+
+#endif
diff --git a/xorg-server/hw/kdrive/ephyr/ephyr_draw.c b/xorg-server/hw/kdrive/ephyr/ephyr_draw.c
new file mode 100644
index 000000000..422b7c6b6
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyr_draw.c
@@ -0,0 +1,524 @@
+/*
+ * Copyright © 2006 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#undef NDEBUG /* No, really. The whole point of this module is to crash. */
+
+#include "ephyr.h"
+#include "exa_priv.h"
+#include "fbpict.h"
+
+#define EPHYR_TRACE_DRAW 0
+
+#if EPHYR_TRACE_DRAW
+#define TRACE_DRAW() ErrorF("%s\n", __FUNCTION__);
+#else
+#define TRACE_DRAW() do { } while (0)
+#endif
+
+/* Use some oddball alignments, to expose issues in alignment handling in EXA. */
+#define EPHYR_OFFSET_ALIGN 24
+#define EPHYR_PITCH_ALIGN 24
+
+#define EPHYR_OFFSCREEN_SIZE (16 * 1024 * 1024)
+#define EPHYR_OFFSCREEN_BASE (1 * 1024 * 1024)
+
+/**
+ * Forces a real devPrivate.ptr for hidden pixmaps, so that we can call down to
+ * fb functions.
+ */
+static void
+ephyrPreparePipelinedAccess(PixmapPtr pPix, int index)
+{
+ KdScreenPriv(pPix->drawable.pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa = scrpriv->fakexa;
+
+ assert(fakexa->saved_ptrs[index] == NULL);
+ fakexa->saved_ptrs[index] = pPix->devPrivate.ptr;
+
+ if (pPix->devPrivate.ptr != NULL)
+ return;
+
+ pPix->devPrivate.ptr = fakexa->exa->memoryBase + exaGetPixmapOffset(pPix);
+}
+
+/**
+ * Restores the original devPrivate.ptr of the pixmap from before we messed with
+ * it.
+ */
+static void
+ephyrFinishPipelinedAccess(PixmapPtr pPix, int index)
+{
+ KdScreenPriv(pPix->drawable.pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa = scrpriv->fakexa;
+
+ pPix->devPrivate.ptr = fakexa->saved_ptrs[index];
+ fakexa->saved_ptrs[index] = NULL;
+}
+
+/**
+ * Sets up a scratch GC for fbFill, and saves other parameters for the
+ * ephyrSolid implementation.
+ */
+static Bool
+ephyrPrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg)
+{
+ ScreenPtr pScreen = pPix->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa = scrpriv->fakexa;
+ CARD32 tmpval[3];
+
+ ephyrPreparePipelinedAccess(pPix, EXA_PREPARE_DEST);
+
+ fakexa->pDst = pPix;
+ fakexa->pGC = GetScratchGC(pPix->drawable.depth, pScreen);
+
+ tmpval[0] = alu;
+ tmpval[1] = pm;
+ tmpval[2] = fg;
+ ChangeGC(fakexa->pGC, GCFunction | GCPlaneMask | GCForeground,
+ tmpval);
+
+ ValidateGC(&pPix->drawable, fakexa->pGC);
+
+ TRACE_DRAW();
+
+ return TRUE;
+}
+
+/**
+ * Does an fbFill of the rectangle to be drawn.
+ */
+static void
+ephyrSolid(PixmapPtr pPix, int x1, int y1, int x2, int y2)
+{
+ ScreenPtr pScreen = pPix->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa = scrpriv->fakexa;
+
+ fbFill(&fakexa->pDst->drawable, fakexa->pGC, x1, y1, x2 - x1, y2 - y1);
+}
+
+/**
+ * Cleans up the scratch GC created in ephyrPrepareSolid.
+ */
+static void
+ephyrDoneSolid(PixmapPtr pPix)
+{
+ ScreenPtr pScreen = pPix->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa = scrpriv->fakexa;
+
+ FreeScratchGC(fakexa->pGC);
+
+ ephyrFinishPipelinedAccess(pPix, EXA_PREPARE_DEST);
+}
+
+/**
+ * Sets up a scratch GC for fbCopyArea, and saves other parameters for the
+ * ephyrCopy implementation.
+ */
+static Bool
+ephyrPrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu,
+ Pixel pm)
+{
+ ScreenPtr pScreen = pDst->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa = scrpriv->fakexa;
+ CARD32 tmpval[2];
+
+ ephyrPreparePipelinedAccess(pDst, EXA_PREPARE_DEST);
+ ephyrPreparePipelinedAccess(pSrc, EXA_PREPARE_SRC);
+
+ fakexa->pSrc = pSrc;
+ fakexa->pDst = pDst;
+ fakexa->pGC = GetScratchGC(pDst->drawable.depth, pScreen);
+
+ tmpval[0] = alu;
+ tmpval[1] = pm;
+ ChangeGC (fakexa->pGC, GCFunction | GCPlaneMask, tmpval);
+
+ ValidateGC(&pDst->drawable, fakexa->pGC);
+
+ TRACE_DRAW();
+
+ return TRUE;
+}
+
+/**
+ * Does an fbCopyArea to take care of the requested copy.
+ */
+static void
+ephyrCopy(PixmapPtr pDst, int srcX, int srcY, int dstX, int dstY, int w, int h)
+{
+ ScreenPtr pScreen = pDst->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa = scrpriv->fakexa;
+
+ fbCopyArea(&fakexa->pSrc->drawable, &fakexa->pDst->drawable, fakexa->pGC,
+ srcX, srcY, w, h, dstX, dstY);
+}
+
+/**
+ * Cleans up the scratch GC created in ephyrPrepareCopy.
+ */
+static void
+ephyrDoneCopy(PixmapPtr pDst)
+{
+ ScreenPtr pScreen = pDst->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa = scrpriv->fakexa;
+
+ FreeScratchGC (fakexa->pGC);
+
+ ephyrFinishPipelinedAccess(fakexa->pSrc, EXA_PREPARE_SRC);
+ ephyrFinishPipelinedAccess(fakexa->pDst, EXA_PREPARE_DEST);
+}
+
+/**
+ * Reports that we can always accelerate the given operation. This may not be
+ * desirable from an EXA testing standpoint -- testing the fallback paths would
+ * be useful, too.
+ */
+static Bool
+ephyrCheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture)
+{
+ /* Exercise the component alpha helper, so fail on this case like a normal
+ * driver
+ */
+ if (pMaskPicture && pMaskPicture->componentAlpha && op == PictOpOver)
+ return FALSE;
+
+ return TRUE;
+}
+
+/**
+ * Saves off the parameters for ephyrComposite.
+ */
+static Bool
+ephyrPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask,
+ PixmapPtr pDst)
+{
+ KdScreenPriv(pDst->drawable.pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa = scrpriv->fakexa;
+
+ ephyrPreparePipelinedAccess(pDst, EXA_PREPARE_DEST);
+ ephyrPreparePipelinedAccess(pSrc, EXA_PREPARE_SRC);
+ if (pMask != NULL)
+ ephyrPreparePipelinedAccess(pMask, EXA_PREPARE_MASK);
+
+ fakexa->op = op;
+ fakexa->pSrcPicture = pSrcPicture;
+ fakexa->pMaskPicture = pMaskPicture;
+ fakexa->pDstPicture = pDstPicture;
+ fakexa->pSrc = pSrc;
+ fakexa->pMask = pMask;
+ fakexa->pDst = pDst;
+
+ TRACE_DRAW();
+
+ return TRUE;
+}
+
+/**
+ * Does an fbComposite to complete the requested drawing operation.
+ */
+static void
+ephyrComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY,
+ int dstX, int dstY, int w, int h)
+{
+ KdScreenPriv(pDst->drawable.pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa = scrpriv->fakexa;
+
+ fbComposite(fakexa->op, fakexa->pSrcPicture, fakexa->pMaskPicture,
+ fakexa->pDstPicture, srcX, srcY, maskX, maskY, dstX, dstY,
+ w, h);
+}
+
+static void
+ephyrDoneComposite(PixmapPtr pDst)
+{
+ KdScreenPriv(pDst->drawable.pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa = scrpriv->fakexa;
+
+ if (fakexa->pMask != NULL)
+ ephyrFinishPipelinedAccess(fakexa->pMask, EXA_PREPARE_MASK);
+ ephyrFinishPipelinedAccess(fakexa->pSrc, EXA_PREPARE_SRC);
+ ephyrFinishPipelinedAccess(fakexa->pDst, EXA_PREPARE_DEST);
+}
+
+/**
+ * Does fake acceleration of DownloadFromScren using memcpy.
+ */
+static Bool
+ephyrDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, char *dst,
+ int dst_pitch)
+{
+ KdScreenPriv(pSrc->drawable.pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa = scrpriv->fakexa;
+ unsigned char *src;
+ int src_pitch, cpp;
+
+ if (pSrc->drawable.bitsPerPixel < 8)
+ return FALSE;
+
+ ephyrPreparePipelinedAccess(pSrc, EXA_PREPARE_SRC);
+
+ cpp = pSrc->drawable.bitsPerPixel / 8;
+ src_pitch = exaGetPixmapPitch(pSrc);
+ src = fakexa->exa->memoryBase + exaGetPixmapOffset(pSrc);
+ src += y * src_pitch + x * cpp;
+
+ for (; h > 0; h--) {
+ memcpy(dst, src, w * cpp);
+ dst += dst_pitch;
+ src += src_pitch;
+ }
+
+ exaMarkSync(pSrc->drawable.pScreen);
+
+ ephyrFinishPipelinedAccess(pSrc, EXA_PREPARE_SRC);
+
+ return TRUE;
+}
+
+/**
+ * Does fake acceleration of UploadToScreen using memcpy.
+ */
+static Bool
+ephyrUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src,
+ int src_pitch)
+{
+ KdScreenPriv(pDst->drawable.pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa = scrpriv->fakexa;
+ unsigned char *dst;
+ int dst_pitch, cpp;
+
+ if (pDst->drawable.bitsPerPixel < 8)
+ return FALSE;
+
+ ephyrPreparePipelinedAccess(pDst, EXA_PREPARE_DEST);
+
+ cpp = pDst->drawable.bitsPerPixel / 8;
+ dst_pitch = exaGetPixmapPitch(pDst);
+ dst = fakexa->exa->memoryBase + exaGetPixmapOffset(pDst);
+ dst += y * dst_pitch + x * cpp;
+
+ for (; h > 0; h--) {
+ memcpy(dst, src, w * cpp);
+ dst += dst_pitch;
+ src += src_pitch;
+ }
+
+ exaMarkSync(pDst->drawable.pScreen);
+
+ ephyrFinishPipelinedAccess(pDst, EXA_PREPARE_DEST);
+
+ return TRUE;
+}
+
+static Bool
+ephyrPrepareAccess(PixmapPtr pPix, int index)
+{
+ /* Make sure we don't somehow end up with a pointer that is in framebuffer
+ * and hasn't been readied for us.
+ */
+ assert(pPix->devPrivate.ptr != NULL);
+
+ return TRUE;
+}
+
+/**
+ * In fakexa, we currently only track whether we have synced to the latest
+ * "accelerated" drawing that has happened or not. It's not used for anything
+ * yet.
+ */
+static int
+ephyrMarkSync(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa = scrpriv->fakexa;
+
+ fakexa->is_synced = FALSE;
+
+ return 0;
+}
+
+/**
+ * Assumes that we're waiting on the latest marker. When EXA gets smarter and
+ * starts using markers in a fine-grained way (for example, waiting on drawing
+ * to required pixmaps to complete, rather than waiting for all drawing to
+ * complete), we'll want to make the ephyrMarkSync/ephyrWaitMarker
+ * implementation fine-grained as well.
+ */
+static void
+ephyrWaitMarker(ScreenPtr pScreen, int marker)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa = scrpriv->fakexa;
+
+ fakexa->is_synced = TRUE;
+}
+
+/**
+ * This function initializes EXA to use the fake acceleration implementation
+ * which just falls through to software. The purpose is to have a reliable,
+ * correct driver with which to test changes to the EXA core.
+ */
+Bool
+ephyrDrawInit(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EphyrScrPriv *scrpriv = screen->driver;
+ EphyrFakexaPriv *fakexa;
+ Bool success;
+
+ fakexa = xcalloc(1, sizeof(*fakexa));
+ if (fakexa == NULL)
+ return FALSE;
+
+ fakexa->exa = exaDriverAlloc();
+ if (fakexa->exa == NULL) {
+ xfree(fakexa);
+ return FALSE;
+ }
+
+ fakexa->exa->memoryBase = screen->memory_base;
+ fakexa->exa->memorySize = screen->memory_size;
+ fakexa->exa->offScreenBase = screen->off_screen_base;
+
+ /* Since we statically link against EXA, we shouldn't have to be smart about
+ * versioning.
+ */
+ fakexa->exa->exa_major = 2;
+ fakexa->exa->exa_minor = 0;
+
+ fakexa->exa->PrepareSolid = ephyrPrepareSolid;
+ fakexa->exa->Solid = ephyrSolid;
+ fakexa->exa->DoneSolid = ephyrDoneSolid;
+
+ fakexa->exa->PrepareCopy = ephyrPrepareCopy;
+ fakexa->exa->Copy = ephyrCopy;
+ fakexa->exa->DoneCopy = ephyrDoneCopy;
+
+ fakexa->exa->CheckComposite = ephyrCheckComposite;
+ fakexa->exa->PrepareComposite = ephyrPrepareComposite;
+ fakexa->exa->Composite = ephyrComposite;
+ fakexa->exa->DoneComposite = ephyrDoneComposite;
+
+ fakexa->exa->DownloadFromScreen = ephyrDownloadFromScreen;
+ fakexa->exa->UploadToScreen = ephyrUploadToScreen;
+
+ fakexa->exa->MarkSync = ephyrMarkSync;
+ fakexa->exa->WaitMarker = ephyrWaitMarker;
+
+ fakexa->exa->PrepareAccess = ephyrPrepareAccess;
+
+ fakexa->exa->pixmapOffsetAlign = EPHYR_OFFSET_ALIGN;
+ fakexa->exa->pixmapPitchAlign = EPHYR_PITCH_ALIGN;
+
+ fakexa->exa->maxX = 1023;
+ fakexa->exa->maxY = 1023;
+
+ fakexa->exa->flags = EXA_OFFSCREEN_PIXMAPS;
+
+ success = exaDriverInit(pScreen, fakexa->exa);
+ if (success) {
+ ErrorF("Initialized fake EXA acceleration\n");
+ scrpriv->fakexa = fakexa;
+ } else {
+ ErrorF("Failed to initialize EXA\n");
+ xfree(fakexa->exa);
+ xfree(fakexa);
+ }
+
+ return success;
+}
+
+void
+ephyrDrawEnable(ScreenPtr pScreen)
+{
+}
+
+void
+ephyrDrawDisable(ScreenPtr pScreen)
+{
+}
+
+void
+ephyrDrawFini(ScreenPtr pScreen)
+{
+}
+
+/**
+ * exaDDXDriverInit is required by the top-level EXA module, and is used by
+ * the xorg DDX to hook in its EnableDisableFB wrapper. We don't need it, since
+ * we won't be enabling/disabling the FB.
+ */
+void
+exaDDXDriverInit(ScreenPtr pScreen)
+{
+ ExaScreenPriv(pScreen);
+
+ pExaScr->migration = ExaMigrationSmart;
+ pExaScr->checkDirtyCorrectness = TRUE;
+}
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdri.c b/xorg-server/hw/kdrive/ephyr/ephyrdri.c
new file mode 100644
index 000000000..53a96ba11
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrdri.c
@@ -0,0 +1,291 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * 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 OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+#ifdef XEPHYR_DRI
+
+#include <X11/Xutil.h>
+#include <X11/Xlibint.h>
+/*#define _XF86DRI_SERVER_*/
+#include <GL/glx.h>
+#include <X11/dri/xf86dri.h>
+#include "hostx.h"
+#include "ephyrdri.h"
+#define _HAVE_XALLOC_DECLS
+#include "ephyrlog.h"
+#include "dixstruct.h"
+#include "pixmapstr.h"
+
+#ifndef TRUE
+#define TRUE 1
+#endif /*TRUE*/
+
+#ifndef FALSE
+#define FALSE 0
+#endif /*FALSE*/
+
+Bool
+ephyrDRIQueryDirectRenderingCapable (int a_screen, Bool *a_is_capable)
+{
+ Display *dpy=hostx_get_display () ;
+ Bool is_ok=FALSE ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_is_capable, FALSE) ;
+ EPHYR_LOG ("enter\n") ;
+ is_ok = XF86DRIQueryDirectRenderingCapable (dpy, DefaultScreen (dpy),
+ a_is_capable) ;
+ EPHYR_LOG ("leave. is_capable:%d, is_ok=%d\n", *a_is_capable, is_ok) ;
+
+ return is_ok ;
+}
+
+Bool
+ephyrDRIOpenConnection (int a_screen,
+ drm_handle_t *a_sarea,
+ char **a_bus_id_string)
+{
+ Display *dpy = hostx_get_display () ;
+ Bool is_ok=FALSE ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_bus_id_string, FALSE) ;
+ EPHYR_LOG ("enter. screen:%d\n", a_screen) ;
+ is_ok = XF86DRIOpenConnection (dpy, DefaultScreen (dpy),
+ a_sarea,
+ a_bus_id_string) ;
+ if (*a_bus_id_string) {
+ EPHYR_LOG ("leave. bus_id_string:%s, is_ok:%d\n",
+ *a_bus_id_string, is_ok) ;
+ } else {
+ EPHYR_LOG ("leave. bus_id_string:null, is_ok:%d\n",
+ is_ok) ;
+ }
+ return is_ok ;
+}
+
+Bool
+ephyrDRIAuthConnection (int a_screen, drm_magic_t a_magic)
+{
+ Display *dpy = hostx_get_display () ;
+ Bool is_ok=FALSE ;
+
+ EPHYR_LOG ("enter\n") ;
+ is_ok = XF86DRIAuthConnection (dpy, DefaultScreen (dpy), a_magic) ;
+ EPHYR_LOG ("leave. is_ok:%d\n", is_ok) ;
+ return is_ok ;
+}
+
+Bool
+ephyrDRICloseConnection (int a_screen)
+{
+ Display *dpy = hostx_get_display () ;
+ Bool is_ok=FALSE ;
+
+ EPHYR_LOG ("enter\n") ;
+ is_ok = XF86DRICloseConnection (dpy, DefaultScreen (dpy)) ;
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+Bool
+ephyrDRIGetClientDriverName (int a_screen,
+ int *a_ddx_driver_major_version,
+ int *a_ddx_driver_minor_version,
+ int *a_ddx_driver_patch_version,
+ char ** a_client_driver_name)
+{
+ Display *dpy = hostx_get_display () ;
+ Bool is_ok=FALSE ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_ddx_driver_major_version
+ && a_ddx_driver_minor_version
+ && a_ddx_driver_patch_version
+ && a_client_driver_name,
+ FALSE);
+ EPHYR_LOG ("enter\n") ;
+ is_ok = XF86DRIGetClientDriverName (dpy, DefaultScreen (dpy),
+ a_ddx_driver_major_version,
+ a_ddx_driver_minor_version,
+ a_ddx_driver_patch_version,
+ a_client_driver_name) ;
+ EPHYR_LOG ("major:%d, minor:%d, patch:%d, name:%s\n",
+ *a_ddx_driver_major_version,
+ *a_ddx_driver_minor_version,
+ *a_ddx_driver_patch_version,
+ *a_client_driver_name) ;
+ EPHYR_LOG ("leave:%d\n", is_ok) ;
+ return is_ok ;
+}
+
+Bool
+ephyrDRICreateContext (int a_screen,
+ int a_visual_id,
+ unsigned long int *a_returned_ctxt_id,
+ drm_context_t *a_hw_ctxt)
+{
+ Display *dpy = hostx_get_display () ;
+ Bool is_ok=FALSE ;
+ Visual v;
+
+ EPHYR_LOG ("enter. screen:%d, visual:%d\n", a_screen, a_visual_id) ;
+ memset (&v, 0, sizeof (v)) ;
+ v.visualid = a_visual_id ;
+ is_ok = XF86DRICreateContext (dpy,
+ DefaultScreen (dpy),
+ &v,
+ a_returned_ctxt_id,
+ a_hw_ctxt) ;
+ EPHYR_LOG ("leave:%d\n", is_ok) ;
+ return is_ok ;
+}
+
+Bool
+ephyrDRIDestroyContext (int a_screen,
+ int a_context_id)
+{
+ Display *dpy = hostx_get_display () ;
+ Bool is_ok=FALSE ;
+
+ EPHYR_LOG ("enter\n") ;
+ is_ok = XF86DRIDestroyContext (dpy, DefaultScreen (dpy), a_context_id) ;
+ EPHYR_LOG ("leave:%d\n", is_ok) ;
+ return is_ok ;
+}
+
+Bool
+ephyrDRICreateDrawable (int a_screen,
+ int a_drawable,
+ drm_drawable_t *a_hw_drawable)
+{
+ Bool is_ok=FALSE;
+ Display *dpy=hostx_get_display () ;
+
+ EPHYR_LOG ("enter\n") ;
+ is_ok = XF86DRICreateDrawable (dpy, DefaultScreen (dpy),
+ a_drawable, a_hw_drawable) ;
+ EPHYR_LOG ("leave. is_ok:%d\n", is_ok) ;
+ return is_ok ;
+}
+
+Bool
+ephyrDRIDestroyDrawable (int a_screen, int a_drawable)
+{
+ EPHYR_LOG ("enter\n") ;
+ EPHYR_LOG_ERROR ("not implemented yet\n") ;
+ EPHYR_LOG ("leave\n") ;
+ return FALSE ;
+}
+
+Bool
+ephyrDRIGetDrawableInfo (int a_screen,
+ int a_drawable,
+ unsigned int *a_index,
+ unsigned int *a_stamp,
+ int *a_x,
+ int *a_y,
+ int *a_w,
+ int *a_h,
+ int *a_num_clip_rects,
+ drm_clip_rect_t **a_clip_rects,
+ int *a_back_x,
+ int *a_back_y,
+ int *a_num_back_clip_rects,
+ drm_clip_rect_t **a_back_clip_rects)
+{
+ Bool is_ok=FALSE;
+ Display *dpy=hostx_get_display () ;
+ EphyrHostWindowAttributes attrs ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_x && a_y && a_w && a_h
+ && a_num_clip_rects,
+ FALSE) ;
+
+ EPHYR_LOG ("enter\n") ;
+ memset (&attrs, 0, sizeof (attrs)) ;
+ if (!hostx_get_window_attributes (a_drawable, &attrs)) {
+ EPHYR_LOG_ERROR ("failed to query host window attributes\n") ;
+ goto out;
+ }
+ if (!XF86DRIGetDrawableInfo (dpy, DefaultScreen (dpy), a_drawable,
+ a_index, a_stamp,
+ a_x, a_y,
+ a_w, a_h,
+ a_num_clip_rects, a_clip_rects,
+ a_back_x, a_back_y,
+ a_num_back_clip_rects,
+ a_back_clip_rects)) {
+ EPHYR_LOG_ERROR ("XF86DRIGetDrawableInfo ()\n") ;
+ goto out ;
+ }
+ EPHYR_LOG ("host x,y,w,h: (%d,%d,%d,%d)\n", *a_x, *a_y, *a_w, *a_h) ;
+ if (*a_num_clip_rects) {
+ free (*a_back_clip_rects) ;
+ *a_back_clip_rects = calloc (*a_num_clip_rects,
+ sizeof (drm_clip_rect_t)) ;
+ memmove (*a_back_clip_rects,
+ *a_clip_rects,
+ *a_num_clip_rects * sizeof (drm_clip_rect_t)) ;
+ *a_num_back_clip_rects = *a_num_clip_rects;
+ }
+ EPHYR_LOG ("num back clip rects:%d, num clip rects:%d\n",
+ *a_num_clip_rects, *a_num_back_clip_rects) ;
+ *a_back_x = *a_x ;
+ *a_back_y = *a_y ;
+ *a_w = attrs.width;
+ *a_h = attrs.height;
+
+ is_ok = TRUE ;
+out:
+ EPHYR_LOG ("leave. index:%d, stamp:%d, x,y:(%d,%d), w,y:(%d,%d)\n",
+ *a_index, *a_stamp, *a_x, *a_y, *a_w, *a_h) ;
+ return is_ok ;
+}
+
+Bool
+ephyrDRIGetDeviceInfo (int a_screen,
+ drm_handle_t *a_frame_buffer,
+ int *a_fb_origin,
+ int *a_fb_size,
+ int *a_fb_stride,
+ int *a_dev_private_size,
+ void **a_dev_private)
+{
+ Bool is_ok = FALSE ;
+ Display *dpy = hostx_get_display () ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
+ EPHYR_LOG ("enter\n") ;
+ is_ok = XF86DRIGetDeviceInfo (dpy, DefaultScreen (dpy), a_frame_buffer,
+ a_fb_origin, a_fb_size, a_fb_stride,
+ a_dev_private_size, a_dev_private) ;
+ EPHYR_LOG ("leave:%d\n", is_ok) ;
+ return is_ok ;
+}
+#endif /*EPHYR_DRI*/
+
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdri.h b/xorg-server/hw/kdrive/ephyr/ephyrdri.h
new file mode 100644
index 000000000..af8bb11fd
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrdri.h
@@ -0,0 +1,75 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * 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 OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+
+#ifndef __EPHYRDRI_H__
+#define __EPHYRDRI_H__
+
+#include <xf86drm.h>
+
+Bool ephyrDRIQueryDirectRenderingCapable (int a_screen, Bool *a_is_capable) ;
+Bool ephyrDRIOpenConnection (int screen, drm_handle_t *a_sarea, char **a_bus_id_string) ;
+Bool ephyrDRIAuthConnection (int a_screen, drm_magic_t a_magic) ;
+Bool ephyrDRICloseConnection (int a_screen) ;
+Bool ephyrDRIGetClientDriverName (int a_screen,
+ int *a_ddx_driver_major_version,
+ int *a_ddx_driver_minor_version,
+ int *a_ddx_driver_patch_version,
+ char ** a_client_driver_name) ;
+Bool ephyrDRICreateContext (int a_screen,
+ int a_visual_id,
+ unsigned long int *a_returned_ctx_id,
+ drm_context_t *a_hw_ctx) ;
+Bool ephyrDRIDestroyContext (int a_screen,
+ int a_context_id) ;
+Bool ephyrDRICreateDrawable (int a_screen,
+ int a_drawable,
+ drm_drawable_t *a_hw_drawable) ;
+Bool ephyrDRIDestroyDrawable (int a_screen, int a_drawable) ;
+Bool ephyrDRIGetDrawableInfo (int a_screen,
+ int /*Drawable*/a_drawable,
+ unsigned int *a_index,
+ unsigned int *a_stamp,
+ int *a_x,
+ int *a_y,
+ int *a_w,
+ int *a_h,
+ int *a_num_clip_rects,
+ drm_clip_rect_t **a_clip_rects,
+ int *a_back_x,
+ int *a_back_y,
+ int *num_back_clip_rects,
+ drm_clip_rect_t **a_back_clip_rects) ;
+Bool ephyrDRIGetDeviceInfo (int a_screen,
+ drm_handle_t *a_frame_buffer,
+ int *a_fb_origin,
+ int *a_fb_size,
+ int *a_fb_stride,
+ int *a_dev_private_size,
+ void **a_dev_private) ;
+#endif /*__EPHYRDRI_H__*/
+
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdriext.c b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
new file mode 100644
index 000000000..fafe56d1f
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
@@ -0,0 +1,1443 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * 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 OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * This file is heavily copied from hw/xfree86/dri/xf86dri.c
+ *
+ * Authors:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+#ifdef XEPHYR_DRI
+
+#include <string.h>
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#define _XF86DRI_SERVER_
+#include <X11/dri/xf86dri.h>
+#include <X11/dri/xf86dristr.h>
+#include "misc.h"
+#include "privates.h"
+#include "dixstruct.h"
+#include "extnsionst.h"
+#include "colormapst.h"
+#include "cursorstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#include "swaprep.h"
+#include "ephyrdri.h"
+#include "ephyrdriext.h"
+#include "hostx.h"
+#define _HAVE_XALLOC_DECLS
+#include "ephyrlog.h"
+
+
+typedef struct {
+ int foo;
+} EphyrDRIWindowPrivRec;
+typedef EphyrDRIWindowPrivRec* EphyrDRIWindowPrivPtr;
+
+typedef struct {
+ CreateWindowProcPtr CreateWindow ;
+ DestroyWindowProcPtr DestroyWindow ;
+ MoveWindowProcPtr MoveWindow ;
+ PositionWindowProcPtr PositionWindow ;
+ ClipNotifyProcPtr ClipNotify ;
+} EphyrDRIScreenPrivRec;
+typedef EphyrDRIScreenPrivRec* EphyrDRIScreenPrivPtr;
+
+static int DRIErrorBase;
+
+static DISPATCH_PROC(ProcXF86DRIQueryVersion);
+static DISPATCH_PROC(ProcXF86DRIQueryDirectRenderingCapable);
+static DISPATCH_PROC(ProcXF86DRIOpenConnection);
+static DISPATCH_PROC(ProcXF86DRICloseConnection);
+static DISPATCH_PROC(ProcXF86DRIGetClientDriverName);
+static DISPATCH_PROC(ProcXF86DRICreateContext);
+static DISPATCH_PROC(ProcXF86DRIDestroyContext);
+static DISPATCH_PROC(ProcXF86DRICreateDrawable);
+static DISPATCH_PROC(ProcXF86DRIDestroyDrawable);
+static DISPATCH_PROC(ProcXF86DRIGetDrawableInfo);
+static DISPATCH_PROC(ProcXF86DRIGetDeviceInfo);
+static DISPATCH_PROC(ProcXF86DRIDispatch);
+static DISPATCH_PROC(ProcXF86DRIAuthConnection);
+
+static DISPATCH_PROC(SProcXF86DRIQueryVersion);
+static DISPATCH_PROC(SProcXF86DRIQueryDirectRenderingCapable);
+static DISPATCH_PROC(SProcXF86DRIDispatch);
+
+static void XF86DRIResetProc(ExtensionEntry* extEntry);
+
+static Bool ephyrDRIScreenInit (ScreenPtr a_screen) ;
+static Bool ephyrDRICreateWindow (WindowPtr a_win) ;
+static Bool ephyrDRIDestroyWindow (WindowPtr a_win) ;
+static void ephyrDRIMoveWindow (WindowPtr a_win,
+ int a_x, int a_y,
+ WindowPtr a_siblings,
+ VTKind a_kind);
+static Bool ephyrDRIPositionWindow (WindowPtr a_win,
+ int x, int y) ;
+static void ephyrDRIClipNotify (WindowPtr a_win,
+ int a_x, int a_y) ;
+
+static Bool EphyrMirrorHostVisuals (ScreenPtr a_screen) ;
+static Bool destroyHostPeerWindow (const WindowPtr a_win) ;
+static Bool findWindowPairFromLocal (WindowPtr a_local,
+ EphyrWindowPair **a_pair);
+
+static unsigned char DRIReqCode = 0;
+
+static DevPrivateKey ephyrDRIWindowKey = &ephyrDRIWindowKey;
+static DevPrivateKey ephyrDRIScreenKey = &ephyrDRIScreenKey;
+
+#define GET_EPHYR_DRI_WINDOW_PRIV(win) ((EphyrDRIWindowPrivPtr) \
+ dixLookupPrivate(&(win)->devPrivates, ephyrDRIWindowKey))
+#define GET_EPHYR_DRI_SCREEN_PRIV(screen) ((EphyrDRIScreenPrivPtr) \
+ dixLookupPrivate(&(screen)->devPrivates, ephyrDRIScreenKey))
+
+
+Bool
+ephyrDRIExtensionInit (ScreenPtr a_screen)
+{
+ Bool is_ok=FALSE ;
+ ExtensionEntry* extEntry=NULL;
+ EphyrDRIScreenPrivPtr screen_priv=NULL ;
+
+ EPHYR_LOG ("enter\n") ;
+ if (!hostx_has_dri ()) {
+ EPHYR_LOG ("host does not have DRI extension\n") ;
+ goto out ;
+ }
+ EPHYR_LOG ("host X does have DRI extension\n") ;
+ if (!hostx_has_xshape ()) {
+ EPHYR_LOG ("host does not have XShape extension\n") ;
+ goto out ;
+ }
+ EPHYR_LOG ("host X does have XShape extension\n") ;
+
+#ifdef XF86DRI_EVENTS
+ EventType = CreateNewResourceType (XF86DRIFreeEvents);
+#endif
+
+ if ((extEntry = AddExtension(XF86DRINAME,
+ XF86DRINumberEvents,
+ XF86DRINumberErrors,
+ ProcXF86DRIDispatch,
+ SProcXF86DRIDispatch,
+ XF86DRIResetProc,
+ StandardMinorOpcode))) {
+ DRIReqCode = (unsigned char)extEntry->base;
+ DRIErrorBase = extEntry->errorBase;
+ } else {
+ EPHYR_LOG_ERROR ("failed to register DRI extension\n") ;
+ goto out ;
+ }
+ screen_priv = xcalloc (1, sizeof (EphyrDRIScreenPrivRec)) ;
+ if (!screen_priv) {
+ EPHYR_LOG_ERROR ("failed to allocate screen_priv\n") ;
+ goto out ;
+ }
+ dixSetPrivate(&a_screen->devPrivates, ephyrDRIScreenKey, screen_priv);
+
+ if (!ephyrDRIScreenInit (a_screen)) {
+ EPHYR_LOG_ERROR ("ephyrDRIScreenInit() failed\n") ;
+ goto out ;
+ }
+ EphyrMirrorHostVisuals (a_screen) ;
+ is_ok=TRUE ;
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+static Bool
+ephyrDRIScreenInit (ScreenPtr a_screen)
+{
+ Bool is_ok=FALSE ;
+ EphyrDRIScreenPrivPtr screen_priv=NULL ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_screen, FALSE) ;
+
+ screen_priv=GET_EPHYR_DRI_SCREEN_PRIV (a_screen) ;
+ EPHYR_RETURN_VAL_IF_FAIL (screen_priv, FALSE) ;
+
+ screen_priv->CreateWindow = a_screen->CreateWindow ;
+ screen_priv->DestroyWindow = a_screen->DestroyWindow ;
+ screen_priv->MoveWindow = a_screen->MoveWindow ;
+ screen_priv->PositionWindow = a_screen->PositionWindow ;
+ screen_priv->ClipNotify = a_screen->ClipNotify ;
+
+ a_screen->CreateWindow = ephyrDRICreateWindow ;
+ a_screen->DestroyWindow = ephyrDRIDestroyWindow ;
+ a_screen->MoveWindow = ephyrDRIMoveWindow ;
+ a_screen->PositionWindow = ephyrDRIPositionWindow ;
+ a_screen->ClipNotify = ephyrDRIClipNotify ;
+
+ is_ok = TRUE ;
+
+ return is_ok ;
+}
+
+static Bool
+ephyrDRICreateWindow (WindowPtr a_win)
+{
+ Bool is_ok=FALSE ;
+ ScreenPtr screen=NULL ;
+ EphyrDRIScreenPrivPtr screen_priv =NULL;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_win, FALSE) ;
+ screen = a_win->drawable.pScreen ;
+ EPHYR_RETURN_VAL_IF_FAIL (screen, FALSE) ;
+ screen_priv = GET_EPHYR_DRI_SCREEN_PRIV (screen) ;
+ EPHYR_RETURN_VAL_IF_FAIL (screen_priv
+ && screen_priv->CreateWindow,
+ FALSE) ;
+
+ EPHYR_LOG ("enter. win:%#x\n",
+ (unsigned int)a_win) ;
+
+ screen->CreateWindow = screen_priv->CreateWindow ;
+ is_ok = (*screen->CreateWindow) (a_win) ;
+ screen->CreateWindow = ephyrDRICreateWindow ;
+
+ if (is_ok) {
+ dixSetPrivate(&a_win->devPrivates, ephyrDRIWindowKey, NULL);
+ }
+ return is_ok ;
+}
+
+static Bool
+ephyrDRIDestroyWindow (WindowPtr a_win)
+{
+ Bool is_ok=FALSE ;
+ ScreenPtr screen=NULL ;
+ EphyrDRIScreenPrivPtr screen_priv =NULL;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_win, FALSE) ;
+ screen = a_win->drawable.pScreen ;
+ EPHYR_RETURN_VAL_IF_FAIL (screen, FALSE) ;
+ screen_priv = GET_EPHYR_DRI_SCREEN_PRIV (screen) ;
+ EPHYR_RETURN_VAL_IF_FAIL (screen_priv
+ && screen_priv->DestroyWindow,
+ FALSE) ;
+
+ screen->DestroyWindow = screen_priv->DestroyWindow ;
+ if (screen->DestroyWindow) {
+ is_ok = (*screen->DestroyWindow) (a_win) ;
+ }
+ screen->DestroyWindow = ephyrDRIDestroyWindow ;
+
+ if (is_ok) {
+ EphyrDRIWindowPrivPtr win_priv=GET_EPHYR_DRI_WINDOW_PRIV (a_win) ;
+ if (win_priv) {
+ destroyHostPeerWindow (a_win) ;
+ xfree (win_priv) ;
+ dixSetPrivate(&a_win->devPrivates, ephyrDRIWindowKey, NULL);
+ EPHYR_LOG ("destroyed the remote peer window\n") ;
+ }
+ }
+ return is_ok ;
+}
+
+static void
+ephyrDRIMoveWindow (WindowPtr a_win,
+ int a_x, int a_y,
+ WindowPtr a_siblings,
+ VTKind a_kind)
+{
+ Bool is_ok=FALSE ;
+ ScreenPtr screen=NULL ;
+ EphyrDRIScreenPrivPtr screen_priv =NULL;
+ EphyrDRIWindowPrivPtr win_priv=NULL ;
+ EphyrWindowPair *pair=NULL ;
+ EphyrBox geo;
+ int x=0,y=0;/*coords relative to parent window*/
+
+ EPHYR_RETURN_IF_FAIL (a_win) ;
+
+ EPHYR_LOG ("enter\n") ;
+ screen = a_win->drawable.pScreen ;
+ EPHYR_RETURN_IF_FAIL (screen) ;
+ screen_priv = GET_EPHYR_DRI_SCREEN_PRIV (screen) ;
+ EPHYR_RETURN_IF_FAIL (screen_priv
+ && screen_priv->MoveWindow) ;
+
+ screen->MoveWindow = screen_priv->MoveWindow ;
+ if (screen->MoveWindow) {
+ (*screen->MoveWindow) (a_win, a_x, a_y, a_siblings, a_kind) ;
+ }
+ screen->MoveWindow = ephyrDRIMoveWindow ;
+
+ EPHYR_LOG ("window: %#x\n", (unsigned int)a_win) ;
+ if (!a_win->parent) {
+ EPHYR_LOG ("cannot move root window\n") ;
+ is_ok = TRUE ;
+ goto out ;
+ }
+ win_priv = GET_EPHYR_DRI_WINDOW_PRIV (a_win) ;
+ if (!win_priv) {
+ EPHYR_LOG ("not a DRI peered window\n") ;
+ is_ok = TRUE ;
+ goto out ;
+ }
+ if (!findWindowPairFromLocal (a_win, &pair) || !pair) {
+ EPHYR_LOG_ERROR ("failed to get window pair\n") ;
+ goto out ;
+ }
+ /*compute position relative to parent window*/
+ x = a_win->drawable.x - a_win->parent->drawable.x ;
+ y = a_win->drawable.y - a_win->parent->drawable.y ;
+ /*set the geometry to pass to hostx_set_window_geometry*/
+ memset (&geo, 0, sizeof (geo)) ;
+ geo.x = x ;
+ geo.y = y ;
+ geo.width = a_win->drawable.width ;
+ geo.height = a_win->drawable.height ;
+ hostx_set_window_geometry (pair->remote, &geo) ;
+ is_ok = TRUE ;
+
+out:
+ EPHYR_LOG ("leave. is_ok:%d\n", is_ok) ;
+ /*do cleanup here*/
+}
+
+static Bool
+ephyrDRIPositionWindow (WindowPtr a_win,
+ int a_x, int a_y)
+{
+ Bool is_ok=FALSE ;
+ ScreenPtr screen=NULL ;
+ EphyrDRIScreenPrivPtr screen_priv =NULL;
+ EphyrDRIWindowPrivPtr win_priv=NULL ;
+ EphyrWindowPair *pair=NULL ;
+ EphyrBox geo;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_win, FALSE) ;
+
+ EPHYR_LOG ("enter\n") ;
+ screen = a_win->drawable.pScreen ;
+ EPHYR_RETURN_VAL_IF_FAIL (screen, FALSE) ;
+ screen_priv = GET_EPHYR_DRI_SCREEN_PRIV (screen) ;
+ EPHYR_RETURN_VAL_IF_FAIL (screen_priv
+ && screen_priv->PositionWindow,
+ FALSE) ;
+
+ screen->PositionWindow = screen_priv->PositionWindow ;
+ if (screen->PositionWindow) {
+ (*screen->PositionWindow) (a_win, a_x, a_y) ;
+ }
+ screen->PositionWindow = ephyrDRIPositionWindow ;
+
+ EPHYR_LOG ("window: %#x\n", (unsigned int)a_win) ;
+ win_priv = GET_EPHYR_DRI_WINDOW_PRIV (a_win) ;
+ if (!win_priv) {
+ EPHYR_LOG ("not a DRI peered window\n") ;
+ is_ok = TRUE ;
+ goto out ;
+ }
+ if (!findWindowPairFromLocal (a_win, &pair) || !pair) {
+ EPHYR_LOG_ERROR ("failed to get window pair\n") ;
+ goto out ;
+ }
+ /*set the geometry to pass to hostx_set_window_geometry*/
+ memset (&geo, 0, sizeof (geo)) ;
+ geo.x = a_x ;
+ geo.y = a_y ;
+ geo.width = a_win->drawable.width ;
+ geo.height = a_win->drawable.height ;
+ hostx_set_window_geometry (pair->remote, &geo) ;
+ is_ok = TRUE ;
+
+out:
+ EPHYR_LOG ("leave. is_ok:%d\n", is_ok) ;
+ /*do cleanup here*/
+ return is_ok ;
+}
+
+static void
+ephyrDRIClipNotify (WindowPtr a_win,
+ int a_x, int a_y)
+{
+ Bool is_ok=FALSE ;
+ ScreenPtr screen=NULL ;
+ EphyrDRIScreenPrivPtr screen_priv =NULL;
+ EphyrDRIWindowPrivPtr win_priv=NULL ;
+ EphyrWindowPair *pair=NULL ;
+ EphyrRect *rects=NULL;
+ int i=0 ;
+
+ EPHYR_RETURN_IF_FAIL (a_win) ;
+
+ EPHYR_LOG ("enter\n") ;
+ screen = a_win->drawable.pScreen ;
+ EPHYR_RETURN_IF_FAIL (screen) ;
+ screen_priv = GET_EPHYR_DRI_SCREEN_PRIV (screen) ;
+ EPHYR_RETURN_IF_FAIL (screen_priv && screen_priv->ClipNotify) ;
+
+ screen->ClipNotify = screen_priv->ClipNotify ;
+ if (screen->ClipNotify) {
+ (*screen->ClipNotify) (a_win, a_x, a_y) ;
+ }
+ screen->ClipNotify = ephyrDRIClipNotify ;
+
+ EPHYR_LOG ("window: %#x\n", (unsigned int)a_win) ;
+ win_priv = GET_EPHYR_DRI_WINDOW_PRIV (a_win) ;
+ if (!win_priv) {
+ EPHYR_LOG ("not a DRI peered window\n") ;
+ is_ok = TRUE ;
+ goto out ;
+ }
+ if (!findWindowPairFromLocal (a_win, &pair) || !pair) {
+ EPHYR_LOG_ERROR ("failed to get window pair\n") ;
+ goto out ;
+ }
+ rects = xcalloc (REGION_NUM_RECTS (&a_win->clipList),
+ sizeof (EphyrRect)) ;
+ for (i=0; i < REGION_NUM_RECTS (&a_win->clipList); i++) {
+ memmove (&rects[i],
+ &REGION_RECTS (&a_win->clipList)[i],
+ sizeof (EphyrRect)) ;
+ rects[i].x1 -= a_win->drawable.x;
+ rects[i].x2 -= a_win->drawable.x;
+ rects[i].y1 -= a_win->drawable.y;
+ rects[i].y2 -= a_win->drawable.y;
+ }
+ /*
+ * push the clipping region of this window
+ * to the peer window in the host
+ */
+ is_ok = hostx_set_window_bounding_rectangles
+ (pair->remote,
+ rects,
+ REGION_NUM_RECTS (&a_win->clipList)) ;
+ is_ok = TRUE ;
+
+out:
+ if (rects) {
+ xfree (rects) ;
+ rects = NULL ;
+ }
+ EPHYR_LOG ("leave. is_ok:%d\n", is_ok) ;
+ /*do cleanup here*/
+}
+
+/**
+ * Duplicates a visual of a_screen
+ * In screen a_screen, for depth a_depth, find a visual which
+ * bitsPerRGBValue and colormap size equal
+ * a_bits_per_rgb_values and a_colormap_entries.
+ * The ID of that duplicated visual is set to a_new_id.
+ * That duplicated visual is then added to the list of visuals
+ * of the screen.
+ */
+static Bool
+EphyrDuplicateVisual (unsigned int a_screen,
+ short a_depth,
+ short a_class,
+ short a_bits_per_rgb_values,
+ short a_colormap_entries,
+ unsigned int a_red_mask,
+ unsigned int a_green_mask,
+ unsigned int a_blue_mask,
+ unsigned int a_new_id)
+{
+ Bool is_ok = FALSE, found_visual=FALSE, found_depth=FALSE ;
+ ScreenPtr screen=NULL ;
+ VisualRec new_visual, *new_visuals=NULL ;
+ int i=0 ;
+
+ EPHYR_LOG ("enter\n") ;
+ if (a_screen > screenInfo.numScreens) {
+ EPHYR_LOG_ERROR ("bad screen number\n") ;
+ goto out;
+ }
+ memset (&new_visual, 0, sizeof (VisualRec)) ;
+
+ /*get the screen pointed to by a_screen*/
+ screen = screenInfo.screens[a_screen] ;
+ EPHYR_RETURN_VAL_IF_FAIL (screen, FALSE) ;
+
+ /*
+ * In that screen, first look for an existing visual that has the
+ * same characteristics as those passed in parameter
+ * to this function and copy it.
+ */
+ for (i=0; i < screen->numVisuals; i++) {
+ if (screen->visuals[i].bitsPerRGBValue == a_bits_per_rgb_values &&
+ screen->visuals[i].ColormapEntries == a_colormap_entries ) {
+ /*copy the visual found*/
+ memcpy (&new_visual, &screen->visuals[i], sizeof (new_visual)) ;
+ new_visual.vid = a_new_id ;
+ new_visual.class = a_class ;
+ new_visual.redMask = a_red_mask ;
+ new_visual.greenMask = a_green_mask ;
+ new_visual.blueMask = a_blue_mask ;
+ found_visual = TRUE ;
+ EPHYR_LOG ("found a visual that matches visual id: %d\n",
+ a_new_id) ;
+ break;
+ }
+ }
+ if (!found_visual) {
+ EPHYR_LOG ("did not find any visual matching %d\n", a_new_id) ;
+ goto out ;
+ }
+ /*
+ * be prepare to extend screen->visuals to add new_visual to it
+ */
+ new_visuals = xcalloc (screen->numVisuals+1, sizeof (VisualRec)) ;
+ memmove (new_visuals,
+ screen->visuals,
+ screen->numVisuals*sizeof (VisualRec)) ;
+ memmove (&new_visuals[screen->numVisuals],
+ &new_visual,
+ sizeof (VisualRec)) ;
+ /*
+ * Now, in that same screen, update the screen->allowedDepths member.
+ * In that array, each element represents the visuals applicable to
+ * a given depth. So we need to add an entry matching the new visual
+ * that we are going to add to screen->visuals
+ */
+ for (i=0; i<screen->numDepths; i++) {
+ VisualID *vids=NULL;
+ DepthPtr cur_depth=NULL ;
+ /*find the entry matching a_depth*/
+ if (screen->allowedDepths[i].depth != a_depth)
+ continue ;
+ cur_depth = &screen->allowedDepths[i];
+ /*
+ * extend the list of visual IDs in that entry,
+ * so to add a_new_id in there.
+ */
+ vids = xrealloc (cur_depth->vids,
+ (cur_depth->numVids+1)*sizeof (VisualID));
+ if (!vids) {
+ EPHYR_LOG_ERROR ("failed to realloc numids\n") ;
+ goto out ;
+ }
+ vids[cur_depth->numVids] = a_new_id ;
+ /*
+ * Okay now commit our change.
+ * Do really update screen->allowedDepths[i]
+ */
+ cur_depth->numVids++ ;
+ cur_depth->vids = vids ;
+ found_depth=TRUE;
+ }
+ if (!found_depth) {
+ EPHYR_LOG_ERROR ("failed to update screen[%d]->allowedDepth\n",
+ a_screen) ;
+ goto out ;
+ }
+ /*
+ * Commit our change to screen->visuals
+ */
+ xfree (screen->visuals) ;
+ screen->visuals = new_visuals ;
+ screen->numVisuals++ ;
+ new_visuals = NULL ;
+
+ is_ok = TRUE ;
+out:
+ if (new_visuals) {
+ xfree (new_visuals) ;
+ new_visuals = NULL ;
+ }
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+/**
+ * Duplicates the visuals of the host X server.
+ * This is necessary to have visuals that have the same
+ * ID as those of the host X. It is important to have that for
+ * GLX.
+ */
+static Bool
+EphyrMirrorHostVisuals (ScreenPtr a_screen)
+{
+ Bool is_ok=FALSE;
+ EphyrHostVisualInfo *visuals=NULL;
+ int nb_visuals=0, i=0;
+
+ EPHYR_LOG ("enter\n") ;
+ if (!hostx_get_visuals_info (&visuals, &nb_visuals)) {
+ EPHYR_LOG_ERROR ("failed to get host visuals\n") ;
+ goto out ;
+ }
+ for (i=0; i<nb_visuals; i++) {
+ if (!EphyrDuplicateVisual (a_screen->myNum,
+ visuals[i].depth,
+ visuals[i].class,
+ visuals[i].bits_per_rgb,
+ visuals[i].colormap_size,
+ visuals[i].red_mask,
+ visuals[i].green_mask,
+ visuals[i].blue_mask,
+ visuals[i].visualid)) {
+ EPHYR_LOG_ERROR ("failed to duplicate host visual %d\n",
+ (int)visuals[i].visualid) ;
+ }
+ }
+
+ is_ok = TRUE ;
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok;
+}
+
+
+/*ARGSUSED*/
+static void
+XF86DRIResetProc (
+ ExtensionEntry* extEntry
+)
+{
+}
+
+static int
+ProcXF86DRIQueryVersion (register ClientPtr client)
+{
+ xXF86DRIQueryVersionReply rep;
+ register int n;
+
+ EPHYR_LOG ("enter\n") ;
+
+ REQUEST_SIZE_MATCH(xXF86DRIQueryVersionReq);
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.majorVersion = XF86DRI_MAJOR_VERSION;
+ rep.minorVersion = XF86DRI_MINOR_VERSION;
+ rep.patchVersion = XF86DRI_PATCH_VERSION;
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ swaps(&rep.majorVersion, n);
+ swaps(&rep.minorVersion, n);
+ swapl(&rep.patchVersion, n);
+ }
+ WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *)&rep);
+ EPHYR_LOG ("leave\n") ;
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIQueryDirectRenderingCapable (register ClientPtr client)
+{
+ xXF86DRIQueryDirectRenderingCapableReply rep;
+ Bool isCapable;
+ register int n;
+
+ EPHYR_LOG ("enter\n") ;
+ REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
+ REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!ephyrDRIQueryDirectRenderingCapable (stuff->screen, &isCapable)) {
+ return BadValue;
+ }
+ rep.isCapable = isCapable;
+
+ if (!LocalClient(client) || client->swapped)
+ rep.isCapable = 0;
+
+ if (client->swapped) {
+ swaps(&rep.sequenceNumber, n);
+ swapl(&rep.length, n);
+ }
+
+ WriteToClient(client, sizeof(xXF86DRIQueryDirectRenderingCapableReply), (char *)&rep);
+ EPHYR_LOG ("leave\n") ;
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIOpenConnection (register ClientPtr client)
+{
+ xXF86DRIOpenConnectionReply rep;
+ drm_handle_t hSAREA;
+ char* busIdString;
+
+ EPHYR_LOG ("enter\n") ;
+ REQUEST(xXF86DRIOpenConnectionReq);
+ REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ if (!ephyrDRIOpenConnection(stuff->screen,
+ &hSAREA,
+ &busIdString)) {
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.busIdStringLength = 0;
+ if (busIdString)
+ rep.busIdStringLength = strlen(busIdString);
+ rep.length = (SIZEOF(xXF86DRIOpenConnectionReply) - SIZEOF(xGenericReply) +
+ ((rep.busIdStringLength + 3) & ~3)) >> 2;
+
+ rep.hSAREALow = (CARD32)(hSAREA & 0xffffffff);
+#if defined(LONG64) && !defined(__linux__)
+ rep.hSAREAHigh = (CARD32)(hSAREA >> 32);
+#else
+ rep.hSAREAHigh = 0;
+#endif
+
+ WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), (char *)&rep);
+ if (rep.busIdStringLength)
+ WriteToClient(client, rep.busIdStringLength, busIdString);
+ EPHYR_LOG ("leave\n") ;
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIAuthConnection (register ClientPtr client)
+{
+ xXF86DRIAuthConnectionReply rep;
+
+ EPHYR_LOG ("enter\n") ;
+ REQUEST(xXF86DRIAuthConnectionReq);
+ REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+ rep.authenticated = 1;
+
+ if (!ephyrDRIAuthConnection (stuff->screen, stuff->magic)) {
+ ErrorF("Failed to authenticate %lu\n", (unsigned long)stuff->magic);
+ rep.authenticated = 0;
+ }
+ WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), (char *)&rep);
+ EPHYR_LOG ("leave\n") ;
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRICloseConnection (register ClientPtr client)
+{
+ EPHYR_LOG ("enter\n") ;
+ REQUEST(xXF86DRICloseConnectionReq);
+ REQUEST_SIZE_MATCH(xXF86DRICloseConnectionReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ /*
+ DRICloseConnection( screenInfo.screens[stuff->screen]);
+ */
+
+ EPHYR_LOG ("leave\n") ;
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIGetClientDriverName (register ClientPtr client)
+{
+ xXF86DRIGetClientDriverNameReply rep;
+ char* clientDriverName;
+
+ EPHYR_LOG ("enter\n") ;
+ REQUEST(xXF86DRIGetClientDriverNameReq);
+ REQUEST_SIZE_MATCH(xXF86DRIGetClientDriverNameReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ ephyrDRIGetClientDriverName (stuff->screen,
+ (int *)&rep.ddxDriverMajorVersion,
+ (int *)&rep.ddxDriverMinorVersion,
+ (int *)&rep.ddxDriverPatchVersion,
+ &clientDriverName);
+
+ rep.type = X_Reply;
+ rep.sequenceNumber = client->sequence;
+ rep.clientDriverNameLength = 0;
+ if (clientDriverName)
+ rep.clientDriverNameLength = strlen(clientDriverName);
+ rep.length = (SIZEOF(xXF86DRIGetClientDriverNameReply) -
+ SIZEOF(xGenericReply) +
+ ((rep.clientDriverNameLength + 3) & ~3)) >> 2;
+
+ WriteToClient(client,
+ sizeof(xXF86DRIGetClientDriverNameReply), (char *)&rep);
+ if (rep.clientDriverNameLength)
+ WriteToClient(client,
+ rep.clientDriverNameLength,
+ clientDriverName);
+ EPHYR_LOG ("leave\n") ;
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRICreateContext (register ClientPtr client)
+{
+ xXF86DRICreateContextReply rep;
+ ScreenPtr pScreen;
+ VisualPtr visual;
+ int i=0;
+ unsigned long context_id=0;
+
+ EPHYR_LOG ("enter\n") ;
+ REQUEST(xXF86DRICreateContextReq);
+ REQUEST_SIZE_MATCH(xXF86DRICreateContextReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ pScreen = screenInfo.screens[stuff->screen];
+ visual = pScreen->visuals;
+
+ /* Find the requested X visual */
+ for (i = 0; i < pScreen->numVisuals; i++, visual++)
+ if (visual->vid == stuff->visual)
+ break;
+ if (i == pScreen->numVisuals) {
+ /* No visual found */
+ return BadValue;
+ }
+
+ context_id = stuff->context ;
+ if (!ephyrDRICreateContext (stuff->screen,
+ stuff->visual,
+ &context_id,
+ (drm_context_t *)&rep.hHWContext)) {
+ return BadValue;
+ }
+
+ WriteToClient(client, sizeof(xXF86DRICreateContextReply), (char *)&rep);
+ EPHYR_LOG ("leave\n") ;
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIDestroyContext (register ClientPtr client)
+{
+ EPHYR_LOG ("enter\n") ;
+
+ REQUEST(xXF86DRIDestroyContextReq);
+ REQUEST_SIZE_MATCH(xXF86DRIDestroyContextReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ if (!ephyrDRIDestroyContext (stuff->screen, stuff->context)) {
+ return BadValue;
+ }
+
+ EPHYR_LOG ("leave\n") ;
+ return (client->noClientException);
+}
+
+static Bool
+getWindowVisual (const WindowPtr a_win,
+ VisualPtr *a_visual)
+{
+ int i=0, visual_id=0 ;
+ EPHYR_RETURN_VAL_IF_FAIL (a_win
+ && a_win->drawable.pScreen
+ && a_win->drawable.pScreen->visuals,
+ FALSE) ;
+
+ visual_id = wVisual (a_win) ;
+ for (i=0; i < a_win->drawable.pScreen->numVisuals; i++) {
+ if (a_win->drawable.pScreen->visuals[i].vid == visual_id) {
+ *a_visual = &a_win->drawable.pScreen->visuals[i] ;
+ return TRUE ;
+ }
+ }
+ return FALSE ;
+}
+
+
+#define NUM_WINDOW_PAIRS 256
+static EphyrWindowPair window_pairs[NUM_WINDOW_PAIRS] ;
+
+static Bool
+appendWindowPairToList (WindowPtr a_local,
+ int a_remote)
+{
+ int i=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_local, FALSE) ;
+
+ EPHYR_LOG ("(local,remote):(%#x, %d)\n", (unsigned int)a_local, a_remote) ;
+
+ for (i=0; i < NUM_WINDOW_PAIRS; i++) {
+ if (window_pairs[i].local == NULL) {
+ window_pairs[i].local = a_local ;
+ window_pairs[i].remote = a_remote ;
+ return TRUE ;
+ }
+ }
+ return FALSE ;
+}
+
+static Bool
+findWindowPairFromLocal (WindowPtr a_local,
+ EphyrWindowPair **a_pair)
+{
+ int i=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_pair && a_local, FALSE) ;
+
+ for (i=0; i < NUM_WINDOW_PAIRS; i++) {
+ if (window_pairs[i].local == a_local) {
+ *a_pair = &window_pairs[i] ;
+ EPHYR_LOG ("found (%#x, %d)\n",
+ (unsigned int)(*a_pair)->local,
+ (*a_pair)->remote) ;
+ return TRUE ;
+ }
+ }
+ return FALSE ;
+}
+
+Bool
+findWindowPairFromRemote (int a_remote,
+ EphyrWindowPair **a_pair)
+{
+ int i=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_pair, FALSE) ;
+
+ for (i=0; i < NUM_WINDOW_PAIRS; i++) {
+ if (window_pairs[i].remote == a_remote) {
+ *a_pair = &window_pairs[i] ;
+ EPHYR_LOG ("found (%p, %d)\n",
+ (*a_pair)->local,
+ (*a_pair)->remote) ;
+ return TRUE ;
+ }
+ }
+ return FALSE ;
+}
+
+static Bool
+createHostPeerWindow (const WindowPtr a_win,
+ int *a_peer_win)
+{
+ Bool is_ok=FALSE ;
+ VisualPtr visual=NULL;
+ EphyrBox geo ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_win && a_peer_win, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL (a_win->drawable.pScreen,
+ FALSE) ;
+
+ EPHYR_LOG ("enter. a_win '%#x'\n", (unsigned int)a_win) ;
+ if (!getWindowVisual (a_win, &visual)) {
+ EPHYR_LOG_ERROR ("failed to get window visual\n") ;
+ goto out ;
+ }
+ if (!visual) {
+ EPHYR_LOG_ERROR ("failed to create visual\n") ;
+ goto out ;
+ }
+ memset (&geo, 0, sizeof (geo)) ;
+ geo.x = a_win->drawable.x ;
+ geo.y = a_win->drawable.y ;
+ geo.width = a_win->drawable.width ;
+ geo.height = a_win->drawable.height ;
+ if (!hostx_create_window (a_win->drawable.pScreen->myNum,
+ &geo, visual->vid, a_peer_win)) {
+ EPHYR_LOG_ERROR ("failed to create host peer window\n") ;
+ goto out ;
+ }
+ if (!appendWindowPairToList (a_win, *a_peer_win)) {
+ EPHYR_LOG_ERROR ("failed to append window to pair list\n") ;
+ goto out ;
+ }
+ is_ok = TRUE ;
+out:
+ EPHYR_LOG ("leave:remote win%d\n", *a_peer_win) ;
+ return is_ok ;
+}
+
+static Bool
+destroyHostPeerWindow (const WindowPtr a_win)
+{
+ Bool is_ok = FALSE ;
+ EphyrWindowPair *pair=NULL ;
+ EPHYR_RETURN_VAL_IF_FAIL (a_win, FALSE) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ if (!findWindowPairFromLocal (a_win, &pair) || !pair) {
+ EPHYR_LOG_ERROR ("failed to find peer to local window\n") ;
+ goto out;
+ }
+ hostx_destroy_window (pair->remote) ;
+ is_ok = TRUE ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok;
+}
+
+static int
+ProcXF86DRICreateDrawable (ClientPtr client)
+{
+ xXF86DRICreateDrawableReply rep;
+ DrawablePtr drawable=NULL;
+ WindowPtr window=NULL ;
+ EphyrWindowPair *pair=NULL ;
+ EphyrDRIWindowPrivPtr win_priv=NULL;
+ int rc=0, remote_win=0;
+
+ EPHYR_LOG ("enter\n") ;
+ REQUEST(xXF86DRICreateDrawableReq);
+ REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ rc = dixLookupDrawable (&drawable, stuff->drawable, client, 0,
+ DixReadAccess);
+ if (rc != Success)
+ return rc;
+ if (drawable->type != DRAWABLE_WINDOW) {
+ EPHYR_LOG_ERROR ("non drawable windows are not yet supported\n") ;
+ return BadImplementation ;
+ }
+ EPHYR_LOG ("lookedup drawable %#x\n", (unsigned int)drawable) ;
+ window = (WindowPtr)drawable;
+ if (findWindowPairFromLocal (window, &pair) && pair) {
+ remote_win = pair->remote ;
+ EPHYR_LOG ("found window '%#x' paire with remote '%d'\n",
+ (unsigned int)window, remote_win) ;
+ } else if (!createHostPeerWindow (window, &remote_win)) {
+ EPHYR_LOG_ERROR ("failed to create host peer window\n") ;
+ return BadAlloc ;
+ }
+
+ if (!ephyrDRICreateDrawable (stuff->screen,
+ remote_win,
+ (drm_drawable_t *)&rep.hHWDrawable)) {
+ EPHYR_LOG_ERROR ("failed to create dri drawable\n") ;
+ return BadValue;
+ }
+
+ win_priv = GET_EPHYR_DRI_WINDOW_PRIV (window) ;
+ if (!win_priv) {
+ win_priv = xcalloc (1, sizeof (EphyrDRIWindowPrivRec)) ;
+ if (!win_priv) {
+ EPHYR_LOG_ERROR ("failed to allocate window private\n") ;
+ return BadAlloc ;
+ }
+ dixSetPrivate(&window->devPrivates, ephyrDRIWindowKey, win_priv);
+ EPHYR_LOG ("paired window '%#x' with remote '%d'\n",
+ (unsigned int)window, remote_win) ;
+ }
+
+ WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), (char *)&rep);
+ EPHYR_LOG ("leave\n") ;
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIDestroyDrawable (register ClientPtr client)
+{
+ REQUEST(xXF86DRIDestroyDrawableReq);
+ DrawablePtr drawable=NULL;
+ WindowPtr window=NULL;
+ EphyrWindowPair *pair=NULL;
+ REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq);
+ int rc=0;
+
+ EPHYR_LOG ("enter\n") ;
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rc = dixLookupDrawable(&drawable,
+ stuff->drawable,
+ client,
+ 0,
+ DixReadAccess);
+ if (rc != Success)
+ return rc;
+ if (drawable->type != DRAWABLE_WINDOW) {
+ EPHYR_LOG_ERROR ("non drawable windows are not yet supported\n") ;
+ return BadImplementation ;
+ }
+ window = (WindowPtr)drawable;
+ if (!findWindowPairFromLocal (window, &pair) && pair) {
+ EPHYR_LOG_ERROR ("failed to find pair window\n") ;
+ return BadImplementation;
+ }
+ if (!ephyrDRIDestroyDrawable(stuff->screen,
+ pair->remote/*drawable in host x*/)) {
+ EPHYR_LOG_ERROR ("failed to destroy dri drawable\n") ;
+ return BadImplementation;
+ }
+ pair->local=NULL ;
+ pair->remote=0;
+
+ EPHYR_LOG ("leave\n") ;
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIGetDrawableInfo (register ClientPtr client)
+{
+ xXF86DRIGetDrawableInfoReply rep;
+ DrawablePtr drawable;
+ WindowPtr window=NULL;
+ EphyrWindowPair *pair=NULL;
+ int X=0, Y=0, W=0, H=0, backX=0, backY=0, rc=0, i=0;
+ drm_clip_rect_t *clipRects=NULL;
+ drm_clip_rect_t *backClipRects=NULL;
+
+ EPHYR_LOG ("enter\n") ;
+ memset (&rep, 0, sizeof (rep)) ;
+ REQUEST(xXF86DRIGetDrawableInfoReq);
+ REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ rc = dixLookupDrawable(&drawable, stuff->drawable, client, 0,
+ DixReadAccess);
+ if (rc != Success || !drawable) {
+ EPHYR_LOG_ERROR ("could not get drawable\n") ;
+ return rc;
+ }
+
+ if (drawable->type != DRAWABLE_WINDOW) {
+ EPHYR_LOG_ERROR ("non windows type drawables are not yes supported\n") ;
+ return BadImplementation ;
+ }
+ window = (WindowPtr)drawable ;
+ memset (&pair, 0, sizeof (pair)) ;
+ if (!findWindowPairFromLocal (window, &pair) || !pair) {
+ EPHYR_LOG_ERROR ("failed to find remote peer drawable\n") ;
+ return BadMatch ;
+ }
+ EPHYR_LOG ("clip list of xephyr gl drawable:\n") ;
+ for (i=0; i < REGION_NUM_RECTS (&window->clipList); i++) {
+ EPHYR_LOG ("x1:%d, y1:%d, x2:%d, y2:%d\n",
+ REGION_RECTS (&window->clipList)[i].x1,
+ REGION_RECTS (&window->clipList)[i].y1,
+ REGION_RECTS (&window->clipList)[i].x2,
+ REGION_RECTS (&window->clipList)[i].y2) ;
+ }
+
+ if (!ephyrDRIGetDrawableInfo (stuff->screen,
+ pair->remote/*the drawable in hostx*/,
+ (unsigned int*)&rep.drawableTableIndex,
+ (unsigned int*)&rep.drawableTableStamp,
+ (int*)&X,
+ (int*)&Y,
+ (int*)&W,
+ (int*)&H,
+ (int*)&rep.numClipRects,
+ &clipRects,
+ &backX,
+ &backY,
+ (int*)&rep.numBackClipRects,
+ &backClipRects)) {
+ return BadValue;
+ }
+ EPHYR_LOG ("num clip rects:%d, num back clip rects:%d\n",
+ (int)rep.numClipRects, (int)rep.numBackClipRects) ;
+
+ rep.drawableX = X;
+ rep.drawableY = Y;
+ rep.drawableWidth = W;
+ rep.drawableHeight = H;
+ rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) -
+ SIZEOF(xGenericReply));
+
+ rep.backX = backX;
+ rep.backY = backY;
+
+
+ if (rep.numClipRects) {
+ if (clipRects) {
+ ScreenPtr pScreen = screenInfo.screens[stuff->screen];
+ int i=0;
+ EPHYR_LOG ("clip list of host gl drawable:\n") ;
+ for (i = 0; i < rep.numClipRects; i++) {
+ clipRects[i].x1 = max (clipRects[i].x1, 0);
+ clipRects[i].y1 = max (clipRects[i].y1, 0);
+ clipRects[i].x2 = min (clipRects[i].x2,
+ pScreen->width + clipRects[i].x1) ;
+ clipRects[i].y2 = min (clipRects[i].y2,
+ pScreen->width + clipRects[i].y1) ;
+
+ EPHYR_LOG ("x1:%d, y1:%d, x2:%d, y2:%d\n",
+ clipRects[i].x1, clipRects[i].y1,
+ clipRects[i].x2, clipRects[i].y2) ;
+ }
+ } else {
+ rep.numClipRects = 0;
+ }
+ } else {
+ EPHYR_LOG ("got zero host gl drawable clipping rects\n") ;
+ }
+ rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
+ backClipRects = clipRects ;
+ rep.numBackClipRects = rep.numClipRects ;
+ if (rep.numBackClipRects)
+ rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects;
+ EPHYR_LOG ("num host clip rects:%d\n", (int)rep.numClipRects) ;
+ EPHYR_LOG ("num host back clip rects:%d\n", (int)rep.numBackClipRects) ;
+
+ rep.length = ((rep.length + 3) & ~3) >> 2;
+
+ WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *)&rep);
+
+ if (rep.numClipRects) {
+ WriteToClient(client,
+ sizeof(drm_clip_rect_t) * rep.numClipRects,
+ (char *)clipRects);
+ }
+
+ if (rep.numBackClipRects) {
+ WriteToClient(client,
+ sizeof(drm_clip_rect_t) * rep.numBackClipRects,
+ (char *)backClipRects);
+ }
+ if (clipRects) {
+ xfree(clipRects);
+ clipRects = NULL ;
+ }
+ EPHYR_LOG ("leave\n") ;
+
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIGetDeviceInfo (register ClientPtr client)
+{
+ xXF86DRIGetDeviceInfoReply rep;
+ drm_handle_t hFrameBuffer;
+ void *pDevPrivate;
+
+ EPHYR_LOG ("enter\n") ;
+ REQUEST(xXF86DRIGetDeviceInfoReq);
+ REQUEST_SIZE_MATCH(xXF86DRIGetDeviceInfoReq);
+ if (stuff->screen >= screenInfo.numScreens) {
+ client->errorValue = stuff->screen;
+ return BadValue;
+ }
+
+ rep.type = X_Reply;
+ rep.length = 0;
+ rep.sequenceNumber = client->sequence;
+
+ if (!ephyrDRIGetDeviceInfo (stuff->screen,
+ &hFrameBuffer,
+ (int*)&rep.framebufferOrigin,
+ (int*)&rep.framebufferSize,
+ (int*)&rep.framebufferStride,
+ (int*)&rep.devPrivateSize,
+ &pDevPrivate)) {
+ return BadValue;
+ }
+
+ rep.hFrameBufferLow = (CARD32)(hFrameBuffer & 0xffffffff);
+#if defined(LONG64) && !defined(__linux__)
+ rep.hFrameBufferHigh = (CARD32)(hFrameBuffer >> 32);
+#else
+ rep.hFrameBufferHigh = 0;
+#endif
+
+ rep.length = 0;
+ if (rep.devPrivateSize) {
+ rep.length = (SIZEOF(xXF86DRIGetDeviceInfoReply) -
+ SIZEOF(xGenericReply) +
+ ((rep.devPrivateSize + 3) & ~3)) >> 2;
+ }
+
+ WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *)&rep);
+ if (rep.length) {
+ WriteToClient(client, rep.devPrivateSize, (char *)pDevPrivate);
+ }
+ EPHYR_LOG ("leave\n") ;
+ return (client->noClientException);
+}
+
+static int
+ProcXF86DRIDispatch (register ClientPtr client)
+{
+ REQUEST(xReq);
+ EPHYR_LOG ("enter\n") ;
+
+ switch (stuff->data)
+ {
+ case X_XF86DRIQueryVersion: {
+ EPHYR_LOG ("leave\n") ;
+ return ProcXF86DRIQueryVersion(client);
+ }
+ case X_XF86DRIQueryDirectRenderingCapable: {
+ EPHYR_LOG ("leave\n") ;
+ return ProcXF86DRIQueryDirectRenderingCapable(client);
+ }
+ }
+
+ if (!LocalClient(client))
+ return DRIErrorBase + XF86DRIClientNotLocal;
+
+ switch (stuff->data)
+ {
+ case X_XF86DRIOpenConnection: {
+ EPHYR_LOG ("leave\n") ;
+ return ProcXF86DRIOpenConnection(client);
+ }
+ case X_XF86DRICloseConnection: {
+ EPHYR_LOG ("leave\n") ;
+ return ProcXF86DRICloseConnection(client);
+ }
+ case X_XF86DRIGetClientDriverName: {
+ EPHYR_LOG ("leave\n") ;
+ return ProcXF86DRIGetClientDriverName(client);
+ }
+ case X_XF86DRICreateContext: {
+ EPHYR_LOG ("leave\n") ;
+ return ProcXF86DRICreateContext(client);
+ }
+ case X_XF86DRIDestroyContext: {
+ EPHYR_LOG ("leave\n") ;
+ return ProcXF86DRIDestroyContext(client);
+ }
+ case X_XF86DRICreateDrawable: {
+ EPHYR_LOG ("leave\n") ;
+ return ProcXF86DRICreateDrawable(client);
+ }
+ case X_XF86DRIDestroyDrawable: {
+ EPHYR_LOG ("leave\n") ;
+ return ProcXF86DRIDestroyDrawable(client);
+ }
+ case X_XF86DRIGetDrawableInfo: {
+ EPHYR_LOG ("leave\n") ;
+ return ProcXF86DRIGetDrawableInfo(client);
+ }
+ case X_XF86DRIGetDeviceInfo: {
+ EPHYR_LOG ("leave\n") ;
+ return ProcXF86DRIGetDeviceInfo(client);
+ }
+ case X_XF86DRIAuthConnection: {
+ EPHYR_LOG ("leave\n") ;
+ return ProcXF86DRIAuthConnection(client);
+ }
+ /* {Open,Close}FullScreen are deprecated now */
+ default: {
+ EPHYR_LOG ("leave\n") ;
+ return BadRequest;
+ }
+ }
+}
+
+static int
+SProcXF86DRIQueryVersion (register ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86DRIQueryVersionReq);
+ swaps(&stuff->length, n);
+ return ProcXF86DRIQueryVersion(client);
+}
+
+static int
+SProcXF86DRIQueryDirectRenderingCapable (register ClientPtr client)
+{
+ register int n;
+ REQUEST(xXF86DRIQueryDirectRenderingCapableReq);
+ swaps(&stuff->length, n);
+ swapl(&stuff->screen, n);
+ return ProcXF86DRIQueryDirectRenderingCapable(client);
+}
+
+static int
+SProcXF86DRIDispatch (register ClientPtr client)
+{
+ REQUEST(xReq);
+
+ EPHYR_LOG ("enter\n") ;
+ /*
+ * Only local clients are allowed DRI access, but remote clients still need
+ * these requests to find out cleanly.
+ */
+ switch (stuff->data)
+ {
+ case X_XF86DRIQueryVersion: {
+ EPHYR_LOG ("leave\n") ;
+ return SProcXF86DRIQueryVersion(client);
+ }
+ case X_XF86DRIQueryDirectRenderingCapable: {
+ EPHYR_LOG ("leave\n") ;
+ return SProcXF86DRIQueryDirectRenderingCapable(client);
+ }
+ default: {
+ EPHYR_LOG ("leave\n") ;
+ return DRIErrorBase + XF86DRIClientNotLocal;
+ }
+ }
+}
+
+#endif /*XEPHYR_DRI*/
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdriext.h b/xorg-server/hw/kdrive/ephyr/ephyrdriext.h
new file mode 100644
index 000000000..01c9421fb
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrdriext.h
@@ -0,0 +1,42 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * 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 OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+#ifndef __EPHYRDRIEXT_H__
+#define __EPHYRDRIEXT_H__
+
+typedef struct {
+ WindowPtr local ;
+ int remote ;
+} EphyrWindowPair;
+
+Bool ephyrDRIExtensionInit (ScreenPtr a_screen) ;
+
+Bool findWindowPairFromRemote (int a_remote,
+ EphyrWindowPair **a_pair);
+
+#endif /*__EPHYRDRIEXT_H__*/
+
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrglxext.c b/xorg-server/hw/kdrive/ephyr/ephyrglxext.c
new file mode 100644
index 000000000..2cc14517b
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrglxext.c
@@ -0,0 +1,732 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * 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 OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+#include "extnsionst.h"
+#include "ephyrglxext.h"
+#include "ephyrhostglx.h"
+#define _HAVE_XALLOC_DECLS
+#include "ephyrlog.h"
+#include <GL/glxproto.h>
+#include "glx/glxserver.h"
+#include "glx/indirect_table.h"
+#include "glx/indirect_util.h"
+#include "glx/unpack.h"
+#include "hostx.h"
+
+
+#ifdef XEPHYR_DRI
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+
+int ephyrGLXQueryVersion (__GLXclientState *cl, GLbyte *pc) ;
+int ephyrGLXQueryVersionSwap (__GLXclientState *cl, GLbyte *pc) ;
+int ephyrGLXGetVisualConfigs (__GLXclientState *cl, GLbyte *pc) ;
+int ephyrGLXGetVisualConfigsSwap (__GLXclientState *cl, GLbyte *pc) ;
+int ephyrGLXClientInfo(__GLXclientState *cl, GLbyte *pc) ;
+int ephyrGLXClientInfoSwap(__GLXclientState *cl, GLbyte *pc) ;
+int ephyrGLXQueryServerString(__GLXclientState *a_cl, GLbyte *a_pc) ;
+int ephyrGLXQueryServerStringSwap(__GLXclientState *a_cl, GLbyte *a_pc) ;
+int ephyrGLXGetFBConfigsSGIX (__GLXclientState *a_cl, GLbyte *a_pc);
+int ephyrGLXGetFBConfigsSGIXSwap (__GLXclientState *a_cl, GLbyte *a_pc);
+int ephyrGLXCreateContext (__GLXclientState *a_cl, GLbyte *a_pc);
+int ephyrGLXCreateContextSwap (__GLXclientState *a_cl, GLbyte *a_pc);
+int ephyrGLXDestroyContext (__GLXclientState *a_cl, GLbyte *a_pc) ;
+int ephyrGLXDestroyContextSwap (__GLXclientState *a_cl, GLbyte *a_pc) ;
+int ephyrGLXMakeCurrent (__GLXclientState *a_cl, GLbyte *a_pc) ;
+int ephyrGLXMakeCurrentSwap (__GLXclientState *a_cl, GLbyte *a_pc) ;
+int ephyrGLXGetString (__GLXclientState *a_cl, GLbyte *a_pc) ;
+int ephyrGLXGetStringSwap (__GLXclientState *a_cl, GLbyte *a_pc) ;
+int ephyrGLXGetIntegerv (__GLXclientState *a_cl, GLbyte *a_pc) ;
+int ephyrGLXGetIntegervSwap (__GLXclientState *a_cl, GLbyte *a_pc) ;
+int ephyrGLXIsDirect (__GLXclientState *a_cl, GLbyte *a_pc) ;
+int ephyrGLXIsDirectSwap (__GLXclientState *a_cl, GLbyte *a_pc) ;
+
+Bool
+ephyrHijackGLXExtension (void)
+{
+ const void *(*dispatch_functions)[2];
+
+ if (!hostx_has_glx ()) {
+ EPHYR_LOG ("host X does not have GLX\n") ;
+ return FALSE ;
+ }
+ EPHYR_LOG ("host X does have GLX\n") ;
+
+ if (!Single_dispatch_info.dispatch_functions) {
+ EPHYR_LOG_ERROR ("could not get dispatch functions table\n") ;
+ return FALSE ;
+ }
+ /*
+ * hijack some single entry point dispatch functions
+ */
+ dispatch_functions = Single_dispatch_info.dispatch_functions ;
+ EPHYR_RETURN_VAL_IF_FAIL (dispatch_functions, FALSE) ;
+
+ dispatch_functions[X_GLXQueryVersion][0] = ephyrGLXQueryVersion ;
+ dispatch_functions[X_GLXQueryVersion][1] = ephyrGLXQueryVersionSwap ;
+
+ dispatch_functions[X_GLXGetVisualConfigs][0] = ephyrGLXGetVisualConfigs ;
+ dispatch_functions[X_GLXGetVisualConfigs][1] = ephyrGLXGetVisualConfigsSwap ;
+ dispatch_functions[X_GLXClientInfo][0] = ephyrGLXClientInfo ;
+ dispatch_functions[X_GLXClientInfo][1] = ephyrGLXClientInfoSwap ;
+
+ dispatch_functions[X_GLXQueryServerString][0] = ephyrGLXQueryServerString ;
+ dispatch_functions[X_GLXQueryServerString][1] =
+ ephyrGLXQueryServerStringSwap ;
+
+ dispatch_functions[X_GLXCreateContext][0] = ephyrGLXCreateContext ;
+ dispatch_functions[X_GLXCreateContext][1] = ephyrGLXCreateContextSwap ;
+
+ dispatch_functions[X_GLXDestroyContext][0] = ephyrGLXDestroyContext ;
+ dispatch_functions[X_GLXDestroyContext][1] = ephyrGLXDestroyContextSwap ;
+
+ dispatch_functions[X_GLXMakeCurrent][0] = ephyrGLXMakeCurrent ;
+ dispatch_functions[X_GLXMakeCurrent][1] = ephyrGLXMakeCurrentSwap ;
+
+ dispatch_functions[X_GLXIsDirect][0] = ephyrGLXIsDirect ;
+ dispatch_functions[X_GLXIsDirect][1] = ephyrGLXIsDirectSwap ;
+
+ dispatch_functions[73][0] = ephyrGLXGetString ;
+ dispatch_functions[73][1] = ephyrGLXGetStringSwap ;
+
+ dispatch_functions[61][0] = ephyrGLXGetIntegerv ;
+ dispatch_functions[61][1] = ephyrGLXGetIntegervSwap ;
+
+ /*
+ * hijack some vendor priv entry point dispatch functions
+ */
+ dispatch_functions = VendorPriv_dispatch_info.dispatch_functions ;
+ dispatch_functions[92][0] = ephyrGLXGetFBConfigsSGIX;
+ dispatch_functions[92][1] = ephyrGLXGetFBConfigsSGIXSwap;
+ EPHYR_LOG ("hijacked glx entry points to forward requests to host X\n") ;
+
+ return TRUE ;
+}
+
+/*********************
+ * implementation of
+ * hijacked GLX entry
+ * points
+ ********************/
+
+int
+ephyrGLXQueryVersion(__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ ClientPtr client = a_cl->client;
+ xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) a_pc;
+ xGLXQueryVersionReply reply;
+ int major, minor;
+ int res = BadImplementation ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ major = req->majorVersion ;
+ minor = req->minorVersion ;
+
+ if (!ephyrHostGLXQueryVersion (&major, &minor)) {
+ EPHYR_LOG_ERROR ("ephyrHostGLXQueryVersion() failed\n") ;
+ goto out ;
+ }
+ EPHYR_LOG ("major:%d, minor:%d\n",
+ major, minor);
+ reply.majorVersion = major ;
+ reply.minorVersion = minor ;
+ reply.length = 0 ;
+ reply.type = X_Reply ;
+ reply.sequenceNumber = client->sequence ;
+
+ if (client->swapped) {
+ __glXSwapQueryVersionReply(client, &reply);
+ } else {
+ WriteToClient(client, sz_xGLXQueryVersionReply, (char *)&reply);
+ }
+
+ res = Success ;
+out:
+ EPHYR_LOG ("leave\n") ;
+ return res;
+}
+
+int
+ephyrGLXQueryVersionSwap (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ xGLXQueryVersionReq *req = (xGLXQueryVersionReq *) a_pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT (&req->length);
+ __GLX_SWAP_INT (&req->majorVersion);
+ __GLX_SWAP_INT (&req->minorVersion);
+ return ephyrGLXQueryVersion (a_cl, a_pc) ;
+}
+
+static int
+ephyrGLXGetVisualConfigsReal (__GLXclientState *a_cl,
+ GLbyte *a_pc,
+ Bool a_do_swap)
+{
+ xGLXGetVisualConfigsReq *req = (xGLXGetVisualConfigsReq *) a_pc;
+ ClientPtr client = a_cl->client;
+ xGLXGetVisualConfigsReply reply;
+ int32_t *props_buf=NULL, num_visuals=0,
+ num_props=0, res=BadImplementation, i=0,
+ props_per_visual_size=0,
+ props_buf_size=0;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ EPHYR_LOG ("enter\n") ;
+
+ if (!ephyrHostGLXGetVisualConfigs (req->screen,
+ &num_visuals,
+ &num_props,
+ &props_buf_size,
+ &props_buf)) {
+ EPHYR_LOG_ERROR ("ephyrHostGLXGetVisualConfigs() failed\n") ;
+ goto out ;
+ }
+ EPHYR_LOG ("num_visuals:%d, num_props:%d\n", num_visuals, num_props) ;
+
+ reply.numVisuals = num_visuals;
+ reply.numProps = num_props;
+ reply.length = (num_visuals *__GLX_SIZE_CARD32 * num_props) >> 2;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (a_do_swap) {
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.numVisuals);
+ __GLX_SWAP_INT(&reply.numProps);
+ __GLX_SWAP_INT_ARRAY (props_buf, num_props) ;
+ }
+ WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char*)&reply);
+ props_per_visual_size = props_buf_size/num_visuals ;
+ for (i=0; i < num_visuals; i++) {
+ WriteToClient (client,
+ props_per_visual_size,
+ (char*)props_buf +i*props_per_visual_size);
+ }
+ res = Success ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ if (props_buf) {
+ xfree (props_buf) ;
+ props_buf = NULL ;
+ }
+ return res ;
+}
+
+static int
+ephyrGLXGetFBConfigsSGIXReal (__GLXclientState *a_cl,
+ GLbyte *a_pc,
+ Bool a_do_swap)
+{
+ xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *)a_pc;
+ ClientPtr client = a_cl->client;
+ xGLXGetVisualConfigsReply reply;
+ int32_t *props_buf=NULL, num_visuals=0,
+ num_props=0, res=BadImplementation, i=0,
+ props_per_visual_size=0,
+ props_buf_size=0;
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
+
+ EPHYR_LOG ("enter\n") ;
+
+ if (!ephyrHostGLXVendorPrivGetFBConfigsSGIX (req->screen,
+ &num_visuals,
+ &num_props,
+ &props_buf_size,
+ &props_buf)) {
+ EPHYR_LOG_ERROR ("ephyrHostGLXGetVisualConfigs() failed\n") ;
+ goto out ;
+ }
+ EPHYR_LOG ("num_visuals:%d, num_props:%d\n", num_visuals, num_props) ;
+
+ reply.numVisuals = num_visuals;
+ reply.numProps = num_props;
+ reply.length = props_buf_size >> 2;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+
+ if (a_do_swap) {
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.numVisuals);
+ __GLX_SWAP_INT(&reply.numProps);
+ __GLX_SWAP_INT_ARRAY (props_buf, num_props) ;
+ }
+ WriteToClient(client, sz_xGLXGetVisualConfigsReply, (char*)&reply);
+ props_per_visual_size = props_buf_size/num_visuals ;
+ for (i=0; i < num_visuals; i++) {
+ WriteToClient (client,
+ props_per_visual_size,
+ &((char*)props_buf)[i*props_per_visual_size]);
+ }
+ res = Success ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ if (props_buf) {
+ xfree (props_buf) ;
+ props_buf = NULL ;
+ }
+ return res ;
+}
+
+int
+ephyrGLXGetVisualConfigs (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ return ephyrGLXGetVisualConfigsReal (a_cl, a_pc, FALSE) ;
+}
+
+int
+ephyrGLXGetVisualConfigsSwap (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ return ephyrGLXGetVisualConfigsReal (a_cl, a_pc, TRUE) ;
+}
+
+
+int
+ephyrGLXClientInfo(__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ int res=BadImplementation ;
+ xGLXClientInfoReq *req = (xGLXClientInfoReq *) a_pc;
+
+ EPHYR_LOG ("enter\n") ;
+ if (!ephyrHostGLXSendClientInfo (req->major, req->minor, (char*)req+1)) {
+ EPHYR_LOG_ERROR ("failed to send client info to host\n") ;
+ goto out ;
+ }
+ res = Success ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return res ;
+}
+
+int
+ephyrGLXClientInfoSwap (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ xGLXClientInfoReq *req = (xGLXClientInfoReq *)a_pc;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ __GLX_SWAP_SHORT (&req->length);
+ __GLX_SWAP_INT (&req->major);
+ __GLX_SWAP_INT (&req->minor);
+ __GLX_SWAP_INT (&req->numbytes);
+
+ return ephyrGLXClientInfo (a_cl, a_pc) ;
+}
+
+int
+ephyrGLXQueryServerString(__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ int res = BadImplementation ;
+ ClientPtr client = a_cl->client;
+ xGLXQueryServerStringReq *req = (xGLXQueryServerStringReq *) a_pc;
+ xGLXQueryServerStringReply reply;
+ char *server_string=NULL, *buf=NULL;
+ int length=0 ;
+
+ EPHYR_LOG ("enter\n") ;
+ if (!ephyrHostGLXGetStringFromServer (req->screen,
+ req->name,
+ EPHYR_HOST_GLX_QueryServerString,
+ &server_string)) {
+ EPHYR_LOG_ERROR ("failed to query string from host\n") ;
+ goto out ;
+ }
+ EPHYR_LOG ("string: %s\n", server_string) ;
+ length= strlen (server_string) + 1;
+ reply.type = X_Reply ;
+ reply.sequenceNumber = client->sequence ;
+ reply.length = __GLX_PAD (length) >> 2 ;
+ reply.n = length ;
+ buf = xcalloc (reply.length << 2, 1);
+ if (!buf) {
+ EPHYR_LOG_ERROR ("failed to allocate string\n;");
+ return BadAlloc;
+ }
+ memcpy (buf, server_string, length);
+
+ WriteToClient(client, sz_xGLXQueryServerStringReply, (char*)&reply);
+ WriteToClient(client, (int)(reply.length << 2), server_string);
+
+ res = Success ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ if (server_string) {
+ xfree (server_string) ;
+ server_string = NULL;
+ }
+ if (buf) {
+ xfree (buf);
+ buf = NULL;
+ }
+ return res ;
+}
+
+int
+ephyrGLXQueryServerStringSwap(__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ EPHYR_LOG_ERROR ("not yet implemented\n") ;
+ return BadImplementation ;
+}
+
+
+int
+ephyrGLXGetFBConfigsSGIX (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ return ephyrGLXGetFBConfigsSGIXReal (a_cl, a_pc, FALSE) ;
+}
+
+int
+ephyrGLXGetFBConfigsSGIXSwap (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ return ephyrGLXGetFBConfigsSGIXReal (a_cl, a_pc, TRUE) ;
+}
+
+static int
+ephyrGLXCreateContextReal (xGLXCreateContextReq *a_req, Bool a_do_swap)
+{
+ int res=BadImplementation;
+ EphyrHostWindowAttributes host_w_attrs ;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_req, BadValue) ;
+ EPHYR_LOG ("enter\n") ;
+
+ if (a_do_swap) {
+ __GLX_SWAP_SHORT(&a_req->length);
+ __GLX_SWAP_INT(&a_req->context);
+ __GLX_SWAP_INT(&a_req->visual);
+ __GLX_SWAP_INT(&a_req->screen);
+ __GLX_SWAP_INT(&a_req->shareList);
+ }
+
+ EPHYR_LOG ("context creation requested. localid:%d, "
+ "screen:%d, visual:%d, direct:%d\n",
+ (int)a_req->context, (int)a_req->screen,
+ (int)a_req->visual, (int)a_req->isDirect) ;
+
+ memset (&host_w_attrs, 0, sizeof (host_w_attrs)) ;
+ if (!hostx_get_window_attributes (hostx_get_window (a_req->screen),
+ &host_w_attrs)) {
+ EPHYR_LOG_ERROR ("failed to get host window attrs\n") ;
+ goto out ;
+ }
+
+ EPHYR_LOG ("host window visual id: %d\n", host_w_attrs.visualid) ;
+
+ if (!ephyrHostGLXCreateContext (a_req->screen,
+ host_w_attrs.visualid,
+ a_req->context,
+ a_req->shareList,
+ a_req->isDirect)) {
+ EPHYR_LOG_ERROR ("ephyrHostGLXCreateContext() failed\n") ;
+ goto out ;
+ }
+ res = Success;
+out:
+ EPHYR_LOG ("leave\n") ;
+ return res ;
+}
+
+int
+ephyrGLXCreateContext (__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
+
+ return ephyrGLXCreateContextReal (req, FALSE) ;
+}
+
+int ephyrGLXCreateContextSwap (__GLXclientState *cl, GLbyte *pc)
+{
+ xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
+ return ephyrGLXCreateContextReal (req, TRUE) ;
+}
+
+static int
+ephyrGLXDestroyContextReal (__GLXclientState *a_cl,
+ GLbyte *a_pc,
+ Bool a_do_swap)
+{
+ int res=BadImplementation;
+ ClientPtr client = a_cl->client;
+ xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) a_pc;
+
+ EPHYR_LOG ("enter. id:%d\n", (int)req->context) ;
+ if (!ephyrHostDestroyContext (req->context)) {
+ EPHYR_LOG_ERROR ("ephyrHostDestroyContext() failed\n") ;
+ client->errorValue = req->context ;
+ goto out ;
+ }
+ res = Success ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return res ;
+}
+
+int
+ephyrGLXDestroyContext (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ return ephyrGLXDestroyContextReal (a_cl, a_pc, FALSE) ;
+}
+
+int
+ephyrGLXDestroyContextSwap (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ return ephyrGLXDestroyContextReal (a_cl, a_pc, TRUE) ;
+}
+
+static int
+ephyrGLXMakeCurrentReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
+{
+ int res=BadImplementation;
+ xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) a_pc;
+ xGLXMakeCurrentReply reply ;
+ DrawablePtr drawable=NULL;
+ int rc=0;
+
+ EPHYR_LOG ("enter\n") ;
+ rc = dixLookupDrawable (&drawable,
+ req->drawable,
+ a_cl->client,
+ 0,
+ DixReadAccess);
+ EPHYR_RETURN_VAL_IF_FAIL (drawable, BadValue) ;
+ EPHYR_RETURN_VAL_IF_FAIL (drawable->pScreen, BadValue) ;
+ EPHYR_LOG ("screen nummber requested:%d\n",
+ drawable->pScreen->myNum) ;
+
+ memset (&reply, 0, sizeof (reply)) ;
+ if (!ephyrHostGLXMakeCurrent (hostx_get_window (drawable->pScreen->myNum),
+ req->context,
+ req->oldContextTag,
+ (int*)&reply.contextTag)) {
+ EPHYR_LOG_ERROR ("ephyrHostGLXMakeCurrent() failed\n") ;
+ goto out;
+ }
+ reply.length = 0;
+ reply.type = X_Reply;
+ reply.sequenceNumber = a_cl->client->sequence;
+ if (a_do_swap) {
+ __GLX_DECLARE_SWAP_VARIABLES;
+ __GLX_SWAP_SHORT(&reply.sequenceNumber);
+ __GLX_SWAP_INT(&reply.length);
+ __GLX_SWAP_INT(&reply.contextTag);
+ }
+ WriteToClient(a_cl->client, sz_xGLXMakeCurrentReply, (char *)&reply);
+
+ res = Success ;
+out:
+ EPHYR_LOG ("leave\n") ;
+ return res ;
+}
+
+int
+ephyrGLXMakeCurrent (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ return ephyrGLXMakeCurrentReal (a_cl, a_pc, FALSE) ;
+}
+
+int
+ephyrGLXMakeCurrentSwap (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ return ephyrGLXMakeCurrentReal (a_cl, a_pc, TRUE) ;
+}
+
+static int
+ephyrGLXGetStringReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
+{
+ ClientPtr client=NULL ;
+ int context_tag=0, name=0, res=BadImplementation, length=0 ;
+ char *string=NULL;
+ __GLX_DECLARE_SWAP_VARIABLES;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_cl && a_pc, BadValue) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ client = a_cl->client ;
+
+ if (a_do_swap) {
+ __GLX_SWAP_INT (a_pc + 4);
+ __GLX_SWAP_INT (a_pc + __GLX_SINGLE_HDR_SIZE);
+ }
+ context_tag = __GLX_GET_SINGLE_CONTEXT_TAG (a_pc) ;
+ a_pc += __GLX_SINGLE_HDR_SIZE;
+ name = *(GLenum*)(a_pc + 0);
+ EPHYR_LOG ("context_tag:%d, name:%d\n", context_tag, name) ;
+ if (!ephyrHostGLXGetStringFromServer (context_tag,
+ name,
+ EPHYR_HOST_GLX_GetString,
+ &string)) {
+ EPHYR_LOG_ERROR ("failed to get string from server\n") ;
+ goto out ;
+ }
+ if (string) {
+ length = strlen (string) + 1;
+ EPHYR_LOG ("got string:'%s', size:%d\n", string, length) ;
+ } else {
+ EPHYR_LOG ("got string: string (null)\n") ;
+ }
+ __GLX_BEGIN_REPLY (length);
+ __GLX_PUT_SIZE (length);
+ __GLX_SEND_HEADER ();
+ if (a_do_swap) {
+ __GLX_SWAP_REPLY_SIZE ();
+ __GLX_SWAP_REPLY_HEADER ();
+ }
+ WriteToClient (client, length, (char *)string);
+
+ res = Success ;
+out:
+ EPHYR_LOG ("leave\n") ;
+ return res ;
+}
+
+int
+ephyrGLXGetString (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ return ephyrGLXGetStringReal (a_cl, a_pc, FALSE) ;
+}
+
+int
+ephyrGLXGetStringSwap (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ return ephyrGLXGetStringReal (a_cl, a_pc, TRUE) ;
+}
+
+static int
+ephyrGLXGetIntegervReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
+{
+ int res=BadImplementation;
+ xGLXSingleReq * const req = (xGLXSingleReq *) a_pc;
+ GLenum int_name ;
+ int value=0 ;
+ GLint answer_buf_room[200];
+ GLint *buf=NULL ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ a_pc += __GLX_SINGLE_HDR_SIZE;
+
+ int_name = *(GLenum*) (a_pc+0) ;
+ if (!ephyrHostGetIntegerValue (req->contextTag, int_name, &value)) {
+ EPHYR_LOG_ERROR ("ephyrHostGetIntegerValue() failed\n") ;
+ goto out ;
+ }
+ buf = __glXGetAnswerBuffer (a_cl, sizeof (value),
+ answer_buf_room,
+ sizeof (answer_buf_room),
+ 4) ;
+
+ if (!buf) {
+ EPHYR_LOG_ERROR ("failed to allocate reply buffer\n") ;
+ res = BadAlloc ;
+ goto out ;
+ }
+ __glXSendReply (a_cl->client, buf, 1, sizeof (value), GL_FALSE, 0) ;
+ res = Success ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return res ;
+}
+
+int
+ephyrGLXGetIntegerv (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ return ephyrGLXGetIntegervReal (a_cl, a_pc, FALSE) ;
+}
+
+int
+ephyrGLXGetIntegervSwap (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ return ephyrGLXGetIntegervReal (a_cl, a_pc, TRUE) ;
+}
+
+static int
+ephyrGLXIsDirectReal (__GLXclientState *a_cl, GLbyte *a_pc, Bool a_do_swap)
+{
+ int res=BadImplementation;
+ ClientPtr client = a_cl->client;
+ xGLXIsDirectReq *req = (xGLXIsDirectReq *) a_pc;
+ xGLXIsDirectReply reply;
+ int is_direct=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_cl && a_pc, FALSE) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ memset (&reply, 0, sizeof (reply)) ;
+ if (!ephyrHostIsContextDirect (req->context, (int*)&is_direct)) {
+ EPHYR_LOG_ERROR ("ephyrHostIsContextDirect() failed\n") ;
+ goto out ;
+ }
+ reply.isDirect = is_direct ;
+ reply.length = 0;
+ reply.type = X_Reply;
+ reply.sequenceNumber = client->sequence;
+ WriteToClient(client, sz_xGLXIsDirectReply, (char *)&reply);
+ res = Success ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return res ;
+}
+
+int
+ephyrGLXIsDirect (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ return ephyrGLXIsDirectReal (a_cl, a_pc, FALSE) ;
+}
+
+int
+ephyrGLXIsDirectSwap (__GLXclientState *a_cl, GLbyte *a_pc)
+{
+ return ephyrGLXIsDirectReal (a_cl, a_pc, TRUE) ;
+}
+
+#endif /*XEPHYR_DRI*/
+
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrglxext.h b/xorg-server/hw/kdrive/ephyr/ephyrglxext.h
new file mode 100644
index 000000000..22ea605d7
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrglxext.h
@@ -0,0 +1,35 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * 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 OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+#ifndef __EPHYR_GLXEXT_H__
+#define __EPHYR_GLXEXT_H__
+
+#include <X11/Xdefs.h>
+Bool ephyrHijackGLXExtension (void) ;
+
+#endif /*__EPHYR_GLXEXT_H__*/
+
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrhostglx.c b/xorg-server/hw/kdrive/ephyr/ephyrhostglx.c
new file mode 100644
index 000000000..1eec4e02b
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrhostglx.c
@@ -0,0 +1,703 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * 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 OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * a lots of the content of this file has been adapted from the mesa source
+ * code.
+ * Authors:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+/*
+ * including some server headers (like kdrive-config.h)
+ * might define the macro _XSERVER64
+ * on 64 bits machines. That macro must _NOT_ be defined for Xlib
+ * client code, otherwise bad things happen.
+ * So let's undef that macro if necessary.
+ */
+#ifdef _XSERVER64
+#undef _XSERVER64
+#endif
+
+#include <X11/Xlibint.h>
+#include <GL/glx.h>
+#include <GL/internal/glcore.h>
+#include <GL/glxproto.h>
+#include <GL/glxint.h>
+#include "ephyrhostglx.h"
+#define _HAVE_XALLOC_DECLS
+#include "ephyrlog.h"
+#include "hostx.h"
+
+#ifdef XEPHYR_DRI
+enum VisualConfRequestType {
+ EPHYR_GET_FB_CONFIG,
+ EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX,
+ EPHYR_GET_VISUAL_CONFIGS
+
+};
+
+static Bool ephyrHostGLXGetVisualConfigsInternal
+ (enum VisualConfRequestType a_type,
+ int32_t a_screen,
+ int32_t *a_num_visuals,
+ int32_t *a_num_props,
+ int32_t *a_props_buf_size,
+ int32_t **a_props_buf);
+Bool
+ephyrHostGLXGetMajorOpcode (int *a_opcode)
+{
+ Bool is_ok=FALSE ;
+ Display *dpy=hostx_get_display () ;
+ static int opcode ;
+ int first_event_return=0, first_error_return=0;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
+ EPHYR_LOG ("enter\n") ;
+ if (!opcode) {
+ if (!XQueryExtension (dpy, GLX_EXTENSION_NAME, &opcode,
+ &first_event_return, &first_error_return)) {
+ EPHYR_LOG_ERROR ("XQueryExtension() failed\n") ;
+ goto out ;
+ }
+ }
+ *a_opcode = opcode ;
+ is_ok = TRUE ;
+out:
+ EPHYR_LOG ("release\n") ;
+ return is_ok ;
+}
+
+Bool
+ephyrHostGLXQueryVersion (int *a_major, int *a_minor)
+{
+ Bool is_ok = FALSE ;
+ Display *dpy = hostx_get_display () ;
+ int major_opcode=0;
+ xGLXQueryVersionReq *req=NULL;
+ xGLXQueryVersionReply reply;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_major && a_minor, FALSE) ;
+ EPHYR_LOG ("enter\n") ;
+
+ if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
+ EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
+ goto out ;
+ }
+ EPHYR_LOG ("major opcode: %d\n", major_opcode) ;
+
+ /* Send the glXQueryVersion request */
+ memset (&reply, 0, sizeof (reply)) ;
+ LockDisplay (dpy);
+ GetReq (GLXQueryVersion, req);
+ req->reqType = major_opcode;
+ req->glxCode = X_GLXQueryVersion;
+ req->majorVersion = 2;
+ req->minorVersion = 1;
+ _XReply(dpy, (xReply*) &reply, 0, False);
+ UnlockDisplay (dpy);
+ SyncHandle ();
+
+ *a_major = reply.majorVersion ;
+ *a_minor = reply.minorVersion ;
+
+ EPHYR_LOG ("major:%d, minor:%d\n", *a_major, *a_minor) ;
+
+ is_ok = TRUE ;
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+/**
+ * GLX protocol structure for the ficticious "GXLGenericGetString" request.
+ *
+ * This is a non-existant protocol packet. It just so happens that all of
+ * the real protocol packets used to request a string from the server have
+ * an identical binary layout. The only difference between them is the
+ * meaning of the \c for_whom field and the value of the \c glxCode.
+ * (this has been copied from the mesa source code)
+ */
+typedef struct GLXGenericGetString {
+ CARD8 reqType;
+ CARD8 glxCode;
+ CARD16 length B16;
+ CARD32 for_whom B32;
+ CARD32 name B32;
+} xGLXGenericGetStringReq;
+
+/* These defines are only needed to make the GetReq macro happy.
+ */
+#define sz_xGLXGenericGetStringReq 12
+#define X_GLXGenericGetString 0
+
+Bool
+ephyrHostGLXGetStringFromServer (int a_screen_number,
+ int a_string_name,
+ enum EphyrHostGLXGetStringOps a_op,
+ char **a_string)
+{
+ Bool is_ok=FALSE ;
+ Display *dpy = hostx_get_display () ;
+ int default_screen = DefaultScreen (dpy);
+ xGLXGenericGetStringReq *req=NULL;
+ xGLXSingleReply reply;
+ int length=0, numbytes=0, major_opcode=0, get_string_op=0;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy && a_string, FALSE) ;
+
+ EPHYR_LOG ("enter\n") ;
+ switch (a_op) {
+ case EPHYR_HOST_GLX_QueryServerString:
+ get_string_op = X_GLXQueryServerString;
+ break ;
+ case EPHYR_HOST_GLX_GetString:
+ get_string_op = X_GLsop_GetString;
+ EPHYR_LOG ("Going to glXGetString. strname:%#x, ctxttag:%d\n",
+ a_string_name, a_screen_number) ;
+ break ;
+ default:
+ EPHYR_LOG_ERROR ("unknown EphyrHostGLXGetStringOp:%d\n", a_op) ;
+ goto out ;
+ }
+
+ if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
+ EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
+ goto out ;
+ }
+ EPHYR_LOG ("major opcode: %d\n", major_opcode) ;
+
+ LockDisplay (dpy);
+
+ /* All of the GLX protocol requests for getting a string from the server
+ * look the same. The exact meaning of the a_for_whom field is usually
+ * either the screen number (for glXQueryServerString) or the context tag
+ * (for GLXSingle).
+ */
+ GetReq (GLXGenericGetString, req);
+ req->reqType = major_opcode;
+ req->glxCode = get_string_op;
+ req->for_whom = default_screen;
+ req->name = a_string_name;
+
+ _XReply (dpy, (xReply *)&reply, 0, False);
+
+ length = reply.length * 4;
+ if (!length) {
+ numbytes = 0;
+ } else {
+ numbytes = reply.size;
+ }
+ EPHYR_LOG ("going to get a string of size:%d\n", numbytes) ;
+
+ *a_string = (char *) Xmalloc (numbytes +1);
+ if (!a_string) {
+ EPHYR_LOG_ERROR ("allocation failed\n") ;
+ goto out;
+ }
+
+ memset (*a_string, 0, numbytes+1) ;
+ if (_XRead (dpy, *a_string, numbytes)) {
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ EPHYR_LOG_ERROR ("read failed\n") ;
+ goto out ;
+ }
+ length -= numbytes;
+ _XEatData (dpy, length) ;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ EPHYR_LOG ("strname:%#x, strvalue:'%s', strlen:%d\n",
+ a_string_name, *a_string, numbytes) ;
+
+ is_ok = TRUE ;
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+static Bool
+ephyrHostGLXGetVisualConfigsInternal (enum VisualConfRequestType a_type,
+ int32_t a_screen,
+ int32_t *a_num_visuals,
+ int32_t *a_num_props,
+ int32_t *a_props_buf_size,
+ int32_t **a_props_buf)
+{
+ Bool is_ok = FALSE ;
+ Display *dpy = hostx_get_display () ;
+ xGLXGetVisualConfigsReq *req;
+ xGLXGetFBConfigsReq *fb_req;
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ xGLXGetFBConfigsSGIXReq *sgi_req;
+ xGLXGetVisualConfigsReply reply;
+ char *server_glx_version=NULL,
+ *server_glx_extensions=NULL ;
+ int j=0,
+ screens=0,
+ major_opcode=0,
+ num_props=0,
+ num_visuals=0,
+ props_buf_size=0,
+ props_per_visual_size=0;
+ int32_t *props_buf=NULL;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
+
+ screens = ScreenCount (dpy);
+ if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
+ EPHYR_LOG_ERROR ("failed to get opcode\n") ;
+ goto out ;
+ }
+
+ LockDisplay(dpy);
+ switch (a_type) {
+ case EPHYR_GET_FB_CONFIG:
+ GetReq(GLXGetFBConfigs,fb_req);
+ fb_req->reqType = major_opcode;
+ fb_req->glxCode = X_GLXGetFBConfigs;
+ fb_req->screen = DefaultScreen (dpy);
+ break;
+
+ case EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX:
+ GetReqExtra(GLXVendorPrivateWithReply,
+ sz_xGLXGetFBConfigsSGIXReq
+ -
+ sz_xGLXVendorPrivateWithReplyReq,
+ vpreq);
+ sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq;
+ sgi_req->reqType = major_opcode;
+ sgi_req->glxCode = X_GLXVendorPrivateWithReply;
+ sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX;
+ sgi_req->screen = DefaultScreen (dpy);
+ break;
+
+ case EPHYR_GET_VISUAL_CONFIGS:
+ GetReq(GLXGetVisualConfigs,req);
+ req->reqType = major_opcode;
+ req->glxCode = X_GLXGetVisualConfigs;
+ req->screen = DefaultScreen (dpy);
+ break;
+ }
+
+ if (!_XReply(dpy, (xReply*) &reply, 0, False)) {
+ EPHYR_LOG_ERROR ("unknown error\n") ;
+ UnlockDisplay(dpy);
+ goto out ;
+ }
+ if (!reply.numVisuals) {
+ EPHYR_LOG_ERROR ("screen does not support GL rendering\n") ;
+ UnlockDisplay(dpy);
+ goto out ;
+ }
+ num_visuals = reply.numVisuals ;
+
+ /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for
+ * FIXME: FBconfigs?
+ */
+ /* Check number of properties */
+ num_props = reply.numProps;
+ if ((num_props < __GLX_MIN_CONFIG_PROPS) ||
+ (num_props > __GLX_MAX_CONFIG_PROPS)) {
+ /* Huh? Not in protocol defined limits. Punt */
+ EPHYR_LOG_ERROR ("got a bad reply to request\n") ;
+ UnlockDisplay(dpy);
+ goto out ;
+ }
+
+ if (a_type != EPHYR_GET_VISUAL_CONFIGS) {
+ num_props *= 2;
+ }
+ props_per_visual_size = num_props * __GLX_SIZE_INT32;
+ props_buf_size = props_per_visual_size * reply.numVisuals;
+ props_buf = malloc (props_buf_size) ;
+ for (j = 0; j < reply.numVisuals; j++) {
+ if (_XRead (dpy,
+ &((char*)props_buf)[j*props_per_visual_size],
+ props_per_visual_size) != Success) {
+ EPHYR_LOG_ERROR ("read failed\n") ;
+ }
+ }
+ UnlockDisplay(dpy);
+
+ *a_num_visuals = num_visuals ;
+ *a_num_props = reply.numProps ;
+ *a_props_buf_size = props_buf_size ;
+ *a_props_buf = props_buf ;
+ is_ok = TRUE ;
+
+out:
+ if (server_glx_version) {
+ XFree (server_glx_version) ;
+ server_glx_version = NULL ;
+ }
+ if (server_glx_extensions) {
+ XFree (server_glx_extensions) ;
+ server_glx_extensions = NULL ;
+ }
+ SyncHandle () ;
+ return is_ok;
+}
+
+Bool
+ephyrHostGLXGetVisualConfigs (int32_t a_screen,
+ int32_t *a_num_visuals,
+ int32_t *a_num_props,
+ int32_t *a_props_buf_size,
+ int32_t **a_props_buf)
+{
+ Bool is_ok = FALSE;
+
+ EPHYR_LOG ("enter\n") ;
+ is_ok = ephyrHostGLXGetVisualConfigsInternal (EPHYR_GET_VISUAL_CONFIGS,
+ a_screen,
+ a_num_visuals,
+ a_num_props,
+ a_props_buf_size,
+ a_props_buf) ;
+
+ EPHYR_LOG ("leave:%d\n", is_ok) ;
+ return is_ok;
+}
+
+Bool
+ephyrHostGLXVendorPrivGetFBConfigsSGIX (int a_screen,
+ int32_t *a_num_visuals,
+ int32_t *a_num_props,
+ int32_t *a_props_buf_size,
+ int32_t **a_props_buf)
+{
+ Bool is_ok=FALSE ;
+ EPHYR_LOG ("enter\n") ;
+ is_ok = ephyrHostGLXGetVisualConfigsInternal
+ (EPHYR_VENDOR_PRIV_GET_FB_CONFIG_SGIX,
+ a_screen,
+ a_num_visuals,
+ a_num_props,
+ a_props_buf_size,
+ a_props_buf) ;
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+Bool
+ephyrHostGLXSendClientInfo (int32_t a_major, int32_t a_minor,
+ const char* a_extension_list)
+{
+ Bool is_ok = FALSE ;
+ Display *dpy = hostx_get_display () ;
+ xGLXClientInfoReq *req;
+ int size;
+ int32_t major_opcode=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy && a_extension_list, FALSE) ;
+
+ if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
+ EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
+ goto out ;
+ }
+
+ LockDisplay (dpy);
+
+ GetReq (GLXClientInfo,req);
+ req->reqType = major_opcode;
+ req->glxCode = X_GLXClientInfo;
+ req->major = a_major;
+ req->minor = a_minor;
+
+ size = strlen (a_extension_list) + 1;
+ req->length += (size + 3) >> 2;
+ req->numbytes = size;
+ Data (dpy, a_extension_list, size);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ is_ok=TRUE ;
+
+out:
+ return is_ok ;
+}
+
+Bool
+ephyrHostGLXCreateContext (int a_screen,
+ int a_visual_id,
+ int a_context_id,
+ int a_share_list_ctxt_id,
+ Bool a_direct)
+{
+ Bool is_ok = FALSE;
+ Display *dpy = hostx_get_display ();
+ int major_opcode=0, remote_context_id=0;
+ xGLXCreateContextReq *req;
+
+ EPHYR_LOG ("enter. screen:%d, visual:%d, contextid:%d, direct:%d\n",
+ a_screen, a_visual_id, a_context_id, a_direct) ;
+
+ if (!hostx_allocate_resource_id_peer (a_context_id, &remote_context_id)) {
+ EPHYR_LOG_ERROR ("failed to peer the context id %d host X",
+ remote_context_id) ;
+ goto out ;
+ }
+
+ if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
+ EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
+ goto out ;
+ }
+
+ LockDisplay (dpy) ;
+
+ /* Send the glXCreateContext request */
+ GetReq(GLXCreateContext,req);
+ req->reqType = major_opcode;
+ req->glxCode = X_GLXCreateContext;
+ req->context = remote_context_id;
+ req->visual = a_visual_id;
+ req->screen = DefaultScreen (dpy);
+ req->shareList = a_share_list_ctxt_id;
+ req->isDirect = a_direct;
+
+ UnlockDisplay (dpy);
+ SyncHandle ();
+
+ is_ok = TRUE ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+Bool
+ephyrHostDestroyContext (int a_ctxt_id)
+{
+ Bool is_ok=FALSE;
+ Display *dpy=hostx_get_display ();
+ int major_opcode=0, remote_ctxt_id=0 ;
+ xGLXDestroyContextReq *req=NULL;
+
+ EPHYR_LOG ("enter:%d\n", a_ctxt_id) ;
+
+ if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
+ EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
+ goto out ;
+ }
+ if (!hostx_get_resource_id_peer (a_ctxt_id, &remote_ctxt_id)) {
+ EPHYR_LOG_ERROR ("failed to get remote glx ctxt id\n") ;
+ goto out ;
+ }
+ EPHYR_LOG ("host context id:%d\n", remote_ctxt_id) ;
+
+ LockDisplay (dpy);
+ GetReq (GLXDestroyContext,req);
+ req->reqType = major_opcode;
+ req->glxCode = X_GLXDestroyContext;
+ req->context = remote_ctxt_id;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+
+ is_ok = TRUE ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+Bool
+ephyrHostGLXMakeCurrent (int a_drawable,
+ int a_glx_ctxt_id,
+ int a_old_ctxt_tag,
+ int *a_ctxt_tag)
+{
+ Bool is_ok=FALSE ;
+ Display *dpy = hostx_get_display () ;
+ int32_t major_opcode=0 ;
+ int remote_glx_ctxt_id=0 ;
+ xGLXMakeCurrentReq *req;
+ xGLXMakeCurrentReply reply;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_ctxt_tag, FALSE) ;
+
+ EPHYR_LOG ("enter. drawable:%d, context:%d, oldtag:%d\n",
+ a_drawable, a_glx_ctxt_id, a_old_ctxt_tag) ;
+
+ if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
+ EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
+ goto out ;
+ }
+ if (!hostx_get_resource_id_peer (a_glx_ctxt_id, &remote_glx_ctxt_id)) {
+ EPHYR_LOG_ERROR ("failed to get remote glx ctxt id\n") ;
+ goto out ;
+ }
+
+ LockDisplay (dpy);
+
+ GetReq (GLXMakeCurrent,req);
+ req->reqType = major_opcode;
+ req->glxCode = X_GLXMakeCurrent;
+ req->drawable = a_drawable;
+ req->context = remote_glx_ctxt_id;
+ req->oldContextTag = a_old_ctxt_tag;
+
+ memset (&reply, 0, sizeof (reply)) ;
+ if (!_XReply (dpy, (xReply*)&reply, 0, False)) {
+ EPHYR_LOG_ERROR ("failed to get reply from host\n") ;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ goto out ;
+ }
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ *a_ctxt_tag = reply.contextTag ;
+ EPHYR_LOG ("context tag:%d\n", *a_ctxt_tag) ;
+ is_ok = TRUE ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+#define X_GLXSingle 0
+
+#define __EPHYR_GLX_SINGLE_PUT_CHAR(offset,a) \
+ *((INT8 *) (pc + offset)) = a
+
+#define EPHYR_GLX_SINGLE_PUT_SHORT(offset,a) \
+ *((INT16 *) (pc + offset)) = a
+
+#define EPHYR_GLX_SINGLE_PUT_LONG(offset,a) \
+ *((INT32 *) (pc + offset)) = a
+
+#define EPHYR_GLX_SINGLE_PUT_FLOAT(offset,a) \
+ *((FLOAT32 *) (pc + offset)) = a
+
+#define EPHYR_GLX_SINGLE_READ_XREPLY() \
+ (void) _XReply(dpy, (xReply*) &reply, 0, False)
+
+#define EPHYR_GLX_SINGLE_GET_RETVAL(a,cast) \
+ a = (cast) reply.retval
+
+#define EPHYR_GLX_SINGLE_GET_SIZE(a) \
+ a = (GLint) reply.size
+
+#define EPHYR_GLX_SINGLE_GET_CHAR(p) \
+ *p = *(GLbyte *)&reply.pad3;
+
+#define EPHYR_GLX_SINGLE_GET_SHORT(p) \
+ *p = *(GLshort *)&reply.pad3;
+
+#define EPHYR_GLX_SINGLE_GET_LONG(p) \
+ *p = *(GLint *)&reply.pad3;
+
+#define EPHYR_GLX_SINGLE_GET_FLOAT(p) \
+ *p = *(GLfloat *)&reply.pad3;
+
+Bool
+ephyrHostGetIntegerValue (int a_current_context_tag, int a_int, int *a_val)
+{
+ Bool is_ok=FALSE;
+ Display *dpy = hostx_get_display () ;
+ int major_opcode=0, size=0;
+ xGLXSingleReq *req=NULL;
+ xGLXSingleReply reply;
+ unsigned char* pc=NULL ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_val, FALSE) ;
+
+ EPHYR_LOG ("enter\n") ;
+ if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
+ EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
+ goto out ;
+ }
+ LockDisplay (dpy) ;
+ GetReqExtra (GLXSingle, 4, req) ;
+ req->reqType = major_opcode ;
+ req->glxCode = X_GLsop_GetIntegerv ;
+ req->contextTag = a_current_context_tag;
+ pc = ((unsigned char *)(req) + sz_xGLXSingleReq) ;
+ EPHYR_GLX_SINGLE_PUT_LONG (0, a_int) ;
+ EPHYR_GLX_SINGLE_READ_XREPLY () ;
+ EPHYR_GLX_SINGLE_GET_SIZE (size) ;
+ if (!size) {
+ UnlockDisplay (dpy) ;
+ SyncHandle () ;
+ EPHYR_LOG_ERROR ("X_GLsop_GetIngerv failed\n") ;
+ goto out ;
+ }
+ EPHYR_GLX_SINGLE_GET_LONG (a_val) ;
+ UnlockDisplay (dpy) ;
+ SyncHandle () ;
+ is_ok = TRUE ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+Bool
+ephyrHostIsContextDirect (int a_ctxt_id,
+ int *a_is_direct)
+{
+ Bool is_ok=FALSE;
+ Display *dpy = hostx_get_display () ;
+ xGLXIsDirectReq *req=NULL;
+ xGLXIsDirectReply reply;
+ int major_opcode=0, remote_glx_ctxt_id=0;
+
+ EPHYR_LOG ("enter\n") ;
+ if (!ephyrHostGLXGetMajorOpcode (&major_opcode)) {
+ EPHYR_LOG_ERROR ("failed to get major opcode\n") ;
+ goto out ;
+ }
+ if (!hostx_get_resource_id_peer (a_ctxt_id, &remote_glx_ctxt_id)) {
+ EPHYR_LOG_ERROR ("failed to get remote glx ctxt id\n") ;
+ goto out ;
+ }
+ memset (&reply, 0, sizeof (reply)) ;
+
+ /* Send the glXIsDirect request */
+ LockDisplay (dpy);
+ GetReq (GLXIsDirect,req);
+ req->reqType = major_opcode;
+ req->glxCode = X_GLXIsDirect;
+ req->context = remote_glx_ctxt_id;
+ if (!_XReply (dpy, (xReply*) &reply, 0, False)) {
+ EPHYR_LOG_ERROR ("fail in reading reply from host\n") ;
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ goto out ;
+ }
+ UnlockDisplay (dpy);
+ SyncHandle ();
+ *a_is_direct = reply.isDirect ;
+ is_ok = TRUE ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+#endif /*XEPHYR_DRI*/
+
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrhostglx.h b/xorg-server/hw/kdrive/ephyr/ephyrhostglx.h
new file mode 100644
index 000000000..6db362f30
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrhostglx.h
@@ -0,0 +1,76 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * 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 OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+#ifndef __EPHYRHOSTGLX_H__
+#define __EPHYRHOSTGLX_H__
+
+enum EphyrHostGLXGetStringOps {
+ EPHYR_HOST_GLX_UNDEF,
+ EPHYR_HOST_GLX_QueryServerString,
+ EPHYR_HOST_GLX_GetString,
+};
+
+Bool ephyrHostGLXQueryVersion (int *a_maj, int *a_min) ;
+Bool ephyrHostGLXGetStringFromServer (int a_screen_number,
+ int a_string_name,
+ enum EphyrHostGLXGetStringOps a_op,
+ char **a_string) ;
+Bool ephyrHostGLXGetVisualConfigs (int a_screen,
+ int32_t *a_num_visuals,
+ int32_t *a_num_props,
+ int32_t *a_props_buf_size,
+ int32_t **a_props_buf) ;
+Bool
+ephyrHostGLXVendorPrivGetFBConfigsSGIX (int a_screen,
+ int32_t *a_num_visuals,
+ int32_t *a_num_props,
+ int32_t *a_props_buf_size,
+ int32_t **a_props_buf);
+Bool ephyrHostGLXGetMajorOpcode (int32_t *a_opcode) ;
+Bool ephyrHostGLXSendClientInfo (int32_t a_major, int32_t a_minor,
+ const char* a_extension_list) ;
+Bool ephyrHostGLXCreateContext (int a_screen,
+ int a_visual_id,
+ int a_context_id,
+ int a_shared_list_ctx_id,
+ Bool a_direct) ;
+
+Bool ephyrHostDestroyContext (int a_ctxt_id) ;
+
+Bool ephyrHostGLXMakeCurrent (int a_drawable, int a_glx_ctxt_id,
+ int a_olg_ctxt_tag, int *a_ctxt_tag) ;
+
+Bool ephyrHostGetIntegerValue (int a_current_context_tag,
+ int a_int,
+ int *a_val) ;
+
+Bool ephyrHostIsContextDirect (int a_ctxt_id,
+ int *a_is_direct) ;
+
+
+#endif /*__EPHYRHOSTGLX_H__*/
+
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.c b/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.c
new file mode 100644
index 000000000..41c0b755b
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.c
@@ -0,0 +1,1014 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * 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 OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+/*
+ * including some server headers (like kdrive-config.h)
+ * might define the macro _XSERVER64
+ * on 64 bits machines. That macro must _NOT_ be defined for Xlib
+ * client code, otherwise bad things happen.
+ * So let's undef that macro if necessary.
+ */
+#ifdef _XSERVER64
+#undef _XSERVER64
+#endif
+#include <X11/Xutil.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xvlib.h>
+#include <X11/extensions/Xvproto.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#define _HAVE_XALLOC_DECLS
+
+#include "hostx.h"
+#include "ephyrhostvideo.h"
+#include "ephyrlog.h"
+
+#ifndef TRUE
+#define TRUE 1
+#endif /*TRUE*/
+
+#ifndef FALSE
+#define FALSE 0
+#endif /*FALSE*/
+
+static XExtensionInfo _xv_info_data;
+static XExtensionInfo *xv_info = &_xv_info_data;
+static char *xv_extension_name = XvName;
+static char *xv_error_string(Display *dpy, int code, XExtCodes *codes,
+ char * buf, int n);
+static int xv_close_display(Display *dpy, XExtCodes *codes);
+static Bool xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire);
+
+static XExtensionHooks xv_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ xv_close_display, /* close_display */
+ xv_wire_to_event, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ xv_error_string /* error_string */
+};
+
+
+static char *xv_error_list[] =
+{
+ "BadPort", /* XvBadPort */
+ "BadEncoding", /* XvBadEncoding */
+ "BadControl" /* XvBadControl */
+};
+
+
+#define XvCheckExtension(dpy, i, val) \
+ XextCheckExtension(dpy, i, xv_extension_name, val)
+#define XvGetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xv##name##Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xv##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = info->codes->major_opcode;\
+ req->xvReqType = xv_##name; \
+ req->length = (SIZEOF(xv##name##Req))>>2;\
+ dpy->bufptr += SIZEOF(xv##name##Req);\
+ dpy->request++
+
+static XEXT_GENERATE_CLOSE_DISPLAY (xv_close_display, xv_info)
+
+
+static XEXT_GENERATE_FIND_DISPLAY (xv_find_display, xv_info,
+ xv_extension_name,
+ &xv_extension_hooks,
+ XvNumEvents, NULL)
+
+static XEXT_GENERATE_ERROR_STRING (xv_error_string, xv_extension_name,
+ XvNumErrors, xv_error_list)
+
+struct _EphyrHostXVAdaptorArray {
+ XvAdaptorInfo *adaptors ;
+ unsigned int nb_adaptors ;
+};
+
+/*heavily copied from libx11*/
+#define BUFSIZE 2048
+static void
+ephyrHostXVLogXErrorEvent (Display *a_display,
+ XErrorEvent *a_err_event,
+ FILE *a_fp)
+{
+ char buffer[BUFSIZ];
+ char mesg[BUFSIZ];
+ char number[32];
+ const char *mtype = "XlibMessage";
+ register _XExtension *ext = (_XExtension *)NULL;
+ _XExtension *bext = (_XExtension *)NULL;
+ Display *dpy = a_display ;
+
+ XGetErrorText(dpy, a_err_event->error_code, buffer, BUFSIZ);
+ XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
+ (void) fprintf(a_fp, "%s: %s\n ", mesg, buffer);
+ XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
+ mesg, BUFSIZ);
+ (void) fprintf(a_fp, mesg, a_err_event->request_code);
+ if (a_err_event->request_code < 128) {
+ sprintf(number, "%d", a_err_event->request_code);
+ XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
+ } else {
+ for (ext = dpy->ext_procs;
+ ext && (ext->codes.major_opcode != a_err_event->request_code);
+ ext = ext->next)
+ ;
+ if (ext)
+ strcpy(buffer, ext->name);
+ else
+ buffer[0] = '\0';
+ }
+ (void) fprintf(a_fp, " (%s)\n", buffer);
+ if (a_err_event->request_code >= 128) {
+ XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
+ mesg, BUFSIZ);
+ fputs(" ", a_fp);
+ (void) fprintf(a_fp, mesg, a_err_event->minor_code);
+ if (ext) {
+ sprintf(mesg, "%s.%d", ext->name, a_err_event->minor_code);
+ XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
+ (void) fprintf(a_fp, " (%s)", buffer);
+ }
+ fputs("\n", a_fp);
+ }
+ if (a_err_event->error_code >= 128) {
+ /* kludge, try to find the extension that caused it */
+ buffer[0] = '\0';
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_string)
+ (*ext->error_string)(dpy, a_err_event->error_code, &ext->codes,
+ buffer, BUFSIZ);
+ if (buffer[0]) {
+ bext = ext;
+ break;
+ }
+ if (ext->codes.first_error &&
+ ext->codes.first_error < (int)a_err_event->error_code &&
+ (!bext || ext->codes.first_error > bext->codes.first_error))
+ bext = ext;
+ }
+ if (bext)
+ sprintf(buffer, "%s.%d", bext->name,
+ a_err_event->error_code - bext->codes.first_error);
+ else
+ strcpy(buffer, "Value");
+ XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
+ if (mesg[0]) {
+ fputs(" ", a_fp);
+ (void) fprintf(a_fp, mesg, a_err_event->resourceid);
+ fputs("\n", a_fp);
+ }
+ /* let extensions try to print the values */
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_values)
+ (*ext->error_values)(dpy, a_err_event, a_fp);
+ }
+ } else if ((a_err_event->error_code == BadWindow) ||
+ (a_err_event->error_code == BadPixmap) ||
+ (a_err_event->error_code == BadCursor) ||
+ (a_err_event->error_code == BadFont) ||
+ (a_err_event->error_code == BadDrawable) ||
+ (a_err_event->error_code == BadColor) ||
+ (a_err_event->error_code == BadGC) ||
+ (a_err_event->error_code == BadIDChoice) ||
+ (a_err_event->error_code == BadValue) ||
+ (a_err_event->error_code == BadAtom)) {
+ if (a_err_event->error_code == BadValue)
+ XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
+ mesg, BUFSIZ);
+ else if (a_err_event->error_code == BadAtom)
+ XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
+ mesg, BUFSIZ);
+ else
+ XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
+ mesg, BUFSIZ);
+ fputs(" ", a_fp);
+ (void) fprintf(a_fp, mesg, a_err_event->resourceid);
+ fputs("\n", a_fp);
+ }
+ XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
+ mesg, BUFSIZ);
+ fputs(" ", a_fp);
+ (void) fprintf(a_fp, mesg, a_err_event->serial);
+ XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
+ mesg, BUFSIZ);
+ fputs("\n ", a_fp);
+ (void) fprintf(a_fp, mesg, dpy->request);
+ fputs("\n", a_fp);
+}
+
+static int
+ephyrHostXVErrorHandler (Display *a_display,
+ XErrorEvent *a_error_event)
+{
+ EPHYR_LOG_ERROR ("got an error from the host xserver:\n") ;
+ ephyrHostXVLogXErrorEvent (a_display, a_error_event, stderr) ;
+ return Success ;
+}
+
+void
+ephyrHostXVInit (void)
+{
+ static Bool s_initialized ;
+
+ if (s_initialized)
+ return ;
+ XSetErrorHandler (ephyrHostXVErrorHandler) ;
+ s_initialized = TRUE ;
+}
+
+Bool
+ephyrHostXVQueryAdaptors (EphyrHostXVAdaptorArray **a_adaptors)
+{
+ EphyrHostXVAdaptorArray *result=NULL ;
+ int ret=0 ;
+ Bool is_ok=FALSE ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_adaptors, FALSE) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ result = Xcalloc (1, sizeof (EphyrHostXVAdaptorArray)) ;
+ if (!result)
+ goto out ;
+
+ ret = XvQueryAdaptors (hostx_get_display (),
+ DefaultRootWindow (hostx_get_display ()),
+ &result->nb_adaptors,
+ &result->adaptors) ;
+ if (ret != Success) {
+ EPHYR_LOG_ERROR ("failed to query host adaptors: %d\n", ret) ;
+ goto out ;
+ }
+ *a_adaptors = result ;
+ is_ok = TRUE ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+void
+ephyrHostXVAdaptorArrayDelete (EphyrHostXVAdaptorArray *a_adaptors)
+{
+ if (!a_adaptors)
+ return ;
+ if (a_adaptors->adaptors) {
+ XvFreeAdaptorInfo (a_adaptors->adaptors) ;
+ a_adaptors->adaptors = NULL ;
+ a_adaptors->nb_adaptors = 0 ;
+ }
+ XFree (a_adaptors) ;
+}
+
+int
+ephyrHostXVAdaptorArrayGetSize (const EphyrHostXVAdaptorArray *a_this)
+{
+ EPHYR_RETURN_VAL_IF_FAIL (a_this, -1) ;
+ return a_this->nb_adaptors ;
+}
+
+EphyrHostXVAdaptor*
+ephyrHostXVAdaptorArrayAt (const EphyrHostXVAdaptorArray *a_this,
+ int a_index)
+{
+ EPHYR_RETURN_VAL_IF_FAIL (a_this, NULL) ;
+
+ if (a_index >= a_this->nb_adaptors)
+ return NULL ;
+ return (EphyrHostXVAdaptor*)&a_this->adaptors[a_index] ;
+}
+
+char
+ephyrHostXVAdaptorGetType (const EphyrHostXVAdaptor *a_this)
+{
+ EPHYR_RETURN_VAL_IF_FAIL (a_this, -1) ;
+ return ((XvAdaptorInfo*)a_this)->type ;
+}
+
+const char*
+ephyrHostXVAdaptorGetName (const EphyrHostXVAdaptor *a_this)
+{
+ EPHYR_RETURN_VAL_IF_FAIL (a_this, NULL) ;
+
+ return ((XvAdaptorInfo*)a_this)->name ;
+}
+
+EphyrHostVideoFormat*
+ephyrHostXVAdaptorGetVideoFormats (const EphyrHostXVAdaptor *a_this,
+ int *a_nb_formats)
+{
+ EphyrHostVideoFormat *formats=NULL ;
+ int nb_formats=0, i=0 ;
+ XVisualInfo *visual_info, visual_info_template ;
+ int nb_visual_info ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_this, NULL) ;
+
+ nb_formats = ((XvAdaptorInfo*)a_this)->num_formats ;
+ formats = Xcalloc (nb_formats, sizeof (EphyrHostVideoFormat)) ;
+ for (i=0; i < nb_formats; i++) {
+ memset (&visual_info_template, 0, sizeof (visual_info_template)) ;
+ visual_info_template.visualid =
+ ((XvAdaptorInfo*)a_this)->formats[i].visual_id;
+ visual_info = XGetVisualInfo (hostx_get_display (),
+ VisualIDMask,
+ &visual_info_template,
+ &nb_visual_info) ;
+ formats[i].depth = ((XvAdaptorInfo*)a_this)->formats[i].depth ;
+ formats[i].visual_class = visual_info->class ;
+ XFree (visual_info) ;
+ }
+ if (a_nb_formats)
+ *a_nb_formats = nb_formats ;
+ return formats ;
+}
+
+int
+ephyrHostXVAdaptorGetNbPorts (const EphyrHostXVAdaptor *a_this)
+{
+ EPHYR_RETURN_VAL_IF_FAIL (a_this, -1) ;
+
+ return ((XvAdaptorInfo*)a_this)->num_ports ;
+}
+
+int
+ephyrHostXVAdaptorGetFirstPortID (const EphyrHostXVAdaptor *a_this)
+{
+ EPHYR_RETURN_VAL_IF_FAIL (a_this, -1) ;
+
+ return ((XvAdaptorInfo*)a_this)->base_id ;
+}
+
+Bool
+ephyrHostXVAdaptorHasPutVideo (const EphyrHostXVAdaptor *a_this,
+ Bool *a_result)
+{
+ EPHYR_RETURN_VAL_IF_FAIL (a_this && a_result, FALSE) ;
+
+ if (((XvAdaptorInfo*)a_this)->type & XvVideoMask & XvInputMask)
+ *a_result = TRUE ;
+ else
+ *a_result = FALSE ;
+ return TRUE ;
+}
+
+Bool
+ephyrHostXVAdaptorHasGetVideo (const EphyrHostXVAdaptor *a_this,
+ Bool *a_result)
+{
+ if (((XvAdaptorInfo*)a_this)->type & XvVideoMask & XvOutputMask)
+ *a_result = TRUE ;
+ else
+ *a_result = FALSE ;
+ return TRUE ;
+}
+
+Bool
+ephyrHostXVAdaptorHasPutStill (const EphyrHostXVAdaptor *a_this,
+ Bool *a_result)
+{
+ EPHYR_RETURN_VAL_IF_FAIL (a_this && a_result, FALSE) ;
+
+ if (((XvAdaptorInfo*)a_this)->type & XvStillMask && XvInputMask)
+ *a_result = TRUE ;
+ else
+ *a_result = FALSE ;
+ return TRUE ;
+}
+
+Bool
+ephyrHostXVAdaptorHasGetStill (const EphyrHostXVAdaptor *a_this,
+ Bool *a_result)
+{
+ EPHYR_RETURN_VAL_IF_FAIL (a_this && a_result, FALSE) ;
+
+ if (((XvAdaptorInfo*)a_this)->type & XvStillMask && XvOutputMask)
+ *a_result = TRUE ;
+ else
+ *a_result = FALSE ;
+ return TRUE ;
+}
+
+Bool
+ephyrHostXVAdaptorHasPutImage (const EphyrHostXVAdaptor *a_this,
+ Bool *a_result)
+{
+ EPHYR_RETURN_VAL_IF_FAIL (a_this && a_result, FALSE) ;
+
+ if (((XvAdaptorInfo*)a_this)->type & XvImageMask && XvInputMask)
+ *a_result = TRUE ;
+ else
+ *a_result = FALSE ;
+ return TRUE ;
+}
+
+Bool
+ephyrHostXVQueryEncodings (int a_port_id,
+ EphyrHostEncoding **a_encodings,
+ unsigned int *a_num_encodings)
+{
+ EphyrHostEncoding *encodings=NULL ;
+ XvEncodingInfo *encoding_info=NULL ;
+ unsigned int num_encodings=0, i;
+ int ret=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_encodings && a_num_encodings, FALSE) ;
+
+ ret = XvQueryEncodings (hostx_get_display (),
+ a_port_id,
+ &num_encodings,
+ &encoding_info) ;
+ if (num_encodings && encoding_info) {
+ encodings = Xcalloc (num_encodings, sizeof (EphyrHostEncoding)) ;
+ for (i=0; i<num_encodings; i++) {
+ encodings[i].id = encoding_info[i].encoding_id ;
+ encodings[i].name = strdup (encoding_info[i].name) ;
+ encodings[i].width = encoding_info[i].width ;
+ encodings[i].height = encoding_info[i].height ;
+ encodings[i].rate.numerator = encoding_info[i].rate.numerator ;
+ encodings[i].rate.denominator = encoding_info[i].rate.denominator ;
+ }
+ }
+ if (encoding_info) {
+ XvFreeEncodingInfo (encoding_info) ;
+ encoding_info = NULL ;
+ }
+ *a_encodings = encodings ;
+ *a_num_encodings = num_encodings ;
+
+ if (ret != Success)
+ return FALSE ;
+ return TRUE ;
+}
+
+void
+ephyrHostEncodingsDelete (EphyrHostEncoding *a_encodings,
+ int a_num_encodings)
+{
+ int i=0 ;
+
+ if (!a_encodings)
+ return ;
+ for (i=0; i < a_num_encodings; i++) {
+ if (a_encodings[i].name) {
+ xfree (a_encodings[i].name) ;
+ a_encodings[i].name = NULL ;
+ }
+ }
+ xfree (a_encodings) ;
+}
+
+void
+ephyrHostAttributesDelete (EphyrHostAttribute *a_attributes)
+{
+ if (!a_attributes)
+ return ;
+ XFree (a_attributes) ;
+}
+
+Bool
+ephyrHostXVQueryPortAttributes (int a_port_id,
+ EphyrHostAttribute **a_attributes,
+ int *a_num_attributes)
+{
+ EPHYR_RETURN_VAL_IF_FAIL (a_attributes && a_num_attributes, FALSE) ;
+
+ *a_attributes =
+ (EphyrHostAttribute*)XvQueryPortAttributes (hostx_get_display (),
+ a_port_id,
+ a_num_attributes);
+
+ return TRUE ;
+}
+
+Bool
+ephyrHostXVQueryImageFormats (int a_port_id,
+ EphyrHostImageFormat **a_formats,
+ int *a_num_format)
+{
+ XvImageFormatValues *result=NULL ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_formats && a_num_format, FALSE) ;
+
+ result = XvListImageFormats (hostx_get_display (),
+ a_port_id,
+ a_num_format) ;
+ *a_formats = (EphyrHostImageFormat*) result ;
+ return TRUE ;
+
+}
+
+Bool
+ephyrHostXVSetPortAttribute (int a_port_id,
+ int a_atom,
+ int a_attr_value)
+{
+ int res=Success ;
+
+ EPHYR_LOG ("atom,name,value: (%d,%s,%d)\n",
+ a_atom,
+ XGetAtomName (hostx_get_display (), a_atom),
+ a_attr_value) ;
+
+ res = XvSetPortAttribute (hostx_get_display (),
+ a_port_id,
+ a_atom,
+ a_attr_value) ;
+ if (res != Success) {
+ EPHYR_LOG_ERROR ("XvSetPortAttribute() failed: %d\n", res) ;
+ return FALSE ;
+ }
+ XFlush (hostx_get_display ()) ;
+ EPHYR_LOG ("leave\n") ;
+
+ return TRUE ;
+}
+
+Bool
+ephyrHostXVGetPortAttribute (int a_port_id,
+ int a_atom,
+ int *a_attr_value)
+{
+ int res=Success ;
+ Bool ret=FALSE ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_attr_value, FALSE) ;
+
+ EPHYR_LOG ("enter, a_port_id: %d, a_atomid: %d, attr_name: %s\n",
+ a_port_id, a_atom, XGetAtomName (hostx_get_display (), a_atom)) ;
+
+ res = XvGetPortAttribute (hostx_get_display (),
+ a_port_id,
+ a_atom,
+ a_attr_value) ;
+ if (res != Success) {
+ EPHYR_LOG_ERROR ("XvGetPortAttribute() failed: %d \n", res) ;
+ goto out ;
+ }
+ EPHYR_LOG ("atom,value: (%d, %d)\n", a_atom, *a_attr_value) ;
+
+ ret = TRUE ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return ret ;
+}
+
+Bool
+ephyrHostXVQueryBestSize (int a_port_id,
+ Bool a_motion,
+ unsigned int a_frame_w,
+ unsigned int a_frame_h,
+ unsigned int a_drw_w,
+ unsigned int a_drw_h,
+ unsigned int *a_actual_w,
+ unsigned int *a_actual_h)
+{
+ int res=0 ;
+ Bool is_ok=FALSE ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_actual_w && a_actual_h, FALSE) ;
+
+ EPHYR_LOG ("enter: frame (%dx%d), drw (%dx%d)\n",
+ a_frame_w, a_frame_h,
+ a_drw_w, a_drw_h) ;
+
+ res = XvQueryBestSize (hostx_get_display (),
+ a_port_id,
+ a_motion,
+ a_frame_w, a_frame_h,
+ a_drw_w, a_drw_h,
+ a_actual_w, a_actual_h) ;
+ if (res != Success) {
+ EPHYR_LOG_ERROR ("XvQueryBestSize() failed: %d\n", res) ;
+ goto out ;
+ }
+ XSync (hostx_get_display (), FALSE) ;
+
+ EPHYR_LOG ("actual (%dx%d)\n", *a_actual_w, *a_actual_h) ;
+ is_ok = TRUE ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+static Bool
+xv_wire_to_event(Display *dpy, XEvent *host, xEvent *wire)
+{
+ XExtDisplayInfo *info = xv_find_display (dpy);
+ XvEvent *re = (XvEvent *)host;
+ xvEvent *event = (xvEvent *)wire;
+
+ XvCheckExtension(dpy, info, False);
+
+ switch ((event->u.u.type & 0x7F) - info->codes->first_event) {
+ case XvVideoNotify:
+ re->xvvideo.type = event->u.u.type & 0x7f;
+ re->xvvideo.serial =
+ _XSetLastRequestRead(dpy, (xGenericReply *)event);
+ re->xvvideo.send_event = ((event->u.u.type & 0x80) != 0);
+ re->xvvideo.display = dpy;
+ re->xvvideo.time = event->u.videoNotify.time;
+ re->xvvideo.reason = event->u.videoNotify.reason;
+ re->xvvideo.drawable = event->u.videoNotify.drawable;
+ re->xvvideo.port_id = event->u.videoNotify.port;
+ break;
+ case XvPortNotify:
+ re->xvport.type = event->u.u.type & 0x7f;
+ re->xvport.serial =
+ _XSetLastRequestRead(dpy, (xGenericReply *)event);
+ re->xvport.send_event = ((event->u.u.type & 0x80) != 0);
+ re->xvport.display = dpy;
+ re->xvport.time = event->u.portNotify.time;
+ re->xvport.port_id = event->u.portNotify.port;
+ re->xvport.attribute = event->u.portNotify.attribute;
+ re->xvport.value = event->u.portNotify.value;
+ break;
+ default:
+ return False;
+ }
+
+ return True ;
+}
+
+Bool
+ephyrHostXVQueryImageAttributes (int a_port_id,
+ int a_image_id /*image fourcc code*/,
+ unsigned short *a_width,
+ unsigned short *a_height,
+ int *a_image_size,
+ int *a_pitches,
+ int *a_offsets)
+{
+ Display *dpy = hostx_get_display () ;
+ Bool ret=FALSE ;
+ XExtDisplayInfo *info = xv_find_display (dpy);
+ xvQueryImageAttributesReq *req=NULL;
+ xvQueryImageAttributesReply rep;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_width, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL (a_height, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL (a_image_size, FALSE) ;
+
+ XvCheckExtension (dpy, info, FALSE);
+
+ LockDisplay (dpy);
+
+ XvGetReq (QueryImageAttributes, req);
+ req->id = a_image_id;
+ req->port = a_port_id;
+ req->width = *a_width;
+ req->height = *a_height;
+ /*
+ * read the reply
+ */
+ if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) {
+ EPHYR_LOG_ERROR ("QeryImageAttribute req failed\n") ;
+ goto out ;
+ }
+ if (a_pitches && a_offsets) {
+ _XRead (dpy,
+ (char*)a_pitches,
+ rep.num_planes << 2);
+ _XRead (dpy,
+ (char*)a_offsets,
+ rep.num_planes << 2);
+ } else {
+ _XEatData(dpy, rep.length << 2);
+ }
+ *a_width = rep.width ;
+ *a_height = rep.height ;
+ *a_image_size = rep.data_size ;
+
+ ret = TRUE ;
+
+out:
+ UnlockDisplay (dpy) ;
+ SyncHandle ();
+ return ret ;
+}
+
+Bool
+ephyrHostGetAtom (const char* a_name,
+ Bool a_create_if_not_exists,
+ int *a_atom)
+{
+ int atom=None ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_atom, FALSE) ;
+
+ atom = XInternAtom (hostx_get_display (), a_name, a_create_if_not_exists);
+ if (atom == None) {
+ return FALSE ;
+ }
+ *a_atom = atom ;
+ return TRUE ;
+}
+
+char*
+ephyrHostGetAtomName (int a_atom)
+{
+ return XGetAtomName (hostx_get_display (), a_atom) ;
+}
+
+void
+ephyrHostFree (void *a_pointer)
+{
+ if (a_pointer)
+ XFree (a_pointer) ;
+}
+
+Bool
+ephyrHostXVPutImage (int a_screen_num,
+ int a_port_id,
+ int a_image_id,
+ int a_drw_x,
+ int a_drw_y,
+ int a_drw_w,
+ int a_drw_h,
+ int a_src_x,
+ int a_src_y,
+ int a_src_w,
+ int a_src_h,
+ int a_image_width,
+ int a_image_height,
+ unsigned char *a_buf,
+ EphyrHostBox *a_clip_rects,
+ int a_clip_rect_nums )
+{
+ Bool is_ok=TRUE ;
+ XvImage *xv_image=NULL ;
+ GC gc=0 ;
+ XGCValues gc_values;
+ Display *dpy = hostx_get_display () ;
+ XRectangle *rects=NULL ;
+ int res = 0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_buf, FALSE) ;
+
+ EPHYR_LOG ("enter, num_clip_rects: %d\n", a_clip_rect_nums) ;
+
+ memset (&gc_values, 0, sizeof (gc_values)) ;
+ gc = XCreateGC (dpy, hostx_get_window (a_screen_num), 0L, &gc_values);
+ if (!gc) {
+ EPHYR_LOG_ERROR ("failed to create gc \n") ;
+ goto out ;
+ }
+ xv_image = (XvImage*) XvCreateImage (hostx_get_display (),
+ a_port_id, a_image_id,
+ NULL, a_image_width, a_image_height) ;
+ if (!xv_image) {
+ EPHYR_LOG_ERROR ("failed to create image\n") ;
+ goto out ;
+ }
+ xv_image->data = (char*)a_buf ;
+ if (a_clip_rect_nums) {
+ int i=0 ;
+ rects = calloc (a_clip_rect_nums, sizeof (XRectangle)) ;
+ for (i=0; i < a_clip_rect_nums; i++) {
+ rects[i].x = a_clip_rects[i].x1 ;
+ rects[i].y = a_clip_rects[i].y1 ;
+ rects[i].width = a_clip_rects[i].x2 - a_clip_rects[i].x1;
+ rects[i].height = a_clip_rects[i].y2 - a_clip_rects[i].y1;
+ EPHYR_LOG ("(x,y,w,h): (%d,%d,%d,%d)\n",
+ rects[i].x, rects[i].y,
+ rects[i].width, rects[i].height) ;
+ }
+ XSetClipRectangles (dpy, gc, 0, 0, rects, a_clip_rect_nums, YXBanded) ;
+ /*this always returns 1*/
+ }
+ res = XvPutImage (dpy, a_port_id,
+ hostx_get_window (a_screen_num),
+ gc, xv_image,
+ a_src_x, a_src_y, a_src_w, a_src_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h) ;
+ if (res != Success) {
+ EPHYR_LOG_ERROR ("XvPutImage() failed: %d\n", res) ;
+ goto out ;
+ }
+ is_ok = TRUE ;
+
+out:
+ if (xv_image) {
+ XFree (xv_image) ;
+ xv_image = NULL ;
+ }
+ if (gc) {
+ XFreeGC (dpy, gc) ;
+ gc = NULL ;
+ }
+ if (rects) {
+ free (rects) ;
+ rects = NULL ;
+ }
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+Bool
+ephyrHostXVPutVideo (int a_screen_num, int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
+{
+ Bool is_ok=FALSE ;
+ int res=FALSE ;
+ GC gc=0 ;
+ XGCValues gc_values;
+ Display *dpy=hostx_get_display () ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
+
+ gc = XCreateGC (dpy, hostx_get_window (a_screen_num), 0L, &gc_values);
+ if (!gc) {
+ EPHYR_LOG_ERROR ("failed to create gc \n") ;
+ goto out ;
+ }
+ res = XvPutVideo (dpy, a_port_id, hostx_get_window (a_screen_num), gc,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h) ;
+
+ if (res != Success) {
+ EPHYR_LOG_ERROR ("XvPutVideo() failed: %d\n", res) ;
+ goto out ;
+ }
+
+ is_ok = TRUE ;
+
+out:
+ if (gc) {
+ XFreeGC (dpy, gc) ;
+ gc = NULL ;
+ }
+ return is_ok ;
+}
+
+Bool
+ephyrHostXVGetVideo (int a_screen_num, int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
+{
+ Bool is_ok=FALSE ;
+ int res=FALSE ;
+ GC gc=0 ;
+ XGCValues gc_values;
+ Display *dpy=hostx_get_display () ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
+
+ gc = XCreateGC (dpy, hostx_get_window (a_screen_num), 0L, &gc_values);
+ if (!gc) {
+ EPHYR_LOG_ERROR ("failed to create gc \n") ;
+ goto out ;
+ }
+ res = XvGetVideo (dpy, a_port_id, hostx_get_window (a_screen_num), gc,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h) ;
+
+ if (res != Success) {
+ EPHYR_LOG_ERROR ("XvGetVideo() failed: %d\n", res) ;
+ goto out ;
+ }
+
+ is_ok = TRUE ;
+
+out:
+ if (gc) {
+ XFreeGC (dpy, gc) ;
+ gc = NULL ;
+ }
+ return is_ok ;
+}
+
+Bool
+ephyrHostXVPutStill (int a_screen_num, int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
+{
+ Bool is_ok=FALSE ;
+ int res=FALSE ;
+ GC gc=0 ;
+ XGCValues gc_values;
+ Display *dpy=hostx_get_display () ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
+
+ gc = XCreateGC (dpy, hostx_get_window (a_screen_num), 0L, &gc_values);
+ if (!gc) {
+ EPHYR_LOG_ERROR ("failed to create gc \n") ;
+ goto out ;
+ }
+ res = XvPutStill (dpy, a_port_id, hostx_get_window (a_screen_num), gc,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h) ;
+
+ if (res != Success) {
+ EPHYR_LOG_ERROR ("XvPutStill() failed: %d\n", res) ;
+ goto out ;
+ }
+
+ is_ok = TRUE ;
+
+out:
+ if (gc) {
+ XFreeGC (dpy, gc) ;
+ gc = NULL ;
+ }
+ return is_ok ;
+}
+
+Bool
+ephyrHostXVGetStill (int a_screen_num, int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h)
+{
+ Bool is_ok=FALSE ;
+ int res=FALSE ;
+ GC gc=0 ;
+ XGCValues gc_values;
+ Display *dpy=hostx_get_display () ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
+
+ gc = XCreateGC (dpy, hostx_get_window (a_screen_num), 0L, &gc_values);
+ if (!gc) {
+ EPHYR_LOG_ERROR ("failed to create gc \n") ;
+ goto out ;
+ }
+ res = XvGetStill (dpy, a_port_id, hostx_get_window (a_screen_num), gc,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h) ;
+
+ if (res != Success) {
+ EPHYR_LOG_ERROR ("XvGetStill() failed: %d\n", res) ;
+ goto out ;
+ }
+
+ is_ok = TRUE ;
+
+out:
+ if (gc) {
+ XFreeGC (dpy, gc) ;
+ gc = NULL ;
+ }
+ return is_ok ;
+}
+
+Bool
+ephyrHostXVStopVideo (int a_screen_num, int a_port_id)
+{
+ int ret=0 ;
+ Bool is_ok=FALSE ;
+ Display *dpy = hostx_get_display () ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ ret = XvStopVideo (dpy, a_port_id, hostx_get_window (a_screen_num)) ;
+ if (ret != Success) {
+ EPHYR_LOG_ERROR ("XvStopVideo() failed: %d \n", ret) ;
+ goto out ;
+ }
+ is_ok = TRUE ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.h b/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.h
new file mode 100644
index 000000000..05ee38a03
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrhostvideo.h
@@ -0,0 +1,238 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * 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 OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+#ifndef __EPHYRHOSTVIDEO_H__
+#define __EPHYRHOSTVIDEO_H__
+
+typedef void* EphyrHostXVAdaptor ;
+typedef struct _EphyrHostXVAdaptorArray EphyrHostXVAdaptorArray ;
+
+typedef struct _EphyrHostVideoFormat {
+ char depth ;
+ short visual_class;
+} EphyrHostVideoFormat ;
+
+typedef struct _EphyrHostRational {
+ int numerator ;
+ int denominator ;
+} EphyrHostRational;
+
+typedef struct _EphyrHostEncoding {
+ int id ;
+ char *name ;
+ unsigned short width, height ;
+ EphyrHostRational rate ;
+} EphyrHostEncoding ;
+
+typedef struct _EphyrHostAttribute {
+ int flags;
+ int min_value;
+ int max_value;
+ char *name;
+} EphyrHostAttribute ;
+
+typedef struct _EphyrHostImageFormat {
+ int id; /* Unique descriptor for the format */
+ int type; /* XvRGB, XvYUV */
+ int byte_order; /* LSBFirst, MSBFirst */
+ char guid[16]; /* Globally Unique IDentifier */
+ int bits_per_pixel;
+ int format; /* XvPacked, XvPlanar */
+ 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]; /* eg. UYVY */
+ int scanline_order; /* XvTopToBottom, XvBottomToTop */
+} EphyrHostImageFormat ;
+
+typedef struct {
+ unsigned short x1, y1, x2, y2 ;
+} EphyrHostBox ;
+
+void ephyrHostXVInit (void) ;
+
+void ephyrHostFree (void *a_pointer) ;
+
+/*
+ * host adaptor array
+ */
+Bool ephyrHostXVQueryAdaptors (EphyrHostXVAdaptorArray **a_adaptors) ;
+void ephyrHostXVAdaptorArrayDelete (EphyrHostXVAdaptorArray *a_adaptors) ;
+int ephyrHostXVAdaptorArrayGetSize (const EphyrHostXVAdaptorArray *a_this) ;
+EphyrHostXVAdaptor* ephyrHostXVAdaptorArrayAt (const EphyrHostXVAdaptorArray *a_this,
+ int a_index) ;
+
+/*
+ * host adaptor
+ */
+
+char ephyrHostXVAdaptorGetType (const EphyrHostXVAdaptor *a_this) ;
+const char* ephyrHostXVAdaptorGetName (const EphyrHostXVAdaptor *a_this) ;
+EphyrHostVideoFormat* ephyrHostXVAdaptorGetVideoFormats
+ (const EphyrHostXVAdaptor *a_this,
+ int *a_nb_formats) ;
+int ephyrHostXVAdaptorGetNbPorts (const EphyrHostXVAdaptor *a_this) ;
+int ephyrHostXVAdaptorGetFirstPortID (const EphyrHostXVAdaptor *a_this) ;
+
+Bool ephyrHostXVAdaptorHasPutVideo (const EphyrHostXVAdaptor *a_this,
+ Bool *a_result) ;
+Bool ephyrHostXVAdaptorHasGetVideo (const EphyrHostXVAdaptor *a_this,
+ Bool *a_result) ;
+Bool ephyrHostXVAdaptorHasPutStill (const EphyrHostXVAdaptor *a_this,
+ Bool *a_result) ;
+Bool ephyrHostXVAdaptorHasGetStill (const EphyrHostXVAdaptor *a_this,
+ Bool *a_result) ;
+Bool ephyrHostXVAdaptorHasPutImage (const EphyrHostXVAdaptor *a_this,
+ Bool *a_result) ;
+
+/*
+ * encoding
+ */
+Bool ephyrHostXVQueryEncodings (int a_port_id,
+ EphyrHostEncoding **a_encodings,
+ unsigned int *a_num_encodings) ;
+
+void ephyrHostEncodingsDelete (EphyrHostEncoding *a_encodings,
+ int a_num_encodings) ;
+
+/*
+ * attribute
+ */
+Bool ephyrHostXVQueryPortAttributes (int a_port_id,
+ EphyrHostAttribute **a_attributes,
+ int *a_num_attributes) ;
+
+void ephyrHostAttributesDelete (EphyrHostAttribute *a_attributes) ;
+/*
+ * image format
+ */
+
+Bool ephyrHostXVQueryImageFormats (int a_port_id,
+ EphyrHostImageFormat **a_formats,
+ int *a_num_format) ;
+/*
+ * Port Attribute Get/Set
+ */
+Bool ephyrHostXVSetPortAttribute (int a_port_id,
+ int a_atom,
+ int a_attr_value) ;
+Bool ephyrHostXVGetPortAttribute (int a_port_id,
+ int a_atom,
+ int *a_attr_value) ;
+/*
+ *size query
+ */
+Bool ephyrHostXVQueryBestSize (int a_port_id,
+ Bool a_motion,
+ unsigned int a_frame_w,
+ unsigned int a_frame_h,
+ unsigned int a_drw_w,
+ unsigned int a_drw_h,
+ unsigned int *a_actual_w,
+ unsigned int *a_actual_h) ;
+
+Bool ephyrHostXVQueryImageAttributes (int a_port_id,
+ int a_image_id /*image fourcc code*/,
+ unsigned short *a_width,
+ unsigned short *a_height,
+ int *a_image_size,
+ int *a_pitches,
+ int *a_offsets) ;
+/*
+ * atom
+ */
+Bool ephyrHostGetAtom (const char* a_name,
+ Bool a_create_if_not_exists,
+ int *a_atom) ;
+char* ephyrHostGetAtomName (int a_atom) ;
+
+/*
+ *PutImage
+ * (ignore clipping for now)
+ */
+Bool ephyrHostXVPutImage (int a_screen_num,
+ int a_port_id,
+ int a_image_id,
+ int a_drw_x,
+ int a_drw_y,
+ int a_drw_w,
+ int a_drw_h,
+ int a_src_x,
+ int a_src_y,
+ int a_src_w,
+ int a_src_h,
+ int a_image_width,
+ int a_image_height,
+ unsigned char *a_buf,
+ EphyrHostBox *a_clip_rects,
+ int a_clip_rect_nums) ;
+
+/*
+ * Putvideo/PutStill/GetVideo
+ */
+Bool ephyrHostXVPutVideo (int a_screen_num,
+ int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
+
+Bool ephyrHostXVGetVideo (int a_screen_num,
+ int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
+
+Bool ephyrHostXVPutStill (int a_screen_num,
+ int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
+
+Bool ephyrHostXVGetStill (int a_screen_num,
+ int a_port_id,
+ int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
+ int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
+
+/*
+ * StopVideo
+ */
+Bool ephyrHostXVStopVideo (int a_screen_num, int a_port_id) ;
+
+#endif /*__EPHYRHOSTVIDEO_H__*/
+
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrinit.c b/xorg-server/hw/kdrive/ephyr/ephyrinit.c
new file mode 100644
index 000000000..47ddb3d82
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrinit.c
@@ -0,0 +1,345 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@o-hand.com>
+ *
+ * Copyright © 2004 Nokia
+ *
+ * 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 Nokia not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Nokia makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "ephyr.h"
+#include "ephyrlog.h"
+
+extern Window EphyrPreExistingHostWin;
+extern Bool EphyrWantGrayScale;
+extern Bool kdHasPointer;
+extern Bool kdHasKbd;
+
+#ifdef GLXEXT
+extern Bool ephyrNoDRI;
+extern Bool noGlxVisualInit;
+#endif
+extern Bool ephyrNoXV;
+
+void processScreenArg (char *screen_size, char *parent_id) ;
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+
+ EPHYR_DBG("mark");
+
+
+ KdCardInfoAdd (&ephyrFuncs, &attr, 0);
+}
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdKeyboardInfo *ki;
+ KdPointerInfo *pi;
+
+ KdAddKeyboardDriver(&EphyrKeyboardDriver);
+#ifdef linux
+ KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver);
+#endif
+ KdAddPointerDriver(&EphyrMouseDriver);
+#ifdef linux
+ KdAddPointerDriver(&LinuxEvdevMouseDriver);
+#endif
+
+ if (!kdHasKbd) {
+ ki = KdNewKeyboard();
+ if (!ki)
+ FatalError("Couldn't create Xephyr keyboard\n");
+ ki->driver = &EphyrKeyboardDriver;
+ KdAddKeyboard(ki);
+ }
+
+ if (!kdHasPointer) {
+ pi = KdNewPointer();
+ if (!pi)
+ FatalError("Couldn't create Xephyr pointer\n");
+ pi->driver = &EphyrMouseDriver;
+ KdAddPointer(pi);
+ }
+
+ KdInitInput();
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+
+ ErrorF("\nXephyr Option Usage:\n");
+ ErrorF("-parent <XID> Use existing window as Xephyr root win\n");
+ ErrorF("-host-cursor Re-use exisiting X host server cursor\n");
+ ErrorF("-fullscreen Attempt to run Xephyr fullscreen\n");
+ ErrorF("-grayscale Simulate 8bit grayscale\n");
+ ErrorF("-fakexa Simulate acceleration using software rendering\n");
+ ErrorF("-verbosity <level> Set log verbosity level\n");
+#ifdef GLXEXT
+ ErrorF("-nodri do not use DRI\n");
+#endif
+ ErrorF("-noxv do not use XV\n");
+ ErrorF("-name [name] define the name in the WM_CLASS property\n");
+ ErrorF("\n");
+
+ exit(1);
+}
+
+void
+processScreenArg (char *screen_size, char *parent_id)
+{
+ KdCardInfo *card;
+
+ InitCard (0); /*Put each screen on a separate card*/
+ card = KdCardInfoLast ();
+
+ if (card)
+ {
+ KdScreenInfo *screen;
+ unsigned long p_id = 0;
+
+ screen = KdScreenInfoAdd (card);
+ KdParseScreen (screen, screen_size);
+
+ if (parent_id)
+ {
+ p_id = strtol (parent_id, NULL, 0);
+ }
+ EPHYR_DBG ("screen number:%d\n", screen->mynum) ;
+ hostx_add_screen (screen, p_id, screen->mynum);
+ }
+ else
+ {
+ ErrorF("No matching card found!\n");
+ }
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ EPHYR_DBG("mark argv[%d]='%s'", i, argv[i] );
+
+ if (i == 1)
+ {
+ hostx_use_resname(basename(argv[0]), 0);
+ }
+
+ if (!strcmp (argv[i], "-parent"))
+ {
+ if(i+1 < argc)
+ {
+ processScreenArg ("100x100", argv[i+1]);
+ return 2;
+ }
+
+ UseMsg();
+ exit(1);
+ }
+ else if (!strcmp (argv[i], "-screen"))
+ {
+ if ((i+1) < argc)
+ {
+ processScreenArg (argv[i+1], NULL);
+ return 2;
+ }
+
+ UseMsg();
+ exit(1);
+ }
+ else if (!strcmp (argv[i], "-host-cursor"))
+ {
+ hostx_use_host_cursor();
+ return 1;
+ }
+ else if (!strcmp (argv[i], "-fullscreen"))
+ {
+ hostx_use_fullscreen();
+ return 1;
+ }
+ else if (!strcmp (argv[i], "-grayscale"))
+ {
+ EphyrWantGrayScale = 1;
+ return 1;
+ }
+ else if (!strcmp (argv[i], "-fakexa"))
+ {
+ ephyrFuncs.initAccel = ephyrDrawInit;
+ ephyrFuncs.enableAccel = ephyrDrawEnable;
+ ephyrFuncs.disableAccel = ephyrDrawDisable;
+ ephyrFuncs.finiAccel = ephyrDrawFini;
+ return 1;
+ }
+ else if (!strcmp (argv[i], "-verbosity"))
+ {
+ if(i+1 < argc && argv[i+1][0] != '-')
+ {
+ int verbosity=atoi (argv[i+1]) ;
+ LogSetParameter (XLOG_VERBOSITY, verbosity) ;
+ EPHYR_LOG ("set verbosiry to %d\n", verbosity) ;
+ return 2 ;
+ }
+ else
+ {
+ UseMsg() ;
+ exit(1) ;
+ }
+ }
+#ifdef GLXEXT
+ else if (!strcmp (argv[i], "-nodri"))
+ {
+ noGlxVisualInit = FALSE ;
+ ephyrNoDRI = TRUE ;
+ EPHYR_LOG ("no direct rendering enabled\n") ;
+ return 1 ;
+ }
+#endif
+ else if (!strcmp (argv[i], "-noxv"))
+ {
+ ephyrNoXV = TRUE ;
+ EPHYR_LOG ("no XVideo enabled\n") ;
+ return 1 ;
+ }
+ else if (!strcmp (argv[i], "-name"))
+ {
+ if (i+1 < argc && argv[i+1][0] != '-')
+ {
+ hostx_use_resname(argv[i+1], 1);
+ return 2;
+ }
+ else
+ {
+ UseMsg();
+ return 0;
+ }
+ }
+ else if (argv[i][0] == ':')
+ {
+ hostx_set_display_name(argv[i]);
+ }
+
+ return KdProcessArgument (argc, argv, i);
+}
+
+void
+OsVendorInit (void)
+{
+ EPHYR_DBG("mark");
+
+ if (hostx_want_host_cursor())
+ {
+ ephyrFuncs.initCursor = &ephyrCursorInit;
+ ephyrFuncs.enableCursor = &ephyrCursorEnable;
+ }
+
+ KdOsInit (&EphyrOsFuncs);
+}
+
+/* 'Fake' cursor stuff, could be improved */
+
+static Bool
+ephyrRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+ return TRUE;
+}
+
+static Bool
+ephyrUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
+{
+ return TRUE;
+}
+
+static void
+ephyrSetCursor(ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
+{
+ ;
+}
+
+static void
+ephyrMoveCursor(ScreenPtr pScreen, int x, int y)
+{
+ ;
+}
+
+miPointerSpriteFuncRec EphyrPointerSpriteFuncs = {
+ ephyrRealizeCursor,
+ ephyrUnrealizeCursor,
+ ephyrSetCursor,
+ ephyrMoveCursor,
+};
+
+
+Bool
+ephyrCursorInit(ScreenPtr pScreen)
+{
+ miPointerInitialize(pScreen,
+ &EphyrPointerSpriteFuncs,
+ &ephyrPointerScreenFuncs,
+ FALSE);
+
+ return TRUE;
+}
+
+void
+ephyrCursorEnable(ScreenPtr pScreen)
+{
+ ;
+}
+
+KdCardFuncs ephyrFuncs = {
+ ephyrCardInit, /* cardinit */
+ ephyrScreenInit, /* scrinit */
+ ephyrInitScreen, /* initScreen */
+ ephyrFinishInitScreen, /* finishInitScreen */
+ ephyrCreateResources, /* createRes */
+ ephyrPreserve, /* preserve */
+ ephyrEnable, /* enable */
+ ephyrDPMS, /* dpms */
+ ephyrDisable, /* disable */
+ ephyrRestore, /* restore */
+ ephyrScreenFini, /* scrfini */
+ ephyrCardFini, /* cardfini */
+
+ 0, /* initCursor */
+ 0, /* enableCursor */
+ 0, /* disableCursor */
+ 0, /* finiCursor */
+ 0, /* recolorCursor */
+
+ 0, /* initAccel */
+ 0, /* enableAccel */
+ 0, /* disableAccel */
+ 0, /* finiAccel */
+
+ ephyrGetColors, /* getColors */
+ ephyrPutColors, /* putColors */
+};
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrlog.h b/xorg-server/hw/kdrive/ephyr/ephyrlog.h
new file mode 100644
index 000000000..71f797777
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrlog.h
@@ -0,0 +1,67 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * 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 OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+#ifndef __EPHYRLOG_H__
+#define __EPHYRLOG_H__
+
+#include <assert.h>
+#include "os.h"
+
+#ifdef NDEBUG
+/*we are not in debug mode*/
+#define EPHYR_LOG(...)
+#define EPHYR_LOG_ERROR(...)
+#endif /*NDEBUG*/
+
+#define ERROR_LOG_LEVEL 3
+#define INFO_LOG_LEVEL 4
+
+#ifndef EPHYR_LOG
+#define EPHYR_LOG(...) \
+LogMessageVerb(X_NOTICE, INFO_LOG_LEVEL, "in %s:%d:%s: ",\
+ __FILE__, __LINE__, __func__) ; \
+LogMessageVerb(X_NOTICE, INFO_LOG_LEVEL, __VA_ARGS__)
+#endif /*nomadik_log*/
+
+#ifndef EPHYR_LOG_ERROR
+#define EPHYR_LOG_ERROR(...) \
+LogMessageVerb(X_NOTICE, ERROR_LOG_LEVEL, "Error:in %s:%d:%s: ",\
+ __FILE__, __LINE__, __func__) ; \
+LogMessageVerb(X_NOTICE, ERROR_LOG_LEVEL, __VA_ARGS__)
+#endif /*EPHYR_LOG_ERROR*/
+
+#ifndef EPHYR_RETURN_IF_FAIL
+#define EPHYR_RETURN_IF_FAIL(cond) \
+if (!(cond)) {EPHYR_LOG_ERROR("condition %s failed\n", #cond);return;}
+#endif /*nomadik_return_if_fail*/
+
+#ifndef EPHYR_RETURN_VAL_IF_FAIL
+#define EPHYR_RETURN_VAL_IF_FAIL(cond,val) \
+if (!(cond)) {EPHYR_LOG_ERROR("condition %s failed\n", #cond);return val;}
+#endif /*nomadik_return_val_if_fail*/
+
+#endif /*__EPHYRLOG_H__*/
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrvideo.c b/xorg-server/hw/kdrive/ephyr/ephyrvideo.c
new file mode 100644
index 000000000..bfe4d7223
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/ephyrvideo.c
@@ -0,0 +1,1278 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@openedhand.com>
+ *
+ * Copyright © 2007 OpenedHand Ltd
+ *
+ * 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 OpenedHand Ltd not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OpenedHand Ltd makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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:
+ * Dodji Seketeli <dodji@openedhand.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include <string.h>
+#include <X11/extensions/Xv.h>
+#include "ephyrlog.h"
+#include "kdrive.h"
+#include "kxv.h"
+#include "ephyr.h"
+#include "hostx.h"
+#include "ephyrhostvideo.h"
+
+struct _EphyrXVPriv {
+ EphyrHostXVAdaptorArray *host_adaptors ;
+ KdVideoAdaptorPtr adaptors ;
+ int num_adaptors ;
+};
+typedef struct _EphyrXVPriv EphyrXVPriv ;
+
+struct _EphyrPortPriv {
+ int port_number ;
+ KdVideoAdaptorPtr current_adaptor ;
+ EphyrXVPriv *xv_priv;
+ unsigned char *image_buf ;
+ int image_buf_size ;
+ int image_id ;
+ int drw_x, drw_y, drw_w, drw_h ;
+ int src_x, src_y, src_w, src_h ;
+ int image_width, image_height ;
+};
+typedef struct _EphyrPortPriv EphyrPortPriv ;
+
+static Bool DoSimpleClip (BoxPtr a_dst_drw,
+ BoxPtr a_clipper,
+ BoxPtr a_result) ;
+
+static Bool ephyrLocalAtomToHost (int a_local_atom, int *a_host_atom) ;
+
+/*
+static Bool ephyrHostAtomToLocal (int a_host_atom, int *a_local_atom) ;
+*/
+
+static EphyrXVPriv* ephyrXVPrivNew (void) ;
+static void ephyrXVPrivDelete (EphyrXVPriv *a_this) ;
+static Bool ephyrXVPrivQueryHostAdaptors (EphyrXVPriv *a_this) ;
+static Bool ephyrXVPrivSetAdaptorsHooks (EphyrXVPriv *a_this) ;
+static Bool ephyrXVPrivRegisterAdaptors (EphyrXVPriv *a_this,
+ ScreenPtr a_screen) ;
+
+static Bool ephyrXVPrivIsAttrValueValid (KdAttributePtr a_attrs,
+ int a_attrs_len,
+ const char *a_attr_name,
+ int a_attr_value,
+ Bool *a_is_valid) ;
+
+static Bool ephyrXVPrivGetImageBufSize (int a_port_id,
+ int a_image_id,
+ unsigned short a_width,
+ unsigned short a_height,
+ int *a_size) ;
+
+static Bool ephyrXVPrivSaveImageToPortPriv (EphyrPortPriv *a_port_priv,
+ const unsigned char *a_image,
+ int a_image_len) ;
+
+static void ephyrStopVideo (KdScreenInfo *a_info,
+ pointer a_xv_priv,
+ Bool a_exit);
+
+static int ephyrSetPortAttribute (KdScreenInfo *a_info,
+ Atom a_attr_name,
+ int a_attr_value,
+ pointer a_port_priv);
+
+static int ephyrGetPortAttribute (KdScreenInfo *a_screen_info,
+ Atom a_attr_name,
+ int *a_attr_value,
+ pointer a_port_priv);
+
+static void ephyrQueryBestSize (KdScreenInfo *a_info,
+ Bool a_motion,
+ short a_src_w,
+ short a_src_h,
+ short a_drw_w,
+ short a_drw_h,
+ unsigned int *a_prefered_w,
+ unsigned int *a_prefered_h,
+ pointer a_port_priv);
+
+static int ephyrPutImage (KdScreenInfo *a_info,
+ DrawablePtr a_drawable,
+ short a_src_x,
+ short a_src_y,
+ short a_drw_x,
+ short a_drw_y,
+ short a_src_w,
+ short a_src_h,
+ short a_drw_w,
+ short a_drw_h,
+ int a_id,
+ unsigned char *a_buf,
+ short a_width,
+ short a_height,
+ Bool a_sync,
+ RegionPtr a_clipping_region,
+ pointer a_port_priv);
+
+static int ephyrReputImage (KdScreenInfo *a_info,
+ DrawablePtr a_drawable,
+ short a_drw_x,
+ short a_drw_y,
+ RegionPtr a_clipping_region,
+ pointer a_port_priv) ;
+
+static int ephyrPutVideo (KdScreenInfo *a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clip_region,
+ pointer a_port_priv) ;
+
+static int ephyrGetVideo (KdScreenInfo *a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clip_region,
+ pointer a_port_priv) ;
+
+static int ephyrPutStill (KdScreenInfo *a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clip_region,
+ pointer a_port_priv) ;
+
+static int ephyrGetStill (KdScreenInfo *a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clip_region,
+ pointer a_port_priv) ;
+
+static int ephyrQueryImageAttributes (KdScreenInfo *a_info,
+ int a_id,
+ unsigned short *a_w,
+ unsigned short *a_h,
+ int *a_pitches,
+ int *a_offsets);
+static int s_base_port_id ;
+
+/**************
+ * <helpers>
+ * ************/
+
+static Bool
+DoSimpleClip (BoxPtr a_dst_box,
+ BoxPtr a_clipper,
+ BoxPtr a_result)
+{
+ BoxRec dstClippedBox ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_dst_box && a_clipper && a_result, FALSE) ;
+
+ /*
+ * setup the clipbox inside the destination.
+ */
+ dstClippedBox.x1 = a_dst_box->x1 ;
+ dstClippedBox.x2 = a_dst_box->x2 ;
+ dstClippedBox.y1 = a_dst_box->y1 ;
+ dstClippedBox.y2 = a_dst_box->y2 ;
+
+ /*
+ * if the cliper leftmost edge is inside
+ * the destination area then the leftmost edge of the resulting
+ * clipped box is the leftmost edge of the cliper.
+ */
+ if (a_clipper->x1 > dstClippedBox.x1)
+ dstClippedBox.x1 = a_clipper->x1 ;
+
+ /*
+ * if the cliper top edge is inside the destination area
+ * then the bottom horizontal edge of the resulting clipped box
+ * is the bottom edge of the cliper
+ */
+ if (a_clipper->y1 > dstClippedBox.y1)
+ dstClippedBox.y1 = a_clipper->y1 ;
+
+ /*ditto for right edge*/
+ if (a_clipper->x2 < dstClippedBox.x2)
+ dstClippedBox.x2 = a_clipper->x2 ;
+
+ /*ditto for bottom edge*/
+ if (a_clipper->y2 < dstClippedBox.y2)
+ dstClippedBox.y2 = a_clipper->y2 ;
+
+ memcpy (a_result, &dstClippedBox, sizeof (dstClippedBox)) ;
+ return TRUE ;
+}
+
+static Bool
+ephyrLocalAtomToHost (int a_local_atom, int *a_host_atom)
+{
+ char *atom_name=NULL;
+ int host_atom=None ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_host_atom, FALSE) ;
+
+ if (!ValidAtom (a_local_atom))
+ return FALSE ;
+
+ atom_name = NameForAtom (a_local_atom) ;
+
+ if (!atom_name)
+ return FALSE ;
+
+ if (!ephyrHostGetAtom (atom_name, FALSE, &host_atom) || host_atom == None) {
+ EPHYR_LOG_ERROR ("no atom for string %s defined in host X\n",
+ atom_name) ;
+ return FALSE ;
+ }
+ *a_host_atom = host_atom ;
+ return TRUE ;
+}
+
+/*
+ Not used yed.
+static Bool
+ephyrHostAtomToLocal (int a_host_atom, int *a_local_atom)
+{
+ Bool is_ok=FALSE ;
+ char *atom_name=NULL ;
+ int atom=None ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_local_atom, FALSE) ;
+
+ atom_name = ephyrHostGetAtomName (a_host_atom) ;
+ if (!atom_name)
+ goto out ;
+
+ atom = MakeAtom (atom_name, strlen (atom_name), TRUE) ;
+ if (atom == None)
+ goto out ;
+
+ *a_local_atom = atom ;
+ is_ok = TRUE ;
+
+out:
+ if (atom_name) {
+ ephyrHostFree (atom_name) ;
+ }
+ return is_ok ;
+}
+*/
+
+/**************
+ *</helpers>
+ * ************/
+
+Bool
+ephyrInitVideo (ScreenPtr pScreen)
+{
+ Bool is_ok = FALSE ;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ static EphyrXVPriv *xv_priv;
+
+ EPHYR_LOG ("enter\n") ;
+
+ if (screen->fb[0].bitsPerPixel == 8) {
+ EPHYR_LOG_ERROR ("8 bits depth not supported\n") ;
+ return FALSE ;
+ }
+
+ if (!xv_priv) {
+ xv_priv = ephyrXVPrivNew () ;
+ }
+ if (!xv_priv) {
+ EPHYR_LOG_ERROR ("failed to create xv_priv\n") ;
+ goto out ;
+ }
+
+ if (!ephyrXVPrivRegisterAdaptors (xv_priv, pScreen)) {
+ EPHYR_LOG_ERROR ("failed to register adaptors\n") ;
+ goto out ;
+ }
+ is_ok = TRUE ;
+
+out:
+ return is_ok ;
+}
+
+static EphyrXVPriv*
+ephyrXVPrivNew (void)
+{
+ EphyrXVPriv *xv_priv=NULL ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ xv_priv = xcalloc (1, sizeof (EphyrXVPriv)) ;
+ if (!xv_priv) {
+ EPHYR_LOG_ERROR ("failed to create EphyrXVPriv\n") ;
+ goto error ;
+ }
+
+ ephyrHostXVInit () ;
+
+ if (!ephyrXVPrivQueryHostAdaptors (xv_priv)) {
+ EPHYR_LOG_ERROR ("failed to query the host x for xv properties\n") ;
+ goto error ;
+ }
+ if (!ephyrXVPrivSetAdaptorsHooks (xv_priv)) {
+ EPHYR_LOG_ERROR ("failed to set xv_priv hooks\n") ;
+ goto error ;
+ }
+
+ EPHYR_LOG ("leave\n") ;
+ return xv_priv ;
+
+error:
+ if (xv_priv) {
+ ephyrXVPrivDelete (xv_priv) ;
+ xv_priv = NULL ;
+ }
+ return NULL ;
+}
+
+static void
+ephyrXVPrivDelete (EphyrXVPriv *a_this)
+{
+ EPHYR_LOG ("enter\n") ;
+
+ if (!a_this)
+ return ;
+ if (a_this->host_adaptors) {
+ ephyrHostXVAdaptorArrayDelete (a_this->host_adaptors) ;
+ a_this->host_adaptors = NULL ;
+ }
+ if (a_this->adaptors) {
+ xfree (a_this->adaptors) ;
+ a_this->adaptors = NULL ;
+ }
+ xfree (a_this) ;
+ EPHYR_LOG ("leave\n") ;
+}
+
+static KdVideoEncodingPtr
+videoEncodingDup (EphyrHostEncoding *a_encodings,
+ int a_num_encodings)
+{
+ KdVideoEncodingPtr result = NULL ;
+ int i=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_encodings && a_num_encodings, NULL) ;
+
+ result = xcalloc (a_num_encodings, sizeof (KdVideoEncodingRec)) ;
+ for (i=0 ; i < a_num_encodings; i++) {
+ result[i].id = a_encodings[i].id ;
+ result[i].name = strdup (a_encodings[i].name) ;
+ result[i].width = a_encodings[i].width ;
+ result[i].height = a_encodings[i].height ;
+ result[i].rate.numerator = a_encodings[i].rate.numerator ;
+ result[i].rate.denominator = a_encodings[i].rate.denominator ;
+ }
+ return result ;
+}
+
+static KdAttributePtr
+portAttributesDup (EphyrHostAttribute *a_encodings,
+ int a_num_encodings)
+{
+ int i=0 ;
+ KdAttributePtr result=NULL ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_encodings && a_num_encodings, NULL) ;
+
+ result = xcalloc (a_num_encodings, sizeof (KdAttributeRec)) ;
+ if (!result) {
+ EPHYR_LOG_ERROR ("failed to allocate attributes\n") ;
+ return NULL ;
+ }
+ for (i=0; i < a_num_encodings; i++) {
+ result[i].flags = a_encodings[i].flags ;
+ result[i].min_value = a_encodings[i].min_value ;
+ result[i].max_value = a_encodings[i].max_value ;
+ result[i].name = strdup (a_encodings[i].name) ;
+ }
+ return result ;
+}
+
+static Bool
+ephyrXVPrivQueryHostAdaptors (EphyrXVPriv *a_this)
+{
+ EphyrHostXVAdaptor *cur_host_adaptor=NULL ;
+ EphyrHostVideoFormat *video_formats=NULL ;
+ EphyrHostEncoding *encodings=NULL ;
+ EphyrHostAttribute *attributes=NULL ;
+ EphyrHostImageFormat *image_formats=NULL ;
+ int num_video_formats=0, base_port_id=0,
+ num_attributes=0, num_formats=0, i=0,
+ port_priv_offset=0;
+ unsigned num_encodings=0 ;
+ Bool is_ok = FALSE ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_this, FALSE) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ if (!ephyrHostXVQueryAdaptors (&a_this->host_adaptors)) {
+ EPHYR_LOG_ERROR ("failed to query host adaptors\n") ;
+ goto out ;
+ }
+ if (a_this->host_adaptors)
+ a_this->num_adaptors =
+ ephyrHostXVAdaptorArrayGetSize (a_this->host_adaptors) ;
+ if (a_this->num_adaptors < 0) {
+ EPHYR_LOG_ERROR ("failed to get number of host adaptors\n") ;
+ goto out ;
+ }
+ EPHYR_LOG ("host has %d adaptors\n", a_this->num_adaptors) ;
+ /*
+ * copy what we can from adaptors into a_this->adaptors
+ */
+ if (a_this->num_adaptors) {
+ a_this->adaptors = xcalloc (a_this->num_adaptors,
+ sizeof (KdVideoAdaptorRec)) ;
+ if (!a_this->adaptors) {
+ EPHYR_LOG_ERROR ("failed to create internal adaptors\n") ;
+ goto out ;
+ }
+ }
+ for (i=0; i < a_this->num_adaptors; i++) {
+ int j=0 ;
+ cur_host_adaptor =
+ ephyrHostXVAdaptorArrayAt (a_this->host_adaptors, i) ;
+ if (!cur_host_adaptor)
+ continue ;
+ a_this->adaptors[i].nPorts =
+ ephyrHostXVAdaptorGetNbPorts (cur_host_adaptor) ;
+ if (a_this->adaptors[i].nPorts <=0) {
+ EPHYR_LOG_ERROR ("Could not find any port of adaptor %d\n", i) ;
+ continue ;
+ }
+ a_this->adaptors[i].type =
+ ephyrHostXVAdaptorGetType (cur_host_adaptor) ;
+ a_this->adaptors[i].type |= XvWindowMask ;
+ a_this->adaptors[i].flags =
+ VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
+ if (ephyrHostXVAdaptorGetName (cur_host_adaptor))
+ a_this->adaptors[i].name =
+ strdup (ephyrHostXVAdaptorGetName (cur_host_adaptor)) ;
+ else
+ a_this->adaptors[i].name = strdup ("Xephyr Video Overlay");
+ base_port_id = ephyrHostXVAdaptorGetFirstPortID (cur_host_adaptor) ;
+ if (base_port_id < 0) {
+ EPHYR_LOG_ERROR ("failed to get port id for adaptor %d\n", i) ;
+ continue ;
+ }
+ if (!s_base_port_id)
+ s_base_port_id = base_port_id ;
+
+ if (!ephyrHostXVQueryEncodings (base_port_id,
+ &encodings,
+ &num_encodings)) {
+ EPHYR_LOG_ERROR ("failed to get encodings for port port id %d,"
+ " adaptors %d\n",
+ base_port_id, i) ;
+ continue ;
+ }
+ a_this->adaptors[i].nEncodings = num_encodings ;
+ a_this->adaptors[i].pEncodings =
+ videoEncodingDup (encodings, num_encodings) ;
+ video_formats = (EphyrHostVideoFormat*)
+ ephyrHostXVAdaptorGetVideoFormats (cur_host_adaptor,
+ &num_video_formats);
+ a_this->adaptors[i].pFormats = (KdVideoFormatPtr) video_formats ;
+ a_this->adaptors[i].nFormats = num_video_formats ;
+ /* got a_this->adaptors[i].nPorts already
+ a_this->adaptors[i].nPorts =
+ ephyrHostXVAdaptorGetNbPorts (cur_host_adaptor) ;
+ */
+ a_this->adaptors[i].pPortPrivates =
+ xcalloc (a_this->adaptors[i].nPorts,
+ sizeof (DevUnion) + sizeof (EphyrPortPriv)) ;
+ port_priv_offset = a_this->adaptors[i].nPorts;
+ for (j=0; j < a_this->adaptors[i].nPorts; j++) {
+ EphyrPortPriv *port_privs_base =
+ (EphyrPortPriv*)&a_this->adaptors[i].pPortPrivates[port_priv_offset];
+ EphyrPortPriv *port_priv = &port_privs_base[j] ;
+ port_priv->port_number = base_port_id + j;
+ port_priv->current_adaptor = &a_this->adaptors[i] ;
+ port_priv->xv_priv = a_this ;
+ a_this->adaptors[i].pPortPrivates[j].ptr = port_priv;
+ }
+ if (!ephyrHostXVQueryPortAttributes (base_port_id,
+ &attributes,
+ &num_attributes)) {
+ EPHYR_LOG_ERROR ("failed to get port attribute "
+ "for adaptor %d\n", i) ;
+ continue ;
+ }
+ a_this->adaptors[i].pAttributes =
+ portAttributesDup (attributes, num_attributes);
+ a_this->adaptors[i].nAttributes = num_attributes ;
+ /*make sure atoms of attrs names are created in xephyr*/
+ for (j=0; j < a_this->adaptors[i].nAttributes; j++) {
+ if (a_this->adaptors[i].pAttributes[j].name)
+ MakeAtom (a_this->adaptors[i].pAttributes[j].name,
+ strlen (a_this->adaptors[i].pAttributes[j].name),
+ TRUE) ;
+ }
+ if (!ephyrHostXVQueryImageFormats (base_port_id,
+ &image_formats,
+ &num_formats)) {
+ EPHYR_LOG_ERROR ("failed to get image formats "
+ "for adaptor %d\n", i) ;
+ continue ;
+ }
+ a_this->adaptors[i].pImages = (KdImagePtr) image_formats ;
+ a_this->adaptors[i].nImages = num_formats ;
+ }
+ is_ok = TRUE ;
+
+out:
+ if (encodings) {
+ ephyrHostEncodingsDelete (encodings, num_encodings) ;
+ encodings = NULL ;
+ }
+ if (attributes) {
+ ephyrHostAttributesDelete (attributes) ;
+ attributes = NULL ;
+ }
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+static Bool
+ephyrXVPrivSetAdaptorsHooks (EphyrXVPriv *a_this)
+{
+ int i=0 ;
+ Bool has_it=FALSE ;
+ EphyrHostXVAdaptor *cur_host_adaptor=NULL ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_this, FALSE) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ for (i=0; i < a_this->num_adaptors; i++) {
+ a_this->adaptors[i].ReputImage = ephyrReputImage ;
+ a_this->adaptors[i].StopVideo = ephyrStopVideo ;
+ a_this->adaptors[i].SetPortAttribute = ephyrSetPortAttribute ;
+ a_this->adaptors[i].GetPortAttribute = ephyrGetPortAttribute ;
+ a_this->adaptors[i].QueryBestSize = ephyrQueryBestSize ;
+ a_this->adaptors[i].QueryImageAttributes = ephyrQueryImageAttributes ;
+
+ cur_host_adaptor =
+ ephyrHostXVAdaptorArrayAt (a_this->host_adaptors, i) ;
+ if (!cur_host_adaptor) {
+ EPHYR_LOG_ERROR ("failed to get host adaptor at index %d\n", i) ;
+ continue ;
+ }
+ has_it = FALSE ;
+ if (!ephyrHostXVAdaptorHasPutImage (cur_host_adaptor, &has_it)) {
+ EPHYR_LOG_ERROR ("error\n") ;
+ }
+ if (has_it) {
+ a_this->adaptors[i].PutImage = ephyrPutImage;
+ }
+
+ has_it = FALSE ;
+ if (!ephyrHostXVAdaptorHasPutVideo (cur_host_adaptor, &has_it)) {
+ EPHYR_LOG_ERROR ("error\n") ;
+ }
+ if (has_it) {
+ a_this->adaptors[i].PutVideo = ephyrPutVideo;
+ }
+
+ has_it = FALSE ;
+ if (!ephyrHostXVAdaptorHasGetVideo (cur_host_adaptor, &has_it)) {
+ EPHYR_LOG_ERROR ("error\n") ;
+ }
+ if (has_it) {
+ a_this->adaptors[i].GetVideo = ephyrGetVideo;
+ }
+
+ has_it = FALSE ;
+ if (!ephyrHostXVAdaptorHasPutStill (cur_host_adaptor, &has_it)) {
+ EPHYR_LOG_ERROR ("error\n") ;
+ }
+ if (has_it) {
+ a_this->adaptors[i].PutStill = ephyrPutStill;
+ }
+
+ has_it = FALSE ;
+ if (!ephyrHostXVAdaptorHasGetStill (cur_host_adaptor, &has_it)) {
+ EPHYR_LOG_ERROR ("error\n") ;
+ }
+ if (has_it) {
+ a_this->adaptors[i].GetStill = ephyrGetStill;
+ }
+ }
+ EPHYR_LOG ("leave\n") ;
+ return TRUE ;
+}
+
+static Bool
+ephyrXVPrivRegisterAdaptors (EphyrXVPriv *a_this,
+ ScreenPtr a_screen)
+{
+ KdScreenPriv(a_screen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ Bool is_ok = FALSE ;
+ KdVideoAdaptorPtr *adaptors=NULL, *registered_adaptors=NULL ;
+ int num_registered_adaptors=0, i=0, num_adaptors=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_this && a_screen, FALSE) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ if (!a_this->num_adaptors)
+ goto out ;
+ num_registered_adaptors =
+ KdXVListGenericAdaptors (screen, &registered_adaptors);
+
+ num_adaptors = num_registered_adaptors + a_this->num_adaptors ;
+ adaptors = xcalloc (num_adaptors, sizeof (KdVideoAdaptorPtr)) ;
+ if (!adaptors) {
+ EPHYR_LOG_ERROR ("failed to allocate adaptors tab\n") ;
+ goto out ;
+ }
+ memmove (adaptors, registered_adaptors, num_registered_adaptors) ;
+ for (i=0 ; i < a_this->num_adaptors; i++) {
+ *(adaptors + num_registered_adaptors + i) = &a_this->adaptors[i] ;
+ }
+ if (!KdXVScreenInit (a_screen, adaptors, num_adaptors)) {
+ EPHYR_LOG_ERROR ("failed to register adaptors\n");
+ goto out ;
+ }
+ EPHYR_LOG ("there are %d registered adaptors\n", num_adaptors) ;
+ is_ok = TRUE ;
+
+out:
+ if (registered_adaptors) {
+ xfree (registered_adaptors) ;
+ registered_adaptors = NULL ;
+ }
+ if (adaptors) {
+ xfree (adaptors) ;
+ adaptors=NULL ;
+ }
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+static Bool
+ephyrXVPrivIsAttrValueValid (KdAttributePtr a_attrs,
+ int a_attrs_len,
+ const char *a_attr_name,
+ int a_attr_value,
+ Bool *a_is_valid)
+{
+ int i=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_attrs && a_attr_name && a_is_valid,
+ FALSE) ;
+
+ for (i=0; i < a_attrs_len; i++) {
+ if (a_attrs[i].name && strcmp (a_attrs[i].name, a_attr_name))
+ continue ;
+ if (a_attrs[i].min_value > a_attr_value ||
+ a_attrs[i].max_value < a_attr_value) {
+ *a_is_valid = FALSE ;
+ EPHYR_LOG_ERROR ("attribute was not valid\n"
+ "value:%d. min:%d. max:%d\n",
+ a_attr_value,
+ a_attrs[i].min_value,
+ a_attrs[i].max_value) ;
+ } else {
+ *a_is_valid = TRUE ;
+ }
+ return TRUE ;
+ }
+ return FALSE ;
+}
+
+static Bool
+ephyrXVPrivGetImageBufSize (int a_port_id,
+ int a_image_id,
+ unsigned short a_width,
+ unsigned short a_height,
+ int *a_size)
+{
+ Bool is_ok=FALSE ;
+ unsigned short width=a_width, height=a_height ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_size, FALSE) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ if (!ephyrHostXVQueryImageAttributes (a_port_id, a_image_id,
+ &width, &height, a_size, NULL, NULL)) {
+ EPHYR_LOG_ERROR ("failed to get image attributes\n") ;
+ goto out ;
+ }
+ is_ok = TRUE ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+static Bool
+ephyrXVPrivSaveImageToPortPriv (EphyrPortPriv *a_port_priv,
+ const unsigned char *a_image_buf,
+ int a_image_len)
+{
+ Bool is_ok=FALSE ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ if (a_port_priv->image_buf_size < a_image_len) {
+ unsigned char *buf=NULL ;
+ buf = realloc (a_port_priv->image_buf, a_image_len) ;
+ if (!buf) {
+ EPHYR_LOG_ERROR ("failed to realloc image buffer\n") ;
+ goto out ;
+ }
+ a_port_priv->image_buf = buf ;
+ a_port_priv->image_buf_size = a_image_len;
+ }
+ memmove (a_port_priv->image_buf, a_image_buf, a_image_len) ;
+ is_ok = TRUE ;
+
+out:
+ return is_ok ;
+ EPHYR_LOG ("leave\n") ;
+}
+
+static void
+ephyrStopVideo (KdScreenInfo *a_info, pointer a_port_priv, Bool a_exit)
+{
+ EphyrPortPriv *port_priv = a_port_priv ;
+
+ EPHYR_RETURN_IF_FAIL (a_info && a_info->pScreen) ;
+ EPHYR_RETURN_IF_FAIL (port_priv) ;
+
+ EPHYR_LOG ("enter\n") ;
+ if (!ephyrHostXVStopVideo (a_info->pScreen->myNum,
+ port_priv->port_number)) {
+ EPHYR_LOG_ERROR ("XvStopVideo() failed\n") ;
+ }
+ EPHYR_LOG ("leave\n") ;
+}
+
+static int
+ephyrSetPortAttribute (KdScreenInfo *a_info,
+ Atom a_attr_name,
+ int a_attr_value,
+ pointer a_port_priv)
+{
+ int res=Success, host_atom=0 ;
+ EphyrPortPriv *port_priv = a_port_priv ;
+ Bool is_attr_valid=FALSE ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (port_priv, BadMatch) ;
+ EPHYR_RETURN_VAL_IF_FAIL (port_priv->current_adaptor, BadMatch) ;
+ EPHYR_RETURN_VAL_IF_FAIL (port_priv->current_adaptor->pAttributes,
+ BadMatch) ;
+ EPHYR_RETURN_VAL_IF_FAIL (port_priv->current_adaptor->nAttributes,
+ BadMatch) ;
+ EPHYR_RETURN_VAL_IF_FAIL (ValidAtom (a_attr_name), BadMatch) ;
+
+ EPHYR_LOG ("enter, portnum:%d, atomid:%d, attr_name:%s, attr_val:%d\n",
+ port_priv->port_number,
+ (int)a_attr_name,
+ NameForAtom (a_attr_name),
+ a_attr_value) ;
+
+ if (!ephyrLocalAtomToHost (a_attr_name, &host_atom)) {
+ EPHYR_LOG_ERROR ("failed to convert local atom to host atom\n") ;
+ res = BadMatch ;
+ goto out ;
+ }
+
+ if (!ephyrXVPrivIsAttrValueValid (port_priv->current_adaptor->pAttributes,
+ port_priv->current_adaptor->nAttributes,
+ NameForAtom (a_attr_name),
+ a_attr_value,
+ &is_attr_valid)) {
+ EPHYR_LOG_ERROR ("failed to validate attribute %s\n",
+ NameForAtom (a_attr_name)) ;
+ /*
+ res = BadMatch ;
+ goto out ;
+ */
+ }
+ if (!is_attr_valid) {
+ EPHYR_LOG_ERROR ("attribute %s is not valid\n",
+ NameForAtom (a_attr_name)) ;
+ /*
+ res = BadMatch ;
+ goto out ;
+ */
+ }
+
+ if (!ephyrHostXVSetPortAttribute (port_priv->port_number,
+ host_atom,
+ a_attr_value)) {
+ EPHYR_LOG_ERROR ("failed to set port attribute\n") ;
+ res = BadMatch ;
+ goto out ;
+ }
+
+ res = Success ;
+out:
+ EPHYR_LOG ("leave\n") ;
+ return res ;
+}
+
+static int
+ephyrGetPortAttribute (KdScreenInfo *a_screen_info,
+ Atom a_attr_name,
+ int *a_attr_value,
+ pointer a_port_priv)
+{
+ int res=Success, host_atom=0 ;
+ EphyrPortPriv *port_priv = a_port_priv ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (port_priv, BadMatch) ;
+ EPHYR_RETURN_VAL_IF_FAIL (ValidAtom (a_attr_name), BadMatch) ;
+
+ EPHYR_LOG ("enter, portnum:%d, atomid:%d, attr_name:%s\n",
+ port_priv->port_number,
+ (int)a_attr_name,
+ NameForAtom (a_attr_name)) ;
+
+ if (!ephyrLocalAtomToHost (a_attr_name, &host_atom)) {
+ EPHYR_LOG_ERROR ("failed to convert local atom to host atom\n") ;
+ res = BadMatch ;
+ goto out ;
+ }
+
+ if (!ephyrHostXVGetPortAttribute (port_priv->port_number,
+ host_atom,
+ a_attr_value)) {
+ EPHYR_LOG_ERROR ("failed to get port attribute\n") ;
+ res = BadMatch ;
+ goto out ;
+ }
+
+ res = Success ;
+out:
+ EPHYR_LOG ("leave\n") ;
+ return res ;
+}
+
+static void
+ephyrQueryBestSize (KdScreenInfo *a_info,
+ Bool a_motion,
+ short a_src_w,
+ short a_src_h,
+ short a_drw_w,
+ short a_drw_h,
+ unsigned int *a_prefered_w,
+ unsigned int *a_prefered_h,
+ pointer a_port_priv)
+{
+ int res=0 ;
+ EphyrPortPriv *port_priv = a_port_priv ;
+
+ EPHYR_RETURN_IF_FAIL (port_priv) ;
+
+ EPHYR_LOG ("enter\n") ;
+ res = ephyrHostXVQueryBestSize (port_priv->port_number,
+ a_motion,
+ a_src_w, a_src_h,
+ a_drw_w, a_drw_h,
+ a_prefered_w, a_prefered_h) ;
+ if (!res) {
+ EPHYR_LOG_ERROR ("Failed to query best size\n") ;
+ }
+ EPHYR_LOG ("leave\n") ;
+}
+
+static int
+ephyrPutImage (KdScreenInfo *a_info,
+ DrawablePtr a_drawable,
+ short a_src_x,
+ short a_src_y,
+ short a_drw_x,
+ short a_drw_y,
+ short a_src_w,
+ short a_src_h,
+ short a_drw_w,
+ short a_drw_h,
+ int a_id,
+ unsigned char *a_buf,
+ short a_width,
+ short a_height,
+ Bool a_sync,
+ RegionPtr a_clipping_region,
+ pointer a_port_priv)
+{
+ EphyrPortPriv *port_priv = a_port_priv ;
+ Bool is_ok=FALSE ;
+ int result=BadImplementation, image_size=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_info && a_info->pScreen, BadValue) ;
+ EPHYR_RETURN_VAL_IF_FAIL (a_drawable, BadValue) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ if (!ephyrHostXVPutImage (a_info->pScreen->myNum,
+ port_priv->port_number,
+ a_id,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h,
+ a_src_x, a_src_y, a_src_w, a_src_h,
+ a_width, a_height, a_buf,
+ (EphyrHostBox*)REGION_RECTS (a_clipping_region),
+ REGION_NUM_RECTS (a_clipping_region))) {
+ EPHYR_LOG_ERROR ("EphyrHostXVPutImage() failed\n") ;
+ goto out ;
+ }
+
+ /*
+ * Now save the image so that we can resend it to host it
+ * later, in ReputImage.
+ */
+ if (!ephyrXVPrivGetImageBufSize (port_priv->port_number,
+ a_id, a_width, a_height, &image_size)) {
+ EPHYR_LOG_ERROR ("failed to get image size\n") ;
+ /*this is a minor error so we won't get bail out abruptly*/
+ is_ok = FALSE ;
+ } else {
+ is_ok = TRUE ;
+ }
+ if (is_ok) {
+ if (!ephyrXVPrivSaveImageToPortPriv (port_priv, a_buf, image_size)) {
+ is_ok=FALSE ;
+ } else {
+ port_priv->image_id = a_id;
+ port_priv->drw_x = a_drw_x;
+ port_priv->drw_y = a_drw_y;
+ port_priv->drw_w = a_drw_w ;
+ port_priv->drw_h = a_drw_h ;
+ port_priv->src_x = a_src_x;
+ port_priv->src_y = a_src_y ;
+ port_priv->src_w = a_src_w ;
+ port_priv->src_h = a_src_h ;
+ port_priv->image_width = a_width ;
+ port_priv->image_height = a_height ;
+ }
+ }
+ if (!is_ok) {
+ if (port_priv->image_buf) {
+ free (port_priv->image_buf) ;
+ port_priv->image_buf = NULL ;
+ port_priv->image_buf_size = 0 ;
+ }
+ }
+
+ result = Success ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return result ;
+}
+
+static int
+ephyrReputImage (KdScreenInfo *a_info,
+ DrawablePtr a_drawable,
+ short a_drw_x,
+ short a_drw_y,
+ RegionPtr a_clipping_region,
+ pointer a_port_priv)
+{
+ EphyrPortPriv *port_priv = a_port_priv ;
+ int result=BadImplementation ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_info->pScreen, FALSE) ;
+ EPHYR_RETURN_VAL_IF_FAIL (a_drawable && port_priv, BadValue) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ if (!port_priv->image_buf_size || !port_priv->image_buf) {
+ EPHYR_LOG_ERROR ("has null image buf in cache\n") ;
+ goto out ;
+ }
+ if (!ephyrHostXVPutImage (a_info->pScreen->myNum,
+ port_priv->port_number,
+ port_priv->image_id,
+ a_drw_x, a_drw_y,
+ port_priv->drw_w, port_priv->drw_h,
+ port_priv->src_x, port_priv->src_y,
+ port_priv->src_w, port_priv->src_h,
+ port_priv->image_width, port_priv->image_height,
+ port_priv->image_buf,
+ (EphyrHostBox*)REGION_RECTS (a_clipping_region),
+ REGION_NUM_RECTS (a_clipping_region))) {
+ EPHYR_LOG_ERROR ("ephyrHostXVPutImage() failed\n") ;
+ goto out ;
+ }
+
+ result = Success ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return result ;
+}
+
+static int
+ephyrPutVideo (KdScreenInfo *a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clipping_region,
+ pointer a_port_priv)
+{
+ EphyrPortPriv *port_priv = a_port_priv ;
+ BoxRec clipped_area, dst_box ;
+ int result=BadImplementation ;
+ int drw_x=0, drw_y=0, drw_w=0, drw_h=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_info->pScreen, BadValue) ;
+ EPHYR_RETURN_VAL_IF_FAIL (a_drawable && port_priv, BadValue) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ dst_box.x1 = a_drw_x ;
+ dst_box.x2 = a_drw_x + a_drw_w;
+ dst_box.y1 = a_drw_y ;
+ dst_box.y2 = a_drw_y + a_drw_h;
+
+ if (!DoSimpleClip (&dst_box,
+ REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
+ &clipped_area)) {
+ EPHYR_LOG_ERROR ("failed to simple clip\n") ;
+ goto out ;
+ }
+
+ drw_x = clipped_area.x1 ;
+ drw_y = clipped_area.y1 ;
+ drw_w = clipped_area.x2 - clipped_area.x1 ;
+ drw_h = clipped_area.y2 - clipped_area.y1 ;
+
+ if (!ephyrHostXVPutVideo (a_info->pScreen->myNum,
+ port_priv->port_number,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
+ EPHYR_LOG_ERROR ("ephyrHostXVPutVideo() failed\n") ;
+ goto out ;
+ }
+ result = Success ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return result ;
+}
+
+static int
+ephyrGetVideo (KdScreenInfo *a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clipping_region,
+ pointer a_port_priv)
+{
+ EphyrPortPriv *port_priv = a_port_priv ;
+ BoxRec clipped_area, dst_box ;
+ int result=BadImplementation ;
+ int drw_x=0, drw_y=0, drw_w=0, drw_h=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_info && a_info->pScreen, BadValue) ;
+ EPHYR_RETURN_VAL_IF_FAIL (a_drawable && port_priv, BadValue) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ dst_box.x1 = a_drw_x ;
+ dst_box.x2 = a_drw_x + a_drw_w;
+ dst_box.y1 = a_drw_y ;
+ dst_box.y2 = a_drw_y + a_drw_h;
+
+ if (!DoSimpleClip (&dst_box,
+ REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
+ &clipped_area)) {
+ EPHYR_LOG_ERROR ("failed to simple clip\n") ;
+ goto out ;
+ }
+
+ drw_x = clipped_area.x1 ;
+ drw_y = clipped_area.y1 ;
+ drw_w = clipped_area.x2 - clipped_area.x1 ;
+ drw_h = clipped_area.y2 - clipped_area.y1 ;
+
+ if (!ephyrHostXVGetVideo (a_info->pScreen->myNum,
+ port_priv->port_number,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
+ EPHYR_LOG_ERROR ("ephyrHostXVGetVideo() failed\n") ;
+ goto out ;
+ }
+ result = Success ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return result ;
+}
+
+static int
+ephyrPutStill (KdScreenInfo *a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clipping_region,
+ pointer a_port_priv)
+{
+ EphyrPortPriv *port_priv = a_port_priv ;
+ BoxRec clipped_area, dst_box ;
+ int result=BadImplementation ;
+ int drw_x=0, drw_y=0, drw_w=0, drw_h=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_info && a_info->pScreen, BadValue) ;
+ EPHYR_RETURN_VAL_IF_FAIL (a_drawable && port_priv, BadValue) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ dst_box.x1 = a_drw_x ;
+ dst_box.x2 = a_drw_x + a_drw_w;
+ dst_box.y1 = a_drw_y ;
+ dst_box.y2 = a_drw_y + a_drw_h;
+
+ if (!DoSimpleClip (&dst_box,
+ REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
+ &clipped_area)) {
+ EPHYR_LOG_ERROR ("failed to simple clip\n") ;
+ goto out ;
+ }
+
+ drw_x = clipped_area.x1 ;
+ drw_y = clipped_area.y1 ;
+ drw_w = clipped_area.x2 - clipped_area.x1 ;
+ drw_h = clipped_area.y2 - clipped_area.y1 ;
+
+ if (!ephyrHostXVPutStill (a_info->pScreen->myNum,
+ port_priv->port_number,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
+ EPHYR_LOG_ERROR ("ephyrHostXVPutStill() failed\n") ;
+ goto out ;
+ }
+ result = Success ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return result ;
+}
+
+static int
+ephyrGetStill (KdScreenInfo *a_info,
+ DrawablePtr a_drawable,
+ short a_vid_x, short a_vid_y,
+ short a_drw_x, short a_drw_y,
+ short a_vid_w, short a_vid_h,
+ short a_drw_w, short a_drw_h,
+ RegionPtr a_clipping_region,
+ pointer a_port_priv)
+{
+ EphyrPortPriv *port_priv = a_port_priv ;
+ BoxRec clipped_area, dst_box ;
+ int result=BadImplementation ;
+ int drw_x=0, drw_y=0, drw_w=0, drw_h=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_info && a_info->pScreen, BadValue) ;
+ EPHYR_RETURN_VAL_IF_FAIL (a_drawable && port_priv, BadValue) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ dst_box.x1 = a_drw_x ;
+ dst_box.x2 = a_drw_x + a_drw_w;
+ dst_box.y1 = a_drw_y ;
+ dst_box.y2 = a_drw_y + a_drw_h;
+
+ if (!DoSimpleClip (&dst_box,
+ REGION_EXTENTS (pScreen->pScreen, a_clipping_region),
+ &clipped_area)) {
+ EPHYR_LOG_ERROR ("failed to simple clip\n") ;
+ goto out ;
+ }
+
+ drw_x = clipped_area.x1 ;
+ drw_y = clipped_area.y1 ;
+ drw_w = clipped_area.x2 - clipped_area.x1 ;
+ drw_h = clipped_area.y2 - clipped_area.y1 ;
+
+ if (!ephyrHostXVGetStill (a_info->pScreen->myNum,
+ port_priv->port_number,
+ a_vid_x, a_vid_y, a_vid_w, a_vid_h,
+ a_drw_x, a_drw_y, a_drw_w, a_drw_h)) {
+ EPHYR_LOG_ERROR ("ephyrHostXVGetStill() failed\n") ;
+ goto out ;
+ }
+ result = Success ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return result ;
+}
+
+static int
+ephyrQueryImageAttributes (KdScreenInfo *a_info,
+ int a_id,
+ unsigned short *a_w,
+ unsigned short *a_h,
+ int *a_pitches,
+ int *a_offsets)
+{
+ int image_size=0 ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_w && a_h, FALSE) ;
+
+ EPHYR_LOG ("enter: dim (%dx%d), pitches: %#x, offsets: %#x\n",
+ *a_w, *a_h, (unsigned int)a_pitches, (unsigned int)a_offsets) ;
+
+ if (!ephyrHostXVQueryImageAttributes (s_base_port_id,
+ a_id,
+ a_w, a_h,
+ &image_size,
+ a_pitches, a_offsets)) {
+ EPHYR_LOG_ERROR ("EphyrHostXVQueryImageAttributes() failed\n") ;
+ goto out ;
+ }
+ EPHYR_LOG ("image size: %d, dim (%dx%d)\n", image_size, *a_w, *a_h) ;
+
+out:
+ EPHYR_LOG ("leave\n") ;
+ return image_size ;
+}
diff --git a/xorg-server/hw/kdrive/ephyr/hostx.c b/xorg-server/hw/kdrive/ephyr/hostx.c
new file mode 100644
index 000000000..c870a291d
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/hostx.c
@@ -0,0 +1,1434 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@o-hand.com>
+ *
+ * Copyright © 2004 Nokia
+ *
+ * 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 Nokia not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Nokia makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+/*
+ * including some server headers (like kdrive-config.h)
+ * might define the macro _XSERVER64
+ * on 64 bits machines. That macro must _NOT_ be defined for Xlib
+ * client code, otherwise bad things happen.
+ * So let's undef that macro if necessary.
+ */
+#ifdef _XSERVER64
+#undef _XSERVER64
+#endif
+
+
+#include "hostx.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h> /* for memset */
+#include <time.h>
+
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <sys/time.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/keysym.h>
+#include <X11/extensions/XShm.h>
+#include <X11/extensions/shape.h>
+#ifdef XEPHYR_DRI
+#include <GL/glx.h>
+#endif /*XEPHYR_DRI*/
+#include "ephyrlog.h"
+
+#ifdef XEPHYR_DRI
+extern Bool XF86DRIQueryExtension (Display *dpy,
+ int *event_basep,
+ int *error_basep);
+#endif
+
+/*
+ * All xlib calls go here, which gets built as its own .a .
+ * Mixing kdrive and xlib headers causes all sorts of types
+ * to get clobbered.
+ */
+
+struct EphyrHostScreen
+{
+ Window win;
+ Window win_pre_existing; /* Set via -parent option like xnest */
+ XImage *ximg;
+ int win_width, win_height;
+ int server_depth;
+ unsigned char *fb_data; /* only used when host bpp != server bpp */
+ XShmSegmentInfo shminfo;
+
+ void *info; /* Pointer to the screen this is associated with */
+ int mynum; /* Screen number */
+};
+
+struct EphyrHostXVars
+{
+ char *server_dpy_name;
+ Display *dpy;
+ int screen;
+ Visual *visual;
+ Window winroot;
+ GC gc;
+ int depth;
+ Bool use_host_cursor;
+ Bool use_fullscreen;
+ Bool have_shm;
+
+ int n_screens;
+ struct EphyrHostScreen *screens;
+
+ long damage_debug_msec;
+
+ unsigned long cmap[256];
+};
+
+/* memset ( missing> ) instead of below */
+/*static EphyrHostXVars HostX = { "?", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};*/
+static EphyrHostXVars HostX;
+
+static int HostXWantDamageDebug = 0;
+
+extern EphyrKeySyms ephyrKeySyms;
+
+extern int monitorResolution;
+
+char *ephyrResName = NULL;
+int ephyrResNameFromCmd = 0;
+
+static void
+hostx_set_fullscreen_hint(void);
+
+/* X Error traps */
+
+static int trapped_error_code = 0;
+static int (*old_error_handler) (Display *d, XErrorEvent *e);
+
+#define host_depth_matches_server(_vars) (HostX.depth == (_vars)->server_depth)
+
+static struct EphyrHostScreen *
+host_screen_from_screen_info (EphyrScreenInfo *screen)
+{
+ int i;
+
+ for (i = 0 ; i < HostX.n_screens ; i++)
+ {
+ if ( HostX.screens[i].info == screen)
+ {
+ return &HostX.screens[i];
+ }
+ }
+ return NULL;
+}
+
+static int
+error_handler(Display *display,
+ XErrorEvent *error)
+{
+ trapped_error_code = error->error_code;
+ return 0;
+}
+
+static void
+hostx_errors_trap(void)
+{
+ trapped_error_code = 0;
+ old_error_handler = XSetErrorHandler(error_handler);
+}
+
+static int
+hostx_errors_untrap(void)
+{
+ XSetErrorHandler(old_error_handler);
+ return trapped_error_code;
+}
+
+int
+hostx_want_screen_size (EphyrScreenInfo screen, int *width, int *height )
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+
+ if (host_screen &&
+ (host_screen->win_pre_existing != None ||
+ HostX.use_fullscreen == True))
+ {
+ *width = host_screen->win_width;
+ *height = host_screen->win_height;
+ return 1;
+ }
+
+ return 0;
+}
+
+void
+hostx_add_screen (EphyrScreenInfo screen,
+ unsigned long win_id,
+ int screen_num)
+{
+ int index = HostX.n_screens;
+
+ HostX.n_screens += 1;
+ HostX.screens = realloc (HostX.screens,
+ HostX.n_screens * sizeof(struct EphyrHostScreen));
+ memset (&HostX.screens[index], 0, sizeof (struct EphyrHostScreen));
+
+ HostX.screens[index].info = screen;
+ HostX.screens[index].win_pre_existing = win_id;
+}
+
+
+void
+hostx_set_display_name (char *name)
+{
+ HostX.server_dpy_name = strdup (name);
+}
+
+void
+hostx_set_screen_number(EphyrScreenInfo screen, int number)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+ if (host_screen) {
+ host_screen->mynum = number;
+ hostx_set_win_title (host_screen->info, "") ;
+ }}
+
+void
+hostx_set_win_title (EphyrScreenInfo screen, char *extra_text)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+#define BUF_LEN 256
+ char buf[BUF_LEN+1];
+
+ if (!host_screen)
+ return;
+
+ memset (buf, 0, BUF_LEN+1) ;
+ snprintf (buf, BUF_LEN, "Xephyr on %s.%d %s",
+ HostX.server_dpy_name,
+ host_screen->mynum,
+ (extra_text != NULL) ? extra_text : "");
+
+ XStoreName (HostX.dpy, host_screen->win, buf);
+}
+
+int
+hostx_want_host_cursor (void)
+{
+ return HostX.use_host_cursor;
+}
+
+void
+hostx_use_host_cursor (void)
+{
+ HostX.use_host_cursor = True;
+}
+
+int
+hostx_want_preexisting_window (EphyrScreenInfo screen)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+
+ if (host_screen && host_screen->win_pre_existing)
+ {
+ return 1;
+ }
+ else
+ {
+ return 0;
+ }
+}
+
+void
+hostx_use_fullscreen (void)
+{
+ HostX.use_fullscreen = True;
+}
+
+int
+hostx_want_fullscreen (void)
+{
+ return HostX.use_fullscreen;
+}
+
+static void
+hostx_set_fullscreen_hint (void)
+{
+ Atom atom_WINDOW_STATE, atom_WINDOW_STATE_FULLSCREEN;
+ int index;
+
+ atom_WINDOW_STATE
+ = XInternAtom(HostX.dpy, "_NET_WM_STATE", False);
+ atom_WINDOW_STATE_FULLSCREEN
+ = XInternAtom(HostX.dpy, "_NET_WM_STATE_FULLSCREEN",False);
+
+ for (index = 0 ; index < HostX.n_screens ; index++)
+ {
+ XChangeProperty (HostX.dpy, HostX.screens[index].win,
+ atom_WINDOW_STATE, XA_ATOM, 32,
+ PropModeReplace,
+ (unsigned char *)&atom_WINDOW_STATE_FULLSCREEN, 1);
+ }
+}
+
+
+static void
+hostx_toggle_damage_debug (void)
+{
+ HostXWantDamageDebug ^= 1;
+}
+
+void
+hostx_handle_signal (int signum)
+{
+ hostx_toggle_damage_debug();
+ EPHYR_DBG ("Signal caught. Damage Debug:%i\n",
+ HostXWantDamageDebug);
+}
+
+void
+hostx_use_resname (char *name, int fromcmd)
+{
+ ephyrResName = name;
+ ephyrResNameFromCmd = fromcmd;
+}
+
+int
+hostx_init (void)
+{
+ XSetWindowAttributes attr;
+ Cursor empty_cursor;
+ Pixmap cursor_pxm;
+ XColor col;
+ int index;
+ char *tmpstr;
+ XClassHint *class_hint;
+
+ attr.event_mask =
+ ButtonPressMask
+ |ButtonReleaseMask
+ |PointerMotionMask
+ |KeyPressMask
+ |KeyReleaseMask
+ |ExposureMask;
+
+ EPHYR_DBG("mark");
+
+ if ((HostX.dpy = XOpenDisplay(getenv("DISPLAY"))) == NULL)
+ {
+ fprintf(stderr, "\nXephyr cannot open host display. Is DISPLAY set?\n");
+ exit(1);
+ }
+
+ HostX.screen = DefaultScreen(HostX.dpy);
+ HostX.winroot = RootWindow(HostX.dpy, HostX.screen);
+ HostX.gc = XCreateGC(HostX.dpy, HostX.winroot, 0, NULL);
+ HostX.depth = DefaultDepth(HostX.dpy, HostX.screen);
+ HostX.visual = DefaultVisual(HostX.dpy, HostX.screen);
+
+ class_hint = XAllocClassHint();
+
+ for (index = 0 ; index < HostX.n_screens ; index++)
+ {
+ struct EphyrHostScreen *host_screen = &HostX.screens[index];
+
+ host_screen->server_depth = HostX.depth;
+ if (host_screen->win_pre_existing != None)
+ {
+ Status result;
+ XWindowAttributes prewin_attr;
+
+ /* Get screen size from existing window */
+
+ hostx_errors_trap();
+
+ result = XGetWindowAttributes (HostX.dpy,
+ host_screen->win_pre_existing,
+ &prewin_attr);
+
+
+ if (hostx_errors_untrap() || !result)
+ {
+ fprintf (stderr, "\nXephyr -parent window' does not exist!\n");
+ exit (1);
+ }
+
+ host_screen->win_width = prewin_attr.width;
+ host_screen->win_height = prewin_attr.height;
+
+ host_screen->win = XCreateWindow (HostX.dpy,
+ host_screen->win_pre_existing,
+ 0,0,
+ host_screen->win_width,
+ host_screen->win_height,
+ 0,
+ CopyFromParent,
+ CopyFromParent,
+ CopyFromParent,
+ CWEventMask,
+ &attr);
+ }
+ else
+ {
+ host_screen->win = XCreateWindow (HostX.dpy,
+ HostX.winroot,
+ 0,0,100,100, /* will resize */
+ 0,
+ CopyFromParent,
+ CopyFromParent,
+ CopyFromParent,
+ CWEventMask,
+ &attr);
+
+ hostx_set_win_title (host_screen->info,
+ "(ctrl+shift grabs mouse and keyboard)");
+
+ if (HostX.use_fullscreen)
+ {
+ host_screen->win_width = DisplayWidth(HostX.dpy, HostX.screen);
+ host_screen->win_height = DisplayHeight(HostX.dpy, HostX.screen);
+
+ hostx_set_fullscreen_hint();
+ }
+
+ if (class_hint)
+ {
+ tmpstr = getenv("RESOURCE_NAME");
+ if (tmpstr && (!ephyrResNameFromCmd))
+ ephyrResName = tmpstr;
+ class_hint->res_name = ephyrResName;
+ class_hint->res_class = "Xephyr";
+ XSetClassHint(hostx_get_display(), host_screen->win, class_hint);
+
+ }
+
+ }
+ }
+
+ if (class_hint)
+ XFree(class_hint);
+
+ XParseColor (HostX.dpy, DefaultColormap (HostX.dpy,HostX.screen),
+ "red", &col);
+ XAllocColor (HostX.dpy, DefaultColormap (HostX.dpy, HostX.screen),
+ &col);
+ XSetForeground (HostX.dpy, HostX.gc, col.pixel);
+
+ if (!hostx_want_host_cursor ())
+ {
+ /* Ditch the cursor, we provide our 'own' */
+ cursor_pxm = XCreatePixmap (HostX.dpy, HostX.winroot, 1, 1, 1);
+ memset (&col, 0, sizeof (col));
+ empty_cursor = XCreatePixmapCursor (HostX.dpy,
+ cursor_pxm, cursor_pxm,
+ &col, &col, 1, 1);
+ for ( index = 0 ; index < HostX.n_screens ; index++ )
+ {
+ XDefineCursor (HostX.dpy,
+ HostX.screens[index].win,
+ empty_cursor);
+ }
+ XFreePixmap (HostX.dpy, cursor_pxm);
+ }
+
+ for (index = 0 ; index < HostX.n_screens ; index++)
+ {
+ HostX.screens[index].ximg = NULL;
+ }
+ /* Try to get share memory ximages for a little bit more speed */
+
+ if (!XShmQueryExtension(HostX.dpy) || getenv("XEPHYR_NO_SHM"))
+ {
+ fprintf(stderr, "\nXephyr unable to use SHM XImages\n");
+ HostX.have_shm = False;
+ }
+ else
+ {
+ /* Really really check we have shm - better way ?*/
+ XShmSegmentInfo shminfo;
+
+ HostX.have_shm = True;
+
+ shminfo.shmid=shmget(IPC_PRIVATE, 1, IPC_CREAT|0777);
+ shminfo.shmaddr=shmat(shminfo.shmid,0,0);
+ shminfo.readOnly=True;
+
+ hostx_errors_trap();
+
+ XShmAttach(HostX.dpy, &shminfo);
+ XSync(HostX.dpy, False);
+
+ if (hostx_errors_untrap())
+ {
+ fprintf(stderr, "\nXephyr unable to use SHM XImages\n");
+ HostX.have_shm = False;
+ }
+
+ shmdt(shminfo.shmaddr);
+ shmctl(shminfo.shmid, IPC_RMID, 0);
+}
+
+ XFlush(HostX.dpy);
+
+ /* Setup the pause time between paints when debugging updates */
+
+ HostX.damage_debug_msec = 20000; /* 1/50 th of a second */
+
+ if (getenv ("XEPHYR_PAUSE"))
+ {
+ HostX.damage_debug_msec = strtol (getenv ("XEPHYR_PAUSE"), NULL, 0);
+ EPHYR_DBG ("pause is %li\n", HostX.damage_debug_msec);
+ }
+
+ return 1;
+}
+
+int
+hostx_get_depth (void)
+{
+ return HostX.depth;
+}
+
+int
+hostx_get_server_depth (EphyrScreenInfo screen)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+
+ return (host_screen ? host_screen->server_depth : 0);
+}
+
+void
+hostx_set_server_depth (EphyrScreenInfo screen, int depth)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+
+ if (host_screen)
+ host_screen->server_depth = depth;
+}
+
+int
+hostx_get_bpp (EphyrScreenInfo screen)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+
+ if (!host_screen)
+ return 0;
+
+ if (host_depth_matches_server (host_screen))
+ return HostX.visual->bits_per_rgb;
+ else
+ return host_screen->server_depth; /*XXX correct ?*/
+}
+
+void
+hostx_get_visual_masks (EphyrScreenInfo screen,
+ CARD32 *rmsk,
+ CARD32 *gmsk,
+ CARD32 *bmsk)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+
+ if (!host_screen)
+ return;
+
+ if (host_depth_matches_server(host_screen))
+ {
+ *rmsk = HostX.visual->red_mask;
+ *gmsk = HostX.visual->green_mask;
+ *bmsk = HostX.visual->blue_mask;
+ }
+ else if (host_screen->server_depth == 16)
+ {
+ /* Assume 16bpp 565 */
+ *rmsk = 0xf800;
+ *gmsk = 0x07e0;
+ *bmsk = 0x001f;
+ }
+ else
+ {
+ *rmsk = 0x0;
+ *gmsk = 0x0;
+ *bmsk = 0x0;
+ }
+}
+
+void
+hostx_set_cmap_entry(unsigned char idx,
+ unsigned char r,
+ unsigned char g,
+ unsigned char b)
+{
+ /* XXX Will likely break for 8 on 16, not sure if this is correct */
+ HostX.cmap[idx] = (r << 16) | (g << 8) | (b);
+}
+
+/**
+ * hostx_screen_init creates the XImage that will contain the front buffer of
+ * the ephyr screen, and possibly offscreen memory.
+ *
+ * @param width width of the screen
+ * @param height height of the screen
+ * @param buffer_height height of the rectangle to be allocated.
+ *
+ * hostx_screen_init() creates an XImage, using MIT-SHM if it's available.
+ * buffer_height can be used to create a larger offscreen buffer, which is used
+ * by fakexa for storing offscreen pixmap data.
+ */
+void*
+hostx_screen_init (EphyrScreenInfo screen,
+ int width, int height,
+ int buffer_height)
+{
+ int bitmap_pad;
+ Bool shm_success = False;
+ XSizeHints *size_hints;
+
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+ if (!host_screen)
+ {
+ fprintf (stderr, "%s: Error in accessing hostx data\n", __func__ );
+ exit(1);
+ }
+
+ EPHYR_DBG ("host_screen=%p wxh=%dx%d, buffer_height=%d",
+ host_screen, width, height, buffer_height);
+
+ if (host_screen->ximg != NULL)
+ {
+ /* Free up the image data if previously used
+ * i.ie called by server reset
+ */
+
+ if (HostX.have_shm)
+ {
+ XShmDetach(HostX.dpy, &host_screen->shminfo);
+ XDestroyImage (host_screen->ximg);
+ shmdt(host_screen->shminfo.shmaddr);
+ shmctl(host_screen->shminfo.shmid, IPC_RMID, 0);
+ }
+ else
+ {
+ if (host_screen->ximg->data)
+ {
+ free(host_screen->ximg->data);
+ host_screen->ximg->data = NULL;
+ }
+
+ XDestroyImage(host_screen->ximg);
+ }
+ }
+
+ if (HostX.have_shm)
+ {
+ host_screen->ximg = XShmCreateImage (HostX.dpy, HostX.visual, HostX.depth,
+ ZPixmap, NULL, &host_screen->shminfo,
+ width, buffer_height );
+
+ host_screen->shminfo.shmid =
+ shmget(IPC_PRIVATE,
+ host_screen->ximg->bytes_per_line * buffer_height,
+ IPC_CREAT|0777);
+ host_screen->ximg->data = shmat(host_screen->shminfo.shmid, 0, 0);
+ host_screen->shminfo.shmaddr = host_screen->ximg->data;
+
+ if (host_screen->ximg->data == (char *)-1)
+ {
+ EPHYR_DBG("Can't attach SHM Segment, falling back to plain XImages");
+ HostX.have_shm = False;
+ XDestroyImage(host_screen->ximg);
+ shmctl(host_screen->shminfo.shmid, IPC_RMID, 0);
+ }
+ else
+ {
+ EPHYR_DBG("SHM segment attached %p", host_screen->shminfo.shmaddr);
+ host_screen->shminfo.readOnly = False;
+ XShmAttach(HostX.dpy, &host_screen->shminfo);
+ shm_success = True;
+ }
+ }
+
+ if (!shm_success)
+ {
+ bitmap_pad = ( HostX.depth > 16 )? 32 : (( HostX.depth > 8 )? 16 : 8 );
+
+ EPHYR_DBG("Creating image %dx%d for screen host_screen=%p\n",
+ width, buffer_height, host_screen );
+ host_screen->ximg = XCreateImage (HostX.dpy,
+ HostX.visual,
+ HostX.depth,
+ ZPixmap, 0, 0,
+ width,
+ buffer_height,
+ bitmap_pad,
+ 0);
+
+ host_screen->ximg->data =
+ malloc (host_screen->ximg->bytes_per_line * buffer_height);
+ }
+
+ XResizeWindow (HostX.dpy, host_screen->win, width, height);
+
+ /* Ask the WM to keep our size static */
+ size_hints = XAllocSizeHints();
+ size_hints->max_width = size_hints->min_width = width;
+ size_hints->max_height = size_hints->min_height = height;
+ size_hints->flags = PMinSize|PMaxSize;
+ XSetWMNormalHints(HostX.dpy, host_screen->win, size_hints);
+ XFree(size_hints);
+
+ XMapWindow(HostX.dpy, host_screen->win);
+
+ XSync(HostX.dpy, False);
+
+ host_screen->win_width = width;
+ host_screen->win_height = height;
+
+ if (host_depth_matches_server(host_screen))
+ {
+ EPHYR_DBG("Host matches server");
+ return host_screen->ximg->data;
+ }
+ else
+ {
+ EPHYR_DBG("server bpp %i", host_screen->server_depth>>3);
+ host_screen->fb_data = malloc(width*buffer_height*(host_screen->server_depth>>3));
+ return host_screen->fb_data;
+ }
+}
+
+static void hostx_paint_debug_rect (struct EphyrHostScreen *host_screen,
+ int x, int y,
+ int width, int height);
+
+void
+hostx_paint_rect (EphyrScreenInfo screen,
+ int sx, int sy,
+ int dx, int dy,
+ int width, int height)
+{
+ struct EphyrHostScreen *host_screen = host_screen_from_screen_info (screen);
+
+ EPHYR_DBG ("painting in screen %d\n", host_screen->mynum) ;
+
+ /*
+ * Copy the image data updated by the shadow layer
+ * on to the window
+ */
+
+ if (HostXWantDamageDebug)
+ {
+ hostx_paint_debug_rect(host_screen, dx, dy, width, height);
+ }
+
+ /*
+ * If the depth of the ephyr server is less than that of the host,
+ * the kdrive fb does not point to the ximage data but to a buffer
+ * ( fb_data ), we shift the various bits from this onto the XImage
+ * so they match the host.
+ *
+ * Note, This code is pretty new ( and simple ) so may break on
+ * endian issues, 32 bpp host etc.
+ * Not sure if 8bpp case is right either.
+ * ... and it will be slower than the matching depth case.
+ */
+
+ if (!host_depth_matches_server(host_screen))
+ {
+ int x,y,idx, bytes_per_pixel = (host_screen->server_depth>>3);
+ unsigned char r,g,b;
+ unsigned long host_pixel;
+
+ EPHYR_DBG("Unmatched host depth host_screen=%p\n", host_screen);
+ for (y=sy; y<sy+height; y++)
+ for (x=sx; x<sx+width; x++)
+ {
+ idx = (host_screen->win_width*y*bytes_per_pixel)+(x*bytes_per_pixel);
+
+ switch (host_screen->server_depth)
+ {
+ case 16:
+ {
+ unsigned short pixel = *(unsigned short*)(host_screen->fb_data+idx);
+
+ r = ((pixel & 0xf800) >> 8);
+ g = ((pixel & 0x07e0) >> 3);
+ b = ((pixel & 0x001f) << 3);
+
+ host_pixel = (r << 16) | (g << 8) | (b);
+
+ XPutPixel(host_screen->ximg, x, y, host_pixel);
+ break;
+ }
+ case 8:
+ {
+ unsigned char pixel = *(unsigned char*)(host_screen->fb_data+idx);
+ XPutPixel(host_screen->ximg, x, y, HostX.cmap[pixel]);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+ if (HostX.have_shm)
+ {
+ XShmPutImage (HostX.dpy, host_screen->win,
+ HostX.gc, host_screen->ximg,
+ sx, sy, dx, dy, width, height, False);
+ }
+ else
+ {
+ XPutImage (HostX.dpy, host_screen->win, HostX.gc, host_screen->ximg,
+ sx, sy, dx, dy, width, height);
+ }
+
+ XSync (HostX.dpy, False);
+}
+
+static void
+hostx_paint_debug_rect (struct EphyrHostScreen *host_screen,
+ int x, int y,
+ int width, int height)
+{
+ struct timespec tspec;
+
+ tspec.tv_sec = HostX.damage_debug_msec / (1000000);
+ tspec.tv_nsec = (HostX.damage_debug_msec % 1000000) * 1000;
+
+ EPHYR_DBG("msec: %li tv_sec %li, tv_msec %li",
+ HostX.damage_debug_msec, tspec.tv_sec, tspec.tv_nsec);
+
+ /* fprintf(stderr, "Xephyr updating: %i+%i %ix%i\n", x, y, width, height); */
+
+ XFillRectangle (HostX.dpy, host_screen->win, HostX.gc, x, y, width,height);
+ XSync (HostX.dpy, False);
+
+ /* nanosleep seems to work better than usleep for me... */
+ nanosleep(&tspec, NULL);
+}
+
+void
+hostx_load_keymap(void)
+{
+ XID *keymap;
+ int host_width, min_keycode, max_keycode, width;
+ int i,j;
+
+ XDisplayKeycodes (HostX.dpy, &min_keycode, &max_keycode);
+
+ EPHYR_DBG ("min: %d, max: %d", min_keycode, max_keycode);
+
+ keymap = XGetKeyboardMapping (HostX.dpy,
+ min_keycode,
+ max_keycode - min_keycode + 1,
+ &host_width);
+
+ /* Try and copy the hosts keymap into our keymap to avoid loads
+ * of messing around.
+ *
+ * kdrive cannot can have more than 4 keysyms per keycode
+ * so we only copy at most the first 4 ( xorg has 6 per keycode, XVNC 2 )
+ */
+ width = (host_width > 4) ? 4 : host_width;
+
+ ephyrKeySyms.map = (CARD32 *)calloc(sizeof(CARD32),
+ (max_keycode - min_keycode + 1) *
+ width);
+ if (!ephyrKeySyms.map)
+ return;
+
+ for (i=0; i<(max_keycode - min_keycode+1); i++)
+ for (j=0; j<width; j++)
+ ephyrKeySyms.map[(i*width)+j] = (CARD32) keymap[(i*host_width) + j];
+
+ EPHYR_DBG("keymap width, host:%d kdrive:%d", host_width, width);
+
+ ephyrKeySyms.minKeyCode = min_keycode;
+ ephyrKeySyms.maxKeyCode = max_keycode;
+ ephyrKeySyms.mapWidth = width;
+
+ XFree(keymap);
+}
+
+static struct EphyrHostScreen *
+host_screen_from_window (Window w)
+{
+ int index = 0;
+ struct EphyrHostScreen *result = NULL;
+#if 0
+ unsigned int num_children = 0;
+ Window root = None, parent = None, *children = NULL;
+#endif
+
+ for (index = 0 ; index < HostX.n_screens ; index++)
+ {
+ if (HostX.screens[index].win == w)
+ {
+ result = &HostX.screens[index];
+ goto out;
+ }
+ }
+#if 0
+ XQueryTree (hostx_get_display (), w, &root, &parent,
+ &children, &num_children);
+ if (parent == root || parent == None)
+ goto out;
+ result = host_screen_from_window (parent);
+#endif
+
+out:
+#if 0
+ if (children)
+ {
+ XFree (children);
+ children = NULL;
+ }
+#endif
+ return result;
+}
+
+int
+hostx_get_event(EphyrHostXEvent *ev)
+{
+ XEvent xev;
+ static int grabbed_screen = -1;
+
+ if (XPending(HostX.dpy))
+ {
+ XNextEvent(HostX.dpy, &xev);
+
+ switch (xev.type)
+ {
+ case Expose:
+ /* Not so great event compression, but works ok */
+ while (XCheckTypedWindowEvent(HostX.dpy, xev.xexpose.window,
+ Expose, &xev));
+ {
+ struct EphyrHostScreen *host_screen =
+ host_screen_from_window (xev.xexpose.window);
+ if (host_screen)
+ {
+ hostx_paint_rect (host_screen->info, 0, 0, 0, 0,
+ host_screen->win_width,
+ host_screen->win_height);
+ }
+ else
+ {
+ EPHYR_LOG_ERROR ("failed to get host screen\n");
+ ev->type = EPHYR_EV_EXPOSE;
+ ev->data.expose.window = xev.xexpose.window;
+ return 1;
+ }
+ }
+ return 0;
+
+ case MotionNotify:
+ {
+ struct EphyrHostScreen *host_screen =
+ host_screen_from_window (xev.xmotion.window);
+
+ ev->type = EPHYR_EV_MOUSE_MOTION;
+ ev->data.mouse_motion.x = xev.xmotion.x;
+ ev->data.mouse_motion.y = xev.xmotion.y;
+ ev->data.mouse_motion.window = xev.xmotion.window;
+ ev->data.mouse_motion.screen = (host_screen ? host_screen->mynum : -1);
+ }
+ return 1;
+
+ case ButtonPress:
+ ev->type = EPHYR_EV_MOUSE_PRESS;
+ ev->key_state = xev.xkey.state;
+ /*
+ * This is a bit hacky. will break for button 5 ( defined as 0x10 )
+ * Check KD_BUTTON defines in kdrive.h
+ */
+ ev->data.mouse_down.button_num = 1<<(xev.xbutton.button-1);
+ return 1;
+
+ case ButtonRelease:
+ ev->type = EPHYR_EV_MOUSE_RELEASE;
+ ev->key_state = xev.xkey.state;
+ ev->data.mouse_up.button_num = 1<<(xev.xbutton.button-1);
+ return 1;
+
+ case KeyPress:
+ {
+ ev->type = EPHYR_EV_KEY_PRESS;
+ ev->key_state = xev.xkey.state;
+ ev->data.key_down.scancode = xev.xkey.keycode;
+ return 1;
+ }
+ case KeyRelease:
+
+ if ((XKeycodeToKeysym(HostX.dpy,xev.xkey.keycode,0) == XK_Shift_L
+ || XKeycodeToKeysym(HostX.dpy,xev.xkey.keycode,0) == XK_Shift_R)
+ && (xev.xkey.state & ControlMask))
+ {
+ struct EphyrHostScreen *host_screen =
+ host_screen_from_window (xev.xexpose.window);
+
+ if (grabbed_screen != -1)
+ {
+ XUngrabKeyboard (HostX.dpy, CurrentTime);
+ XUngrabPointer (HostX.dpy, CurrentTime);
+ grabbed_screen = -1;
+ hostx_set_win_title (host_screen->info,
+ "(ctrl+shift grabs mouse and keyboard)");
+ }
+ else
+ {
+ /* Attempt grab */
+ if (XGrabKeyboard (HostX.dpy, host_screen->win, True,
+ GrabModeAsync,
+ GrabModeAsync,
+ CurrentTime) == 0)
+ {
+ if (XGrabPointer (HostX.dpy, host_screen->win, True,
+ NoEventMask,
+ GrabModeAsync,
+ GrabModeAsync,
+ host_screen->win, None, CurrentTime) == 0)
+ {
+ grabbed_screen = host_screen->mynum;
+ hostx_set_win_title
+ (host_screen->info,
+ "(ctrl+shift releases mouse and keyboard)");
+ }
+ else /* Failed pointer grabm ungrab keyboard */
+ XUngrabKeyboard (HostX.dpy, CurrentTime);
+ }
+ }
+ }
+
+ /* Still send the release event even if above has happened
+ * server will get confused with just an up event.
+ * Maybe it would be better to just block shift+ctrls getting to
+ * kdrive all togeather.
+ */
+ ev->type = EPHYR_EV_KEY_RELEASE;
+ ev->key_state = xev.xkey.state;
+ ev->data.key_up.scancode = xev.xkey.keycode;
+ return 1;
+
+ default:
+ break;
+
+ }
+ }
+ return 0;
+}
+
+void*
+hostx_get_display(void)
+{
+ return HostX.dpy ;
+}
+
+int
+hostx_get_window (int a_screen_number)
+{
+ if (a_screen_number < 0 || a_screen_number >= HostX.n_screens) {
+ EPHYR_LOG_ERROR ("bad screen number:%d\n", a_screen_number) ;
+ return 0;
+ }
+ return HostX.screens[a_screen_number].win ;
+}
+
+int
+hostx_get_window_attributes (int a_window, EphyrHostWindowAttributes *a_attrs)
+{
+ XWindowAttributes attrs ;
+
+ memset (&attrs, 0, sizeof (attrs)) ;
+
+ if (!XGetWindowAttributes (hostx_get_display (),
+ a_window,
+ &attrs)) {
+ return FALSE ;
+ }
+ a_attrs->x = attrs.x ;
+ a_attrs->y = attrs.y ;
+ a_attrs->width = attrs.width ;
+ a_attrs->height = attrs.height ;
+ if (attrs.visual)
+ a_attrs->visualid = attrs.visual->visualid ;
+ return TRUE ;
+}
+
+int
+hostx_get_extension_info (const char *a_ext_name,
+ int *a_major_opcode,
+ int *a_first_event,
+ int *a_first_error)
+{
+ if (!a_ext_name || !a_major_opcode || !a_first_event || !a_first_error)
+ return 0 ;
+ if (!XQueryExtension (HostX.dpy,
+ a_ext_name,
+ a_major_opcode,
+ a_first_event,
+ a_first_error))
+ {
+ return 0 ;
+ }
+ return 1 ;
+}
+
+int
+hostx_get_visuals_info (EphyrHostVisualInfo **a_visuals,
+ int *a_num_entries)
+{
+ Display *dpy=hostx_get_display () ;
+ Bool is_ok=False ;
+ XVisualInfo templ, *visuals=NULL;
+ EphyrHostVisualInfo *host_visuals=NULL ;
+ int nb_items=0, i=0;
+
+ EPHYR_RETURN_VAL_IF_FAIL (a_visuals && a_num_entries && dpy,
+ False) ;
+ EPHYR_LOG ("enter\n") ;
+ memset (&templ, 0, sizeof (templ)) ;
+ visuals = XGetVisualInfo (dpy, VisualNoMask, &templ, &nb_items) ;
+ if (!visuals) {
+ EPHYR_LOG_ERROR ("host does not advertise any visual\n") ;
+ goto out ;
+ }
+ EPHYR_LOG ("host advertises %d visuals\n", nb_items) ;
+ host_visuals = calloc (nb_items, sizeof (EphyrHostVisualInfo)) ;
+ for (i=0; i<nb_items; i++) {
+ host_visuals[i].visualid = visuals[i].visualid ;
+ host_visuals[i].screen = visuals[i].screen ;
+ host_visuals[i].depth = visuals[i].depth ;
+ host_visuals[i].class = visuals[i].class ;
+ host_visuals[i].red_mask = visuals[i].red_mask ;
+ host_visuals[i].green_mask = visuals[i].green_mask ;
+ host_visuals[i].blue_mask = visuals[i].blue_mask ;
+ host_visuals[i].colormap_size = visuals[i].colormap_size ;
+ host_visuals[i].bits_per_rgb = visuals[i].bits_per_rgb ;
+ }
+ *a_visuals = host_visuals ;
+ *a_num_entries = nb_items;
+ host_visuals=NULL;
+
+ is_ok = TRUE;
+out:
+ if (visuals) {
+ XFree (visuals) ;
+ visuals = NULL;
+ }
+ if (host_visuals) {
+ free (host_visuals) ;
+ host_visuals = NULL;
+ }
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+
+}
+
+int
+hostx_create_window (int a_screen_number,
+ EphyrBox *a_geometry,
+ int a_visual_id,
+ int *a_host_peer /*out parameter*/)
+{
+ Bool is_ok=FALSE ;
+ Display *dpy=hostx_get_display () ;
+ XVisualInfo *visual_info=NULL, visual_info_templ;
+ int visual_mask=VisualIDMask ;
+ Window win=None ;
+ int nb_visuals=0, winmask=0;
+ XSetWindowAttributes attrs;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy && a_geometry, FALSE) ;
+
+ EPHYR_LOG ("enter\n") ;
+
+ /*get visual*/
+ memset (&visual_info, 0, sizeof (visual_info)) ;
+ visual_info_templ.visualid = a_visual_id ;
+ visual_info = XGetVisualInfo (dpy, visual_mask,
+ &visual_info_templ,
+ &nb_visuals) ;
+ if (!visual_info) {
+ EPHYR_LOG_ERROR ("argh, could not find a remote visual with id:%d\n",
+ a_visual_id) ;
+ goto out ;
+ }
+ memset (&attrs, 0, sizeof (attrs)) ;
+ attrs.colormap = XCreateColormap (dpy,
+ RootWindow (dpy,
+ visual_info->screen),
+ visual_info->visual,
+ AllocNone) ;
+ attrs.event_mask = ButtonPressMask
+ |ButtonReleaseMask
+ |PointerMotionMask
+ |KeyPressMask
+ |KeyReleaseMask
+ |ExposureMask;
+ winmask = CWColormap|CWEventMask;
+
+ win = XCreateWindow (dpy, hostx_get_window (a_screen_number),
+ a_geometry->x, a_geometry->y,
+ a_geometry->width, a_geometry->height, 0,
+ visual_info->depth, CopyFromParent,
+ visual_info->visual, winmask, &attrs) ;
+ if (win == None) {
+ EPHYR_LOG_ERROR ("failed to create peer window\n") ;
+ goto out ;
+ }
+ XFlush (dpy) ;
+ XMapWindow (dpy, win) ;
+ *a_host_peer = win ;
+ is_ok = TRUE ;
+out:
+ EPHYR_LOG ("leave\n") ;
+ return is_ok ;
+}
+
+int
+hostx_destroy_window (int a_win)
+{
+ Display *dpy=hostx_get_display () ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy, FALSE) ;
+ XDestroyWindow (dpy, a_win) ;
+ XFlush (dpy) ;
+ return TRUE ;
+}
+
+int
+hostx_set_window_geometry (int a_win, EphyrBox *a_geo)
+{
+ Display *dpy=hostx_get_display ();
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy && a_geo, FALSE) ;
+
+ EPHYR_LOG ("enter. x,y,w,h:(%d,%d,%d,%d)\n",
+ a_geo->x, a_geo->y,
+ a_geo->width, a_geo->height) ;
+
+ XMoveWindow (dpy, a_win, a_geo->x, a_geo->y) ;
+ XResizeWindow (dpy, a_win, a_geo->width, a_geo->height) ;
+ EPHYR_LOG ("leave\n") ;
+ return TRUE;
+}
+
+int
+hostx_set_window_bounding_rectangles (int a_window,
+ EphyrRect *a_rects,
+ int a_num_rects)
+{
+ Bool is_ok=FALSE;
+ Display *dpy=hostx_get_display () ;
+ int i=0 ;
+ XRectangle *rects=NULL ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy && a_rects, FALSE) ;
+
+ EPHYR_LOG ("enter. num rects:%d\n", a_num_rects) ;
+
+ rects = calloc (a_num_rects, sizeof (XRectangle)) ;
+ for (i=0; i<a_num_rects; i++) {
+ rects[i].x = a_rects[i].x1 ;
+ rects[i].y = a_rects[i].y1 ;
+ rects[i].width = abs (a_rects[i].x2 - a_rects[i].x1);
+ rects[i].height = abs (a_rects[i].y2 - a_rects[i].y1) ;
+ EPHYR_LOG ("borders clipped to rect[x:%d,y:%d,w:%d,h:%d]\n",
+ rects[i].x, rects[i].y,
+ rects[i].width, rects[i].height) ;
+ }
+ /*this aways returns 1*/
+ XShapeCombineRectangles (dpy, a_window, ShapeBounding, 0, 0,
+ rects, a_num_rects, ShapeSet, YXBanded) ;
+ is_ok = TRUE ;
+
+ if (rects) {
+ free (rects) ;
+ rects = NULL ;
+ }
+ EPHYR_LOG ("leave\n") ;
+ return is_ok;
+}
+
+int
+hostx_set_window_clipping_rectangles (int a_window,
+ EphyrRect *a_rects,
+ int a_num_rects)
+{
+ Bool is_ok=FALSE;
+ Display *dpy=hostx_get_display () ;
+ int i=0 ;
+ XRectangle *rects=NULL ;
+
+ EPHYR_RETURN_VAL_IF_FAIL (dpy && a_rects, FALSE) ;
+
+ EPHYR_LOG ("enter. num rects:%d\n", a_num_rects) ;
+
+ rects = calloc (a_num_rects, sizeof (XRectangle)) ;
+ for (i=0; i<a_num_rects; i++) {
+ rects[i].x = a_rects[i].x1 ;
+ rects[i].y = a_rects[i].y1 ;
+ rects[i].width = abs (a_rects[i].x2 - a_rects[i].x1);
+ rects[i].height = abs (a_rects[i].y2 - a_rects[i].y1) ;
+ EPHYR_LOG ("clipped to rect[x:%d,y:%d,w:%d,h:%d]\n",
+ rects[i].x, rects[i].y,
+ rects[i].width, rects[i].height) ;
+ }
+ /*this aways returns 1*/
+ XShapeCombineRectangles (dpy, a_window, ShapeClip, 0, 0,
+ rects, a_num_rects, ShapeSet, YXBanded) ;
+ is_ok = TRUE ;
+
+ if (rects) {
+ free (rects) ;
+ rects = NULL ;
+ }
+ EPHYR_LOG ("leave\n") ;
+ return is_ok;
+}
+
+int
+hostx_has_xshape (void)
+{
+ int event_base=0, error_base=0 ;
+ Display *dpy=hostx_get_display () ;
+ if (!XShapeQueryExtension (dpy,
+ &event_base,
+ &error_base)) {
+ return FALSE ;
+ }
+ return TRUE;
+}
+
+#ifdef XEPHYR_DRI
+typedef struct {
+ int is_valid ;
+ int local_id ;
+ int remote_id ;
+} ResourcePair ;
+
+#define RESOURCE_PEERS_SIZE 1024*10
+static ResourcePair resource_peers[RESOURCE_PEERS_SIZE] ;
+
+
+int
+hostx_allocate_resource_id_peer (int a_local_resource_id,
+ int *a_remote_resource_id)
+{
+ int i=0 ;
+ ResourcePair *peer=NULL ;
+ Display *dpy=hostx_get_display ();
+
+ /*
+ * first make sure a resource peer
+ * does not exist already for
+ * a_local_resource_id
+ */
+ for (i=0; i<RESOURCE_PEERS_SIZE; i++) {
+ if (resource_peers[i].is_valid
+ && resource_peers[i].local_id == a_local_resource_id) {
+ peer = &resource_peers[i] ;
+ break ;
+ }
+ }
+ /*
+ * find one free peer entry, an feed it with
+ */
+ if (!peer) {
+ for (i=0; i<RESOURCE_PEERS_SIZE; i++) {
+ if (!resource_peers[i].is_valid) {
+ peer = &resource_peers[i] ;
+ break ;
+ }
+ }
+ if (peer) {
+ peer->remote_id = XAllocID (dpy);
+ peer->local_id = a_local_resource_id ;
+ peer->is_valid = TRUE ;
+ }
+ }
+ if (peer) {
+ *a_remote_resource_id = peer->remote_id ;
+ return TRUE ;
+ }
+ return FALSE ;
+}
+
+int
+hostx_get_resource_id_peer (int a_local_resource_id,
+ int *a_remote_resource_id)
+{
+ int i=0 ;
+ ResourcePair *peer=NULL ;
+ for (i=0; i<RESOURCE_PEERS_SIZE; i++) {
+ if (resource_peers[i].is_valid
+ && resource_peers[i].local_id == a_local_resource_id) {
+ peer = &resource_peers[i] ;
+ break ;
+ }
+ }
+ if (peer) {
+ *a_remote_resource_id = peer->remote_id ;
+ return TRUE ;
+ }
+ return FALSE ;
+}
+
+int
+hostx_has_dri (void)
+{
+ int event_base=0, error_base=0 ;
+ Display *dpy=hostx_get_display () ;
+
+ if (!dpy)
+ return FALSE ;
+
+ if (!XF86DRIQueryExtension (dpy,
+ &event_base,
+ &error_base)) {
+ return FALSE ;
+ }
+ return TRUE ;
+}
+
+int
+hostx_has_glx (void)
+{
+ Display *dpy=hostx_get_display () ;
+ int event_base=0, error_base=0 ;
+
+ if (!glXQueryExtension (dpy, &event_base, &error_base)) {
+ return FALSE ;
+ }
+ return TRUE ;
+}
+
+#endif /*XEPHYR_DRI*/
+
diff --git a/xorg-server/hw/kdrive/ephyr/hostx.h b/xorg-server/hw/kdrive/ephyr/hostx.h
new file mode 100644
index 000000000..47ba61b5b
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/hostx.h
@@ -0,0 +1,261 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@o-hand.com>
+ *
+ * Copyright © 2004 Nokia
+ *
+ * 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 Nokia not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Nokia makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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 _XLIBS_STUFF_H_
+#define _XLIBS_STUFF_H_
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#define EPHYR_WANT_DEBUG 0
+
+#if (EPHYR_WANT_DEBUG)
+#define EPHYR_DBG(x, a...) \
+ fprintf(stderr, __FILE__ ":%d,%s() " x "\n", __LINE__, __func__, ##a)
+#else
+#define EPHYR_DBG(x, a...) do {} while (0)
+#endif
+
+typedef struct EphyrHostXVars EphyrHostXVars;
+typedef struct EphyrHostXEvent EphyrHostXEvent;
+typedef void* EphyrScreenInfo ;
+typedef enum EphyrHostXEventType
+{
+ EPHYR_EV_MOUSE_MOTION,
+ EPHYR_EV_MOUSE_PRESS,
+ EPHYR_EV_MOUSE_RELEASE,
+ EPHYR_EV_KEY_PRESS,
+ EPHYR_EV_KEY_RELEASE,
+ EPHYR_EV_EXPOSE
+}
+EphyrHostXEventType;
+
+/* I can't believe it's not a KeySymsRec. */
+typedef struct {
+ int minKeyCode;
+ int maxKeyCode;
+ int mapWidth;
+ CARD32 *map;
+} EphyrKeySyms;
+
+struct EphyrHostXEvent
+{
+ EphyrHostXEventType type;
+
+ union
+ {
+ struct mouse_motion {
+ int x;
+ int y;
+ int screen;
+ int window;
+ } mouse_motion;
+
+ struct mouse_down {
+ int button_num;
+ } mouse_down;
+
+ struct mouse_up {
+ int button_num;
+ } mouse_up;
+
+ struct key_up {
+ int scancode;
+ } key_up;
+
+ struct key_down {
+ int scancode;
+ } key_down;
+
+ struct expose {
+ int window;
+ } expose;
+
+ } data;
+
+ int key_state;
+};
+
+typedef struct {
+ VisualID visualid;
+ int screen;
+ int depth;
+ int class;
+ unsigned long red_mask;
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ int colormap_size;
+ int bits_per_rgb;
+} EphyrHostVisualInfo;
+
+typedef struct {
+ int x, y;
+ int width, height ;
+ int visualid ;
+} EphyrHostWindowAttributes;
+
+typedef struct {
+ int x,y,width,height;
+} EphyrBox;
+
+typedef struct {
+ short x1,y1,x2,y2;
+} EphyrRect;
+
+int
+hostx_want_screen_size(EphyrScreenInfo screen, int *width, int *height);
+
+int
+hostx_want_host_cursor(void);
+
+void
+hostx_use_host_cursor(void);
+
+void
+hostx_use_fullscreen(void);
+
+int
+hostx_want_fullscreen(void);
+
+int
+hostx_want_preexisting_window(EphyrScreenInfo screen);
+
+void
+hostx_use_preexisting_window(unsigned long win_id);
+
+void
+hostx_use_resname (char *name, int fromcmd);
+
+void
+hostx_handle_signal(int signum);
+
+int
+hostx_init(void);
+
+void
+hostx_add_screen(EphyrScreenInfo screen, unsigned long win_id, int screen_num);
+
+void
+hostx_set_display_name(char *name);
+
+void
+hostx_set_screen_number(EphyrScreenInfo screen, int number);
+
+void
+hostx_set_win_title(EphyrScreenInfo screen, char *extra_text);
+
+int
+hostx_get_depth (void);
+
+int
+hostx_get_server_depth (EphyrScreenInfo screen);
+
+void
+hostx_set_server_depth(EphyrScreenInfo screen, int depth);
+
+int
+hostx_get_bpp(void *info);
+
+void
+hostx_get_visual_masks (void *info,
+ CARD32 *rmsk,
+ CARD32 *gmsk,
+ CARD32 *bmsk);
+void
+hostx_set_cmap_entry(unsigned char idx,
+ unsigned char r,
+ unsigned char g,
+ unsigned char b);
+
+void*
+hostx_screen_init (EphyrScreenInfo screen,
+ int width, int height,
+ int buffer_height);
+
+void
+hostx_paint_rect(EphyrScreenInfo screen,
+ int sx, int sy,
+ int dx, int dy,
+ int width, int height);
+
+
+void
+hostx_load_keymap (void);
+
+int
+hostx_get_event (EphyrHostXEvent *ev);
+
+void*
+hostx_get_display (void) ;
+
+int
+hostx_get_window (int a_screen_number) ;
+
+int
+hostx_get_window_attributes (int a_window, EphyrHostWindowAttributes *a_attr) ;
+
+int
+hostx_get_extension_info (const char *a_ext_name,
+ int *a_major_opcode,
+ int *a_first_even,
+ int *a_first_error) ;
+int
+hostx_get_visuals_info (EphyrHostVisualInfo **a_visuals,
+ int *a_num_entries) ;
+
+int hostx_create_window (int a_screen_number,
+ EphyrBox *a_geometry,
+ int a_visual_id,
+ int *a_host_win /*out parameter*/) ;
+
+int hostx_destroy_window (int a_win) ;
+
+int hostx_set_window_geometry (int a_win, EphyrBox *a_geo) ;
+
+
+int hostx_set_window_bounding_rectangles (int a_window,
+ EphyrRect *a_rects,
+ int a_num_rects) ;
+
+int hostx_set_window_clipping_rectangles (int a_window,
+ EphyrRect *a_rects,
+ int a_num_rects) ;
+int hostx_has_xshape (void) ;
+
+#ifdef XEPHYR_DRI
+int hostx_lookup_peer_window (void *a_local_window,
+ int *a_host_peer /*out parameter*/) ;
+int
+hostx_allocate_resource_id_peer (int a_local_resource_id,
+ int *a_remote_resource_id) ;
+int
+hostx_get_resource_id_peer (int a_local_resource_id,
+ int *a_remote_resource_id) ;
+int hostx_has_dri (void) ;
+
+int hostx_has_glx (void) ;
+#endif /*XEPHYR_DRI*/
+
+#endif /*_XLIBS_STUFF_H_*/
diff --git a/xorg-server/hw/kdrive/ephyr/os.c b/xorg-server/hw/kdrive/ephyr/os.c
new file mode 100644
index 000000000..4bf6e8858
--- /dev/null
+++ b/xorg-server/hw/kdrive/ephyr/os.c
@@ -0,0 +1,51 @@
+/*
+ * Xephyr - A kdrive X server thats runs in a host X window.
+ * Authored by Matthew Allum <mallum@o-hand.com>
+ *
+ * Copyright © 2004 Nokia
+ *
+ * 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 Nokia not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Nokia makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * NOKIA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL NOKIA BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "ephyr.h"
+
+extern void processScreenArg (char *screen_size, char *parent_id) ;
+
+static int
+EphyrInit (void)
+{
+ /*
+ * make sure at least one screen
+ * has been added to the system.
+ */
+ if (!KdCardInfoLast ())
+ {
+ processScreenArg ("640x480", NULL) ;
+ }
+ return hostx_init();
+}
+
+KdOsFuncs EphyrOsFuncs = {
+ .Init = EphyrInit,
+ .pollEvents = ephyrPoll,
+};
+
diff --git a/xorg-server/hw/kdrive/epson/Makefile.am b/xorg-server/hw/kdrive/epson/Makefile.am
new file mode 100644
index 000000000..14bb04996
--- /dev/null
+++ b/xorg-server/hw/kdrive/epson/Makefile.am
@@ -0,0 +1,36 @@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+bin_PROGRAMS = Xepson
+
+noinst_LIBRARIES = libepson.a
+
+libepson_a_SOURCES = \
+ epson13806.c \
+ epson13806.h \
+ epson13806draw.c\
+ epson13806draw.h\
+ epson13806reg.h
+
+Xepson_SOURCES = \
+ epson13806stub.c
+
+EPSON_LIBS = \
+ libepson.a \
+ @KDRIVE_LIBS@
+
+if GLX
+Xepson_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
+Xepson_LDADD = \
+ $(EPSON_LIBS) \
+ @KDRIVE_LIBS@
+
+Xepson_DEPENDENCIES = \
+ libepson.a \
+ @KDRIVE_LOCAL_LIBS@
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/epson/Makefile.in b/xorg-server/hw/kdrive/epson/Makefile.in
new file mode 100644
index 000000000..7e7083e5b
--- /dev/null
+++ b/xorg-server/hw/kdrive/epson/Makefile.in
@@ -0,0 +1,716 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xepson$(EXEEXT)
+subdir = hw/kdrive/epson
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libepson_a_AR = $(AR) $(ARFLAGS)
+libepson_a_LIBADD =
+am_libepson_a_OBJECTS = epson13806.$(OBJEXT) epson13806draw.$(OBJEXT)
+libepson_a_OBJECTS = $(am_libepson_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xepson_OBJECTS = epson13806stub.$(OBJEXT)
+Xepson_OBJECTS = $(am_Xepson_OBJECTS)
+am__DEPENDENCIES_1 = libepson.a
+Xepson_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xepson_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libepson_a_SOURCES) $(Xepson_SOURCES)
+DIST_SOURCES = $(libepson_a_SOURCES) $(Xepson_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libepson.a
+libepson_a_SOURCES = \
+ epson13806.c \
+ epson13806.h \
+ epson13806draw.c\
+ epson13806draw.h\
+ epson13806reg.h
+
+Xepson_SOURCES = \
+ epson13806stub.c
+
+EPSON_LIBS = \
+ libepson.a \
+ @KDRIVE_LIBS@
+
+@GLX_TRUE@Xepson_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xepson_LDADD = \
+ $(EPSON_LIBS) \
+ @KDRIVE_LIBS@
+
+Xepson_DEPENDENCIES = \
+ libepson.a \
+ @KDRIVE_LOCAL_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/epson/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/epson/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libepson.a: $(libepson_a_OBJECTS) $(libepson_a_DEPENDENCIES)
+ -rm -f libepson.a
+ $(libepson_a_AR) libepson.a $(libepson_a_OBJECTS) $(libepson_a_LIBADD)
+ $(RANLIB) libepson.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xepson$(EXEEXT): $(Xepson_OBJECTS) $(Xepson_DEPENDENCIES)
+ @rm -f Xepson$(EXEEXT)
+ $(Xepson_LINK) $(Xepson_OBJECTS) $(Xepson_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epson13806.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epson13806draw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epson13806stub.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/epson/epson13806.c b/xorg-server/hw/kdrive/epson/epson13806.c
new file mode 100644
index 000000000..6cf8c9ad9
--- /dev/null
+++ b/xorg-server/hw/kdrive/epson/epson13806.c
@@ -0,0 +1,604 @@
+/*
+ * Copyright 2004 by Costas Stylianou <costas.stylianou@psion.com> +44(0)7850 394095
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Costas Sylianou not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Costas Stylianou makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL COSTAS STYLIANOU BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+ * epson13806.c - Implementation of hardware accelerated functions for
+ * Epson S1D13806 graphics controller.
+ *
+ * History:
+ * 28-Jan-04 C.Stylianou PRJ NBL: Created from fbdev.c.
+ * 30-Mar-04 Phil Blundell/Peter Naulls Integration with XFree 4.3
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+#include <sys/ioctl.h>
+
+#include "epson13806.h"
+#include "epson13806reg.h"
+
+extern int KdTsPhyScreen;
+
+Bool
+epsonInitialize (KdCardInfo *card, EpsonPriv *priv)
+{
+ int k;
+ unsigned long off;
+ if ((priv->fd = open("/dev/fb0", O_RDWR)) < 0) {
+ perror("Error opening /dev/fb0\n");
+ return FALSE;
+ }
+
+ if ((k=ioctl(priv->fd, FBIOGET_FSCREENINFO, &priv->fix)) < 0) {
+ perror("Error with /dev/fb ioctl FIOGET_FSCREENINFO");
+ close (priv->fd);
+ return FALSE;
+ }
+
+ if ((k=ioctl(priv->fd, FBIOGET_VSCREENINFO, &priv->var)) < 0) {
+ perror("Error with /dev/fb ioctl FIOGET_VSCREENINFO");
+ close (priv->fd);
+ return FALSE;
+ }
+
+ priv->fb_base = KdMapDevice (EPSON13806_PHYSICAL_VMEM_ADDR, EPSON13806_VMEM_SIZE);
+
+
+ if (priv->fb_base == (char *)-1) {
+ perror("ERROR: mmap framebuffer fails!");
+ close (priv->fd);
+ return FALSE;
+ }
+
+ off = (unsigned long) priv->fix.smem_start % (unsigned long) getpagesize();
+ priv->fb = priv->fb_base + off;
+ return TRUE;
+}
+
+Bool
+epsonCardInit (KdCardInfo *card)
+{
+ EpsonPriv *priv;
+
+ priv = (EpsonPriv *) xalloc (sizeof (EpsonPriv));
+ if (!priv)
+ return FALSE;
+
+ if (!epsonInitialize (card, priv))
+ {
+ xfree (priv);
+ return FALSE;
+ }
+ card->driver = priv;
+
+ // Call InitEpson to map onto Epson registers
+ initEpson13806();
+
+ return TRUE;
+}
+
+#define FBDEV_KLUDGE_FORMAT
+#ifdef FBDEV_KLUDGE_FORMAT
+static Pixel
+epsonMakeContig (Pixel orig, Pixel others)
+{
+ Pixel low;
+
+ low = lowbit (orig) >> 1;
+ while (low && (others & low) == 0)
+ {
+ orig |= low;
+ low >>= 1;
+ }
+ return orig;
+}
+#endif
+
+Bool
+epsonScreenInitialize (KdScreenInfo *screen, EpsonScrPriv *scrpriv)
+{
+ EpsonPriv *priv = screen->card->driver;
+ Pixel allbits;
+ int depth;
+ Bool gray;
+ depth = priv->var.bits_per_pixel;
+ gray = priv->var.grayscale;
+
+
+ screen->fb[0].visuals = (1 << TrueColor);
+#define Mask(o,l) (((1 << l) - 1) << o)
+ screen->fb[0].redMask = Mask (priv->var.red.offset, priv->var.red.length);
+ screen->fb[0].greenMask = Mask (priv->var.green.offset, priv->var.green.length);
+ screen->fb[0].blueMask = Mask (priv->var.blue.offset, priv->var.blue.length);
+#ifdef FBDEV_KLUDGE_FORMAT
+ /*
+ * This is a kludge so that Render will work -- fill in the gaps
+ * in the pixel
+ */
+ screen->fb[0].redMask = epsonMakeContig (screen->fb[0].redMask,
+ screen->fb[0].greenMask|
+ screen->fb[0].blueMask);
+
+ screen->fb[0].greenMask = epsonMakeContig (screen->fb[0].greenMask,
+ screen->fb[0].redMask|
+ screen->fb[0].blueMask);
+
+ screen->fb[0].blueMask = epsonMakeContig (screen->fb[0].blueMask,
+ screen->fb[0].redMask|
+ screen->fb[0].greenMask);
+
+#endif
+ allbits = screen->fb[0].redMask | screen->fb[0].greenMask | screen->fb[0].blueMask;
+ depth = 32;
+ while (depth && !(allbits & (1 << (depth - 1))))
+ depth--;
+
+ screen->rate = 60;
+ scrpriv->randr = screen->randr;
+
+ {
+ screen->fb[0].depth = depth;
+ screen->fb[0].bitsPerPixel = priv->var.bits_per_pixel;
+ screen->width = priv->var.xres;
+ screen->height = priv->var.yres;
+ screen->fb[0].byteStride = priv->fix.line_length;
+ screen->fb[0].pixelStride = (priv->fix.line_length * 8 /
+ priv->var.bits_per_pixel);
+ screen->fb[0].frameBuffer = (CARD8 *) (priv->fb);
+ screen->off_screen_base = screen->fb[0].byteStride * screen->height;
+ screen->memory_base = priv->fb;
+ screen->memory_size = EPSON13806_VMEM_SIZE;
+ }
+ return TRUE;
+}
+
+Bool
+epsonScreenInit (KdScreenInfo *screen)
+{
+ EpsonScrPriv *scrpriv;
+
+ scrpriv = xalloc (sizeof (EpsonScrPriv));
+ if (!scrpriv)
+ return FALSE;
+ memset (scrpriv, '\0', sizeof (EpsonScrPriv));
+ screen->driver = scrpriv;
+ if (!epsonScreenInitialize (screen, scrpriv)) {
+ screen->driver = 0;
+ xfree (scrpriv);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static void *
+epsonWindowLinear (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure)
+{
+ KdScreenPriv(pScreen);
+ EpsonPriv *priv = pScreenPriv->card->driver;
+
+ if (!pScreenPriv->enabled)
+ return 0;
+ *size = priv->fix.line_length;
+ return (CARD8 *) priv->fb + row * priv->fix.line_length + offset;
+}
+
+
+#ifdef RANDR
+static Bool
+epsonRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EpsonScrPriv *scrpriv = screen->driver;
+#if 0
+ RRVisualGroupPtr pVisualGroup;
+ RRGroupOfVisualGroupPtr pGroupOfVisualGroup;
+#endif
+ RRScreenSizePtr pSize;
+ Rotation randr;
+ int n;
+
+ *rotations = RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270;
+
+ for (n = 0; n < pScreen->numDepths; n++)
+ if (pScreen->allowedDepths[n].numVids)
+ break;
+ if (n == pScreen->numDepths)
+ return FALSE;
+
+#if 0
+ pVisualGroup = RRCreateVisualGroup (pScreen);
+ if (!pVisualGroup)
+ return FALSE;
+
+ if (!RRAddDepthToVisualGroup (pScreen, pVisualGroup, &pScreen->allowedDepths[n])) {
+ RRDestroyVisualGroup (pScreen, pVisualGroup);
+ return FALSE;
+ }
+
+ pVisualGroup = RRRegisterVisualGroup (pScreen, pVisualGroup);
+ if (!pVisualGroup)
+ return FALSE;
+
+ pGroupOfVisualGroup = RRCreateGroupOfVisualGroup (pScreen);
+
+ if (!RRAddVisualGroupToGroupOfVisualGroup (pScreen,
+ pGroupOfVisualGroup,
+ pVisualGroup))
+ {
+ RRDestroyGroupOfVisualGroup (pScreen, pGroupOfVisualGroup);
+ /* pVisualGroup left until screen closed */
+ return FALSE;
+ }
+
+ pGroupOfVisualGroup = RRRegisterGroupOfVisualGroup (pScreen, pGroupOfVisualGroup);
+ if (!pGroupOfVisualGroup)
+ return FALSE;
+#endif
+
+ pSize = RRRegisterSize (pScreen,
+ screen->width,
+ screen->height,
+ screen->width_mm,
+ screen->height_mm);
+
+ randr = KdSubRotation (scrpriv->randr, screen->randr);
+
+ RRSetCurrentConfig (pScreen, randr, RR_Rotate_0, pSize);
+
+ return TRUE;
+}
+
+static Bool
+epsonRandRSetConfig (ScreenPtr pScreen,
+ Rotation randr,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EpsonScrPriv *scrpriv = screen->driver;
+ Bool wasEnabled = pScreenPriv->enabled;
+
+ randr = KdAddRotation (randr, screen->randr);
+
+ if (scrpriv->randr != randr)
+ {
+ if (wasEnabled)
+ KdDisableScreen (pScreen);
+
+ scrpriv->randr = randr;
+
+ if (wasEnabled)
+ KdEnableScreen (pScreen);
+ }
+ return TRUE;
+}
+
+static Bool
+epsonRandRInit (ScreenPtr pScreen)
+{
+ rrScrPrivPtr pScrPriv;
+
+ if (!RRScreenInit (pScreen))
+ return FALSE;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+ pScrPriv->rrGetInfo = epsonRandRGetInfo;
+ pScrPriv->rrSetConfig = epsonRandRSetConfig;
+ return TRUE;
+}
+#endif
+
+static Bool
+epsonCreateColormap (ColormapPtr pmap)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+ KdScreenPriv(pScreen);
+ EpsonPriv *priv = pScreenPriv->card->driver;
+ VisualPtr pVisual;
+ int i;
+ int nent;
+ xColorItem *pdefs;
+
+ switch (priv->fix.visual) {
+ case FB_VISUAL_STATIC_PSEUDOCOLOR:
+ pVisual = pmap->pVisual;
+ nent = pVisual->ColormapEntries;
+ pdefs = xalloc (nent * sizeof (xColorItem));
+ if (!pdefs)
+ return FALSE;
+ for (i = 0; i < nent; i++)
+ pdefs[i].pixel = i;
+ epsonGetColors (pScreen, 0, nent, pdefs);
+ for (i = 0; i < nent; i++)
+ {
+ pmap->red[i].co.local.red = pdefs[i].red;
+ pmap->red[i].co.local.green = pdefs[i].green;
+ pmap->red[i].co.local.blue = pdefs[i].blue;
+ }
+ xfree (pdefs);
+ return TRUE;
+
+ default:
+ return fbInitializeColormap (pmap);
+ }
+}
+
+Bool
+epsonInitScreen (ScreenPtr pScreen)
+{
+#ifdef TOUCHSCREEN
+ KdTsPhyScreen = pScreen->myNum;
+#endif
+
+ pScreen->CreateColormap = epsonCreateColormap;
+
+ return TRUE;
+}
+
+static Bool
+epsonFinishInitScreen (ScreenPtr pScreen)
+{
+ if (!shadowSetup (pScreen))
+ return FALSE;
+
+#ifdef RANDR
+ if (!epsonRandRInit (pScreen))
+ return FALSE;
+#endif
+
+ return TRUE;
+}
+
+static Bool
+epsonSetShadow (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EpsonScrPriv *scrpriv = screen->driver;
+ ShadowUpdateProc update;
+ ShadowWindowProc window;
+
+ window = epsonWindowLinear;
+ update = shadowUpdatePacked;
+
+ return KdShadowSet (pScreen, scrpriv->randr, update, window);
+}
+
+static Bool
+epsonCreateResources (ScreenPtr pScreen)
+{
+ return epsonSetShadow (pScreen);
+}
+
+void
+epsonPreserve (KdCardInfo *card)
+{
+}
+
+Bool
+epsonEnable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ EpsonPriv *priv = pScreenPriv->card->driver;
+ int k;
+
+ priv->var.activate = FB_ACTIVATE_NOW|FB_CHANGE_CMAP_VBL;
+
+ /* display it on the LCD */
+ k = ioctl (priv->fd, FBIOPUT_VSCREENINFO, &priv->var);
+ if (k < 0) {
+ perror ("FBIOPUT_VSCREENINFO");
+ return FALSE;
+ }
+
+ k = ioctl (priv->fd, FBIOGET_FSCREENINFO, &priv->fix);
+ if (k < 0) {
+ perror ("FBIOGET_FSCREENINFO");
+ return FALSE;
+ }
+
+ if (priv->fix.visual == FB_VISUAL_DIRECTCOLOR) {
+ struct fb_cmap cmap;
+ int i;
+
+ for (i = 0;
+ i < (1 << priv->var.red.length) ||
+ i < (1 << priv->var.green.length) ||
+ i < (1 << priv->var.blue.length); i++) {
+ priv->red[i] = i * 65535 / ((1 << priv->var.red.length) - 1);
+ priv->green[i] = i * 65535 / ((1 << priv->var.green.length) - 1);
+ priv->blue[i] = i * 65535 / ((1 << priv->var.blue.length) - 1);
+ }
+ cmap.start = 0;
+ cmap.len = i;
+ cmap.red = &priv->red[0];
+ cmap.green = &priv->green[0];
+ cmap.blue = &priv->blue[0];
+ cmap.transp = 0;
+ ioctl (priv->fd, FBIOPUTCMAP, &cmap);
+ }
+ return TRUE;
+}
+
+Bool
+epsonDPMS (ScreenPtr pScreen, int mode)
+{
+ KdScreenPriv(pScreen);
+ EpsonPriv *priv = pScreenPriv->card->driver;
+ static int oldmode = -1;
+
+ if (mode == oldmode)
+ return TRUE;
+#ifdef FBIOPUT_POWERMODE
+ if (ioctl (priv->fd, FBIOPUT_POWERMODE, &mode) >= 0) {
+ oldmode = mode;
+ return TRUE;
+ }
+#endif
+#ifdef FBIOBLANK
+ if (ioctl (priv->fd, FBIOBLANK, mode ? mode + 1 : 0) >= 0) {
+ oldmode = mode;
+ return TRUE;
+ }
+#endif
+ return FALSE;
+}
+
+void
+epsonDisable (ScreenPtr pScreen)
+{
+}
+
+void
+epsonRestore (KdCardInfo *card)
+{
+}
+
+void
+epsonScreenFini (KdScreenInfo *screen)
+{
+}
+
+void
+epsonCardFini (KdCardInfo *card)
+{
+ EpsonPriv *priv = card->driver;
+
+ munmap (priv->fb_base, priv->fix.smem_len);
+ close (priv->fd);
+ xfree (priv);
+}
+
+void
+epsonGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ KdScreenPriv(pScreen);
+ EpsonPriv *priv = pScreenPriv->card->driver;
+ struct fb_cmap cmap;
+ int p;
+ int k;
+ int min, max;
+
+ min = 256;
+ max = 0;
+ for (k = 0; k < n; k++) {
+ if (pdefs[k].pixel < min)
+ min = pdefs[k].pixel;
+ if (pdefs[k].pixel > max)
+ max = pdefs[k].pixel;
+ }
+ cmap.start = min;
+ cmap.len = max - min + 1;
+ cmap.red = &priv->red[min];
+ cmap.green = &priv->green[min];;
+ cmap.blue = &priv->blue[min];
+ cmap.transp = 0;
+ k = ioctl (priv->fd, FBIOGETCMAP, &cmap);
+ if (k < 0) {
+ perror ("can't get colormap");
+ return;
+ }
+ while (n--) {
+ p = pdefs->pixel;
+ pdefs->red = priv->red[p];
+ pdefs->green = priv->green[p];
+ pdefs->blue = priv->blue[p];
+ pdefs++;
+ }
+}
+
+void
+epsonPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ KdScreenPriv(pScreen);
+ EpsonPriv *priv = pScreenPriv->card->driver;
+ struct fb_cmap cmap;
+ int p;
+ int min, max;
+
+ min = 256;
+ max = 0;
+ while (n--) {
+ p = pdefs->pixel;
+ priv->red[p] = pdefs->red;
+ priv->green[p] = pdefs->green;
+ priv->blue[p] = pdefs->blue;
+ if (p < min)
+ min = p;
+ if (p > max)
+ max = p;
+ pdefs++;
+ }
+ cmap.start = min;
+ cmap.len = max - min + 1;
+ cmap.red = &priv->red[min];
+ cmap.green = &priv->green[min];
+ cmap.blue = &priv->blue[min];
+ cmap.transp = 0;
+ ioctl (priv->fd, FBIOPUTCMAP, &cmap);
+}
+
+
+
+KdCardFuncs epsonFuncs = {
+ epsonCardInit, /* cardinit */
+ epsonScreenInit, /* scrinit */
+ epsonInitScreen, /* initScreen */
+ epsonFinishInitScreen,
+ epsonCreateResources,
+ epsonPreserve, /* preserve */
+ epsonEnable, /* enable */
+ epsonDPMS, /* dpms */
+ epsonDisable, /* disable */
+ epsonRestore, /* restore */
+ epsonScreenFini, /* scrfini */
+ epsonCardFini, /* cardfini */
+
+ 0, /* initCursor */
+ 0, /* enableCursor */
+ 0, /* disableCursor */
+ 0, /* finiCursor */
+ 0, /* recolorCursor */
+
+ /*
+ * History:
+ * 28-Jan-04 C.Stylianou NBL: Added the following for h/w accel.
+ *
+ */
+
+ epsonDrawInit, /* initAccel */
+ epsonDrawEnable, /* enableAccel */
+ epsonDrawDisable, /* disableAccel */
+ epsonDrawFini, /* finiAccel */
+
+ epsonGetColors, /* getColors */
+ epsonPutColors, /* putColors */
+};
diff --git a/xorg-server/hw/kdrive/epson/epson13806.h b/xorg-server/hw/kdrive/epson/epson13806.h
new file mode 100644
index 000000000..b28d7c085
--- /dev/null
+++ b/xorg-server/hw/kdrive/epson/epson13806.h
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2004 by Costas Stylianou <costas.stylianou@psion.com> +44(0)7850 394095
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Costas Sylianou not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Costas Stylianou makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL COSTAS STYLIANOU BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+ * epson13806draw.h - Implementation of hard ware accelerated functions for epson S1D13806
+ * Graphic controller.
+ *
+ * History:
+ * 28-Jan-04 C.Stylianou PRJ NBL: Created from fbdev.h
+ *
+ */
+
+#ifndef _EPSON13806_H_
+#define _EPSON13806_H_
+
+#include <stdio.h>
+#include <linux/fb.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include "kdrive.h"
+
+#ifdef RANDR
+#include "randrstr.h"
+#endif
+
+typedef struct _epsonPriv {
+ struct fb_var_screeninfo var;
+ struct fb_fix_screeninfo fix;
+ __u16 red[256];
+ __u16 green[256];
+ __u16 blue[256];
+ int fd;
+ char *fb;
+ char *fb_base;
+} EpsonPriv;
+
+typedef struct _epsonScrPriv {
+ Rotation randr;
+ Bool shadow;
+ KaaScreenInfoRec kaa;
+} EpsonScrPriv;
+
+extern KdCardFuncs epsonFuncs;
+
+Bool
+epsonInitialize (KdCardInfo *card, EpsonPriv *priv);
+
+Bool
+epsonCardInit (KdCardInfo *card);
+
+Bool
+epsonScreenInit (KdScreenInfo *screen);
+
+Bool
+epsonScreenInitialize (KdScreenInfo *screen, EpsonScrPriv *scrpriv);
+
+Bool
+epsonInitScreen (ScreenPtr pScreen);
+
+void
+epsonPreserve (KdCardInfo *card);
+
+Bool
+epsonEnable (ScreenPtr pScreen);
+
+Bool
+epsonDPMS (ScreenPtr pScreen, int mode);
+
+void
+epsonDisable (ScreenPtr pScreen);
+
+void
+epsonRestore (KdCardInfo *card);
+
+void
+epsonScreenFini (KdScreenInfo *screen);
+
+void
+epsonCardFini (KdCardInfo *card);
+
+void
+epsonGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+
+void
+epsonPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+
+/*
+ * History:
+ * 28-Jan-04 C.Stylianou NBL: Added the following prototypes for h/w accel.
+ *
+ */
+Bool
+epsonDrawInit (ScreenPtr pScreen);
+
+void
+epsonDrawEnable (ScreenPtr pScreen);
+
+void
+epsonDrawDisable (ScreenPtr pScreen);
+
+void
+epsonDrawFini (ScreenPtr pScreen);
+
+/*
+ * History:
+ * 28-Jan-04 C.Stylianou NBL: Maps to Epson registers
+ *
+ */
+void
+initEpson13806(void);
+
+
+#endif /* __EPSON13806_H_ */
diff --git a/xorg-server/hw/kdrive/epson/epson13806draw.c b/xorg-server/hw/kdrive/epson/epson13806draw.c
new file mode 100644
index 000000000..3222353a3
--- /dev/null
+++ b/xorg-server/hw/kdrive/epson/epson13806draw.c
@@ -0,0 +1,649 @@
+/*
+ * Copyright 2004 by Costas Stylianou <costas.stylianou@psion.com> +44(0)7850 394095
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Costas Sylianou not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Costas Stylianou makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL COSTAS STYLIANOU BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+ * epson13806draw.c - Implementation of hardware accelerated functions for epson S1D13806
+ * Graphic controller.
+ *
+ * History:
+ * 28-Jan-04 C.Stylianou PRJ NBL: Created from chipsdraw.c
+ *
+ */
+
+#include "epson13806.h"
+#include "epson13806draw.h"
+#include "epson13806reg.h"
+
+#include "kaa.h"
+
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mistruct.h"
+#include "dixfontstr.h"
+#include "fb.h"
+#include "migc.h"
+#include "miline.h"
+
+
+// Functionality of BitBLT ROP register for Epson S1D13806 Graphics controller
+CARD8 epson13806Rop[16] = {
+ /* GXclear */ 0x00, /* 0 */
+ /* GXand */ 0x08, /* src AND dst */
+ /* GXandReverse */ 0x04, /* src AND NOT dst */
+ /* GXcopy */ 0x0C, /* src */
+ /* GXandInverted*/ 0x02, /* NOT src AND dst */
+ /* GXnoop */ 0x0A, /* dst */
+ /* GXxor */ 0x06, /* src XOR dst */
+ /* GXor */ 0x0E, /* src OR dst */
+ /* GXnor */ 0x01, /* NOT src AND NOT dst */
+ /* GXequiv */ 0x09, /* NOT src XOR dst */
+ /* GXinvert */ 0x05, /* NOT dst */
+ /* GXorReverse */ 0x0D, /* src OR NOT dst */
+ /* GXcopyInverted*/ 0x03, /* NOT src */
+ /* GXorInverted */ 0x0B, /* NOT src OR dst */
+ /* GXnand */ 0x07, /* NOT src OR NOT dst */
+ /* GXset */ 0x0F, /* 1 */
+};
+
+
+
+#undef __DEBUG_EPSON__
+#undef __DEBUG_EPSON_FBSET__
+#undef __DEBUG_EPSON_SOLID__
+#undef __DEBUG_EPSON_COPY__
+
+
+#ifdef __DEBUG_EPSON__
+ #define EPSON_DEBUG(a) a
+#else
+ #define EPSON_DEBUG(a)
+#endif
+
+#ifdef __DEBUG_EPSON_FBSET__
+ #define EPSON_DEBUG_FBSET(a) a
+#else
+ #define EPSON_DEBUG_FBSET(a)
+#endif
+
+#ifdef __DEBUG_EPSON_SOLID__
+ #define EPSON_DEBUG_SOLID(a) a
+#else
+ #define EPSON_DEBUG_SOLID(a)
+#endif
+
+#ifdef __DEBUG_EPSON_COPY__
+ #define EPSON_DEBUG_COPY(a) a
+#else
+ #define EPSON_DEBUG_COPY(a)
+#endif
+
+
+static unsigned int byteStride; // Distance between lines in the frame buffer (in bytes)
+static unsigned int bytesPerPixel;
+static unsigned int pixelStride;
+
+static unsigned char *regbase;
+
+/*
+ * epsonSet
+ *
+ * Description: Sets Epson variables
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+static void
+epsonSet (ScreenPtr pScreen)
+{
+ EPSON_DEBUG_FBSET (fprintf(stderr,"+epsonSet\n"));
+
+ KdScreenPriv(pScreen);
+
+ byteStride = pScreenPriv->screen->fb[0].byteStride;
+ bytesPerPixel = pScreenPriv->screen->fb[0].bitsPerPixel >> 3;
+ pixelStride = pScreenPriv->screen->fb[0].pixelStride;
+
+ EPSON_DEBUG_FBSET (fprintf(stderr,"byteStride: [%x]\n", pScreenPriv->screen->fb[0].byteStride));
+ EPSON_DEBUG_FBSET (fprintf(stderr,"bytesPerPixel: [%x]\n", pScreenPriv->screen->fb[0].bitsPerPixel >> 3));
+ EPSON_DEBUG_FBSET (fprintf(stderr,"pixelStride: [%x]\n", pScreenPriv->screen->fb[0].pixelStride));
+
+ EPSON_DEBUG_FBSET (fprintf(stderr,"-epsonSet\n"));
+}
+
+
+/*
+ * epsonBg
+ *
+ * Description: Sets background colour
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+static void
+epsonBg (Pixel bg)
+{
+ EPSON13806_REG16(EPSON13806_BLTBGCOLOR) = bg;
+}
+
+
+/*
+ * epsonFg
+ *
+ * Description: Sets foreground colour
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+static void
+epsonFg (Pixel fg)
+{
+ EPSON13806_REG16(EPSON13806_BLTFGCOLOR) = fg;
+}
+
+
+/*
+ * epsonWaitForHwBltDone
+ *
+ * Description: Wait for previous blt to be done before programming any blt registers
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+static void
+epsonWaitForHwBltDone (void)
+{
+ while (EPSON13806_REG (EPSON13806_BLTCTRL0) & EPSON13806_BLTCTRL0_ACTIVE) {}
+}
+
+
+/*
+ * epsonDrawSync
+ *
+ * Description: Sync hardware acceleration
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+static void
+epsonWaitMarker (ScreenPtr pScreen, int marker)
+{
+ EPSON_DEBUG (fprintf(stderr,"+epsonDrawSync\n"));
+
+ epsonWaitForHwBltDone ();
+
+ EPSON_DEBUG (fprintf(stderr,"-epsonDrawSync\n"));
+}
+
+
+/*
+ * epsonPrepareSolid
+ *
+ * Description: Prepare Solid Fill i.e, can it be accelerated
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+static Bool
+epsonPrepareSolid (PixmapPtr pPixmap,
+ int alu,
+ Pixel pm,
+ Pixel fg)
+{
+ EPSON_DEBUG_SOLID (fprintf(stderr,"+epsonPrepareSolid\n"));
+
+ FbBits depthMask;
+
+ depthMask = FbFullMask(pPixmap->drawable.depth);
+ if ((pm & depthMask) != depthMask)
+ return FALSE;
+
+ epsonSet (pPixmap->drawable.pScreen);
+ fg &= 0xffff;
+ epsonFg (fg);
+ epsonBg (fg);
+
+ epsonWaitForHwBltDone ();
+
+ EPSON_DEBUG_SOLID (fprintf(stderr,"Solid.alu [0x%x], [%d]\n", alu ,epson13806Rop[alu]));
+ EPSON13806_REG(EPSON13806_BLTROP) = epson13806Rop[alu];
+
+ if (epson13806Rop[alu] == GXnoop)
+ {
+ EPSON13806_REG(EPSON13806_BLTOPERATION) = EPSON13806_BLTOPERATION_PATFILLROP;
+ }
+ else
+ {
+ EPSON13806_REG(EPSON13806_BLTOPERATION) = EPSON13806_BLTOPERATION_SOLIDFILL;
+ }
+
+
+ EPSON_DEBUG_SOLID (fprintf(stderr,"-epsonPrepareSolid\n"));
+ return TRUE;
+
+}
+
+
+/*
+ * epsonSolid
+ *
+ * Description: Executes Solid Fill
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+static void
+epsonSolid (int x1, int y1, int x2, int y2)
+{
+
+ EPSON_DEBUG_SOLID (fprintf(stderr,"+epsonSolid\n"));
+
+ CARD32 dst_addr;
+ int width, height;
+
+ EPSON_DEBUG_SOLID (fprintf(stderr,"Solid X1 [%d] Y1 [%d] X2 [%d] Y2 [%d]\n", x1, y1, x2, y2));
+
+ dst_addr = y1 * byteStride + x1 * bytesPerPixel;
+ width = ((x2 - x1)-1);
+ height = ((y2 - y1)-1);
+
+ // program dst address
+ EPSON13806_REG16(EPSON13806_BLTDSTSTART01) = dst_addr;
+ EPSON13806_REG(EPSON13806_BLTDSTSTART2) = dst_addr >> 16;
+
+ // program width and height of blit
+ EPSON13806_REG16(EPSON13806_BLTWIDTH) = width;
+ EPSON13806_REG16(EPSON13806_BLTHEIGHT) = height;
+
+ EPSON13806_REG(EPSON13806_BLTCTRL0) = EPSON13806_BLTCTRL0_ACTIVE;
+
+ // Wait for operation to complete
+ while (EPSON13806_REG(EPSON13806_BLTCTRL0) & EPSON13806_BLTCTRL0_ACTIVE) {}
+
+ EPSON_DEBUG_SOLID (fprintf(stderr,"-epsonSolid\n"));
+}
+
+
+/*
+ * epsonDoneSolid
+ *
+ * Description: Done Solid
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+static void
+epsonDoneSolid (void)
+{
+ EPSON_DEBUG_SOLID (fprintf(stderr,"+epsonDoneSolid\n"));
+
+ // Read from BitBLT data offset 0 to shut it down
+ //(void)EPSON13806_REG(EPSON13806_BITBLTDATA);
+
+ EPSON_DEBUG_SOLID (fprintf(stderr,"-epsonDoneSolid\n"));
+
+}
+
+
+/*
+ * epsonPrepareCopy
+ *
+ * Description: Prepares BitBLT, i.e, can it be accelerated
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+static Bool
+epsonPrepareCopy (PixmapPtr pSrcPixmap,
+ PixmapPtr pDstPixmap,
+ int dx,
+ int dy,
+ int alu,
+ Pixel pm)
+{
+ EPSON_DEBUG_COPY (fprintf(stderr,"+epsonPrepareCopy dx [0x%x] dy [0x%x]\n", dx, dy));
+
+ FbBits depthMask;
+
+ depthMask = FbFullMask(pDstPixmap->drawable.depth);
+
+ if ((pm & depthMask) != depthMask)
+ return FALSE;
+
+ epsonSet (pDstPixmap->drawable.pScreen);
+ epsonWaitForHwBltDone ();
+ EPSON13806_REG(EPSON13806_BLTROP) = epson13806Rop[alu];
+
+ EPSON_DEBUG_COPY (fprintf(stderr,"-epsonPrepareCopy\n"));
+
+ return TRUE;
+}
+
+
+/*
+ * epsonCopy
+ *
+ * Description: Executes BitBLT
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+static void
+epsonCopy (int srcX,
+ int srcY,
+ int dstX,
+ int dstY,
+ int width,
+ int height)
+{
+ EPSON_DEBUG_COPY (fprintf(stderr,"+epsonCopy\n"));
+ int src_addr, dst_addr;
+ int neg_dir = FALSE;
+
+ if (!width || !height)
+ return;
+
+ src_addr = srcX * bytesPerPixel + srcY * byteStride;
+ dst_addr = dstX * bytesPerPixel + dstY * byteStride;
+
+ /*
+ * See if regions overlap and dest region is beyond source region.
+ * If so, we need to do a move BLT in negative direction. Only applies
+ * if the BLT is not transparent.
+ */
+
+ if ((srcX + width > dstX) && (srcX < dstX + width) &&
+ (srcY + height > dstY) && (srcY < dstY + height) &&
+ (dst_addr > src_addr))
+ {
+ neg_dir = TRUE;
+
+ // negative direction : get the coords of lower right corner
+ src_addr += byteStride * (height-1) + bytesPerPixel * (width-1);
+ dst_addr += byteStride * (height-1) + bytesPerPixel * (width-1);
+ }
+
+ // program BLIT memory offset
+ EPSON13806_REG16(EPSON13806_BLTSTRIDE) = byteStride/2;
+
+ // program src and dst addresses
+ EPSON13806_REG16(EPSON13806_BLTSRCSTART01) = src_addr;
+ EPSON13806_REG(EPSON13806_BLTSRCSTART2) = src_addr >> 16;
+ EPSON13806_REG16(EPSON13806_BLTDSTSTART01) = dst_addr;
+ EPSON13806_REG(EPSON13806_BLTDSTSTART2) = dst_addr >> 16;
+
+ // program width and height of blit
+ EPSON13806_REG16(EPSON13806_BLTWIDTH) = width-1;
+ EPSON13806_REG16(EPSON13806_BLTHEIGHT) = height-1;
+
+ // select pos/neg move BLIT
+ EPSON13806_REG(EPSON13806_BLTOPERATION) = neg_dir ?
+ EPSON13806_BLTOPERATION_MOVENEGROP : EPSON13806_BLTOPERATION_MOVEPOSROP;
+
+ EPSON13806_REG(EPSON13806_BLTCTRL0) = EPSON13806_BLTCTRL0_ACTIVE;
+
+ // Wait for operation to complete
+ while (EPSON13806_REG(EPSON13806_BLTCTRL0) & EPSON13806_BLTCTRL0_ACTIVE) {}
+
+ EPSON_DEBUG_COPY (fprintf(stderr,"-epsonCopy\n"));
+}
+
+
+/*
+ * epsonDoneCopy
+ *
+ * Description: Done Copy
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+static void
+epsonDoneCopy (void)
+{
+ EPSON_DEBUG_COPY (fprintf(stderr,"+epsonDoneCopy\n"));
+
+ // Read from BitBLT data offset 0 to shut it down
+ //(void)EPSON13806_REG(EPSON13806_BITBLTDATA);
+
+ EPSON_DEBUG_COPY (fprintf(stderr,"-epsonDoneCopy\n"));
+}
+
+
+/*
+ * epsonDrawInit
+ *
+ * Description: Configure the Epson S1D13806 for a 800x600 TFT colour display
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+Bool
+epsonDrawInit (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ EpsonScrPriv *epsons = screen->driver;
+
+ EPSON_DEBUG (fprintf(stderr,"+epsonDrawInit\n"));
+
+ epsonSet(pScreen);
+
+#if 0
+ EPSON13806_REG(EPSON13806_MISC) = 0x00;
+ EPSON13806_REG(EPSON13806_DISPMODE) = 0x00;
+ EPSON13806_REG16(EPSON13806_GPIOCFG) = 0xffff;
+ EPSON13806_REG16(EPSON13806_GPIOCTRL) = 0x0001;
+
+ EPSON13806_REG(EPSON13806_MEMCLKCFG) = 0x01;
+ EPSON13806_REG(EPSON13806_LCDPCLKCFG) = 0x00;
+ EPSON13806_REG(EPSON13806_CRTPCLKCFG) = 0x02;
+ EPSON13806_REG(EPSON13806_MPCLKCFG) = 0x02;
+ EPSON13806_REG(EPSON13806_CPUMEMWAITSEL) = 0x01;
+ EPSON13806_REG(EPSON13806_MEMCFG) = 0x80;
+ EPSON13806_REG(EPSON13806_DRAMREFRESH) = 0x03;
+ EPSON13806_REG16(EPSON13806_DRAMTIMINGCTRL) = 0x0100;
+
+ // 5ms delay for internal LCD SDRAM to initialize
+ usleep(5000);
+
+ EPSON13806_REG(EPSON13806_PANELTYPE) = 0x25;
+ EPSON13806_REG(EPSON13806_MODRATE) = 0x00;
+ EPSON13806_REG(EPSON13806_LCDHDP) = 0x63;
+ EPSON13806_REG(EPSON13806_LCDHNDP) = 0x1f;
+ EPSON13806_REG(EPSON13806_TFTFPLINESTART) = 0x01;
+ EPSON13806_REG(EPSON13806_TFTFPLINEPULSE) = 0x0b;
+ EPSON13806_REG16(EPSON13806_LCDVDP0) = 0x0257;
+ EPSON13806_REG(EPSON13806_LCDVNDP) = 0x1b;
+ EPSON13806_REG(EPSON13806_TFTFPFRAMESTART) = 0x0a;
+ EPSON13806_REG(EPSON13806_TFTFPFRAMEPULSE) = 0x01;
+ EPSON13806_REG(EPSON13806_LCDDISPMODE) = 0x85;
+ EPSON13806_REG(EPSON13806_LCDMISC) = 0x00;
+ EPSON13806_REG16(EPSON13806_LCDSTART01) = 0x0000;
+ EPSON13806_REG(EPSON13806_LCDSTART2) = 0x00;
+ EPSON13806_REG16(EPSON13806_LCDSTRIDE) = byteStride>>1;
+ EPSON13806_REG(EPSON13806_LCDPIXELPAN) = 0x00;
+ EPSON13806_REG(EPSON13806_LCDFIFOHIGH) = 0x00;
+ EPSON13806_REG(EPSON13806_LCDFIFOLOW) = 0x00;
+#endif
+
+
+ EPSON13806_REG(EPSON13806_BLTCTRL0) = 0x00;
+ EPSON13806_REG(EPSON13806_BLTCTRL1) = 0x01; // We're using 16 bpp
+ EPSON13806_REG16(EPSON13806_BLTSTRIDE) = byteStride>>1; // program BLIT memory offset
+
+#if 0
+ EPSON13806_REG(EPSON13806_LUTMODE) = 0x00;
+ EPSON13806_REG(EPSON13806_LUTADDR) = 0x00;
+ EPSON13806_REG(EPSON13806_PWRSAVECFG) = 0x10;
+ EPSON13806_REG(EPSON13806_PWRSAVESTATUS) = 0x00;
+ EPSON13806_REG(EPSON13806_CPUMEMWATCHDOG) = 0x00;
+ EPSON13806_REG(EPSON13806_DISPMODE) = 0x01;
+
+ // Enable backlight voltage
+ EPSON13806_REG16(EPSON13806_GPIOCTRL) |= 1<<1;
+ // 10ms delay after turning on LCD.
+ usleep(10000);
+#endif
+
+ // Instruct the BitBLT unit to fill the screen with black, i.e clear fb.
+ static int addr = 0x00000000;
+ EPSON13806_REG16(EPSON13806_BLTDSTSTART01) = addr;
+ EPSON13806_REG(EPSON13806_BLTDSTSTART2) = addr >> 16;
+ EPSON13806_REG16(EPSON13806_BLTFGCOLOR) = 0x0000;
+ EPSON13806_REG(EPSON13806_BLTOPERATION) = EPSON13806_BLTOPERATION_SOLIDFILL; // solid fill blt
+ EPSON13806_REG16(EPSON13806_BLTWIDTH) = (0x0320-1);
+ EPSON13806_REG16(EPSON13806_BLTHEIGHT) = (0x0258-1);
+ EPSON13806_REG(EPSON13806_BLTCTRL0) = EPSON13806_BLTCTRL0_ACTIVE;
+
+#if 0
+ // Enable LCD data
+ EPSON13806_REG(EPSON13806_LCDDISPMODE) &= ~(1<<7);
+
+ // Turn on backlight full
+ EPSON13806_REG16(EPSON13806_GPIOCTRL) |= 0x00fc;
+#endif
+
+ memset(&epsons->kaa, 0, sizeof(KaaScreenInfoRec));
+ epsons->kaa.waitMarker = epsonWaitMarker;
+ epsons->kaa.PrepareSolid = epsonPrepareSolid;
+ epsons->kaa.Solid = epsonSolid;
+ epsons->kaa.DoneSolid = epsonDoneSolid;
+ epsons->kaa.PrepareCopy = epsonPrepareCopy;
+ epsons->kaa.Copy = epsonCopy;
+ epsons->kaa.DoneCopy = epsonDoneCopy;
+ epsons->kaa.flags = KAA_OFFSCREEN_PIXMAPS;
+
+ if (!kaaDrawInit (pScreen, &epsons->kaa))
+ return FALSE;
+
+ EPSON_DEBUG (fprintf(stderr,"-epsonDrawInit\n"));
+ return TRUE;
+}
+
+
+/*
+ * epsonDrawEnable
+ *
+ * Description: Enables hardware acceleration
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+void
+epsonDrawEnable (ScreenPtr pScreen)
+{
+ EPSON_DEBUG (fprintf(stderr,"+epsonDrawEnable\n"));
+ epsonWaitForHwBltDone ();
+ kaaMarkSync (pScreen);
+ EPSON_DEBUG (fprintf(stderr,"-epsonDrawEnable\n"));
+}
+
+
+/*
+ * epsonDrawDisable
+ *
+ * Description: Disables hardware acceleration
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+void
+epsonDrawDisable (ScreenPtr pScreen)
+{
+ EPSON_DEBUG (fprintf(stderr,"+epsonDrawDisable\n"));
+}
+
+
+/*
+ * epsonDrawFini
+ *
+ * Description: Finish hardware acceleration
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+void
+epsonDrawFini (ScreenPtr pScreen)
+{
+ EPSON_DEBUG (fprintf(stderr,"+epsonDrawFini\n"));
+}
+
+
+/*
+ * initEpson13806
+ *
+ * Description: Maps Epson S1D13806 registers
+ *
+ * History:
+ * 11-Feb-04 C.Stylianou NBL: Created.
+ *
+ */
+
+void
+initEpson13806(void)
+{
+ EPSON_DEBUG (fprintf(stderr,"+initEpson\n"));
+
+ // Map Epson S1D13806 registers
+ regbase = KdMapDevice (EPSON13806_PHYSICAL_REG_ADDR, EPSON13806_GPIO_REGSIZE);
+ if (!regbase)
+ perror("ERROR: regbase\n"); // Sets up register mappings in header files.
+
+#if 0
+ CARD8 rev_code;
+ rev_code = EPSON13806_REG (EPSON13806_REVCODE);
+ if ((rev_code >> 2) != 0x07)
+ perror("ERROR: EPSON13806 Display Controller NOT FOUND!\n");
+#endif
+
+ EPSON_DEBUG (fprintf(stderr,"-initEpson\n"));
+}
diff --git a/xorg-server/hw/kdrive/epson/epson13806draw.h b/xorg-server/hw/kdrive/epson/epson13806draw.h
new file mode 100644
index 000000000..b5f1bf5c2
--- /dev/null
+++ b/xorg-server/hw/kdrive/epson/epson13806draw.h
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2004 by Costas Stylianou <costas.stylianou@psion.com> +44(0)7850 394095
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Costas Sylianou not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Costas Stylianou makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL COSTAS STYLIANOU BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+ * epson13806draw.h - Implementation of hard ware accelerated functions for epson S1D13806
+ * Graphic controller.
+ *
+ * History:
+ * 28-Jan-04 C.Stylianou PRJ NBL: Created from chipsdraw.h
+ *
+ */
+
+#ifndef _EPSON13806DRAW_H_
+#define _EPSON13806DRAW_H_
+
+
+/*
+ * offset from ioport beginning
+ */
+
+
+#define SetupEpson(s) KdScreenPriv(s); \
+ epsonCardInfo(pScreenPriv); \
+ EpsonPtr epson = epsonc->epson
+
+
+typedef volatile CARD8 VOL8;
+typedef volatile CARD16 VOL16;
+typedef volatile CARD32 VOL32;
+
+typedef struct _epsonSave {
+ int dummy;
+} EpsonSave;
+
+typedef struct _epsonCardInfo {
+ EpsonPriv epson;
+ CARD32 *window;
+ Bool mmio;
+ EpsonSave save;
+} epsonCardInfo;
+
+#define getEpsonCardInfo(kd) ((epsonCardInfo *) ((kd)->card->driver))
+#define epsonCardInfo(kd) epsonCardInfo *epsonc = getEpsonCardInfo(kd)
+
+typedef struct _epsonCursor {
+ int width, height;
+ int xhot, yhot;
+ Bool has_cursor;
+ CursorPtr pCursor;
+ Pixel source, mask;
+} EpsonCursor;
+
+#define epson_CURSOR_WIDTH 64
+#define epson_CURSOR_HEIGHT 64
+
+typedef struct _epsonScreenInfo {
+ EpsonScrPriv epson;
+ CARD8 *cursor_base;
+ CARD8 *screen;
+ CARD8 *off_screen;
+ int off_screen_size;
+ EpsonCursor cursor;
+ void *regbase_virt;
+} EpsonScreenInfo;
+
+#define getEpsonScreenInfo(kd) ((EpsonScreenInfo *) ((kd)->screen->driver))
+#define epsonScreenInfo(kd) EpsonScreenInfo *epsons = getEpsonScreenInfo(kd)
+
+Bool
+epsonDrawInit (ScreenPtr pScreen);
+
+void
+epsonDrawEnable (ScreenPtr pScreen);
+
+void
+epsonDrawSync (ScreenPtr pScreen);
+
+void
+epsonDrawDisable (ScreenPtr pScreen);
+
+void
+epsonDrawFini (ScreenPtr pScreen);
+
+Bool
+epsonCursorInit (ScreenPtr pScreen);
+
+void
+epsonCursorEnable (ScreenPtr pScreen);
+
+void
+epsonCursorDisable (ScreenPtr pScreen);
+
+void
+epsonCursorFini (ScreenPtr pScreen);
+
+void
+epsonRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef);
+
+extern KdCardFuncs epsonFuncs;
+
+#endif
diff --git a/xorg-server/hw/kdrive/epson/epson13806reg.h b/xorg-server/hw/kdrive/epson/epson13806reg.h
new file mode 100644
index 000000000..ee745a08f
--- /dev/null
+++ b/xorg-server/hw/kdrive/epson/epson13806reg.h
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2004 by Costas Stylianou <costas.stylianou@psion.com> +44(0)7850 394095
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Costas Sylianou not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Costas Stylianou makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL COSTAS STYLIANOU BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+ * epson13806reg.h Epson S1D13806 LCD controller header file.
+ *
+ * History:
+ * 15-Feb-04 C.Stylianou PRJ NBL: Created.
+ *
+ */
+
+
+#ifndef EPSON13806REG_H
+#define EPSON13806REG_H
+
+
+#define TT_UNUSED(x) ((void) (x))
+
+
+#define EPSON13806_PHYSICAL_REG_ADDR 0x14000000
+#define EPSON13806_GPIO_REGSIZE 0x001f0000
+
+#define EPSON13806_PHYSICAL_VMEM_ADDR 0x14200000
+#define EPSON13806_VMEM_SIZE 0x140000
+
+#define PLATFORM_EPSON13806_BASE (regbase)
+#define EPSON13806_REG_BASE (PLATFORM_EPSON13806_BASE + 0x000000) // Register base address
+#define EPSON13806_SDRAM_BASE (PLATFORM_EPSON13806_BASE + 0x200000) // SDRAM base address
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Register Offsets
+//////////////////////////////////////////////////////////////////////////////////////////
+#define EPSON13806_REVCODE (EPSON13806_REG_BASE + 0x0000) // Revision Code Register
+#define EPSON13806_MISC (EPSON13806_REG_BASE + 0x0001) // Miscellaneous Register
+#define EPSON13806_GPIOCFG (EPSON13806_REG_BASE + 0x0004) // General IO Pins Configuration Register (16 bits)
+#define EPSON13806_GPIOCFG0 (EPSON13806_REG_BASE + 0x0004) // General IO Pins Configuration Register 0
+#define EPSON13806_GPIOCFG1 (EPSON13806_REG_BASE + 0x0005) // General IO Pins Configuration Register 1
+#define EPSON13806_GPIOCTRL (EPSON13806_REG_BASE + 0x0008) // General IO Pins Control Register (16 bits)
+#define EPSON13806_GPIOCTRL0 (EPSON13806_REG_BASE + 0x0008) // General IO Pins Control Register 0
+#define EPSON13806_GPIOCTRL1 (EPSON13806_REG_BASE + 0x0009) // General IO Pins Control Register 1
+#define EPSON13806_MDCFGSTATUS (EPSON13806_REG_BASE + 0x000C) // Configuration Status Register
+#define EPSON13806_MEMCLKCFG (EPSON13806_REG_BASE + 0x0010) // Memory Clock Configuration Register
+#define EPSON13806_LCDPCLKCFG (EPSON13806_REG_BASE + 0x0014) // LCD Pixel Clock Configuration Register
+#define EPSON13806_CRTPCLKCFG (EPSON13806_REG_BASE + 0x0018) // CRT/TV Clock Configuration Register
+#define EPSON13806_MPCLKCFG (EPSON13806_REG_BASE + 0x001C) // MediaPlug Clock Configuration Register
+#define EPSON13806_CPUMEMWAITSEL (EPSON13806_REG_BASE + 0x001E) // CPU To Memory Wait State Select Register
+#define EPSON13806_MEMCFG (EPSON13806_REG_BASE + 0x0020) // Memory Configuration Register
+#define EPSON13806_DRAMREFRESH (EPSON13806_REG_BASE + 0x0021) // DRAM Refresh Rate Register
+#define EPSON13806_DRAMTIMINGCTRL (EPSON13806_REG_BASE + 0x002A) // DRAM Timings Control Register (16 bits)
+#define EPSON13806_DRAMTIMINGCTRL0 (EPSON13806_REG_BASE + 0x002A) // DRAM Timings Control Register 0
+#define EPSON13806_DRAMTIMINGCTRL1 (EPSON13806_REG_BASE + 0x002B) // DRAM Timings Control Register 1
+#define EPSON13806_PANELTYPE (EPSON13806_REG_BASE + 0x0030) // Panel Type Register
+#define EPSON13806_MODRATE (EPSON13806_REG_BASE + 0x0031) // MOD Rate Register
+#define EPSON13806_LCDHDP (EPSON13806_REG_BASE + 0x0032) // LCD Horizontal Display Width Register
+#define EPSON13806_LCDHNDP (EPSON13806_REG_BASE + 0x0034) // LCD Horizontal Non-Display Period Register
+#define EPSON13806_TFTFPLINESTART (EPSON13806_REG_BASE + 0x0035) // TFT FPLINE Start Position Register
+#define EPSON13806_TFTFPLINEPULSE (EPSON13806_REG_BASE + 0x0036) // TFT FPLINE Pulse Width Register
+#define EPSON13806_LCDVDP (EPSON13806_REG_BASE + 0x0038) // LCD Vertical Display Height Register (16 bits)
+#define EPSON13806_LCDVDP0 (EPSON13806_REG_BASE + 0x0038) // LCD Vertical Display Height Register 0
+#define EPSON13806_LCDVDP1 (EPSON13806_REG_BASE + 0x0039) // LCD Vertical Display Height Register 1
+#define EPSON13806_LCDVNDP (EPSON13806_REG_BASE + 0x003A) // LCD Vertical Non-Display Period Register
+#define EPSON13806_TFTFPFRAMESTART (EPSON13806_REG_BASE + 0x003B) // TFT FPFRAME Start Position Register
+#define EPSON13806_TFTFPFRAMEPULSE (EPSON13806_REG_BASE + 0x003C) // TFT FPFRAME Pulse Width Register
+#define EPSON13806_LCDLINECOUNT (EPSON13806_REG_BASE + 0x003E) // LCD Line Count Register (16 bits)
+#define EPSON13806_LCDLINECOUNT0 (EPSON13806_REG_BASE + 0x003E) // LCD Line Count Register 0
+#define EPSON13806_LCDLINECOUNT1 (EPSON13806_REG_BASE + 0x003F) // LCD Line Count Register 1
+#define EPSON13806_LCDDISPMODE (EPSON13806_REG_BASE + 0x0040) // LCD Display Mode Register
+#define EPSON13806_LCDMISC (EPSON13806_REG_BASE + 0x0041) // LCD Miscellaneous Register
+#define EPSON13806_LCDSTART01 (EPSON13806_REG_BASE + 0x0042) // LCD Display Start Address Register 0 and 1 (16 bits)
+#define EPSON13806_LCDSTART0 (EPSON13806_REG_BASE + 0x0042) // LCD Display Start Address Register 0
+#define EPSON13806_LCDSTART1 (EPSON13806_REG_BASE + 0x0043) // LCD Display Start Address Register 1
+#define EPSON13806_LCDSTART2 (EPSON13806_REG_BASE + 0x0044) // LCD Display Start Address Register 2
+#define EPSON13806_LCDSTRIDE (EPSON13806_REG_BASE + 0x0046) // LCD Memory Address Offset Register (16 bits)
+#define EPSON13806_LCDSTRIDE0 (EPSON13806_REG_BASE + 0x0046) // LCD Memory Address Offset Register 0
+#define EPSON13806_LCDSTRIDE1 (EPSON13806_REG_BASE + 0x0047) // LCD Memory Address Offset Register 1
+#define EPSON13806_LCDPIXELPAN (EPSON13806_REG_BASE + 0x0048) // LCD Pixel Panning Register
+#define EPSON13806_LCDFIFOHIGH (EPSON13806_REG_BASE + 0x004A) // LCD Display FIFO High Threshold Control Register
+#define EPSON13806_LCDFIFOLOW (EPSON13806_REG_BASE + 0x004B) // LCD Display FIFO Low Threshold Control Register
+
+#define EPSON13806_LCDINKCURSCTRL (EPSON13806_REG_BASE + 0x0070) // LCD INK/Cursor Control Register
+#define EPSON13806_LCDINKCURSSTART (EPSON13806_REG_BASE + 0x0071) // LCD INK/Cursor Start Address Register
+#define EPSON13806_LCDCURSORXPOS (EPSON13806_REG_BASE + 0x0072) // LCD Cursor X Position Register (16 bits)
+#define EPSON13806_LCDCURSORXPOS0 (EPSON13806_REG_BASE + 0x0072) // LCD Cursor X Position Register 0
+#define EPSON13806_LCDCURSORXPOS1 (EPSON13806_REG_BASE + 0x0073) // LCD Cursor X Position Register 1
+#define EPSON13806_LCDCURSORYPOS (EPSON13806_REG_BASE + 0x0074) // LCD Cursor Y Position Register (16 bits)
+#define EPSON13806_LCDCURSORYPOS0 (EPSON13806_REG_BASE + 0x0074) // LCD Cursor Y Position Register 0
+#define EPSON13806_LCDCURSORYPOS1 (EPSON13806_REG_BASE + 0x0075) // LCD Cursor Y Position Register 1
+#define EPSON13806_LCDINKCURSBLUE0 (EPSON13806_REG_BASE + 0x0076) // LCD INK/Cursor Blue Color 0 Register
+#define EPSON13806_LCDINKCURSGREEN0 (EPSON13806_REG_BASE + 0x0077) // LCD INK/Cursor Green Color 0 Register
+#define EPSON13806_LCDINKCURSRED0 (EPSON13806_REG_BASE + 0x0078) // LCD INK/Cursor Red Color 0 Register
+#define EPSON13806_LCDINKCURSBLUE1 (EPSON13806_REG_BASE + 0x007A) // LCD INK/Cursor Blue Color 1 Register
+#define EPSON13806_LCDINKCURSGREEN1 (EPSON13806_REG_BASE + 0x007B) // LCD INK/Cursor Green Colour 1 Register
+#define EPSON13806_LCDINKCURSRED1 (EPSON13806_REG_BASE + 0x007C) // LCD INK/Cursor Red Color 1 Register
+#define EPSON13806_LCDINKCURSFIFO (EPSON13806_REG_BASE + 0x007E) // LCD INK/Cursor FIFO Threshold Register
+
+#define EPSON13806_BLTCTRL0 (EPSON13806_REG_BASE + 0x0100) // BitBlt Control Register 0
+#define EPSON13806_BLTCTRL1 (EPSON13806_REG_BASE + 0x0101) // BitBlt Control Register 1
+#define EPSON13806_BLTROP (EPSON13806_REG_BASE + 0x0102) // BitBlt ROP Code/Color Expansion Register
+#define EPSON13806_BLTOPERATION (EPSON13806_REG_BASE + 0x0103) // BitBlt Operation Register
+#define EPSON13806_BLTSRCSTART01 (EPSON13806_REG_BASE + 0x0104) // BitBlt Source Start Address Register 0 and 1 (16 bits)
+#define EPSON13806_BLTSRCSTART0 (EPSON13806_REG_BASE + 0x0104) // BitBlt Source Start Address Register 0
+#define EPSON13806_BLTSRCSTART1 (EPSON13806_REG_BASE + 0x0105) // BitBlt Source Start Address Register 1
+#define EPSON13806_BLTSRCSTART2 (EPSON13806_REG_BASE + 0x0106) // BitBlt Source Start Address Register 2
+#define EPSON13806_BLTDSTSTART01 (EPSON13806_REG_BASE + 0x0108) // BitBlt Destination Start Address Register 0 and 1 (16 bits)
+#define EPSON13806_BLTDSTSTART0 (EPSON13806_REG_BASE + 0x0108) // BitBlt Destination Start Address Register 0
+#define EPSON13806_BLTDSTSTART1 (EPSON13806_REG_BASE + 0x0109) // BitBlt Destination Start Address Register 1
+#define EPSON13806_BLTDSTSTART2 (EPSON13806_REG_BASE + 0x010A) // BitBlt Destination Start Address Register 2
+#define EPSON13806_BLTSTRIDE (EPSON13806_REG_BASE + 0x010C) // BitBlt Memory Address Offset Register (16 bits)
+#define EPSON13806_BLTSTRIDE0 (EPSON13806_REG_BASE + 0x010C) // BitBlt Memory Address Offset Register 0
+#define EPSON13806_BLTSTRIDE1 (EPSON13806_REG_BASE + 0x010D) // BitBlt Memory Address Offset Register 1
+#define EPSON13806_BLTWIDTH (EPSON13806_REG_BASE + 0x0110) // BitBlt Width Register (16 bits)
+#define EPSON13806_BLTWIDTH0 (EPSON13806_REG_BASE + 0x0110) // BitBlt Width Register 0
+#define EPSON13806_BLTWIDTH1 (EPSON13806_REG_BASE + 0x0111) // BitBlt Width Register 1
+#define EPSON13806_BLTHEIGHT (EPSON13806_REG_BASE + 0x0112) // BitBlt Height Register (16 bits)
+#define EPSON13806_BLTHEIGHT0 (EPSON13806_REG_BASE + 0x0112) // BitBlt Height Register 0
+#define EPSON13806_BLTHEIGHT1 (EPSON13806_REG_BASE + 0x0113) // BitBlt Height Register 1
+#define EPSON13806_BLTBGCOLOR (EPSON13806_REG_BASE + 0x0114) // BitBlt Background Color Register (16 bits)
+#define EPSON13806_BLTBGCOLOR0 (EPSON13806_REG_BASE + 0x0114) // BitBlt Background Color Register 0
+#define EPSON13806_BLTBGCOLOR1 (EPSON13806_REG_BASE + 0x0115) // BitBlt Background Color Register 1
+#define EPSON13806_BLTFGCOLOR (EPSON13806_REG_BASE + 0x0118) // BitBlt Foreground Color Register (16 bits)
+#define EPSON13806_BLTFGCOLOR0 (EPSON13806_REG_BASE + 0x0118) // BitBlt Foreground Color Register 0
+#define EPSON13806_BLTFGCOLOR1 (EPSON13806_REG_BASE + 0x0119) // BitBlt Foreground Color Register 0
+
+#define EPSON13806_LUTMODE (EPSON13806_REG_BASE + 0x01E0) // Look-Up Table Mode Register
+#define EPSON13806_LUTADDR (EPSON13806_REG_BASE + 0x01E2) // Look-Up Table Address Register
+#define EPSON13806_LUTDATA (EPSON13806_REG_BASE + 0x01E4) // Look-Up Table Data Register
+#define EPSON13806_PWRSAVECFG (EPSON13806_REG_BASE + 0x01F0) // Power Save Configuration Register
+#define EPSON13806_PWRSAVESTATUS (EPSON13806_REG_BASE + 0x01F1) // Power Save Status Register
+#define EPSON13806_CPUMEMWATCHDOG (EPSON13806_REG_BASE + 0x01F4) // CPU-to-Memory Access Watchdog Timer Register
+#define EPSON13806_DISPMODE (EPSON13806_REG_BASE + 0x01FC) // Display Mode Register
+
+#define EPSON13806_MEDIALCMD (EPSON13806_REG_BASE + 0x1000) // MediaPlug LCMD Register
+#define EPSON13806_MEDIARESERVEDLCMD (EPSON13806_REG_BASE + 0x1002) // MediaPlug Reserved LCMD Register
+#define EPSON13806_MEDIACMD (EPSON13806_REG_BASE + 0x1004) // MediaPlug CMD Register
+#define EPSON13806_MEDIARESERVEDCMD (EPSON13806_REG_BASE + 0x1006) // MediaPlug Reserved CMD Register
+#define EPSON13806_MEDIADATA (EPSON13806_REG_BASE + 0x1008) // MediaPlug Data Registers (base)
+
+#define EPSON13806_BITBLTDATA (EPSON13806_REG_BASE + 0x100000) // BitBLT Data Registers (base)
+
+// BLTCTRL0 register defines
+#define EPSON13806_BLTCTRL0_ACTIVE (1<<7) // Read: 1=busy, 0=idle / Write: 1=start, 0=no change
+
+// BLTOPERATION register defines
+#define EPSON13806_BLTOPERATION_WRITEROP (0x00) // Write BitBLT with ROP
+#define EPSON13806_BLTOPERATION_READ (0x01) // Read BitBLT
+#define EPSON13806_BLTOPERATION_MOVEPOSROP (0x02) // Move BitBLT in positive direction with ROP
+#define EPSON13806_BLTOPERATION_MOVENEGROP (0x03) // Move BitBLT in negative direction with ROP
+#define EPSON13806_BLTOPERATION_TRANSWRITE (0x04) // Transparent Write BitBLT
+#define EPSON13806_BLTOPERATION_TRANSMOVEPOS (0x05) // Transparent Move BitBLT in positive direction
+#define EPSON13806_BLTOPERATION_PATFILLROP (0x06) // Pattern fill with ROP
+#define EPSON13806_BLTOPERATION_PATFILLTRANS (0x07) // Pattern fill with transparency
+#define EPSON13806_BLTOPERATION_COLOREXP (0x08) // Color expansion
+#define EPSON13806_BLTOPERATION_COLOREXPTRANS (0x09) // Color expansion with transparency
+#define EPSON13806_BLTOPERATION_MOVECOLOREXP (0x0A) // Move BitBLT with color expansion
+#define EPSON13806_BLTOPERATION_MOVECOLOREXPTRANS (0x0B) // Move BitBLT with color expansion and transparency
+#define EPSON13806_BLTOPERATION_SOLIDFILL (0x0C) // Solid fill
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Epson register access macros
+//////////////////////////////////////////////////////////////////////////////////////////
+#define EPSON13806_REG(address) *(VOL8 *)(address)
+#define EPSON13806_REG16(address) *(VOL16 *)(address)
+
+
+#endif // EPSON13806
diff --git a/xorg-server/hw/kdrive/epson/epson13806stub.c b/xorg-server/hw/kdrive/epson/epson13806stub.c
new file mode 100644
index 000000000..087a30fc7
--- /dev/null
+++ b/xorg-server/hw/kdrive/epson/epson13806stub.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2004 by Costas Stylianou <costas.stylianou@psion.com> +44(0)7850 394095
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Costas Sylianou not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Costas Stylianou makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL COSTAS STYLIANOU BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+ * epson13806stub.c
+ *
+ * History:
+ * 28-Jan-04 C.Stylianou PRJ NBL: Created from fbdevinit.c
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+#include <epson13806.h>
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+
+ fprintf(stderr, "Epson 13806 Tiny X Driver ver 1.01\n");
+
+ KdCardInfoAdd (&epsonFuncs, &attr, 0);
+}
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdOsAddInputDrivers ();
+ KdInitInput ();
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ return KdProcessArgument (argc, argv, i);
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+}
diff --git a/xorg-server/hw/kdrive/fake/Makefile.am b/xorg-server/hw/kdrive/fake/Makefile.am
new file mode 100644
index 000000000..76ed9fc8b
--- /dev/null
+++ b/xorg-server/hw/kdrive/fake/Makefile.am
@@ -0,0 +1,31 @@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libfake.a
+
+bin_PROGRAMS = Xfake
+
+libfake_a_SOURCES = \
+ fake.c \
+ kbd.c \
+ os.c \
+ mouse.c \
+ fake.h
+
+Xfake_SOURCES = \
+ fakeinit.c
+
+Xfake_LDADD = \
+ libfake.a \
+ @KDRIVE_LIBS@ \
+ @XSERVER_LIBS@
+
+Xfake_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+
+Xfake_DEPENDENCIES = \
+ libfake.a \
+ @KDRIVE_LOCAL_LIBS@
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/fake/Makefile.in b/xorg-server/hw/kdrive/fake/Makefile.in
new file mode 100644
index 000000000..b9c1a4fbb
--- /dev/null
+++ b/xorg-server/hw/kdrive/fake/Makefile.in
@@ -0,0 +1,715 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xfake$(EXEEXT)
+subdir = hw/kdrive/fake
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libfake_a_AR = $(AR) $(ARFLAGS)
+libfake_a_LIBADD =
+am_libfake_a_OBJECTS = fake.$(OBJEXT) kbd.$(OBJEXT) os.$(OBJEXT) \
+ mouse.$(OBJEXT)
+libfake_a_OBJECTS = $(am_libfake_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xfake_OBJECTS = fakeinit.$(OBJEXT)
+Xfake_OBJECTS = $(am_Xfake_OBJECTS)
+Xfake_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xfake_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libfake_a_SOURCES) $(Xfake_SOURCES)
+DIST_SOURCES = $(libfake_a_SOURCES) $(Xfake_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libfake.a
+libfake_a_SOURCES = \
+ fake.c \
+ kbd.c \
+ os.c \
+ mouse.c \
+ fake.h
+
+Xfake_SOURCES = \
+ fakeinit.c
+
+Xfake_LDADD = \
+ libfake.a \
+ @KDRIVE_LIBS@ \
+ @XSERVER_LIBS@
+
+Xfake_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xfake_DEPENDENCIES = \
+ libfake.a \
+ @KDRIVE_LOCAL_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/fake/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/fake/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libfake.a: $(libfake_a_OBJECTS) $(libfake_a_DEPENDENCIES)
+ -rm -f libfake.a
+ $(libfake_a_AR) libfake.a $(libfake_a_OBJECTS) $(libfake_a_LIBADD)
+ $(RANLIB) libfake.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xfake$(EXEEXT): $(Xfake_OBJECTS) $(Xfake_DEPENDENCIES)
+ @rm -f Xfake$(EXEEXT)
+ $(Xfake_LINK) $(Xfake_OBJECTS) $(Xfake_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fake.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fakeinit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kbd.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mouse.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/os.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/fake/fake.c b/xorg-server/hw/kdrive/fake/fake.c
new file mode 100644
index 000000000..6211ab871
--- /dev/null
+++ b/xorg-server/hw/kdrive/fake/fake.c
@@ -0,0 +1,484 @@
+/*
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "fake.h"
+
+extern int KdTsPhyScreen;
+
+Bool
+fakeInitialize (KdCardInfo *card, FakePriv *priv)
+{
+ priv->base = 0;
+ priv->bytes_per_line = 0;
+ return TRUE;
+}
+
+Bool
+fakeCardInit (KdCardInfo *card)
+{
+ FakePriv *priv;
+
+ priv = (FakePriv *) xalloc (sizeof (FakePriv));
+ if (!priv)
+ return FALSE;
+
+ if (!fakeInitialize (card, priv))
+ {
+ xfree (priv);
+ return FALSE;
+ }
+ card->driver = priv;
+
+ return TRUE;
+}
+
+Bool
+fakeScreenInitialize (KdScreenInfo *screen, FakeScrPriv *scrpriv)
+{
+ if (!screen->width || !screen->height)
+ {
+ screen->width = 1024;
+ screen->height = 768;
+ screen->rate = 72;
+ }
+
+ if (screen->width <= 0)
+ screen->width = 1;
+ if (screen->height <= 0)
+ screen->height = 1;
+
+ if (!screen->fb[0].depth)
+ screen->fb[0].depth = 16;
+
+ if (screen->fb[0].depth <= 8)
+ {
+ screen->fb[0].visuals = ((1 << StaticGray) |
+ (1 << GrayScale) |
+ (1 << StaticColor) |
+ (1 << PseudoColor) |
+ (1 << TrueColor) |
+ (1 << DirectColor));
+ }
+ else
+ {
+ screen->fb[0].visuals = (1 << TrueColor);
+#define Mask(o,l) (((1 << l) - 1) << o)
+ if (screen->fb[0].depth <= 15)
+ {
+ screen->fb[0].depth = 15;
+ screen->fb[0].bitsPerPixel = 16;
+ screen->fb[0].redMask = Mask (10, 5);
+ screen->fb[0].greenMask = Mask (5, 5);
+ screen->fb[0].blueMask = Mask (0, 5);
+ }
+ else if (screen->fb[0].depth <= 16)
+ {
+ screen->fb[0].depth = 16;
+ screen->fb[0].bitsPerPixel = 16;
+ screen->fb[0].redMask = Mask (11, 5);
+ screen->fb[0].greenMask = Mask (5, 6);
+ screen->fb[0].blueMask = Mask (0, 5);
+ }
+ else
+ {
+ screen->fb[0].depth = 24;
+ screen->fb[0].bitsPerPixel = 32;
+ screen->fb[0].redMask = Mask (16, 8);
+ screen->fb[0].greenMask = Mask (8, 8);
+ screen->fb[0].blueMask = Mask (0, 8);
+ }
+ }
+
+ scrpriv->randr = screen->randr;
+
+ return fakeMapFramebuffer (screen);
+}
+
+Bool
+fakeScreenInit (KdScreenInfo *screen)
+{
+ FakeScrPriv *scrpriv;
+
+ scrpriv = xalloc (sizeof (FakeScrPriv));
+ if (!scrpriv)
+ return FALSE;
+ memset (scrpriv, '\0', sizeof (FakeScrPriv));
+ screen->driver = scrpriv;
+ if (!fakeScreenInitialize (screen, scrpriv))
+ {
+ screen->driver = 0;
+ xfree (scrpriv);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void *
+fakeWindowLinear (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure)
+{
+ KdScreenPriv(pScreen);
+ FakePriv *priv = pScreenPriv->card->driver;
+
+ if (!pScreenPriv->enabled)
+ return 0;
+ *size = priv->bytes_per_line;
+ return priv->base + row * priv->bytes_per_line;
+}
+
+Bool
+fakeMapFramebuffer (KdScreenInfo *screen)
+{
+ FakeScrPriv *scrpriv = screen->driver;
+ KdPointerMatrix m;
+ FakePriv *priv = screen->card->driver;
+
+ if (scrpriv->randr != RR_Rotate_0)
+ scrpriv->shadow = TRUE;
+ else
+ scrpriv->shadow = FALSE;
+
+ KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
+
+ KdSetPointerMatrix (&m);
+
+ priv->bytes_per_line = ((screen->width * screen->fb[0].bitsPerPixel + 31) >> 5) << 2;
+ if (priv->base)
+ free (priv->base);
+ priv->base = malloc (priv->bytes_per_line * screen->height);
+ screen->memory_base = (CARD8 *) (priv->base);
+ screen->memory_size = 0;
+ screen->off_screen_base = 0;
+
+ if (scrpriv->shadow)
+ {
+ if (!KdShadowFbAlloc (screen, 0,
+ scrpriv->randr & (RR_Rotate_90|RR_Rotate_270)))
+ return FALSE;
+ }
+ else
+ {
+ screen->fb[0].byteStride = priv->bytes_per_line;
+ screen->fb[0].pixelStride = (priv->bytes_per_line * 8/
+ screen->fb[0].bitsPerPixel);
+ screen->fb[0].frameBuffer = (CARD8 *) (priv->base);
+ }
+
+ return TRUE;
+}
+
+void
+fakeSetScreenSizes (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FakeScrPriv *scrpriv = screen->driver;
+
+ if (scrpriv->randr & (RR_Rotate_0|RR_Rotate_180))
+ {
+ pScreen->width = screen->width;
+ pScreen->height = screen->height;
+ pScreen->mmWidth = screen->width_mm;
+ pScreen->mmHeight = screen->height_mm;
+ }
+ else
+ {
+ pScreen->width = screen->width;
+ pScreen->height = screen->height;
+ pScreen->mmWidth = screen->height_mm;
+ pScreen->mmHeight = screen->width_mm;
+ }
+}
+
+Bool
+fakeUnmapFramebuffer (KdScreenInfo *screen)
+{
+ FakePriv *priv = screen->card->driver;
+ KdShadowFbFree (screen, 0);
+ if (priv->base)
+ {
+ free (priv->base);
+ priv->base = 0;
+ }
+ return TRUE;
+}
+
+Bool
+fakeSetShadow (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FakeScrPriv *scrpriv = screen->driver;
+ ShadowUpdateProc update;
+ ShadowWindowProc window;
+
+ window = fakeWindowLinear;
+ update = 0;
+ if (scrpriv->randr)
+ update = shadowUpdateRotatePacked;
+ else
+ update = shadowUpdatePacked;
+ return KdShadowSet (pScreen, scrpriv->randr, update, window);
+}
+
+
+#ifdef RANDR
+Bool
+fakeRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FakeScrPriv *scrpriv = screen->driver;
+ RRScreenSizePtr pSize;
+ Rotation randr;
+ int n;
+
+ *rotations = RR_Rotate_All|RR_Reflect_All;
+
+ for (n = 0; n < pScreen->numDepths; n++)
+ if (pScreen->allowedDepths[n].numVids)
+ break;
+ if (n == pScreen->numDepths)
+ return FALSE;
+
+ pSize = RRRegisterSize (pScreen,
+ screen->width,
+ screen->height,
+ screen->width_mm,
+ screen->height_mm);
+
+ randr = KdSubRotation (scrpriv->randr, screen->randr);
+
+ RRSetCurrentConfig (pScreen, randr, 0, pSize);
+
+ return TRUE;
+}
+
+Bool
+fakeRandRSetConfig (ScreenPtr pScreen,
+ Rotation randr,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FakeScrPriv *scrpriv = screen->driver;
+ Bool wasEnabled = pScreenPriv->enabled;
+ FakeScrPriv oldscr;
+ int oldwidth;
+ int oldheight;
+ int oldmmwidth;
+ int oldmmheight;
+ int newwidth, newheight;
+
+ if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
+ {
+ newwidth = pSize->width;
+ newheight = pSize->height;
+ }
+ else
+ {
+ newwidth = pSize->height;
+ newheight = pSize->width;
+ }
+
+ if (wasEnabled)
+ KdDisableScreen (pScreen);
+
+ oldscr = *scrpriv;
+
+ oldwidth = screen->width;
+ oldheight = screen->height;
+ oldmmwidth = pScreen->mmWidth;
+ oldmmheight = pScreen->mmHeight;
+
+ /*
+ * Set new configuration
+ */
+
+ scrpriv->randr = KdAddRotation (screen->randr, randr);
+
+ KdOffscreenSwapOut (screen->pScreen);
+
+ fakeUnmapFramebuffer (screen);
+
+ if (!fakeMapFramebuffer (screen))
+ goto bail4;
+
+ KdShadowUnset (screen->pScreen);
+
+ if (!fakeSetShadow (screen->pScreen))
+ goto bail4;
+
+ fakeSetScreenSizes (screen->pScreen);
+
+ /*
+ * Set frame buffer mapping
+ */
+ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
+ pScreen->width,
+ pScreen->height,
+ screen->fb[0].depth,
+ screen->fb[0].bitsPerPixel,
+ screen->fb[0].byteStride,
+ screen->fb[0].frameBuffer);
+
+ /* set the subpixel order */
+
+ KdSetSubpixelOrder (pScreen, scrpriv->randr);
+ if (wasEnabled)
+ KdEnableScreen (pScreen);
+
+ return TRUE;
+
+bail4:
+ fakeUnmapFramebuffer (screen);
+ *scrpriv = oldscr;
+ (void) fakeMapFramebuffer (screen);
+ pScreen->width = oldwidth;
+ pScreen->height = oldheight;
+ pScreen->mmWidth = oldmmwidth;
+ pScreen->mmHeight = oldmmheight;
+
+ if (wasEnabled)
+ KdEnableScreen (pScreen);
+ return FALSE;
+}
+
+Bool
+fakeRandRInit (ScreenPtr pScreen)
+{
+ rrScrPrivPtr pScrPriv;
+
+ if (!RRScreenInit (pScreen))
+ return FALSE;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+ pScrPriv->rrGetInfo = fakeRandRGetInfo;
+ pScrPriv->rrSetConfig = fakeRandRSetConfig;
+ return TRUE;
+}
+#endif
+
+Bool
+fakeCreateColormap (ColormapPtr pmap)
+{
+ return fbInitializeColormap (pmap);
+}
+
+Bool
+fakeInitScreen (ScreenPtr pScreen)
+{
+#ifdef TOUCHSCREEN
+ KdTsPhyScreen = pScreen->myNum;
+#endif
+
+ pScreen->CreateColormap = fakeCreateColormap;
+ return TRUE;
+}
+
+Bool
+fakeFinishInitScreen (ScreenPtr pScreen)
+{
+ if (!shadowSetup (pScreen))
+ return FALSE;
+
+#ifdef RANDR
+ if (!fakeRandRInit (pScreen))
+ return FALSE;
+#endif
+
+ return TRUE;
+}
+
+
+Bool
+fakeCreateResources (ScreenPtr pScreen)
+{
+ return fakeSetShadow (pScreen);
+}
+
+void
+fakePreserve (KdCardInfo *card)
+{
+}
+
+Bool
+fakeEnable (ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+Bool
+fakeDPMS (ScreenPtr pScreen, int mode)
+{
+ return TRUE;
+}
+
+void
+fakeDisable (ScreenPtr pScreen)
+{
+}
+
+void
+fakeRestore (KdCardInfo *card)
+{
+}
+
+void
+fakeScreenFini (KdScreenInfo *screen)
+{
+}
+
+void
+fakeCardFini (KdCardInfo *card)
+{
+ FakePriv *priv = card->driver;
+
+ if (priv->base)
+ free (priv->base);
+ xfree (priv);
+}
+
+void
+fakeGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ while (n--)
+ {
+ pdefs->red = 0;
+ pdefs->green = 0;
+ pdefs->blue = 0;
+ pdefs++;
+ }
+}
+
+void
+fakePutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+}
diff --git a/xorg-server/hw/kdrive/fake/fake.h b/xorg-server/hw/kdrive/fake/fake.h
new file mode 100644
index 000000000..88d209674
--- /dev/null
+++ b/xorg-server/hw/kdrive/fake/fake.h
@@ -0,0 +1,137 @@
+/*
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _FBDEV_H_
+#define _FBDEV_H_
+#include <stdio.h>
+#include <unistd.h>
+#include "kdrive.h"
+
+#ifdef RANDR
+#include "randrstr.h"
+#endif
+
+typedef struct _fakePriv {
+ CARD8 *base;
+ int bytes_per_line;
+} FakePriv;
+
+typedef struct _fakeScrPriv {
+ Rotation randr;
+ Bool shadow;
+ PixmapPtr pShadow;
+} FakeScrPriv;
+
+extern KdCardFuncs fakeFuncs;
+
+Bool
+fakeInitialize (KdCardInfo *card, FakePriv *priv);
+
+Bool
+fakeCardInit (KdCardInfo *card);
+
+Bool
+fakeScreenInit (KdScreenInfo *screen);
+
+Bool
+fakeScreenInitialize (KdScreenInfo *screen, FakeScrPriv *scrpriv);
+
+Bool
+fakeInitScreen (ScreenPtr pScreen);
+
+Bool
+fakeFinishInitScreen (ScreenPtr pScreen);
+
+Bool
+fakeCreateResources (ScreenPtr pScreen);
+
+void
+fakePreserve (KdCardInfo *card);
+
+Bool
+fakeEnable (ScreenPtr pScreen);
+
+Bool
+fakeDPMS (ScreenPtr pScreen, int mode);
+
+void
+fakeDisable (ScreenPtr pScreen);
+
+void
+fakeRestore (KdCardInfo *card);
+
+void
+fakeScreenFini (KdScreenInfo *screen);
+
+void
+fakeCardFini (KdCardInfo *card);
+
+void
+fakeGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+
+void
+fakePutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+
+Bool
+fakeMapFramebuffer (KdScreenInfo *screen);
+
+void *
+fakeWindowLinear (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure);
+
+void
+fakeSetScreenSizes (ScreenPtr pScreen);
+
+Bool
+fakeUnmapFramebuffer (KdScreenInfo *screen);
+
+Bool
+fakeSetShadow (ScreenPtr pScreen);
+
+Bool
+fakeCreateColormap (ColormapPtr pmap);
+
+#ifdef RANDR
+Bool
+fakeRandRGetInfo (ScreenPtr pScreen, Rotation *rotations);
+
+Bool
+fakeRandRSetConfig (ScreenPtr pScreen,
+ Rotation randr,
+ int rate,
+ RRScreenSizePtr pSize);
+Bool
+fakeRandRInit (ScreenPtr pScreen);
+
+#endif
+
+extern KdPointerDriver FakePointerDriver;
+
+extern KdKeyboardDriver FakeKeyboardDriver;
+
+extern KdOsFuncs FakeOsFuncs;
+
+#endif /* _FBDEV_H_ */
diff --git a/xorg-server/hw/kdrive/fake/fakeinit.c b/xorg-server/hw/kdrive/fake/fakeinit.c
new file mode 100644
index 000000000..2cfcbedd5
--- /dev/null
+++ b/xorg-server/hw/kdrive/fake/fakeinit.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "fake.h"
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+
+ KdCardInfoAdd (&fakeFuncs, &attr, 0);
+}
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdPointerInfo *pi;
+ KdKeyboardInfo *ki;
+
+ pi = KdNewPointer ();
+ if (!pi)
+ return;
+ pi->driver = &FakePointerDriver;
+ KdAddPointer(pi);
+
+ ki = KdNewKeyboard ();
+ if (!ki)
+ return;
+ ki->driver = &FakeKeyboardDriver;
+ KdAddKeyboard(ki);
+
+ KdInitInput ();
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ return KdProcessArgument (argc, argv, i);
+}
+
+void
+OsVendorInit (void)
+{
+ KdOsInit (&FakeOsFuncs);
+}
+
+KdCardFuncs fakeFuncs = {
+ fakeCardInit, /* cardinit */
+ fakeScreenInit, /* scrinit */
+ fakeInitScreen, /* initScreen */
+ fakeFinishInitScreen, /* finishInitScreen */
+ fakeCreateResources, /* createRes */
+ fakePreserve, /* preserve */
+ fakeEnable, /* enable */
+ fakeDPMS, /* dpms */
+ fakeDisable, /* disable */
+ fakeRestore, /* restore */
+ fakeScreenFini, /* scrfini */
+ fakeCardFini, /* cardfini */
+
+ 0, /* initCursor */
+ 0, /* enableCursor */
+ 0, /* disableCursor */
+ 0, /* finiCursor */
+ 0, /* recolorCursor */
+
+ 0, /* initAccel */
+ 0, /* enableAccel */
+ 0, /* disableAccel */
+ 0, /* finiAccel */
+
+ fakeGetColors, /* getColors */
+ fakePutColors, /* putColors */
+};
diff --git a/xorg-server/hw/kdrive/fake/kbd.c b/xorg-server/hw/kdrive/fake/kbd.c
new file mode 100644
index 000000000..83c1b3b20
--- /dev/null
+++ b/xorg-server/hw/kdrive/fake/kbd.c
@@ -0,0 +1,208 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "fake.h"
+#include <X11/keysym.h>
+
+#define FAKE_WIDTH 2
+
+KeySym FakeKeymap[] = {
+/* 1 8 */ XK_Escape, NoSymbol,
+/* 2 9 */ XK_1, XK_exclam,
+/* 3 10 */ XK_2, XK_at,
+/* 4 11 */ XK_3, XK_numbersign,
+/* 5 12 */ XK_4, XK_dollar,
+/* 6 13 */ XK_5, XK_percent,
+/* 7 14 */ XK_6, XK_asciicircum,
+/* 8 15 */ XK_7, XK_ampersand,
+/* 9 16 */ XK_8, XK_asterisk,
+/* 10 17 */ XK_9, XK_parenleft,
+/* 11 18 */ XK_0, XK_parenright,
+/* 12 19 */ XK_minus, XK_underscore,
+/* 13 20 */ XK_equal, XK_plus,
+/* 14 21 */ XK_BackSpace, NoSymbol,
+/* 15 22 */ XK_Tab, NoSymbol,
+/* 16 23 */ XK_Q, NoSymbol,
+/* 17 24 */ XK_W, NoSymbol,
+/* 18 25 */ XK_E, NoSymbol,
+/* 19 26 */ XK_R, NoSymbol,
+/* 20 27 */ XK_T, NoSymbol,
+/* 21 28 */ XK_Y, NoSymbol,
+/* 22 29 */ XK_U, NoSymbol,
+/* 23 30 */ XK_I, NoSymbol,
+/* 24 31 */ XK_O, NoSymbol,
+/* 25 32 */ XK_P, NoSymbol,
+/* 26 33 */ XK_bracketleft, XK_braceleft,
+/* 27 34 */ XK_bracketright, XK_braceright,
+/* 28 35 */ XK_Return, NoSymbol,
+/* 29 36 */ XK_Control_L, NoSymbol,
+/* 30 37 */ XK_A, NoSymbol,
+/* 31 38 */ XK_S, NoSymbol,
+/* 32 39 */ XK_D, NoSymbol,
+/* 33 40 */ XK_F, NoSymbol,
+/* 34 41 */ XK_G, NoSymbol,
+/* 35 42 */ XK_H, NoSymbol,
+/* 36 43 */ XK_J, NoSymbol,
+/* 37 44 */ XK_K, NoSymbol,
+/* 38 45 */ XK_L, NoSymbol,
+/* 39 46 */ XK_semicolon, XK_colon,
+/* 40 47 */ XK_apostrophe, XK_quotedbl,
+/* 41 48 */ XK_grave, XK_asciitilde,
+/* 42 49 */ XK_Shift_L, NoSymbol,
+/* 43 50 */ XK_backslash, XK_bar,
+/* 44 51 */ XK_Z, NoSymbol,
+/* 45 52 */ XK_X, NoSymbol,
+/* 46 53 */ XK_C, NoSymbol,
+/* 47 54 */ XK_V, NoSymbol,
+/* 48 55 */ XK_B, NoSymbol,
+/* 49 56 */ XK_N, NoSymbol,
+/* 50 57 */ XK_M, NoSymbol,
+/* 51 58 */ XK_comma, XK_less,
+/* 52 59 */ XK_period, XK_greater,
+/* 53 60 */ XK_slash, XK_question,
+/* 54 61 */ XK_Shift_R, NoSymbol,
+/* 55 62 */ XK_KP_Multiply, NoSymbol,
+/* 56 63 */ XK_Alt_L, XK_Meta_L,
+/* 57 64 */ XK_space, NoSymbol,
+/* 58 65 */ XK_Caps_Lock, NoSymbol,
+/* 59 66 */ XK_F1, NoSymbol,
+/* 60 67 */ XK_F2, NoSymbol,
+/* 61 68 */ XK_F3, NoSymbol,
+/* 62 69 */ XK_F4, NoSymbol,
+/* 63 70 */ XK_F5, NoSymbol,
+/* 64 71 */ XK_F6, NoSymbol,
+/* 65 72 */ XK_F7, NoSymbol,
+/* 66 73 */ XK_F8, NoSymbol,
+/* 67 74 */ XK_F9, NoSymbol,
+/* 68 75 */ XK_F10, NoSymbol,
+/* 69 76 */ XK_Break, XK_Pause,
+/* 70 77 */ XK_Scroll_Lock, NoSymbol,
+/* 71 78 */ XK_KP_Home, XK_KP_7,
+/* 72 79 */ XK_KP_Up, XK_KP_8,
+/* 73 80 */ XK_KP_Page_Up, XK_KP_9,
+/* 74 81 */ XK_KP_Subtract, NoSymbol,
+/* 75 82 */ XK_KP_Left, XK_KP_4,
+/* 76 83 */ XK_KP_5, NoSymbol,
+/* 77 84 */ XK_KP_Right, XK_KP_6,
+/* 78 85 */ XK_KP_Add, NoSymbol,
+/* 79 86 */ XK_KP_End, XK_KP_1,
+/* 80 87 */ XK_KP_Down, XK_KP_2,
+/* 81 88 */ XK_KP_Page_Down, XK_KP_3,
+/* 82 89 */ XK_KP_Insert, XK_KP_0,
+/* 83 90 */ XK_KP_Delete, XK_KP_Decimal,
+/* 84 91 */ NoSymbol, NoSymbol,
+/* 85 92 */ NoSymbol, NoSymbol,
+/* 86 93 */ NoSymbol, NoSymbol,
+/* 87 94 */ XK_F11, NoSymbol,
+/* 88 95 */ XK_F12, NoSymbol,
+
+/* These are remapped from the extended set (using ExtendMap) */
+
+/* 89 96 */ XK_Control_R, NoSymbol,
+/* 90 97 */ XK_KP_Enter, NoSymbol,
+/* 91 98 */ XK_KP_Divide, NoSymbol,
+/* 92 99 */ XK_Sys_Req, XK_Print,
+/* 93 100 */ XK_Alt_R, XK_Meta_R,
+/* 94 101 */ XK_Num_Lock, NoSymbol,
+/* 95 102 */ XK_Home, NoSymbol,
+/* 96 103 */ XK_Up, NoSymbol,
+/* 97 104 */ XK_Page_Up, NoSymbol,
+/* 98 105 */ XK_Left, NoSymbol,
+/* 99 106 */ XK_Right, NoSymbol,
+/* 100 107 */ XK_End, NoSymbol,
+/* 101 108 */ XK_Down, NoSymbol,
+/* 102 109 */ XK_Page_Down, NoSymbol,
+/* 103 110 */ XK_Insert, NoSymbol,
+/* 104 111 */ XK_Delete, NoSymbol,
+/* 105 112 */ XK_Super_L, NoSymbol,
+/* 106 113 */ XK_Super_R, NoSymbol,
+/* 107 114 */ XK_Menu, NoSymbol,
+
+/* 108 115 */ XK_Next, NoSymbol, /* right button on side */
+/* 109 116 */ XK_Prior, NoSymbol, /* left button on side */
+/* 110 117 */ XK_Up, NoSymbol, /* joypad */
+/* 111 118 */ XK_Down, NoSymbol,
+/* 112 119 */ XK_Left, NoSymbol,
+/* 113 120 */ XK_Right, NoSymbol,
+/* 114 121 */ NoSymbol, NoSymbol, /* left near speaker */
+/* 115 122 */ NoSymbol, NoSymbol, /* right near speaker */
+/* 116 123 */ NoSymbol, NoSymbol, /* tiny button */
+};
+
+static Status
+FakeKeyboardInit (KdKeyboardInfo *ki)
+{
+ ki->keySyms.minKeyCode = 1;
+ ki->keySyms.maxKeyCode = (sizeof (FakeKeymap) / sizeof (FakeKeymap[0])) / FAKE_WIDTH;
+ ki->keySyms.mapWidth = FAKE_WIDTH;
+ if (ki->keySyms.map)
+ xfree(ki->keySyms.map);
+ ki->keySyms.map = (KeySym *)xalloc(sizeof(FakeKeymap));
+ if (!ki->keySyms.map)
+ return BadAlloc;
+ memcpy (ki->keySyms.map, FakeKeymap, sizeof (FakeKeymap));
+
+ return Success;
+}
+
+static Status
+FakeKeyboardEnable (KdKeyboardInfo *ki)
+{
+ return Success;
+}
+
+static void
+FakeKeyboardDisable (KdKeyboardInfo *ki)
+{
+ return;
+}
+
+static void
+FakeKeyboardFini (KdKeyboardInfo *ki)
+{
+ xfree(ki->keySyms.map);
+ ki->keySyms.map = NULL;
+}
+
+static void
+FakeKeyboardLeds (KdKeyboardInfo *ki, int leds)
+{
+}
+
+static void
+FakeKeyboardBell (KdKeyboardInfo *ki, int volume, int frequency, int duration)
+{
+}
+
+KdKeyboardDriver FakeKeyboardDriver = {
+ "fake",
+ FakeKeyboardInit,
+ FakeKeyboardEnable,
+ FakeKeyboardLeds,
+ FakeKeyboardBell,
+ FakeKeyboardDisable,
+ FakeKeyboardFini,
+ NULL,
+};
diff --git a/xorg-server/hw/kdrive/fake/mouse.c b/xorg-server/hw/kdrive/fake/mouse.c
new file mode 100644
index 000000000..4b8d2b06d
--- /dev/null
+++ b/xorg-server/hw/kdrive/fake/mouse.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#define NEED_EVENTS
+#include <errno.h>
+#include <termios.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xpoll.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "kdrive.h"
+
+static Status
+MouseInit (KdPointerInfo *pi)
+{
+ return Success;
+}
+
+static Status
+MouseEnable (KdPointerInfo *pi)
+{
+ return Success;
+}
+
+static void
+MouseDisable (KdPointerInfo *pi)
+{
+ return;
+}
+
+static void
+MouseFini (KdPointerInfo *pi)
+{
+ return;
+}
+
+
+KdPointerDriver FakePointerDriver = {
+ "fake",
+ MouseInit,
+ MouseEnable,
+ MouseDisable,
+ MouseFini,
+};
diff --git a/xorg-server/hw/kdrive/fake/os.c b/xorg-server/hw/kdrive/fake/os.c
new file mode 100644
index 000000000..76cd9e728
--- /dev/null
+++ b/xorg-server/hw/kdrive/fake/os.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "fake.h"
+
+static int
+FakeInit (void)
+{
+ return 1;
+}
+
+static void
+FakeEnable (void)
+{
+}
+
+static Bool
+FakeSpecialKey (KeySym sym)
+{
+ return FALSE;
+}
+
+static void
+FakeDisable (void)
+{
+}
+
+static void
+FakeFini (void)
+{
+}
+
+KdOsFuncs FakeOsFuncs = {
+ FakeInit,
+ FakeEnable,
+ FakeSpecialKey,
+ FakeDisable,
+ FakeFini,
+ 0
+};
+
diff --git a/xorg-server/hw/kdrive/fbdev/Makefile.am b/xorg-server/hw/kdrive/fbdev/Makefile.am
new file mode 100644
index 000000000..cb1292802
--- /dev/null
+++ b/xorg-server/hw/kdrive/fbdev/Makefile.am
@@ -0,0 +1,29 @@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libfbdev.a
+
+libfbdev_a_SOURCES = \
+ fbdev.c \
+ fbdev.h
+
+if KDRIVEFBDEV
+bin_PROGRAMS = Xfbdev
+
+Xfbdev_SOURCES = \
+ fbinit.c
+
+Xfbdev_LDADD = \
+ libfbdev.a \
+ @KDRIVE_LIBS@
+
+Xfbdev_DEPENDENCIES = \
+ libfbdev.a \
+ $(KDRIVE_PURE_LIBS)
+
+Xfbdev_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+endif
diff --git a/xorg-server/hw/kdrive/fbdev/Makefile.in b/xorg-server/hw/kdrive/fbdev/Makefile.in
new file mode 100644
index 000000000..687f1171d
--- /dev/null
+++ b/xorg-server/hw/kdrive/fbdev/Makefile.in
@@ -0,0 +1,708 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@KDRIVEFBDEV_TRUE@bin_PROGRAMS = Xfbdev$(EXEEXT)
+subdir = hw/kdrive/fbdev
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libfbdev_a_AR = $(AR) $(ARFLAGS)
+libfbdev_a_LIBADD =
+am_libfbdev_a_OBJECTS = fbdev.$(OBJEXT)
+libfbdev_a_OBJECTS = $(am_libfbdev_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am__Xfbdev_SOURCES_DIST = fbinit.c
+@KDRIVEFBDEV_TRUE@am_Xfbdev_OBJECTS = fbinit.$(OBJEXT)
+Xfbdev_OBJECTS = $(am_Xfbdev_OBJECTS)
+Xfbdev_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xfbdev_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libfbdev_a_SOURCES) $(Xfbdev_SOURCES)
+DIST_SOURCES = $(libfbdev_a_SOURCES) $(am__Xfbdev_SOURCES_DIST)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libfbdev.a
+libfbdev_a_SOURCES = \
+ fbdev.c \
+ fbdev.h
+
+@KDRIVEFBDEV_TRUE@Xfbdev_SOURCES = \
+@KDRIVEFBDEV_TRUE@ fbinit.c
+
+@KDRIVEFBDEV_TRUE@Xfbdev_LDADD = \
+@KDRIVEFBDEV_TRUE@ libfbdev.a \
+@KDRIVEFBDEV_TRUE@ @KDRIVE_LIBS@
+
+@KDRIVEFBDEV_TRUE@Xfbdev_DEPENDENCIES = \
+@KDRIVEFBDEV_TRUE@ libfbdev.a \
+@KDRIVEFBDEV_TRUE@ $(KDRIVE_PURE_LIBS)
+
+@KDRIVEFBDEV_TRUE@Xfbdev_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/fbdev/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/fbdev/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libfbdev.a: $(libfbdev_a_OBJECTS) $(libfbdev_a_DEPENDENCIES)
+ -rm -f libfbdev.a
+ $(libfbdev_a_AR) libfbdev.a $(libfbdev_a_OBJECTS) $(libfbdev_a_LIBADD)
+ $(RANLIB) libfbdev.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xfbdev$(EXEEXT): $(Xfbdev_OBJECTS) $(Xfbdev_DEPENDENCIES)
+ @rm -f Xfbdev$(EXEEXT)
+ $(Xfbdev_LINK) $(Xfbdev_OBJECTS) $(Xfbdev_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fbdev.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fbinit.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+@KDRIVEFBDEV_TRUE@relink:
+@KDRIVEFBDEV_TRUE@ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/fbdev/fbdev.c b/xorg-server/hw/kdrive/fbdev/fbdev.c
new file mode 100644
index 000000000..177be0bdc
--- /dev/null
+++ b/xorg-server/hw/kdrive/fbdev/fbdev.c
@@ -0,0 +1,821 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "fbdev.h"
+#include <sys/ioctl.h>
+
+#include <errno.h>
+
+extern int KdTsPhyScreen;
+
+char *fbdevDevicePath = NULL;
+
+Bool
+fbdevInitialize (KdCardInfo *card, FbdevPriv *priv)
+{
+ int k;
+ unsigned long off;
+
+ if (fbdevDevicePath == NULL)
+ fbdevDevicePath = "/dev/fb0";
+
+ if ((priv->fd = open(fbdevDevicePath, O_RDWR)) < 0)
+ {
+ ErrorF("Error opening framebuffer %s: %s\n",
+ fbdevDevicePath, strerror(errno));
+ return FALSE;
+ }
+
+ /* quiet valgrind */
+ memset (&priv->fix, '\0', sizeof (priv->fix));
+ if ((k=ioctl(priv->fd, FBIOGET_FSCREENINFO, &priv->fix)) < 0) {
+ perror("Error with /dev/fb ioctl FIOGET_FSCREENINFO");
+ close (priv->fd);
+ return FALSE;
+ }
+ /* quiet valgrind */
+ memset (&priv->var, '\0', sizeof (priv->var));
+ if ((k=ioctl(priv->fd, FBIOGET_VSCREENINFO, &priv->var)) < 0) {
+ perror("Error with /dev/fb ioctl FIOGET_VSCREENINFO");
+ close (priv->fd);
+ return FALSE;
+ }
+
+ priv->fb_base = (char *) mmap ((caddr_t) NULL,
+ priv->fix.smem_len,
+ PROT_READ|PROT_WRITE,
+ MAP_SHARED,
+ priv->fd, 0);
+
+ if (priv->fb_base == (char *)-1)
+ {
+ perror("ERROR: mmap framebuffer fails!");
+ close (priv->fd);
+ return FALSE;
+ }
+ off = (unsigned long) priv->fix.smem_start % (unsigned long) getpagesize();
+ priv->fb = priv->fb_base + off;
+ return TRUE;
+}
+
+Bool
+fbdevCardInit (KdCardInfo *card)
+{
+ FbdevPriv *priv;
+
+ priv = (FbdevPriv *) xalloc (sizeof (FbdevPriv));
+ if (!priv)
+ return FALSE;
+
+ if (!fbdevInitialize (card, priv))
+ {
+ xfree (priv);
+ return FALSE;
+ }
+ card->driver = priv;
+
+ return TRUE;
+}
+
+#define FBDEV_KLUDGE_FORMAT
+#ifdef FBDEV_KLUDGE_FORMAT
+static Pixel
+fbdevMakeContig (Pixel orig, Pixel others)
+{
+ Pixel low;
+
+ low = lowbit (orig) >> 1;
+ while (low && (others & low) == 0)
+ {
+ orig |= low;
+ low >>= 1;
+ }
+ return orig;
+}
+#endif
+
+static Bool
+fbdevModeSupported (KdScreenInfo *screen,
+ const KdMonitorTiming *t)
+{
+ return TRUE;
+}
+
+static void
+fbdevConvertMonitorTiming (const KdMonitorTiming *t, struct fb_var_screeninfo *var)
+{
+ memset (var, 0, sizeof (struct fb_var_screeninfo));
+
+ var->xres = t->horizontal;
+ var->yres = t->vertical;
+ var->xres_virtual = t->horizontal;
+ var->yres_virtual = t->vertical;
+ var->xoffset = 0;
+ var->yoffset = 0;
+ var->pixclock = t->clock ? 1000000000 / t->clock : 0;
+ var->left_margin = t->hbp;
+ var->right_margin = t->hfp;
+ var->upper_margin = t->vbp;
+ var->lower_margin = t->vfp;
+ var->hsync_len = t->hblank - t->hfp - t->hbp;
+ var->vsync_len = t->vblank - t->vfp - t->vbp;
+
+ var->sync = 0;
+ var->vmode = 0;
+
+ if (t->hpol == KdSyncPositive)
+ var->sync |= FB_SYNC_HOR_HIGH_ACT;
+ if (t->vpol == KdSyncPositive)
+ var->sync |= FB_SYNC_VERT_HIGH_ACT;
+}
+
+Bool
+fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv)
+{
+ FbdevPriv *priv = screen->card->driver;
+ Pixel allbits;
+ int depth;
+ Bool gray;
+ struct fb_var_screeninfo var;
+ const KdMonitorTiming *t;
+ int k;
+
+ k = ioctl (priv->fd, FBIOGET_VSCREENINFO, &var);
+
+ if (!screen->width || !screen->height)
+ {
+ if (k >= 0)
+ {
+ screen->width = var.xres;
+ screen->height = var.yres;
+ }
+ else
+ {
+ screen->width = 1024;
+ screen->height = 768;
+ }
+ screen->rate = 103; /* FIXME: should get proper value from fb driver */
+ }
+ if (!screen->fb[0].depth)
+ screen->fb[0].depth = 16;
+
+ t = KdFindMode (screen, fbdevModeSupported);
+ screen->rate = t->rate;
+ screen->width = t->horizontal;
+ screen->height = t->vertical;
+
+ /* Now try setting the mode */
+ if (k < 0 || (t->horizontal != var.xres || t->vertical != var.yres))
+ fbdevConvertMonitorTiming (t, &var);
+
+ var.activate = FB_ACTIVATE_NOW;
+ var.bits_per_pixel = screen->fb[0].depth;
+ var.nonstd = 0;
+ var.grayscale = 0;
+
+ k = ioctl (priv->fd, FBIOPUT_VSCREENINFO, &var);
+
+ if (k < 0)
+ {
+ fprintf (stderr, "error: %s\n", strerror (errno));
+ return FALSE;
+ }
+
+ /* Re-get the "fixed" parameters since they might have changed */
+ k = ioctl (priv->fd, FBIOGET_FSCREENINFO, &priv->fix);
+ if (k < 0)
+ perror ("FBIOGET_FSCREENINFO");
+
+ /* Now get the new screeninfo */
+ ioctl (priv->fd, FBIOGET_VSCREENINFO, &priv->var);
+ depth = priv->var.bits_per_pixel;
+ gray = priv->var.grayscale;
+
+ switch (priv->fix.visual) {
+ case FB_VISUAL_PSEUDOCOLOR:
+ if (gray)
+ {
+ screen->fb[0].visuals = (1 << StaticGray);
+ /* could also support GrayScale, but what's the point? */
+ }
+ else
+ {
+ screen->fb[0].visuals = ((1 << StaticGray) |
+ (1 << GrayScale) |
+ (1 << StaticColor) |
+ (1 << PseudoColor) |
+ (1 << TrueColor) |
+ (1 << DirectColor));
+ }
+ screen->fb[0].blueMask = 0x00;
+ screen->fb[0].greenMask = 0x00;
+ screen->fb[0].redMask = 0x00;
+ break;
+ case FB_VISUAL_STATIC_PSEUDOCOLOR:
+ if (gray)
+ {
+ screen->fb[0].visuals = (1 << StaticGray);
+ }
+ else
+ {
+ screen->fb[0].visuals = (1 << StaticColor);
+ }
+ screen->fb[0].blueMask = 0x00;
+ screen->fb[0].greenMask = 0x00;
+ screen->fb[0].redMask = 0x00;
+ break;
+ case FB_VISUAL_TRUECOLOR:
+ case FB_VISUAL_DIRECTCOLOR:
+ screen->fb[0].visuals = (1 << TrueColor);
+#define Mask(o,l) (((1 << l) - 1) << o)
+ screen->fb[0].redMask = Mask (priv->var.red.offset, priv->var.red.length);
+ screen->fb[0].greenMask = Mask (priv->var.green.offset, priv->var.green.length);
+ screen->fb[0].blueMask = Mask (priv->var.blue.offset, priv->var.blue.length);
+#ifdef FBDEV_KLUDGE_FORMAT
+ /*
+ * This is a kludge so that Render will work -- fill in the gaps
+ * in the pixel
+ */
+ screen->fb[0].redMask = fbdevMakeContig (screen->fb[0].redMask,
+ screen->fb[0].greenMask|
+ screen->fb[0].blueMask);
+
+ screen->fb[0].greenMask = fbdevMakeContig (screen->fb[0].greenMask,
+ screen->fb[0].redMask|
+ screen->fb[0].blueMask);
+
+ screen->fb[0].blueMask = fbdevMakeContig (screen->fb[0].blueMask,
+ screen->fb[0].redMask|
+ screen->fb[0].greenMask);
+
+#endif
+ allbits = screen->fb[0].redMask | screen->fb[0].greenMask | screen->fb[0].blueMask;
+ depth = 32;
+ while (depth && !(allbits & (1 << (depth - 1))))
+ depth--;
+ break;
+ default:
+ return FALSE;
+ break;
+ }
+ screen->fb[0].depth = depth;
+ screen->fb[0].bitsPerPixel = priv->var.bits_per_pixel;
+
+ scrpriv->randr = screen->randr;
+
+ return fbdevMapFramebuffer (screen);
+}
+
+Bool
+fbdevScreenInit (KdScreenInfo *screen)
+{
+ FbdevScrPriv *scrpriv;
+
+ scrpriv = xalloc (sizeof (FbdevScrPriv));
+ if (!scrpriv)
+ return FALSE;
+ memset (scrpriv, '\0', sizeof (FbdevScrPriv));
+ screen->driver = scrpriv;
+ if (!fbdevScreenInitialize (screen, scrpriv))
+ {
+ screen->driver = 0;
+ xfree (scrpriv);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void *
+fbdevWindowLinear (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure)
+{
+ KdScreenPriv(pScreen);
+ FbdevPriv *priv = pScreenPriv->card->driver;
+
+ if (!pScreenPriv->enabled)
+ return 0;
+ *size = priv->fix.line_length;
+ return (CARD8 *) priv->fb + row * priv->fix.line_length + offset;
+}
+
+Bool
+fbdevMapFramebuffer (KdScreenInfo *screen)
+{
+ FbdevScrPriv *scrpriv = screen->driver;
+ KdPointerMatrix m;
+ FbdevPriv *priv = screen->card->driver;
+
+ if (scrpriv->randr != RR_Rotate_0)
+ scrpriv->shadow = TRUE;
+ else
+ scrpriv->shadow = FALSE;
+
+ KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
+
+ KdSetPointerMatrix (&m);
+
+ screen->width = priv->var.xres;
+ screen->height = priv->var.yres;
+ screen->memory_base = (CARD8 *) (priv->fb);
+ screen->memory_size = priv->fix.smem_len;
+
+ if (scrpriv->shadow)
+ {
+ if (!KdShadowFbAlloc (screen, 0,
+ scrpriv->randr & (RR_Rotate_90|RR_Rotate_270)))
+ return FALSE;
+ screen->off_screen_base = screen->memory_size;
+ }
+ else
+ {
+ screen->fb[0].byteStride = priv->fix.line_length;
+ screen->fb[0].pixelStride = (priv->fix.line_length * 8 /
+ priv->var.bits_per_pixel);
+ screen->fb[0].frameBuffer = (CARD8 *) (priv->fb);
+ screen->off_screen_base = screen->fb[0].byteStride * screen->height;
+ }
+
+ return TRUE;
+}
+
+void
+fbdevSetScreenSizes (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FbdevScrPriv *scrpriv = screen->driver;
+ FbdevPriv *priv = screen->card->driver;
+
+ if (scrpriv->randr & (RR_Rotate_0|RR_Rotate_180))
+ {
+ pScreen->width = priv->var.xres;
+ pScreen->height = priv->var.yres;
+ pScreen->mmWidth = screen->width_mm;
+ pScreen->mmHeight = screen->height_mm;
+ }
+ else
+ {
+ pScreen->width = priv->var.yres;
+ pScreen->height = priv->var.xres;
+ pScreen->mmWidth = screen->height_mm;
+ pScreen->mmHeight = screen->width_mm;
+ }
+}
+
+Bool
+fbdevUnmapFramebuffer (KdScreenInfo *screen)
+{
+ KdShadowFbFree (screen, 0);
+ return TRUE;
+}
+
+Bool
+fbdevSetShadow (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FbdevScrPriv *scrpriv = screen->driver;
+ FbdevPriv *priv = screen->card->driver;
+ ShadowUpdateProc update;
+ ShadowWindowProc window;
+ int useYX = 0;
+
+#ifdef __arm__
+ /* Use variant copy routines that always read left to right in the
+ shadow framebuffer. Reading vertical strips is exceptionally
+ slow on XScale due to cache effects. */
+ useYX = 1;
+#endif
+
+ window = fbdevWindowLinear;
+ update = 0;
+ if (scrpriv->randr)
+ if (priv->var.bits_per_pixel == 16) {
+ switch (scrpriv->randr) {
+ case RR_Rotate_90:
+ if (useYX)
+ update = shadowUpdateRotate16_90YX;
+ else
+ update = shadowUpdateRotate16_90;
+ break;
+ case RR_Rotate_180:
+ update = shadowUpdateRotate16_180;
+ break;
+ case RR_Rotate_270:
+ if (useYX)
+ update = shadowUpdateRotate16_270YX;
+ else
+ update = shadowUpdateRotate16_270;
+ break;
+ default:
+ update = shadowUpdateRotate16;
+ break;
+ }
+ } else
+ update = shadowUpdateRotatePacked;
+ else
+ update = shadowUpdatePacked;
+ return KdShadowSet (pScreen, scrpriv->randr, update, window);
+}
+
+
+#ifdef RANDR
+Bool
+fbdevRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FbdevScrPriv *scrpriv = screen->driver;
+ RRScreenSizePtr pSize;
+ Rotation randr;
+ int n;
+
+ *rotations = RR_Rotate_All|RR_Reflect_All;
+
+ for (n = 0; n < pScreen->numDepths; n++)
+ if (pScreen->allowedDepths[n].numVids)
+ break;
+ if (n == pScreen->numDepths)
+ return FALSE;
+
+ pSize = RRRegisterSize (pScreen,
+ screen->width,
+ screen->height,
+ screen->width_mm,
+ screen->height_mm);
+
+ randr = KdSubRotation (scrpriv->randr, screen->randr);
+
+ RRSetCurrentConfig (pScreen, randr, 0, pSize);
+
+ return TRUE;
+}
+
+Bool
+fbdevRandRSetConfig (ScreenPtr pScreen,
+ Rotation randr,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ FbdevScrPriv *scrpriv = screen->driver;
+ Bool wasEnabled = pScreenPriv->enabled;
+ FbdevScrPriv oldscr;
+ int oldwidth;
+ int oldheight;
+ int oldmmwidth;
+ int oldmmheight;
+ int newwidth, newheight;
+
+ if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
+ {
+ newwidth = pSize->width;
+ newheight = pSize->height;
+ }
+ else
+ {
+ newwidth = pSize->height;
+ newheight = pSize->width;
+ }
+
+ if (wasEnabled)
+ KdDisableScreen (pScreen);
+
+ oldscr = *scrpriv;
+
+ oldwidth = screen->width;
+ oldheight = screen->height;
+ oldmmwidth = pScreen->mmWidth;
+ oldmmheight = pScreen->mmHeight;
+
+ /*
+ * Set new configuration
+ */
+
+ scrpriv->randr = KdAddRotation (screen->randr, randr);
+
+ KdOffscreenSwapOut (screen->pScreen);
+
+ fbdevUnmapFramebuffer (screen);
+
+ if (!fbdevMapFramebuffer (screen))
+ goto bail4;
+
+ KdShadowUnset (screen->pScreen);
+
+ if (!fbdevSetShadow (screen->pScreen))
+ goto bail4;
+
+ fbdevSetScreenSizes (screen->pScreen);
+
+ /*
+ * Set frame buffer mapping
+ */
+ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
+ pScreen->width,
+ pScreen->height,
+ screen->fb[0].depth,
+ screen->fb[0].bitsPerPixel,
+ screen->fb[0].byteStride,
+ screen->fb[0].frameBuffer);
+
+ /* set the subpixel order */
+
+ KdSetSubpixelOrder (pScreen, scrpriv->randr);
+ if (wasEnabled)
+ KdEnableScreen (pScreen);
+
+ return TRUE;
+
+bail4:
+ fbdevUnmapFramebuffer (screen);
+ *scrpriv = oldscr;
+ (void) fbdevMapFramebuffer (screen);
+ pScreen->width = oldwidth;
+ pScreen->height = oldheight;
+ pScreen->mmWidth = oldmmwidth;
+ pScreen->mmHeight = oldmmheight;
+
+ if (wasEnabled)
+ KdEnableScreen (pScreen);
+ return FALSE;
+}
+
+Bool
+fbdevRandRInit (ScreenPtr pScreen)
+{
+ rrScrPrivPtr pScrPriv;
+
+ if (!RRScreenInit (pScreen))
+ return FALSE;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+ pScrPriv->rrGetInfo = fbdevRandRGetInfo;
+ pScrPriv->rrSetConfig = fbdevRandRSetConfig;
+ return TRUE;
+}
+#endif
+
+Bool
+fbdevCreateColormap (ColormapPtr pmap)
+{
+ ScreenPtr pScreen = pmap->pScreen;
+ KdScreenPriv(pScreen);
+ FbdevPriv *priv = pScreenPriv->card->driver;
+ VisualPtr pVisual;
+ int i;
+ int nent;
+ xColorItem *pdefs;
+
+ switch (priv->fix.visual) {
+ case FB_VISUAL_STATIC_PSEUDOCOLOR:
+ pVisual = pmap->pVisual;
+ nent = pVisual->ColormapEntries;
+ pdefs = xalloc (nent * sizeof (xColorItem));
+ if (!pdefs)
+ return FALSE;
+ for (i = 0; i < nent; i++)
+ pdefs[i].pixel = i;
+ fbdevGetColors (pScreen, 0, nent, pdefs);
+ for (i = 0; i < nent; i++)
+ {
+ pmap->red[i].co.local.red = pdefs[i].red;
+ pmap->red[i].co.local.green = pdefs[i].green;
+ pmap->red[i].co.local.blue = pdefs[i].blue;
+ }
+ xfree (pdefs);
+ return TRUE;
+ default:
+ return fbInitializeColormap (pmap);
+ }
+}
+
+Bool
+fbdevInitScreen (ScreenPtr pScreen)
+{
+#ifdef TOUCHSCREEN
+ KdTsPhyScreen = pScreen->myNum;
+#endif
+
+ pScreen->CreateColormap = fbdevCreateColormap;
+ return TRUE;
+}
+
+Bool
+fbdevFinishInitScreen (ScreenPtr pScreen)
+{
+ if (!shadowSetup (pScreen))
+ return FALSE;
+
+#ifdef RANDR
+ if (!fbdevRandRInit (pScreen))
+ return FALSE;
+#endif
+
+ return TRUE;
+}
+
+
+Bool
+fbdevCreateResources (ScreenPtr pScreen)
+{
+ return fbdevSetShadow (pScreen);
+}
+
+void
+fbdevPreserve (KdCardInfo *card)
+{
+}
+
+Bool
+fbdevEnable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ FbdevPriv *priv = pScreenPriv->card->driver;
+ int k;
+
+ priv->var.activate = FB_ACTIVATE_NOW|FB_CHANGE_CMAP_VBL;
+
+ /* display it on the LCD */
+ k = ioctl (priv->fd, FBIOPUT_VSCREENINFO, &priv->var);
+ if (k < 0)
+ {
+ perror ("FBIOPUT_VSCREENINFO");
+ return FALSE;
+ }
+
+ if (priv->fix.visual == FB_VISUAL_DIRECTCOLOR)
+ {
+ struct fb_cmap cmap;
+ int i;
+
+ for (i = 0;
+ i < (1 << priv->var.red.length) ||
+ i < (1 << priv->var.green.length) ||
+ i < (1 << priv->var.blue.length); i++)
+ {
+ priv->red[i] = i * 65535 / ((1 << priv->var.red.length) - 1);
+ priv->green[i] = i * 65535 / ((1 << priv->var.green.length) - 1);
+ priv->blue[i] = i * 65535 / ((1 << priv->var.blue.length) - 1);
+ }
+ cmap.start = 0;
+ cmap.len = i;
+ cmap.red = &priv->red[0];
+ cmap.green = &priv->green[0];
+ cmap.blue = &priv->blue[0];
+ cmap.transp = 0;
+ ioctl (priv->fd, FBIOPUTCMAP, &cmap);
+ }
+ return TRUE;
+}
+
+Bool
+fbdevDPMS (ScreenPtr pScreen, int mode)
+{
+ KdScreenPriv(pScreen);
+ FbdevPriv *priv = pScreenPriv->card->driver;
+ static int oldmode = -1;
+
+ if (mode == oldmode)
+ return TRUE;
+#ifdef FBIOPUT_POWERMODE
+ if (ioctl (priv->fd, FBIOPUT_POWERMODE, &mode) >= 0)
+ {
+ oldmode = mode;
+ return TRUE;
+ }
+#endif
+#ifdef FBIOBLANK
+ if (ioctl (priv->fd, FBIOBLANK, mode ? mode + 1 : 0) >= 0)
+ {
+ oldmode = mode;
+ return TRUE;
+ }
+#endif
+ return FALSE;
+}
+
+void
+fbdevDisable (ScreenPtr pScreen)
+{
+}
+
+void
+fbdevRestore (KdCardInfo *card)
+{
+}
+
+void
+fbdevScreenFini (KdScreenInfo *screen)
+{
+}
+
+void
+fbdevCardFini (KdCardInfo *card)
+{
+ FbdevPriv *priv = card->driver;
+
+ munmap (priv->fb_base, priv->fix.smem_len);
+ close (priv->fd);
+ xfree (priv);
+}
+
+void
+fbdevGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ KdScreenPriv(pScreen);
+ FbdevPriv *priv = pScreenPriv->card->driver;
+ struct fb_cmap cmap;
+ int p;
+ int k;
+ int min, max;
+
+ min = 256;
+ max = 0;
+ for (k = 0; k < n; k++)
+ {
+ if (pdefs[k].pixel < min)
+ min = pdefs[k].pixel;
+ if (pdefs[k].pixel > max)
+ max = pdefs[k].pixel;
+ }
+ cmap.start = min;
+ cmap.len = max - min + 1;
+ cmap.red = &priv->red[min];
+ cmap.green = &priv->green[min];;
+ cmap.blue = &priv->blue[min];
+ cmap.transp = 0;
+ k = ioctl (priv->fd, FBIOGETCMAP, &cmap);
+ if (k < 0)
+ {
+ perror ("can't get colormap");
+ return;
+ }
+ while (n--)
+ {
+ p = pdefs->pixel;
+ pdefs->red = priv->red[p];
+ pdefs->green = priv->green[p];
+ pdefs->blue = priv->blue[p];
+ pdefs++;
+ }
+}
+
+void
+fbdevPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ KdScreenPriv(pScreen);
+ FbdevPriv *priv = pScreenPriv->card->driver;
+ struct fb_cmap cmap;
+ int p;
+ int min, max;
+
+ min = 256;
+ max = 0;
+ while (n--)
+ {
+ p = pdefs->pixel;
+ priv->red[p] = pdefs->red;
+ priv->green[p] = pdefs->green;
+ priv->blue[p] = pdefs->blue;
+ if (p < min)
+ min = p;
+ if (p > max)
+ max = p;
+ pdefs++;
+ }
+ cmap.start = min;
+ cmap.len = max - min + 1;
+ cmap.red = &priv->red[min];
+ cmap.green = &priv->green[min];
+ cmap.blue = &priv->blue[min];
+ cmap.transp = 0;
+ ioctl (priv->fd, FBIOPUTCMAP, &cmap);
+}
diff --git a/xorg-server/hw/kdrive/fbdev/fbdev.h b/xorg-server/hw/kdrive/fbdev/fbdev.h
new file mode 100644
index 000000000..9e322dacb
--- /dev/null
+++ b/xorg-server/hw/kdrive/fbdev/fbdev.h
@@ -0,0 +1,140 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _FBDEV_H_
+#define _FBDEV_H_
+#include <stdio.h>
+#include <linux/fb.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include "kdrive.h"
+
+#ifdef RANDR
+#include "randrstr.h"
+#endif
+
+typedef struct _fbdevPriv {
+ struct fb_var_screeninfo var;
+ struct fb_fix_screeninfo fix;
+ __u16 red[256];
+ __u16 green[256];
+ __u16 blue[256];
+ int fd;
+ char *fb;
+ char *fb_base;
+} FbdevPriv;
+
+typedef struct _fbdevScrPriv {
+ Rotation randr;
+ Bool shadow;
+ PixmapPtr pShadow;
+} FbdevScrPriv;
+
+extern KdCardFuncs fbdevFuncs;
+extern char* fbdevDevicePath;
+
+Bool
+fbdevInitialize (KdCardInfo *card, FbdevPriv *priv);
+
+Bool
+fbdevCardInit (KdCardInfo *card);
+
+Bool
+fbdevScreenInit (KdScreenInfo *screen);
+
+Bool
+fbdevScreenInitialize (KdScreenInfo *screen, FbdevScrPriv *scrpriv);
+
+Bool
+fbdevInitScreen (ScreenPtr pScreen);
+
+Bool
+fbdevFinishInitScreen (ScreenPtr pScreen);
+
+Bool
+fbdevCreateResources (ScreenPtr pScreen);
+
+void
+fbdevPreserve (KdCardInfo *card);
+
+Bool
+fbdevEnable (ScreenPtr pScreen);
+
+Bool
+fbdevDPMS (ScreenPtr pScreen, int mode);
+
+void
+fbdevDisable (ScreenPtr pScreen);
+
+void
+fbdevRestore (KdCardInfo *card);
+
+void
+fbdevScreenFini (KdScreenInfo *screen);
+
+void
+fbdevCardFini (KdCardInfo *card);
+
+void
+fbdevGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+
+void
+fbdevPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+
+Bool
+fbdevMapFramebuffer (KdScreenInfo *screen);
+
+void *
+fbdevWindowLinear (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure);
+
+void
+fbdevSetScreenSizes (ScreenPtr pScreen);
+
+Bool
+fbdevUnmapFramebuffer (KdScreenInfo *screen);
+
+Bool
+fbdevSetShadow (ScreenPtr pScreen);
+
+Bool
+fbdevCreateColormap (ColormapPtr pmap);
+
+#ifdef RANDR
+Bool
+fbdevRandRGetInfo (ScreenPtr pScreen, Rotation *rotations);
+
+Bool
+fbdevRandRSetConfig (ScreenPtr pScreen,
+ Rotation randr,
+ int rate,
+ RRScreenSizePtr pSize);
+Bool
+fbdevRandRInit (ScreenPtr pScreen);
+
+#endif
+
+#endif /* _FBDEV_H_ */
diff --git a/xorg-server/hw/kdrive/fbdev/fbinit.c b/xorg-server/hw/kdrive/fbdev/fbinit.c
new file mode 100644
index 000000000..de80c79aa
--- /dev/null
+++ b/xorg-server/hw/kdrive/fbdev/fbinit.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include <fbdev.h>
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+
+ KdCardInfoAdd (&fbdevFuncs, &attr, 0);
+}
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdOsAddInputDrivers ();
+ KdInitInput ();
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+ ErrorF("\nXfbdev Device Usage:\n");
+ ErrorF("-fb path Framebuffer device to use. Defaults to /dev/fb0\n");
+ ErrorF("\n");
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ if (!strcmp (argv[i], "-fb"))
+ {
+ if (i+1 < argc)
+ {
+ fbdevDevicePath = argv[i+1];
+ return 2;
+ }
+ UseMsg();
+ exit(1);
+ }
+
+ return KdProcessArgument (argc, argv, i);
+}
+
+
+KdCardFuncs fbdevFuncs = {
+ fbdevCardInit, /* cardinit */
+ fbdevScreenInit, /* scrinit */
+ fbdevInitScreen, /* initScreen */
+ fbdevFinishInitScreen, /* finishInitScreen */
+ fbdevCreateResources, /* createRes */
+ fbdevPreserve, /* preserve */
+ fbdevEnable, /* enable */
+ fbdevDPMS, /* dpms */
+ fbdevDisable, /* disable */
+ fbdevRestore, /* restore */
+ fbdevScreenFini, /* scrfini */
+ fbdevCardFini, /* cardfini */
+
+ 0, /* initCursor */
+ 0, /* enableCursor */
+ 0, /* disableCursor */
+ 0, /* finiCursor */
+ 0, /* recolorCursor */
+
+ 0, /* initAccel */
+ 0, /* enableAccel */
+ 0, /* disableAccel */
+ 0, /* finiAccel */
+
+ fbdevGetColors, /* getColors */
+ fbdevPutColors, /* putColors */
+};
diff --git a/xorg-server/hw/kdrive/i810/Makefile.am b/xorg-server/hw/kdrive/i810/Makefile.am
new file mode 100644
index 000000000..30919fad9
--- /dev/null
+++ b/xorg-server/hw/kdrive/i810/Makefile.am
@@ -0,0 +1,39 @@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+bin_PROGRAMS = Xi810
+
+noinst_LIBRARIES = libi810.a
+
+
+libi810_a_SOURCES = \
+ i810_cursor.c \
+ i810_video.c \
+ i810draw.c \
+ i810draw.h \
+ i810_reg.h \
+ i810.c \
+ i810.h
+
+Xi810_SOURCES = \
+ i810stub.c
+
+I810_LIBS = \
+ libi810.a \
+ @KDRIVE_LIBS@
+
+if GLX
+Xi810_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
+Xi810_LDADD = \
+ $(I810_LIBS) \
+ @KDRIVE_LIBS@
+
+Xi810_DEPENDENCIES = \
+ libi810.a \
+ @KDRIVE_LOCAL_LIBS@
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/i810/Makefile.in b/xorg-server/hw/kdrive/i810/Makefile.in
new file mode 100644
index 000000000..ba05704b7
--- /dev/null
+++ b/xorg-server/hw/kdrive/i810/Makefile.in
@@ -0,0 +1,721 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xi810$(EXEEXT)
+subdir = hw/kdrive/i810
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libi810_a_AR = $(AR) $(ARFLAGS)
+libi810_a_LIBADD =
+am_libi810_a_OBJECTS = i810_cursor.$(OBJEXT) i810_video.$(OBJEXT) \
+ i810draw.$(OBJEXT) i810.$(OBJEXT)
+libi810_a_OBJECTS = $(am_libi810_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xi810_OBJECTS = i810stub.$(OBJEXT)
+Xi810_OBJECTS = $(am_Xi810_OBJECTS)
+am__DEPENDENCIES_1 = libi810.a
+Xi810_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xi810_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libi810_a_SOURCES) $(Xi810_SOURCES)
+DIST_SOURCES = $(libi810_a_SOURCES) $(Xi810_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libi810.a
+libi810_a_SOURCES = \
+ i810_cursor.c \
+ i810_video.c \
+ i810draw.c \
+ i810draw.h \
+ i810_reg.h \
+ i810.c \
+ i810.h
+
+Xi810_SOURCES = \
+ i810stub.c
+
+I810_LIBS = \
+ libi810.a \
+ @KDRIVE_LIBS@
+
+@GLX_TRUE@Xi810_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xi810_LDADD = \
+ $(I810_LIBS) \
+ @KDRIVE_LIBS@
+
+Xi810_DEPENDENCIES = \
+ libi810.a \
+ @KDRIVE_LOCAL_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/i810/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/i810/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libi810.a: $(libi810_a_OBJECTS) $(libi810_a_DEPENDENCIES)
+ -rm -f libi810.a
+ $(libi810_a_AR) libi810.a $(libi810_a_OBJECTS) $(libi810_a_LIBADD)
+ $(RANLIB) libi810.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xi810$(EXEEXT): $(Xi810_OBJECTS) $(Xi810_DEPENDENCIES)
+ @rm -f Xi810$(EXEEXT)
+ $(Xi810_LINK) $(Xi810_OBJECTS) $(Xi810_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i810.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i810_cursor.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i810_video.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i810draw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/i810stub.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/i810/i810.c b/xorg-server/hw/kdrive/i810/i810.c
new file mode 100644
index 000000000..49090f9eb
--- /dev/null
+++ b/xorg-server/hw/kdrive/i810/i810.c
@@ -0,0 +1,2112 @@
+/* COPYRIGHT AND PERMISSION NOTICE
+
+Copyright (c) 2000, 2001 Nokia Home Communications
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+X Window System is a trademark of The Open Group */
+
+/*
+ * i810.c - KDrive driver for the i810 chipset
+ *
+ * Authors:
+ * Pontus Lidman <pontus.lidman@nokia.com>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "kxv.h"
+#include "klinux.h"
+
+#include "i810.h"
+#include "agp.h"
+
+#include "i810draw.h"
+
+#ifndef I810_DEBUG
+int I810_DEBUG = (0
+/* | DEBUG_ALWAYS_SYNC */
+/* | DEBUG_VERBOSE_ACCEL */
+/* | DEBUG_VERBOSE_SYNC */
+/* | DEBUG_VERBOSE_VGA */
+/* | DEBUG_VERBOSE_RING */
+/* | DEBUG_VERBOSE_OUTREG */
+/* | DEBUG_VERBOSE_MEMORY */
+/* | DEBUG_VERBOSE_CURSOR */
+ );
+#endif
+
+
+static Bool
+i810ModeInit(KdScreenInfo *screen, const KdMonitorTiming *t);
+
+static void
+i810PrintMode( vgaRegPtr vgaReg, I810RegPtr mode );
+
+Bool
+i810CardInit (KdCardInfo *card)
+{
+ int i;
+
+ I810CardInfo *i810c;
+
+/* fprintf(stderr,"i810CardInit\n"); */
+
+ i810c = (I810CardInfo *) xalloc (sizeof (I810CardInfo));
+
+ if (!i810c)
+ return FALSE;
+
+ /* 2MB Video RAM */
+ i810c->videoRam=2048;
+
+ /* Find FB address */
+
+ if (card->attr.address[1] != 0) {
+ i810c->LinearAddr = card->attr.address[0] & 0xFF000000;
+
+ if (!i810c->LinearAddr) {
+ fprintf(stderr,"No valid FB address in PCI config space(1)\n");
+ xfree(i810c);
+ return FALSE;
+ } else {
+/* fprintf(stderr,"Linear framebuffer at %lx\n",i810c->LinearAddr); */
+ }
+ } else {
+ fprintf(stderr,"No valid FB address in PCI config space(2)\n");
+ xfree(i810c);
+ return FALSE;
+ }
+
+ if (card->attr.address[1]) {
+
+ i810c->MMIOAddr = card->attr.address[1] & 0xFFF80000;
+
+ i810c->MMIOBase =
+ KdMapDevice (i810c->MMIOAddr, I810_REG_SIZE);
+ if (!i810c->MMIOBase) {
+ fprintf(stderr,"No valid MMIO address in PCI config space(1)\n");
+ xfree(i810c);
+ return FALSE;
+ } else {
+
+ }
+ } else {
+ fprintf(stderr,"No valid MMIO address in PCI config space(2)\n");
+ xfree(i810c);
+ return FALSE;
+ }
+
+/* fprintf(stderr,"Mapped 0x%x bytes of MMIO regs at phys 0x%lx virt %p\n", */
+/* I810_REG_SIZE,i810c->MMIOAddr,i810c->MMIOBase); */
+
+ /* Find out memory bus frequency.
+ */
+
+ {
+ unsigned long *p;
+
+ if (!(p= (unsigned long *) LinuxGetPciCfg(&card->attr)))
+ return FALSE;
+
+/* fprintf(stderr,"Frequency long %lx\n",p[WHTCFG_PAMR_DRP]); */
+
+ if ( (p[WHTCFG_PAMR_DRP] & LM_FREQ_MASK) == LM_FREQ_133 )
+ i810c->LmFreqSel = 133;
+ else
+ i810c->LmFreqSel = 100;
+
+ xfree(p);
+
+/* fprintf(stderr,"Selected frequency %d\n",i810c->LmFreqSel); */
+ }
+
+/* fprintf(stderr,"Will alloc AGP framebuffer: %d kByte\n",i810c->videoRam); */
+
+ /* Since we always want write combining on first 32 mb of framebuffer
+ * we pass a mapsize of 32 mb */
+ i810c->FbMapSize = 32*1024*1024;
+
+ for (i = 2 ; i < i810c->FbMapSize ; i <<= 1);
+ i810c->FbMapSize = i;
+
+ i810c->FbBase =
+ KdMapDevice (i810c->LinearAddr, i810c->FbMapSize);
+
+ if (!i810c->FbBase) return FALSE;
+/* fprintf(stderr,"Mapped 0x%lx bytes of framebuffer at %p\n", */
+/* i810c->FbMapSize,i810c->FbBase); */
+
+ card->driver=i810c;
+
+ return TRUE;
+}
+
+static void
+i810ScreenFini (KdScreenInfo *screen)
+{
+ I810ScreenInfo *i810s = (I810ScreenInfo *) screen->driver;
+
+ xfree (i810s);
+ screen->driver = 0;
+}
+
+static Bool
+i810InitScreen (ScreenPtr pScreen) {
+
+#ifdef XV
+ i810InitVideo(pScreen);
+#endif
+ return TRUE;
+}
+
+static Bool
+i810FinishInitScreen(ScreenPtr pScreen)
+{
+ /* XXX: RandR init */
+ return TRUE;
+}
+
+static void
+i810CardFini (KdCardInfo *card)
+{
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+
+ KdUnmapDevice (i810c->FbBase, i810c->FbMapSize);
+ KdUnmapDevice (i810c->MMIOBase, I810_REG_SIZE);
+ xfree (i810c);
+ card->driver = 0;
+}
+
+struct wm_info {
+ double freq;
+ unsigned int wm;
+};
+
+struct wm_info i810_wm_8_100[] = {
+ { 0, 0x22003000 },
+ { 25.2, 0x22003000 },
+ { 28.0, 0x22003000 },
+ { 31.5, 0x22003000 },
+ { 36.0, 0x22007000 },
+ { 40.0, 0x22007000 },
+ { 45.0, 0x22007000 },
+ { 49.5, 0x22008000 },
+ { 50.0, 0x22008000 },
+ { 56.3, 0x22008000 },
+ { 65.0, 0x22008000 },
+ { 75.0, 0x22008000 },
+ { 78.8, 0x22008000 },
+ { 80.0, 0x22008000 },
+ { 94.0, 0x22008000 },
+ { 96.0, 0x22107000 },
+ { 99.0, 0x22107000 },
+ { 108.0, 0x22107000 },
+ { 121.0, 0x22107000 },
+ { 128.9, 0x22107000 },
+ { 132.0, 0x22109000 },
+ { 135.0, 0x22109000 },
+ { 157.5, 0x2210b000 },
+ { 162.0, 0x2210b000 },
+ { 175.5, 0x2210b000 },
+ { 189.0, 0x2220e000 },
+ { 202.5, 0x2220e000 }
+};
+
+struct wm_info i810_wm_16_100[] = {
+ { 0, 0x22004000 },
+ { 25.2, 0x22006000 },
+ { 28.0, 0x22006000 },
+ { 31.5, 0x22007000 },
+ { 36.0, 0x22007000 },
+ { 40.0, 0x22007000 },
+ { 45.0, 0x22007000 },
+ { 49.5, 0x22009000 },
+ { 50.0, 0x22009000 },
+ { 56.3, 0x22108000 },
+ { 65.0, 0x2210e000 },
+ { 75.0, 0x2210e000 },
+ { 78.8, 0x2210e000 },
+ { 80.0, 0x22210000 },
+ { 94.5, 0x22210000 },
+ { 96.0, 0x22210000 },
+ { 99.0, 0x22210000 },
+ { 108.0, 0x22210000 },
+ { 121.0, 0x22210000 },
+ { 128.9, 0x22210000 },
+ { 132.0, 0x22314000 },
+ { 135.0, 0x22314000 },
+ { 157.5, 0x22415000 },
+ { 162.0, 0x22416000 },
+ { 175.5, 0x22416000 },
+ { 189.0, 0x22416000 },
+ { 195.0, 0x22416000 },
+ { 202.5, 0x22416000 }
+};
+
+
+struct wm_info i810_wm_24_100[] = {
+ { 0, 0x22006000 },
+ { 25.2, 0x22009000 },
+ { 28.0, 0x22009000 },
+ { 31.5, 0x2200a000 },
+ { 36.0, 0x2210c000 },
+ { 40.0, 0x2210c000 },
+ { 45.0, 0x2210c000 },
+ { 49.5, 0x22111000 },
+ { 50.0, 0x22111000 },
+ { 56.3, 0x22111000 },
+ { 65.0, 0x22214000 },
+ { 75.0, 0x22214000 },
+ { 78.8, 0x22215000 },
+ { 80.0, 0x22216000 },
+ { 94.5, 0x22218000 },
+ { 96.0, 0x22418000 },
+ { 99.0, 0x22418000 },
+ { 108.0, 0x22418000 },
+ { 121.0, 0x22418000 },
+ { 128.9, 0x22419000 },
+ { 132.0, 0x22519000 },
+ { 135.0, 0x4441d000 },
+ { 157.5, 0x44419000 },
+ { 162.0, 0x44419000 },
+ { 175.5, 0x44419000 },
+ { 189.0, 0x44419000 },
+ { 195.0, 0x44419000 },
+ { 202.5, 0x44419000 }
+};
+
+struct wm_info i810_wm_32_100[] = {
+ { 0, 0x2210b000 },
+ { 60, 0x22415000 }, /* 0x314000 works too */
+ { 80, 0x22419000 } /* 0x518000 works too */
+};
+
+
+struct wm_info i810_wm_8_133[] = {
+ { 0, 0x22003000 },
+ { 25.2, 0x22003000 },
+ { 28.0, 0x22003000 },
+ { 31.5, 0x22003000 },
+ { 36.0, 0x22007000 },
+ { 40.0, 0x22007000 },
+ { 45.0, 0x22007000 },
+ { 49.5, 0x22008000 },
+ { 50.0, 0x22008000 },
+ { 56.3, 0x22008000 },
+ { 65.0, 0x22008000 },
+ { 75.0, 0x22008000 },
+ { 78.8, 0x22008000 },
+ { 80.0, 0x22008000 },
+ { 94.0, 0x22008000 },
+ { 96.0, 0x22107000 },
+ { 99.0, 0x22107000 },
+ { 108.0, 0x22107000 },
+ { 121.0, 0x22107000 },
+ { 128.9, 0x22107000 },
+ { 132.0, 0x22109000 },
+ { 135.0, 0x22109000 },
+ { 157.5, 0x2210b000 },
+ { 162.0, 0x2210b000 },
+ { 175.5, 0x2210b000 },
+ { 189.0, 0x2220e000 },
+ { 202.5, 0x2220e000 }
+};
+
+
+struct wm_info i810_wm_16_133[] = {
+ { 0, 0x22004000 },
+ { 25.2, 0x22006000 },
+ { 28.0, 0x22006000 },
+ { 31.5, 0x22007000 },
+ { 36.0, 0x22007000 },
+ { 40.0, 0x22007000 },
+ { 45.0, 0x22007000 },
+ { 49.5, 0x22009000 },
+ { 50.0, 0x22009000 },
+ { 56.3, 0x22108000 },
+ { 65.0, 0x2210e000 },
+ { 75.0, 0x2210e000 },
+ { 78.8, 0x2210e000 },
+ { 80.0, 0x22210000 },
+ { 94.5, 0x22210000 },
+ { 96.0, 0x22210000 },
+ { 99.0, 0x22210000 },
+ { 108.0, 0x22210000 },
+ { 121.0, 0x22210000 },
+ { 128.9, 0x22210000 },
+ { 132.0, 0x22314000 },
+ { 135.0, 0x22314000 },
+ { 157.5, 0x22415000 },
+ { 162.0, 0x22416000 },
+ { 175.5, 0x22416000 },
+ { 189.0, 0x22416000 },
+ { 195.0, 0x22416000 },
+ { 202.5, 0x22416000 }
+};
+
+struct wm_info i810_wm_24_133[] = {
+ { 0, 0x22006000 },
+ { 25.2, 0x22009000 },
+ { 28.0, 0x22009000 },
+ { 31.5, 0x2200a000 },
+ { 36.0, 0x2210c000 },
+ { 40.0, 0x2210c000 },
+ { 45.0, 0x2210c000 },
+ { 49.5, 0x22111000 },
+ { 50.0, 0x22111000 },
+ { 56.3, 0x22111000 },
+ { 65.0, 0x22214000 },
+ { 75.0, 0x22214000 },
+ { 78.8, 0x22215000 },
+ { 80.0, 0x22216000 },
+ { 94.5, 0x22218000 },
+ { 96.0, 0x22418000 },
+ { 99.0, 0x22418000 },
+ { 108.0, 0x22418000 },
+ { 121.0, 0x22418000 },
+ { 128.9, 0x22419000 },
+ { 132.0, 0x22519000 },
+ { 135.0, 0x4441d000 },
+ { 157.5, 0x44419000 },
+ { 162.0, 0x44419000 },
+ { 175.5, 0x44419000 },
+ { 189.0, 0x44419000 },
+ { 195.0, 0x44419000 },
+ { 202.5, 0x44419000 }
+};
+
+static void
+i810WriteControlMMIO(I810CardInfo *i810c, int addr, CARD8 index, CARD8 val) {
+ moutb(addr, index);
+ moutb(addr+1, val);
+}
+
+static CARD8
+i810ReadControlMMIO(I810CardInfo *i810c, int addr, CARD8 index) {
+ moutb(addr, index);
+ return minb(addr+1);
+}
+
+static Bool
+i810ModeSupported (KdScreenInfo *screen, const KdMonitorTiming *t)
+{
+ /* This is just a guess. */
+ if (t->horizontal > 1600 || t->horizontal < 640) return FALSE;
+ if (t->vertical > 1200 || t->horizontal < 350) return FALSE;
+ return TRUE;
+}
+
+static Bool
+i810ModeUsable (KdScreenInfo *screen)
+{
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+ int byte_width, pixel_width, screen_size;
+
+/* fprintf(stderr,"i810ModeUsable\n"); */
+
+ if (screen->fb[0].depth >= 24)
+ {
+ screen->fb[0].depth = 24;
+ screen->fb[0].bitsPerPixel = 24;
+ screen->dumb = TRUE;
+ }
+ else if (screen->fb[0].depth >= 16)
+ {
+ screen->fb[0].depth = 16;
+ screen->fb[0].bitsPerPixel = 16;
+ }
+ else if (screen->fb[0].depth >= 15)
+ {
+ screen->fb[0].depth = 15;
+ screen->fb[0].bitsPerPixel = 16;
+ }
+ else
+ {
+ screen->fb[0].depth = 8;
+ screen->fb[0].bitsPerPixel = 8;
+ }
+ byte_width = screen->width * (screen->fb[0].bitsPerPixel >> 3);
+ pixel_width = screen->width;
+
+ screen->fb[0].pixelStride = pixel_width;
+ screen->fb[0].byteStride = byte_width;
+
+ screen_size = byte_width * screen->height;
+
+ return screen_size <= (i810c->videoRam * 1024);
+}
+
+static int i810AllocateGARTMemory( KdScreenInfo *screen )
+{
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+ unsigned long size = i810c->videoRam * 1024;
+
+ int key;
+ long tom = 0;
+ unsigned long physical;
+
+ if (!KdAgpGARTSupported())
+ return FALSE;
+
+ if (!KdAcquireGART(screen->mynum))
+ return FALSE;
+
+ /* This allows the 2d only Xserver to regen */
+ i810c->agpAcquired2d = TRUE;
+
+ /* Treat the gart like video memory - we assume we own all that is
+ * there, so ignore EBUSY errors. Don't try to remove it on
+ * failure, either, as other X server may be using it.
+ */
+
+ if ((key = KdAllocateGARTMemory(screen->mynum, size, 0, NULL)) == -1)
+ return FALSE;
+
+ i810c->VramOffset = 0;
+ i810c->VramKey = key;
+
+ if (!KdBindGARTMemory(screen->mynum, key, 0))
+ return FALSE;
+
+
+ i810c->SysMem.Start = 0;
+ i810c->SysMem.Size = size;
+ i810c->SysMem.End = size;
+ i810c->SavedSysMem = i810c->SysMem;
+
+ tom = i810c->SysMem.End;
+
+ i810c->DcacheMem.Start = 0;
+ i810c->DcacheMem.End = 0;
+ i810c->DcacheMem.Size = 0;
+ i810c->CursorPhysical = 0;
+
+ /* Dcache - half the speed of normal ram, so not really useful for
+ * a 2d server. Don't bother reporting its presence. This is
+ * mapped in addition to the requested amount of system ram.
+ */
+ size = 1024 * 4096;
+
+ /* Keep it 512K aligned for the sake of tiled regions.
+ */
+ tom += 0x7ffff;
+ tom &= ~0x7ffff;
+
+ if ((key = KdAllocateGARTMemory(screen->mynum, size, AGP_DCACHE_MEMORY, NULL)) != -1) {
+ i810c->DcacheOffset= tom;
+ i810c->DcacheKey = key;
+ if (!KdBindGARTMemory(screen->mynum, key, tom)) {
+ fprintf(stderr,"Allocation of %ld bytes for DCACHE failed\n", size);
+ i810c->DcacheKey = -1;
+ } else {
+ i810c->DcacheMem.Start = tom;
+ i810c->DcacheMem.Size = size;
+ i810c->DcacheMem.End = i810c->DcacheMem.Start + i810c->DcacheMem.Size;
+ tom = i810c->DcacheMem.End;
+ }
+ } else {
+ fprintf(stderr,
+ "No physical memory available for %ld bytes of DCACHE\n",
+ size);
+ i810c->DcacheKey = -1;
+ }
+
+ /* Mouse cursor -- The i810 (crazy) needs a physical address in
+ * system memory from which to upload the cursor. We get this from
+ * the agpgart module using a special memory type.
+ */
+
+ /* 4k for the cursor is excessive, I'm going to steal 3k for
+ * overlay registers later
+ */
+
+ size = 4096;
+
+ if ((key = KdAllocateGARTMemory(screen->mynum, size, AGP_PHYS_MEMORY,
+ &physical)) == -1) {
+ fprintf(stderr,
+ "No physical memory available for HW cursor\n");
+ i810c->HwcursKey = -1;
+ } else {
+ i810c->HwcursOffset= tom;
+ i810c->HwcursKey = key;
+ if (!KdBindGARTMemory(screen->mynum, key, tom)) {
+ fprintf(stderr,
+ "Allocation of %ld bytes for HW cursor failed\n",
+ size);
+ i810c->HwcursKey = -1;
+ } else {
+ i810c->CursorPhysical = physical;
+ i810c->CursorStart = tom;
+ tom += size;
+ }
+ }
+
+ /* Overlay register buffer -- Just like the cursor, the i810 needs a
+ * physical address in system memory from which to upload the overlay
+ * registers.
+ */
+ if (i810c->CursorStart != 0) {
+ i810c->OverlayPhysical = i810c->CursorPhysical + 1024;
+ i810c->OverlayStart = i810c->CursorStart + 1024;
+ }
+
+
+ i810c->GttBound = 1;
+
+ return TRUE;
+}
+
+/* Allocate from a memrange, returns success */
+
+static int i810AllocLow( I810MemRange *result, I810MemRange *pool, int size )
+{
+ if (size > pool->Size) return FALSE;
+
+ pool->Size -= size;
+ result->Size = size;
+ result->Start = pool->Start;
+ result->End = pool->Start += size;
+ return TRUE;
+}
+
+static int i810AllocHigh( I810MemRange *result, I810MemRange *pool, int size )
+{
+ if (size > pool->Size) return 0;
+
+ pool->Size -= size;
+ result->Size = size;
+ result->End = pool->End;
+ result->Start = pool->End -= size;
+ return 1;
+}
+
+static Bool
+i810AllocateFront(KdScreenInfo *screen) {
+
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+
+ int cache_lines = -1;
+
+ if(i810c->DoneFrontAlloc)
+ return TRUE;
+
+ memset(&(i810c->FbMemBox), 0, sizeof(BoxRec));
+ /* Alloc FrontBuffer/Ring/Accel memory */
+ i810c->FbMemBox.x1=0;
+ i810c->FbMemBox.x2=screen->width;
+ i810c->FbMemBox.y1=0;
+ i810c->FbMemBox.y2=screen->height;
+
+ /* This could be made a command line option */
+ cache_lines = 0;
+
+ if(cache_lines >= 0)
+ i810c->FbMemBox.y2 += cache_lines;
+ else {
+ /* make sure there is enough for two DVD sized YUV buffers */
+ i810c->FbMemBox.y2 += (screen->fb[0].depth == 24) ? 256 : 384;
+ if (screen->width <= 1024)
+ i810c->FbMemBox.y2 += (screen->fb[0].depth == 24) ? 256 : 384;
+ cache_lines = i810c->FbMemBox.y2 - screen->height;
+ }
+
+ if (I810_DEBUG)
+ ErrorF("Adding %i scanlines for pixmap caching\n", cache_lines);
+
+ /* Reserve room for the framebuffer and pixcache. Put at the top
+ * of memory so we can have nice alignment for the tiled regions at
+ * the start of memory.
+ */
+ i810AllocLow( &(i810c->FrontBuffer),
+ &(i810c->SysMem),
+ ((i810c->FbMemBox.x2 *
+ i810c->FbMemBox.y2 *
+ i810c->cpp) + 4095) & ~4095);
+
+ memset( &(i810c->LpRing), 0, sizeof( I810RingBuffer ) );
+ if(i810AllocLow( &(i810c->LpRing.mem), &(i810c->SysMem), 16*4096 )) {
+ if (I810_DEBUG & DEBUG_VERBOSE_MEMORY)
+ ErrorF( "ring buffer at local %lx\n",
+ i810c->LpRing.mem.Start);
+
+ i810c->LpRing.tail_mask = i810c->LpRing.mem.Size - 1;
+ i810c->LpRing.virtual_start = i810c->FbBase + i810c->LpRing.mem.Start;
+ i810c->LpRing.head = 0;
+ i810c->LpRing.tail = 0;
+ i810c->LpRing.space = 0;
+ }
+
+ if ( i810AllocLow( &i810c->Scratch, &(i810c->SysMem), 64*1024 ) ||
+ i810AllocLow( &i810c->Scratch, &(i810c->SysMem), 16*1024 ) ) {
+ if (I810_DEBUG & DEBUG_VERBOSE_MEMORY)
+ ErrorF("Allocated Scratch Memory\n");
+ }
+
+#ifdef XV
+ /* 720x720 is just how much memory the mpeg player needs for overlays */
+
+ if ( i810AllocHigh( &i810c->XvMem, &(i810c->SysMem), 720*720*2 )) {
+ if (I810_DEBUG & DEBUG_VERBOSE_MEMORY)
+ ErrorF("Allocated overlay Memory\n");
+ }
+#endif
+
+ i810c->DoneFrontAlloc = TRUE;
+ return TRUE;
+}
+
+static Bool
+i810MapMem(KdScreenInfo *screen)
+{
+
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+
+ i810c->LpRing.virtual_start = i810c->FbBase + i810c->LpRing.mem.Start;
+
+ return TRUE;
+}
+
+
+Bool
+i810ScreenInit (KdScreenInfo *screen)
+{
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+ I810ScreenInfo *i810s;
+
+ int i;
+
+ const KdMonitorTiming *t;
+
+/* fprintf(stderr,"i810ScreenInit\n"); */
+
+ i810s = (I810ScreenInfo *) xalloc (sizeof (I810ScreenInfo));
+ if (!i810s)
+ return FALSE;
+
+ memset (i810s, '\0', sizeof (I810ScreenInfo));
+
+ i810s->i810c = i810c;
+
+ /* Default dimensions */
+ if (!screen->width || !screen->height)
+ {
+ screen->width = 720;
+ screen->height = 576;
+ screen->rate = 52;
+#if 0
+ screen->width = 1024;
+ screen->height = 768;
+ screen->rate = 72;
+#endif
+ }
+
+ if (!screen->fb[0].depth)
+ screen->fb[0].depth = 16;
+
+ t = KdFindMode (screen, i810ModeSupported);
+
+ screen->rate = t->rate;
+ screen->width = t->horizontal;
+ screen->height = t->vertical;
+
+ if (!KdTuneMode (screen, i810ModeUsable, i810ModeSupported))
+ {
+ xfree (i810c);
+ return FALSE;
+ }
+
+/* fprintf(stderr,"Screen rate %d horiz %d vert %d\n",t->rate,t->horizontal,t->vertical); */
+
+ switch (screen->fb[0].depth) {
+ case 8:
+ screen->fb[0].visuals = ((1 << StaticGray) |
+ (1 << GrayScale) |
+ (1 << StaticColor) |
+ (1 << PseudoColor) |
+ (1 << TrueColor) |
+ (1 << DirectColor));
+ screen->fb[0].blueMask = 0x00;
+ screen->fb[0].greenMask = 0x00;
+ screen->fb[0].redMask = 0x00;
+ break;
+ case 15:
+ screen->fb[0].visuals = (1 << TrueColor);
+ screen->fb[0].blueMask = 0x001f;
+ screen->fb[0].greenMask = 0x03e0;
+ screen->fb[0].redMask = 0x7c00;
+
+ i810c->colorKey = 0x043f;
+
+ break;
+ case 16:
+ screen->fb[0].visuals = (1 << TrueColor);
+ screen->fb[0].blueMask = 0x001f;
+ screen->fb[0].greenMask = 0x07e0;
+ screen->fb[0].redMask = 0xf800;
+
+ i810c->colorKey = 0x083f;
+
+ break;
+ case 24:
+ screen->fb[0].visuals = (1 << TrueColor);
+ screen->fb[0].blueMask = 0x0000ff;
+ screen->fb[0].greenMask = 0x00ff00;
+ screen->fb[0].redMask = 0xff0000;
+
+ i810c->colorKey = 0x0101ff;
+
+ break;
+ default:
+ fprintf(stderr,"Unsupported depth %d\n",screen->fb[0].depth);
+ return FALSE;
+ }
+
+
+
+ /* Set all colours to black */
+ for (i=0; i<768; i++) i810c->vga.ModeReg.DAC[i] = 0x00;
+
+ /* ... and the overscan */
+ if (screen->fb[0].depth >= 4)
+ i810c->vga.ModeReg.Attribute[OVERSCAN] = 0xFF;
+
+ /* Could be made a command-line option */
+
+#ifdef I810CFG_SHOW_OVERSCAN
+ i810c->vga.ModeReg.DAC[765] = 0x3F;
+ i810c->vga.ModeReg.DAC[766] = 0x00;
+ i810c->vga.ModeReg.DAC[767] = 0x3F;
+ i810c->vga.ModeReg.Attribute[OVERSCAN] = 0xFF;
+ i810c->vga.ShowOverscan = TRUE;
+#else
+ i810c->vga.ShowOverscan = FALSE;
+#endif
+
+ i810c->vga.paletteEnabled = FALSE;
+ i810c->vga.cmapSaved = FALSE;
+ i810c->vga.MMIOBase = i810c->MMIOBase;
+
+ i810c->cpp = screen->fb[0].bitsPerPixel/8;
+
+ /* move to initscreen? */
+
+ switch (screen->fb[0].bitsPerPixel) {
+ case 8:
+ i810c->MaxClock = 203000;
+ break;
+ case 16:
+ i810c->MaxClock = 163000;
+ break;
+ case 24:
+ i810c->MaxClock = 136000;
+ break;
+ case 32: /* not supported */
+ i810c->MaxClock = 86000;
+ default:
+ fprintf(stderr,"Unsupported bpp %d\n",screen->fb[0].bitsPerPixel);
+ return FALSE;
+ }
+
+ if (!i810AllocateGARTMemory( screen )) {
+ return FALSE;
+ }
+
+ i810AllocateFront(screen);
+
+ /* Map LpRing memory */
+ if (!i810MapMem(screen)) return FALSE;
+
+ screen->fb[0].frameBuffer = i810c->FbBase;
+
+ screen->driver = i810s;
+
+ return TRUE;
+}
+
+/*
+ * I810Save --
+ *
+ * This function saves the video state. It reads all of the SVGA registers
+ * into the vgaI810Rec data structure. There is in general no need to
+ * mask out bits here - just read the registers.
+ */
+static void
+DoSave(KdCardInfo *card, vgaRegPtr vgaReg, I810RegPtr i810Reg, Bool saveFonts)
+{
+
+ I810CardInfo *i810c = card->driver;
+ i810VGAPtr vgap = &i810c->vga;
+
+ int i;
+
+ /* Save VGA registers */
+
+ vgaReg->MiscOutReg = mmioReadMiscOut(vgap);
+ if (vgaReg->MiscOutReg & 0x01)
+ vgap->IOBase = VGA_IOBASE_COLOR;
+ else
+ vgap->IOBase = VGA_IOBASE_MONO;
+
+ for (i = 0; i < VGA_NUM_CRTC; i++) {
+ vgaReg->CRTC[i] = mmioReadCrtc(vgap, i);
+ }
+
+ mmioEnablePalette(vgap);
+ for (i = 0; i < VGA_NUM_ATTR; i++) {
+ vgaReg->Attribute[i] = mmioReadAttr(vgap, i);
+ }
+ mmioDisablePalette(vgap);
+
+ for (i = 0; i < VGA_NUM_GFX; i++) {
+ vgaReg->Graphics[i] = mmioReadGr(vgap, i);
+ }
+
+ for (i = 1; i < VGA_NUM_SEQ; i++) {
+ vgaReg->Sequencer[i] = mmioReadSeq(vgap, i);
+ }
+
+ /*
+ * The port I/O code necessary to read in the extended registers
+ * into the fields of the I810Rec structure goes here.
+ */
+ i810Reg->IOControl = mmioReadCrtc(vgap, IO_CTNL);
+ i810Reg->AddressMapping = i810ReadControlMMIO(i810c, GRX, ADDRESS_MAPPING);
+ i810Reg->BitBLTControl = INREG8(BITBLT_CNTL);
+ i810Reg->VideoClk2_M = INREG16(VCLK2_VCO_M);
+ i810Reg->VideoClk2_N = INREG16(VCLK2_VCO_N);
+ i810Reg->VideoClk2_DivisorSel = INREG8(VCLK2_VCO_DIV_SEL);
+
+ i810Reg->ExtVertTotal=mmioReadCrtc(vgap, EXT_VERT_TOTAL);
+ i810Reg->ExtVertDispEnd=mmioReadCrtc(vgap, EXT_VERT_DISPLAY);
+ i810Reg->ExtVertSyncStart=mmioReadCrtc(vgap, EXT_VERT_SYNC_START);
+ i810Reg->ExtVertBlankStart=mmioReadCrtc(vgap, EXT_VERT_BLANK_START);
+ i810Reg->ExtHorizTotal=mmioReadCrtc(vgap, EXT_HORIZ_TOTAL);
+ i810Reg->ExtHorizBlank=mmioReadCrtc(vgap, EXT_HORIZ_BLANK);
+ i810Reg->ExtOffset=mmioReadCrtc(vgap, EXT_OFFSET);
+ i810Reg->InterlaceControl=mmioReadCrtc(vgap, INTERLACE_CNTL);
+
+ i810Reg->PixelPipeCfg0 = INREG8(PIXPIPE_CONFIG_0);
+ i810Reg->PixelPipeCfg1 = INREG8(PIXPIPE_CONFIG_1);
+ i810Reg->PixelPipeCfg2 = INREG8(PIXPIPE_CONFIG_2);
+ i810Reg->DisplayControl = INREG8(DISPLAY_CNTL);
+ i810Reg->LMI_FIFO_Watermark = INREG(FWATER_BLC);
+
+ for (i = 0 ; i < 8 ; i++)
+ i810Reg->Fence[i] = INREG(FENCE+i*4);
+
+ i810Reg->LprbTail = INREG(LP_RING + RING_TAIL);
+ i810Reg->LprbHead = INREG(LP_RING + RING_HEAD);
+ i810Reg->LprbStart = INREG(LP_RING + RING_START);
+ i810Reg->LprbLen = INREG(LP_RING + RING_LEN);
+
+ if ((i810Reg->LprbTail & TAIL_ADDR) != (i810Reg->LprbHead & HEAD_ADDR) &&
+ i810Reg->LprbLen & RING_VALID) {
+ i810PrintErrorState( i810c );
+ FatalError( "Active ring not flushed\n");
+ }
+
+ if (I810_DEBUG) {
+ fprintf(stderr,"Got mode in I810Save:\n");
+ i810PrintMode( vgaReg, i810Reg );
+ }
+}
+
+static void
+i810Preserve(KdCardInfo *card)
+{
+ I810CardInfo *i810c = card->driver;
+ i810VGAPtr vgap = &i810c->vga;
+
+/* fprintf(stderr,"i810Preserve\n"); */
+ DoSave(card, &vgap->SavedReg, &i810c->SavedReg, TRUE);
+}
+
+/* Famous last words
+ */
+void
+i810PrintErrorState(i810CardInfo *i810c)
+{
+
+ fprintf(stderr, "pgetbl_ctl: 0x%lx pgetbl_err: 0x%lx\n",
+ INREG(PGETBL_CTL),
+ INREG(PGE_ERR));
+
+ fprintf(stderr, "ipeir: %lx iphdr: %lx\n",
+ INREG(IPEIR),
+ INREG(IPEHR));
+
+ fprintf(stderr, "LP ring tail: %lx head: %lx len: %lx start %lx\n",
+ INREG(LP_RING + RING_TAIL),
+ INREG(LP_RING + RING_HEAD) & HEAD_ADDR,
+ INREG(LP_RING + RING_LEN),
+ INREG(LP_RING + RING_START));
+
+ fprintf(stderr, "eir: %x esr: %x emr: %x\n",
+ INREG16(EIR),
+ INREG16(ESR),
+ INREG16(EMR));
+
+ fprintf(stderr, "instdone: %x instpm: %x\n",
+ INREG16(INST_DONE),
+ INREG8(INST_PM));
+
+ fprintf(stderr, "memmode: %lx instps: %lx\n",
+ INREG(MEMMODE),
+ INREG(INST_PS));
+
+ fprintf(stderr, "hwstam: %x ier: %x imr: %x iir: %x\n",
+ INREG16(HWSTAM),
+ INREG16(IER),
+ INREG16(IMR),
+ INREG16(IIR));
+}
+
+static Bool
+i810BindGARTMemory( KdScreenInfo *screen )
+{
+
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = card->driver;
+
+ if (!i810c->GttBound) {
+ if (!KdAcquireGART(screen->mynum))
+ return FALSE;
+ if (!KdBindGARTMemory(screen->mynum, i810c->VramKey,
+ i810c->VramOffset))
+
+ return FALSE;
+ if (i810c->DcacheKey != -1) {
+ if (!KdBindGARTMemory(screen->mynum, i810c->DcacheKey,
+ i810c->DcacheOffset))
+ return FALSE;
+ }
+ if (i810c->HwcursKey != -1) {
+ if (!KdBindGARTMemory(screen->mynum, i810c->HwcursKey,
+ i810c->HwcursOffset))
+ return FALSE;
+ }
+ i810c->GttBound = 1;
+ }
+ return TRUE;
+}
+
+static Bool
+i810UnbindGARTMemory(KdScreenInfo *screen)
+{
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = card->driver;
+
+
+ if (KdAgpGARTSupported() && i810c->GttBound) {
+ if (!KdUnbindGARTMemory(screen->mynum, i810c->VramKey))
+ return FALSE;
+ if (i810c->DcacheKey != -1) {
+ if (!KdUnbindGARTMemory(screen->mynum, i810c->DcacheKey))
+ return FALSE;
+ }
+ if (i810c->HwcursKey != -1) {
+ if (!KdUnbindGARTMemory(screen->mynum, i810c->HwcursKey))
+ return FALSE;
+ }
+ if (!KdReleaseGART(screen->mynum))
+ return FALSE;
+ i810c->GttBound = 0;
+ }
+ return TRUE;
+}
+
+/*
+ * I810CalcVCLK --
+ *
+ * Determine the closest clock frequency to the one requested.
+ */
+
+#define MAX_VCO_FREQ 600.0
+#define TARGET_MAX_N 30
+#define REF_FREQ 24.0
+
+#define CALC_VCLK(m,n,p) \
+ (double)m / ((double)n * (1 << p)) * 4 * REF_FREQ
+
+static void
+i810CalcVCLK( KdScreenInfo *screen, double freq )
+{
+
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = card->driver;
+ I810RegPtr i810Reg = &i810c->ModeReg;
+
+ int m, n, p;
+ double f_out, f_best;
+ double f_err;
+ double f_vco;
+ int m_best = 0, n_best = 0, p_best = 0;
+ double f_target = freq;
+ double err_max = 0.005;
+ double err_target = 0.001;
+ double err_best = 999999.0;
+
+ p_best = p = log(MAX_VCO_FREQ/f_target)/log((double)2);
+ f_vco = f_target * (1 << p);
+
+ n = 2;
+ do {
+ n++;
+ m = f_vco / (REF_FREQ / (double)n) / (double)4.0 + 0.5;
+ if (m < 3) m = 3;
+ f_out = CALC_VCLK(m,n,p);
+ f_err = 1.0 - (f_target/f_out);
+ if (fabs(f_err) < err_max) {
+ m_best = m;
+ n_best = n;
+ f_best = f_out;
+ err_best = f_err;
+ }
+ } while ((fabs(f_err) >= err_target) &&
+ ((n <= TARGET_MAX_N) || (fabs(err_best) > err_max)));
+
+ if (fabs(f_err) < err_target) {
+ m_best = m;
+ n_best = n;
+ }
+
+ i810Reg->VideoClk2_M = (m_best-2) & 0x3FF;
+ i810Reg->VideoClk2_N = (n_best-2) & 0x3FF;
+ i810Reg->VideoClk2_DivisorSel = (p_best << 4);
+
+/* fprintf(stderr, "Setting dot clock to %.1f MHz " */
+/* "[ 0x%x 0x%x 0x%x ] " */
+/* "[ %d %d %d ]\n", */
+/* CALC_VCLK(m_best,n_best,p_best), */
+/* i810Reg->VideoClk2_M, */
+/* i810Reg->VideoClk2_N, */
+/* i810Reg->VideoClk2_DivisorSel, */
+/* m_best, n_best, p_best); */
+}
+
+/*
+ * I810CalcFIFO --
+ *
+ * Calculate burst length and FIFO watermark.
+ */
+
+#define Elements(x) (sizeof(x)/sizeof(*x))
+
+static unsigned int
+i810CalcWatermark( KdScreenInfo *screen, double freq, Bool dcache )
+{
+
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = card->driver;
+
+
+ struct wm_info *tab;
+ int nr;
+ int i;
+
+ if (i810c->LmFreqSel == 100) {
+ switch(screen->fb[0].bitsPerPixel) {
+ case 8:
+ tab = i810_wm_8_100;
+ nr = Elements(i810_wm_8_100);
+ break;
+ case 16:
+ tab = i810_wm_16_100;
+ nr = Elements(i810_wm_16_100);
+ break;
+ case 24:
+ tab = i810_wm_24_100;
+ nr = Elements(i810_wm_24_100);
+ break;
+ default:
+ return 0;
+ }
+ } else {
+ switch(screen->fb[0].bitsPerPixel) {
+ case 8:
+ tab = i810_wm_8_133;
+ nr = Elements(i810_wm_8_133);
+ break;
+ case 16:
+ tab = i810_wm_16_133;
+ nr = Elements(i810_wm_16_133);
+ break;
+ case 24:
+ tab = i810_wm_24_133;
+ nr = Elements(i810_wm_24_133);
+ break;
+ default:
+ return 0;
+ }
+ }
+
+ for (i = 0 ; i < nr && tab[i].freq < freq ; i++);
+
+ if (i == nr)
+ i--;
+
+/* fprintf(stderr,"chose watermark 0x%x: (tab.freq %.1f)\n", */
+/* tab[i].wm, tab[i].freq); */
+
+ /* None of these values (sourced from intel) have watermarks for
+ * the dcache memory. Fake it for now by using the same watermark
+ * for both...
+ *
+ * Update: this is probably because dcache isn't real useful as
+ * framebuffer memory, so intel's drivers don't need watermarks
+ * for that memory because they never use it to feed the ramdacs.
+ * We do use it in the fallback mode, so keep the watermarks for
+ * now.
+ */
+ if (dcache)
+ return (tab[i].wm & ~0xffffff) | ((tab[i].wm>>12) & 0xfff);
+ else
+ return tab[i].wm;
+}
+
+static void i810PrintMode( vgaRegPtr vgaReg, I810RegPtr mode )
+{
+ int i;
+
+ fprintf(stderr," MiscOut: %x\n", vgaReg->MiscOutReg);
+
+
+ fprintf(stderr,"SEQ: ");
+ for (i = 0 ; i < VGA_NUM_SEQ ; i++) {
+ if ((i&7)==0) fprintf(stderr,"\n");
+ fprintf(stderr," %d: %x", i, vgaReg->Sequencer[i]);
+ }
+ fprintf(stderr,"\n");
+
+ fprintf(stderr,"CRTC: ");
+ for (i = 0 ; i < VGA_NUM_CRTC ; i++) {
+ if ((i&3)==0) fprintf(stderr,"\n");
+ fprintf(stderr," CR%02x: %2x", i, vgaReg->CRTC[i]);
+ }
+ fprintf(stderr,"\n");
+
+ fprintf(stderr,"GFX: ");
+ for (i = 0 ; i < VGA_NUM_GFX ; i++) {
+ if ((i&3)==0) fprintf(stderr,"\n");
+ fprintf(stderr," GR%02x: %02x", i, vgaReg->Graphics[i]);
+ }
+ fprintf(stderr,"\n");
+
+ fprintf(stderr,"ATTR: ");
+ for (i = 0 ; i < VGA_NUM_ATTR ; i++) {
+ if ((i&7)==0) fprintf(stderr,"\n");
+ fprintf(stderr," %d: %x", i, vgaReg->Attribute[i]);
+ }
+ fprintf(stderr,"\n");
+
+
+ fprintf(stderr," DisplayControl: %x\n", mode->DisplayControl);
+ fprintf(stderr," PixelPipeCfg0: %x\n", mode->PixelPipeCfg0);
+ fprintf(stderr," PixelPipeCfg1: %x\n", mode->PixelPipeCfg1);
+ fprintf(stderr," PixelPipeCfg2: %x\n", mode->PixelPipeCfg2);
+ fprintf(stderr," VideoClk2_M: %x\n", mode->VideoClk2_M);
+ fprintf(stderr," VideoClk2_N: %x\n", mode->VideoClk2_N);
+ fprintf(stderr," VideoClk2_DivisorSel: %x\n", mode->VideoClk2_DivisorSel);
+ fprintf(stderr," AddressMapping: %x\n", mode->AddressMapping);
+ fprintf(stderr," IOControl: %x\n", mode->IOControl);
+ fprintf(stderr," BitBLTControl: %x\n", mode->BitBLTControl);
+ fprintf(stderr," ExtVertTotal: %x\n", mode->ExtVertTotal);
+ fprintf(stderr," ExtVertDispEnd: %x\n", mode->ExtVertDispEnd);
+ fprintf(stderr," ExtVertSyncStart: %x\n", mode->ExtVertSyncStart);
+ fprintf(stderr," ExtVertBlankStart: %x\n", mode->ExtVertBlankStart);
+ fprintf(stderr," ExtHorizTotal: %x\n", mode->ExtHorizTotal);
+ fprintf(stderr," ExtHorizBlank: %x\n", mode->ExtHorizBlank);
+ fprintf(stderr," ExtOffset: %x\n", mode->ExtOffset);
+ fprintf(stderr," InterlaceControl: %x\n", mode->InterlaceControl);
+ fprintf(stderr," LMI_FIFO_Watermark: %x\n", mode->LMI_FIFO_Watermark);
+ fprintf(stderr," LprbTail: %x\n", mode->LprbTail);
+ fprintf(stderr," LprbHead: %x\n", mode->LprbHead);
+ fprintf(stderr," LprbStart: %x\n", mode->LprbStart);
+ fprintf(stderr," LprbLen: %x\n", mode->LprbLen);
+ fprintf(stderr," OverlayActiveStart: %x\n", mode->OverlayActiveStart);
+ fprintf(stderr," OverlayActiveEnd: %x\n", mode->OverlayActiveEnd);
+}
+
+
+/*
+ * i810VGASeqReset
+ * perform a sequencer reset.
+ *
+ * The i815 documentation states that these bits are not used by the
+ * HW, but still warns about not programming them...
+ */
+
+static void
+i810VGASeqReset(i810VGAPtr vgap, Bool start)
+{
+ if (start)
+ {
+ mmioWriteSeq(vgap, 0x00, 0x01); /* Synchronous Reset */
+ }
+ else
+ {
+ mmioWriteSeq(vgap, 0x00, 0x03); /* End Reset */
+ }
+}
+
+static void
+i810VGAProtect(KdCardInfo *card, Bool on)
+{
+
+ I810CardInfo *i810c = card->driver;
+ i810VGAPtr vgap = &i810c->vga;
+
+ unsigned char tmp;
+
+ if (on) {
+ /*
+ * Turn off screen and disable sequencer.
+ */
+ tmp = mmioReadSeq(vgap, 0x01);
+
+ i810VGASeqReset(vgap, TRUE); /* start synchronous reset */
+ mmioWriteSeq(vgap, 0x01, tmp | 0x20); /* disable the display */
+
+ mmioEnablePalette(vgap);
+ } else {
+ /*
+ * Reenable sequencer, then turn on screen.
+ */
+
+ tmp = mmioReadSeq(vgap, 0x01);
+
+ mmioWriteSeq(vgap, 0x01, tmp & ~0x20); /* reenable display */
+ i810VGASeqReset(vgap, FALSE); /* clear synchronousreset */
+
+ mmioDisablePalette(vgap);
+ }
+}
+
+/*
+ * i810VGABlankScreen -- blank the screen.
+ */
+
+void
+i810VGABlankScreen(KdCardInfo *card, Bool on)
+{
+ I810CardInfo *i810c = card->driver;
+ i810VGAPtr vgap = &i810c->vga;
+
+ unsigned char scrn;
+
+ scrn = mmioReadSeq(vgap, 0x01);
+
+ if (on) {
+ scrn &= ~0x20; /* enable screen */
+ } else {
+ scrn |= 0x20; /* blank screen */
+ }
+
+ mmioWriteSeq(vgap,0x00,0x01);
+ mmioWriteSeq(vgap, 0x01, scrn); /* change mode */
+ mmioWriteSeq(vgap,0x00,0x03);
+}
+
+/* Restore hardware state */
+
+static void
+DoRestore(KdCardInfo *card, vgaRegPtr vgaReg, I810RegPtr i810Reg,
+ Bool restoreFonts) {
+
+
+ I810CardInfo *i810c = card->driver;
+
+ i810VGAPtr vgap = &i810c->vga;
+
+ unsigned char temp;
+ unsigned int itemp;
+ int i;
+
+ if (I810_DEBUG & DEBUG_VERBOSE_VGA) {
+ fprintf(stderr,"Setting mode in DoRestore:\n");
+ i810PrintMode( vgaReg, i810Reg );
+ }
+
+ /* Blank screen (i810vgaprotect) */
+ i810VGAProtect(card, TRUE);
+
+ /* Should wait for at least two hsync and no more than two vsync
+ before writing PIXCONF and turning the display on (?) */
+ usleep(50000);
+
+ /* Turn off DRAM Refresh */
+ temp = INREG8( DRAM_ROW_CNTL_HI );
+ temp &= ~DRAM_REFRESH_RATE;
+ temp |= DRAM_REFRESH_DISABLE;
+ OUTREG8( DRAM_ROW_CNTL_HI, temp );
+
+ usleep(1000); /* Wait 1 ms */
+
+ /* Write the M, N and P values */
+ OUTREG16( VCLK2_VCO_M, i810Reg->VideoClk2_M);
+ OUTREG16( VCLK2_VCO_N, i810Reg->VideoClk2_N);
+ OUTREG8( VCLK2_VCO_DIV_SEL, i810Reg->VideoClk2_DivisorSel);
+
+ /*
+ * Turn on 8 bit dac mode, if requested. This is needed to make
+ * sure that vgaHWRestore writes the values into the DAC properly.
+ * The problem occurs if 8 bit dac mode is requested and the HW is
+ * in 6 bit dac mode. If this happens, all the values are
+ * automatically shifted left twice by the HW and incorrect colors
+ * will be displayed on the screen. The only time this can happen
+ * is at server startup time and when switching back from a VT.
+ */
+ temp = INREG8(PIXPIPE_CONFIG_0);
+ temp &= 0x7F; /* Save all but the 8 bit dac mode bit */
+ temp |= (i810Reg->PixelPipeCfg0 & DAC_8_BIT);
+ OUTREG8( PIXPIPE_CONFIG_0, temp );
+
+ /*
+ * Code to restore any SVGA registers that have been saved/modified
+ * goes here. Note that it is allowable, and often correct, to
+ * only modify certain bits in a register by a read/modify/write cycle.
+ *
+ * A special case - when using an external clock-setting program,
+ * this function must not change bits associated with the clock
+ * selection. This condition can be checked by the condition:
+ *
+ * if (i810Reg->std.NoClock >= 0)
+ * restore clock-select bits.
+ */
+
+ /* VGA restore */
+ if (vgaReg->MiscOutReg & 0x01)
+ vgap->IOBase = VGA_IOBASE_COLOR;
+ else
+ vgap->IOBase = VGA_IOBASE_MONO;
+
+ mmioWriteMiscOut(vgap, vgaReg->MiscOutReg);
+
+ for (i = 1; i < VGA_NUM_SEQ; i++)
+ mmioWriteSeq(vgap, i, vgaReg->Sequencer[i]);
+
+ /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 or CRTC[17] */
+ /* = CR11 */
+ mmioWriteCrtc(vgap, 17, vgaReg->CRTC[17] & ~0x80);
+
+ for (i = 0; i < VGA_NUM_CRTC; i++) {
+ mmioWriteCrtc(vgap, i, vgaReg->CRTC[i]);
+ }
+
+ for (i = 0; i < VGA_NUM_GFX; i++)
+ mmioWriteGr(vgap, i, vgaReg->Graphics[i]);
+
+ mmioEnablePalette(vgap);
+ for (i = 0; i < VGA_NUM_ATTR; i++)
+ mmioWriteAttr(vgap, i, vgaReg->Attribute[i]);
+ mmioDisablePalette(vgap);
+
+
+ mmioWriteCrtc(vgap, EXT_VERT_TOTAL, i810Reg->ExtVertTotal);
+ mmioWriteCrtc(vgap, EXT_VERT_DISPLAY, i810Reg->ExtVertDispEnd);
+ mmioWriteCrtc(vgap, EXT_VERT_SYNC_START, i810Reg->ExtVertSyncStart);
+ mmioWriteCrtc(vgap, EXT_VERT_BLANK_START, i810Reg->ExtVertBlankStart);
+ mmioWriteCrtc(vgap, EXT_HORIZ_TOTAL, i810Reg->ExtHorizTotal);
+ mmioWriteCrtc(vgap, EXT_HORIZ_BLANK, i810Reg->ExtHorizBlank);
+
+ /* write CR40, CR42 first etc to get CR13 written as described in PRM */
+
+ mmioWriteCrtc(vgap, EXT_START_ADDR_HI, 0);
+ mmioWriteCrtc(vgap, EXT_START_ADDR, EXT_START_ADDR_ENABLE);
+
+ mmioWriteCrtc(vgap, EXT_OFFSET, i810Reg->ExtOffset);
+ mmioWriteCrtc(vgap, 0x13, vgaReg->CRTC[0x13]);
+
+ temp=mmioReadCrtc(vgap, INTERLACE_CNTL);
+ temp &= ~INTERLACE_ENABLE;
+ temp |= i810Reg->InterlaceControl;
+ mmioWriteCrtc(vgap, INTERLACE_CNTL, temp);
+
+ temp=i810ReadControlMMIO(i810c, GRX, ADDRESS_MAPPING);
+ temp &= 0xE0; /* Save reserved bits 7:5 */
+ temp |= i810Reg->AddressMapping;
+ i810WriteControlMMIO(i810c, GRX, ADDRESS_MAPPING, temp);
+
+ /* Setting the OVRACT Register for video overlay*/
+ OUTREG(0x6001C, (i810Reg->OverlayActiveEnd << 16) | i810Reg->OverlayActiveStart);
+
+ /* Turn on DRAM Refresh */
+ temp = INREG8( DRAM_ROW_CNTL_HI );
+ temp &= ~DRAM_REFRESH_RATE;
+ temp |= DRAM_REFRESH_60HZ;
+ OUTREG8( DRAM_ROW_CNTL_HI, temp );
+
+ temp = INREG8( BITBLT_CNTL );
+ temp &= ~COLEXP_MODE;
+ temp |= i810Reg->BitBLTControl;
+ OUTREG8( BITBLT_CNTL, temp );
+
+ temp = INREG8( DISPLAY_CNTL );
+ temp &= ~(VGA_WRAP_MODE | GUI_MODE);
+ temp |= i810Reg->DisplayControl;
+ OUTREG8( DISPLAY_CNTL, temp );
+
+
+ temp = INREG8( PIXPIPE_CONFIG_0 );
+ temp &= 0x64; /* Save reserved bits 6:5,2 */
+ temp |= i810Reg->PixelPipeCfg0;
+ OUTREG8( PIXPIPE_CONFIG_0, temp );
+
+ temp = INREG8( PIXPIPE_CONFIG_2 );
+ temp &= 0xF3; /* Save reserved bits 7:4,1:0 */
+ temp |= i810Reg->PixelPipeCfg2;
+ OUTREG8( PIXPIPE_CONFIG_2, temp );
+
+ temp = INREG8( PIXPIPE_CONFIG_1 );
+ temp &= ~DISPLAY_COLOR_MODE;
+ temp &= 0xEF; /* Restore the CRT control bit */
+ temp |= i810Reg->PixelPipeCfg1;
+ OUTREG8( PIXPIPE_CONFIG_1, temp );
+
+ OUTREG16(EIR, 0);
+
+ itemp = INREG(FWATER_BLC);
+ itemp &= ~(LM_BURST_LENGTH | LM_FIFO_WATERMARK |
+ MM_BURST_LENGTH | MM_FIFO_WATERMARK );
+ itemp |= i810Reg->LMI_FIFO_Watermark;
+ OUTREG(FWATER_BLC, itemp);
+
+
+ for (i = 0 ; i < 8 ; i++) {
+ OUTREG( FENCE+i*4, i810Reg->Fence[i] );
+ if (I810_DEBUG & DEBUG_VERBOSE_VGA)
+ fprintf(stderr,"Fence Register : %x\n", i810Reg->Fence[i]);
+ }
+
+ /* First disable the ring buffer (Need to wait for empty first?, if so
+ * should probably do it before entering this section)
+ */
+ itemp = INREG(LP_RING + RING_LEN);
+ itemp &= ~RING_VALID_MASK;
+ OUTREG(LP_RING + RING_LEN, itemp );
+
+ /* Set up the low priority ring buffer.
+ */
+ OUTREG(LP_RING + RING_TAIL, 0 );
+ OUTREG(LP_RING + RING_HEAD, 0 );
+
+ i810c->LpRing.head = 0;
+ i810c->LpRing.tail = 0;
+
+ itemp = INREG(LP_RING + RING_START);
+ itemp &= ~(START_ADDR);
+ itemp |= i810Reg->LprbStart;
+ OUTREG(LP_RING + RING_START, itemp );
+
+ itemp = INREG(LP_RING + RING_LEN);
+ itemp &= ~(RING_NR_PAGES | RING_REPORT_MASK | RING_VALID_MASK);
+ itemp |= i810Reg->LprbLen;
+ OUTREG(LP_RING + RING_LEN, itemp );
+
+ i810VGAProtect(card, FALSE);
+
+ temp=mmioReadCrtc(vgap, IO_CTNL);
+ temp &= ~(EXTENDED_ATTR_CNTL | EXTENDED_CRTC_CNTL);
+ temp |= i810Reg->IOControl;
+ mmioWriteCrtc(vgap, IO_CTNL, temp);
+ /* Protect CRTC[0-7] */
+ mmioWriteCrtc(vgap, 0x11, mmioReadCrtc(vgap, 0x11) | 0x80);
+}
+
+
+static Bool
+i810SetMode(KdScreenInfo *screen, const KdMonitorTiming *t)
+{
+
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = card->driver;
+ i810VGAPtr vgap = &i810c->vga;
+
+ I810RegPtr i810Reg = &i810c->ModeReg;
+ vgaRegPtr pVga = &vgap->ModeReg;
+
+ double dclk = t->clock/1000.0;
+
+ switch (screen->fb[0].bitsPerPixel) {
+ case 8:
+ pVga->CRTC[0x13] = screen->width >> 3;
+ i810Reg->ExtOffset = screen->width >> 11;
+ i810Reg->PixelPipeCfg1 = DISPLAY_8BPP_MODE;
+ i810Reg->BitBLTControl = COLEXP_8BPP;
+ break;
+ case 16:
+ i810Reg->PixelPipeCfg1 = DISPLAY_16BPP_MODE;
+ pVga->CRTC[0x13] = screen->width >> 2;
+ i810Reg->ExtOffset = screen->width >> 10;
+ i810Reg->BitBLTControl = COLEXP_16BPP;
+ break;
+ case 24:
+ pVga->CRTC[0x13] = (screen->width * 3) >> 3;
+ i810Reg->ExtOffset = (screen->width * 3) >> 11;
+
+ i810Reg->PixelPipeCfg1 = DISPLAY_24BPP_MODE;
+ i810Reg->BitBLTControl = COLEXP_24BPP;
+ break;
+ default:
+ break;
+ }
+
+ i810Reg->PixelPipeCfg0 = DAC_8_BIT;
+
+ /* Do not delay CRT Blank: needed for video overlay */
+ i810Reg->PixelPipeCfg1 |= 0x10;
+
+ /* Turn on Extended VGA Interpretation */
+ i810Reg->IOControl = EXTENDED_CRTC_CNTL;
+
+ /* Turn on linear and page mapping */
+ i810Reg->AddressMapping = (LINEAR_MODE_ENABLE |
+ GTT_MEM_MAP_ENABLE);
+
+ /* Turn on GUI mode */
+ i810Reg->DisplayControl = HIRES_MODE;
+
+ i810Reg->OverlayActiveStart = t->horizontal + t->hblank - 32;
+ i810Reg->OverlayActiveEnd = t->horizontal - 32;
+
+ /* Turn on interlaced mode if necessary (it's not) */
+ i810Reg->InterlaceControl = INTERLACE_DISABLE;
+
+ /*
+ * Set the overscan color to 0.
+ * NOTE: This only affects >8bpp mode.
+ */
+ pVga->Attribute[0x11] = 0;
+
+ /*
+ * Calculate the VCLK that most closely matches the requested dot
+ * clock.
+ */
+ i810CalcVCLK(screen, dclk);
+
+ /* Since we program the clocks ourselves, always use VCLK2. */
+ pVga->MiscOutReg |= 0x0C;
+
+ /* Calculate the FIFO Watermark and Burst Length. */
+ i810Reg->LMI_FIFO_Watermark = i810CalcWatermark(screen, dclk, FALSE);
+
+ /* Setup the ring buffer */
+ i810Reg->LprbTail = 0;
+ i810Reg->LprbHead = 0;
+ i810Reg->LprbStart = i810c->LpRing.mem.Start;
+
+ if (i810Reg->LprbStart)
+ i810Reg->LprbLen = ((i810c->LpRing.mem.Size-4096) |
+ RING_NO_REPORT | RING_VALID);
+ else
+ i810Reg->LprbLen = RING_INVALID;
+
+ return TRUE;
+}
+
+static Bool
+i810ModeInit(KdScreenInfo *screen, const KdMonitorTiming *t)
+{
+
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = card->driver;
+ i810VGAPtr vgap = &i810c->vga;
+ vgaRegPtr pVga;
+
+/* fprintf(stderr,"i810ModeInit\n"); */
+
+ i810VGAUnlock(vgap);
+
+ if (!i810VGAInit(screen, t)) return FALSE;
+ pVga = &vgap->ModeReg;
+
+ if (!i810SetMode(screen, t)) return FALSE;
+
+ DoRestore(screen->card, &vgap->ModeReg, &i810c->ModeReg, FALSE);
+
+ return TRUE;
+}
+
+Bool
+i810VGAInit(KdScreenInfo *screen, const KdMonitorTiming *t)
+{
+ unsigned int i;
+
+ int hactive, hblank, hbp, hfp;
+ int vactive, vblank, vbp, vfp;
+ int h_screen_off = 0, h_adjust = 0, h_total, h_display_end, h_blank_start;
+ int h_blank_end, h_sync_start, h_sync_end, v_total, v_retrace_start;
+ int v_retrace_end, v_display_end, v_blank_start, v_blank_end;
+
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = card->driver;
+
+ i810VGAPtr vgap = &i810c->vga;
+ I810RegPtr ireg = &i810c->ModeReg;
+
+
+ vgaRegPtr regp;
+ int depth = screen->fb[0].depth;
+
+ regp = &vgap->ModeReg;
+
+ /*
+ * compute correct Hsync & Vsync polarity
+ */
+
+ regp->MiscOutReg = 0x23;
+ if (t->vpol == KdSyncNegative) regp->MiscOutReg |= 0x40;
+ if (t->hpol == KdSyncNegative) regp->MiscOutReg |= 0x80;
+
+ /*
+ * Time Sequencer
+ */
+ if (depth == 4)
+ regp->Sequencer[0] = 0x02;
+ else
+ regp->Sequencer[0] = 0x00;
+ /* No support for 320 or 360 x resolution */
+ regp->Sequencer[1] = 0x01;
+
+ if (depth == 1)
+ regp->Sequencer[2] = 1 << BIT_PLANE;
+ else
+ regp->Sequencer[2] = 0x0F;
+
+ regp->Sequencer[3] = 0x00; /* Font select */
+
+ if (depth < 8)
+ regp->Sequencer[4] = 0x06; /* Misc */
+ else
+ regp->Sequencer[4] = 0x0E; /* Misc */
+
+ hactive = t->horizontal;
+ hblank = t->hblank;
+ hbp = t->hbp;
+ hfp = t->hfp;
+
+ vactive = t->vertical;
+ vblank = t->vblank;
+ vbp = t->vbp;
+ vfp = t->vfp;
+
+ switch (screen->fb[0].bitsPerPixel) {
+ case 8:
+ hactive /= 8;
+ hblank /= 8;
+ hfp /= 8;
+ hbp /= 8;
+ h_screen_off = hactive;
+ h_adjust = 1;
+ break;
+ case 16:
+ hactive /= 8;
+ hblank /= 8;
+ hfp /= 8;
+ hbp /= 8;
+
+ h_screen_off = hactive * 2;
+ h_adjust = 1;
+ break;
+ case 24:
+ hactive /= 8;
+ hblank /= 8;
+ hfp /= 8;
+ hbp /= 8;
+
+ h_screen_off = hactive * 3;
+ h_adjust = 1;
+ break;
+ case 32:
+ hactive /= 8;
+ hblank /= 8;
+ hfp /= 8;
+ hbp /= 8;
+
+ h_screen_off = hactive * 4;
+ h_adjust = 1;
+ break;
+ }
+
+ /*
+ * Compute horizontal register values from timings
+ */
+ h_total = hactive + hblank - 5;
+ h_display_end = hactive - 1;
+ h_blank_start = h_display_end;
+ h_blank_end = h_blank_start + hblank;
+
+ h_sync_start = hactive + hfp + h_adjust;
+ h_sync_end = h_sync_start + hblank - hbp - hfp;
+
+ /* Set CRTC regs for horizontal timings */
+ regp->CRTC[0x0] = h_total;
+ ireg->ExtHorizTotal=(h_total & 0x100) >> 8;
+
+ regp->CRTC[0x1] = h_display_end;
+
+ regp->CRTC[0x2] = h_blank_start;
+
+ regp->CRTC[0x3] = 0x80 | (h_blank_end & 0x1f);
+ regp->CRTC[0x5] = (h_blank_end & 0x20) << 2;
+
+ regp->CRTC[0x4] = h_sync_start;
+
+ regp->CRTC[0x5] |= h_sync_end & 0x1f;
+
+ regp->CRTC[0x13] = h_screen_off;
+ ireg->ExtOffset = h_screen_off >> 8;
+
+ /* Compute vertical timings */
+ v_total = vactive + vblank - 2;
+ v_retrace_start = vactive + vfp - 1;
+ v_retrace_end = v_retrace_start + vblank - vbp - vfp;
+ v_display_end = vactive - 1;
+ v_blank_start = vactive - 1;
+ v_blank_end = v_blank_start + vblank /* - 1 */;
+
+ regp->CRTC[0x6] = v_total;
+ ireg->ExtVertTotal = v_total >> 8;
+
+ regp->CRTC[0x10] = v_retrace_start;
+ ireg->ExtVertSyncStart = v_retrace_start >> 8;
+
+ regp->CRTC[0x11] = v_retrace_end;
+
+ regp->CRTC[0x12] = v_display_end;
+ ireg->ExtVertDispEnd = v_display_end >> 8;
+
+ regp->CRTC[0x15] = v_blank_start;
+ ireg->ExtVertBlankStart = v_blank_start >> 8;
+
+ regp->CRTC[0x16] = v_blank_end;
+
+ if (depth < 8)
+ regp->CRTC[23] = 0xE3;
+ else
+ regp->CRTC[23] = 0xC3;
+ regp->CRTC[24] = 0xFF;
+
+ /*
+ * Graphics Display Controller
+ */
+ regp->Graphics[0] = 0x00;
+ regp->Graphics[1] = 0x00;
+ regp->Graphics[2] = 0x00;
+ regp->Graphics[3] = 0x00;
+ if (depth == 1) {
+ regp->Graphics[4] = BIT_PLANE;
+ regp->Graphics[5] = 0x00;
+ } else {
+ regp->Graphics[4] = 0x00;
+ if (depth == 4)
+ regp->Graphics[5] = 0x02;
+ else
+ regp->Graphics[5] = 0x40;
+ }
+ regp->Graphics[6] = 0x05;
+ regp->Graphics[7] = 0x0F;
+ regp->Graphics[8] = 0xFF;
+
+ if (depth == 1) {
+ /* Initialise the Mono map according to which bit-plane gets used */
+
+ Bool flipPixels = FALSE; /* maybe support this in the future? */
+
+ for (i=0; i<16; i++)
+ if (((i & (1 << BIT_PLANE)) != 0) != flipPixels)
+ regp->Attribute[i] = WHITE_VALUE;
+ else
+ regp->Attribute[i] = BLACK_VALUE;
+
+ regp->Attribute[16] = 0x01; /* -VGA2- */
+ if (!vgap->ShowOverscan)
+ regp->Attribute[OVERSCAN] = OVERSCAN_VALUE; /* -VGA2- */
+ } else {
+ regp->Attribute[0] = 0x00; /* standard colormap translation */
+ regp->Attribute[1] = 0x01;
+ regp->Attribute[2] = 0x02;
+ regp->Attribute[3] = 0x03;
+ regp->Attribute[4] = 0x04;
+ regp->Attribute[5] = 0x05;
+ regp->Attribute[6] = 0x06;
+ regp->Attribute[7] = 0x07;
+ regp->Attribute[8] = 0x08;
+ regp->Attribute[9] = 0x09;
+ regp->Attribute[10] = 0x0A;
+ regp->Attribute[11] = 0x0B;
+ regp->Attribute[12] = 0x0C;
+ regp->Attribute[13] = 0x0D;
+ regp->Attribute[14] = 0x0E;
+ regp->Attribute[15] = 0x0F;
+ if (depth == 4)
+ regp->Attribute[16] = 0x81;
+ else
+ regp->Attribute[16] = 0x41;
+ /* Attribute[17] (overscan) was initialised earlier */
+ }
+ regp->Attribute[18] = 0x0F;
+ regp->Attribute[19] = 0x00;
+ regp->Attribute[20] = 0x00;
+
+ return(TRUE);
+}
+
+void
+i810VGALock(i810VGAPtr vgap)
+{
+ /* Protect CRTC[0-7] */
+ mmioWriteCrtc(vgap, 0x11, mmioReadCrtc(vgap, 0x11) & ~0x80);
+}
+
+void
+i810VGAUnlock(i810VGAPtr vgap)
+{
+ /* Unprotect CRTC[0-7] */
+ mmioWriteCrtc(vgap, 0x11, mmioReadCrtc(vgap, 0x11) | 0x80);
+}
+
+static void
+i810Restore(KdCardInfo *card) {
+
+ I810CardInfo *i810c = card->driver;
+
+ i810VGAPtr vgap = &i810c->vga;
+
+ if (I810_DEBUG)
+ fprintf(stderr,"i810Restore\n");
+
+ DoRestore(card, &vgap->SavedReg, &i810c->SavedReg, TRUE);
+}
+
+static Bool
+i810Enable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ KdCardInfo *card = pScreenPriv->card;
+ I810CardInfo *i810c = card->driver;
+ i810VGAPtr vgap = &i810c->vga;
+ const KdMonitorTiming *t;
+
+ if (I810_DEBUG)
+ fprintf(stderr,"i810Enable\n");
+
+ vgap->IOBase = (mmioReadMiscOut(vgap) & 0x01) ?
+ VGA_IOBASE_COLOR : VGA_IOBASE_MONO;
+
+ {
+ I810RegPtr i810Reg = &i810c->ModeReg;
+ int i;
+
+ for (i = 0 ; i < 8 ; i++)
+ i810Reg->Fence[i] = 0;
+ }
+
+ t = KdFindMode (screen, i810ModeSupported);
+
+ if (!i810BindGARTMemory(screen))
+ return FALSE;
+
+ if (!i810ModeInit(screen, t)) return FALSE;
+
+ {
+ /* DPMS power on state */
+
+ unsigned char SEQ01=0;
+ int DPMSSyncSelect=0;
+
+ SEQ01 = 0x00;
+ DPMSSyncSelect = HSYNC_ON | VSYNC_ON;
+
+ SEQ01 |= i810ReadControlMMIO(i810c, SRX, 0x01) & ~0x20;
+ i810WriteControlMMIO(i810c, SRX, 0x01, SEQ01);
+
+ /* Set the DPMS mode */
+ OUTREG8(DPMS_SYNC_SELECT, DPMSSyncSelect);
+ }
+#ifdef XV
+ KdXVEnable (pScreen);
+#endif
+ return TRUE;
+}
+
+
+static void
+i810Disable(ScreenPtr pScreen) {
+
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ KdCardInfo *card = pScreenPriv->card;
+ I810CardInfo *i810c = card->driver;
+
+ i810VGAPtr vgap = &i810c->vga;
+
+ if (I810_DEBUG)
+ fprintf(stderr,"i810Disable\n");
+
+#ifdef XV
+ KdXVDisable (pScreen);
+#endif
+ i810Restore(screen->card);
+
+ if (!i810UnbindGARTMemory(screen))
+ return;
+
+ i810VGALock(vgap);
+}
+
+
+static Bool
+i810DPMS(ScreenPtr pScreen, int mode)
+{
+ KdScreenPriv(pScreen);
+ KdCardInfo *card = pScreenPriv->card;
+ I810CardInfo *i810c = card->driver;
+
+ unsigned char SEQ01=0;
+ int DPMSSyncSelect=0;
+
+ if (I810_DEBUG)
+ fprintf(stderr,"i810DPMS: %d\n",mode);
+
+ switch (mode) {
+ case KD_DPMS_NORMAL:
+ /* Screen: On; HSync: On, VSync: On */
+ SEQ01 = 0x00;
+ DPMSSyncSelect = HSYNC_ON | VSYNC_ON;
+ break;
+ case KD_DPMS_STANDBY:
+ /* Screen: Off; HSync: Off, VSync: On */
+ SEQ01 = 0x20;
+ DPMSSyncSelect = HSYNC_OFF | VSYNC_ON;
+ break;
+ case KD_DPMS_SUSPEND:
+ /* Screen: Off; HSync: On, VSync: Off */
+ SEQ01 = 0x20;
+ DPMSSyncSelect = HSYNC_ON | VSYNC_OFF;
+ break;
+ case KD_DPMS_POWERDOWN:
+ /* Screen: Off; HSync: Off, VSync: Off */
+ SEQ01 = 0x20;
+ DPMSSyncSelect = HSYNC_OFF | VSYNC_OFF;
+ break;
+ }
+
+ /* Turn the screen on/off */
+ SEQ01 |= i810ReadControlMMIO(i810c, SRX, 0x01) & ~0x20;
+ i810WriteControlMMIO(i810c, SRX, 0x01, SEQ01);
+
+ /* Set the DPMS mode */
+ OUTREG8(DPMS_SYNC_SELECT, DPMSSyncSelect);
+ return TRUE;
+}
+
+
+static void
+i810GetColors (ScreenPtr pScreen, int fb, int ndefs, xColorItem *c)
+{
+
+ if (I810_DEBUG)
+ fprintf(stderr,"i810GetColors (NOT IMPLEMENTED)\n");
+}
+
+#define DACDelay(hw) \
+ do { \
+ unsigned char temp = Vminb((hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
+ temp = Vminb((hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
+ } while (0)
+
+static void
+i810PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
+{
+
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+
+ i810VGAPtr vgap = &i810c->vga;
+
+ if (I810_DEBUG)
+ fprintf(stderr,"i810PutColors\n");
+
+ while (ndef--)
+ {
+ mmioWriteDacWriteAddr(vgap, pdefs->pixel);
+ DACDelay(vgap);
+ mmioWriteDacData(vgap, pdefs->red);
+ DACDelay(vgap);
+ mmioWriteDacData(vgap, pdefs->green);
+ DACDelay(vgap);
+ mmioWriteDacData(vgap, pdefs->blue);
+ DACDelay(vgap);
+
+ pdefs++;
+ }
+}
+
+
+KdCardFuncs i810Funcs = {
+ i810CardInit, /* cardinit */
+ i810ScreenInit, /* scrinit */
+ i810InitScreen, /* initScreen */
+ i810FinishInitScreen, /* finishInitScreen */
+ NULL, /* createResources */
+ i810Preserve, /* preserve */
+ i810Enable, /* enable */
+ i810DPMS, /* dpms */
+ i810Disable, /* disable */
+ i810Restore, /* restore */
+ i810ScreenFini, /* scrfini */
+ i810CardFini, /* cardfini */
+
+ i810CursorInit, /* initCursor */
+ i810CursorEnable, /* enableCursor */
+ i810CursorDisable, /* disableCursor */
+ i810CursorFini, /* finiCursor */
+ NULL, /* recolorCursor */
+
+ i810InitAccel, /* initAccel */
+ i810EnableAccel, /* enableAccel */
+ i810DisableAccel, /* disableAccel */
+ i810FiniAccel, /* finiAccel */
+
+ i810GetColors, /* getColors */
+ i810PutColors, /* putColors */
+};
diff --git a/xorg-server/hw/kdrive/i810/i810.h b/xorg-server/hw/kdrive/i810/i810.h
new file mode 100644
index 000000000..8fc2d56be
--- /dev/null
+++ b/xorg-server/hw/kdrive/i810/i810.h
@@ -0,0 +1,511 @@
+/* COPYRIGHT AND PERMISSION NOTICE
+
+Copyright (c) 2000, 2001 Nokia Home Communications
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+X Window System is a trademark of The Open Group */
+
+/*
+ * Author:
+ * Pontus Lidman <pontus.lidman@nokia.com>
+ */
+
+#ifndef _I810_H_
+#define _I810_H_
+
+#include "i810_reg.h"
+
+/* Globals */
+
+typedef struct _I810Rec *I810Ptr;
+
+/* Linear region allocated in framebuffer.
+ */
+typedef struct {
+ unsigned long Start;
+ unsigned long End;
+ unsigned long Size;
+} I810MemRange;
+
+typedef struct {
+ int tail_mask;
+ I810MemRange mem;
+ unsigned char *virtual_start;
+ int head;
+ int tail;
+ int space;
+} I810RingBuffer;
+
+typedef struct {
+ unsigned char DisplayControl;
+ unsigned char PixelPipeCfg0;
+ unsigned char PixelPipeCfg1;
+ unsigned char PixelPipeCfg2;
+ unsigned short VideoClk2_M;
+ unsigned short VideoClk2_N;
+ unsigned char VideoClk2_DivisorSel;
+ unsigned char AddressMapping;
+ unsigned char IOControl;
+ unsigned char BitBLTControl;
+ unsigned char ExtVertTotal;
+ unsigned char ExtVertDispEnd;
+ unsigned char ExtVertSyncStart;
+ unsigned char ExtVertBlankStart;
+ unsigned char ExtHorizTotal;
+ unsigned char ExtHorizBlank;
+ unsigned char ExtOffset;
+ unsigned char InterlaceControl;
+ unsigned int LMI_FIFO_Watermark;
+
+ unsigned int LprbTail;
+ unsigned int LprbHead;
+ unsigned int LprbStart;
+ unsigned int LprbLen;
+
+ unsigned int Fence[8];
+
+ unsigned short OverlayActiveStart;
+ unsigned short OverlayActiveEnd;
+
+
+} I810RegRec, *I810RegPtr;
+
+#define minb(p) *(volatile CARD8 *)(i810c->MMIOBase + (p))
+#define moutb(p,v) *(volatile CARD8 *)(i810c->MMIOBase + (p)) = (v)
+
+#define OUT_RING(n) { \
+ if (I810_DEBUG & DEBUG_VERBOSE_RING) \
+ ErrorF( "OUT_RING %x: %x\n", outring, n); \
+ *(volatile unsigned int *)(virt + outring) = n; \
+ outring += 4; \
+ outring &= ringmask; \
+}
+
+#define ADVANCE_LP_RING() { \
+ i810c->LpRing.tail = outring; \
+ OUTREG(LP_RING + RING_TAIL, outring); \
+}
+
+#ifdef __GNUC__
+#define LP_RING_MESSAGE(n) \
+ ErrorF("BEGIN_LP_RING %d in %s\n", n, __FUNCTION__)
+#else
+#define LP_RING_MESSAGE(n) \
+ ErrorF("BEGIN_LP_RING %d in %s:%d\n", n, __FILE__, __LINE__)
+#endif
+
+#define LP_RING_LOCALS \
+ unsigned int outring, ringmask; \
+ volatile unsigned char *virt
+
+#define BEGIN_LP_RING(n) \
+ if (n>2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC)) \
+ i810Sync(i810s); \
+ if (i810c->LpRing.space < n*4) i810WaitLpRing(i810s, n*4, 0); \
+ i810c->LpRing.space -= n*4; \
+ if (I810_DEBUG & DEBUG_VERBOSE_RING) \
+ LP_RING_MESSAGE(n); \
+ outring = i810c->LpRing.tail; \
+ ringmask = i810c->LpRing.tail_mask; \
+ virt = i810c->LpRing.virtual_start;
+
+/* Memory mapped register access macros */
+#define INREG8(addr) *(volatile CARD8 *)(i810c->MMIOBase + (addr))
+#define INREG16(addr) *(volatile CARD16 *)(i810c->MMIOBase + (addr))
+#define INREG(addr) *(volatile CARD32 *)(i810c->MMIOBase + (addr))
+
+#define OUTREG8(addr, val) do { \
+ *(volatile CARD8 *)(i810c->MMIOBase + (addr)) = (val); \
+ if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) \
+ ErrorF( "OUTREG8(%x, %x)\n", addr, val); \
+} while (0)
+
+#define OUTREG16(addr, val) do { \
+ *(volatile CARD16 *)(i810c->MMIOBase + (addr)) = (val); \
+ if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) \
+ ErrorF( "OUTREG16(%x, %x)\n", addr, val); \
+} while (0)
+
+#define OUTREG(addr, val) do { \
+ *(volatile CARD32 *)(i810c->MMIOBase + (addr)) = (val); \
+ if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) \
+ ErrorF( "OUTREG(%x, %x)\n", addr, val); \
+} while (0)
+
+/* To remove all debugging, make sure I810_DEBUG is defined as a
+ * preprocessor symbol, and equal to zero.
+ */
+
+#define I810_DEBUG 0
+
+#ifndef I810_DEBUG
+#warning "Debugging enabled - expect reduced performance"
+extern int I810_DEBUG;
+#endif
+
+#define DEBUG_VERBOSE_ACCEL 0x1
+#define DEBUG_VERBOSE_SYNC 0x2
+#define DEBUG_VERBOSE_VGA 0x4
+#define DEBUG_VERBOSE_RING 0x8
+#define DEBUG_VERBOSE_OUTREG 0x10
+#define DEBUG_VERBOSE_MEMORY 0x20
+#define DEBUG_VERBOSE_CURSOR 0x40
+#define DEBUG_ALWAYS_SYNC 0x80
+#define DEBUG_VERBOSE_DRI 0x100
+
+
+/* Size of the mmio region.
+ */
+#define I810_REG_SIZE 0x80000
+
+/* PCI identifiers */
+#ifndef PCI_CHIP_I810
+#define PCI_CHIP_I810 0x7121
+#define PCI_CHIP_I810_DC100 0x7123
+#define PCI_CHIP_I810_E 0x7125
+#define PCI_CHIP_I815 0x1132
+#define PCI_CHIP_I810_BRIDGE 0x7120
+#define PCI_CHIP_I810_DC100_BRIDGE 0x7122
+#define PCI_CHIP_I810_E_BRIDGE 0x7124
+#define PCI_CHIP_I815_BRIDGE 0x1130
+#define PCI_CHIP_I845G 0x2562
+#endif
+
+
+#define IS_I810(i810c) (i810c->PciInfo->chipType == PCI_CHIP_I810 || \
+ i810c->PciInfo->chipType == PCI_CHIP_I810_DC100 || \
+ i810c->PciInfo->chipType == PCI_CHIP_I810_E)
+#define IS_I815(i810c) (i810c->PciInfo->chipType == PCI_CHIP_I815)
+
+
+/* default number of VGA registers stored internally */
+#define VGA_NUM_CRTC 25 /* 0x19 */
+#define VGA_NUM_SEQ 5
+#define VGA_NUM_GFX 9
+#define VGA_NUM_ATTR 21
+
+/*
+ * Settings of standard VGA registers.
+ */
+typedef struct {
+ unsigned char MiscOutReg; /* */
+ unsigned char CRTC[VGA_NUM_CRTC]; /* Crtc Controller */
+ unsigned char Sequencer[VGA_NUM_SEQ]; /* Video Sequencer */
+ unsigned char Graphics[VGA_NUM_GFX]; /* Video Graphics */
+ unsigned char Attribute[VGA_NUM_ATTR]; /* Video Atribute */
+ unsigned char DAC[768]; /* Internal Colorlookuptable */
+} vgaRegRec, *vgaRegPtr;
+
+
+typedef struct _i810VGARec *i810VGAPtr;
+
+/* VGA registers */
+typedef struct _i810VGARec {
+ int IOBase; /* I/O Base address */
+ CARD8 * MMIOBase; /* Pointer to MMIO start */
+ vgaRegRec SavedReg; /* saved registers */
+ vgaRegRec ModeReg; /* register settings for
+ current mode */
+ Bool ShowOverscan;
+ Bool paletteEnabled;
+ Bool cmapSaved;
+} i810VGARec;
+
+typedef struct _i810CardInfo {
+ int videoRam;
+ int MaxClock;
+ long FbMapSize;
+ int cpp; /* chars per pixel */
+
+ unsigned long LinearAddr;
+ unsigned long MMIOAddr;
+
+ unsigned char *MMIOBase;
+ unsigned char *FbBase;
+
+ Bool GttBound;
+ Bool agpAcquired2d;
+ int VramKey;
+ unsigned long VramOffset;
+ int DcacheKey;
+ unsigned long DcacheOffset;
+ int HwcursKey;
+ unsigned long HwcursOffset;
+
+ I810MemRange DcacheMem;
+ I810MemRange SysMem;
+
+ I810MemRange SavedDcacheMem;
+ I810MemRange SavedSysMem;
+
+ unsigned int bufferOffset; /* for I810SelectBuffer */
+ Bool DoneFrontAlloc;
+ BoxRec FbMemBox;
+ I810MemRange FrontBuffer;
+ I810MemRange Scratch;
+ I810MemRange XvMem;
+
+ int LmFreqSel;
+
+ i810VGARec vga;
+
+ I810RegRec SavedReg;
+ I810RegRec ModeReg;
+ I810RingBuffer LpRing;
+
+ unsigned int BR[20];
+
+ int CursorOffset;
+ unsigned long CursorPhysical;
+ unsigned long CursorStart;
+ unsigned long OverlayPhysical;
+ unsigned long OverlayStart;
+ int colorKey;
+
+ int nextColorExpandBuf;
+
+ ScreenBlockHandlerProcPtr BlockHandler;
+
+#ifdef XV
+ KdVideoAdaptorPtr adaptor;
+#endif
+
+} i810CardInfo;
+
+typedef struct _i810CardInfo I810CardInfo; /* compatibility */
+
+#define getI810CardInfo(kd) ((I810CardInfo *) ((kd)->card->driver))
+#define i810CardInfo(kd) I810CardInfo *i810c = getI810CardInfo(kd)
+
+#define getI810ScreenInfo(kd) ((I810ScreenInfo *) ((kd)->screen->driver))
+#define i810ScreenInfo(kd) I810ScreenInfo *i810s = getI810ScreenInfo(kd)
+
+typedef struct _i810Cursor {
+ int width, height;
+ int xhot, yhot;
+ Bool has_cursor;
+ CursorPtr pCursor;
+} i810Cursor, *i810CursorPtr;
+
+typedef struct _i810ScreenInfo {
+ i810CardInfo *i810c;
+ i810Cursor cursor;
+
+ int pitch;
+ KaaScreenInfoRec kaa;
+} i810ScreenInfo;
+
+typedef struct _i810ScreenInfo I810ScreenInfo; /* compatibility */
+
+#define I810_CURSOR_HEIGHT 64
+#define I810_CURSOR_WIDTH 64
+
+/* init functions (i810.c) */
+
+Bool
+i810CardInit (KdCardInfo *card);
+
+Bool
+i810ScreenInit (KdScreenInfo *screen);
+
+/* The cursor functions (i810_cursor.c) */
+
+Bool
+i810CursorInit(ScreenPtr pScreen);
+
+void
+i810CursorEnable (ScreenPtr pScreen);
+
+void
+i810CursorDisable (ScreenPtr pScreen);
+
+void
+i810CursorFini (ScreenPtr pScreen);
+
+/* Accel functions (i810draw.c) */
+
+Bool
+i810InitAccel(ScreenPtr);
+
+void
+i810EnableAccel (ScreenPtr);
+
+void
+i810DisableAccel (ScreenPtr);
+
+void
+i810FiniAccel (ScreenPtr);
+
+void
+i810FillBoxSolid (KdScreenInfo *screen, int nBox, BoxPtr pBox,
+ unsigned long pixel, int alu, unsigned long planemask);
+
+
+extern KdCardFuncs i810Funcs;
+
+/* Standard VGA registers */
+
+#define VGA_ATTR_INDEX 0x3C0
+#define VGA_ATTR_DATA_W 0x3C0
+#define VGA_ATTR_DATA_R 0x3C1
+#define VGA_IN_STAT_0 0x3C2 /* read */
+#define VGA_MISC_OUT_W 0x3C2 /* write */
+#define VGA_ENABLE 0x3C3
+#define VGA_SEQ_INDEX 0x3C4
+#define VGA_SEQ_DATA 0x3C5
+#define VGA_DAC_MASK 0x3C6
+#define VGA_DAC_READ_ADDR 0x3C7
+#define VGA_DAC_WRITE_ADDR 0x3C8
+#define VGA_DAC_DATA 0x3C9
+#define VGA_FEATURE_R 0x3CA /* read */
+#define VGA_MISC_OUT_R 0x3CC /* read */
+#define VGA_GRAPH_INDEX 0x3CE
+#define VGA_GRAPH_DATA 0x3CF
+
+#define VGA_IOBASE_MONO 0x3B0
+#define VGA_IOBASE_COLOR 0x3D0
+
+#define VGA_CRTC_INDEX_OFFSET 0x04
+#define VGA_CRTC_DATA_OFFSET 0x05
+#define VGA_IN_STAT_1_OFFSET 0x0A /* read */
+#define VGA_FEATURE_W_OFFSET 0x0A /* write */
+
+/* VGA stuff */
+#define BIT_PLANE 3 /* Which plane we write to in mono mode */
+
+/* DAC indices for white and black */
+#define WHITE_VALUE 0x3F
+#define BLACK_VALUE 0x00
+#define OVERSCAN_VALUE 0x01
+
+#define OVERSCAN 0x11 /* Index of OverScan register */
+
+void
+i810VGAUnlock(i810VGAPtr vgap);
+
+void
+i810VGALock(i810VGAPtr vgap);
+
+Bool
+i810VGAInit(KdScreenInfo *scrninfp, const KdMonitorTiming *t);
+
+void
+i810VGABlankScreen(KdCardInfo *card, Bool on);
+
+void
+i810AdjustFrame(KdScreenInfo *screen, int x, int y, int flags);
+
+Bool
+i810VGAMapMem(KdCardInfo *card);
+
+void
+i810VGASave(KdCardInfo *card, vgaRegPtr save, int flags);
+
+void
+i810PrintErrorState(i810CardInfo *i810c);
+
+void
+i810VGAGetIOBase(i810VGAPtr vgap);
+
+Bool
+i810InitVideo(ScreenPtr pScreen);
+
+/*
+ * MMIO versions of the register access functions. These require
+ * hwp->MemBase to be set in such a way that when the standard VGA port
+ * address is added the correct memory address results.
+ */
+
+#define Vminb(p) ( *(volatile CARD8 *)(vgap->MMIOBase + (p)))
+#define Vmoutb(p,v) ( *(volatile CARD8 *)(vgap->MMIOBase + (p)) = (v))
+
+#define mmioWriteCrtc(vgap, index, value) { \
+ Vmoutb(vgap->IOBase + VGA_CRTC_INDEX_OFFSET, index); \
+ Vmoutb(vgap->IOBase + VGA_CRTC_DATA_OFFSET, value); \
+}
+
+#define mmioReadCrtc(vgap, index) ( \
+ Vmoutb(vgap->IOBase + VGA_CRTC_INDEX_OFFSET, index), \
+ Vminb(vgap->IOBase + VGA_CRTC_DATA_OFFSET) \
+)
+
+#define mmioWriteGr(vgap, index, value) { \
+ Vmoutb(VGA_GRAPH_INDEX, index); \
+ Vmoutb(VGA_GRAPH_DATA, value); \
+}
+
+#define mmioReadGr(vgap, index) ( \
+ Vmoutb(VGA_GRAPH_INDEX, index), \
+ Vminb(VGA_GRAPH_DATA) \
+)
+
+#define mmioWriteSeq(vgap, index, value) {\
+ Vmoutb(VGA_SEQ_INDEX, index); \
+ Vmoutb(VGA_SEQ_DATA, value); \
+}
+
+#define mmioReadSeq(vgap, index) ( \
+ Vmoutb(VGA_SEQ_INDEX, index), \
+ Vminb(VGA_SEQ_DATA) \
+)
+
+#define mmioWriteAttr(vgap, index, value) { \
+ (void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET); \
+ Vmoutb(VGA_ATTR_INDEX, index); \
+ Vmoutb(VGA_ATTR_DATA_W, value); \
+}
+
+#define mmioReadAttr(vgap, index) ( \
+ (void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET), \
+ Vmoutb(VGA_ATTR_INDEX, index), \
+ Vminb(VGA_ATTR_DATA_R) \
+)
+
+#define mmioWriteMiscOut(vgap, value) Vmoutb(VGA_MISC_OUT_W, value)
+
+
+#define mmioReadMiscOut(vgap) Vminb(VGA_MISC_OUT_R)
+
+#define mmioEnablePalette(vgap) { \
+ (void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET); \
+ Vmoutb(VGA_ATTR_INDEX, 0x00); \
+ vgap->paletteEnabled = TRUE; \
+}
+
+#define mmioDisablePalette(vgap) { \
+ (void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET); \
+ Vmoutb(VGA_ATTR_INDEX, 0x20); \
+ vgap->paletteEnabled = FALSE; \
+}
+
+#define mmioWriteDacWriteAddr(vgap, value) Vmoutb(VGA_DAC_WRITE_ADDR, value)
+
+#define mmioWriteDacData(vgap, value) Vmoutb(VGA_DAC_DATA, value)
+
+#endif /* _I810_H_ */
diff --git a/xorg-server/hw/kdrive/i810/i810_cursor.c b/xorg-server/hw/kdrive/i810/i810_cursor.c
new file mode 100644
index 000000000..434fc4087
--- /dev/null
+++ b/xorg-server/hw/kdrive/i810/i810_cursor.c
@@ -0,0 +1,435 @@
+/* COPYRIGHT AND PERMISSION NOTICE
+
+Copyright (c) 2000, 2001 Nokia Home Communications
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+X Window System is a trademark of The Open Group */
+
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/* i810_cursor.c: KDrive hardware cursor routines for the i810 chipset */
+
+/*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Pontus Lidman <pontus.lidman@nokia.com>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "kxv.h"
+#include "i810.h"
+#include "cursorstr.h"
+
+#define SetupCursor(s) KdScreenPriv(pScreen); \
+ i810CardInfo(pScreenPriv); \
+ i810ScreenInfo(pScreenPriv); \
+ i810Cursor *pCurPriv = &i810s->cursor
+
+
+static void
+writeStandardMMIO(I810CardInfo *i810c, int addr, CARD8 val)
+{
+ moutb(addr, val);
+}
+
+static void
+_i810MoveCursor(ScreenPtr pScreen, int x, int y)
+{
+ KdScreenPriv(pScreen);
+ i810CardInfo(pScreenPriv);
+ int flag;
+
+ if (I810_DEBUG & DEBUG_VERBOSE_CURSOR)
+ ErrorF( "I810SetCursorPosition %d %d\n", x, y);
+
+ x += i810c->CursorOffset;
+
+ if (x >= 0) flag = CURSOR_X_POS;
+ else {
+ flag = CURSOR_X_NEG;
+ x=-x;
+ }
+
+ OUTREG8( CURSOR_X_LO, x&0xFF);
+ OUTREG8( CURSOR_X_HI, (((x >> 8) & 0x07) | flag));
+
+ if (y >= 0) flag = CURSOR_Y_POS;
+ else {
+ flag = CURSOR_Y_NEG;
+ y=-y;
+ }
+ OUTREG8( CURSOR_Y_LO, y&0xFF);
+ OUTREG8( CURSOR_Y_HI, (((y >> 8) & 0x07) | flag));
+
+ /* Enable cursor */
+ OUTREG( CURSOR_BASEADDR, i810c->CursorPhysical);
+ OUTREG8( CURSOR_CONTROL, CURSOR_ORIGIN_DISPLAY | CURSOR_MODE_64_3C);
+
+}
+
+static void i810LoadCursor(ScreenPtr pScreen, int x, int y);
+
+static void
+i810MoveCursor (ScreenPtr pScreen, int x, int y)
+{
+ KdScreenPriv(pScreen);
+ i810ScreenInfo(pScreenPriv);
+ i810Cursor *pCurPriv = &i810s->cursor;
+
+ if (!pCurPriv->has_cursor)
+ return;
+
+ if (!pScreenPriv->enabled)
+ return;
+
+ _i810MoveCursor (pScreen, x, y);
+
+ i810LoadCursor(pScreen, x, y);
+}
+
+static void
+_i810SetCursorColors(ScreenPtr pScreen)
+{
+
+ KdScreenPriv(pScreen);
+ i810CardInfo(pScreenPriv);
+ int tmp;
+
+ int bg = 0xffffff;
+ int fg = 0x000000;
+
+ tmp=INREG8(PIXPIPE_CONFIG_0);
+ tmp |= EXTENDED_PALETTE;
+ OUTREG8( PIXPIPE_CONFIG_0, tmp);
+
+ writeStandardMMIO(i810c, DACMASK, 0xFF);
+ writeStandardMMIO(i810c, DACWX, 0x04);
+
+ writeStandardMMIO(i810c, DACDATA, (bg & 0x00FF0000) >> 16);
+ writeStandardMMIO(i810c, DACDATA, (bg & 0x0000FF00) >> 8);
+ writeStandardMMIO(i810c, DACDATA, (bg & 0x000000FF));
+
+ writeStandardMMIO(i810c, DACDATA, (fg & 0x00FF0000) >> 16);
+ writeStandardMMIO(i810c, DACDATA, (fg & 0x0000FF00) >> 8);
+ writeStandardMMIO(i810c, DACDATA, (fg & 0x000000FF));
+
+ tmp=INREG8( PIXPIPE_CONFIG_0 );
+ tmp &= ~EXTENDED_PALETTE;
+ OUTREG8( PIXPIPE_CONFIG_0, tmp );
+}
+
+#define InvertBits32(v) { \
+ v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
+ v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
+ v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
+}
+
+static void i810LoadCursor(ScreenPtr pScreen, int x, int y)
+{
+ SetupCursor(pScreen);
+
+ int h;
+ unsigned int *msk, *mskLine, *src, *srcLine;
+
+ int i, j;
+ int src_stride, src_width;
+
+ CursorPtr pCursor = pCurPriv->pCursor;
+ CursorBitsPtr bits = pCursor->bits;
+ CARD8 tmp;
+ unsigned int *ram, *ramLine;
+
+ pCurPriv->pCursor = pCursor;
+ pCurPriv->xhot = pCursor->bits->xhot;
+ pCurPriv->yhot = pCursor->bits->yhot;
+
+ ramLine = (unsigned int *) (i810c->FbBase + i810c->CursorStart);
+ mskLine = (unsigned int *) (bits->mask);
+ srcLine = (unsigned int *) (bits->source);
+
+ h = bits->height;
+ if (h > I810_CURSOR_HEIGHT)
+ h = I810_CURSOR_HEIGHT;
+
+ src_stride = BitmapBytePad(bits->width); /* bytes per line */
+ src_stride = (src_stride +3) >> 2;
+ src_width = (bits->width + 31) >> 5;
+
+ for (i = 0; i < I810_CURSOR_HEIGHT; i++) {
+
+ msk = mskLine;
+ src = srcLine;
+ ram = ramLine;
+ mskLine += src_stride;
+ srcLine += src_stride;
+ ramLine += I810_CURSOR_WIDTH / 16;
+
+ for (j = 0; j < I810_CURSOR_WIDTH / 32; j++) {
+
+ unsigned long m, s;
+
+ if (i < h && j < src_width)
+ {
+ m = *msk++;
+ s = *src++ & m;
+ m = ~m;
+ /* mask off right side */
+ if (j == src_width - 1 && (bits->width & 31))
+ {
+ m |= 0xffffffff << (bits->width & 31);
+ }
+ }
+ else
+ {
+ m = 0xffffffff;
+ s = 0x00000000;
+ }
+
+ InvertBits32(s);
+ InvertBits32(m);
+
+ ram[2+j]=s;
+ ram[0+j]=m;
+ }
+ }
+ /* Set new color */
+ _i810SetCursorColors (pScreen);
+
+ /* Move to new position */
+ _i810MoveCursor (pScreen, x, y);
+
+ /* Enable cursor */
+ OUTREG( CURSOR_BASEADDR, i810c->CursorPhysical);
+ OUTREG8( CURSOR_CONTROL, CURSOR_ORIGIN_DISPLAY | CURSOR_MODE_64_3C);
+
+ tmp = INREG8( PIXPIPE_CONFIG_0 );
+ tmp |= HW_CURSOR_ENABLE;
+ OUTREG8( PIXPIPE_CONFIG_0, tmp);
+}
+
+static void
+i810UnloadCursor(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ i810CardInfo(pScreenPriv);
+
+ unsigned char tmp;
+
+ tmp=INREG8( PIXPIPE_CONFIG_0 );
+ tmp &= ~HW_CURSOR_ENABLE;
+ OUTREG8( PIXPIPE_CONFIG_0, tmp);
+}
+
+
+static Bool
+i810RealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
+{
+ KdScreenPriv(pScreen);
+ i810ScreenInfo(pScreenPriv);
+ i810Cursor *pCurPriv = &i810s->cursor;
+
+ if (!pScreenPriv->enabled)
+ return TRUE;
+
+ /* miRecolorCursor does this */
+ if (pCurPriv->pCursor == pCursor)
+ {
+ if (pCursor)
+ {
+ int x, y;
+
+ miPointerPosition (&x, &y);
+ i810LoadCursor (pScreen, x, y);
+ }
+ }
+ return TRUE;
+}
+
+static Bool
+i810UnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
+{
+ return TRUE;
+}
+
+static void
+i810SetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
+{
+ KdScreenPriv(pScreen);
+ i810ScreenInfo(pScreenPriv);
+ i810Cursor *pCurPriv = &i810s->cursor;
+
+ pCurPriv->pCursor = pCursor;
+
+ if (!pScreenPriv->enabled)
+ return;
+
+ if (pCursor)
+ i810LoadCursor (pScreen, x, y);
+ else
+ i810UnloadCursor (pScreen);
+}
+
+miPointerSpriteFuncRec i810PointerSpriteFuncs = {
+ i810RealizeCursor,
+ i810UnrealizeCursor,
+ i810SetCursor,
+ i810MoveCursor,
+};
+
+static void
+i810QueryBestSize (int class,
+ unsigned short *pwidth, unsigned short *pheight,
+ ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ i810ScreenInfo(pScreenPriv);
+ i810Cursor *pCurPriv = &i810s->cursor;
+
+ switch (class)
+ {
+ case CursorShape:
+ if (*pwidth > pCurPriv->width)
+ *pwidth = pCurPriv->width;
+ if (*pheight > pCurPriv->height)
+ *pheight = pCurPriv->height;
+ if (*pwidth > pScreen->width)
+ *pwidth = pScreen->width;
+ if (*pheight > pScreen->height)
+ *pheight = pScreen->height;
+ break;
+ default:
+ fbQueryBestSize (class, pwidth, pheight, pScreen);
+ break;
+ }
+}
+
+Bool
+i810CursorInit(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ i810ScreenInfo(pScreenPriv);
+ i810CardInfo(pScreenPriv);
+ i810Cursor *pCurPriv = &i810s->cursor;
+
+ if (!i810c->CursorStart) {
+ pCurPriv->has_cursor = FALSE;
+ return FALSE;
+ }
+
+ pCurPriv->width = I810_CURSOR_WIDTH;
+ pCurPriv->height= I810_CURSOR_HEIGHT;
+ pScreen->QueryBestSize = i810QueryBestSize;
+ miPointerInitialize (pScreen,
+ &i810PointerSpriteFuncs,
+ &kdPointerScreenFuncs,
+ FALSE);
+ pCurPriv->has_cursor = TRUE;
+ pCurPriv->pCursor = NULL;
+ return TRUE;
+}
+
+void
+i810CursorEnable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ i810ScreenInfo(pScreenPriv);
+ i810Cursor *pCurPriv = &i810s->cursor;
+
+ if (pCurPriv->has_cursor)
+ {
+ if (pCurPriv->pCursor)
+ {
+ int x, y;
+
+ miPointerPosition (&x, &y);
+ i810LoadCursor (pScreen, x, y);
+ }
+ else
+ i810UnloadCursor (pScreen);
+ }
+}
+
+void
+i810CursorDisable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ i810ScreenInfo(pScreenPriv);
+ i810Cursor *pCurPriv = &i810s->cursor;
+
+ if (!pScreenPriv->enabled)
+ return;
+
+ if (pCurPriv->has_cursor)
+ {
+ if (pCurPriv->pCursor)
+ {
+ i810UnloadCursor (pScreen);
+ }
+ }
+}
+
+void
+i810CursorFini (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ i810ScreenInfo(pScreenPriv);
+ i810Cursor *pCurPriv = &i810s->cursor;
+
+ pCurPriv->pCursor = NULL;
+}
+
diff --git a/xorg-server/hw/kdrive/i810/i810_reg.h b/xorg-server/hw/kdrive/i810/i810_reg.h
new file mode 100644
index 000000000..d9f4c8f48
--- /dev/null
+++ b/xorg-server/hw/kdrive/i810/i810_reg.h
@@ -0,0 +1,695 @@
+/* COPYRIGHT AND PERMISSION NOTICE
+
+Copyright (c) 2000, 2001 Nokia Home Communications
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+X Window System is a trademark of The Open Group */
+
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Pontus Lidman <pontus.lidman@nokia.com>
+ *
+ * based on the i740 driver by
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ *
+ */
+
+/* I/O register offsets
+ */
+#define SRX 0x3C4 /* p208 */
+#define GRX 0x3CE /* p213 */
+#define ARX 0x3C0 /* p224 */
+
+/* VGA Color Palette Registers */
+#define DACMASK 0x3C6 /* p232 */
+#define DACSTATE 0x3C7 /* p232 */
+#define DACRX 0x3C7 /* p233 */
+#define DACWX 0x3C8 /* p233 */
+#define DACDATA 0x3C9 /* p233 */
+
+/* CRT Controller Registers (CRX) */
+#define START_ADDR_HI 0x0C /* p246 */
+#define START_ADDR_LO 0x0D /* p247 */
+#define VERT_SYNC_END 0x11 /* p249 */
+#define EXT_VERT_TOTAL 0x30 /* p257 */
+#define EXT_VERT_DISPLAY 0x31 /* p258 */
+#define EXT_VERT_SYNC_START 0x32 /* p259 */
+#define EXT_VERT_BLANK_START 0x33 /* p260 */
+#define EXT_HORIZ_TOTAL 0x35 /* p261 */
+#define EXT_HORIZ_BLANK 0x39 /* p261 */
+#define EXT_START_ADDR 0x40 /* p262 */
+#define EXT_START_ADDR_ENABLE 0x80
+#define EXT_OFFSET 0x41 /* p263 */
+#define EXT_START_ADDR_HI 0x42 /* p263 */
+#define INTERLACE_CNTL 0x70 /* p264 */
+#define INTERLACE_ENABLE 0x80
+#define INTERLACE_DISABLE 0x00
+
+/* Miscellaneous Output Register
+ */
+#define MSR_R 0x3CC /* p207 */
+#define MSR_W 0x3C2 /* p207 */
+#define IO_ADDR_SELECT 0x01
+
+#define MDA_BASE 0x3B0 /* p207 */
+#define CGA_BASE 0x3D0 /* p207 */
+
+/* CR80 - IO Control, p264
+ */
+#define IO_CTNL 0x80
+#define EXTENDED_ATTR_CNTL 0x02
+#define EXTENDED_CRTC_CNTL 0x01
+
+/* GR10 - Address mapping, p221
+ */
+#define ADDRESS_MAPPING 0x10
+#define PAGE_TO_LOCAL_MEM_ENABLE 0x10
+#define GTT_MEM_MAP_ENABLE 0x08
+#define PACKED_MODE_ENABLE 0x04
+#define LINEAR_MODE_ENABLE 0x02
+#define PAGE_MAPPING_ENABLE 0x01
+
+/* Blitter control, p378
+ */
+#define BITBLT_CNTL 0x7000c
+#define COLEXP_MODE 0x30
+#define COLEXP_8BPP 0x00
+#define COLEXP_16BPP 0x10
+#define COLEXP_24BPP 0x20
+#define COLEXP_RESERVED 0x30
+#define BITBLT_STATUS 0x01
+
+/* p375.
+ */
+#define DISPLAY_CNTL 0x70008
+#define VGA_WRAP_MODE 0x02
+#define VGA_WRAP_AT_256KB 0x00
+#define VGA_NO_WRAP 0x02
+#define GUI_MODE 0x01
+#define STANDARD_VGA_MODE 0x00
+#define HIRES_MODE 0x01
+
+/* p375
+ */
+#define PIXPIPE_CONFIG_0 0x70009
+#define DAC_8_BIT 0x80
+#define DAC_6_BIT 0x00
+#define HW_CURSOR_ENABLE 0x10
+#define EXTENDED_PALETTE 0x01
+
+/* p375
+ */
+#define PIXPIPE_CONFIG_1 0x7000a
+#define DISPLAY_COLOR_MODE 0x0F
+#define DISPLAY_VGA_MODE 0x00
+#define DISPLAY_8BPP_MODE 0x02
+#define DISPLAY_15BPP_MODE 0x04
+#define DISPLAY_16BPP_MODE 0x05
+#define DISPLAY_24BPP_MODE 0x06
+#define DISPLAY_32BPP_MODE 0x07
+
+/* p375
+ */
+#define PIXPIPE_CONFIG_2 0x7000b
+#define DISPLAY_GAMMA_ENABLE 0x08
+#define DISPLAY_GAMMA_DISABLE 0x00
+#define OVERLAY_GAMMA_ENABLE 0x04
+#define OVERLAY_GAMMA_DISABLE 0x00
+
+
+/* p380
+ */
+#define DISPLAY_BASE 0x70020
+#define DISPLAY_BASE_MASK 0x03fffffc
+
+
+/* Cursor control registers, pp383-384
+ */
+#define CURSOR_CONTROL 0x70080
+#define CURSOR_ORIGIN_SCREEN 0x00
+#define CURSOR_ORIGIN_DISPLAY 0x10
+#define CURSOR_MODE 0x07
+#define CURSOR_MODE_DISABLE 0x00
+#define CURSOR_MODE_32_4C_AX 0x01
+#define CURSOR_MODE_64_3C 0x04
+#define CURSOR_MODE_64_4C_AX 0x05
+#define CURSOR_MODE_64_4C 0x06
+#define CURSOR_MODE_RESERVED 0x07
+#define CURSOR_BASEADDR 0x70084
+#define CURSOR_BASEADDR_MASK 0x1FFFFF00
+#define CURSOR_X_LO 0x70088
+#define CURSOR_X_HI 0x70089
+#define CURSOR_X_POS 0x00
+#define CURSOR_X_NEG 0x80
+#define CURSOR_Y_LO 0x7008A
+#define CURSOR_Y_HI 0x7008B
+#define CURSOR_Y_POS 0x00
+#define CURSOR_Y_NEG 0x80
+
+
+
+/* Similar registers exist in Device 0 on the i810 (pp55-65), but I'm
+ * not sure they refer to local (graphics) memory.
+ *
+ * These details are for the local memory control registers,
+ * (pp301-310). The test machines are not equiped with local memory,
+ * so nothing is tested. Only a single row seems to be supported.
+ */
+#define DRAM_ROW_TYPE 0x3000
+#define DRAM_ROW_0 0x01
+#define DRAM_ROW_0_SDRAM 0x01
+#define DRAM_ROW_0_EMPTY 0x00
+#define DRAM_ROW_CNTL_LO 0x3001
+#define DRAM_PAGE_MODE_CTRL 0x10
+#define DRAM_RAS_TO_CAS_OVRIDE 0x08
+#define DRAM_CAS_LATENCY 0x04
+#define DRAM_RAS_TIMING 0x02
+#define DRAM_RAS_PRECHARGE 0x01
+#define DRAM_ROW_CNTL_HI 0x3002
+#define DRAM_REFRESH_RATE 0x18
+#define DRAM_REFRESH_DISABLE 0x00
+#define DRAM_REFRESH_60HZ 0x08
+#define DRAM_REFRESH_FAST_TEST 0x10
+#define DRAM_REFRESH_RESERVED 0x18
+#define DRAM_SMS 0x07
+#define DRAM_SMS_NORMAL 0x00
+#define DRAM_SMS_NOP_ENABLE 0x01
+#define DRAM_SMS_ABPCE 0x02
+#define DRAM_SMS_MRCE 0x03
+#define DRAM_SMS_CBRCE 0x04
+
+/* p307
+ */
+#define DPMS_SYNC_SELECT 0x5002
+#define VSYNC_CNTL 0x08
+#define VSYNC_ON 0x00
+#define VSYNC_OFF 0x08
+#define HSYNC_CNTL 0x02
+#define HSYNC_ON 0x00
+#define HSYNC_OFF 0x02
+
+
+
+/* p317, 319
+ */
+#define VCLK2_VCO_M 0x6008 /* treat as 16 bit? (includes msbs) */
+#define VCLK2_VCO_N 0x600a
+#define VCLK2_VCO_DIV_SEL 0x6012
+#define POST_DIV_SELECT 0x70
+#define POST_DIV_1 0x00
+#define POST_DIV_2 0x10
+#define POST_DIV_4 0x20
+#define POST_DIV_8 0x30
+#define POST_DIV_16 0x40
+#define POST_DIV_32 0x50
+#define VCO_LOOP_DIV_BY_4M 0x00
+#define VCO_LOOP_DIV_BY_16M 0x04
+
+
+/* Instruction Parser Mode Register
+ * - p281
+ * - 2 new bits.
+ */
+#define INST_PM 0x20c0
+#define AGP_SYNC_PACKET_FLUSH_ENABLE 0x20 /* reserved */
+#define SYNC_PACKET_FLUSH_ENABLE 0x10
+#define TWO_D_INST_DISABLE 0x08
+#define THREE_D_INST_DISABLE 0x04
+#define STATE_VAR_UPDATE_DISABLE 0x02
+#define PAL_STIP_DISABLE 0x01
+
+#define INST_DONE 0x2090
+#define INST_PS 0x20c4
+
+#define MEMMODE 0x20dc
+
+
+/* Instruction parser error register. p279
+ */
+#define IPEIR 0x2088
+#define IPEHR 0x208C
+
+
+/* General error reporting regs, p296
+ */
+#define EIR 0x20B0
+#define EMR 0x20B4
+#define ESR 0x20B8
+#define IP_ERR 0x0001
+#define ERROR_RESERVED 0xffc6
+
+
+/* Interrupt Control Registers
+ * - new bits for i810
+ * - new register hwstam (mask)
+ */
+#define HWSTAM 0x2098 /* p290 */
+#define IER 0x20a0 /* p291 */
+#define IIR 0x20a4 /* p292 */
+#define IMR 0x20a8 /* p293 */
+#define ISR 0x20ac /* p294 */
+#define HW_ERROR 0x8000
+#define SYNC_STATUS_TOGGLE 0x1000
+#define DPY_0_FLIP_PENDING 0x0800
+#define DPY_1_FLIP_PENDING 0x0400 /* not implemented on i810 */
+#define OVL_0_FLIP_PENDING 0x0200
+#define OVL_1_FLIP_PENDING 0x0100 /* not implemented on i810 */
+#define DPY_0_VBLANK 0x0080
+#define DPY_0_EVENT 0x0040
+#define DPY_1_VBLANK 0x0020 /* not implemented on i810 */
+#define DPY_1_EVENT 0x0010 /* not implemented on i810 */
+#define HOST_PORT_EVENT 0x0008 /* */
+#define CAPTURE_EVENT 0x0004 /* */
+#define USER_DEFINED 0x0002
+#define BREAKPOINT 0x0001
+
+
+#define INTR_RESERVED (0x6000 | \
+ DPY_1_FLIP_PENDING | \
+ OVL_1_FLIP_PENDING | \
+ DPY_1_VBLANK | \
+ DPY_1_EVENT | \
+ HOST_PORT_EVENT | \
+ CAPTURE_EVENT )
+
+/* FIFO Watermark and Burst Length Control Register
+ *
+ * - different offset and contents on i810 (p299) (fewer bits per field)
+ * - some overlay fields added
+ * - what does it all mean?
+ */
+#define FWATER_BLC 0x20d8
+#define MM_BURST_LENGTH 0x00700000
+#define MM_FIFO_WATERMARK 0x0001F000
+#define LM_BURST_LENGTH 0x00000700
+#define LM_FIFO_WATERMARK 0x0000001F
+
+
+/* Fence/Tiling ranges [0..7]
+ */
+#define FENCE 0x2000
+#define FENCE_NR 8
+
+#define FENCE_START_MASK 0x03F80000
+#define FENCE_X_MAJOR 0x00000000
+#define FENCE_Y_MAJOR 0x00001000
+#define FENCE_SIZE_MASK 0x00000700
+#define FENCE_SIZE_512K 0x00000000
+#define FENCE_SIZE_1M 0x00000100
+#define FENCE_SIZE_2M 0x00000200
+#define FENCE_SIZE_4M 0x00000300
+#define FENCE_SIZE_8M 0x00000400
+#define FENCE_SIZE_16M 0x00000500
+#define FENCE_SIZE_32M 0x00000600
+#define FENCE_PITCH_MASK 0x00000070
+#define FENCE_PITCH_1 0x00000000
+#define FENCE_PITCH_2 0x00000010
+#define FENCE_PITCH_4 0x00000020
+#define FENCE_PITCH_8 0x00000030
+#define FENCE_PITCH_16 0x00000040
+#define FENCE_PITCH_32 0x00000050
+#define FENCE_VALID 0x00000001
+
+
+/* Registers to control page table, p274
+ */
+#define PGETBL_CTL 0x2020
+#define PGETBL_ADDR_MASK 0xFFFFF000
+#define PGETBL_ENABLE_MASK 0x00000001
+#define PGETBL_ENABLED 0x00000001
+
+/* Register containing pge table error results, p276
+ */
+#define PGE_ERR 0x2024
+#define PGE_ERR_ADDR_MASK 0xFFFFF000
+#define PGE_ERR_ID_MASK 0x00000038
+#define PGE_ERR_CAPTURE 0x00000000
+#define PGE_ERR_OVERLAY 0x00000008
+#define PGE_ERR_DISPLAY 0x00000010
+#define PGE_ERR_HOST 0x00000018
+#define PGE_ERR_RENDER 0x00000020
+#define PGE_ERR_BLITTER 0x00000028
+#define PGE_ERR_MAPPING 0x00000030
+#define PGE_ERR_CMD_PARSER 0x00000038
+#define PGE_ERR_TYPE_MASK 0x00000007
+#define PGE_ERR_INV_TABLE 0x00000000
+#define PGE_ERR_INV_PTE 0x00000001
+#define PGE_ERR_MIXED_TYPES 0x00000002
+#define PGE_ERR_PAGE_MISS 0x00000003
+#define PGE_ERR_ILLEGAL_TRX 0x00000004
+#define PGE_ERR_LOCAL_MEM 0x00000005
+#define PGE_ERR_TILED 0x00000006
+
+
+
+/* Page table entries loaded via mmio region, p323
+ */
+#define PTE_BASE 0x10000
+#define PTE_ADDR_MASK 0x3FFFF000
+#define PTE_TYPE_MASK 0x00000006
+#define PTE_LOCAL 0x00000002
+#define PTE_MAIN_UNCACHED 0x00000000
+#define PTE_MAIN_CACHED 0x00000006
+#define PTE_VALID_MASK 0x00000001
+#define PTE_VALID 0x00000001
+
+
+/* Ring buffer registers, p277, overview p19
+ */
+#define LP_RING 0x2030
+#define HP_RING 0x2040
+
+#define RING_TAIL 0x00
+#define TAIL_ADDR 0x000FFFF8
+
+#define RING_HEAD 0x04
+#define HEAD_WRAP_COUNT 0xFFE00000
+#define HEAD_WRAP_ONE 0x00200000
+#define HEAD_ADDR 0x001FFFFC
+
+#define RING_START 0x08
+#define START_ADDR 0x00FFFFF8
+
+#define RING_LEN 0x0C
+#define RING_NR_PAGES 0x000FF000
+#define RING_REPORT_MASK 0x00000006
+#define RING_REPORT_64K 0x00000002
+#define RING_REPORT_128K 0x00000004
+#define RING_NO_REPORT 0x00000000
+#define RING_VALID_MASK 0x00000001
+#define RING_VALID 0x00000001
+#define RING_INVALID 0x00000000
+
+
+
+/* BitBlt Instructions
+ *
+ * There are many more masks & ranges yet to add.
+ */
+#define BR00_BITBLT_CLIENT 0x40000000
+#define BR00_OP_COLOR_BLT 0x10000000
+#define BR00_OP_SRC_COPY_BLT 0x10C00000
+#define BR00_OP_FULL_BLT 0x11400000
+#define BR00_OP_MONO_SRC_BLT 0x11800000
+#define BR00_OP_MONO_SRC_COPY_BLT 0x11000000
+#define BR00_OP_MONO_PAT_BLT 0x11C00000
+#define BR00_OP_MONO_SRC_COPY_IMMEDIATE_BLT (0x61 << 22)
+#define BR00_OP_TEXT_IMMEDIATE_BLT 0xc000000
+
+
+#define BR00_TPCY_DISABLE 0x00000000
+#define BR00_TPCY_ENABLE 0x00000010
+
+#define BR00_TPCY_ROP 0x00000000
+#define BR00_TPCY_NO_ROP 0x00000020
+#define BR00_TPCY_EQ 0x00000000
+#define BR00_TPCY_NOT_EQ 0x00000040
+
+#define BR00_PAT_MSB_FIRST 0x00000000 /* ? */
+
+#define BR00_PAT_VERT_ALIGN 0x000000e0
+
+#define BR00_LENGTH 0x0000000F
+
+#define BR09_DEST_ADDR 0x03FFFFFF
+
+#define BR11_SOURCE_PITCH 0x00003FFF
+
+#define BR12_SOURCE_ADDR 0x03FFFFFF
+
+#define BR13_SOLID_PATTERN 0x80000000
+#define BR13_RIGHT_TO_LEFT 0x40000000
+#define BR13_LEFT_TO_RIGHT 0x00000000
+#define BR13_MONO_TRANSPCY 0x20000000
+#define BR13_USE_DYN_DEPTH 0x04000000
+#define BR13_DYN_8BPP 0x00000000
+#define BR13_DYN_16BPP 0x01000000
+#define BR13_DYN_24BPP 0x02000000
+#define BR13_ROP_MASK 0x00FF0000
+#define BR13_DEST_PITCH 0x0000FFFF
+#define BR13_PITCH_SIGN_BIT 0x00008000
+
+#define BR14_DEST_HEIGHT 0xFFFF0000
+#define BR14_DEST_WIDTH 0x0000FFFF
+
+#define BR15_PATTERN_ADDR 0x03FFFFFF
+
+#define BR16_SOLID_PAT_COLOR 0x00FFFFFF
+#define BR16_BACKGND_PAT_CLR 0x00FFFFFF
+
+#define BR17_FGND_PAT_CLR 0x00FFFFFF
+
+#define BR18_SRC_BGND_CLR 0x00FFFFFF
+#define BR19_SRC_FGND_CLR 0x00FFFFFF
+
+
+/* Instruction parser instructions
+ */
+
+#define INST_PARSER_CLIENT 0x00000000
+#define INST_OP_FLUSH 0x02000000
+#define INST_FLUSH_MAP_CACHE 0x00000001
+
+#define INST_DEST_BUFFER_INFO 0x06800000
+
+#define INST_FRONT_BUFFER_INFO 0x06000000
+#define FRONT_INFO_ASYNC_FLIP 1<<6
+#define FRONT_INFO_PITCH_B 8
+
+#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
+
+
+/* Registers in the i810 host-pci bridge pci config space which affect
+ * the i810 graphics operations.
+ */
+#define SMRAM_MISCC 0x70
+#define GMS 0x000000c0
+#define GMS_DISABLE 0x00000000
+#define GMS_ENABLE_BARE 0x00000040
+#define GMS_ENABLE_512K 0x00000080
+#define GMS_ENABLE_1M 0x000000c0
+#define USMM 0x00000030
+#define USMM_DISABLE 0x00000000
+#define USMM_TSEG_ZERO 0x00000010
+#define USMM_TSEG_512K 0x00000020
+#define USMM_TSEG_1M 0x00000030
+#define GFX_MEM_WIN_SIZE 0x00010000
+#define GFX_MEM_WIN_32M 0x00010000
+#define GFX_MEM_WIN_64M 0x00000000
+
+/* Overkill? I don't know. Need to figure out top of mem to make the
+ * SMRAM calculations come out. Linux seems to have problems
+ * detecting it all on its own, so this seems a reasonable double
+ * check to any user supplied 'mem=...' boot param.
+ *
+ * ... unfortunately this reg doesn't work according to spec on the
+ * test hardware.
+ */
+#define WHTCFG_PAMR_DRP 0x50
+#define SYS_DRAM_ROW_0_SHIFT 16
+#define SYS_DRAM_ROW_1_SHIFT 20
+#define DRAM_MASK 0x0f
+#define DRAM_VALUE_0 0
+#define DRAM_VALUE_1 8
+/* No 2 value defined */
+#define DRAM_VALUE_3 16
+#define DRAM_VALUE_4 16
+#define DRAM_VALUE_5 24
+#define DRAM_VALUE_6 32
+#define DRAM_VALUE_7 32
+#define DRAM_VALUE_8 48
+#define DRAM_VALUE_9 64
+#define DRAM_VALUE_A 64
+#define DRAM_VALUE_B 96
+#define DRAM_VALUE_C 128
+#define DRAM_VALUE_D 128
+#define DRAM_VALUE_E 192
+#define DRAM_VALUE_F 256 /* nice one, geezer */
+#define LM_FREQ_MASK 0x10
+#define LM_FREQ_133 0x10
+#define LM_FREQ_100 0x00
+
+
+
+
+/* These are 3d state registers, but the state is invarient, so we let
+ * the X server handle it:
+ */
+
+
+
+/* GFXRENDERSTATE_COLOR_CHROMA_KEY, p135
+ */
+#define GFX_OP_COLOR_CHROMA_KEY ((0x3<<29)|(0x1d<<24)|(0x2<<16)|0x1)
+#define CC1_UPDATE_KILL_WRITE (1<<28)
+#define CC1_ENABLE_KILL_WRITE (1<<27)
+#define CC1_DISABLE_KILL_WRITE 0
+#define CC1_UPDATE_COLOR_IDX (1<<26)
+#define CC1_UPDATE_CHROMA_LOW (1<<25)
+#define CC1_UPDATE_CHROMA_HI (1<<24)
+#define CC1_CHROMA_LOW_MASK ((1<<24)-1)
+#define CC2_COLOR_IDX_SHIFT 24
+#define CC2_COLOR_IDX_MASK (0xff<<24)
+#define CC2_CHROMA_HI_MASK ((1<<24)-1)
+
+
+#define GFX_CMD_CONTEXT_SEL ((0<<29)|(0x5<<23))
+#define CS_UPDATE_LOAD (1<<17)
+#define CS_UPDATE_USE (1<<16)
+#define CS_UPDATE_LOAD (1<<17)
+#define CS_LOAD_CTX0 0
+#define CS_LOAD_CTX1 (1<<8)
+#define CS_USE_CTX0 0
+#define CS_USE_CTX1 (1<<0)
+
+/* 3D Rendering Engine */
+
+#define RENDER_CLIENT 0x60000000
+
+/* Primitive rendering instruction */
+
+#define GFX_PRIMITIVE 0x1f000000
+#define PRIMITIVE_TRIANGLE 0 << 18
+#define PRIMITIVE_TRI_STRIP 1 << 18
+#define PRIMITIVE_TRI_REV_STRIP 2 << 18
+#define PRIMITIVE_TRI_FAN 3 << 18
+#define PRIMITIVE_POLYGON 4 << 18
+#define PRIMITIVE_LINE 5 << 18
+#define PRIMITIVE_LINE_STRIP 6 << 18
+#define PRIMITIVE_RECTANGLE 7 << 18
+
+/* Vertex format instruction */
+#define GFX_VERTEX_FORMAT 0x05000000
+#define VERTEX_0_TEXCOORDS 0 << 8
+#define VERTEX_1_TEXCOORDS 1 << 8
+#define VERTEX_2_TEXCOORDS 2 << 8
+#define VERTEX_SPECULAR_FOG 1 << 7
+#define VERTEX_DIFFUSE_ALPHA 1 << 6
+#define VERTEX_Z_OFFSET 1 << 5
+#define VERTEX_POS_XYZ 1 << 1
+#define VERTEX_POS_XYZ_RHW 2 << 1
+#define VERTEX_POS_XY 3 << 1
+#define VERTEX_POS_XY_RHW 4 << 1
+
+/* Drawing Rectangle Info instruction */
+
+#define GFX_DRAWING_RECTANGLE_INFO 0x1d800003
+#define GFX_DRAWING_CLIP_DISABLE 1<<31
+
+/* Boolean enable 1 */
+#define GFX_BOOLEAN_ENA_1 0x03000000
+#define BOOL1_ALPHA_SETUP_MASK 1<<17
+#define BOOL1_ALPHA_SETUP_BIT 1<<16
+#define BOOL1_FOG_ENABLE_MASK 1<<7
+#define BOOL1_FOG_ENABLE_BIT 1<<6
+#define BOOL1_ALPHA_TEST_MASK 1<<5
+#define BOOL1_ALPHA_TEST_BIT 1<<4
+#define BOOL1_BLEND_ENABLE_MASK 1<<3
+#define BOOL1_BLEND_ENABLE_BIT 1<<2
+#define BOOL1_Z_ENABLE_MASK 1<<1
+#define BOOL1_Z_ENABLE_BIT 1<<0
+
+/* Boolean enable 2 */
+#define GFX_BOOLEAN_ENA_2 0x04000000
+#define BOOL2_MAPPING_CACHE_MASK 1<<17
+#define BOOL2_MAPPING_CACHE_BIT 1<<16
+#define BOOL2_ALPHA_DITHER_MASK 1<<15
+#define BOOL2_ALPHA_DITHER_BIT 1<<14
+#define BOOL2_FOG_DITHER_MASK 1<<13
+#define BOOL2_FOG_DITHER_BIT 1<<12
+#define BOOL2_SPECULAR_DITHER_MASK 1<<11
+#define BOOL2_SPECULAR_DITHER_BIT 1<<10
+#define BOOL2_COLOR_DITHER_MASK 1<<9
+#define BOOL2_COLOR_DITHER_BIT 1<<8
+#define BOOL2_FB_WRITE_MASK 1<<3
+#define BOOL2_FB_WRITE_BIT 1<<2
+#define BOOL2_Z_WRITE_MASK 1<<1
+#define BOOL2_Z_WRITE_BIT 1<<0
+
+/* Dest buffer variables */
+
+#define GFX_DEST_BUFFER_VARIABLES 0x1d850000
+
+#define DEST_BUF_VAR_8BIT 0 << 8
+#define DEST_BUF_VAR_555 1 << 8
+#define DEST_BUF_VAR_565 2 << 8
+
+/* map color blend stages */
+
+#define GFX_MAP_COLOR_BLEND_STAGES 0
+
+#define MAP_BLEND_STAGE_B 20
+#define MAP_BLEND_ACC_SEL_MASK 1<<19
+#define MAP_BLEND_ACC_SEL_BIT 1<<18
+#define MAP_BLEND_ARG1_MASK 1<<17
+#define MAP_BLEND_ARG1_B 14
+#define MAP_BLEND_REPLICATE_ARG1 1<<13
+#define MAP_BLEND_INVERT_ARG1 1<<12
+
+#define MAP_BLEND_ARG2_MASK 1<<11
+#define MAP_BLEND_ARG2_B 8
+#define MAP_BLEND_REPLICATE_ARG2 1<<7
+#define MAP_BLEND_INVERT_ARG2 1<<6
+
+#define MAP_BLEND_COLOR_OP_MASK 1<<5
+#define MAP_BLEND_COLOR_OP_B 0
+
+#define GFX_SCISSOR_ENABLE 0x1c800000
+
+#define SCISSOR_ENABLE_MASK 1<<1
+#define SCISSOR_ENABLE_BIT 1<<0
diff --git a/xorg-server/hw/kdrive/i810/i810_video.c b/xorg-server/hw/kdrive/i810/i810_video.c
new file mode 100644
index 000000000..ac881d51d
--- /dev/null
+++ b/xorg-server/hw/kdrive/i810/i810_video.c
@@ -0,0 +1,1136 @@
+/* COPYRIGHT AND PERMISSION NOTICE
+
+Copyright (c) 2000, 2001 Nokia Home Communications
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+X Window System is a trademark of The Open Group */
+
+/***************************************************************************
+
+Copyright 2000 Intel Corporation. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL INTEL, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+
+/*
+ * i810_video.c: i810 KDrive Xv driver.
+ * Based on the XFree86 i810 Xv driver by Jonathan Bian.
+ *
+ * Authors:
+ * Jonathan Bian <jonathan.bian@intel.com>
+ * Pontus Lidman <pontus.lidman@nokia.com>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "kxv.h"
+#include "i810.h"
+
+#include <X11/extensions/Xv.h>
+
+#include "fourcc.h"
+
+typedef struct {
+ CARD32 size;
+ CARD32 offset;
+} FBLinearRec, *FBLinearPtr;
+
+#define OFF_DELAY 250 /* milliseconds */
+#define FREE_DELAY 15000
+
+#define OFF_TIMER 0x01
+#define FREE_TIMER 0x02
+#define CLIENT_VIDEO_ON 0x04
+
+#define TIMER_MASK (OFF_TIMER | FREE_TIMER)
+
+static KdVideoAdaptorPtr i810SetupImageVideo(ScreenPtr);
+static void i810StopVideo(KdScreenInfo *, pointer, Bool);
+static int i810SetPortAttribute(KdScreenInfo *, Atom, int, pointer);
+static int i810GetPortAttribute(KdScreenInfo *, Atom, int *, pointer);
+static void i810QueryBestSize(KdScreenInfo *, Bool,
+ short, short, short, short, unsigned int *, unsigned int *, pointer);
+static int i810PutImage( KdScreenInfo *, DrawablePtr,
+ short, short, short, short, short, short, short, short,
+ int, unsigned char*, short, short, Bool, RegionPtr, pointer);
+static int i810QueryImageAttributes(KdScreenInfo *,
+ int, unsigned short *, unsigned short *, int *, int *);
+
+static void i810BlockHandler(int, pointer, pointer, pointer);
+
+#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
+
+static Atom xvBrightness, xvContrast, xvColorKey;
+
+#define IMAGE_MAX_WIDTH 720
+#define IMAGE_MAX_HEIGHT 576
+#define Y_BUF_SIZE (IMAGE_MAX_WIDTH * IMAGE_MAX_HEIGHT)
+
+#define OVERLAY_UPDATE(p) OUTREG(0x30000, p | 0x80000000);
+
+/*
+ * OV0CMD - Overlay Command Register
+ */
+#define VERTICAL_CHROMINANCE_FILTER 0x70000000
+#define VC_SCALING_OFF 0x00000000
+#define VC_LINE_REPLICATION 0x10000000
+#define VC_UP_INTERPOLATION 0x20000000
+#define VC_PIXEL_DROPPING 0x50000000
+#define VC_DOWN_INTERPOLATION 0x60000000
+#define VERTICAL_LUMINANCE_FILTER 0x0E000000
+#define VL_SCALING_OFF 0x00000000
+#define VL_LINE_REPLICATION 0x02000000
+#define VL_UP_INTERPOLATION 0x04000000
+#define VL_PIXEL_DROPPING 0x0A000000
+#define VL_DOWN_INTERPOLATION 0x0C000000
+#define HORIZONTAL_CHROMINANCE_FILTER 0x01C00000
+#define HC_SCALING_OFF 0x00000000
+#define HC_LINE_REPLICATION 0x00400000
+#define HC_UP_INTERPOLATION 0x00800000
+#define HC_PIXEL_DROPPING 0x01400000
+#define HC_DOWN_INTERPOLATION 0x01800000
+#define HORIZONTAL_LUMINANCE_FILTER 0x00380000
+#define HL_SCALING_OFF 0x00000000
+#define HL_LINE_REPLICATION 0x00080000
+#define HL_UP_INTERPOLATION 0x00100000
+#define HL_PIXEL_DROPPING 0x00280000
+#define HL_DOWN_INTERPOLATION 0x00300000
+
+#define Y_ADJUST 0x00010000
+#define OV_BYTE_ORDER 0x0000C000
+#define UV_SWAP 0x00004000
+#define Y_SWAP 0x00008000
+#define Y_AND_UV_SWAP 0x0000C000
+#define SOURCE_FORMAT 0x00003C00
+#define RGB_555 0x00000800
+#define RGB_565 0x00000C00
+#define YUV_422 0x00002000
+#define YUV_411 0x00002400
+#define YUV_420 0x00003000
+#define YUV_410 0x00003800
+#define BUFFER_AND_FIELD 0x00000006
+#define BUFFER0_FIELD0 0x00000000
+#define BUFFER1_FIELD0 0x00000004
+#define OVERLAY_ENABLE 0x00000001
+
+/*
+ * DOV0STA - Display/Overlay 0 Status Register
+ */
+#define DOV0STA 0x30008
+
+#define MINUV_SCALE 0x1
+
+#define RGB16ToColorKey(c) \
+ (((c & 0xF800) << 8) | ((c & 0x07E0) << 5) | ((c & 0x001F) << 3))
+
+#define RGB15ToColorKey(c) \
+ (((c & 0x7c00) << 9) | ((c & 0x03E0) << 6) | ((c & 0x001F) << 3))
+
+Bool i810InitVideo(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL;
+ KdVideoAdaptorPtr newAdaptor = NULL;
+ int num_adaptors;
+
+/* fprintf(stderr,"i810InitVideo\n"); */
+
+ if (screen->fb[0].bitsPerPixel != 8)
+ {
+ newAdaptor = i810SetupImageVideo(pScreen);
+ }
+
+ num_adaptors = KdXVListGenericAdaptors(screen, &adaptors);
+
+ if(newAdaptor) {
+ if(!num_adaptors) {
+ num_adaptors = 1;
+ adaptors = &newAdaptor;
+ } else {
+ newAdaptors = /* need to free this someplace */
+ xalloc((num_adaptors + 1) * sizeof(KdVideoAdaptorPtr*));
+ if(newAdaptors) {
+ memcpy(newAdaptors, adaptors, num_adaptors *
+ sizeof(KdVideoAdaptorPtr));
+ newAdaptors[num_adaptors] = newAdaptor;
+ adaptors = newAdaptors;
+ num_adaptors++;
+ }
+ }
+ }
+
+ if(num_adaptors)
+ KdXVScreenInit(pScreen, adaptors, num_adaptors);
+
+ if(newAdaptors)
+ xfree(newAdaptors);
+ return TRUE;
+}
+
+/* client libraries expect an encoding */
+static KdVideoEncodingRec DummyEncoding[1] =
+{
+ {
+ 0,
+ "XV_IMAGE",
+ IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT,
+ {1, 1}
+ }
+};
+
+#define NUM_FORMATS 3
+
+static KdVideoFormatRec Formats[NUM_FORMATS] =
+{
+ {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
+};
+
+#define NUM_ATTRIBUTES 3
+
+static KdAttributeRec Attributes[NUM_ATTRIBUTES] =
+{
+ {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"},
+ {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"},
+ {XvSettable | XvGettable, 0, 255, "XV_CONTRAST"}
+};
+
+#define NUM_IMAGES 4
+
+static KdImageRec Images[NUM_IMAGES] =
+{
+ XVIMAGE_YUY2,
+ XVIMAGE_YV12,
+ XVIMAGE_I420,
+ XVIMAGE_UYVY
+};
+
+typedef struct {
+ CARD32 OBUF_0Y;
+ CARD32 OBUF_1Y;
+ CARD32 OBUF_0U;
+ CARD32 OBUF_0V;
+ CARD32 OBUF_1U;
+ CARD32 OBUF_1V;
+ CARD32 OV0STRIDE;
+ CARD32 YRGB_VPH;
+ CARD32 UV_VPH;
+ CARD32 HORZ_PH;
+ CARD32 INIT_PH;
+ CARD32 DWINPOS;
+ CARD32 DWINSZ;
+ CARD32 SWID;
+ CARD32 SWIDQW;
+ CARD32 SHEIGHT;
+ CARD32 YRGBSCALE;
+ CARD32 UVSCALE;
+ CARD32 OV0CLRC0;
+ CARD32 OV0CLRC1;
+ CARD32 DCLRKV;
+ CARD32 DCLRKM;
+ CARD32 SCLRKVH;
+ CARD32 SCLRKVL;
+ CARD32 SCLRKM;
+ CARD32 OV0CONF;
+ CARD32 OV0CMD;
+} I810OverlayRegRec, *I810OverlayRegPtr;
+
+typedef struct {
+ CARD32 YBuf0offset;
+ CARD32 UBuf0offset;
+ CARD32 VBuf0offset;
+
+ CARD32 YBuf1offset;
+ CARD32 UBuf1offset;
+ CARD32 VBuf1offset;
+
+ unsigned char currentBuf;
+
+ unsigned char brightness;
+ unsigned char contrast;
+
+ RegionRec clip;
+ CARD32 colorKey;
+
+ CARD32 videoStatus;
+ Time offTime;
+ Time freeTime;
+ FBLinearPtr linear;
+} I810PortPrivRec, *I810PortPrivPtr;
+
+#define GET_PORT_PRIVATE(screen) \
+ (I810PortPrivPtr)(((I810CardInfo *) (screen->card->driver))->adaptor->pPortPrivates[0].ptr)
+
+static void i810ResetVideo(KdScreenInfo *screen)
+{
+ ScreenPtr pScreen = screen->pScreen;
+ KdScreenPriv(pScreen);
+ KdCardInfo *card = pScreenPriv->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+
+ I810PortPrivPtr pPriv = i810c->adaptor->pPortPrivates[0].ptr;
+ I810OverlayRegPtr overlay = (I810OverlayRegPtr) (i810c->FbBase + i810c->OverlayStart);
+
+ /*
+ * Default to maximum image size in YV12
+ */
+
+ overlay->YRGB_VPH = 0;
+ overlay->UV_VPH = 0;
+ overlay->HORZ_PH = 0;
+ overlay->INIT_PH = 0;
+ overlay->DWINPOS = 0;
+ overlay->DWINSZ = (IMAGE_MAX_HEIGHT << 16) | IMAGE_MAX_WIDTH;
+ overlay->SWID = IMAGE_MAX_WIDTH | (IMAGE_MAX_WIDTH << 15);
+ overlay->SWIDQW = (IMAGE_MAX_WIDTH >> 3) | (IMAGE_MAX_WIDTH << 12);
+ overlay->SHEIGHT = IMAGE_MAX_HEIGHT | (IMAGE_MAX_HEIGHT << 15);
+ overlay->YRGBSCALE = 0x80004000; /* scale factor 1 */
+ overlay->UVSCALE = 0x80004000; /* scale factor 1 */
+ overlay->OV0CLRC0 = 0x4000; /* brightness: 0 contrast: 1.0 */
+ overlay->OV0CLRC1 = 0x80; /* saturation: bypass */
+
+ /*
+ * Enable destination color keying
+ */
+ switch(screen->fb[0].depth) {
+ case 16: overlay->DCLRKV = RGB16ToColorKey(pPriv->colorKey);
+ overlay->DCLRKM = 0x80070307;
+ break;
+ case 15: overlay->DCLRKV = RGB15ToColorKey(pPriv->colorKey);
+ overlay->DCLRKM = 0x80070707;
+ break;
+ default: overlay->DCLRKV = pPriv->colorKey;
+ overlay->DCLRKM = 0x80000000;
+ break;
+ }
+
+ overlay->SCLRKVH = 0;
+ overlay->SCLRKVL = 0;
+ overlay->SCLRKM = 0; /* source color key disable */
+ overlay->OV0CONF = 0; /* two 720 pixel line buffers */
+
+ overlay->OV0CMD = VC_UP_INTERPOLATION | HC_UP_INTERPOLATION | Y_ADJUST |
+ YUV_420;
+
+ OVERLAY_UPDATE(i810c->OverlayPhysical);
+}
+
+
+static KdVideoAdaptorPtr
+i810SetupImageVideo(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ KdCardInfo *card = pScreenPriv->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+
+
+ KdVideoAdaptorPtr adapt;
+ I810PortPrivPtr pPriv;
+
+/* fprintf(stderr,"i810SetupImageVideo\n"); */
+
+ if(!(adapt = xcalloc(1, sizeof(KdVideoAdaptorRec) +
+ sizeof(I810PortPrivRec) +
+ sizeof(DevUnion))))
+ return NULL;
+
+ adapt->type = XvWindowMask | XvInputMask | XvImageMask;
+ adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
+ adapt->name = "I810 Video Overlay";
+ adapt->nEncodings = 1;
+ adapt->pEncodings = DummyEncoding;
+ adapt->nFormats = NUM_FORMATS;
+ adapt->pFormats = Formats;
+ adapt->nPorts = 1;
+ adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
+
+ pPriv = (I810PortPrivPtr)(&adapt->pPortPrivates[1]);
+
+ adapt->pPortPrivates[0].ptr = (pointer)(pPriv);
+ adapt->pAttributes = Attributes;
+ adapt->nImages = NUM_IMAGES;
+ adapt->nAttributes = NUM_ATTRIBUTES;
+ adapt->pImages = Images;
+ adapt->PutVideo = NULL;
+ adapt->PutStill = NULL;
+ adapt->GetVideo = NULL;
+ adapt->GetStill = NULL;
+ adapt->StopVideo = i810StopVideo;
+ adapt->SetPortAttribute = i810SetPortAttribute;
+ adapt->GetPortAttribute = i810GetPortAttribute;
+ adapt->QueryBestSize = i810QueryBestSize;
+ adapt->PutImage = i810PutImage;
+ adapt->QueryImageAttributes = i810QueryImageAttributes;
+
+ pPriv->colorKey = i810c->colorKey & ((1 << screen->fb[0].depth) - 1);
+ pPriv->videoStatus = 0;
+ pPriv->brightness = 0;
+ pPriv->contrast = 128;
+ pPriv->linear = NULL;
+ pPriv->currentBuf = 0;
+
+ /* gotta uninit this someplace */
+ REGION_INIT(pScreen, &pPriv->clip, NullBox, 0);
+
+ i810c->adaptor = adapt;
+
+ i810c->BlockHandler = pScreen->BlockHandler;
+ pScreen->BlockHandler = i810BlockHandler;
+
+ xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
+ xvContrast = MAKE_ATOM("XV_CONTRAST");
+ xvColorKey = MAKE_ATOM("XV_COLORKEY");
+
+ i810ResetVideo(screen);
+
+ return adapt;
+}
+
+
+/* I810ClipVideo -
+
+ Takes the dst box in standard X BoxRec form (top and left
+ edges inclusive, bottom and right exclusive). The new dst
+ box is returned. The source boundaries are given (x1, y1
+ inclusive, x2, y2 exclusive) and returned are the new source
+ boundaries in 16.16 fixed point.
+*/
+
+static void
+I810ClipVideo(
+ BoxPtr dst,
+ INT32 *x1,
+ INT32 *x2,
+ INT32 *y1,
+ INT32 *y2,
+ BoxPtr extents, /* extents of the clip region */
+ INT32 width,
+ INT32 height
+){
+ INT32 vscale, hscale, delta;
+ int diff;
+
+ hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1);
+ vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1);
+
+ *x1 <<= 16; *x2 <<= 16;
+ *y1 <<= 16; *y2 <<= 16;
+
+ diff = extents->x1 - dst->x1;
+ if(diff > 0) {
+ dst->x1 = extents->x1;
+ *x1 += diff * hscale;
+ }
+ diff = dst->x2 - extents->x2;
+ if(diff > 0) {
+ dst->x2 = extents->x2;
+ *x2 -= diff * hscale;
+ }
+ diff = extents->y1 - dst->y1;
+ if(diff > 0) {
+ dst->y1 = extents->y1;
+ *y1 += diff * vscale;
+ }
+ diff = dst->y2 - extents->y2;
+ if(diff > 0) {
+ dst->y2 = extents->y2;
+ *y2 -= diff * vscale;
+ }
+
+ if(*x1 < 0) {
+ diff = (- *x1 + hscale - 1)/ hscale;
+ dst->x1 += diff;
+ *x1 += diff * hscale;
+ }
+ delta = *x2 - (width << 16);
+ if(delta > 0) {
+ diff = (delta + hscale - 1)/ hscale;
+ dst->x2 -= diff;
+ *x2 -= diff * hscale;
+ }
+ if(*y1 < 0) {
+ diff = (- *y1 + vscale - 1)/ vscale;
+ dst->y1 += diff;
+ *y1 += diff * vscale;
+ }
+ delta = *y2 - (height << 16);
+ if(delta > 0) {
+ diff = (delta + vscale - 1)/ vscale;
+ dst->y2 -= diff;
+ *y2 -= diff * vscale;
+ }
+}
+
+static void
+i810StopVideo(KdScreenInfo *screen, pointer data, Bool exit)
+{
+ I810PortPrivPtr pPriv = (I810PortPrivPtr)data;
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+
+ I810OverlayRegPtr overlay = (I810OverlayRegPtr) (i810c->FbBase + i810c->OverlayStart);
+
+ REGION_EMPTY(screen->pScreen, &pPriv->clip);
+
+ if(exit) {
+ if(pPriv->videoStatus & CLIENT_VIDEO_ON) {
+ overlay->OV0CMD &= 0xFFFFFFFE;
+ OVERLAY_UPDATE(i810c->OverlayPhysical);
+ }
+ if(pPriv->linear) {
+ xfree(pPriv->linear);
+ pPriv->linear = NULL;
+ }
+ pPriv->videoStatus = 0;
+ } else {
+ if(pPriv->videoStatus & CLIENT_VIDEO_ON) {
+ pPriv->videoStatus |= OFF_TIMER;
+ pPriv->offTime = currentTime.milliseconds + OFF_DELAY;
+ }
+ }
+
+}
+
+static int
+i810SetPortAttribute(
+ KdScreenInfo *screen,
+ Atom attribute,
+ int value,
+ pointer data
+){
+ I810PortPrivPtr pPriv = (I810PortPrivPtr)data;
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+
+ I810OverlayRegPtr overlay = (I810OverlayRegPtr) (i810c->FbBase + i810c->OverlayStart);
+
+ if(attribute == xvBrightness) {
+ if((value < -128) || (value > 127))
+ return BadValue;
+ pPriv->brightness = value;
+ overlay->OV0CLRC0 &= 0xFFFFFF00;
+ overlay->OV0CLRC0 |= value;
+ OVERLAY_UPDATE(i810c->OverlayPhysical);
+ } else
+ if(attribute == xvContrast) {
+ if((value < 0) || (value > 255))
+ return BadValue;
+ pPriv->contrast = value;
+ overlay->OV0CLRC0 &= 0xFFFE00FF;
+ overlay->OV0CLRC0 |= value << 9;
+ OVERLAY_UPDATE(i810c->OverlayPhysical);
+ } else
+ if(attribute == xvColorKey) {
+ pPriv->colorKey = value;
+ switch(screen->fb[0].depth) {
+ case 16: overlay->DCLRKV = RGB16ToColorKey(pPriv->colorKey);
+ break;
+ case 15: overlay->DCLRKV = RGB15ToColorKey(pPriv->colorKey);
+ break;
+ default: overlay->DCLRKV = pPriv->colorKey;
+ break;
+ }
+ OVERLAY_UPDATE(i810c->OverlayPhysical);
+ REGION_EMPTY(screen->pScreen, &pPriv->clip);
+ } else return BadMatch;
+
+ return Success;
+}
+
+static int
+i810GetPortAttribute(
+ KdScreenInfo *screen,
+ Atom attribute,
+ int *value,
+ pointer data
+){
+ I810PortPrivPtr pPriv = (I810PortPrivPtr)data;
+
+ if(attribute == xvBrightness) {
+ *value = pPriv->brightness;
+ } else
+ if(attribute == xvContrast) {
+ *value = pPriv->contrast;
+ } else
+ if(attribute == xvColorKey) {
+ *value = pPriv->colorKey;
+ } else return BadMatch;
+
+ return Success;
+}
+
+static void
+i810QueryBestSize(
+ KdScreenInfo *screen,
+ Bool motion,
+ short vid_w, short vid_h,
+ short drw_w, short drw_h,
+ unsigned int *p_w, unsigned int *p_h,
+ pointer data
+){
+ *p_w = drw_w;
+ *p_h = drw_h;
+}
+
+
+static void
+I810CopyPackedData(
+ KdScreenInfo *screen,
+ unsigned char *buf,
+ int srcPitch,
+ int dstPitch,
+ int top,
+ int left,
+ int h,
+ int w
+ )
+{
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+ I810PortPrivPtr pPriv = i810c->adaptor->pPortPrivates[0].ptr;
+ unsigned char *src, *dst;
+
+ src = buf + (top*srcPitch) + (left<<1);
+
+ if (pPriv->currentBuf == 0)
+ dst = i810c->FbBase + pPriv->YBuf0offset;
+ else
+ dst = i810c->FbBase + pPriv->YBuf1offset;
+
+ w <<= 1;
+ while(h--) {
+ memcpy(dst, src, w);
+ src += srcPitch;
+ dst += dstPitch;
+ }
+}
+
+static void
+i810CopyPlanarData(
+ KdScreenInfo *screen,
+ unsigned char *buf,
+ int srcPitch,
+ int dstPitch, /* of chroma */
+ int srcH,
+ int top,
+ int left,
+ int h,
+ int w,
+ int id
+ )
+{
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+ I810PortPrivPtr pPriv = i810c->adaptor->pPortPrivates[0].ptr;
+ int i;
+ unsigned char *src1, *src2, *src3, *dst1, *dst2, *dst3;
+
+ /* Copy Y data */
+ src1 = buf + (top*srcPitch) + left;
+ if (pPriv->currentBuf == 0)
+ dst1 = i810c->FbBase + pPriv->YBuf0offset;
+ else
+ dst1 = i810c->FbBase + pPriv->YBuf1offset;
+
+ for (i = 0; i < h; i++) {
+ memcpy(dst1, src1, w);
+ src1 += srcPitch;
+ dst1 += dstPitch << 1;
+ }
+
+ /* Copy V data for YV12, or U data for I420 */
+ src2 = buf + (srcH*srcPitch) + ((top*srcPitch)>>2) + (left>>1);
+ if (pPriv->currentBuf == 0) {
+ if (id == FOURCC_I420)
+ dst2 = i810c->FbBase + pPriv->UBuf0offset;
+ else
+ dst2 = i810c->FbBase + pPriv->VBuf0offset;
+ } else {
+ if (id == FOURCC_I420)
+ dst2 = i810c->FbBase + pPriv->UBuf1offset;
+ else
+ dst2 = i810c->FbBase + pPriv->VBuf1offset;
+ }
+
+ for (i = 0; i < h/2; i++) {
+ memcpy(dst2, src2, w/2);
+ src2 += srcPitch>>1;
+ dst2 += dstPitch;
+ }
+
+ /* Copy U data for YV12, or V data for I420 */
+ src3 = buf + (srcH*srcPitch) + ((srcH*srcPitch)>>2) + ((top*srcPitch)>>2) + (left>>1);
+ if (pPriv->currentBuf == 0) {
+ if (id == FOURCC_I420)
+ dst3 = i810c->FbBase + pPriv->VBuf0offset;
+ else
+ dst3 = i810c->FbBase + pPriv->UBuf0offset;
+ } else {
+ if (id == FOURCC_I420)
+ dst3 = i810c->FbBase + pPriv->VBuf1offset;
+ else
+ dst3 = i810c->FbBase + pPriv->UBuf1offset;
+ }
+
+ for (i = 0; i < h/2; i++) {
+ memcpy(dst3, src3, w/2);
+ src3 += srcPitch>>1;
+ dst3 += dstPitch;
+ }
+}
+
+static void
+i810DisplayVideo(
+ KdScreenInfo *screen,
+ int id,
+ short width, short height,
+ int dstPitch, /* of chroma for 4:2:0 */
+ int x1, int y1, int x2, int y2,
+ BoxPtr dstBox,
+ short src_w, short src_h,
+ short drw_w, short drw_h
+){
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+ I810PortPrivPtr pPriv = i810c->adaptor->pPortPrivates[0].ptr;
+ I810OverlayRegPtr overlay = (I810OverlayRegPtr) (i810c->FbBase + i810c->OverlayStart);
+ int xscaleInt, xscaleFract, yscaleInt, yscaleFract;
+ int xscaleIntUV = 0, xscaleFractUV = 0, yscaleIntUV = 0, yscaleFractUV = 0;
+ unsigned int swidth;
+
+ switch(id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ swidth = (width + 7) & ~7;
+ overlay->SWID = (swidth << 15) | swidth;
+ overlay->SWIDQW = (swidth << 12) | (swidth >> 3);
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ default:
+ swidth = ((width + 3) & ~3) << 1;
+ overlay->SWID = swidth;
+ overlay->SWIDQW = swidth >> 3;
+ break;
+ }
+
+ overlay->SHEIGHT = height | (height << 15);
+ overlay->DWINPOS = (dstBox->y1 << 16) | dstBox->x1;
+ overlay->DWINSZ = ((dstBox->y2 - dstBox->y1) << 16) |
+ (dstBox->x2 - dstBox->x1);
+
+ /* buffer locations */
+ overlay->OBUF_0Y = pPriv->YBuf0offset;
+ overlay->OBUF_1Y = pPriv->YBuf1offset;
+ overlay->OBUF_0U = pPriv->UBuf0offset;
+ overlay->OBUF_0V = pPriv->VBuf0offset;
+ overlay->OBUF_1U = pPriv->UBuf1offset;
+ overlay->OBUF_1V = pPriv->VBuf1offset;
+
+ /*
+ * Calculate horizontal and vertical scaling factors, default to 1:1
+ */
+ overlay->YRGBSCALE = 0x80004000;
+ overlay->UVSCALE = 0x80004000;
+
+ /*
+ * Initially, YCbCr and Overlay Enable and
+ * vertical chrominance up interpolation and horozontal chrominance
+ * up interpolation
+ */
+ overlay->OV0CMD = VC_UP_INTERPOLATION | HC_UP_INTERPOLATION | Y_ADJUST |
+ OVERLAY_ENABLE;
+
+ if ((drw_w != src_w) || (drw_h != src_h))
+ {
+ xscaleInt = (src_w / drw_w) & 0x3;
+ xscaleFract = (src_w << 12) / drw_w;
+ yscaleInt = (src_h / drw_h) & 0x3;
+ yscaleFract = (src_h << 12) / drw_h;
+
+ overlay->YRGBSCALE = (xscaleInt << 15) |
+ ((xscaleFract & 0xFFF) << 3) |
+ (yscaleInt) |
+ ((yscaleFract & 0xFFF) << 20);
+
+ if (drw_w > src_w)
+ {
+ /* horizontal up-scaling */
+ overlay->OV0CMD &= ~HORIZONTAL_CHROMINANCE_FILTER;
+ overlay->OV0CMD &= ~HORIZONTAL_LUMINANCE_FILTER;
+ overlay->OV0CMD |= (HC_UP_INTERPOLATION | HL_UP_INTERPOLATION);
+ }
+
+ if (drw_h > src_h)
+ {
+ /* vertical up-scaling */
+ overlay->OV0CMD &= ~VERTICAL_CHROMINANCE_FILTER;
+ overlay->OV0CMD &= ~VERTICAL_LUMINANCE_FILTER;
+ overlay->OV0CMD |= (VC_UP_INTERPOLATION | VL_UP_INTERPOLATION);
+ }
+
+ if (drw_w < src_w)
+ {
+ /* horizontal down-scaling */
+ overlay->OV0CMD &= ~HORIZONTAL_CHROMINANCE_FILTER;
+ overlay->OV0CMD &= ~HORIZONTAL_LUMINANCE_FILTER;
+ overlay->OV0CMD |= (HC_DOWN_INTERPOLATION | HL_DOWN_INTERPOLATION);
+ }
+
+ if (drw_h < src_h)
+ {
+ /* vertical down-scaling */
+ overlay->OV0CMD &= ~VERTICAL_CHROMINANCE_FILTER;
+ overlay->OV0CMD &= ~VERTICAL_LUMINANCE_FILTER;
+ overlay->OV0CMD |= (VC_DOWN_INTERPOLATION | VL_DOWN_INTERPOLATION);
+ }
+
+ /* now calculate the UV scaling factor */
+
+ if (xscaleFract)
+ {
+ xscaleFractUV = xscaleFract >> MINUV_SCALE;
+ overlay->OV0CMD &= ~HC_DOWN_INTERPOLATION;
+ overlay->OV0CMD |= HC_UP_INTERPOLATION;
+ }
+
+ if (xscaleInt)
+ {
+ xscaleIntUV = xscaleInt >> MINUV_SCALE;
+ if (xscaleIntUV)
+ {
+ overlay->OV0CMD &= ~HC_UP_INTERPOLATION;
+ }
+ }
+
+ if (yscaleFract)
+ {
+ yscaleFractUV = yscaleFract >> MINUV_SCALE;
+ overlay->OV0CMD &= ~VC_DOWN_INTERPOLATION;
+ overlay->OV0CMD |= VC_UP_INTERPOLATION;
+ }
+
+ if (yscaleInt)
+ {
+ yscaleIntUV = yscaleInt >> MINUV_SCALE;
+ if (yscaleIntUV)
+ {
+ overlay->OV0CMD &= ~VC_UP_INTERPOLATION;
+ overlay->OV0CMD |= VC_DOWN_INTERPOLATION;
+ }
+ }
+
+ overlay->UVSCALE = yscaleIntUV | ((xscaleFractUV & 0xFFF) << 3) |
+ ((yscaleFractUV & 0xFFF) << 20);
+ }
+
+ switch(id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ overlay->OV0STRIDE = (dstPitch << 1) | (dstPitch << 16);
+ overlay->OV0CMD &= ~SOURCE_FORMAT;
+ overlay->OV0CMD |= YUV_420;
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ default:
+ overlay->OV0STRIDE = dstPitch;
+ overlay->OV0CMD &= ~SOURCE_FORMAT;
+ overlay->OV0CMD |= YUV_422;
+ overlay->OV0CMD &= ~OV_BYTE_ORDER;
+ if (id == FOURCC_UYVY)
+ overlay->OV0CMD |= Y_SWAP;
+ break;
+ }
+
+ overlay->OV0CMD &= ~BUFFER_AND_FIELD;
+ if (pPriv->currentBuf == 0)
+ overlay->OV0CMD |= BUFFER0_FIELD0;
+ else
+ overlay->OV0CMD |= BUFFER1_FIELD0;
+
+ OVERLAY_UPDATE(i810c->OverlayPhysical);
+
+}
+
+static FBLinearPtr
+i810AllocateMemory(
+ KdScreenInfo *screen,
+ FBLinearPtr linear,
+ int size
+){
+ KdCardInfo *card=screen->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+ FBLinearPtr new_linear;
+
+ if(linear) {
+ if(linear->size >= size)
+ return linear;
+ else
+ ErrorF("Ran out of memory for overlay buffer, requested size = %d\n",size);
+ }
+
+ new_linear = xalloc(sizeof(FBLinearRec));
+ new_linear->size = i810c->XvMem.Size;
+ new_linear->offset = i810c->XvMem.Start;
+
+/* fprintf(stderr,"Overlay mem offset %lx\n",new_linear->offset); */
+
+ return new_linear;
+}
+
+static int
+i810PutImage(KdScreenInfo *screen,
+ DrawablePtr pDraw,
+ short src_x,
+ short src_y,
+ short drw_x,
+ short drw_y,
+ short src_w,
+ short src_h,
+ short drw_w,
+ short drw_h,
+ int id,
+ unsigned char *buf,
+ short width,
+ short height,
+ Bool sync,
+ RegionPtr clipBoxes,
+ pointer data)
+{
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+ I810PortPrivPtr pPriv = (I810PortPrivPtr)data;
+ INT32 x1, x2, y1, y2;
+ int srcPitch, dstPitch;
+ int top, left, npixels, nlines, size;
+ BoxRec dstBox;
+
+ /* Clip */
+ x1 = src_x;
+ x2 = src_x + src_w;
+ y1 = src_y;
+ y2 = src_y + src_h;
+
+ dstBox.x1 = drw_x;
+ dstBox.x2 = drw_x + drw_w;
+ dstBox.y1 = drw_y;
+ dstBox.y2 = drw_y + drw_h;
+
+ I810ClipVideo(&dstBox, &x1, &x2, &y1, &y2,
+ REGION_EXTENTS(pScreen, clipBoxes), width, height);
+
+ if((x1 >= x2) || (y1 >= y2))
+ return Success;
+
+ switch(id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ srcPitch = (width + 3) & ~3;
+ dstPitch = ((width >> 1) + 7) & ~7; /* of chroma */
+ size = dstPitch * height * 3;
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ default:
+ srcPitch = (width << 1);
+ dstPitch = (srcPitch + 7) & ~7;
+ size = dstPitch * height;
+ break;
+ }
+
+ if(!(pPriv->linear = i810AllocateMemory(screen, pPriv->linear,
+ (screen->fb[0].bitsPerPixel == 16) ? size : (size >> 1))))
+ return BadAlloc;
+
+ /* fixup pointers */
+ pPriv->YBuf0offset = pPriv->linear->offset;
+ pPriv->UBuf0offset = pPriv->YBuf0offset + (dstPitch * 2 * height);
+ pPriv->VBuf0offset = pPriv->UBuf0offset + (dstPitch * height >> 1);
+
+ pPriv->YBuf1offset = pPriv->linear->offset + size;
+ pPriv->UBuf1offset = pPriv->YBuf1offset + (dstPitch * 2 * height);
+ pPriv->VBuf1offset = pPriv->UBuf1offset + (dstPitch * height >> 1);
+
+ /* wait for the last rendered buffer to be flipped in */
+ while (((INREG(DOV0STA)&0x00100000)>>20) != pPriv->currentBuf);
+
+ /* buffer swap */
+ if (pPriv->currentBuf == 0)
+ pPriv->currentBuf = 1;
+ else
+ pPriv->currentBuf = 0;
+
+ /* copy data */
+ top = y1 >> 16;
+ left = (x1 >> 16) & ~1;
+ npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left;
+
+ switch(id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ top &= ~1;
+ nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
+ i810CopyPlanarData(screen, buf, srcPitch, dstPitch, height, top, left,
+ nlines, npixels, id);
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ default:
+ nlines = ((y2 + 0xffff) >> 16) - top;
+ I810CopyPackedData(screen, buf, srcPitch, dstPitch, top, left, nlines,
+ npixels);
+ break;
+ }
+
+ /* update cliplist */
+ if(!REGION_EQUAL(screen->pScreen, &pPriv->clip, clipBoxes)) {
+ REGION_COPY(screen->pScreen, &pPriv->clip, clipBoxes);
+ KXVPaintRegion (pDraw, &pPriv->clip, pPriv->colorKey);
+ }
+
+
+ i810DisplayVideo(screen, id, width, height, dstPitch,
+ x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h);
+
+ pPriv->videoStatus = CLIENT_VIDEO_ON;
+
+ return Success;
+}
+
+
+static int
+i810QueryImageAttributes(
+ KdScreenInfo *screen,
+ int id,
+ unsigned short *w, unsigned short *h,
+ int *pitches, int *offsets
+){
+ int size, tmp;
+
+ if(*w > 720) *w = 720;
+ if(*h > 576) *h = 576;
+
+ *w = (*w + 1) & ~1;
+ if(offsets) offsets[0] = 0;
+
+ switch(id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ *h = (*h + 1) & ~1;
+ size = (*w + 3) & ~3;
+ if(pitches) pitches[0] = size;
+ size *= *h;
+ if(offsets) offsets[1] = size;
+ tmp = ((*w >> 1) + 3) & ~3;
+ if(pitches) pitches[1] = pitches[2] = tmp;
+ tmp *= (*h >> 1);
+ size += tmp;
+ if(offsets) offsets[2] = size;
+ size += tmp;
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ default:
+ size = *w << 1;
+ if(pitches) pitches[0] = size;
+ size *= *h;
+ break;
+ }
+
+ return size;
+}
+
+static void
+i810BlockHandler (
+ int i,
+ pointer blockData,
+ pointer pTimeout,
+ pointer pReadmask
+){
+ ScreenPtr pScreen = screenInfo.screens[i];
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ KdCardInfo *card = screen->card;
+ I810CardInfo *i810c = (I810CardInfo *) card->driver;
+ I810PortPrivPtr pPriv = GET_PORT_PRIVATE(screen);
+ I810OverlayRegPtr overlay = (I810OverlayRegPtr) (i810c->FbBase + i810c->OverlayStart);
+
+ pScreen->BlockHandler = i810c->BlockHandler;
+
+ (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
+
+ pScreen->BlockHandler = i810BlockHandler;
+
+ if(pPriv->videoStatus & TIMER_MASK) {
+ UpdateCurrentTime();
+ if(pPriv->videoStatus & OFF_TIMER) {
+ if(pPriv->offTime < currentTime.milliseconds) {
+ /* Turn off the overlay */
+ overlay->OV0CMD &= 0xFFFFFFFE;
+ OVERLAY_UPDATE(i810c->OverlayPhysical);
+
+ pPriv->videoStatus = FREE_TIMER;
+ pPriv->freeTime = currentTime.milliseconds + FREE_DELAY;
+ }
+ } else { /* FREE_TIMER */
+ if(pPriv->freeTime < currentTime.milliseconds) {
+ if(pPriv->linear) {
+ xfree(pPriv->linear);
+ pPriv->linear = NULL;
+ }
+ pPriv->videoStatus = 0;
+ }
+ }
+ }
+}
diff --git a/xorg-server/hw/kdrive/i810/i810draw.c b/xorg-server/hw/kdrive/i810/i810draw.c
new file mode 100644
index 000000000..b571efbe0
--- /dev/null
+++ b/xorg-server/hw/kdrive/i810/i810draw.c
@@ -0,0 +1,352 @@
+/* COPYRIGHT AND PERMISSION NOTICE
+
+Copyright (c) 2000, 2001 Nokia Home Communications
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+X Window System is a trademark of The Open Group */
+
+/* Hardware accelerated drawing for KDrive i810 driver.
+ Author: Pontus Lidman <pontus.lidman@nokia.com>
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "kaa.h"
+#ifdef XV
+#include "kxv.h"
+#endif
+#include "i810.h"
+#include "i810_reg.h"
+
+//#include "Xmd.h"
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mistruct.h"
+#include "dixfontstr.h"
+#include "fb.h"
+#include "migc.h"
+#include "miline.h"
+#include "picturestr.h"
+
+#define NUM_STACK_RECTS 1024
+
+i810ScreenInfo *accel_i810s;
+
+static int
+i810WaitLpRing(i810ScreenInfo *i810s, int n, int timeout_millis)
+{
+ i810CardInfo *i810c = i810s->i810c;
+ I810RingBuffer *ring = &(i810c->LpRing);
+ int iters = 0;
+ int start = 0;
+ int now = 0;
+ int last_head = 0;
+ int first = 0;
+
+ /* If your system hasn't moved the head pointer in 2 seconds, I'm going to
+ * call it crashed.
+ */
+ if (timeout_millis == 0)
+ timeout_millis = 2000;
+
+ if (I810_DEBUG) {
+ fprintf(stderr, "i810WaitLpRing %d\n", n);
+ first = GetTimeInMillis();
+ }
+
+ while (ring->space < n)
+ {
+ int i;
+
+ ring->head = INREG(LP_RING + RING_HEAD) & HEAD_ADDR;
+ ring->space = ring->head - (ring->tail+8);
+
+ if (ring->space < 0)
+ ring->space += ring->mem.Size;
+
+ iters++;
+ now = GetTimeInMillis();
+ if ( start == 0 || now < start || ring->head != last_head) {
+ if (I810_DEBUG)
+ if (now > start)
+ fprintf(stderr, "space: %d wanted %d\n", ring->space, n );
+ start = now;
+ last_head = ring->head;
+ } else if ( now - start > timeout_millis ) {
+
+ i810PrintErrorState(i810c);
+ fprintf(stderr, "space: %d wanted %d\n", ring->space, n );
+ FatalError("lockup\n");
+ }
+
+ for (i = 0 ; i < 2000 ; i++)
+ ;
+ }
+
+ if (I810_DEBUG)
+ {
+ now = GetTimeInMillis();
+ if (now - first) {
+ fprintf(stderr,"Elapsed %d ms\n", now - first);
+ fprintf(stderr, "space: %d wanted %d\n", ring->space, n );
+ }
+ }
+
+ return iters;
+}
+
+static void
+i810Sync(i810ScreenInfo *i810s)
+{
+ i810CardInfo *i810c = i810s->i810c;
+ LP_RING_LOCALS;
+
+ if (I810_DEBUG)
+ fprintf(stderr, "i810Sync\n");
+
+ /* Send a flush instruction and then wait till the ring is empty.
+ * This is stronger than waiting for the blitter to finish as it also
+ * flushes the internal graphics caches.
+ */
+ BEGIN_LP_RING(2);
+ OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE );
+ OUT_RING( 0 ); /* pad to quadword */
+ ADVANCE_LP_RING();
+
+ i810WaitLpRing(i810s, i810c->LpRing.mem.Size - 8, 0);
+
+ i810c->LpRing.space = i810c->LpRing.mem.Size - 8;
+ i810c->nextColorExpandBuf = 0;
+}
+
+static void
+i810WaitMarker(ScreenPtr pScreen, int marker)
+{
+ KdScreenPriv(pScreen);
+ i810ScreenInfo(pScreenPriv);
+
+ i810Sync(i810s);
+}
+
+#if 0
+static void
+i810EmitInvarientState(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ i810CardInfo(pScreenPriv);
+ i810ScreenInfo(pScreenPriv);
+ LP_RING_LOCALS;
+
+ BEGIN_LP_RING( 10 );
+
+ OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE );
+ OUT_RING( GFX_CMD_CONTEXT_SEL | CS_UPDATE_USE | CS_USE_CTX0 );
+ OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE);
+ OUT_RING( 0 );
+
+
+ OUT_RING( GFX_OP_COLOR_CHROMA_KEY );
+ OUT_RING( CC1_UPDATE_KILL_WRITE |
+ CC1_DISABLE_KILL_WRITE |
+ CC1_UPDATE_COLOR_IDX |
+ CC1_UPDATE_CHROMA_LOW |
+ CC1_UPDATE_CHROMA_HI |
+ 0);
+ OUT_RING( 0 );
+ OUT_RING( 0 );
+
+ /* No depth buffer in KDrive yet */
+ /* OUT_RING( CMD_OP_Z_BUFFER_INFO ); */
+ /* OUT_RING( pI810->DepthBuffer.Start | pI810->auxPitchBits); */
+
+ ADVANCE_LP_RING();
+}
+#endif
+
+static unsigned int i810PatternRop[16] = {
+ 0x00, /* GXclear */
+ 0xA0, /* GXand */
+ 0x50, /* GXandReverse */
+ 0xF0, /* GXcopy */
+ 0x0A, /* GXandInvert */
+ 0xAA, /* GXnoop */
+ 0x5A, /* GXxor */
+ 0xFA, /* GXor */
+ 0x05, /* GXnor */
+ 0xA5, /* GXequiv */
+ 0x55, /* GXinvert */
+ 0xF5, /* GXorReverse */
+ 0x0F, /* GXcopyInvert */
+ 0xAF, /* GXorInverted */
+ 0x5F, /* GXnand */
+ 0xFF /* GXset */
+};
+
+static Bool
+i810PrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg)
+{
+ KdScreenPriv(pPix->drawable.pScreen);
+ i810ScreenInfo(pScreenPriv);
+ i810CardInfo(pScreenPriv);
+
+ if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
+ ErrorF( "i810PrepareSolid color: %x rop: %x mask: %x\n",
+ fg, alu, pm);
+
+ /* Color blit, p166 */
+ i810c->BR[13] = BR13_SOLID_PATTERN |
+ (i810PatternRop[alu] << 16) |
+ (pPix->drawable.pScreen->width * i810c->cpp);
+ i810c->BR[16] = fg;
+
+ accel_i810s = i810s;
+
+ return TRUE;
+}
+
+static void
+i810Solid(int x1, int y1, int x2, int y2)
+{
+ I810ScreenInfo *i810s = accel_i810s;
+ I810CardInfo *i810c = i810s->i810c;
+ LP_RING_LOCALS;
+
+ if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
+ ErrorF( "i810SubsequentFillRectSolid %d,%d %d,%d\n", x1, y1, x2, y2);
+
+ BEGIN_LP_RING(6);
+
+ OUT_RING( BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3 );
+ OUT_RING( i810c->BR[13] );
+ OUT_RING( ((y2 - y1) << 16) | ((x2 - x1) * i810c->cpp));
+ OUT_RING( i810c->bufferOffset + y1 * i810s->pitch + x1 * i810c->cpp );
+
+ OUT_RING( i810c->BR[16]);
+ OUT_RING( 0 ); /* pad to quadword */
+
+ ADVANCE_LP_RING();
+}
+
+static void
+i810DoneSolid(void)
+{
+}
+
+static Bool
+i810PrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu, Pixel pm)
+{
+ return FALSE;
+}
+
+static void
+i810RefreshRing(i810CardInfo *i810c)
+{
+ i810c->LpRing.head = INREG(LP_RING + RING_HEAD) & HEAD_ADDR;
+ i810c->LpRing.tail = INREG(LP_RING + RING_TAIL);
+ i810c->LpRing.space = i810c->LpRing.head - (i810c->LpRing.tail+8);
+ if (i810c->LpRing.space < 0)
+ i810c->LpRing.space += i810c->LpRing.mem.Size;
+}
+
+
+static void
+i810SetRingRegs(i810CardInfo *i810c)
+{
+ unsigned int itemp;
+
+ OUTREG(LP_RING + RING_TAIL, 0 );
+ OUTREG(LP_RING + RING_HEAD, 0 );
+
+ itemp = INREG(LP_RING + RING_START);
+ itemp &= ~(START_ADDR);
+ itemp |= i810c->LpRing.mem.Start;
+ OUTREG(LP_RING + RING_START, itemp );
+
+ itemp = INREG(LP_RING + RING_LEN);
+ itemp &= ~(RING_NR_PAGES | RING_REPORT_MASK | RING_VALID_MASK);
+ itemp |= ((i810c->LpRing.mem.Size-4096) | RING_NO_REPORT | RING_VALID);
+ OUTREG(LP_RING + RING_LEN, itemp );
+}
+
+Bool
+i810InitAccel(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ i810ScreenInfo(pScreenPriv);
+ i810CardInfo(pScreenPriv);
+
+ memset(&i810s->kaa, 0, sizeof(KaaScreenInfoRec));
+ i810s->kaa.waitMarker = i810WaitMarker;
+ i810s->kaa.PrepareSolid = i810PrepareSolid;
+ i810s->kaa.Solid = i810Solid;
+ i810s->kaa.DoneSolid = i810DoneSolid;
+ i810s->kaa.PrepareCopy = i810PrepareCopy;
+ i810s->kaa.Copy = NULL;
+ i810s->kaa.DoneCopy = NULL;
+
+ i810s->pitch = pScreen->width * i810c->cpp;
+
+ return FALSE;
+}
+
+void
+i810EnableAccel(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ i810CardInfo(pScreenPriv);
+
+ if (i810c->LpRing.mem.Size == 0) {
+ ErrorF("No memory for LpRing!! Acceleration not functional!!\n");
+ }
+
+ i810SetRingRegs(i810c);
+
+ kaaMarkSync (pScreen);
+}
+
+
+void
+i810DisableAccel(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ i810CardInfo(pScreenPriv);
+ i810ScreenInfo(pScreenPriv);
+
+ i810RefreshRing(i810c);
+ i810Sync(i810s);
+}
+
+void
+i810FiniAccel(ScreenPtr pScreen)
+{
+}
diff --git a/xorg-server/hw/kdrive/i810/i810draw.h b/xorg-server/hw/kdrive/i810/i810draw.h
new file mode 100644
index 000000000..7c8c04489
--- /dev/null
+++ b/xorg-server/hw/kdrive/i810/i810draw.h
@@ -0,0 +1,46 @@
+/* COPYRIGHT AND PERMISSION NOTICE
+
+Copyright (c) 2000, 2001 Nokia Home Communications
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+X Window System is a trademark of The Open Group */
+
+/* Hardware accelerated drawing for KDrive i810 driver, header file.
+ Author: Pontus Lidman <pontus.lidman@nokia.com>
+*/
+
+
+#ifndef _I810DRAW_H_
+#define _I810DRAW_H_
+
+void i810RefreshRing(KdScreenInfo *screen);
+int i810WaitLpRing( KdScreenInfo *screen, int n, int timeout_millis );
+void i810Sync( KdScreenInfo *screen );
+
+#endif /* _I810DRAW_H_ */
diff --git a/xorg-server/hw/kdrive/i810/i810stub.c b/xorg-server/hw/kdrive/i810/i810stub.c
new file mode 100644
index 000000000..3109984e0
--- /dev/null
+++ b/xorg-server/hw/kdrive/i810/i810stub.c
@@ -0,0 +1,92 @@
+/* COPYRIGHT AND PERMISSION NOTICE
+
+Copyright (c) 2000, 2001 Nokia Home Communications
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+X Window System is a trademark of The Open Group */
+
+/* Stub functions for the i810 KDrive driver
+ Author: Pontus Lidman <pontus.lidman@nokia.com>
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "kxv.h"
+#include "i810.h"
+#include "klinux.h"
+
+static const int i810Cards[]={
+ PCI_CHIP_I810,
+ PCI_CHIP_I810_DC100,
+ PCI_CHIP_I810_E
+};
+
+#define numI810Cards (sizeof(i810Cards) / sizeof(i810Cards[0]))
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+ int i;
+
+ for (i = 0; i < numI810Cards; i++)
+ if (LinuxFindPci (0x8086, i810Cards[i], 0, &attr))
+ KdCardInfoAdd (&i810Funcs, &attr, (void *) i810Cards[i]);
+}
+
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdOsAddInputDrivers ();
+ KdInitInput ();
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ int ret;
+
+ ret = KdProcessArgument(argc, argv, i);
+ return ret;
+}
diff --git a/xorg-server/hw/kdrive/linux/Makefile.am b/xorg-server/hw/kdrive/linux/Makefile.am
new file mode 100644
index 000000000..e13d08312
--- /dev/null
+++ b/xorg-server/hw/kdrive/linux/Makefile.am
@@ -0,0 +1,34 @@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+AM_CFLAGS = -DHAVE_DIX_CONFIG_H
+
+noinst_LIBRARIES = liblinux.a
+
+if TSLIB
+TSLIB_C = tslib.c
+endif
+
+if H3600_TS
+TS_C = ts.c
+endif
+
+if KDRIVE_HW
+KDRIVE_HW_SOURCES = \
+ agp.c \
+ agp.h \
+ evdev.c \
+ keyboard.c \
+ linux.c
+endif
+
+liblinux_a_SOURCES = \
+ bus.c \
+ klinux.h \
+ mouse.c \
+ ms.c \
+ ps2.c \
+ $(KDRIVE_HW_SOURCES) \
+ $(TSLIB_C) \
+ $(TS_C)
diff --git a/xorg-server/hw/kdrive/linux/Makefile.in b/xorg-server/hw/kdrive/linux/Makefile.in
new file mode 100644
index 000000000..331f45ec7
--- /dev/null
+++ b/xorg-server/hw/kdrive/linux/Makefile.in
@@ -0,0 +1,679 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = hw/kdrive/linux
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+liblinux_a_AR = $(AR) $(ARFLAGS)
+liblinux_a_LIBADD =
+am__liblinux_a_SOURCES_DIST = bus.c klinux.h mouse.c ms.c ps2.c agp.c \
+ agp.h evdev.c keyboard.c linux.c tslib.c ts.c
+@KDRIVE_HW_TRUE@am__objects_1 = agp.$(OBJEXT) evdev.$(OBJEXT) \
+@KDRIVE_HW_TRUE@ keyboard.$(OBJEXT) linux.$(OBJEXT)
+@TSLIB_TRUE@am__objects_2 = tslib.$(OBJEXT)
+@H3600_TS_TRUE@am__objects_3 = ts.$(OBJEXT)
+am_liblinux_a_OBJECTS = bus.$(OBJEXT) mouse.$(OBJEXT) ms.$(OBJEXT) \
+ ps2.$(OBJEXT) $(am__objects_1) $(am__objects_2) \
+ $(am__objects_3)
+liblinux_a_OBJECTS = $(am_liblinux_a_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(liblinux_a_SOURCES)
+DIST_SOURCES = $(am__liblinux_a_SOURCES_DIST)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+AM_CFLAGS = -DHAVE_DIX_CONFIG_H
+noinst_LIBRARIES = liblinux.a
+@TSLIB_TRUE@TSLIB_C = tslib.c
+@H3600_TS_TRUE@TS_C = ts.c
+@KDRIVE_HW_TRUE@KDRIVE_HW_SOURCES = \
+@KDRIVE_HW_TRUE@ agp.c \
+@KDRIVE_HW_TRUE@ agp.h \
+@KDRIVE_HW_TRUE@ evdev.c \
+@KDRIVE_HW_TRUE@ keyboard.c \
+@KDRIVE_HW_TRUE@ linux.c
+
+liblinux_a_SOURCES = \
+ bus.c \
+ klinux.h \
+ mouse.c \
+ ms.c \
+ ps2.c \
+ $(KDRIVE_HW_SOURCES) \
+ $(TSLIB_C) \
+ $(TS_C)
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/linux/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/linux/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+liblinux.a: $(liblinux_a_OBJECTS) $(liblinux_a_DEPENDENCIES)
+ -rm -f liblinux.a
+ $(liblinux_a_AR) liblinux.a $(liblinux_a_OBJECTS) $(liblinux_a_LIBADD)
+ $(RANLIB) liblinux.a
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/agp.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bus.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evdev.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keyboard.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/linux.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mouse.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ms.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ps2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ts.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tslib.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/linux/agp.c b/xorg-server/hw/kdrive/linux/agp.c
new file mode 100644
index 000000000..80fb7259b
--- /dev/null
+++ b/xorg-server/hw/kdrive/linux/agp.c
@@ -0,0 +1,354 @@
+/*
+ * Abstraction of the AGP GART interface.
+ *
+ * This version is for both Linux and FreeBSD.
+ *
+ * Copyright © 2000-2001 Nokia Home Communications
+ * Copyright © 2000 VA Linux Systems, Inc.
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+ */
+
+/*
+ * Author: Pontus Lidman <pontus.lidman@nokia.com> (adaption to KDrive) and others
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include <X11/X.h>
+#include "misc.h"
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include "agp.h"
+
+#if defined(linux)
+#include <asm/ioctl.h>
+
+#include <linux/agpgart.h>
+
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#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;
+
+/*
+ * Open /dev/agpgart. Keep it open until server exit.
+ */
+
+static Bool
+GARTInit(void)
+{
+ static Bool initDone = FALSE;
+ 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) {
+ fprintf(stderr, "Unable to open " AGP_DEVICE " (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+
+ KdAcquireGART(-1);
+ /* Check the kernel driver version. */
+ if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
+ fprintf(stderr, "GARTInit: AGPIOC_INFO failed (%s)\n",
+ strerror(errno));
+ close(gartFd);
+ gartFd = -1;
+ return FALSE;
+ }
+ KdReleaseGART(-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)) {
+ fprintf(stderr,
+ "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
+KdAgpGARTSupported()
+{
+ return GARTInit();
+}
+
+AgpInfoPtr
+KdGetAGPInfo(int screenNum)
+{
+ struct _agp_info agpinf;
+ AgpInfoPtr info;
+
+ if (!GARTInit())
+ return NULL;
+
+
+ if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) {
+ fprintf(stderr, "Failed to allocate AgpInfo\n");
+ return NULL;
+ }
+
+ if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
+ fprintf(stderr,
+ "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;
+
+ return info;
+}
+
+/*
+ * XXX If multiple screens can acquire the GART, should we have a reference
+ * count instead of using acquiredScreen?
+ */
+
+Bool
+KdAcquireGART(int screenNum)
+{
+ if (screenNum != -1 && !GARTInit())
+ return FALSE;
+
+ if (screenNum == -1 || acquiredScreen != screenNum) {
+ if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) {
+ fprintf(stderr,
+ "AGPIOC_ACQUIRE failed (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+ acquiredScreen = screenNum;
+ }
+
+ return TRUE;
+}
+
+Bool
+KdReleaseGART(int screenNum)
+{
+ if (screenNum != -1 && !GARTInit())
+ return FALSE;
+
+ if (acquiredScreen == screenNum) {
+ if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) {
+ fprintf(stderr,
+ "AGPIOC_RELEASE failed (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+ acquiredScreen = -1;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+int
+KdAllocateGARTMemory(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() || 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) {
+ fprintf(stderr, "KdAllocateGARTMemory: "
+ "allocation of %d pages failed\n\t(%s)\n", pages,
+ strerror(errno));
+ return -1;
+ }
+
+ if (physical)
+ *physical = alloc.physical;
+
+ return alloc.key;
+}
+
+
+/* Bind GART memory with "key" at "offset" */
+Bool
+KdBindGARTMemory(int screenNum, int key, unsigned long offset)
+{
+ struct _agp_bind bind;
+ int pageOffset;
+
+ if (!GARTInit() || acquiredScreen != screenNum)
+ return FALSE;
+
+ if (acquiredScreen != screenNum) {
+ fprintf(stderr,
+ "AGP not acquired by this screen\n");
+ return FALSE;
+ }
+
+ if (offset % AGP_PAGE_SIZE != 0) {
+ fprintf(stderr, "KdBindGARTMemory: "
+ "offset (0x%lx) is not page-aligned (%d)\n",
+ offset, AGP_PAGE_SIZE);
+ return FALSE;
+ }
+ pageOffset = offset / AGP_PAGE_SIZE;
+
+ bind.pg_start = pageOffset;
+ bind.key = key;
+
+ if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) {
+ fprintf(stderr, "KdBindGARTMemory: "
+ "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
+KdUnbindGARTMemory(int screenNum, int key)
+{
+ struct _agp_unbind unbind;
+
+ if (!GARTInit() || acquiredScreen != screenNum)
+ return FALSE;
+
+ if (acquiredScreen != screenNum) {
+ fprintf(stderr,
+ "AGP not acquired by this screen\n");
+ return FALSE;
+ }
+
+ unbind.priority = 0;
+ unbind.key = key;
+
+ if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) {
+ fprintf(stderr, "KdUnbindGARTMemory: "
+ "unbinding of gart memory with key %d "
+ "failed (%s)\n", key, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/* XXX Interface may change. */
+Bool
+KdEnableAGP(int screenNum, CARD32 mode)
+{
+ agp_setup setup;
+
+ if (!GARTInit() || acquiredScreen != screenNum)
+ return FALSE;
+
+ setup.agp_mode = mode;
+ if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) {
+ fprintf(stderr, "KdEnableAGP: "
+ "AGPIOC_SETUP with mode %ld failed (%s)\n",
+ mode, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
diff --git a/xorg-server/hw/kdrive/linux/agp.h b/xorg-server/hw/kdrive/linux/agp.h
new file mode 100644
index 000000000..419dee1b4
--- /dev/null
+++ b/xorg-server/hw/kdrive/linux/agp.h
@@ -0,0 +1,71 @@
+/* COPYRIGHT AND PERMISSION NOTICE
+
+Copyright (c) 2000, 2001 Nokia Home Communications
+
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+X Window System is a trademark of The Open Group */
+
+/* agp.h - header file for KDrive AGP GART interface
+ *
+ * Author: Pontus Lidman <pontus.lidman@nokia.com>
+ *
+ */
+
+#ifndef _AGP_H_
+#define _AGP_H_
+
+#include <X11/Xdefs.h>
+#include <X11/Xmd.h>
+
+/* These two definitions must be consistent with the kernel's,
+ but using 1 or 2 in driver code is even uglier */
+#define AGP_DCACHE_MEMORY 1
+#define AGP_PHYS_MEMORY 2
+
+typedef struct _AgpInfo {
+ unsigned long bridgeId;
+ unsigned long agpMode;
+ unsigned long base;
+ unsigned long size;
+ unsigned long totalPages;
+ unsigned long systemPages;
+ unsigned long usedPages;
+} AgpInfo, *AgpInfoPtr;
+
+extern Bool KdAgpGARTSupported(void);
+extern AgpInfoPtr KdGetAGPInfo(int screenNum);
+extern Bool KdAcquireGART(int screenNum);
+extern Bool KdReleaseGART(int screenNum);
+extern int KdAllocateGARTMemory(int screenNum, unsigned long size, int type,
+ unsigned long *physical);
+extern Bool KdBindGARTMemory(int screenNum, int key, unsigned long offset);
+extern Bool KdUnbindGARTMemory(int screenNum, int key);
+extern Bool KdEnableAGP(int screenNum, CARD32 mode);
+
+#endif /* _AGP_H_ */
diff --git a/xorg-server/hw/kdrive/linux/bus.c b/xorg-server/hw/kdrive/linux/bus.c
new file mode 100644
index 000000000..2d7a15751
--- /dev/null
+++ b/xorg-server/hw/kdrive/linux/bus.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xpoll.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "kdrive.h"
+
+/* /dev/adbmouse is a busmouse */
+
+static void
+BusRead (int adbPort, void *closure)
+{
+ unsigned char buf[3];
+ int n;
+ int dx, dy;
+ unsigned long flags;
+
+ n = read (adbPort, buf, 3);
+ if (n == 3)
+ {
+ flags = KD_MOUSE_DELTA;
+ dx = (char) buf[1];
+ dy = -(char) buf[2];
+ if ((buf[0] & 4) == 0)
+ flags |= KD_BUTTON_1;
+ if ((buf[0] & 2) == 0)
+ flags |= KD_BUTTON_2;
+ if ((buf[0] & 1) == 0)
+ flags |= KD_BUTTON_3;
+ KdEnqueuePointerEvent (closure, flags, dx, dy, 0);
+ }
+}
+
+char *BusNames[] = {
+ "/dev/adbmouse",
+ "/dev/mouse",
+};
+
+#define NUM_BUS_NAMES (sizeof (BusNames) / sizeof (BusNames[0]))
+
+static int
+BusInit (KdPointerInfo *pi)
+{
+ int i, fd = 0;
+
+ if (!pi->path || (strcmp(pi->path, "auto") == 0))
+ {
+ for (i = 0; i < NUM_BUS_NAMES; i++)
+ {
+ if ((fd = open (BusNames[i], 0)) > 0)
+ {
+ close(fd);
+ if (pi->path)
+ xfree(pi->path);
+ pi->path = KdSaveString(BusNames[i]);
+ return Success;
+ }
+ }
+ }
+ else
+ {
+ if ((fd = open(pi->path, 0)) > 0)
+ {
+ close(fd);
+ return Success;
+ }
+ }
+
+ return !Success;
+}
+
+static int
+BusEnable (KdPointerInfo *pi)
+{
+ int fd = open(pi->path, 0);
+
+ if (fd > 0)
+ {
+ KdRegisterFd(fd, BusRead, pi);
+ pi->driverPrivate = (void *)fd;
+ return Success;
+ }
+ else
+ {
+ return !Success;
+ }
+}
+
+static void
+BusDisable (KdPointerInfo *pi)
+{
+ KdUnregisterFd(pi, (int)pi->driverPrivate, TRUE);
+}
+
+static void
+BusFini (KdPointerInfo *pi)
+{
+ return;
+}
+
+KdPointerDriver BusMouseDriver = {
+ "bus",
+ BusInit,
+ BusEnable,
+ BusDisable,
+ BusFini,
+ NULL
+};
diff --git a/xorg-server/hw/kdrive/linux/evdev.c b/xorg-server/hw/kdrive/linux/evdev.c
new file mode 100644
index 000000000..2eaa1e332
--- /dev/null
+++ b/xorg-server/hw/kdrive/linux/evdev.c
@@ -0,0 +1,536 @@
+/*
+ * Copyright © 2004 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#define NEED_EVENTS
+#include <errno.h>
+#include <linux/input.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xpoll.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "kdrive.h"
+
+#define NUM_EVENTS 128
+#define ABS_UNSET -65535
+
+#define BITS_PER_LONG (sizeof(long) * 8)
+#define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1)
+#define ISBITSET(x,y) ((x)[LONG(y)] & BIT(y))
+#define OFF(x) ((x)%BITS_PER_LONG)
+#define LONG(x) ((x)/BITS_PER_LONG)
+#define BIT(x) (1 << OFF(x))
+
+typedef struct _kevdev {
+ /* current device state */
+ int rel[REL_MAX + 1];
+ int abs[ABS_MAX + 1];
+ int prevabs[ABS_MAX + 1];
+ long key[NBITS(KEY_MAX + 1)];
+
+ /* supported device info */
+ long relbits[NBITS(REL_MAX + 1)];
+ long absbits[NBITS(ABS_MAX + 1)];
+ long keybits[NBITS(KEY_MAX + 1)];
+ struct input_absinfo absinfo[ABS_MAX + 1];
+ int max_rel;
+ int max_abs;
+
+ int fd;
+} Kevdev;
+
+static void
+EvdevPtrBtn (KdPointerInfo *pi, struct input_event *ev)
+{
+ int flags = KD_MOUSE_DELTA | pi->buttonState;
+
+ if (ev->code >= BTN_MOUSE && ev->code < BTN_JOYSTICK) {
+ switch (ev->code) {
+ case BTN_LEFT:
+ if (ev->value == 1)
+ flags |= KD_BUTTON_1;
+ else
+ flags &= ~KD_BUTTON_1;
+ break;
+ case BTN_MIDDLE:
+ if (ev->value == 1)
+ flags |= KD_BUTTON_2;
+ else
+ flags &= ~KD_BUTTON_2;
+ break;
+ case BTN_RIGHT:
+ if (ev->value == 1)
+ flags |= KD_BUTTON_3;
+ else
+ flags &= ~KD_BUTTON_3;
+ break;
+ default:
+ /* Unknow button */
+ break;
+ }
+
+ KdEnqueuePointerEvent (pi, flags, 0, 0, 0);
+ }
+}
+static void
+EvdevPtrMotion (KdPointerInfo *pi, struct input_event *ev)
+{
+ Kevdev *ke = pi->driverPrivate;
+ int i;
+ int flags = KD_MOUSE_DELTA | pi->buttonState;
+
+ for (i = 0; i <= ke->max_rel; i++)
+ if (ke->rel[i])
+ {
+ int a;
+ for (a = 0; a <= ke->max_rel; a++)
+ {
+ if (ISBITSET (ke->relbits, a))
+ {
+ if (a == 0)
+ KdEnqueuePointerEvent(pi, flags, ke->rel[a], 0, 0);
+ else if (a == 1)
+ KdEnqueuePointerEvent(pi, flags, 0, ke->rel[a], 0);
+ }
+ ke->rel[a] = 0;
+ }
+ break;
+ }
+ for (i = 0; i < ke->max_abs; i++)
+ if (ke->abs[i] != ke->prevabs[i])
+ {
+ int a;
+ ErrorF ("abs");
+ for (a = 0; a <= ke->max_abs; a++)
+ {
+ if (ISBITSET (ke->absbits, a))
+ ErrorF (" %d=%d", a, ke->abs[a]);
+ ke->prevabs[a] = ke->abs[a];
+ }
+ ErrorF ("\n");
+ break;
+ }
+
+ if (ev->code == REL_WHEEL) {
+ for (i = 0; i < abs (ev->value); i++)
+ {
+ if (ev->value > 0)
+ flags |= KD_BUTTON_4;
+ else
+ flags |= KD_BUTTON_5;
+
+ KdEnqueuePointerEvent (pi, flags, 0, 0, 0);
+
+ if (ev->value > 0)
+ flags &= ~KD_BUTTON_4;
+ else
+ flags &= ~KD_BUTTON_5;
+
+ KdEnqueuePointerEvent (pi, flags, 0, 0, 0);
+ }
+ }
+
+}
+
+static void
+EvdevPtrRead (int evdevPort, void *closure)
+{
+ KdPointerInfo *pi = closure;
+ Kevdev *ke = pi->driverPrivate;
+ int i;
+ struct input_event events[NUM_EVENTS];
+ int n;
+
+ n = read (evdevPort, &events, NUM_EVENTS * sizeof (struct input_event));
+ if (n <= 0) {
+ if (errno == ENODEV)
+ DeleteInputDeviceRequest(pi->dixdev);
+ return;
+ }
+
+ n /= sizeof (struct input_event);
+ for (i = 0; i < n; i++)
+ {
+ switch (events[i].type) {
+ case EV_SYN:
+ break;
+ case EV_KEY:
+ EvdevPtrBtn (pi, &events[i]);
+ break;
+ case EV_REL:
+ ke->rel[events[i].code] += events[i].value;
+ EvdevPtrMotion (pi, &events[i]);
+ break;
+ case EV_ABS:
+ ke->abs[events[i].code] = events[i].value;
+ EvdevPtrMotion (pi, &events[i]);
+ break;
+ }
+ }
+}
+
+char *kdefaultEvdev[] = {
+ "/dev/input/event0",
+ "/dev/input/event1",
+ "/dev/input/event2",
+ "/dev/input/event3",
+};
+
+#define NUM_DEFAULT_EVDEV (sizeof (kdefaultEvdev) / sizeof (kdefaultEvdev[0]))
+
+static Status
+EvdevPtrInit (KdPointerInfo *pi)
+{
+ int i;
+ int fd;
+
+ if (!pi->path) {
+ for (i = 0; i < NUM_DEFAULT_EVDEV; i++) {
+ fd = open (kdefaultEvdev[i], 2);
+ if (fd >= 0) {
+ pi->path = KdSaveString (kdefaultEvdev[i]);
+ break;
+ }
+ }
+ }
+ else {
+ fd = open (pi->path, O_RDWR);
+ if (fd < 0) {
+ ErrorF("Failed to open evdev device %s\n", pi->path);
+ return BadMatch;
+ }
+ }
+
+ close(fd);
+
+ pi->name = KdSaveString("Evdev mouse");
+
+ return Success;
+}
+
+static Status
+EvdevPtrEnable (KdPointerInfo *pi)
+{
+ int fd;
+
+ if (!pi || !pi->path)
+ return BadImplementation;
+
+ fd = open(pi->path, 2);
+ if (fd < 0)
+ return BadMatch;
+
+ unsigned long ev[NBITS(EV_MAX)];
+ Kevdev *ke;
+
+ if (ioctl (fd, EVIOCGBIT(0 /*EV*/, sizeof (ev)), ev) < 0)
+ {
+ perror ("EVIOCGBIT 0");
+ close (fd);
+ return BadMatch;
+ }
+ ke = xalloc (sizeof (Kevdev));
+ if (!ke)
+ {
+ close (fd);
+ return BadAlloc;
+ }
+ memset (ke, '\0', sizeof (Kevdev));
+ if (ISBITSET (ev, EV_KEY))
+ {
+ if (ioctl (fd, EVIOCGBIT (EV_KEY, sizeof (ke->keybits)),
+ ke->keybits) < 0)
+ {
+ perror ("EVIOCGBIT EV_KEY");
+ xfree (ke);
+ close (fd);
+ return BadMatch;
+ }
+ }
+ if (ISBITSET (ev, EV_REL))
+ {
+ if (ioctl (fd, EVIOCGBIT (EV_REL, sizeof (ke->relbits)),
+ ke->relbits) < 0)
+ {
+ perror ("EVIOCGBIT EV_REL");
+ xfree (ke);
+ close (fd);
+ return BadMatch;
+ }
+ for (ke->max_rel = REL_MAX; ke->max_rel >= 0; ke->max_rel--)
+ if (ISBITSET(ke->relbits, ke->max_rel))
+ break;
+ }
+ if (ISBITSET (ev, EV_ABS))
+ {
+ int i;
+
+ if (ioctl (fd, EVIOCGBIT (EV_ABS, sizeof (ke->absbits)),
+ ke->absbits) < 0)
+ {
+ perror ("EVIOCGBIT EV_ABS");
+ xfree (ke);
+ close (fd);
+ return BadMatch;
+ }
+ for (ke->max_abs = ABS_MAX; ke->max_abs >= 0; ke->max_abs--)
+ if (ISBITSET(ke->absbits, ke->max_abs))
+ break;
+ for (i = 0; i <= ke->max_abs; i++)
+ {
+ if (ISBITSET (ke->absbits, i))
+ if (ioctl (fd, EVIOCGABS(i), &ke->absinfo[i]) < 0)
+ {
+ perror ("EVIOCGABS");
+ break;
+ }
+ ke->prevabs[i] = ABS_UNSET;
+ }
+ if (i <= ke->max_abs)
+ {
+ xfree (ke);
+ close (fd);
+ return BadValue;
+ }
+ }
+ if (!KdRegisterFd (fd, EvdevPtrRead, pi)) {
+ xfree (ke);
+ close (fd);
+ return BadAlloc;
+ }
+ pi->driverPrivate = ke;
+ ke->fd = fd;
+
+ return Success;
+}
+
+static void
+EvdevPtrDisable (KdPointerInfo *pi)
+{
+ Kevdev *ke;
+
+ ke = pi->driverPrivate;
+
+ if (!pi || !pi->driverPrivate)
+ return;
+
+ KdUnregisterFd (pi, ke->fd, TRUE);
+ xfree (ke);
+ pi->driverPrivate = 0;
+}
+
+static void
+EvdevPtrFini (KdPointerInfo *pi)
+{
+}
+
+
+/*
+ * Evdev keyboard functions
+ */
+
+static void
+readMapping (KdKeyboardInfo *ki)
+{
+ int minScanCode, maxScanCode;
+
+ if (!ki)
+ return;
+
+ minScanCode = 0;
+ maxScanCode = 193;
+
+ ki->keySyms.mapWidth = 2;
+
+ ki->minScanCode = minScanCode;
+ ki->maxScanCode = maxScanCode;
+}
+
+static void
+EvdevKbdRead (int evdevPort, void *closure)
+{
+ KdKeyboardInfo *ki = closure;
+ struct input_event events[NUM_EVENTS];
+ int i, n;
+
+ n = read (evdevPort, &events, NUM_EVENTS * sizeof (struct input_event));
+ if (n <= 0) {
+ if (errno == ENODEV)
+ DeleteInputDeviceRequest(ki->dixdev);
+ return;
+ }
+
+ n /= sizeof (struct input_event);
+ for (i = 0; i < n; i++)
+ {
+ if (events[i].type == EV_KEY)
+ KdEnqueueKeyboardEvent (ki, events[i].code, !events[i].value);
+/* FIXME: must implement other types of events
+ else
+ ErrorF("Event type (%d) not delivered\n", events[i].type);
+*/
+ }
+}
+
+static Status
+EvdevKbdInit (KdKeyboardInfo *ki)
+{
+ int fd;
+
+ if (!ki->path) {
+ ErrorF("Couldn't find evdev device path\n");
+ return BadValue;
+ }
+ else {
+ fd = open (ki->path, O_RDWR);
+ if (fd < 0) {
+ ErrorF("Failed to open evdev device %s\n", ki->path);
+ return BadMatch;
+ }
+ }
+
+ close (fd);
+
+ ki->name = KdSaveString("Evdev keyboard");
+
+ readMapping(ki);
+
+ return Success;
+}
+
+static Status
+EvdevKbdEnable (KdKeyboardInfo *ki)
+{
+ unsigned long ev[NBITS(EV_MAX)];
+ Kevdev *ke;
+ int fd;
+
+ if (!ki || !ki->path)
+ return BadImplementation;
+
+ fd = open(ki->path, O_RDWR);
+ if (fd < 0)
+ return BadMatch;
+
+ if (ioctl (fd, EVIOCGBIT(0 /*EV*/, sizeof (ev)), ev) < 0) {
+ perror ("EVIOCGBIT 0");
+ close (fd);
+ return BadMatch;
+ }
+
+ ke = xalloc (sizeof (Kevdev));
+ if (!ke) {
+ close (fd);
+ return BadAlloc;
+ }
+ memset (ke, '\0', sizeof (Kevdev));
+
+ if (!KdRegisterFd (fd, EvdevKbdRead, ki)) {
+ xfree (ke);
+ close (fd);
+ return BadAlloc;
+ }
+ ki->driverPrivate = ke;
+ ke->fd = fd;
+
+ return Success;
+}
+
+static void
+EvdevKbdLeds (KdKeyboardInfo *ki, int leds)
+{
+/* struct input_event event;
+ Kevdev *ke;
+
+ ki->driverPrivate = ke;
+
+ memset(&event, 0, sizeof(event));
+
+ event.type = EV_LED;
+ event.code = LED_CAPSL;
+ event.value = leds & (1 << 0) ? 1 : 0;
+ write(ke->fd, (char *) &event, sizeof(event));
+
+ event.type = EV_LED;
+ event.code = LED_NUML;
+ event.value = leds & (1 << 1) ? 1 : 0;
+ write(ke->fd, (char *) &event, sizeof(event));
+
+ event.type = EV_LED;
+ event.code = LED_SCROLLL;
+ event.value = leds & (1 << 2) ? 1 : 0;
+ write(ke->fd, (char *) &event, sizeof(event));
+
+ event.type = EV_LED;
+ event.code = LED_COMPOSE;
+ event.value = leds & (1 << 3) ? 1 : 0;
+ write(ke->fd, (char *) &event, sizeof(event));
+*/
+}
+
+static void
+EvdevKbdBell (KdKeyboardInfo *ki, int volume, int frequency, int duration)
+{
+}
+
+static void
+EvdevKbdDisable (KdKeyboardInfo *ki)
+{
+ Kevdev *ke;
+
+ ke = ki->driverPrivate;
+
+ if (!ki || !ki->driverPrivate)
+ return;
+
+ KdUnregisterFd (ki, ke->fd, TRUE);
+ xfree (ke);
+ ki->driverPrivate = 0;
+}
+
+static void
+EvdevKbdFini (KdKeyboardInfo *ki)
+{
+}
+
+KdPointerDriver LinuxEvdevMouseDriver = {
+ "evdev",
+ EvdevPtrInit,
+ EvdevPtrEnable,
+ EvdevPtrDisable,
+ EvdevPtrFini,
+ NULL,
+};
+
+KdKeyboardDriver LinuxEvdevKeyboardDriver = {
+ "evdev",
+ EvdevKbdInit,
+ EvdevKbdEnable,
+ EvdevKbdLeds,
+ EvdevKbdBell,
+ EvdevKbdDisable,
+ EvdevKbdFini,
+ NULL,
+};
diff --git a/xorg-server/hw/kdrive/linux/keyboard.c b/xorg-server/hw/kdrive/linux/keyboard.c
new file mode 100644
index 000000000..3193ab761
--- /dev/null
+++ b/xorg-server/hw/kdrive/linux/keyboard.c
@@ -0,0 +1,803 @@
+/*
+ * Copyright © 1999 Keith Packard
+ * XKB integration © 2006 Nokia Corporation, author: Tomas Frydrych <tf@o-hand.com>
+ *
+ * LinuxKeyboardRead() XKB code based on xf86KbdLnx.c:
+ * Copyright © 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ * Copyright © 1994-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_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include <linux/keyboard.h>
+#include <linux/kd.h>
+#define XK_PUBLISHING
+#include <X11/keysym.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+extern int LinuxConsoleFd;
+
+static const KeySym linux_to_x[256] = {
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_Escape,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_space, XK_exclam, XK_quotedbl, XK_numbersign,
+ XK_dollar, XK_percent, XK_ampersand, XK_apostrophe,
+ XK_parenleft, XK_parenright, XK_asterisk, XK_plus,
+ XK_comma, XK_minus, XK_period, XK_slash,
+ XK_0, XK_1, XK_2, XK_3,
+ XK_4, XK_5, XK_6, XK_7,
+ XK_8, XK_9, XK_colon, XK_semicolon,
+ XK_less, XK_equal, XK_greater, XK_question,
+ XK_at, XK_A, XK_B, XK_C,
+ XK_D, XK_E, XK_F, XK_G,
+ XK_H, XK_I, XK_J, XK_K,
+ XK_L, XK_M, XK_N, XK_O,
+ XK_P, XK_Q, XK_R, XK_S,
+ XK_T, XK_U, XK_V, XK_W,
+ XK_X, XK_Y, XK_Z, XK_bracketleft,
+ XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore,
+ XK_grave, XK_a, XK_b, XK_c,
+ XK_d, XK_e, XK_f, XK_g,
+ XK_h, XK_i, XK_j, XK_k,
+ XK_l, XK_m, XK_n, XK_o,
+ XK_p, XK_q, XK_r, XK_s,
+ XK_t, XK_u, XK_v, XK_w,
+ XK_x, XK_y, XK_z, XK_braceleft,
+ XK_bar, XK_braceright, XK_asciitilde, XK_BackSpace,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_nobreakspace,XK_exclamdown, XK_cent, XK_sterling,
+ XK_currency, XK_yen, XK_brokenbar, XK_section,
+ XK_diaeresis, XK_copyright, XK_ordfeminine, XK_guillemotleft,
+ XK_notsign, XK_hyphen, XK_registered, XK_macron,
+ XK_degree, XK_plusminus, XK_twosuperior, XK_threesuperior,
+ XK_acute, XK_mu, XK_paragraph, XK_periodcentered,
+ XK_cedilla, XK_onesuperior, XK_masculine, XK_guillemotright,
+ XK_onequarter, XK_onehalf, XK_threequarters,XK_questiondown,
+ XK_Agrave, XK_Aacute, XK_Acircumflex, XK_Atilde,
+ XK_Adiaeresis, XK_Aring, XK_AE, XK_Ccedilla,
+ XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis,
+ XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis,
+ XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute,
+ XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_multiply,
+ XK_Ooblique, XK_Ugrave, XK_Uacute, XK_Ucircumflex,
+ XK_Udiaeresis, XK_Yacute, XK_THORN, XK_ssharp,
+ XK_agrave, XK_aacute, XK_acircumflex, XK_atilde,
+ XK_adiaeresis, XK_aring, XK_ae, XK_ccedilla,
+ XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis,
+ XK_igrave, XK_iacute, XK_icircumflex, XK_idiaeresis,
+ XK_eth, XK_ntilde, XK_ograve, XK_oacute,
+ XK_ocircumflex, XK_otilde, XK_odiaeresis, XK_division,
+ XK_oslash, XK_ugrave, XK_uacute, XK_ucircumflex,
+ XK_udiaeresis, XK_yacute, XK_thorn, XK_ydiaeresis
+};
+
+#ifdef XKB
+/*
+ * Getting a keycode from scancode
+ *
+ * With XKB
+ * --------
+ *
+ * We have to enqueue keyboard events using standard X keycodes which correspond
+ * to AT scancode + 8; this means that we need to translate the Linux scancode
+ * provided by the kernel to an AT scancode -- this translation is not linear
+ * and requires that we use a LUT.
+ *
+ *
+ * Without XKB
+ * -----------
+ *
+ * We can use custom keycodes, which makes things simpler; we define our custom
+ * keycodes as Linux scancodes + KD_KEY_OFFSET
+*/
+
+/*
+ This LUT translates AT scancodes into Linux ones -- the keymap we create
+ for the core X keyboard protocol has to be AT-scancode based so that it
+ corresponds to the Xkb keymap.
+*/
+static unsigned char at2lnx[] =
+{
+ 0x0, /* no valid scancode */
+ 0x01, /* KEY_Escape */ 0x02, /* KEY_1 */
+ 0x03, /* KEY_2 */ 0x04, /* KEY_3 */
+ 0x05, /* KEY_4 */ 0x06, /* KEY_5 */
+ 0x07, /* KEY_6 */ 0x08, /* KEY_7 */
+ 0x09, /* KEY_8 */ 0x0a, /* KEY_9 */
+ 0x0b, /* KEY_0 */ 0x0c, /* KEY_Minus */
+ 0x0d, /* KEY_Equal */ 0x0e, /* KEY_BackSpace */
+ 0x0f, /* KEY_Tab */ 0x10, /* KEY_Q */
+ 0x11, /* KEY_W */ 0x12, /* KEY_E */
+ 0x13, /* KEY_R */ 0x14, /* KEY_T */
+ 0x15, /* KEY_Y */ 0x16, /* KEY_U */
+ 0x17, /* KEY_I */ 0x18, /* KEY_O */
+ 0x19, /* KEY_P */ 0x1a, /* KEY_LBrace */
+ 0x1b, /* KEY_RBrace */ 0x1c, /* KEY_Enter */
+ 0x1d, /* KEY_LCtrl */ 0x1e, /* KEY_A */
+ 0x1f, /* KEY_S */ 0x20, /* KEY_D */
+ 0x21, /* KEY_F */ 0x22, /* KEY_G */
+ 0x23, /* KEY_H */ 0x24, /* KEY_J */
+ 0x25, /* KEY_K */ 0x26, /* KEY_L */
+ 0x27, /* KEY_SemiColon */ 0x28, /* KEY_Quote */
+ 0x29, /* KEY_Tilde */ 0x2a, /* KEY_ShiftL */
+ 0x2b, /* KEY_BSlash */ 0x2c, /* KEY_Z */
+ 0x2d, /* KEY_X */ 0x2e, /* KEY_C */
+ 0x2f, /* KEY_V */ 0x30, /* KEY_B */
+ 0x31, /* KEY_N */ 0x32, /* KEY_M */
+ 0x33, /* KEY_Comma */ 0x34, /* KEY_Period */
+ 0x35, /* KEY_Slash */ 0x36, /* KEY_ShiftR */
+ 0x37, /* KEY_KP_Multiply */ 0x38, /* KEY_Alt */
+ 0x39, /* KEY_Space */ 0x3a, /* KEY_CapsLock */
+ 0x3b, /* KEY_F1 */ 0x3c, /* KEY_F2 */
+ 0x3d, /* KEY_F3 */ 0x3e, /* KEY_F4 */
+ 0x3f, /* KEY_F5 */ 0x40, /* KEY_F6 */
+ 0x41, /* KEY_F7 */ 0x42, /* KEY_F8 */
+ 0x43, /* KEY_F9 */ 0x44, /* KEY_F10 */
+ 0x45, /* KEY_NumLock */ 0x46, /* KEY_ScrollLock */
+ 0x47, /* KEY_KP_7 */ 0x48, /* KEY_KP_8 */
+ 0x49, /* KEY_KP_9 */ 0x4a, /* KEY_KP_Minus */
+ 0x4b, /* KEY_KP_4 */ 0x4c, /* KEY_KP_5 */
+ 0x4d, /* KEY_KP_6 */ 0x4e, /* KEY_KP_Plus */
+ 0x4f, /* KEY_KP_1 */ 0x50, /* KEY_KP_2 */
+ 0x51, /* KEY_KP_3 */ 0x52, /* KEY_KP_0 */
+ 0x53, /* KEY_KP_Decimal */ 0x54, /* KEY_SysReqest */
+ 0x00, /* 0x55 */ 0x56, /* KEY_Less */
+ 0x57, /* KEY_F11 */ 0x58, /* KEY_F12 */
+ 0x66, /* KEY_Home */ 0x67, /* KEY_Up */
+ 0x68, /* KEY_PgUp */ 0x69, /* KEY_Left */
+ 0x5d, /* KEY_Begin */ 0x6a, /* KEY_Right */
+ 0x6b, /* KEY_End */ 0x6c, /* KEY_Down */
+ 0x6d, /* KEY_PgDown */ 0x6e, /* KEY_Insert */
+ 0x6f, /* KEY_Delete */ 0x60, /* KEY_KP_Enter */
+ 0x61, /* KEY_RCtrl */ 0x77, /* KEY_Pause */
+ 0x63, /* KEY_Print */ 0x62, /* KEY_KP_Divide */
+ 0x64, /* KEY_AltLang */ 0x65, /* KEY_Break */
+ 0x00, /* KEY_LMeta */ 0x00, /* KEY_RMeta */
+ 0x7A, /* KEY_Menu/FOCUS_PF11*/0x00, /* 0x6e */
+ 0x7B, /* FOCUS_PF12 */ 0x00, /* 0x70 */
+ 0x00, /* 0x71 */ 0x00, /* 0x72 */
+ 0x59, /* FOCUS_PF2 */ 0x78, /* FOCUS_PF9 */
+ 0x00, /* 0x75 */ 0x00, /* 0x76 */
+ 0x5A, /* FOCUS_PF3 */ 0x5B, /* FOCUS_PF4 */
+ 0x5C, /* FOCUS_PF5 */ 0x5D, /* FOCUS_PF6 */
+ 0x5E, /* FOCUS_PF7 */ 0x5F, /* FOCUS_PF8 */
+ 0x7C, /* JAP_86 */ 0x79, /* FOCUS_PF10 */
+ 0x00, /* 0x7f */
+};
+
+#define NUM_AT_KEYS (sizeof(at2lnx)/sizeof(at2lnx[0]))
+#define LNX_KEY_INDEX(n) n < NUM_AT_KEYS ? at2lnx[n] : 0
+
+#else /* not XKB */
+#define LNX_KEY_INDEX(n) n
+#endif
+
+static unsigned char tbl[KD_MAX_WIDTH] =
+{
+ 0,
+ 1 << KG_SHIFT,
+ (1 << KG_ALTGR),
+ (1 << KG_ALTGR) | (1 << KG_SHIFT)
+};
+
+static void
+readKernelMapping(KdKeyboardInfo *ki)
+{
+ KeySym *k;
+ int i, j;
+ struct kbentry kbe;
+ int minKeyCode, maxKeyCode;
+ int row;
+ int fd;
+
+ if (!ki)
+ return;
+
+ fd = LinuxConsoleFd;
+
+ minKeyCode = NR_KEYS;
+ maxKeyCode = 0;
+ row = 0;
+ ki->keySyms.mapWidth = KD_MAX_WIDTH;
+ for (i = 0; i < NR_KEYS && row < KD_MAX_LENGTH; ++i)
+ {
+ kbe.kb_index = LNX_KEY_INDEX(i);
+
+ k = ki->keySyms.map + row * ki->keySyms.mapWidth;
+
+ for (j = 0; j < ki->keySyms.mapWidth; ++j)
+ {
+ unsigned short kval;
+
+ k[j] = NoSymbol;
+
+ kbe.kb_table = tbl[j];
+ kbe.kb_value = 0;
+ if (ioctl(fd, KDGKBENT, &kbe))
+ continue;
+
+ kval = KVAL(kbe.kb_value);
+ switch (KTYP(kbe.kb_value))
+ {
+ case KT_LATIN:
+ case KT_LETTER:
+ k[j] = linux_to_x[kval];
+ break;
+
+ case KT_FN:
+ if (kval <= 19)
+ k[j] = XK_F1 + kval;
+ else switch (kbe.kb_value)
+ {
+ case K_FIND:
+ k[j] = XK_Home; /* or XK_Find */
+ break;
+ case K_INSERT:
+ k[j] = XK_Insert;
+ break;
+ case K_REMOVE:
+ k[j] = XK_Delete;
+ break;
+ case K_SELECT:
+ k[j] = XK_End; /* or XK_Select */
+ break;
+ case K_PGUP:
+ k[j] = XK_Prior;
+ break;
+ case K_PGDN:
+ k[j] = XK_Next;
+ break;
+ case K_HELP:
+ k[j] = XK_Help;
+ break;
+ case K_DO:
+ k[j] = XK_Execute;
+ break;
+ case K_PAUSE:
+ k[j] = XK_Pause;
+ break;
+ case K_MACRO:
+ k[j] = XK_Menu;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case KT_SPEC:
+ switch (kbe.kb_value)
+ {
+ case K_ENTER:
+ k[j] = XK_Return;
+ break;
+ case K_BREAK:
+ k[j] = XK_Break;
+ break;
+ case K_CAPS:
+ k[j] = XK_Caps_Lock;
+ break;
+ case K_NUM:
+ k[j] = XK_Num_Lock;
+ break;
+ case K_HOLD:
+ k[j] = XK_Scroll_Lock;
+ break;
+ case K_COMPOSE:
+ k[j] = XK_Multi_key;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case KT_PAD:
+ switch (kbe.kb_value)
+ {
+ case K_PPLUS:
+ k[j] = XK_KP_Add;
+ break;
+ case K_PMINUS:
+ k[j] = XK_KP_Subtract;
+ break;
+ case K_PSTAR:
+ k[j] = XK_KP_Multiply;
+ break;
+ case K_PSLASH:
+ k[j] = XK_KP_Divide;
+ break;
+ case K_PENTER:
+ k[j] = XK_KP_Enter;
+ break;
+ case K_PCOMMA:
+ k[j] = XK_KP_Separator;
+ break;
+ case K_PDOT:
+ k[j] = XK_KP_Decimal;
+ break;
+ case K_PPLUSMINUS:
+ k[j] = XK_KP_Subtract;
+ break;
+ default:
+ if (kval <= 9)
+ k[j] = XK_KP_0 + kval;
+ break;
+ }
+ break;
+
+ /*
+ * KT_DEAD keys are for accelerated diacritical creation.
+ */
+ case KT_DEAD:
+ switch (kbe.kb_value)
+ {
+ case K_DGRAVE:
+ k[j] = XK_dead_grave;
+ break;
+ case K_DACUTE:
+ k[j] = XK_dead_acute;
+ break;
+ case K_DCIRCM:
+ k[j] = XK_dead_circumflex;
+ break;
+ case K_DTILDE:
+ k[j] = XK_dead_tilde;
+ break;
+ case K_DDIERE:
+ k[j] = XK_dead_diaeresis;
+ break;
+ }
+ break;
+
+ case KT_CUR:
+ switch (kbe.kb_value)
+ {
+ case K_DOWN:
+ k[j] = XK_Down;
+ break;
+ case K_LEFT:
+ k[j] = XK_Left;
+ break;
+ case K_RIGHT:
+ k[j] = XK_Right;
+ break;
+ case K_UP:
+ k[j] = XK_Up;
+ break;
+ }
+ break;
+
+ case KT_SHIFT:
+ switch (kbe.kb_value)
+ {
+ case K_ALTGR:
+ k[j] = XK_Mode_switch;
+ break;
+ case K_ALT:
+ k[j] = (kbe.kb_index == 0x64 ?
+ XK_Alt_R : XK_Alt_L);
+ break;
+ case K_CTRL:
+ k[j] = (kbe.kb_index == 0x61 ?
+ XK_Control_R : XK_Control_L);
+ break;
+ case K_CTRLL:
+ k[j] = XK_Control_L;
+ break;
+ case K_CTRLR:
+ k[j] = XK_Control_R;
+ break;
+ case K_SHIFT:
+ k[j] = (kbe.kb_index == 0x36 ?
+ XK_Shift_R : XK_Shift_L);
+ break;
+ case K_SHIFTL:
+ k[j] = XK_Shift_L;
+ break;
+ case K_SHIFTR:
+ k[j] = XK_Shift_R;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ /*
+ * KT_ASCII keys accumulate a 3 digit decimal number that gets
+ * emitted when the shift state changes. We can't emulate that.
+ */
+ case KT_ASCII:
+ break;
+
+ case KT_LOCK:
+ if (kbe.kb_value == K_SHIFTLOCK)
+ k[j] = XK_Shift_Lock;
+ break;
+
+#ifdef KT_X
+ case KT_X:
+ /* depends on new keyboard symbols in file linux/keyboard.h */
+ if(kbe.kb_value == K_XMENU) k[j] = XK_Menu;
+ if(kbe.kb_value == K_XTELEPHONE) k[j] = XK_telephone;
+ break;
+#endif
+#ifdef KT_XF
+ case KT_XF:
+ /* special linux keysyms which map directly to XF86 keysyms */
+ k[j] = (kbe.kb_value & 0xFF) + 0x1008FF00;
+ break;
+#endif
+
+ default:
+ break;
+ }
+ if (i < minKeyCode)
+ minKeyCode = i;
+ if (i > maxKeyCode)
+ maxKeyCode = i;
+ }
+
+ if (minKeyCode == NR_KEYS)
+ continue;
+
+ if (k[3] == k[2]) k[3] = NoSymbol;
+ if (k[2] == k[1]) k[2] = NoSymbol;
+ if (k[1] == k[0]) k[1] = NoSymbol;
+ if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
+ if (k[3] == k[0] && k[2] == k[1] && k[2] == NoSymbol) k[3] =NoSymbol;
+ row++;
+ }
+ ki->minScanCode = minKeyCode;
+ ki->maxScanCode = maxKeyCode;
+}
+
+#ifdef XKB
+
+/*
+ * We need these to handle extended scancodes correctly (I could just use the
+ * numbers below, but this makes the code more readable
+ */
+
+/* The prefix codes */
+#define KEY_Prefix0 /* special 0x60 */ 96
+#define KEY_Prefix1 /* special 0x61 */ 97
+
+/* The raw scancodes */
+#define KEY_Enter /* Enter 0x1c */ 28
+#define KEY_LCtrl /* Ctrl(left) 0x1d */ 29
+#define KEY_Slash /* / (Slash) ? 0x35 */ 53
+#define KEY_KP_Multiply /* * 0x37 */ 55
+#define KEY_Alt /* Alt(left) 0x38 */ 56
+#define KEY_F3 /* F3 0x3d */ 61
+#define KEY_F4 /* F4 0x3e */ 62
+#define KEY_F5 /* F5 0x3f */ 63
+#define KEY_F6 /* F6 0x40 */ 64
+#define KEY_F7 /* F7 0x41 */ 65
+#define KEY_ScrollLock /* ScrollLock 0x46 */ 70
+#define KEY_KP_7 /* 7 Home 0x47 */ 71
+#define KEY_KP_8 /* 8 Up 0x48 */ 72
+#define KEY_KP_9 /* 9 PgUp 0x49 */ 73
+#define KEY_KP_Minus /* - (Minus) 0x4a */ 74
+#define KEY_KP_4 /* 4 Left 0x4b */ 75
+#define KEY_KP_5 /* 5 0x4c */ 76
+#define KEY_KP_6 /* 6 Right 0x4d */ 77
+#define KEY_KP_Plus /* + (Plus) 0x4e */ 78
+#define KEY_KP_1 /* 1 End 0x4f */ 79
+#define KEY_KP_2 /* 2 Down 0x50 */ 80
+#define KEY_KP_3 /* 3 PgDown 0x51 */ 81
+#define KEY_KP_0 /* 0 Insert 0x52 */ 82
+#define KEY_KP_Decimal /* . (Decimal) Delete 0x53 */ 83
+#define KEY_Home /* Home 0x59 */ 89
+#define KEY_Up /* Up 0x5a */ 90
+#define KEY_PgUp /* PgUp 0x5b */ 91
+#define KEY_Left /* Left 0x5c */ 92
+#define KEY_Begin /* Begin 0x5d */ 93
+#define KEY_Right /* Right 0x5e */ 94
+#define KEY_End /* End 0x5f */ 95
+#define KEY_Down /* Down 0x60 */ 96
+#define KEY_PgDown /* PgDown 0x61 */ 97
+#define KEY_Insert /* Insert 0x62 */ 98
+#define KEY_Delete /* Delete 0x63 */ 99
+#define KEY_KP_Enter /* Enter 0x64 */ 100
+#define KEY_RCtrl /* Ctrl(right) 0x65 */ 101
+#define KEY_Pause /* Pause 0x66 */ 102
+#define KEY_Print /* Print 0x67 */ 103
+#define KEY_KP_Divide /* Divide 0x68 */ 104
+#define KEY_AltLang /* AtlLang(right) 0x69 */ 105
+#define KEY_Break /* Break 0x6a */ 106
+#define KEY_LMeta /* Left Meta 0x6b */ 107
+#define KEY_RMeta /* Right Meta 0x6c */ 108
+#define KEY_Menu /* Menu 0x6d */ 109
+#define KEY_F13 /* F13 0x6e */ 110
+#define KEY_F14 /* F14 0x6f */ 111
+#define KEY_F15 /* F15 0x70 */ 112
+#define KEY_F16 /* F16 0x71 */ 113
+#define KEY_F17 /* F17 0x72 */ 114
+#define KEY_KP_DEC /* KP_DEC 0x73 */ 115
+
+#endif /* XKB */
+
+
+static void
+LinuxKeyboardRead (int fd, void *closure)
+{
+ unsigned char buf[256], *b;
+ int n;
+ unsigned char prefix = 0, scancode = 0;
+
+ while ((n = read (fd, buf, sizeof (buf))) > 0) {
+ b = buf;
+ while (n--) {
+#ifdef XKB
+ if (!noXkbExtension) {
+ /*
+ * With xkb we use RAW mode for reading the console, which allows us
+ * process extended scancodes.
+ *
+ * See if this is a prefix extending the following keycode
+ */
+ if (!prefix && ((b[0] & 0x7f) == KEY_Prefix0))
+ {
+ prefix = KEY_Prefix0;
+#ifdef DEBUG
+ ErrorF("Prefix0");
+#endif
+ /* swallow this up */
+ b++;
+ continue;
+ }
+ else if (!prefix && ((b[0] & 0x7f) == KEY_Prefix1))
+ {
+ prefix = KEY_Prefix1;
+ ErrorF("Prefix1");
+ /* swallow this up */
+ b++;
+ continue;
+ }
+ scancode = b[0] & 0x7f;
+
+ switch (prefix) {
+ /* from xf86Events.c */
+ case KEY_Prefix0:
+ {
+#ifdef DEBUG
+ ErrorF("Prefix0 scancode: 0x%02x\n", scancode);
+#endif
+ switch (scancode) {
+ case KEY_KP_7:
+ scancode = KEY_Home; break; /* curs home */
+ case KEY_KP_8:
+ scancode = KEY_Up; break; /* curs up */
+ case KEY_KP_9:
+ scancode = KEY_PgUp; break; /* curs pgup */
+ case KEY_KP_4:
+ scancode = KEY_Left; break; /* curs left */
+ case KEY_KP_5:
+ scancode = KEY_Begin; break; /* curs begin */
+ case KEY_KP_6:
+ scancode = KEY_Right; break; /* curs right */
+ case KEY_KP_1:
+ scancode = KEY_End; break; /* curs end */
+ case KEY_KP_2:
+ scancode = KEY_Down; break; /* curs down */
+ case KEY_KP_3:
+ scancode = KEY_PgDown; break; /* curs pgdown */
+ case KEY_KP_0:
+ scancode = KEY_Insert; break; /* curs insert */
+ case KEY_KP_Decimal:
+ scancode = KEY_Delete; break; /* curs delete */
+ case KEY_Enter:
+ scancode = KEY_KP_Enter; break; /* keypad enter */
+ case KEY_LCtrl:
+ scancode = KEY_RCtrl; break; /* right ctrl */
+ case KEY_KP_Multiply:
+ scancode = KEY_Print; break; /* print */
+ case KEY_Slash:
+ scancode = KEY_KP_Divide; break; /* keyp divide */
+ case KEY_Alt:
+ scancode = KEY_AltLang; break; /* right alt */
+ case KEY_ScrollLock:
+ scancode = KEY_Break; break; /* curs break */
+ case 0x5b:
+ scancode = KEY_LMeta; break;
+ case 0x5c:
+ scancode = KEY_RMeta; break;
+ case 0x5d:
+ scancode = KEY_Menu; break;
+ case KEY_F3:
+ scancode = KEY_F13; break;
+ case KEY_F4:
+ scancode = KEY_F14; break;
+ case KEY_F5:
+ scancode = KEY_F15; break;
+ case KEY_F6:
+ scancode = KEY_F16; break;
+ case KEY_F7:
+ scancode = KEY_F17; break;
+ case KEY_KP_Plus:
+ scancode = KEY_KP_DEC; break;
+ /* Ignore virtual shifts (E0 2A, E0 AA, E0 36, E0 B6) */
+ case 0x2A:
+ case 0x36:
+ b++;
+ prefix = 0;
+ continue;
+ default:
+#ifdef DEBUG
+ ErrorF("Unreported Prefix0 scancode: 0x%02x\n",
+ scancode);
+#endif
+ /*
+ * "Internet" keyboards are generating lots of new
+ * codes. Let them pass. There is little consistency
+ * between them, so don't bother with symbolic names at
+ * this level.
+ */
+ scancode += 0x78;
+ }
+ break;
+ }
+
+ case KEY_Prefix1:
+ {
+ /* we do no handle these */
+#ifdef DEBUG
+ ErrorF("Prefix1 scancode: 0x%02x\n", scancode);
+#endif
+ b++;
+ prefix = 0;
+ continue;
+ }
+
+ default: /* should not happen*/
+ case 0: /* do nothing */
+#ifdef DEBUG
+ ErrorF("Plain scancode: 0x%02x\n", scancode);
+#endif
+ ;
+ }
+
+ prefix = 0;
+ }
+ /* without xkb we use mediumraw mode -- enqueue the scancode as is */
+ else
+#endif
+ scancode = b[0] & 0x7f;
+ KdEnqueueKeyboardEvent (closure, scancode, b[0] & 0x80);
+ b++;
+ }
+ }
+}
+
+static int LinuxKbdTrans;
+static struct termios LinuxTermios;
+
+static Status
+LinuxKeyboardEnable (KdKeyboardInfo *ki)
+{
+ struct termios nTty;
+ unsigned char buf[256];
+ int n;
+ int fd;
+
+ if (!ki)
+ return !Success;
+
+ fd = LinuxConsoleFd;
+ ki->driverPrivate = (void *) fd;
+
+ ioctl (fd, KDGKBMODE, &LinuxKbdTrans);
+ tcgetattr (fd, &LinuxTermios);
+#ifdef XKB
+ if (!noXkbExtension)
+ ioctl(fd, KDSKBMODE, K_RAW);
+ else
+#else
+ ioctl(fd, KDSKBMODE, K_MEDIUMRAW);
+#endif
+ nTty = LinuxTermios;
+ nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME]=0;
+ nTty.c_cc[VMIN]=1;
+ cfsetispeed(&nTty, 9600);
+ cfsetospeed(&nTty, 9600);
+ tcsetattr(fd, TCSANOW, &nTty);
+ /*
+ * Flush any pending keystrokes
+ */
+ while ((n = read (fd, buf, sizeof (buf))) > 0)
+ ;
+ KdRegisterFd (fd, LinuxKeyboardRead, ki);
+ return Success;
+}
+
+static void
+LinuxKeyboardDisable (KdKeyboardInfo *ki)
+{
+ int fd;
+
+ if (!ki)
+ return;
+
+ fd = (int) ki->driverPrivate;
+
+ KdUnregisterFd(ki, fd, FALSE);
+ ioctl(fd, KDSKBMODE, LinuxKbdTrans);
+ tcsetattr(fd, TCSANOW, &LinuxTermios);
+}
+
+static Status
+LinuxKeyboardInit (KdKeyboardInfo *ki)
+{
+ if (!ki)
+ return !Success;
+
+ if (ki->path)
+ xfree(ki->path);
+ ki->path = KdSaveString("console");
+ if (ki->name)
+ xfree(ki->name);
+ ki->name = KdSaveString("Linux console keyboard");
+
+ readKernelMapping (ki);
+
+ return Success;
+}
+
+static void
+LinuxKeyboardLeds (KdKeyboardInfo *ki, int leds)
+{
+ if (!ki)
+ return;
+
+ ioctl ((int)ki->driverPrivate, KDSETLED, leds & 7);
+}
+
+KdKeyboardDriver LinuxKeyboardDriver = {
+ "keyboard",
+ .Init = LinuxKeyboardInit,
+ .Enable = LinuxKeyboardEnable,
+ .Leds = LinuxKeyboardLeds,
+ .Disable = LinuxKeyboardDisable,
+};
diff --git a/xorg-server/hw/kdrive/linux/klinux.h b/xorg-server/hw/kdrive/linux/klinux.h
new file mode 100644
index 000000000..349685241
--- /dev/null
+++ b/xorg-server/hw/kdrive/linux/klinux.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _KLINUX_H_
+#define _KLINUX_H_
+
+Bool
+LinuxFindPci (CARD16 vendor, CARD16 device, CARD32 count, KdCardAttr *attr);
+
+unsigned char *
+LinuxGetPciCfg(KdCardAttr *attr);
+
+#endif /* _KLINUX_H_ */
diff --git a/xorg-server/hw/kdrive/linux/linux.c b/xorg-server/hw/kdrive/linux/linux.c
new file mode 100644
index 000000000..258dc7b81
--- /dev/null
+++ b/xorg-server/hw/kdrive/linux/linux.c
@@ -0,0 +1,484 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "klinux.h"
+#include <errno.h>
+#include <signal.h>
+#include <linux/vt.h>
+#include <linux/kd.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <X11/keysym.h>
+#include <linux/apm_bios.h>
+
+static int vtno;
+int LinuxConsoleFd;
+int LinuxApmFd = -1;
+static int activeVT;
+static Bool enabled;
+
+static void
+LinuxVTRequest (int sig)
+{
+ kdSwitchPending = TRUE;
+}
+
+/* Check before chowning -- this avoids touching the file system */
+static void
+LinuxCheckChown (char *file)
+{
+ struct stat st;
+ __uid_t u;
+ __gid_t g;
+
+ if (stat (file, &st) < 0)
+ return;
+ u = getuid ();
+ g = getgid ();
+ if (st.st_uid != u || st.st_gid != g)
+ chown (file, u, g);
+}
+
+static int
+LinuxInit (void)
+{
+ int fd = -1;
+ char vtname[11];
+ struct vt_stat vts;
+
+ LinuxConsoleFd = -1;
+ /* check if we're run with euid==0 */
+ if (geteuid() != 0)
+ {
+ FatalError("LinuxInit: Server must be suid root\n");
+ }
+
+ if (kdVirtualTerminal >= 0)
+ vtno = kdVirtualTerminal;
+ else
+ {
+ if ((fd = open("/dev/tty0",O_WRONLY,0)) < 0)
+ {
+ FatalError(
+ "LinuxInit: Cannot open /dev/tty0 (%s)\n",
+ strerror(errno));
+ }
+ if ((ioctl(fd, VT_OPENQRY, &vtno) < 0) ||
+ (vtno == -1))
+ {
+ FatalError("xf86OpenConsole: Cannot find a free VT\n");
+ }
+ }
+ close(fd);
+
+ sprintf(vtname,"/dev/tty%d",vtno); /* /dev/tty1-64 */
+
+ if ((LinuxConsoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0)
+ {
+ FatalError("LinuxInit: Cannot open %s (%s)\n",
+ vtname, strerror(errno));
+ }
+
+ /* change ownership of the vt */
+ LinuxCheckChown (vtname);
+
+ /*
+ * the current VT device we're running on is not "console", we want
+ * to grab all consoles too
+ *
+ * Why is this needed?
+ */
+ LinuxCheckChown ("/dev/tty0");
+ /*
+ * 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.
+ */
+ memset (&vts, '\0', sizeof (vts)); /* valgrind */
+ if (ioctl(LinuxConsoleFd, VT_GETSTATE, &vts) == 0)
+ {
+ activeVT = vts.v_active;
+ }
+
+ return 1;
+}
+
+Bool
+LinuxFindPci (CARD16 vendor, CARD16 device, CARD32 count, KdCardAttr *attr)
+{
+ FILE *f;
+ char line[2048], *l, *end;
+ CARD32 bus, id, addr;
+ int n;
+ CARD32 ven_dev;
+ Bool ret = FALSE;
+ int i;
+
+ attr->vendorID = vendor;
+ attr->deviceID = device;
+ ven_dev = (((CARD32) vendor) << 16) | ((CARD32) device);
+ f = fopen ("/proc/bus/pci/devices", "r");
+ if (!f)
+ return FALSE;
+ attr->io = 0;
+ while (fgets (line, sizeof (line)-1, f))
+ {
+ line[sizeof(line)-1] = '\0';
+ l = line;
+ bus = strtoul (l, &end, 16);
+ if (end == l)
+ continue;
+ l = end;
+ id = strtoul (l, &end, 16);
+ if (end == l)
+ continue;
+ l = end;
+ if (id != ven_dev)
+ continue;
+ if (count--)
+ continue;
+ (void) strtoul (l, &end, 16); /* IRQ */
+ if (end == l)
+ continue;
+ l = end;
+ n = 0;
+ for (i = 0; i < 6; i++)
+ {
+ addr = strtoul (l, &end, 16);
+ if (end == l)
+ break;
+ if (addr & 1)
+ attr->io = addr & ~0xf;
+ else
+ {
+ if (n == KD_MAX_CARD_ADDRESS)
+ break;
+ attr->address[n++] = addr & ~0xf;
+ }
+ l = end;
+ }
+ while (n > 0)
+ {
+ if (attr->address[n-1] != 0)
+ break;
+ n--;
+ }
+ attr->naddr = n;
+ attr->domain = 0; /* XXX */
+ attr->bus = (bus >> 8) & 0xff;
+ attr->slot = (bus >> 3) & 0x1f;
+ attr->func = bus & 0x07;
+ ret = TRUE;
+ break;
+ }
+ fclose (f);
+ return ret;
+}
+
+unsigned char *
+LinuxGetPciCfg(KdCardAttr *attr)
+{
+ char filename[256];
+ FILE *f;
+ unsigned char *cfg;
+ int r;
+
+ snprintf(filename, 255, "/proc/bus/pci/%02x/%02x.%x",
+ attr->bus >> 8, (attr->bus & 0xff) >> 3, attr->bus & 7);
+/* fprintf(stderr,"Find card on path %s\n",filename); */
+
+ if (!(f=fopen(filename,"r")))
+ return NULL;
+
+ if (!(cfg=xalloc(256)))
+ {
+ fclose(f);
+ return NULL;
+ }
+
+ if (256 != (r=fread(cfg, 1, 256, f)))
+ {
+ fprintf(stderr,"LinuxGetPciCfg: read %d, expected 256\n",r);
+ free(cfg);
+ cfg=NULL;
+ }
+ fclose(f);
+/* fprintf(stderr,"LinuxGetPciCfg: success, returning %p\n",cfg); */
+ return cfg;
+}
+
+static void
+LinuxSetSwitchMode (int mode)
+{
+ struct sigaction act;
+ struct vt_mode VT;
+
+ if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) < 0)
+ {
+ FatalError ("LinuxInit: VT_GETMODE failed\n");
+ }
+
+ if (mode == VT_PROCESS)
+ {
+ act.sa_handler = LinuxVTRequest;
+ sigemptyset (&act.sa_mask);
+ act.sa_flags = 0;
+ sigaction (SIGUSR1, &act, 0);
+
+ VT.mode = mode;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ }
+ else
+ {
+ act.sa_handler = SIG_IGN;
+ sigemptyset (&act.sa_mask);
+ act.sa_flags = 0;
+ sigaction (SIGUSR1, &act, 0);
+
+ VT.mode = mode;
+ VT.relsig = 0;
+ VT.acqsig = 0;
+ }
+ if (ioctl(LinuxConsoleFd, VT_SETMODE, &VT) < 0)
+ {
+ FatalError("LinuxInit: VT_SETMODE failed\n");
+ }
+}
+
+static void
+LinuxApmBlock (pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
+{
+}
+
+static Bool LinuxApmRunning;
+
+static void
+LinuxApmWakeup (pointer blockData, int result, pointer pReadmask)
+{
+ fd_set *readmask = (fd_set *) pReadmask;
+
+ if (result > 0 && LinuxApmFd >= 0 && FD_ISSET (LinuxApmFd, readmask))
+ {
+ apm_event_t event;
+ Bool running = LinuxApmRunning;
+ int cmd = APM_IOC_SUSPEND;
+
+ while (read (LinuxApmFd, &event, sizeof (event)) == sizeof (event))
+ {
+ switch (event) {
+ case APM_SYS_STANDBY:
+ case APM_USER_STANDBY:
+ running = FALSE;
+ cmd = APM_IOC_STANDBY;
+ break;
+ case APM_SYS_SUSPEND:
+ case APM_USER_SUSPEND:
+ case APM_CRITICAL_SUSPEND:
+ running = FALSE;
+ cmd = APM_IOC_SUSPEND;
+ break;
+ case APM_NORMAL_RESUME:
+ case APM_CRITICAL_RESUME:
+ case APM_STANDBY_RESUME:
+ running = TRUE;
+ break;
+ }
+ }
+ if (running && !LinuxApmRunning)
+ {
+ KdResume ();
+ LinuxApmRunning = TRUE;
+ }
+ else if (!running && LinuxApmRunning)
+ {
+ KdSuspend ();
+ LinuxApmRunning = FALSE;
+ ioctl (LinuxApmFd, cmd, 0);
+ }
+ }
+}
+
+#ifdef FNONBLOCK
+#define NOBLOCK FNONBLOCK
+#else
+#define NOBLOCK FNDELAY
+#endif
+
+static void
+LinuxEnable (void)
+{
+ if (enabled)
+ return;
+ if (kdSwitchPending)
+ {
+ kdSwitchPending = FALSE;
+ ioctl (LinuxConsoleFd, VT_RELDISP, VT_ACKACQ);
+ }
+ /*
+ * Open the APM driver
+ */
+ LinuxApmFd = open ("/dev/apm_bios", 2);
+ if (LinuxApmFd < 0 && errno == ENOENT)
+ LinuxApmFd = open ("/dev/misc/apm_bios", 2);
+ if (LinuxApmFd >= 0)
+ {
+ LinuxApmRunning = TRUE;
+ fcntl (LinuxApmFd, F_SETFL, fcntl (LinuxApmFd, F_GETFL) | NOBLOCK);
+ RegisterBlockAndWakeupHandlers (LinuxApmBlock, LinuxApmWakeup, 0);
+ AddEnabledDevice (LinuxApmFd);
+ }
+
+ /*
+ * now get the VT
+ */
+ LinuxSetSwitchMode (VT_AUTO);
+ if (ioctl(LinuxConsoleFd, VT_ACTIVATE, vtno) != 0)
+ {
+ FatalError("LinuxInit: VT_ACTIVATE failed\n");
+ }
+ if (ioctl(LinuxConsoleFd, VT_WAITACTIVE, vtno) != 0)
+ {
+ FatalError("LinuxInit: VT_WAITACTIVE failed\n");
+ }
+ LinuxSetSwitchMode (VT_PROCESS);
+ if (ioctl(LinuxConsoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ {
+ FatalError("LinuxInit: KDSETMODE KD_GRAPHICS failed\n");
+ }
+ enabled = TRUE;
+}
+
+static void
+LinuxDisable (void)
+{
+ ioctl(LinuxConsoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */
+ if (kdSwitchPending)
+ {
+ kdSwitchPending = FALSE;
+ ioctl (LinuxConsoleFd, VT_RELDISP, 1);
+ }
+ enabled = FALSE;
+ if (LinuxApmFd >= 0)
+ {
+ RemoveBlockAndWakeupHandlers (LinuxApmBlock, LinuxApmWakeup, 0);
+ RemoveEnabledDevice (LinuxApmFd);
+ close (LinuxApmFd);
+ LinuxApmFd = -1;
+ }
+}
+
+static void
+LinuxFini (void)
+{
+ struct vt_mode VT;
+ struct vt_stat vts;
+ int fd;
+
+ if (LinuxConsoleFd < 0)
+ return;
+
+ if (ioctl(LinuxConsoleFd, VT_GETMODE, &VT) != -1)
+ {
+ VT.mode = VT_AUTO;
+ ioctl(LinuxConsoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
+ }
+ memset (&vts, '\0', sizeof (vts)); /* valgrind */
+ ioctl (LinuxConsoleFd, VT_GETSTATE, &vts);
+ if (vtno == vts.v_active)
+ {
+ /*
+ * Find a legal VT to switch to, either the one we started from
+ * or the lowest active one that isn't ours
+ */
+ if (activeVT < 0 ||
+ activeVT == vts.v_active ||
+ !(vts.v_state & (1 << activeVT)))
+ {
+ for (activeVT = 1; activeVT < 16; activeVT++)
+ if (activeVT != vtno && (vts.v_state & (1 << activeVT)))
+ break;
+ if (activeVT == 16)
+ activeVT = -1;
+ }
+ /*
+ * Perform a switch back to the active VT when we were started
+ */
+ if (activeVT >= -1)
+ {
+ ioctl (LinuxConsoleFd, VT_ACTIVATE, activeVT);
+ ioctl (LinuxConsoleFd, VT_WAITACTIVE, activeVT);
+ activeVT = -1;
+ }
+ }
+ close(LinuxConsoleFd); /* make the vt-manager happy */
+ LinuxConsoleFd = -1;
+ fd = open ("/dev/tty0", O_RDWR|O_NDELAY, 0);
+ if (fd >= 0)
+ {
+ memset (&vts, '\0', sizeof (vts)); /* valgrind */
+ ioctl (fd, VT_GETSTATE, &vts);
+ if (ioctl (fd, VT_DISALLOCATE, vtno) < 0)
+ fprintf (stderr, "Can't deallocate console %d %s\n", vtno, strerror(errno));
+ close (fd);
+ }
+ return;
+}
+
+void
+KdOsAddInputDrivers ()
+{
+ KdAddPointerDriver(&LinuxMouseDriver);
+ KdAddPointerDriver(&MsMouseDriver);
+ KdAddPointerDriver(&Ps2MouseDriver);
+#ifdef TSLIB
+ KdAddPointerDriver(&TsDriver);
+#endif
+ KdAddPointerDriver(&LinuxEvdevMouseDriver);
+ KdAddKeyboardDriver(&LinuxKeyboardDriver);
+ KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver);
+}
+
+static void
+LinuxBell(int volume, int pitch, int duration)
+{
+ if (volume && pitch)
+ ioctl(LinuxConsoleFd, KDMKTONE, ((1193190 / pitch) & 0xffff) |
+ (((unsigned long)duration * volume / 50) << 16));
+}
+
+KdOsFuncs LinuxFuncs = {
+ .Init = LinuxInit,
+ .Enable = LinuxEnable,
+ .Disable = LinuxDisable,
+ .Fini = LinuxFini,
+ .Bell = LinuxBell,
+};
+
+void
+OsVendorInit (void)
+{
+ KdOsInit (&LinuxFuncs);
+}
diff --git a/xorg-server/hw/kdrive/linux/mouse.c b/xorg-server/hw/kdrive/linux/mouse.c
new file mode 100644
index 000000000..1965342b8
--- /dev/null
+++ b/xorg-server/hw/kdrive/linux/mouse.c
@@ -0,0 +1,1027 @@
+/*
+ * Copyright © 2001 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#define NEED_EVENTS
+#include <errno.h>
+#include <termios.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xpoll.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "kdrive.h"
+
+#undef DEBUG
+#undef DEBUG_BYTES
+#define KBUFIO_SIZE 256
+#define MOUSE_TIMEOUT 100
+
+typedef struct _kbufio {
+ int fd;
+ unsigned char buf[KBUFIO_SIZE];
+ int avail;
+ int used;
+} Kbufio;
+
+static Bool
+MouseWaitForReadable (int fd, int timeout)
+{
+ fd_set set;
+ struct timeval tv, *tp;
+ int n;
+ CARD32 done;
+
+ done = GetTimeInMillis () + timeout;
+ for (;;)
+ {
+ FD_ZERO (&set);
+ FD_SET (fd, &set);
+ if (timeout == -1)
+ tp = 0;
+ else
+ {
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout % 1000) * 1000;
+ tp = &tv;
+ }
+ n = select (fd + 1, &set, 0, 0, tp);
+ if (n > 0)
+ return TRUE;
+ if (n < 0 && (errno == EAGAIN || errno == EINTR))
+ {
+ timeout = (int) (done - GetTimeInMillis ());
+ if (timeout > 0)
+ continue;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+static int
+MouseReadByte (Kbufio *b, int timeout)
+{
+ int n;
+ if (b->avail <= b->used)
+ {
+ if (timeout && !MouseWaitForReadable (b->fd, timeout))
+ {
+#ifdef DEBUG_BYTES
+ ErrorF ("\tTimeout %d\n", timeout);
+#endif
+ return -1;
+ }
+ n = read (b->fd, b->buf, KBUFIO_SIZE);
+ if (n <= 0)
+ return -1;
+ b->avail = n;
+ b->used = 0;
+ }
+#ifdef DEBUG_BYTES
+ ErrorF ("\tget %02x\n", b->buf[b->used]);
+#endif
+ return b->buf[b->used++];
+}
+
+#if NOTUSED
+static int
+MouseFlush (Kbufio *b, char *buf, int size)
+{
+ CARD32 now = GetTimeInMillis ();
+ CARD32 done = now + 100;
+ int c;
+ int n = 0;
+
+ while ((c = MouseReadByte (b, done - now)) != -1)
+ {
+ if (buf)
+ {
+ if (n == size)
+ {
+ memmove (buf, buf + 1, size - 1);
+ n--;
+ }
+ buf[n++] = c;
+ }
+ now = GetTimeInMillis ();
+ if ((INT32) (now - done) >= 0)
+ break;
+ }
+ return n;
+}
+
+static int
+MousePeekByte (Kbufio *b, int timeout)
+{
+ int c;
+
+ c = MouseReadByte (b, timeout);
+ if (c != -1)
+ --b->used;
+ return c;
+}
+#endif /* NOTUSED */
+
+static Bool
+MouseWaitForWritable (int fd, int timeout)
+{
+ fd_set set;
+ struct timeval tv, *tp;
+ int n;
+
+ FD_ZERO (&set);
+ FD_SET (fd, &set);
+ if (timeout == -1)
+ tp = 0;
+ else
+ {
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout % 1000) * 1000;
+ tp = &tv;
+ }
+ n = select (fd + 1, 0, &set, 0, tp);
+ if (n > 0)
+ return TRUE;
+ return FALSE;
+}
+
+static Bool
+MouseWriteByte (int fd, unsigned char c, int timeout)
+{
+ int ret;
+
+#ifdef DEBUG_BYTES
+ ErrorF ("\tput %02x\n", c);
+#endif
+ for (;;)
+ {
+ ret = write (fd, &c, 1);
+ if (ret == 1)
+ return TRUE;
+ if (ret == 0)
+ return FALSE;
+ if (errno != EWOULDBLOCK)
+ return FALSE;
+ if (!MouseWaitForWritable (fd, timeout))
+ return FALSE;
+ }
+}
+
+static Bool
+MouseWriteBytes (int fd, unsigned char *c, int n, int timeout)
+{
+ while (n--)
+ if (!MouseWriteByte (fd, *c++, timeout))
+ return FALSE;
+ return TRUE;
+}
+
+#define MAX_MOUSE 10 /* maximum length of mouse protocol */
+#define MAX_SKIP 16 /* number of error bytes before switching */
+#define MAX_VALID 4 /* number of valid packets before accepting */
+
+typedef struct _kmouseProt {
+ char *name;
+ Bool (*Complete) (KdPointerInfo *pi, unsigned char *ev, int ne);
+ int (*Valid) (KdPointerInfo *pi, unsigned char *ev, int ne);
+ Bool (*Parse) (KdPointerInfo *pi, unsigned char *ev, int ne);
+ Bool (*Init) (KdPointerInfo *pi);
+ unsigned char headerMask, headerValid;
+ unsigned char dataMask, dataValid;
+ Bool tty;
+ unsigned int c_iflag;
+ unsigned int c_oflag;
+ unsigned int c_lflag;
+ unsigned int c_cflag;
+ unsigned int speed;
+ unsigned char *init;
+ unsigned long state;
+} KmouseProt;
+
+typedef enum _kmouseStage {
+ MouseBroken, MouseTesting, MouseWorking
+} KmouseStage;
+
+typedef struct _kmouse {
+ Kbufio iob;
+ const KmouseProt *prot;
+ int i_prot;
+ KmouseStage stage; /* protocol verification stage */
+ Bool tty; /* mouse device is a tty */
+ int valid; /* sequential valid events */
+ int tested; /* bytes scanned during Testing phase */
+ int invalid;/* total invalid bytes for this protocol */
+ unsigned long state; /* private per protocol, init to prot->state */
+} Kmouse;
+
+static int mouseValid (KdPointerInfo *pi, unsigned char *ev, int ne)
+{
+ Kmouse *km = pi->driverPrivate;
+ const KmouseProt *prot = km->prot;
+ int i;
+
+ for (i = 0; i < ne; i++)
+ if ((ev[i] & prot->headerMask) == prot->headerValid)
+ break;
+ if (i != 0)
+ return i;
+ for (i = 1; i < ne; i++)
+ if ((ev[i] & prot->dataMask) != prot->dataValid)
+ return -1;
+ return 0;
+}
+
+static Bool threeComplete (KdPointerInfo *pi, unsigned char *ev, int ne)
+{
+ return ne == 3;
+}
+
+static Bool fourComplete (KdPointerInfo *pi, unsigned char *ev, int ne)
+{
+ return ne == 4;
+}
+
+static Bool fiveComplete (KdPointerInfo *pi, unsigned char *ev, int ne)
+{
+ return ne == 5;
+}
+
+static Bool MouseReasonable (KdPointerInfo *pi, unsigned long flags, int dx, int dy)
+{
+ Kmouse *km = pi->driverPrivate;
+
+ if (km->stage == MouseWorking)
+ return TRUE;
+ if (dx < -50 || dx > 50)
+ {
+#ifdef DEBUG
+ ErrorF ("Large X %d\n", dx);
+#endif
+ return FALSE;
+ }
+ if (dy < -50 || dy > 50)
+ {
+#ifdef DEBUG
+ ErrorF ("Large Y %d\n", dy);
+#endif
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/*
+ * Standard PS/2 mouse protocol
+ */
+static Bool ps2Parse (KdPointerInfo *pi, unsigned char *ev, int ne)
+{
+ Kmouse *km = pi->driverPrivate;
+ int dx, dy, dz;
+ unsigned long flags;
+ unsigned long flagsrelease = 0;
+
+ flags = KD_MOUSE_DELTA;
+ if (ev[0] & 4)
+ flags |= KD_BUTTON_2;
+ if (ev[0] & 2)
+ flags |= KD_BUTTON_3;
+ if (ev[0] & 1)
+ flags |= KD_BUTTON_1;
+
+ if (ne > 3)
+ {
+ dz = (int) (signed char) ev[3];
+ if (dz < 0)
+ {
+ flags |= KD_BUTTON_4;
+ flagsrelease = KD_BUTTON_4;
+ }
+ else if (dz > 0)
+ {
+ flags |= KD_BUTTON_5;
+ flagsrelease = KD_BUTTON_5;
+ }
+ }
+
+ dx = ev[1];
+ if (ev[0] & 0x10)
+ dx -= 256;
+ dy = ev[2];
+ if (ev[0] & 0x20)
+ dy -= 256;
+ dy = -dy;
+ if (!MouseReasonable (pi, flags, dx, dy))
+ return FALSE;
+ if (km->stage == MouseWorking)
+ {
+ KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
+ if (flagsrelease)
+ {
+ flags &= ~flagsrelease;
+ KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
+ }
+ }
+ return TRUE;
+}
+
+static Bool ps2Init (KdPointerInfo *pi);
+
+static const KmouseProt ps2Prot = {
+ "ps/2",
+ threeComplete, mouseValid, ps2Parse, ps2Init,
+ 0x08, 0x08, 0x00, 0x00,
+ FALSE
+};
+
+static const KmouseProt imps2Prot = {
+ "imps/2",
+ fourComplete, mouseValid, ps2Parse, ps2Init,
+ 0x08, 0x08, 0x00, 0x00,
+ FALSE
+};
+
+static const KmouseProt exps2Prot = {
+ "exps/2",
+ fourComplete, mouseValid, ps2Parse, ps2Init,
+ 0x08, 0x08, 0x00, 0x00,
+ FALSE
+};
+
+/*
+ * Once the mouse is known to speak ps/2 protocol, go and find out
+ * what advanced capabilities it has and turn them on
+ */
+
+/* these extracted from FreeBSD 4.3 sys/dev/kbd/atkbdcreg.h */
+
+/* aux device commands (sent to KBD_DATA_PORT) */
+#define PSMC_SET_SCALING11 0x00e6
+#define PSMC_SET_SCALING21 0x00e7
+#define PSMC_SET_RESOLUTION 0x00e8
+#define PSMC_SEND_DEV_STATUS 0x00e9
+#define PSMC_SET_STREAM_MODE 0x00ea
+#define PSMC_SEND_DEV_DATA 0x00eb
+#define PSMC_SET_REMOTE_MODE 0x00f0
+#define PSMC_SEND_DEV_ID 0x00f2
+#define PSMC_SET_SAMPLING_RATE 0x00f3
+#define PSMC_ENABLE_DEV 0x00f4
+#define PSMC_DISABLE_DEV 0x00f5
+#define PSMC_SET_DEFAULTS 0x00f6
+#define PSMC_RESET_DEV 0x00ff
+
+/* PSMC_SET_RESOLUTION argument */
+#define PSMD_RES_LOW 0 /* typically 25ppi */
+#define PSMD_RES_MEDIUM_LOW 1 /* typically 50ppi */
+#define PSMD_RES_MEDIUM_HIGH 2 /* typically 100ppi (default) */
+#define PSMD_RES_HIGH 3 /* typically 200ppi */
+#define PSMD_MAX_RESOLUTION PSMD_RES_HIGH
+
+/* PSMC_SET_SAMPLING_RATE */
+#define PSMD_MAX_RATE 255 /* FIXME: not sure if it's possible */
+
+/* aux device ID */
+#define PSM_MOUSE_ID 0
+#define PSM_BALLPOINT_ID 2
+#define PSM_INTELLI_ID 3
+#define PSM_EXPLORER_ID 4
+#define PSM_4DMOUSE_ID 6
+#define PSM_4DPLUS_ID 8
+
+static unsigned char ps2_init[] = {
+ PSMC_ENABLE_DEV,
+ 0,
+};
+
+#define NINIT_PS2 1
+
+static unsigned char wheel_3button_init[] = {
+ PSMC_SET_SAMPLING_RATE, 200,
+ PSMC_SET_SAMPLING_RATE, 100,
+ PSMC_SET_SAMPLING_RATE, 80,
+ PSMC_SEND_DEV_ID,
+ 0,
+};
+
+#define NINIT_IMPS2 4
+
+static unsigned char wheel_5button_init[] = {
+ PSMC_SET_SAMPLING_RATE, 200,
+ PSMC_SET_SAMPLING_RATE, 100,
+ PSMC_SET_SAMPLING_RATE, 80,
+ PSMC_SET_SAMPLING_RATE, 200,
+ PSMC_SET_SAMPLING_RATE, 200,
+ PSMC_SET_SAMPLING_RATE, 80,
+ PSMC_SEND_DEV_ID,
+ 0
+};
+
+#define NINIT_EXPS2 7
+
+static unsigned char intelli_init[] = {
+ PSMC_SET_SAMPLING_RATE, 200,
+ PSMC_SET_SAMPLING_RATE, 100,
+ PSMC_SET_SAMPLING_RATE, 80,
+ 0
+};
+
+#define NINIT_INTELLI 3
+
+static int
+ps2SkipInit (KdPointerInfo *pi, int ninit, Bool ret_next)
+{
+ Kmouse *km = pi->driverPrivate;
+ int c = -1;
+ int skipping;
+ Bool waiting;
+
+ skipping = 0;
+ waiting = FALSE;
+ while (ninit || ret_next)
+ {
+ c = MouseReadByte (&km->iob, MOUSE_TIMEOUT);
+ if (c == -1)
+ break;
+ /* look for ACK */
+ if (c == 0xfa)
+ {
+ ninit--;
+ if (ret_next)
+ waiting = TRUE;
+ }
+ /* look for packet start -- not the response */
+ else if ((c & 0x08) == 0x08)
+ waiting = FALSE;
+ else if (waiting)
+ break;
+ }
+ return c;
+}
+
+static Bool
+ps2Init (KdPointerInfo *pi)
+{
+ Kmouse *km = pi->driverPrivate;
+ int skipping;
+ Bool waiting;
+ int id;
+ unsigned char *init;
+ int ninit;
+
+ /* Send Intellimouse initialization sequence */
+ MouseWriteBytes (km->iob.fd, intelli_init, strlen ((char *) intelli_init), 100);
+ /*
+ * Send ID command
+ */
+ if (!MouseWriteByte (km->iob.fd, PSMC_SEND_DEV_ID, 100))
+ return FALSE;
+ skipping = 0;
+ waiting = FALSE;
+ id = ps2SkipInit (pi, 0, TRUE);
+ switch (id) {
+ case 3:
+ init = wheel_3button_init;
+ ninit = NINIT_IMPS2;
+ km->prot = &imps2Prot;
+ break;
+ case 4:
+ init = wheel_5button_init;
+ ninit = NINIT_EXPS2;
+ km->prot = &exps2Prot;
+ break;
+ default:
+ init = ps2_init;
+ ninit = NINIT_PS2;
+ km->prot = &ps2Prot;
+ break;
+ }
+ if (init)
+ MouseWriteBytes (km->iob.fd, init, strlen ((char *) init), 100);
+ /*
+ * Flush out the available data to eliminate responses to the
+ * initialization string. Make sure any partial event is
+ * skipped
+ */
+ (void) ps2SkipInit (pi, ninit, FALSE);
+ return TRUE;
+}
+
+static Bool busParse (KdPointerInfo *pi, unsigned char *ev, int ne)
+{
+ Kmouse *km = pi->driverPrivate;
+ int dx, dy;
+ unsigned long flags;
+
+ flags = KD_MOUSE_DELTA;
+ dx = (signed char) ev[1];
+ dy = -(signed char) ev[2];
+ if ((ev[0] & 4) == 0)
+ flags |= KD_BUTTON_1;
+ if ((ev[0] & 2) == 0)
+ flags |= KD_BUTTON_2;
+ if ((ev[0] & 1) == 0)
+ flags |= KD_BUTTON_3;
+ if (!MouseReasonable (pi, flags, dx, dy))
+ return FALSE;
+ if (km->stage == MouseWorking)
+ KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
+ return TRUE;
+}
+
+static const KmouseProt busProt = {
+ "bus",
+ threeComplete, mouseValid, busParse, 0,
+ 0xf8, 0x00, 0x00, 0x00,
+ FALSE
+};
+
+/*
+ * Standard MS serial protocol, three bytes
+ */
+
+static Bool msParse (KdPointerInfo *pi, unsigned char *ev, int ne)
+{
+ Kmouse *km = pi->driverPrivate;
+ int dx, dy;
+ unsigned long flags;
+
+ flags = KD_MOUSE_DELTA;
+
+ if (ev[0] & 0x20)
+ flags |= KD_BUTTON_1;
+ if (ev[0] & 0x10)
+ flags |= KD_BUTTON_3;
+
+ dx = (signed char)(((ev[0] & 0x03) << 6) | (ev[1] & 0x3F));
+ dy = (signed char)(((ev[0] & 0x0C) << 4) | (ev[2] & 0x3F));
+ if (!MouseReasonable (pi, flags, dx, dy))
+ return FALSE;
+ if (km->stage == MouseWorking)
+ KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
+ return TRUE;
+}
+
+static const KmouseProt msProt = {
+ "ms",
+ threeComplete, mouseValid, msParse, 0,
+ 0xc0, 0x40, 0xc0, 0x00,
+ TRUE,
+ IGNPAR,
+ 0,
+ 0,
+ CS7 | CSTOPB | CREAD | CLOCAL,
+ B1200,
+};
+
+/*
+ * Logitech mice send 3 or 4 bytes, the only way to tell is to look at the
+ * first byte of a synchronized protocol stream and see if it's got
+ * any bits turned on that can't occur in that fourth byte
+ */
+static Bool logiComplete (KdPointerInfo *pi, unsigned char *ev, int ne)
+{
+ Kmouse *km = pi->driverPrivate;
+
+ if ((ev[0] & 0x40) == 0x40)
+ return ne == 3;
+ if (km->stage != MouseBroken && (ev[0] & ~0x23) == 0)
+ return ne == 1;
+ return FALSE;
+}
+
+static int logiValid (KdPointerInfo *pi, unsigned char *ev, int ne)
+{
+ Kmouse *km = pi->driverPrivate;
+ const KmouseProt *prot = km->prot;
+ int i;
+
+ for (i = 0; i < ne; i++)
+ {
+ if ((ev[i] & 0x40) == 0x40)
+ break;
+ if (km->stage != MouseBroken && (ev[i] & ~0x23) == 0)
+ break;
+ }
+ if (i != 0)
+ return i;
+ for (i = 1; i < ne; i++)
+ if ((ev[i] & prot->dataMask) != prot->dataValid)
+ return -1;
+ return 0;
+}
+
+static Bool logiParse (KdPointerInfo *pi, unsigned char *ev, int ne)
+{
+ Kmouse *km = pi->driverPrivate;
+ int dx, dy;
+ unsigned long flags;
+
+ flags = KD_MOUSE_DELTA;
+
+ if (ne == 3)
+ {
+ if (ev[0] & 0x20)
+ flags |= KD_BUTTON_1;
+ if (ev[0] & 0x10)
+ flags |= KD_BUTTON_3;
+
+ dx = (signed char)(((ev[0] & 0x03) << 6) | (ev[1] & 0x3F));
+ dy = (signed char)(((ev[0] & 0x0C) << 4) | (ev[2] & 0x3F));
+ flags |= km->state & KD_BUTTON_2;
+ }
+ else
+ {
+ if (ev[0] & 0x20)
+ flags |= KD_BUTTON_2;
+ dx = 0;
+ dy = 0;
+ flags |= km->state & (KD_BUTTON_1|KD_BUTTON_3);
+ }
+
+ if (!MouseReasonable (pi, flags, dx, dy))
+ return FALSE;
+ if (km->stage == MouseWorking)
+ KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
+ return TRUE;
+}
+
+static const KmouseProt logiProt = {
+ "logitech",
+ logiComplete, logiValid, logiParse, 0,
+ 0xc0, 0x40, 0xc0, 0x00,
+ TRUE,
+ IGNPAR,
+ 0,
+ 0,
+ CS7 | CSTOPB | CREAD | CLOCAL,
+ B1200,
+};
+
+/*
+ * Mouse systems protocol, 5 bytes
+ */
+static Bool mscParse (KdPointerInfo *pi, unsigned char *ev, int ne)
+{
+ Kmouse *km = pi->driverPrivate;
+ int dx, dy;
+ unsigned long flags;
+
+ flags = KD_MOUSE_DELTA;
+
+ if (!(ev[0] & 0x4))
+ flags |= KD_BUTTON_1;
+ if (!(ev[0] & 0x2))
+ flags |= KD_BUTTON_2;
+ if (!(ev[0] & 0x1))
+ flags |= KD_BUTTON_3;
+ dx = (signed char)(ev[1]) + (signed char)(ev[3]);
+ dy = - ((signed char)(ev[2]) + (signed char)(ev[4]));
+
+ if (!MouseReasonable (pi, flags, dx, dy))
+ return FALSE;
+ if (km->stage == MouseWorking)
+ KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
+ return TRUE;
+}
+
+static const KmouseProt mscProt = {
+ "msc",
+ fiveComplete, mouseValid, mscParse, 0,
+ 0xf8, 0x80, 0x00, 0x00,
+ TRUE,
+ IGNPAR,
+ 0,
+ 0,
+ CS8 | CSTOPB | CREAD | CLOCAL,
+ B1200,
+};
+
+/*
+ * Use logitech before ms -- they're the same except that
+ * logitech sometimes has a fourth byte
+ */
+static const KmouseProt *kmouseProts[] = {
+ &ps2Prot, &imps2Prot, &exps2Prot, &busProt, &logiProt, &msProt, &mscProt,
+};
+
+#define NUM_PROT (sizeof (kmouseProts) / sizeof (kmouseProts[0]))
+
+static void
+MouseInitProtocol (Kmouse *km)
+{
+ int ret;
+ struct termios t;
+
+ if (km->prot->tty)
+ {
+ ret = tcgetattr (km->iob.fd, &t);
+
+ if (ret >= 0)
+ {
+ t.c_iflag = km->prot->c_iflag;
+ t.c_oflag = km->prot->c_oflag;
+ t.c_lflag = km->prot->c_lflag;
+ t.c_cflag = km->prot->c_cflag;
+ cfsetispeed (&t, km->prot->speed);
+ cfsetospeed (&t, km->prot->speed);
+ ret = tcsetattr (km->iob.fd, TCSANOW, &t);
+ }
+ }
+ km->stage = MouseBroken;
+ km->valid = 0;
+ km->tested = 0;
+ km->invalid = 0;
+ km->state = km->prot->state;
+}
+
+static void
+MouseFirstProtocol (Kmouse *km, char *prot)
+{
+ if (prot)
+ {
+ for (km->i_prot = 0; km->i_prot < NUM_PROT; km->i_prot++)
+ if (!strcmp (prot, kmouseProts[km->i_prot]->name))
+ break;
+ if (km->i_prot == NUM_PROT)
+ {
+ int i;
+ ErrorF ("Unknown mouse protocol \"%s\". Pick one of:", prot);
+ for (i = 0; i < NUM_PROT; i++)
+ ErrorF (" %s", kmouseProts[i]->name);
+ ErrorF ("\n");
+ }
+ else
+ {
+ km->prot = kmouseProts[km->i_prot];
+ if (km->tty && !km->prot->tty)
+ ErrorF ("Mouse device is serial port, protocol %s is not serial protocol\n",
+ prot);
+ else if (!km->tty && km->prot->tty)
+ ErrorF ("Mouse device is not serial port, protocol %s is serial protocol\n",
+ prot);
+ }
+ }
+ if (!km->prot)
+ {
+ for (km->i_prot = 0; kmouseProts[km->i_prot]->tty != km->tty; km->i_prot++)
+ ;
+ km->prot = kmouseProts[km->i_prot];
+ }
+ MouseInitProtocol (km);
+}
+
+static void
+MouseNextProtocol (Kmouse *km)
+{
+ do
+ {
+ if (!km->prot)
+ km->i_prot = 0;
+ else
+ if (++km->i_prot == NUM_PROT) km->i_prot = 0;
+ km->prot = kmouseProts[km->i_prot];
+ } while (km->prot->tty != km->tty);
+ MouseInitProtocol (km);
+ ErrorF ("Switching to mouse protocol \"%s\"\n", km->prot->name);
+}
+
+static void
+MouseRead (int mousePort, void *closure)
+{
+ KdPointerInfo *pi = closure;
+ Kmouse *km = pi->driverPrivate;
+ unsigned char event[MAX_MOUSE];
+ int ne;
+ int c;
+ int i;
+ int timeout;
+
+ timeout = 0;
+ ne = 0;
+ for(;;)
+ {
+ c = MouseReadByte (&km->iob, timeout);
+ if (c == -1)
+ {
+ if (ne)
+ {
+ km->invalid += ne + km->tested;
+ km->valid = 0;
+ km->tested = 0;
+ km->stage = MouseBroken;
+ }
+ break;
+ }
+ event[ne++] = c;
+ i = (*km->prot->Valid) (pi, event, ne);
+ if (i != 0)
+ {
+#ifdef DEBUG
+ ErrorF ("Mouse protocol %s broken %d of %d bytes bad\n",
+ km->prot->name, i > 0 ? i : ne, ne);
+#endif
+ if (i > 0 && i < ne)
+ {
+ ne -= i;
+ memmove (event, event + i, ne);
+ }
+ else
+ {
+ i = ne;
+ ne = 0;
+ }
+ km->invalid += i + km->tested;
+ km->valid = 0;
+ km->tested = 0;
+ if (km->stage == MouseWorking)
+ km->i_prot--;
+ km->stage = MouseBroken;
+ if (km->invalid > MAX_SKIP)
+ {
+ MouseNextProtocol (km);
+ ne = 0;
+ }
+ timeout = 0;
+ }
+ else
+ {
+ if ((*km->prot->Complete) (pi, event, ne))
+ {
+ if ((*km->prot->Parse) (pi, event, ne))
+ {
+ switch (km->stage)
+ {
+ case MouseBroken:
+#ifdef DEBUG
+ ErrorF ("Mouse protocol %s seems OK\n",
+ km->prot->name);
+#endif
+ /* do not zero invalid to accumulate invalid bytes */
+ km->valid = 0;
+ km->tested = 0;
+ km->stage = MouseTesting;
+ /* fall through ... */
+ case MouseTesting:
+ km->valid++;
+ km->tested += ne;
+ if (km->valid > MAX_VALID)
+ {
+#ifdef DEBUG
+ ErrorF ("Mouse protocol %s working\n",
+ km->prot->name);
+#endif
+ km->stage = MouseWorking;
+ km->invalid = 0;
+ km->tested = 0;
+ km->valid = 0;
+ if (km->prot->Init && !(*km->prot->Init) (pi))
+ km->stage = MouseBroken;
+ }
+ break;
+ case MouseWorking:
+ break;
+ }
+ }
+ else
+ {
+ km->invalid += ne + km->tested;
+ km->valid = 0;
+ km->tested = 0;
+ km->stage = MouseBroken;
+ }
+ ne = 0;
+ timeout = 0;
+ }
+ else
+ timeout = MOUSE_TIMEOUT;
+ }
+ }
+}
+
+int MouseInputType;
+
+char *kdefaultMouse[] = {
+ "/dev/input/mice",
+ "/dev/mouse",
+ "/dev/psaux",
+ "/dev/adbmouse",
+ "/dev/ttyS0",
+ "/dev/ttyS1",
+};
+
+#define NUM_DEFAULT_MOUSE (sizeof (kdefaultMouse) / sizeof (kdefaultMouse[0]))
+
+static Status
+MouseInit (KdPointerInfo *pi)
+{
+ int i;
+ int fd;
+ Kmouse *km;
+
+ if (!pi)
+ return BadImplementation;
+
+ if (!pi->path || strcmp(pi->path, "auto") == 0) {
+ for (i = 0; i < NUM_DEFAULT_MOUSE; i++) {
+ fd = open (kdefaultMouse[i], 2);
+ if (fd >= 0) {
+ pi->path = KdSaveString (kdefaultMouse[i]);
+ break;
+ }
+ }
+ }
+ else {
+ fd = open (pi->path, 2);
+ }
+
+ if (fd < 0)
+ return BadMatch;
+
+ close(fd);
+
+ km = (Kmouse *) xalloc (sizeof (Kmouse));
+ if (km) {
+ km->iob.avail = km->iob.used = 0;
+ MouseFirstProtocol(km, "exps/2");
+ km->i_prot = 0;
+ km->tty = isatty (fd);
+ km->iob.fd = -1;
+ pi->driverPrivate = km;
+ }
+ else {
+ close (fd);
+ return BadAlloc;
+ }
+
+ return Success;
+}
+
+static Status
+MouseEnable (KdPointerInfo *pi)
+{
+ Kmouse *km;
+
+ if (!pi || !pi->driverPrivate || !pi->path)
+ return BadImplementation;
+
+ km = pi->driverPrivate;
+
+ km->iob.fd = open(pi->path, 2);
+ if (km->iob.fd < 0)
+ return BadMatch;
+
+ if (!KdRegisterFd (km->iob.fd, MouseRead, pi))
+ {
+ close(km->iob.fd);
+ return BadAlloc;
+ }
+
+ return Success;
+}
+
+static void
+MouseDisable (KdPointerInfo *pi)
+{
+ Kmouse *km;
+ if (!pi || !pi->driverPrivate)
+ return;
+
+ km = pi->driverPrivate;
+ KdUnregisterFd (pi, km->iob.fd, TRUE);
+}
+
+static void
+MouseFini (KdPointerInfo *pi)
+{
+ xfree (pi->driverPrivate);
+ pi->driverPrivate = NULL;
+}
+
+KdPointerDriver LinuxMouseDriver = {
+ "mouse",
+ MouseInit,
+ MouseEnable,
+ MouseDisable,
+ MouseFini,
+ NULL,
+};
diff --git a/xorg-server/hw/kdrive/linux/ms.c b/xorg-server/hw/kdrive/linux/ms.c
new file mode 100644
index 000000000..d0b47a3ee
--- /dev/null
+++ b/xorg-server/hw/kdrive/linux/ms.c
@@ -0,0 +1,183 @@
+/*
+Copyright (c) 2001 by Juliusz Chroboczek
+Copyright (c) 1999 by Keith Packard
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#define NEED_EVENTS
+#include <errno.h>
+#include <termios.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xpoll.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "kdrive.h"
+
+static int
+MsReadBytes (int fd, char *buf, int len, int min)
+{
+ int n, tot;
+ fd_set set;
+ struct timeval tv;
+
+ tot = 0;
+ while (len)
+ {
+ n = read (fd, buf, len);
+ if (n > 0)
+ {
+ tot += n;
+ buf += n;
+ len -= n;
+ }
+ if (tot % min == 0)
+ break;
+ FD_ZERO (&set);
+ FD_SET (fd, &set);
+ tv.tv_sec = 0;
+ tv.tv_usec = 100 * 1000;
+ n = select (fd + 1, &set, 0, 0, &tv);
+ if (n <= 0)
+ break;
+ }
+ return tot;
+}
+
+static void
+MsRead (int port, void *closure)
+{
+ unsigned char buf[3 * 200];
+ unsigned char *b;
+ int n;
+ int dx, dy;
+ unsigned long flags;
+
+ while ((n = MsReadBytes (port, (char *) buf, sizeof (buf), 3)) > 0)
+ {
+ b = buf;
+ while (n >= 3)
+ {
+ flags = KD_MOUSE_DELTA;
+
+ if (b[0] & 0x20)
+ flags |= KD_BUTTON_1;
+ if (b[0] & 0x10)
+ flags |= KD_BUTTON_3;
+
+ dx = (char)(((b[0] & 0x03) << 6) | (b[1] & 0x3F));
+ dy = (char)(((b[0] & 0x0C) << 4) | (b[2] & 0x3F));
+ n -= 3;
+ b += 3;
+ KdEnqueuePointerEvent (closure, flags, dx, dy, 0);
+ }
+ }
+}
+
+static Status
+MsInit (KdPointerInfo *pi)
+{
+ if (!pi)
+ return BadImplementation;
+
+ if (!pi->path || strcmp(pi->path, "auto"))
+ pi->path = KdSaveString("/dev/mouse");
+ if (!pi->name)
+ pi->name = KdSaveString("Microsoft protocol mouse");
+
+ return Success;
+}
+
+static Status
+MsEnable (KdPointerInfo *pi)
+{
+ int port;
+ struct termios t;
+ int ret;
+
+ port = open (pi->path, O_RDWR | O_NONBLOCK);
+ if(port < 0) {
+ ErrorF("Couldn't open %s (%d)\n", pi->path, (int)errno);
+ return 0;
+ } else if (port == 0) {
+ ErrorF("Opening %s returned 0! Please complain to Keith.\n",
+ pi->path);
+ goto bail;
+ }
+
+ if(!isatty(port)) {
+ ErrorF("%s is not a tty\n", pi->path);
+ goto bail;
+ }
+
+ ret = tcgetattr(port, &t);
+ if(ret < 0) {
+ ErrorF("Couldn't tcgetattr(%s): %d\n", pi->path, errno);
+ goto bail;
+ }
+ t.c_iflag &= ~ (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR |
+ IGNCR | ICRNL | IXON | IXOFF);
+ t.c_oflag &= ~ OPOST;
+ t.c_lflag &= ~ (ECHO | ECHONL | ICANON | ISIG | IEXTEN);
+ t.c_cflag &= ~ (CSIZE | PARENB);
+ t.c_cflag |= CS8 | CLOCAL | CSTOPB;
+
+ cfsetispeed (&t, B1200);
+ cfsetospeed (&t, B1200);
+ t.c_cc[VMIN] = 1;
+ t.c_cc[VTIME] = 0;
+ ret = tcsetattr(port, TCSANOW, &t);
+ if(ret < 0) {
+ ErrorF("Couldn't tcsetattr(%s): %d\n", pi->path, errno);
+ goto bail;
+ }
+ if (KdRegisterFd (port, MsRead, pi))
+ return TRUE;
+ pi->driverPrivate = (void *)port;
+
+ return Success;
+
+ bail:
+ close(port);
+ return BadMatch;
+}
+
+static void
+MsDisable (KdPointerInfo *pi)
+{
+ KdUnregisterFd (pi, (int)pi->driverPrivate, TRUE);
+}
+
+static void
+MsFini (KdPointerInfo *pi)
+{
+}
+
+KdPointerDriver MsMouseDriver = {
+ "ms",
+ MsInit,
+ MsEnable,
+ MsDisable,
+ MsFini,
+ NULL,
+};
diff --git a/xorg-server/hw/kdrive/linux/ps2.c b/xorg-server/hw/kdrive/linux/ps2.c
new file mode 100644
index 000000000..d361e82a1
--- /dev/null
+++ b/xorg-server/hw/kdrive/linux/ps2.c
@@ -0,0 +1,187 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xpoll.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "kdrive.h"
+
+static int
+Ps2ReadBytes (int fd, char *buf, int len, int min)
+{
+ int n, tot;
+ fd_set set;
+ struct timeval tv;
+
+ tot = 0;
+ while (len)
+ {
+ n = read (fd, buf, len);
+ if (n > 0)
+ {
+ tot += n;
+ buf += n;
+ len -= n;
+ }
+ if (tot % min == 0)
+ break;
+ FD_ZERO (&set);
+ FD_SET (fd, &set);
+ tv.tv_sec = 0;
+ tv.tv_usec = 100 * 1000;
+ n = select (fd + 1, &set, 0, 0, &tv);
+ if (n <= 0)
+ break;
+ }
+ return tot;
+}
+
+char *Ps2Names[] = {
+ "/dev/psaux",
+/* "/dev/mouse", */
+ "/dev/input/mice",
+};
+
+#define NUM_PS2_NAMES (sizeof (Ps2Names) / sizeof (Ps2Names[0]))
+
+static void
+Ps2Read (int ps2Port, void *closure)
+{
+ unsigned char buf[3 * 200];
+ unsigned char *b;
+ int n;
+ int dx, dy;
+ unsigned long flags;
+ unsigned long left_button = KD_BUTTON_1;
+ unsigned long right_button = KD_BUTTON_3;
+
+#undef SWAP_USB
+#ifdef SWAP_USB
+ if (id == 2)
+ {
+ left_button = KD_BUTTON_3;
+ right_button = KD_BUTTON_1;
+ }
+#endif
+ while ((n = Ps2ReadBytes (ps2Port, (char *) buf, sizeof (buf), 3)) > 0)
+ {
+ b = buf;
+ while (n >= 3)
+ {
+ flags = KD_MOUSE_DELTA;
+ if (b[0] & 4)
+ flags |= KD_BUTTON_2;
+ if (b[0] & 2)
+ flags |= right_button;
+ if (b[0] & 1)
+ flags |= left_button;
+
+ dx = b[1];
+ if (b[0] & 0x10)
+ dx -= 256;
+ dy = b[2];
+ if (b[0] & 0x20)
+ dy -= 256;
+ dy = -dy;
+ n -= 3;
+ b += 3;
+ KdEnqueuePointerEvent (closure, flags, dx, dy, 0);
+ }
+ }
+}
+
+static Status
+Ps2Init (KdPointerInfo *pi)
+{
+ int ps2Port, i;
+
+ if (!pi->path) {
+ for (i = 0; i < NUM_PS2_NAMES; i++) {
+ ps2Port = open (Ps2Names[i], 0);
+ if (ps2Port >= 0) {
+ pi->path = KdSaveString (Ps2Names[i]);
+ break;
+ }
+ }
+ }
+ else {
+ ps2Port = open (pi->path, 0);
+ }
+
+ if (ps2Port < 0)
+ return BadMatch;
+
+ close(ps2Port);
+ if (!pi->name)
+ pi->name = KdSaveString ("PS/2 Mouse");
+
+ return Success;
+}
+
+static Status
+Ps2Enable (KdPointerInfo *pi)
+{
+ int fd;
+
+ if (!pi)
+ return BadImplementation;
+
+ fd = open (pi->path, 0);
+ if (fd < 0)
+ return BadMatch;
+
+ if (!KdRegisterFd (fd, Ps2Read, pi)) {
+ close(fd);
+ return BadAlloc;
+ }
+
+ pi->driverPrivate = (void *)fd;
+
+ return Success;
+}
+
+
+static void
+Ps2Disable (KdPointerInfo *pi)
+{
+ KdUnregisterFd (pi, (int)pi->driverPrivate, TRUE);
+}
+
+static void
+Ps2Fini (KdPointerInfo *pi)
+{
+}
+
+KdPointerDriver Ps2MouseDriver = {
+ "ps2",
+ Ps2Init,
+ Ps2Enable,
+ Ps2Disable,
+ Ps2Fini,
+ NULL,
+};
diff --git a/xorg-server/hw/kdrive/linux/ts.c b/xorg-server/hw/kdrive/linux/ts.c
new file mode 100644
index 000000000..831953f02
--- /dev/null
+++ b/xorg-server/hw/kdrive/linux/ts.c
@@ -0,0 +1,209 @@
+/*
+ * Derived from ps2.c by Jim Gettys
+ *
+ * Copyright © 1999 Keith Packard
+ * Copyright © 2000 Compaq Computer Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard or Compaq not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard and Compaq makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD AND COMPAQ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xpoll.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "kdrive.h"
+#include <sys/ioctl.h>
+#include <linux/h3600_ts.h> /* touch screen events */
+
+static long lastx = 0, lasty = 0;
+
+int KdTsPhyScreen = 0;
+
+static int
+TsReadBytes (int fd, char *buf, int len, int min)
+{
+ int n, tot;
+ fd_set set;
+ struct timeval tv;
+
+ tot = 0;
+ while (len)
+ {
+ n = read (fd, buf, len);
+ if (n > 0)
+ {
+ tot += n;
+ buf += n;
+ len -= n;
+ }
+ if (tot % min == 0)
+ break;
+ FD_ZERO (&set);
+ FD_SET (fd, &set);
+ tv.tv_sec = 0;
+ tv.tv_usec = 100 * 1000;
+ n = select (fd + 1, &set, 0, 0, &tv);
+ if (n <= 0)
+ break;
+ }
+ return tot;
+}
+
+static void
+TsRead (int tsPort, void *closure)
+{
+ KdPointerInfo *pi = closure;
+ TS_EVENT event;
+ int n;
+ long x, y;
+ unsigned long flags;
+
+ n = TsReadBytes (tsPort, (char *) &event, sizeof (event), sizeof (event));
+ if (n == sizeof (event))
+ {
+ if (event.pressure)
+ {
+ /*
+ * HACK ATTACK. (static global variables used !)
+ * Here we test for the touch screen driver actually being on the
+ * touch screen, if it is we send absolute coordinates. If not,
+ * then we send delta's so that we can track the entire vga screen.
+ */
+ if (KdCurScreen == KdTsPhyScreen) {
+ flags = KD_BUTTON_1;
+ x = event.x;
+ y = event.y;
+ }
+ else
+ {
+ flags = /* KD_BUTTON_1 |*/ KD_MOUSE_DELTA;
+ if ((lastx == 0) || (lasty == 0)) {
+ x = 0;
+ y = 0;
+ } else {
+ x = event.x - lastx;
+ y = event.y - lasty;
+ }
+ lastx = event.x;
+ lasty = event.y;
+ }
+ } else {
+ flags = KD_MOUSE_DELTA;
+ x = 0;
+ y = 0;
+ lastx = 0;
+ lasty = 0;
+ }
+ KdEnqueuePointerEvent (pi, flags, x, y, 0);
+ }
+}
+
+char *TsNames[] = {
+ "/dev/ts",
+ "/dev/h3600_ts" /* temporary name; note this code can try
+ to open more than one device */
+};
+
+#define NUM_TS_NAMES (sizeof (TsNames) / sizeof (TsNames[0]))
+
+static Status
+TsInit (KdPointerInfo *pi)
+{
+ int i;
+ int fd;
+ int n = 0;
+
+ if (!pi->path || strcmp(pi->path, "auto") == 0) {
+ for (i = 0; i < NUM_TS_NAMES; i++) {
+ fd = open (TsNames[i], 0);
+ if (fd >= 0) {
+ pi->path = KdSaveString (TsNames[i]);
+ break;
+ }
+ }
+ }
+ else {
+ fd = open (pi->path, 0);
+ }
+
+ if (fd < 0) {
+ ErrorF("TsInit: Couldn't open %s\n", pi->path);
+ return BadMatch;
+ }
+ close(fd);
+
+ pi->name = KdSaveString("H3600 Touchscreen");
+
+ return Success;
+}
+
+static Status
+TsEnable (KdPointerInfo *pi)
+{
+ int fd;
+
+ if (!pi || !pi->path)
+ return BadImplementation;
+
+ fd = open(pi->path, 0);
+
+ if (fd < 0) {
+ ErrorF("TsInit: Couldn't open %s\n", pi->path);
+ return BadMatch;
+ }
+
+ struct h3600_ts_calibration cal;
+ /*
+ * Check to see if this is a touch screen
+ */
+ if (ioctl (fd, TS_GET_CAL, &cal) != -1) {
+ mi->driverPrivate = (void *) fd;
+ if (!KdRegisterFd (fd, TsRead, (void *) mi)) {
+ close(fd);
+ return BadAlloc;
+ }
+ }
+ else {
+ ErrorF("TsEnable: %s is not a touchscreen\n", pi->path);
+ close (fd);
+ return BadMatch;
+ }
+
+ return Success;
+}
+
+static void
+TsFini (KdPointerInfo *pi)
+{
+ KdUnregisterFds (pi, (int)pi->driverPrivate, TRUE);
+ mi->driverPrivate = NULL;
+}
+
+KdPointerDriver TsDriver = {
+ TsInit,
+ TsEnable,
+ TsDisable,
+ TsFini,
+ NULL,
+};
diff --git a/xorg-server/hw/kdrive/linux/tslib.c b/xorg-server/hw/kdrive/linux/tslib.c
new file mode 100644
index 000000000..371aeced9
--- /dev/null
+++ b/xorg-server/hw/kdrive/linux/tslib.c
@@ -0,0 +1,193 @@
+/*
+ * TSLIB based touchscreen driver for KDrive
+ * Porting to new input API and event queueing by Daniel Stone.
+ * Derived from ts.c by Keith Packard
+ * Derived from ps2.c by Jim Gettys
+ *
+ * Copyright © 1999 Keith Packard
+ * Copyright © 2000 Compaq Computer Corporation
+ * Copyright © 2002 MontaVista Software Inc.
+ * Copyright © 2005 OpenedHand Ltd.
+ * Copyright © 2006 Nokia Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the authors and/or copyright holders
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. The authors and/or
+ * 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 AUTHORS AND/OR COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL THE AUTHORS AND/OR 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_KDRIVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+#define NEED_EVENTS
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xpoll.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "kdrive.h"
+#include <sys/ioctl.h>
+#include <tslib.h>
+#include <dirent.h>
+#include <linux/input.h>
+
+struct TslibPrivate {
+ int fd;
+ int lastx, lasty;
+ struct tsdev *tsDev;
+ void (*raw_event_hook)(int x, int y, int pressure, void *closure);
+ void *raw_event_closure;
+ int phys_screen;
+};
+
+
+static void
+TsRead (int fd, void *closure)
+{
+ KdPointerInfo *pi = closure;
+ struct TslibPrivate *private = pi->driverPrivate;
+ struct ts_sample event;
+ long x = 0, y = 0;
+ unsigned long flags;
+
+ if (private->raw_event_hook) {
+ while (ts_read_raw(private->tsDev, &event, 1) == 1)
+ private->raw_event_hook (event.x, event.y, event.pressure,
+ private->raw_event_closure);
+ return;
+ }
+
+ while (ts_read(private->tsDev, &event, 1) == 1) {
+ if (event.pressure) {
+ flags = KD_BUTTON_1;
+
+ /*
+ * Here we test for the touch screen driver actually being on the
+ * touch screen, if it is we send absolute coordinates. If not,
+ * then we send delta's so that we can track the entire vga screen.
+ */
+ if (KdCurScreen == private->phys_screen) {
+ x = event.x;
+ y = event.y;
+ } else {
+ flags |= KD_MOUSE_DELTA;
+ if ((private->lastx == 0) || (private->lasty == 0)) {
+ x = event.x;
+ y = event.y;
+ } else {
+ x = event.x - private->lastx;
+ y = event.y - private->lasty;
+ }
+ }
+ private->lastx = x;
+ private->lasty = y;
+ } else {
+ flags = 0;
+ x = private->lastx;
+ y = private->lasty;
+ }
+
+ KdEnqueuePointerEvent (pi, flags, x, y, event.pressure);
+ }
+}
+
+static Status
+TslibEnable (KdPointerInfo *pi)
+{
+ struct TslibPrivate *private = pi->driverPrivate;
+
+ private->raw_event_hook = NULL;
+ private->raw_event_closure = NULL;
+ private->tsDev = ts_open(pi->path, 0);
+ private->fd = ts_fd(private->tsDev);
+ if (!private->tsDev || ts_config(private->tsDev) || private->fd < 0) {
+ ErrorF("[tslib/TslibEnable] failed to open %s\n", pi->path);
+ if (private->fd >= 0)
+ close(private->fd);
+ return BadAlloc;
+ }
+
+ KdRegisterFd(private->fd, TsRead, pi);
+
+ return Success;
+}
+
+
+static void
+TslibDisable (KdPointerInfo *pi)
+{
+ struct TslibPrivate *private = pi->driverPrivate;
+
+ if (private->fd)
+ KdUnregisterFd(pi, private->fd, TRUE);
+
+ if (private->tsDev)
+ ts_close(private->tsDev);
+
+ private->fd = 0;
+ private->tsDev = NULL;
+}
+
+
+static Status
+TslibInit (KdPointerInfo *pi)
+{
+ int fd = 0, i = 0;
+ DIR *inputdir = NULL;
+ struct dirent *inputent = NULL;
+ struct tsdev *tsDev = NULL;
+ struct TslibPrivate *private = NULL;
+
+ if (!pi || !pi->dixdev)
+ return !Success;
+
+ pi->driverPrivate = (struct TslibPrivate *)
+ xcalloc(sizeof(struct TslibPrivate), 1);
+ if (!pi->driverPrivate)
+ return !Success;
+
+ private = pi->driverPrivate;
+ /* hacktastic */
+ private->phys_screen = 0;
+ pi->nAxes = 3;
+ pi->name = KdSaveString("Touchscreen");
+ pi->inputClass = KD_TOUCHSCREEN;
+
+ return Success;
+}
+
+
+static void
+TslibFini (KdPointerInfo *pi)
+{
+ if (pi->driverPrivate) {
+ xfree(pi->driverPrivate);
+ pi->driverPrivate = NULL;
+ }
+}
+
+
+KdPointerDriver TsDriver = {
+ "tslib",
+ TslibInit,
+ TslibEnable,
+ TslibDisable,
+ TslibFini,
+ NULL,
+};
diff --git a/xorg-server/hw/kdrive/mach64/Makefile.am b/xorg-server/hw/kdrive/mach64/Makefile.am
new file mode 100644
index 000000000..6ca376ab2
--- /dev/null
+++ b/xorg-server/hw/kdrive/mach64/Makefile.am
@@ -0,0 +1,43 @@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_CFLAGS@
+
+bin_PROGRAMS = Xmach64
+
+if TSLIB
+TSLIB_FLAG = -lts
+endif
+
+
+noinst_LIBRARIES = libmach64.a
+
+libmach64_a_SOURCES = \
+ mach64.c \
+ mach64draw.c \
+ mach64video.c \
+ mach64.h \
+ mach64draw.h
+
+Xmach64_SOURCES = \
+ mach64stub.c
+
+MACH64_LIBS = \
+ libmach64.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a
+
+
+if GLX
+Xmach64_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
+Xmach64_LDADD = \
+ $(MACH64_LIBS) \
+ @KDRIVE_LIBS@
+
+Xmach64_DEPENDENCIES = \
+ libmach64.a \
+ @KDRIVE_LOCAL_LIBS@
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/mach64/Makefile.in b/xorg-server/hw/kdrive/mach64/Makefile.in
new file mode 100644
index 000000000..f1dc13650
--- /dev/null
+++ b/xorg-server/hw/kdrive/mach64/Makefile.in
@@ -0,0 +1,719 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xmach64$(EXEEXT)
+subdir = hw/kdrive/mach64
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libmach64_a_AR = $(AR) $(ARFLAGS)
+libmach64_a_LIBADD =
+am_libmach64_a_OBJECTS = mach64.$(OBJEXT) mach64draw.$(OBJEXT) \
+ mach64video.$(OBJEXT)
+libmach64_a_OBJECTS = $(am_libmach64_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xmach64_OBJECTS = mach64stub.$(OBJEXT)
+Xmach64_OBJECTS = $(am_Xmach64_OBJECTS)
+Xmach64_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xmach64_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libmach64_a_SOURCES) $(Xmach64_SOURCES)
+DIST_SOURCES = $(libmach64_a_SOURCES) $(Xmach64_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_CFLAGS@
+
+@TSLIB_TRUE@TSLIB_FLAG = -lts
+noinst_LIBRARIES = libmach64.a
+libmach64_a_SOURCES = \
+ mach64.c \
+ mach64draw.c \
+ mach64video.c \
+ mach64.h \
+ mach64draw.h
+
+Xmach64_SOURCES = \
+ mach64stub.c
+
+MACH64_LIBS = \
+ libmach64.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a
+
+@GLX_TRUE@Xmach64_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xmach64_LDADD = \
+ $(MACH64_LIBS) \
+ @KDRIVE_LIBS@
+
+Xmach64_DEPENDENCIES = \
+ libmach64.a \
+ @KDRIVE_LOCAL_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/mach64/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/mach64/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libmach64.a: $(libmach64_a_OBJECTS) $(libmach64_a_DEPENDENCIES)
+ -rm -f libmach64.a
+ $(libmach64_a_AR) libmach64.a $(libmach64_a_OBJECTS) $(libmach64_a_LIBADD)
+ $(RANLIB) libmach64.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xmach64$(EXEEXT): $(Xmach64_OBJECTS) $(Xmach64_DEPENDENCIES)
+ @rm -f Xmach64$(EXEEXT)
+ $(Xmach64_LINK) $(Xmach64_OBJECTS) $(Xmach64_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mach64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mach64draw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mach64stub.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mach64video.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/mach64/mach64.c b/xorg-server/hw/kdrive/mach64/mach64.c
new file mode 100644
index 000000000..3c513ba17
--- /dev/null
+++ b/xorg-server/hw/kdrive/mach64/mach64.c
@@ -0,0 +1,433 @@
+/*
+ * Copyright © 2001 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "mach64.h"
+#include "kaa.h"
+
+static Bool
+mach64CardInit (KdCardInfo *card)
+{
+ Mach64CardInfo *mach64c;
+
+ mach64c = (Mach64CardInfo *) xalloc (sizeof (Mach64CardInfo));
+ if (!mach64c)
+ return FALSE;
+
+ (void) mach64MapReg (card, mach64c);
+ mach64c->lcdEnabled = FALSE;
+
+ if (!vesaInitialize (card, &mach64c->vesa))
+ {
+ xfree (mach64c);
+ return FALSE;
+ }
+
+ card->driver = mach64c;
+
+ return TRUE;
+}
+
+static Bool
+mach64ScreenInit (KdScreenInfo *screen)
+{
+ Mach64CardInfo *mach64c = screen->card->driver;
+ Mach64ScreenInfo *mach64s;
+
+ mach64s = (Mach64ScreenInfo *) xalloc (sizeof (Mach64ScreenInfo));
+ if (!mach64s)
+ return FALSE;
+ memset (mach64s, '\0', sizeof (Mach64ScreenInfo));
+ if (!vesaScreenInitialize (screen, &mach64s->vesa))
+ {
+ xfree (mach64s);
+ return FALSE;
+ }
+ if (!mach64c->reg)
+ screen->dumb = TRUE;
+ if (mach64s->vesa.mapping != VESA_LINEAR)
+ screen->dumb = TRUE;
+ switch (screen->fb[0].depth) {
+ case 8:
+ mach64s->colorKey = 0xff;
+ break;
+ case 15:
+ case 16:
+ mach64s->colorKey = 0x001e;
+ break;
+ case 24:
+ mach64s->colorKey = 0x0000fe;
+ break;
+ default:
+ mach64s->colorKey = 1;
+ break;
+ }
+ screen->driver = mach64s;
+ return TRUE;
+}
+
+static Bool
+mach64InitScreen (ScreenPtr pScreen)
+{
+#ifdef XV
+ mach64InitVideo(pScreen);
+#endif
+ return vesaInitScreen (pScreen);
+}
+
+#ifdef RANDR
+static Bool
+mach64RandRSetConfig (ScreenPtr pScreen,
+ Rotation rotation,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ kaaWaitSync (pScreen);
+
+ if (!vesaRandRSetConfig (pScreen, rotation, rate, pSize))
+ return FALSE;
+
+ return TRUE;
+}
+
+static void
+mach64RandRInit (ScreenPtr pScreen)
+{
+ rrScrPriv(pScreen);
+
+ pScrPriv->rrSetConfig = mach64RandRSetConfig;
+}
+#endif
+
+static Bool
+mach64FinishInitScreen (ScreenPtr pScreen)
+{
+ Bool ret;
+ ret = vesaFinishInitScreen (pScreen);
+#ifdef RANDR
+ mach64RandRInit (pScreen);
+#endif
+ return ret;
+}
+
+static Bool
+mach64CreateResources (ScreenPtr pScreen)
+{
+ return vesaCreateResources (pScreen);
+}
+
+CARD32
+mach64ReadLCD (Reg *reg, int id)
+{
+ CARD32 LCD_INDEX;
+
+ LCD_INDEX = reg->LCD_INDEX & ~(0x3f);
+ reg->LCD_INDEX = (LCD_INDEX | id);
+ return reg->LCD_DATA;
+}
+
+void
+mach64WriteLCD (Reg *reg, int id, CARD32 data)
+{
+ CARD32 LCD_INDEX;
+
+ LCD_INDEX = reg->LCD_INDEX & ~(0x3f);
+ reg->LCD_INDEX = (LCD_INDEX | id);
+ reg->LCD_DATA = data;
+}
+
+void
+mach64Preserve (KdCardInfo *card)
+{
+ Mach64CardInfo *mach64c = card->driver;
+ Reg *reg = mach64c->reg;
+
+ vesaPreserve(card);
+ if (reg)
+ {
+ mach64c->save.LCD_GEN_CTRL = mach64ReadLCD (reg, 1);
+ }
+}
+
+Bool
+mach64MapReg (KdCardInfo *card, Mach64CardInfo *mach64c)
+{
+ mach64c->reg_base = (CARD8 *) KdMapDevice (MACH64_REG_BASE(card),
+ MACH64_REG_SIZE(card));
+
+ if (!mach64c->reg_base)
+ {
+ mach64c->reg = 0;
+ mach64c->media_reg = 0;
+ return FALSE;
+ }
+
+ KdSetMappedMode (MACH64_REG_BASE(card),
+ MACH64_REG_SIZE(card),
+ KD_MAPPED_MODE_REGISTERS);
+ mach64c->reg = (Reg *) (mach64c->reg_base + MACH64_REG_OFF(card));
+ mach64c->media_reg = (MediaReg *) (mach64c->reg_base + MACH64_MEDIA_REG_OFF(card));
+ return TRUE;
+}
+
+void
+mach64UnmapReg (KdCardInfo *card, Mach64CardInfo *mach64c)
+{
+ if (mach64c->reg_base)
+ {
+ KdResetMappedMode (MACH64_REG_BASE(card),
+ MACH64_REG_SIZE(card),
+ KD_MAPPED_MODE_REGISTERS);
+ KdUnmapDevice ((void *) mach64c->reg_base, MACH64_REG_SIZE(card));
+ mach64c->reg_base = 0;
+ mach64c->reg = 0;
+ mach64c->media_reg = 0;
+ }
+}
+
+void
+mach64SetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c)
+{
+ if (!mach64c->reg_base)
+ mach64MapReg (card, mach64c);
+ if (mach64c->reg)
+ {
+ if (mach64c->reg->GUI_STAT == 0xffffffff)
+ FatalError ("Mach64 REG not visible\n");
+ }
+}
+
+void
+mach64ResetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c)
+{
+ mach64UnmapReg (card, mach64c);
+}
+
+Bool
+mach64Enable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ Mach64CardInfo *mach64c = pScreenPriv->card->driver;
+
+ if (!vesaEnable (pScreen))
+ return FALSE;
+
+ mach64SetMMIO (pScreenPriv->card, mach64c);
+ mach64DPMS (pScreen, KD_DPMS_NORMAL);
+#ifdef XV
+ KdXVEnable (pScreen);
+#endif
+ return TRUE;
+}
+
+void
+mach64Disable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ Mach64CardInfo *mach64c = pScreenPriv->card->driver;
+
+#ifdef XV
+ KdXVDisable (pScreen);
+#endif
+ mach64ResetMMIO (pScreenPriv->card, mach64c);
+ vesaDisable (pScreen);
+}
+
+const CARD8 mach64DPMSModes[4] = {
+ 0x80, /* KD_DPMS_NORMAL */
+ 0x8c, /* KD_DPMS_STANDBY */
+ 0x8c, /* KD_DPMS_STANDBY */
+ 0x8c, /* KD_DPMS_STANDBY */
+/* 0xb0, KD_DPMS_SUSPEND */
+/* 0xbc, KD_DPMS_POWERDOWN */
+};
+
+#define PWR_MGT_ON (1 << 0)
+#define PWR_MGT_MODE (3 << 1)
+#define PWR_MGT_MODE_PIN (0 << 1)
+#define PWR_MGT_MODE_REG (1 << 1)
+#define PWR_MGT_MODE_TIMER (2 << 1)
+#define PWR_MGR_MODE_PCI (3 << 1)
+#define AUTO_PWRUP_EN (1 << 3)
+#define ACTIVITY_PIN_ON (1 << 4)
+#define STANDBY_POL (1 << 5)
+#define SUSPEND_POL (1 << 6)
+#define SELF_REFRESH (1 << 7)
+#define ACTIVITY_PIN_EN (1 << 8)
+#define KEYBD_SNOOP (1 << 9)
+#define DONT_USE_F32KHZ (1 << 10)
+#define TRISTATE_MEM_EN (1 << 11)
+#define LCDENG_TEST_MODE (0xf << 12)
+#define STANDBY_COUNT (0xf << 16)
+#define SUSPEND_COUNT (0xf << 20)
+#define BIASON (1 << 24)
+#define BLON (1 << 25)
+#define DIGON (1 << 26)
+#define PM_D3_RST_ENB (1 << 27)
+#define STANDBY_NOW (1 << 28)
+#define SUSPEND_NOW (1 << 29)
+#define PWR_MGT_STATUS (3 << 30)
+#define PWR_MGT_STATUS_ON (0 << 30)
+#define PWR_MGT_STATUS_STANDBY (1 << 30)
+#define PWR_MGT_STATUS_SUSPEND (2 << 30)
+#define PWR_MGT_STATUS_TRANSITION (3 << 30)
+
+Bool
+mach64DPMS (ScreenPtr pScreen, int mode)
+{
+ KdScreenPriv(pScreen);
+ Mach64CardInfo *mach64c = pScreenPriv->card->driver;
+ int hsync_off = 0, vsync_off = 0, blank = 0;
+ CARD32 CRTC_GEN_CNTL;
+ CARD32 LCD_GEN_CTRL;
+ Reg *reg = mach64c->reg;
+
+ if (!reg)
+ return FALSE;
+
+ CRTC_GEN_CNTL = reg->CRTC_GEN_CNTL;
+ LCD_GEN_CTRL = mach64ReadLCD (reg, 1);
+
+ switch (mode) {
+ case KD_DPMS_NORMAL:
+ hsync_off = 0;
+ vsync_off = 0;
+ blank = 0;
+ break;
+ case KD_DPMS_STANDBY:
+ hsync_off = 1;
+ vsync_off = 0;
+ blank = 1;
+ break;
+ case KD_DPMS_SUSPEND:
+ hsync_off = 0;
+ vsync_off = 1;
+ blank = 1;
+ break;
+ case KD_DPMS_POWERDOWN:
+ hsync_off = 1;
+ vsync_off = 1;
+ blank = 1;
+ }
+
+ if (hsync_off)
+ CRTC_GEN_CNTL |= (1 << 2);
+ else
+ CRTC_GEN_CNTL &= ~(1 << 2);
+ if (vsync_off)
+ CRTC_GEN_CNTL |= (1 << 3);
+ else
+ CRTC_GEN_CNTL &= ~(1 << 3);
+ if (blank)
+ {
+ mach64c->lcdEnabled = (LCD_GEN_CTRL & (1 << 1)) != 0;
+ LCD_GEN_CTRL &= ~(1 << 1);
+ CRTC_GEN_CNTL |= (1 << 6);
+
+ }
+ else
+ {
+ if (!(LCD_GEN_CTRL & 3) || mach64c->lcdEnabled)
+ LCD_GEN_CTRL |= (1 << 1);
+ CRTC_GEN_CNTL &= ~(1 << 6);
+ }
+
+ kaaWaitSync (pScreen);
+
+ mach64WriteLCD (reg, 1, LCD_GEN_CTRL);
+
+ reg->CRTC_GEN_CNTL = CRTC_GEN_CNTL;
+ return TRUE;
+}
+
+static void
+mach64Restore (KdCardInfo *card)
+{
+ Mach64CardInfo *mach64c = card->driver;
+ Reg *reg = mach64c->reg;
+
+ if (reg)
+ {
+ mach64WriteLCD (reg, 1, mach64c->save.LCD_GEN_CTRL);
+ }
+ mach64ResetMMIO (card, mach64c);
+ vesaRestore (card);
+}
+
+static void
+mach64ScreenFini (KdScreenInfo *screen)
+{
+ Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
+#ifdef XV
+ mach64FiniVideo(screen->pScreen);
+#endif
+ vesaScreenFini (screen);
+ xfree (mach64s);
+ screen->driver = 0;
+}
+
+static void
+mach64CardFini (KdCardInfo *card)
+{
+ Mach64CardInfo *mach64c = card->driver;
+
+ mach64UnmapReg (card, mach64c);
+ vesaCardFini (card);
+ xfree (mach64c);
+}
+
+#define mach64CursorInit 0 /* initCursor */
+#define mach64CursorEnable 0 /* enableCursor */
+#define mach64CursorDisable 0 /* disableCursor */
+#define mach64CursorFini 0 /* finiCursor */
+#define mach64RecolorCursor 0 /* recolorCursor */
+
+KdCardFuncs mach64Funcs = {
+ mach64CardInit, /* cardinit */
+ mach64ScreenInit, /* scrinit */
+ mach64InitScreen, /* initScreen */
+ mach64FinishInitScreen, /* finishInitScreen */
+ mach64CreateResources, /* createRes */
+ mach64Preserve, /* preserve */
+ mach64Enable, /* enable */
+ mach64DPMS, /* dpms */
+ mach64Disable, /* disable */
+ mach64Restore, /* restore */
+ mach64ScreenFini, /* scrfini */
+ mach64CardFini, /* cardfini */
+
+ mach64CursorInit, /* initCursor */
+ mach64CursorEnable, /* enableCursor */
+ mach64CursorDisable, /* disableCursor */
+ mach64CursorFini, /* finiCursor */
+ mach64RecolorCursor, /* recolorCursor */
+
+ mach64DrawInit, /* initAccel */
+ mach64DrawEnable, /* enableAccel */
+ mach64DrawDisable, /* disableAccel */
+ mach64DrawFini, /* finiAccel */
+
+ vesaGetColors, /* getColors */
+ vesaPutColors, /* putColors */
+};
diff --git a/xorg-server/hw/kdrive/mach64/mach64.h b/xorg-server/hw/kdrive/mach64/mach64.h
new file mode 100644
index 000000000..fbb10b2ba
--- /dev/null
+++ b/xorg-server/hw/kdrive/mach64/mach64.h
@@ -0,0 +1,653 @@
+/*
+ * Copyright © 2001 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _MACH64_H_
+#define _MACH64_H_
+#include <vesa.h>
+#include "kxv.h"
+
+/*
+ * offset from ioport beginning
+ */
+
+#define MACH64_REG_BASE(c) ((c)->attr.address[1])
+#define MACH64_REG_SIZE(c) (4096)
+
+#define MACH64_REG_OFF(c) (1024)
+#define MACH64_MEDIA_REG_OFF(c) (0)
+
+typedef volatile CARD8 VOL8;
+typedef volatile CARD16 VOL16;
+typedef volatile CARD32 VOL32;
+
+typedef struct _Reg {
+ VOL32 CRTC_H_TOTAL_DISP; /* 0x00 */
+ VOL32 CRTC_H_SYNC_STRT_WID; /* 0x01 */
+ VOL32 CRTC_V_TOTAL_DISP; /* 0x02 */
+ VOL32 CRTC_V_SYNC_STRT_WID; /* 0x03 */
+ VOL32 CRTC_VLINE_CRNT_VLINE; /* 0x04 */
+ VOL32 CRTC_OFF_PITCH; /* 0x05 */
+ VOL32 CRTC_INT_CNTL; /* 0x06 */
+ VOL32 CRTC_GEN_CNTL; /* 0x07 */
+ VOL32 DSP_CONFIG; /* 0x08 */
+ VOL32 DSP_ON_OFF; /* 0x09 */
+ VOL32 TIMER_CONFIG; /* 0x0a */
+ VOL32 MEM_BUF_CNTL; /* 0x0b */
+ VOL32 unused0; /* 0x0c */
+ VOL32 MEM_ADDR_CONFIG; /* 0x0d */
+ VOL32 CRT_TRAP; /* 0x0e */
+ VOL32 I2C_CNTL_0; /* 0x0f */
+ VOL32 OVR_CLR; /* 0x10 */
+ VOL32 OVR_WID_LEFT_RIGHT; /* 0x11 */
+ VOL32 OVR_WID_TOP_BOTTOM; /* 0x12 */
+ VOL32 VGA_DSP_CONFIG; /* 0x13 */
+ VOL32 VGA_DSP_ON_OFF; /* 0x14 */
+ VOL32 DSP2_CONFIG; /* 0x15 */
+ VOL32 DSP2_ON_OFF; /* 0x16 */
+ VOL32 CRTC2_OFF_PITCH; /* 0x17 */
+ VOL32 CUR_CLR0; /* 0x18 */
+ VOL32 CUR_CLR1; /* 0x19 */
+ VOL32 CUR_OFFSET; /* 0x1a */
+ VOL32 CUR_HORZ_VERT_POSN; /* 0x1b */
+ VOL32 CUR_HORZ_VERT_OFF; /* 0x1c */
+ VOL32 TV_OUT_INDEX; /* 0x1d */
+ VOL32 GP_IO; /* 0x1e */
+ VOL32 HW_DEBUG; /* 0x1f */
+ VOL32 SCRATCH_REG0; /* 0x20 */
+ VOL32 SCRATCH_REG1;
+ VOL32 SCRATCH_REG2;
+ VOL32 SCRATCH_REG3;
+ VOL32 CLOCK_CNTL;
+ VOL32 CONFIG_STAT1;
+ VOL32 CONFIG_STAT2;
+ VOL32 TV_OUT_DATA;
+ VOL32 BUS_CNTL; /* 0x28 */
+ VOL32 LCD_INDEX; /* 0x29 */
+ VOL32 LCD_DATA; /* 0x2a */
+ VOL32 EXT_MEM_CNTL;
+ VOL32 MEM_CNTL;
+ VOL32 MEM_VGA_WP_SEL;
+ VOL32 MEM_VGA_RP_SEL;
+ VOL32 I2C_CNTL_1;
+ VOL32 DAC_REGS; /* 0x30 */
+ VOL32 DAC_CNTL; /* 0x31 */
+ VOL32 unused_32;
+ VOL32 unused_33;
+ VOL32 GEN_TEST_CNTL; /* 0x34 */
+ VOL32 CUSTOM_MACRO_CNTL;
+ VOL32 unused36;
+ VOL32 CONFIG_CNTL;
+ VOL32 CONFIG_CHIP_ID;
+ VOL32 CONFIG_STAT0;
+ VOL32 CRC_SIG;
+ VOL32 unused_3b;
+ VOL32 unused_3c;
+ VOL32 unused_3d;
+ VOL32 unused_3e;
+ VOL32 unused_3f;
+ VOL32 DST_OFF_PITCH; /* 0x40 */
+ VOL32 DST_X;
+ VOL32 DST_Y;
+ VOL32 DST_Y_X;
+ VOL32 DST_WIDTH;
+ VOL32 DST_HEIGHT;
+ VOL32 DST_HEIGHT_WIDTH;
+ VOL32 DST_X_WIDTH;
+ VOL32 DST_BRES_LNTH;
+ VOL32 DST_BRES_ERR;
+ VOL32 DST_BRES_INC;
+ VOL32 DST_BRES_DEC;
+ VOL32 DST_CNTL;
+ VOL32 DST_Y_X_ALIAS;
+ VOL32 TRAIL_BRES_ERR;
+ VOL32 TRAIL_BRES_INC;
+ VOL32 TRAIL_BRES_DEC;
+ VOL32 LEAD_BRES_LNTH;
+ VOL32 Z_OFF_PITCH;
+ VOL32 Z_CNTL;
+ VOL32 ALPHA_TST_CNTL;
+ VOL32 unused55;
+ VOL32 SECONDARY_STW_EXP;
+ VOL32 SECONDARY_S_X_INC;
+ VOL32 SECONDARY_S_Y_INC;
+ VOL32 SECONDARY_S_START;
+ VOL32 SECONDARY_W_X_INC;
+ VOL32 SECONDARY_W_Y_INC;
+ VOL32 SECONDARY_W_START;
+ VOL32 SECONDARY_T_X_INC;
+ VOL32 SECONDARY_T_Y_INC;
+ VOL32 SECONDARY_T_START;
+ VOL32 SRC_OFF_PITCH;
+ VOL32 SRC_X;
+ VOL32 SRC_Y;
+ VOL32 SRC_Y_X;
+ VOL32 SRC_WIDTH1;
+ VOL32 SRC_HEIGHT1;
+ VOL32 SRC_HEIGHT1_WIDTH1;
+ VOL32 SRC_X_START;
+ VOL32 SRC_Y_START;
+ VOL32 SRC_Y_X_START;
+ VOL32 SRC_WIDTH2;
+ VOL32 SRC_HEIGHT2;
+ VOL32 SRC_HEIGHT2_WIDTH2;
+ VOL32 SRC_CNTL;
+ VOL32 unused6e;
+ VOL32 unused6f;
+ union {
+ struct {
+ VOL32 SCALE_OFF; /* 0x70 */
+ VOL32 unused71;
+ VOL32 unused72;
+ VOL32 unused73;
+ VOL32 unused74;
+ VOL32 unused75;
+ VOL32 unused76;
+ VOL32 SCALE_WIDTH;
+ VOL32 SCALE_HEIGHT;
+ VOL32 unused79;
+ VOL32 unused7a;
+ VOL32 SCALE_PITCH;
+ VOL32 SCALE_X_INC;
+ VOL32 SCALE_Y_INC;
+ VOL32 SCALE_VACC;
+ VOL32 SCALE_3D_CNTL; /* 0x7f */
+ } scaler;
+ struct {
+ VOL32 TEX_0_OFF; /* 0x70 */
+ VOL32 TEX_1_OFF;
+ VOL32 TEX_2_OFF;
+ VOL32 TEX_3_OFF;
+ VOL32 TEX_4_OFF;
+ VOL32 TEX_5_OFF;
+ VOL32 TEX_6_OFF;
+ VOL32 TEX_7_OFF;
+ VOL32 TEX_8_OFF;
+ VOL32 TEX_9_OFF;
+ VOL32 TEX_10_OFF;
+ VOL32 S_Y_INC;
+ VOL32 RED_X_INC;
+ VOL32 GREEN_X_INC; /* 0x7d */
+ VOL32 unused7e;
+ VOL32 unused7f;
+ } texture;
+ } u;
+ VOL32 HOST_DATA[16]; /* 0x80 */
+ VOL32 HOST_CNTL; /* 0x90 */
+ VOL32 BM_HOSTDATA; /* 0x91 */
+ VOL32 BM_ADDR; /* 0x92 */
+ VOL32 BM_GUI_TABLE_CMD; /* 0x93 */
+ VOL32 unused94; /* 0x94 */
+ VOL32 unused95; /* 0x95 */
+ VOL32 unused96; /* 0x96 */
+ VOL32 FOG_TABLE_INDEX; /* 0x97 */
+ VOL32 FOG_TABLE_DATA[8]; /* 0x98 */
+ VOL32 PAT_REG0; /* 0xa0 */
+ VOL32 PAT_REG1;
+ VOL32 PAT_CNTL;
+ VOL32 unused_0a3;
+ VOL32 unused_0a4;
+ VOL32 unused_0a5;
+ VOL32 unused_0a6;
+ VOL32 unused_0a7;
+ VOL32 SC_LEFT;
+ VOL32 SC_RIGHT;
+ VOL32 SC_LEFT_RIGHT;
+ VOL32 SC_TOP;
+ VOL32 SC_BOTTOM;
+ VOL32 SC_TOP_BOTTOM;
+ VOL32 USR1_DST_OFF_PITCH;
+ VOL32 USR2_DST_OFF_PITCH;
+ VOL32 DP_BKGD_CLR; /* 0xb0 */
+ VOL32 DP_FRGD_CLR;
+ VOL32 DP_WRITE_MSK;
+ VOL32 unused_0b3;
+ VOL32 DP_PIX_WIDTH;
+ VOL32 DP_MIX;
+ VOL32 DP_SRC;
+ VOL32 DP_FRGD_CLR_MIX;
+ VOL32 DP_FRGD_BKGD_CLR;
+ VOL32 unused_0b9;
+ VOL32 DST_X_Y;
+ VOL32 DST_WIDTH_HEIGHT;
+ VOL32 USR_DST_PITCH;
+ VOL32 unused_0bd;
+ VOL32 DP_SET_GUI_ENGINE2;
+ VOL32 DP_SET_GUI_ENGINE;
+ VOL32 CLR_CMP_CLR; /* 0xc0 */
+ VOL32 CLR_CMP_MSK;
+ VOL32 CLR_CMP_CNTL;
+ VOL32 unused_0c3;
+ VOL32 FIFO_STAT;
+ VOL32 unused_0c5;
+ VOL32 unused_0c6;
+ VOL32 unused_0c7;
+ VOL32 unused_0c8;
+ VOL32 unused_0c9;
+ VOL32 unused_0ca;
+ VOL32 unused_0cb;
+ VOL32 GUI_TRAJ_CNTL;
+ VOL32 unused_0cd;
+ VOL32 GUI_STAT;
+ VOL32 unused_0cf;
+ VOL32 TEX_PALETTE_INDEX;
+ VOL32 STW_EXP;
+ VOL32 LOG_MAX_INC;
+ VOL32 S_X_INC;
+ VOL32 S_Y_INC_2_SCALE_PITCH;
+ VOL32 S_START;
+ VOL32 W_X_INC;
+ VOL32 W_Y_INC;
+ VOL32 W_START;
+ VOL32 T_X_INC;
+ VOL32 T_Y_INC_SECONDARY_SCALE_PITCH;
+ VOL32 T_START;
+ VOL32 TEX_SIZE_PITCH;
+ VOL32 TEX_CNTL;
+ VOL32 SECONDARY_TEX_OFFSET_SECONDARY_SCALE_OFF;
+ VOL32 TEX_PALETTE;
+ VOL32 SCALE_PITCH_BOTH; /* 0xe0 */
+ VOL32 SECONDARY_SCALE_OFF_ACC;
+ VOL32 SCALE_OFF_ACC;
+ VOL32 SCALE_DST_Y_X;
+ VOL32 unused_0e4;
+ VOL32 unused_0e5;
+ VOL32 COMPOSITE_SHADOW_ID;
+ VOL32 SECONDARY_SCALE_X_INC_SPECULAR_RED_X_INC;
+ VOL32 SPECULAR_RED_Y_INC;
+ VOL32 SPECULAR_RED_START_SECONDARY_SCALE_HACC;;
+ VOL32 SPECULAR_GREEN_X_INC;
+ VOL32 SPECULAR_GREEN_Y_INC;
+ VOL32 SPECULAR_GREEN_START;
+ VOL32 SPECULAR_BLUE_X_INC;
+ VOL32 SPECULAR_BLUE_Y_INC;
+ VOL32 SPECULAR_BLUE_START;
+ VOL32 RED_X_INC_SCALE_X_INC;
+ VOL32 RED_Y_INC;
+ VOL32 RED_START_SCALE_HACC;
+ VOL32 GREEN_X_INC_SCALE_Y_INC;
+ VOL32 GREEN_Y_INC_SECONDARY_SCALE_Y_INC;
+ VOL32 GREEN_START_SECONDARY_SCALE_VACC;
+ VOL32 BLUE_X_INC;
+ VOL32 BLUE_Y_INC;
+ VOL32 BLUE_START;
+ VOL32 Z_X_INC;
+ VOL32 Z_Y_INC;
+ VOL32 Z_START;
+ VOL32 ALPHA_X_INC;
+ VOL32 FOG_X_INC;
+ VOL32 ALPHA_Y_INC;
+ VOL32 FOG_Y_INC;
+ VOL32 ALPHA_START;
+ VOL32 FOG_START;
+ VOL32 unused_0ff;
+} Reg; /* 0x100 */
+
+#define DST_X_DIR (1 << 0)
+#define DST_Y_DIR (1 << 1)
+#define DST_Y_MAJOR (1 << 2)
+#define DST_X_TILE (1 << 3)
+#define DST_Y_TILE (1 << 4)
+#define DST_LAST_PEL (1 << 5)
+#define DST_POLYGON_EN (1 << 6)
+#define DST_24_ROT_EN (1 << 7)
+#define DST_24_ROT(n) ((n) << 8)
+#define DST_BRES_ZERO (1 << 11)
+#define DST_POLYGON_RTEDGE_DIS (1 << 12)
+#define TRAIL_X_DIR (1 << 13)
+#define TRAP_FILL_DIR (1 << 14)
+#define TRAIL_BRES_SIGN (1 << 15)
+#define SRC_PATT_EN (1 << 16)
+#define SRC_PATT_ROT_EN (1 << 17)
+#define SRC_LINEAR_EN (1 << 18)
+#define SRC_BYTE_ALIGN (1 << 19)
+#define SRC_LINE_X_DIR (1 << 20)
+#define SRC_8x8x8_BRUSH (1 << 21)
+#define FAST_FILL_EN (1 << 22)
+#define SRC_TRACK_DST (1 << 23)
+#define PAT_MONO_EN (1 << 24)
+#define PAT_CLR_4x2_EN (1 << 25)
+#define PAT_CLR_8x1_EN (1 << 26)
+#define HOST_BYTE_ALIGN (1 << 28)
+#define HOST_BIG_ENDIAN_EN (1 << 29)
+
+/* BUS_CNTL bits */
+#define BUS_DBL_RESYNC (1 << 0)
+#define BUS_MSTR_RESET (1 << 1)
+#define BUS_FLUSH_BUF (1 << 2)
+#define BUS_STOP_REQ_DIS (1 << 3)
+#define BUS_APER_REG_DIS (1 << 4)
+#define BUS_EXTRA_PIPE_DIS (1 << 5)
+#define BUS_MASTER_DIS (1 << 6)
+#define ROM_WRT_EN (1 << 7)
+#define CHIP_HIDDEN_REV (3 << 8)
+#define BUS_PCI_READ_RETRY_EN (1 << 13)
+#define BUS_PCI_WRT_RETRY_EN (1 << 15)
+#define BUS_RETRY_WS (0xf << 16)
+#define BUS_MSTR_RD_MULT (1 << 20)
+#define BUS_MSTR_RD_LINE (1 << 21)
+#define BUS_SUSPEND (1 << 22)
+#define LAT16X (1 << 23)
+#define BUS_RD_DISCARD_EN (1 << 24)
+#define BUS_RD_ABORT_EN (1 << 25)
+#define BUS_MSTR_WS (1 << 26)
+#define BUS_EXT_REG_EN (1 << 27)
+#define BUS_MSTR_DISCONNECT_EN (1 << 28)
+#define BUS_WRT_BURST (1 << 29)
+#define BUS_READ_BURST (1 << 30)
+#define BUS_RDY_READ_DLY (1 << 31)
+
+#define SCALE_PIX_EXPAND (1 << 0)
+#define SCALE_Y2R_TEMP (1 << 1)
+#define SCALE_HORZ_MODE (1 << 2)
+#define SCALE_VERT_MODE (1 << 3)
+#define SCALE_SIGNED_UV (1 << 4)
+#define SCALE_GAMMA_SEL (3 << 5)
+#define SCALE_GAMMA_BRIGHT (0 << 5)
+#define SCALE_GAMMA_22 (1 << 5)
+#define SCALE_GAMMA_18 (2 << 5)
+#define SCALE_GAMMA_14 (3 << 5)
+#define SCALE_DISP_SEL (1 << 7)
+#define SCALE_BANDWIDTH (1 << 26)
+#define SCALE_DIS_LIMIT (1 << 27)
+#define SCALE_CLK_FORCE_ON (1 << 29)
+#define SCALE_OVERLAY_EN (1 << 30)
+#define SCALE_EN (1 << 31)
+
+#define VIDEO_IN_VYUY422 (0xb)
+#define VIDEO_IN_YVYU422 (0xc)
+#define SCALER_IN_15bpp (0x3 << 16)
+#define SCALER_IN_16bpp (0x4 << 16)
+#define SCALER_IN_32bpp (0x6 << 16)
+#define SCALER_IN_YUV_9 (0x9 << 16)
+#define SCALER_IN_YUV_12 (0xa << 16)
+#define SCALER_IN_VYUY422 (0xb << 16)
+#define SCALER_IN_YVYU422 (0xc << 16)
+
+#define CAP_INPUT_MODE (1 << 0)
+#define CAP_BUF_MODE (1 << 2)
+#define CAP_START_BUF (1 << 3)
+#define CAP_BUF_TYPE_FIELD (0 << 4)
+#define CAP_BUF_TYPE_ALTERNATING (1 << 4)
+#define CAP_BUF_TYPE_FRAME (2 << 4)
+
+#define OVL_BUF_MODE (1 << 28)
+#define OVL_BUF_NEXT (1 << 29)
+
+#define CAP_TRIGGER (3 << 0)
+#define OVL_CUR_BUF (1 << 5)
+#define OVL_BUF_STATUS (1 << 6)
+#define CAP_BUF_STATUS (1 << 7)
+#define CAPTURE_EN (1 << 31)
+
+typedef struct _MediaReg {
+ VOL32 OVERLAY_Y_X_START; /* 0x100 */
+ VOL32 OVERLAY_Y_X_END;
+ VOL32 OVERLAY_VIDEO_KEY_CLR;
+ VOL32 OVERLAY_VIDEO_KEY_MSK;
+ VOL32 OVERLAY_GRAPHICS_KEY_CLR;
+ VOL32 OVERLAY_GRAPHICS_KEY_MSK;
+ VOL32 OVERLAY_KEY_CNTL;
+ VOL32 unused_107;
+ VOL32 OVERLAY_SCALE_INC;
+ VOL32 OVERLAY_SCALE_CNTL;
+ VOL32 SCALER_HEIGHT_WIDTH;
+ VOL32 SCALER_TEST;
+ VOL32 unused_10c;
+ VOL32 SCALER_BUF0_OFFSET;
+ VOL32 SCALER_BUF1_OFFSET;
+ VOL32 SCALER_BUF_PITCH;
+ VOL32 CAPTURE_START_END; /* 0x110 */
+ VOL32 CAPTURE_X_WIDTH;
+ VOL32 VIDEO_FORMAT;
+ VOL32 VBI_START_END;
+ VOL32 CAPTURE_CONFIG;
+ VOL32 TRIG_CNTL;
+ VOL32 OVERLAY_EXCLUSIVE_HORZ;
+ VOL32 OVERLAY_EXCLUSIVE_VERT;
+ VOL32 VBI_WIDTH;
+ VOL32 CAPTURE_DEBUG;
+ VOL32 VIDEO_SYNC_TEST;
+ VOL32 unused_11b;
+ VOL32 SNAPSHOT_VH_COUNTS;
+ VOL32 SNAPSHOT_F_COUNT;
+ VOL32 N_VIF_COUNT;
+ VOL32 SNAPSHOT_VIF_COUNT;
+ VOL32 CAPTURE_BUF0_OFFSET; /* 0x120 */
+ VOL32 CAPTURE_BUF1_OFFSET;
+ VOL32 ONESHOT_BUF_OFFSET;
+ VOL32 unused_123;
+ VOL32 unused_124;
+ VOL32 unused_125;
+ VOL32 unused_126;
+ VOL32 unused_127;
+ VOL32 unused_128;
+ VOL32 unused_129;
+ VOL32 unused_12a;
+ VOL32 unused_12b;
+ VOL32 SNAPSHOT2_VH_COUNTS;
+ VOL32 SNAPSHOT2_F_COUNT;
+ VOL32 N_VIF2_COUNT;
+ VOL32 SNAPSHOT2_VIF_COUNT;
+ VOL32 MPP_CONFIG; /* 0x130 */
+ VOL32 MPP_STROBE_SEQ;
+ VOL32 MPP_ADDR;
+ VOL32 MPP_DATA;
+ VOL32 unused_134;
+ VOL32 unused_135;
+ VOL32 unused_136;
+ VOL32 unused_137;
+ VOL32 unused_138;
+ VOL32 unused_139;
+ VOL32 unused_13a;
+ VOL32 unused_13b;
+ VOL32 unused_13c;
+ VOL32 unused_13d;
+ VOL32 unused_13e;
+ VOL32 unused_13f;
+ VOL32 TVO_CNTL; /* 0x140 */
+ VOL32 unused_141[15];
+ VOL32 unused_150; /* 0x150 */
+ VOL32 CRT_HORZ_VERT_LOAD; /* 0x151 */
+ VOL32 AGP_BASE; /* 0x152 */
+ VOL32 AGP_CNTL; /* 0x153 */
+ VOL32 SCALER_COLOUR_CNTL; /* 0x154 */
+ VOL32 SCALER_H_COEFF0; /* 0x155 */
+ VOL32 SCALER_H_COEFF1; /* 0x156 */
+ VOL32 SCALER_H_COEFF2; /* 0x157 */
+ VOL32 SCALER_H_COEFF3; /* 0x158 */
+ VOL32 SCALER_H_COEFF4; /* 0x159 */
+ VOL32 unused_15a;
+ VOL32 unused_15b;
+ VOL32 GUI_CMDFIFO_DEBUG;
+ VOL32 GUI_CMDFIFO_DATA;
+ VOL32 GUI_CNTL;
+ VOL32 unused_15f;
+ VOL32 BM_FRAME_BUF_OFFSET; /* 0x160 */
+ VOL32 BM_SYSTEM_MEM_ADDR;
+ VOL32 BM_COMMAND;
+ VOL32 BM_STATUS;
+ VOL32 unused_164[10];
+ VOL32 BM_GUI_TABLE;
+ VOL32 BM_SYSTEM_TABLE;
+ VOL32 unused_170[5]; /* 0x170 */
+ VOL32 SCALER_BUF0_OFFSET_U;
+ VOL32 SCALER_BUF0_OFFSET_V;
+ VOL32 SCALER_BUF1_OFFSET_U;
+ VOL32 SCALER_BUF1_OFFSET_V;
+ VOL32 unused_179[7];
+ VOL32 unused_180[16]; /* 0x180 */
+ VOL32 setup_engine[0x40]; /* 0x190 */
+ VOL32 dvd_subpicture[0x30]; /* 0x1d0 */
+} MediaReg;
+
+#define MACH64_XY(x,y) (((x) & 0x7fff) | (((y) & 0x7fff) << 16))
+#define MACH64_YX(x,y) (((y) & 0x7fff) | (((x) & 0x7fff) << 16))
+
+typedef struct _mach64Save {
+ CARD32 LCD_GEN_CTRL;
+} Mach64Save;
+
+typedef struct _mach64CardInfo {
+ VesaCardPrivRec vesa;
+ CARD8 *reg_base;
+ Reg *reg;
+ MediaReg *media_reg;
+ Mach64Save save;
+ Bool lcdEnabled;
+} Mach64CardInfo;
+
+#define getMach64CardInfo(kd) ((Mach64CardInfo *) ((kd)->card->driver))
+#define mach64CardInfo(kd) Mach64CardInfo *mach64c = getMach64CardInfo(kd)
+
+typedef struct _mach64Cursor {
+ int width, height;
+ int xhot, yhot;
+ Bool has_cursor;
+ CursorPtr pCursor;
+ Pixel source, mask;
+} Mach64Cursor;
+
+#define MACH64_CURSOR_WIDTH 64
+#define MACH64_CURSOR_HEIGHT 64
+
+/*
+ * Xv information, optional
+ */
+typedef struct _mach64PortPriv {
+ CARD32 YBuf0Offset;
+
+ CARD32 YBuf1Offset;
+
+ CARD8 currentBuf;
+
+ int brightness;
+ int saturation;
+
+ RegionRec clip;
+ CARD32 colorKey;
+
+ Bool videoOn;
+ Time offTime;
+ Time freeTime;
+ CARD32 size;
+ CARD32 offset;
+ KdOffscreenArea *off_screen;
+} Mach64PortPrivRec, *Mach64PortPrivPtr;
+
+Bool mach64InitVideo(ScreenPtr pScreen);
+void mach64FiniVideo(ScreenPtr pScreen);
+
+/*
+ * These values are per-format, which is essentially per-depth/per-bpp.
+ * Because bpp is fixed for the screen by depth, they're computed
+ * per-screen per-depth.
+ */
+
+typedef struct _mach64ScreenInfo {
+ VesaScreenPrivRec vesa;
+ Mach64Cursor cursor;
+ CARD32 colorKey;
+ KdVideoAdaptorPtr pAdaptor;
+ KaaScreenInfoRec kaa;
+} Mach64ScreenInfo;
+
+#define getMach64ScreenInfo(kd) ((Mach64ScreenInfo *) ((kd)->screen->driver))
+#define mach64ScreenInfo(kd) Mach64ScreenInfo *mach64s = getMach64ScreenInfo(kd)
+
+CARD32
+mach64ReadLCD (Reg *reg, int id);
+
+void
+mach64WriteLCD (Reg *reg, int id, CARD32 data);
+
+void
+mach64Preserve (KdCardInfo *card);
+
+Bool
+mach64MapReg (KdCardInfo *card, Mach64CardInfo *mach64c);
+
+void
+mach64UnmapReg (KdCardInfo *card, Mach64CardInfo *mach64c);
+
+void
+mach64SetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c);
+
+void
+mach64ResetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c);
+
+Bool
+mach64Enable (ScreenPtr pScreen);
+
+void
+mach64Disable (ScreenPtr pScreen);
+
+Bool
+mach64DPMS (ScreenPtr pScreen, int mode);
+
+void
+mach64WaitAvail(Reg *reg, int n);
+
+void
+mach64WaitIdle (Reg *reg);
+
+Bool
+mach64DrawSetup (ScreenPtr pScreen);
+
+Bool
+mach64DrawInit (ScreenPtr pScreen);
+
+void
+mach64DrawReinit (ScreenPtr pScreen);
+
+void
+mach64DrawEnable (ScreenPtr pScreen);
+
+void
+mach64DrawDisable (ScreenPtr pScreen);
+
+void
+mach64DrawFini (ScreenPtr pScreen);
+
+CARD8
+mach64ReadIndex (Mach64CardInfo *mach64c, CARD16 port, CARD8 index);
+
+void
+mach64WriteIndex (Mach64CardInfo *mach64c, CARD16 port, CARD8 index, CARD8 value);
+
+Bool
+mach64CursorInit (ScreenPtr pScreen);
+
+void
+mach64CursorEnable (ScreenPtr pScreen);
+
+void
+mach64CursorDisable (ScreenPtr pScreen);
+
+void
+mach64CursorFini (ScreenPtr pScreen);
+
+void
+mach64RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef);
+
+extern KdCardFuncs mach64Funcs;
+
+#endif /* _MACH64_H_ */
diff --git a/xorg-server/hw/kdrive/mach64/mach64draw.c b/xorg-server/hw/kdrive/mach64/mach64draw.c
new file mode 100644
index 000000000..15d4d417a
--- /dev/null
+++ b/xorg-server/hw/kdrive/mach64/mach64draw.c
@@ -0,0 +1,590 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "mach64.h"
+#include "mach64draw.h"
+
+#include <X11/Xmd.h>
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mistruct.h"
+#include "dixfontstr.h"
+#include "fb.h"
+#include "migc.h"
+#include "miline.h"
+#include "picturestr.h"
+#include "kaa.h"
+
+CARD8 mach64Rop[16] = {
+ /* GXclear */ 0x01, /* 0 */
+ /* GXand */ 0x0c, /* src AND dst */
+ /* GXandReverse */ 0x0d, /* src AND NOT dst */
+ /* GXcopy */ 0x07, /* src */
+ /* GXandInverted*/ 0x0e, /* NOT src AND dst */
+ /* GXnoop */ 0x03, /* dst */
+ /* GXxor */ 0x05, /* src XOR dst */
+ /* GXor */ 0x0b, /* src OR dst */
+ /* GXnor */ 0x0f, /* NOT src AND NOT dst */
+ /* GXequiv */ 0x06, /* NOT src XOR dst */
+ /* GXinvert */ 0x00, /* NOT dst */
+ /* GXorReverse */ 0x0a, /* src OR NOT dst */
+ /* GXcopyInverted*/ 0x04, /* NOT src */
+ /* GXorInverted */ 0x09, /* NOT src OR dst */
+ /* GXnand */ 0x08, /* NOT src OR NOT dst */
+ /* GXset */ 0x02, /* 1 */
+};
+
+#define MACH64_DRAW_COMBO_SOLID 0x1
+#define MACH64_DRAW_COMBO_COPY 0x8
+
+#define SYNC_ALWAYS 0
+static Reg *reg;
+static CARD32 avail;
+static CARD32 triple;
+
+#define IDX(reg,n) (&(reg)->n - &(reg)->CRTC_H_TOTAL_DISP)
+
+void
+mach64WaitAvail(Reg *reg, int n)
+{
+ if (avail < n)
+ {
+ while ((avail = ((reg->GUI_STAT) >> 16) & 0x3ff) < n)
+ ;
+ }
+ avail -= n;
+}
+
+void
+mach64WaitIdle (Reg *reg)
+{
+ while (reg->GUI_STAT & 1)
+ ;
+}
+
+#define PIX_FORMAT_MONO 0
+#define PIX_FORMAT_PSEUDO_8 2
+#define PIX_FORMAT_TRUE_1555 3
+#define PIX_FORMAT_TRUE_565 4
+#define PIX_FORMAT_TRUE_8888 6
+#define PIX_FORMAT_TRUE_332 7
+#define PIX_FORMAT_GRAY_8 8
+#define PIX_FORMAT_YUV_422 0xb
+#define PIX_FORMAT_YUV_444 0xe
+#define PIX_FORMAT_TRUE_4444 0xf
+
+typedef struct _mach64AccelReg {
+ int depth;
+ int bitsPerPixel;
+ CARD32 DP_PIX_WIDTH;
+ CARD32 DP_SET_GUI_ENGINE;
+} Mach64AccelReg;
+
+static const Mach64AccelReg mach64AccelReg[] = {
+ { 1, 1,
+ /* DP_PIX_WIDTH */
+ ((PIX_FORMAT_MONO << 0) | /* DP_DST_PIX_WIDTH */
+ (PIX_FORMAT_MONO << 4) | /* COMPOSITE_PIX_WIDTH */
+ (PIX_FORMAT_MONO << 8) | /* DP_SRC_PIX_WIDTH */
+ (0 << 13) | /* DP_HOST_TRIPLE_EN */
+ (0 << 14) | /* DP_PALETTE_TYPE */
+ (PIX_FORMAT_MONO << 16) | /* DP_HOST_PIX_WIDTH */
+ (0 << 20) | /* DP_C14_RGB_INDEX */
+ (0 << 24) | /* DP_BYTE_PIX_ORDER */
+ (0 << 25) | /* DP_CONVERSION_TEMP */
+ (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */
+ (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */
+ (PIX_FORMAT_MONO << 28) | /* DP_SCALE_PIX_WIDTH */
+ 0),
+ /* DP_SET_GUI_ENGINE */
+ ((PIX_FORMAT_MONO << 3) |
+ (1 << 6) | /* SET_DP_SRC_PIX_WIDTH */
+ (6 << 7) | /* SET_DST_OFFSET */
+ (0 << 10) | /* SET_DST_PITCH */
+ (0 << 14) | /* SET_DST_PITCH_BY_2 */
+ (0 << 15) | /* SET_SRC_OFFPITCH_COPY */
+ (0 << 16) | /* SET_SRC_HGTWID1_2 */
+ (0 << 20) | /* SET_DRAWING_COMBO */
+ (1 << 24) | /* SET_BUS_MASTER_OP */
+ (0 << 26) | /* SET_BUS_MASTER_EN */
+ (0 << 27) | /* SET_BUS_MASTER_SYNC */
+ (0 << 28) | /* DP_HOST_TRIPLE_EN */
+ (0 << 29) | /* FAST_FILL_EN */
+ (0 << 30) | /* BLOCK_WRITE_EN */
+ 0)
+ },
+ { 8, 8,
+ /* DP_PIX_WIDTH */
+ ((PIX_FORMAT_PSEUDO_8 << 0) | /* DP_DST_PIX_WIDTH */
+ (PIX_FORMAT_PSEUDO_8 << 4) | /* COMPOSITE_PIX_WIDTH */
+ (PIX_FORMAT_PSEUDO_8 << 8) | /* DP_SRC_PIX_WIDTH */
+ (0 << 13) | /* DP_HOST_TRIPLE_EN */
+ (0 << 14) | /* DP_PALETTE_TYPE */
+ (PIX_FORMAT_PSEUDO_8 << 16) | /* DP_HOST_PIX_WIDTH */
+ (0 << 20) | /* DP_C14_RGB_INDEX */
+ (0 << 24) | /* DP_BYTE_PIX_ORDER */
+ (0 << 25) | /* DP_CONVERSION_TEMP */
+ (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */
+ (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */
+ (PIX_FORMAT_PSEUDO_8 << 28) | /* DP_SCALE_PIX_WIDTH */
+ 0),
+ /* DP_SET_GUI_ENGINE */
+ ((PIX_FORMAT_PSEUDO_8 << 3) |
+ (1 << 6) | /* SET_DP_SRC_PIX_WIDTH */
+ (6 << 7) | /* SET_DST_OFFSET */
+ (0 << 10) | /* SET_DST_PITCH */
+ (0 << 14) | /* SET_DST_PITCH_BY_2 */
+ (0 << 15) | /* SET_SRC_OFFPITCH_COPY */
+ (0 << 16) | /* SET_SRC_HGTWID1_2 */
+ (0 << 20) | /* SET_DRAWING_COMBO */
+ (1 << 24) | /* SET_BUS_MASTER_OP */
+ (0 << 26) | /* SET_BUS_MASTER_EN */
+ (0 << 27) | /* SET_BUS_MASTER_SYNC */
+ (0 << 28) | /* DP_HOST_TRIPLE_EN */
+ (0 << 29) | /* FAST_FILL_EN */
+ (0 << 30) | /* BLOCK_WRITE_EN */
+ 0)
+ },
+ { 15, 16,
+ /* DP_PIX_WIDTH */
+ ((PIX_FORMAT_TRUE_1555 << 0) | /* DP_DST_PIX_WIDTH */
+ (PIX_FORMAT_TRUE_1555 << 4) | /* COMPOSITE_PIX_WIDTH */
+ (PIX_FORMAT_TRUE_1555 << 8) | /* DP_SRC_PIX_WIDTH */
+ (0 << 13) | /* DP_HOST_TRIPLE_EN */
+ (0 << 14) | /* DP_PALETTE_TYPE */
+ (PIX_FORMAT_TRUE_1555 << 16) | /* DP_HOST_PIX_WIDTH */
+ (0 << 20) | /* DP_C14_RGB_INDEX */
+ (0 << 24) | /* DP_BYTE_PIX_ORDER */
+ (0 << 25) | /* DP_CONVERSION_TEMP */
+ (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */
+ (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */
+ (PIX_FORMAT_TRUE_1555 << 28) | /* DP_SCALE_PIX_WIDTH */
+ 0),
+ /* DP_SET_GUI_ENGINE */
+ ((PIX_FORMAT_TRUE_1555 << 3) |
+ (1 << 6) | /* SET_DP_SRC_PIX_WIDTH */
+ (6 << 7) | /* SET_DST_OFFSET */
+ (0 << 10) | /* SET_DST_PITCH */
+ (0 << 14) | /* SET_DST_PITCH_BY_2 */
+ (0 << 15) | /* SET_SRC_OFFPITCH_COPY */
+ (0 << 16) | /* SET_SRC_HGTWID1_2 */
+ (0 << 20) | /* SET_DRAWING_COMBO */
+ (1 << 24) | /* SET_BUS_MASTER_OP */
+ (0 << 26) | /* SET_BUS_MASTER_EN */
+ (0 << 27) | /* SET_BUS_MASTER_SYNC */
+ (0 << 28) | /* DP_HOST_TRIPLE_EN */
+ (0 << 29) | /* FAST_FILL_EN */
+ (0 << 30) | /* BLOCK_WRITE_EN */
+ 0)
+ },
+ { 16, 16,
+ /* DP_PIX_WIDTH */
+ ((PIX_FORMAT_TRUE_565 << 0) | /* DP_DST_PIX_WIDTH */
+ (PIX_FORMAT_TRUE_565 << 4) | /* COMPOSITE_PIX_WIDTH */
+ (PIX_FORMAT_TRUE_565 << 8) | /* DP_SRC_PIX_WIDTH */
+ (0 << 13) | /* DP_HOST_TRIPLE_EN */
+ (0 << 14) | /* DP_PALETTE_TYPE */
+ (PIX_FORMAT_TRUE_565 << 16) | /* DP_HOST_PIX_WIDTH */
+ (0 << 20) | /* DP_C14_RGB_INDEX */
+ (0 << 24) | /* DP_BYTE_PIX_ORDER */
+ (0 << 25) | /* DP_CONVERSION_TEMP */
+ (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */
+ (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */
+ (PIX_FORMAT_TRUE_565 << 28) | /* DP_SCALE_PIX_WIDTH */
+ 0),
+ /* DP_SET_GUI_ENGINE */
+ ((PIX_FORMAT_TRUE_565 << 3) |
+ (1 << 6) | /* SET_DP_SRC_PIX_WIDTH */
+ (6 << 7) | /* SET_DST_OFFSET */
+ (0 << 10) | /* SET_DST_PITCH */
+ (0 << 14) | /* SET_DST_PITCH_BY_2 */
+ (0 << 15) | /* SET_SRC_OFFPITCH_COPY */
+ (0 << 16) | /* SET_SRC_HGTWID1_2 */
+ (0 << 20) | /* SET_DRAWING_COMBO */
+ (1 << 24) | /* SET_BUS_MASTER_OP */
+ (0 << 26) | /* SET_BUS_MASTER_EN */
+ (0 << 27) | /* SET_BUS_MASTER_SYNC */
+ (0 << 28) | /* DP_HOST_TRIPLE_EN */
+ (0 << 29) | /* FAST_FILL_EN */
+ (0 << 30) | /* BLOCK_WRITE_EN */
+ 0)
+ },
+ { 24, 24,
+ /* DP_PIX_WIDTH */
+ ((PIX_FORMAT_PSEUDO_8 << 0) | /* DP_DST_PIX_WIDTH */
+ (PIX_FORMAT_PSEUDO_8 << 4) | /* COMPOSITE_PIX_WIDTH */
+ (PIX_FORMAT_PSEUDO_8 << 8) | /* DP_SRC_PIX_WIDTH */
+ (0 << 13) | /* DP_HOST_TRIPLE_EN */
+ (0 << 14) | /* DP_PALETTE_TYPE */
+ (PIX_FORMAT_PSEUDO_8 << 16) | /* DP_HOST_PIX_WIDTH */
+ (0 << 20) | /* DP_C14_RGB_INDEX */
+ (0 << 24) | /* DP_BYTE_PIX_ORDER */
+ (0 << 25) | /* DP_CONVERSION_TEMP */
+ (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */
+ (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */
+ (PIX_FORMAT_PSEUDO_8 << 28) | /* DP_SCALE_PIX_WIDTH */
+ 0),
+ /* DP_SET_GUI_ENGINE */
+ ((PIX_FORMAT_PSEUDO_8 << 3) |
+ (1 << 6) | /* SET_DP_SRC_PIX_WIDTH */
+ (6 << 7) | /* SET_DST_OFFSET */
+ (0 << 10) | /* SET_DST_PITCH */
+ (0 << 14) | /* SET_DST_PITCH_BY_2 */
+ (0 << 15) | /* SET_SRC_OFFPITCH_COPY */
+ (0 << 16) | /* SET_SRC_HGTWID1_2 */
+ (0 << 20) | /* SET_DRAWING_COMBO */
+ (1 << 24) | /* SET_BUS_MASTER_OP */
+ (0 << 26) | /* SET_BUS_MASTER_EN */
+ (0 << 27) | /* SET_BUS_MASTER_SYNC */
+ (0 << 28) | /* DP_HOST_TRIPLE_EN */
+ (0 << 29) | /* FAST_FILL_EN */
+ (0 << 30) | /* BLOCK_WRITE_EN */
+ 0)
+ },
+ { 24, 32,
+ /* DP_PIX_WIDTH */
+ ((PIX_FORMAT_TRUE_8888 << 0) | /* DP_DST_PIX_WIDTH */
+ (PIX_FORMAT_TRUE_8888 << 4) | /* COMPOSITE_PIX_WIDTH */
+ (PIX_FORMAT_TRUE_8888 << 8) | /* DP_SRC_PIX_WIDTH */
+ (0 << 13) | /* DP_HOST_TRIPLE_EN */
+ (0 << 14) | /* DP_PALETTE_TYPE */
+ (PIX_FORMAT_TRUE_8888 << 16) | /* DP_HOST_PIX_WIDTH */
+ (0 << 20) | /* DP_C14_RGB_INDEX */
+ (0 << 24) | /* DP_BYTE_PIX_ORDER */
+ (0 << 25) | /* DP_CONVERSION_TEMP */
+ (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */
+ (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */
+ (PIX_FORMAT_TRUE_8888 << 28) | /* DP_SCALE_PIX_WIDTH */
+ 0),
+ /* DP_SET_GUI_ENGINE */
+ ((PIX_FORMAT_TRUE_8888 << 3) |
+ (1 << 6) | /* SET_DP_SRC_PIX_WIDTH */
+ (6 << 7) | /* SET_DST_OFFSET */
+ (0 << 10) | /* SET_DST_PITCH */
+ (0 << 14) | /* SET_DST_PITCH_BY_2 */
+ (0 << 15) | /* SET_SRC_OFFPITCH_COPY */
+ (0 << 16) | /* SET_SRC_HGTWID1_2 */
+ (0 << 20) | /* SET_DRAWING_COMBO */
+ (1 << 24) | /* SET_BUS_MASTER_OP */
+ (0 << 26) | /* SET_BUS_MASTER_EN */
+ (0 << 27) | /* SET_BUS_MASTER_SYNC */
+ (0 << 28) | /* DP_HOST_TRIPLE_EN */
+ (0 << 29) | /* FAST_FILL_EN */
+ (0 << 30) | /* BLOCK_WRITE_EN */
+ 0)
+ },
+ { 32, 32,
+ /* DP_PIX_WIDTH */
+ ((PIX_FORMAT_TRUE_8888 << 0) | /* DP_DST_PIX_WIDTH */
+ (PIX_FORMAT_TRUE_8888 << 4) | /* COMPOSITE_PIX_WIDTH */
+ (PIX_FORMAT_TRUE_8888 << 8) | /* DP_SRC_PIX_WIDTH */
+ (0 << 13) | /* DP_HOST_TRIPLE_EN */
+ (0 << 14) | /* DP_PALETTE_TYPE */
+ (PIX_FORMAT_TRUE_8888 << 16) | /* DP_HOST_PIX_WIDTH */
+ (0 << 20) | /* DP_C14_RGB_INDEX */
+ (0 << 24) | /* DP_BYTE_PIX_ORDER */
+ (0 << 25) | /* DP_CONVERSION_TEMP */
+ (0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */
+ (0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */
+ (PIX_FORMAT_TRUE_8888 << 28) | /* DP_SCALE_PIX_WIDTH */
+ 0),
+ /* DP_SET_GUI_ENGINE */
+ ((PIX_FORMAT_TRUE_8888 << 3) |
+ (1 << 6) | /* SET_DP_SRC_PIX_WIDTH */
+ (6 << 7) | /* SET_DST_OFFSET */
+ (0 << 10) | /* SET_DST_PITCH */
+ (0 << 14) | /* SET_DST_PITCH_BY_2 */
+ (0 << 15) | /* SET_SRC_OFFPITCH_COPY */
+ (0 << 16) | /* SET_SRC_HGTWID1_2 */
+ (0 << 20) | /* SET_DRAWING_COMBO */
+ (1 << 24) | /* SET_BUS_MASTER_OP */
+ (0 << 26) | /* SET_BUS_MASTER_EN */
+ (0 << 27) | /* SET_BUS_MASTER_SYNC */
+ (0 << 28) | /* DP_HOST_TRIPLE_EN */
+ (0 << 29) | /* FAST_FILL_EN */
+ (0 << 30) | /* BLOCK_WRITE_EN */
+ 0)
+ }
+};
+
+#define NACCELREG (sizeof mach64AccelReg / sizeof mach64AccelReg[0])
+
+static void
+mach64WaitMarker (ScreenPtr pScreen, int marker)
+{
+ KdScreenPriv(pScreen);
+ mach64CardInfo(pScreenPriv);
+ reg = mach64c->reg;
+
+ mach64WaitIdle (reg);
+}
+
+static Bool
+mach64Setup (PixmapPtr pDst, PixmapPtr pSrc, CARD32 combo, int wait)
+{
+ ScreenPtr pScreen = pDst->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ mach64CardInfo(pScreenPriv);
+ CARD32 DST_PITCH;
+ CARD32 DST_OFFSET;
+ CARD32 SRC_PITCH;
+ CARD32 SRC_OFFSET;
+ CARD32 DP_PIX_WIDTH;
+ CARD32 DP_SET_GUI_ENGINE;
+ int i;
+
+ for (i = 0; i < NACCELREG; i++)
+ if (mach64AccelReg[i].depth == pDst->drawable.depth &&
+ mach64AccelReg[i].bitsPerPixel == pDst->drawable.bitsPerPixel)
+ break;
+ if (i == NACCELREG)
+ return FALSE;
+ DP_PIX_WIDTH = mach64AccelReg[i].DP_PIX_WIDTH;
+ DP_SET_GUI_ENGINE = mach64AccelReg[i].DP_SET_GUI_ENGINE;
+
+ reg = mach64c->reg;
+ if (!reg)
+ return FALSE;
+
+ triple = (pDst->drawable.bitsPerPixel == 24);
+
+ if (triple)
+ {
+ /* bytes / 8 = bytes >> 3 */
+ DST_PITCH = pDst->devKind >> 3;
+ }
+ else
+ {
+ /* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */
+ DST_PITCH = pDst->devKind / pDst->drawable.bitsPerPixel;
+ }
+
+ /* bytes / 8 */
+ DST_OFFSET = ((CARD8 *) pDst->devPrivate.ptr - pScreenPriv->screen->memory_base) >> 3;
+
+ mach64WaitAvail(reg, wait + (pSrc ? 5 : 4));
+ reg->DP_SET_GUI_ENGINE = DP_SET_GUI_ENGINE | (combo << 20);
+ reg->DP_PIX_WIDTH = DP_PIX_WIDTH;
+ reg->DST_OFF_PITCH = ((DST_OFFSET << 0) | /* USR1_DST_OFFSET */
+ (DST_PITCH << 22) | /* USR1_DST_PITCH */
+ 0);
+ if (pSrc)
+ {
+ if (triple)
+ {
+ SRC_PITCH = pSrc->devKind >> 3;
+ }
+ else
+ {
+ /* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */
+ SRC_PITCH = pSrc->devKind / pSrc->drawable.bitsPerPixel;
+ }
+ /* bytes / 8 */
+ SRC_OFFSET = ((CARD8 *) pSrc->devPrivate.ptr - pScreenPriv->screen->memory_base) >> 3;
+
+ reg->SRC_OFF_PITCH = ((SRC_OFFSET << 0) |
+ (SRC_PITCH << 22) |
+ 0);
+ }
+ return TRUE;
+}
+
+static Bool
+mach64PrepareSolid (PixmapPtr pPixmap,
+ int alu,
+ Pixel pm,
+ Pixel fg)
+{
+ if (!mach64Setup (pPixmap, 0, 1, 3))
+ return FALSE;
+ reg->DP_MIX = (mach64Rop[alu] << 16) | 0;
+ reg->DP_WRITE_MSK = pm;
+ reg->DP_FRGD_CLR = fg;
+ return TRUE;
+}
+
+static void
+mach64Solid (int x1, int y1, int x2, int y2)
+{
+ if (triple)
+ {
+ CARD32 traj;
+
+ x1 *= 3;
+ x2 *= 3;
+
+ traj = (DST_X_DIR |
+ DST_Y_DIR |
+ DST_24_ROT_EN |
+ DST_24_ROT((x1 / 4) % 6));
+ mach64WaitAvail (reg, 1);
+ reg->GUI_TRAJ_CNTL = traj;
+ }
+ mach64WaitAvail(reg,2);
+ reg->DST_X_Y = MACH64_XY(x1,y1);
+ reg->DST_WIDTH_HEIGHT = MACH64_XY(x2-x1,y2-y1);
+}
+
+static void
+mach64DoneSolid (void)
+{
+#if SYNC_ALWAYS
+ mach64WaitIdle (reg);
+#endif
+}
+
+static int copyDx;
+static int copyDy;
+static CARD32 copyCombo;
+
+static Bool
+mach64PrepareCopy (PixmapPtr pSrcPixmap,
+ PixmapPtr pDstPixmap,
+ int dx,
+ int dy,
+ int alu,
+ Pixel pm)
+{
+ copyCombo = 8 | 2 | 1;
+ copyDx = dx;
+ copyDy = dy;
+
+ /*
+ * Avoid going backwards when copying pixmaps to the screen.
+ * This should reduce tearing somewhat
+ */
+ if (pSrcPixmap == pDstPixmap)
+ {
+ if (dx <= 0)
+ copyCombo &= ~1;
+ if (dy <= 0)
+ copyCombo &= ~2;
+ }
+
+ if (!mach64Setup (pDstPixmap, pSrcPixmap, copyCombo, 2))
+ return FALSE;
+
+ reg->DP_MIX = (mach64Rop[alu] << 16) | 0;
+ reg->DP_WRITE_MSK = pm;
+ return TRUE;
+}
+
+static void
+mach64Copy (int srcX,
+ int srcY,
+ int dstX,
+ int dstY,
+ int w,
+ int h)
+{
+ if (triple)
+ {
+ CARD32 traj;
+
+ srcX *= 3;
+ dstX *= 3;
+ w *= 3;
+
+ traj = DST_24_ROT_EN | DST_24_ROT((dstX / 4) % 6);
+
+ if (copyCombo & 1)
+ traj |= 1;
+ if (copyCombo & 2)
+ traj |= 2;
+
+ mach64WaitAvail (reg, 1);
+ reg->GUI_TRAJ_CNTL = traj;
+ }
+ if ((copyCombo & 1) == 0)
+ {
+ srcX += w - 1;
+ dstX += w - 1;
+ }
+ if ((copyCombo & 2) == 0)
+ {
+ srcY += h - 1;
+ dstY += h - 1;
+ }
+ mach64WaitAvail (reg, 4);
+ reg->SRC_Y_X = MACH64_YX(srcX, srcY);
+ reg->SRC_WIDTH1 = w;
+ reg->DST_Y_X = MACH64_YX(dstX, dstY);
+ reg->DST_HEIGHT_WIDTH = MACH64_YX(w,h);
+}
+
+static void
+mach64DoneCopy (void)
+{
+#if SYNC_ALWAYS
+ mach64WaitIdle (reg);
+#endif
+}
+
+
+Bool
+mach64DrawInit (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ mach64ScreenInfo(pScreenPriv);
+
+ memset(&mach64s->kaa, 0, sizeof(KaaScreenInfoRec));
+ mach64s->kaa.waitMarker = mach64WaitMarker;
+ mach64s->kaa.PrepareSolid = mach64PrepareSolid;
+ mach64s->kaa.Solid = mach64Solid;
+ mach64s->kaa.DoneSolid = mach64DoneSolid;
+ mach64s->kaa.PrepareCopy = mach64PrepareCopy;
+ mach64s->kaa.Copy = mach64Copy;
+ mach64s->kaa.DoneCopy = mach64DoneCopy;
+ mach64s->kaa.offsetAlign = 64;
+ mach64s->kaa.pitchAlign = 64;
+ mach64s->kaa.flags = KAA_OFFSCREEN_PIXMAPS;
+
+ if (pScreenPriv->screen->fb[0].depth == 4)
+ return FALSE;
+
+ if (!kaaDrawInit (pScreen, &mach64s->kaa))
+ return FALSE;
+
+ return TRUE;
+}
+
+void
+mach64DrawEnable (ScreenPtr pScreen)
+{
+ kaaMarkSync (pScreen);
+}
+
+void
+mach64DrawDisable (ScreenPtr pScreen)
+{
+}
+
+void
+mach64DrawFini (ScreenPtr pScreen)
+{
+ kaaDrawFini (pScreen);
+}
diff --git a/xorg-server/hw/kdrive/mach64/mach64draw.h b/xorg-server/hw/kdrive/mach64/mach64draw.h
new file mode 100644
index 000000000..bac11c2a6
--- /dev/null
+++ b/xorg-server/hw/kdrive/mach64/mach64draw.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _TRIDENTDRAW_H_
+#define _TRIDENTDRAW_H_
+
+#define SetupTrident(s) KdScreenPriv(s); \
+ tridentCardInfo(pScreenPriv); \
+ Cop *cop = tridentc->cop
+
+#define TridentAlpha (COP_MULTI_ALPHA|COP_ALPHA_WRITE_ENABLE)
+
+#define _tridentInit(cop,tridentc) { \
+ if ((cop)->status == 0xffffffff) tridentSetMMIO(tridentc); \
+ (cop)->multi = (tridentc)->cop_depth; \
+ (cop)->multi = (tridentc)->cop_stride; \
+ (cop)->multi = TridentAlpha; \
+} \
+
+#define _tridentSetSolidRect(cop,pix,alu,cmd) {\
+ cop->multi = COP_MULTI_PATTERN; \
+ cop->multi = COP_MULTI_ROP | tridentRop[alu]; \
+ cop->fg = (pix); \
+ cmd = COP_OP_BLT | COP_SCL_OPAQUE | COP_OP_ROP | COP_OP_FG; \
+}
+
+#define _tridentRect(cop,x1,y1,x2,y2,cmd) { \
+ (cop)->dst_start_xy = TRI_XY (x1,y1); \
+ (cop)->dst_end_xy = TRI_XY(x2,y2); \
+ _tridentWaitDone(cop); \
+ (cop)->command = (cmd); \
+}
+
+#define COP_STATUS_BUSY (COP_STATUS_BE_BUSY | \
+ COP_STATUS_DPE_BUSY | \
+ COP_STATUS_MI_BUSY)
+
+#define _tridentWaitDone(cop) { \
+ int __q__ = 500000; \
+ while (__q__-- && (cop)->status & COP_STATUS_BUSY) \
+ ; \
+ if (!__q__) \
+ (cop)->status = 0; \
+}
+
+#define _tridentWaitIdleEmpty(cop) _tridentWaitDone(cop)
+
+#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3))
+
+#endif
diff --git a/xorg-server/hw/kdrive/mach64/mach64stub.c b/xorg-server/hw/kdrive/mach64/mach64stub.c
new file mode 100644
index 000000000..5895a3cb7
--- /dev/null
+++ b/xorg-server/hw/kdrive/mach64/mach64stub.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright 1999 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "mach64.h"
+#include <klinux.h>
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+
+ if (LinuxFindPci (0x1002, 0x4750, 0, &attr))
+ KdCardInfoAdd (&mach64Funcs, &attr, 0);
+ else if (LinuxFindPci (0x1002, 0x4c42, 0, &attr))
+ KdCardInfoAdd (&mach64Funcs, &attr, 0);
+ else if (LinuxFindPci (0x1002, 0x4c46, 0, &attr))
+ KdCardInfoAdd (&mach64Funcs, &attr, 0);
+ else if (LinuxFindPci (0x1002, 0x4c49, 0, &attr))
+ KdCardInfoAdd (&mach64Funcs, &attr, 0);
+ else if (LinuxFindPci (0x1002, 0x4c4d, 0, &attr))
+ KdCardInfoAdd (&mach64Funcs, &attr, 0);
+}
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdOsAddInputDrivers ();
+ KdInitInput ();
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+ vesaUseMsg();
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ int ret;
+
+ if (!(ret = vesaProcessArgument (argc, argv, i)))
+ ret = KdProcessArgument(argc, argv, i);
+ return ret;
+}
diff --git a/xorg-server/hw/kdrive/mach64/mach64video.c b/xorg-server/hw/kdrive/mach64/mach64video.c
new file mode 100644
index 000000000..38fcef7eb
--- /dev/null
+++ b/xorg-server/hw/kdrive/mach64/mach64video.c
@@ -0,0 +1,994 @@
+/*
+ * Copyright © 2001 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "mach64.h"
+
+#include <X11/extensions/Xv.h>
+#include "fourcc.h"
+
+#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
+
+static Atom xvBrightness, xvSaturation, xvColorKey;
+
+#define IMAGE_MAX_WIDTH 720
+#define IMAGE_MAX_HEIGHT 576
+
+static void
+mach64StopVideo(KdScreenInfo *screen, pointer data, Bool exit)
+{
+ ScreenPtr pScreen = screen->pScreen;
+ KdScreenPriv(pScreen);
+ KdCardInfo *card = pScreenPriv->card;
+ Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
+ Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
+ Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
+ Reg *reg = mach64c->reg;
+ MediaReg *media = mach64c->media_reg;
+
+ REGION_EMPTY(screen->pScreen, &pPortPriv->clip);
+
+ if (!media)
+ return;
+
+ if(pPortPriv->videoOn)
+ {
+ mach64WaitIdle (reg);
+ /* wait for buffer to be displayed */
+ while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf)
+ ;
+ /* wait for buffer to be finished */
+ while (((media->TRIG_CNTL >> 6) & 1) != 0)
+ ;
+ mach64WaitAvail (reg, 1);
+ media->OVERLAY_SCALE_CNTL = 0;
+ pPortPriv->videoOn = FALSE;
+ mach64WaitIdle (reg);
+ }
+ if (pPortPriv->off_screen)
+ {
+ KdOffscreenFree (pScreen, pPortPriv->off_screen);
+ pPortPriv->off_screen = 0;
+ }
+}
+
+static int
+mach64SetPortAttribute(KdScreenInfo *screen,
+ Atom attribute,
+ int value,
+ pointer data)
+{
+ Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
+ Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
+
+ if(attribute == xvBrightness)
+ {
+ if(value < -1000)
+ value = -1000;
+ if (value > 1000)
+ value = 1000;
+ pPortPriv->brightness = value;
+ }
+ else if(attribute == xvSaturation)
+ {
+ if (value < -1000)
+ value = -1000;
+ if (value > 1000)
+ value = 1000;
+ pPortPriv->saturation = value;
+ }
+ else if(attribute == xvColorKey)
+ {
+ if (pPortPriv->colorKey != value)
+ {
+ pPortPriv->colorKey = value;
+ REGION_EMPTY(screen->pScreen, &pPortPriv->clip);
+ }
+ }
+ else
+ return BadMatch;
+
+ return Success;
+}
+
+static int
+mach64GetPortAttribute(KdScreenInfo *screen,
+ Atom attribute,
+ int *value,
+ pointer data)
+{
+ Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data;
+
+ if(attribute == xvBrightness)
+ *value = pPortPriv->brightness;
+ else if(attribute == xvSaturation)
+ *value = pPortPriv->saturation;
+ else if(attribute == xvColorKey)
+ *value = pPortPriv->colorKey;
+ else
+ return BadMatch;
+
+ return Success;
+}
+
+static void
+mach64QueryBestSize(KdScreenInfo *screen,
+ Bool motion,
+ short vid_w,
+ short vid_h,
+ short drw_w,
+ short drw_h,
+ unsigned int *p_w,
+ unsigned int *p_h,
+ pointer data)
+{
+ *p_w = drw_w;
+ *p_h = drw_h;
+}
+
+
+static void
+mach64CopyPackedData(KdScreenInfo *screen,
+ unsigned char *buf,
+ int randr,
+ int srcPitch,
+ int dstPitch,
+ int srcW,
+ int srcH,
+ int top,
+ int left,
+ int h,
+ int w)
+{
+ Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
+ Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
+ CARD8 *src = buf, *dst;
+ int srcDown = srcPitch, srcRight = 2, srcNext;
+ int p;
+
+ switch (randr & RR_Rotate_All) {
+ case RR_Rotate_0:
+ src = buf;
+ srcDown = srcPitch;
+ srcRight = 2;
+ break;
+ case RR_Rotate_90:
+ src = buf + (srcH - 1) * 2;
+ srcDown = -2;
+ srcRight = srcPitch;
+ break;
+ case RR_Rotate_180:
+ src = buf + srcPitch * (srcH - 1) + (srcW - 1) * 2;
+ srcDown = -srcPitch;
+ srcRight = -2;
+ break;
+ case RR_Rotate_270:
+ src = buf + srcPitch * (srcW - 1);
+ srcDown = 2;
+ srcRight = -srcPitch;
+ break;
+ }
+
+ src = src + top*srcDown + left*srcRight;
+
+ if (pPortPriv->currentBuf == 0)
+ dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset;
+ else
+ dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset;
+
+ w >>= 1;
+ srcRight >>= 1;
+ srcNext = srcRight >> 1;
+ while(h--)
+ {
+ CARD16 *s = (CARD16 *) src;
+ CARD32 *d = (CARD32 *) dst;
+ p = w;
+ while (p--)
+ {
+ *d++ = s[0] | (s[srcNext] << 16);
+ s += srcRight;
+ }
+ src += srcPitch;
+ dst += dstPitch;
+ }
+}
+
+static void
+mach64CopyPlanarData(KdScreenInfo *screen,
+ unsigned char *buf,
+ int randr,
+ int srcPitch,
+ int srcPitch2,
+ int dstPitch, /* of chroma */
+ int srcW,
+ int srcH,
+ int height,
+ int top,
+ int left,
+ int h,
+ int w,
+ int id)
+{
+ Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
+ Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
+ int i, j;
+ CARD8 *src1, *src2, *src3, *dst1;
+ int srcDown = srcPitch, srcDown2 = srcPitch2;
+ int srcRight = 2, srcRight2 = 1, srcNext = 1;
+
+ /* compute source data pointers */
+ src1 = buf;
+ src2 = src1 + height * srcPitch;
+ src3 = src2 + (height >> 1) * srcPitch2;
+ switch (randr & RR_Rotate_All) {
+ case RR_Rotate_0:
+ srcDown = srcPitch;
+ srcDown2 = srcPitch2;
+ srcRight = 2;
+ srcRight2 = 1;
+ srcNext = 1;
+ break;
+ case RR_Rotate_90:
+ src1 = src1 + srcH - 1;
+ src2 = src2 + (srcH >> 1) - 1;
+ src3 = src3 + (srcH >> 1) - 1;
+ srcDown = -1;
+ srcDown2 = -1;
+ srcRight = srcPitch * 2;
+ srcRight2 = srcPitch2;
+ srcNext = srcPitch;
+ break;
+ case RR_Rotate_180:
+ src1 = src1 + srcPitch * (srcH - 1) + (srcW - 1);
+ src2 = src2 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
+ src3 = src3 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
+ srcDown = -srcPitch;
+ srcDown2 = -srcPitch2;
+ srcRight = -2;
+ srcRight2 = -1;
+ srcNext = -1;
+ break;
+ case RR_Rotate_270:
+ src1 = src1 + srcPitch * (srcW - 1);
+ src2 = src2 + srcPitch2 * ((srcW >> 1) - 1);
+ src3 = src3 + srcPitch2 * ((srcW >> 1) - 1);
+ srcDown = 1;
+ srcDown2 = 1;
+ srcRight = -srcPitch * 2;
+ srcRight2 = -srcPitch2;
+ srcNext = -srcPitch;
+ break;
+ }
+
+ /* adjust for origin */
+ src1 += top * srcDown + left * srcNext;
+ src2 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
+ src3 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
+
+ if (id == FOURCC_I420)
+ {
+ CARD8 *srct = src2;
+ src2 = src3;
+ src3 = srct;
+ }
+
+ if (pPortPriv->currentBuf == 0)
+ dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset;
+ else
+ dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset;
+
+ w >>= 1;
+ for (j = 0; j < h; j++)
+ {
+ CARD32 *dst = (CARD32 *) dst1;
+ CARD8 *s1l = src1;
+ CARD8 *s1r = src1 + srcNext;
+ CARD8 *s2 = src2;
+ CARD8 *s3 = src3;
+
+ for (i = 0; i < w; i++)
+ {
+ *dst++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24);
+ s1l += srcRight;
+ s1r += srcRight;
+ s2 += srcRight2;
+ s3 += srcRight2;
+ }
+ src1 += srcDown;
+ dst1 += dstPitch;
+ if (j & 1)
+ {
+ src2 += srcDown2;
+ src3 += srcDown2;
+ }
+ }
+}
+
+
+/* Mach64ClipVideo -
+
+ Takes the dst box in standard X BoxRec form (top and left
+ edges inclusive, bottom and right exclusive). The new dst
+ box is returned. The source boundaries are given (x1, y1
+ inclusive, x2, y2 exclusive) and returned are the new source
+ boundaries in 16.16 fixed point.
+*/
+
+static void
+Mach64ClipVideo(BoxPtr dst,
+ INT32 *x1,
+ INT32 *x2,
+ INT32 *y1,
+ INT32 *y2,
+ BoxPtr extents, /* extents of the clip region */
+ INT32 width,
+ INT32 height)
+{
+ INT32 vscale, hscale, delta;
+ int diff;
+
+ hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1);
+ vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1);
+
+ *x1 <<= 16; *x2 <<= 16;
+ *y1 <<= 16; *y2 <<= 16;
+
+ diff = extents->x1 - dst->x1;
+ if(diff > 0) {
+ dst->x1 = extents->x1;
+ *x1 += diff * hscale;
+ }
+ diff = dst->x2 - extents->x2;
+ if(diff > 0) {
+ dst->x2 = extents->x2;
+ *x2 -= diff * hscale;
+ }
+ diff = extents->y1 - dst->y1;
+ if(diff > 0) {
+ dst->y1 = extents->y1;
+ *y1 += diff * vscale;
+ }
+ diff = dst->y2 - extents->y2;
+ if(diff > 0) {
+ dst->y2 = extents->y2;
+ *y2 -= diff * vscale;
+ }
+
+ if(*x1 < 0) {
+ diff = (- *x1 + hscale - 1)/ hscale;
+ dst->x1 += diff;
+ *x1 += diff * hscale;
+ }
+ delta = *x2 - (width << 16);
+ if(delta > 0) {
+ diff = (delta + hscale - 1)/ hscale;
+ dst->x2 -= diff;
+ *x2 -= diff * hscale;
+ }
+ if(*y1 < 0) {
+ diff = (- *y1 + vscale - 1)/ vscale;
+ dst->y1 += diff;
+ *y1 += diff * vscale;
+ }
+ delta = *y2 - (height << 16);
+ if(delta > 0) {
+ diff = (delta + vscale - 1)/ vscale;
+ dst->y2 -= diff;
+ *y2 -= diff * vscale;
+ }
+}
+
+static void
+mach64DisplayVideo(KdScreenInfo *screen,
+ int id,
+ int dstPitch, /* of chroma for 4:2:0 */
+ int x1,
+ int y1,
+ int x2,
+ int y2,
+ int dst_x1,
+ int dst_y1,
+ int dst_x2,
+ int dst_y2,
+ short src_w,
+ short src_h,
+ short drw_w,
+ short drw_h)
+{
+ ScreenPtr pScreen = screen->pScreen;
+ KdScreenPriv(pScreen);
+ KdCardInfo *card = pScreenPriv->card;
+ Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
+ Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
+ Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
+ Reg *reg = mach64c->reg;
+ MediaReg *media = mach64c->media_reg;
+ int HORZ_INC, VERT_INC;
+ CARD32 SCALER_IN;
+ int bright;
+ int sat;
+
+ if (id == FOURCC_UYVY)
+ SCALER_IN = SCALER_IN_YVYU422;
+ else
+ SCALER_IN = SCALER_IN_VYUY422;
+
+ mach64WaitAvail (reg, 4);
+
+ media->VIDEO_FORMAT = SCALER_IN | VIDEO_IN_VYUY422;
+
+ /* color key */
+ media->OVERLAY_GRAPHICS_KEY_MSK = (1 << screen->fb[0].depth) - 1;
+ media->OVERLAY_GRAPHICS_KEY_CLR = pPortPriv->colorKey;
+ /* set key control to obey only graphics color key */
+ media->OVERLAY_KEY_CNTL = 0x50;
+
+ mach64WaitAvail (reg, 9);
+ media->CAPTURE_DEBUG = 0;
+ /* no exclusive video region */
+ media->OVERLAY_EXCLUSIVE_HORZ = 0;
+ media->OVERLAY_EXCLUSIVE_VERT = 0;
+ /* scaling coefficients */
+ media->SCALER_H_COEFF0 = 0x00002000;
+ media->SCALER_H_COEFF1 = 0x0D06200D;
+ media->SCALER_H_COEFF2 = 0x0D0A1C0D;
+ media->SCALER_H_COEFF3 = 0x0C0E1A0C;
+ media->SCALER_H_COEFF4 = 0x0C14140C;
+ media->SCALER_TEST = 0;
+
+ mach64WaitAvail (reg, 2);
+ media->OVERLAY_SCALE_CNTL = (SCALE_PIX_EXPAND |
+ SCALE_GAMMA_BRIGHT |
+ SCALE_BANDWIDTH |
+ SCALE_OVERLAY_EN |
+ SCALE_EN);
+
+ bright = (pPortPriv->brightness * 64 / 1000);
+ if (bright < -0x40)
+ bright = -0x40;
+ if (bright > 0x3f)
+ bright = 0x3f;
+ bright = bright & 0x7f;
+ sat = ((pPortPriv->saturation * 31 + 31000) / 2000);
+ if (sat > 0x1f)
+ sat = 0x1f;
+ if (sat < 0)
+ sat = 0;
+
+ media->SCALER_COLOUR_CNTL = ((bright << 0) | /* BRIGHTNESS */
+ (sat << 8) | /* SATURATION_U */
+ (sat << 16) | /* SATURATION_V */
+ (0 << 21) | /* SCALER_VERT_ADJ_UV */
+ (0 << 28)); /* SCALER_HORZ_ADJ_UV */
+
+ VERT_INC = (src_h << 12) / drw_h;
+ HORZ_INC = (src_w << 12) / drw_w;
+
+ mach64WaitAvail (reg, 13);
+
+ /* lock registers to prevent non-atomic update */
+ media->OVERLAY_Y_X_START = 0x80000000 | MACH64_YX (dst_x1, dst_y1);
+ /* ending screen coordinate */
+ media->OVERLAY_Y_X_END = 0x80000000 | MACH64_YX (dst_x2, dst_y2);
+
+ media->OVERLAY_SCALE_INC = MACH64_YX(HORZ_INC, VERT_INC);
+
+ media->SCALER_BUF0_OFFSET = pPortPriv->YBuf0Offset;
+ media->SCALER_BUF1_OFFSET = pPortPriv->YBuf1Offset;
+
+ media->SCALER_BUF0_OFFSET_U = pPortPriv->YBuf0Offset;
+ media->SCALER_BUF1_OFFSET_U = pPortPriv->YBuf1Offset;
+
+ media->SCALER_BUF0_OFFSET_V = pPortPriv->YBuf0Offset;
+ media->SCALER_BUF1_OFFSET_V = pPortPriv->YBuf1Offset;
+
+ media->SCALER_BUF_PITCH = dstPitch >> 1;
+ media->SCALER_HEIGHT_WIDTH = MACH64_YX(src_w - (x1 >> 16), src_h - (y1 >> 16));
+
+ media->CAPTURE_CONFIG = pPortPriv->currentBuf << 28;
+
+ /* set XY location and unlock */
+ media->OVERLAY_Y_X_START = MACH64_YX (dst_x1, dst_y1);
+}
+
+static void
+mach64VideoSave (ScreenPtr pScreen, KdOffscreenArea *area)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
+ Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
+
+ if (pPortPriv->off_screen == area)
+ pPortPriv->off_screen = 0;
+}
+
+static int
+mach64PutImage(KdScreenInfo *screen,
+ DrawablePtr pDraw,
+ short src_x,
+ short src_y,
+ short drw_x,
+ short drw_y,
+ short src_w,
+ short src_h,
+ short drw_w,
+ short drw_h,
+ int id,
+ unsigned char *buf,
+ short width,
+ short height,
+ Bool sync,
+ RegionPtr clipBoxes,
+ pointer data)
+{
+ KdCardInfo *card = screen->card;
+ Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
+ Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
+ Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data;
+ MediaReg *media = mach64c->media_reg;
+ INT32 x1, x2, y1, y2;
+ int randr = mach64s->vesa.randr;
+ int srcPitch, srcPitch2, dstPitch;
+ int top, left, npixels, nlines, size;
+ BoxRec dstBox;
+ int dst_width = width, dst_height = height;
+ int rot_x1, rot_y1, rot_x2, rot_y2;
+ int dst_x1, dst_y1, dst_x2, dst_y2;
+ int rot_src_w, rot_src_h, rot_drw_w, rot_drw_h;
+
+ /* Clip */
+ x1 = src_x;
+ x2 = src_x + src_w;
+ y1 = src_y;
+ y2 = src_y + src_h;
+
+ dstBox.x1 = drw_x;
+ dstBox.x2 = drw_x + drw_w;
+ dstBox.y1 = drw_y;
+ dstBox.y2 = drw_y + drw_h;
+
+ Mach64ClipVideo(&dstBox, &x1, &x2, &y1, &y2,
+ REGION_EXTENTS(pScreen, clipBoxes), width, height);
+
+ if((x1 >= x2) || (y1 >= y2))
+ return Success;
+
+ if (!media)
+ return BadAlloc;
+
+ if (randr & (RR_Rotate_0|RR_Rotate_180))
+ {
+ dst_width = width;
+ dst_height = height;
+ rot_src_w = src_w;
+ rot_src_h = src_h;
+ rot_drw_w = drw_w;
+ rot_drw_h = drw_h;
+ }
+ else
+ {
+ dst_width = height;
+ dst_height = width;
+ rot_src_w = src_h;
+ rot_src_h = src_w;
+ rot_drw_w = drw_h;
+ rot_drw_h = drw_w;
+ }
+
+ switch (randr & RR_Rotate_All) {
+ case RR_Rotate_0:
+ default:
+ dst_x1 = dstBox.x1;
+ dst_y1 = dstBox.y1;
+ dst_x2 = dstBox.x2;
+ dst_y2 = dstBox.y2;
+ rot_x1 = x1;
+ rot_y1 = y1;
+ rot_x2 = x2;
+ rot_y2 = y2;
+ break;
+ case RR_Rotate_90:
+ dst_x1 = dstBox.y1;
+ dst_y1 = screen->height - dstBox.x2;
+ dst_x2 = dstBox.y2;
+ dst_y2 = screen->height - dstBox.x1;
+
+ rot_x1 = y1;
+ rot_y1 = (src_w << 16) - x2;
+ rot_x2 = y2;
+ rot_y2 = (src_w << 16) - x1;
+ break;
+ case RR_Rotate_180:
+ dst_x1 = screen->width - dstBox.x2;
+ dst_y1 = screen->height - dstBox.y2;
+ dst_x2 = screen->width - dstBox.x1;
+ dst_y2 = screen->height - dstBox.y1;
+ rot_x1 = (src_w << 16) - x2;
+ rot_y1 = (src_h << 16) - y2;
+ rot_x2 = (src_w << 16) - x1;
+ rot_y2 = (src_h << 16) - y1;
+ break;
+ case RR_Rotate_270:
+ dst_x1 = screen->width - dstBox.y2;
+ dst_y1 = dstBox.x1;
+ dst_x2 = screen->width - dstBox.y1;
+ dst_y2 = dstBox.x2;
+ rot_x1 = (src_h << 16) - y2;
+ rot_y1 = x1;
+ rot_x2 = (src_h << 16) - y1;
+ rot_y2 = x2;
+ break;
+ }
+
+ switch(id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ dstPitch = ((dst_width << 1) + 15) & ~15;
+ srcPitch = (width + 3) & ~3;
+ srcPitch2 = ((width >> 1) + 3) & ~3;
+ size = dstPitch * (int) dst_height;
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ default:
+ dstPitch = ((dst_width << 1) + 15) & ~15;
+ srcPitch = (width << 1);
+ srcPitch2 = 0;
+ size = dstPitch * (int) dst_height;
+ break;
+ }
+
+ if (pPortPriv->off_screen && size != pPortPriv->size)
+ {
+ KdOffscreenFree (screen->pScreen, pPortPriv->off_screen);
+ pPortPriv->off_screen = 0;
+ }
+
+ if (!pPortPriv->off_screen)
+ {
+ pPortPriv->off_screen = KdOffscreenAlloc (screen->pScreen, size * 2, 64,
+ TRUE, mach64VideoSave,
+ pPortPriv);
+ if (!pPortPriv->off_screen)
+ return BadAlloc;
+ }
+
+ pPortPriv->offset = pPortPriv->off_screen->offset;
+ pPortPriv->size = size;
+ /* fixup pointers */
+
+ pPortPriv->YBuf0Offset = pPortPriv->offset;
+ pPortPriv->YBuf1Offset = pPortPriv->offset + size;
+
+#if 0
+ mach64WaitIdle (reg);
+
+ if (pPortPriv->videoOn)
+ {
+ /* wait for buffer to be displayed */
+ while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf)
+ ;
+ }
+#endif
+ /*
+ * Use the other buffer
+ */
+ pPortPriv->currentBuf = 1 - pPortPriv->currentBuf;
+
+ /* copy data */
+ top = rot_y1 >> 16;
+ left = (rot_x1 >> 16) & ~1;
+ npixels = ((((rot_x2 + 0xffff) >> 16) + 1) & ~1) - left;
+
+ switch(id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ top &= ~1;
+ nlines = ((((rot_y2 + 0xffff) >> 16) + 1) & ~1) - top;
+ mach64CopyPlanarData(screen, buf, randr,
+ srcPitch, srcPitch2, dstPitch,
+ rot_src_w, rot_src_h, height,
+ top, left, nlines, npixels, id);
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ default:
+ nlines = ((rot_y2 + 0xffff) >> 16) - top;
+ mach64CopyPackedData(screen, buf, randr,
+ srcPitch, dstPitch,
+ rot_src_w, rot_src_h,
+ top, left, nlines,
+ npixels);
+ break;
+ }
+
+ mach64DisplayVideo(screen, id, dstPitch,
+ rot_x1, rot_y1, rot_x2, rot_y2,
+ dst_x1, dst_y1,
+ dst_x2, dst_y2,
+ rot_src_w, rot_src_h, rot_drw_w, rot_drw_h);
+
+ /* update cliplist */
+ if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes))
+ {
+ REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes);
+ KXVPaintRegion (pDraw, &pPortPriv->clip, pPortPriv->colorKey);
+ }
+
+ pPortPriv->videoOn = TRUE;
+
+ return Success;
+}
+
+static int
+mach64QueryImageAttributes(KdScreenInfo *screen,
+ int id,
+ unsigned short *w,
+ unsigned short *h,
+ int *pitches,
+ int *offsets)
+{
+ int size, tmp;
+
+ if(*w > IMAGE_MAX_WIDTH)
+ *w = IMAGE_MAX_WIDTH;
+ if(*h > IMAGE_MAX_HEIGHT)
+ *h = IMAGE_MAX_HEIGHT;
+
+ *w = (*w + 1) & ~1;
+ if(offsets) offsets[0] = 0;
+
+ switch(id) {
+ case FOURCC_YV12:
+ case FOURCC_I420:
+ *h = (*h + 1) & ~1;
+ size = (*w + 3) & ~3;
+ if(pitches)
+ pitches[0] = size;
+ size *= *h;
+ if(offsets)
+ offsets[1] = size;
+ tmp = ((*w >> 1) + 3) & ~3;
+ if(pitches)
+ pitches[1] = pitches[2] = tmp;
+ tmp *= (*h >> 1);
+ size += tmp;
+ if(offsets)
+ offsets[2] = size;
+ size += tmp;
+ break;
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
+ default:
+ size = *w << 1;
+ if(pitches)
+ pitches[0] = size;
+ size *= *h;
+ break;
+ }
+
+ return size;
+}
+
+
+/* client libraries expect an encoding */
+static KdVideoEncodingRec DummyEncoding[1] =
+{
+ {
+ 0,
+ "XV_IMAGE",
+ IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT,
+ {1, 1}
+ }
+};
+
+#define NUM_FORMATS 3
+
+static KdVideoFormatRec Formats[NUM_FORMATS] =
+{
+ {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
+};
+
+#define NUM_ATTRIBUTES 3
+
+static KdAttributeRec Attributes[NUM_ATTRIBUTES] =
+{
+ {XvSettable | XvGettable, 0, ~0, "XV_COLORKEY"},
+ {XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"},
+ {XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"}
+};
+
+#define NUM_IMAGES 4
+
+static KdImageRec Images[NUM_IMAGES] =
+{
+ XVIMAGE_YUY2,
+ XVIMAGE_YV12,
+ XVIMAGE_I420,
+ XVIMAGE_UYVY
+};
+
+static void mach64ResetVideo(KdScreenInfo *screen)
+{
+}
+
+static int
+mach64ReputImage (KdScreenInfo *screen,
+ DrawablePtr pDraw,
+ short drw_x,
+ short drw_y,
+ RegionPtr clipBoxes,
+ pointer data)
+{
+ Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data;
+ BoxPtr pOldExtents = REGION_EXTENTS (screen->pScreen, &pPortPriv->clip);
+ BoxPtr pNewExtents = REGION_EXTENTS (screen->pScreen, clipBoxes);
+
+ if (pOldExtents->x1 == pNewExtents->x1 &&
+ pOldExtents->x2 == pNewExtents->x2 &&
+ pOldExtents->y1 == pNewExtents->y1 &&
+ pOldExtents->y2 == pNewExtents->y2)
+ {
+ /* update cliplist */
+ if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes))
+ {
+ REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes);
+ KXVPaintRegion (pDraw, &pPortPriv->clip, pPortPriv->colorKey);
+ }
+ return Success;
+ }
+ return BadMatch;
+}
+
+static KdVideoAdaptorPtr
+mach64SetupImageVideo(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ mach64ScreenInfo(pScreenPriv);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ KdVideoAdaptorPtr adapt;
+ Mach64PortPrivPtr pPortPriv;
+
+ if(!(adapt = xcalloc(1, sizeof(KdVideoAdaptorRec) +
+ sizeof(Mach64PortPrivRec) +
+ sizeof(DevUnion))))
+ return NULL;
+
+ adapt->type = XvWindowMask | XvInputMask | XvImageMask;
+ adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
+ adapt->name = "Mach64 Video Overlay";
+ adapt->nEncodings = 1;
+ adapt->pEncodings = DummyEncoding;
+ adapt->nFormats = NUM_FORMATS;
+ adapt->pFormats = Formats;
+ adapt->nPorts = 1;
+ adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
+
+ pPortPriv = (Mach64PortPrivPtr)(&adapt->pPortPrivates[1]);
+
+ adapt->pPortPrivates[0].ptr = (pointer)(pPortPriv);
+ adapt->pAttributes = Attributes;
+ adapt->nImages = NUM_IMAGES;
+ adapt->nAttributes = NUM_ATTRIBUTES;
+ adapt->pImages = Images;
+ adapt->PutVideo = NULL;
+ adapt->PutStill = NULL;
+ adapt->GetVideo = NULL;
+ adapt->GetStill = NULL;
+ adapt->StopVideo = mach64StopVideo;
+ adapt->SetPortAttribute = mach64SetPortAttribute;
+ adapt->GetPortAttribute = mach64GetPortAttribute;
+ adapt->QueryBestSize = mach64QueryBestSize;
+ adapt->PutImage = mach64PutImage;
+ adapt->ReputImage = mach64ReputImage;
+ adapt->QueryImageAttributes = mach64QueryImageAttributes;
+
+ pPortPriv->colorKey = mach64s->colorKey;
+ pPortPriv->videoOn = FALSE;
+ pPortPriv->brightness = 0;
+ pPortPriv->saturation = 0;
+ pPortPriv->currentBuf = 0;
+ pPortPriv->off_screen = 0;
+ pPortPriv->size = 0;
+ pPortPriv->offset = 0;
+
+ /* gotta uninit this someplace */
+ REGION_INIT(pScreen, &pPortPriv->clip, NullBox, 0);
+
+ mach64s->pAdaptor = adapt;
+
+ xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
+ xvSaturation = MAKE_ATOM("XV_SATURATION");
+ xvColorKey = MAKE_ATOM("XV_COLORKEY");
+
+ mach64ResetVideo(screen);
+
+ return adapt;
+}
+
+Bool mach64InitVideo(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL;
+ KdVideoAdaptorPtr newAdaptor = NULL;
+ int num_adaptors;
+ KdCardInfo *card = pScreenPriv->card;
+ Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
+ Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
+
+ mach64s->pAdaptor = NULL;
+
+ if (!mach64c->media_reg)
+ return FALSE;
+
+ newAdaptor = mach64SetupImageVideo(pScreen);
+
+ num_adaptors = KdXVListGenericAdaptors(screen, &adaptors);
+
+ if(newAdaptor)
+ {
+ if(!num_adaptors)
+ {
+ num_adaptors = 1;
+ adaptors = &newAdaptor;
+ }
+ else
+ {
+ newAdaptors = xalloc((num_adaptors + 1) *
+ sizeof(KdVideoAdaptorPtr*));
+ if(newAdaptors)
+ {
+ memcpy(newAdaptors, adaptors,
+ num_adaptors * sizeof(KdVideoAdaptorPtr));
+ newAdaptors[num_adaptors] = newAdaptor;
+ adaptors = newAdaptors;
+ num_adaptors++;
+ }
+ }
+ }
+
+ if(num_adaptors)
+ KdXVScreenInit(pScreen, adaptors, num_adaptors);
+
+ if(newAdaptors)
+ xfree(newAdaptors);
+ return TRUE;
+}
+
+void
+mach64FiniVideo (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ mach64ScreenInfo(pScreenPriv);
+ KdVideoAdaptorPtr adapt = mach64s->pAdaptor;
+
+ if (adapt)
+ {
+ Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)(&adapt->pPortPrivates[1]);
+ REGION_UNINIT (pScreen, &pPortPriv->clip);
+ xfree (adapt);
+ }
+}
diff --git a/xorg-server/hw/kdrive/mga/Makefile.am b/xorg-server/hw/kdrive/mga/Makefile.am
new file mode 100644
index 000000000..a7dd2cbf6
--- /dev/null
+++ b/xorg-server/hw/kdrive/mga/Makefile.am
@@ -0,0 +1,38 @@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_CFLAGS@
+
+bin_PROGRAMS = Xmga
+
+noinst_LIBRARIES = libmga.a
+
+libmga_a_SOURCES = \
+ mgadraw.c \
+ g400_composite.c \
+ g400_common.h \
+ mga.c \
+ mga.h
+
+Xmga_SOURCES = \
+ mgastub.c
+
+MGA_LIBS = \
+ libmga.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a \
+ @KDRIVE_LIBS@
+
+if GLX
+Xmga_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
+Xmga_LDADD = \
+ $(MGA_LIBS) \
+ @KDRIVE_LIBS@
+
+Xmga_DEPENDENCIES = \
+ libmga.a \
+ @KDRIVE_LOCAL_LIBS@
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/mga/Makefile.in b/xorg-server/hw/kdrive/mga/Makefile.in
new file mode 100644
index 000000000..45b95f2e0
--- /dev/null
+++ b/xorg-server/hw/kdrive/mga/Makefile.in
@@ -0,0 +1,720 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xmga$(EXEEXT)
+subdir = hw/kdrive/mga
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libmga_a_AR = $(AR) $(ARFLAGS)
+libmga_a_LIBADD =
+am_libmga_a_OBJECTS = mgadraw.$(OBJEXT) g400_composite.$(OBJEXT) \
+ mga.$(OBJEXT)
+libmga_a_OBJECTS = $(am_libmga_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xmga_OBJECTS = mgastub.$(OBJEXT)
+Xmga_OBJECTS = $(am_Xmga_OBJECTS)
+am__DEPENDENCIES_1 = libmga.a $(top_builddir)/hw/kdrive/vesa/libvesa.a
+Xmga_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xmga_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libmga_a_SOURCES) $(Xmga_SOURCES)
+DIST_SOURCES = $(libmga_a_SOURCES) $(Xmga_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libmga.a
+libmga_a_SOURCES = \
+ mgadraw.c \
+ g400_composite.c \
+ g400_common.h \
+ mga.c \
+ mga.h
+
+Xmga_SOURCES = \
+ mgastub.c
+
+MGA_LIBS = \
+ libmga.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a \
+ @KDRIVE_LIBS@
+
+@GLX_TRUE@Xmga_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xmga_LDADD = \
+ $(MGA_LIBS) \
+ @KDRIVE_LIBS@
+
+Xmga_DEPENDENCIES = \
+ libmga.a \
+ @KDRIVE_LOCAL_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/mga/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/mga/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libmga.a: $(libmga_a_OBJECTS) $(libmga_a_DEPENDENCIES)
+ -rm -f libmga.a
+ $(libmga_a_AR) libmga.a $(libmga_a_OBJECTS) $(libmga_a_LIBADD)
+ $(RANLIB) libmga.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xmga$(EXEEXT): $(Xmga_OBJECTS) $(Xmga_DEPENDENCIES)
+ @rm -f Xmga$(EXEEXT)
+ $(Xmga_LINK) $(Xmga_OBJECTS) $(Xmga_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/g400_composite.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mga.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mgadraw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mgastub.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/mga/g400_common.h b/xorg-server/hw/kdrive/mga/g400_common.h
new file mode 100644
index 000000000..9f16d2431
--- /dev/null
+++ b/xorg-server/hw/kdrive/mga/g400_common.h
@@ -0,0 +1,185 @@
+/*
+ * Copyright © 2004 Damien Ciabrini
+ *
+ * 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 Anders Carlsson not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Anders Carlsson makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * DAMIEN CIABRINI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ANDERS CARLSSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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 __G400_COMMON_H__
+#define __G400_COMMON_H__
+
+/* Color registers */
+#define MGA_REG_DR4 (0x1CD0)
+#define MGA_REG_DR6 (0x1CD8)
+#define MGA_REG_DR7 (0x1CDC)
+#define MGA_REG_DR8 (0x1CE0)
+#define MGA_REG_DR10 (0x1CE8)
+#define MGA_REG_DR11 (0x1CEC)
+#define MGA_REG_DR12 (0x1CF0)
+#define MGA_REG_DR14 (0x1CF8)
+#define MGA_REG_DR15 (0x1CFC)
+
+/* Alpha registers */
+#define MGA_REG_ALPHASTART (0x2C70)
+#define MGA_REG_ALPHAXINC (0x2C74)
+#define MGA_REG_ALPHAYINC (0x2C78)
+#define MGA_REG_ALPHACTRL (0x2C7C)
+# define MGA_SRC_ZERO (0x00000000)
+# define MGA_SRC_ONE (0x00000001)
+# define MGA_SRC_DST_COLOR (0x00000002)
+# define MGA_SRC_ONE_MINUS_DST_COLOR (0x00000003)
+# define MGA_SRC_ALPHA (0x00000004)
+# define MGA_SRC_ONE_MINUS_SRC_ALPHA (0x00000005)
+# define MGA_SRC_DST_ALPHA (0x00000006)
+# define MGA_SRC_ONE_MINUS_DST_ALPHA (0x00000007)
+# define MGA_SRC_SRC_ALPHA_SATURATE (0x00000008)
+# define MGA_SRC_BLEND_MASK (0x0000000f)
+
+# define MGA_DST_ZERO (0x00000000)
+# define MGA_DST_ONE (0x00000010)
+# define MGA_DST_SRC_COLOR (0x00000020)
+# define MGA_DST_ONE_MINUS_SRC_COLOR (0x00000030)
+# define MGA_DST_SRC_ALPHA (0x00000040)
+# define MGA_DST_ONE_MINUS_SRC_ALPHA (0x00000050)
+# define MGA_DST_DST_ALPHA (0x00000060)
+# define MGA_DST_ONE_MINUS_DST_ALPHA (0x00000070)
+# define MGA_DST_BLEND_MASK (0x00000070)
+
+# define MGA_ALPHACHANNEL (0x00000100)
+# define MGA_VIDEOALPHA (0x00000200)
+# define MGA_DIFFUSEDALPHA (0x01000000)
+# define MGA_MODULATEDALPHA (0x02000000)
+
+/* Textures registers */
+#define MGA_REG_TEXORG (0x2c24)
+#define MGA_REG_TEXORG1 (0x2ca4)
+#define MGA_REG_TEXWIDTH (0x2C28)
+#define MGA_REG_TEXHEIGHT (0x2C2C)
+#define MGA_REG_TMR0 (0x2C00)
+#define MGA_REG_TMR1 (0x2C04)
+#define MGA_REG_TMR2 (0x2C08)
+#define MGA_REG_TMR3 (0x2C0C)
+#define MGA_REG_TMR4 (0x2C10)
+#define MGA_REG_TMR5 (0x2C14)
+#define MGA_REG_TMR6 (0x2C18)
+#define MGA_REG_TMR7 (0x2C1C)
+#define MGA_REG_TMR8 (0x2C20)
+
+/* Texture Control Registers */
+#define MGA_REG_TEXCTL (0x2C30)
+# define MGA_TW4 (0x00000000)
+# define MGA_TW8 (0x00000001)
+# define MGA_TW15 (0x00000002)
+# define MGA_TW16 (0x00000003)
+# define MGA_TW12 (0x00000004)
+# define MGA_TW32 (0x00000006)
+# define MGA_TW8A (0x00000007)
+# define MGA_TW8AL (0x00000008)
+# define MGA_TW422 (0x0000000A)
+# define MGA_TW422UYVY (0x0000000B)
+# define MGA_PITCHLIN (0x00000100)
+# define MGA_NOPERSPECTIVE (0x00200000)
+# define MGA_TAKEY (0x02000000)
+# define MGA_TAMASK (0x04000000)
+# define MGA_CLAMPUV (0x18000000)
+#define MGA_REG_TEXCTL2 (0x2C3C)
+# define MGA_G400_TC2_MAGIC (0x00008000)
+# define MGA_TC2_DECALBLEND (0x00000001)
+# define MGA_TC2_IDECAL (0x00000002)
+# define MGA_TC2_DECALDIS (0x00000004)
+# define MGA_TC2_CKSTRANSDIS (0x00000010)
+# define MGA_TC2_BORDEREN (0x00000020)
+# define MGA_TC2_SPECEN (0x00000040)
+# define MGA_TC2_DUALTEX (0x00000080)
+# define MGA_TC2_TABLEFOG (0x00000100)
+# define MGA_TC2_BUMPMAP (0x00000200)
+# define MGA_TC2_SELECT_TMU1 (0x80000000)
+#define MGA_REG_TEXFILTER (0x2C58)
+# define MGA_MIN_NRST (0x00000000)
+# define MGA_MIN_BILIN (0x00000002)
+# define MGA_MIN_ANISO (0x0000000D)
+# define MGA_MAG_NRST (0x00000000)
+# define MGA_MAG_BILIN (0x00000020)
+
+/* Multi-Textures Control Registers */
+#define MGA_REG_TDUALSTAGE0 (0x2CF8)
+#define MGA_REG_TDUALSTAGE1 (0x2CFC)
+# define MGA_TDS_COLOR_ARG2_DIFFUSE (0x00000000)
+# define MGA_TDS_COLOR_ARG2_SPECULAR (0x00000001)
+# define MGA_TDS_COLOR_ARG2_FCOL (0x00000002)
+# define MGA_TDS_COLOR_ARG2_PREVSTAGE (0x00000003)
+# define MGA_TDS_COLOR_ALPHA_DIFFUSE (0x00000000)
+# define MGA_TDS_COLOR_ALPHA_FCOL (0x00000004)
+# define MGA_TDS_COLOR_ALPHA_CURRTEX (0x00000008)
+# define MGA_TDS_COLOR_ALPHA_PREVTEX (0x0000000c)
+# define MGA_TDS_COLOR_ALPHA_PREVSTAGE (0x00000010)
+# define MGA_TDS_COLOR_ARG1_REPLICATEALPHA (0x00000020)
+# define MGA_TDS_COLOR_ARG1_INV (0x00000040)
+# define MGA_TDS_COLOR_ARG2_REPLICATEALPHA (0x00000080)
+# define MGA_TDS_COLOR_ARG2_INV (0x00000100)
+# define MGA_TDS_COLOR_ALPHA1INV (0x00000200)
+# define MGA_TDS_COLOR_ALPHA2INV (0x00000400)
+# define MGA_TDS_COLOR_ARG1MUL_ALPHA1 (0x00000800)
+# define MGA_TDS_COLOR_ARG2MUL_ALPHA2 (0x00001000)
+# define MGA_TDS_COLOR_ARG1ADD_MULOUT (0x00002000)
+# define MGA_TDS_COLOR_ARG2ADD_MULOUT (0x00004000)
+# define MGA_TDS_COLOR_MODBRIGHT_2X (0x00008000)
+# define MGA_TDS_COLOR_MODBRIGHT_4X (0x00010000)
+# define MGA_TDS_COLOR_ADD_SUB (0x00000000)
+# define MGA_TDS_COLOR_ADD_ADD (0x00020000)
+# define MGA_TDS_COLOR_ADD2X (0x00040000)
+# define MGA_TDS_COLOR_ADDBIAS (0x00080000)
+# define MGA_TDS_COLOR_BLEND (0x00100000)
+# define MGA_TDS_COLOR_SEL_ARG1 (0x00000000)
+# define MGA_TDS_COLOR_SEL_ARG2 (0x00200000)
+# define MGA_TDS_COLOR_SEL_ADD (0x00400000)
+# define MGA_TDS_COLOR_SEL_MUL (0x00600000)
+# define MGA_TDS_ALPHA_ARG1_INV (0x00800000)
+# define MGA_TDS_ALPHA_ARG2_DIFFUSE (0x00000000)
+# define MGA_TDS_ALPHA_ARG2_FCOL (0x01000000)
+# define MGA_TDS_ALPHA_ARG2_PREVTEX (0x02000000)
+# define MGA_TDS_ALPHA_ARG2_PREVSTAGE (0x03000000)
+# define MGA_TDS_ALPHA_ARG2_INV (0x04000000)
+# define MGA_TDS_ALPHA_ADD (0x08000000)
+# define MGA_TDS_ALPHA_ADDBIAS (0x10000000)
+# define MGA_TDS_ALPHA_ADD2X (0x20000000)
+# define MGA_TDS_ALPHA_SEL_ARG1 (0x00000000)
+# define MGA_TDS_ALPHA_SEL_ARG2 (0x40000000)
+# define MGA_TDS_ALPHA_SEL_ADD (0x80000000)
+# define MGA_TDS_ALPHA_SEL_MUL (0xc0000000)
+
+
+
+/* Composition Prototypes. MMIO Access */
+Bool
+mgaCheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture);
+
+Bool
+mgaPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture, PixmapPtr pSrc,
+ PixmapPtr pMask, PixmapPtr pDst);
+
+void
+mgaComposite(int srcX, int srcY, int maskX, int maskY,
+ int dstX, int dstY, int w, int h);
+
+void
+mgaDoneComposite(void);
+
+#endif
diff --git a/xorg-server/hw/kdrive/mga/g400_composite.c b/xorg-server/hw/kdrive/mga/g400_composite.c
new file mode 100644
index 000000000..dda9d9347
--- /dev/null
+++ b/xorg-server/hw/kdrive/mga/g400_composite.c
@@ -0,0 +1,510 @@
+/*
+ * Copyright © 2004 Damien Ciabrini
+ *
+ * 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 Anders Carlsson not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Anders Carlsson makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * DAMIEN CIABRINI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ANDERS CARLSSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+#include "mga.h"
+#include "g400_common.h"
+
+
+static PicturePtr currentSrcPicture;
+static PicturePtr currentMaskPicture;
+static PixmapPtr currentSrc;
+static PixmapPtr currentMask;
+static int src_w2;
+static int src_h2;
+static int mask_w2;
+static int mask_h2;
+
+struct blendinfo {
+ Bool dst_alpha;
+ Bool src_alpha;
+ CARD32 blend_cntl;
+};
+
+static struct blendinfo mgaBlendOP[] = {
+ /* Clear */
+ {0, 0, MGA_SRC_ZERO | MGA_DST_ZERO},
+ /* Src */
+ {0, 0, MGA_SRC_ONE | MGA_DST_ZERO},
+ /* Dst */
+ {0, 0, MGA_SRC_ZERO | MGA_DST_ONE},
+ /* Over */
+ {0, 1, MGA_SRC_ONE | MGA_DST_ONE_MINUS_SRC_ALPHA},
+ /* OverReverse */
+ {1, 0, MGA_SRC_ONE_MINUS_DST_ALPHA | MGA_DST_ONE},
+ /* In */
+ {1, 0, MGA_SRC_DST_ALPHA | MGA_DST_ZERO},
+ /* InReverse */
+ {0, 1, MGA_SRC_ZERO | MGA_DST_SRC_ALPHA},
+ /* Out */
+ {1, 0, MGA_SRC_ONE_MINUS_DST_ALPHA | MGA_DST_ZERO},
+ /* OutReverse */
+ {0, 1, MGA_SRC_ZERO | MGA_DST_ONE_MINUS_SRC_ALPHA},
+ /* Atop */
+ {1, 1, MGA_SRC_DST_ALPHA | MGA_DST_ONE_MINUS_SRC_ALPHA},
+ /* AtopReverse */
+ {1, 1, MGA_SRC_ONE_MINUS_DST_ALPHA | MGA_DST_SRC_ALPHA},
+ /* Xor */
+ {1, 1, MGA_SRC_ONE_MINUS_DST_ALPHA | MGA_DST_ONE_MINUS_SRC_ALPHA},
+ /* Add */
+ {0, 0, MGA_SRC_ONE | MGA_DST_ONE},
+};
+
+struct formatinfo {
+ int fmt;
+ CARD32 card_fmt;
+};
+
+static struct formatinfo texformats[] = {
+ {PICT_a8r8g8b8, MGA_TW32},
+ {PICT_x8r8g8b8, MGA_TW32},
+ {PICT_r5g6b5, MGA_TW16},
+ {PICT_a1r5g5b5, MGA_TW15},
+ {PICT_x1r5g5b5, MGA_TW15},
+ {PICT_a4r4g4b4, MGA_TW12},
+ {PICT_x4r4g4b4, MGA_TW12},
+ {PICT_a8, MGA_TW8A},
+};
+
+static int
+MGA_LOG2( int val )
+{
+ int ret = 0;
+ if (val==1) return 0;
+ while (val >> ret)
+ ret++;
+
+ return ((1 << (ret-1)) == val) ? (ret-1) : ret;
+}
+
+
+static Bool
+mgaCheckSourceTexture (int tmu,
+ PicturePtr pPict)
+{
+ int w = pPict->pDrawable->width;
+ int h = pPict->pDrawable->height;
+ int i;
+ CARD32 texctl = 0;
+
+ if ((w > 2047) || (h > 2047))
+ MGA_FALLBACK(("Picture w/h too large (%dx%d)\n", w, h));
+
+ for (i = 0; i < sizeof(texformats) / sizeof(texformats[0]); i++) {
+ if (texformats[i].fmt == pPict->format) {
+ texctl = texformats[i].card_fmt;
+ break;
+ }
+ }
+ if (texctl == 0) {
+ MGA_FALLBACK(("Unsupported picture format 0x%x\n", pPict->format));
+ }
+
+ if (pPict->repeat && ((w & (w - 1)) != 0 || (h & (h - 1)) != 0))
+ MGA_FALLBACK(("NPOT repeat unsupported (%dx%d)\n", w, h));
+
+ if (pPict->filter != PictFilterNearest &&
+ pPict->filter != PictFilterBilinear)
+ MGA_FALLBACK(("Unsupported filter 0x%x\n", pPict->filter));
+
+ return TRUE;
+}
+
+static Bool
+PrepareSourceTexture (int tmu,
+ PicturePtr pSrcPicture,
+ PixmapPtr pSrc)
+{
+ KdScreenPriv (pSrc->drawable.pScreen);
+ int mem_base=(int)pScreenPriv->screen->memory_base;
+ int pitch = pSrc->devKind / (pSrc->drawable.bitsPerPixel >> 3);
+ int i;
+
+ int w = pSrc->drawable.width;
+ int h = pSrc->drawable.height;
+ int w_log2 = MGA_LOG2(w);
+ int h_log2 = MGA_LOG2(h);
+
+ int texctl = MGA_PITCHLIN | ((pitch & (2048 - 1)) << 9) |
+ MGA_CLAMPUV | MGA_NOPERSPECTIVE;
+ int flags = 0;
+ int texctl2 = MGA_G400_TC2_MAGIC | flags;
+
+ for (i = 0; i < sizeof(texformats) / sizeof(texformats[0]); i++) {
+ if (texformats[i].fmt == pSrcPicture->format) {
+ texctl |= texformats[i].card_fmt;
+ break;
+ }
+ }
+
+ if (PICT_FORMAT_A(pSrcPicture->format) != 0) {
+ texctl |= MGA_TAKEY;
+ } else {
+ texctl |= MGA_TAMASK | MGA_TAKEY;
+ }
+
+ if (pSrcPicture->repeat) {
+ texctl &= ~MGA_CLAMPUV;
+ }
+
+ if (tmu == 1)
+ texctl2 |= MGA_TC2_DUALTEX | MGA_TC2_SELECT_TMU1 | flags;
+
+ mgaWaitAvail (6);
+ MGA_OUT32 (mmio, MGA_REG_TEXCTL2, texctl2);
+ MGA_OUT32 (mmio, MGA_REG_TEXCTL, texctl);
+ /* Source (texture) address + pitch */
+ MGA_OUT32 (mmio, MGA_REG_TEXORG, ((int)pSrc->devPrivate.ptr - mem_base));
+ MGA_OUT32 (mmio, MGA_REG_TEXWIDTH, (w-1)<<18 | ((8-w_log2)&63)<<9 | w_log2);
+ MGA_OUT32 (mmio, MGA_REG_TEXHEIGHT, (h-1)<<18 | ((8-h_log2)&63)<<9 | h_log2);
+ /* Set blit filtering flags */
+ if (pSrcPicture->filter == PictFilterBilinear) {
+ MGA_OUT32 (mmio, MGA_REG_TEXFILTER,
+ (0x10<<21) | MGA_MAG_BILIN | MGA_MIN_BILIN);
+ } else {
+ MGA_OUT32 (mmio, MGA_REG_TEXFILTER,
+ (0x10<<21) | MGA_MAG_NRST | MGA_MIN_NRST);
+ }
+
+ if (tmu == 1) {
+ mgaWaitAvail (1);
+ MGA_OUT32 (mmio, MGA_REG_TEXCTL2, MGA_G400_TC2_MAGIC | MGA_TC2_DUALTEX | flags);
+ }
+
+ return TRUE;
+}
+
+
+/*
+ * The formals params are the elements of the following matrix:
+ *
+ * Dest Transform Src
+ * coords coords
+ * / Xdst \ / X_incx X_incy X_init \ / Xsrc \
+ * | Ydst | = | Y_incx Y_incy Y_init | x | Ysrc |
+ * \ 1 / \ H_incx H_incy H_init / \ 1 /
+ *
+ * matrix elements are 32bits fixed points (16.16)
+ * mga_fx_* is the size of the fixed point for the TMU
+ */
+static void
+setTMIncrementsRegs(int X_incx,
+ int X_incy,
+ int X_init,
+ int Y_incx,
+ int Y_incy,
+ int Y_init,
+ int H_incx,
+ int H_incy,
+ int H_init,
+ int mga_fx_width_size,
+ int mga_fx_height_size) {
+ int decalw = mga_fx_width_size - 16;
+ int decalh = mga_fx_height_size - 16;
+
+ /* Convert 16 bits fixpoint -> MGA variable size fixpoint */
+ if (decalw >= 0) {
+ X_incx = X_incx << decalw;
+ X_incy = X_incy << decalw;
+ X_init = X_init << decalw;
+ } else {
+ decalw =- decalw;
+ X_incx = X_incx >> decalw;
+ X_incy = X_incy >> decalw;
+ X_init = X_init >> decalw;
+ }
+
+ /* Convert 16 bits fixpoint -> MGA variable size fixpoint */
+ if (decalh >= 0) {
+ Y_incx = Y_incx << decalh;
+ Y_incy = Y_incy << decalh;
+ Y_init = Y_init << decalh;
+ } else {
+ decalh =- decalh;
+ Y_incx = Y_incx >> decalh;
+ Y_incy = Y_incy >> decalh;
+ Y_init = Y_init >> decalh;
+ }
+
+ /* Set TM registers */
+ mgaWaitAvail (9);
+ MGA_OUT32 (mmio, MGA_REG_TMR0, X_incx);
+ MGA_OUT32 (mmio, MGA_REG_TMR1, Y_incx);
+ MGA_OUT32 (mmio, MGA_REG_TMR2, X_incy);
+ MGA_OUT32 (mmio, MGA_REG_TMR3, Y_incy);
+ MGA_OUT32 (mmio, MGA_REG_TMR4, H_incx);
+ MGA_OUT32 (mmio, MGA_REG_TMR5, H_incy);
+ MGA_OUT32 (mmio, MGA_REG_TMR6, X_init);
+ MGA_OUT32 (mmio, MGA_REG_TMR7, Y_init);
+ MGA_OUT32 (mmio, MGA_REG_TMR8, H_init);
+}
+
+
+
+
+Bool
+mgaCheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
+ PicturePtr pDstPicture)
+{
+ if (op >= sizeof(mgaBlendOP) / sizeof(mgaBlendOP[0]))
+ MGA_FALLBACK(("unsupported op %x", op));
+ if (!mgaCheckSourceTexture (0, pSrcPicture))
+ return FALSE;
+
+ if (pMaskPicture != NULL) {
+ if (PICT_FORMAT_A(pMaskPicture->format) == 0)
+ MGA_FALLBACK(("Mask without alpha unsupported"));
+ if (!mgaCheckSourceTexture (1, pMaskPicture))
+ return FALSE;
+ }
+
+ if (pMaskPicture->componentAlpha)
+ MGA_FALLBACK(("Component alpha unsupported"));
+
+ if (pDstPicture->format == PICT_a8)
+ MGA_FALLBACK(("render to A8 unsupported"));
+
+ return TRUE;
+}
+
+#define C_ARG1_CUR 0x0
+#define C_ARG1_ALPHA MGA_TDS_COLOR_ARG1_REPLICATEALPHA
+#define C_ARG2_DIFFUSE MGA_TDS_COLOR_ARG2_DIFFUSE
+#define C_ARG2_FCOL MGA_TDS_COLOR_ARG2_FCOL
+#define C_ARG2_PREV MGA_TDS_COLOR_ARG2_PREVSTAGE
+#define C_ARG1_INV MGA_TDS_COLOR_ARG1_INV
+#define C_ARG2_INV MGA_TDS_COLOR_ARG2_INV
+#define COLOR_MUL MGA_TDS_COLOR_SEL_MUL
+#define COLOR_ARG1 MGA_TDS_COLOR_SEL_ARG1
+#define COLOR_ARG2 MGA_TDS_COLOR_SEL_ARG2
+#define A_ARG1_CUR 0x0
+#define A_ARG2_IGN A_ARG2_DIFFUSE
+#define A_ARG2_FCOL MGA_TDS_ALPHA_ARG2_FCOL
+#define A_ARG2_DIFFUSE MGA_TDS_ALPHA_ARG2_DIFFUSE
+#define A_ARG2_PREV MGA_TDS_ALPHA_ARG2_PREVSTAGE
+#define ALPHA_MUL MGA_TDS_ALPHA_SEL_MUL
+#define ALPHA_ARG1 MGA_TDS_ALPHA_SEL_ARG1
+#define ALPHA_ARG2 MGA_TDS_ALPHA_SEL_ARG2
+
+
+Bool
+mgaPrepareComposite (int op,
+ PicturePtr pSrcPicture,
+ PicturePtr pMaskPicture,
+ PicturePtr pDstPicture,
+ PixmapPtr pSrc,
+ PixmapPtr pMask,
+ PixmapPtr pDst)
+{
+ KdScreenPriv (pSrc->drawable.pScreen);
+ int mem_base=(int)pScreenPriv->screen->memory_base;
+ int cmd, blendcntl;
+ int ds0, ds1;
+
+ /* Init MGA (clipping) */
+ mgaSetup (pSrc->drawable.pScreen, pDst->drawable.bitsPerPixel, 1);
+
+ /* Initialize fg color to 0, used in the src = A8 case */
+ MGA_OUT32 (mmio, MGA_REG_FCOL, 0xff000000);
+
+ /* Destination flags */
+ mgaWaitAvail (2);
+ MGA_OUT32 (mmio, MGA_REG_DSTORG, ((int)pDst->devPrivate.ptr - mem_base));
+ MGA_OUT32 (mmio, MGA_REG_PITCH,
+ pDst->devKind / (pDst->drawable.bitsPerPixel >> 3));
+
+
+ /* Source(s) flags */
+ if (!PrepareSourceTexture (0, pSrcPicture, pSrc)) return FALSE;
+ if (pMask != NULL) {
+ if (!PrepareSourceTexture (1, pMaskPicture, pMask)) return FALSE;
+ }
+
+ /* Prepare multi-texture registers */
+ ds0=ds1=0;
+
+ if (pSrcPicture->format == PICT_a8) {
+ /* C = 0 A = As */
+ /* MGA HW: A8 format makes RGB white. We use FCOL for the black
+ * If FCOL was not 0, it would have been be premultiplied (RENDER)
+ * color component would have been:
+ * C_ARG1_ALPHA | C_ARG2_FCOL | COLOR_MUL
+ */
+ ds0=C_ARG2_FCOL | COLOR_ARG2 |
+ A_ARG1_CUR | ALPHA_ARG1;
+ /* MGA HW: TMU1 must be enabled when DUALSTAGE0 contains something */
+ if (pMask == NULL) {
+ if (!PrepareSourceTexture (1, pSrcPicture, pSrc)) return FALSE;
+ ds1=C_ARG2_PREV | COLOR_ARG2 |
+ A_ARG2_PREV | ALPHA_ARG2;
+ }
+ } else {
+ /* C = Cs A = As */
+ ds0=C_ARG1_CUR | COLOR_ARG1 |
+ A_ARG1_CUR | ALPHA_ARG1;
+ }
+
+ if (pMask != NULL) {
+ /* As or Am might be NULL. in this case we don't multiply because,
+ * the alpha component holds garbage.
+ */
+ int color,alpha;
+ if (PICT_FORMAT_A (pMaskPicture->format) == 0) {
+ /* C = Cs */
+ color = C_ARG2_PREV | COLOR_ARG2;
+ } else {
+ /* C = Am * Cs */
+ color = C_ARG1_ALPHA | C_ARG2_PREV | COLOR_MUL;
+ }
+
+ if (PICT_FORMAT_A (pMaskPicture->format) == 0) {
+ /* A = As */
+ alpha = A_ARG2_PREV | ALPHA_ARG2;
+ } else if (PICT_FORMAT_A (pSrcPicture->format) == 0) {
+ /* A = Am */
+ alpha = A_ARG1_CUR | ALPHA_ARG1;
+ } else {
+ /* A = Am * As */
+ alpha = A_ARG1_CUR | A_ARG2_PREV | ALPHA_MUL;
+ }
+
+ ds1 = color | alpha;
+ }
+
+ /* MultiTexture modulation */
+ mgaWaitAvail (2);
+ MGA_OUT32 (mmio, MGA_REG_TDUALSTAGE0, ds0);
+ MGA_OUT32 (mmio, MGA_REG_TDUALSTAGE1, ds1);
+
+
+ cmd = MGA_OPCOD_TEXTURE_TRAP | MGA_ATYPE_RSTR | 0x000c0000 |
+ MGA_DWGCTL_SHIFTZERO | MGA_DWGCTL_SGNZERO | MGA_DWGCTL_ARZERO |
+ MGA_ATYPE_I;
+
+ blendcntl = mgaBlendOP[op].blend_cntl;
+ if (PICT_FORMAT_A(pDstPicture->format) == 0 && mgaBlendOP[op].dst_alpha) {
+ if ((blendcntl & MGA_SRC_BLEND_MASK) == MGA_SRC_DST_ALPHA)
+ blendcntl = (blendcntl & ~MGA_SRC_BLEND_MASK) | MGA_SRC_ONE;
+ else if ((blendcntl & MGA_SRC_BLEND_MASK) == MGA_SRC_ONE_MINUS_DST_ALPHA)
+ blendcntl = (blendcntl & ~MGA_SRC_BLEND_MASK) | MGA_SRC_ZERO;
+ }
+
+ mgaWaitAvail (2);
+ MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd);
+ MGA_OUT32 (mmio, MGA_REG_ALPHACTRL, MGA_ALPHACHANNEL | blendcntl);
+
+ currentSrcPicture = pSrcPicture;
+ currentMaskPicture = pMaskPicture;
+ currentSrc = pSrc;
+ currentMask = pMask;
+ src_w2 = MGA_LOG2 (currentSrc->drawable.width);
+ src_h2 = MGA_LOG2 (currentSrc->drawable.height);
+ mask_w2 = MGA_LOG2 (currentMask->drawable.width);
+ mask_h2 = MGA_LOG2 (currentMask->drawable.height);
+
+ return TRUE;
+}
+
+
+void
+mgaComposite (int srcX,
+ int srcY,
+ int maskX,
+ int maskY,
+ int dstX,
+ int dstY,
+ int width,
+ int height)
+{
+ /* Source positions can be outside source textures' boundaries.
+ * We clamp the values here to avoid rendering glitches.
+ */
+ srcX=srcX % currentSrc->drawable.width;
+ srcY=srcY % currentSrc->drawable.height;
+ maskX=maskX % currentMask->drawable.width;
+ maskY=maskY % currentMask->drawable.height;
+
+ if (currentSrcPicture->transform) {
+ setTMIncrementsRegs (currentSrcPicture->transform->matrix[0][0],
+ currentSrcPicture->transform->matrix[0][1],
+ currentSrcPicture->transform->matrix[0][2] +
+ (srcX << 16),
+ currentSrcPicture->transform->matrix[1][0],
+ currentSrcPicture->transform->matrix[1][1],
+ currentSrcPicture->transform->matrix[1][2] +
+ (srcY << 16),
+ currentSrcPicture->transform->matrix[2][0],
+ currentSrcPicture->transform->matrix[2][1],
+ currentSrcPicture->transform->matrix[2][2],
+ 20-src_w2, 20-src_h2);
+ } else {
+ setTMIncrementsRegs (1 << 16, 0, srcX << 16,
+ 0, 1 << 16, srcY << 16,
+ 0, 0, 0x10000,
+ 20-src_w2, 20-src_h2);
+ }
+
+ if (currentMask != NULL) {
+ mgaWaitAvail (1);
+ MGA_OUT32 (mmio, MGA_REG_TEXCTL2,
+ MGA_G400_TC2_MAGIC | MGA_TC2_DUALTEX | MGA_TC2_SELECT_TMU1);
+ if (currentMaskPicture->transform) {
+ setTMIncrementsRegs (currentMaskPicture->transform->matrix[0][0],
+ currentMaskPicture->transform->matrix[0][1],
+ currentMaskPicture->transform->matrix[0][2] +
+ (maskX << 16),
+ currentMaskPicture->transform->matrix[1][0],
+ currentMaskPicture->transform->matrix[1][1],
+ currentMaskPicture->transform->matrix[1][2] +
+ (maskY << 16),
+ currentMaskPicture->transform->matrix[2][0],
+ currentMaskPicture->transform->matrix[2][1],
+ currentMaskPicture->transform->matrix[2][2],
+ 20-mask_w2, 20-mask_h2);
+ } else {
+ setTMIncrementsRegs (1 << 16, 0, maskX << 16,
+ 0, 1 << 16, maskY << 16,
+ 0, 0, 0x10000,
+ 20-mask_w2, 20-mask_h2);
+ }
+
+ mgaWaitAvail (1);
+ MGA_OUT32 (mmio, MGA_REG_TEXCTL2, MGA_G400_TC2_MAGIC | MGA_TC2_DUALTEX);
+ }
+
+ /* Destination Bounding Box
+ * (Boundary Right | Boundary Left, Y dest | Height)
+ */
+ mgaWaitAvail (2);
+ MGA_OUT32 (mmio, MGA_REG_FXBNDRY,
+ ((dstX + width) << 16) | (dstX & 0xffff));
+ MGA_OUT32 (mmio, MGA_REG_YDSTLEN | MGA_REG_EXEC,
+ (dstY << 16) | (height & 0xffff));
+}
+
+void
+mgaDoneComposite (void)
+{
+}
diff --git a/xorg-server/hw/kdrive/mga/mga.c b/xorg-server/hw/kdrive/mga/mga.c
new file mode 100644
index 000000000..2ae35d143
--- /dev/null
+++ b/xorg-server/hw/kdrive/mga/mga.c
@@ -0,0 +1,240 @@
+/*
+ * Copyright © 2003 Anders Carlsson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Anders Carlsson not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Anders Carlsson makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ANDERS CARLSSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "mga.h"
+
+static Bool
+mgaCardInit (KdCardInfo *card)
+{
+ MgaCardInfo *mgac;
+
+ mgac = (MgaCardInfo *) xalloc (sizeof (MgaCardInfo));
+ if (!mgac)
+ return FALSE;
+
+ mgaMapReg (card, mgac);
+
+ if (!vesaInitialize (card, &mgac->vesa))
+ {
+ xfree (mgac);
+ return FALSE;
+ }
+
+ mgac->fifo_size = 0;
+
+ card->driver = mgac;
+
+ return TRUE;
+}
+
+static Bool
+mgaScreenInit (KdScreenInfo *screen)
+{
+ MgaScreenInfo *mgas;
+
+ mgas = (MgaScreenInfo *) xalloc (sizeof (MgaScreenInfo));
+ if (!mgas)
+ return FALSE;
+ memset (mgas, '\0', sizeof (MgaScreenInfo));
+ if (!vesaScreenInitialize (screen, &mgas->vesa))
+ {
+ xfree (mgas);
+ return FALSE;
+ }
+#if 0
+ /* if (!mgac->reg)
+ screen->dumb = TRUE; */
+
+ if (mgas->vesa.mapping != VESA_LINEAR)
+ screen->dumb = TRUE;
+
+ fprintf (stderr, "vesa mapping is %d\n", mgas->vesa.mapping);
+#endif
+ screen->driver = mgas;
+ return TRUE;
+}
+
+static Bool
+mgaInitScreen (ScreenPtr pScreen)
+{
+ return vesaInitScreen (pScreen);
+}
+
+static Bool
+mgaFinishInitScreen (ScreenPtr pScreen)
+{
+ Bool ret;
+
+ ret = vesaFinishInitScreen (pScreen);
+
+ return ret;
+}
+
+static Bool
+mgaCreateResources (ScreenPtr pScreen)
+{
+ return vesaCreateResources (pScreen);
+}
+
+static void
+mgaPreserve (KdCardInfo *card)
+{
+ vesaPreserve (card);
+}
+
+Bool
+mgaMapReg (KdCardInfo *card, MgaCardInfo *mgac)
+{
+ mgac->reg_base = (CARD8 *) KdMapDevice (MGA_REG_BASE (card),
+ MGA_REG_SIZE (card));
+
+ if (!mgac->reg_base)
+ {
+ return FALSE;
+ }
+
+ KdSetMappedMode (MGA_REG_BASE (card),
+ MGA_REG_SIZE (card),
+ KD_MAPPED_MODE_REGISTERS);
+
+ return TRUE;
+}
+
+void
+mgaUnmapReg (KdCardInfo *card, MgaCardInfo *mgac)
+{
+ if (mgac->reg_base)
+ {
+ KdResetMappedMode (MGA_REG_BASE (card),
+ MGA_REG_SIZE (card),
+ KD_MAPPED_MODE_REGISTERS);
+ KdUnmapDevice ((void *) mgac->reg_base, MGA_REG_SIZE (card));
+ mgac->reg_base = 0;
+ /* mgac->reg = 0; */
+ }
+}
+
+void
+mgaSetMMIO (KdCardInfo *card, MgaCardInfo *mgac)
+{
+ if (!mgac->reg_base)
+ mgaMapReg (card, mgac);
+}
+
+void
+mgaResetMMIO (KdCardInfo *card, MgaCardInfo *mgac)
+{
+ mgaUnmapReg (card, mgac);
+}
+
+static Bool
+mgaDPMS (ScreenPtr pScreen, int mode)
+{
+ /* XXX */
+ return TRUE;
+}
+
+static Bool
+mgaEnable (ScreenPtr pScreen)
+{
+ KdScreenPriv (pScreen);
+ MgaCardInfo *mgac = pScreenPriv->card->driver;
+
+ if (!vesaEnable (pScreen))
+ return FALSE;
+
+ mgaSetMMIO (pScreenPriv->card, mgac);
+ mgaDPMS (pScreen, KD_DPMS_NORMAL);
+
+ return TRUE;
+}
+
+static void
+mgaDisable (ScreenPtr pScreen)
+{
+ KdScreenPriv (pScreen);
+ MgaCardInfo *mgac = pScreenPriv->card->driver;
+
+ mgaResetMMIO (pScreenPriv->card, mgac);
+
+ vesaDisable (pScreen);
+}
+
+static void
+mgaRestore (KdCardInfo *card)
+{
+ MgaCardInfo *mgac = card->driver;
+
+ mgaResetMMIO (card, mgac);
+ vesaRestore (card);
+}
+
+static void
+mgaScreenFini (KdScreenInfo *screen)
+{
+ MgaScreenInfo *mgas = (MgaScreenInfo *) screen->driver;
+
+ vesaScreenFini (screen);
+ xfree (mgas);
+ screen->driver = 0;
+}
+
+static void
+mgaCardFini (KdCardInfo *card)
+{
+ MgaCardInfo *mgac = (MgaCardInfo *)card->driver;
+
+ mgaUnmapReg (card, mgac);
+ vesaCardFini (card);
+}
+
+KdCardFuncs mgaFuncs = {
+ mgaCardInit, /* cardinit */
+ mgaScreenInit, /* scrinit */
+ mgaInitScreen, /* initScreen */
+ mgaFinishInitScreen, /* finishInitScreen */
+ mgaCreateResources, /* createRes */
+ mgaPreserve, /* preserve */
+ mgaEnable, /* enable */
+ mgaDPMS, /* dpms */
+ mgaDisable, /* disable */
+ mgaRestore, /* restore */
+ mgaScreenFini, /* scrfini */
+ mgaCardFini, /* cardfini */
+
+ 0, /* initCursor */
+ 0, /* enableCursor */
+ 0, /* disableCursor */
+ 0, /* finiCursor */
+ 0, /* recolorCursor */
+
+ mgaDrawInit, /* initAccel */
+ mgaDrawEnable, /* enableAccel */
+ mgaDrawDisable, /* disableAccel */
+ mgaDrawFini, /* finiAccel */
+
+ vesaGetColors, /* getColors */
+ vesaPutColors, /* putColors */
+};
+
diff --git a/xorg-server/hw/kdrive/mga/mga.h b/xorg-server/hw/kdrive/mga/mga.h
new file mode 100644
index 000000000..8fa956096
--- /dev/null
+++ b/xorg-server/hw/kdrive/mga/mga.h
@@ -0,0 +1,164 @@
+/*
+ * Copyright © 2003-2004 Anders Carlsson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Anders Carlsson not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Anders Carlsson makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ANDERS CARLSSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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 _MGA_H_
+#define _MGA_H_
+#include <vesa.h>
+#include <klinux.h>
+
+#define MGA_REG_BASE(c) ((c)->attr.address[1])
+#define MGA_REG_SIZE(c) (0x4000)
+
+#define MGA_OUT32(mmio, a, v) (*(VOL32 *) ((mmio) + (a)) = (v))
+#define MGA_IN32(mmio, a) (*(VOL32 *) ((mmio) + (a)))
+
+#define MGA_REG_EXEC (0x0100)
+#define MGA_REG_DWGCTL (0x1c00)
+#define MGA_REG_PLNWT (0x1c1c)
+#define MGA_REG_FCOL (0x1c24)
+#define MGA_REG_MACCESS (0x1c04)
+#define MGA_REG_SGN (0x1c58)
+#define MGA_REG_AR0 (0x1c60)
+#define MGA_REG_AR1 (0x1c64)
+#define MGA_REG_AR2 (0x1c68)
+#define MGA_REG_AR3 (0x1c6C)
+#define MGA_REG_AR4 (0x1c70)
+#define MGA_REG_AR5 (0x1c74)
+#define MGA_REG_AR6 (0x1c78)
+
+#define MGA_REG_CXBNDRY (0x1c80)
+#define MGA_REG_FXBNDRY (0x1c84)
+#define MGA_REG_YDSTLEN (0x1c88)
+#define MGA_REG_PITCH (0x1c8c)
+#define MGA_REG_YTOP (0x1c98)
+#define MGA_REG_YBOT (0x1c9c)
+#define MGA_REG_FIFOSTATUS (0x1e10)
+#define MGA_REG_STATUS (0x1e14)
+#define MGA_REG_CACHEFLUSH (0x1fff)
+#define MGA_REG_SRCORG (0x2cb4)
+#define MGA_REG_DSTORG (0x2cb8)
+
+#define MGA_G4XX_DEVICE_ID (0x0525)
+
+#define MGA_PW8 (0)
+#define MGA_PW16 (1)
+#define MGA_PW24 (2)
+#define MGA_PW32 (3)
+
+/* Drawing opcodes */
+#define MGA_OPCOD_TRAP (4)
+#define MGA_OPCOD_TEXTURE_TRAP (6)
+#define MGA_OPCOD_BITBLT (8)
+
+#define MGA_DWGCTL_SOLID (1 << 11)
+#define MGA_DWGCTL_ARZERO (1 << 12)
+#define MGA_DWGCTL_SGNZERO (1 << 13)
+#define MGA_DWGCTL_SHIFTZERO (1 << 14)
+
+#define MGA_DWGCTL_BFCOL (2 << 25)
+
+#define MGA_ATYPE_RPL (0 << 4)
+#define MGA_ATYPE_RSTR (1 << 4)
+#define MGA_ATYPE_ZI (3 << 4)
+#define MGA_ATYPE_BLK (4 << 4)
+#define MGA_ATYPE_I (7 << 4)
+
+typedef volatile CARD8 VOL8;
+typedef volatile CARD16 VOL16;
+typedef volatile CARD32 VOL32;
+
+typedef struct _mgaCardInfo {
+ VesaCardPrivRec vesa;
+ CARD8 *reg_base;
+ int fifo_size;
+} MgaCardInfo;
+
+#define getMgaCardInfo(kd) ((MgaCardInfo *) ((kd)->card->driver))
+#define mgaCardInfo(kd) MgaCardInfo *mgac = getMgaCardInfo(kd)
+
+typedef struct _mgaScreenInfo {
+ VesaScreenPrivRec vesa;
+
+ KaaScreenInfoRec kaa;
+
+ int pitch;
+ int pw;
+} MgaScreenInfo;
+
+#define getMgaScreenInfo(kd) ((MgaScreenInfo *) ((kd)->screen->driver))
+#define mgaScreenInfo(kd) MgaScreenInfo *mgas = getMgaScreenInfo(kd)
+
+
+VOL8 *mmio;
+
+
+Bool
+mgaMapReg (KdCardInfo *card, MgaCardInfo *mgac);
+
+void
+mgaUnmapReg (KdCardInfo *card, MgaCardInfo *mgac);
+
+void
+mgaSetMMIO (KdCardInfo *card, MgaCardInfo *mgac);
+
+void
+mgaResetMMIO (KdCardInfo *card, MgaCardInfo *mgac);
+
+Bool
+mgaDrawSetup (ScreenPtr pScreen);
+
+Bool
+mgaDrawInit (ScreenPtr pScreen);
+
+void
+mgaDrawEnable (ScreenPtr pScreen);
+
+void
+mgaDrawDisable (ScreenPtr pScreen);
+
+void
+mgaDrawFini (ScreenPtr pScreen);
+
+extern KdCardFuncs mgaFuncs;
+
+
+void
+mgaWaitAvail (int n);
+
+void
+mgaWaitIdle (void);
+
+Bool
+mgaSetup (ScreenPtr pScreen, int dest_bpp, int wait);
+
+
+#if 0
+#define MGA_FALLBACK(x) \
+do { \
+ ErrorF x; \
+ return FALSE; \
+} while (0);
+#else
+#define MGA_FALLBACK(x) return FALSE;
+#endif
+
+#endif /* _MGA_H_ */
diff --git a/xorg-server/hw/kdrive/mga/mgadraw.c b/xorg-server/hw/kdrive/mga/mgadraw.c
new file mode 100644
index 000000000..d27e8c9cc
--- /dev/null
+++ b/xorg-server/hw/kdrive/mga/mgadraw.c
@@ -0,0 +1,324 @@
+/*
+ * Copyright © 2003-2004 Anders Carlsson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Anders Carlsson not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Anders Carlsson makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ANDERS CARLSSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "mga.h"
+#include "g400_common.h"
+#include "kaa.h"
+#include <unistd.h>
+
+CARD32 mgaRop[16] = {
+ /* GXclear */ MGA_ATYPE_RPL | 0x00000000, /* 0 */
+ /* GXand */ MGA_ATYPE_RSTR | 0x00080000, /* src AND dst */
+ /* GXandReverse */ MGA_ATYPE_RSTR | 0x00040000, /* src AND NOT dst */
+ /* GXcopy */ MGA_ATYPE_RSTR | 0x000c0000, /* src */
+ /* GXandInverted */ MGA_ATYPE_RSTR | 0x00020000, /* NOT src AND dst */
+ /* GXnoop */ MGA_ATYPE_RSTR | 0x000a0000, /* dst */
+ /* GXxor */ MGA_ATYPE_RSTR | 0x00060000, /* src XOR dst */
+ /* GXor */ MGA_ATYPE_RSTR | 0x000e0000, /* src OR dst */
+ /* GXnor */ MGA_ATYPE_RSTR | 0x00010000, /* NOT src AND NOT dst */
+ /* GXequiv */ MGA_ATYPE_RSTR | 0x00090000, /* NOT src XOR dst */
+ /* GXinvert */ MGA_ATYPE_RSTR | 0x00050000, /* NOT dst */
+ /* GXorReverse */ MGA_ATYPE_RSTR | 0x000d0000, /* src OR NOT dst */
+ /* GXcopyInverted */ MGA_ATYPE_RPL | 0x00030000, /* NOT src */
+ /* GXorInverted */ MGA_ATYPE_RSTR | 0x000b0000, /* NOT src OR dst */
+ /* GXnand */ MGA_ATYPE_RSTR | 0x00070000, /* NOT src OR NOT dst */
+ /* GXset */ MGA_ATYPE_RPL | 0x000f0000 /* 1 */
+};
+
+VOL8 *mmio;
+int fifo_size;
+int pitch, src_pitch;
+int dir;
+
+void
+mgaWaitAvail (int n)
+{
+ if (fifo_size < n) {
+ while ((fifo_size = MGA_IN32 (mmio, MGA_REG_FIFOSTATUS) & 0xff) < n)
+ ;
+ }
+
+ fifo_size -= n;
+}
+
+#define MGA_OUT8(mmio, a, v) (*(VOL8 *) ((mmio) + (a)) = (v))
+#define MGA_REG_CRTC_INDEX (0x1fd4)
+
+void
+mgaWaitIdle (void)
+{
+
+ mgaWaitAvail (2);
+ MGA_OUT32(mmio, MGA_REG_CACHEFLUSH, 0);
+ /* MGA_OUT8 (mmio, MGA_REG_CRTC_INDEX, 0); */
+ while (MGA_IN32 (mmio, MGA_REG_STATUS) & 0x10000)
+ ;
+}
+
+static void
+mgaWaitMarker (ScreenPtr pScreen, int marker)
+{
+ KdScreenPriv (pScreen);
+ mgaCardInfo (pScreenPriv);
+
+ mmio = mgac->reg_base;
+
+ mgaWaitIdle ();
+}
+
+Bool
+mgaSetup (ScreenPtr pScreen, int dest_bpp, int wait)
+{
+ KdScreenPriv (pScreen);
+ mgaScreenInfo (pScreenPriv);
+ mgaCardInfo (pScreenPriv);
+
+ fifo_size = 0;
+ mmio = mgac->reg_base;
+ pitch = mgas->pitch;
+
+ if (!mmio)
+ return FALSE;
+
+ mgaWaitAvail (wait + 4);
+ /* Set the format of the destination pixmap */
+ switch (dest_bpp) {
+ case 8:
+ MGA_OUT32 (mmio, MGA_REG_MACCESS, MGA_PW8);
+ break;
+ case 16:
+ MGA_OUT32 (mmio, MGA_REG_MACCESS, MGA_PW16);
+ break;
+ case 24:
+ case 32:
+ MGA_OUT32 (mmio, MGA_REG_MACCESS, MGA_PW24);
+ break;
+ }
+ MGA_OUT32 (mmio, MGA_REG_CXBNDRY, 0xffff0000);
+ MGA_OUT32 (mmio, MGA_REG_YTOP, 0x00000000);
+ MGA_OUT32 (mmio, MGA_REG_YBOT, 0x007fffff);
+
+ return TRUE;
+}
+
+static Bool
+mgaPrepareSolid (PixmapPtr pPixmap, int alu, Pixel pm, Pixel fg)
+{
+
+ KdScreenPriv(pPixmap->drawable.pScreen);
+ int cmd;
+ int dst_org;
+ /* We must pad pm and fg depending on the format of the
+ * destination pixmap
+ */
+ switch (pPixmap->drawable.bitsPerPixel) {
+ case 16:
+ fg |= fg << 16;
+ pm |= pm << 16;
+ break;
+ case 8:
+ fg |= (fg << 8) | (fg << 16) | (fg << 24);
+ pm |= (pm << 8) | (pm << 16) | (pm << 24);
+ break;
+ }
+
+ cmd = MGA_OPCOD_TRAP | MGA_DWGCTL_SOLID | MGA_DWGCTL_ARZERO | MGA_DWGCTL_SGNZERO |
+ MGA_DWGCTL_SHIFTZERO | mgaRop[alu];
+
+ dst_org = (int)pPixmap->devPrivate.ptr - (int)pScreenPriv->screen->memory_base;
+
+ mgaSetup (pPixmap->drawable.pScreen, pPixmap->drawable.bitsPerPixel, 5);
+ MGA_OUT32 (mmio, MGA_REG_DSTORG, dst_org);
+ MGA_OUT32 (mmio, MGA_REG_PITCH, pPixmap->devKind / (pPixmap->drawable.bitsPerPixel >> 3));
+ MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd);
+ MGA_OUT32 (mmio, MGA_REG_FCOL, fg);
+ MGA_OUT32 (mmio, MGA_REG_PLNWT, pm);
+
+ return TRUE;
+}
+
+static void
+mgaSolid (int x1, int y1, int x2, int y2)
+{
+ mgaWaitAvail (2);
+ MGA_OUT32 (mmio, MGA_REG_FXBNDRY, (x2 << 16) | (x1 & 0xffff));
+ MGA_OUT32 (mmio, MGA_REG_YDSTLEN | MGA_REG_EXEC, (y1 << 16) | (y2 - y1));
+}
+
+static void
+mgaDoneSolid (void)
+{
+}
+
+#define BLIT_LEFT 1
+#define BLIT_UP 4
+
+static Bool
+mgaPrepareCopy (PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap,
+ int dx, int dy, int alu, Pixel pm)
+{
+ KdScreenPriv(pSrcPixmap->drawable.pScreen);
+ int cmd;
+
+ cmd = MGA_OPCOD_BITBLT | MGA_DWGCTL_BFCOL | MGA_DWGCTL_SHIFTZERO | mgaRop[alu];
+
+ dir = 0;
+
+ if (dy < 0)
+ dir |= BLIT_UP;
+ if (dx < 0)
+ dir |= BLIT_LEFT;
+
+ mgaSetup (pSrcPixmap->drawable.pScreen,
+ pDstPixmap->drawable.bitsPerPixel, 7);
+
+ MGA_OUT32 (mmio, MGA_REG_SRCORG, ((int)pSrcPixmap->devPrivate.ptr -
+ (int)pScreenPriv->screen->memory_base));
+ MGA_OUT32 (mmio, MGA_REG_DSTORG, ((int)pDstPixmap->devPrivate.ptr -
+ (int)pScreenPriv->screen->memory_base));
+ MGA_OUT32 (mmio, MGA_REG_PITCH, (pDstPixmap->devKind /
+ (pDstPixmap->drawable.bitsPerPixel >> 3)));
+ src_pitch = pSrcPixmap->devKind / (pSrcPixmap->drawable.bitsPerPixel >> 3);
+
+ MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd);
+ MGA_OUT32 (mmio, MGA_REG_SGN, dir);
+ MGA_OUT32 (mmio, MGA_REG_PLNWT, pm);
+ MGA_OUT32 (mmio, MGA_REG_AR5, src_pitch * (dy < 0 ? -1 : 1) );
+
+ return TRUE;
+}
+
+static void
+mgaCopy (int srcX, int srcY, int dstX, int dstY, int w, int h)
+{
+ int start, end;
+ if (dir & BLIT_UP)
+ {
+ srcY += h - 1;
+ dstY += h - 1;
+ }
+
+ w--;
+ start = end = srcY * src_pitch + srcX;
+
+ if (dir & BLIT_LEFT)
+ start += w;
+ else
+ end += w;
+
+ mgaWaitAvail (4);
+ MGA_OUT32 (mmio, MGA_REG_AR0, end);
+ MGA_OUT32 (mmio, MGA_REG_AR3, start);
+ MGA_OUT32 (mmio, MGA_REG_FXBNDRY, ((dstX + w) << 16) | (dstX & 0xffff));
+ MGA_OUT32 (mmio, MGA_REG_YDSTLEN | MGA_REG_EXEC, (dstY << 16) | h);
+}
+
+static void
+mgaDoneCopy (void)
+{
+}
+
+#if 0
+static Bool
+mgaUploadToScreen(PixmapPtr pDst, char *src, int src_pitch) {
+ /*fprintf(stderr,"Upload to Screen %p [%d]\n",src,src_pitch);*/
+ return TRUE;
+}
+#endif
+
+Bool
+mgaDrawInit (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ mgaScreenInfo (pScreenPriv);
+ KdCardInfo *card = pScreenPriv->card;
+
+ memset(&mgas->kaa, 0, sizeof(KaaScreenInfoRec));
+ mgas->kaa.waitMarker = mgaWaitMarker;
+ mgas->kaa.PrepareSolid = mgaPrepareSolid;
+ mgas->kaa.Solid = mgaSolid;
+ mgas->kaa.DoneSolid = mgaDoneSolid;
+ mgas->kaa.PrepareCopy = mgaPrepareCopy;
+ mgas->kaa.Copy = mgaCopy;
+ mgas->kaa.DoneCopy = mgaDoneCopy;
+ /* In PW24 mode, we need to align to "3 64-bytes" */
+ mgas->kaa.offsetAlign = 192;
+ /* Pitch alignment is in sets of 32 pixels, and we need to cover 32bpp, so
+ * 128 bytes
+ */
+ mgas->kaa.pitchAlign = 128;
+ mgas->kaa.flags = KAA_OFFSCREEN_PIXMAPS;
+
+ if (card->attr.deviceID == MGA_G4XX_DEVICE_ID) {
+ mgas->kaa.CheckComposite = mgaCheckComposite;
+ mgas->kaa.PrepareComposite = mgaPrepareComposite;
+ mgas->kaa.Composite = mgaComposite;
+ mgas->kaa.DoneComposite = mgaDoneComposite;
+ }
+
+ /*mgas->kaa.UploadToScreen=mgaUploadToScreen;*/
+
+ if (!kaaDrawInit (pScreen, &mgas->kaa))
+ return FALSE;
+
+ return TRUE;
+}
+
+void
+mgaDrawEnable (ScreenPtr pScreen)
+{
+ KdScreenPriv (pScreen);
+ mgaScreenInfo (pScreenPriv);
+
+ mgas->pitch = pScreenPriv->screen->width;
+
+ switch (pScreenPriv->screen->fb[0].depth) {
+ case 8:
+ mgas->pw = MGA_PW8;
+ break;
+ case 16:
+ mgas->pw = MGA_PW16;
+ break;
+ case 24:
+ case 32:
+ mgas->pw = MGA_PW24;
+ break;
+ default:
+ FatalError ("unsupported pixel format");
+ }
+
+ kaaMarkSync (pScreen);
+}
+
+void
+mgaDrawDisable (ScreenPtr pScreen)
+{
+ kaaWaitSync(pScreen);
+}
+
+void
+mgaDrawFini (ScreenPtr pScreen)
+{
+}
+
diff --git a/xorg-server/hw/kdrive/mga/mgastub.c b/xorg-server/hw/kdrive/mga/mgastub.c
new file mode 100644
index 000000000..61e6963b8
--- /dev/null
+++ b/xorg-server/hw/kdrive/mga/mgastub.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2003 Anders Carlsson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Anders Carlsson not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Anders Carlsson makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ANDERS CARLSSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "mga.h"
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+
+ if (LinuxFindPci (0x102b, 0x0525, 0, &attr))
+ KdCardInfoAdd (&mgaFuncs, &attr, 0);
+}
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdOsAddInputDrivers ();
+ KdInitInput ();
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+ vesaUseMsg();
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ int ret;
+
+ if (!(ret = vesaProcessArgument (argc, argv, i)))
+ ret = KdProcessArgument(argc, argv, i);
+ return ret;
+}
diff --git a/xorg-server/hw/kdrive/neomagic/Makefile.am b/xorg-server/hw/kdrive/neomagic/Makefile.am
new file mode 100644
index 000000000..b449c37c5
--- /dev/null
+++ b/xorg-server/hw/kdrive/neomagic/Makefile.am
@@ -0,0 +1,49 @@
+if KDRIVEFBDEV
+FBDEV_INCLUDES =-I$(top_srcdir)/hw/kdrive/fbdev
+FBDEV_LIBS = $(top_builddir)/hw/kdrive/fbdev/libfbdev.a
+endif
+
+if KDRIVEVESA
+VESA_INCLUDES = -I$(top_srcdir)/hw/kdrive/vesa
+VESA_LIBS = $(top_builddir)/hw/kdrive/vesa/libvesa.a
+endif
+
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ $(FBDEV_INCLUDES) \
+ $(VESA_INCLUDES) \
+ @KDRIVE_CFLAGS@
+
+bin_PROGRAMS = Xneomagic
+
+noinst_LIBRARIES = libneomagic.a
+
+libneomagic_a_SOURCES = \
+ neomagic.c \
+ neomagic.h \
+ neo_draw.c
+
+Xneomagic_SOURCES = \
+ neomagicstub.c
+
+NEOMAGIC_LIBS = \
+ libneomagic.a \
+ ${FBDEV_LIBS} \
+ ${VESA_LIBS} \
+ @KDRIVE_LIBS@
+
+if GLX
+Xneomagic_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
+Xneomagic_LDADD = \
+ $(NEOMAGIC_LIBS) \
+ @KDRIVE_LIBS@ \
+ @XSERVER_LIBS@
+
+Xneomagic_DEPENDENCIES = \
+ libneomagic.a \
+ @KDRIVE_LOCAL_LIBS@
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/neomagic/Makefile.in b/xorg-server/hw/kdrive/neomagic/Makefile.in
new file mode 100644
index 000000000..db610a6dc
--- /dev/null
+++ b/xorg-server/hw/kdrive/neomagic/Makefile.in
@@ -0,0 +1,723 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xneomagic$(EXEEXT)
+subdir = hw/kdrive/neomagic
+DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libneomagic_a_AR = $(AR) $(ARFLAGS)
+libneomagic_a_LIBADD =
+am_libneomagic_a_OBJECTS = neomagic.$(OBJEXT) neo_draw.$(OBJEXT)
+libneomagic_a_OBJECTS = $(am_libneomagic_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xneomagic_OBJECTS = neomagicstub.$(OBJEXT)
+Xneomagic_OBJECTS = $(am_Xneomagic_OBJECTS)
+am__DEPENDENCIES_1 = libneomagic.a $(FBDEV_LIBS) $(VESA_LIBS)
+Xneomagic_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(Xneomagic_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libneomagic_a_SOURCES) $(Xneomagic_SOURCES)
+DIST_SOURCES = $(libneomagic_a_SOURCES) $(Xneomagic_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+@KDRIVEFBDEV_TRUE@FBDEV_INCLUDES = -I$(top_srcdir)/hw/kdrive/fbdev
+@KDRIVEFBDEV_TRUE@FBDEV_LIBS = $(top_builddir)/hw/kdrive/fbdev/libfbdev.a
+@KDRIVEVESA_TRUE@VESA_INCLUDES = -I$(top_srcdir)/hw/kdrive/vesa
+@KDRIVEVESA_TRUE@VESA_LIBS = $(top_builddir)/hw/kdrive/vesa/libvesa.a
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ $(FBDEV_INCLUDES) \
+ $(VESA_INCLUDES) \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libneomagic.a
+libneomagic_a_SOURCES = \
+ neomagic.c \
+ neomagic.h \
+ neo_draw.c
+
+Xneomagic_SOURCES = \
+ neomagicstub.c
+
+NEOMAGIC_LIBS = \
+ libneomagic.a \
+ ${FBDEV_LIBS} \
+ ${VESA_LIBS} \
+ @KDRIVE_LIBS@
+
+@GLX_TRUE@Xneomagic_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xneomagic_LDADD = \
+ $(NEOMAGIC_LIBS) \
+ @KDRIVE_LIBS@ \
+ @XSERVER_LIBS@
+
+Xneomagic_DEPENDENCIES = \
+ libneomagic.a \
+ @KDRIVE_LOCAL_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/neomagic/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/neomagic/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libneomagic.a: $(libneomagic_a_OBJECTS) $(libneomagic_a_DEPENDENCIES)
+ -rm -f libneomagic.a
+ $(libneomagic_a_AR) libneomagic.a $(libneomagic_a_OBJECTS) $(libneomagic_a_LIBADD)
+ $(RANLIB) libneomagic.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xneomagic$(EXEEXT): $(Xneomagic_OBJECTS) $(Xneomagic_DEPENDENCIES)
+ @rm -f Xneomagic$(EXEEXT)
+ $(Xneomagic_LINK) $(Xneomagic_OBJECTS) $(Xneomagic_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/neo_draw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/neomagic.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/neomagicstub.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/neomagic/README b/xorg-server/hw/kdrive/neomagic/README
new file mode 100644
index 000000000..2b086d75c
--- /dev/null
+++ b/xorg-server/hw/kdrive/neomagic/README
@@ -0,0 +1,15 @@
+Neomagic KDrive driver for xserver
+
+This is a very simple implementation for Neomagic based cards.
+Almost all functions are handled by the VESA driver, and
+only solid drawing and bitblt are done with acceleration,
+
+This driver has been tested in MagicGraph 256AV+(NM2230) card
+but it should work on other cards as well.
+
+The only warning is to choose a working mode. You can ask
+for supported modes using -listmodes. I use -mode 0x117.
+
+--
+Franco Catrin L.
+fcatrin@tuxpan.com
diff --git a/xorg-server/hw/kdrive/neomagic/neo_draw.c b/xorg-server/hw/kdrive/neomagic/neo_draw.c
new file mode 100644
index 000000000..89452b3d8
--- /dev/null
+++ b/xorg-server/hw/kdrive/neomagic/neo_draw.c
@@ -0,0 +1,210 @@
+/*
+ *
+ * Copyright © 2004 Franco Catrin
+ *
+ * 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 Franco Catrin not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Franco Catrin makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * FRANCO CATRIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL FRANCO CATRIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "neomagic.h"
+
+#include <X11/Xmd.h>
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mistruct.h"
+#include "dixfontstr.h"
+#include "fb.h"
+#include "migc.h"
+#include "miline.h"
+#include "picturestr.h"
+
+NeoMMIO *mmio;
+NeoScreenInfo *screen;
+NeoCardInfo *card;
+CARD32 fgColor;
+CARD32 rop;
+
+CARD32 neoRop[16] = {
+ 0x000000, /* GXclear */
+ 0x080000, /* GXand */
+ 0x040000, /* GXandReverse */
+ 0x0c0000, /* GXcopy */
+ 0x020000, /* GXandInvert */
+ 0x0a0000, /* GXnoop */
+ 0x060000, /* GXxor */
+ 0x0e0000, /* GXor */
+ 0x010000, /* GXnor */
+ 0x090000, /* GXequiv */
+ 0x050000, /* GXinvert */
+ 0x0d0000, /* GXorReverse */
+ 0x030000, /* GXcopyInvert */
+ 0x0b0000, /* GXorInverted */
+ 0x070000, /* GXnand */
+ 0x0f0000 /* GXset */
+};
+
+static void neoWaitIdle(NeoCardInfo *neoc)
+{
+ // if MMIO is not working it may halt the machine
+ unsigned int i = 0;
+ while ((mmio->bltStat & 1) && ++i<100000);
+}
+
+static void neoWaitMarker (ScreenPtr pScreen, int marker)
+{
+ KdScreenPriv(pScreen);
+ neoCardInfo(pScreenPriv);
+
+ neoWaitIdle(neoc);
+}
+
+
+static Bool neoPrepareSolid(PixmapPtr pPixmap,
+ int alu,
+ Pixel pm,
+ Pixel fg)
+{
+ FbBits depthMask = FbFullMask(pPixmap->drawable.depth);
+ if ((pm & depthMask) != depthMask) {
+ return FALSE;
+ } else {
+ fgColor = fg;
+ if (alu!=3) DBGOUT("used ROP %i\n", alu);
+ rop = neoRop[alu];
+ return TRUE;
+ }
+}
+
+static void neoSolid (int x1, int y1, int x2, int y2)
+{
+ int x, y, w, h;
+ x = x1;
+ y = y1;
+ w = x2-x1;
+ h = y2-y1;
+ neoWaitIdle(card);
+ mmio->fgColor = fgColor;
+ mmio->bltCntl =
+ NEO_BC3_FIFO_EN |
+ NEO_BC0_SRC_IS_FG |
+ NEO_BC3_SKIP_MAPPING | rop;
+ mmio->dstStart = y * screen->pitch + x * screen->depth;
+
+ mmio->xyExt = (unsigned long)(h << 16) | (w & 0xffff);
+
+}
+
+
+static void neoDoneSolid(void)
+{
+}
+
+static Bool neoPrepareCopy (PixmapPtr pSrcPixpam, PixmapPtr pDstPixmap,
+ int dx, int dy, int alu, Pixel pm)
+{
+ rop = neoRop[alu];
+ return TRUE;
+}
+
+static void neoCopy (int srcX, int srcY, int dstX, int dstY, int w, int h)
+{
+ neoWaitIdle(card);
+
+ if ((dstY < srcY) || ((dstY == srcY) && (dstX < srcX))) {
+ mmio->bltCntl =
+ NEO_BC3_FIFO_EN |
+ NEO_BC3_SKIP_MAPPING | rop;
+ mmio->srcStart = srcY * screen->pitch + srcX * screen->depth;
+ mmio->dstStart = dstY * screen->pitch + dstX * screen->depth;
+
+ mmio->xyExt = (unsigned long)(h << 16) | (w & 0xffff);
+ } else {
+ mmio->bltCntl = NEO_BC0_X_DEC |
+ NEO_BC0_DST_Y_DEC |
+ NEO_BC0_SRC_Y_DEC |
+ NEO_BC3_FIFO_EN |
+ NEO_BC3_SKIP_MAPPING | rop;
+ srcX+=w-1;
+ dstX+=w-1;
+ srcY+=h-1;
+ dstY+=h-1;
+ mmio->srcStart = srcY * screen->pitch + srcX * screen->depth;
+ mmio->dstStart = dstY * screen->pitch + dstX * screen->depth;
+ mmio->xyExt = (unsigned long)(h << 16) | (w & 0xffff);
+ }
+
+}
+
+static void neoDoneCopy (void)
+{
+}
+
+
+Bool neoDrawInit (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ neoScreenInfo(pScreenPriv);
+
+ ENTER();
+
+ memset(&neos->kaa, 0, sizeof(KaaScreenInfoRec));
+ neos->kaa.waitMarker = neoWaitMarker;
+ neos->kaa.PrepareSolid = neoPrepareSolid;
+ neos->kaa.Solid = neoSolid;
+ neos->kaa.DoneSolid = neoDoneSolid;
+ neos->kaa.PrepareCopy = neoPrepareCopy;
+ neos->kaa.Copy = neoCopy;
+ neos->kaa.DoneCopy = neoDoneCopy;
+
+ if (!kaaDrawInit (pScreen, &neos->kaa)) {
+ return FALSE;
+ }
+ LEAVE();
+ return TRUE;
+}
+
+void neoDrawEnable (ScreenPtr pScreen)
+{
+ ENTER();
+ SetupNeo(pScreen);
+ screen = neos;
+ card = neoc;
+ mmio = neoc->mmio;
+ screen->depth = (screen->backendScreen.mode.BitsPerPixel+7)/8;
+ screen->pitch = screen->backendScreen.mode.BytesPerScanLine;
+ DBGOUT("NEO depth=%x, pitch=%x\n", screen->depth, screen->pitch);
+ LEAVE();
+}
+
+void neoDrawDisable (ScreenPtr pScreen)
+{
+ ENTER();
+ LEAVE();
+}
+
+void neoDrawFini (ScreenPtr pScreen)
+{
+ ENTER();
+ LEAVE();
+}
+
diff --git a/xorg-server/hw/kdrive/neomagic/neomagic.c b/xorg-server/hw/kdrive/neomagic/neomagic.c
new file mode 100644
index 000000000..ac0c7569a
--- /dev/null
+++ b/xorg-server/hw/kdrive/neomagic/neomagic.c
@@ -0,0 +1,335 @@
+/*
+ *
+ * Copyright © 2004 Franco Catrin
+ *
+ * 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 Franco Catrin not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Franco Catrin makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * FRANCO CATRIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL FRANCO CATRIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "neomagic.h"
+#include <sys/io.h>
+
+struct NeoChipInfo neoChips[] = {
+ {NEO_VENDOR, 0x0001, CAP_NM2070, "MagicGraph 128(NM2070)",
+ 896, 65000, 2048, 0x100, 1024, 1024, 1024},
+ {NEO_VENDOR, 0x0002, CAP_NM2090, "MagicGraph 128V(NM2090)",
+ 1152, 80000, 2048, 0x100, 2048, 1024, 1024},
+ {NEO_VENDOR, 0x0003, CAP_NM2090, "MagicGraph 128ZV(NM2093)",
+ 1152, 80000, 2048, 0x100, 2048, 1024, 1024},
+ {NEO_VENDOR, 0x0083, CAP_NM2097, "MagicGraph 128ZV+(NM2097)",
+ 1152, 80000, 1024, 0x100, 2048, 1024, 1024},
+ {NEO_VENDOR, 0x0004, CAP_NM2097, "MagicGraph 128XD(NM2160)",
+ 2048, 90000, 1024, 0x100, 2048, 1024, 1024},
+ {NEO_VENDOR, 0x0005, CAP_NM2200, "MagicGraph 256AV(NM2200)",
+ 2560, 110000, 1024, 0x1000, 4096, 1280, 1024},
+ {NEO_VENDOR, 0x0025, CAP_NM2200, "MagicGraph 256AV+(NM2230)",
+ 3008, 110000, 1024, 0x1000, 4096, 1280, 1024},
+ {NEO_VENDOR, 0x0006, CAP_NM2200, "MagicGraph 256ZX(NM2360)",
+ 4096, 110000, 1024, 0x1000, 4096, 1280, 1024},
+ {NEO_VENDOR, 0x0016, CAP_NM2200, "MagicGraph 256XL+(NM2380)",
+ 6144, 110000, 1024, 0x1000, 8192, 1280, 1024},
+ {0, 0, 0, NULL},
+};
+
+static Bool
+neoCardInit(KdCardInfo *card)
+{
+ NeoCardInfo *neoc;
+ struct NeoChipInfo *chip;
+
+ neoc =(NeoCardInfo *) xalloc(sizeof(NeoCardInfo));
+ if(!neoc) {
+ return FALSE;
+ }
+
+ if(!vesaInitialize(card, &neoc->backendCard)) {
+ xfree(neoc);
+ return FALSE;
+ }
+
+ for(chip = neoChips; chip->name != NULL; ++chip) {
+ if(chip->device == card->attr.deviceID) {
+ neoc->chip = chip;
+ break;
+ }
+ }
+
+ ErrorF("Using Neomagic card: %s\n", neoc->chip->name);
+
+ neoMapReg(card, neoc);
+
+ card->driver = neoc;
+
+ return TRUE;
+}
+
+static Bool
+neoScreenInit(KdScreenInfo *screen)
+{
+ NeoScreenInfo *neos;
+ int screen_size, memory;
+
+ neos = xcalloc(sizeof(NeoScreenInfo), 1);
+ if(neos == NULL) {
+ return FALSE;
+ }
+
+ memset (neos, '\0', sizeof (NeoScreenInfo));
+
+
+ if(!vesaScreenInitialize(screen, &neos->backendScreen)) {
+ xfree(neos);
+ return FALSE;
+ }
+
+ screen->softCursor = TRUE; // no hardware color cursor available
+
+ neos->screen = neos->backendScreen.fb;
+
+ memory = neos->backendScreen.fb_size;
+ screen_size = screen->fb[0].byteStride * screen->height;
+ memory -= screen_size;
+
+ if(memory > screen->fb[0].byteStride) {
+ neos->off_screen = neos->screen + screen_size;
+ neos->off_screen_size = memory;
+ } else {
+ neos->off_screen = 0;
+ neos->off_screen_size = 0;
+ }
+
+ screen->driver = neos;
+
+ return TRUE;
+}
+
+static Bool
+neoInitScreen(ScreenPtr pScreen)
+{
+ return vesaInitScreen(pScreen);
+}
+
+static Bool
+neoFinishInitScreen(ScreenPtr pScreen)
+{
+ return vesaFinishInitScreen(pScreen);
+}
+
+static Bool
+neoCreateResources(ScreenPtr pScreen)
+{
+ return vesaCreateResources(pScreen);
+}
+
+void
+neoPreserve(KdCardInfo *card)
+{
+ vesaPreserve(card);
+}
+
+CARD8
+neoGetIndex(NeoCardInfo *nvidiac, CARD16 addr, CARD8 index)
+{
+ outb(index, addr);
+
+ return inb(addr+1);
+}
+
+void
+neoSetIndex(NeoCardInfo *nvidiac, CARD16 addr, CARD8 index, CARD8 val)
+{
+ outb(index, addr);
+ outb(val, addr+1);
+}
+
+static void neoLock(NeoCardInfo *neoc){
+ CARD8 cr11;
+ neoSetIndex(neoc, 0x3ce, 0x09, 0x00);
+ neoSetIndex(neoc, 0x3ce, 0x11, 0x0); // disable MMIO and linear mode
+ cr11 = neoGetIndex(neoc, 0x3d4, 0x11);
+ neoSetIndex(neoc, 0x3d4, 0x11, cr11 | 0x80);
+}
+
+static void neoUnlock(NeoCardInfo *neoc){
+ CARD8 cr11;
+ cr11 = neoGetIndex(neoc, 0x3d4, 0x11);
+ neoSetIndex(neoc, 0x3d4, 0x11, cr11 & 0x7F);
+ neoSetIndex(neoc, 0x3ce, 0x09, 0x26);
+ neoSetIndex(neoc, 0x3ce, 0x11, 0xc0); // enable MMIO and linear mode
+}
+
+
+Bool
+neoMapReg(KdCardInfo *card, NeoCardInfo *neoc)
+{
+ neoc->reg_base = card->attr.address[1] & 0xFFF80000;
+ if(!neoc->reg_base) {
+ return FALSE;
+ }
+
+ neoc->mmio = KdMapDevice(neoc->reg_base, NEO_REG_SIZE(card));
+ if(!neoc->mmio) {
+ return FALSE;
+ }
+
+ KdSetMappedMode(neoc->reg_base, NEO_REG_SIZE(card), KD_MAPPED_MODE_REGISTERS);
+
+ return TRUE;
+}
+
+void
+neoUnmapReg(KdCardInfo *card, NeoCardInfo *neoc)
+{
+ if(neoc->reg_base)
+ {
+ neoSetIndex(neoc, 0x3ce, 0x82,0);
+ KdResetMappedMode(neoc->reg_base, NEO_REG_SIZE(card), KD_MAPPED_MODE_REGISTERS);
+ KdUnmapDevice((void *)neoc->mmio, NEO_REG_SIZE(card));
+ neoc->reg_base = 0;
+ }
+}
+
+static void
+neoSetMMIO(KdCardInfo *card, NeoCardInfo *neoc)
+{
+ if(!neoc->reg_base)
+ neoMapReg(card, neoc);
+ neoUnlock(neoc);
+}
+
+static void
+neoResetMMIO(KdCardInfo *card, NeoCardInfo *neoc)
+{
+ neoUnmapReg(card, neoc);
+ neoLock(neoc);
+}
+
+
+Bool
+neoEnable(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ neoCardInfo(pScreenPriv);
+
+ if(!vesaEnable(pScreen)) {
+ return FALSE;
+ }
+
+ neoSetMMIO(pScreenPriv->card, neoc);
+ return TRUE;
+}
+
+void
+neoDisable(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ neoCardInfo(pScreenPriv);
+
+ neoResetMMIO(pScreenPriv->card, neoc);
+
+ vesaDisable(pScreen);
+}
+
+static void
+neoGetColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ vesaGetColors(pScreen, fb, n, pdefs);
+}
+
+static void
+neoPutColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ vesaPutColors(pScreen, fb, n, pdefs);
+}
+
+static Bool
+neoDPMS(ScreenPtr pScreen, int mode)
+{
+ return vesaDPMS(pScreen, mode);
+}
+
+static void
+neoRestore(KdCardInfo *card)
+{
+ NeoCardInfo *neoc = card->driver;
+
+ neoResetMMIO(card, neoc);
+ vesaRestore(card);
+}
+
+static void
+neoScreenFini(KdScreenInfo *screen)
+{
+ NeoScreenInfo *neos =(NeoScreenInfo *) screen->driver;
+
+ vesaScreenFini(screen);
+ xfree(neos);
+ screen->driver = 0;
+}
+
+static void
+neoCardFini(KdCardInfo *card)
+{
+ NeoCardInfo *neoc = card->driver;
+
+ neoUnmapReg(card, neoc);
+ vesaCardFini(card);
+}
+
+#define neoCursorInit 0 // initCursor
+#define neoCursorEnable 0 // enableCursor
+#define neoCursorDisable 0 // disableCursor
+#define neoCursorFini 0 // finiCursor */
+#define neoRecolorCursor 0 // recolorCursor */
+//#define neoDrawInit 0 // initAccel
+//#define neoDrawEnable 0 // enableAccel
+//#define neoDrawSync 0 // syncAccel
+//#define neoDrawDisable 0 // disableAccel
+//#define neoDrawFini 0 // finiAccel
+
+KdCardFuncs neoFuncs = {
+ neoCardInit, // cardinit
+ neoScreenInit, // scrinit
+ neoInitScreen, // initScreen
+ neoFinishInitScreen, // finishInitScreen
+ neoCreateResources, // createRes
+ neoPreserve, // preserve
+ neoEnable, // enable
+ neoDPMS, // dpms
+ neoDisable, // disable
+ neoRestore, // restore
+ neoScreenFini, // scrfini
+ neoCardFini, // cardfini
+
+ neoCursorInit, // initCursor
+ neoCursorEnable, // enableCursor
+ neoCursorDisable, // disableCursor
+ neoCursorFini, // finiCursor
+ neoRecolorCursor, // recolorCursor
+
+ neoDrawInit, // initAccel
+ neoDrawEnable, // enableAccel
+ neoDrawDisable, // disableAccel
+ neoDrawFini, // finiAccel
+
+ neoGetColors, // getColors
+ neoPutColors, // putColors
+};
diff --git a/xorg-server/hw/kdrive/neomagic/neomagic.h b/xorg-server/hw/kdrive/neomagic/neomagic.h
new file mode 100644
index 000000000..9b100051b
--- /dev/null
+++ b/xorg-server/hw/kdrive/neomagic/neomagic.h
@@ -0,0 +1,210 @@
+/*
+ *
+ * Copyright © 2004 Franco Catrin
+ *
+ * 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 Franco Catrin not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Franco Catrin makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * FRANCO CATRIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL FRANCO CATRIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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 _NEOMAGIC_H_
+#define _NEOMAGIC_H_
+#include <backend.h>
+#include "kxv.h"
+#include "klinux.h"
+#include "vesa.h"
+
+
+#define DBGOUT DebugF
+
+#define ENTER() DBGOUT("Enter %s\n", __FUNCTION__)
+#define LEAVE() DBGOUT("Leave %s\n", __FUNCTION__)
+
+#define NEO_VENDOR 0x10c8
+#define CAP_NM2070 0x01 /* If it's a NM2070 series */
+#define CAP_NM2090 0x02 /* If it's a NM2090 series */
+#define CAP_NM2097 0x03 /* If it's a NM2097 series */
+#define CAP_NM2200 0x04 /* If it's a NM2200 series */
+
+#define NEO_BS0_BLT_BUSY 0x00000001
+#define NEO_BS0_FIFO_AVAIL 0x00000002
+#define NEO_BS0_FIFO_PEND 0x00000004
+
+#define NEO_BC0_DST_Y_DEC 0x00000001
+#define NEO_BC0_X_DEC 0x00000002
+#define NEO_BC0_SRC_TRANS 0x00000004
+#define NEO_BC0_SRC_IS_FG 0x00000008
+#define NEO_BC0_SRC_Y_DEC 0x00000010
+#define NEO_BC0_FILL_PAT 0x00000020
+#define NEO_BC0_SRC_MONO 0x00000040
+#define NEO_BC0_SYS_TO_VID 0x00000080
+
+#define NEO_BC1_DEPTH8 0x00000100
+#define NEO_BC1_DEPTH16 0x00000200
+#define NEO_BC1_X_320 0x00000400
+#define NEO_BC1_X_640 0x00000800
+#define NEO_BC1_X_800 0x00000c00
+#define NEO_BC1_X_1024 0x00001000
+#define NEO_BC1_X_1152 0x00001400
+#define NEO_BC1_X_1280 0x00001800
+#define NEO_BC1_X_1600 0x00001c00
+#define NEO_BC1_DST_TRANS 0x00002000
+#define NEO_BC1_MSTR_BLT 0x00004000
+#define NEO_BC1_FILTER_Z 0x00008000
+
+#define NEO_BC2_WR_TR_DST 0x00800000
+
+#define NEO_BC3_SRC_XY_ADDR 0x01000000
+#define NEO_BC3_DST_XY_ADDR 0x02000000
+#define NEO_BC3_CLIP_ON 0x04000000
+#define NEO_BC3_FIFO_EN 0x08000000
+#define NEO_BC3_BLT_ON_ADDR 0x10000000
+#define NEO_BC3_SKIP_MAPPING 0x80000000
+
+#define NEO_MODE1_DEPTH8 0x0100
+#define NEO_MODE1_DEPTH16 0x0200
+#define NEO_MODE1_DEPTH24 0x0300
+#define NEO_MODE1_X_320 0x0400
+#define NEO_MODE1_X_640 0x0800
+#define NEO_MODE1_X_800 0x0c00
+#define NEO_MODE1_X_1024 0x1000
+#define NEO_MODE1_X_1152 0x1400
+#define NEO_MODE1_X_1280 0x1800
+#define NEO_MODE1_X_1600 0x1c00
+#define NEO_MODE1_BLT_ON_ADDR 0x2000
+
+typedef volatile CARD8 VOL8;
+typedef volatile CARD16 VOL16;
+typedef volatile CARD32 VOL32;
+
+#define NEO_REG_SIZE(c) (0x200000L)
+
+typedef volatile struct {
+ CARD32 bltStat;
+ CARD32 bltCntl;
+ CARD32 xpColor;
+ CARD32 fgColor;
+ CARD32 bgColor;
+ CARD32 pitch;
+ CARD32 clipLT;
+ CARD32 clipRB;
+ CARD32 srcBitOffset;
+ CARD32 srcStart;
+ CARD32 reserved0;
+ CARD32 dstStart;
+ CARD32 xyExt;
+
+ CARD32 reserved1[19];
+
+ CARD32 pageCntl;
+ CARD32 pageBase;
+ CARD32 postBase;
+ CARD32 postPtr;
+ CARD32 dataPtr;
+} NeoMMIO;
+
+typedef struct _neoCardInfo {
+ VesaCardPrivRec backendCard;
+
+ CARD32 reg_base;
+ NeoMMIO *mmio;
+ int dstOrg;
+ int dstPitch;
+ int dstPixelWidth;
+
+ int srcOrg;
+ int srcPitch;
+ int srcPixelWidth;
+
+ struct NeoChipInfo *chip;
+
+ CARD32 bltCntl;
+
+} NeoCardInfo;
+
+struct NeoChipInfo {
+ CARD16 vendor;
+ CARD16 device;
+ CARD8 caps;
+ char *name;
+ int videoRam;
+ int maxClock;
+ int cursorMem;
+ int cursorOff;
+ int linearSize;
+ int maxWidth;
+ int maxHeight;
+};
+
+#define getNeoCardInfo(kd) ((NeoCardInfo *) ((kd)->card->driver))
+#define neoCardInfo(kd) NeoCardInfo *neoc = getNeoCardInfo(kd)
+
+typedef struct _neoScreenInfo {
+ VesaScreenPrivRec backendScreen;
+
+ CARD8 *screen;
+ CARD8 *off_screen;
+ int off_screen_size;
+ int pitch;
+ int depth;
+ KdVideoAdaptorPtr pAdaptor;
+ KaaScreenInfoRec kaa;
+} NeoScreenInfo;
+
+#define getNeoScreenInfo(kd) ((NeoScreenInfo *) ((kd)->screen->driver))
+#define neoScreenInfo(kd) NeoScreenInfo *neos = getNeoScreenInfo(kd)
+
+#define SetupNeo(s) KdScreenPriv(s); \
+ neoCardInfo(pScreenPriv); \
+ neoScreenInfo(pScreenPriv);
+
+void
+neoPreserve (KdCardInfo *card);
+
+Bool
+neoEnable (ScreenPtr pScreen);
+
+void
+neoDisable (ScreenPtr pScreen);
+
+Bool
+neoMapReg (KdCardInfo *card, NeoCardInfo *nvidiac);
+
+void
+neoUnmapReg (KdCardInfo *card, NeoCardInfo *nvidiac);
+
+CARD8
+neoGetIndex (NeoCardInfo *nvidiac, CARD16 addr, CARD8 id);
+
+void
+neoSetIndex (NeoCardInfo *nvidiac, CARD16 addr, CARD8 id, CARD8 val);
+
+Bool
+neoDrawInit (ScreenPtr pScreen);
+
+void
+neoDrawEnable (ScreenPtr pScreen);
+
+void
+neoDrawDisable (ScreenPtr pScreen);
+
+void
+neoDrawFini (ScreenPtr pScreen);
+
+extern KdCardFuncs neoFuncs;
+
+#endif /* _NEOMAGIC_H_ */
diff --git a/xorg-server/hw/kdrive/neomagic/neomagicstub.c b/xorg-server/hw/kdrive/neomagic/neomagicstub.c
new file mode 100644
index 000000000..c7ec83b44
--- /dev/null
+++ b/xorg-server/hw/kdrive/neomagic/neomagicstub.c
@@ -0,0 +1,73 @@
+/*
+ *
+ * Copyright © 2004 Franco Catrin
+ *
+ * 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 Franco Catrin not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Franco Catrin makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * FRANCO CATRIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL FRANCO CATRIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "neomagic.h"
+
+extern struct NeoChipInfo neoChips[];
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+ struct NeoChipInfo *chip;
+
+ for (chip = neoChips; chip->name != NULL; ++chip) {
+ int j = 0;
+ while (LinuxFindPci(chip->vendor, chip->device, j++, &attr)) {
+ KdCardInfoAdd(&neoFuncs, &attr, 0);
+ }
+ }
+}
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdOsAddInputDrivers ();
+ KdInitInput ();
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+ vesaUseMsg();
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ int ret;
+
+ if (!(ret = vesaProcessArgument (argc, argv, i)))
+ ret = KdProcessArgument(argc, argv, i);
+ return ret;
+}
diff --git a/xorg-server/hw/kdrive/nvidia/Makefile.am b/xorg-server/hw/kdrive/nvidia/Makefile.am
new file mode 100644
index 000000000..81736c311
--- /dev/null
+++ b/xorg-server/hw/kdrive/nvidia/Makefile.am
@@ -0,0 +1,39 @@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_CFLAGS@
+
+bin_PROGRAMS = Xnvidia
+
+noinst_LIBRARIES = libnvidia.a
+
+# nvidiavideo.c
+
+libnvidia_a_SOURCES = \
+ nvidia.c \
+ nvidiadraw.c \
+ nvidia.h \
+ nvidiadraw.h
+
+Xnvidia_SOURCES = \
+ nvidiastub.c
+
+NVIDIA_LIBS = \
+ libnvidia.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a \
+ @KDRIVE_LIBS@
+
+if GLX
+Xnvidia_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
+Xnvidia_LDADD = \
+ $(NVIDIA_LIBS) \
+ @KDRIVE_LIBS@
+
+Xnvidia_DEPENDENCIES = \
+ libnvidia.a \
+ @KDRIVE_LOCAL_LIBS@
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/nvidia/Makefile.in b/xorg-server/hw/kdrive/nvidia/Makefile.in
new file mode 100644
index 000000000..e93f94789
--- /dev/null
+++ b/xorg-server/hw/kdrive/nvidia/Makefile.in
@@ -0,0 +1,720 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xnvidia$(EXEEXT)
+subdir = hw/kdrive/nvidia
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libnvidia_a_AR = $(AR) $(ARFLAGS)
+libnvidia_a_LIBADD =
+am_libnvidia_a_OBJECTS = nvidia.$(OBJEXT) nvidiadraw.$(OBJEXT)
+libnvidia_a_OBJECTS = $(am_libnvidia_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xnvidia_OBJECTS = nvidiastub.$(OBJEXT)
+Xnvidia_OBJECTS = $(am_Xnvidia_OBJECTS)
+am__DEPENDENCIES_1 = libnvidia.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a
+Xnvidia_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xnvidia_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libnvidia_a_SOURCES) $(Xnvidia_SOURCES)
+DIST_SOURCES = $(libnvidia_a_SOURCES) $(Xnvidia_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libnvidia.a
+
+# nvidiavideo.c
+libnvidia_a_SOURCES = \
+ nvidia.c \
+ nvidiadraw.c \
+ nvidia.h \
+ nvidiadraw.h
+
+Xnvidia_SOURCES = \
+ nvidiastub.c
+
+NVIDIA_LIBS = \
+ libnvidia.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a \
+ @KDRIVE_LIBS@
+
+@GLX_TRUE@Xnvidia_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xnvidia_LDADD = \
+ $(NVIDIA_LIBS) \
+ @KDRIVE_LIBS@
+
+Xnvidia_DEPENDENCIES = \
+ libnvidia.a \
+ @KDRIVE_LOCAL_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/nvidia/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/nvidia/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libnvidia.a: $(libnvidia_a_OBJECTS) $(libnvidia_a_DEPENDENCIES)
+ -rm -f libnvidia.a
+ $(libnvidia_a_AR) libnvidia.a $(libnvidia_a_OBJECTS) $(libnvidia_a_LIBADD)
+ $(RANLIB) libnvidia.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xnvidia$(EXEEXT): $(Xnvidia_OBJECTS) $(Xnvidia_DEPENDENCIES)
+ @rm -f Xnvidia$(EXEEXT)
+ $(Xnvidia_LINK) $(Xnvidia_OBJECTS) $(Xnvidia_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nvidia.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nvidiadraw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nvidiastub.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/nvidia/nvidia.c b/xorg-server/hw/kdrive/nvidia/nvidia.c
new file mode 100644
index 000000000..be42e561a
--- /dev/null
+++ b/xorg-server/hw/kdrive/nvidia/nvidia.c
@@ -0,0 +1,361 @@
+/*
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "nvidia.h"
+#include "kaa.h"
+#include <sys/io.h>
+
+static Bool
+nvidiaCardInit (KdCardInfo *card)
+{
+ NvidiaCardInfo *nvidiac;
+
+ nvidiac = (NvidiaCardInfo *) xalloc (sizeof (NvidiaCardInfo));
+ if (!nvidiac)
+ return FALSE;
+
+ (void) nvidiaMapReg (card, nvidiac);
+
+ if (!vesaInitialize (card, &nvidiac->vesa))
+ {
+ xfree (nvidiac);
+ return FALSE;
+ }
+
+ card->driver = nvidiac;
+
+ return TRUE;
+}
+
+static Bool
+nvidiaScreenInit (KdScreenInfo *screen)
+{
+ NvidiaCardInfo *nvidiac = screen->card->driver;
+ NvidiaScreenInfo *nvidias;
+ int screen_size, memory;
+
+ nvidias = (NvidiaScreenInfo *) xalloc (sizeof (NvidiaScreenInfo));
+ if (!nvidias)
+ return FALSE;
+ memset (nvidias, '\0', sizeof (NvidiaScreenInfo));
+ if (!vesaScreenInitialize (screen, &nvidias->vesa))
+ {
+ xfree (nvidias);
+ return FALSE;
+ }
+ if (!nvidiac->reg_base)
+ screen->dumb = TRUE;
+ if (nvidias->vesa.mapping != VESA_LINEAR)
+ screen->dumb = TRUE;
+ nvidias->screen = nvidias->vesa.fb;
+ memory = nvidias->vesa.fb_size;
+ screen_size = screen->fb[0].byteStride * screen->height;
+ if (nvidias->screen && memory >= screen_size + 2048)
+ {
+ memory -= 2048;
+ nvidias->cursor_base = nvidias->screen + memory - 2048;
+ }
+ else
+ nvidias->cursor_base = 0;
+ screen->softCursor = TRUE; /* XXX for now */
+ memory -= screen_size;
+ if (memory > screen->fb[0].byteStride)
+ {
+ nvidias->off_screen = nvidias->screen + screen_size;
+ nvidias->off_screen_size = memory;
+ }
+ else
+ {
+ nvidias->off_screen = 0;
+ nvidias->off_screen_size = 0;
+ }
+ screen->driver = nvidias;
+ return TRUE;
+}
+
+static Bool
+nvidiaInitScreen (ScreenPtr pScreen)
+{
+#if 0
+#ifdef XV
+ KdScreenPriv(pScreen);
+ NvidiaCardInfo *nvidiac = pScreenPriv->screen->card->driver;
+ if (nvidiac->media_reg && nvidiac->reg)
+ nvidiaInitVideo(pScreen);
+#endif
+#endif
+ return vesaInitScreen (pScreen);
+}
+
+#ifdef RANDR
+static Bool
+nvidiaRandRSetConfig (ScreenPtr pScreen,
+ Rotation rotation,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ kaaWaitSync (pScreen);
+
+ if (!vesaRandRSetConfig (pScreen, rotation, rate, pSize))
+ return FALSE;
+
+ return TRUE;
+}
+
+static void
+nvidiaRandRInit (ScreenPtr pScreen)
+{
+ rrScrPriv(pScreen);
+
+ pScrPriv->rrSetConfig = nvidiaRandRSetConfig;
+}
+#endif
+
+static Bool
+nvidiaFinishInitScreen (ScreenPtr pScreen)
+{
+ Bool ret;
+ ret = vesaFinishInitScreen (pScreen);
+#ifdef RANDR
+ nvidiaRandRInit (pScreen);
+#endif
+ return ret;
+}
+
+void
+nvidiaPreserve (KdCardInfo *card)
+{
+ vesaPreserve(card);
+}
+
+void
+nvidiaOutb (NvidiaCardInfo *nvidiac, CARD16 port, CARD8 val)
+{
+ asm volatile ("outb %b0,%w1" : : "a" (val), "d" (port));
+}
+
+CARD8
+nvidiaInb (NvidiaCardInfo *nvidiac, CARD16 port)
+{
+ CARD8 v;
+ asm volatile ("inb %w1,%b0" : "=a" (v) : "d" (port));
+ return v;
+}
+
+CARD8
+nvidiaGetIndex (NvidiaCardInfo *nvidiac, CARD16 addr, CARD16 data, CARD8 id)
+{
+ CARD8 ret;
+ DBGOUT ("nvidiaGetIndex(0x%x,0x%x)\n", addr, id);
+ nvidiaOutb (nvidiac, addr, id);
+ ret = nvidiaInb (nvidiac, data);
+ DBGOUT (" -> 0x%x\n", ret);
+ return ret;
+}
+
+void
+nvidiaSetIndex (NvidiaCardInfo *nvidiac, CARD16 addr, CARD16 data, CARD8 id, CARD8 val)
+{
+ DBGOUT ("nvidiaSetIndex(0x%x,0x%x) = 0x%x\n", addr, id, val);
+ nvidiaOutb (nvidiac, addr, id);
+ nvidiaOutb (nvidiac, data, val);
+}
+
+static void vgaLockUnlock (NvidiaCardInfo *nvidiac, Bool lock)
+{
+ CARD8 cr11;
+ ENTER ();
+ cr11 = nvidiaGetIndex (nvidiac, 0x3d4, 0x3d5, 0x11);
+ if (lock) cr11 |= 0x80;
+ else cr11 &= ~0x80;
+ nvidiaSetIndex (nvidiac, 0x3d4, 0x3d5, 0x11, cr11);
+ LEAVE ();
+}
+
+static void nvidiaLockUnlock (NvidiaCardInfo *nvidiac, Bool lock)
+{
+ if (NVIDIA_IS_3(nvidiac))
+ nvidiaSetIndex (nvidiac, 0x3c4, 0x3c5, 0x06, lock ? 0x99 : 0x57);
+ else
+ nvidiaSetIndex (nvidiac, 0x3c4, 0x3c5, 0x1f, lock ? 0x99 : 0x57);
+ vgaLockUnlock(nvidiac, lock);
+}
+
+Bool
+nvidiaMapReg (KdCardInfo *card, NvidiaCardInfo *nvidiac)
+{
+ nvidiac->reg_base = (CARD8 *) KdMapDevice (NVIDIA_REG_BASE(card),
+ NVIDIA_REG_SIZE(card));
+
+ if (!nvidiac->reg_base)
+ {
+ nvidiac->mmio = 0;
+ nvidiac->rop = 0;
+ nvidiac->blt = 0;
+ nvidiac->rect = 0;
+ return FALSE;
+ }
+
+ nvidiac->mmio = (CARD8 *) (nvidiac->reg_base + NVIDIA_MMIO_OFF(card));
+ nvidiac->rop = (NvidiaRop *) (nvidiac->reg_base + NVIDIA_ROP_OFF(card));
+ nvidiac->rect = (NvidiaRectangle *) (nvidiac->reg_base + NVIDIA_RECTANGLE_OFF(card));
+ nvidiac->blt = (NvidiaScreenBlt *) (nvidiac->reg_base + NVIDIA_BLT_OFF(card));
+ nvidiac->busy = (NvidiaBusy *) (nvidiac->reg_base + NVIDIA_BUSY_OFF(card));
+ KdSetMappedMode (NVIDIA_REG_BASE(card),
+ NVIDIA_REG_SIZE(card),
+ KD_MAPPED_MODE_REGISTERS);
+ return TRUE;
+}
+
+void
+nvidiaUnmapReg (KdCardInfo *card, NvidiaCardInfo *nvidiac)
+{
+ if (nvidiac->reg_base)
+ {
+ KdResetMappedMode (NVIDIA_REG_BASE(card),
+ NVIDIA_REG_SIZE(card),
+ KD_MAPPED_MODE_REGISTERS);
+ KdUnmapDevice ((void *) nvidiac->reg_base, NVIDIA_REG_SIZE(card));
+ nvidiac->reg_base = 0;
+ nvidiac->rop = 0;
+ nvidiac->blt = 0;
+ nvidiac->rect = 0;
+ }
+}
+
+void
+nvidiaSetMMIO (KdCardInfo *card, NvidiaCardInfo *nvidiac)
+{
+ if (!nvidiac->reg_base)
+ nvidiaMapReg (card, nvidiac);
+ nvidiaLockUnlock (nvidiac, FALSE);
+ nvidiac->fifo_free = 0;
+ nvidiac->fifo_size = nvidiac->rop->FifoFree.FifoFree;
+}
+
+void
+nvidiaResetMMIO (KdCardInfo *card, NvidiaCardInfo *nvidiac)
+{
+ nvidiaUnmapReg (card, nvidiac);
+ nvidiaLockUnlock (nvidiac, TRUE);
+}
+
+Bool
+nvidiaEnable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ NvidiaCardInfo *nvidiac = pScreenPriv->card->driver;
+
+ if (!vesaEnable (pScreen))
+ return FALSE;
+
+ nvidiaSetMMIO (pScreenPriv->card, nvidiac);
+#ifdef XV
+ KdXVEnable (pScreen);
+#endif
+ return TRUE;
+}
+
+void
+nvidiaDisable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ NvidiaCardInfo *nvidiac = pScreenPriv->card->driver;
+
+#ifdef XV
+ KdXVDisable (pScreen);
+#endif
+ nvidiaResetMMIO (pScreenPriv->card, nvidiac);
+ vesaDisable (pScreen);
+}
+
+static Bool
+nvidiaDPMS (ScreenPtr pScreen, int mode)
+{
+ return vesaDPMS (pScreen, mode);
+}
+
+static void
+nvidiaRestore (KdCardInfo *card)
+{
+ NvidiaCardInfo *nvidiac = card->driver;
+
+ nvidiaResetMMIO (card, nvidiac);
+ vesaRestore (card);
+}
+
+static void
+nvidiaScreenFini (KdScreenInfo *screen)
+{
+ NvidiaScreenInfo *nvidias = (NvidiaScreenInfo *) screen->driver;
+
+ vesaScreenFini (screen);
+ xfree (nvidias);
+ screen->driver = 0;
+}
+
+static void
+nvidiaCardFini (KdCardInfo *card)
+{
+ NvidiaCardInfo *nvidiac = card->driver;
+
+ nvidiaUnmapReg (card, nvidiac);
+ vesaCardFini (card);
+}
+
+#define nvidiaCursorInit 0 /* initCursor */
+#define nvidiaCursorEnable 0 /* enableCursor */
+#define nvidiaCursorDisable 0 /* disableCursor */
+#define nvidiaCursorFini 0 /* finiCursor */
+#define nvidiaRecolorCursor 0 /* recolorCursor */
+
+KdCardFuncs nvidiaFuncs = {
+ nvidiaCardInit, /* cardinit */
+ nvidiaScreenInit, /* scrinit */
+ nvidiaInitScreen, /* initScreen */
+ nvidiaFinishInitScreen, /* finishInitScreen */
+ vesaCreateResources, /* createRes */
+ nvidiaPreserve, /* preserve */
+ nvidiaEnable, /* enable */
+ nvidiaDPMS, /* dpms */
+ nvidiaDisable, /* disable */
+ nvidiaRestore, /* restore */
+ nvidiaScreenFini, /* scrfini */
+ nvidiaCardFini, /* cardfini */
+
+ nvidiaCursorInit, /* initCursor */
+ nvidiaCursorEnable, /* enableCursor */
+ nvidiaCursorDisable, /* disableCursor */
+ nvidiaCursorFini, /* finiCursor */
+ nvidiaRecolorCursor, /* recolorCursor */
+
+ nvidiaDrawInit, /* initAccel */
+ nvidiaDrawEnable, /* enableAccel */
+ nvidiaDrawDisable, /* disableAccel */
+ nvidiaDrawFini, /* finiAccel */
+
+ vesaGetColors, /* getColors */
+ vesaPutColors, /* putColors */
+};
diff --git a/xorg-server/hw/kdrive/nvidia/nvidia.h b/xorg-server/hw/kdrive/nvidia/nvidia.h
new file mode 100644
index 000000000..026233cc1
--- /dev/null
+++ b/xorg-server/hw/kdrive/nvidia/nvidia.h
@@ -0,0 +1,247 @@
+/*
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _NVIDIA_H_
+#define _NVIDIA_H_
+#include <vesa.h>
+#include "kxv.h"
+#include "klinux.h"
+
+/*
+ * offset from ioport beginning
+ */
+
+#define DEBUG
+#ifdef DEBUG
+#define DBGOUT(fmt,a...) fprintf (stderr, fmt, ##a)
+#else
+#define DBGOUT(fmt,a...)
+#endif
+
+#define ENTER() DBGOUT("Enter %s\n", __FUNCTION__)
+#define LEAVE() DBGOUT("Leave %s\n", __FUNCTION__)
+
+#define NVIDIA_REG_BASE(c) ((c)->attr.address[0])
+#define NVIDIA_REG_SIZE(c) (16 * 1024 * 1024)
+
+#define NVIDIA_PCIO_OFF(c) (0x601000)
+#define NVIDIA_MMIO_OFF(c) (NVIDIA_PCIO_OFF(c) + 0)
+#define NVIDIA_FIFO_OFF(c) (0x800000)
+#define NVIDIA_ROP_OFF(c) (NVIDIA_FIFO_OFF(c) + 0)
+#define NVIDIA_CLIP_OFF(c) (NVIDIA_FIFO_OFF(c) + 0x2000)
+#define NVIDIA_PATT_OFF(c) (NVIDIA_FIFO_OFF(c) + 0x4000)
+#define NVIDIA_PIXMAP_OFF(c) (NVIDIA_FIFO_OFF(c) + 0x6000)
+#define NVIDIA_BLT_OFF(c) (NVIDIA_FIFO_OFF(c) + 0x8000)
+#define NVIDIA_RECTANGLE_OFF(c) (NVIDIA_FIFO_OFF(c) + 0xa000)
+#define NVIDIA_LINE_OFF(c) (NVIDIA_FIFO_OFF(c) + 0xc000)
+#define NVIDIA_IS_3(c) (0)
+#define NVIDIA_BUSY(c) (NVIDIA_IS_3(c) ? 0x6b0 : 0x700)
+#define NVIDIA_BUSY_OFF(c) (0x400000 + NVIDIA_BUSY(c))
+
+typedef volatile CARD8 VOL8;
+typedef volatile CARD16 VOL16;
+typedef volatile CARD32 VOL32;
+
+#define NVIDIA_XY(x,y) ((x) | ((y) << 16))
+
+typedef struct {
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ VOL32 FifoFree;
+#else
+ VOL16 FifoFree;
+ VOL16 Nop;
+#endif
+} NvidiaFifoFree;
+
+/*
+ * Raster OPeration. Windows style ROP3.
+ */
+typedef struct {
+ VOL32 reserved00[4];
+ NvidiaFifoFree FifoFree;
+ VOL32 reserved01[0x0BB];
+ VOL32 Rop3;
+} NvidiaRop;
+
+/*
+ * 2D filled rectangle.
+ */
+typedef struct {
+ VOL32 reserved00[4];
+ NvidiaFifoFree FifoFree;
+ VOL32 reserved01[0x0BB];
+ VOL32 reserved03[(0x040)-1];
+ VOL32 Color1A;
+ VOL32 TopLeft;
+ VOL32 WidthHeight;
+} NvidiaRectangle;
+
+/*
+ * 2D screen-screen BLT.
+ */
+typedef struct {
+ VOL32 reserved00[4];
+ NvidiaFifoFree FifoFree;
+ VOL32 reserved01[0x0BB];
+ VOL32 TopLeftSrc;
+ VOL32 TopLeftDst;
+ VOL32 WidthHeight;
+} NvidiaScreenBlt;
+
+typedef struct {
+ VOL32 busy;
+} NvidiaBusy;
+
+typedef struct _nvidiaCardInfo {
+ VesaCardPrivRec vesa;
+ CARD8 *reg_base;
+ int fifo_free;
+ int fifo_size;
+ CARD8 *mmio;
+ NvidiaRop *rop;
+ NvidiaRectangle *rect;
+ NvidiaScreenBlt *blt;
+ NvidiaBusy *busy;
+} NvidiaCardInfo;
+
+#define getNvidiaCardInfo(kd) ((NvidiaCardInfo *) ((kd)->card->driver))
+#define nvidiaCardInfo(kd) NvidiaCardInfo *nvidiac = getNvidiaCardInfo(kd)
+
+/*
+ * Xv information, optional
+ */
+typedef struct _nvidiaPortPriv {
+ CARD32 YBuf0Offset;
+
+ CARD32 YBuf1Offset;
+
+ CARD8 currentBuf;
+
+ int brightness;
+ int saturation;
+
+ RegionRec clip;
+ CARD32 colorKey;
+
+ Bool videoOn;
+ Time offTime;
+ Time freeTime;
+ CARD32 size;
+ CARD32 offset;
+} NvidiaPortPrivRec, *NvidiaPortPrivPtr;
+
+Bool nvidiaInitVideo(ScreenPtr pScreen);
+
+typedef struct _nvidiaScreenInfo {
+ VesaScreenPrivRec vesa;
+ CARD8 *cursor_base;
+ CARD8 *screen;
+ CARD8 *off_screen;
+ int off_screen_size;
+ KdVideoAdaptorPtr pAdaptor;
+ KaaScreenInfoRec kaa;
+} NvidiaScreenInfo;
+
+#define getNvidiaScreenInfo(kd) ((NvidiaScreenInfo *) ((kd)->screen->driver))
+#define nvidiaScreenInfo(kd) NvidiaScreenInfo *nvidias = getNvidiaScreenInfo(kd)
+
+void
+nvidiaPreserve (KdCardInfo *card);
+
+void
+nvidiaOutb (NvidiaCardInfo *nvidiac, CARD16 port, CARD8 val);
+
+CARD8
+nvidiaInb (NvidiaCardInfo *nvidiac, CARD16 port);
+
+CARD8
+nvidiaGetIndex (NvidiaCardInfo *nvidiac, CARD16 addr, CARD16 data, CARD8 id);
+
+void
+nvidiaSetIndex (NvidiaCardInfo *nvidiac, CARD16 addr, CARD16 data, CARD8 id, CARD8 val);
+
+Bool
+nvidiaMapReg (KdCardInfo *card, NvidiaCardInfo *nvidiac);
+
+void
+nvidiaUnmapReg (KdCardInfo *card, NvidiaCardInfo *nvidiac);
+
+void
+nvidiaSetMMIO (KdCardInfo *card, NvidiaCardInfo *nvidiac);
+
+void
+nvidiaResetMMIO (KdCardInfo *card, NvidiaCardInfo *nvidiac);
+
+Bool
+nvidiaEnable (ScreenPtr pScreen);
+
+void
+nvidiaDisable (ScreenPtr pScreen);
+
+void
+nvidiaWait (NvidiaCardInfo *card, NvidiaFifoFree *free, int n);
+
+void
+nvidiaWaitIdle (NvidiaCardInfo *card);
+
+Bool
+nvidiaDrawSetup (ScreenPtr pScreen);
+
+Bool
+nvidiaDrawInit (ScreenPtr pScreen);
+
+void
+nvidiaDrawReinit (ScreenPtr pScreen);
+
+void
+nvidiaDrawEnable (ScreenPtr pScreen);
+
+void
+nvidiaDrawDisable (ScreenPtr pScreen);
+
+void
+nvidiaDrawFini (ScreenPtr pScreen);
+
+CARD8
+nvidiaReadIndex (NvidiaCardInfo *nvidiac, CARD16 port, CARD8 index);
+
+void
+nvidiaWriteIndex (NvidiaCardInfo *nvidiac, CARD16 port, CARD8 index, CARD8 value);
+
+Bool
+nvidiaCursorInit (ScreenPtr pScreen);
+
+void
+nvidiaCursorEnable (ScreenPtr pScreen);
+
+void
+nvidiaCursorDisable (ScreenPtr pScreen);
+
+void
+nvidiaCursorFini (ScreenPtr pScreen);
+
+void
+nvidiaRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef);
+
+extern KdCardFuncs nvidiaFuncs;
+
+#endif /* _NVIDIA_H_ */
diff --git a/xorg-server/hw/kdrive/nvidia/nvidiadraw.c b/xorg-server/hw/kdrive/nvidia/nvidiadraw.c
new file mode 100644
index 000000000..a39f79888
--- /dev/null
+++ b/xorg-server/hw/kdrive/nvidia/nvidiadraw.c
@@ -0,0 +1,238 @@
+/*
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "nvidia.h"
+#include "nvidiadraw.h"
+
+#include <X11/Xmd.h>
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mistruct.h"
+#include "dixfontstr.h"
+#include "fb.h"
+#include "migc.h"
+#include "miline.h"
+#include "picturestr.h"
+#include "kaa.h"
+
+CARD8 nvidiaRop[16] = {
+ /* GXclear */ 0x01, /* 0 */
+ /* GXand */ 0x0c, /* src AND dst */
+ /* GXandReverse */ 0x0d, /* src AND NOT dst */
+ /* GXcopy */ 0x07, /* src */
+ /* GXandInverted*/ 0x0e, /* NOT src AND dst */
+ /* GXnoop */ 0x03, /* dst */
+ /* GXxor */ 0x05, /* src XOR dst */
+ /* GXor */ 0x0b, /* src OR dst */
+ /* GXnor */ 0x0f, /* NOT src AND NOT dst */
+ /* GXequiv */ 0x06, /* NOT src XOR dst */
+ /* GXinvert */ 0x00, /* NOT dst */
+ /* GXorReverse */ 0x0a, /* src OR NOT dst */
+ /* GXcopyInverted*/ 0x04, /* NOT src */
+ /* GXorInverted */ 0x09, /* NOT src OR dst */
+ /* GXnand */ 0x08, /* NOT src OR NOT dst */
+ /* GXset */ 0x02, /* 1 */
+};
+
+static NvidiaCardInfo *card;
+
+void
+nvidiaWait (NvidiaCardInfo *card, NvidiaFifoFree *free, int n)
+{
+ while (card->fifo_free < n)
+ {
+ card->fifo_free = free->FifoFree >> 2;
+ }
+ card->fifo_free -= n;
+}
+
+void
+nvidiaWaitIdle (NvidiaCardInfo *card)
+{
+ while (card->fifo_free < card->fifo_size || (card->busy->busy & 1))
+ {
+ card->fifo_free = card->rop->FifoFree.FifoFree >> 2;
+ }
+}
+
+static void
+nvidiaWaitMarker (ScreenPtr pScreen, int marker)
+{
+ KdScreenPriv(pScreen);
+ nvidiaCardInfo(pScreenPriv);
+
+ nvidiaWaitIdle (nvidiac);
+}
+
+static Bool
+nvidiaPrepareSolid (PixmapPtr pPixmap,
+ int alu,
+ Pixel pm,
+ Pixel fg)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ nvidiaCardInfo(pScreenPriv);
+
+ card = nvidiac;
+ if (~pm & FbFullMask(pPixmap->drawable.depth))
+ return FALSE;
+ nvidiaWait (nvidiac, &nvidiac->rop->FifoFree, 1);
+ nvidiac->rop->Rop3 = nvidiaRop[alu];
+ nvidiaWait (nvidiac, &nvidiac->rect->FifoFree, 1);
+ nvidiac->rect->Color1A = fg;
+ return TRUE;
+}
+
+static void
+nvidiaSolid (int x1, int y1, int x2, int y2)
+{
+ nvidiaWait (card, &card->rect->FifoFree, 2);
+ card->rect->TopLeft = NVIDIA_XY(x1,y1);
+ card->rect->WidthHeight = NVIDIA_XY(x2-x1,y2-y1);
+}
+
+static void
+nvidiaDoneSolid (void)
+{
+}
+
+
+static Bool
+nvidiaPrepareCopy (PixmapPtr pSrcPixmap,
+ PixmapPtr pDstPixmap,
+ int dx,
+ int dy,
+ int alu,
+ Pixel pm)
+{
+ ScreenPtr pScreen = pDstPixmap->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ nvidiaCardInfo(pScreenPriv);
+
+ card = nvidiac;
+ if (~pm & FbFullMask(pDstPixmap->drawable.depth))
+ return FALSE;
+ nvidiaWait (nvidiac, &card->rop->FifoFree, 1);
+ nvidiac->rop->Rop3 = nvidiaRop[alu];
+ return TRUE;
+}
+
+static void
+nvidiaCopy (int srcX,
+ int srcY,
+ int dstX,
+ int dstY,
+ int w,
+ int h)
+{
+ nvidiaWait (card, &card->blt->FifoFree, 3);
+ card->blt->TopLeftSrc = NVIDIA_XY(srcX, srcY);
+ card->blt->TopLeftDst = NVIDIA_XY(dstX, dstY);
+ card->blt->WidthHeight = NVIDIA_XY(w, h);
+}
+
+static void
+nvidiaDoneCopy (void)
+{
+}
+
+Bool
+nvidiaDrawInit (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ nvidiaCardInfo(pScreenPriv);
+ nvidiaScreenInfo(pScreenPriv);
+ Bool ret = TRUE;
+
+ ENTER ();
+ if (pScreenPriv->screen->fb[0].depth == 4)
+ ret = FALSE;
+
+ memset(&nvidias->kaa, 0, sizeof(KaaScreenInfoRec));
+ nvidias->kaa.waitMarker = nvidiaWaitMarker;
+ nvidias->kaa.PrepareSolid = nvidiaPrepareSolid;
+ nvidias->kaa.Solid = nvidiaSolid;
+ nvidias->kaa.DoneSolid = nvidiaDoneSolid;
+ nvidias->kaa.PrepareCopy = nvidiaPrepareCopy;
+ nvidias->kaa.Copy = nvidiaCopy;
+ nvidias->kaa.DoneCopy = nvidiaDoneCopy;
+
+ if (ret && !nvidiac->rop)
+ {
+ ErrorF ("Failed to map fifo registers\n");
+ ret = FALSE;
+ }
+ if (ret && !nvidiac->rop->FifoFree.FifoFree)
+ {
+ ErrorF ("Fifo appears broken\n");
+ ret = FALSE;
+ }
+ if (ret && !kaaDrawInit (pScreen, &nvidias->kaa))
+ {
+ ErrorF ("kaaDrawInit failed\n");
+ ret = FALSE;
+ }
+
+ LEAVE ();
+ return ret;
+}
+
+#define PIX_FORMAT_MONO 0
+#define PIX_FORMAT_PSEUDO_8 2
+#define PIX_FORMAT_TRUE_1555 3
+#define PIX_FORMAT_TRUE_565 4
+#define PIX_FORMAT_TRUE_8888 6
+#define PIX_FORMAT_TRUE_332 7
+#define PIX_FORMAT_GRAY_8 8
+#define PIX_FORMAT_YUV_422 0xb
+#define PIX_FORMAT_YUV_444 0xe
+#define PIX_FORMAT_TRUE_4444 0xf
+
+void
+nvidiaDrawEnable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ nvidiaCardInfo(pScreenPriv);
+
+ ENTER ();
+ nvidiac->fifo_size = nvidiac->rop->FifoFree.FifoFree;
+ nvidiac->fifo_free = 0;
+ kaaMarkSync (pScreen);
+ LEAVE ();
+}
+
+void
+nvidiaDrawDisable (ScreenPtr pScreen)
+{
+}
+
+void
+nvidiaDrawFini (ScreenPtr pScreen)
+{
+}
+
diff --git a/xorg-server/hw/kdrive/nvidia/nvidiadraw.h b/xorg-server/hw/kdrive/nvidia/nvidiadraw.h
new file mode 100644
index 000000000..bac11c2a6
--- /dev/null
+++ b/xorg-server/hw/kdrive/nvidia/nvidiadraw.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _TRIDENTDRAW_H_
+#define _TRIDENTDRAW_H_
+
+#define SetupTrident(s) KdScreenPriv(s); \
+ tridentCardInfo(pScreenPriv); \
+ Cop *cop = tridentc->cop
+
+#define TridentAlpha (COP_MULTI_ALPHA|COP_ALPHA_WRITE_ENABLE)
+
+#define _tridentInit(cop,tridentc) { \
+ if ((cop)->status == 0xffffffff) tridentSetMMIO(tridentc); \
+ (cop)->multi = (tridentc)->cop_depth; \
+ (cop)->multi = (tridentc)->cop_stride; \
+ (cop)->multi = TridentAlpha; \
+} \
+
+#define _tridentSetSolidRect(cop,pix,alu,cmd) {\
+ cop->multi = COP_MULTI_PATTERN; \
+ cop->multi = COP_MULTI_ROP | tridentRop[alu]; \
+ cop->fg = (pix); \
+ cmd = COP_OP_BLT | COP_SCL_OPAQUE | COP_OP_ROP | COP_OP_FG; \
+}
+
+#define _tridentRect(cop,x1,y1,x2,y2,cmd) { \
+ (cop)->dst_start_xy = TRI_XY (x1,y1); \
+ (cop)->dst_end_xy = TRI_XY(x2,y2); \
+ _tridentWaitDone(cop); \
+ (cop)->command = (cmd); \
+}
+
+#define COP_STATUS_BUSY (COP_STATUS_BE_BUSY | \
+ COP_STATUS_DPE_BUSY | \
+ COP_STATUS_MI_BUSY)
+
+#define _tridentWaitDone(cop) { \
+ int __q__ = 500000; \
+ while (__q__-- && (cop)->status & COP_STATUS_BUSY) \
+ ; \
+ if (!__q__) \
+ (cop)->status = 0; \
+}
+
+#define _tridentWaitIdleEmpty(cop) _tridentWaitDone(cop)
+
+#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3))
+
+#endif
diff --git a/xorg-server/hw/kdrive/nvidia/nvidiastub.c b/xorg-server/hw/kdrive/nvidia/nvidiastub.c
new file mode 100644
index 000000000..0e8250e31
--- /dev/null
+++ b/xorg-server/hw/kdrive/nvidia/nvidiastub.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright © 2003 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "nvidia.h"
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+
+ if (LinuxFindPci (0x10de, 0x0112, 0, &attr))
+ KdCardInfoAdd (&nvidiaFuncs, &attr, 0);
+}
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdOsAddInputDrivers ();
+ KdInitInput ();
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+ vesaUseMsg();
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ int ret;
+
+ if (!(ret = vesaProcessArgument (argc, argv, i)))
+ ret = KdProcessArgument(argc, argv, i);
+ return ret;
+}
diff --git a/xorg-server/hw/kdrive/pm2/Makefile.am b/xorg-server/hw/kdrive/pm2/Makefile.am
new file mode 100644
index 000000000..cb28de6cb
--- /dev/null
+++ b/xorg-server/hw/kdrive/pm2/Makefile.am
@@ -0,0 +1,37 @@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_CFLAGS@
+
+bin_PROGRAMS = Xpm2
+
+noinst_LIBRARIES = libpm2.a
+
+libpm2_a_SOURCES = \
+ glint_regs.h \
+ pm2.c \
+ pm2_draw.c \
+ pm2.h
+
+Xpm2_SOURCES = \
+ pm2stub.c
+
+PM2_LIBS = \
+ libpm2.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a \
+ @KDRIVE_LIBS@
+
+if GLX
+Xpm2_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
+Xpm2_LDADD = \
+ $(PM2_LIBS) \
+ @KDRIVE_LIBS@
+
+Xpm2_DEPENDENCIES = \
+ libpm2.a \
+ @KDRIVE_LOCAL_LIBS@
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/pm2/Makefile.in b/xorg-server/hw/kdrive/pm2/Makefile.in
new file mode 100644
index 000000000..2f583eb92
--- /dev/null
+++ b/xorg-server/hw/kdrive/pm2/Makefile.in
@@ -0,0 +1,717 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xpm2$(EXEEXT)
+subdir = hw/kdrive/pm2
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libpm2_a_AR = $(AR) $(ARFLAGS)
+libpm2_a_LIBADD =
+am_libpm2_a_OBJECTS = pm2.$(OBJEXT) pm2_draw.$(OBJEXT)
+libpm2_a_OBJECTS = $(am_libpm2_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xpm2_OBJECTS = pm2stub.$(OBJEXT)
+Xpm2_OBJECTS = $(am_Xpm2_OBJECTS)
+am__DEPENDENCIES_1 = libpm2.a $(top_builddir)/hw/kdrive/vesa/libvesa.a
+Xpm2_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xpm2_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libpm2_a_SOURCES) $(Xpm2_SOURCES)
+DIST_SOURCES = $(libpm2_a_SOURCES) $(Xpm2_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libpm2.a
+libpm2_a_SOURCES = \
+ glint_regs.h \
+ pm2.c \
+ pm2_draw.c \
+ pm2.h
+
+Xpm2_SOURCES = \
+ pm2stub.c
+
+PM2_LIBS = \
+ libpm2.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a \
+ @KDRIVE_LIBS@
+
+@GLX_TRUE@Xpm2_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xpm2_LDADD = \
+ $(PM2_LIBS) \
+ @KDRIVE_LIBS@
+
+Xpm2_DEPENDENCIES = \
+ libpm2.a \
+ @KDRIVE_LOCAL_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/pm2/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/pm2/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libpm2.a: $(libpm2_a_OBJECTS) $(libpm2_a_DEPENDENCIES)
+ -rm -f libpm2.a
+ $(libpm2_a_AR) libpm2.a $(libpm2_a_OBJECTS) $(libpm2_a_LIBADD)
+ $(RANLIB) libpm2.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xpm2$(EXEEXT): $(Xpm2_OBJECTS) $(Xpm2_DEPENDENCIES)
+ @rm -f Xpm2$(EXEEXT)
+ $(Xpm2_LINK) $(Xpm2_OBJECTS) $(Xpm2_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pm2.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pm2_draw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pm2stub.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/pm2/glint_regs.h b/xorg-server/hw/kdrive/pm2/glint_regs.h
new file mode 100644
index 000000000..84f220298
--- /dev/null
+++ b/xorg-server/hw/kdrive/pm2/glint_regs.h
@@ -0,0 +1,1370 @@
+
+/*
+ * glint register file
+ *
+ * Copyright by Stefan Dirsch, Dirk Hohndel, Alan Hourihane
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ * Dirk Hohndel, <hohndel@suse.de>
+ * Stefan Dirsch, <sndirsch@suse.de>
+ * Simon P., <sim@suse.de>
+ *
+ * this work is sponsored by S.u.S.E. GmbH, Fuerth, Elsa GmbH, Aachen and
+ * Siemens Nixdorf Informationssysteme
+ *
+ */
+
+#ifndef _GLINTREG_H_
+#define _GLINTREG_H_
+
+/* The chips we know */
+#define PCI_CHIP_3DLABS_300SX 0x01
+#define PCI_CHIP_3DLABS_500TX 0x02
+#define PCI_CHIP_3DLABS_DELTA 0x03
+#define PCI_CHIP_3DLABS_PERMEDIA 0x04
+#define PCI_CHIP_3DLABS_MX 0x06
+#define PCI_CHIP_3DLABS_PERMEDIA2 0x07
+#define PCI_CHIP_3DLABS_GAMMA 0x08
+#define PCI_CHIP_3DLABS_PERMEDIA2V 0x09
+#define PCI_CHIP_3DLABS_PERMEDIA3 0x0A
+#define PCI_CHIP_3DLABS_PERMEDIA4 0x0C
+#define PCI_CHIP_3DLABS_R4 0x0D
+#define PCI_CHIP_3DLABS_GAMMA2 0x0E
+
+/* The boards we know */
+#define IS_GLORIAXXL ((pGlint->PciInfo->subsysVendor == 0x1048) && \
+ (pGlint->PciInfo->subsysCard == 0x0a42))
+
+#define IS_GLORIASYNERGY ((pGlint->PciInfo->subsysVendor == 0x1048) && \
+ (pGlint->PciInfo->subsysCard == 0x0a32))
+
+#define IS_GMX2000 ((pGlint->PciInfo->subsysVendor == 0x3d3d) && \
+ (pGlint->PciInfo->subsysCard == 0x0106))
+
+#define IS_J2000 ((pGlint->PciInfo->subsysVendor == 0x1097) && \
+ (pGlint->PciInfo->subsysCard == 0x3d32))
+
+#define IS_JPRO ((pGlint->PciInfo->subsysVendor == 0x1097) && \
+ (pGlint->PciInfo->subsysCard == 0x3db3))
+
+/* COMPAQ OEM VX1 PCI
+ * subsys == 0x0121 if VGA is enabled
+ * subsys == 0x000a if VGA has never been enabled
+ */
+#define IS_PCI_QVX1 (pGlint->PciInfo->subsysVendor == 0x3d3d && \
+ ((pGlint->PciInfo->subsysCard == 0x0121) || \
+ (pGlint->PciInfo->subsysCard == 0x000a)))
+
+/* COMPAQ OEM VX1 AGP
+ * subsys == 0x0144 if VGA is enabled
+ * subsys == 0x000c if VGA has never been enabled
+ */
+#define IS_AGP_QVX1 (pGlint->PciInfo->subsysVendor == 0x3d3d && \
+ ((pGlint->PciInfo->subsysCard == 0x0144) || \
+ (pGlint->PciInfo->subsysCard == 0x000c)))
+
+#define IS_QVX1 (IS_PCI_QVX1 || IS_AGP_QVX1)
+
+#define IS_ELSA_SYNERGY ((pGlint->PciInfo->subsysVendor == 0x1048) && \
+ (pGlint->PciInfo->subsysCard == 0x0a32))
+
+/* COMPAQ OEM Permedia 2V with VGA disable jumper - 0x13e9 ? */
+#define IS_QPM2V ((pGlint->PciInfo->subsysVendor == 0x13e9) && \
+ ((pGlint->PciInfo->subsysCard == 0x0100) || \
+ (pGlint->PciInfo->subsysCard == 0x0002)))
+
+/**********************************************
+* GLINT 500TX Configuration Region Registers *
+***********************************************/
+
+/* Device Identification */
+#define CFGVendorId 0x0000
+#define PCI_VENDOR_3DLABS 0x3D3D
+#define PCI_VENDOR_TI 0x104C
+#define CFGDeviceId 0x0002
+
+#define CFGRevisionId 0x08
+#define CFGClassCode 0x09
+#define CFGHeaderType 0x0E
+
+/* Device Control/Status */
+#define CFGCommand 0x04
+#define CFGStatus 0x06
+
+/* Miscellaneous Functions */
+#define CFGBist 0x0f
+#define CFGLatTimer 0x0d
+#define CFGCacheLine 0x0c
+#define CFGMaxLat 0x3f
+#define CFGMinGrant 0x3e
+#define CFGIntPin 0x3d
+#define CFGIntLine 0x3c
+
+/* Base Adresses */
+#define CFGBaseAddr0 0x10
+#define CFGBaseAddr1 0x14
+#define CFGBaseAddr2 0x18
+#define CFGBaseAddr3 0x1C
+#define CFGBaseAddr4 0x20
+#define CFGRomAddr 0x30
+
+
+
+/**********************************
+ * GLINT 500TX Region 0 Registers *
+ **********************************/
+
+/* Control Status Registers */
+#define ResetStatus 0x0000
+#define IntEnable 0x0008
+#define IntFlags 0x0010
+#define InFIFOSpace 0x0018
+#define OutFIFOWords 0x0020
+#define DMAAddress 0x0028
+#define DMACount 0x0030
+#define ErrorFlags 0x0038
+#define VClkCtl 0x0040
+#define TestRegister 0x0048
+#define Aperture0 0x0050
+#define Aperture1 0x0058
+#define DMAControl 0x0060
+#define FIFODis 0x0068
+
+/* GLINT PerMedia Region 0 additional Registers */
+#define ChipConfig 0x0070
+# define SCLK_SEL_MASK (3 << 10)
+# define SCLK_SEL_MCLK_HALF (3 << 10)
+
+#define ByDMAControl 0x00D8
+
+/* GLINT 500TX LocalBuffer Registers */
+#define LBMemoryCtl 0x1000
+# define LBNumBanksMask 0x00000001
+# define LBNumBanks1 (0)
+# define LBNumBanks2 (1)
+# define LBPageSizeMask 0x00000006
+# define LBPageSize256 (0<<1)
+# define LBPageSize512 (1<<1)
+# define LBPageSize1024 (2<<1)
+# define LBPageSize2048 (3<<1)
+# define LBRASCASLowMask 0x00000018
+# define LBRASCASLow2 (0<<3)
+# define LBRASCASLow3 (1<<3)
+# define LBRASCASLow4 (2<<3)
+# define LBRASCASLow5 (3<<3)
+# define LBRASPrechargeMask 0x00000060
+# define LBRASPrecharge2 (0<<5)
+# define LBRASPrecharge3 (1<<5)
+# define LBRASPrecharge4 (2<<5)
+# define LBRASPrecharge5 (3<<5)
+# define LBCASLowMask 0x00000180
+# define LBCASLow1 (0<<7)
+# define LBCASLow2 (1<<7)
+# define LBCASLow3 (2<<7)
+# define LBCASLow4 (3<<7)
+# define LBPageModeMask 0x00000200
+# define LBPageModeEnabled (0<<9)
+# define LBPageModeDisabled (1<<9)
+# define LBRefreshCountMask 0x0003fc00
+# define LBRefreshCountShift 10
+
+#define LBMemoryEDO 0x1008
+# define LBEDOMask 0x00000001
+# define LBEDODisabled (0)
+# define LBEDOEnabled (1)
+# define LBEDOBankSizeMask 0x0000000e
+# define LBEDOBankSizeDiabled (0<<1)
+# define LBEDOBankSize256K (1<<1)
+# define LBEDOBankSize512K (2<<1)
+# define LBEDOBankSize1M (3<<1)
+# define LBEDOBankSize2M (4<<1)
+# define LBEDOBankSize4M (5<<1)
+# define LBEDOBankSize8M (6<<1)
+# define LBEDOBankSize16M (7<<1)
+# define LBTwoPageDetectorMask 0x00000010
+# define LBSinglePageDetector (0<<4)
+# define LBTwoPageDetector (1<<4)
+
+/* GLINT PerMedia Memory Control Registers */
+#define PMReboot 0x1000
+#define PMRomControl 0x1040
+#define PMBootAddress 0x1080
+#define PMMemConfig 0x10C0
+# define RowCharge8 1 << 10
+# define TimeRCD8 1 << 7
+# define TimeRC8 0x6 << 3
+# define TimeRP8 1
+# define CAS3Latency8 0 << 16
+# define BootAdress8 0x10
+# define NumberBanks8 0x3 << 29
+# define RefreshCount8 0x41 << 21
+# define TimeRASMin8 1 << 13
+# define DeadCycle8 1 << 17
+# define BankDelay8 0 << 18
+# define Burst1Cycle8 1 << 31
+# define SDRAM8 0 << 4
+
+# define RowCharge6 1 << 10
+# define TimeRCD6 1 << 7
+# define TimeRC6 0x6 << 3
+# define TimeRP6 0x2
+# define CAS3Latency6 1 << 16
+# define BootAdress6 0x60
+# define NumberBanks6 0x2 << 29
+# define RefreshCount6 0x41 << 21
+# define TimeRASMin6 1 << 13
+# define DeadCycle6 1 << 17
+# define BankDelay6 0 << 18
+# define Burst1Cycle6 1 << 31
+# define SDRAM6 0 << 4
+
+# define RowCharge4 0 << 10
+# define TimeRCD4 0 << 7
+# define TimeRC4 0x4 << 3
+# define TimeRP4 1
+# define CAS3Latency4 0 << 16
+# define BootAdress4 0x10
+# define NumberBanks4 1 << 29
+# define RefreshCount4 0x30 << 21
+# define TimeRASMin4 1 << 13
+# define DeadCycle4 0 << 17
+# define BankDelay4 0 << 18
+# define Burst1Cycle4 1 << 31
+# define SDRAM4 0 << 4
+
+/* Permedia 2 Control */
+#define MemControl 0x1040
+
+#define PMBypassWriteMask 0x1100
+#define PMFramebufferWriteMask 0x1140
+#define PMCount 0x1180
+
+/* Framebuffer Registers */
+#define FBMemoryCtl 0x1800
+#define FBModeSel 0x1808
+#define FBGCWrMask 0x1810
+#define FBGCColorLower 0x1818
+#define FBTXMemCtl 0x1820
+#define FBWrMaskk 0x1830
+#define FBGCColorUpper 0x1838
+
+/* Core FIFO */
+#define OutputFIFO 0x2000
+
+/* 500TX Internal Video Registers */
+#define VTGHLimit 0x3000
+#define VTGHSyncStart 0x3008
+#define VTGHSyncEnd 0x3010
+#define VTGHBlankEnd 0x3018
+#define VTGVLimit 0x3020
+#define VTGVSyncStart 0x3028
+#define VTGVSyncEnd 0x3030
+#define VTGVBlankEnd 0x3038
+#define VTGHGateStart 0x3040
+#define VTGHGateEnd 0x3048
+#define VTGVGateStart 0x3050
+#define VTGVGateEnd 0x3058
+#define VTGPolarity 0x3060
+#define VTGFrameRowAddr 0x3068
+#define VTGVLineNumber 0x3070
+#define VTGSerialClk 0x3078
+#define VTGModeCtl 0x3080
+
+/* Permedia Video Control Registers */
+#define PMScreenBase 0x3000
+#define PMScreenStride 0x3008
+#define PMHTotal 0x3010
+#define PMHgEnd 0x3018
+#define PMHbEnd 0x3020
+#define PMHsStart 0x3028
+#define PMHsEnd 0x3030
+#define PMVTotal 0x3038
+#define PMVbEnd 0x3040
+#define PMVsStart 0x3048
+#define PMVsEnd 0x3050
+#define PMVideoControl 0x3058
+#define PMInterruptLine 0x3060
+#define PMDDCData 0x3068
+# define DataIn (1<<0)
+# define ClkIn (1<<1)
+# define DataOut (1<<2)
+# define ClkOut (1<<3)
+#define PMLineCount 0x3070
+#define PMFifoControl 0x3078
+
+/* Permedia 2 RAMDAC Registers */
+#define PM2DACWriteAddress 0x4000
+#define PM2DACIndexReg 0x4000
+#define PM2DACData 0x4008
+#define PM2DACReadMask 0x4010
+#define PM2DACReadAddress 0x4018
+#define PM2DACCursorColorAddress 0x4020
+#define PM2DACCursorColorData 0x4028
+#define PM2DACIndexData 0x4050
+#define PM2DACCursorData 0x4058
+#define PM2DACCursorXLsb 0x4060
+#define PM2DACCursorXMsb 0x4068
+#define PM2DACCursorYLsb 0x4070
+#define PM2DACCursorYMsb 0x4078
+#define PM2DACCursorControl 0x06
+
+#define PM2DACIndexCMR 0x18
+# define PM2DAC_TRUECOLOR 0x80
+# define PM2DAC_RGB 0x20
+# define PM2DAC_GRAPHICS 0x10
+# define PM2DAC_PACKED 0x09
+# define PM2DAC_8888 0x08
+# define PM2DAC_565 0x06
+# define PM2DAC_4444 0x05
+# define PM2DAC_5551 0x04
+# define PM2DAC_2321 0x03
+# define PM2DAC_2320 0x02
+# define PM2DAC_332 0x01
+# define PM2DAC_CI8 0x00
+
+#define PM2DACIndexMDCR 0x19
+#define PM2DACIndexPalettePage 0x1c
+#define PM2DACIndexMCR 0x1e
+#define PM2DACIndexClockAM 0x20
+#define PM2DACIndexClockAN 0x21
+#define PM2DACIndexClockAP 0x22
+#define PM2DACIndexClockBM 0x23
+#define PM2DACIndexClockBN 0x24
+#define PM2DACIndexClockBP 0x25
+#define PM2DACIndexClockCM 0x26
+#define PM2DACIndexClockCN 0x27
+#define PM2DACIndexClockCP 0x28
+#define PM2DACIndexClockStatus 0x29
+#define PM2DACIndexMemClockM 0x30
+#define PM2DACIndexMemClockN 0x31
+#define PM2DACIndexMemClockP 0x32
+#define PM2DACIndexMemClockStatus 0x33
+#define PM2DACIndexColorKeyControl 0x40
+#define PM2DACIndexColorKeyOverlay 0x41
+#define PM2DACIndexColorKeyRed 0x42
+#define PM2DACIndexColorKeyGreen 0x43
+#define PM2DACIndexColorKeyBlue 0x44
+
+/* Permedia 2V extensions */
+#define PM2VDACRDMiscControl 0x000
+#define PM2VDACRDSyncControl 0x001
+#define PM2VDACRDDACControl 0x002
+#define PM2VDACRDPixelSize 0x003
+#define PM2VDACRDColorFormat 0x004
+#define PM2VDACRDCursorMode 0x005
+#define PM2VDACRDCursorXLow 0x007
+#define PM2VDACRDCursorXHigh 0x008
+#define PM2VDACRDCursorYLow 0x009
+#define PM2VDACRDCursorYHigh 0x00A
+#define PM2VDACRDCursorHotSpotX 0x00B
+#define PM2VDACRDCursorHotSpotY 0x00C
+#define PM2VDACRDOverlayKey 0x00D
+#define PM2VDACRDPan 0x00E
+#define PM2VDACRDSense 0x00F
+#define PM2VDACRDCheckControl 0x018
+#define PM2VDACIndexClockControl 0x200
+#define PM2VDACRDDClk0PreScale 0x201
+#define PM2VDACRDDClk0FeedbackScale 0x202
+#define PM2VDACRDDClk0PostScale 0x203
+#define PM2VDACRDDClk1PreScale 0x204
+#define PM2VDACRDDClk1FeedbackScale 0x205
+#define PM2VDACRDDClk1PostScale 0x206
+#define PM2VDACRDMClkControl 0x20D
+#define PM2VDACRDMClkPreScale 0x20E
+#define PM2VDACRDMClkFeedbackScale 0x20F
+#define PM2VDACRDMClkPostScale 0x210
+#define PM2VDACRDCursorPalette 0x303
+#define PM2VDACRDCursorPattern 0x400
+#define PM2VDACIndexRegLow 0x4020
+#define PM2VDACIndexRegHigh 0x4028
+#define PM2VDACIndexData 0x4030
+
+#define PM2VDACRDIndexControl 0x4038
+/* Permedia 2 Video Streams Unit Registers */
+# define VSBIntFlag (1<<8)
+# define VSAIntFlag (1<<9)
+
+#define VSConfiguration 0x5800
+# define VS_UnitMode_ROM 0
+# define VS_UnitMode_AB8 3
+# define VS_UnitMode_Mask 7
+# define VS_GPBusMode_A (1<<3)
+# define VS_HRefPolarityA (1<<9)
+# define VS_VRefPolarityA (1<<10)
+# define VS_VActivePolarityA (1<<11)
+# define VS_UseFieldA (1<<12)
+# define VS_FieldPolarityA (1<<13)
+# define VS_FieldEdgeA (1<<14)
+# define VS_VActiveVBIA (1<<15)
+# define VS_InterlaceA (1<<16)
+# define VS_ReverseDataA (1<<17)
+# define VS_HRefPolarityB (1<<18)
+# define VS_VRefPolarityB (1<<19)
+# define VS_VActivePolarityB (1<<20)
+# define VS_UseFieldB (1<<21)
+# define VS_FieldPolarityB (1<<22)
+# define VS_FieldEdgeB (1<<23)
+# define VS_VActiveVBIB (1<<24)
+# define VS_InterlaceB (1<<25)
+# define VS_ColorSpaceB_RGB (1<<26)
+# define VS_ReverseDataB (1<<27)
+# define VS_DoubleEdgeB (1<<28)
+
+#define VSStatus 0x5808
+# define VS_FieldOne0A (1<<9)
+# define VS_FieldOne1A (1<<10)
+# define VS_FieldOne2A (1<<11)
+# define VS_InvalidInterlaceA (1<<12)
+# define VS_FieldOne0B (1<<17)
+# define VS_FieldOne1B (1<<18)
+# define VS_FieldOne2B (1<<19)
+# define VS_InvalidInterlaceB (1<<20)
+
+#define VSSerialBusControl 0x5810
+
+#define VSABase 0x5900
+# define VSA_Video (1<<0)
+# define VSA_VBI (1<<1)
+# define VSA_BufferCtl (1<<2)
+# define VSA_MirrorX (1<<7)
+# define VSA_MirrorY (1<<8)
+# define VSA_Discard_None (0<<9)
+# define VSA_Discard_FieldOne (1<<9)
+# define VSA_Discard_FieldTwo (2<<9)
+# define VSA_CombineFields (1<<11)
+# define VSA_LockToStreamB (1<<12)
+
+#define VSBBase 0x5A00
+# define VSB_Video (1<<0)
+# define VSB_VBI (1<<1)
+# define VSB_BufferCtl (1<<2)
+# define VSB_CombineFields (1<<3)
+# define VSB_RGBOrder (1<<11)
+# define VSB_GammaCorrect (1<<12)
+# define VSB_LockToStreamA (1<<13)
+
+#define VSControl 0x0000
+#define VSInterrupt 0x0008
+#define VSCurrentLine 0x0010
+#define VSVideoAddressHost 0x0018
+#define VSVideoAddressIndex 0x0020
+#define VSVideoAddress0 0x0028
+#define VSVideoAddress1 0x0030
+#define VSVideoAddress2 0x0038
+#define VSVideoStride 0x0040
+#define VSVideoStartLine 0x0048
+#define VSVideoEndLine 0x0050
+#define VSVideoStartData 0x0058
+#define VSVideoEndData 0x0060
+#define VSVBIAddressHost 0x0068
+#define VSVBIAddressIndex 0x0070
+#define VSVBIAddress0 0x0078
+#define VSVBIAddress1 0x0080
+#define VSVBIAddress2 0x0088
+#define VSVBIStride 0x0090
+#define VSVBIStartLine 0x0098
+#define VSVBIEndLine 0x00A0
+#define VSVBIStartData 0x00A8
+#define VSVBIEndData 0x00B0
+#define VSFifoControl 0x00B8
+
+/**********************************
+ * GLINT Delta Region 0 Registers *
+ **********************************/
+
+/* Control Status Registers */
+#define DResetStatus 0x0800
+#define DIntEnable 0x0808
+#define DIntFlags 0x0810
+#define DErrorFlags 0x0838
+#define DTestRegister 0x0848
+#define DFIFODis 0x0868
+
+
+
+/**********************************
+ * GLINT Gamma Region 0 Registers *
+ **********************************/
+
+/* Control Status Registers */
+#define GInFIFOSpace 0x0018
+#define GDMAAddress 0x0028
+#define GDMACount 0x0030
+#define GDMAControl 0x0060
+#define GOutDMA 0x0080
+#define GOutDMACount 0x0088
+#define GResetStatus 0x0800
+#define GIntEnable 0x0808
+#define GIntFlags 0x0810
+#define GErrorFlags 0x0838
+#define GTestRegister 0x0848
+#define GFIFODis 0x0868
+
+#define GChipConfig 0x0870
+# define GChipAGPCapable 1 << 0
+# define GChipAGPSideband 1 << 1
+# define GChipMultiGLINTApMask 3 << 19
+# define GChipMultiGLINTAp_0M 0 << 19
+# define GChipMultiGLINTAp_16M 1 << 19
+# define GChipMultiGLINTAp_32M 2 << 19
+# define GChipMultiGLINTAp_64M 3 << 19
+
+#define GCSRAperture 0x0878
+# define GCSRSecondaryGLINTMapEn 1 << 0
+# define GCSRBitSwap 1 << 1
+
+#define GPageTableAddr 0x0c00
+#define GPageTableLength 0x0c08
+#define GDelayTimer 0x0c38
+#define GCommandMode 0x0c40
+#define GCommandIntEnable 0x0c48
+#define GCommandIntFlags 0x0c50
+#define GCommandErrorFlags 0x0c58
+#define GCommandStatus 0x0c60
+#define GCommandFaultingAddr 0x0c68
+#define GVertexFaultingAddr 0x0c70
+#define GWriteFaultingAddr 0x0c88
+#define GFeedbackSelectCount 0x0c98
+#define GGammaProcessorMode 0x0cb8
+#define GVGAShadow 0x0d00
+#define GMultGLINTAperture 0x0d08
+#define GMultGLINT1 0x0d10
+#define GMultGLINT2 0x0d18
+
+/************************
+ * GLINT Core Registers *
+ ************************/
+
+#define GLINT_TAG(major,offset) (((major) << 7) | ((offset) << 3))
+#define GLINT_TAG_ADDR(major,offset) (0x8000 | GLINT_TAG((major),(offset)))
+
+#define UNIT_DISABLE 0
+#define UNIT_ENABLE 1
+
+#define StartXDom GLINT_TAG_ADDR(0x00,0x00)
+#define dXDom GLINT_TAG_ADDR(0x00,0x01)
+#define StartXSub GLINT_TAG_ADDR(0x00,0x02)
+#define dXSub GLINT_TAG_ADDR(0x00,0x03)
+#define StartY GLINT_TAG_ADDR(0x00,0x04)
+#define dY GLINT_TAG_ADDR(0x00,0x05)
+#define GLINTCount GLINT_TAG_ADDR(0x00,0x06)
+
+#define Render GLINT_TAG_ADDR(0x00,0x07)
+# define AreaStippleEnable 0x00001
+# define LineStippleEnable 0x00002
+# define ResetLineStipple 0x00004
+# define FastFillEnable 0x00008
+# define PrimitiveLine 0
+# define PrimitiveTrapezoid 0x00040
+# define PrimitivePoint 0x00080
+# define PrimitiveRectangle 0x000C0
+# define AntialiasEnable 0x00100
+# define AntialiasingQuality 0x00200
+# define UsePointTable 0x00400
+# define SyncOnBitMask 0x00800
+# define SyncOnHostData 0x01000
+# define TextureEnable 0x02000
+# define FogEnable 0x04000
+# define CoverageEnable 0x08000
+# define SubPixelCorrectionEnable 0x10000
+# define SpanOperation 0x40000
+# define XPositive 1<<21
+# define YPositive 1<<22
+
+#define ContinueNewLine GLINT_TAG_ADDR(0x00,0x08)
+#define ContinueNewDom GLINT_TAG_ADDR(0x00,0x09)
+#define ContinueNewSub GLINT_TAG_ADDR(0x00,0x0a)
+#define Continue GLINT_TAG_ADDR(0x00,0x0b)
+#define FlushSpan GLINT_TAG_ADDR(0x00,0x0c)
+#define BitMaskPattern GLINT_TAG_ADDR(0x00,0x0d)
+
+#define PointTable0 GLINT_TAG_ADDR(0x01,0x00)
+#define PointTable1 GLINT_TAG_ADDR(0x01,0x01)
+#define PointTable2 GLINT_TAG_ADDR(0x01,0x02)
+#define PointTable3 GLINT_TAG_ADDR(0x01,0x03)
+
+#define RasterizerMode GLINT_TAG_ADDR(0x01,0x04)
+#define RMMultiGLINT 1<<17
+#define BitMaskPackingEachScanline 1<<9
+#define ForceBackgroundColor 1<<6
+#define InvertBitMask 1<<1
+
+#define YLimits GLINT_TAG_ADDR(0x01,0x05)
+#define ScanLineOwnership GLINT_TAG_ADDR(0x01,0x06)
+#define WaitForCompletion GLINT_TAG_ADDR(0x01,0x07)
+#define PixelSize GLINT_TAG_ADDR(0x01,0x08)
+#define XLimits GLINT_TAG_ADDR(0x01,0x09) /* PM only */
+
+#define RectangleOrigin GLINT_TAG_ADDR(0x01,0x0A) /* PM2 only */
+#define RectangleSize GLINT_TAG_ADDR(0x01,0x0B) /* PM2 only */
+
+#define PackedDataLimits GLINT_TAG_ADDR(0x02,0x0a) /* PM only */
+
+#define ScissorMode GLINT_TAG_ADDR(0x03,0x00)
+# define SCI_USER 0x01
+# define SCI_SCREEN 0x02
+# define SCI_USERANDSCREEN 0x03
+
+#define ScissorMinXY GLINT_TAG_ADDR(0x03,0x01)
+#define ScissorMaxXY GLINT_TAG_ADDR(0x03,0x02)
+#define ScreenSize GLINT_TAG_ADDR(0x03,0x03)
+#define AreaStippleMode GLINT_TAG_ADDR(0x03,0x04)
+ /* 0: */
+ /* NoMirrorY */
+ /* NoMirrorX */
+ /* NoInvertPattern */
+ /* YAddress_1bit */
+ /* XAddress_1bit */
+ /* UNIT_DISABLE */
+
+# define ASM_XAddress_2bit 1 << 1
+# define ASM_XAddress_3bit 2 << 1
+# define ASM_XAddress_4bit 3 << 1
+# define ASM_XAddress_5bit 4 << 1
+# define ASM_YAddress_2bit 1 << 4
+# define ASM_YAddress_3bit 2 << 4
+# define ASM_YAddress_4bit 3 << 4
+# define ASM_YAddress_5bit 4 << 4
+# define ASM_InvertPattern 1 << 17
+# define ASM_MirrorX 1 << 18
+# define ASM_MirrorY 1 << 19
+
+#define LineStippleMode GLINT_TAG_ADDR(0x03,0x05)
+#define LoadLineStippleCounters GLINT_TAG_ADDR(0x03,0x06)
+#define UpdateLineStippleCounters GLINT_TAG_ADDR(0x03,0x07)
+#define SaveLineStippleState GLINT_TAG_ADDR(0x03,0x08)
+#define WindowOrigin GLINT_TAG_ADDR(0x03,0x09)
+
+#define AreaStipplePattern0 GLINT_TAG_ADDR(0x04,0x00)
+#define AreaStipplePattern1 GLINT_TAG_ADDR(0x04,0x01)
+#define AreaStipplePattern2 GLINT_TAG_ADDR(0x04,0x02)
+#define AreaStipplePattern3 GLINT_TAG_ADDR(0x04,0x03)
+#define AreaStipplePattern4 GLINT_TAG_ADDR(0x04,0x04)
+#define AreaStipplePattern5 GLINT_TAG_ADDR(0x04,0x05)
+#define AreaStipplePattern6 GLINT_TAG_ADDR(0x04,0x06)
+#define AreaStipplePattern7 GLINT_TAG_ADDR(0x04,0x07)
+
+#define TextureAddressMode GLINT_TAG_ADDR(0x07,0x00)
+#define SStart GLINT_TAG_ADDR(0x07,0x01)
+#define dSdx GLINT_TAG_ADDR(0x07,0x02)
+#define dSdyDom GLINT_TAG_ADDR(0x07,0x03)
+#define TStart GLINT_TAG_ADDR(0x07,0x04)
+#define dTdx GLINT_TAG_ADDR(0x07,0x05)
+#define dTdyDom GLINT_TAG_ADDR(0x07,0x06)
+#define QStart GLINT_TAG_ADDR(0x07,0x07)
+#define dQdx GLINT_TAG_ADDR(0x07,0x08)
+#define dQdyDom GLINT_TAG_ADDR(0x07,0x09)
+#define LOD GLINT_TAG_ADDR(0x07,0x0A)
+#define dSdy GLINT_TAG_ADDR(0x07,0x0B)
+#define dTdy GLINT_TAG_ADDR(0x07,0x0C)
+#define dQdy GLINT_TAG_ADDR(0x07,0x0D)
+
+#define TextureReadMode GLINT_TAG_ADDR(0x09,0x00)
+
+#define TextureFormat GLINT_TAG_ADDR(0x09,0x01)
+# define Texture_4_Components 3 << 3
+# define Texture_Texel 0
+
+#define TextureCacheControl GLINT_TAG_ADDR(0x09,0x02)
+# define TextureCacheControlEnable 2
+# define TextureCacheControlInvalidate 1
+
+#define GLINTBorderColor GLINT_TAG_ADDR(0x09,0x05)
+
+#define TexelLUTIndex GLINT_TAG_ADDR(0x09,0x08)
+#define TexelLUTData GLINT_TAG_ADDR(0x09,0x09)
+#define TexelLUTAddress GLINT_TAG_ADDR(0x09,0x0A)
+#define TexelLUTTransfer GLINT_TAG_ADDR(0x09,0x0B)
+
+#define TextureFilterMode GLINT_TAG_ADDR(0x09,0x0C)
+
+#define TextureChromaUpper GLINT_TAG_ADDR(0x09,0x0D)
+#define TextureChromaLower GLINT_TAG_ADDR(0x09,0x0E)
+
+#define TxBaseAddr0 GLINT_TAG_ADDR(0x0A,0x00)
+#define TxBaseAddr1 GLINT_TAG_ADDR(0x0A,0x01)
+#define TxBaseAddr2 GLINT_TAG_ADDR(0x0A,0x02)
+#define TxBaseAddr3 GLINT_TAG_ADDR(0x0A,0x03)
+#define TxBaseAddr4 GLINT_TAG_ADDR(0x0A,0x04)
+#define TxBaseAddr5 GLINT_TAG_ADDR(0x0A,0x05)
+#define TxBaseAddr6 GLINT_TAG_ADDR(0x0A,0x06)
+#define TxBaseAddr7 GLINT_TAG_ADDR(0x0A,0x07)
+#define TxBaseAddr8 GLINT_TAG_ADDR(0x0A,0x08)
+#define TxBaseAddr9 GLINT_TAG_ADDR(0x0A,0x09)
+#define TxBaseAddr10 GLINT_TAG_ADDR(0x0A,0x0A)
+#define TxBaseAddr11 GLINT_TAG_ADDR(0x0A,0x0B)
+
+#define PMTextureBaseAddress GLINT_TAG_ADDR(0x0b,0x00)
+#define PMTextureMapFormat GLINT_TAG_ADDR(0x0b,0x01)
+#define PMTextureDataFormat GLINT_TAG_ADDR(0x0b,0x02)
+
+#define Texel0 GLINT_TAG_ADDR(0x0c,0x00)
+#define Texel1 GLINT_TAG_ADDR(0x0c,0x01)
+#define Texel2 GLINT_TAG_ADDR(0x0c,0x02)
+#define Texel3 GLINT_TAG_ADDR(0x0c,0x03)
+#define Texel4 GLINT_TAG_ADDR(0x0c,0x04)
+#define Texel5 GLINT_TAG_ADDR(0x0c,0x05)
+#define Texel6 GLINT_TAG_ADDR(0x0c,0x06)
+#define Texel7 GLINT_TAG_ADDR(0x0c,0x07)
+
+#define Interp0 GLINT_TAG_ADDR(0x0c,0x08)
+#define Interp1 GLINT_TAG_ADDR(0x0c,0x09)
+#define Interp2 GLINT_TAG_ADDR(0x0c,0x0a)
+#define Interp3 GLINT_TAG_ADDR(0x0c,0x0b)
+#define Interp4 GLINT_TAG_ADDR(0x0c,0x0c)
+
+#define TextureFilter GLINT_TAG_ADDR(0x0c,0x0d)
+#define PMTextureReadMode GLINT_TAG_ADDR(0x0c,0x0e)
+#define TexelLUTMode GLINT_TAG_ADDR(0x0c,0x0f)
+
+#define TextureColorMode GLINT_TAG_ADDR(0x0d,0x00)
+# define TextureTypeOpenGL 0
+# define TextureTypeApple 1 << 4
+# define TextureKsDDA 1 << 5 /* only Apple-Mode */
+# define TextureKdDDA 1 << 6 /* only Apple-Mode */
+
+#define TextureEnvColor GLINT_TAG_ADDR(0x0d,0x01)
+#define FogMode GLINT_TAG_ADDR(0x0d,0x02)
+ /* 0: */
+ /* FOG RGBA */
+ /* UNIT_DISABLE */
+# define FOG_CI 0x0002
+
+#define FogColor GLINT_TAG_ADDR(0x0d,0x03)
+#define FStart GLINT_TAG_ADDR(0x0d,0x04)
+#define dFdx GLINT_TAG_ADDR(0x0d,0x05)
+#define dFdyDom GLINT_TAG_ADDR(0x0d,0x06)
+#define KsStart GLINT_TAG_ADDR(0x0d,0x09)
+#define dKsdx GLINT_TAG_ADDR(0x0d,0x0a)
+#define dKsdyDom GLINT_TAG_ADDR(0x0d,0x0b)
+#define KdStart GLINT_TAG_ADDR(0x0d,0x0c)
+#define dKdStart GLINT_TAG_ADDR(0x0d,0x0d)
+#define dKddyDom GLINT_TAG_ADDR(0x0d,0x0e)
+
+#define RStart GLINT_TAG_ADDR(0x0f,0x00)
+#define dRdx GLINT_TAG_ADDR(0x0f,0x01)
+#define dRdyDom GLINT_TAG_ADDR(0x0f,0x02)
+#define GStart GLINT_TAG_ADDR(0x0f,0x03)
+#define dGdx GLINT_TAG_ADDR(0x0f,0x04)
+#define dGdyDom GLINT_TAG_ADDR(0x0f,0x05)
+#define BStart GLINT_TAG_ADDR(0x0f,0x06)
+#define dBdx GLINT_TAG_ADDR(0x0f,0x07)
+#define dBdyDom GLINT_TAG_ADDR(0x0f,0x08)
+#define AStart GLINT_TAG_ADDR(0x0f,0x09)
+#define dAdx GLINT_TAG_ADDR(0x0f,0x0a)
+#define dAdyDom GLINT_TAG_ADDR(0x0f,0x0b)
+#define ColorDDAMode GLINT_TAG_ADDR(0x0f,0x0c)
+ /* 0:*/
+ /* UNIT_DISABLE */
+# define CDDA_FlatShading 0
+# define CDDA_GouraudShading 0x0002
+
+
+#define ConstantColor GLINT_TAG_ADDR(0x0f,0x0d)
+#define GLINTColor GLINT_TAG_ADDR(0x0f,0x0e)
+#define AlphaTestMode GLINT_TAG_ADDR(0x10,0x00)
+#define AntialiasMode GLINT_TAG_ADDR(0x10,0x01)
+#define AlphaBlendMode GLINT_TAG_ADDR(0x10,0x02)
+ /* 0: */
+ /* SrcZERO */
+ /* DstZERO */
+ /* ColorFormat8888 */
+ /* AlphaBuffer present */
+ /* ColorOrderBGR */
+ /* TypeOpenGL */
+ /* DstFBData */
+ /* UNIT_DISABLE */
+
+# define ABM_SrcONE 1 << 1
+# define ABM_SrcDST_COLOR 2 << 1
+# define ABM_SrcONE_MINUS_DST_COLOR 3 << 1
+# define ABM_SrcSRC_ALPHA 4 << 1
+# define ABM_SrcONE_MINUS_SRC_ALPHA 5 << 1
+# define ABM_SrcDST_ALPHA 6 << 1
+# define ABM_SrcONE_MINUS_DST_ALPHA 7 << 1
+# define ABM_SrcSRC_ALPHA_SATURATE 8 << 1
+# define ABM_DstONE 1 << 5
+# define ABM_DstSRC_COLOR 2 << 5
+# define ABM_DstONE_MINUS_SRC_COLOR 3 << 5
+# define ABM_DstSRC_ALPHA 4 << 5
+# define ABM_DstONE_MINUS_SRC_ALPHA 5 << 5
+# define ABM_DstDST_ALPHA 6 << 5
+# define ABM_DstONE_MINUS_DST_ALPHA 7 << 5
+# define ABM_ColorFormat5555 1 << 8
+# define ABM_ColorFormat4444 2 << 8
+# define ABM_ColorFormat4444_Front 3 << 8
+# define ABM_ColorFormat4444_Back 4 << 8
+# define ABM_ColorFormat332_Front 5 << 8
+# define ABM_ColorFormat332_Back 6 << 8
+# define ABM_ColorFormat121_Front 7 << 8
+# define ABM_ColorFormat121_Back 8 << 8
+# define ABM_ColorFormat555_Back 13 << 8
+# define ABM_ColorFormat_CI8 14 << 8
+# define ABM_ColorFormat_CI4 15 << 8
+# define ABM_NoAlphaBuffer 0x1000
+# define ABM_ColorOrderRGB 0x2000
+# define ABM_TypeQuickDraw3D 0x4000
+# define ABM_DstFBSourceData 0x8000
+
+#define DitherMode GLINT_TAG_ADDR(0x10,0x03)
+ /* 0: */
+ /* ColorOrder BGR */
+ /* AlphaDitherDefault */
+ /* ColorFormat8888 */
+ /* TruncateMode */
+ /* DitherDisable */
+ /* UNIT_DISABLE */
+
+# define DTM_DitherEnable 1 << 1
+# define DTM_ColorFormat5555 1 << 2
+# define DTM_ColorFormat4444 2 << 2
+# define DTM_ColorFormat4444_Front 3 << 2
+# define DTM_ColorFormat4444_Back 4 << 2
+# define DTM_ColorFormat332_Front 5 << 2
+# define DTM_ColorFormat332_Back 6 << 2
+# define DTM_ColorFormat121_Front 7 << 2
+# define DTM_ColorFormat121_Back 8 << 2
+# define DTM_ColorFormat555_Back 13 << 2
+# define DTM_ColorFormat_CI8 14 << 2
+# define DTM_ColorFormat_CI4 15 << 2
+# define DTM_ColorOrderRGB 1 << 10
+# define DTM_NoAlphaDither 1 << 14
+# define DTM_RoundMode 1 << 15
+
+#define FBSoftwareWriteMask GLINT_TAG_ADDR(0x10,0x04)
+#define LogicalOpMode GLINT_TAG_ADDR(0x10,0x05)
+# define Use_ConstantFBWriteData 0x40
+
+
+#define FBWriteData GLINT_TAG_ADDR(0x10,0x06)
+#define RouterMode GLINT_TAG_ADDR(0x10,0x08)
+# define ROUTER_Depth_Texture 1
+# define ROUTER_Texture_Depth 0
+
+
+#define LBReadMode GLINT_TAG_ADDR(0x11,0x00)
+ /* 0: */
+ /* SrcNoRead */
+ /* DstNoRead */
+ /* DataLBDefault */
+ /* WinTopLeft */
+ /* NoPatch */
+ /* ScanlineInterval1 */
+
+# define LBRM_SrcEnable 1 << 9
+# define LBRM_DstEnable 1 << 10
+# define LBRM_DataLBStencil 1 << 16
+# define LBRM_DataLBDepth 2 << 16
+# define LBRM_WinBottomLeft 1 << 18
+# define LBRM_DoPatch 1 << 19
+
+# define LBRM_ScanlineInt2 1 << 20
+# define LBRM_ScanlineInt4 2 << 20
+# define LBRM_ScanlineInt8 3 << 20
+
+
+#define LBReadFormat GLINT_TAG_ADDR(0x11,0x01)
+# define LBRF_DepthWidth15 0x03 /* only permedia */
+# define LBRF_DepthWidth16 0x00
+# define LBRF_DepthWidth24 0x01
+# define LBRF_DepthWidth32 0x02
+
+# define LBRF_StencilWidth0 (0 << 2)
+# define LBRF_StencilWidth4 (1 << 2)
+# define LBRF_StencilWidth8 (2 << 2)
+
+# define LBRF_StencilPos16 (0 << 4)
+# define LBRF_StencilPos20 (1 << 4)
+# define LBRF_StencilPos24 (2 << 4)
+# define LBRF_StencilPos28 (3 << 4)
+# define LBRF_StencilPos32 (4 << 4)
+
+# define LBRF_FrameCount0 (0 << 7)
+# define LBRF_FrameCount4 (1 << 7)
+# define LBRF_FrameCount8 (2 << 7)
+
+# define LBRF_FrameCountPos16 (0 << 9)
+# define LBRF_FrameCountPos20 (1 << 9)
+# define LBRF_FrameCountPos24 (2 << 9)
+# define LBRF_FrameCountPos28 (3 << 9)
+# define LBRF_FrameCountPos32 (4 << 9)
+# define LBRF_FrameCountPos36 (5 << 9)
+# define LBRF_FrameCountPos40 (6 << 9)
+
+# define LBRF_GIDWidth0 (0 << 12)
+# define LBRF_GIDWidth4 (1 << 12)
+
+# define LBRF_GIDPos16 (0 << 13)
+# define LBRF_GIDPos20 (1 << 13)
+# define LBRF_GIDPos24 (2 << 13)
+# define LBRF_GIDPos28 (3 << 13)
+# define LBRF_GIDPos32 (4 << 13)
+# define LBRF_GIDPos36 (5 << 13)
+# define LBRF_GIDPos40 (6 << 13)
+# define LBRF_GIDPos44 (7 << 13)
+# define LBRF_GIDPos48 (8 << 13)
+
+# define LBRF_Compact32 (1 << 17)
+
+
+
+#define LBSourceOffset GLINT_TAG_ADDR(0x11,0x02)
+#define LBStencil GLINT_TAG_ADDR(0x11,0x05)
+#define LBDepth GLINT_TAG_ADDR(0x11,0x06)
+#define LBWindowBase GLINT_TAG_ADDR(0x11,0x07)
+#define LBWriteMode GLINT_TAG_ADDR(0x11,0x08)
+# define LBWM_WriteEnable 0x1
+# define LBWM_UpLoad_LBDepth 0x2
+# define LBWM_UpLoad_LBStencil 0x4
+
+#define LBWriteFormat GLINT_TAG_ADDR(0x11,0x09)
+
+
+#define TextureData GLINT_TAG_ADDR(0x11,0x0d)
+#define TextureDownloadOffset GLINT_TAG_ADDR(0x11,0x0e)
+#define LBWindowOffset GLINT_TAG_ADDR(0x11,0x0f)
+
+#define GLINTWindow GLINT_TAG_ADDR(0x13,0x00)
+# define GWIN_UnitEnable (1 << 0)
+# define GWIN_ForceLBUpdate (1 << 3)
+# define GWIN_LBUpdateSourceREG (1 << 4)
+# define GWIN_LBUpdateSourceLB (0 << 4)
+# define GWIN_StencilFCP (1 << 17)
+# define GWIN_DepthFCP (1 << 18)
+# define GWIN_OverrideWriteFilter (1 << 19)
+# define GWIN_DisableLBUpdate 0x40000 /* ??? is this needed, set by permedia (2) modules */
+
+#define StencilMode GLINT_TAG_ADDR(0x13,0x01)
+#define StencilData GLINT_TAG_ADDR(0x13,0x02)
+#define GLINTStencil GLINT_TAG_ADDR(0x13,0x03)
+#define DepthMode GLINT_TAG_ADDR(0x13,0x04)
+ /* 0: */
+ /* WriteDisable */
+ /* SrcCompFragment */
+ /* CompFuncNEVER */
+ /* UNIT_DISABLE */
+
+# define DPM_WriteEnable 1 << 1
+# define DPM_SrcCompLBData 1 << 2
+# define DPM_SrcCompDregister 2 << 2
+# define DPM_SrcCompLBSourceData 3 << 2
+# define DPM_CompFuncLESS 1 << 4
+# define DPM_CompFuncEQUAL 2 << 4
+# define DPM_CompFuncLESS_OR_EQ 3 << 4
+# define DPM_CompFuncGREATER 4 << 4
+# define DPM_CompFuncNOT_EQ 5 << 4
+# define DPM_CompFuncGREATER_OR_EQ 6 << 4
+# define DPM_CompFuncALWAYS 7 << 4
+
+#define GLINTDepth GLINT_TAG_ADDR(0x13,0x05)
+#define ZStartU GLINT_TAG_ADDR(0x13,0x06)
+#define ZStartL GLINT_TAG_ADDR(0x13,0x07)
+#define dZdxU GLINT_TAG_ADDR(0x13,0x08)
+#define dZdxL GLINT_TAG_ADDR(0x13,0x09)
+#define dZdyDomU GLINT_TAG_ADDR(0x13,0x0a)
+#define dZdyDomL GLINT_TAG_ADDR(0x13,0x0b)
+#define FastClearDepth GLINT_TAG_ADDR(0x13,0x0c)
+
+#define FBReadMode GLINT_TAG_ADDR(0x15,0x00)
+ /* 0: */
+ /* SrcNoRead */
+ /* DstNoRead */
+ /* DataFBDefault */
+ /* WinTopLeft */
+ /* ScanlineInterval1 */
+
+# define FBRM_SrcEnable 1 << 9
+# define FBRM_DstEnable 1 << 10
+# define FBRM_DataFBColor 1 << 15
+# define FBRM_WinBottomLeft 1 << 16
+# define FBRM_Packed 1 << 19
+# define FBRM_ScanlineInt2 1 << 23
+# define FBRM_ScanlineInt4 2 << 23
+# define FBRM_ScanlineInt8 3 << 23
+
+
+#define FBSourceOffset GLINT_TAG_ADDR(0x15,0x01)
+#define FBPixelOffset GLINT_TAG_ADDR(0x15,0x02)
+#define FBColor GLINT_TAG_ADDR(0x15,0x03)
+#define FBData GLINT_TAG_ADDR(0x15,0x04)
+#define FBSourceData GLINT_TAG_ADDR(0x15,0x05)
+
+#define FBWindowBase GLINT_TAG_ADDR(0x15,0x06)
+#define FBWriteMode GLINT_TAG_ADDR(0x15,0x07)
+ /* 0: */
+ /* FBWM_NoColorUpload */
+ /* FBWM_WriteDisable */
+# define FBWM_WriteEnable 1
+# define FBWM_UploadColor 1 << 3
+# define FBWM_Enable0 1 << 12 /* PM3 */
+
+#define FBHardwareWriteMask GLINT_TAG_ADDR(0x15,0x08)
+#define FBBlockColor GLINT_TAG_ADDR(0x15,0x09)
+#define FBReadPixel GLINT_TAG_ADDR(0x15,0x0a) /* PM */
+#define PatternRamMode GLINT_TAG_ADDR(0x15,0x0f)
+
+#define PatternRamData0 GLINT_TAG_ADDR(0x16,0x00)
+#define PatternRamData1 GLINT_TAG_ADDR(0x16,0x01)
+#define PatternRamData2 GLINT_TAG_ADDR(0x16,0x02)
+#define PatternRamData3 GLINT_TAG_ADDR(0x16,0x03)
+#define PatternRamData4 GLINT_TAG_ADDR(0x16,0x04)
+#define PatternRamData5 GLINT_TAG_ADDR(0x16,0x05)
+#define PatternRamData6 GLINT_TAG_ADDR(0x16,0x06)
+#define PatternRamData7 GLINT_TAG_ADDR(0x16,0x07)
+
+#define FilterMode GLINT_TAG_ADDR(0x18,0x00)
+ /* 0: */
+ /* CullDepthTags */
+ /* CullDepthData */
+ /* CullStencilTags */
+ /* CullStencilData */
+ /* CullColorTag */
+ /* CullColorData */
+ /* CullSyncTag */
+ /* CullSyncData */
+ /* CullStatisticTag */
+ /* CullStatisticData */
+
+# define FM_PassDepthTags 0x0010
+# define FM_PassDepthData 0x0020
+# define FM_PassStencilTags 0x0040
+# define FM_PassStencilData 0x0080
+# define FM_PassColorTag 0x0100
+# define FM_PassColorData 0x0200
+# define FM_PassSyncTag 0x0400
+# define FM_PassSyncData 0x0800
+# define FM_PassStatisticTag 0x1000
+# define FM_PassStatisticData 0x2000
+
+#define Sync_tag 0x0188
+
+#define StatisticMode GLINT_TAG_ADDR(0x18,0x01)
+#define MinRegion GLINT_TAG_ADDR(0x18,0x02)
+#define MaxRegion GLINT_TAG_ADDR(0x18,0x03)
+#define ResetPickResult GLINT_TAG_ADDR(0x18,0x04)
+#define MitHitRegion GLINT_TAG_ADDR(0x18,0x05)
+#define MaxHitRegion GLINT_TAG_ADDR(0x18,0x06)
+#define PickResult GLINT_TAG_ADDR(0x18,0x07)
+#define GlintSync GLINT_TAG_ADDR(0x18,0x08)
+
+#define FBBlockColorU GLINT_TAG_ADDR(0x18,0x0d)
+#define FBBlockColorL GLINT_TAG_ADDR(0x18,0x0e)
+#define SuspendUntilFrameBlank GLINT_TAG_ADDR(0x18,0x0f)
+
+#define KsRStart GLINT_TAG_ADDR(0x19,0x00)
+#define dKsRdx GLINT_TAG_ADDR(0x19,0x01)
+#define dKsRdyDom GLINT_TAG_ADDR(0x19,0x02)
+#define KsGStart GLINT_TAG_ADDR(0x19,0x03)
+#define dKsGdx GLINT_TAG_ADDR(0x19,0x04)
+#define dKsGdyDom GLINT_TAG_ADDR(0x19,0x05)
+#define KsBStart GLINT_TAG_ADDR(0x19,0x06)
+#define dKsBdx GLINT_TAG_ADDR(0x19,0x07)
+#define dKsBdyDom GLINT_TAG_ADDR(0x19,0x08)
+
+#define KdRStart GLINT_TAG_ADDR(0x1A,0x00)
+#define dKdRdx GLINT_TAG_ADDR(0x1A,0x01)
+#define dKdRdyDom GLINT_TAG_ADDR(0x1A,0x02)
+#define KdGStart GLINT_TAG_ADDR(0x1A,0x03)
+#define dKdGdx GLINT_TAG_ADDR(0x1A,0x04)
+#define dKdGdyDom GLINT_TAG_ADDR(0x1A,0x05)
+#define KdBStart GLINT_TAG_ADDR(0x1A,0x06)
+#define dKdBdx GLINT_TAG_ADDR(0x1A,0x07)
+#define dKdBdyDom GLINT_TAG_ADDR(0x1A,0x08)
+
+#define FBSourceBase GLINT_TAG_ADDR(0x1B,0x00)
+#define FBSourceDelta GLINT_TAG_ADDR(0x1B,0x01)
+#define Config GLINT_TAG_ADDR(0x1B,0x02)
+#define CFBRM_SrcEnable 1<<0
+#define CFBRM_DstEnable 1<<1
+#define CFBRM_Packed 1<<2
+#define CWM_Enable 1<<3
+#define CCDDA_Enable 1<<4
+#define CLogOp_Enable 1<<5
+#define ContextDump GLINT_TAG_ADDR(0x1B,0x08)
+#define ContextRestore GLINT_TAG_ADDR(0x1B,0x09)
+#define ContextData GLINT_TAG_ADDR(0x1B,0x0a)
+
+#define TexelLUT0 GLINT_TAG_ADDR(0x1D,0x00)
+#define TexelLUT1 GLINT_TAG_ADDR(0x1D,0x01)
+#define TexelLUT2 GLINT_TAG_ADDR(0x1D,0x02)
+#define TexelLUT3 GLINT_TAG_ADDR(0x1D,0x03)
+#define TexelLUT4 GLINT_TAG_ADDR(0x1D,0x04)
+#define TexelLUT5 GLINT_TAG_ADDR(0x1D,0x05)
+#define TexelLUT6 GLINT_TAG_ADDR(0x1D,0x06)
+#define TexelLUT7 GLINT_TAG_ADDR(0x1D,0x07)
+#define TexelLUT8 GLINT_TAG_ADDR(0x1D,0x08)
+#define TexelLUT9 GLINT_TAG_ADDR(0x1D,0x09)
+#define TexelLUT10 GLINT_TAG_ADDR(0x1D,0x0A)
+#define TexelLUT11 GLINT_TAG_ADDR(0x1D,0x0B)
+#define TexelLUT12 GLINT_TAG_ADDR(0x1D,0x0C)
+#define TexelLUT13 GLINT_TAG_ADDR(0x1D,0x0D)
+#define TexelLUT14 GLINT_TAG_ADDR(0x1D,0x0E)
+#define TexelLUT15 GLINT_TAG_ADDR(0x1D,0x0F)
+
+#define YUVMode GLINT_TAG_ADDR(0x1E,0x00)
+#define ChromaUpper GLINT_TAG_ADDR(0x1E,0x01)
+#define ChromaLower GLINT_TAG_ADDR(0x1E,0x02)
+#define ChromaTestMode GLINT_TAG_ADDR(0x1E,0x03)
+
+
+/******************************
+ * GLINT Delta Core Registers *
+ ******************************/
+
+#define V0FixedTag GLINT_TAG_ADDR(0x20,0x00)
+#define V1FixedTag GLINT_TAG_ADDR(0x21,0x00)
+#define V2FixedTag GLINT_TAG_ADDR(0x22,0x00)
+#define V0FloatTag GLINT_TAG_ADDR(0x23,0x00)
+#define V1FloatTag GLINT_TAG_ADDR(0x24,0x00)
+#define V2FloatTag GLINT_TAG_ADDR(0x25,0x00)
+
+#define VPAR_s 0x00
+#define VPAR_t 0x08
+#define VPAR_q 0x10
+#define VPAR_Ks 0x18
+#define VPAR_Kd 0x20
+
+/* have changed colors in ramdac !
+#define VPAR_R 0x28
+#define VPAR_G 0x30
+#define VPAR_B 0x38
+#define VPAR_A 0x40
+*/
+#define VPAR_B 0x28
+#define VPAR_G 0x30
+#define VPAR_R 0x38
+#define VPAR_A 0x40
+
+#define VPAR_f 0x48
+
+#define VPAR_x 0x50
+#define VPAR_y 0x58
+#define VPAR_z 0x60
+
+#define DeltaModeTag GLINT_TAG_ADDR(0x26,0x00)
+ /* 0: */
+ /* GLINT_300SX */
+
+ /* DeltaMode Register Bit Field Assignments */
+# define DM_GLINT_300SX 0x0000
+# define DM_GLINT_500TX 0x0001
+# define DM_PERMEDIA 0x0002
+# define DM_Depth_16BPP (1 << 2)
+# define DM_Depth_24BPP (2 << 2)
+# define DM_Depth_32BPP (3 << 2)
+# define DM_FogEnable 0x0010
+# define DM_TextureEnable 0x0020
+# define DM_SmoothShadingEnable 0x0040
+# define DM_DepthEnable 0x0080
+# define DM_SpecularTextureEnable 0x0100
+# define DM_DiffuseTextureEnable 0x0200
+# define DM_SubPixelCorrectionEnable 0x0400
+# define DM_DiamondExit 0x0800
+# define DM_NoDraw 0x1000
+# define DM_ClampEnable 0x2000
+# define DM_ClampedTexParMode 0x4000
+# define DM_NormalizedTexParMode 0xC000
+
+
+# define DDCMD_AreaStrippleEnable 0x0001
+# define DDCMD_LineStrippleEnable 0x0002
+# define DDCMD_ResetLineStripple 1 << 2
+# define DDCMD_FastFillEnable 1 << 3
+ /* 2 Bits reserved */
+# define DDCMD_PrimitiveType_Point 2 << 6
+# define DDCMD_PrimitiveType_Line 0 << 6
+# define DDCMD_PrimitiveType_Trapezoid 1 << 6
+# define DDCMD_AntialiasEnable 1 << 8
+# define DDCMD_AntialiasingQuality 1 << 9
+# define DDCMD_UsePointTable 1 << 10
+# define DDCMD_SyncOnBitMask 1 << 11
+# define DDCMD_SyncOnHostDate 1 << 12
+# define DDCMD_TextureEnable 1 << 13
+# define DDCMD_FogEnable 1 << 14
+# define DDCMD_CoverageEnable 1 << 15
+# define DDCMD_SubPixelCorrectionEnable 1 << 16
+
+
+
+#define DrawTriangle GLINT_TAG_ADDR(0x26,0x01)
+#define RepeatTriangle GLINT_TAG_ADDR(0x26,0x02)
+#define DrawLine01 GLINT_TAG_ADDR(0x26,0x03)
+#define DrawLine10 GLINT_TAG_ADDR(0x26,0x04)
+#define RepeatLine GLINT_TAG_ADDR(0x26,0x05)
+#define BroadcastMask GLINT_TAG_ADDR(0x26,0x0F)
+
+/* Permedia 3 - Accelerator Extensions */
+#define FillRectanglePosition 0x8348
+#define FillRender2D 0x8350
+#define FBDstReadBufAddr0 0xAE80
+#define FBDstReadBufOffset0 0xAEA0
+#define FBDstReadBufWidth0 0xAEC0
+#define FBDstReadMode 0xAEE0
+#define FBDRM_Enable0 1<<8
+#define FBDRM_Blocking 1<<24
+#define FBDstReadEnables 0xAEE8
+#define FBSrcReadMode 0xAF00
+#define FBSRM_Blocking 1<<11
+#define FBSrcReadBufAddr 0xAF08
+#define FBSrcReadBufOffset0 0xAF10
+#define FBSrcReadBufWidth 0xAF18
+#define FBWriteBufAddr0 0xB000
+#define FBWriteBufOffset0 0xB020
+#define FBWriteBufWidth0 0xB040
+#define FBBlockColorBack 0xB0A0
+#define ForegroundColor 0xB0C0
+#define BackgroundColor 0xB0C8
+#define RectanglePosition 0xB600
+#define Render2D 0xB640
+
+/* Colorformats */
+#define BGR555 1
+#define BGR565 16
+#define CI8 14
+#define CI4 15
+
+#if 0
+
+#ifdef DEBUG
+#define GLINT_WRITE_REG(v,r) \
+ GLINT_VERB_WRITE_REG(pGlint,v,r,__FILE__,__LINE__)
+#define GLINT_READ_REG(r) \
+ GLINT_VERB_READ_REG(pGlint,r,__FILE__,__LINE__)
+#else
+
+#define GLINT_WRITE_REG(v,r) \
+ MMIO_OUT32(pGlint->IOBase + pGlint->IOOffset,(unsigned long)(r), (v))
+#define GLINT_READ_REG(r) \
+ MMIO_IN32(pGlint->IOBase + pGlint->IOOffset,(unsigned long)(r))
+
+#endif /* DEBUG */
+
+#define GLINT_WAIT(n) \
+do{ \
+ if (pGlint->InFifoSpace>=(n)) \
+ pGlint->InFifoSpace -= (n); \
+ else { \
+ int tmp; \
+ while((tmp=GLINT_READ_REG(InFIFOSpace))<(n)); \
+ /* Clamp value due to bugs in PM3 */ \
+ if (tmp > pGlint->FIFOSize) \
+ tmp = pGlint->FIFOSize; \
+ pGlint->InFifoSpace = tmp - (n); \
+ } \
+}while(0)
+
+#define GLINTDACDelay(x) do { \
+ int delay = x; \
+ while(delay--){(void)GLINT_READ_REG(InFIFOSpace);}; \
+ } while(0)
+
+#define GLINT_MASK_WRITE_REG(v,m,r) \
+ GLINT_WRITE_REG((GLINT_READ_REG(r)&(m))|(v),r)
+
+#define GLINT_SLOW_WRITE_REG(v,r) \
+do{ \
+ mem_barrier(); \
+ GLINT_WAIT(pGlint->FIFOSize); \
+ mem_barrier(); \
+ GLINT_WRITE_REG(v,r); \
+}while(0)
+
+#define GLINT_SET_INDEX(index) \
+do{ \
+ GLINT_SLOW_WRITE_REG(((index)>>8)&0xff,PM2VDACIndexRegHigh); \
+ GLINT_SLOW_WRITE_REG((index)&0xff,PM2VDACIndexRegLow); \
+} while(0)
+
+#define REPLICATE(r) \
+{ \
+ if (pScrn->bitsPerPixel == 16) { \
+ r &= 0xFFFF; \
+ r |= (r<<16); \
+ } else \
+ if (pScrn->bitsPerPixel == 8) { \
+ r &= 0xFF; \
+ r |= (r<<8); \
+ r |= (r<<16); \
+ } \
+}
+
+#ifndef XF86DRI
+#define LOADROP(rop) \
+{ \
+ if (pGlint->ROP != rop) { \
+ GLINT_WRITE_REG(rop<<1|UNIT_ENABLE, LogicalOpMode); \
+ pGlint->ROP = rop; \
+ } \
+}
+#else
+#define LOADROP(rop) \
+ { \
+ GLINT_WRITE_REG(rop<<1|UNIT_ENABLE, LogicalOpMode); \
+ pGlint->ROP = rop; \
+ }
+#endif
+
+#define CHECKCLIPPING \
+{ \
+ if (pGlint->ClippingOn) { \
+ pGlint->ClippingOn = FALSE; \
+ GLINT_WAIT(1); \
+ GLINT_WRITE_REG(0, ScissorMode); \
+ } \
+}
+
+#ifndef XF86DRI
+#define DO_PLANEMASK(planemask) \
+{ \
+ if (planemask != pGlint->planemask) { \
+ pGlint->planemask = planemask; \
+ REPLICATE(planemask); \
+ GLINT_WRITE_REG(planemask, FBHardwareWriteMask);\
+ } \
+}
+#else
+#define DO_PLANEMASK(planemask) \
+ { \
+ pGlint->planemask = planemask; \
+ REPLICATE(planemask); \
+ GLINT_WRITE_REG(planemask, FBHardwareWriteMask);\
+ }
+#endif
+
+/* Permedia Save/Restore functions */
+
+#define STOREREG(address,value) \
+ pReg->glintRegs[address >> 3] = value;
+
+#define SAVEREG(address) \
+ pReg->glintRegs[address >> 3] = GLINT_READ_REG(address);
+
+#define RESTOREREG(address) \
+ GLINT_SLOW_WRITE_REG(pReg->glintRegs[address >> 3], address);
+
+#define STOREDAC(address,value) \
+ pReg->DacRegs[address] = value;
+
+#define P2VOUT(address) \
+ Permedia2vOutIndReg(pScrn, address, 0x00, pReg->DacRegs[address]);
+
+#define P2VIN(address) \
+ pReg->DacRegs[address] = Permedia2vInIndReg(pScrn, address);
+
+/* RamDac Save/Restore functions, used by external DAC's */
+
+#define STORERAMDAC(address,value) \
+ ramdacReg->DacRegs[address] = value;
+
+/* Multi Chip access */
+
+#define ACCESSCHIP1() \
+ pGlint->IOOffset = 0;
+
+#define ACCESSCHIP2() \
+ pGlint->IOOffset = 0x10000;
+
+#endif /* 0 */
+
+#define GLINT_XY(x,y) (((x) & 0x0FFF) | (((y) & 0x0FFF) << 16))
+
+#endif
diff --git a/xorg-server/hw/kdrive/pm2/pm2.c b/xorg-server/hw/kdrive/pm2/pm2.c
new file mode 100644
index 000000000..148f03abd
--- /dev/null
+++ b/xorg-server/hw/kdrive/pm2/pm2.c
@@ -0,0 +1,295 @@
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "kaa.h"
+
+#include "pm2.h"
+
+#define PARTPROD(a,b,c) (((a)<<6) | ((b)<<3) | (c))
+
+char bppand[4] = { 0x03, /* 8bpp */
+ 0x01, /* 16bpp */
+ 0x00, /* 24bpp */
+ 0x00 /* 32bpp */};
+
+int partprodPermedia[] = {
+ -1,
+ PARTPROD(0,0,1), PARTPROD(0,1,1), PARTPROD(1,1,1), PARTPROD(1,1,2),
+ PARTPROD(1,2,2), PARTPROD(2,2,2), PARTPROD(1,2,3), PARTPROD(2,2,3),
+ PARTPROD(1,3,3), PARTPROD(2,3,3), PARTPROD(1,2,4), PARTPROD(3,3,3),
+ PARTPROD(1,3,4), PARTPROD(2,3,4), -1, PARTPROD(3,3,4),
+ PARTPROD(1,4,4), PARTPROD(2,4,4), -1, PARTPROD(3,4,4),
+ -1, PARTPROD(2,3,5), -1, PARTPROD(4,4,4),
+ PARTPROD(1,4,5), PARTPROD(2,4,5), PARTPROD(3,4,5), -1,
+ -1, -1, -1, PARTPROD(4,4,5),
+ PARTPROD(1,5,5), PARTPROD(2,5,5), -1, PARTPROD(3,5,5),
+ -1, -1, -1, PARTPROD(4,5,5),
+ -1, -1, -1, PARTPROD(3,4,6),
+ -1, -1, -1, PARTPROD(5,5,5),
+ PARTPROD(1,5,6), PARTPROD(2,5,6), -1, PARTPROD(3,5,6),
+ -1, -1, -1, PARTPROD(4,5,6),
+ -1, -1, -1, -1,
+ -1, -1, -1, PARTPROD(5,5,6),
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ -1, -1, -1, -1,
+ 0};
+
+static Bool
+pmMapReg(KdCardInfo *card, PM2CardInfo *pm2c)
+{
+ pm2c->reg_base = (CARD8 *)KdMapDevice(PM2_REG_BASE(card),
+ PM2_REG_SIZE(card));
+
+ if (pm2c->reg_base == NULL)
+ return FALSE;
+
+ KdSetMappedMode(PM2_REG_BASE(card), PM2_REG_SIZE(card),
+ KD_MAPPED_MODE_REGISTERS);
+
+ return TRUE;
+}
+
+static void
+pmUnmapReg(KdCardInfo *card, PM2CardInfo *pm2c)
+{
+ if (pm2c->reg_base) {
+ KdResetMappedMode(PM2_REG_BASE(card), PM2_REG_SIZE(card),
+ KD_MAPPED_MODE_REGISTERS);
+ KdUnmapDevice((void *)pm2c->reg_base, PM2_REG_SIZE(card));
+ pm2c->reg_base = 0;
+ }
+}
+
+Bool
+pmCardInit (KdCardInfo *card)
+{
+ PM2CardInfo *pm2c;
+
+ pm2c = (PM2CardInfo *) xalloc (sizeof (PM2CardInfo));
+ if (!pm2c)
+ return FALSE;
+ memset (pm2c, '\0', sizeof (PM2CardInfo));
+
+ (void) pmMapReg (card, pm2c);
+
+ if (!vesaInitialize (card, &pm2c->vesa))
+ {
+ xfree (pm2c);
+ return FALSE;
+ }
+
+ pm2c->InFifoSpace = 0;
+
+ card->driver = pm2c;
+
+ return TRUE;
+}
+
+static void
+pmCardFini (KdCardInfo *card)
+{
+ PM2CardInfo *pm2c = (PM2CardInfo *) card->driver;
+
+ pmUnmapReg (card, pm2c);
+ vesaCardFini (card);
+}
+
+Bool
+pmScreenInit (KdScreenInfo *screen)
+{
+ PM2CardInfo *pm2c = screen->card->driver;
+ PM2ScreenInfo *pm2s;
+ int screen_size, memory;
+
+ pm2s = (PM2ScreenInfo *) xalloc (sizeof (PM2ScreenInfo));
+ if (!pm2s)
+ return FALSE;
+ memset (pm2s, '\0', sizeof (PM2ScreenInfo));
+
+ if (!vesaScreenInitialize (screen, &pm2s->vesa))
+ {
+ xfree (pm2s);
+ return FALSE;
+ }
+
+ pm2c->pprod = partprodPermedia[screen->width >> 5];
+ pm2c->bppalign = bppand[(screen->fb[0].bitsPerPixel>>3)-1];
+
+ pm2s->screen = pm2s->vesa.fb;
+ memory = pm2s->vesa.fb_size;
+
+ screen_size = screen->fb[0].byteStride * screen->height;
+
+ if (pm2s->screen && memory >= screen_size + 2048)
+ {
+ memory -= 2048;
+ pm2s->cursor_base = pm2s->screen + memory - 2048;
+ }
+ else
+ pm2s->cursor_base = 0;
+ memory -= screen_size;
+ if (memory > screen->fb[0].byteStride)
+ {
+ pm2s->off_screen = pm2s->screen + screen_size;
+ pm2s->off_screen_size = memory;
+ }
+ else
+ {
+ pm2s->off_screen = 0;
+ pm2s->off_screen_size = 0;
+ }
+
+ switch (screen->fb[0].bitsPerPixel) {
+ case 8:
+ pm2c->BppShift = 2;
+ break;
+ case 16:
+ pm2c->BppShift = 1;
+ break;
+ case 24:
+ pm2c->BppShift = 2;
+ break;
+ case 32:
+ pm2c->BppShift = 0;
+ break;
+ }
+
+ screen->driver = pm2s;
+
+ return TRUE;
+}
+
+static void
+pmScreenFini (KdScreenInfo *screen)
+{
+ PM2ScreenInfo *pm2s = (PM2ScreenInfo *) screen->driver;
+
+ vesaScreenFini (screen);
+ xfree (pm2s);
+ screen->driver = 0;
+}
+
+static Bool
+pmInitScreen (ScreenPtr pScreen)
+{
+ return vesaInitScreen (pScreen);
+}
+
+#ifdef RANDR
+static Bool
+pmRandRSetConfig (ScreenPtr pScreen,
+ Rotation rotation,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ kaaWaitSync (pScreen);
+
+ if (!vesaRandRSetConfig (pScreen, rotation, rate, pSize))
+ return FALSE;
+
+ return TRUE;
+}
+
+static void
+pmRandRInit (ScreenPtr pScreen)
+{
+ rrScrPriv(pScreen);
+
+ pScrPriv->rrSetConfig = pmRandRSetConfig;
+}
+#endif
+
+static Bool
+pmFinishInitScreen (ScreenPtr pScreen)
+{
+ Bool ret;
+ ret = vesaFinishInitScreen (pScreen);
+#ifdef RANDR
+ pmRandRInit (pScreen);
+#endif
+ return ret;
+}
+
+static void
+pmPreserve(KdCardInfo *card)
+{
+ vesaPreserve(card);
+}
+
+static void
+pmRestore(KdCardInfo *card)
+{
+ vesaRestore (card);
+}
+
+static Bool
+pmEnable (ScreenPtr pScreen)
+{
+ if (!vesaEnable (pScreen))
+ return FALSE;
+
+#ifdef XV
+ KdXVEnable (pScreen);
+#endif
+
+ return TRUE;
+}
+
+static void
+pmDisable(ScreenPtr pScreen)
+{
+#ifdef XV
+ KdXVDisable (pScreen);
+#endif
+ vesaDisable (pScreen);
+}
+
+static Bool
+pmDPMS(ScreenPtr pScreen, int mode)
+{
+ return vesaDPMS (pScreen, mode);
+}
+
+KdCardFuncs PM2Funcs = {
+ pmCardInit, /* cardinit */
+ pmScreenInit, /* scrinit */
+ pmInitScreen, /* initScreen */
+ pmFinishInitScreen, /* finishInitScreen */
+ vesaCreateResources, /* createRes */
+ pmPreserve, /* preserve */
+ pmEnable, /* enable */
+ pmDPMS, /* dpms */
+ pmDisable, /* disable */
+ pmRestore, /* restore */
+ pmScreenFini, /* scrfini */
+ pmCardFini, /* cardfini */
+
+ 0, /* initCursor */
+ 0, /* enableCursor */
+ 0, /* disableCursor */
+ 0, /* finiCursor */
+ NULL, /* recolorCursor */
+
+ pmDrawInit, /* initAccel */
+ pmDrawEnable, /* enableAccel */
+ pmDrawDisable, /* disableAccel */
+ pmDrawFini, /* finiAccel */
+
+ vesaGetColors, /* getColors */
+ vesaPutColors, /* putColors */
+};
diff --git a/xorg-server/hw/kdrive/pm2/pm2.h b/xorg-server/hw/kdrive/pm2/pm2.h
new file mode 100644
index 000000000..e05903365
--- /dev/null
+++ b/xorg-server/hw/kdrive/pm2/pm2.h
@@ -0,0 +1,162 @@
+#ifndef _PM2_H_
+#define _PM2_H_
+#include <vesa.h>
+#include "kxv.h"
+#include "klinux.h"
+
+#include "glint_regs.h"
+
+typedef volatile CARD8 VOL8;
+typedef volatile CARD16 VOL16;
+typedef volatile CARD32 VOL32;
+
+#define PM2_REG_BASE(c) ((c)->attr.address[0] & 0xFFFFC000)
+#define PM2_REG_SIZE(c) (0x10000)
+
+typedef struct _PM2CardInfo {
+ VesaCardPrivRec vesa;
+ CARD8 *reg_base;
+
+ int InFifoSpace;
+ int FIFOSize;
+
+ int pprod;
+ int bppalign;
+
+ int ClippingOn;
+
+ int ROP;
+
+ int x;
+ int y;
+ int w;
+ int h;
+
+ int FrameBufferReadMode;
+ int BppShift;
+ int BltScanDirection;
+
+ int RasterizerSwap;
+ int PixelWidth;
+ int TexMapFormat;
+ int startxdom;
+ int startxsub;
+ int starty;
+ int count;
+ int dy;
+ int dxdom;
+
+ int planemask;
+} PM2CardInfo;
+
+#define getPM2CardInfo(kd) ((PM2CardInfo *) ((kd)->card->driver))
+#define pmCardInfo(kd) PM2CardInfo *pm2c = getPM2CardInfo(kd)
+
+typedef struct _PM2ScreenInfo {
+ VesaScreenPrivRec vesa;
+ CARD8 *cursor_base;
+ CARD8 *screen;
+ CARD8 *off_screen;
+ int off_screen_size;
+ KdVideoAdaptorPtr pAdaptor;
+ KaaScreenInfoRec kaa;
+} PM2ScreenInfo;
+
+#define getPM2ScreenInfo(kd) ((PM2ScreenInfo *) ((kd)->screen->driver))
+#define pmScreenInfo(kd) PM2ScreenInfo *pm2s = getPM2ScreenInfo(kd)
+
+Bool
+pmCardInit (KdCardInfo *card);
+
+Bool
+pmScreenInit (KdScreenInfo *screen);
+
+Bool
+pmDrawInit(ScreenPtr);
+
+void
+pmDrawEnable (ScreenPtr);
+
+void
+pmDrawDisable (ScreenPtr);
+
+void
+pmDrawFini (ScreenPtr);
+
+
+extern KdCardFuncs PM2Funcs;
+
+#define MMIO_OUT32(base, offset, val) \
+do { \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val); \
+} while (0)
+
+# define MMIO_IN32(base, offset) \
+ *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset))
+
+#define GLINT_WRITE_REG(v,r) \
+ MMIO_OUT32(mmio,(unsigned long)(r), (v))
+
+#define GLINT_READ_REG(r) \
+ MMIO_IN32(mmio,(unsigned long)(r))
+
+#define GLINT_SLOW_WRITE_REG(v,r) \
+do{ \
+ GLINT_WAIT(card->FIFOSize); \
+ GLINT_WRITE_REG(v,r); \
+}while(0)
+
+#define REPLICATE(r) \
+{ \
+ if (pScreenPriv->screen->fb[0].bitsPerPixel == 16) { \
+ r &= 0xFFFF; \
+ r |= (r<<16); \
+ } else \
+ if (pScreenPriv->screen->fb[0].bitsPerPixel == 8) { \
+ r &= 0xFF; \
+ r |= (r<<8); \
+ r |= (r<<16); \
+ } \
+}
+
+#define DO_PLANEMASK(planemask) \
+{ \
+ if (planemask != card->planemask) { \
+ card->planemask = planemask; \
+ REPLICATE(planemask); \
+ GLINT_WRITE_REG(planemask, FBHardwareWriteMask);\
+ } \
+}
+
+#define LOADROP(rop) \
+{ \
+ if (card->ROP != rop) { \
+ GLINT_WRITE_REG(rop<<1|UNIT_ENABLE, LogicalOpMode); \
+ card->ROP = rop; \
+ } \
+}
+
+#define GLINT_WAIT(n) \
+do{ \
+ if (card->InFifoSpace>=(n)) \
+ card->InFifoSpace -= (n); \
+ else { \
+ int tmp; \
+ while((tmp=GLINT_READ_REG(InFIFOSpace))<(n)); \
+ /* Clamp value due to bugs in PM3 */ \
+ if (tmp > card->FIFOSize) \
+ tmp = card->FIFOSize; \
+ card->InFifoSpace = tmp - (n); \
+ } \
+}while(0)
+
+#define CHECKCLIPPING \
+{ \
+ if (card->ClippingOn) { \
+ card->ClippingOn = FALSE; \
+ GLINT_WAIT(1); \
+ GLINT_WRITE_REG(0, ScissorMode); \
+ } \
+}
+
+#endif /* _PM2_H_ */
diff --git a/xorg-server/hw/kdrive/pm2/pm2_draw.c b/xorg-server/hw/kdrive/pm2/pm2_draw.c
new file mode 100644
index 000000000..332fc8c8a
--- /dev/null
+++ b/xorg-server/hw/kdrive/pm2/pm2_draw.c
@@ -0,0 +1,318 @@
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "kaa.h"
+
+#include "pm2.h"
+
+static PM2CardInfo *card;
+static VOL8 *mmio;
+
+static void Permedia2LoadCoord(int x, int y, int w, int h);
+
+static void
+pmWaitMarker (ScreenPtr pScreen, int marker)
+{
+ CHECKCLIPPING;
+
+ while (GLINT_READ_REG(DMACount) != 0);
+ GLINT_WAIT(2);
+ GLINT_WRITE_REG(0x400, FilterMode);
+ GLINT_WRITE_REG(0, GlintSync);
+ do {
+ while(GLINT_READ_REG(OutFIFOWords) == 0);
+ } while (GLINT_READ_REG(OutputFIFO) != Sync_tag);
+}
+
+static Bool
+pmPrepareSolid (PixmapPtr pPixmap,
+ int rop,
+ Pixel planemask,
+ Pixel color)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ pmCardInfo(pScreenPriv);
+
+ card = pm2c;
+ mmio = pm2c->reg_base;
+
+ if (~planemask & FbFullMask(pPixmap->drawable.depth))
+ return FALSE;
+
+ REPLICATE(color);
+
+ GLINT_WAIT(6);
+ DO_PLANEMASK(planemask);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ GLINT_WRITE_REG(card->pprod, FBReadMode);
+ GLINT_WRITE_REG(color, FBBlockColor);
+ } else {
+ GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode);
+ GLINT_WRITE_REG(color, ConstantColor);
+ /* We can use Packed mode for filling solid non-GXcopy rasters */
+ GLINT_WRITE_REG(card->pprod|FBRM_DstEnable|FBRM_Packed, FBReadMode);
+ }
+ LOADROP(rop);
+
+ return TRUE;
+}
+
+static void
+pmSolid (int x1, int y1, int x2, int y2)
+{
+ int speed = 0;
+
+ if (card->ROP == GXcopy) {
+ GLINT_WAIT(3);
+ Permedia2LoadCoord(x1, y1, x2-x1, y2-y1);
+ speed = FastFillEnable;
+ } else {
+ GLINT_WAIT(4);
+ Permedia2LoadCoord(x1>>card->BppShift, y1,
+ ((x2-x1)+7)>>card->BppShift, y2-y1);
+ GLINT_WRITE_REG(x1<<16|(x1+(x2-x1)), PackedDataLimits);
+ speed = 0;
+ }
+ GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | speed, Render);
+}
+
+static void
+pmDoneSolid (void)
+{
+}
+
+static Bool
+pmPrepareCopy (PixmapPtr pSrcPixmap,
+ PixmapPtr pDstPixmap,
+ int dx,
+ int dy,
+ int rop,
+ Pixel planemask)
+{
+ ScreenPtr pScreen = pDstPixmap->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ pmCardInfo(pScreenPriv);
+
+ card = pm2c;
+ mmio = pm2c->reg_base;
+
+ if (~planemask & FbFullMask(pDstPixmap->drawable.depth))
+ return FALSE;
+
+ card->BltScanDirection = ((dx >= 0 ? XPositive : 0) | (dy >= 0 ? YPositive : 0));
+
+ GLINT_WAIT(4);
+ DO_PLANEMASK(planemask);
+
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ if ((rop == GXset) || (rop == GXclear)) {
+ card->FrameBufferReadMode = card->pprod;
+ } else
+ if ((rop == GXcopy) || (rop == GXcopyInverted)) {
+ card->FrameBufferReadMode = card->pprod |FBRM_SrcEnable;
+ } else {
+ card->FrameBufferReadMode = card->pprod | FBRM_SrcEnable |
+ FBRM_DstEnable;
+ }
+ LOADROP(rop);
+
+ return TRUE;
+}
+
+
+static void
+pmCopy (int x1,
+ int y1,
+ int x2,
+ int y2,
+ int w,
+ int h)
+{
+ char align;
+
+ /* We can only use GXcopy for Packed modes */
+ if (card->ROP != GXcopy) {
+ GLINT_WAIT(5);
+ GLINT_WRITE_REG(card->FrameBufferReadMode, FBReadMode);
+ Permedia2LoadCoord(x2, y2, w, h);
+ GLINT_WRITE_REG(((y1-y2)&0x0FFF)<<16 | ((x1-x2)&0x0FFF), FBSourceDelta);
+ } else {
+ align = (x2 & card->bppalign) - (x1 & card->bppalign);
+ GLINT_WAIT(6);
+ GLINT_WRITE_REG(card->FrameBufferReadMode|FBRM_Packed, FBReadMode);
+ Permedia2LoadCoord(x2>>card->BppShift, y2,
+ (w+7)>>card->BppShift, h);
+ GLINT_WRITE_REG(align<<29|x2<<16|(x2+w), PackedDataLimits);
+ GLINT_WRITE_REG(((y1-y2)&0x0FFF)<<16 | (((x1 & ~card->bppalign)-(x2 & ~card->bppalign))&0x0FFF), FBSourceDelta);
+ }
+
+ GLINT_WRITE_REG(PrimitiveRectangle | card->BltScanDirection, Render);
+}
+
+
+static void
+pmDoneCopy (void)
+{
+}
+
+static void
+Permedia2LoadCoord(int x, int y,
+ int w, int h)
+{
+ if ((h != card->h) || (w != card->w)) {
+ card->w = w;
+ card->h = h;
+ GLINT_WRITE_REG(((h&0x0FFF)<<16)|(w&0x0FFF), RectangleSize);
+ }
+ if ((y != card->y) || (x != card->x)) {
+ card->x = x;
+ card->y = y;
+ GLINT_WRITE_REG(((y&0x0FFF)<<16)|(x&0x0FFF), RectangleOrigin);
+ }
+}
+
+
+Bool
+pmDrawInit (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ pmCardInfo(pScreenPriv);
+ pmScreenInfo(pScreenPriv);
+ Bool ret = TRUE;
+
+ card = pm2c;
+ mmio = pm2c->reg_base;
+
+ memset(&pm2s->kaa, 0, sizeof(KaaScreenInfoRec));
+ pm2s->kaa.waitMarker = pmWaitMarker;
+ pm2s->kaa.PrepareSolid = pmPrepareSolid;
+ pm2s->kaa.Solid = pmSolid;
+ pm2s->kaa.DoneSolid = pmDoneSolid;
+ pm2s->kaa.PrepareCopy = pmPrepareCopy;
+ pm2s->kaa.Copy = pmCopy;
+ pm2s->kaa.DoneCopy = pmDoneCopy;
+
+ if (ret && !kaaDrawInit (pScreen, &pm2s->kaa))
+ {
+ ErrorF ("kaaDrawInit failed\n");
+ ret = FALSE;
+ }
+
+ return ret;
+}
+
+
+void
+pmDrawEnable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ pmCardInfo(pScreenPriv);
+
+ card = pm2c;
+ mmio = pm2c->reg_base;
+
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ScissorMode);
+ GLINT_SLOW_WRITE_REG(UNIT_ENABLE, FBWriteMode);
+ GLINT_SLOW_WRITE_REG(0, dXSub);
+ GLINT_SLOW_WRITE_REG(GWIN_DisableLBUpdate, GLINTWindow);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DitherMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaBlendMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureColorMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureAddressMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PMTextureReadMode);
+ GLINT_SLOW_WRITE_REG(card->pprod, LBReadMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaBlendMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TexelLUTMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, YUVMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DepthMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RouterMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FogMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AntialiasMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaTestMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StencilMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AreaStippleMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LogicalOpMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DepthMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StatisticMode);
+ GLINT_SLOW_WRITE_REG(0x400, FilterMode);
+ GLINT_SLOW_WRITE_REG(0xffffffff, FBHardwareWriteMask);
+ GLINT_SLOW_WRITE_REG(0xffffffff, FBSoftwareWriteMask);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RasterizerMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, GLINTDepth);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBSourceOffset);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBPixelOffset);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBSourceOffset);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, WindowOrigin);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBWindowBase);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBSourceBase);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBWindowBase);
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ card->RasterizerSwap = 1;
+#else
+ card->RasterizerSwap = 0;
+#endif
+
+ switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
+ case 8:
+ card->PixelWidth = 0x0; /* 8 Bits */
+ card->TexMapFormat = card->pprod;
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ card->RasterizerSwap |= 3<<15; /* Swap host data */
+#endif
+ break;
+ case 16:
+ card->PixelWidth = 0x1; /* 16 Bits */
+ card->TexMapFormat = card->pprod | 1<<19;
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ card->RasterizerSwap |= 2<<15; /* Swap host data */
+#endif
+ break;
+ case 24:
+ card->PixelWidth = 0x4; /* 24 Bits */
+ card->TexMapFormat = card->pprod | 2<<19;
+ break;
+ case 32:
+ card->PixelWidth = 0x2; /* 32 Bits */
+ card->TexMapFormat = card->pprod | 2<<19;
+ break;
+ }
+ card->ClippingOn = FALSE;
+ card->startxdom = 0;
+ card->startxsub = 0;
+ card->starty = 0;
+ card->count = 0;
+ card->dy = 1<<16;
+ card->dxdom = 0;
+ card->x = 0;
+ card->y = 0;
+ card->h = 0;
+ card->w = 0;
+ card->ROP = 0xFF;
+ GLINT_SLOW_WRITE_REG(card->PixelWidth, FBReadPixel);
+ GLINT_SLOW_WRITE_REG(card->TexMapFormat, PMTextureMapFormat);
+ GLINT_SLOW_WRITE_REG(0, RectangleSize);
+ GLINT_SLOW_WRITE_REG(0, RectangleOrigin);
+ GLINT_SLOW_WRITE_REG(0, dXDom);
+ GLINT_SLOW_WRITE_REG(1<<16, dY);
+ GLINT_SLOW_WRITE_REG(0, StartXDom);
+ GLINT_SLOW_WRITE_REG(0, StartXSub);
+ GLINT_SLOW_WRITE_REG(0, StartY);
+ GLINT_SLOW_WRITE_REG(0, GLINTCount);
+
+ kaaMarkSync (pScreen);
+}
+
+void
+pmDrawDisable (ScreenPtr pScreen)
+{
+}
+
+void
+pmDrawFini (ScreenPtr pScreen)
+{
+}
diff --git a/xorg-server/hw/kdrive/pm2/pm2stub.c b/xorg-server/hw/kdrive/pm2/pm2stub.c
new file mode 100644
index 000000000..1f824b347
--- /dev/null
+++ b/xorg-server/hw/kdrive/pm2/pm2stub.c
@@ -0,0 +1,54 @@
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "klinux.h"
+
+#include "pm2.h"
+
+static const int PM2Cards[]={ PCI_CHIP_3DLABS_PERMEDIA2, PCI_CHIP_3DLABS_PERMEDIA2V };
+
+
+#define numPM2Cards (sizeof(PM2Cards) / sizeof(PM2Cards[0]))
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+ int i;
+
+ for (i = 0; i < numPM2Cards; i++)
+ if (LinuxFindPci (0x3d3d, PM2Cards[i], 0, &attr))
+ KdCardInfoAdd (&PM2Funcs, &attr, (void *) PM2Cards[i]);
+}
+
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdOsAddInputDrivers ();
+ KdInitInput ();
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+ vesaUseMsg();
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ int ret;
+
+ if (!(ret = vesaProcessArgument (argc, argv, i)))
+ ret = KdProcessArgument(argc, argv, i);
+ return ret;
+}
diff --git a/xorg-server/hw/kdrive/r128/Makefile.am b/xorg-server/hw/kdrive/r128/Makefile.am
new file mode 100644
index 000000000..344fbebf7
--- /dev/null
+++ b/xorg-server/hw/kdrive/r128/Makefile.am
@@ -0,0 +1,36 @@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_CFLAGS@
+
+bin_PROGRAMS = Xr128
+
+noinst_LIBRARIES = libr128.a
+
+libr128_a_SOURCES = \
+ r128draw.c \
+ r128.c \
+ r128.h
+
+Xr128_SOURCES = \
+ r128stub.c
+
+R128_LIBS = \
+ libr128.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a \
+ @KDRIVE_LIBS@
+
+if GLX
+Xr128_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
+Xr128_LDADD = \
+ $(R128_LIBS) \
+ @KDRIVE_LIBS@
+
+Xr128_DEPENDENCIES = \
+ libr128.a \
+ @KDRIVE_LOCAL_LIBS@
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/r128/Makefile.in b/xorg-server/hw/kdrive/r128/Makefile.in
new file mode 100644
index 000000000..bb7aae627
--- /dev/null
+++ b/xorg-server/hw/kdrive/r128/Makefile.in
@@ -0,0 +1,717 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xr128$(EXEEXT)
+subdir = hw/kdrive/r128
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libr128_a_AR = $(AR) $(ARFLAGS)
+libr128_a_LIBADD =
+am_libr128_a_OBJECTS = r128draw.$(OBJEXT) r128.$(OBJEXT)
+libr128_a_OBJECTS = $(am_libr128_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xr128_OBJECTS = r128stub.$(OBJEXT)
+Xr128_OBJECTS = $(am_Xr128_OBJECTS)
+am__DEPENDENCIES_1 = libr128.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a
+Xr128_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xr128_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libr128_a_SOURCES) $(Xr128_SOURCES)
+DIST_SOURCES = $(libr128_a_SOURCES) $(Xr128_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libr128.a
+libr128_a_SOURCES = \
+ r128draw.c \
+ r128.c \
+ r128.h
+
+Xr128_SOURCES = \
+ r128stub.c
+
+R128_LIBS = \
+ libr128.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a \
+ @KDRIVE_LIBS@
+
+@GLX_TRUE@Xr128_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xr128_LDADD = \
+ $(R128_LIBS) \
+ @KDRIVE_LIBS@
+
+Xr128_DEPENDENCIES = \
+ libr128.a \
+ @KDRIVE_LOCAL_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/r128/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/r128/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libr128.a: $(libr128_a_OBJECTS) $(libr128_a_DEPENDENCIES)
+ -rm -f libr128.a
+ $(libr128_a_AR) libr128.a $(libr128_a_OBJECTS) $(libr128_a_LIBADD)
+ $(RANLIB) libr128.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xr128$(EXEEXT): $(Xr128_OBJECTS) $(Xr128_DEPENDENCIES)
+ @rm -f Xr128$(EXEEXT)
+ $(Xr128_LINK) $(Xr128_OBJECTS) $(Xr128_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/r128.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/r128draw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/r128stub.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/r128/r128.c b/xorg-server/hw/kdrive/r128/r128.c
new file mode 100644
index 000000000..9e7f312e0
--- /dev/null
+++ b/xorg-server/hw/kdrive/r128/r128.c
@@ -0,0 +1,250 @@
+/*
+ * Copyright © 2003 Anders Carlsson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Anders Carlsson not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Anders Carlsson makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ANDERS CARLSSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "r128.h"
+
+static Bool
+r128CardInit (KdCardInfo *card)
+{
+ R128CardInfo *r128c;
+
+ r128c = (R128CardInfo *) xalloc (sizeof (R128CardInfo));
+ if (!r128c)
+ return FALSE;
+
+ r128MapReg (card, r128c);
+
+ if (!vesaInitialize (card, &r128c->vesa))
+ {
+ xfree (r128c);
+ return FALSE;
+ }
+
+ r128c->fifo_size = 0;
+
+ card->driver = r128c;
+
+ return TRUE;
+}
+
+static Bool
+r128ScreenInit (KdScreenInfo *screen)
+{
+ R128ScreenInfo *r128s;
+ int screen_size, memory;
+
+ r128s = (R128ScreenInfo *) xalloc (sizeof (R128ScreenInfo));
+ if (!r128s)
+ return FALSE;
+ memset (r128s, '\0', sizeof (R128ScreenInfo));
+ if (!vesaScreenInitialize (screen, &r128s->vesa))
+ {
+ xfree (r128s);
+ return FALSE;
+ }
+#if 0
+ /* if (!r128c->reg)
+ screen->dumb = TRUE; */
+
+ if (r128s->vesa.mapping != VESA_LINEAR)
+ screen->dumb = TRUE;
+
+ fprintf (stderr, "vesa mapping is %d\n", r128s->vesa.mapping);
+#endif
+ r128s->screen = r128s->vesa.fb;
+
+ memory = r128s->vesa.fb_size;
+ screen_size = screen->fb[0].byteStride * screen->height;
+
+ memory -= screen_size;
+ if (memory > screen->fb[0].byteStride)
+ {
+ r128s->off_screen = r128s->screen + screen_size;
+ r128s->off_screen_size = memory;
+ }
+ else
+ {
+ r128s->off_screen = 0;
+ r128s->off_screen_size = 0;
+ }
+ screen->driver = r128s;
+ return TRUE;
+}
+
+static Bool
+r128InitScreen (ScreenPtr pScreen)
+{
+ return vesaInitScreen (pScreen);
+}
+
+static Bool
+r128FinishInitScreen (ScreenPtr pScreen)
+{
+ Bool ret;
+
+ ret = vesaFinishInitScreen (pScreen);
+
+ return ret;
+}
+
+static void
+r128Preserve (KdCardInfo *card)
+{
+ vesaPreserve (card);
+}
+
+Bool
+r128MapReg (KdCardInfo *card, R128CardInfo *r128c)
+{
+ r128c->reg_base = (CARD8 *) KdMapDevice (R128_REG_BASE (card),
+ R128_REG_SIZE (card));
+
+ if (!r128c->reg_base)
+ {
+ return FALSE;
+ }
+
+ KdSetMappedMode (R128_REG_BASE (card),
+ R128_REG_SIZE (card),
+ KD_MAPPED_MODE_REGISTERS);
+
+ return TRUE;
+}
+
+void
+r128UnmapReg (KdCardInfo *card, R128CardInfo *r128c)
+{
+ if (r128c->reg_base)
+ {
+ KdResetMappedMode (R128_REG_BASE (card),
+ R128_REG_SIZE (card),
+ KD_MAPPED_MODE_REGISTERS);
+ KdUnmapDevice ((void *) r128c->reg_base, R128_REG_SIZE (card));
+ r128c->reg_base = 0;
+ }
+}
+
+void
+r128SetMMIO (KdCardInfo *card, R128CardInfo *r128c)
+{
+ if (!r128c->reg_base)
+ r128MapReg (card, r128c);
+}
+
+void
+r128ResetMMIO (KdCardInfo *card, R128CardInfo *r128c)
+{
+ r128UnmapReg (card, r128c);
+}
+
+
+static Bool
+r128DPMS (ScreenPtr pScreen, int mode)
+{
+ /* XXX */
+ return TRUE;
+}
+
+static Bool
+r128Enable (ScreenPtr pScreen)
+{
+ KdScreenPriv (pScreen);
+ R128CardInfo *r128c = pScreenPriv->card->driver;
+
+ if (!vesaEnable (pScreen))
+ return FALSE;
+
+ r128SetMMIO (pScreenPriv->card, r128c);
+ r128DPMS (pScreen, KD_DPMS_NORMAL);
+
+ return TRUE;
+}
+
+static void
+r128Disable (ScreenPtr pScreen)
+{
+ KdScreenPriv (pScreen);
+ R128CardInfo *r128c = pScreenPriv->card->driver;
+
+ r128ResetMMIO (pScreenPriv->card, r128c);
+ vesaDisable (pScreen);
+}
+
+static void
+r128Restore (KdCardInfo *card)
+{
+ R128CardInfo *r128c = card->driver;
+
+ r128ResetMMIO (card, r128c);
+ vesaRestore (card);
+}
+
+static void
+r128ScreenFini (KdScreenInfo *screen)
+{
+ R128ScreenInfo *r128s = (R128ScreenInfo *) screen->driver;
+
+ vesaScreenFini (screen);
+ xfree (r128s);
+ screen->driver = 0;
+}
+
+static void
+r128CardFini (KdCardInfo *card)
+{
+ R128CardInfo *r128c = (R128CardInfo *)card->driver;
+
+ r128UnmapReg (card, r128c);
+ vesaCardFini (card);
+}
+
+KdCardFuncs r128Funcs = {
+ r128CardInit, /* cardinit */
+ r128ScreenInit, /* scrinit */
+ r128InitScreen, /* initScreen */
+ r128FinishInitScreen, /* finishInitScreen */
+ vesaCreateResources,/* createRes */
+ r128Preserve, /* preserve */
+ r128Enable, /* enable */
+ r128DPMS, /* dpms */
+ r128Disable, /* disable */
+ r128Restore, /* restore */
+ r128ScreenFini, /* scrfini */
+ r128CardFini, /* cardfini */
+
+ 0, /* initCursor */
+ 0, /* enableCursor */
+ 0, /* disableCursor */
+ 0, /* finiCursor */
+ 0, /* recolorCursor */
+
+ r128DrawInit, /* initAccel */
+ r128DrawEnable, /* enableAccel */
+ r128DrawDisable, /* disableAccel */
+ r128DrawFini, /* finiAccel */
+
+ vesaGetColors, /* getColors */
+ vesaPutColors, /* putColors */
+};
+
diff --git a/xorg-server/hw/kdrive/r128/r128.h b/xorg-server/hw/kdrive/r128/r128.h
new file mode 100644
index 000000000..ae9ae03aa
--- /dev/null
+++ b/xorg-server/hw/kdrive/r128/r128.h
@@ -0,0 +1,123 @@
+/*
+ * Copyright © 2003 Anders Carlsson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Anders Carlsson not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Anders Carlsson makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ANDERS CARLSSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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 _R128_H_
+#define _R128_H_
+#include <vesa.h>
+
+#define R128_REG_BASE(c) ((c)->attr.address[1])
+#define R128_REG_SIZE(c) (0x4000)
+
+#define R128_OUT32(mmio, a, v) (*(VOL32 *) ((mmio) + (a)) = (v))
+#define R128_IN32(mmio, a) (*(VOL32 *) ((mmio) + (a)))
+
+#define R128_REG_GUI_STAT 0x1740
+#define R128_REG_DEFAULT_OFFSET 0x16e0
+#define R128_REG_DEFAULT_PITCH 0x16e4
+#define R128_REG_DP_GUI_MASTER_CNTL 0x146c
+#define R128_REG_DP_BRUSH_FRGD_CLR 0x147c
+#define R128_REG_DP_WRITE_MASK 0x16cc
+#define R128_REG_DP_CNTL 0x16c0
+#define R128_REG_DST_WIDTH_HEIGHT 0x1598
+#define R128_REG_DST_Y_X 0x1438
+#define R128_REG_PC_NGUI_CTLSTAT 0x0184
+#define R128_REG_DST_HEIGHT_WIDTH 0x143c
+#define R128_REG_SRC_Y_X 0x1434
+#define R128_DEFAULT_SC_BOTTOM_RIGHT 0x16e8
+#define R128_AUX_SC_CNTL 0x1660
+#define R128_SC_TOP_LEFT 0x16ec
+#define R128_SC_BOTTOM_RIGHT 0x16f0
+
+#define R128_GMC_DST_DATATYPE_SHIFT 8
+#define R128_GMC_CLR_CMP_CNTL_DIS (1 << 28)
+#define R128_GMC_AUX_CLIP_DIS (1 << 29)
+#define R128_GMC_BRUSH_SOLID_COLOR (13 << 4)
+#define R128_GMC_SRC_DATATYPE_COLOR (3 << 12)
+#define R128_GMC_ROP3_SHIFT 16
+#define R128_DST_X_LEFT_TO_RIGHT (1 << 0)
+#define R128_DST_Y_TOP_TO_BOTTOM (1 << 1)
+#define R128_GUI_ACTIVE (1 << 31)
+#define R128_PC_BUSY (1 << 31)
+#define R128_DP_SRC_SOURCE_MEMORY (2 << 24)
+#define R128_DEFAULT_SC_RIGHT_MAX (0x1fff << 0)
+#define R128_DEFAULT_SC_BOTTOM_MAX (0x1fff << 16)
+
+typedef volatile CARD8 VOL8;
+typedef volatile CARD16 VOL16;
+typedef volatile CARD32 VOL32;
+
+typedef struct _r128CardInfo {
+ VesaCardPrivRec vesa;
+ CARD8 *reg_base;
+ int fifo_size;
+} R128CardInfo;
+
+#define getR128CardInfo(kd) ((R128CardInfo *) ((kd)->card->driver))
+#define r128CardInfo(kd) R128CardInfo *r128c = getR128CardInfo(kd)
+
+typedef struct _r128ScreenInfo {
+ VesaScreenPrivRec vesa;
+ CARD8 *screen;
+ CARD8 *off_screen;
+ int off_screen_size;
+
+ KaaScreenInfoRec kaa;
+
+ int pitch;
+ int datatype;
+
+ int dp_gui_master_cntl;
+} R128ScreenInfo;
+
+#define getR128ScreenInfo(kd) ((R128ScreenInfo *) ((kd)->screen->driver))
+#define r128ScreenInfo(kd) R128ScreenInfo *r128s = getR128ScreenInfo(kd)
+
+Bool
+r128MapReg (KdCardInfo *card, R128CardInfo *r128c);
+
+void
+r128UnmapReg (KdCardInfo *card, R128CardInfo *r128c);
+
+void
+r128SetMMIO (KdCardInfo *card, R128CardInfo *r128c);
+
+void
+r128ResetMMIO (KdCardInfo *card, R128CardInfo *r128c);
+
+Bool
+r128DrawSetup (ScreenPtr pScreen);
+
+Bool
+r128DrawInit (ScreenPtr pScreen);
+
+void
+r128DrawEnable (ScreenPtr pScreen);
+
+void
+r128DrawDisable (ScreenPtr pScreen);
+
+void
+r128DrawFini (ScreenPtr pScreen);
+
+extern KdCardFuncs r128Funcs;
+
+#endif /* _R128_H_ */
diff --git a/xorg-server/hw/kdrive/r128/r128draw.c b/xorg-server/hw/kdrive/r128/r128draw.c
new file mode 100644
index 000000000..142cc8b3e
--- /dev/null
+++ b/xorg-server/hw/kdrive/r128/r128draw.c
@@ -0,0 +1,296 @@
+/*
+ * Copyright © 2003 Anders Carlsson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Anders Carlsson not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Anders Carlsson makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ANDERS CARLSSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "r128.h"
+#include "kaa.h"
+
+CARD8 r128SolidRop[16] = {
+ /* GXclear */ 0x00, /* 0 */
+ /* GXand */ 0xa0, /* src AND dst */
+ /* GXandReverse */ 0x50, /* src AND NOT dst */
+ /* GXcopy */ 0xf0, /* src */
+ /* GXandInverted*/ 0x0a, /* NOT src AND dst */
+ /* GXnoop */ 0xaa, /* dst */
+ /* GXxor */ 0x5a, /* src XOR dst */
+ /* GXor */ 0xfa, /* src OR dst */
+ /* GXnor */ 0x05, /* NOT src AND NOT dst */
+ /* GXequiv */ 0xa5, /* NOT src XOR dst */
+ /* GXinvert */ 0x55, /* NOT dst */
+ /* GXorReverse */ 0xf5, /* src OR NOT dst */
+ /* GXcopyInverted*/ 0x0f, /* NOT src */
+ /* GXorInverted */ 0xaf, /* NOT src OR dst */
+ /* GXnand */ 0x5f, /* NOT src OR NOT dst */
+ /* GXset */ 0xff, /* 1 */
+};
+
+CARD8 r128BltRop[16] = {
+ /* GXclear */ 0x00, /* 0 */
+ /* GXand */ 0x88, /* src AND dst */
+ /* GXandReverse */ 0x44, /* src AND NOT dst */
+ /* GXcopy */ 0xcc, /* src */
+ /* GXandInverted*/ 0x22, /* NOT src AND dst */
+ /* GXnoop */ 0xaa, /* dst */
+ /* GXxor */ 0x66, /* src XOR dst */
+ /* GXor */ 0xee, /* src OR dst */
+ /* GXnor */ 0x11, /* NOT src AND NOT dst */
+ /* GXequiv */ 0x99, /* NOT src XOR dst */
+ /* GXinvert */ 0x55, /* NOT dst */
+ /* GXorReverse */ 0xdd, /* src OR NOT dst */
+ /* GXcopyInverted*/ 0x33, /* NOT src */
+ /* GXorInverted */ 0xbb, /* NOT src OR dst */
+ /* GXnand */ 0x77, /* NOT src OR NOT dst */
+ /* GXset */ 0xff, /* 1 */
+};
+
+int copydx, copydy;
+int fifo_size;
+char *mmio;
+
+static void
+r128WaitAvail (int n)
+{
+ if (fifo_size < n)
+ {
+ while ((fifo_size = R128_IN32 (mmio, R128_REG_GUI_STAT) & 0xfff) < n)
+ ;
+ }
+
+ fifo_size -= n;
+}
+
+static void
+r128WaitIdle (void)
+{
+ int tries;
+
+ r128WaitAvail (64);
+
+ tries = 1000000;
+ while (tries--)
+ {
+ if ((R128_IN32 (mmio, R128_REG_GUI_STAT) & R128_GUI_ACTIVE) == 0)
+ break;
+ }
+
+ R128_OUT32 (mmio, R128_REG_PC_NGUI_CTLSTAT,
+ R128_IN32 (mmio, R128_REG_PC_NGUI_CTLSTAT | 0xff));
+
+ tries = 1000000;
+ while (tries--)
+ {
+ if ((R128_IN32 (mmio, R128_REG_PC_NGUI_CTLSTAT) & R128_PC_BUSY) != R128_PC_BUSY)
+ break;
+ }
+
+}
+
+static void
+r128WaitMarker (ScreenPtr pScreen, int marker)
+{
+ KdScreenPriv (pScreen);
+ r128CardInfo (pScreenPriv);
+
+ mmio = r128c->reg_base;
+
+ r128WaitIdle ();
+}
+
+static Bool
+r128Setup (ScreenPtr pScreen, int wait)
+{
+ KdScreenPriv (pScreen);
+ r128ScreenInfo (pScreenPriv);
+ r128CardInfo (pScreenPriv);
+
+ fifo_size = 0;
+
+ mmio = r128c->reg_base;
+
+ if (!mmio)
+ return FALSE;
+
+ r128WaitAvail (2);
+ R128_OUT32 (mmio, R128_REG_DEFAULT_OFFSET, 0);
+ R128_OUT32 (mmio, R128_REG_DEFAULT_PITCH, r128s->pitch);
+
+ r128WaitAvail (4);
+ R128_OUT32 (mmio, R128_AUX_SC_CNTL, 0);
+ R128_OUT32 (mmio, R128_DEFAULT_SC_BOTTOM_RIGHT, (R128_DEFAULT_SC_RIGHT_MAX
+ | R128_DEFAULT_SC_BOTTOM_MAX));
+ R128_OUT32 (mmio, R128_SC_TOP_LEFT, 0);
+ R128_OUT32 (mmio, R128_SC_BOTTOM_RIGHT, (R128_DEFAULT_SC_RIGHT_MAX
+ | R128_DEFAULT_SC_BOTTOM_MAX));
+ r128WaitAvail (wait);
+ return TRUE;
+}
+
+static Bool
+r128PrepareSolid (PixmapPtr pPixmap, int alu, Pixel pm, Pixel fg)
+{
+ KdScreenPriv (pPixmap->drawable.pScreen);
+ r128ScreenInfo (pScreenPriv);
+
+ r128Setup (pPixmap->drawable.pScreen, 4);
+ R128_OUT32 (mmio, R128_REG_DP_GUI_MASTER_CNTL, r128s->dp_gui_master_cntl
+ | R128_GMC_BRUSH_SOLID_COLOR
+ | R128_GMC_SRC_DATATYPE_COLOR
+ | (r128SolidRop[alu] << R128_GMC_ROP3_SHIFT));
+ R128_OUT32 (mmio, R128_REG_DP_BRUSH_FRGD_CLR, fg);
+ R128_OUT32 (mmio, R128_REG_DP_WRITE_MASK, pm);
+ R128_OUT32 (mmio, R128_REG_DP_CNTL,
+ (R128_DST_X_LEFT_TO_RIGHT | R128_DST_Y_TOP_TO_BOTTOM));
+
+ return TRUE;
+}
+
+static void
+r128Solid (int x1, int y1, int x2, int y2)
+{
+ r128WaitAvail (2);
+ R128_OUT32 (mmio, R128_REG_DST_Y_X, (y1 << 16) | x1);
+ R128_OUT32 (mmio, R128_REG_DST_WIDTH_HEIGHT, ((x2 - x1) << 16) | (y2 - y1));
+
+}
+
+static void
+r128DoneSolid (void)
+{
+}
+
+static Bool
+r128PrepareCopy (PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu, Pixel pm)
+{
+ KdScreenPriv (pSrc->drawable.pScreen);
+ r128ScreenInfo (pScreenPriv);
+
+ copydx = dx;
+ copydy = dy;
+
+ r128Setup (pSrc->drawable.pScreen, 3);
+ R128_OUT32 (mmio, R128_REG_DP_GUI_MASTER_CNTL, r128s->dp_gui_master_cntl
+ | R128_GMC_BRUSH_SOLID_COLOR
+ | R128_GMC_SRC_DATATYPE_COLOR
+ | (r128BltRop[alu] << R128_GMC_ROP3_SHIFT)
+ | R128_DP_SRC_SOURCE_MEMORY);
+ R128_OUT32 (mmio, R128_REG_DP_WRITE_MASK, pm);
+ R128_OUT32 (mmio, R128_REG_DP_CNTL,
+ ((dx >= 0 ? R128_DST_X_LEFT_TO_RIGHT : 0)
+ | (dy >= 0 ? R128_DST_Y_TOP_TO_BOTTOM : 0)));
+
+
+ return TRUE;
+}
+
+static void
+r128Copy (int srcX, int srcY, int dstX, int dstY, int w, int h)
+{
+ if (copydx < 0)
+ {
+ srcX += w - 1;
+ dstX += w - 1;
+ }
+
+ if (copydy < 0)
+ {
+ srcY += h - 1;
+ dstY += h - 1;
+ }
+
+ r128WaitAvail (3);
+ R128_OUT32 (mmio, R128_REG_SRC_Y_X, (srcY << 16) | srcX);
+ R128_OUT32 (mmio, R128_REG_DST_Y_X, (dstY << 16) | dstX);
+ R128_OUT32 (mmio, R128_REG_DST_HEIGHT_WIDTH, (h << 16) | w);
+}
+
+static void
+r128DoneCopy (void)
+{
+}
+
+
+Bool
+r128DrawInit (ScreenPtr pScreen)
+{
+ KdScreenPriv (pScreen);
+ r128ScreenInfo (pScreenPriv);
+
+ memset(&r128s->kaa, 0, sizeof(KaaScreenInfoRec));
+ r128s->kaa.waitMarker = r128WaitMarker;
+ r128s->kaa.PrepareSolid = r128PrepareSolid;
+ r128s->kaa.Solid = r128Solid;
+ r128s->kaa.DoneSolid = r128DoneSolid;
+ r128s->kaa.PrepareCopy = r128PrepareCopy;
+ r128s->kaa.Copy = r128Copy;
+ r128s->kaa.DoneCopy = r128DoneCopy;
+
+ if (!kaaDrawInit (pScreen, &r128s->kaa))
+ return FALSE;
+
+ return TRUE;
+}
+
+void
+r128DrawEnable (ScreenPtr pScreen)
+{
+ KdScreenPriv (pScreen);
+ r128ScreenInfo (pScreenPriv);
+
+ r128s->pitch = pScreenPriv->screen->width >> 3;
+
+ switch (pScreenPriv->screen->fb[0].depth) {
+ case 8:
+ r128s->datatype = 2;
+ break;
+ case 15:
+ r128s->datatype = 3;
+ break;
+ case 16:
+ r128s->datatype = 4;
+ break;
+ case 24:
+ r128s->datatype = 5;
+ break;
+ case 32:
+ r128s->datatype = 6;
+ break;
+ default:
+ FatalError ("unsupported pixel format");
+ }
+
+ r128s->dp_gui_master_cntl = ((r128s->datatype << R128_GMC_DST_DATATYPE_SHIFT)
+ | R128_GMC_CLR_CMP_CNTL_DIS
+ | R128_GMC_AUX_CLIP_DIS);
+
+ kaaMarkSync (pScreen);
+}
+
+void
+r128DrawDisable (ScreenPtr pScreen)
+{
+}
+
+void
+r128DrawFini (ScreenPtr pScreen)
+{
+}
diff --git a/xorg-server/hw/kdrive/r128/r128stub.c b/xorg-server/hw/kdrive/r128/r128stub.c
new file mode 100644
index 000000000..b5ffd9d77
--- /dev/null
+++ b/xorg-server/hw/kdrive/r128/r128stub.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright © 2003 Anders Carlsson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Anders Carlsson not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Anders Carlsson makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ANDERS CARLSSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "r128.h"
+#include "klinux.h"
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+
+ if (LinuxFindPci (0x1002, 0x4c46, 0, &attr))
+ KdCardInfoAdd (&r128Funcs, &attr, 0);
+ else if (LinuxFindPci (0x1002, 0x5046, 0, &attr))
+ KdCardInfoAdd (&r128Funcs, &attr, 0);
+}
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdOsAddInputDrivers ();
+ KdInitInput ();
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+ vesaUseMsg();
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ int ret;
+
+ if (!(ret = vesaProcessArgument (argc, argv, i)))
+ ret = KdProcessArgument(argc, argv, i);
+ return ret;
+}
diff --git a/xorg-server/hw/kdrive/sdl/Makefile.am b/xorg-server/hw/kdrive/sdl/Makefile.am
new file mode 100644
index 000000000..0973cb4ea
--- /dev/null
+++ b/xorg-server/hw/kdrive/sdl/Makefile.am
@@ -0,0 +1,19 @@
+INCLUDES = \
+ @KDRIVE_PURE_INCS@ \
+ @KDRIVE_CFLAGS@ \
+ @XSDL_INCS@
+
+bin_PROGRAMS = Xsdl
+
+Xsdl_SOURCES = sdl.c
+
+Xsdl_LDADD = \
+ @KDRIVE_LIBS@ \
+ @XSDL_LIBS@
+
+Xsdl_DEPENDENCIES = @KDRIVE_LOCAL_LIBS@
+
+Xsdl_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/sdl/Makefile.in b/xorg-server/hw/kdrive/sdl/Makefile.in
new file mode 100644
index 000000000..9e5fc2606
--- /dev/null
+++ b/xorg-server/hw/kdrive/sdl/Makefile.in
@@ -0,0 +1,682 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xsdl$(EXEEXT)
+subdir = hw/kdrive/sdl
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xsdl_OBJECTS = sdl.$(OBJEXT)
+Xsdl_OBJECTS = $(am_Xsdl_OBJECTS)
+Xsdl_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xsdl_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(Xsdl_SOURCES)
+DIST_SOURCES = $(Xsdl_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_PURE_INCS@ \
+ @KDRIVE_CFLAGS@ \
+ @XSDL_INCS@
+
+Xsdl_SOURCES = sdl.c
+Xsdl_LDADD = \
+ @KDRIVE_LIBS@ \
+ @XSDL_LIBS@
+
+Xsdl_DEPENDENCIES = @KDRIVE_LOCAL_LIBS@
+Xsdl_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/sdl/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/sdl/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xsdl$(EXEEXT): $(Xsdl_OBJECTS) $(Xsdl_DEPENDENCIES)
+ @rm -f Xsdl$(EXEEXT)
+ $(Xsdl_LINK) $(Xsdl_OBJECTS) $(Xsdl_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sdl.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-binPROGRAMS install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am \
+ uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/sdl/sdl.c b/xorg-server/hw/kdrive/sdl/sdl.c
new file mode 100644
index 000000000..411b5d4e1
--- /dev/null
+++ b/xorg-server/hw/kdrive/sdl/sdl.c
@@ -0,0 +1,455 @@
+/*
+ * Copyright © 2004 PillowElephantBadgerBankPond
+
+ * 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 PillowElephantBadgerBankPond not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. PillowElephantBadgerBankPond makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * PillowElephantBadgerBankPond DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL PillowElephantBadgerBankPond BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * It's really not my fault - see it was the elephants!!
+ * - jaymz
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include "kdrive-config.h"
+#endif
+#include "kdrive.h"
+#include <SDL/SDL.h>
+#include <X11/keysym.h>
+
+static void xsdlFini(void);
+static Bool sdlScreenInit(KdScreenInfo *screen);
+static Bool sdlFinishInitScreen(ScreenPtr pScreen);
+static Bool sdlCreateRes(ScreenPtr pScreen);
+
+static void sdlKeyboardFini(KdKeyboardInfo *ki);
+static Bool sdlKeyboardInit(KdKeyboardInfo *ki);
+
+static Bool sdlMouseInit(KdPointerInfo *pi);
+static void sdlMouseFini(KdPointerInfo *pi);
+
+void *sdlShadowWindow (ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, CARD32 *size, void *closure);
+void sdlShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf);
+
+void sdlTimer(void);
+
+KdKeyboardInfo *sdlKeyboard = NULL;
+KdPointerInfo *sdlPointer = NULL;
+
+KeySym sdlKeymap[]={
+ 0, /* 8 */
+ 0,
+ XK_Escape, NoSymbol, /* escape */
+ XK_1, XK_exclam,
+ XK_2, XK_at,
+ XK_3, XK_numbersign,
+ XK_4, XK_dollar,
+ XK_5, XK_percent,
+ XK_6, XK_asciicircum,
+ XK_7, XK_ampersand,
+ XK_8, XK_asterisk,
+ XK_9, XK_parenleft,
+ XK_0, XK_parenright,
+ XK_minus, XK_underscore,
+ XK_equal, XK_plus,
+ XK_BackSpace, NoSymbol, /* backspace */
+ XK_Tab, NoSymbol,
+ XK_q, XK_Q,
+ XK_w, XK_W,
+ XK_e, XK_E,
+ XK_r, XK_R,
+ XK_t, XK_T,
+ XK_y, XK_Y,
+ XK_u, XK_U,
+ XK_i, XK_I,
+ XK_o, XK_O,
+ XK_p, XK_P,
+ XK_bracketleft, XK_braceleft, /* [, { */
+ XK_bracketright, XK_braceright, /* ]. } */
+ XK_Return, NoSymbol,
+ XK_Control_L, NoSymbol,
+ XK_a, XK_A,
+ XK_s, XK_S,
+ XK_d, XK_D,
+ XK_f, XK_F,
+ XK_g, XK_G,
+ XK_h, XK_H,
+ XK_j, XK_J,
+ XK_k, XK_K,
+ XK_l, XK_L,
+ XK_semicolon, XK_colon,
+ XK_apostrophe, XK_quotedbl,
+ XK_grave, XK_asciitilde,
+ XK_Shift_L, NoSymbol,
+ XK_backslash, XK_bar,
+ XK_z, XK_z,
+ XK_x, XK_X,
+ XK_c, XK_C,
+ XK_v, XK_V,
+ XK_b, XK_B,
+ XK_n, XK_N,
+ XK_m, XK_M,
+ XK_comma, XK_less,
+ XK_period, XK_greater,
+ XK_slash, XK_question,
+ XK_Shift_R, NoSymbol,
+ XK_KP_Multiply, NoSymbol,
+ XK_Meta_L, XK_Alt_L,
+ XK_space, NoSymbol,
+ XK_Caps_Lock, NoSymbol,
+ XK_F1, NoSymbol,
+ XK_F2, NoSymbol,
+ XK_F3, NoSymbol,
+ XK_F4, NoSymbol,
+ XK_F5, NoSymbol,
+ XK_F6, NoSymbol,
+ XK_F7, NoSymbol,
+ XK_F8, NoSymbol,
+ XK_F9, NoSymbol,
+ XK_F10, NoSymbol,
+ XK_Num_Lock, NoSymbol,
+ XK_Scroll_Lock, NoSymbol,
+ XK_KP_Home, XK_KP_7,
+ XK_KP_Up, XK_KP_8,
+ XK_KP_Page_Up, XK_KP_9,
+ XK_KP_Subtract, NoSymbol,
+ XK_KP_Left, XK_KP_4,
+ XK_KP_5, NoSymbol,
+ XK_KP_Right, XK_KP_6,
+ XK_KP_Add, NoSymbol,
+ XK_KP_End, XK_KP_1,
+ XK_KP_Down, XK_KP_2,
+ XK_KP_Page_Down, XK_KP_3,
+ XK_KP_Insert, XK_KP_0,
+ XK_KP_Delete, XK_KP_Decimal,
+ NoSymbol, NoSymbol, /* 92 */
+ NoSymbol, NoSymbol, /* 93 */
+ NoSymbol, NoSymbol, /* 94 */
+ XK_F11, NoSymbol, /* 95 */
+ XK_F12, NoSymbol, /* 96 */
+ XK_Home, NoSymbol, /* 97 */
+ XK_Up, NoSymbol, /* 98 */
+ XK_Page_Up, NoSymbol, /* 99 */
+ XK_Left, NoSymbol, /* 100 */
+ NoSymbol, NoSymbol, /* 101 */
+ XK_Right, NoSymbol, /* 102 */
+ NoSymbol, NoSymbol, /* 103 */
+ XK_Down, NoSymbol, /* 104 */
+ XK_Page_Down, NoSymbol, /* 105 */
+ XK_Insert, NoSymbol, /* 106 */
+ NoSymbol, NoSymbol, /* 107 */
+ NoSymbol, NoSymbol, /* 108 */
+ XK_Meta_R, XK_Alt_R, /* 109 */
+ XK_Pause, XK_Break, /* 110 */
+ XK_Sys_Req, XK_Print, /* 111 */
+ NoSymbol, NoSymbol, /* 112 */
+ XK_Control_R, NoSymbol, /* 113 */
+ NoSymbol, NoSymbol, /* 114 */
+ XK_Super_L, NoSymbol, /* 115 */
+ XK_Super_R, NoSymbol, /* 116 */
+ XK_Menu, NoSymbol, /* 117 */
+ NoSymbol, NoSymbol /* 118 */
+};
+
+KdKeyboardDriver sdlKeyboardDriver = {
+ .name = "keyboard",
+ .Init = sdlKeyboardInit,
+ .Fini = sdlKeyboardFini,
+};
+
+KdPointerDriver sdlMouseDriver = {
+ .name = "mouse",
+ .Init = sdlMouseInit,
+ .Fini = sdlMouseFini,
+};
+
+
+KdCardFuncs sdlFuncs = {
+ .scrinit = sdlScreenInit, /* scrinit */
+ .finishInitScreen = sdlFinishInitScreen, /* finishInitScreen */
+ .createRes = sdlCreateRes, /* createRes */
+};
+
+int mouseState=0;
+
+struct SdlDriver
+{
+ SDL_Surface *screen;
+};
+
+
+
+static Bool sdlScreenInit(KdScreenInfo *screen)
+{
+ struct SdlDriver *sdlDriver=calloc(1, sizeof(struct SdlDriver));
+#ifdef DEBUG
+ printf("sdlScreenInit()\n");
+#endif
+ if (!screen->width || !screen->height)
+ {
+ screen->width = 640;
+ screen->height = 480;
+ }
+ if (!screen->fb[0].depth)
+ screen->fb[0].depth = 4;
+#ifdef DEBUG
+ printf("Attempting for %dx%d/%dbpp mode\n", screen->width, screen->height, screen->fb[0].depth);
+#endif
+ sdlDriver->screen=SDL_SetVideoMode(screen->width, screen->height, screen->fb[0].depth, 0);
+ if(sdlDriver->screen==NULL)
+ return FALSE;
+#ifdef DEBUG
+ printf("Set %dx%d/%dbpp mode\n", sdlDriver->screen->w, sdlDriver->screen->h, sdlDriver->screen->format->BitsPerPixel);
+#endif
+ screen->width=sdlDriver->screen->w;
+ screen->height=sdlDriver->screen->h;
+ screen->fb[0].depth=sdlDriver->screen->format->BitsPerPixel;
+ screen->fb[0].visuals=(1<<TrueColor);
+ screen->fb[0].redMask=sdlDriver->screen->format->Rmask;
+ screen->fb[0].greenMask=sdlDriver->screen->format->Gmask;
+ screen->fb[0].blueMask=sdlDriver->screen->format->Bmask;
+ screen->fb[0].bitsPerPixel=sdlDriver->screen->format->BitsPerPixel;
+ screen->rate=60;
+ screen->memory_base=(CARD8 *)sdlDriver->screen->pixels;
+ screen->memory_size=0;
+ screen->off_screen_base=0;
+ screen->driver=sdlDriver;
+ screen->fb[0].byteStride=(sdlDriver->screen->w*sdlDriver->screen->format->BitsPerPixel)/8;
+ screen->fb[0].pixelStride=sdlDriver->screen->w;
+ screen->fb[0].frameBuffer=(CARD8 *)sdlDriver->screen->pixels;
+ SDL_WM_SetCaption("Freedesktop.org X server (SDL)", NULL);
+ return TRUE;
+}
+
+void sdlShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ struct SdlDriver *sdlDriver=screen->driver;
+#ifdef DEBUG
+ printf("Shadow update()\n");
+#endif
+ if(SDL_MUSTLOCK(sdlDriver->screen))
+ {
+ if(SDL_LockSurface(sdlDriver->screen)<0)
+ {
+#ifdef DEBUG
+ printf("Couldn't lock SDL surface - d'oh!\n");
+#endif
+ return;
+ }
+ }
+
+ if(SDL_MUSTLOCK(sdlDriver->screen))
+ SDL_UnlockSurface(sdlDriver->screen);
+ SDL_UpdateRect(sdlDriver->screen, 0, 0, sdlDriver->screen->w, sdlDriver->screen->h);
+}
+
+
+void *sdlShadowWindow (ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, CARD32 *size, void *closure)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ struct SdlDriver *sdlDriver=screen->driver;
+ *size=(sdlDriver->screen->w*sdlDriver->screen->format->BitsPerPixel)/8;
+#ifdef DEBUG
+ printf("Shadow window()\n");
+#endif
+ return (void *)((CARD8 *)sdlDriver->screen->pixels + row * (*size) + offset);
+}
+
+
+static Bool sdlCreateRes(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ KdShadowFbAlloc(screen, 0, FALSE);
+ KdShadowSet(pScreen, RR_Rotate_0, sdlShadowUpdate, sdlShadowWindow);
+ return TRUE;
+}
+
+static Bool sdlFinishInitScreen(ScreenPtr pScreen)
+{
+ if (!shadowSetup (pScreen))
+ return FALSE;
+
+/*
+#ifdef RANDR
+ if (!sdlRandRInit (pScreen))
+ return FALSE;
+#endif
+*/
+ return TRUE;
+}
+
+static void sdlKeyboardFini(KdKeyboardInfo *ki)
+{
+ sdlKeyboard = NULL;
+}
+
+static Bool sdlKeyboardInit(KdKeyboardInfo *ki)
+{
+ ki->minScanCode = 8;
+ ki->maxScanCode = 255;
+ ki->keySyms.minKeyCode = 8;
+ ki->keySyms.maxKeyCode = 255;
+ ki->keySyms.mapWidth = 2;
+ memcpy(ki->keySyms.map, sdlKeymap, sizeof(sdlKeymap));
+
+ sdlKeyboard = ki;
+
+ return TRUE;
+}
+
+static Bool sdlMouseInit (KdPointerInfo *pi)
+{
+ sdlPointer = pi;
+ return TRUE;
+}
+
+static void sdlMouseFini(KdPointerInfo *pi)
+{
+ sdlPointer = NULL;
+}
+
+
+void InitCard(char *name)
+{
+ KdCardAttr attr;
+ KdCardInfoAdd (&sdlFuncs, &attr, 0);
+#ifdef DEBUG
+ printf("InitCard: %s\n", name);
+#endif
+}
+
+void InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput(pScreenInfo, argc, argv);
+#ifdef DEBUG
+ printf("InitOutput()\n");
+#endif
+}
+
+void InitInput(int argc, char **argv)
+{
+ KdPointerInfo *pi;
+ KdKeyboardInfo *ki;
+
+ KdAddKeyboardDriver(&sdlKeyboardDriver);
+ KdAddPointerDriver(&sdlMouseDriver);
+
+ ki = KdParseKeyboard("keyboard");
+ KdAddKeyboard(ki);
+ pi = KdParsePointer("mouse");
+ KdAddPointer(pi);
+
+ KdInitInput();
+}
+
+void ddxUseMsg(void)
+{
+ KdUseMsg();
+}
+
+int ddxProcessArgument(int argc, char **argv, int i)
+{
+ return KdProcessArgument(argc, argv, i);
+}
+
+void sdlTimer(void)
+{
+ static int buttonState=0;
+ SDL_Event event;
+ SDL_ShowCursor(FALSE);
+ /* get the mouse state */
+ while ( SDL_PollEvent(&event) ) {
+ switch (event.type) {
+ case SDL_MOUSEMOTION:
+ KdEnqueuePointerEvent(sdlPointer, mouseState, event.motion.x, event.motion.y, 0);
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ switch(event.button.button)
+ {
+ case 1:
+ buttonState=KD_BUTTON_1;
+ break;
+ case 2:
+ buttonState=KD_BUTTON_2;
+ break;
+ case 3:
+ buttonState=KD_BUTTON_3;
+ break;
+ }
+ mouseState|=buttonState;
+ KdEnqueuePointerEvent(sdlPointer, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
+ break;
+ case SDL_MOUSEBUTTONUP:
+ switch(event.button.button)
+ {
+ case 1:
+ buttonState=KD_BUTTON_1;
+ break;
+ case 2:
+ buttonState=KD_BUTTON_2;
+ break;
+ case 3:
+ buttonState=KD_BUTTON_3;
+ break;
+ }
+ mouseState &= ~buttonState;
+ KdEnqueuePointerEvent(sdlPointer, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
+ break;
+ case SDL_KEYDOWN:
+ case SDL_KEYUP:
+#ifdef DEBUG
+ printf("Keycode: %d\n", event.key.keysym.scancode);
+#endif
+ KdEnqueueKeyboardEvent (sdlKeyboard, event.key.keysym.scancode, event.type==SDL_KEYUP);
+ break;
+
+ case SDL_QUIT:
+ /* this should never happen */
+ SDL_Quit();
+ }
+ }
+}
+
+static int xsdlInit(void)
+{
+#ifdef DEBUG
+ printf("Calling SDL_Init()\n");
+#endif
+ return SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
+}
+
+
+static void xsdlFini(void)
+{
+ SDL_Quit();
+}
+
+KdOsFuncs sdlOsFuncs={
+ .Init = xsdlInit,
+ .Fini = xsdlFini,
+ .pollEvents = sdlTimer,
+};
+
+void OsVendorInit (void)
+{
+ KdOsInit (&sdlOsFuncs);
+}
+
+
diff --git a/xorg-server/hw/kdrive/sis300/Makefile.am b/xorg-server/hw/kdrive/sis300/Makefile.am
new file mode 100644
index 000000000..af2500aee
--- /dev/null
+++ b/xorg-server/hw/kdrive/sis300/Makefile.am
@@ -0,0 +1,51 @@
+if KDRIVEFBDEV
+FBDEV_INCLUDES =-I$(top_srcdir)/hw/kdrive/fbdev
+FBDEV_LIBS = $(top_builddir)/hw/kdrive/fbdev/libfbdev.a
+endif
+
+if KDRIVEVESA
+VESA_INCLUDES = -I$(top_srcdir)/hw/kdrive/vesa
+VESA_LIBS = $(top_builddir)/hw/kdrive/vesa/libvesa.a
+endif
+
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ $(DRI_INCLUDES) \
+ $(FBDEV_INCLUDES) \
+ $(VESA_INCLUDES) \
+ @KDRIVE_CFLAGS@
+
+bin_PROGRAMS = Xsis
+
+noinst_LIBRARIES = libsis.a
+
+libsis_a_SOURCES = \
+ sis.c \
+ sis.h \
+ sis_draw.c \
+ sis_reg.h
+
+Xsis_SOURCES = \
+ sis_stub.c
+
+SIS_LIBS = \
+ libsis.a \
+ $(FBDEV_LIBS) \
+ $(VESA_LIBS) \
+ @KDRIVE_LIBS@
+
+if GLX
+Xsis_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
+Xsis_LDADD = \
+ $(SIS_LIBS) \
+ @KDRIVE_LIBS@ \
+ $(TSLIB_FLAG)
+
+Xsis_DEPENDENCIES = \
+ libsis.a \
+ @KDRIVE_LOCAL_LIBS@
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/sis300/Makefile.in b/xorg-server/hw/kdrive/sis300/Makefile.in
new file mode 100644
index 000000000..bbd059906
--- /dev/null
+++ b/xorg-server/hw/kdrive/sis300/Makefile.in
@@ -0,0 +1,725 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xsis$(EXEEXT)
+subdir = hw/kdrive/sis300
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libsis_a_AR = $(AR) $(ARFLAGS)
+libsis_a_LIBADD =
+am_libsis_a_OBJECTS = sis.$(OBJEXT) sis_draw.$(OBJEXT)
+libsis_a_OBJECTS = $(am_libsis_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xsis_OBJECTS = sis_stub.$(OBJEXT)
+Xsis_OBJECTS = $(am_Xsis_OBJECTS)
+am__DEPENDENCIES_1 = libsis.a $(FBDEV_LIBS) $(VESA_LIBS)
+Xsis_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xsis_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libsis_a_SOURCES) $(Xsis_SOURCES)
+DIST_SOURCES = $(libsis_a_SOURCES) $(Xsis_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+@KDRIVEFBDEV_TRUE@FBDEV_INCLUDES = -I$(top_srcdir)/hw/kdrive/fbdev
+@KDRIVEFBDEV_TRUE@FBDEV_LIBS = $(top_builddir)/hw/kdrive/fbdev/libfbdev.a
+@KDRIVEVESA_TRUE@VESA_INCLUDES = -I$(top_srcdir)/hw/kdrive/vesa
+@KDRIVEVESA_TRUE@VESA_LIBS = $(top_builddir)/hw/kdrive/vesa/libvesa.a
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ $(DRI_INCLUDES) \
+ $(FBDEV_INCLUDES) \
+ $(VESA_INCLUDES) \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libsis.a
+libsis_a_SOURCES = \
+ sis.c \
+ sis.h \
+ sis_draw.c \
+ sis_reg.h
+
+Xsis_SOURCES = \
+ sis_stub.c
+
+SIS_LIBS = \
+ libsis.a \
+ $(FBDEV_LIBS) \
+ $(VESA_LIBS) \
+ @KDRIVE_LIBS@
+
+@GLX_TRUE@Xsis_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xsis_LDADD = \
+ $(SIS_LIBS) \
+ @KDRIVE_LIBS@ \
+ $(TSLIB_FLAG)
+
+Xsis_DEPENDENCIES = \
+ libsis.a \
+ @KDRIVE_LOCAL_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/sis300/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/sis300/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libsis.a: $(libsis_a_OBJECTS) $(libsis_a_DEPENDENCIES)
+ -rm -f libsis.a
+ $(libsis_a_AR) libsis.a $(libsis_a_OBJECTS) $(libsis_a_LIBADD)
+ $(RANLIB) libsis.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xsis$(EXEEXT): $(Xsis_OBJECTS) $(Xsis_DEPENDENCIES)
+ @rm -f Xsis$(EXEEXT)
+ $(Xsis_LINK) $(Xsis_OBJECTS) $(Xsis_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sis.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sis_draw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sis_stub.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/sis300/sis.c b/xorg-server/hw/kdrive/sis300/sis.c
new file mode 100644
index 000000000..30b7ac2c5
--- /dev/null
+++ b/xorg-server/hw/kdrive/sis300/sis.c
@@ -0,0 +1,311 @@
+/*
+ * Copyright © 2003 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "sis.h"
+#include "sis_reg.h"
+
+struct pci_id_entry sis_pci_ids[] = {
+ {0x1039, 0x0300, 0x1, "SiS 300/305"},
+ {0x1039, 0x5300, 0x1, "SiS 540"},
+ {0x1039, 0x6300, 0x1, "SiS 630"},
+ {0x1039, 0x7300, 0x1, "SiS 730"},
+ {0, 0, 0, NULL}
+};
+
+static Bool
+SiSCardInit(KdCardInfo *card)
+{
+ SiSCardInfo *sisc;
+ Bool initialized = FALSE;
+
+ sisc = xcalloc(sizeof(SiSCardInfo), 1);
+ if (sisc == NULL)
+ return FALSE;
+
+#ifdef KDRIVEFBDEV
+ if (!initialized && fbdevInitialize(card, &sisc->backend_priv.fbdev)) {
+ sisc->use_fbdev = TRUE;
+ initialized = TRUE;
+ sisc->backend_funcs.cardfini = fbdevCardFini;
+ sisc->backend_funcs.scrfini = fbdevScreenFini;
+ sisc->backend_funcs.initScreen = fbdevInitScreen;
+ sisc->backend_funcs.finishInitScreen = fbdevFinishInitScreen;
+ sisc->backend_funcs.createRes = fbdevCreateResources;
+ sisc->backend_funcs.preserve = fbdevPreserve;
+ sisc->backend_funcs.restore = fbdevRestore;
+ sisc->backend_funcs.dpms = fbdevDPMS;
+ sisc->backend_funcs.enable = fbdevEnable;
+ sisc->backend_funcs.disable = fbdevDisable;
+ sisc->backend_funcs.getColors = fbdevGetColors;
+ sisc->backend_funcs.putColors = fbdevPutColors;
+ }
+#endif
+#ifdef KDRIVEVESA
+ if (!initialized && vesaInitialize(card, &sisc->backend_priv.vesa)) {
+ sisc->use_vesa = TRUE;
+ initialized = TRUE;
+ sisc->backend_funcs.cardfini = vesaCardFini;
+ sisc->backend_funcs.scrfini = vesaScreenFini;
+ sisc->backend_funcs.initScreen = vesaInitScreen;
+ sisc->backend_funcs.finishInitScreen = vesaFinishInitScreen;
+ sisc->backend_funcs.createRes = vesaCreateResources;
+ sisc->backend_funcs.preserve = vesaPreserve;
+ sisc->backend_funcs.restore = vesaRestore;
+ sisc->backend_funcs.dpms = vesaDPMS;
+ sisc->backend_funcs.enable = vesaEnable;
+ sisc->backend_funcs.disable = vesaDisable;
+ sisc->backend_funcs.getColors = vesaGetColors;
+ sisc->backend_funcs.putColors = vesaPutColors;
+ }
+#endif
+
+ if (!initialized || !SiSMapReg(card, sisc)) {
+ xfree(sisc);
+ return FALSE;
+ }
+
+ card->driver = sisc;
+
+ return TRUE;
+}
+
+static void
+SiSCardFini(KdCardInfo *card)
+{
+ SiSCardInfo *sisc = (SiSCardInfo *)card->driver;
+
+ SiSUnmapReg(card, sisc);
+ sisc->backend_funcs.cardfini(card);
+}
+
+static Bool
+SiSScreenInit(KdScreenInfo *screen)
+{
+ SiSScreenInfo *siss;
+ SiSCardInfo(screen);
+ int success = FALSE;
+
+ siss = xcalloc(sizeof(SiSScreenInfo), 1);
+ if (siss == NULL)
+ return FALSE;
+
+ siss->sisc = sisc;
+
+ screen->driver = siss;
+
+#ifdef KDRIVEFBDEV
+ if (sisc->use_fbdev) {
+ success = fbdevScreenInitialize(screen,
+ &siss->backend_priv.fbdev);
+ screen->memory_size = sisc->backend_priv.fbdev.fix.smem_len;
+ screen->off_screen_base =
+ sisc->backend_priv.fbdev.var.yres_virtual *
+ screen->fb[0].byteStride;
+ }
+#endif
+#ifdef KDRIVEVESA
+ if (sisc->use_vesa) {
+ if (screen->fb[0].depth == 0)
+ screen->fb[0].depth = 16;
+ success = vesaScreenInitialize(screen,
+ &siss->backend_priv.vesa);
+ }
+#endif
+ if (!success) {
+ screen->driver = NULL;
+ xfree(siss);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+SiSScreenFini(KdScreenInfo *screen)
+{
+ SiSScreenInfo *siss = (SiSScreenInfo *)screen->driver;
+ SiSCardInfo *sisc = screen->card->driver;
+
+ sisc->backend_funcs.scrfini(screen);
+ xfree(siss);
+ screen->driver = 0;
+}
+
+Bool
+SiSMapReg(KdCardInfo *card, SiSCardInfo *sisc)
+{
+ sisc->reg_base = (CARD8 *)KdMapDevice(SIS_REG_BASE(card),
+ SIS_REG_SIZE(card));
+
+ if (sisc->reg_base == NULL)
+ return FALSE;
+
+ KdSetMappedMode(SIS_REG_BASE(card), SIS_REG_SIZE(card),
+ KD_MAPPED_MODE_REGISTERS);
+
+ return TRUE;
+}
+
+void
+SiSUnmapReg(KdCardInfo *card, SiSCardInfo *sisc)
+{
+ if (sisc->reg_base) {
+ KdResetMappedMode(SIS_REG_BASE(card), SIS_REG_SIZE(card),
+ KD_MAPPED_MODE_REGISTERS);
+ KdUnmapDevice((void *)sisc->reg_base, SIS_REG_SIZE(card));
+ sisc->reg_base = 0;
+ }
+}
+
+static Bool
+SiSInitScreen(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ SiSCardInfo(pScreenPriv);
+
+ return sisc->backend_funcs.initScreen(pScreen);
+}
+
+static Bool
+SiSFinishInitScreen(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ SiSCardInfo(pScreenPriv);
+
+ return sisc->backend_funcs.finishInitScreen(pScreen);
+}
+
+static Bool
+SiSCreateResources(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ SiSCardInfo(pScreenPriv);
+
+ return sisc->backend_funcs.createRes(pScreen);
+}
+
+static void
+SiSPreserve(KdCardInfo *card)
+{
+ SiSCardInfo *sisc = card->driver;
+
+ sisc->backend_funcs.preserve(card);
+}
+
+static void
+SiSRestore(KdCardInfo *card)
+{
+ SiSCardInfo *sisc = card->driver;
+
+ SiSUnmapReg(card, sisc);
+
+ sisc->backend_funcs.restore(card);
+}
+
+static Bool
+SiSDPMS(ScreenPtr pScreen, int mode)
+{
+ KdScreenPriv(pScreen);
+ SiSCardInfo(pScreenPriv);
+
+ return sisc->backend_funcs.dpms(pScreen, mode);
+}
+
+static Bool
+SiSEnable(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ SiSCardInfo(pScreenPriv);
+
+ if (!sisc->backend_funcs.enable(pScreen))
+ return FALSE;
+
+ if ((sisc->reg_base == NULL) && !SiSMapReg(pScreenPriv->screen->card,
+ sisc))
+ return FALSE;
+
+ SiSDPMS(pScreen, KD_DPMS_NORMAL);
+
+ return TRUE;
+}
+
+static void
+SiSDisable(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ SiSCardInfo(pScreenPriv);
+
+ SiSUnmapReg(pScreenPriv->card, sisc);
+
+ sisc->backend_funcs.disable(pScreen);
+}
+
+static void
+SiSGetColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ KdScreenPriv(pScreen);
+ SiSCardInfo(pScreenPriv);
+
+ sisc->backend_funcs.getColors(pScreen, fb, n, pdefs);
+}
+
+static void
+SiSPutColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ KdScreenPriv(pScreen);
+ SiSCardInfo(pScreenPriv);
+
+ sisc->backend_funcs.putColors(pScreen, fb, n, pdefs);
+}
+
+KdCardFuncs SiSFuncs = {
+ SiSCardInit, /* cardinit */
+ SiSScreenInit, /* scrinit */
+ SiSInitScreen, /* initScreen */
+ SiSFinishInitScreen, /* finishInitScreen */
+ SiSCreateResources, /* createRes */
+ SiSPreserve, /* preserve */
+ SiSEnable, /* enable */
+ SiSDPMS, /* dpms */
+ SiSDisable, /* disable */
+ SiSRestore, /* restore */
+ SiSScreenFini, /* scrfini */
+ SiSCardFini, /* cardfini */
+
+ 0, /* initCursor */
+ 0, /* enableCursor */
+ 0, /* disableCursor */
+ 0, /* finiCursor */
+ 0, /* recolorCursor */
+
+ SiSDrawInit, /* initAccel */
+ SiSDrawEnable, /* enableAccel */
+ SiSDrawSync, /* syncAccel */
+ SiSDrawDisable, /* disableAccel */
+ SiSDrawFini, /* finiAccel */
+
+ SiSGetColors, /* getColors */
+ SiSPutColors, /* putColors */
+};
diff --git a/xorg-server/hw/kdrive/sis300/sis.h b/xorg-server/hw/kdrive/sis300/sis.h
new file mode 100644
index 000000000..25d55be31
--- /dev/null
+++ b/xorg-server/hw/kdrive/sis300/sis.h
@@ -0,0 +1,160 @@
+/*
+ * Copyright © 2003 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _SIS_H_
+#define _SIS_H_
+
+#include "kdrive-config.h"
+
+#ifdef KDRIVEFBDEV
+#include <fbdev.h>
+#endif
+#ifdef KDRIVEVESA
+#include <vesa.h>
+#endif
+
+/* XXX */
+#define SIS_REG_BASE(c) ((c)->attr.address[1])
+#define SIS_REG_SIZE(c) (0x10000)
+
+#ifdef __powerpc__
+
+static __inline__ void
+MMIO_OUT32(__volatile__ void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ __asm__ __volatile__(
+ "stwbrx %1,%2,%3\n\t"
+ "eieio"
+ : "=m" (*((volatile unsigned char *)base+offset))
+ : "r" (val), "b" (base), "r" (offset));
+}
+
+static __inline__ CARD32
+MMIO_IN32(__volatile__ void *base, const unsigned long offset)
+{
+ register unsigned int val;
+ __asm__ __volatile__(
+ "lwbrx %0,%1,%2\n\t"
+ "eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset),
+ "m" (*((volatile unsigned char *)base+offset)));
+ return val;
+}
+
+#else
+
+#define MMIO_OUT32(mmio, a, v) (*(VOL32 *)((mmio) + (a)) = (v))
+#define MMIO_IN32(mmio, a) (*(VOL32 *)((mmio) + (a)))
+
+#endif
+
+typedef volatile CARD8 VOL8;
+typedef volatile CARD16 VOL16;
+typedef volatile CARD32 VOL32;
+
+struct pci_id_entry {
+ CARD16 vendor;
+ CARD16 device;
+ CARD8 caps;
+ char *name;
+};
+
+struct backend_funcs {
+ void (*cardfini)(KdCardInfo *);
+ void (*scrfini)(KdScreenInfo *);
+ Bool (*initScreen)(ScreenPtr);
+ Bool (*finishInitScreen)(ScreenPtr pScreen);
+ Bool (*createRes)(ScreenPtr);
+ void (*preserve)(KdCardInfo *);
+ void (*restore)(KdCardInfo *);
+ Bool (*dpms)(ScreenPtr, int);
+ Bool (*enable)(ScreenPtr);
+ void (*disable)(ScreenPtr);
+ void (*getColors)(ScreenPtr, int, int, xColorItem *);
+ void (*putColors)(ScreenPtr, int, int, xColorItem *);
+};
+
+typedef struct _SiSCardInfo {
+ union {
+#ifdef KDRIVEFBDEV
+ FbdevPriv fbdev;
+#endif
+#ifdef KDRIVEVESA
+ VesaCardPrivRec vesa;
+#endif
+ } backend_priv;
+ struct backend_funcs backend_funcs;
+
+ struct pci_id_entry *pci_id;
+ CARD8 *reg_base;
+ Bool use_fbdev, use_vesa;
+} SiSCardInfo;
+
+#define getSiSCardInfo(kd) ((SiSCardInfo *) ((kd)->card->driver))
+#define SiSCardInfo(kd) SiSCardInfo *sisc = getSiSCardInfo(kd)
+
+typedef struct _SiSScreenInfo {
+ union {
+#ifdef KDRIVEFBDEV
+ FbdevScrPriv fbdev;
+#endif
+#ifdef KDRIVEVESA
+ VesaScreenPrivRec vesa;
+#endif
+ } backend_priv;
+ CARD32 depthSet; /* depth value for REG_BLT_SRCPITCH */
+ KaaScreenInfoRec kaa;
+ SiSCardInfo *sisc;
+} SiSScreenInfo;
+
+#define getSiSScreenInfo(kd) ((SiSScreenInfo *) ((kd)->screen->driver))
+#define SiSScreenInfo(kd) SiSScreenInfo *siss = getSiSScreenInfo(kd)
+
+Bool
+SiSMapReg(KdCardInfo *card, SiSCardInfo *sisc);
+
+void
+SiSUnmapReg(KdCardInfo *card, SiSCardInfo *sisc);
+
+Bool
+SiSDrawSetup(ScreenPtr pScreen);
+
+Bool
+SiSDrawInit(ScreenPtr pScreen);
+
+void
+SiSDrawEnable(ScreenPtr pScreen);
+
+void
+SiSDrawSync(ScreenPtr pScreen);
+
+void
+SiSDrawDisable(ScreenPtr pScreen);
+
+void
+SiSDrawFini(ScreenPtr pScreen);
+
+extern KdCardFuncs SiSFuncs;
+
+#endif /* _SIS_H_ */
diff --git a/xorg-server/hw/kdrive/sis300/sis_draw.c b/xorg-server/hw/kdrive/sis300/sis_draw.c
new file mode 100644
index 000000000..bbc905e1d
--- /dev/null
+++ b/xorg-server/hw/kdrive/sis300/sis_draw.c
@@ -0,0 +1,320 @@
+/*
+ * Copyright © 2003 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/io.h>
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+
+#include "sis.h"
+#include "sis_reg.h"
+
+#if 0
+#define SIS_FALLBACK(x) \
+do { \
+ ErrorF x; \
+ return FALSE; \
+} while (0)
+#else
+#define SIS_FALLBACK(x) return FALSE
+#endif
+
+CARD8 SiSSolidRop[16] = {
+ /* GXclear */ 0x00, /* 0 */
+ /* GXand */ 0xa0, /* src AND dst */
+ /* GXandReverse */ 0x50, /* src AND NOT dst */
+ /* GXcopy */ 0xf0, /* src */
+ /* GXandInverted*/ 0x0a, /* NOT src AND dst */
+ /* GXnoop */ 0xaa, /* dst */
+ /* GXxor */ 0x5a, /* src XOR dst */
+ /* GXor */ 0xfa, /* src OR dst */
+ /* GXnor */ 0x05, /* NOT src AND NOT dst */
+ /* GXequiv */ 0xa5, /* NOT src XOR dst */
+ /* GXinvert */ 0x55, /* NOT dst */
+ /* GXorReverse */ 0xf5, /* src OR NOT dst */
+ /* GXcopyInverted*/ 0x0f, /* NOT src */
+ /* GXorInverted */ 0xaf, /* NOT src OR dst */
+ /* GXnand */ 0x5f, /* NOT src OR NOT dst */
+ /* GXset */ 0xff, /* 1 */
+};
+
+CARD8 SiSBltRop[16] = {
+ /* GXclear */ 0x00, /* 0 */
+ /* GXand */ 0x88, /* src AND dst */
+ /* GXandReverse */ 0x44, /* src AND NOT dst */
+ /* GXcopy */ 0xcc, /* src */
+ /* GXandInverted*/ 0x22, /* NOT src AND dst */
+ /* GXnoop */ 0xaa, /* dst */
+ /* GXxor */ 0x66, /* src XOR dst */
+ /* GXor */ 0xee, /* src OR dst */
+ /* GXnor */ 0x11, /* NOT src AND NOT dst */
+ /* GXequiv */ 0x99, /* NOT src XOR dst */
+ /* GXinvert */ 0x55, /* NOT dst */
+ /* GXorReverse */ 0xdd, /* src OR NOT dst */
+ /* GXcopyInverted*/ 0x33, /* NOT src */
+ /* GXorInverted */ 0xbb, /* NOT src OR dst */
+ /* GXnand */ 0x77, /* NOT src OR NOT dst */
+ /* GXset */ 0xff, /* 1 */
+};
+
+int copydx, copydy;
+int fifo_size;
+SiSScreenInfo *accel_siss;
+char *mmio;
+CARD32 sis_color = 0;
+CARD32 blitCmd;
+
+static void
+SiSWaitAvailMMIO(int n)
+{
+ while (fifo_size < n) {
+ fifo_size = MMIO_IN32(mmio, REG_CommandQueue) & MASK_QueueLen;
+ }
+ fifo_size -= n;
+}
+
+static void
+SiSWaitIdle(void)
+{
+ CARD32 engineState;
+ do {
+ engineState = MMIO_IN32(mmio, REG_CommandQueue);
+ } while ((engineState & SiS_EngIdle) != SiS_EngIdle);
+}
+
+static Bool
+SiSPrepareSolid(PixmapPtr pPixmap, int alu, Pixel pm, Pixel fg)
+{
+ KdScreenPriv(pPixmap->drawable.pScreen);
+ SiSScreenInfo(pScreenPriv);
+ SiSCardInfo(pScreenPriv);
+
+ /* No acceleration for other formats (yet) */
+ if (pPixmap->drawable.bitsPerPixel !=
+ pScreenPriv->screen->fb[0].bitsPerPixel)
+ return FALSE;
+
+ if ((pm & 0x00ffffff) != 0x00ffffff) /* XXX */
+ SIS_FALLBACK(("Unsupported planemask 0x%x\n", pm));
+
+ accel_siss = siss;
+ mmio = sisc->reg_base;
+
+ SiSWaitAvailMMIO(4);
+ MMIO_OUT32(mmio, REG_BLT_PATFG, fg);
+ MMIO_OUT32(mmio, REG_BLT_DSTRECT, (-1 << 16) | pPixmap->devKind);
+ MMIO_OUT32(mmio, REG_BLT_SRCPITCH, siss->depthSet);
+ MMIO_OUT32(mmio, REG_BLT_DSTBASE, ((CARD8 *)pPixmap->devPrivate.ptr -
+ pScreenPriv->screen->memory_base));
+
+ blitCmd = BLT_CMD_BITBLT | BLT_PAT_FG | BLT_X_INC | BLT_Y_INC |
+ BLT_NOCLIP | (SiSSolidRop[alu] << 8);
+
+ return TRUE;
+}
+
+static void
+SiSSolid(int x1, int y1, int x2, int y2)
+{
+ SiSWaitAvailMMIO(3);
+ MMIO_OUT32(mmio, REG_BLT_DSTXY, (x1 << 16) | y1);
+ MMIO_OUT32(mmio, REG_BLT_H_W, ((y2 - y1) << 16) | (x2 - x1));
+ MMIO_OUT32(mmio, REG_BLT_CMD, blitCmd);
+}
+
+static void
+SiSDoneSolid(void)
+{
+}
+
+static Bool
+SiSPrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu,
+ Pixel pm)
+{
+ KdScreenPriv(pDst->drawable.pScreen);
+ SiSScreenInfo(pScreenPriv);
+ SiSCardInfo(pScreenPriv);
+
+ /* No acceleration for other formats (yet) */
+ if (pDst->drawable.bitsPerPixel !=
+ pScreenPriv->screen->fb[0].bitsPerPixel)
+ return FALSE;
+
+ if ((pm & 0x00ffffff) != 0x00ffffff) /* XXX */
+ SIS_FALLBACK(("Unsupported pixel mask 0x%x\n", pm));
+
+ accel_siss = siss;
+ mmio = sisc->reg_base;
+
+ SiSWaitAvailMMIO(4);
+ MMIO_OUT32(mmio, REG_BLT_SRCPITCH, siss->depthSet | pSrc->devKind);
+ MMIO_OUT32(mmio, REG_BLT_DSTRECT, (-1 << 16) | pDst->devKind);
+ MMIO_OUT32(mmio, REG_BLT_SRCBASE, ((CARD8 *)pSrc->devPrivate.ptr -
+ pScreenPriv->screen->memory_base));
+ MMIO_OUT32(mmio, REG_BLT_DSTBASE, ((CARD8 *)pDst->devPrivate.ptr -
+ pScreenPriv->screen->memory_base));
+
+ blitCmd = BLT_CMD_BITBLT | BLT_PAT_FG | BLT_NOCLIP |
+ (SiSBltRop[alu] << 8);
+
+ if (pSrc != pDst || dx >= 0)
+ blitCmd |= BLT_X_INC;
+ if (pSrc != pDst || dy >= 0)
+ blitCmd |= BLT_Y_INC;
+
+ return TRUE;
+}
+
+static void
+SiSCopy(int srcX, int srcY, int dstX, int dstY, int w, int h)
+{
+ if (!(blitCmd & BLT_X_INC)) {
+ srcX += w - 1;
+ dstX += w - 1;
+ }
+
+ if (!(blitCmd & BLT_Y_INC)) {
+ srcY += h - 1;
+ dstY += h - 1;
+ }
+
+ SiSWaitAvailMMIO(4);
+ MMIO_OUT32(mmio, REG_BLT_H_W, (h << 16) | w);
+ MMIO_OUT32(mmio, REG_BLT_SRCXY, (srcX << 16) | srcY);
+ MMIO_OUT32(mmio, REG_BLT_DSTXY, (dstX << 16) | dstY);
+ MMIO_OUT32(mmio, REG_BLT_CMD, blitCmd);
+}
+
+static void
+SiSDoneCopy(void)
+{
+}
+
+KaaScreenInfoRec SiSKaa = {
+ SiSPrepareSolid,
+ SiSSolid,
+ SiSDoneSolid,
+ SiSPrepareCopy,
+ SiSCopy,
+ SiSDoneCopy,
+ KAA_OFFSCREEN_PIXMAPS,
+ 8,
+ 8
+};
+
+#define USE_TURBOQUEUE 0
+
+Bool
+SiSDrawInit(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ SiSScreenInfo(pScreenPriv);
+ CARD8 tmp;
+#if USE_TURBOQUEUE
+ int tqsize;
+#endif
+
+ switch (pScreenPriv->screen->fb[0].depth)
+ {
+ case 8:
+ siss->depthSet = 0x00000000;
+ break;
+ case 15:
+ siss->depthSet = 0x40000000;
+ break;
+ case 16:
+ siss->depthSet = 0x80000000;
+ break;
+ case 24:
+ if (pScreenPriv->screen->fb[0].bitsPerPixel == 32) {
+ siss->depthSet = 0xc0000000;
+ break;
+ }
+ /* FALLTHROUGH*/
+ default:
+ ErrorF("Unsupported depth/bpp %d/%d\n",
+ pScreenPriv->screen->fb[0].depth,
+ pScreenPriv->screen->fb[0].bitsPerPixel);
+ return FALSE;
+ }
+
+ outb(0x05, 0x3c4);
+ outb(0x86, 0x3c5); /* unlock registers */
+
+ outb(0x20, 0x3c4);
+ outb(0xA1, 0x3c5); /* enable pci linear addressing, MMIO, PCI_IO */
+
+ outb(0x1e, 0x3c4);
+ tmp = inb(0x3c5);
+ outb(tmp | 0x42 | 0x18, 0x3c5); /* Enable 2d and 3d */
+
+#if USE_TURBOQUEUE
+ tqsize = (pScreenPriv->screen->memory_size / 1024) / 64 - 8;
+ /* Enable TQ */
+ outb(0x26, 0x3c4);
+ outb(tqsize & 0xff, 0x3c5);
+ outb(0x27, 0x3c4);
+ tmp = inb(0x3c5);
+ outb(((tqsize >> 8) & 0x03) | (tmp & 0x0c) | 0xF0, 0x3c5);
+
+ /* XXX: Adjust offscreen size to avoid TQ area (last 512k) */
+#endif
+
+ ErrorF("Screen: %d/%d depth/bpp\n", pScreenPriv->screen->fb[0].depth,
+ pScreenPriv->screen->fb[0].bitsPerPixel);
+
+ if (!kaaDrawInit(pScreen, &SiSKaa))
+ return FALSE;
+
+ return TRUE;
+}
+
+void
+SiSDrawEnable(ScreenPtr pScreen)
+{
+ KdMarkSync(pScreen);
+}
+
+void
+SiSDrawDisable(ScreenPtr pScreen)
+{
+}
+
+void
+SiSDrawFini(ScreenPtr pScreen)
+{
+ kaaDrawFini (pScreen);
+}
+
+void
+SiSDrawSync(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ SiSScreenInfo(pScreenPriv);
+ SiSCardInfo(pScreenPriv);
+
+ accel_siss = siss;
+ mmio = sisc->reg_base;
+
+ SiSWaitIdle();
+}
diff --git a/xorg-server/hw/kdrive/sis300/sis_reg.h b/xorg-server/hw/kdrive/sis300/sis_reg.h
new file mode 100644
index 000000000..6e5a8f6d5
--- /dev/null
+++ b/xorg-server/hw/kdrive/sis300/sis_reg.h
@@ -0,0 +1,902 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 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:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#ifndef _sis_reg_h_
+#define _sis_reg_h_
+
+/*
+ * Define All the Register Address of 6327
+ */
+
+#define REG_BLT_SRCBASE 0x8200
+#define REG_BLT_SRCPITCH 0x8204
+#define REG_BLT_SRCXY 0x8208
+#define REG_BLT_DSTXY 0x820c
+#define REG_BLT_DSTBASE 0x8210
+#define REG_BLT_DSTRECT 0x8214
+#define REG_BLT_H_W 0x8218
+#define REG_BLT_PATFG 0x821c
+#define REG_BLT_PATBG 0x8220
+#define REG_BLT_SRCFG 0x8224
+#define REG_BLT_SRCBG 0x8228
+#define REG_BLT_MONOPAT0 0x822c
+#define REG_BLT_MONOPAT1 0x8230
+#define REG_BLT_CLIPLT 0x8234
+#define REG_BLT_CLIBRB 0x8238
+#define REG_BLT_CMD 0x823c
+#define REG_CommandQueue 0x8240
+
+#define REG_3D_TSFSa 0x8800
+#define REG_3D_TSZa 0x8804
+#define REG_3D_TSXa 0x8808
+#define REG_3D_TSYa 0x880C
+#define REG_3D_TSARGBa 0x8810
+#define REG_3D_TSWGa 0x8814
+#define REG_3D_TSUAa 0x8818
+#define REG_3D_TSVAa 0x881C
+#define REG_3D_TSUBa 0x8820
+#define REG_3D_TSVBa 0x8824
+#define REG_3D_TSUCa 0x8828
+#define REG_3D_TSVCa 0x882C
+
+#define REG_3D_TSFSb 0x8830
+#define REG_3D_TSZb 0x8834
+#define REG_3D_TSXb 0x8838
+#define REG_3D_TSYb 0x883C
+#define REG_3D_TSARGBb 0x8840
+#define REG_3D_TSWGb 0x8844
+#define REG_3D_TSUAb 0x8848
+#define REG_3D_TSVAb 0x884C
+#define REG_3D_TSUBb 0x8850
+#define REG_3D_TSVBb 0x8854
+#define REG_3D_TSUCb 0x8858
+#define REG_3D_TSVCb 0x885C
+
+#define REG_3D_TSFSc 0x8860
+#define REG_3D_TSZc 0x8864
+#define REG_3D_TSXc 0x8868
+#define REG_3D_TSYc 0x886C
+#define REG_3D_TSARGBc 0x8870
+#define REG_3D_TSWGc 0x8874
+#define REG_3D_TSUAc 0x8878
+#define REG_3D_TSVAc 0x887C
+#define REG_3D_TSUBc 0x8880
+#define REG_3D_TSVBc 0x8884
+#define REG_3D_TSUCc 0x8888
+#define REG_3D_TSVCc 0x888C
+
+/*
+ * REG_3D_AGPCmdSetting (89e4h-89f7)
+ */
+#define REG_3D_AGPCmBase 0x89E4
+#define REG_3D_AGPRmDwNum 0x89E8
+#define REG_3D_AGPTtDwNum 0x89EC
+#define REG_3D_AGPCmFire 0x89F0
+
+#define REG_3D_ParsingSet 0x89F4
+#define REG_3D_PrimitiveSet 0x89F8
+#define REG_3D_ShadeMode 0x89F8
+#define REG_3D_EngineFire 0x89FC
+#define REG_3D_EngineStatus 0x89FC
+#define REG_3D_TEnable 0x8A00
+#define REG_3D_TEnable2 0x8A04
+
+#define REG_3D_ZSet 0x8A08
+#define REG_3D_ZBias 0x8A0C
+#define REG_3D_ZStWriteMask 0x8A10
+
+#define REG_3D_ZAddress 0x8A14
+#define REG_3D_AlphaSet 0x8A18
+#define REG_3D_AlphaAddress 0x8A1C
+#define REG_3D_DstSet 0x8A20
+#define REG_3D_DstAlphaWriteMask 0x8A24
+
+#define REG_3D_DstAddress 0x8A28
+
+#define REG_3D_LinePattern 0x8A2C
+
+#define REG_3D_FogSet 0x8A30
+
+#define REG_3D_FogFarDistance 0x8A34
+#define REG_3D_FogInverseDistance 0x8A38
+#define REG_3D_FogFactorDensity 0x8A3C
+
+#define REG_3D_StencilSet 0x8A44
+#define REG_3D_StencilSet2 0x8A48
+#define REG_3D_StencilAddress 0x8A4C
+
+#define REG_3D_DstBlendMode 0x8A50
+#define REG_3D_SrcBlendMode 0x8A50
+#define REG_3D_ClipTopBottom 0x8A54
+#define REG_3D_ClipLeftRight 0x8A58
+
+#define REG_3D_Brightness 0x8A5C
+
+#define REG_3D_BumpMapSet 0x8A68
+#define REG_3D_BumpMapAddress 0x8A6C
+#define REG_3D_BumpMapPitch 0x8A70
+#define REG_3D_BumpMapMatrix0 0x8A74
+#define REG_3D_BumpMapMatrix1 0x8A78
+
+/*
+ * Define the Texture Register Address of 6326
+ */
+#define REG_3D_TextureSet 0x8A7C
+#define REG_3D_TextureWidthHeight 0x8A7C
+#define REG_3D_TextureMip 0x8A80
+
+#define REG_3D_TextureTransparencyColorHigh 0x8A84
+#define REG_3D_TextureTransparencyColorLow 0x8A88
+#define REG_3D_TextureBorderColor 0x8A8C
+#define REG_3D_TextureAddress0 0x8A90
+#define REG_3D_TextureAddress1 0x8A94
+#define REG_3D_TextureAddress2 0x8A98
+#define REG_3D_TextureAddress3 0x8A9C
+#define REG_3D_TextureAddress4 0x8AA0
+#define REG_3D_TextureAddress5 0x8AA4
+#define REG_3D_TextureAddress6 0x8AA8
+#define REG_3D_TextureAddress7 0x8AAC
+#define REG_3D_TextureAddress8 0x8AB0
+#define REG_3D_TextureAddress9 0x8AB4
+#define REG_3D_TextureAddress10 0x8AB8
+#define REG_3D_TextureAddress11 0x8ABC
+#define REG_3D_TexturePitch0 0x8AC0
+#define REG_3D_TexturePitch1 0x8AC0
+#define REG_3D_TexturePitch2 0x8AC4
+#define REG_3D_TexturePitch3 0x8AC4
+#define REG_3D_TexturePitch4 0x8AC8
+#define REG_3D_TexturePitch5 0x8AC8
+#define REG_3D_TexturePitch6 0x8ACC
+#define REG_3D_TexturePitch7 0x8ACC
+#define REG_3D_TexturePitch8 0x8AD0
+#define REG_3D_TexturePitch9 0x8AD0
+#define REG_3D_TexturePitch10 0x8AD4
+
+#define REG_3D_Texture1Set 0x8ADC
+#define REG_3D_Texture1WidthHeight 0x8ADC
+#define REG_3D_Texture1Mip 0x8AE0
+
+#define REG_3D_Texture1TransparencyColorHigh 0x8AE4
+#define REG_3D_Texture1TransparencyColorLow 0x8AE8
+#define REG_3D_Texture1BorderColor 0x8AEC
+#define REG_3D_Texture1Address0 0x8AF0
+#define REG_3D_Texture1Address1 0x8AF4
+#define REG_3D_Texture1Address2 0x8AF8
+#define REG_3D_Texture1Address3 0x8AFC
+#define REG_3D_Texture1Address4 0x8B00
+#define REG_3D_Texture1Address5 0x8B04
+#define REG_3D_Texture1Address6 0x8B08
+#define REG_3D_Texture1Address7 0x8B0C
+#define REG_3D_Texture1Address8 0x8B10
+#define REG_3D_Texture1Address9 0x8B14
+#define REG_3D_Texture1Address10 0x8B18
+#define REG_3D_Texture1Address11 0x8B1C
+#define REG_3D_Texture1Pitch0 0x8B20
+#define REG_3D_Texture1Pitch1 0x8B20
+#define REG_3D_Texture1Pitch2 0x8B24
+#define REG_3D_Texture1Pitch3 0x8B24
+#define REG_3D_Texture1Pitch4 0x8B28
+#define REG_3D_Texture1Pitch5 0x8B28
+#define REG_3D_Texture1Pitch6 0x8B2C
+#define REG_3D_Texture1Pitch7 0x8B2C
+#define REG_3D_Texture1Pitch8 0x8B30
+#define REG_3D_Texture1Pitch9 0x8B30
+#define REG_3D_Texture1Pitch10 0x8B34
+
+#define REG_3D_TextureBlendFactor 0x8B3C
+#define REG_3D_TextureColorBlendSet0 0x8B40
+#define REG_3D_TextureColorBlendSet1 0x8B44
+#define REG_3D_TextureAlphaBlendSet0 0x8B48
+#define REG_3D_TextureAlphaBlendSet1 0x8B4C
+/*
+ * Define the End of Primitive List of 6326
+ */
+#define REG_3D_EndPrimitiveList 0X8B50
+
+
+/*
+ * Define the Stipple Register Address of 6326
+ */
+#define REG_3D_Stipple0 0X8B60
+
+#define REG_3D_TexturePalette 0x8C00
+
+/*
+ * REG_BLT_CMD -- (8x823c-0x823f)
+ */
+#define BLT_CMD_BITBLT 0x00000000
+#define BLT_CMD_COLOREXP 0x00000001
+#define BLT_CMD_ENCOLOREXP 0x00000002
+#define BLT_CMD_MULTIPLE_SCANLINE 0x00000003
+#define BLT_CMD_LINE 0x00000004
+#define BLT_CMD_TRAPAZOID_FILL 0x00000005
+#define BLT_CMD_TRANSPARENT_BITBLT 0x00000006
+
+#define BLT_X_INC 0x00010000
+#define BLT_Y_INC 0x00020000
+
+#define BLT_SRC_VIDEO 0x00000000
+#define BLT_SRC_SYSTEM 0x00000010
+#define BLT_SRC_CPUBLITBUF BLT_SRC_SYSTEM
+#define BLT_SRC_AGP 0x00000020
+
+#define BLT_PAT_FG 0x00000000
+#define BLT_PAT_PATREG 0x00000040
+#define BLT_PAT_MONO 0x00000080
+
+/* Clipping flags */
+#define BLT_NOCLIP 0x00000000
+#define BLT_NOMERGECLIP 0x04000000
+#define BLT_CLIPENABLE 0x00040000
+#define BLT_CLIPWITHOUTMERGE 0x04040000
+
+/*
+ * REG_CommandQueue -- (8240h-8243h)
+ */
+#define MASK_QueueLen 0x0000ffff
+#define SiS_EngIdle2d 0x80000000
+#define SiS_EngIdle 0xe0000000
+#define MASK_EngState 0xf0000000
+
+/*
+ * REG_3D_ParsingSet -- Define Parsing Mask (89F4h-89F7h)
+ */
+#define MASK_VertexDWSize 0xF0000000
+#define MASK_VertexDataFormat 0x0FFF0000
+#define MASK_PsVertex_HAS_RHW 0x08000000
+#define MASK_PsVertex_HAS_NORMALXYZ 0x04000000
+#define MASK_PsVertex_HAS_DIFFUSE 0x02000000
+#define MASK_PsVertex_HAS_SPECULAR 0x01000000
+#define MASK_PsUVSet 0x00FF0000
+#define MASK_PsVertex_HAS_1SetUV 0x00800000
+#define MASK_PsVertex_HAS_2SetUV 0x00C00000
+#define MASK_PsVertex_HAS_3SetUV 0x00E00000
+#define MASK_PsVertex_HAS_UVSet1 0x00800000
+#define MASK_PsVertex_HAS_UVSet2 0x00400000
+#define MASK_PsVertex_HAS_UVSet3 0x00200000
+#define MASK_PsCullDirection_CCW 0x00008000
+#define MASK_PsShadingMode 0x00007000
+/* XXX Shading modes just a guess, but seem to work*/
+#define MASK_PsShadingFlatA 0x00001000
+#define MASK_PsShadingFlatB 0x00002000
+#define MASK_PsShadingFlatC 0x00003000
+#define MASK_PsShadingSmooth 0x00004000
+#define MASK_PsTextureFrom 0x000003F0
+#define MASK_PsTexture0FromA 0x00000000
+#define MASK_PsTexture1FromA 0x00000000
+#define MASK_PsTexture1FromB 0x00000040
+#define MASK_PsBumpTextureFromA 0x00000000
+#define MASK_PsBumpTextureFromB 0x00000010
+#define MASK_PsBumpTextureFromC 0x00000020
+#define MASK_PsDataType 0x0000000F
+#define MASK_PsPointList 0x00000000
+#define MASK_PsLineList 0x00000004
+#define MASK_PsLineStrip 0x00000005
+#define MASK_PsTriangleList 0x00000008
+#define MASK_PsTriangleStrip 0x00000009
+#define MASK_PsTriangleFan 0x0000000A
+
+/*
+ * REG_3D_PrimitiveSet -- Define Fire Primitive Mask (89F8h-89FBh)
+ */
+#define MASK_DrawPrimitiveCommand 0x00000007
+#define MASK_SetFirePosition 0x00001F00
+#define MASK_BumpTextureFrom 0x00030000
+#define MASK_Texture1From 0x000C0000
+#define MASK_Texture0From 0x00300000
+#define MASK_ShadingMode 0x07000000
+#define MASK_CullDirection 0x08000000
+
+#define OP_3D_POINT_DRAW 0x00000000
+#define OP_3D_LINE_DRAW 0x00000001
+#define OP_3D_TRIANGLE_DRAW 0x00000002
+
+#define OP_3D_DIRECTION_RIGHT 0x00000000
+#define OP_3D_DIRECTION_LEFT 0x00000100
+#define OP_3D_DIRECTION_HORIZONTAL 0x00000000
+#define OP_3D_DIRECTION_VERTICAL 0x00000100
+
+#define OP_3D_FIRE_TFIRE 0x00000000
+#define OP_3D_FIRE_TSARGBa 0x00000100
+#define OP_3D_FIRE_TSWa 0x00000200
+#define OP_3D_FIRE_TSVAa 0x00000300
+#define OP_3D_FIRE_TSVBa 0x00000400
+#define OP_3D_FIRE_TSVCa 0x00000500
+
+#define OP_3D_FIRE_TSARGBb 0x00000900
+#define OP_3D_FIRE_TSWb 0x00000a00
+#define OP_3D_FIRE_TSVAb 0x00000b00
+#define OP_3D_FIRE_TSVBb 0x00000c00
+#define OP_3D_FIRE_TSVCb 0x00000d00
+
+#define OP_3D_FIRE_TSARGBc 0x00001100
+#define OP_3D_FIRE_TSWc 0x00001200
+#define OP_3D_FIRE_TSVAc 0x00001300
+#define OP_3D_FIRE_TSVBc 0x00001400
+#define OP_3D_FIRE_TSVCc 0x00001500
+
+#define OP_3D_Texture0FromA 0x00000000
+#define OP_3D_Texture0FromB 0x00100000
+#define OP_3D_Texture0FromC 0x00200000
+#define OP_3D_Texture1FromA 0x00000000
+#define OP_3D_Texture1FromB 0x00040000
+#define OP_3D_Texture1FromC 0x00080000
+#define OP_3D_TextureBumpFromA 0x00000000
+#define OP_3D_TextureBumpFromB 0x00010000
+#define OP_3D_TextureBumpFromC 0x00020000
+
+#define OP_3D_CullDirection_CCW 0x08000000
+
+#define SHADE_FLAT_VertexA 0x01000000
+#define SHADE_FLAT_VertexB 0x02000000
+#define SHADE_FLAT_VertexC 0x03000000
+#define SHADE_GOURAUD 0x04000000
+
+/*
+ * Define Command Queue Length Mask (89FCh-89FF)
+ */
+#define MASK_CmdQueueLen 0x0FFF0000
+
+/*
+ * REG_3D_TEnable -- Define Capility Enable Mask (8A00h-8A03h)
+ */
+#define MASK_DitherEnable 0x00000001
+#define MASK_BlendEnable 0x00000002
+#define MASK_FogTestEnable 0x00000004
+#define MASK_FogEnable 0x00000008
+#define MASK_SpecularEnable 0x00000010
+#define MASK_FogPerspectiveEnable 0x00000020
+#define MASK_TextureCacheClear 0x00000040
+#define MASK_TextureCacheEnable 0x00000080
+#define MASK_BumpMapEnable 0x00000100
+#define MASK_TexturePerspectiveEnable 0x00000200
+#define MASK_TextureEnable 0x00000400
+#define MASK_CullEnable 0x00000800
+#define MASK_TextureNumUsed 0x0000F000
+#define MASK_AlphaBufferEnable 0x00010000
+#define MASK_AlphaTestEnable 0x00020000
+#define MASK_AlphaWriteEnable 0x00040000
+#define MASK_ZTestEnable 0x00080000
+#define MASK_ZWriteEnable 0x00100000
+#define MASK_StencilBufferEnable 0x00200000
+#define MASK_StencilTestEnable 0x00400000
+#define MASK_StencilWriteEnable 0x00800000
+#define MASK_Texture0TransparencyEnable 0x01000000
+#define MASK_Texture1TransparencyEnable 0x02000000
+#define MASK_TextureAWrapUCorrection 0x04000000
+#define MASK_TextureAWrapVCorrection 0x08000000
+#define MASK_TextureBWrapUCorrection 0x10000000
+#define MASK_TextureBWrapVCorrection 0x20000000
+#define MASK_TextureCWrapUCorrection 0x40000000
+#define MASK_TextureCWrapVCorrection 0x80000000
+
+/*
+ * REG_3D_TEnable2 -- Define Capility Enable Mask2 (8A04h-8A07h)
+ */
+#define MASK_Texture0BlockTextureEnable 0x00000001
+#define MASK_Texture1BlockTextureEnable 0x00000002
+#define MASK_Texture0AnisotropicEnable 0x00000010
+#define MASK_Texture1AnisotropicEnable 0x00000020
+#define MASK_TextureMipmapBiasEnable 0x00000040
+#define MASK_LinePatternEnable 0x00000100
+#define MASK_StippleAlphaEnable 0x00000200
+#define MASK_StippleEnable 0x00000400
+#define MASK_AntiAliasEnable 0x00000800
+#define MASK_ZMaskWriteEnable 0x00001000
+#define MASK_StencilMaskWriteEnable 0x00002000
+#define MASK_AlphaMaskWriteEnable 0x00004000
+#define MASK_ColorMaskWriteEnable 0x00008000
+#define MASK_ZCacheClear 0x00010000
+#define MASK_ZCacheEnable 0x00020000
+#define MASK_StencilCacheClear 0x00040000
+#define MASK_StencilCacheEnable 0x00080000
+#define MASK_AlphaCacheClear 0x00100000
+#define MASK_AlphaCacheEnable 0x00200000
+#define MASK_ColorCacheClear 0x00400000
+#define MASK_ColorCacheEnable 0x00800000
+
+/*
+ * REG_3D_ZSet -- Define Z Buffer Setting Mask (8A08h-8A0Bh)
+ */
+#define MASK_ZBufferPitch 0x00000FFF
+#define MASK_ZTestMode 0x00070000
+#define MASK_ZBufferInSystem 0x00080000
+#define MASK_ZBufferFormat 0x01F00000
+
+#define SiS_Z_COMP_NEVER 0x00000000
+#define SiS_Z_COMP_S_LT_B 0x00010000
+#define SiS_Z_COMP_S_EQ_B 0x00020000
+#define SiS_Z_COMP_S_LE_B 0x00030000
+#define SiS_Z_COMP_S_GT_B 0x00040000
+#define SiS_Z_COMP_S_NE_B 0x00050000
+#define SiS_Z_COMP_S_GE_B 0x00060000
+#define SiS_Z_COMP_ALWAYS 0x00070000
+
+#define SiS_ZFORMAT_Z16 0x00000000
+#define SiS_ZFORMAT_Z16_INT 0x00100000
+#define SiS_ZFORMAT_S1Z15 0x00400000
+#define SiS_ZFORMAT_S1Z15_INT 0x00500000
+#define SiS_ZFORMAT_Z32 0x00800000
+#define SiS_ZFORMAT_S1Z31 0x00C00000
+#define SiS_ZFORMAT_S2Z30 0x00D00000
+#define SiS_ZFORMAT_S4Z28 0x00E00000
+#define SiS_ZFORMAT_S8Z24 0x00F00000
+#define SiS_ZFORMAT_FZ30 0x01800000
+#define SiS_ZFORMAT_FS1Z30 0x01C00000
+#define SiS_ZFORMAT_FS2Z30 0x01D00000
+
+/*
+ * REG_3D_ZBias -- Define Z Buffer Setting Mask (8A0Ch-8A0Fh)
+ */
+#define MASK_ZBias 0xFFFFFFFF
+
+/*
+ * REG_3D_ZStWriteMask -- Define Z and Stencil Buffer Mask (8A10h-8A13h)
+ */
+#define MASK_ZWriteMask 0x00FFFFFF
+
+/*
+ * REG_3D_ZAddress -- Define Z Buffer Base Address(8A14h-8A17h)
+ */
+#define MASK_ZAddress 0xFFFFFFFF
+
+/*
+ * REG_3D_AlphaSet -- Define Alpha Buffer Setting Mask (8A18h-8A1Bh)
+ */
+#define MASK_AlphaBufferPitch 0x000003FF
+#define MASK_AlphaRefValue 0x00FF0000
+#define MASK_AlphaTestMode 0x07000000
+#define MASK_AlphaBufferInSystem 0x08000000
+#define MASK_AlphaBufferFormat 0x30000000
+
+#define SiS_ALPHA_NEVER 0x00000000
+#define SiS_ALPHA_LESS 0x01000000
+#define SiS_ALPHA_EQUAL 0x02000000
+#define SiS_ALPHA_LEQUAL 0x03000000
+#define SiS_ALPHA_GREATER 0x04000000
+#define SiS_ALPHA_NOTEQUAL 0x05000000
+#define SiS_ALPHA_GEQUAL 0x06000000
+#define SiS_ALPHA_ALWAYS 0x07000000
+
+/*
+ * REG_3D_AlphaAddress -- Define Alpha Buffer Base Address(8A1Ch-8A1Fh)
+ */
+#define MASK_AlphaAddress 0xFFFFFFFF
+
+/*
+ * REG_3D_DstSet -- Define Destination Buffer Setting Mask (8A20h-8A23h)
+ */
+#define MASK_DstBufferPitch 0x00000FFF
+#define MASK_DstBufferFormat 0x000F0000
+#define MASK_DstBufferBitDepth 0x00300000
+#define MASK_DstBufferRgbOrder 0x00400000
+#define MASK_DstBufferInSystem 0x00800000
+#define MASK_Dst7BitFormat 0x007F0000
+#define MASK_ROP2 0x0F000000
+
+#define DST_FORMAT_RGB_555 0x00100000
+#define DST_FORMAT_RGB_565 0x00110000
+#define DST_FORMAT_ARGB_1555 0x00120000
+#define DST_FORMAT_ARGB_4444 0x00130000
+#define DST_FORMAT_ARGB_1888 0x00300000
+#define DST_FORMAT_ARGB_2888 0x00310000
+#define DST_FORMAT_ARGB_4888 0x00320000
+#define DST_FORMAT_ARGB_8888 0x00330000
+#define DST_FORMAT_ARGB_0888 0x00340000
+
+#define DST_FORMAT_BGR_555 0x00500000
+#define DST_FORMAT_BGR_565 0x00510000
+#define DST_FORMAT_ABGR_1555 0x00520000
+#define DST_FORMAT_ABGR_4444 0x00530000
+#define DST_FORMAT_ABGR_1888 0x00700000
+#define DST_FORMAT_ABGR_2888 0x00710000
+#define DST_FORMAT_ABGR_4888 0x00720000
+#define DST_FORMAT_ABGR_8888 0x00730000
+#define DST_FORMAT_ABGR_0888 0x00740000
+
+#define LOP_CLEAR 0x00000000
+#define LOP_NOR 0x01000000
+#define LOP_AND_INVERTED 0x02000000
+#define LOP_COPY_INVERTED 0x03000000
+#define LOP_AND_REVERSE 0x04000000
+#define LOP_INVERT 0x05000000
+#define LOP_XOR 0x06000000
+#define LOP_NAND 0x07000000
+#define LOP_AND 0x08000000
+#define LOP_EQUIV 0x09000000
+#define LOP_NOOP 0x0a000000
+#define LOP_OR_INVERTED 0x0b000000
+#define LOP_COPY 0x0c000000
+#define LOP_OR_REVERSE 0x0d000000
+#define LOP_OR 0x0e000000
+#define LOP_SET 0x0f000000
+
+/*
+ * REG_3D_DstAlphaWriteMask -- Define Destination/Alpha Buffer Write Mask (8A24h-8A27h)
+ */
+#define MASK_ColorWriteMask 0x00FFFFFF
+#define MASK_AlphaWriteMask 0xFF000000
+
+/*
+ * REG_3D_DstAddress -- Define Destination Buffer Base Address(8A1Ch-8A1Fh)
+ */
+#define MASK_DstAddress 0xFFFFFFFF
+
+/*
+ * REG_3D_LinePattern -- Define Line Pattern (8A2Ch-8A2Fh)
+ */
+#define MASK_LinePatternRepeatFactor 0x00007FFF
+#define MASK_LinePatternLastPixelFlag 0x00008000
+#define MASK_LinePattern 0xFFFF0000
+
+/*
+ * REG_3D_FogSet -- Define Fog Mask (8A30h-8A33h)
+ */
+#define MASK_FogColor 0x00FFFFFF
+#define MASK_FogMode 0x07000000
+#define MASK_FogZLookup 0x08000000
+
+#define FOGMODE_CHEAP 0x04000000
+#define FOGMODE_LINEAR 0x05000000
+#define FOGMODE_EXP 0x06000000
+#define FOGMODE_EXP2 0x07000000
+
+/*
+ * REG_3D_FogStartEnd -- Define Fog Start End Setting (0x8A34 - 0x8A37)
+ */
+#define MASK_FogFarDistance 0x0007FFFF
+
+/*
+ * REG_3D_FogStartEnd -- Define Fog End Setting (0x8A38 - 0x8A3B)
+ */
+#define MASK_FogInvFarDistance 0x0007FFFF
+
+/*
+ * REG_3D_FogFactorDensity (0x8A3C - 0x8A3F)
+ */
+#define MASK_FogDensity 0x0003FFFF
+#define MASK_FogFactor 0xFF000000
+
+/*
+ * REG_3D_StencilSet -- Define stencil test (8A44h-8A47h)
+ */
+#define MASK_StencilValueMask 0x000000ff
+#define MASK_StencilRefMask 0x0000ff00
+#define MASK_StencilTestMode 0x07000000
+#define MASK_StencilBufferInSystem 0x08000000
+#define MASK_StencilFormat 0x30000000
+
+#define SiS_STENCIL_NEVER 0x00000000
+#define SiS_STENCIL_LESS 0x01000000
+#define SiS_STENCIL_EQUAL 0x02000000
+#define SiS_STENCIL_LEQUAL 0x03000000
+#define SiS_STENCIL_GREATER 0x04000000
+#define SiS_STENCIL_NOTEQUAL 0x05000000
+#define SiS_STENCIL_GEQUAL 0x06000000
+#define SiS_STENCIL_ALWAYS 0x07000000
+
+#define STENCIL_FORMAT_1 0x00000000
+#define STENCIL_FORMAT_2 0x10000000
+#define STENCIL_FORMAT_4 0x20000000
+#define STENCIL_FORMAT_8 0x30000000
+
+/*
+ * REG_3D_StencilSet2 -- Define stencil test (8A4h-8A47h)
+ */
+#define MASK_StencilBufferPitch 0x00000FFF
+#define MASK_StencilZPassOp 0x00007000
+#define MASK_StencilZFailOp 0x00070000
+#define MASK_StencilFailOp 0x00700000
+#define MASK_StencilWriteMask 0xFF000000
+
+#define SiS_SFAIL_KEEP 0x00000000
+#define SiS_SFAIL_ZERO 0x00100000
+#define SiS_SFAIL_REPLACE 0x00200000
+#define SiS_SFAIL_INVERT 0x00500000
+#define SiS_SFAIL_INCR 0x00600000
+#define SiS_SFAIL_DECR 0x00700000
+
+#define SiS_SPASS_ZFAIL_KEEP 0x00000000
+#define SiS_SPASS_ZFAIL_ZERO 0x00010000
+#define SiS_SPASS_ZFAIL_REPLACE 0x00020000
+#define SiS_SPASS_ZFAIL_INVERT 0x00050000
+#define SiS_SPASS_ZFAIL_INCR 0x00060000
+#define SiS_SPASS_ZFAIL_DECR 0x00070000
+
+#define SiS_SPASS_ZPASS_KEEP 0x00000000
+#define SiS_SPASS_ZPASS_ZERO 0x00001000
+#define SiS_SPASS_ZPASS_REPLACE 0x00002000
+#define SiS_SPASS_ZPASS_INVERT 0x00005000
+#define SiS_SPASS_ZPASS_INCR 0x00006000
+#define SiS_SPASS_ZPASS_DECR 0x00007000
+
+/*
+ * REG_3D_DstBlendMode (0x8A50 - 0x8A53)
+ */
+#define MASK_SrcBlendMode 0x0000000F
+#define MASK_DstBlendMode 0x000000F0
+
+#define SiS_D_ZERO 0x00000000
+#define SiS_D_ONE 0x00000010
+#define SiS_D_SRC_COLOR 0x00000020
+#define SiS_D_ONE_MINUS_SRC_COLOR 0x00000030
+#define SiS_D_SRC_ALPHA 0x00000040
+#define SiS_D_ONE_MINUS_SRC_ALPHA 0x00000050
+#define SiS_D_DST_ALPHA 0x00000060
+#define SiS_D_ONE_MINUS_DST_ALPHA 0x00000070
+#define SiS_D_DST_COLOR 0x00000080
+#define SiS_D_ONE_MINUS_DST_COLOR 0x00000090
+#define SiS_D_SRC_ALPHA_SAT 0x000000a0
+
+#define SiS_S_ZERO 0x00000000
+#define SiS_S_ONE 0x00000001
+#define SiS_S_SRC_COLOR 0x00000002
+#define SiS_S_ONE_MINUS_SRC_COLOR 0x00000003
+#define SiS_S_SRC_ALPHA 0x00000004
+#define SiS_S_ONE_MINUS_SRC_ALPHA 0x00000005
+#define SiS_S_DST_ALPHA 0x00000006
+#define SiS_S_ONE_MINUS_DST_ALPHA 0x00000007
+#define SiS_S_DST_COLOR 0x00000008
+#define SiS_S_ONE_MINUS_DST_COLOR 0x00000009
+#define SiS_S_SRC_ALPHA_SATURATE 0x0000000a
+#define SiS_S_BOTH_SRC_ALPHA 0x0000000b
+#define SiS_S_BOTH_ONE_MINUS_SRC_ALPHA 0x0000000c
+
+/*
+ * REG_3D_DstBlendMode (0x8A54 - 0x8A57)
+ */
+#define MASK_BottomClip 0x00001FFF
+#define MASK_TopClip 0x03FFE000
+
+/*
+ * REG_3D_DstBlendMode (0x8A58 - 0x8A5B)
+ */
+#define MASK_RightClip 0x00001FFF
+#define MASK_LeftClip 0x03FFE000
+
+/*
+ * REG_3D_TextureSet (0x8A7C - 0x8A7F)
+ * REG_3D_Texture1Set (0x8ADC - 0x8ADF)
+ */
+#define MASK_TextureHeight 0x0000000F
+#define MASK_TextureWidth 0x000000F0
+#define MASK_TextureLevel 0x00000F00
+#define MASK_TextureSignYUVFormat 0x00001000
+#define MASK_TextureMappingMode 0x00FF0000
+#define MASK_TextureWrapU 0x00010000
+#define MASK_TextureWrapV 0x00020000
+#define MASK_TextureMirrorU 0x00040000
+#define MASK_TextureMirrorV 0x00080000
+#define MASK_TextureClampU 0x00100000
+#define MASK_TextureClampV 0x00200000
+#define MASK_TextureBorderU 0x00400000
+#define MASK_TextureBorderV 0x00800000
+#define MASK_TextureFormat 0xFF000000
+#define MASK_TextureBitDepth 0x70000000
+#define MASK_TextureRgbOrder 0x80000000
+
+#define TEXEL_INDEX1 0x00000000
+#define TEXEL_INDEX2 0x01000000
+#define TEXEL_INDEX4 0x02000000
+#define TEXEL_INDEX8 0x03000000
+
+#define TEXEL_INDEX1WithAlpha 0x04000000
+#define TEXEL_INDEX2WithAlpha 0x05000000
+#define TEXEL_INDEX4WithAlpha 0x06000000
+#define TEXEL_INDEX8WithAlpha 0x07000000
+
+#define TEXEL_I1 0x10000000
+#define TEXEL_I2 0x11000000
+#define TEXEL_I4 0x12000000
+#define TEXEL_I8 0x13000000
+
+#define TEXEL_DXT1 0x19000000
+#define TEXEL_DXT2 0x1A000000
+#define TEXEL_DXT3 0x1B000000
+
+#define TEXEL_YUV422 0x20000000
+#define TEXEL_YVU422 0x21000000
+#define TEXEL_UVY422 0x22000000
+#define TEXEL_VUY422 0x23000000
+#define TEXEL_YUV411 0x24000000
+
+#define TEXEL_L1 0x30000000
+#define TEXEL_L2 0x31000000
+#define TEXEL_L4 0x32000000
+#define TEXEL_L8 0x33000000
+
+#define TEXEL_AL11 0x34000000
+#define TEXEL_AL44 0x35000000
+#define TEXEL_AL26 0x37000000
+#define TEXEL_AL88 0x38000000
+
+#define TEXEL_A1 0x40000000
+#define TEXEL_A2 0x41000000
+#define TEXEL_A4 0x42000000
+#define TEXEL_A8 0x43000000
+
+#define TEXEL_RGB_332_8 0x50000000
+#define TEXEL_RGB_233_8 0x51000000
+#define TEXEL_RGB_232_8 0x52000000
+#define TEXEL_ARGB_1232_8 0x53000000
+#define TEXEL_ARGB_2222_8 0x54000000
+
+#define TEXEL_RGB_555_16 0x60000000
+#define TEXEL_RGB_565_16 0x61000000
+#define TEXEL_ARGB_1555_16 0x62000000
+#define TEXEL_ARGB_4444_16 0x63000000
+
+#define TEXEL_ARGB_1888_32 0x70000000
+#define TEXEL_ARGB_2888_32 0x71000000
+#define TEXEL_ARGB_4888_32 0x72000000
+#define TEXEL_ARGB_8888_32 0x73000000
+#define TEXEL_ARGB_0888_32 0x74000000
+
+#define TEXEL_BGR_332_8 0xD0000000
+#define TEXEL_BGR_233_8 0xD1000000
+#define TEXEL_BGR_232_8 0xD2000000
+#define TEXEL_ABGR_1232_8 0xD3000000
+#define TEXEL_ABGR_2222_8 0xD4000000
+
+#define TEXEL_BGR_555_16 0xE0000000
+#define TEXEL_BGR_565_16 0xE1000000
+#define TEXEL_ABGR_1555_16 0xE2000000
+#define TEXEL_ABGR_4444_16 0xE3000000
+
+#define TEXEL_ABGR_1888_32 0xF0000000
+#define TEXEL_ABGR_2888_32 0xF1000000
+#define TEXEL_ABGR_4888_32 0xF2000000
+#define TEXEL_ABGR_8888_32 0xF3000000
+#define TEXEL_ABGR_0888_32 0xF4000000
+
+#define TEXEL_VU88 0x00000000
+#define TEXEL_LVU655 0x00800000
+#define TEXEL_LVU888 0x01000000
+#define TEXEL_UV88 0x02000000
+#define TEXEL_LUV655 0x02800000
+#define TEXEL_LUV888 0x03000000
+
+/*
+ * REG_3D_TextureMip (0x8A80 - 0x8A83)
+ * REG_3D_Texture1Mip (0x8AE0 - 0x8AE3)
+ */
+#define MASK_TextureAnisotropyRatio 0x0000000F
+#define MASK_TextureMipmapLodBias 0x00003FF0
+#define MASK_TextureFilterMin 0x0001C000
+#define MASK_TextureFilterMag 0x00020000
+#define MASK_TextureFilter 0x0003C000
+#define MASK_TextureLevelInSystem 0x3FFC0000
+#define MASK_TextureLevel0InSystem 0x00040000
+#define MASK_TextureBlockLength 0xF0000000
+
+#define TEXTURE_FILTER_NEAREST 0x00000000
+#define TEXTURE_FILTER_LINEAR 0x00004000
+#define TEXTURE_FILTER_NEAREST_MIP_NEAREST 0x00008000
+#define TEXTURE_FILTER_NEAREST_MIP_LINEAR 0x00010000
+#define TEXTURE_FILTER_LINEAR_MIP_NEAREST 0x0000c000
+#define TEXTURE_FILTER_LINEAR_MIP_LINEAR 0x00014000
+
+/*
+ * REG_3D_TextureTransparencyColorHigh (0x8A84 - 0x8A87)
+ * REG_3D_Texture1TransparencyColorHigh (0x8AE4 - 0x8AE7)
+ */
+#define MASK_TextureTransparencyColorHighB 0x000000FF
+#define MASK_TextureTransparencyColorHighG 0x0000FF00
+#define MASK_TextureTransparencyColorHighR 0x00FF0000
+#define MASK_TextureAlphaTransparencyMode 0x08000000
+
+/*
+ * REG_3D_TextureTransparencyColorLow (0x8A88 - 0x8A8B)
+ * REG_3D_Texture1TransparencyColorLow (0x8AE8 - 0x8AEB)
+ */
+#define MASK_TextureTransparencyColorLowB 0x000000FF
+#define MASK_TextureTransparencyColorLowG 0x0000FF00
+#define MASK_TextureTransparencyColorLowR 0x00FF0000
+#define MASK_TextureBlockHeight 0x07000000
+#define MASK_TextureBlockWidth 0x70000000
+
+/*
+ * REG_3D_TextureTransparencyColorLow (0x8A8C - 0x8A8F)
+ * REG_3D_Texture1TransparencyColorLow (0x8AEC - 0x8AEF)
+ */
+#define MASK_TextureBorderColorB 0x000000FF
+#define MASK_TextureBorderColorG 0x0000FF00
+#define MASK_TextureBorderColorR 0x00FF0000
+#define MASK_TextureBorderColorA 0xFF000000
+
+/*
+ * REG_3D_TexturePitch0-10 (0x8AC0 - 0x8AD7)
+ * REG_3D_Texture1Pitch0-10 (0x8B20 - 0x8B37)
+ */
+#define MASK_TexturePitchOdd 0x000003FF
+#define MASK_TexturePitchEven 0x03FF0000
+#define SHIFT_TexturePitchEven 16
+
+/*
+ * REG_3D_TextureColorBlendSet0 (0x8B40 - 0x8B43)
+ * REG_3D_TextureColorBlendSet1 (0x8B44 - 0x8B46)
+ * REG_3D_TextureAlphaBlendSet0 (0x8B40 - 0x8B43)
+ * REG_3D_TextureAlphaBlendSet1 (0x8B44 - 0x8B46)
+ */
+#define STAGE0_C_CF 0xa1485000
+#define STAGE0_C_CS 0xc1485000
+#define STAGE0_C_CFCS 0xa1705000
+#define STAGE0_C_CFOMAS_CSAS 0xc534c001
+#define STAGE0_C_CFOMCS_CCCS 0x4530c001
+
+#define STAGE0_A_AF 0x63230000
+#define STAGE0_A_AS 0xc3230000
+#define STAGE0_A_AFAS 0x63c30000
+#define STAGE0_A_AFOMAS_ACAS 0x46c60001
+
+#define STAGE1_C_CF 0xa1485000
+#define STAGE1_C_CS 0xe1485000
+#define STAGE1_C_CFCS 0xa1785000
+#define STAGE1_C_CFOMAS_CSAS 0xe5394001
+#define STAGE1_C_CFOMCS_CCCS 0x45394001
+
+#define STAGE1_A_AF 0xa3230000
+#define STAGE1_A_AS 0xe3230000
+#define STAGE1_A_AFAS 0xa3e30000
+#define STAGE1_A_AFOMAS_ACAS 0x4aea0001
+
+/* What registers are these associated with? */
+#define MASK_BMMemoryInSystem 0x00000080
+#define MASK_BMHeight 0x00000F00
+#define MASK_BMWidth 0x0000F000
+#define MASK_BMFilter 0x00010000
+#define MASK_BMMappingMode 0x007E0000
+#define MASK_BMFormat 0x07800000
+#define MASK_BMTxBumpmap 0x08000000
+
+#define MASK_BMAddress 0xFFFFFFFC
+
+#define MASK_BMOffset 0xFF800000
+#define MASK_BMScale 0x007FE000
+#define MASK_BMPitch 0x00001FFF
+
+#define MASK_BMMatrix00 0x000007FF
+#define MASK_BMMatrix01 0x07FF0000
+#define MASK_BMMatrix10 0x000007FF
+#define MASK_BMMatrix11 0x07FF0000
+
+#define MASK_TextureRealInSystem 0x00000001
+#define MASK_TextureDowngrade 0x00000002
+
+#define ALPHA_BUFFER_FORMAT_1 0x00000000
+#define ALPHA_BUFFER_FORMAT_2 0x10000000
+#define ALPHA_BUFFER_FORMAT_4 0x20000000
+#define ALPHA_BUFFER_FORMAT_8 0x30000000
+
+#endif
diff --git a/xorg-server/hw/kdrive/sis300/sis_stub.c b/xorg-server/hw/kdrive/sis300/sis_stub.c
new file mode 100644
index 000000000..bce7d02d2
--- /dev/null
+++ b/xorg-server/hw/kdrive/sis300/sis_stub.c
@@ -0,0 +1,77 @@
+/*
+ * Copyright © 2003 Eric Anholt
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Eric Anholt not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Eric Anholt makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "sis.h"
+#include "klinux.h"
+
+extern struct pci_id_entry sis_pci_ids[];
+
+void
+InitCard(char *name)
+{
+ struct pci_id_entry *id;
+ KdCardAttr attr;
+
+ for (id = sis_pci_ids; id->name != NULL; id++) {
+ int j = 0;
+ while (LinuxFindPci(id->vendor, id->device, j++, &attr))
+ KdCardInfoAdd(&SiSFuncs, &attr, 0);
+ }
+}
+
+void
+InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput(pScreenInfo, argc, argv);
+}
+
+void
+InitInput(int argc, char **argv)
+{
+ KdOsAddInputDrivers();
+ KdInitInput();
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+#ifdef KDRIVEVESA
+ vesaUseMsg();
+#endif
+}
+
+int
+ddxProcessArgument(int argc, char **argv, int i)
+{
+ int ret;
+
+#ifdef KDRIVEVESA
+ if (!(ret = vesaProcessArgument (argc, argv, i)))
+#endif
+ ret = KdProcessArgument(argc, argv, i);
+
+ return ret;
+}
diff --git a/xorg-server/hw/kdrive/smi/Makefile.am b/xorg-server/hw/kdrive/smi/Makefile.am
new file mode 100644
index 000000000..bd7077c56
--- /dev/null
+++ b/xorg-server/hw/kdrive/smi/Makefile.am
@@ -0,0 +1,41 @@
+INCLUDES = \
+ -I$(top_srcdir)/hw/kdrive/fbdev \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+bin_PROGRAMS = Xsmi
+
+noinst_LIBRARIES = libsmi.a
+
+# smivideo.c # not ready yet
+
+libsmi_a_SOURCES = \
+ smi.c \
+ smi.h \
+ smidraw.c \
+ smidraw.h
+
+Xsmi_SOURCES = \
+ smistub.c
+
+SMI_LIBS = \
+ libsmi.a \
+ $(top_builddir)/hw/kdrive/fbdev/libfbdev.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a \
+ @KDRIVE_LIBS@
+
+if GLX
+Xsmi_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
+Xsmi_LDADD = \
+ $(SMI_LIBS) \
+ @KDRIVE_LIBS@
+
+Xsmi_DEPENDENCIES = \
+ libsmi.a \
+ @KDRIVE_LOCAL_LIBS@
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/smi/Makefile.in b/xorg-server/hw/kdrive/smi/Makefile.in
new file mode 100644
index 000000000..843e245a4
--- /dev/null
+++ b/xorg-server/hw/kdrive/smi/Makefile.in
@@ -0,0 +1,723 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xsmi$(EXEEXT)
+subdir = hw/kdrive/smi
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libsmi_a_AR = $(AR) $(ARFLAGS)
+libsmi_a_LIBADD =
+am_libsmi_a_OBJECTS = smi.$(OBJEXT) smidraw.$(OBJEXT)
+libsmi_a_OBJECTS = $(am_libsmi_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xsmi_OBJECTS = smistub.$(OBJEXT)
+Xsmi_OBJECTS = $(am_Xsmi_OBJECTS)
+am__DEPENDENCIES_1 = libsmi.a \
+ $(top_builddir)/hw/kdrive/fbdev/libfbdev.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a
+Xsmi_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xsmi_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libsmi_a_SOURCES) $(Xsmi_SOURCES)
+DIST_SOURCES = $(libsmi_a_SOURCES) $(Xsmi_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ -I$(top_srcdir)/hw/kdrive/fbdev \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libsmi.a
+
+# smivideo.c # not ready yet
+libsmi_a_SOURCES = \
+ smi.c \
+ smi.h \
+ smidraw.c \
+ smidraw.h
+
+Xsmi_SOURCES = \
+ smistub.c
+
+SMI_LIBS = \
+ libsmi.a \
+ $(top_builddir)/hw/kdrive/fbdev/libfbdev.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a \
+ @KDRIVE_LIBS@
+
+@GLX_TRUE@Xsmi_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xsmi_LDADD = \
+ $(SMI_LIBS) \
+ @KDRIVE_LIBS@
+
+Xsmi_DEPENDENCIES = \
+ libsmi.a \
+ @KDRIVE_LOCAL_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/smi/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/smi/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libsmi.a: $(libsmi_a_OBJECTS) $(libsmi_a_DEPENDENCIES)
+ -rm -f libsmi.a
+ $(libsmi_a_AR) libsmi.a $(libsmi_a_OBJECTS) $(libsmi_a_LIBADD)
+ $(RANLIB) libsmi.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xsmi$(EXEEXT): $(Xsmi_OBJECTS) $(Xsmi_DEPENDENCIES)
+ @rm -f Xsmi$(EXEEXT)
+ $(Xsmi_LINK) $(Xsmi_OBJECTS) $(Xsmi_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/smi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/smidraw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/smistub.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/smi/smi.c b/xorg-server/hw/kdrive/smi/smi.c
new file mode 100644
index 000000000..7d4d725c7
--- /dev/null
+++ b/xorg-server/hw/kdrive/smi/smi.c
@@ -0,0 +1,343 @@
+/*
+ * Copyright © 2001 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "smi.h"
+#include "kaa.h"
+#include <sys/io.h>
+
+static Bool
+smiCardInit (KdCardInfo *card)
+{
+ SmiCardInfo *smic;
+
+ ENTER ();
+ smic = (SmiCardInfo *) xalloc (sizeof (SmiCardInfo));
+ if (!smic)
+ return FALSE;
+ memset (smic, '\0', sizeof (SmiCardInfo));
+
+ (void) smiMapReg (card, smic);
+
+ if (!subInitialize (card, &smic->sub))
+ {
+ xfree (smic);
+ return FALSE;
+ }
+
+ card->driver = smic;
+ LEAVE();
+ return TRUE;
+}
+
+static Bool
+smiScreenInit (KdScreenInfo *screen)
+{
+ SmiCardInfo *smic = screen->card->driver;
+ SmiScreenInfo *smis;
+
+ ENTER();
+ smis = (SmiScreenInfo *) xalloc (sizeof (SmiScreenInfo));
+ if (!smis)
+ return FALSE;
+ memset (smis, '\0', sizeof (SmiScreenInfo));
+ screen->driver = smis;
+ if (!subScreenInitialize (screen, &smis->sub))
+ {
+ xfree (smis);
+ return FALSE;
+ }
+ if (!smic->reg_base)
+ screen->dumb = TRUE;
+ screen->softCursor = TRUE;
+#if SMI_VESA
+ smis->screen = smis->sub.fb;
+#else
+ smis->screen = smic->sub.fb;
+#endif
+ LEAVE();
+ return TRUE;
+}
+
+static Bool
+smiInitScreen (ScreenPtr pScreen)
+{
+ Bool ret;
+ ENTER ();
+#if 0
+#ifdef XV
+ KdScreenPriv(pScreen);
+ SmiCardInfo *smic = pScreenPriv->screen->card->driver;
+ if (smic->media_reg && smic->reg)
+ smiInitVideo(pScreen);
+#endif
+#endif
+ ret = subInitScreen (pScreen);
+ LEAVE();
+ return ret;
+}
+
+#ifdef RANDR
+static Bool
+smiRandRSetConfig (ScreenPtr pScreen,
+ Rotation randr,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ Bool ret;
+
+ ENTER ();
+ kaaWaitSync (pScreen);
+
+ ret = subRandRSetConfig (pScreen, randr, rate, pSize);
+ LEAVE();
+ return ret;
+}
+
+static Bool
+smiRandRInit (ScreenPtr pScreen)
+{
+ rrScrPriv(pScreen);
+
+ ENTER ();
+ pScrPriv->rrSetConfig = smiRandRSetConfig;
+ LEAVE ();
+ return TRUE;
+}
+#endif
+
+static Bool
+smiFinishInitScreen (ScreenPtr pScreen)
+{
+ Bool ret;
+ ret = subFinishInitScreen (pScreen);
+#ifdef RANDR
+ smiRandRInit (pScreen);
+#endif
+ return ret;
+}
+
+void
+smiPreserve (KdCardInfo *card)
+{
+ ENTER ();
+ subPreserve(card);
+ LEAVE();
+}
+
+Bool
+smiMapReg (KdCardInfo *card, SmiCardInfo *smic)
+{
+ ENTER ();
+ smic->io_base = 0; /* only handles one SMI card at standard VGA address */
+ smic->reg_base = (CARD8 *) KdMapDevice (SMI_REG_BASE(card),
+ SMI_REG_SIZE(card));
+
+ if (!smic->reg_base)
+ {
+ smic->dpr = 0;
+ return FALSE;
+ }
+
+ KdSetMappedMode (SMI_REG_BASE(card),
+ SMI_REG_SIZE(card),
+ KD_MAPPED_MODE_REGISTERS);
+ smic->dpr = (DPR *) (smic->reg_base + SMI_DPR_OFF(card));
+ LEAVE ();
+ return TRUE;
+}
+
+void
+smiUnmapReg (KdCardInfo *card, SmiCardInfo *smic)
+{
+ ENTER ();
+ if (smic->reg_base)
+ {
+ KdResetMappedMode (SMI_REG_BASE(card),
+ SMI_REG_SIZE(card),
+ KD_MAPPED_MODE_REGISTERS);
+ KdUnmapDevice ((void *) smic->reg_base, SMI_REG_SIZE(card));
+ smic->reg_base = 0;
+ smic->dpr = 0;
+ }
+ LEAVE ();
+}
+
+void
+smiOutb (CARD16 port, CARD8 val)
+{
+ asm volatile ("outb %b0,%w1" : : "a" (val), "d" (port));
+}
+
+CARD8
+smiInb (CARD16 port)
+{
+ CARD8 v;
+ asm volatile ("inb %w1,%b0" : "=a" (v) : "d" (port));
+ return v;
+}
+
+CARD8
+smiGetIndex (SmiCardInfo *smic, CARD16 addr, CARD16 data, CARD8 id)
+{
+ smiOutb (smic->io_base + addr, id);
+ return smiInb (smic->io_base + data);
+}
+
+void
+smiSetIndex (SmiCardInfo *smic, CARD16 addr, CARD16 data, CARD8 id, CARD8 val)
+{
+ smiOutb (smic->io_base + addr, id);
+ smiOutb (smic->io_base + data, val);
+}
+
+void
+smiSetMMIO (KdCardInfo *card, SmiCardInfo *smic)
+{
+ ENTER ();
+ if (!smic->reg_base)
+ smiMapReg (card, smic);
+ LEAVE();
+}
+
+void
+smiResetMMIO (KdCardInfo *card, SmiCardInfo *smic)
+{
+ smiUnmapReg (card, smic);
+}
+
+static Bool
+smiDPMS (ScreenPtr pScreen, int mode)
+{
+ Bool ret;
+ ENTER ();
+ ret = subDPMS (pScreen, mode);
+ LEAVE ();
+ return ret;
+}
+
+Bool
+smiEnable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ SmiCardInfo *smic = pScreenPriv->card->driver;
+
+ ENTER ();
+ iopl (3);
+ if (!subEnable (pScreen))
+ return FALSE;
+
+ smiSetMMIO (pScreenPriv->card, smic);
+ smiDPMS (pScreen, KD_DPMS_NORMAL);
+#if 0
+#ifdef XV
+ KdXVEnable (pScreen);
+#endif
+#endif
+ LEAVE ();
+ return TRUE;
+}
+
+void
+smiDisable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ SmiCardInfo *smic = pScreenPriv->card->driver;
+
+ ENTER ();
+#if 0
+#ifdef XV
+ KdXVDisable (pScreen);
+#endif
+#endif
+ smiResetMMIO (pScreenPriv->card, smic);
+ subDisable (pScreen);
+ LEAVE ();
+}
+
+static void
+smiRestore (KdCardInfo *card)
+{
+ ENTER ();
+ subRestore (card);
+ LEAVE();
+}
+
+static void
+smiScreenFini (KdScreenInfo *screen)
+{
+ SmiScreenInfo *smis = (SmiScreenInfo *) screen->driver;
+
+ ENTER ();
+ subScreenFini (screen);
+ xfree (smis);
+ screen->driver = 0;
+ LEAVE ();
+}
+
+static void
+smiCardFini (KdCardInfo *card)
+{
+ SmiCardInfo *smic = card->driver;
+
+ ENTER ();
+ smiUnmapReg (card, smic);
+ subCardFini (card);
+ LEAVE ();
+}
+
+#define smiCursorInit 0 /* initCursor */
+#define smiCursorEnable 0 /* enableCursor */
+#define smiCursorDisable 0 /* disableCursor */
+#define smiCursorFini 0 /* finiCursor */
+#define smiRecolorCursor 0 /* recolorCursor */
+
+KdCardFuncs smiFuncs = {
+ smiCardInit, /* cardinit */
+ smiScreenInit, /* scrinit */
+ smiInitScreen, /* initScreen */
+ smiFinishInitScreen, /* finishInitScreen */
+ subCreateResources, /* createRes */
+ smiPreserve, /* preserve */
+ smiEnable, /* enable */
+ smiDPMS, /* dpms */
+ smiDisable, /* disable */
+ smiRestore, /* restore */
+ smiScreenFini, /* scrfini */
+ smiCardFini, /* cardfini */
+
+ smiCursorInit, /* initCursor */
+ smiCursorEnable, /* enableCursor */
+ smiCursorDisable, /* disableCursor */
+ smiCursorFini, /* finiCursor */
+ smiRecolorCursor, /* recolorCursor */
+
+ smiDrawInit, /* initAccel */
+ smiDrawEnable, /* enableAccel */
+ smiDrawDisable, /* disableAccel */
+ smiDrawFini, /* finiAccel */
+
+ subGetColors, /* getColors */
+ subPutColors, /* putColors */
+};
diff --git a/xorg-server/hw/kdrive/smi/smi.h b/xorg-server/hw/kdrive/smi/smi.h
new file mode 100644
index 000000000..ef0fd110a
--- /dev/null
+++ b/xorg-server/hw/kdrive/smi/smi.h
@@ -0,0 +1,257 @@
+/*
+ * Copyright © 2001 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _SMI_H_
+#define _SMI_H_
+
+#define SMI_VESA 0
+
+#if SMI_VESA
+#include <vesa.h>
+#define subGetColors vesaGetColors
+#define subPutColors vesaPutColors
+#define subInitialize vesaInitialize
+#define subScreenInitialize vesaScreenInitialize
+#define subInitScreen vesaInitScreen
+#define subFinishInitScreen vesaFinishInitScreen
+#define subCreateResources vesaCreateResources
+#define subRandRSetConfig vesaRandRSetConfig
+#define subPreserve vesaPreserve
+#define subEnable vesaEnable
+#define subDPMS vesaDPMS
+#define subRestore vesaRestore
+#define subScreenFini vesaScreenFini
+#define subCardFini vesaCardFini
+#define subDisable vesaDisable
+#define SubCardPrivRec VesaCardPrivRec
+#define SubScreenPrivRec VesaScreenPrivRec
+#define subUseMsg() vesaUseMsg()
+#define subProcessArgument(c,v,i) vesaProcessArgument(c,v,i)
+#else
+#include <fbdev.h>
+#define subGetColors fbdevGetColors
+#define subPutColors fbdevPutColors
+#define subInitialize fbdevInitialize
+#define subScreenInitialize fbdevScreenInitialize
+#define subInitScreen fbdevInitScreen
+#define subFinishInitScreen fbdevFinishInitScreen
+#define subCreateResources fbdevCreateResources
+#define subRandRSetConfig fbdevRandRSetConfig
+#define subPreserve fbdevPreserve
+#define subEnable fbdevEnable
+#define subDPMS fbdevDPMS
+#define subRestore fbdevRestore
+#define subScreenFini fbdevScreenFini
+#define subCardFini fbdevCardFini
+#define subDisable fbdevDisable
+#define SubCardPrivRec FbdevPriv
+#define SubScreenPrivRec FbdevScrPriv
+#define subUseMsg()
+#define subProcessArgument(c,v,i) 0
+#endif
+
+#include "kxv.h"
+
+#define SMI_DEBUG 0
+#if SMI_DEBUG
+#define DBGOUT(fmt,a...) fprintf (stderr, fmt, ##a)
+#else
+#define DBGOUT(fmt,a...)
+#endif
+
+#define ENTER() DBGOUT("Enter %s\n", __FUNCTION__)
+#define LEAVE() DBGOUT("Leave %s\n", __FUNCTION__)
+
+/*
+ * offset from ioport beginning
+ */
+
+#define SMI_IO_BASE(c) ((c)->attr.io)
+#define SMI_REG_BASE(c) ((c)->attr.address[0])
+#define SMI_REG_SIZE(c) (4096)
+
+#define SMI_DPR_OFF(c) (0x00000)
+
+typedef volatile CARD8 VOL8;
+typedef volatile CARD16 VOL16;
+typedef volatile CARD32 VOL32;
+
+/* DPR reg */
+typedef struct _DPR {
+ VOL32 src_xy; /* 0x00 */
+ VOL32 dst_xy; /* 0x04 */
+ VOL32 dst_wh; /* 0x08 */
+ VOL32 accel_cmd; /* 0x0c */
+ VOL32 src_stride; /* 0x10 */
+ VOL32 fg; /* 0x14 */
+ VOL32 bg; /* 0x18 */
+ VOL32 data_format; /* 0x1c */
+ VOL32 transparent; /* 0x20 */
+ VOL32 mask1; /* 0x24 ? */
+ VOL32 mask2; /* 0x28 ? */
+ VOL32 scissors_ul; /* 0x2c */
+ VOL32 scissors_lr; /* 0x30 */
+ VOL32 mask3; /* 0x34 */
+ VOL32 mask4; /* 0x38 */
+ VOL32 dst_stride; /* 0x3c */
+ VOL32 unknown_40; /* 0x40 */
+ VOL32 unknown_44; /* 0x44 */
+} DPR;
+
+#define SMI_XY(x,y) (((y) & 0x7fff) | (((x) & 0x7fff) << 16))
+
+/* 2D Engine commands */
+#define SMI_TRANSPARENT_SRC 0x00000100
+#define SMI_TRANSPARENT_DEST 0x00000300
+
+#define SMI_OPAQUE_PXL 0x00000000
+#define SMI_TRANSPARENT_PXL 0x00000400
+
+#define SMI_MONO_PACK_8 0x00001000
+#define SMI_MONO_PACK_16 0x00002000
+#define SMI_MONO_PACK_32 0x00003000
+
+#define SMI_ROP2_SRC 0x00008000
+#define SMI_ROP2_PAT 0x0000C000
+#define SMI_ROP3 0x00000000
+
+#define SMI_BITBLT 0x00000000
+#define SMI_RECT_FILL 0x00010000
+#define SMI_TRAPEZOID_FILL 0x00030000
+#define SMI_SHORT_STROKE 0x00060000
+#define SMI_BRESENHAM_LINE 0x00070000
+#define SMI_HOSTBLT_WRITE 0x00080000
+#define SMI_HOSTBLT_READ 0x00090000
+#define SMI_ROTATE_BLT 0x000B0000
+
+#define SMI_SRC_COLOR 0x00000000
+#define SMI_SRC_MONOCHROME 0x00400000
+
+#define SMI_GRAPHICS_STRETCH 0x00800000
+
+#define SMI_ROTATE_CW 0x01000000
+#define SMI_ROTATE_CCW 0x02000000
+
+#define SMI_MAJOR_X 0x00000000
+#define SMI_MAJOR_Y 0x04000000
+
+#define SMI_LEFT_TO_RIGHT 0x00000000
+#define SMI_RIGHT_TO_LEFT 0x08000000
+
+#define SMI_COLOR_PATTERN 0x40000000
+#define SMI_MONO_PATTERN 0x00000000
+
+#define SMI_QUICK_START 0x10000000
+#define SMI_START_ENGINE 0x80000000
+
+#define VGA_SEQ_INDEX 0x3C4
+#define VGA_SEQ_DATA 0x3C5
+
+typedef struct _smiCardInfo {
+ SubCardPrivRec sub;
+ CARD16 io_base;
+ CARD8 *reg_base;
+ DPR *dpr;
+ int avail;
+} SmiCardInfo;
+
+#define getSmiCardInfo(kd) ((SmiCardInfo *) ((kd)->card->driver))
+#define smiCardInfo(kd) SmiCardInfo *smic = getSmiCardInfo(kd)
+
+typedef struct _smiScreenInfo {
+ SubScreenPrivRec sub;
+ CARD8 *screen;
+ CARD32 stride;
+ CARD32 data_format;
+ CARD8 dpr_vpr_enable;
+ KaaScreenInfoRec kaa;
+} SmiScreenInfo;
+
+#define getSmiScreenInfo(kd) ((SmiScreenInfo *) ((kd)->screen->driver))
+#define smiScreenInfo(kd) SmiScreenInfo *smis = getSmiScreenInfo(kd)
+
+void
+smiPreserve (KdCardInfo *card);
+
+Bool
+smiMapReg (KdCardInfo *card, SmiCardInfo *smic);
+
+void
+smiUnmapReg (KdCardInfo *card, SmiCardInfo *smic);
+
+void
+smiOutb (CARD16 port, CARD8 val);
+
+CARD8
+smiInb (CARD16 port);
+
+CARD8
+smiGetIndex (SmiCardInfo *smic, CARD16 addr, CARD16 data, CARD8 id);
+
+void
+smiSetIndex (SmiCardInfo *smic, CARD16 addr, CARD16 data, CARD8 id, CARD8 val);
+
+void
+smiSetMMIO (KdCardInfo *card, SmiCardInfo *smic);
+
+void
+smiResetMMIO (KdCardInfo *card, SmiCardInfo *smic);
+
+Bool
+smiEnable (ScreenPtr pScreen);
+
+void
+smiDisable (ScreenPtr pScreen);
+
+void
+smiWaitAvail(SmiCardInfo *smic, int n);
+
+void
+smiWaitIdle (SmiCardInfo *smic);
+
+Bool
+smiDrawSetup (ScreenPtr pScreen);
+
+Bool
+smiDrawInit (ScreenPtr pScreen);
+
+void
+smiDrawReinit (ScreenPtr pScreen);
+
+void
+smiDrawEnable (ScreenPtr pScreen);
+
+void
+smiDrawDisable (ScreenPtr pScreen);
+
+void
+smiDrawFini (ScreenPtr pScreen);
+
+CARD8
+smiReadIndex (SmiCardInfo *smic, CARD16 port, CARD8 index);
+
+void
+smiWriteIndex (SmiCardInfo *smic, CARD16 port, CARD8 index, CARD8 value);
+
+extern KdCardFuncs smiFuncs;
+
+#endif /* _SMI_H_ */
diff --git a/xorg-server/hw/kdrive/smi/smidraw.c b/xorg-server/hw/kdrive/smi/smidraw.c
new file mode 100644
index 000000000..ba4e3904d
--- /dev/null
+++ b/xorg-server/hw/kdrive/smi/smidraw.c
@@ -0,0 +1,340 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "smi.h"
+#include "smidraw.h"
+
+#include <X11/Xmd.h>
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mistruct.h"
+#include "dixfontstr.h"
+#include "fb.h"
+#include "migc.h"
+#include "miline.h"
+#include "picturestr.h"
+#include "kaa.h"
+
+CARD8 smiBltRop[16] = {
+ /* GXclear */ 0x00, /* 0 */
+ /* GXand */ 0x88, /* src AND dst */
+ /* GXandReverse */ 0x44, /* src AND NOT dst */
+ /* GXcopy */ 0xcc, /* src */
+ /* GXandInverted*/ 0x22, /* NOT src AND dst */
+ /* GXnoop */ 0xaa, /* dst */
+ /* GXxor */ 0x66, /* src XOR dst */
+ /* GXor */ 0xee, /* src OR dst */
+ /* GXnor */ 0x11, /* NOT src AND NOT dst */
+ /* GXequiv */ 0x99, /* NOT src XOR dst */
+ /* GXinvert */ 0x55, /* NOT dst */
+ /* GXorReverse */ 0xdd, /* src OR NOT dst */
+ /* GXcopyInverted*/ 0x33, /* NOT src */
+ /* GXorInverted */ 0xbb, /* NOT src OR dst */
+ /* GXnand */ 0x77, /* NOT src OR NOT dst */
+ /* GXset */ 0xff, /* 1 */
+};
+
+CARD8 smiSolidRop[16] = {
+ /* GXclear */ 0x00, /* 0 */
+ /* GXand */ 0xa0, /* src AND dst */
+ /* GXandReverse */ 0x50, /* src AND NOT dst */
+ /* GXcopy */ 0xf0, /* src */
+ /* GXandInverted*/ 0x0a, /* NOT src AND dst */
+ /* GXnoop */ 0xaa, /* dst */
+ /* GXxor */ 0x5a, /* src XOR dst */
+ /* GXor */ 0xfa, /* src OR dst */
+ /* GXnor */ 0x05, /* NOT src AND NOT dst */
+ /* GXequiv */ 0xa5, /* NOT src XOR dst */
+ /* GXinvert */ 0x55, /* NOT dst */
+ /* GXorReverse */ 0xf5, /* src OR NOT dst */
+ /* GXcopyInverted*/ 0x0f, /* NOT src */
+ /* GXorInverted */ 0xaf, /* NOT src OR dst */
+ /* GXnand */ 0x5f, /* NOT src OR NOT dst */
+ /* GXset */ 0xff, /* 1 */
+};
+
+
+#define GET_STATUS(smic) smiGetIndex (smic, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x16)
+
+#define ENGINE_IDLE_EMPTY(smic) ((GET_STATUS(smic) & 0x18) == 0x10)
+#define FIFO_EMPTY(smic) ((GET_STATUS(smic) & 0x10) == 0x10)
+
+#define MAX_FIFO 16
+
+void
+smiWaitAvail(SmiCardInfo *smic, int n)
+{
+ if (smic->avail < n)
+ {
+ while (!FIFO_EMPTY (smic))
+ ;
+ smic->avail = MAX_FIFO;
+ }
+ smic->avail -= n;
+}
+
+void
+smiWaitIdle (SmiCardInfo *smic)
+{
+ while (!ENGINE_IDLE_EMPTY (smic))
+ ;
+ smic->avail = MAX_FIFO;
+}
+
+static SmiCardInfo *smic;
+static SmiScreenInfo *smis;
+static DPR *dpr;
+static CARD32 accel_cmd;
+
+static Bool
+smiSetup (ScreenPtr pScreen, int wait)
+{
+ KdScreenPriv(pScreen);
+
+ smis = getSmiScreenInfo (pScreenPriv);
+ smic = getSmiCardInfo(pScreenPriv);
+ dpr = smic->dpr;
+
+ if (!dpr)
+ return FALSE;
+
+ /* enable DPR/VPR registers */
+ smiSetIndex (smic, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21,
+ smis->dpr_vpr_enable);
+
+ smiWaitAvail (smic, wait + 9);
+ dpr->src_stride = (smis->stride << 16) | smis->stride;
+ dpr->data_format = smis->data_format;
+ dpr->mask1 = 0xffffffff;
+ dpr->mask2 = 0xffffffff;
+ dpr->dst_stride = (smis->stride << 16) | smis->stride;
+ dpr->unknown_40 = 0x0;
+ dpr->unknown_44 = 0x0;
+ dpr->scissors_ul = 0x0;
+ dpr->scissors_lr = SMI_XY(4095,4095);
+
+ return TRUE;
+}
+
+static void
+smiWaitMarker (ScreenPtr pScreen, int marker)
+{
+ KdScreenPriv(pScreen);
+ smic = getSmiCardInfo(pScreenPriv);
+
+ smiWaitIdle (smic);
+}
+
+static Bool
+smiPrepareSolid (PixmapPtr pPixmap,
+ int alu,
+ Pixel pm,
+ Pixel fg)
+{
+ if (~pm & FbFullMask(pPixmap->drawable.depth))
+ return FALSE;
+
+ if (!smiSetup (pPixmap->drawable.pScreen, 3))
+ return FALSE;
+
+ accel_cmd = smiSolidRop[alu] | SMI_BITBLT | SMI_START_ENGINE;
+ dpr->fg = fg;
+ dpr->mask3 = 0xffffffff;
+ dpr->mask4 = 0xffffffff;
+ return TRUE;
+}
+
+static void
+smiSolid (int x1, int y1, int x2, int y2)
+{
+ smiWaitAvail(smic,3);
+ dpr->dst_xy = SMI_XY(x1,y1);
+ dpr->dst_wh = SMI_XY(x2-x1,y2-y1);
+ dpr->accel_cmd = accel_cmd;
+}
+
+static void
+smiDoneSolid (void)
+{
+}
+
+static int copyDx;
+static int copyDy;
+
+static Bool
+smiPrepareCopy (PixmapPtr pSrcPixmap,
+ PixmapPtr pDstPixmap,
+ int dx,
+ int dy,
+ int alu,
+ Pixel pm)
+{
+ if (~pm & FbFullMask(pSrcPixmap->drawable.depth))
+ return FALSE;
+
+ if (!smiSetup (pSrcPixmap->drawable.pScreen, 0))
+ return FALSE;
+
+ accel_cmd = smiBltRop[alu] | SMI_BITBLT | SMI_START_ENGINE;
+
+ copyDx = dx;
+ copyDy = dy;
+ if (dy < 0 || (dy == 0 && dx < 0))
+ accel_cmd |= SMI_RIGHT_TO_LEFT;
+ return TRUE;
+}
+
+static void
+smiCopy (int srcX,
+ int srcY,
+ int dstX,
+ int dstY,
+ int w,
+ int h)
+{
+ if (accel_cmd & SMI_RIGHT_TO_LEFT)
+ {
+ srcX += w - 1;
+ dstX += w - 1;
+ srcY += h - 1;
+ dstY += h - 1;
+ }
+ smiWaitAvail (smic, 4);
+ dpr->src_xy = SMI_XY (srcX, srcY);
+ dpr->dst_xy = SMI_XY (dstX, dstY);
+ dpr->dst_wh = SMI_XY (w, h);
+ dpr->accel_cmd = accel_cmd;
+}
+
+static void
+smiDoneCopy (void)
+{
+}
+
+
+Bool
+smiDrawInit (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ smiCardInfo (pScreenPriv);
+
+ ENTER ();
+ if (pScreenPriv->screen->fb[0].depth == 4)
+ {
+ LEAVE ();
+ return FALSE;
+ }
+
+ if (!smic->dpr)
+ {
+ LEAVE ();
+ return FALSE;
+ }
+
+ memset(&smis->kaa, 0, sizeof(KaaScreenInfoRec));
+ smis->kaa.PrepareSolid = smiPrepareSolid;
+ smis->kaa.Solid = smiSolid;
+ smis->kaa.DoneSolid = smiDoneSolid;
+ smis->kaa.PrepareCopy = smiPrepareCopy;
+ smis->kaa.Copy = smiCopy;
+ smis->kaa.DoneCopy = smiDoneCopy;
+ smis->kaa.waitMarker = smiWaitMarker;
+
+ if (!kaaDrawInit (pScreen, &smis->kaa))
+ {
+ LEAVE ();
+ return FALSE;
+ }
+
+ LEAVE ();
+ return TRUE;
+}
+
+void
+smiDrawEnable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ int i;
+ static const int xyAddress[] = { 320, 400, 512, 640, 800, 1024, 1280, 1600, 2048 };
+
+ ENTER ();
+ smis = getSmiScreenInfo (pScreenPriv);
+ smic = getSmiCardInfo(pScreenPriv);
+ dpr = smic->dpr;
+
+ smis->stride = pScreenPriv->screen->fb[0].byteStride;
+ smis->dpr_vpr_enable = smiGetIndex (smic, VGA_SEQ_INDEX,
+ VGA_SEQ_DATA, 0x21) & ~0x03;
+
+ switch (pScreenPriv->screen->fb[0].depth) {
+ case 8:
+ smis->data_format = 0x00000000;
+ break;
+ case 15:
+ case 16:
+ smis->data_format = 0x00100000;
+ smis->stride >>= 1;
+ break;
+ case 24:
+ smis->data_format = 0x00300000;
+ break;
+ case 32:
+ smis->data_format = 0x00200000;
+ smis->stride >>= 2;
+ break;
+ }
+ for (i = 0; i < sizeof(xyAddress) / sizeof(xyAddress[0]); i++)
+ {
+ if (xyAddress[i] == pScreenPriv->screen->fb[0].pixelStride)
+ {
+ smis->data_format |= i << 16;
+ break;
+ }
+ }
+
+ smiSetup (pScreen, 0);
+ kaaMarkSync (pScreen);
+ LEAVE ();
+}
+
+void
+smiDrawDisable (ScreenPtr pScreen)
+{
+ ENTER ();
+ smic = 0;
+ smis = 0;
+ dpr = 0;
+ accel_cmd = 0;
+ LEAVE ();
+}
+
+void
+smiDrawFini (ScreenPtr pScreen)
+{
+ ENTER ();
+ LEAVE ();
+}
diff --git a/xorg-server/hw/kdrive/smi/smidraw.h b/xorg-server/hw/kdrive/smi/smidraw.h
new file mode 100644
index 000000000..4165c7406
--- /dev/null
+++ b/xorg-server/hw/kdrive/smi/smidraw.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _SMIDRAW_H_
+#define _SMIDRAW_H_
+
+#define SetupSmi(s) KdScreenPriv(s); \
+ smiCardInfo(pScreenPriv); \
+ Cop *cop = smic->cop
+
+#define SmiAlpha (COP_MULTI_ALPHA|COP_ALPHA_WRITE_ENABLE)
+
+#define _smiInit(cop,smic) { \
+ if ((cop)->status == 0xffffffff) smiSetMMIO(smic); \
+ (cop)->multi = (smic)->cop_depth; \
+ (cop)->multi = (smic)->cop_stride; \
+ (cop)->multi = SmiAlpha; \
+} \
+
+#define _smiSetSolidRect(cop,pix,alu,cmd) {\
+ cop->multi = COP_MULTI_PATTERN; \
+ cop->multi = COP_MULTI_ROP | smiRop[alu]; \
+ cop->fg = (pix); \
+ cmd = COP_OP_BLT | COP_SCL_OPAQUE | COP_OP_ROP | COP_OP_FG; \
+}
+
+#define _smiRect(cop,x1,y1,x2,y2,cmd) { \
+ (cop)->dst_start_xy = TRI_XY (x1,y1); \
+ (cop)->dst_end_xy = TRI_XY(x2,y2); \
+ _smiWaitDone(cop); \
+ (cop)->command = (cmd); \
+}
+
+#define COP_STATUS_BUSY (COP_STATUS_BE_BUSY | \
+ COP_STATUS_DPE_BUSY | \
+ COP_STATUS_MI_BUSY)
+
+#define _smiWaitDone(cop) { \
+ int __q__ = 500000; \
+ while (__q__-- && (cop)->status & COP_STATUS_BUSY) \
+ ; \
+ if (!__q__) \
+ (cop)->status = 0; \
+}
+
+#define _smiWaitIdleEmpty(cop) _smiWaitDone(cop)
+
+#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3))
+
+#endif
diff --git a/xorg-server/hw/kdrive/smi/smistub.c b/xorg-server/hw/kdrive/smi/smistub.c
new file mode 100644
index 000000000..59faf2839
--- /dev/null
+++ b/xorg-server/hw/kdrive/smi/smistub.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright 1999 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "smi.h"
+#include "klinux.h"
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+
+ if (LinuxFindPci (0x126f, 0x0720, 0, &attr))
+ KdCardInfoAdd (&smiFuncs, &attr, 0);
+}
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdOsAddInputDrivers ();
+ KdInitInput ();
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+ subUseMsg();
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ int ret;
+
+ if (!(ret = subProcessArgument (argc, argv, i)))
+ ret = KdProcessArgument(argc, argv, i);
+ return ret;
+}
diff --git a/xorg-server/hw/kdrive/src/Makefile.am b/xorg-server/hw/kdrive/src/Makefile.am
new file mode 100644
index 000000000..07ab8c859
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/Makefile.am
@@ -0,0 +1,40 @@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+AM_CFLAGS = -DHAVE_DIX_CONFIG_H
+
+noinst_LIBRARIES = libkdrive.a libkdrivestubs.a
+
+if KDRIVE_HW
+KDRIVE_HW_SOURCES = \
+ vga.c \
+ vga.h
+endif
+
+libkdrive_a_SOURCES = \
+ fourcc.h \
+ kaa.c \
+ kaa.h \
+ kaapict.c \
+ kasync.c \
+ kcmap.c \
+ kcurscol.c \
+ kdrive.c \
+ kdrive.h \
+ kinfo.c \
+ kinput.c \
+ kkeymap.c \
+ kmap.c \
+ kmode.c \
+ knoop.c \
+ koffscreen.c \
+ kshadow.c \
+ ktest.c \
+ kxv.c \
+ kxv.h \
+ $(KDRIVE_HW_SOURCES) \
+ $(top_srcdir)/mi/miinitext.c
+
+libkdrivestubs_a_SOURCES = \
+ $(top_srcdir)/fb/fbcmap_mi.c
diff --git a/xorg-server/hw/kdrive/src/Makefile.in b/xorg-server/hw/kdrive/src/Makefile.in
new file mode 100644
index 000000000..4938456a5
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/Makefile.in
@@ -0,0 +1,740 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = hw/kdrive/src
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libkdrive_a_AR = $(AR) $(ARFLAGS)
+libkdrive_a_LIBADD =
+am__libkdrive_a_SOURCES_DIST = fourcc.h kaa.c kaa.h kaapict.c kasync.c \
+ kcmap.c kcurscol.c kdrive.c kdrive.h kinfo.c kinput.c \
+ kkeymap.c kmap.c kmode.c knoop.c koffscreen.c kshadow.c \
+ ktest.c kxv.c kxv.h vga.c vga.h $(top_srcdir)/mi/miinitext.c
+@KDRIVE_HW_TRUE@am__objects_1 = vga.$(OBJEXT)
+am_libkdrive_a_OBJECTS = kaa.$(OBJEXT) kaapict.$(OBJEXT) \
+ kasync.$(OBJEXT) kcmap.$(OBJEXT) kcurscol.$(OBJEXT) \
+ kdrive.$(OBJEXT) kinfo.$(OBJEXT) kinput.$(OBJEXT) \
+ kkeymap.$(OBJEXT) kmap.$(OBJEXT) kmode.$(OBJEXT) \
+ knoop.$(OBJEXT) koffscreen.$(OBJEXT) kshadow.$(OBJEXT) \
+ ktest.$(OBJEXT) kxv.$(OBJEXT) $(am__objects_1) \
+ miinitext.$(OBJEXT)
+libkdrive_a_OBJECTS = $(am_libkdrive_a_OBJECTS)
+libkdrivestubs_a_AR = $(AR) $(ARFLAGS)
+libkdrivestubs_a_LIBADD =
+am_libkdrivestubs_a_OBJECTS = fbcmap_mi.$(OBJEXT)
+libkdrivestubs_a_OBJECTS = $(am_libkdrivestubs_a_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libkdrive_a_SOURCES) $(libkdrivestubs_a_SOURCES)
+DIST_SOURCES = $(am__libkdrive_a_SOURCES_DIST) \
+ $(libkdrivestubs_a_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+AM_CFLAGS = -DHAVE_DIX_CONFIG_H
+noinst_LIBRARIES = libkdrive.a libkdrivestubs.a
+@KDRIVE_HW_TRUE@KDRIVE_HW_SOURCES = \
+@KDRIVE_HW_TRUE@ vga.c \
+@KDRIVE_HW_TRUE@ vga.h
+
+libkdrive_a_SOURCES = \
+ fourcc.h \
+ kaa.c \
+ kaa.h \
+ kaapict.c \
+ kasync.c \
+ kcmap.c \
+ kcurscol.c \
+ kdrive.c \
+ kdrive.h \
+ kinfo.c \
+ kinput.c \
+ kkeymap.c \
+ kmap.c \
+ kmode.c \
+ knoop.c \
+ koffscreen.c \
+ kshadow.c \
+ ktest.c \
+ kxv.c \
+ kxv.h \
+ $(KDRIVE_HW_SOURCES) \
+ $(top_srcdir)/mi/miinitext.c
+
+libkdrivestubs_a_SOURCES = \
+ $(top_srcdir)/fb/fbcmap_mi.c
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/src/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/src/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libkdrive.a: $(libkdrive_a_OBJECTS) $(libkdrive_a_DEPENDENCIES)
+ -rm -f libkdrive.a
+ $(libkdrive_a_AR) libkdrive.a $(libkdrive_a_OBJECTS) $(libkdrive_a_LIBADD)
+ $(RANLIB) libkdrive.a
+libkdrivestubs.a: $(libkdrivestubs_a_OBJECTS) $(libkdrivestubs_a_DEPENDENCIES)
+ -rm -f libkdrivestubs.a
+ $(libkdrivestubs_a_AR) libkdrivestubs.a $(libkdrivestubs_a_OBJECTS) $(libkdrivestubs_a_LIBADD)
+ $(RANLIB) libkdrivestubs.a
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fbcmap_mi.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kaa.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kaapict.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kasync.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kcmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kcurscol.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kdrive.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kinfo.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kinput.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kkeymap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kmap.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kmode.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/knoop.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/koffscreen.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kshadow.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ktest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kxv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/miinitext.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vga.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+miinitext.o: $(top_srcdir)/mi/miinitext.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT miinitext.o -MD -MP -MF $(DEPDIR)/miinitext.Tpo -c -o miinitext.o `test -f '$(top_srcdir)/mi/miinitext.c' || echo '$(srcdir)/'`$(top_srcdir)/mi/miinitext.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/miinitext.Tpo $(DEPDIR)/miinitext.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/mi/miinitext.c' object='miinitext.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o miinitext.o `test -f '$(top_srcdir)/mi/miinitext.c' || echo '$(srcdir)/'`$(top_srcdir)/mi/miinitext.c
+
+miinitext.obj: $(top_srcdir)/mi/miinitext.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT miinitext.obj -MD -MP -MF $(DEPDIR)/miinitext.Tpo -c -o miinitext.obj `if test -f '$(top_srcdir)/mi/miinitext.c'; then $(CYGPATH_W) '$(top_srcdir)/mi/miinitext.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/mi/miinitext.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/miinitext.Tpo $(DEPDIR)/miinitext.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/mi/miinitext.c' object='miinitext.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o miinitext.obj `if test -f '$(top_srcdir)/mi/miinitext.c'; then $(CYGPATH_W) '$(top_srcdir)/mi/miinitext.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/mi/miinitext.c'; fi`
+
+fbcmap_mi.o: $(top_srcdir)/fb/fbcmap_mi.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT fbcmap_mi.o -MD -MP -MF $(DEPDIR)/fbcmap_mi.Tpo -c -o fbcmap_mi.o `test -f '$(top_srcdir)/fb/fbcmap_mi.c' || echo '$(srcdir)/'`$(top_srcdir)/fb/fbcmap_mi.c
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/fbcmap_mi.Tpo $(DEPDIR)/fbcmap_mi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/fb/fbcmap_mi.c' object='fbcmap_mi.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o fbcmap_mi.o `test -f '$(top_srcdir)/fb/fbcmap_mi.c' || echo '$(srcdir)/'`$(top_srcdir)/fb/fbcmap_mi.c
+
+fbcmap_mi.obj: $(top_srcdir)/fb/fbcmap_mi.c
+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT fbcmap_mi.obj -MD -MP -MF $(DEPDIR)/fbcmap_mi.Tpo -c -o fbcmap_mi.obj `if test -f '$(top_srcdir)/fb/fbcmap_mi.c'; then $(CYGPATH_W) '$(top_srcdir)/fb/fbcmap_mi.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/fb/fbcmap_mi.c'; fi`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/fbcmap_mi.Tpo $(DEPDIR)/fbcmap_mi.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(top_srcdir)/fb/fbcmap_mi.c' object='fbcmap_mi.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o fbcmap_mi.obj `if test -f '$(top_srcdir)/fb/fbcmap_mi.c'; then $(CYGPATH_W) '$(top_srcdir)/fb/fbcmap_mi.c'; else $(CYGPATH_W) '$(srcdir)/$(top_srcdir)/fb/fbcmap_mi.c'; fi`
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/src/fourcc.h b/xorg-server/hw/kdrive/src/fourcc.h
new file mode 100644
index 000000000..54be7ebe8
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/fourcc.h
@@ -0,0 +1,133 @@
+
+/*
+ This header file contains listings of STANDARD guids for video formats.
+ Please do not place non-registered, or incomplete entries in this file.
+ A list of some popular fourcc's are at: http://www.webartz.com/fourcc/
+ For an explanation of fourcc <-> guid mappings see RFC2361.
+*/
+
+#ifndef _XF86_FOURCC_H_
+#define _XF86_FOURCC_H_ 1
+
+#define FOURCC_YUY2 0x32595559
+#define XVIMAGE_YUY2 \
+ { \
+ FOURCC_YUY2, \
+ XvYUV, \
+ LSBFirst, \
+ {'Y','U','Y','2', \
+ 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 16, \
+ XvPacked, \
+ 1, \
+ 0, 0, 0, 0, \
+ 8, 8, 8, \
+ 1, 2, 2, \
+ 1, 1, 1, \
+ {'Y','U','Y','V', \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ XvTopToBottom \
+ }
+
+#define FOURCC_YV12 0x32315659
+#define XVIMAGE_YV12 \
+ { \
+ FOURCC_YV12, \
+ XvYUV, \
+ LSBFirst, \
+ {'Y','V','1','2', \
+ 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 12, \
+ XvPlanar, \
+ 3, \
+ 0, 0, 0, 0, \
+ 8, 8, 8, \
+ 1, 2, 2, \
+ 1, 2, 2, \
+ {'Y','V','U', \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ XvTopToBottom \
+ }
+
+#define FOURCC_I420 0x30323449
+#define XVIMAGE_I420 \
+ { \
+ FOURCC_I420, \
+ XvYUV, \
+ LSBFirst, \
+ {'I','4','2','0', \
+ 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 12, \
+ XvPlanar, \
+ 3, \
+ 0, 0, 0, 0, \
+ 8, 8, 8, \
+ 1, 2, 2, \
+ 1, 2, 2, \
+ {'Y','U','V', \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ XvTopToBottom \
+ }
+
+
+#define FOURCC_UYVY 0x59565955
+#define XVIMAGE_UYVY \
+ { \
+ FOURCC_UYVY, \
+ XvYUV, \
+ LSBFirst, \
+ {'U','Y','V','Y', \
+ 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 16, \
+ XvPacked, \
+ 1, \
+ 0, 0, 0, 0, \
+ 8, 8, 8, \
+ 1, 2, 2, \
+ 1, 1, 1, \
+ {'U','Y','V','Y', \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ XvTopToBottom \
+ }
+
+#define FOURCC_IA44 0x34344149
+#define XVIMAGE_IA44 \
+ { \
+ FOURCC_IA44, \
+ XvYUV, \
+ LSBFirst, \
+ {'I','A','4','4', \
+ 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 8, \
+ XvPacked, \
+ 1, \
+ 0, 0, 0, 0, \
+ 8, 8, 8, \
+ 1, 1, 1, \
+ 1, 1, 1, \
+ {'A','I', \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ XvTopToBottom \
+ }
+
+#define FOURCC_AI44 0x34344941
+#define XVIMAGE_AI44 \
+ { \
+ FOURCC_AI44, \
+ XvYUV, \
+ LSBFirst, \
+ {'A','I','4','4', \
+ 0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71}, \
+ 8, \
+ XvPacked, \
+ 1, \
+ 0, 0, 0, 0, \
+ 8, 8, 8, \
+ 1, 1, 1, \
+ 1, 1, 1, \
+ {'I','A', \
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, \
+ XvTopToBottom \
+ }
+
+#endif /* _XF86_FOURCC_H_ */
diff --git a/xorg-server/hw/kdrive/src/kaa.c b/xorg-server/hw/kdrive/src/kaa.c
new file mode 100644
index 000000000..db09e9dba
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kaa.c
@@ -0,0 +1,1081 @@
+/*
+ * Copyright © 2001 Keith Packard
+ *
+ * Partly based on code that is Copyright © 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_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "kaa.h"
+#include "dixfontstr.h"
+
+#define DEBUG_MIGRATE 0
+#define DEBUG_PIXMAP 0
+#if DEBUG_MIGRATE
+#define DBG_MIGRATE(a) ErrorF a
+#else
+#define DBG_MIGRATE(a)
+#endif
+#if DEBUG_PIXMAP
+#define DBG_PIXMAP(a) ErrorF a
+#else
+#define DBG_PIXMAP(a)
+#endif
+
+DevPrivateKey kaaScreenPrivateKey = &kaaScreenPrivateKey;
+DevPrivateKey kaaPixmapPrivateKey = &kaaPixmapPrivateKey;
+
+#define KAA_PIXMAP_SCORE_MOVE_IN 10
+#define KAA_PIXMAP_SCORE_MAX 20
+#define KAA_PIXMAP_SCORE_MOVE_OUT -10
+#define KAA_PIXMAP_SCORE_MIN -20
+#define KAA_PIXMAP_SCORE_PINNED 1000
+#define KAA_PIXMAP_SCORE_INIT 1001
+
+void
+kaaDrawableDirty (DrawablePtr pDrawable)
+{
+ PixmapPtr pPixmap;
+ KaaPixmapPrivPtr pKaaPixmap;
+
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ pPixmap = (*pDrawable->pScreen->GetWindowPixmap)((WindowPtr) pDrawable);
+ else
+ pPixmap = (PixmapPtr)pDrawable;
+
+ pKaaPixmap = KaaGetPixmapPriv(pPixmap);
+ if (pKaaPixmap != NULL)
+ pKaaPixmap->dirty = TRUE;
+}
+
+static void
+kaaPixmapSave (ScreenPtr pScreen, KdOffscreenArea *area)
+{
+ PixmapPtr pPixmap = area->privData;
+ KaaPixmapPriv(pPixmap);
+ int dst_pitch, src_pitch, bytes;
+ unsigned char *dst, *src;
+ int i;
+
+ DBG_MIGRATE (("Save 0x%08x (0x%x) (%dx%d)\n",
+ pPixmap->drawable.id,
+ KaaGetPixmapPriv(pPixmap)->area ?
+ KaaGetPixmapPriv(pPixmap)->area->offset : -1,
+ pPixmap->drawable.width,
+ pPixmap->drawable.height));
+
+ src_pitch = pPixmap->devKind;
+ dst_pitch = pKaaPixmap->devKind;
+
+ src = pPixmap->devPrivate.ptr;
+ dst = pKaaPixmap->devPrivate.ptr;
+
+ pPixmap->devKind = dst_pitch;
+ pPixmap->devPrivate.ptr = dst;
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ pKaaPixmap->area = NULL;
+
+#if 0
+ if (!pKaaPixmap->dirty)
+ return;
+#endif
+
+ kaaWaitSync (pPixmap->drawable.pScreen);
+
+ bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;
+
+ i = pPixmap->drawable.height;
+ while (i--) {
+ memcpy (dst, src, bytes);
+ dst += dst_pitch;
+ src += src_pitch;
+ }
+}
+
+static int
+kaaLog2(int val)
+{
+ int bits;
+
+ if (!val)
+ return 0;
+ for (bits = 0; val != 0; bits++)
+ val >>= 1;
+ return bits - 1;
+}
+
+static Bool
+kaaPixmapAllocArea (PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ KaaScreenPriv (pScreen);
+ KaaPixmapPriv (pPixmap);
+ KdScreenPriv (pScreen);
+ int bpp = pPixmap->drawable.bitsPerPixel;
+ CARD16 h = pPixmap->drawable.height;
+ CARD16 w = pPixmap->drawable.width;
+ int pitch;
+
+ if (pKaaScr->info->flags & KAA_OFFSCREEN_ALIGN_POT && w != 1)
+ w = 1 << (kaaLog2(w - 1) + 1);
+ pitch = (w * bpp / 8 + pKaaScr->info->pitchAlign - 1) &
+ ~(pKaaScr->info->pitchAlign - 1);
+
+ pKaaPixmap->devKind = pPixmap->devKind;
+ pKaaPixmap->devPrivate = pPixmap->devPrivate;
+ pKaaPixmap->area = KdOffscreenAlloc (pScreen, pitch * h,
+ pKaaScr->info->offsetAlign,
+ FALSE,
+ kaaPixmapSave, (pointer) pPixmap);
+ if (!pKaaPixmap->area)
+ return FALSE;
+
+ DBG_PIXMAP(("++ 0x%08x (0x%x) (%dx%d)\n",
+ pPixmap->drawable.id,
+ KaaGetPixmapPriv(pPixmap)->area ?
+ KaaGetPixmapPriv(pPixmap)->area->offset : -1,
+ pPixmap->drawable.width,
+ pPixmap->drawable.height));
+ pPixmap->devKind = pitch;
+ pPixmap->devPrivate.ptr = (pointer) ((CARD8 *) pScreenPriv->screen->memory_base + pKaaPixmap->area->offset);
+ pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
+ return TRUE;
+}
+
+void
+kaaMoveInPixmap (PixmapPtr pPixmap)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ KaaScreenPriv (pScreen);
+ KaaPixmapPriv (pPixmap);
+ int dst_pitch, src_pitch, bytes;
+ unsigned char *dst, *src;
+ int i;
+
+ DBG_MIGRATE (("-> 0x%08x (0x%x) (%dx%d)\n",
+ pPixmap->drawable.id,
+ KaaGetPixmapPriv(pPixmap)->area ?
+ KaaGetPixmapPriv(pPixmap)->area->offset : -1,
+ pPixmap->drawable.width,
+ pPixmap->drawable.height));
+
+ src = pPixmap->devPrivate.ptr;
+ src_pitch = pPixmap->devKind;
+
+ if (!kaaPixmapAllocArea (pPixmap))
+ return;
+
+ pKaaPixmap->dirty = FALSE;
+
+ if (pKaaScr->info->UploadToScreen)
+ {
+ if (pKaaScr->info->UploadToScreen(pPixmap, (char *) src, src_pitch))
+ return;
+ }
+
+ dst = pPixmap->devPrivate.ptr;
+ dst_pitch = pPixmap->devKind;
+
+ bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;
+
+ kaaWaitSync (pPixmap->drawable.pScreen);
+
+ i = pPixmap->drawable.height;
+ while (i--) {
+ memcpy (dst, src, bytes);
+ dst += dst_pitch;
+ src += src_pitch;
+ }
+}
+
+static void
+kaaMoveOutPixmap (PixmapPtr pPixmap)
+{
+ KaaPixmapPriv (pPixmap);
+ KdOffscreenArea *area = pKaaPixmap->area;
+
+ DBG_MIGRATE (("<- 0x%08x (0x%x) (%dx%d)\n",
+ pPixmap->drawable.id,
+ KaaGetPixmapPriv(pPixmap)->area ?
+ KaaGetPixmapPriv(pPixmap)->area->offset : -1,
+ pPixmap->drawable.width,
+ pPixmap->drawable.height));
+ if (area)
+ {
+ kaaPixmapSave (pPixmap->drawable.pScreen, area);
+ KdOffscreenFree (pPixmap->drawable.pScreen, area);
+ }
+}
+
+void
+kaaPixmapUseScreen (PixmapPtr pPixmap)
+{
+ KaaPixmapPriv (pPixmap);
+
+ if (pKaaPixmap->score == KAA_PIXMAP_SCORE_PINNED)
+ return;
+
+ if (pKaaPixmap->score == KAA_PIXMAP_SCORE_INIT) {
+ kaaMoveInPixmap(pPixmap);
+ pKaaPixmap->score = 0;
+ }
+
+ if (pKaaPixmap->score < KAA_PIXMAP_SCORE_MAX)
+ {
+ pKaaPixmap->score++;
+ if (!kaaPixmapIsOffscreen(pPixmap) &&
+ pKaaPixmap->score >= KAA_PIXMAP_SCORE_MOVE_IN)
+ kaaMoveInPixmap (pPixmap);
+ }
+ KdOffscreenMarkUsed (pPixmap);
+}
+
+void
+kaaPixmapUseMemory (PixmapPtr pPixmap)
+{
+ KaaPixmapPriv (pPixmap);
+
+ if (pKaaPixmap->score == KAA_PIXMAP_SCORE_PINNED)
+ return;
+
+ if (pKaaPixmap->score == KAA_PIXMAP_SCORE_INIT)
+ pKaaPixmap->score = 0;
+
+ if (pKaaPixmap->score > KAA_PIXMAP_SCORE_MIN)
+ {
+ pKaaPixmap->score--;
+ if (pKaaPixmap->area &&
+ pKaaPixmap->score <= KAA_PIXMAP_SCORE_MOVE_OUT)
+ kaaMoveOutPixmap (pPixmap);
+ }
+}
+
+static Bool
+kaaDestroyPixmap (PixmapPtr pPixmap)
+{
+ if (pPixmap->refcnt == 1)
+ {
+ KaaPixmapPriv (pPixmap);
+ if (pKaaPixmap->area)
+ {
+ DBG_PIXMAP(("-- 0x%08x (0x%x) (%dx%d)\n",
+ pPixmap->drawable.id,
+ KaaGetPixmapPriv(pPixmap)->area->offset,
+ pPixmap->drawable.width,
+ pPixmap->drawable.height));
+ /* Free the offscreen area */
+ KdOffscreenFree (pPixmap->drawable.pScreen, pKaaPixmap->area);
+ pPixmap->devPrivate = pKaaPixmap->devPrivate;
+ pPixmap->devKind = pKaaPixmap->devKind;
+ }
+ }
+ return fbDestroyPixmap (pPixmap);
+}
+
+static PixmapPtr
+kaaCreatePixmap(ScreenPtr pScreen, int w, int h, int depth, unsigned usage_hint)
+{
+ PixmapPtr pPixmap;
+ KaaPixmapPrivPtr pKaaPixmap;
+ int bpp;
+
+ bpp = BitsPerPixel (depth);
+ if (bpp == 32 && depth == 24)
+ {
+ int fb;
+ KdScreenPriv (pScreen);
+
+ for (fb = 0; fb < KD_MAX_FB && pScreenPriv->screen->fb[fb].depth; fb++)
+ if (pScreenPriv->screen->fb[fb].depth == 24)
+ {
+ bpp = pScreenPriv->screen->fb[fb].bitsPerPixel;
+ break;
+ }
+ }
+
+ pPixmap = fbCreatePixmapBpp (pScreen, w, h, depth, bpp, usage_hint);
+ if (!pPixmap)
+ return NULL;
+ pKaaPixmap = KaaGetPixmapPriv(pPixmap);
+ if (!w || !h)
+ pKaaPixmap->score = KAA_PIXMAP_SCORE_PINNED;
+ else
+ pKaaPixmap->score = KAA_PIXMAP_SCORE_INIT;
+
+ pKaaPixmap->area = NULL;
+ pKaaPixmap->dirty = FALSE;
+
+ return pPixmap;
+}
+
+Bool
+kaaPixmapIsOffscreen(PixmapPtr p)
+{
+ ScreenPtr pScreen = p->drawable.pScreen;
+ KdScreenPriv(pScreen);
+
+ return ((unsigned long) ((CARD8 *) p->devPrivate.ptr -
+ (CARD8 *) pScreenPriv->screen->memory_base) <
+ pScreenPriv->screen->memory_size);
+}
+
+PixmapPtr
+kaaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp)
+{
+ PixmapPtr pPixmap;
+ int x, y;
+
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
+#ifdef COMPOSITE
+ x = -pPixmap->screen_x;
+ y = -pPixmap->screen_y;
+#else
+ x = 0;
+ y = 0;
+#endif
+ }
+ else
+ {
+ pPixmap = (PixmapPtr) pDrawable;
+ x = 0;
+ y = 0;
+ }
+ *xp = x;
+ *yp = y;
+ if (kaaPixmapIsOffscreen (pPixmap))
+ return pPixmap;
+ else
+ return NULL;
+}
+
+Bool
+kaaDrawableIsOffscreen (DrawablePtr pDrawable)
+{
+ PixmapPtr pPixmap;
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ pPixmap = (*pDrawable->pScreen->GetWindowPixmap) ((WindowPtr) pDrawable);
+ else
+ pPixmap = (PixmapPtr) pDrawable;
+ return kaaPixmapIsOffscreen (pPixmap);
+}
+
+#if 0
+static void
+kaaFillTiled(int dst_x,
+ int dst_y,
+ int width,
+ int height,
+ int src_x,
+ int src_y,
+ int src_width,
+ int src_height,
+ void (*Copy) (int srcX,
+ int srcY,
+ int dstX,
+ int dstY,
+ int width,
+ int height))
+{
+ modulus (src_x, src_width, src_x);
+ modulus (src_y, src_height, src_y);
+
+ while (height)
+ {
+ int dst_x_tmp = dst_x;
+ int src_x_tmp = src_x;
+ int width_tmp = width;
+ int height_left = src_height - src_y;
+ int height_this = min (height, height_left);
+
+ while (width_tmp)
+ {
+ int width_left = src_width - src_x_tmp;
+ int width_this = min (width_tmp, width_left);
+
+ (*Copy) (src_x_tmp, src_y,
+ dst_x_tmp, dst_y,
+ width_this, height_this);
+
+ width_tmp -= width_this;
+ dst_x_tmp += width_this;
+ }
+ height -= height_this;
+ dst_y += height_this;
+ src_y = 0;
+ }
+}
+#endif
+
+static void
+kaaFillSpans(DrawablePtr pDrawable, GCPtr pGC, int n,
+ DDXPointPtr ppt, int *pwidth, int fSorted)
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ KdScreenPriv (pScreen);
+ KaaScreenPriv (pScreen);
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ PixmapPtr pPixmap;
+ BoxPtr pextent, pbox;
+ int nbox;
+ int extentX1, extentX2, extentY1, extentY2;
+ int fullX1, fullX2, fullY1;
+ int partX1, partX2;
+ int off_x, off_y;
+
+ if (!pScreenPriv->enabled ||
+ pGC->fillStyle != FillSolid ||
+ !(pPixmap = kaaGetOffscreenPixmap (pDrawable, &off_x, &off_y)) ||
+ !(*pKaaScr->info->PrepareSolid) (pPixmap,
+ pGC->alu,
+ pGC->planemask,
+ pGC->fgPixel))
+ {
+ KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
+ return;
+ }
+
+ pextent = REGION_EXTENTS(pGC->pScreen, pClip);
+ extentX1 = pextent->x1;
+ extentY1 = pextent->y1;
+ extentX2 = pextent->x2;
+ extentY2 = pextent->y2;
+ while (n--)
+ {
+ fullX1 = ppt->x;
+ fullY1 = ppt->y;
+ fullX2 = fullX1 + (int) *pwidth;
+ ppt++;
+ pwidth++;
+
+ if (fullY1 < extentY1 || extentY2 <= fullY1)
+ continue;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullX1 >= fullX2)
+ continue;
+
+ nbox = REGION_NUM_RECTS (pClip);
+ if (nbox == 1)
+ {
+ (*pKaaScr->info->Solid) (fullX1 + off_x, fullY1 + off_y,
+ fullX2 + off_x, fullY1 + 1 + off_y);
+ }
+ else
+ {
+ pbox = REGION_RECTS(pClip);
+ while(nbox--)
+ {
+ if (pbox->y1 <= fullY1 && fullY1 < pbox->y2)
+ {
+ partX1 = pbox->x1;
+ if (partX1 < fullX1)
+ partX1 = fullX1;
+ partX2 = pbox->x2;
+ if (partX2 > fullX2)
+ partX2 = fullX2;
+ if (partX2 > partX1)
+ (*pKaaScr->info->Solid) (partX1 + off_x, fullY1 + off_y,
+ partX2 + off_x, fullY1 + 1 + off_y);
+ }
+ pbox++;
+ }
+ }
+ }
+ (*pKaaScr->info->DoneSolid) ();
+ kaaDrawableDirty (pDrawable);
+ kaaMarkSync (pDrawable->pScreen);
+}
+
+void
+kaaCopyNtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ KdScreenPriv (pDstDrawable->pScreen);
+ KaaScreenPriv (pDstDrawable->pScreen);
+ PixmapPtr pSrcPixmap, pDstPixmap;
+ int src_off_x, src_off_y;
+ int dst_off_x, dst_off_y;
+
+ /* Migrate pixmaps to same place as destination */
+ if (pScreenPriv->enabled && pSrcDrawable->type == DRAWABLE_PIXMAP) {
+ if (kaaDrawableIsOffscreen (pDstDrawable))
+ kaaPixmapUseScreen ((PixmapPtr) pSrcDrawable);
+ else
+ kaaPixmapUseMemory ((PixmapPtr) pSrcDrawable);
+ }
+
+ if (pScreenPriv->enabled &&
+ (pSrcPixmap = kaaGetOffscreenPixmap (pSrcDrawable, &src_off_x, &src_off_y)) &&
+ (pDstPixmap = kaaGetOffscreenPixmap (pDstDrawable, &dst_off_x, &dst_off_y)) &&
+ (*pKaaScr->info->PrepareCopy) (pSrcPixmap,
+ pDstPixmap,
+ dx,
+ dy,
+ pGC ? pGC->alu : GXcopy,
+ pGC ? pGC->planemask : FB_ALLONES))
+ {
+ while (nbox--)
+ {
+ (*pKaaScr->info->Copy) (pbox->x1 + dx + src_off_x,
+ pbox->y1 + dy + src_off_y,
+ pbox->x1 + dst_off_x, pbox->y1 + dst_off_y,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ pbox++;
+ }
+ (*pKaaScr->info->DoneCopy) ();
+ kaaMarkSync (pDstDrawable->pScreen);
+ }
+ else
+ {
+ kaaWaitSync (pDstDrawable->pScreen);
+ fbCopyNtoN (pSrcDrawable, pDstDrawable, pGC,
+ pbox, nbox, dx, dy, reverse, upsidedown,
+ bitplane, closure);
+ }
+ kaaDrawableDirty (pDstDrawable);
+}
+
+static RegionPtr
+kaaCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
+ int srcx, int srcy, int width, int height, int dstx, int dsty)
+{
+ return fbDoCopy (pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height,
+ dstx, dsty, kaaCopyNtoN, 0, 0);
+}
+
+static void
+kaaPolyFillRect(DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nrect,
+ xRectangle *prect)
+{
+ KdScreenPriv (pDrawable->pScreen);
+ KaaScreenPriv (pDrawable->pScreen);
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ PixmapPtr pPixmap;
+ register BoxPtr pbox;
+ BoxPtr pextent;
+ int extentX1, extentX2, extentY1, extentY2;
+ int fullX1, fullX2, fullY1, fullY2;
+ int partX1, partX2, partY1, partY2;
+ int xoff, yoff;
+ int xorg, yorg;
+ int n;
+
+ if (!pScreenPriv->enabled ||
+ pGC->fillStyle != FillSolid ||
+ !(pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) ||
+ !(*pKaaScr->info->PrepareSolid) (pPixmap,
+ pGC->alu,
+ pGC->planemask,
+ pGC->fgPixel))
+ {
+ KdCheckPolyFillRect (pDrawable, pGC, nrect, prect);
+ return;
+ }
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, pClip);
+ extentX1 = pextent->x1;
+ extentY1 = pextent->y1;
+ extentX2 = pextent->x2;
+ extentY2 = pextent->y2;
+ while (nrect--)
+ {
+ fullX1 = prect->x + xorg;
+ fullY1 = prect->y + yorg;
+ fullX2 = fullX1 + (int) prect->width;
+ fullY2 = fullY1 + (int) prect->height;
+ prect++;
+
+ if (fullX1 < extentX1)
+ fullX1 = extentX1;
+
+ if (fullY1 < extentY1)
+ fullY1 = extentY1;
+
+ if (fullX2 > extentX2)
+ fullX2 = extentX2;
+
+ if (fullY2 > extentY2)
+ fullY2 = extentY2;
+
+ if ((fullX1 >= fullX2) || (fullY1 >= fullY2))
+ continue;
+ n = REGION_NUM_RECTS (pClip);
+ if (n == 1)
+ {
+ (*pKaaScr->info->Solid) (fullX1 + xoff, fullY1 + yoff,
+ fullX2 + xoff, fullY2 + yoff);
+ }
+ else
+ {
+ pbox = REGION_RECTS(pClip);
+ /*
+ * clip the rectangle to each box in the clip region
+ * this is logically equivalent to calling Intersect()
+ */
+ while(n--)
+ {
+ partX1 = pbox->x1;
+ if (partX1 < fullX1)
+ partX1 = fullX1;
+ partY1 = pbox->y1;
+ if (partY1 < fullY1)
+ partY1 = fullY1;
+ partX2 = pbox->x2;
+ if (partX2 > fullX2)
+ partX2 = fullX2;
+ partY2 = pbox->y2;
+ if (partY2 > fullY2)
+ partY2 = fullY2;
+
+ pbox++;
+
+ if (partX1 < partX2 && partY1 < partY2)
+ (*pKaaScr->info->Solid) (partX1 + xoff, partY1 + yoff,
+ partX2 + xoff, partY2 + yoff);
+ }
+ }
+ }
+ (*pKaaScr->info->DoneSolid) ();
+ kaaDrawableDirty (pDrawable);
+ kaaMarkSync (pDrawable->pScreen);
+}
+
+static void
+kaaSolidBoxClipped (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ FbBits pm,
+ FbBits fg,
+ int x1,
+ int y1,
+ int x2,
+ int y2)
+{
+ KdScreenPriv (pDrawable->pScreen);
+ KaaScreenPriv (pDrawable->pScreen);
+ PixmapPtr pPixmap;
+ BoxPtr pbox;
+ int nbox;
+ int xoff, yoff;
+ int partX1, partX2, partY1, partY2;
+
+ if (!pScreenPriv->enabled ||
+ !(pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) ||
+ !(*pKaaScr->info->PrepareSolid) (pPixmap, GXcopy, pm, fg))
+ {
+ kaaWaitSync (pDrawable->pScreen);
+ fg = fbReplicatePixel (fg, pDrawable->bitsPerPixel);
+ fbSolidBoxClipped (pDrawable, pClip, x1, y1, x2, y2,
+ fbAnd (GXcopy, fg, pm),
+ fbXor (GXcopy, fg, pm));
+ kaaDrawableDirty (pDrawable);
+ return;
+ }
+ for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip);
+ nbox--;
+ pbox++)
+ {
+ partX1 = pbox->x1;
+ if (partX1 < x1)
+ partX1 = x1;
+
+ partX2 = pbox->x2;
+ if (partX2 > x2)
+ partX2 = x2;
+
+ if (partX2 <= partX1)
+ continue;
+
+ partY1 = pbox->y1;
+ if (partY1 < y1)
+ partY1 = y1;
+
+ partY2 = pbox->y2;
+ if (partY2 > y2)
+ partY2 = y2;
+
+ if (partY2 <= partY1)
+ continue;
+
+ (*pKaaScr->info->Solid) (partX1 + xoff, partY1 + yoff,
+ partX2 + xoff, partY2 + yoff);
+ }
+ (*pKaaScr->info->DoneSolid) ();
+ kaaDrawableDirty (pDrawable);
+ kaaMarkSync (pDrawable->pScreen);
+}
+
+static void
+kaaImageGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppciInit,
+ pointer pglyphBase)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ CharInfoPtr *ppci;
+ CharInfoPtr pci;
+ unsigned char *pglyph; /* pointer bits in glyph */
+ int gWidth, gHeight; /* width and height of glyph */
+ FbStride gStride; /* stride of glyph */
+ Bool opaque;
+ int n;
+ int gx, gy;
+ void (*glyph) (FbBits *,
+ FbStride,
+ int,
+ FbStip *,
+ FbBits,
+ int,
+ int);
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int dstXoff, dstYoff;
+ FbBits depthMask;
+
+ depthMask = FbFullMask(pDrawable->depth);
+ if ((pGC->planemask & depthMask) != depthMask)
+ {
+ KdCheckImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase);
+ return;
+ }
+ glyph = 0;
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+ switch (dstBpp) {
+ case 8: glyph = fbGlyph8; break;
+ case 16: glyph = fbGlyph16; break;
+ case 24: glyph = fbGlyph24; break;
+ case 32: glyph = fbGlyph32; break;
+ }
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ if (TERMINALFONT (pGC->font) && !glyph)
+ {
+ opaque = TRUE;
+ }
+ else
+ {
+ int xBack, widthBack;
+ int yBack, heightBack;
+
+ ppci = ppciInit;
+ n = nglyph;
+ widthBack = 0;
+ while (n--)
+ widthBack += (*ppci++)->metrics.characterWidth;
+
+ xBack = x;
+ if (widthBack < 0)
+ {
+ xBack += widthBack;
+ widthBack = -widthBack;
+ }
+ yBack = y - FONTASCENT(pGC->font);
+ heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+ kaaSolidBoxClipped (pDrawable,
+ fbGetCompositeClip(pGC),
+ pGC->planemask,
+ pGC->bgPixel,
+ xBack,
+ yBack,
+ xBack + widthBack,
+ yBack + heightBack);
+ opaque = FALSE;
+ }
+
+ kaaWaitSync (pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+
+ ppci = ppciInit;
+ while (nglyph--)
+ {
+ pci = *ppci++;
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ gWidth = GLYPHWIDTHPIXELS(pci);
+ gHeight = GLYPHHEIGHTPIXELS(pci);
+ if (gWidth && gHeight)
+ {
+ gx = x + pci->metrics.leftSideBearing;
+ gy = y - pci->metrics.ascent;
+ if (glyph && gWidth <= sizeof (FbStip) * 8 &&
+ fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
+ {
+ (*glyph) (dst + (gy + dstYoff) * dstStride,
+ dstStride,
+ dstBpp,
+ (FbStip *) pglyph,
+ pPriv->fg,
+ gx + dstXoff,
+ gHeight);
+ }
+ else
+ {
+ gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
+ fbPutXYImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pPriv->fg,
+ pPriv->bg,
+ pPriv->pm,
+ GXcopy,
+ opaque,
+
+ gx,
+ gy,
+ gWidth, gHeight,
+
+ (FbStip *) pglyph,
+ gStride,
+ 0);
+ }
+ }
+ x += pci->metrics.characterWidth;
+ }
+}
+
+static const GCOps kaaOps = {
+ kaaFillSpans,
+ KdCheckSetSpans,
+ KdCheckPutImage,
+ kaaCopyArea,
+ KdCheckCopyPlane,
+ KdCheckPolyPoint,
+ KdCheckPolylines,
+ KdCheckPolySegment,
+ miPolyRectangle,
+ KdCheckPolyArc,
+ miFillPolygon,
+ kaaPolyFillRect,
+ miPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ kaaImageGlyphBlt,
+ KdCheckPolyGlyphBlt,
+ KdCheckPushPixels,
+};
+
+static void
+kaaValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
+{
+ fbValidateGC (pGC, changes, pDrawable);
+
+ if (kaaDrawableIsOffscreen (pDrawable))
+ pGC->ops = (GCOps *) &kaaOps;
+ else
+ pGC->ops = (GCOps *) &kdAsyncPixmapGCOps;
+}
+
+GCFuncs kaaGCFuncs = {
+ kaaValidateGC,
+ miChangeGC,
+ miCopyGC,
+ miDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip
+};
+
+static int
+kaaCreateGC (GCPtr pGC)
+{
+ if (!fbCreateGC (pGC))
+ return FALSE;
+
+ pGC->funcs = &kaaGCFuncs;
+
+ return TRUE;
+}
+
+
+static void
+kaaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ RegionRec rgnDst;
+ int dx, dy;
+ PixmapPtr pPixmap = (*pWin->drawable.pScreen->GetWindowPixmap) (pWin);
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+
+ REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
+
+ REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+#ifdef COMPOSITE
+ if (pPixmap->screen_x || pPixmap->screen_y)
+ REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst,
+ -pPixmap->screen_x, -pPixmap->screen_y);
+#endif
+
+ fbCopyRegion (&pPixmap->drawable, &pPixmap->drawable,
+ 0,
+ &rgnDst, dx, dy, kaaCopyNtoN, 0, 0);
+
+ REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+}
+
+static void
+kaaFillRegionSolid (DrawablePtr pDrawable,
+ RegionPtr pRegion,
+ Pixel pixel)
+{
+ KdScreenPriv(pDrawable->pScreen);
+ KaaScreenPriv(pDrawable->pScreen);
+ PixmapPtr pPixmap;
+ int xoff, yoff;
+
+ if (pScreenPriv->enabled &&
+ (pPixmap = kaaGetOffscreenPixmap (pDrawable, &xoff, &yoff)) &&
+ (*pKaaScr->info->PrepareSolid) (pPixmap, GXcopy, FB_ALLONES, pixel))
+ {
+ int nbox = REGION_NUM_RECTS (pRegion);
+ BoxPtr pBox = REGION_RECTS (pRegion);
+
+ while (nbox--)
+ {
+ (*pKaaScr->info->Solid) (pBox->x1 + xoff, pBox->y1 + yoff,
+ pBox->x2 + xoff, pBox->y2 + yoff);
+ pBox++;
+ }
+ (*pKaaScr->info->DoneSolid) ();
+ kaaMarkSync (pDrawable->pScreen);
+ }
+ else
+ {
+ kaaWaitSync (pDrawable->pScreen);
+ fbFillRegionSolid (pDrawable, pRegion, 0,
+ fbReplicatePixel (pixel, pDrawable->bitsPerPixel));
+ }
+ kaaDrawableDirty (pDrawable);
+}
+
+Bool
+kaaDrawInit (ScreenPtr pScreen,
+ KaaScreenInfoPtr pScreenInfo)
+{
+ KaaScreenPrivPtr pKaaScr;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+#ifdef RENDER
+ PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
+#endif
+
+ pKaaScr = xalloc (sizeof (KaaScreenPrivRec));
+
+ if (!pKaaScr)
+ return FALSE;
+
+ pKaaScr->info = pScreenInfo;
+
+ dixSetPrivate(&pScreen->devPrivates, kaaScreenPrivateKey, pKaaScr);
+
+ /*
+ * Hook up asynchronous drawing
+ */
+ KdScreenInitAsync (pScreen);
+ /*
+ * Replace various fb screen functions
+ */
+ pScreen->CreateGC = kaaCreateGC;
+ pScreen->CopyWindow = kaaCopyWindow;
+#ifdef RENDER
+ if (ps) {
+ ps->Composite = kaaComposite;
+ ps->RasterizeTrapezoid = kaaRasterizeTrapezoid;
+ }
+#endif
+
+ /*
+ * Hookup offscreen pixmaps
+ */
+ if ((pKaaScr->info->flags & KAA_OFFSCREEN_PIXMAPS) &&
+ screen->off_screen_base < screen->memory_size)
+ {
+ if (!dixRequestPrivate(kaaPixmapPrivateKey, sizeof (KaaPixmapPrivRec)))
+ return FALSE;
+ pScreen->CreatePixmap = kaaCreatePixmap;
+ pScreen->DestroyPixmap = kaaDestroyPixmap;
+ }
+
+ return TRUE;
+}
+
+void
+kaaDrawFini (ScreenPtr pScreen)
+{
+ KaaScreenPriv(pScreen);
+
+ xfree (pKaaScr);
+}
+
+void
+kaaMarkSync (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KaaScreenPriv(pScreen);
+
+ pScreenPriv->card->needSync = TRUE;
+ if (pKaaScr->info->markSync != NULL) {
+ pScreenPriv->card->lastMarker = (*pKaaScr->info->markSync) (pScreen);
+ }
+}
+
+void
+kaaWaitSync (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KaaScreenPriv(pScreen);
+ KdCardInfo *card = pScreenPriv->card;
+
+ if (card->needSync) {
+ (*pKaaScr->info->waitMarker) (pScreen, card->lastMarker);
+ card->needSync = FALSE;
+ }
+}
diff --git a/xorg-server/hw/kdrive/src/kaa.h b/xorg-server/hw/kdrive/src/kaa.h
new file mode 100644
index 000000000..90b963b10
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kaa.h
@@ -0,0 +1,120 @@
+/*
+ * Copyright © 2001 Keith Packard
+ *
+ * Partly based on code that is Copyright © 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.
+ */
+
+#ifndef _KAA_H_
+#define _KAA_H_
+
+#include "picturestr.h"
+
+#define KaaGetScreenPriv(s) ((KaaScreenPrivPtr) \
+ dixLookupPrivate(&(s)->devPrivates, kaaScreenPrivateKey))
+#define KaaScreenPriv(s) KaaScreenPrivPtr pKaaScr = KaaGetScreenPriv(s)
+
+#define KaaGetPixmapPriv(p) ((KaaPixmapPrivPtr) \
+ dixLookupPrivate(&(p)->devPrivates, kaaPixmapPrivateKey))
+#define KaaSetPixmapPriv(p,a) \
+ dixSetPrivate(&(p)->devPrivates, kaaPixmapPrivateKey, a)
+#define KaaPixmapPriv(p) KaaPixmapPrivPtr pKaaPixmap = KaaGetPixmapPriv(p)
+
+typedef struct {
+ KaaScreenInfoPtr info;
+} KaaScreenPrivRec, *KaaScreenPrivPtr;
+
+typedef struct {
+ KdOffscreenArea *area;
+ int score;
+ int devKind;
+ DevUnion devPrivate;
+ Bool dirty;
+} KaaPixmapPrivRec, *KaaPixmapPrivPtr;
+
+extern DevPrivateKey kaaScreenPrivateKey;
+extern DevPrivateKey kaaPixmapPrivateKey;
+
+
+void
+kaaPixmapUseScreen (PixmapPtr pPixmap);
+
+void
+kaaPixmapUseMemory (PixmapPtr pPixmap);
+
+void
+kaaDrawableDirty(DrawablePtr pDrawable);
+
+Bool
+kaaDrawableIsOffscreen (DrawablePtr pDrawable);
+
+Bool
+kaaPixmapIsOffscreen(PixmapPtr p);
+
+PixmapPtr
+kaaGetOffscreenPixmap (DrawablePtr pDrawable, int *xp, int *yp);
+
+void
+kaaMoveInPixmap (PixmapPtr pPixmap);
+
+void
+kaaMarkSync (ScreenPtr pScreen);
+
+void
+kaaWaitSync (ScreenPtr pScreen);
+
+void
+kaaCopyNtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+void
+kaaComposite(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+kaaRasterizeTrapezoid(PicturePtr pPict,
+ xTrapezoid *trap,
+ int xoff,
+ int yoff);
+
+void
+kaaInitTrapOffsets(int grid_order, float *x_offsets, float *y_offsets,
+ float x_offset, float y_offset);
+
+#endif /* _KAA_H_ */
diff --git a/xorg-server/hw/kdrive/src/kaapict.c b/xorg-server/hw/kdrive/src/kaapict.c
new file mode 100644
index 000000000..501b6b9c4
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kaapict.c
@@ -0,0 +1,719 @@
+/*
+ * Copyright © 2001 Keith Packard
+ *
+ * Partly based on code that is Copyright © 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_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "kaa.h"
+
+#ifdef RENDER
+#include "mipict.h"
+
+#define KAA_DEBUG_FALLBACKS 0
+
+#if KAA_DEBUG_FALLBACKS
+static void kaaCompositeFallbackPictDesc(PicturePtr pict, char *string, int n)
+{
+ char format[20];
+ char size[20];
+ char loc;
+ int temp;
+
+ if (!pict) {
+ snprintf(string, n, "None");
+ return;
+ }
+
+ switch (pict->format)
+ {
+ case PICT_a8r8g8b8:
+ snprintf(format, 20, "ARGB8888");
+ break;
+ case PICT_r5g6b5:
+ snprintf(format, 20, "RGB565 ");
+ break;
+ case PICT_x1r5g5b5:
+ snprintf(format, 20, "RGB555 ");
+ break;
+ case PICT_a8:
+ snprintf(format, 20, "A8 ");
+ break;
+ case PICT_a1:
+ snprintf(format, 20, "A1 ");
+ break;
+ default:
+ snprintf(format, 20, "0x%x", (int)pict->format);
+ break;
+ }
+
+ loc = kaaGetOffscreenPixmap(pict->pDrawable, &temp, &temp) ? 's' : 'm';
+
+ snprintf(size, 20, "%dx%d%s", pict->pDrawable->width,
+ pict->pDrawable->height, pict->repeat ?
+ " R" : "");
+
+ snprintf(string, n, "0x%lx:%c fmt %s (%s)", (long)pict, loc, format, size);
+}
+
+static void
+kaaPrintCompositeFallback(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst)
+{
+ char sop[20];
+ char srcdesc[40], maskdesc[40], dstdesc[40];
+
+ switch(op)
+ {
+ case PictOpSrc:
+ sprintf(sop, "Src");
+ break;
+ case PictOpOver:
+ sprintf(sop, "Over");
+ break;
+ default:
+ sprintf(sop, "0x%x", (int)op);
+ break;
+ }
+
+ kaaCompositeFallbackPictDesc(pSrc, srcdesc, 40);
+ kaaCompositeFallbackPictDesc(pMask, maskdesc, 40);
+ kaaCompositeFallbackPictDesc(pDst, dstdesc, 40);
+
+ ErrorF("Composite fallback: op %s, \n"
+ " src %s, \n"
+ " mask %s, \n"
+ " dst %s, \n",
+ sop, srcdesc, maskdesc, dstdesc);
+}
+
+static void
+kaaPrintTrapezoidFallback(PicturePtr pDst)
+{
+ char dstdesc[40];
+
+ kaaCompositeFallbackPictDesc(pDst, dstdesc, 40);
+
+ ErrorF("Trapezoid fallback: dst %s, %c/%s\n",
+ dstdesc,
+ (pDst->polyMode == PolyModePrecise) ? 'p' : 'i',
+ (pDst->polyEdge == PolyEdgeSharp) ? "a" : "aa");
+}
+#endif
+
+static Bool
+kaaGetPixelFromRGBA(CARD32 *pixel,
+ CARD16 red,
+ CARD16 green,
+ CARD16 blue,
+ CARD16 alpha,
+ CARD32 format)
+{
+ int rbits, bbits, gbits, abits;
+ int rshift, bshift, gshift, ashift;
+
+ *pixel = 0;
+
+ if (!PICT_FORMAT_COLOR(format))
+ return FALSE;
+
+ rbits = PICT_FORMAT_R(format);
+ gbits = PICT_FORMAT_G(format);
+ bbits = PICT_FORMAT_B(format);
+ abits = PICT_FORMAT_A(format);
+
+ if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) {
+ bshift = 0;
+ gshift = bbits;
+ rshift = gshift + gbits;
+ ashift = rshift + rbits;
+ } else { /* PICT_TYPE_ABGR */
+ rshift = 0;
+ gshift = rbits;
+ bshift = gshift + gbits;
+ ashift = bshift + bbits;
+ }
+
+ *pixel |= ( blue >> (16 - bbits)) << bshift;
+ *pixel |= ( red >> (16 - rbits)) << rshift;
+ *pixel |= (green >> (16 - gbits)) << gshift;
+ *pixel |= (alpha >> (16 - abits)) << ashift;
+
+ return TRUE;
+}
+
+
+static Bool
+kaaGetRGBAFromPixel(CARD32 pixel,
+ CARD16 *red,
+ CARD16 *green,
+ CARD16 *blue,
+ CARD16 *alpha,
+ CARD32 format)
+{
+ int rbits, bbits, gbits, abits;
+ int rshift, bshift, gshift, ashift;
+
+ if (!PICT_FORMAT_COLOR(format))
+ return FALSE;
+
+ rbits = PICT_FORMAT_R(format);
+ gbits = PICT_FORMAT_G(format);
+ bbits = PICT_FORMAT_B(format);
+ abits = PICT_FORMAT_A(format);
+
+ if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ARGB) {
+ bshift = 0;
+ gshift = bbits;
+ rshift = gshift + gbits;
+ ashift = rshift + rbits;
+ } else { /* PICT_TYPE_ABGR */
+ rshift = 0;
+ gshift = rbits;
+ bshift = gshift + gbits;
+ ashift = bshift + bbits;
+ }
+
+ *red = ((pixel >> rshift ) & ((1 << rbits) - 1)) << (16 - rbits);
+ while (rbits < 16) {
+ *red |= *red >> rbits;
+ rbits <<= 1;
+ }
+
+ *green = ((pixel >> gshift ) & ((1 << gbits) - 1)) << (16 - gbits);
+ while (gbits < 16) {
+ *green |= *green >> gbits;
+ gbits <<= 1;
+ }
+
+ *blue = ((pixel >> bshift ) & ((1 << bbits) - 1)) << (16 - bbits);
+ while (bbits < 16) {
+ *blue |= *blue >> bbits;
+ bbits <<= 1;
+ }
+
+ if (abits) {
+ *alpha = ((pixel >> ashift ) & ((1 << abits) - 1)) << (16 - abits);
+ while (abits < 16) {
+ *alpha |= *alpha >> abits;
+ abits <<= 1;
+ }
+ } else
+ *alpha = 0xffff;
+
+ return TRUE;
+}
+
+static int
+kaaTryDriverSolidFill(PicturePtr pSrc,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ KaaScreenPriv (pDst->pDrawable->pScreen);
+ RegionRec region;
+ BoxPtr pbox;
+ int nbox;
+ int dst_off_x, dst_off_y;
+ PixmapPtr pSrcPix, pDstPix;
+ CARD32 pixel;
+ CARD16 red, green, blue, alpha;
+
+ 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 1;
+
+ if (pSrc->pDrawable->type == DRAWABLE_PIXMAP)
+ kaaPixmapUseMemory ((PixmapPtr) pSrc->pDrawable);
+ if (pDst->pDrawable->type == DRAWABLE_PIXMAP)
+ kaaPixmapUseScreen ((PixmapPtr) pDst->pDrawable);
+
+ pDstPix = kaaGetOffscreenPixmap (pDst->pDrawable, &dst_off_x, &dst_off_y);
+ if (!pDstPix) {
+ REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+ return 0;
+ }
+
+ if (pSrc->pDrawable->type == DRAWABLE_WINDOW)
+ pSrcPix = (*pSrc->pDrawable->pScreen->GetWindowPixmap)(
+ (WindowPtr) (pSrc->pDrawable));
+ else
+ pSrcPix = (PixmapPtr) (pSrc->pDrawable);
+
+ /* If source is offscreen, we need to sync the accelerator
+ * before accessing it. We'd prefer for it to be in memory.
+ */
+ if (kaaPixmapIsOffscreen(pSrcPix)) {
+ kaaWaitSync(pDst->pDrawable->pScreen);
+ }
+
+ pixel = *(CARD32 *)(pSrcPix->devPrivate.ptr);
+ if (!kaaGetRGBAFromPixel(pixel, &red, &green, &blue, &alpha,
+ pSrc->format))
+ {
+ REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+ return -1;
+ }
+ kaaGetPixelFromRGBA(&pixel, red, green, blue, alpha,
+ pDst->format);
+
+ if (!(*pKaaScr->info->PrepareSolid) (pDstPix, GXcopy, 0xffffffff, pixel))
+ {
+ REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+ return -1;
+ }
+
+ nbox = REGION_NUM_RECTS(&region);
+ pbox = REGION_RECTS(&region);
+ while (nbox--)
+ {
+ (*pKaaScr->info->Solid) (pbox->x1 + dst_off_x,
+ pbox->y1 + dst_off_y,
+ pbox->x2 + dst_off_x,
+ pbox->y2 + dst_off_y);
+ pbox++;
+ }
+
+ (*pKaaScr->info->DoneSolid) ();
+ kaaMarkSync (pDst->pDrawable->pScreen);
+ kaaDrawableDirty (pDst->pDrawable);
+
+ REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+ return 1;
+}
+
+static int
+kaaTryDriverBlend(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ KaaScreenPriv (pDst->pDrawable->pScreen);
+ RegionRec region;
+ BoxPtr pbox;
+ int nbox;
+ int src_off_x, src_off_y, dst_off_x, dst_off_y;
+ PixmapPtr pSrcPix, pDstPix;
+ struct _Pixmap srcScratch;
+
+ 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 1;
+
+
+ if (pSrc->pDrawable->type == DRAWABLE_PIXMAP)
+ kaaPixmapUseScreen ((PixmapPtr) pSrc->pDrawable);
+ if (pDst->pDrawable->type == DRAWABLE_PIXMAP)
+ kaaPixmapUseScreen ((PixmapPtr) pDst->pDrawable);
+
+ pSrcPix = kaaGetOffscreenPixmap (pSrc->pDrawable, &src_off_x, &src_off_y);
+ pDstPix = kaaGetOffscreenPixmap (pDst->pDrawable, &dst_off_x, &dst_off_y);
+
+ if (!pDstPix) {
+ REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+ return 0;
+ }
+
+ if (!pSrcPix && pKaaScr->info->UploadToScratch) {
+ if ((*pKaaScr->info->UploadToScratch) ((PixmapPtr) pSrc->pDrawable,
+ &srcScratch))
+ pSrcPix = &srcScratch;
+ }
+
+ if (!pSrcPix) {
+ REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+ return 0;
+ }
+
+ if (!(*pKaaScr->info->PrepareBlend) (op, pSrc, pDst, pSrcPix,
+ pDstPix))
+ {
+ REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+ return -1;
+ }
+
+ nbox = REGION_NUM_RECTS(&region);
+ pbox = REGION_RECTS(&region);
+
+ xSrc -= xDst;
+ ySrc -= yDst;
+
+ while (nbox--)
+ {
+ (*pKaaScr->info->Blend) (pbox->x1 + xSrc + src_off_x,
+ pbox->y1 + ySrc + src_off_y,
+ pbox->x1 + dst_off_x,
+ pbox->y1 + dst_off_y,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ pbox++;
+ }
+
+ (*pKaaScr->info->DoneBlend) ();
+ kaaMarkSync (pDst->pDrawable->pScreen);
+ kaaDrawableDirty (pDst->pDrawable);
+
+ REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+ return 1;
+}
+
+static int
+kaaTryDriverComposite(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ KaaScreenPriv (pDst->pDrawable->pScreen);
+ RegionRec region;
+ BoxPtr pbox;
+ int nbox;
+ int src_off_x, src_off_y, mask_off_x, mask_off_y, dst_off_x, dst_off_y;
+ PixmapPtr pSrcPix, pMaskPix = NULL, pDstPix;
+ struct _Pixmap scratch;
+
+ xDst += pDst->pDrawable->x;
+ yDst += pDst->pDrawable->y;
+
+ if (pMask) {
+ xMask += pMask->pDrawable->x;
+ yMask += pMask->pDrawable->y;
+ }
+
+ xSrc += pSrc->pDrawable->x;
+ ySrc += pSrc->pDrawable->y;
+
+ if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst, yDst,
+ width, height))
+ return 1;
+
+ if (pKaaScr->info->CheckComposite &&
+ !(*pKaaScr->info->CheckComposite) (op, pSrc, pMask, pDst))
+ {
+ REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+ return -1;
+ }
+
+ if (pSrc->pDrawable->type == DRAWABLE_PIXMAP)
+ kaaPixmapUseScreen ((PixmapPtr) pSrc->pDrawable);
+ if (pMask && pMask->pDrawable->type == DRAWABLE_PIXMAP)
+ kaaPixmapUseScreen ((PixmapPtr) pMask->pDrawable);
+ if (pDst->pDrawable->type == DRAWABLE_PIXMAP)
+ kaaPixmapUseScreen ((PixmapPtr) pDst->pDrawable);
+
+ pSrcPix = kaaGetOffscreenPixmap (pSrc->pDrawable, &src_off_x, &src_off_y);
+ if (pMask)
+ pMaskPix = kaaGetOffscreenPixmap (pMask->pDrawable, &mask_off_x,
+ &mask_off_y);
+ pDstPix = kaaGetOffscreenPixmap (pDst->pDrawable, &dst_off_x, &dst_off_y);
+
+ if (!pDstPix) {
+ REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+ return 0;
+ }
+
+ if (!pSrcPix && (!pMask || pMaskPix) && pKaaScr->info->UploadToScratch) {
+ if (pSrc->pDrawable->type == DRAWABLE_WINDOW)
+ pSrcPix = (*pSrc->pDrawable->pScreen->GetWindowPixmap) (
+ (WindowPtr) pSrc->pDrawable);
+ else
+ pSrcPix = (PixmapPtr) pSrc->pDrawable;
+ if ((*pKaaScr->info->UploadToScratch) (pSrcPix, &scratch))
+ pSrcPix = &scratch;
+ } else if (pSrcPix && pMask && !pMaskPix && pKaaScr->info->UploadToScratch) {
+ if (pMask->pDrawable->type == DRAWABLE_WINDOW)
+ pMaskPix = (*pMask->pDrawable->pScreen->GetWindowPixmap) (
+ (WindowPtr) pMask->pDrawable);
+ else
+ pMaskPix = (PixmapPtr) pMask->pDrawable;
+ if ((*pKaaScr->info->UploadToScratch) (pMaskPix, &scratch))
+ pMaskPix = &scratch;
+ }
+
+ if (!pSrcPix || (pMask && !pMaskPix)) {
+ REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+ return 0;
+ }
+
+ if (!(*pKaaScr->info->PrepareComposite) (op, pSrc, pMask, pDst, pSrcPix,
+ pMaskPix, pDstPix))
+ {
+ REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+ return -1;
+ }
+
+ nbox = REGION_NUM_RECTS(&region);
+ pbox = REGION_RECTS(&region);
+
+ xMask -= xDst;
+ yMask -= yDst;
+
+ xSrc -= xDst;
+ ySrc -= yDst;
+
+ while (nbox--)
+ {
+ (*pKaaScr->info->Composite) (pbox->x1 + xSrc + src_off_x,
+ pbox->y1 + ySrc + src_off_y,
+ pbox->x1 + xMask + mask_off_x,
+ pbox->y1 + yMask + mask_off_y,
+ pbox->x1 + dst_off_x,
+ pbox->y1 + dst_off_y,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ pbox++;
+ }
+
+ (*pKaaScr->info->DoneComposite) ();
+ kaaMarkSync (pDst->pDrawable->pScreen);
+ kaaDrawableDirty (pDst->pDrawable);
+
+ REGION_UNINIT(pDst->pDrawable->pScreen, &region);
+ return 1;
+}
+
+
+void
+kaaComposite(CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ KdScreenPriv (pDst->pDrawable->pScreen);
+ KaaScreenPriv (pDst->pDrawable->pScreen);
+ int ret = -1;
+
+ if (!pMask && pSrc->pDrawable)
+ {
+ if (op == PictOpSrc)
+ {
+ if (pScreenPriv->enabled && pSrc->pDrawable && pSrc->pDrawable->width == 1 &&
+ pSrc->pDrawable->height == 1 && pSrc->repeat)
+ {
+ ret = kaaTryDriverSolidFill(pSrc, pDst, xSrc, ySrc, xDst, yDst,
+ width, height);
+ if (ret == 1)
+ return;
+ }
+ else if (!pSrc->repeat && !pSrc->transform &&
+ pSrc->format == pDst->format)
+ {
+ RegionRec region;
+
+ xDst += pDst->pDrawable->x;
+ yDst += pDst->pDrawable->y;
+ xSrc += pSrc->pDrawable->x;
+ ySrc += pSrc->pDrawable->y;
+
+ if (!miComputeCompositeRegion (&region, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst,
+ yDst, width, height))
+ return;
+
+
+ kaaCopyNtoN (pSrc->pDrawable, pDst->pDrawable, 0,
+ REGION_RECTS(&region), REGION_NUM_RECTS(&region),
+ xSrc - xDst, ySrc - yDst,
+ FALSE, FALSE, 0, 0);
+ return;
+ }
+ }
+
+ if (pScreenPriv->enabled && pKaaScr->info->PrepareBlend &&
+ !pSrc->alphaMap && !pDst->alphaMap)
+ {
+ ret = kaaTryDriverBlend(op, pSrc, pDst, xSrc, ySrc, xDst, yDst,
+ width, height);
+ if (ret == 1)
+ return;
+ }
+ }
+
+ if (pSrc->pDrawable && (!pMask || pMask->pDrawable) &&
+ pScreenPriv->enabled && pKaaScr->info->PrepareComposite &&
+ !pSrc->alphaMap && (!pMask || !pMask->alphaMap) && !pDst->alphaMap)
+ {
+ ret = kaaTryDriverComposite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask,
+ yMask, xDst, yDst, width, height);
+ if (ret == 1)
+ return;
+ }
+
+ if (ret != 0) {
+ /* failure to accelerate was not due to pixmaps being in the wrong
+ * locations.
+ */
+ if (pSrc->pDrawable->type == DRAWABLE_PIXMAP)
+ kaaPixmapUseMemory ((PixmapPtr) pSrc->pDrawable);
+ if (pMask && pMask->pDrawable->type == DRAWABLE_PIXMAP)
+ kaaPixmapUseMemory ((PixmapPtr) pMask->pDrawable);
+ if (pDst->pDrawable->type == DRAWABLE_PIXMAP)
+ kaaPixmapUseMemory ((PixmapPtr) pDst->pDrawable);
+ }
+
+#if KAA_DEBUG_FALLBACKS
+ kaaPrintCompositeFallback (op, pSrc, pMask, pDst);
+#endif
+
+ KdCheckComposite (op, pSrc, pMask, pDst, xSrc, ySrc,
+ xMask, yMask, xDst, yDst, width, height);
+}
+#endif
+
+static xFixed
+miLineFixedX (xLineFixed *l, xFixed y, Bool ceil)
+{
+ xFixed dx = l->p2.x - l->p1.x;
+ xFixed_32_32 ex = (xFixed_32_32) (y - l->p1.y) * dx;
+ xFixed dy = l->p2.y - l->p1.y;
+ if (ceil)
+ ex += (dy - 1);
+ return l->p1.x + (xFixed) (ex / dy);
+}
+
+/* Need to decide just how much to trim, to maintain translation independence
+ * when converted to floating point.
+ */
+#define XFIXED_TO_FLOAT(x) (((float)((x) & 0xffffff00)) / 65536.0)
+
+/* This is just to allow us to work on the hardware side of the problem while
+ * waiting for cairo to get a new tesselator. We may not be able to support
+ * RasterizeTrapezoid at all due to the abutting edges requirement, but it might
+ * be technically legal if we widened the trap by some epsilon, so that alpha
+ * values at abutting edges were a little too big and capped at one, rather than
+ * a little too small and looked bad.
+ */
+void kaaRasterizeTrapezoid(PicturePtr pDst,
+ xTrapezoid *trap,
+ int xoff,
+ int yoff)
+{
+ KdScreenPriv (pDst->pDrawable->pScreen);
+ KaaScreenPriv (pDst->pDrawable->pScreen);
+ KaaTrapezoid ktrap;
+ PixmapPtr pPix;
+ xFixed x1, x2;
+
+ if (!pScreenPriv->enabled ||
+ !pKaaScr->info->PrepareTrapezoids ||
+ pDst->pDrawable->type != DRAWABLE_PIXMAP ||
+ pDst->alphaMap || pDst->format != PICT_a8)
+ {
+ KdCheckRasterizeTrapezoid (pDst, trap, xoff, yoff);
+#if KAA_DEBUG_FALLBACKS
+ kaaPrintTrapezoidFallback (pDst);
+#endif
+ return;
+ }
+ pPix = (PixmapPtr)pDst->pDrawable;
+
+ kaaPixmapUseScreen (pPix);
+
+ if (!kaaPixmapIsOffscreen (pPix) ||
+ !(*pKaaScr->info->PrepareTrapezoids) (pDst, pPix))
+ {
+#if KAA_DEBUG_FALLBACKS
+ kaaPrintTrapezoidFallback (pDst);
+#endif
+ KdCheckRasterizeTrapezoid (pDst, trap, xoff, yoff);
+ return;
+ }
+
+ ktrap.ty = XFIXED_TO_FLOAT(trap->top) + yoff;
+ x1 = miLineFixedX (&trap->left, trap->top, FALSE);
+ x2 = miLineFixedX (&trap->right, trap->top, TRUE);
+ ktrap.tl = XFIXED_TO_FLOAT(x1) + xoff;
+ ktrap.tr = XFIXED_TO_FLOAT(x2) + xoff;
+ ktrap.by = XFIXED_TO_FLOAT(trap->bottom) + yoff;
+ x1 = miLineFixedX (&trap->left, trap->bottom, FALSE);
+ x2 = miLineFixedX (&trap->right, trap->bottom, TRUE);
+ ktrap.bl = XFIXED_TO_FLOAT(x1) + xoff;
+ ktrap.br = XFIXED_TO_FLOAT(x2) + xoff;
+
+ (*pKaaScr->info->Trapezoids) (&ktrap, 1);
+ (*pKaaScr->info->DoneTrapezoids) ();
+}
+
+void
+kaaInitTrapOffsets(int grid_order, float *x_offsets, float *y_offsets,
+ float x_offset, float y_offset)
+{
+ int i = 0;
+ float x, y, x_count, y_count;
+
+ x_count = (1 << (grid_order / 2)) + 1;
+ y_count = (1 << (grid_order / 2)) - 1;
+
+ x_offset += 1.0 / x_count / 2.0;
+ y_offset += 1.0 / y_count / 2.0;
+
+ for (x = 0; x < x_count; x++) {
+ for (y = 0; y < y_count; y++) {
+ x_offsets[i] = x / x_count + x_offset;
+ y_offsets[i] = y / y_count + y_offset;
+ i++;
+ }
+ }
+}
+
diff --git a/xorg-server/hw/kdrive/src/kasync.c b/xorg-server/hw/kdrive/src/kasync.c
new file mode 100644
index 000000000..5388f217d
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kasync.c
@@ -0,0 +1,341 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "kaa.h"
+#include "picturestr.h"
+#include "mipict.h"
+#include "fbpict.h"
+
+/*
+ * These functions wrap the low-level fb rendering functions and
+ * synchronize framebuffer/accelerated drawing by stalling until
+ * the accelerator is idle
+ */
+
+void
+KdCheckFillSpans (DrawablePtr pDrawable, GCPtr pGC, int nspans,
+ DDXPointPtr ppt, int *pwidth, int fSorted)
+{
+ kaaWaitSync (pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+ fbFillSpans (pDrawable, pGC, nspans, ppt, pwidth, fSorted);
+}
+
+void
+KdCheckSetSpans (DrawablePtr pDrawable, GCPtr pGC, char *psrc,
+ DDXPointPtr ppt, int *pwidth, int nspans, int fSorted)
+{
+ kaaWaitSync (pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+ fbSetSpans (pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
+}
+
+void
+KdCheckPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth,
+ int x, int y, int w, int h, int leftPad, int format,
+ char *bits)
+{
+ kaaWaitSync (pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+ fbPutImage (pDrawable, pGC, depth, x, y, w, h, leftPad, format, bits);
+}
+
+RegionPtr
+KdCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h, int dstx, int dsty)
+{
+ kaaWaitSync (pSrc->pScreen);
+ kaaDrawableDirty (pDst);
+ return fbCopyArea (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty);
+}
+
+RegionPtr
+KdCheckCopyPlane (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h, int dstx, int dsty,
+ unsigned long bitPlane)
+{
+ kaaWaitSync (pSrc->pScreen);
+ kaaDrawableDirty (pDst);
+ return fbCopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty,
+ bitPlane);
+}
+
+void
+KdCheckPolyPoint (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
+ DDXPointPtr pptInit)
+{
+ kaaWaitSync (pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+ fbPolyPoint (pDrawable, pGC, mode, npt, pptInit);
+}
+
+void
+KdCheckPolylines (DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr ppt)
+{
+
+ if (pGC->lineWidth == 0) {
+ kaaWaitSync(pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+ }
+ kaaDrawableDirty (pDrawable);
+ fbPolyLine (pDrawable, pGC, mode, npt, ppt);
+}
+
+void
+KdCheckPolySegment (DrawablePtr pDrawable, GCPtr pGC,
+ int nsegInit, xSegment *pSegInit)
+{
+ if (pGC->lineWidth == 0) {
+ kaaWaitSync(pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+ }
+ kaaDrawableDirty (pDrawable);
+ fbPolySegment (pDrawable, pGC, nsegInit, pSegInit);
+}
+
+void
+KdCheckPolyRectangle (DrawablePtr pDrawable, GCPtr pGC,
+ int nrects, xRectangle *prect)
+{
+ if (pGC->lineWidth == 0) {
+ kaaWaitSync(pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+ }
+ fbPolyRectangle (pDrawable, pGC, nrects, prect);
+}
+
+void
+KdCheckPolyArc (DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *pArcs)
+{
+ if (pGC->lineWidth == 0)
+ {
+ kaaWaitSync(pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+ fbPolyArc (pDrawable, pGC, narcs, pArcs);
+ }
+ else
+ miPolyArc (pDrawable, pGC, narcs, pArcs);
+}
+
+#if 0
+void
+KdCheckFillPolygon (DrawablePtr pDrawable, GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr pPts)
+{
+ kaaWaitSync(pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+ fbFillPolygon (pDrawable, pGC, mode, count, pPts);
+}
+#endif
+
+void
+KdCheckPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
+ int nrect, xRectangle *prect)
+{
+ kaaWaitSync(pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+ fbPolyFillRect (pDrawable, pGC, nrect, prect);
+}
+
+void
+KdCheckPolyFillArc (DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *pArcs)
+{
+ kaaWaitSync(pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+ fbPolyFillArc (pDrawable, pGC, narcs, pArcs);
+}
+
+void
+KdCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase)
+{
+ kaaWaitSync(pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+ fbImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+}
+
+void
+KdCheckPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase)
+{
+ kaaWaitSync(pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+ fbPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+}
+
+void
+KdCheckPushPixels (GCPtr pGC, PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int w, int h, int x, int y)
+{
+ kaaWaitSync(pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+ fbPushPixels (pGC, pBitmap, pDrawable, w, h, x, y);
+}
+
+void
+KdCheckGetImage (DrawablePtr pDrawable,
+ int x, int y, int w, int h,
+ unsigned int format, unsigned long planeMask,
+ char *d)
+{
+ kaaWaitSync(pDrawable->pScreen);
+ fbGetImage (pDrawable, x, y, w, h, format, planeMask, d);
+}
+
+void
+KdCheckGetSpans (DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pdstStart)
+{
+ kaaWaitSync(pDrawable->pScreen);
+ fbGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+}
+
+void
+KdCheckCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ kaaWaitSync (pWin->drawable.pScreen);
+ kaaDrawableDirty ((DrawablePtr)pWin);
+ fbCopyWindow (pWin, ptOldOrg, prgnSrc);
+}
+
+#if KD_MAX_FB > 1
+void
+KdCheckPaintKey(DrawablePtr pDrawable,
+ RegionPtr pRegion,
+ CARD32 pixel,
+ int layer)
+{
+ kaaWaitSync (pDrawable->pScreen);
+ kaaDrawableDirty (pDrawable);
+ fbOverlayPaintKey (pDrawable, pRegion, pixel, layer);
+}
+
+void
+KdCheckOverlayCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ kaaWaitSync (pWin->drawable.pScreen);
+ kaaDrawableDirty ((DrawablePtr)pWin);
+ fbOverlayCopyWindow (pWin, ptOldOrg, prgnSrc);
+}
+#endif
+
+void
+KdScreenInitAsync (ScreenPtr pScreen)
+{
+ pScreen->GetImage = KdCheckGetImage;
+ pScreen->GetSpans = KdCheckGetSpans;
+ pScreen->CopyWindow = KdCheckCopyWindow;
+#ifdef RENDER
+ KdPictureInitAsync (pScreen);
+#endif
+}
+
+void
+KdCheckComposite (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
+{
+ kaaWaitSync (pDst->pDrawable->pScreen);
+ kaaDrawableDirty (pDst->pDrawable);
+ fbComposite (op,
+ pSrc,
+ pMask,
+ pDst,
+ xSrc,
+ ySrc,
+ xMask,
+ yMask,
+ xDst,
+ yDst,
+ width,
+ height);
+}
+
+void
+KdCheckRasterizeTrapezoid(PicturePtr pMask,
+ xTrapezoid *trap,
+ int x_off,
+ int y_off)
+{
+ kaaWaitSync (pMask->pDrawable->pScreen);
+ kaaDrawableDirty (pMask->pDrawable);
+ fbRasterizeTrapezoid (pMask, trap, x_off, y_off);
+}
+
+/*
+ * Only need to stall for copyarea/copyplane
+ */
+const GCOps kdAsyncPixmapGCOps = {
+ fbFillSpans,
+ fbSetSpans,
+ fbPutImage,
+ KdCheckCopyArea,
+ KdCheckCopyPlane,
+ fbPolyPoint,
+ fbPolyLine,
+ fbPolySegment,
+ fbPolyRectangle,
+ fbPolyArc,
+ fbFillPolygon,
+ fbPolyFillRect,
+ fbPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ fbImageGlyphBlt,
+ fbPolyGlyphBlt,
+ fbPushPixels
+};
+
+void
+KdPictureInitAsync (ScreenPtr pScreen)
+{
+ PictureScreenPtr ps;
+
+ ps = GetPictureScreen(pScreen);
+ ps->Composite = KdCheckComposite;
+ ps->RasterizeTrapezoid = KdCheckRasterizeTrapezoid;
+}
diff --git a/xorg-server/hw/kdrive/src/kcmap.c b/xorg-server/hw/kdrive/src/kcmap.c
new file mode 100644
index 000000000..4941ad17f
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kcmap.c
@@ -0,0 +1,294 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+
+/*
+ * Put the entire colormap into the DAC
+ */
+
+void
+KdSetColormap (ScreenPtr pScreen, int fb)
+{
+ KdScreenPriv(pScreen);
+ ColormapPtr pCmap = pScreenPriv->pInstalledmap[fb];
+ Pixel pixels[KD_MAX_PSEUDO_SIZE];
+ xrgb colors[KD_MAX_PSEUDO_SIZE];
+ xColorItem defs[KD_MAX_PSEUDO_SIZE];
+ int i;
+
+ if (!pScreenPriv->card->cfuncs->putColors)
+ return;
+ if (pScreenPriv->screen->fb[fb].depth > KD_MAX_PSEUDO_DEPTH)
+ return;
+
+ if (!pScreenPriv->enabled)
+ return;
+
+ if (!pCmap)
+ return;
+
+ /*
+ * Make DIX convert pixels into RGB values -- this handles
+ * true/direct as well as pseudo/static visuals
+ */
+
+ for (i = 0; i < (1 << pScreenPriv->screen->fb[fb].depth); i++)
+ pixels[i] = i;
+
+ QueryColors (pCmap, (1 << pScreenPriv->screen->fb[fb].depth), pixels, colors);
+
+ for (i = 0; i < (1 << pScreenPriv->screen->fb[fb].depth); i++)
+ {
+ defs[i].pixel = i;
+ defs[i].red = colors[i].red;
+ defs[i].green = colors[i].green;
+ defs[i].blue = colors[i].blue;
+ defs[i].flags = DoRed|DoGreen|DoBlue;
+ }
+
+ (*pScreenPriv->card->cfuncs->putColors) (pCmap->pScreen, fb,
+ (1 << pScreenPriv->screen->fb[fb].depth),
+ defs);
+
+ /* recolor hardware cursor */
+ if (pScreenPriv->card->cfuncs->recolorCursor)
+ (*pScreenPriv->card->cfuncs->recolorCursor) (pCmap->pScreen, 0, 0);
+}
+
+/*
+ * When the hardware is enabled, save the hardware colors and store
+ * the current colormap
+ */
+void
+KdEnableColormap (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ int i;
+ int fb;
+ Bool done = FALSE;
+
+ if (!pScreenPriv->card->cfuncs->putColors)
+ return;
+ for (fb = 0; fb < KD_MAX_FB && pScreenPriv->screen->fb[fb].depth; fb++)
+ {
+ if (pScreenPriv->screen->fb[fb].depth <= KD_MAX_PSEUDO_DEPTH && !done)
+ {
+ for (i = 0; i < (1 << pScreenPriv->screen->fb[fb].depth); i++)
+ pScreenPriv->systemPalette[i].pixel = i;
+ (*pScreenPriv->card->cfuncs->getColors) (pScreen, fb,
+ (1 << pScreenPriv->screen->fb[fb].depth),
+ pScreenPriv->systemPalette);
+ done = TRUE;
+ }
+ KdSetColormap (pScreen, fb);
+ }
+}
+
+void
+KdDisableColormap (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ int fb;
+
+ if (!pScreenPriv->card->cfuncs->putColors)
+ return;
+ for (fb = 0; fb < KD_MAX_FB && pScreenPriv->screen->fb[fb].depth; fb++)
+ {
+ if (pScreenPriv->screen->fb[fb].depth <= KD_MAX_PSEUDO_DEPTH)
+ {
+ (*pScreenPriv->card->cfuncs->putColors) (pScreen, fb,
+ (1 << pScreenPriv->screen->fb[fb].depth),
+ pScreenPriv->systemPalette);
+ break;
+ }
+ }
+}
+
+static int
+KdColormapFb (ColormapPtr pCmap)
+{
+ ScreenPtr pScreen = pCmap->pScreen;
+ KdScreenPriv (pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ int d;
+ DepthPtr depth;
+ int v;
+ VisualID vid = pCmap->pVisual->vid;
+ int fb;
+
+ if (screen->fb[1].depth)
+ {
+ for (d = 0; d < pScreen->numDepths; d++)
+ {
+ depth = &pScreen->allowedDepths[d];
+ for (v = 0; v < depth->numVids; v++)
+ {
+ if (depth->vids[v] == vid)
+ {
+ for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++)
+ {
+ if (depth->depth == screen->fb[fb].depth)
+ return fb;
+ }
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+/*
+ * KdInstallColormap
+ *
+ * This function is called when the server receives a request to install a
+ * colormap or when the server needs to install one on its own, like when
+ * there's no window manager running and the user has moved the pointer over
+ * an X client window. It needs to build an identity Windows palette for the
+ * colormap and realize it into the Windows system palette.
+ */
+void
+KdInstallColormap (ColormapPtr pCmap)
+{
+ KdScreenPriv(pCmap->pScreen);
+ int fb = KdColormapFb (pCmap);
+
+ if (pCmap == pScreenPriv->pInstalledmap[fb])
+ return;
+
+ /* Tell X clients that the installed colormap is going away. */
+ if (pScreenPriv->pInstalledmap[fb])
+ WalkTree(pScreenPriv->pInstalledmap[fb]->pScreen, TellLostMap,
+ (pointer) &(pScreenPriv->pInstalledmap[fb]->mid));
+
+ /* Take note of the new installed colorscreen-> */
+ pScreenPriv->pInstalledmap[fb] = pCmap;
+
+ KdSetColormap (pCmap->pScreen, fb);
+
+ /* Tell X clients of the new colormap */
+ WalkTree(pCmap->pScreen, TellGainedMap, (pointer) &(pCmap->mid));
+}
+
+/*
+ * KdUninstallColormap
+ *
+ * This function uninstalls a colormap by either installing
+ * the default X colormap or erasing the installed colormap pointer.
+ * The default X colormap itself cannot be uninstalled.
+ */
+void
+KdUninstallColormap (ColormapPtr pCmap)
+{
+ KdScreenPriv(pCmap->pScreen);
+ int fb = KdColormapFb (pCmap);
+ Colormap defMapID;
+ ColormapPtr defMap;
+
+ /* ignore if not installed */
+ if (pCmap != pScreenPriv->pInstalledmap[fb])
+ return;
+
+ /* ignore attempts to uninstall default colormap */
+ defMapID = pCmap->pScreen->defColormap;
+ if ((Colormap) pCmap->mid == defMapID)
+ return;
+
+ /* install default if on same fb */
+ defMap = (ColormapPtr) LookupIDByType(defMapID, RT_COLORMAP);
+ if (defMap && KdColormapFb (defMap) == fb)
+ (*pCmap->pScreen->InstallColormap)(defMap);
+ else
+ {
+ /* uninstall and clear colormap pointer */
+ WalkTree(pCmap->pScreen, TellLostMap,
+ (pointer) &(pCmap->mid));
+ pScreenPriv->pInstalledmap[fb] = 0;
+ }
+}
+
+int
+KdListInstalledColormaps (ScreenPtr pScreen, Colormap *pCmaps)
+{
+ KdScreenPriv(pScreen);
+ int fb;
+ int n = 0;
+
+ for (fb = 0; fb < KD_MAX_FB && pScreenPriv->screen->fb[fb].depth; fb++)
+ {
+ if (pScreenPriv->pInstalledmap[fb])
+ {
+ *pCmaps++ = pScreenPriv->pInstalledmap[fb]->mid;
+ n++;
+ }
+ }
+ return n;
+}
+
+/*
+ * KdStoreColors
+ *
+ * This function is called whenever the server receives a request to store
+ * color values into one or more entries in the currently installed X
+ * colormap; it can be either the default colormap or a private colorscreen->
+ */
+void
+KdStoreColors (ColormapPtr pCmap, int ndef, xColorItem *pdefs)
+{
+ KdScreenPriv(pCmap->pScreen);
+ VisualPtr pVisual;
+ xColorItem expanddefs[KD_MAX_PSEUDO_SIZE];
+ int fb = KdColormapFb (pCmap);
+
+ if (pCmap != pScreenPriv->pInstalledmap[fb])
+ return;
+
+ if (!pScreenPriv->card->cfuncs->putColors)
+ return;
+
+ if (pScreenPriv->screen->fb[fb].depth > KD_MAX_PSEUDO_DEPTH)
+ return;
+
+ if (!pScreenPriv->enabled)
+ return;
+
+ /* Check for DirectColor or TrueColor being simulated on a PseudoColor device. */
+ pVisual = pCmap->pVisual;
+ if ((pVisual->class | DynamicClass) == DirectColor)
+ {
+ /*
+ * Expand DirectColor or TrueColor color values into a PseudoColor
+ * format. Defer to the Color Framebuffer (CFB) code to do that.
+ */
+ ndef = fbExpandDirectColors(pCmap, ndef, pdefs, expanddefs);
+ pdefs = expanddefs;
+ }
+
+ (*pScreenPriv->card->cfuncs->putColors) (pCmap->pScreen, fb, ndef, pdefs);
+
+ /* recolor hardware cursor */
+ if (pScreenPriv->card->cfuncs->recolorCursor)
+ (*pScreenPriv->card->cfuncs->recolorCursor) (pCmap->pScreen, ndef, pdefs);
+}
diff --git a/xorg-server/hw/kdrive/src/kcurscol.c b/xorg-server/hw/kdrive/src/kcurscol.c
new file mode 100644
index 000000000..6a17df30f
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kcurscol.c
@@ -0,0 +1,94 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "cursorstr.h"
+
+static int
+KdComputeCmapShift (unsigned long mask)
+{
+ int shift;
+ unsigned long bit;
+
+ shift = 16;
+ bit = 0x80000000;
+ while (!(mask & bit))
+ {
+ shift--;
+ bit >>= 1;
+ }
+ return shift;
+}
+
+#define Shift(v,d) ((d) < 0 ? ((v) >> (-d)) : ((v) << (d)))
+
+void
+KdAllocateCursorPixels (ScreenPtr pScreen,
+ int fb,
+ CursorPtr pCursor,
+ Pixel *source,
+ Pixel *mask)
+{
+ xColorItem sourceColor, maskColor;
+ int r, g, b;
+ KdScreenPriv(pScreen);
+
+ if (pScreenPriv->screen->fb[fb].redMask)
+ {
+
+ r = KdComputeCmapShift (pScreenPriv->screen->fb[fb].redMask);
+ g = KdComputeCmapShift (pScreenPriv->screen->fb[fb].greenMask);
+ b = KdComputeCmapShift (pScreenPriv->screen->fb[fb].blueMask);
+ *source = ((Shift(pCursor->foreRed,r) & pScreenPriv->screen->fb[fb].redMask) |
+ (Shift(pCursor->foreGreen,g) & pScreenPriv->screen->fb[fb].greenMask) |
+ (Shift(pCursor->foreBlue,b) & pScreenPriv->screen->fb[fb].blueMask));
+ *mask = ((Shift(pCursor->backRed,r) & pScreenPriv->screen->fb[fb].redMask) |
+ (Shift(pCursor->backGreen,g) & pScreenPriv->screen->fb[fb].greenMask) |
+ (Shift(pCursor->backBlue,b) & pScreenPriv->screen->fb[fb].blueMask));
+ }
+ else
+ {
+ /*
+ * Set these to an invalid pixel value so that
+ * when the store colors comes through, the cursor
+ * won't get recolored
+ */
+ *source = ~0;
+ *mask = ~0;
+
+ sourceColor.red = pCursor->foreRed;
+ sourceColor.green = pCursor->foreGreen;
+ sourceColor.blue = pCursor->foreBlue;
+ FakeAllocColor(pScreenPriv->pInstalledmap[fb], &sourceColor);
+ maskColor.red = pCursor->backRed;
+ maskColor.green = pCursor->backGreen;
+ maskColor.blue = pCursor->backBlue;
+ FakeAllocColor(pScreenPriv->pInstalledmap[fb], &maskColor);
+ FakeFreeColor(pScreenPriv->pInstalledmap[fb], sourceColor.pixel);
+ FakeFreeColor(pScreenPriv->pInstalledmap[fb], maskColor.pixel);
+ *source = sourceColor.pixel;
+ *mask = maskColor.pixel;
+ }
+}
diff --git a/xorg-server/hw/kdrive/src/kdrive.c b/xorg-server/hw/kdrive/src/kdrive.c
new file mode 100644
index 000000000..e2ee4adea
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kdrive.c
@@ -0,0 +1,1416 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#ifdef PSEUDO8
+#include "pseudo8/pseudo8.h"
+#endif
+#include <mivalidate.h>
+#include <dixstruct.h>
+#include "privates.h"
+#ifdef RANDR
+#include <randrstr.h>
+#endif
+
+#ifdef XV
+#include "kxv.h"
+#endif
+
+#ifdef DPMSExtension
+#include "dpmsproc.h"
+#endif
+
+#ifdef HAVE_EXECINFO_H
+#include <execinfo.h>
+#endif
+
+#include <signal.h>
+
+typedef struct _kdDepths {
+ CARD8 depth;
+ CARD8 bpp;
+} KdDepths;
+
+KdDepths kdDepths[] = {
+ { 1, 1 },
+ { 4, 4 },
+ { 8, 8 },
+ { 15, 16 },
+ { 16, 16 },
+ { 24, 32 },
+ { 32, 32 }
+};
+
+#define NUM_KD_DEPTHS (sizeof (kdDepths) / sizeof (kdDepths[0]))
+
+#define KD_DEFAULT_BUTTONS 5
+
+DevPrivateKey kdScreenPrivateKey = &kdScreenPrivateKey;
+unsigned long kdGeneration;
+
+Bool kdVideoTest;
+unsigned long kdVideoTestTime;
+Bool kdEmulateMiddleButton;
+Bool kdRawPointerCoordinates;
+Bool kdDisableZaphod;
+Bool kdDontZap;
+Bool kdEnabled;
+int kdSubpixelOrder;
+int kdVirtualTerminal = -1;
+Bool kdSwitchPending;
+char *kdSwitchCmd;
+DDXPointRec kdOrigin;
+Bool kdHasPointer = FALSE;
+Bool kdHasKbd = FALSE;
+
+static Bool kdCaughtSignal = FALSE;
+
+/*
+ * Carry arguments from InitOutput through driver initialization
+ * to KdScreenInit
+ */
+
+KdOsFuncs *kdOsFuncs;
+extern WindowPtr *WindowTable;
+
+void
+KdSetRootClip (ScreenPtr pScreen, BOOL enable)
+{
+ WindowPtr pWin = WindowTable[pScreen->myNum];
+ WindowPtr pChild;
+ Bool WasViewable;
+ Bool anyMarked = FALSE;
+ RegionPtr pOldClip = 0;
+#ifdef DO_SAVE_UNDERS
+ Bool dosave = FALSE;
+#endif
+ WindowPtr pLayerWin;
+ BoxRec box;
+
+ if (!pWin)
+ return;
+ WasViewable = (Bool)(pWin->viewable);
+ if (WasViewable)
+ {
+ for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
+ {
+ (void) (*pScreen->MarkOverlappedWindows)(pChild,
+ pChild,
+ &pLayerWin);
+ }
+ (*pScreen->MarkWindow) (pWin);
+ anyMarked = TRUE;
+ if (pWin->valdata)
+ {
+ if (HasBorder (pWin))
+ {
+ RegionPtr borderVisible;
+
+ borderVisible = REGION_CREATE(pScreen, NullBox, 1);
+ REGION_SUBTRACT(pScreen, borderVisible,
+ &pWin->borderClip, &pWin->winSize);
+ pWin->valdata->before.borderVisible = borderVisible;
+ }
+ pWin->valdata->before.resized = TRUE;
+ }
+ }
+
+ if (enable)
+ {
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pScreen->width;
+ box.y2 = pScreen->height;
+ pWin->drawable.width = pScreen->width;
+ pWin->drawable.height = pScreen->height;
+ REGION_INIT (pScreen, &pWin->winSize, &box, 1);
+ REGION_INIT (pScreen, &pWin->borderSize, &box, 1);
+ REGION_RESET(pScreen, &pWin->borderClip, &box);
+ REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ }
+ else
+ {
+ REGION_EMPTY(pScreen, &pWin->borderClip);
+ REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ }
+
+ ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
+
+ if (WasViewable)
+ {
+ if (pWin->firstChild)
+ {
+ anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild,
+ pWin->firstChild,
+ (WindowPtr *)NULL);
+ }
+ else
+ {
+ (*pScreen->MarkWindow) (pWin);
+ anyMarked = TRUE;
+ }
+
+#ifdef DO_SAVE_UNDERS
+ if (DO_SAVE_UNDERS(pWin))
+ {
+ dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin);
+ }
+#endif /* DO_SAVE_UNDERS */
+
+ if (anyMarked)
+ (*pScreen->ValidateTree)(pWin, NullWindow, VTOther);
+ }
+
+ if (WasViewable)
+ {
+ if (anyMarked)
+ (*pScreen->HandleExposures)(pWin);
+#ifdef DO_SAVE_UNDERS
+ if (dosave)
+ (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin);
+#endif /* DO_SAVE_UNDERS */
+ if (anyMarked && pScreen->PostValidateTree)
+ (*pScreen->PostValidateTree)(pWin, NullWindow, VTOther);
+ }
+ if (pWin->realized)
+ WindowsRestructured ();
+}
+
+void
+KdDisableScreen (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+
+ if (!pScreenPriv->enabled)
+ return;
+ if (!pScreenPriv->closed)
+ KdSetRootClip (pScreen, FALSE);
+ KdDisableColormap (pScreen);
+ KdOffscreenSwapOut (pScreen);
+ if (!pScreenPriv->screen->dumb && pScreenPriv->card->cfuncs->disableAccel)
+ (*pScreenPriv->card->cfuncs->disableAccel) (pScreen);
+ if (!pScreenPriv->screen->softCursor && pScreenPriv->card->cfuncs->disableCursor)
+ (*pScreenPriv->card->cfuncs->disableCursor) (pScreen);
+ if (pScreenPriv->card->cfuncs->dpms)
+ (*pScreenPriv->card->cfuncs->dpms) (pScreen, KD_DPMS_NORMAL);
+ pScreenPriv->enabled = FALSE;
+ if(pScreenPriv->card->cfuncs->disable)
+ (*pScreenPriv->card->cfuncs->disable) (pScreen);
+}
+
+static void
+KdDoSwitchCmd (char *reason)
+{
+ if (kdSwitchCmd)
+ {
+ char *command = xalloc (strlen (kdSwitchCmd) +
+ 1 +
+ strlen (reason) +
+ 1);
+ if (!command)
+ return;
+ strcpy (command, kdSwitchCmd);
+ strcat (command, " ");
+ strcat (command, reason);
+ system (command);
+ xfree (command);
+ }
+}
+
+void
+KdSuspend (void)
+{
+ KdCardInfo *card;
+ KdScreenInfo *screen;
+
+ if (kdEnabled)
+ {
+ for (card = kdCardInfo; card; card = card->next)
+ {
+ for (screen = card->screenList; screen; screen = screen->next)
+ if (screen->mynum == card->selected && screen->pScreen)
+ KdDisableScreen (screen->pScreen);
+ if (card->driver && card->cfuncs->restore)
+ (*card->cfuncs->restore) (card);
+ }
+ KdDisableInput ();
+ KdDoSwitchCmd ("suspend");
+ }
+}
+
+void
+KdDisableScreens (void)
+{
+ KdSuspend ();
+ if (kdEnabled)
+ {
+ if (kdOsFuncs->Disable)
+ (*kdOsFuncs->Disable) ();
+ kdEnabled = FALSE;
+ }
+}
+
+Bool
+KdEnableScreen (ScreenPtr pScreen)
+{
+ KdScreenPriv (pScreen);
+
+ if (pScreenPriv->enabled)
+ return TRUE;
+ if(pScreenPriv->card->cfuncs->enable)
+ if (!(*pScreenPriv->card->cfuncs->enable) (pScreen))
+ return FALSE;
+ pScreenPriv->enabled = TRUE;
+ pScreenPriv->dpmsState = KD_DPMS_NORMAL;
+ pScreenPriv->card->selected = pScreenPriv->screen->mynum;
+ KdOffscreenSwapIn (pScreen);
+ if (!pScreenPriv->screen->softCursor && pScreenPriv->card->cfuncs->enableCursor)
+ (*pScreenPriv->card->cfuncs->enableCursor) (pScreen);
+ if (!pScreenPriv->screen->dumb && pScreenPriv->card->cfuncs->enableAccel)
+ (*pScreenPriv->card->cfuncs->enableAccel) (pScreen);
+ KdEnableColormap (pScreen);
+ KdSetRootClip (pScreen, TRUE);
+ if (pScreenPriv->card->cfuncs->dpms)
+ (*pScreenPriv->card->cfuncs->dpms) (pScreen, pScreenPriv->dpmsState);
+ return TRUE;
+}
+
+void
+KdResume (void)
+{
+ KdCardInfo *card;
+ KdScreenInfo *screen;
+
+ if (kdEnabled)
+ {
+ KdDoSwitchCmd ("resume");
+ for (card = kdCardInfo; card; card = card->next)
+ {
+ if(card->cfuncs->preserve)
+ (*card->cfuncs->preserve) (card);
+ for (screen = card->screenList; screen; screen = screen->next)
+ if (screen->mynum == card->selected && screen->pScreen)
+ KdEnableScreen (screen->pScreen);
+ }
+ KdEnableInput ();
+ KdReleaseAllKeys ();
+ }
+}
+
+void
+KdEnableScreens (void)
+{
+ if (!kdEnabled)
+ {
+ kdEnabled = TRUE;
+ if (kdOsFuncs->Enable)
+ (*kdOsFuncs->Enable) ();
+ }
+ KdResume ();
+}
+
+void
+KdProcessSwitch (void)
+{
+ if (kdEnabled)
+ KdDisableScreens ();
+ else
+ KdEnableScreens ();
+}
+
+void
+AbortDDX(void)
+{
+ KdDisableScreens ();
+ if (kdOsFuncs)
+ {
+ if (kdEnabled && kdOsFuncs->Disable)
+ (*kdOsFuncs->Disable) ();
+ if (kdOsFuncs->Fini)
+ (*kdOsFuncs->Fini) ();
+ KdDoSwitchCmd ("stop");
+ }
+
+ if (kdCaughtSignal)
+ abort();
+}
+
+void
+ddxGiveUp ()
+{
+ AbortDDX ();
+}
+
+Bool kdDumbDriver;
+Bool kdSoftCursor;
+
+char *
+KdParseFindNext (char *cur, char *delim, char *save, char *last)
+{
+ while (*cur && !strchr (delim, *cur))
+ {
+ *save++ = *cur++;
+ }
+ *save = 0;
+ *last = *cur;
+ if (*cur)
+ cur++;
+ return cur;
+}
+
+Rotation
+KdAddRotation (Rotation a, Rotation b)
+{
+ Rotation rotate = (a & RR_Rotate_All) * (b & RR_Rotate_All);
+ Rotation reflect = (a & RR_Reflect_All) ^ (b & RR_Reflect_All);
+
+ if (rotate > RR_Rotate_270)
+ rotate /= (RR_Rotate_270 * RR_Rotate_90);
+ return reflect | rotate;
+}
+
+Rotation
+KdSubRotation (Rotation a, Rotation b)
+{
+ Rotation rotate = (a & RR_Rotate_All) * 16 / (b & RR_Rotate_All);
+ Rotation reflect = (a & RR_Reflect_All) ^ (b & RR_Reflect_All);
+
+ if (rotate > RR_Rotate_270)
+ rotate /= (RR_Rotate_270 * RR_Rotate_90);
+ return reflect | rotate;
+}
+
+void
+KdParseScreen (KdScreenInfo *screen,
+ char *arg)
+{
+ char delim;
+ char save[1024];
+ int fb;
+ int i;
+ int pixels, mm;
+
+ screen->dumb = kdDumbDriver;
+ screen->softCursor = kdSoftCursor;
+ screen->origin = kdOrigin;
+ screen->randr = RR_Rotate_0;
+ screen->width = 0;
+ screen->height = 0;
+ screen->width_mm = 0;
+ screen->height_mm = 0;
+ screen->subpixel_order = kdSubpixelOrder;
+ screen->rate = 0;
+ for (fb = 0; fb < KD_MAX_FB; fb++)
+ screen->fb[fb].depth = 0;
+ if (!arg)
+ return;
+ if (strlen (arg) >= sizeof (save))
+ return;
+
+ for (i = 0; i < 2; i++)
+ {
+ arg = KdParseFindNext (arg, "x/@XY", save, &delim);
+ if (!save[0])
+ return;
+
+ pixels = atoi(save);
+ mm = 0;
+
+ if (delim == '/')
+ {
+ arg = KdParseFindNext (arg, "x@XY", save, &delim);
+ if (!save[0])
+ return;
+ mm = atoi(save);
+ }
+
+ if (i == 0)
+ {
+ screen->width = pixels;
+ screen->width_mm = mm;
+ }
+ else
+ {
+ screen->height = pixels;
+ screen->height_mm = mm;
+ }
+ if (delim != 'x' && delim != '@' && delim != 'X' && delim != 'Y')
+ return;
+ }
+
+ kdOrigin.x += screen->width;
+ kdOrigin.y = 0;
+ kdDumbDriver = FALSE;
+ kdSoftCursor = FALSE;
+ kdSubpixelOrder = SubPixelUnknown;
+
+ if (delim == '@')
+ {
+ arg = KdParseFindNext (arg, "xXY", save, &delim);
+ if (save[0])
+ {
+ int rotate = atoi (save);
+ if (rotate < 45)
+ screen->randr = RR_Rotate_0;
+ else if (rotate < 135)
+ screen->randr = RR_Rotate_90;
+ else if (rotate < 225)
+ screen->randr = RR_Rotate_180;
+ else if (rotate < 315)
+ screen->randr = RR_Rotate_270;
+ else
+ screen->randr = RR_Rotate_0;
+ }
+ }
+ if (delim == 'X')
+ {
+ arg = KdParseFindNext (arg, "xY", save, &delim);
+ screen->randr |= RR_Reflect_X;
+ }
+
+ if (delim == 'Y')
+ {
+ arg = KdParseFindNext (arg, "xY", save, &delim);
+ screen->randr |= RR_Reflect_Y;
+ }
+
+ fb = 0;
+ while (fb < KD_MAX_FB)
+ {
+ arg = KdParseFindNext (arg, "x/,", save, &delim);
+ if (!save[0])
+ break;
+ screen->fb[fb].depth = atoi(save);
+ if (delim == '/')
+ {
+ arg = KdParseFindNext (arg, "x,", save, &delim);
+ if (!save[0])
+ break;
+ screen->fb[fb].bitsPerPixel = atoi (save);
+ }
+ else
+ screen->fb[fb].bitsPerPixel = 0;
+ if (delim != ',')
+ break;
+ fb++;
+ }
+
+ if (delim == 'x')
+ {
+ arg = KdParseFindNext (arg, "x", save, &delim);
+ if (save[0])
+ screen->rate = atoi(save);
+ }
+}
+
+/*
+ * Mouse argument syntax:
+ *
+ * device,protocol,options...
+ *
+ * Options are any of:
+ * 1-5 n button mouse
+ * 2button emulate middle button
+ * {NMO} Reorder buttons
+ */
+
+char *
+KdSaveString (char *str)
+{
+ char *n = (char *) xalloc (strlen (str) + 1);
+
+ if (!n)
+ return 0;
+ strcpy (n, str);
+ return n;
+}
+
+void
+KdParseRgba (char *rgba)
+{
+ if (!strcmp (rgba, "rgb"))
+ kdSubpixelOrder = SubPixelHorizontalRGB;
+ else if (!strcmp (rgba, "bgr"))
+ kdSubpixelOrder = SubPixelHorizontalBGR;
+ else if (!strcmp (rgba, "vrgb"))
+ kdSubpixelOrder = SubPixelVerticalRGB;
+ else if (!strcmp (rgba, "vbgr"))
+ kdSubpixelOrder = SubPixelVerticalBGR;
+ else if (!strcmp (rgba, "none"))
+ kdSubpixelOrder = SubPixelNone;
+ else
+ kdSubpixelOrder = SubPixelUnknown;
+}
+
+void
+KdUseMsg (void)
+{
+ ErrorF("\nTinyX Device Dependent Usage:\n");
+ ErrorF("-card pcmcia Use PCMCIA card as additional screen\n");
+ ErrorF("-screen WIDTH[/WIDTHMM]xHEIGHT[/HEIGHTMM][@ROTATION][X][Y][xDEPTH/BPP{,DEPTH/BPP}[xFREQ]] Specify screen characteristics\n");
+ ErrorF("-rgba rgb/bgr/vrgb/vbgr/none Specify subpixel ordering for LCD panels\n");
+ ErrorF("-mouse driver [,n,,options] Specify the pointer driver and its options (n is the number of buttons)\n");
+ ErrorF("-keybd driver [,,options] Specify the keyboard driver and its options\n");
+ ErrorF("-zaphod Disable cursor screen switching\n");
+ ErrorF("-2button Emulate 3 button mouse\n");
+ ErrorF("-3button Disable 3 button mouse emulation\n");
+ ErrorF("-rawcoord Don't transform pointer coordinates on rotation\n");
+ ErrorF("-dumb Disable hardware acceleration\n");
+ ErrorF("-softCursor Force software cursor\n");
+ ErrorF("-videoTest Start the server, pause momentarily and exit\n");
+ ErrorF("-origin X,Y Locates the next screen in the the virtual screen (Xinerama)\n");
+ ErrorF("-switchCmd Command to execute on vt switch\n");
+ ErrorF("-nozap Don't terminate server on Ctrl+Alt+Backspace\n");
+ ErrorF("vtxx Use virtual terminal xx instead of the next available\n");
+#ifdef PSEUDO8
+ p8UseMsg ();
+#endif
+}
+
+int
+KdProcessArgument (int argc, char **argv, int i)
+{
+ KdCardInfo *card;
+ KdScreenInfo *screen;
+
+ if (!strcmp (argv[i], "-card"))
+ {
+ if ((i+1) < argc)
+ InitCard (argv[i+1]);
+ else
+ UseMsg ();
+ return 2;
+ }
+ if (!strcmp (argv[i], "-screen"))
+ {
+ if ((i+1) < argc)
+ {
+ card = KdCardInfoLast ();
+ if (!card)
+ {
+ InitCard (0);
+ card = KdCardInfoLast ();
+ }
+ if (card) {
+ screen = KdScreenInfoAdd (card);
+ KdParseScreen (screen, argv[i+1]);
+ } else
+ ErrorF("No matching card found!\n");
+ }
+ else
+ UseMsg ();
+ return 2;
+ }
+ if (!strcmp (argv[i], "-zaphod"))
+ {
+ kdDisableZaphod = TRUE;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-nozap"))
+ {
+ kdDontZap = TRUE;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-3button"))
+ {
+ kdEmulateMiddleButton = FALSE;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-2button"))
+ {
+ kdEmulateMiddleButton = TRUE;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-rawcoord"))
+ {
+ kdRawPointerCoordinates = 1;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-dumb"))
+ {
+ kdDumbDriver = TRUE;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-softCursor"))
+ {
+ kdSoftCursor = TRUE;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-videoTest"))
+ {
+ kdVideoTest = TRUE;
+ return 1;
+ }
+ if (!strcmp (argv[i], "-origin"))
+ {
+ if ((i+1) < argc)
+ {
+ char *x = argv[i+1];
+ char *y = strchr (x, ',');
+ if (x)
+ kdOrigin.x = atoi (x);
+ else
+ kdOrigin.x = 0;
+ if (y)
+ kdOrigin.y = atoi(y+1);
+ else
+ kdOrigin.y = 0;
+ }
+ else
+ UseMsg ();
+ return 2;
+ }
+ if (!strcmp (argv[i], "-rgba"))
+ {
+ if ((i+1) < argc)
+ KdParseRgba (argv[i+1]);
+ else
+ UseMsg ();
+ return 2;
+ }
+ if (!strcmp (argv[i], "-switchCmd"))
+ {
+ if ((i+1) < argc)
+ kdSwitchCmd = argv[i+1];
+ else
+ UseMsg ();
+ return 2;
+ }
+ if (!strncmp (argv[i], "vt", 2) &&
+ sscanf (argv[i], "vt%2d", &kdVirtualTerminal) == 1)
+ {
+ return 1;
+ }
+ if (!strcmp (argv[i], "-mouse") ||
+ !strcmp (argv[i], "-pointer")) {
+ if (i + 1 >= argc)
+ UseMsg();
+ KdAddConfigPointer(argv[i + 1]);
+ kdHasPointer = TRUE;
+ return 2;
+ }
+ if (!strcmp (argv[i], "-keybd")) {
+ if (i + 1 >= argc)
+ UseMsg();
+ KdAddConfigKeyboard(argv[i + 1]);
+ kdHasKbd = TRUE;
+ return 2;
+ }
+
+#ifdef PSEUDO8
+ return p8ProcessArgument (argc, argv, i);
+#else
+ return 0;
+#endif
+}
+
+/*
+ * These are getting tossed in here until I can think of where
+ * they really belong
+ */
+
+void
+KdOsInit (KdOsFuncs *pOsFuncs)
+{
+ kdOsFuncs = pOsFuncs;
+ if (pOsFuncs)
+ {
+ if (serverGeneration == 1)
+ {
+ KdDoSwitchCmd ("start");
+ if (pOsFuncs->Init)
+ (*pOsFuncs->Init) ();
+ }
+ }
+}
+
+Bool
+KdAllocatePrivates (ScreenPtr pScreen)
+{
+ KdPrivScreenPtr pScreenPriv;
+
+ if (kdGeneration != serverGeneration)
+ kdGeneration = serverGeneration;
+
+ pScreenPriv = (KdPrivScreenPtr) xalloc(sizeof (*pScreenPriv));
+ if (!pScreenPriv)
+ return FALSE;
+ memset (pScreenPriv, '\0', sizeof (KdPrivScreenRec));
+ KdSetScreenPriv (pScreen, pScreenPriv);
+ return TRUE;
+}
+
+Bool
+KdCreateScreenResources (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdCardInfo *card = pScreenPriv->card;
+ Bool ret;
+
+ pScreen->CreateScreenResources = pScreenPriv->CreateScreenResources;
+ if(pScreen->CreateScreenResources)
+ ret = (*pScreen->CreateScreenResources) (pScreen);
+ else
+ ret= -1;
+ pScreenPriv->CreateScreenResources = pScreen->CreateScreenResources;
+ pScreen->CreateScreenResources = KdCreateScreenResources;
+ if (ret && card->cfuncs->createRes)
+ ret = (*card->cfuncs->createRes) (pScreen);
+ return ret;
+}
+
+Bool
+KdCloseScreen (int index, ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ KdCardInfo *card = pScreenPriv->card;
+ Bool ret;
+
+ pScreenPriv->closed = TRUE;
+ pScreen->CloseScreen = pScreenPriv->CloseScreen;
+ if(pScreen->CloseScreen)
+ ret = (*pScreen->CloseScreen) (index, pScreen);
+ else
+ ret = TRUE;
+
+ if (screen->off_screen_base < screen->memory_size)
+ KdOffscreenFini (pScreen);
+
+ if (pScreenPriv->dpmsState != KD_DPMS_NORMAL)
+ (*card->cfuncs->dpms) (pScreen, KD_DPMS_NORMAL);
+
+ if (screen->mynum == card->selected)
+ KdDisableScreen (pScreen);
+
+ /*
+ * Restore video hardware when last screen is closed
+ */
+ if (screen == card->screenList)
+ {
+ if (kdEnabled && card->cfuncs->restore)
+ (*card->cfuncs->restore) (card);
+ }
+
+ if (!pScreenPriv->screen->dumb && card->cfuncs->finiAccel)
+ (*card->cfuncs->finiAccel) (pScreen);
+
+ if (!pScreenPriv->screen->softCursor && card->cfuncs->finiCursor)
+ (*card->cfuncs->finiCursor) (pScreen);
+
+ if(card->cfuncs->scrfini)
+ (*card->cfuncs->scrfini) (screen);
+
+ /*
+ * Clean up card when last screen is closed, DIX closes them in
+ * reverse order, thus we check for when the first in the list is closed
+ */
+ if (screen == card->screenList)
+ {
+ if(card->cfuncs->cardfini)
+ (*card->cfuncs->cardfini) (card);
+ /*
+ * Clean up OS when last card is closed
+ */
+ if (card == kdCardInfo)
+ {
+ if (kdEnabled)
+ {
+ kdEnabled = FALSE;
+ if(kdOsFuncs->Disable)
+ (*kdOsFuncs->Disable) ();
+ }
+ }
+ }
+
+ pScreenPriv->screen->pScreen = 0;
+
+ xfree ((pointer) pScreenPriv);
+ return ret;
+}
+
+Bool
+KdSaveScreen (ScreenPtr pScreen, int on)
+{
+ KdScreenPriv(pScreen);
+ int dpmsState;
+
+ if (!pScreenPriv->card->cfuncs->dpms)
+ return FALSE;
+
+ dpmsState = pScreenPriv->dpmsState;
+ switch (on) {
+ case SCREEN_SAVER_OFF:
+ dpmsState = KD_DPMS_NORMAL;
+ break;
+ case SCREEN_SAVER_ON:
+ if (dpmsState == KD_DPMS_NORMAL)
+ dpmsState = KD_DPMS_NORMAL+1;
+ break;
+ case SCREEN_SAVER_CYCLE:
+ if (dpmsState < KD_DPMS_MAX)
+ dpmsState++;
+ break;
+ case SCREEN_SAVER_FORCER:
+ break;
+ }
+ if (dpmsState != pScreenPriv->dpmsState)
+ {
+ if (pScreenPriv->enabled)
+ (*pScreenPriv->card->cfuncs->dpms) (pScreen, dpmsState);
+ pScreenPriv->dpmsState = dpmsState;
+ }
+ return TRUE;
+}
+
+static Bool
+KdCreateWindow (WindowPtr pWin)
+{
+#ifndef PHOENIX
+ if (!pWin->parent)
+ {
+ KdScreenPriv(pWin->drawable.pScreen);
+
+ if (!pScreenPriv->enabled)
+ {
+ REGION_EMPTY (pWin->drawable.pScreen, &pWin->borderClip);
+ REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ }
+ }
+#endif
+ return fbCreateWindow (pWin);
+}
+
+void
+KdSetSubpixelOrder (ScreenPtr pScreen, Rotation randr)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ int subpixel_order = screen->subpixel_order;
+ Rotation subpixel_dir;
+ int i;
+
+ static struct {
+ int subpixel_order;
+ Rotation direction;
+ } orders[] = {
+ { SubPixelHorizontalRGB, RR_Rotate_0 },
+ { SubPixelHorizontalBGR, RR_Rotate_180 },
+ { SubPixelVerticalRGB, RR_Rotate_270 },
+ { SubPixelVerticalBGR, RR_Rotate_90 },
+ };
+
+ static struct {
+ int bit;
+ int normal;
+ int reflect;
+ } reflects[] = {
+ { RR_Reflect_X, SubPixelHorizontalRGB, SubPixelHorizontalBGR },
+ { RR_Reflect_X, SubPixelHorizontalBGR, SubPixelHorizontalRGB },
+ { RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalBGR },
+ { RR_Reflect_Y, SubPixelVerticalRGB, SubPixelVerticalRGB },
+ };
+
+ /* map subpixel to direction */
+ for (i = 0; i < 4; i++)
+ if (orders[i].subpixel_order == subpixel_order)
+ break;
+ if (i < 4)
+ {
+ subpixel_dir = KdAddRotation (randr & RR_Rotate_All, orders[i].direction);
+
+ /* map back to subpixel order */
+ for (i = 0; i < 4; i++)
+ if (orders[i].direction & subpixel_dir)
+ {
+ subpixel_order = orders[i].subpixel_order;
+ break;
+ }
+ /* reflect */
+ for (i = 0; i < 4; i++)
+ if ((randr & reflects[i].bit) &&
+ reflects[i].normal == subpixel_order)
+ {
+ subpixel_order = reflects[i].reflect;
+ break;
+ }
+ }
+ PictureSetSubpixelOrder (pScreen, subpixel_order);
+}
+
+/* Pass through AddScreen, which doesn't take any closure */
+static KdScreenInfo *kdCurrentScreen;
+
+Bool
+KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
+{
+ KdScreenInfo *screen = kdCurrentScreen;
+ KdCardInfo *card = screen->card;
+ KdPrivScreenPtr pScreenPriv;
+ int fb;
+ /*
+ * note that screen->fb is set up for the nominal orientation
+ * of the screen; that means if randr is rotated, the values
+ * there should reflect a rotated frame buffer (or shadow).
+ */
+ Bool rotated = (screen->randr & (RR_Rotate_90|RR_Rotate_270)) != 0;
+ int width, height, *width_mmp, *height_mmp;
+
+ KdAllocatePrivates (pScreen);
+
+ pScreenPriv = KdGetScreenPriv(pScreen);
+
+ if (!rotated)
+ {
+ width = screen->width;
+ height = screen->height;
+ width_mmp = &screen->width_mm;
+ height_mmp = &screen->height_mm;
+ }
+ else
+ {
+ width = screen->height;
+ height = screen->width;
+ width_mmp = &screen->height_mm;
+ height_mmp = &screen->width_mm;
+ }
+ screen->pScreen = pScreen;
+ pScreenPriv->screen = screen;
+ pScreenPriv->card = card;
+ for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++)
+ pScreenPriv->bytesPerPixel[fb] = screen->fb[fb].bitsPerPixel >> 3;
+ pScreenPriv->dpmsState = KD_DPMS_NORMAL;
+#ifdef PANORAMIX
+ dixScreenOrigins[pScreen->myNum] = screen->origin;
+#endif
+
+ if (!monitorResolution)
+ monitorResolution = 75;
+ /*
+ * This is done in this order so that backing store wraps
+ * our GC functions; fbFinishScreenInit initializes MI
+ * backing store
+ */
+ if (!fbSetupScreen (pScreen,
+ screen->fb[0].frameBuffer,
+ width, height,
+ monitorResolution, monitorResolution,
+ screen->fb[0].pixelStride,
+ screen->fb[0].bitsPerPixel))
+ {
+ return FALSE;
+ }
+
+ /*
+ * Set colormap functions
+ */
+ pScreen->InstallColormap = KdInstallColormap;
+ pScreen->UninstallColormap = KdUninstallColormap;
+ pScreen->ListInstalledColormaps = KdListInstalledColormaps;
+ pScreen->StoreColors = KdStoreColors;
+
+ pScreen->SaveScreen = KdSaveScreen;
+ pScreen->CreateWindow = KdCreateWindow;
+
+#if KD_MAX_FB > 1
+ if (screen->fb[1].depth)
+ {
+ if (!fbOverlayFinishScreenInit (pScreen,
+ screen->fb[0].frameBuffer,
+ screen->fb[1].frameBuffer,
+ width, height,
+ monitorResolution, monitorResolution,
+ screen->fb[0].pixelStride,
+ screen->fb[1].pixelStride,
+ screen->fb[0].bitsPerPixel,
+ screen->fb[1].bitsPerPixel,
+ screen->fb[0].depth,
+ screen->fb[1].depth))
+ {
+ return FALSE;
+ }
+ }
+ else
+#endif
+ {
+ if (!fbFinishScreenInit (pScreen,
+ screen->fb[0].frameBuffer,
+ width, height,
+ monitorResolution, monitorResolution,
+ screen->fb[0].pixelStride,
+ screen->fb[0].bitsPerPixel))
+ {
+ return FALSE;
+ }
+ }
+
+ /*
+ * Fix screen sizes; for some reason mi takes dpi instead of mm.
+ * Rounding errors are annoying
+ */
+ if (*width_mmp)
+ pScreen->mmWidth = *width_mmp;
+ else
+ *width_mmp = pScreen->mmWidth;
+ if (*height_mmp)
+ pScreen->mmHeight = *height_mmp;
+ else
+ *height_mmp = pScreen->mmHeight;
+
+ /*
+ * Plug in our own block/wakeup handlers.
+ * miScreenInit installs NoopDDA in both places
+ */
+ pScreen->BlockHandler = KdBlockHandler;
+ pScreen->WakeupHandler = KdWakeupHandler;
+
+#ifdef RENDER
+ if (!fbPictureInit (pScreen, 0, 0))
+ return FALSE;
+#endif
+ if (card->cfuncs->initScreen)
+ if (!(*card->cfuncs->initScreen) (pScreen))
+ return FALSE;
+
+ if (!screen->dumb && card->cfuncs->initAccel)
+ if (!(*card->cfuncs->initAccel) (pScreen))
+ screen->dumb = TRUE;
+
+ if (screen->off_screen_base < screen->memory_size)
+ KdOffscreenInit (pScreen);
+
+#ifdef PSEUDO8
+ (void) p8Init (pScreen, PSEUDO8_USE_DEFAULT);
+#endif
+
+ if (card->cfuncs->finishInitScreen)
+ if (!(*card->cfuncs->finishInitScreen) (pScreen))
+ return FALSE;
+
+#if 0
+ fbInitValidateTree (pScreen);
+#endif
+
+#if 0
+ pScreen->backingStoreSupport = Always;
+ miInitializeBackingStore (pScreen);
+#endif
+
+
+ /*
+ * Wrap CloseScreen, the order now is:
+ * KdCloseScreen
+ * miBSCloseScreen
+ * fbCloseScreen
+ */
+ pScreenPriv->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = KdCloseScreen;
+
+ pScreenPriv->CreateScreenResources = pScreen->CreateScreenResources;
+ pScreen->CreateScreenResources = KdCreateScreenResources;
+
+ if (screen->softCursor ||
+ !card->cfuncs->initCursor ||
+ !(*card->cfuncs->initCursor) (pScreen))
+ {
+ /* Use MI for cursor display and event queueing. */
+ screen->softCursor = TRUE;
+ miDCInitialize(pScreen, &kdPointerScreenFuncs);
+ }
+
+
+ if (!fbCreateDefColormap (pScreen))
+ {
+ return FALSE;
+ }
+
+ KdSetSubpixelOrder (pScreen, screen->randr);
+
+ /*
+ * Enable the hardware
+ */
+ if (!kdEnabled)
+ {
+ kdEnabled = TRUE;
+ if(kdOsFuncs->Enable)
+ (*kdOsFuncs->Enable) ();
+ }
+
+ if (screen->mynum == card->selected)
+ {
+ if(card->cfuncs->preserve)
+ (*card->cfuncs->preserve) (card);
+ if(card->cfuncs->enable)
+ if (!(*card->cfuncs->enable) (pScreen))
+ return FALSE;
+ pScreenPriv->enabled = TRUE;
+ if (!screen->softCursor && card->cfuncs->enableCursor)
+ (*card->cfuncs->enableCursor) (pScreen);
+ KdEnableColormap (pScreen);
+ if (!screen->dumb && card->cfuncs->enableAccel)
+ (*card->cfuncs->enableAccel) (pScreen);
+ }
+
+ return TRUE;
+}
+
+void
+KdInitScreen (ScreenInfo *pScreenInfo,
+ KdScreenInfo *screen,
+ int argc,
+ char **argv)
+{
+ KdCardInfo *card = screen->card;
+
+ (*card->cfuncs->scrinit) (screen);
+
+ if (!card->cfuncs->initAccel)
+ screen->dumb = TRUE;
+ if (!card->cfuncs->initCursor)
+ screen->softCursor = TRUE;
+}
+
+static Bool
+KdSetPixmapFormats (ScreenInfo *pScreenInfo)
+{
+ CARD8 depthToBpp[33]; /* depth -> bpp map */
+ KdCardInfo *card;
+ KdScreenInfo *screen;
+ int i;
+ int bpp;
+ int fb;
+ PixmapFormatRec *format;
+
+ for (i = 1; i <= 32; i++)
+ depthToBpp[i] = 0;
+
+ /*
+ * Generate mappings between bitsPerPixel and depth,
+ * also ensure that all screens comply with protocol
+ * restrictions on equivalent formats for the same
+ * depth on different screens
+ */
+ for (card = kdCardInfo; card; card = card->next)
+ {
+ for (screen = card->screenList; screen; screen = screen->next)
+ {
+ for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++)
+ {
+ bpp = screen->fb[fb].bitsPerPixel;
+ if (bpp == 24)
+ bpp = 32;
+ if (!depthToBpp[screen->fb[fb].depth])
+ depthToBpp[screen->fb[fb].depth] = bpp;
+ else if (depthToBpp[screen->fb[fb].depth] != bpp)
+ return FALSE;
+ }
+ }
+ }
+
+ /*
+ * Fill in additional formats
+ */
+ for (i = 0; i < NUM_KD_DEPTHS; i++)
+ if (!depthToBpp[kdDepths[i].depth])
+ depthToBpp[kdDepths[i].depth] = kdDepths[i].bpp;
+
+ pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+ pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+
+ pScreenInfo->numPixmapFormats = 0;
+
+ for (i = 1; i <= 32; i++)
+ {
+ if (depthToBpp[i])
+ {
+ format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats++];
+ format->depth = i;
+ format->bitsPerPixel = depthToBpp[i];
+ format->scanlinePad = BITMAP_SCANLINE_PAD;
+ }
+ }
+
+ return TRUE;
+}
+
+static void
+KdAddScreen (ScreenInfo *pScreenInfo,
+ KdScreenInfo *screen,
+ int argc,
+ char **argv)
+{
+ int i;
+ /*
+ * Fill in fb visual type masks for this screen
+ */
+ for (i = 0; i < pScreenInfo->numPixmapFormats; i++)
+ {
+ unsigned long visuals;
+ Pixel rm, gm, bm;
+ int fb;
+
+ visuals = 0;
+ rm = gm = bm = 0;
+ for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++)
+ {
+ if (pScreenInfo->formats[i].depth == screen->fb[fb].depth)
+ {
+ visuals = screen->fb[fb].visuals;
+ rm = screen->fb[fb].redMask;
+ gm = screen->fb[fb].greenMask;
+ bm = screen->fb[fb].blueMask;
+ break;
+ }
+ }
+ fbSetVisualTypesAndMasks (pScreenInfo->formats[i].depth,
+ visuals,
+ 8,
+ rm, gm, bm);
+ }
+
+ kdCurrentScreen = screen;
+
+ AddScreen (KdScreenInit, argc, argv);
+}
+
+#if 0 /* This function is not used currently */
+
+int
+KdDepthToFb (ScreenPtr pScreen, int depth)
+{
+ KdScreenPriv(pScreen);
+ int fb;
+
+ for (fb = 0; fb <= KD_MAX_FB && pScreenPriv->screen->fb[fb].frameBuffer; fb++)
+ if (pScreenPriv->screen->fb[fb].depth == depth)
+ return fb;
+}
+
+#endif
+
+#ifdef HAVE_BACKTRACE
+/* shamelessly ripped from xf86Events.c */
+void
+KdBacktrace (int signum)
+{
+ void *array[32]; /* more than 32 and you have bigger problems */
+ size_t size, i;
+ char **strings;
+
+ signal(signum, SIG_IGN);
+
+ size = backtrace (array, 32);
+ fprintf (stderr, "\nBacktrace (%d deep):\n", size);
+ strings = backtrace_symbols (array, size);
+ for (i = 0; i < size; i++)
+ fprintf (stderr, "%d: %s\n", i, strings[i]);
+ free (strings);
+
+ kdCaughtSignal = TRUE;
+ if (signum == SIGSEGV)
+ FatalError("Segmentation fault caught\n");
+ else if (signum > 0)
+ FatalError("Signal %d caught\n", signum);
+}
+#else
+void
+KdBacktrace (int signum)
+{
+ kdCaughtSignal = TRUE;
+ FatalError("Segmentation fault caught\n");
+}
+#endif
+
+void
+KdInitOutput (ScreenInfo *pScreenInfo,
+ int argc,
+ char **argv)
+{
+ KdCardInfo *card;
+ KdScreenInfo *screen;
+
+ if (!kdCardInfo)
+ {
+ InitCard (0);
+ if (!(card = KdCardInfoLast ()))
+ FatalError("No matching cards found!\n");
+ screen = KdScreenInfoAdd (card);
+ KdParseScreen (screen, 0);
+ }
+ /*
+ * Initialize all of the screens for all of the cards
+ */
+ for (card = kdCardInfo; card; card = card->next)
+ {
+ int ret=1;
+ if(card->cfuncs->cardinit)
+ ret=(*card->cfuncs->cardinit) (card);
+ if (ret)
+ {
+ for (screen = card->screenList; screen; screen = screen->next)
+ KdInitScreen (pScreenInfo, screen, argc, argv);
+ }
+ }
+
+ /*
+ * Merge the various pixmap formats together, this can fail
+ * when two screens share depth but not bitsPerPixel
+ */
+ if (!KdSetPixmapFormats (pScreenInfo))
+ return;
+
+ /*
+ * Add all of the screens
+ */
+ for (card = kdCardInfo; card; card = card->next)
+ for (screen = card->screenList; screen; screen = screen->next)
+ KdAddScreen (pScreenInfo, screen, argc, argv);
+
+ signal(SIGSEGV, KdBacktrace);
+}
+
+#ifdef DPMSExtension
+int
+DPMSSet(ClientPtr client, int level)
+{
+}
+
+int
+DPMSGet (int *level)
+{
+ return -1;
+}
+
+Bool
+DPMSSupported (void)
+{
+ return FALSE;
+}
+#endif
+
+void ddxInitGlobals(void) { /* THANK YOU XPRINT */ }
+
diff --git a/xorg-server/hw/kdrive/src/kdrive.h b/xorg-server/hw/kdrive/src/kdrive.h
new file mode 100644
index 000000000..4e04b59f7
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kdrive.h
@@ -0,0 +1,1000 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _KDRIVE_H_
+#define _KDRIVE_H_
+
+#include <stdio.h>
+#include <X11/X.h>
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include <X11/Xos.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "servermd.h"
+#include "mibstore.h"
+#include "colormapst.h"
+#include "gcstruct.h"
+#include "input.h"
+#include "mipointer.h"
+#include "mi.h"
+#include "dix.h"
+#include "fb.h"
+#include "fboverlay.h"
+#include "shadow.h"
+#include "randrstr.h"
+
+#ifdef XKB
+#include <X11/extensions/XKBstr.h>
+#endif
+
+extern WindowPtr *WindowTable;
+
+#define KD_DPMS_NORMAL 0
+#define KD_DPMS_STANDBY 1
+#define KD_DPMS_SUSPEND 2
+#define KD_DPMS_POWERDOWN 3
+#define KD_DPMS_MAX KD_DPMS_POWERDOWN
+
+#ifndef KD_MAX_FB
+#define KD_MAX_FB FB_OVERLAY_MAX
+#endif
+
+#ifndef KD_MAX_CARD_ADDRESS
+#define KD_MAX_CARD_ADDRESS 8
+#endif
+
+#define Status int
+
+/*
+ * Configuration information per video card
+ */
+
+typedef struct _KdCardAttr {
+ CARD32 io;
+ CARD32 address[KD_MAX_CARD_ADDRESS];
+ int naddr;
+
+ /* PCI bus info */
+ CARD16 vendorID;
+ CARD16 deviceID;
+ CARD8 domain;
+ CARD8 bus;
+ CARD8 slot;
+ CARD8 func;
+} KdCardAttr;
+
+typedef struct _KdCardInfo {
+ struct _KdCardFuncs *cfuncs;
+ void *closure;
+ KdCardAttr attr;
+ void *driver;
+ struct _KdScreenInfo *screenList;
+ int selected;
+ struct _KdCardInfo *next;
+
+ Bool needSync;
+ int lastMarker;
+} KdCardInfo;
+
+extern KdCardInfo *kdCardInfo;
+
+/*
+ * Configuration information per X screen
+ */
+typedef struct _KdFrameBuffer {
+ CARD8 *frameBuffer;
+ int depth;
+ int bitsPerPixel;
+ int pixelStride;
+ int byteStride;
+ Bool shadow;
+ unsigned long visuals;
+ Pixel redMask, greenMask, blueMask;
+ void *closure;
+} KdFrameBuffer;
+
+typedef struct _KdOffscreenArea KdOffscreenArea;
+
+typedef void (*KdOffscreenSaveProc) (ScreenPtr pScreen, KdOffscreenArea *area);
+
+typedef enum _KdOffscreenState {
+ KdOffscreenAvail,
+ KdOffscreenRemovable,
+ KdOffscreenLocked,
+} KdOffscreenState;
+
+struct _KdOffscreenArea {
+ int offset;
+ int save_offset;
+ int size;
+ int score;
+ pointer privData;
+
+ KdOffscreenSaveProc save;
+
+ KdOffscreenState state;
+
+ KdOffscreenArea *next;
+};
+
+#define RR_Rotate_All (RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270)
+#define RR_Reflect_All (RR_Reflect_X|RR_Reflect_Y)
+
+typedef struct _KdScreenInfo {
+ struct _KdScreenInfo *next;
+ KdCardInfo *card;
+ ScreenPtr pScreen;
+ void *driver;
+ Rotation randr; /* rotation and reflection */
+ int width;
+ int height;
+ int rate;
+ int width_mm;
+ int height_mm;
+ int subpixel_order;
+ Bool dumb;
+ Bool softCursor;
+ int mynum;
+ DDXPointRec origin;
+ KdFrameBuffer fb[KD_MAX_FB];
+ CARD8 *memory_base;
+ unsigned long memory_size;
+ unsigned long off_screen_base;
+} KdScreenInfo;
+
+typedef struct _KdCardFuncs {
+ Bool (*cardinit) (KdCardInfo *); /* detect and map device */
+ Bool (*scrinit) (KdScreenInfo *);/* initialize screen information */
+ Bool (*initScreen) (ScreenPtr); /* initialize ScreenRec */
+ Bool (*finishInitScreen) (ScreenPtr pScreen);
+ Bool (*createRes) (ScreenPtr); /* create screen resources */
+ void (*preserve) (KdCardInfo *); /* save graphics card state */
+ Bool (*enable) (ScreenPtr); /* set up for rendering */
+ Bool (*dpms) (ScreenPtr, int); /* set DPMS screen saver */
+ void (*disable) (ScreenPtr); /* turn off rendering */
+ void (*restore) (KdCardInfo *); /* restore graphics card state */
+ void (*scrfini) (KdScreenInfo *);/* close down screen */
+ void (*cardfini) (KdCardInfo *); /* close down */
+
+ Bool (*initCursor) (ScreenPtr); /* detect and map cursor */
+ void (*enableCursor) (ScreenPtr); /* enable cursor */
+ void (*disableCursor) (ScreenPtr); /* disable cursor */
+ void (*finiCursor) (ScreenPtr); /* close down */
+ void (*recolorCursor) (ScreenPtr, int, xColorItem *);
+
+ Bool (*initAccel) (ScreenPtr);
+ void (*enableAccel) (ScreenPtr);
+ void (*disableAccel) (ScreenPtr);
+ void (*finiAccel) (ScreenPtr);
+
+ void (*getColors) (ScreenPtr, int, int, xColorItem *);
+ void (*putColors) (ScreenPtr, int, int, xColorItem *);
+
+} KdCardFuncs;
+
+#define KD_MAX_PSEUDO_DEPTH 8
+#define KD_MAX_PSEUDO_SIZE (1 << KD_MAX_PSEUDO_DEPTH)
+
+typedef struct {
+ KdScreenInfo *screen;
+ KdCardInfo *card;
+
+ Bool enabled;
+ Bool closed;
+ int bytesPerPixel[KD_MAX_FB];
+
+ int dpmsState;
+
+ KdOffscreenArea *off_screen_areas;
+
+ ColormapPtr pInstalledmap[KD_MAX_FB]; /* current colormap */
+ xColorItem systemPalette[KD_MAX_PSEUDO_SIZE];/* saved windows colors */
+
+ CreateScreenResourcesProcPtr CreateScreenResources;
+ CloseScreenProcPtr CloseScreen;
+} KdPrivScreenRec, *KdPrivScreenPtr;
+
+typedef enum _kdPointerState {
+ start,
+ button_1_pend,
+ button_1_down,
+ button_2_down,
+ button_3_pend,
+ button_3_down,
+ synth_2_down_13,
+ synth_2_down_3,
+ synth_2_down_1,
+ num_input_states
+} KdPointerState;
+
+#define KD_MAX_BUTTON 32
+
+#define KD_KEYBOARD 1
+#define KD_MOUSE 2
+#define KD_TOUCHSCREEN 3
+
+typedef struct _KdPointerInfo KdPointerInfo;
+
+typedef struct _KdPointerDriver {
+ char *name;
+ Status (*Init) (KdPointerInfo *);
+ Status (*Enable) (KdPointerInfo *);
+ void (*Disable) (KdPointerInfo *);
+ void (*Fini) (KdPointerInfo *);
+ struct _KdPointerDriver *next;
+} KdPointerDriver;
+
+struct _KdPointerInfo {
+ DeviceIntPtr dixdev;
+ char *name;
+ char *path;
+ InputOption *options;
+ int inputClass;
+
+ CARD8 map[KD_MAX_BUTTON + 1];
+ int nButtons;
+ int nAxes;
+
+ Bool emulateMiddleButton;
+ unsigned long emulationTimeout;
+ int emulationDx, emulationDy;
+
+ Bool timeoutPending;
+ KdPointerState mouseState;
+ Bool eventHeld;
+ struct {
+ int type;
+ int x;
+ int y;
+ int z;
+ int flags;
+ int absrel;
+ } heldEvent;
+ unsigned char buttonState;
+ Bool transformCoordinates;
+ int pressureThreshold;
+
+ KdPointerDriver *driver;
+ void *driverPrivate;
+
+ struct _KdPointerInfo *next;
+};
+
+extern int KdCurScreen;
+
+void KdAddPointerDriver (KdPointerDriver *driver);
+void KdRemovePointerDriver (KdPointerDriver *driver);
+KdPointerInfo *KdNewPointer (void);
+void KdFreePointer (KdPointerInfo *);
+int KdAddPointer (KdPointerInfo *ki);
+int KdAddConfigPointer (char *pointer);
+void KdRemovePointer (KdPointerInfo *ki);
+
+
+#define KD_KEY_COUNT 248
+#define KD_MIN_KEYCODE 8
+#define KD_MAX_KEYCODE 255
+#define KD_MAX_WIDTH 4
+#define KD_MAX_LENGTH (KD_MAX_KEYCODE - KD_MIN_KEYCODE + 1)
+
+typedef struct {
+ KeySym modsym;
+ int modbit;
+} KdKeySymModsRec;
+
+extern const KeySym kdDefaultKeymap[KD_MAX_LENGTH * KD_MAX_WIDTH];
+extern const int kdDefaultKeymapWidth;
+extern const CARD8 kdDefaultModMap[MAP_LENGTH];
+extern const KeySymsRec kdDefaultKeySyms;
+
+typedef struct _KdKeyboardInfo KdKeyboardInfo;
+
+typedef struct _KdKeyboardDriver {
+ char *name;
+ Bool (*Init) (KdKeyboardInfo *);
+ Bool (*Enable) (KdKeyboardInfo *);
+ void (*Leds) (KdKeyboardInfo *, int);
+ void (*Bell) (KdKeyboardInfo *, int, int, int);
+ void (*Disable) (KdKeyboardInfo *);
+ void (*Fini) (KdKeyboardInfo *);
+ struct _KdKeyboardDriver *next;
+} KdKeyboardDriver;
+
+struct _KdKeyboardInfo {
+ struct _KdKeyboardInfo *next;
+ DeviceIntPtr dixdev;
+ void *closure;
+ char *name;
+ char *path;
+ int inputClass;
+#ifdef XKB
+ XkbDescPtr xkb;
+ char *xkbRules;
+ char *xkbModel;
+ char *xkbLayout;
+ char *xkbVariant;
+ char *xkbOptions;
+#endif
+ int LockLed;
+
+ CARD8 keyState[KD_KEY_COUNT/8];
+ int minScanCode;
+ int maxScanCode;
+ CARD8 modmap[MAP_LENGTH];
+ KeySymsRec keySyms;
+
+ int leds;
+ int bellPitch;
+ int bellDuration;
+ InputOption *options;
+
+ KdKeyboardDriver *driver;
+ void *driverPrivate;
+};
+
+void KdAddKeyboardDriver (KdKeyboardDriver *driver);
+void KdRemoveKeyboardDriver (KdKeyboardDriver *driver);
+KdKeyboardInfo *KdNewKeyboard (void);
+void KdFreeKeyboard (KdKeyboardInfo *ki);
+int KdAddConfigKeyboard (char *pointer);
+int KdAddKeyboard (KdKeyboardInfo *ki);
+void KdRemoveKeyboard (KdKeyboardInfo *ki);
+
+typedef struct _KdOsFuncs {
+ int (*Init) (void);
+ void (*Enable) (void);
+ Bool (*SpecialKey) (KeySym);
+ void (*Disable) (void);
+ void (*Fini) (void);
+ void (*pollEvents) (void);
+ void (*Bell) (int, int, int);
+} KdOsFuncs;
+
+typedef enum _KdSyncPolarity {
+ KdSyncNegative, KdSyncPositive
+} KdSyncPolarity;
+
+typedef struct _KdMonitorTiming {
+ /* label */
+ int horizontal;
+ int vertical;
+ int rate;
+ /* pixel clock */
+ int clock; /* in KHz */
+ /* horizontal timing */
+ int hfp; /* front porch */
+ int hbp; /* back porch */
+ int hblank; /* blanking */
+ KdSyncPolarity hpol; /* polarity */
+ /* vertical timing */
+ int vfp; /* front porch */
+ int vbp; /* back porch */
+ int vblank; /* blanking */
+ KdSyncPolarity vpol; /* polarity */
+} KdMonitorTiming;
+
+extern const KdMonitorTiming kdMonitorTimings[];
+extern const int kdNumMonitorTimings;
+
+typedef struct _KdPointerMatrix {
+ int matrix[2][3];
+} KdPointerMatrix;
+
+typedef struct _KaaTrapezoid {
+ float tl, tr, ty;
+ float bl, br, by;
+} KaaTrapezoid;
+
+typedef struct _KaaScreenInfo {
+ int offsetAlign;
+ int pitchAlign;
+ int flags;
+
+ int (*markSync) (ScreenPtr pScreen);
+ void (*waitMarker) (ScreenPtr pScreen, int marker);
+
+ Bool (*PrepareSolid) (PixmapPtr pPixmap,
+ int alu,
+ Pixel planemask,
+ Pixel fg);
+ void (*Solid) (int x1, int y1, int x2, int y2);
+ void (*DoneSolid) (void);
+
+ Bool (*PrepareCopy) (PixmapPtr pSrcPixmap,
+ PixmapPtr pDstPixmap,
+ Bool upsidedown,
+ Bool reverse,
+ int alu,
+ Pixel planemask);
+ void (*Copy) (int srcX,
+ int srcY,
+ int dstX,
+ int dstY,
+ int width,
+ int height);
+ void (*DoneCopy) (void);
+
+ Bool (*PrepareBlend) (int op,
+ PicturePtr pSrcPicture,
+ PicturePtr pDstPicture,
+ PixmapPtr pSrc,
+ PixmapPtr pDst);
+ void (*Blend) (int srcX,
+ int srcY,
+ int dstX,
+ int dstY,
+ int width,
+ int height);
+ void (*DoneBlend) (void);
+
+ Bool (*CheckComposite) (int op,
+ PicturePtr pSrcPicture,
+ PicturePtr pMaskPicture,
+ PicturePtr pDstPicture);
+ Bool (*PrepareComposite) (int op,
+ PicturePtr pSrcPicture,
+ PicturePtr pMaskPicture,
+ PicturePtr pDstPicture,
+ PixmapPtr pSrc,
+ PixmapPtr pMask,
+ PixmapPtr pDst);
+ void (*Composite) (int srcX,
+ int srcY,
+ int maskX,
+ int maskY,
+ int dstX,
+ int dstY,
+ int width,
+ int height);
+ void (*DoneComposite) (void);
+
+ Bool (*PrepareTrapezoids) (PicturePtr pDstPicture,
+ PixmapPtr pDst);
+ void (*Trapezoids) (KaaTrapezoid *traps,
+ int ntraps);
+ void (*DoneTrapezoids) (void);
+
+ Bool (*UploadToScreen) (PixmapPtr pDst,
+ char *src,
+ int src_pitch);
+ Bool (*UploadToScratch) (PixmapPtr pSrc,
+ PixmapPtr pDst);
+} KaaScreenInfoRec, *KaaScreenInfoPtr;
+
+#define KAA_OFFSCREEN_PIXMAPS (1 << 0)
+#define KAA_OFFSCREEN_ALIGN_POT (1 << 1)
+
+/*
+ * This is the only completely portable way to
+ * compute this info.
+ */
+
+#ifndef BitsPerPixel
+#define BitsPerPixel(d) (\
+ PixmapWidthPaddingInfo[d].notPower2 ? \
+ (PixmapWidthPaddingInfo[d].bytesPerPixel * 8) : \
+ ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
+ (PixmapWidthPaddingInfo[d].padRoundUp+1)))
+#endif
+
+extern DevPrivateKey kdScreenPrivateKey;
+extern unsigned long kdGeneration;
+extern Bool kdEnabled;
+extern Bool kdSwitchPending;
+extern Bool kdEmulateMiddleButton;
+extern Bool kdDisableZaphod;
+extern Bool kdDontZap;
+extern int kdVirtualTerminal;
+extern char *kdSwitchCmd;
+extern KdOsFuncs *kdOsFuncs;
+
+#define KdGetScreenPriv(pScreen) ((KdPrivScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey))
+#define KdSetScreenPriv(pScreen,v) \
+ dixSetPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey, v)
+#define KdScreenPriv(pScreen) KdPrivScreenPtr pScreenPriv = KdGetScreenPriv(pScreen)
+
+/* kaa.c */
+Bool
+kaaDrawInit (ScreenPtr pScreen,
+ KaaScreenInfoPtr pScreenInfo);
+
+void
+kaaDrawFini (ScreenPtr pScreen);
+
+void
+kaaWrapGC (GCPtr pGC);
+
+void
+kaaUnwrapGC (GCPtr pGC);
+
+/* kasync.c */
+void
+KdCheckFillSpans (DrawablePtr pDrawable, GCPtr pGC, int nspans,
+ DDXPointPtr ppt, int *pwidth, int fSorted);
+
+void
+KdCheckSetSpans (DrawablePtr pDrawable, GCPtr pGC, char *psrc,
+ DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
+
+void
+KdCheckPutImage (DrawablePtr pDrawable, GCPtr pGC, int depth,
+ int x, int y, int w, int h, int leftPad, int format,
+ char *bits);
+
+RegionPtr
+KdCheckCopyArea (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h, int dstx, int dsty);
+
+RegionPtr
+KdCheckCopyPlane (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
+ int srcx, int srcy, int w, int h, int dstx, int dsty,
+ unsigned long bitPlane);
+
+void
+KdCheckPolyPoint (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
+ DDXPointPtr pptInit);
+
+void
+KdCheckPolylines (DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr ppt);
+
+void
+KdCheckPolySegment (DrawablePtr pDrawable, GCPtr pGC,
+ int nsegInit, xSegment *pSegInit);
+
+void
+KdCheckPolyRectangle (DrawablePtr pDrawable, GCPtr pGC,
+ int nrects, xRectangle *prect);
+
+void
+KdCheckPolyArc (DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *pArcs);
+
+#define KdCheckFillPolygon miFillPolygon
+
+void
+KdCheckPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
+ int nrect, xRectangle *prect);
+
+void
+KdCheckPolyFillArc (DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *pArcs);
+
+void
+KdCheckImageGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase);
+
+void
+KdCheckPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase);
+
+void
+KdCheckPushPixels (GCPtr pGC, PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int w, int h, int x, int y);
+
+void
+KdCheckGetImage (DrawablePtr pDrawable,
+ int x, int y, int w, int h,
+ unsigned int format, unsigned long planeMask,
+ char *d);
+
+void
+KdCheckGetSpans (DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pdstStart);
+
+void
+KdCheckCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
+
+void
+KdCheckPaintKey(DrawablePtr pDrawable,
+ RegionPtr pRegion,
+ CARD32 pixel,
+ int layer);
+
+void
+KdCheckOverlayCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
+
+void
+KdScreenInitAsync (ScreenPtr pScreen);
+
+extern const GCOps kdAsyncPixmapGCOps;
+
+/* knoop.c */
+extern GCOps kdNoopOps;
+
+/* kcmap.c */
+void
+KdSetColormap (ScreenPtr pScreen, int fb);
+
+void
+KdEnableColormap (ScreenPtr pScreen);
+
+void
+KdDisableColormap (ScreenPtr pScreen);
+
+void
+KdInstallColormap (ColormapPtr pCmap);
+
+void
+KdUninstallColormap (ColormapPtr pCmap);
+
+int
+KdListInstalledColormaps (ScreenPtr pScreen, Colormap *pCmaps);
+
+void
+KdStoreColors (ColormapPtr pCmap, int ndef, xColorItem *pdefs);
+
+/* kcurscol.c */
+void
+KdAllocateCursorPixels (ScreenPtr pScreen,
+ int fb,
+ CursorPtr pCursor,
+ Pixel *source,
+ Pixel *mask);
+
+/* kdrive.c */
+extern miPointerScreenFuncRec kdPointerScreenFuncs;
+
+void
+KdSetRootClip (ScreenPtr pScreen, BOOL enable);
+
+void
+KdDisableScreen (ScreenPtr pScreen);
+
+void
+KdDisableScreens (void);
+
+Bool
+KdEnableScreen (ScreenPtr pScreen);
+
+void
+KdEnableScreens (void);
+
+void
+KdSuspend (void);
+
+void
+KdResume (void);
+
+void
+KdProcessSwitch (void);
+
+Rotation
+KdAddRotation (Rotation a, Rotation b);
+
+Rotation
+KdSubRotation (Rotation a, Rotation b);
+
+void
+KdParseScreen (KdScreenInfo *screen,
+ char *arg);
+
+char *
+KdSaveString (char *str);
+
+KdPointerInfo *
+KdParsePointer (char *arg);
+
+KdKeyboardInfo *
+KdParseKeyboard (char *arg);
+
+char *
+KdParseFindNext (char *cur, char *delim, char *save, char *last);
+
+void
+KdParseRgba (char *rgba);
+
+void
+KdUseMsg (void);
+
+int
+KdProcessArgument (int argc, char **argv, int i);
+
+void
+KdOsInit (KdOsFuncs *pOsFuncs);
+
+void
+KdOsAddInputDrivers (void);
+
+Bool
+KdAllocatePrivates (ScreenPtr pScreen);
+
+Bool
+KdCreateScreenResources (ScreenPtr pScreen);
+
+Bool
+KdCloseScreen (int index, ScreenPtr pScreen);
+
+Bool
+KdSaveScreen (ScreenPtr pScreen, int on);
+
+Bool
+KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv);
+
+void
+KdInitScreen (ScreenInfo *pScreenInfo,
+ KdScreenInfo *screen,
+ int argc,
+ char **argv);
+
+void
+KdInitCard (ScreenInfo *pScreenInfo,
+ KdCardInfo *card,
+ int argc,
+ char **argv);
+
+void
+KdInitOutput (ScreenInfo *pScreenInfo,
+ int argc,
+ char **argv);
+
+void
+KdSetSubpixelOrder (ScreenPtr pScreen, Rotation randr);
+
+void
+KdBacktrace (int signum);
+
+/* kinfo.c */
+KdCardInfo *
+KdCardInfoAdd (KdCardFuncs *funcs,
+ KdCardAttr *attr,
+ void *closure);
+
+KdCardInfo *
+KdCardInfoLast (void);
+
+void
+KdCardInfoDispose (KdCardInfo *ci);
+
+KdScreenInfo *
+KdScreenInfoAdd (KdCardInfo *ci);
+
+void
+KdScreenInfoDispose (KdScreenInfo *si);
+
+
+/* kinput.c */
+void
+KdInitInput(void);
+
+void
+KdAddPointerDriver(KdPointerDriver *);
+
+void
+KdAddKeyboardDriver(KdKeyboardDriver *);
+
+Bool
+KdRegisterFd (int fd, void (*read) (int fd, void *closure), void *closure);
+
+void
+KdUnregisterFds (void *closure, Bool do_close);
+
+void
+KdUnregisterFd (void *closure, int fd, Bool do_close);
+
+void
+KdEnqueueKeyboardEvent(KdKeyboardInfo *ki, unsigned char scan_code,
+ unsigned char is_up);
+
+#define KD_BUTTON_1 0x01
+#define KD_BUTTON_2 0x02
+#define KD_BUTTON_3 0x04
+#define KD_BUTTON_4 0x08
+#define KD_BUTTON_5 0x10
+#define KD_BUTTON_8 0x80
+#define KD_MOUSE_DELTA 0x80000000
+
+void
+KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
+ int rz);
+
+void
+_KdEnqueuePointerEvent(KdPointerInfo *pi, int type, int x, int y, int z,
+ int b, int absrel, Bool force);
+
+void
+KdReleaseAllKeys (void);
+
+void
+KdSetLed (KdKeyboardInfo *ki, int led, Bool on);
+
+void
+KdSetPointerMatrix (KdPointerMatrix *pointer);
+
+void
+KdComputePointerMatrix (KdPointerMatrix *pointer, Rotation randr, int width, int height);
+
+void
+KdScreenToPointerCoords (int *x, int *y);
+
+void
+KdBlockHandler (int screen,
+ pointer blockData,
+ pointer timeout,
+ pointer readmask);
+
+void
+KdWakeupHandler (int screen,
+ pointer data,
+ unsigned long result,
+ pointer readmask);
+
+void
+KdDisableInput (void);
+
+void
+KdEnableInput (void);
+
+void
+ProcessInputEvents (void);
+
+void
+KdRingBell (KdKeyboardInfo *ki,
+ int volume,
+ int pitch,
+ int duration);
+
+extern KdPointerDriver LinuxMouseDriver;
+extern KdPointerDriver LinuxEvdevMouseDriver;
+extern KdPointerDriver Ps2MouseDriver;
+extern KdPointerDriver BusMouseDriver;
+extern KdPointerDriver MsMouseDriver;
+extern KdPointerDriver TsDriver;
+extern KdKeyboardDriver LinuxKeyboardDriver;
+extern KdKeyboardDriver LinuxEvdevKeyboardDriver;
+extern KdOsFuncs LinuxFuncs;
+
+extern KdPointerDriver VxWorksMouseDriver;
+extern KdKeyboardDriver VxWorksKeyboardDriver;
+extern KdOsFuncs VxWorksFuncs;
+
+/* kmap.c */
+
+#define KD_MAPPED_MODE_REGISTERS 0
+#define KD_MAPPED_MODE_FRAMEBUFFER 1
+
+void *
+KdMapDevice (CARD32 addr, CARD32 size);
+
+void
+KdUnmapDevice (void *addr, CARD32 size);
+
+void
+KdSetMappedMode (CARD32 addr, CARD32 size, int mode);
+
+void
+KdResetMappedMode (CARD32 addr, CARD32 size, int mode);
+
+/* kmode.c */
+const KdMonitorTiming *
+KdFindMode (KdScreenInfo *screen,
+ Bool (*supported) (KdScreenInfo *,
+ const KdMonitorTiming *));
+
+Bool
+KdTuneMode (KdScreenInfo *screen,
+ Bool (*usable) (KdScreenInfo *),
+ Bool (*supported) (KdScreenInfo *,
+ const KdMonitorTiming *));
+
+#ifdef RANDR
+Bool
+KdRandRGetInfo (ScreenPtr pScreen,
+ int randr,
+ Bool (*supported) (ScreenPtr pScreen,
+ const KdMonitorTiming *));
+
+const KdMonitorTiming *
+KdRandRGetTiming (ScreenPtr pScreen,
+ Bool (*supported) (ScreenPtr pScreen,
+ const KdMonitorTiming *),
+ int rate,
+ RRScreenSizePtr pSize);
+#endif
+
+/* kpict.c */
+void
+KdPictureInitAsync (ScreenPtr pScreen);
+
+#ifdef RENDER
+void
+KdCheckComposite (CARD8 op,
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height);
+
+void
+KdCheckRasterizeTrapezoid(PicturePtr pMask,
+ xTrapezoid *trap,
+ int x_off,
+ int y_off);
+#endif
+
+/* kshadow.c */
+Bool
+KdShadowFbAlloc (KdScreenInfo *screen, int fb, Bool rotate);
+
+void
+KdShadowFbFree (KdScreenInfo *screen, int fb);
+
+Bool
+KdShadowSet (ScreenPtr pScreen, int randr, ShadowUpdateProc update, ShadowWindowProc window);
+
+void
+KdShadowUnset (ScreenPtr pScreen);
+
+/* ktest.c */
+Bool
+KdFrameBufferValid (CARD8 *base, int size);
+
+int
+KdFrameBufferSize (CARD8 *base, int max);
+
+/* koffscreen.c */
+
+Bool
+KdOffscreenInit (ScreenPtr pScreen);
+
+KdOffscreenArea *
+KdOffscreenAlloc (ScreenPtr pScreen, int size, int align,
+ Bool locked,
+ KdOffscreenSaveProc save,
+ pointer privData);
+
+KdOffscreenArea *
+KdOffscreenFree (ScreenPtr pScreen, KdOffscreenArea *area);
+
+void
+KdOffscreenMarkUsed (PixmapPtr pPixmap);
+
+void
+KdOffscreenSwapOut (ScreenPtr pScreen);
+
+void
+KdOffscreenSwapIn (ScreenPtr pScreen);
+
+void
+KdOffscreenFini (ScreenPtr pScreen);
+
+/* function prototypes to be implemented by the drivers */
+void
+InitCard (char *name);
+
+#endif /* _KDRIVE_H_ */
diff --git a/xorg-server/hw/kdrive/src/kinfo.c b/xorg-server/hw/kdrive/src/kinfo.c
new file mode 100644
index 000000000..2621f10dd
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kinfo.c
@@ -0,0 +1,173 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+
+KdCardInfo *kdCardInfo;
+
+KdCardInfo *
+KdCardInfoAdd (KdCardFuncs *funcs,
+ KdCardAttr *attr,
+ void *closure)
+{
+ KdCardInfo *ci, **prev;
+
+ ci = (KdCardInfo *) xalloc (sizeof (KdCardInfo));
+ if (!ci)
+ return 0;
+ bzero (ci, sizeof (KdCardInfo));
+ for (prev = &kdCardInfo; *prev; prev = &(*prev)->next);
+ *prev = ci;
+ ci->cfuncs = funcs;
+ ci->attr = *attr;
+ ci->closure = closure;
+ ci->screenList = 0;
+ ci->selected = 0;
+ ci->next = 0;
+ return ci;
+}
+
+KdCardInfo *
+KdCardInfoLast (void)
+{
+ KdCardInfo *ci;
+
+ if (!kdCardInfo)
+ return 0;
+ for (ci = kdCardInfo; ci->next; ci = ci->next);
+ return ci;
+}
+
+void
+KdCardInfoDispose (KdCardInfo *ci)
+{
+ KdCardInfo **prev;
+
+ for (prev = &kdCardInfo; *prev; prev = &(*prev)->next)
+ if (*prev == ci)
+ {
+ *prev = ci->next;
+ xfree (ci);
+ break;
+ }
+}
+
+KdScreenInfo *
+KdScreenInfoAdd (KdCardInfo *ci)
+{
+ KdScreenInfo *si, **prev;
+ int n;
+
+ si = (KdScreenInfo *) xalloc (sizeof (KdScreenInfo));
+ if (!si)
+ return 0;
+ bzero (si, sizeof (KdScreenInfo));
+ for (prev = &ci->screenList, n = 0; *prev; prev = &(*prev)->next, n++);
+ *prev = si;
+ si->next = 0;
+ si->card = ci;
+ si->mynum = n;
+ return si;
+}
+
+void
+KdScreenInfoDispose (KdScreenInfo *si)
+{
+ KdCardInfo *ci = si->card;
+ KdScreenInfo **prev;
+
+ for (prev = &ci->screenList; *prev; prev = &(*prev)->next) {
+ if (*prev == si)
+ {
+ *prev = si->next;
+ xfree (si);
+ if (!ci->screenList)
+ KdCardInfoDispose (ci);
+ break;
+ }
+ }
+}
+
+KdPointerInfo *
+KdNewPointer (void)
+{
+ KdPointerInfo *pi;
+ int i;
+
+ pi = (KdPointerInfo *)xcalloc(1, sizeof(KdPointerInfo));
+ if (!pi)
+ return NULL;
+
+ pi->name = KdSaveString("Generic Pointer");
+ pi->path = NULL;
+ pi->inputClass = KD_MOUSE;
+ pi->driver = NULL;
+ pi->driverPrivate = NULL;
+ pi->next = NULL;
+ pi->options = NULL;
+ pi->nAxes = 3;
+ pi->nButtons = KD_MAX_BUTTON;
+ for (i = 1; i < KD_MAX_BUTTON; i++)
+ pi->map[i] = i;
+
+ return pi;
+}
+
+void
+KdFreePointer(KdPointerInfo *pi)
+{
+ InputOption *option, *prev = NULL;
+
+ if (pi->name)
+ xfree(pi->name);
+ if (pi->path)
+ xfree(pi->path);
+
+ for (option = pi->options; option; option = option->next) {
+ if (prev)
+ xfree(prev);
+ if (option->key)
+ xfree(option->key);
+ if (option->value)
+ xfree(option->value);
+ prev = option;
+ }
+
+ if (prev)
+ xfree(prev);
+
+ xfree(pi);
+}
+
+void
+KdFreeKeyboard(KdKeyboardInfo *ki)
+{
+ if (ki->name)
+ xfree(ki->name);
+ if (ki->path)
+ xfree(ki->path);
+ ki->next = NULL;
+ xfree(ki);
+}
diff --git a/xorg-server/hw/kdrive/src/kinput.c b/xorg-server/hw/kdrive/src/kinput.c
new file mode 100644
index 000000000..9ba11661c
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kinput.c
@@ -0,0 +1,2513 @@
+/*
+ * Copyright © 1999 Keith Packard
+ * Copyright © 2006 Nokia Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the authors not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The authors make no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIM 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "inputstr.h"
+
+#define XK_PUBLISHING
+#include <X11/keysym.h>
+#if HAVE_X11_XF86KEYSYM_H
+#include <X11/XF86keysym.h>
+#endif
+#include <signal.h>
+#include <stdio.h>
+#ifdef sun
+#include <sys/file.h> /* needed for FNONBLOCK & FASYNC */
+#endif
+
+#ifdef XKB
+#include <xkbsrv.h>
+#endif
+
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "XIstubs.h" /* even though we don't use stubs. cute, no? */
+#include "exevents.h"
+#include "extinit.h"
+#include "exglobals.h"
+
+#define AtomFromName(x) MakeAtom(x, strlen(x), 1)
+
+struct KdConfigDevice {
+ char *line;
+ struct KdConfigDevice *next;
+};
+
+/* kdKeyboards and kdPointers hold all the real devices. */
+static KdKeyboardInfo *kdKeyboards = NULL;
+static KdPointerInfo *kdPointers = NULL;
+static struct KdConfigDevice *kdConfigKeyboards = NULL;
+static struct KdConfigDevice *kdConfigPointers = NULL;
+
+static KdKeyboardDriver *kdKeyboardDrivers = NULL;
+static KdPointerDriver *kdPointerDrivers = NULL;
+
+static xEvent *kdEvents = NULL;
+
+static Bool kdInputEnabled;
+static Bool kdOffScreen;
+static unsigned long kdOffScreenTime;
+static KdPointerMatrix kdPointerMatrix = {
+ { { 1, 0, 0 },
+ { 0, 1, 0 } }
+};
+
+void KdResetInputMachine (void);
+
+#define IsKeyDown(ki, key) ((ki->keyState[(key) >> 3] >> ((key) & 7)) & 1)
+#define KEYMAP(ki) (ki->dixdev->key->curKeySyms)
+#define KEYMAPDDX(ki) (ki->keySyms)
+#define KEYCOL1(ki, k) (KEYMAP(ki).map[((k)-(KEYMAP(ki).minKeyCode))*KEYMAP(ki).mapWidth])
+#define KEYCOL1DDX(ki, k) (KEYMAPDDX(ki).map[((k)-(KEYMAPDDX(ki).minKeyCode))*KEYMAPDDX(ki).mapWidth])
+
+#define KD_MAX_INPUT_FDS 8
+
+typedef struct _kdInputFd {
+ int fd;
+ void (*read) (int fd, void *closure);
+ int (*enable) (int fd, void *closure);
+ void (*disable) (int fd, void *closure);
+ void *closure;
+} KdInputFd;
+
+static KdInputFd kdInputFds[KD_MAX_INPUT_FDS];
+static int kdNumInputFds;
+
+extern Bool kdRawPointerCoordinates;
+
+static void
+KdSigio (int sig)
+{
+ int i;
+
+ for (i = 0; i < kdNumInputFds; i++)
+ (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
+}
+
+static void
+KdBlockSigio (void)
+{
+ sigset_t set;
+
+ sigemptyset (&set);
+ sigaddset (&set, SIGIO);
+ sigprocmask (SIG_BLOCK, &set, 0);
+}
+
+static void
+KdUnblockSigio (void)
+{
+ sigset_t set;
+
+ sigemptyset (&set);
+ sigaddset (&set, SIGIO);
+ sigprocmask (SIG_UNBLOCK, &set, 0);
+}
+
+#ifdef DEBUG_SIGIO
+
+void
+KdAssertSigioBlocked (char *where)
+{
+ sigset_t set, old;
+
+ sigemptyset (&set);
+ sigprocmask (SIG_BLOCK, &set, &old);
+ if (!sigismember (&old, SIGIO)) {
+ ErrorF ("SIGIO not blocked at %s\n", where);
+ KdBacktrace(0);
+ }
+}
+
+#else
+
+#define KdAssertSigioBlocked(s)
+
+#endif
+
+static int kdnFds;
+
+#ifdef FNONBLOCK
+#define NOBLOCK FNONBLOCK
+#else
+#define NOBLOCK FNDELAY
+#endif
+
+void
+KdResetInputMachine (void)
+{
+ KdPointerInfo *pi;
+
+ for (pi = kdPointers; pi; pi = pi->next) {
+ pi->mouseState = start;
+ pi->eventHeld = FALSE;
+ }
+}
+
+static void
+KdNonBlockFd (int fd)
+{
+ int flags;
+ flags = fcntl (fd, F_GETFL);
+ flags |= FASYNC|NOBLOCK;
+ fcntl (fd, F_SETFL, flags);
+}
+
+static void
+KdAddFd (int fd)
+{
+ struct sigaction act;
+ sigset_t set;
+
+ kdnFds++;
+ fcntl (fd, F_SETOWN, getpid());
+ KdNonBlockFd (fd);
+ AddEnabledDevice (fd);
+ memset (&act, '\0', sizeof act);
+ act.sa_handler = KdSigio;
+ sigemptyset (&act.sa_mask);
+ sigaddset (&act.sa_mask, SIGIO);
+ sigaddset (&act.sa_mask, SIGALRM);
+ sigaddset (&act.sa_mask, SIGVTALRM);
+ sigaction (SIGIO, &act, 0);
+ sigemptyset (&set);
+ sigprocmask (SIG_SETMASK, &set, 0);
+}
+
+static void
+KdRemoveFd (int fd)
+{
+ struct sigaction act;
+ int flags;
+
+ kdnFds--;
+ RemoveEnabledDevice (fd);
+ flags = fcntl (fd, F_GETFL);
+ flags &= ~(FASYNC|NOBLOCK);
+ fcntl (fd, F_SETFL, flags);
+ if (kdnFds == 0)
+ {
+ memset (&act, '\0', sizeof act);
+ act.sa_handler = SIG_IGN;
+ sigemptyset (&act.sa_mask);
+ sigaction (SIGIO, &act, 0);
+ }
+}
+
+Bool
+KdRegisterFd (int fd, void (*read) (int fd, void *closure), void *closure)
+{
+ if (kdNumInputFds == KD_MAX_INPUT_FDS)
+ return FALSE;
+ kdInputFds[kdNumInputFds].fd = fd;
+ kdInputFds[kdNumInputFds].read = read;
+ kdInputFds[kdNumInputFds].enable = 0;
+ kdInputFds[kdNumInputFds].disable = 0;
+ kdInputFds[kdNumInputFds].closure = closure;
+ kdNumInputFds++;
+ if (kdInputEnabled)
+ KdAddFd (fd);
+ return TRUE;
+}
+
+void
+KdUnregisterFd (void *closure, int fd, Bool do_close)
+{
+ int i, j;
+
+ for (i = 0; i < kdNumInputFds; i++) {
+ if (kdInputFds[i].closure == closure &&
+ (fd == -1 || kdInputFds[i].fd == fd)) {
+ if (kdInputEnabled)
+ KdRemoveFd (kdInputFds[i].fd);
+ if (do_close)
+ close (kdInputFds[i].fd);
+ kdNumInputFds--;
+ for (j = i; j < kdNumInputFds; j++)
+ kdInputFds[j] = kdInputFds[j+1];
+ break;
+ }
+ }
+}
+
+void
+KdUnregisterFds (void *closure, Bool do_close)
+{
+ KdUnregisterFd(closure, -1, do_close);
+}
+
+void
+KdDisableInput (void)
+{
+ KdKeyboardInfo *ki;
+ KdPointerInfo *pi;
+ int found = 0, i = 0;
+
+ KdBlockSigio();
+
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ if (ki->driver && ki->driver->Disable)
+ (*ki->driver->Disable) (ki);
+ }
+
+ for (pi = kdPointers; pi; pi = pi->next) {
+ if (pi->driver && pi->driver->Disable)
+ (*pi->driver->Disable) (pi);
+ }
+
+ if (kdNumInputFds) {
+ ErrorF("[KdDisableInput] Buggy drivers: still %d input fds left!",
+ kdNumInputFds);
+ i = 0;
+ while (i < kdNumInputFds) {
+ found = 0;
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ if (ki == kdInputFds[i].closure) {
+ ErrorF(" fd %d belongs to keybd driver %s\n",
+ kdInputFds[i].fd,
+ ki->driver && ki->driver->name ?
+ ki->driver->name : "(unnamed!)");
+ found = 1;
+ break;
+ }
+ }
+
+ if (found) {
+ i++;
+ continue;
+ }
+
+ for (pi = kdPointers; pi; pi = pi->next) {
+ if (pi == kdInputFds[i].closure) {
+ ErrorF(" fd %d belongs to pointer driver %s\n",
+ kdInputFds[i].fd,
+ pi->driver && pi->driver->name ?
+ pi->driver->name : "(unnamed!)");
+ break;
+ }
+ }
+
+ if (found) {
+ i++;
+ continue;
+ }
+
+ ErrorF(" fd %d not claimed by any active device!\n",
+ kdInputFds[i].fd);
+ KdUnregisterFd(kdInputFds[i].closure, kdInputFds[i].fd, TRUE);
+ }
+ }
+
+ kdInputEnabled = FALSE;
+}
+
+void
+KdEnableInput (void)
+{
+ xEvent xE;
+ KdKeyboardInfo *ki;
+ KdPointerInfo *pi;
+
+ kdInputEnabled = TRUE;
+
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ if (ki->driver && ki->driver->Enable)
+ (*ki->driver->Enable) (ki);
+ }
+
+ for (pi = kdPointers; pi; pi = pi->next) {
+ if (pi->driver && pi->driver->Enable)
+ (*pi->driver->Enable) (pi);
+ }
+
+ /* reset screen saver */
+ xE.u.keyButtonPointer.time = GetTimeInMillis ();
+ NoticeEventTime (&xE);
+
+ KdUnblockSigio ();
+}
+
+static KdKeyboardDriver *
+KdFindKeyboardDriver (char *name)
+{
+ KdKeyboardDriver *ret;
+
+ /* ask a stupid question ... */
+ if (!name)
+ return NULL;
+
+ for (ret = kdKeyboardDrivers; ret; ret = ret->next) {
+ if (strcmp(ret->name, name) == 0)
+ return ret;
+ }
+
+ return NULL;
+}
+
+static KdPointerDriver *
+KdFindPointerDriver (char *name)
+{
+ KdPointerDriver *ret;
+
+ /* ask a stupid question ... */
+ if (!name)
+ return NULL;
+
+ for (ret = kdPointerDrivers; ret; ret = ret->next) {
+ if (strcmp(ret->name, name) == 0)
+ return ret;
+ }
+
+ return NULL;
+}
+
+static int
+KdPointerProc(DeviceIntPtr pDevice, int onoff)
+{
+ DevicePtr pDev = (DevicePtr)pDevice;
+ KdPointerInfo *pi;
+ Atom xiclass;
+
+ if (!pDev)
+ return BadImplementation;
+
+ for (pi = kdPointers; pi; pi = pi->next) {
+ if (pi->dixdev && pi->dixdev->id == pDevice->id)
+ break;
+ }
+
+ if (!pi || !pi->dixdev || pi->dixdev->id != pDevice->id) {
+ ErrorF("[KdPointerProc] Failed to find pointer for device %d!\n",
+ pDevice->id);
+ return BadImplementation;
+ }
+
+ switch (onoff)
+ {
+ case DEVICE_INIT:
+#ifdef DEBUG
+ ErrorF("initialising pointer %s ...\n", pi->name);
+#endif
+ if (!pi->driver) {
+ if (!pi->driverPrivate) {
+ ErrorF("no driver specified for %s\n", pi->name);
+ return BadImplementation;
+ }
+
+ pi->driver = KdFindPointerDriver(pi->driverPrivate);
+ if (!pi->driver) {
+ ErrorF("Couldn't find pointer driver %s\n",
+ pi->driverPrivate ? (char *) pi->driverPrivate :
+ "(unnamed)");
+ return !Success;
+ }
+ xfree(pi->driverPrivate);
+ pi->driverPrivate = NULL;
+ }
+
+ if (!pi->driver->Init) {
+ ErrorF("no init function\n");
+ return BadImplementation;
+ }
+
+ if ((*pi->driver->Init) (pi) != Success) {
+ return !Success;
+ }
+
+ InitPointerDeviceStruct(pDev, pi->map, pi->nButtons,
+ GetMotionHistory,
+ (PtrCtrlProcPtr)NoopDDA,
+ GetMotionHistorySize(), pi->nAxes);
+
+ if (pi->inputClass == KD_TOUCHSCREEN) {
+ InitAbsoluteClassDeviceStruct(pDevice);
+ xiclass = AtomFromName(XI_TOUCHSCREEN);
+ }
+ else {
+ xiclass = AtomFromName(XI_MOUSE);
+ }
+
+ AssignTypeAndName(pi->dixdev, xiclass,
+ pi->name ? pi->name : "Generic KDrive Pointer");
+
+ return Success;
+
+ case DEVICE_ON:
+ if (pDev->on == TRUE)
+ return Success;
+
+ if (!pi->driver->Enable) {
+ ErrorF("no enable function\n");
+ return BadImplementation;
+ }
+
+ if ((*pi->driver->Enable) (pi) == Success) {
+ pDev->on = TRUE;
+ return Success;
+ }
+ else {
+ return BadImplementation;
+ }
+
+ return Success;
+
+ case DEVICE_OFF:
+ if (pDev->on == FALSE) {
+ return Success;
+ }
+
+ if (!pi->driver->Disable) {
+ return BadImplementation;
+ }
+ else {
+ (*pi->driver->Disable) (pi);
+ pDev->on = FALSE;
+ return Success;
+ }
+
+ return Success;
+
+ case DEVICE_CLOSE:
+ if (pDev->on) {
+ if (!pi->driver->Disable) {
+ return BadImplementation;
+ }
+ (*pi->driver->Disable) (pi);
+ pDev->on = FALSE;
+ }
+
+ if (!pi->driver->Fini)
+ return BadImplementation;
+
+ (*pi->driver->Fini) (pi);
+
+ KdRemovePointer(pi);
+
+ return Success;
+ }
+
+ /* NOTREACHED */
+ return BadImplementation;
+}
+
+Bool
+LegalModifier(unsigned int key, DeviceIntPtr pDev)
+{
+ return TRUE;
+}
+
+static void
+KdBell (int volume, DeviceIntPtr pDev, pointer arg, int something)
+{
+ KeybdCtrl *ctrl = arg;
+ KdKeyboardInfo *ki = NULL;
+
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ if (ki->dixdev && ki->dixdev->id == pDev->id)
+ break;
+ }
+
+ if (!ki || !ki->dixdev || ki->dixdev->id != pDev->id || !ki->driver)
+ return;
+
+ KdRingBell(ki, volume, ctrl->bell_pitch, ctrl->bell_duration);
+}
+
+void
+DDXRingBell(int volume, int pitch, int duration)
+{
+ KdKeyboardInfo *ki = NULL;
+
+ if (kdOsFuncs->Bell) {
+ (*kdOsFuncs->Bell)(volume, pitch, duration);
+ }
+ else {
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ if (ki->dixdev->coreEvents)
+ KdRingBell(ki, volume, pitch, duration);
+ }
+ }
+}
+
+void
+KdRingBell(KdKeyboardInfo *ki, int volume, int pitch, int duration)
+{
+ if (!ki || !ki->driver || !ki->driver->Bell)
+ return;
+
+ if (kdInputEnabled)
+ (*ki->driver->Bell) (ki, volume, pitch, duration);
+}
+
+
+static void
+KdSetLeds (KdKeyboardInfo *ki, int leds)
+{
+ if (!ki || !ki->driver)
+ return;
+
+ if (kdInputEnabled) {
+ if (ki->driver->Leds)
+ (*ki->driver->Leds) (ki, leds);
+ }
+}
+
+void
+KdSetLed (KdKeyboardInfo *ki, int led, Bool on)
+{
+ if (!ki || !ki->dixdev || !ki->dixdev->kbdfeed)
+ return;
+
+ NoteLedState (ki->dixdev, led, on);
+ KdSetLeds (ki, ki->dixdev->kbdfeed->ctrl.leds);
+}
+
+void
+KdSetPointerMatrix (KdPointerMatrix *matrix)
+{
+ kdPointerMatrix = *matrix;
+}
+
+void
+KdComputePointerMatrix (KdPointerMatrix *m, Rotation randr, int width,
+ int height)
+{
+ int x_dir = 1, y_dir = 1;
+ int i, j;
+ int size[2];
+
+ size[0] = width; size[1] = height;
+ if (randr & RR_Reflect_X)
+ x_dir = -1;
+ if (randr & RR_Reflect_Y)
+ y_dir = -1;
+ switch (randr & (RR_Rotate_All)) {
+ case RR_Rotate_0:
+ m->matrix[0][0] = x_dir; m->matrix[0][1] = 0;
+ m->matrix[1][0] = 0; m->matrix[1][1] = y_dir;
+ break;
+ case RR_Rotate_90:
+ m->matrix[0][0] = 0; m->matrix[0][1] = -x_dir;
+ m->matrix[1][0] = y_dir; m->matrix[1][1] = 0;
+ break;
+ case RR_Rotate_180:
+ m->matrix[0][0] = -x_dir; m->matrix[0][1] = 0;
+ m->matrix[1][0] = 0; m->matrix[1][1] = -y_dir;
+ break;
+ case RR_Rotate_270:
+ m->matrix[0][0] = 0; m->matrix[0][1] = x_dir;
+ m->matrix[1][0] = -y_dir; m->matrix[1][1] = 0;
+ break;
+ }
+ for (i = 0; i < 2; i++)
+ {
+ m->matrix[i][2] = 0;
+ for (j = 0 ; j < 2; j++)
+ if (m->matrix[i][j] < 0)
+ m->matrix[i][2] = size[j] - 1;
+ }
+}
+
+void
+KdScreenToPointerCoords (int *x, int *y)
+{
+ int (*m)[3] = kdPointerMatrix.matrix;
+ int div = m[0][1] * m[1][0] - m[1][1] * m[0][0];
+ int sx = *x;
+ int sy = *y;
+
+ *x = (m[0][1] * sy - m[0][1] * m[1][2] + m[1][1] * m[0][2] - m[1][1] * sx) / div;
+ *y = (m[1][0] * sx + m[0][0] * m[1][2] - m[1][0] * m[0][2] - m[0][0] * sy) / div;
+}
+
+static void
+KdKbdCtrl (DeviceIntPtr pDevice, KeybdCtrl *ctrl)
+{
+ KdKeyboardInfo *ki;
+
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ if (ki->dixdev && ki->dixdev->id == pDevice->id)
+ break;
+ }
+
+ if (!ki || !ki->dixdev || ki->dixdev->id != pDevice->id || !ki->driver)
+ return;
+
+ KdSetLeds(ki, ctrl->leds);
+ ki->bellPitch = ctrl->bell_pitch;
+ ki->bellDuration = ctrl->bell_duration;
+}
+
+extern KeybdCtrl defaultKeyboardControl;
+
+static void
+KdInitAutoRepeats (KdKeyboardInfo *ki)
+{
+ int key_code;
+ unsigned char mask;
+ int i;
+ unsigned char *repeats;
+
+ repeats = defaultKeyboardControl.autoRepeats;
+ memset (repeats, '\0', 32);
+ for (key_code = KD_MIN_KEYCODE; key_code <= KD_MAX_KEYCODE; key_code++)
+ {
+ if (!ki->modmap[key_code])
+ {
+ i = key_code >> 3;
+ mask = 1 << (key_code & 7);
+ repeats[i] |= mask;
+ }
+ }
+}
+
+const KdKeySymModsRec kdKeySymMods[] = {
+ { XK_Control_L, ControlMask },
+ { XK_Control_R, ControlMask },
+ { XK_Shift_L, ShiftMask },
+ { XK_Shift_R, ShiftMask },
+ { XK_Caps_Lock, LockMask },
+ { XK_Shift_Lock, LockMask },
+ { XK_Alt_L, Mod1Mask },
+ { XK_Alt_R, Mod1Mask },
+ { XK_Meta_L, Mod1Mask },
+ { XK_Meta_R, Mod1Mask },
+ { XK_Num_Lock, Mod2Mask },
+ { XK_Super_L, Mod3Mask },
+ { XK_Super_R, Mod3Mask },
+ { XK_Hyper_L, Mod3Mask },
+ { XK_Hyper_R, Mod3Mask },
+ { XK_Mode_switch, Mod4Mask },
+ /* PDA specific hacks */
+#ifdef XF86XK_Start
+ { XF86XK_Start, ControlMask },
+#endif
+ { XK_Menu, ShiftMask },
+ { XK_telephone, Mod1Mask },
+#ifdef XF86XK_AudioRecord
+ { XF86XK_AudioRecord, Mod2Mask },
+#endif
+#ifdef XF86XK_Calendar
+ { XF86XK_Calendar, Mod3Mask }
+#endif
+};
+
+#define NUM_SYM_MODS (sizeof(kdKeySymMods) / sizeof(kdKeySymMods[0]))
+
+static void
+KdInitModMap (KdKeyboardInfo *ki)
+{
+ int key_code;
+ int row;
+ int width;
+ KeySym *syms;
+ int i;
+
+ width = ki->keySyms.mapWidth;
+ for (key_code = ki->keySyms.minKeyCode; key_code <= ki->keySyms.maxKeyCode; key_code++)
+ {
+ ki->modmap[key_code] = 0;
+ syms = ki->keySyms.map + (key_code - ki->keySyms.minKeyCode) * width;
+ for (row = 0; row < width; row++, syms++)
+ {
+ for (i = 0; i < NUM_SYM_MODS; i++)
+ {
+ if (*syms == kdKeySymMods[i].modsym)
+ ki->modmap[key_code] |= kdKeySymMods[i].modbit;
+ }
+ }
+ }
+}
+
+static int
+KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
+{
+ Bool ret;
+ DevicePtr pDev = (DevicePtr)pDevice;
+ KdKeyboardInfo *ki;
+ Atom xiclass;
+#ifdef XKB
+ XkbComponentNamesRec names;
+#endif
+
+ if (!pDev)
+ return BadImplementation;
+
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ if (ki->dixdev && ki->dixdev->id == pDevice->id)
+ break;
+ }
+
+ if (!ki || !ki->dixdev || ki->dixdev->id != pDevice->id) {
+ return BadImplementation;
+ }
+
+ switch (onoff)
+ {
+ case DEVICE_INIT:
+#ifdef DEBUG
+ ErrorF("initialising keyboard %s\n", ki->name);
+#endif
+ if (!ki->driver) {
+ if (!ki->driverPrivate) {
+ ErrorF("no driver specified!\n");
+ return BadImplementation;
+ }
+
+ ki->driver = KdFindKeyboardDriver(ki->driverPrivate);
+ if (!ki->driver) {
+ ErrorF("Couldn't find keyboard driver %s\n",
+ ki->driverPrivate ? (char *) ki->driverPrivate :
+ "(unnamed)");
+ return !Success;
+ }
+ xfree(ki->driverPrivate);
+ ki->driverPrivate = NULL;
+ }
+
+ if (!ki->driver->Init) {
+ ErrorF("Keyboard %s: no init function\n", ki->name);
+ return BadImplementation;
+ }
+
+ if ((*ki->driver->Init) (ki) != Success) {
+ return !Success;
+ }
+
+ KdInitModMap(ki);
+ KdInitAutoRepeats(ki);
+
+#ifdef XKB
+ if (!noXkbExtension) {
+ memset(&names, 0, sizeof(XkbComponentNamesRec));
+
+ XkbSetRulesDflts (ki->xkbRules, ki->xkbModel, ki->xkbLayout,
+ ki->xkbVariant, ki->xkbOptions);
+
+ ret = XkbInitKeyboardDeviceStruct (pDevice,
+ &names,
+ &ki->keySyms,
+ ki->modmap,
+ KdBell, KdKbdCtrl);
+ }
+ else
+#endif
+ ret = InitKeyboardDeviceStruct(pDev,
+ &ki->keySyms,
+ ki->modmap,
+ KdBell, KdKbdCtrl);
+ if (!ret) {
+ ErrorF("Couldn't initialise keyboard %s\n", ki->name);
+ return BadImplementation;
+ }
+
+ xiclass = AtomFromName(XI_KEYBOARD);
+ AssignTypeAndName(pDevice, xiclass,
+ ki->name ? ki->name : "Generic KDrive Keyboard");
+
+ KdResetInputMachine();
+
+ return Success;
+
+ case DEVICE_ON:
+ if (pDev->on == TRUE)
+ return Success;
+
+ if (!ki->driver->Enable)
+ return BadImplementation;
+
+ if ((*ki->driver->Enable) (ki) != Success) {
+ return BadMatch;
+ }
+
+ pDev->on = TRUE;
+ return Success;
+
+ case DEVICE_OFF:
+ if (pDev->on == FALSE)
+ return Success;
+
+ if (!ki->driver->Disable)
+ return BadImplementation;
+
+ (*ki->driver->Disable) (ki);
+ pDev->on = FALSE;
+
+ return Success;
+
+ break;
+
+ case DEVICE_CLOSE:
+ if (pDev->on) {
+ if (!ki->driver->Disable)
+ return BadImplementation;
+
+ (*ki->driver->Disable) (ki);
+ pDev->on = FALSE;
+ }
+
+ if (!ki->driver->Fini)
+ return BadImplementation;
+
+ (*ki->driver->Fini) (ki);
+
+ KdRemoveKeyboard(ki);
+
+ return Success;
+ }
+
+ /* NOTREACHED */
+ return BadImplementation;
+}
+
+void
+KdAddPointerDriver (KdPointerDriver *driver)
+{
+ KdPointerDriver **prev;
+
+ if (!driver)
+ return;
+
+ for (prev = &kdPointerDrivers; *prev; prev = &(*prev)->next) {
+ if (*prev == driver)
+ return;
+ }
+ *prev = driver;
+}
+
+void
+KdRemovePointerDriver (KdPointerDriver *driver)
+{
+ KdPointerDriver *tmp;
+
+ if (!driver)
+ return;
+
+ /* FIXME remove all pointers using this driver */
+ for (tmp = kdPointerDrivers; tmp; tmp = tmp->next) {
+ if (tmp->next == driver)
+ tmp->next = driver->next;
+ }
+ if (tmp == driver)
+ tmp = NULL;
+}
+
+void
+KdAddKeyboardDriver (KdKeyboardDriver *driver)
+{
+ KdKeyboardDriver **prev;
+
+ if (!driver)
+ return;
+
+ for (prev = &kdKeyboardDrivers; *prev; prev = &(*prev)->next) {
+ if (*prev == driver)
+ return;
+ }
+ *prev = driver;
+}
+
+void
+KdRemoveKeyboardDriver (KdKeyboardDriver *driver)
+{
+ KdKeyboardDriver *tmp;
+
+ if (!driver)
+ return;
+
+ /* FIXME remove all keyboards using this driver */
+ for (tmp = kdKeyboardDrivers; tmp; tmp = tmp->next) {
+ if (tmp->next == driver)
+ tmp->next = driver->next;
+ }
+ if (tmp == driver)
+ tmp = NULL;
+}
+
+KdKeyboardInfo *
+KdNewKeyboard (void)
+{
+ KdKeyboardInfo *ki = xcalloc(sizeof(KdKeyboardInfo), 1);
+
+ if (!ki)
+ return NULL;
+
+ ki->keySyms.map = (KeySym *)xcalloc(sizeof(KeySym),
+ KD_MAX_LENGTH *
+ kdDefaultKeySyms.mapWidth);
+ if (!ki->keySyms.map) {
+ xfree(ki);
+ return NULL;
+ }
+
+ memcpy(ki->keySyms.map, kdDefaultKeySyms.map,
+ sizeof(KeySym) * (KD_MAX_LENGTH * kdDefaultKeySyms.mapWidth));
+ ki->keySyms.minKeyCode = kdDefaultKeySyms.minKeyCode;
+ ki->keySyms.maxKeyCode = kdDefaultKeySyms.maxKeyCode;
+ ki->keySyms.mapWidth = kdDefaultKeySyms.mapWidth;
+ ki->minScanCode = 0;
+ ki->maxScanCode = 0;
+ ki->leds = 0;
+ ki->bellPitch = 1000;
+ ki->bellDuration = 200;
+ ki->next = NULL;
+ ki->options = NULL;
+#ifdef XKB
+ ki->xkbRules = KdSaveString("base");
+ ki->xkbModel = KdSaveString("pc105");
+ ki->xkbLayout = KdSaveString("us");
+ ki->xkbVariant = NULL;
+ ki->xkbOptions = NULL;
+#endif
+
+ return ki;
+}
+
+int
+KdAddConfigKeyboard (char *keyboard)
+{
+ struct KdConfigDevice **prev, *new;
+
+ if (!keyboard)
+ return Success;
+
+ new = (struct KdConfigDevice *) xcalloc(sizeof(struct KdConfigDevice), 1);
+ if (!new)
+ return BadAlloc;
+
+ new->line = xstrdup(keyboard);
+ new->next = NULL;
+
+ for (prev = &kdConfigKeyboards; *prev; prev = &(*prev)->next);
+ *prev = new;
+
+ return Success;
+}
+
+int
+KdAddKeyboard (KdKeyboardInfo *ki)
+{
+ KdKeyboardInfo **prev;
+
+ if (!ki)
+ return !Success;
+
+ ki->dixdev = AddInputDevice(KdKeyboardProc, TRUE);
+ if (!ki->dixdev) {
+ ErrorF("Couldn't register keyboard device %s\n",
+ ki->name ? ki->name : "(unnamed)");
+ return !Success;
+ }
+
+ RegisterOtherDevice(ki->dixdev);
+
+#ifdef DEBUG
+ ErrorF("added keyboard %s with dix id %d\n", ki->name, ki->dixdev->id);
+#endif
+
+ for (prev = &kdKeyboards; *prev; prev = &(*prev)->next);
+ *prev = ki;
+
+ return Success;
+}
+
+void
+KdRemoveKeyboard (KdKeyboardInfo *ki)
+{
+ KdKeyboardInfo **prev;
+
+ if (!ki)
+ return;
+
+ for (prev = &kdKeyboards; *prev; prev = &(*prev)->next) {
+ if (*prev == ki) {
+ *prev = ki->next;
+ break;
+ }
+ }
+
+ KdFreeKeyboard(ki);
+}
+
+int
+KdAddConfigPointer (char *pointer)
+{
+ struct KdConfigDevice **prev, *new;
+
+ if (!pointer)
+ return Success;
+
+ new = (struct KdConfigDevice *) xcalloc(sizeof(struct KdConfigDevice), 1);
+ if (!new)
+ return BadAlloc;
+
+ new->line = xstrdup(pointer);
+ new->next = NULL;
+
+ for (prev = &kdConfigPointers; *prev; prev = &(*prev)->next);
+ *prev = new;
+
+ return Success;
+}
+
+int
+KdAddPointer (KdPointerInfo *pi)
+{
+ KdPointerInfo **prev;
+
+ if (!pi)
+ return Success;
+
+ pi->mouseState = start;
+ pi->eventHeld = FALSE;
+
+ pi->dixdev = AddInputDevice(KdPointerProc, TRUE);
+ if (!pi->dixdev) {
+ ErrorF("Couldn't add pointer device %s\n",
+ pi->name ? pi->name : "(unnamed)");
+ return BadDevice;
+ }
+
+ RegisterOtherDevice(pi->dixdev);
+
+ for (prev = &kdPointers; *prev; prev = &(*prev)->next);
+ *prev = pi;
+
+ return Success;
+}
+
+void
+KdRemovePointer (KdPointerInfo *pi)
+{
+ KdPointerInfo **prev;
+
+ if (!pi)
+ return;
+
+ for (prev = &kdPointers; *prev; prev = &(*prev)->next) {
+ if (*prev == pi) {
+ *prev = pi->next;
+ break;
+ }
+ }
+
+ KdFreePointer(pi);
+}
+
+/*
+ * You can call your kdriver server with something like:
+ * $ ./hw/kdrive/yourserver/X :1 -mouse evdev,,device=/dev/input/event4 -keybd
+ * evdev,,device=/dev/input/event1,xkbmodel=abnt2,xkblayout=br
+ */
+static Bool
+KdGetOptions (InputOption **options, char *string)
+{
+ InputOption *newopt = NULL, **tmpo = NULL;
+ int tam_key = 0;
+
+ newopt = (InputOption *) xalloc(sizeof (InputOption));
+ if (!newopt)
+ return FALSE;
+
+ bzero(newopt, sizeof (InputOption));
+
+ for (tmpo = options; *tmpo; tmpo = &(*tmpo)->next)
+ ; /* Hello, I'm here */
+ *tmpo = newopt;
+
+ if (strchr(string, '='))
+ {
+ tam_key = (strchr(string, '=') - string);
+ newopt->key = (char *)xalloc(tam_key);
+ strncpy(newopt->key, string, tam_key);
+ newopt->key[tam_key] = '\0';
+ newopt->value = xstrdup(strchr(string, '=') + 1);
+ }
+ else
+ {
+ newopt->key = xstrdup(string);
+ newopt->value = NULL;
+ }
+ newopt->next = NULL;
+
+ return TRUE;
+}
+
+static void
+KdParseKbdOptions (KdKeyboardInfo *ki)
+{
+ InputOption *option = NULL;
+
+ for (option = ki->options; option; option = option->next)
+ {
+#ifdef XKB
+ if (strcasecmp(option->key, "XkbRules") == 0)
+ ki->xkbRules = option->value;
+ else if (strcasecmp(option->key, "XkbModel") == 0)
+ ki->xkbModel = option->value;
+ else if (strcasecmp(option->key, "XkbLayout") == 0)
+ ki->xkbLayout = option->value;
+ else if (strcasecmp(option->key, "XkbVariant") == 0)
+ ki->xkbVariant = option->value;
+ else if (strcasecmp(option->key, "XkbOptions") == 0)
+ ki->xkbOptions = option->value;
+ else if (!strcasecmp (option->key, "device"))
+ ki->path = KdSaveString(option->value);
+ else
+#endif
+ ErrorF("Kbd option key (%s) of value (%s) not assigned!\n",
+ option->key, option->value);
+ }
+}
+
+KdKeyboardInfo *
+KdParseKeyboard (char *arg)
+{
+ char save[1024];
+ char delim;
+ InputOption *options = NULL;
+ KdKeyboardInfo *ki = NULL;
+
+ ki = KdNewKeyboard();
+ if (!ki)
+ return NULL;
+
+ ki->name = strdup("Unknown KDrive Keyboard");
+ ki->path = NULL;
+ ki->driver = NULL;
+ ki->driverPrivate = NULL;
+#ifdef XKB
+ ki->xkb = NULL;
+#endif
+ ki->next = NULL;
+
+ if (!arg)
+ {
+ ErrorF("keybd: no arg\n");
+ KdFreeKeyboard (ki);
+ return NULL;
+ }
+
+ if (strlen (arg) >= sizeof (save))
+ {
+ ErrorF("keybd: arg too long\n");
+ KdFreeKeyboard (ki);
+ return NULL;
+ }
+
+ arg = KdParseFindNext (arg, ",", save, &delim);
+ if (!save[0])
+ {
+ ErrorF("keybd: failed on save[0]\n");
+ KdFreeKeyboard (ki);
+ return NULL;
+ }
+
+ if (strcmp (save, "auto") == 0)
+ ki->driverPrivate = NULL;
+ else
+ ki->driverPrivate = xstrdup(save);
+
+ if (delim != ',')
+ {
+ return ki;
+ }
+
+ arg = KdParseFindNext (arg, ",", save, &delim);
+
+ while (delim == ',')
+ {
+ arg = KdParseFindNext (arg, ",", save, &delim);
+
+ if (!KdGetOptions(&options, save))
+ {
+ KdFreeKeyboard(ki);
+ return NULL;
+ }
+ }
+
+ if (options)
+ {
+ ki->options = options;
+ KdParseKbdOptions(ki);
+ }
+
+ return ki;
+}
+
+static void
+KdParsePointerOptions (KdPointerInfo *pi)
+{
+ InputOption *option = NULL;
+
+ for (option = pi->options; option; option = option->next)
+ {
+ if (!strcmp (option->key, "emulatemiddle"))
+ pi->emulateMiddleButton = TRUE;
+ else if (!strcmp (option->key, "noemulatemiddle"))
+ pi->emulateMiddleButton = FALSE;
+ else if (!strcmp (option->key, "transformcoord"))
+ pi->transformCoordinates = TRUE;
+ else if (!strcmp (option->key, "rawcoord"))
+ pi->transformCoordinates = FALSE;
+ else if (!strcasecmp (option->key, "device"))
+ pi->path = KdSaveString(option->value);
+ else
+ ErrorF("Pointer option key (%s) of value (%s) not assigned!\n",
+ option->key, option->value);
+ }
+}
+
+KdPointerInfo *
+KdParsePointer (char *arg)
+{
+ char save[1024];
+ char delim;
+ KdPointerInfo *pi = NULL;
+ InputOption *options = NULL;
+ int i = 0;
+
+ pi = KdNewPointer();
+ if (!pi)
+ return NULL;
+ pi->emulateMiddleButton = kdEmulateMiddleButton;
+ pi->transformCoordinates = !kdRawPointerCoordinates;
+ pi->nButtons = 5; /* XXX should not be hardcoded */
+ pi->inputClass = KD_MOUSE;
+
+ if (!arg)
+ {
+ ErrorF("mouse: no arg\n");
+ KdFreePointer (pi);
+ return NULL;
+ }
+
+ if (strlen (arg) >= sizeof (save))
+ {
+ ErrorF("mouse: arg too long\n");
+ KdFreePointer (pi);
+ return NULL;
+ }
+ arg = KdParseFindNext (arg, ",", save, &delim);
+ if (!save[0])
+ {
+ ErrorF("failed on save[0]\n");
+ KdFreePointer (pi);
+ return NULL;
+ }
+
+ if (strcmp(save, "auto") == 0)
+ pi->driverPrivate = NULL;
+ else
+ pi->driverPrivate = xstrdup(save);
+
+ if (delim != ',')
+ {
+ return pi;
+ }
+
+ arg = KdParseFindNext (arg, ",", save, &delim);
+
+ while (delim == ',')
+ {
+ arg = KdParseFindNext (arg, ",", save, &delim);
+ if (save[0] == '{')
+ {
+ char *s = save + 1;
+ i = 0;
+ while (*s && *s != '}')
+ {
+ if ('1' <= *s && *s <= '0' + pi->nButtons)
+ pi->map[i] = *s - '0';
+ else
+ UseMsg ();
+ s++;
+ }
+ }
+ else
+ {
+ if (!KdGetOptions(&options, save))
+ {
+ KdFreePointer(pi);
+ return NULL;
+ }
+ }
+ }
+
+ if (options)
+ {
+ pi->options = options;
+ KdParsePointerOptions(pi);
+ }
+
+ return pi;
+}
+
+
+void
+KdInitInput (void)
+{
+ KdPointerInfo *pi;
+ KdKeyboardInfo *ki;
+ struct KdConfigDevice *dev;
+
+ kdInputEnabled = TRUE;
+
+ for (dev = kdConfigPointers; dev; dev = dev->next) {
+ pi = KdParsePointer(dev->line);
+ if (!pi)
+ ErrorF("Failed to parse pointer\n");
+ if (KdAddPointer(pi) != Success)
+ ErrorF("Failed to add pointer!\n");
+ }
+ for (dev = kdConfigKeyboards; dev; dev = dev->next) {
+ ki = KdParseKeyboard(dev->line);
+ if (!ki)
+ ErrorF("Failed to parse keyboard\n");
+ if (KdAddKeyboard(ki) != Success)
+ ErrorF("Failed to add keyboard!\n");
+ }
+
+ if (!kdEvents)
+ kdEvents = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+ if (!kdEvents)
+ FatalError("Couldn't allocate event buffer\n");
+
+ mieqInit();
+}
+
+/*
+ * Middle button emulation state machine
+ *
+ * Possible transitions:
+ * Button 1 press v1
+ * Button 1 release ^1
+ * Button 2 press v2
+ * Button 2 release ^2
+ * Button 3 press v3
+ * Button 3 release ^3
+ * Button other press vo
+ * Button other release ^o
+ * Mouse motion <>
+ * Keyboard event k
+ * timeout ...
+ * outside box <->
+ *
+ * States:
+ * start
+ * button_1_pend
+ * button_1_down
+ * button_2_down
+ * button_3_pend
+ * button_3_down
+ * synthetic_2_down_13
+ * synthetic_2_down_3
+ * synthetic_2_down_1
+ *
+ * Transition diagram
+ *
+ * start
+ * v1 -> (hold) (settimeout) button_1_pend
+ * ^1 -> (deliver) start
+ * v2 -> (deliver) button_2_down
+ * ^2 -> (deliever) start
+ * v3 -> (hold) (settimeout) button_3_pend
+ * ^3 -> (deliver) start
+ * vo -> (deliver) start
+ * ^o -> (deliver) start
+ * <> -> (deliver) start
+ * k -> (deliver) start
+ *
+ * button_1_pend (button 1 is down, timeout pending)
+ * ^1 -> (release) (deliver) start
+ * v2 -> (release) (deliver) button_1_down
+ * ^2 -> (release) (deliver) button_1_down
+ * v3 -> (cleartimeout) (generate v2) synthetic_2_down_13
+ * ^3 -> (release) (deliver) button_1_down
+ * vo -> (release) (deliver) button_1_down
+ * ^o -> (release) (deliver) button_1_down
+ * <-> -> (release) (deliver) button_1_down
+ * <> -> (deliver) button_1_pend
+ * k -> (release) (deliver) button_1_down
+ * ... -> (release) button_1_down
+ *
+ * button_1_down (button 1 is down)
+ * ^1 -> (deliver) start
+ * v2 -> (deliver) button_1_down
+ * ^2 -> (deliver) button_1_down
+ * v3 -> (deliver) button_1_down
+ * ^3 -> (deliver) button_1_down
+ * vo -> (deliver) button_1_down
+ * ^o -> (deliver) button_1_down
+ * <> -> (deliver) button_1_down
+ * k -> (deliver) button_1_down
+ *
+ * button_2_down (button 2 is down)
+ * v1 -> (deliver) button_2_down
+ * ^1 -> (deliver) button_2_down
+ * ^2 -> (deliver) start
+ * v3 -> (deliver) button_2_down
+ * ^3 -> (deliver) button_2_down
+ * vo -> (deliver) button_2_down
+ * ^o -> (deliver) button_2_down
+ * <> -> (deliver) button_2_down
+ * k -> (deliver) button_2_down
+ *
+ * button_3_pend (button 3 is down, timeout pending)
+ * v1 -> (generate v2) synthetic_2_down
+ * ^1 -> (release) (deliver) button_3_down
+ * v2 -> (release) (deliver) button_3_down
+ * ^2 -> (release) (deliver) button_3_down
+ * ^3 -> (release) (deliver) start
+ * vo -> (release) (deliver) button_3_down
+ * ^o -> (release) (deliver) button_3_down
+ * <-> -> (release) (deliver) button_3_down
+ * <> -> (deliver) button_3_pend
+ * k -> (release) (deliver) button_3_down
+ * ... -> (release) button_3_down
+ *
+ * button_3_down (button 3 is down)
+ * v1 -> (deliver) button_3_down
+ * ^1 -> (deliver) button_3_down
+ * v2 -> (deliver) button_3_down
+ * ^2 -> (deliver) button_3_down
+ * ^3 -> (deliver) start
+ * vo -> (deliver) button_3_down
+ * ^o -> (deliver) button_3_down
+ * <> -> (deliver) button_3_down
+ * k -> (deliver) button_3_down
+ *
+ * synthetic_2_down_13 (button 1 and 3 are down)
+ * ^1 -> (generate ^2) synthetic_2_down_3
+ * v2 -> synthetic_2_down_13
+ * ^2 -> synthetic_2_down_13
+ * ^3 -> (generate ^2) synthetic_2_down_1
+ * vo -> (deliver) synthetic_2_down_13
+ * ^o -> (deliver) synthetic_2_down_13
+ * <> -> (deliver) synthetic_2_down_13
+ * k -> (deliver) synthetic_2_down_13
+ *
+ * synthetic_2_down_3 (button 3 is down)
+ * v1 -> (deliver) synthetic_2_down_3
+ * ^1 -> (deliver) synthetic_2_down_3
+ * v2 -> synthetic_2_down_3
+ * ^2 -> synthetic_2_down_3
+ * ^3 -> start
+ * vo -> (deliver) synthetic_2_down_3
+ * ^o -> (deliver) synthetic_2_down_3
+ * <> -> (deliver) synthetic_2_down_3
+ * k -> (deliver) synthetic_2_down_3
+ *
+ * synthetic_2_down_1 (button 1 is down)
+ * ^1 -> start
+ * v2 -> synthetic_2_down_1
+ * ^2 -> synthetic_2_down_1
+ * v3 -> (deliver) synthetic_2_down_1
+ * ^3 -> (deliver) synthetic_2_down_1
+ * vo -> (deliver) synthetic_2_down_1
+ * ^o -> (deliver) synthetic_2_down_1
+ * <> -> (deliver) synthetic_2_down_1
+ * k -> (deliver) synthetic_2_down_1
+ */
+
+typedef enum _inputClass {
+ down_1, up_1,
+ down_2, up_2,
+ down_3, up_3,
+ down_o, up_o,
+ motion, outside_box,
+ keyboard, timeout,
+ num_input_class
+} KdInputClass;
+
+typedef enum _inputAction {
+ noop,
+ hold,
+ setto,
+ deliver,
+ release,
+ clearto,
+ gen_down_2,
+ gen_up_2
+} KdInputAction;
+
+#define MAX_ACTIONS 2
+
+typedef struct _inputTransition {
+ KdInputAction actions[MAX_ACTIONS];
+ KdPointerState nextState;
+} KdInputTransition;
+
+static const
+KdInputTransition kdInputMachine[num_input_states][num_input_class] = {
+ /* start */
+ {
+ { { hold, setto }, button_1_pend }, /* v1 */
+ { { deliver, noop }, start }, /* ^1 */
+ { { deliver, noop }, button_2_down }, /* v2 */
+ { { deliver, noop }, start }, /* ^2 */
+ { { hold, setto }, button_3_pend }, /* v3 */
+ { { deliver, noop }, start }, /* ^3 */
+ { { deliver, noop }, start }, /* vo */
+ { { deliver, noop }, start }, /* ^o */
+ { { deliver, noop }, start }, /* <> */
+ { { deliver, noop }, start }, /* <-> */
+ { { noop, noop }, start }, /* k */
+ { { noop, noop }, start }, /* ... */
+ },
+ /* button_1_pend */
+ {
+ { { noop, noop }, button_1_pend }, /* v1 */
+ { { release, deliver }, start }, /* ^1 */
+ { { release, deliver }, button_1_down }, /* v2 */
+ { { release, deliver }, button_1_down }, /* ^2 */
+ { { clearto, gen_down_2 }, synth_2_down_13 }, /* v3 */
+ { { release, deliver }, button_1_down }, /* ^3 */
+ { { release, deliver }, button_1_down }, /* vo */
+ { { release, deliver }, button_1_down }, /* ^o */
+ { { deliver, noop }, button_1_pend }, /* <> */
+ { { release, deliver }, button_1_down }, /* <-> */
+ { { noop, noop }, button_1_down }, /* k */
+ { { release, noop }, button_1_down }, /* ... */
+ },
+ /* button_1_down */
+ {
+ { { noop, noop }, button_1_down }, /* v1 */
+ { { deliver, noop }, start }, /* ^1 */
+ { { deliver, noop }, button_1_down }, /* v2 */
+ { { deliver, noop }, button_1_down }, /* ^2 */
+ { { deliver, noop }, button_1_down }, /* v3 */
+ { { deliver, noop }, button_1_down }, /* ^3 */
+ { { deliver, noop }, button_1_down }, /* vo */
+ { { deliver, noop }, button_1_down }, /* ^o */
+ { { deliver, noop }, button_1_down }, /* <> */
+ { { deliver, noop }, button_1_down }, /* <-> */
+ { { noop, noop }, button_1_down }, /* k */
+ { { noop, noop }, button_1_down }, /* ... */
+ },
+ /* button_2_down */
+ {
+ { { deliver, noop }, button_2_down }, /* v1 */
+ { { deliver, noop }, button_2_down }, /* ^1 */
+ { { noop, noop }, button_2_down }, /* v2 */
+ { { deliver, noop }, start }, /* ^2 */
+ { { deliver, noop }, button_2_down }, /* v3 */
+ { { deliver, noop }, button_2_down }, /* ^3 */
+ { { deliver, noop }, button_2_down }, /* vo */
+ { { deliver, noop }, button_2_down }, /* ^o */
+ { { deliver, noop }, button_2_down }, /* <> */
+ { { deliver, noop }, button_2_down }, /* <-> */
+ { { noop, noop }, button_2_down }, /* k */
+ { { noop, noop }, button_2_down }, /* ... */
+ },
+ /* button_3_pend */
+ {
+ { { clearto, gen_down_2 }, synth_2_down_13 }, /* v1 */
+ { { release, deliver }, button_3_down }, /* ^1 */
+ { { release, deliver }, button_3_down }, /* v2 */
+ { { release, deliver }, button_3_down }, /* ^2 */
+ { { release, deliver }, button_3_down }, /* v3 */
+ { { release, deliver }, start }, /* ^3 */
+ { { release, deliver }, button_3_down }, /* vo */
+ { { release, deliver }, button_3_down }, /* ^o */
+ { { deliver, noop }, button_3_pend }, /* <> */
+ { { release, deliver }, button_3_down }, /* <-> */
+ { { release, noop }, button_3_down }, /* k */
+ { { release, noop }, button_3_down }, /* ... */
+ },
+ /* button_3_down */
+ {
+ { { deliver, noop }, button_3_down }, /* v1 */
+ { { deliver, noop }, button_3_down }, /* ^1 */
+ { { deliver, noop }, button_3_down }, /* v2 */
+ { { deliver, noop }, button_3_down }, /* ^2 */
+ { { noop, noop }, button_3_down }, /* v3 */
+ { { deliver, noop }, start }, /* ^3 */
+ { { deliver, noop }, button_3_down }, /* vo */
+ { { deliver, noop }, button_3_down }, /* ^o */
+ { { deliver, noop }, button_3_down }, /* <> */
+ { { deliver, noop }, button_3_down }, /* <-> */
+ { { noop, noop }, button_3_down }, /* k */
+ { { noop, noop }, button_3_down }, /* ... */
+ },
+ /* synthetic_2_down_13 */
+ {
+ { { noop, noop }, synth_2_down_13 }, /* v1 */
+ { { gen_up_2, noop }, synth_2_down_3 }, /* ^1 */
+ { { noop, noop }, synth_2_down_13 }, /* v2 */
+ { { noop, noop }, synth_2_down_13 }, /* ^2 */
+ { { noop, noop }, synth_2_down_13 }, /* v3 */
+ { { gen_up_2, noop }, synth_2_down_1 }, /* ^3 */
+ { { deliver, noop }, synth_2_down_13 }, /* vo */
+ { { deliver, noop }, synth_2_down_13 }, /* ^o */
+ { { deliver, noop }, synth_2_down_13 }, /* <> */
+ { { deliver, noop }, synth_2_down_13 }, /* <-> */
+ { { noop, noop }, synth_2_down_13 }, /* k */
+ { { noop, noop }, synth_2_down_13 }, /* ... */
+ },
+ /* synthetic_2_down_3 */
+ {
+ { { deliver, noop }, synth_2_down_3 }, /* v1 */
+ { { deliver, noop }, synth_2_down_3 }, /* ^1 */
+ { { deliver, noop }, synth_2_down_3 }, /* v2 */
+ { { deliver, noop }, synth_2_down_3 }, /* ^2 */
+ { { noop, noop }, synth_2_down_3 }, /* v3 */
+ { { noop, noop }, start }, /* ^3 */
+ { { deliver, noop }, synth_2_down_3 }, /* vo */
+ { { deliver, noop }, synth_2_down_3 }, /* ^o */
+ { { deliver, noop }, synth_2_down_3 }, /* <> */
+ { { deliver, noop }, synth_2_down_3 }, /* <-> */
+ { { noop, noop }, synth_2_down_3 }, /* k */
+ { { noop, noop }, synth_2_down_3 }, /* ... */
+ },
+ /* synthetic_2_down_1 */
+ {
+ { { noop, noop }, synth_2_down_1 }, /* v1 */
+ { { noop, noop }, start }, /* ^1 */
+ { { deliver, noop }, synth_2_down_1 }, /* v2 */
+ { { deliver, noop }, synth_2_down_1 }, /* ^2 */
+ { { deliver, noop }, synth_2_down_1 }, /* v3 */
+ { { deliver, noop }, synth_2_down_1 }, /* ^3 */
+ { { deliver, noop }, synth_2_down_1 }, /* vo */
+ { { deliver, noop }, synth_2_down_1 }, /* ^o */
+ { { deliver, noop }, synth_2_down_1 }, /* <> */
+ { { deliver, noop }, synth_2_down_1 }, /* <-> */
+ { { noop, noop }, synth_2_down_1 }, /* k */
+ { { noop, noop }, synth_2_down_1 }, /* ... */
+ },
+};
+
+#define EMULATION_WINDOW 10
+#define EMULATION_TIMEOUT 100
+
+static int
+KdInsideEmulationWindow (KdPointerInfo *pi, int x, int y, int z)
+{
+ pi->emulationDx = pi->heldEvent.x - x;
+ pi->emulationDy = pi->heldEvent.y - y;
+
+ return (abs (pi->emulationDx) < EMULATION_WINDOW &&
+ abs (pi->emulationDy) < EMULATION_WINDOW);
+}
+
+static KdInputClass
+KdClassifyInput (KdPointerInfo *pi, int type, int x, int y, int z, int b)
+{
+ switch (type) {
+ case ButtonPress:
+ switch (b) {
+ case 1: return down_1;
+ case 2: return down_2;
+ case 3: return down_3;
+ default: return down_o;
+ }
+ break;
+ case ButtonRelease:
+ switch (b) {
+ case 1: return up_1;
+ case 2: return up_2;
+ case 3: return up_3;
+ default: return up_o;
+ }
+ break;
+ case MotionNotify:
+ if (pi->eventHeld && !KdInsideEmulationWindow(pi, x, y, z))
+ return outside_box;
+ else
+ return motion;
+ default:
+ return keyboard;
+ }
+ return keyboard;
+}
+
+#ifndef NDEBUG
+char *kdStateNames[] = {
+ "start",
+ "button_1_pend",
+ "button_1_down",
+ "button_2_down",
+ "button_3_pend",
+ "button_3_down",
+ "synth_2_down_13",
+ "synth_2_down_3",
+ "synthetic_2_down_1",
+ "num_input_states"
+};
+
+char *kdClassNames[] = {
+ "down_1", "up_1",
+ "down_2", "up_2",
+ "down_3", "up_3",
+ "motion", "ouside_box",
+ "keyboard", "timeout",
+ "num_input_class"
+};
+
+char *kdActionNames[] = {
+ "noop",
+ "hold",
+ "setto",
+ "deliver",
+ "release",
+ "clearto",
+ "gen_down_2",
+ "gen_up_2",
+};
+#endif
+
+static void
+KdQueueEvent (DeviceIntPtr pDev, xEvent *ev)
+{
+ KdAssertSigioBlocked ("KdQueueEvent");
+ mieqEnqueue (pDev, ev);
+}
+
+/* We return true if we're stealing the event. */
+static Bool
+KdRunMouseMachine (KdPointerInfo *pi, KdInputClass c, int type, int x, int y,
+ int z, int b, int absrel)
+{
+ const KdInputTransition *t;
+ int a;
+
+ c = KdClassifyInput(pi, type, x, y, z, b);
+ t = &kdInputMachine[pi->mouseState][c];
+ for (a = 0; a < MAX_ACTIONS; a++)
+ {
+ switch (t->actions[a]) {
+ case noop:
+ break;
+ case hold:
+ pi->eventHeld = TRUE;
+ pi->emulationDx = 0;
+ pi->emulationDy = 0;
+ pi->heldEvent.type = type;
+ pi->heldEvent.x = x;
+ pi->heldEvent.y = y;
+ pi->heldEvent.z = z;
+ pi->heldEvent.flags = b;
+ pi->heldEvent.absrel = absrel;
+ return TRUE;
+ break;
+ case setto:
+ pi->emulationTimeout = GetTimeInMillis () + EMULATION_TIMEOUT;
+ pi->timeoutPending = TRUE;
+ break;
+ case deliver:
+ _KdEnqueuePointerEvent (pi, pi->heldEvent.type, pi->heldEvent.x,
+ pi->heldEvent.y, pi->heldEvent.z,
+ pi->heldEvent.flags, pi->heldEvent.absrel,
+ TRUE);
+ break;
+ case release:
+ pi->eventHeld = FALSE;
+ pi->timeoutPending = FALSE;
+ _KdEnqueuePointerEvent (pi, pi->heldEvent.type, pi->heldEvent.x,
+ pi->heldEvent.y, pi->heldEvent.z,
+ pi->heldEvent.flags, pi->heldEvent.absrel,
+ TRUE);
+ return TRUE;
+ break;
+ case clearto:
+ pi->timeoutPending = FALSE;
+ break;
+ case gen_down_2:
+ _KdEnqueuePointerEvent (pi, ButtonPress, x, y, z, 2, absrel,
+ TRUE);
+ pi->eventHeld = FALSE;
+ return TRUE;
+ break;
+ case gen_up_2:
+ _KdEnqueuePointerEvent (pi, ButtonRelease, x, y, z, 2, absrel,
+ TRUE);
+ return TRUE;
+ break;
+ }
+ }
+ pi->mouseState = t->nextState;
+ return FALSE;
+}
+
+static int
+KdHandlePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z, int b,
+ int absrel)
+{
+ if (pi->emulateMiddleButton)
+ return KdRunMouseMachine (pi, KdClassifyInput(pi, type, x, y, z, b),
+ type, x, y, z, b, absrel);
+ return FALSE;
+}
+
+static void
+KdReceiveTimeout (KdPointerInfo *pi)
+{
+ KdRunMouseMachine (pi, timeout, 0, 0, 0, 0, 0, 0);
+}
+
+#define KILL_SEQUENCE ((1L << KK_CONTROL)|(1L << KK_ALT)|(1L << KK_F8)|(1L << KK_F10))
+#define SPECIAL_SEQUENCE ((1L << KK_CONTROL) | (1L << KK_ALT))
+#define SETKILLKEY(b) (KdSpecialKeys |= (1L << (b)))
+#define CLEARKILLKEY(b) (KdSpecialKeys &= ~(1L << (b)))
+
+CARD32 KdSpecialKeys = 0;
+
+/*
+ * kdCheckTermination
+ *
+ * This function checks for the key sequence that terminates the server. When
+ * detected, it sets the dispatchException flag and returns. The key sequence
+ * is:
+ * Control-Alt
+ * It's assumed that the server will be waken up by the caller when this
+ * function returns.
+ */
+
+extern int nClients;
+
+static void
+KdCheckSpecialKeys(KdKeyboardInfo *ki, int type, int sym)
+{
+ if (!ki)
+ return;
+
+ /*
+ * Ignore key releases
+ */
+
+ if (type == KeyRelease)
+ return;
+
+ /* Some iPaq keyboard -> mouse button mapping used to be here, but I
+ * refuse to perpetuate this madness. -daniels */
+
+ /*
+ * Check for control/alt pressed
+ */
+ if ((ki->dixdev->key->state & (ControlMask|Mod1Mask)) !=
+ (ControlMask|Mod1Mask))
+ return;
+
+ /*
+ * Let OS function see keysym first
+ */
+
+ if (kdOsFuncs->SpecialKey)
+ if ((*kdOsFuncs->SpecialKey) (sym))
+ return;
+
+ /*
+ * Now check for backspace or delete; these signal the
+ * X server to terminate
+ *
+ * I can't believe it's not XKB. -daniels
+ */
+ switch (sym) {
+ case XK_BackSpace:
+ case XK_Delete:
+ case XK_KP_Delete:
+ /*
+ * Set the dispatch exception flag so the server will terminate the
+ * next time through the dispatch loop.
+ */
+ if (kdDontZap == FALSE)
+ dispatchException |= DE_TERMINATE;
+ break;
+ }
+}
+
+/*
+ * kdEnqueueKeyboardEvent
+ *
+ * This function converts hardware keyboard event information into an X event
+ * and enqueues it using MI. It wakes up the server before returning so that
+ * the event will be processed normally.
+ *
+ */
+
+static void
+KdHandleKeyboardEvent (KdKeyboardInfo *ki, int type, int key)
+{
+ int byte;
+ CARD8 bit;
+ KdPointerInfo *pi;
+
+ byte = key >> 3;
+ bit = 1 << (key & 7);
+
+ switch (type) {
+ case KeyPress:
+ ki->keyState[byte] |= bit;
+ break;
+ case KeyRelease:
+ ki->keyState[byte] &= ~bit;
+ break;
+ }
+
+ for (pi = kdPointers; pi; pi = pi->next)
+ KdRunMouseMachine (pi, keyboard, 0, 0, 0, 0, 0, 0);
+}
+
+void
+KdReleaseAllKeys (void)
+{
+ int key, nEvents, i;
+ KdKeyboardInfo *ki;
+
+ KdBlockSigio ();
+
+ for (ki = kdKeyboards; ki; ki = ki->next) {
+ for (key = ki->keySyms.minKeyCode; key < ki->keySyms.maxKeyCode;
+ key++) {
+ if (IsKeyDown(ki, key)) {
+ KdHandleKeyboardEvent(ki, KeyRelease, key);
+ nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, KeyRelease, key);
+ for (i = 0; i < nEvents; i++)
+ KdQueueEvent (ki->dixdev, kdEvents + i);
+ }
+ }
+ }
+
+ KdUnblockSigio ();
+}
+
+static void
+KdCheckLock (void)
+{
+ KeyClassPtr keyc = NULL;
+ Bool isSet = FALSE, shouldBeSet = FALSE;
+ KdKeyboardInfo *tmp = NULL;
+
+ for (tmp = kdKeyboards; tmp; tmp = tmp->next) {
+ if (tmp->LockLed && tmp->dixdev && tmp->dixdev->key) {
+ keyc = tmp->dixdev->key;
+ isSet = (tmp->leds & (1 << (tmp->LockLed-1))) != 0;
+ shouldBeSet = (keyc->state & LockMask) != 0;
+ if (isSet != shouldBeSet)
+ KdSetLed (tmp, tmp->LockLed, shouldBeSet);
+ }
+ }
+}
+
+void
+KdEnqueueKeyboardEvent(KdKeyboardInfo *ki,
+ unsigned char scan_code,
+ unsigned char is_up)
+{
+ unsigned char key_code;
+ KeyClassPtr keyc = NULL;
+ KeybdCtrl *ctrl = NULL;
+ int type, nEvents, i;
+
+ if (!ki || !ki->dixdev || !ki->dixdev->kbdfeed || !ki->dixdev->key)
+ return;
+
+ keyc = ki->dixdev->key;
+ ctrl = &ki->dixdev->kbdfeed->ctrl;
+
+ if (scan_code >= ki->minScanCode && scan_code <= ki->maxScanCode)
+ {
+ key_code = scan_code + KD_MIN_KEYCODE - ki->minScanCode;
+
+ /*
+ * Set up this event -- the type may be modified below
+ */
+ if (is_up)
+ type = KeyRelease;
+ else
+ type = KeyPress;
+
+#ifdef XKB
+ if (noXkbExtension)
+#endif
+ {
+ KdCheckSpecialKeys(ki, type, key_code);
+ KdHandleKeyboardEvent(ki, type, key_code);
+ }
+
+ nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, type, key_code);
+ for (i = 0; i < nEvents; i++)
+ KdQueueEvent(ki->dixdev, kdEvents + i);
+ }
+ else {
+ ErrorF("driver %s wanted to post scancode %d outside of [%d, %d]!\n",
+ ki->name, scan_code, ki->minScanCode, ki->maxScanCode);
+ }
+}
+
+/*
+ * kdEnqueuePointerEvent
+ *
+ * This function converts hardware mouse event information into X event
+ * information. A mouse movement event is passed off to MI to generate
+ * a MotionNotify event, if appropriate. Button events are created and
+ * passed off to MI for enqueueing.
+ */
+
+/* FIXME do something a little more clever to deal with multiple axes here */
+void
+KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
+ int rz)
+{
+ CARD32 ms;
+ unsigned char buttons;
+ int x, y, z;
+ int (*matrix)[3] = kdPointerMatrix.matrix;
+ unsigned long button;
+ int n;
+ int dixflags = 0;
+
+ if (!pi)
+ return;
+
+ ms = GetTimeInMillis();
+
+ /* we don't need to transform z, so we don't. */
+ if (flags & KD_MOUSE_DELTA) {
+ if (pi->transformCoordinates) {
+ x = matrix[0][0] * rx + matrix[0][1] * ry;
+ y = matrix[1][0] * rx + matrix[1][1] * ry;
+ }
+ else {
+ x = rx;
+ y = ry;
+ }
+ }
+ else {
+ if (pi->transformCoordinates) {
+ x = matrix[0][0] * rx + matrix[0][1] * ry;
+ y = matrix[1][0] * rx + matrix[1][1] * ry;
+ }
+ else {
+ x = rx;
+ y = ry;
+ }
+ }
+ z = rz;
+
+ if (flags & KD_MOUSE_DELTA)
+ {
+ if (x || y || z)
+ dixflags = POINTER_RELATIVE | POINTER_ACCELERATE;
+ } else if ((pi->dixdev->valuator) && (x != pi->dixdev->valuator->lastx ||
+ y != pi->dixdev->valuator->lasty))
+ dixflags = POINTER_ABSOLUTE;
+
+ if (dixflags)
+ _KdEnqueuePointerEvent(pi, MotionNotify, x, y, z, 0, dixflags, FALSE);
+
+ buttons = flags;
+
+ for (button = KD_BUTTON_1, n = 1; n <= pi->nButtons;
+ button <<= 1, n++) {
+ if (((pi->buttonState & button) ^ (buttons & button)) &&
+ !(buttons & button)) {
+ _KdEnqueuePointerEvent(pi, ButtonRelease, x, y, z, n,
+ dixflags, FALSE);
+ }
+ }
+ for (button = KD_BUTTON_1, n = 1; n <= pi->nButtons;
+ button <<= 1, n++) {
+ if (((pi->buttonState & button) ^ (buttons & button)) &&
+ (buttons & button)) {
+ _KdEnqueuePointerEvent(pi, ButtonPress, x, y, z, n,
+ dixflags, FALSE);
+ }
+ }
+
+ pi->buttonState = buttons;
+}
+
+void
+_KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
+ int b, int absrel, Bool force)
+{
+ int nEvents = 0, i = 0;
+ int valuators[3] = { x, y, z };
+
+ /* TRUE from KdHandlePointerEvent, means 'we swallowed the event'. */
+ if (!force && KdHandlePointerEvent(pi, type, x, y, z, b, absrel))
+ return;
+
+ nEvents = GetPointerEvents(kdEvents, pi->dixdev, type, b, absrel, 0, 3,
+ valuators);
+ for (i = 0; i < nEvents; i++)
+ KdQueueEvent(pi->dixdev, kdEvents + i);
+}
+
+void
+KdBlockHandler (int screen,
+ pointer blockData,
+ pointer timeout,
+ pointer readmask)
+{
+ KdPointerInfo *pi;
+ int myTimeout=0;
+
+ for (pi = kdPointers; pi; pi = pi->next)
+ {
+ if (pi->timeoutPending)
+ {
+ int ms;
+
+ ms = pi->emulationTimeout - GetTimeInMillis ();
+ if (ms < 1)
+ ms = 1;
+ if(ms<myTimeout || myTimeout==0)
+ myTimeout=ms;
+ }
+ }
+ /* if we need to poll for events, do that */
+ if(kdOsFuncs->pollEvents)
+ {
+ (*kdOsFuncs->pollEvents)();
+ myTimeout=20;
+ }
+ if(myTimeout>0)
+ AdjustWaitForDelay (timeout, myTimeout);
+}
+
+void
+KdWakeupHandler (int screen,
+ pointer data,
+ unsigned long lresult,
+ pointer readmask)
+{
+ int result = (int) lresult;
+ fd_set *pReadmask = (fd_set *) readmask;
+ int i;
+ KdPointerInfo *pi;
+
+ if (kdInputEnabled && result > 0)
+ {
+ for (i = 0; i < kdNumInputFds; i++)
+ if (FD_ISSET (kdInputFds[i].fd, pReadmask))
+ {
+ KdBlockSigio ();
+ (*kdInputFds[i].read) (kdInputFds[i].fd, kdInputFds[i].closure);
+ KdUnblockSigio ();
+ }
+ }
+ for (pi = kdPointers; pi; pi = pi->next)
+ {
+ if (pi->timeoutPending)
+ {
+ if ((long) (GetTimeInMillis () - pi->emulationTimeout) >= 0)
+ {
+ pi->timeoutPending = FALSE;
+ KdBlockSigio ();
+ KdReceiveTimeout (pi);
+ KdUnblockSigio ();
+ }
+ }
+ }
+ if (kdSwitchPending)
+ KdProcessSwitch ();
+}
+
+#define KdScreenOrigin(pScreen) (&(KdGetScreenPriv(pScreen)->screen->origin))
+
+static Bool
+KdCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
+{
+ ScreenPtr pScreen = *ppScreen;
+ ScreenPtr pNewScreen;
+ int n;
+ int dx, dy;
+ int best_x, best_y;
+ int n_best_x, n_best_y;
+ CARD32 ms;
+
+ if (kdDisableZaphod || screenInfo.numScreens <= 1)
+ return FALSE;
+
+ if (0 <= *x && *x < pScreen->width && 0 <= *y && *y < pScreen->height)
+ return FALSE;
+
+ ms = GetTimeInMillis ();
+ if (kdOffScreen && (int) (ms - kdOffScreenTime) < 1000)
+ return FALSE;
+ kdOffScreen = TRUE;
+ kdOffScreenTime = ms;
+ n_best_x = -1;
+ best_x = 32767;
+ n_best_y = -1;
+ best_y = 32767;
+ for (n = 0; n < screenInfo.numScreens; n++)
+ {
+ pNewScreen = screenInfo.screens[n];
+ if (pNewScreen == pScreen)
+ continue;
+ dx = KdScreenOrigin(pNewScreen)->x - KdScreenOrigin(pScreen)->x;
+ dy = KdScreenOrigin(pNewScreen)->y - KdScreenOrigin(pScreen)->y;
+ if (*x < 0)
+ {
+ if (dx <= 0 && -dx < best_x)
+ {
+ best_x = -dx;
+ n_best_x = n;
+ }
+ }
+ else if (*x >= pScreen->width)
+ {
+ if (dx >= 0 && dx < best_x)
+ {
+ best_x = dx;
+ n_best_x = n;
+ }
+ }
+ if (*y < 0)
+ {
+ if (dy <= 0 && -dy < best_y)
+ {
+ best_y = -dy;
+ n_best_y = n;
+ }
+ }
+ else if (*y >= pScreen->height)
+ {
+ if (dy >= 0 && dy < best_y)
+ {
+ best_y = dy;
+ n_best_y = n;
+ }
+ }
+ }
+ if (best_y < best_x)
+ n_best_x = n_best_y;
+ if (n_best_x == -1)
+ return FALSE;
+ pNewScreen = screenInfo.screens[n_best_x];
+
+ if (*x < 0)
+ *x += pNewScreen->width;
+ if (*y < 0)
+ *y += pNewScreen->height;
+
+ if (*x >= pScreen->width)
+ *x -= pScreen->width;
+ if (*y >= pScreen->height)
+ *y -= pScreen->height;
+
+ *ppScreen = pNewScreen;
+ return TRUE;
+}
+
+static void
+KdCrossScreen(ScreenPtr pScreen, Bool entering)
+{
+#ifndef XIPAQ
+ if (entering)
+ KdEnableScreen (pScreen);
+ else
+ KdDisableScreen (pScreen);
+#endif
+}
+
+int KdCurScreen; /* current event screen */
+
+static void
+KdWarpCursor (ScreenPtr pScreen, int x, int y)
+{
+ KdBlockSigio ();
+ KdCurScreen = pScreen->myNum;
+ miPointerWarpCursor (pScreen, x, y);
+ KdUnblockSigio ();
+}
+
+miPointerScreenFuncRec kdPointerScreenFuncs =
+{
+ KdCursorOffScreen,
+ KdCrossScreen,
+ KdWarpCursor
+};
+
+void
+ProcessInputEvents ()
+{
+ mieqProcessInputEvents();
+ miPointerUpdate();
+ if (kdSwitchPending)
+ KdProcessSwitch ();
+ KdCheckLock ();
+}
+
+/* FIXME use XSECURITY to work out whether the client should be allowed to
+ * open and close. */
+void
+OpenInputDevice(DeviceIntPtr pDev, ClientPtr client, int *status)
+{
+ if (!pDev)
+ *status = BadDevice;
+ else
+ *status = Success;
+}
+
+void
+CloseInputDevice(DeviceIntPtr pDev, ClientPtr client)
+{
+ return;
+}
+
+/* We initialise all input devices at startup. */
+void
+AddOtherInputDevices(void)
+{
+ return;
+}
+
+/* At the moment, absolute/relative is up to the client. */
+int
+SetDeviceMode(register ClientPtr client, DeviceIntPtr pDev, int mode)
+{
+ return BadMatch;
+}
+
+int
+SetDeviceValuators(register ClientPtr client, DeviceIntPtr pDev,
+ int *valuators, int first_valuator, int num_valuators)
+{
+ return BadMatch;
+}
+
+int
+ChangeDeviceControl(register ClientPtr client, DeviceIntPtr pDev,
+ xDeviceCtl *control)
+{
+ switch (control->control) {
+ case DEVICE_RESOLUTION:
+ /* FIXME do something more intelligent here */
+ return BadMatch;
+
+ case DEVICE_ABS_CALIB:
+ case DEVICE_ABS_AREA:
+ return Success;
+
+ case DEVICE_CORE:
+ case DEVICE_ENABLE:
+ return Success;
+
+ default:
+ return BadMatch;
+ }
+
+ /* NOTREACHED */
+ return BadImplementation;
+}
+
+int
+NewInputDeviceRequest(InputOption *options, DeviceIntPtr *pdev)
+{
+ InputOption *option = NULL;
+ KdPointerInfo *pi = NULL;
+ KdKeyboardInfo *ki = NULL;
+
+ for (option = options; option; option = option->next) {
+ if (strcmp(option->key, "type") == 0) {
+ if (strcmp(option->value, "pointer") == 0) {
+ pi = KdNewPointer();
+ if (!pi)
+ return BadAlloc;
+ }
+ else if (strcmp(option->value, "keyboard") == 0) {
+ ki = KdNewKeyboard();
+ if (!ki)
+ return BadAlloc;
+ }
+ else {
+ ErrorF("unrecognised device type!\n");
+ return BadValue;
+ }
+ }
+ }
+
+ if (!ki && !pi) {
+ ErrorF("unrecognised device identifier!\n");
+ return BadValue;
+ }
+
+ /* FIXME: change this code below to use KdParseKbdOptions and
+ * KdParsePointerOptions */
+ for (option = options; option; option = option->next) {
+ if (strcmp(option->key, "device") == 0) {
+ if (pi && option->value)
+ pi->path = KdSaveString(option->value);
+ else if (ki && option->value)
+ ki->path = KdSaveString(option->value);
+ }
+ else if (strcmp(option->key, "driver") == 0) {
+ if (pi) {
+ pi->driver = KdFindPointerDriver(option->value);
+ if (!pi->driver) {
+ ErrorF("couldn't find driver!\n");
+ KdFreePointer(pi);
+ return BadValue;
+ }
+ pi->options = options;
+ }
+ else if (ki) {
+ ki->driver = KdFindKeyboardDriver(option->value);
+ if (!ki->driver) {
+ ErrorF("couldn't find driver!\n");
+ KdFreeKeyboard(ki);
+ return BadValue;
+ }
+ ki->options = options;
+ }
+ }
+ }
+
+ if (pi) {
+ if (KdAddPointer(pi) != Success ||
+ ActivateDevice(pi->dixdev) != Success ||
+ EnableDevice(pi->dixdev) != TRUE) {
+ ErrorF("couldn't add or enable pointer\n");
+ return BadImplementation;
+ }
+ }
+ else if (ki) {
+ if (KdAddKeyboard(ki) != Success ||
+ ActivateDevice(ki->dixdev) != Success ||
+ EnableDevice(ki->dixdev) != TRUE) {
+ ErrorF("couldn't add or enable keyboard\n");
+ return BadImplementation;
+ }
+ }
+
+ if (pi) {
+ *pdev = pi->dixdev;
+ } else if(ki) {
+ *pdev = ki->dixdev;
+ }
+
+ return Success;
+}
+
+void
+DeleteInputDeviceRequest(DeviceIntPtr pDev)
+{
+ RemoveDevice(pDev);
+}
diff --git a/xorg-server/hw/kdrive/src/kkeymap.c b/xorg-server/hw/kdrive/src/kkeymap.c
new file mode 100644
index 000000000..ae90a3499
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kkeymap.c
@@ -0,0 +1,189 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include <X11/keysym.h>
+
+/*
+ * Map scan codes (both regular and synthesized from extended keys)
+ * to X keysyms
+ */
+
+const KeySym kdDefaultKeymap[KD_MAX_LENGTH * KD_MAX_WIDTH] = {
+/* These are directly mapped from DOS scanset 0 */
+/* 1 8 */ XK_Escape, NoSymbol,
+/* 2 9 */ XK_1, XK_exclam,
+/* 3 10 */ XK_2, XK_at,
+/* 4 11 */ XK_3, XK_numbersign,
+/* 5 12 */ XK_4, XK_dollar,
+/* 6 13 */ XK_5, XK_percent,
+/* 7 14 */ XK_6, XK_asciicircum,
+/* 8 15 */ XK_7, XK_ampersand,
+/* 9 16 */ XK_8, XK_asterisk,
+/* 10 17 */ XK_9, XK_parenleft,
+/* 11 18 */ XK_0, XK_parenright,
+/* 12 19 */ XK_minus, XK_underscore,
+/* 13 20 */ XK_equal, XK_plus,
+/* 14 21 */ XK_BackSpace, NoSymbol,
+/* 15 22 */ XK_Tab, NoSymbol,
+/* 16 23 */ XK_Q, NoSymbol,
+/* 17 24 */ XK_W, NoSymbol,
+/* 18 25 */ XK_E, NoSymbol,
+/* 19 26 */ XK_R, NoSymbol,
+/* 20 27 */ XK_T, NoSymbol,
+/* 21 28 */ XK_Y, NoSymbol,
+/* 22 29 */ XK_U, NoSymbol,
+/* 23 30 */ XK_I, NoSymbol,
+/* 24 31 */ XK_O, NoSymbol,
+/* 25 32 */ XK_P, NoSymbol,
+/* 26 33 */ XK_bracketleft, XK_braceleft,
+/* 27 34 */ XK_bracketright, XK_braceright,
+/* 28 35 */ XK_Return, NoSymbol,
+/* 29 36 */ XK_Control_L, NoSymbol,
+/* 30 37 */ XK_A, NoSymbol,
+/* 31 38 */ XK_S, NoSymbol,
+/* 32 39 */ XK_D, NoSymbol,
+/* 33 40 */ XK_F, NoSymbol,
+/* 34 41 */ XK_G, NoSymbol,
+/* 35 42 */ XK_H, NoSymbol,
+/* 36 43 */ XK_J, NoSymbol,
+/* 37 44 */ XK_K, NoSymbol,
+/* 38 45 */ XK_L, NoSymbol,
+/* 39 46 */ XK_semicolon, XK_colon,
+/* 40 47 */ XK_apostrophe, XK_quotedbl,
+/* 41 48 */ XK_grave, XK_asciitilde,
+/* 42 49 */ XK_Shift_L, NoSymbol,
+/* 43 50 */ XK_backslash, XK_bar,
+/* 44 51 */ XK_Z, NoSymbol,
+/* 45 52 */ XK_X, NoSymbol,
+/* 46 53 */ XK_C, NoSymbol,
+/* 47 54 */ XK_V, NoSymbol,
+/* 48 55 */ XK_B, NoSymbol,
+/* 49 56 */ XK_N, NoSymbol,
+/* 50 57 */ XK_M, NoSymbol,
+/* 51 58 */ XK_comma, XK_less,
+/* 52 59 */ XK_period, XK_greater,
+/* 53 60 */ XK_slash, XK_question,
+/* 54 61 */ XK_Shift_R, NoSymbol,
+/* 55 62 */ XK_KP_Multiply, NoSymbol,
+/* 56 63 */ XK_Alt_L, XK_Meta_L,
+/* 57 64 */ XK_space, NoSymbol,
+/* 58 65 */ XK_Caps_Lock, NoSymbol,
+/* 59 66 */ XK_F1, NoSymbol,
+/* 60 67 */ XK_F2, NoSymbol,
+/* 61 68 */ XK_F3, NoSymbol,
+/* 62 69 */ XK_F4, NoSymbol,
+/* 63 70 */ XK_F5, NoSymbol,
+/* 64 71 */ XK_F6, NoSymbol,
+/* 65 72 */ XK_F7, NoSymbol,
+/* 66 73 */ XK_F8, NoSymbol,
+/* 67 74 */ XK_F9, NoSymbol,
+/* 68 75 */ XK_F10, NoSymbol,
+/* 69 76 */ XK_Break, XK_Pause,
+/* 70 77 */ XK_Scroll_Lock, NoSymbol,
+/* 71 78 */ XK_KP_Home, XK_KP_7,
+/* 72 79 */ XK_KP_Up, XK_KP_8,
+/* 73 80 */ XK_KP_Page_Up, XK_KP_9,
+/* 74 81 */ XK_KP_Subtract, NoSymbol,
+/* 75 82 */ XK_KP_Left, XK_KP_4,
+/* 76 83 */ XK_KP_5, NoSymbol,
+/* 77 84 */ XK_KP_Right, XK_KP_6,
+/* 78 85 */ XK_KP_Add, NoSymbol,
+/* 79 86 */ XK_KP_End, XK_KP_1,
+/* 80 87 */ XK_KP_Down, XK_KP_2,
+/* 81 88 */ XK_KP_Page_Down, XK_KP_3,
+/* 82 89 */ XK_KP_Insert, XK_KP_0,
+/* 83 90 */ XK_KP_Delete, XK_KP_Decimal,
+/* 84 91 */ NoSymbol, NoSymbol,
+/* 85 92 */ NoSymbol, NoSymbol,
+/* 86 93 */ NoSymbol, NoSymbol,
+/* 87 94 */ XK_F11, NoSymbol,
+/* 88 95 */ XK_F12, NoSymbol,
+
+/* These are remapped from the extended set (using ExtendMap) */
+
+/* 89 96 */ XK_Control_R, NoSymbol,
+/* 90 97 */ XK_KP_Enter, NoSymbol,
+/* 91 98 */ XK_KP_Divide, NoSymbol,
+/* 92 99 */ XK_Sys_Req, XK_Print,
+/* 93 100 */ XK_Alt_R, XK_Meta_R,
+/* 94 101 */ XK_Num_Lock, NoSymbol,
+/* 95 102 */ XK_Home, NoSymbol,
+/* 96 103 */ XK_Up, NoSymbol,
+/* 97 104 */ XK_Page_Up, NoSymbol,
+/* 98 105 */ XK_Left, NoSymbol,
+/* 99 106 */ XK_Right, NoSymbol,
+/* 100 107 */ XK_End, NoSymbol,
+/* 101 108 */ XK_Down, NoSymbol,
+/* 102 109 */ XK_Page_Down, NoSymbol,
+/* 103 110 */ XK_Insert, NoSymbol,
+/* 104 111 */ XK_Delete, NoSymbol,
+/* 105 112 */ XK_Super_L, NoSymbol,
+/* 106 113 */ XK_Super_R, NoSymbol,
+/* 107 114 */ XK_Menu, NoSymbol,
+/* 108 115 */ NoSymbol, NoSymbol,
+/* 109 116 */ NoSymbol, NoSymbol,
+/* 110 117 */ NoSymbol, NoSymbol,
+/* 111 118 */ NoSymbol, NoSymbol,
+/* 112 119 */ NoSymbol, NoSymbol,
+};
+
+/*
+ * List of locking key codes
+ */
+
+CARD8 kdLockMap[] = {
+ 65,
+ 101,
+ 77,
+};
+
+#define NUM_LOCK (sizeof (kdLockMap) / sizeof (kdLockMap[0]))
+
+int kdNumLock = NUM_LOCK;
+
+/*
+ * Map containing list of keys which the X server makes locking when
+ * the KEYMAP_LOCKING_ALTGR flag is set in CEKeymapFlags
+ */
+
+CARD8 kdOptionalLockMap[] = {
+ 100,
+};
+
+#define NUM_OPTIONAL_LOCK (sizeof (kdOptionalLockMap) / sizeof (kdOptionalLockMap[0]))
+
+int kdNumOptionalLock = NUM_OPTIONAL_LOCK;
+
+const CARD8 kdDefaultModMap[MAP_LENGTH];
+
+unsigned long kdDefaultKeymapFlags = 0;
+
+const KeySymsRec kdDefaultKeySyms = {
+ kdDefaultKeymap,
+ KD_MIN_KEYCODE,
+ KD_MAX_KEYCODE,
+ KD_MAX_WIDTH
+};
diff --git a/xorg-server/hw/kdrive/src/kmap.c b/xorg-server/hw/kdrive/src/kmap.c
new file mode 100644
index 000000000..ce1e28ae4
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kmap.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <kdrive-config.h>
+#include "kdrive.h"
+
+#include <errno.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#ifdef HAVE_ASM_MTRR_H
+#include <asm/mtrr.h>
+#endif
+
+#include <sys/ioctl.h>
+
+void *
+KdMapDevice (CARD32 addr, CARD32 size)
+{
+#ifdef WINDOWS
+ void *a;
+ void *d;
+
+ d = VirtualAlloc (NULL, size, MEM_RESERVE, PAGE_NOACCESS);
+ if (!d)
+ return NULL;
+ DRAW_DEBUG ((DEBUG_S3INIT, "Virtual address of 0x%x is 0x%x", addr, d));
+ a = VirtualCopyAddr (addr);
+ DRAW_DEBUG ((DEBUG_S3INIT, "Translated address is 0x%x", a));
+ if (!VirtualCopy (d, a, size,
+ PAGE_READWRITE|PAGE_NOCACHE|PAGE_PHYSICAL))
+ {
+ DRAW_DEBUG ((DEBUG_FAILURE, "VirtualCopy failed %d",
+ GetLastError ()));
+ return NULL;
+ }
+ DRAW_DEBUG ((DEBUG_S3INIT, "Device mapped successfully"));
+ return d;
+#endif
+#ifdef linux
+ void *a;
+ int fd;
+
+#ifdef __arm__
+ fd = open ("/dev/mem", O_RDWR|O_SYNC);
+#else
+ fd = open ("/dev/mem", O_RDWR);
+#endif
+ if (fd < 0)
+ FatalError ("KdMapDevice: failed to open /dev/mem (%s)\n",
+ strerror (errno));
+
+ a = mmap ((caddr_t) 0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, addr);
+ close (fd);
+ if ((long) a == -1)
+ FatalError ("KdMapDevice: failed to map frame buffer (%s)\n",
+ strerror (errno));
+ return a;
+#endif
+#ifdef VXWORKS
+ return (void *) addr;
+#endif
+}
+
+void
+KdUnmapDevice (void *addr, CARD32 size)
+{
+#ifdef WINDOWS
+ VirtualFree (addr, size, MEM_DECOMMIT);
+ VirtualFree (addr, 0, MEM_RELEASE);
+#endif
+#ifdef linux
+ munmap (addr, size);
+#endif
+#ifdef VXWORKS
+ ;
+#endif
+}
+
+#ifdef HAVE_ASM_MTRR_H
+static int mtrr;
+#endif
+
+void
+KdSetMappedMode (CARD32 addr, CARD32 size, int mode)
+{
+#ifdef HAVE_ASM_MTRR_H
+ struct mtrr_sentry sentry;
+ unsigned long base, bound;
+ unsigned int type = MTRR_TYPE_WRBACK;
+
+ if (addr < 0x100000)
+ return;
+ if (!mtrr)
+ mtrr = open ("/proc/mtrr", 2);
+ if (mtrr > 0)
+ {
+ unsigned long nsize;
+ base = addr & ~((1<<22)-1);
+ bound = ((addr + size) + ((1<<22) - 1)) & ~((1<<22) - 1);
+ nsize = 1;
+ while (nsize < (bound - base))
+ nsize <<= 1;
+ switch (mode) {
+ case KD_MAPPED_MODE_REGISTERS:
+ type = MTRR_TYPE_UNCACHABLE;
+ break;
+ case KD_MAPPED_MODE_FRAMEBUFFER:
+ type = MTRR_TYPE_WRCOMB;
+ break;
+ }
+ sentry.base = base;
+ sentry.size = nsize;
+ sentry.type = type;
+
+ if (ioctl (mtrr, MTRRIOC_ADD_ENTRY, &sentry) < 0)
+ ErrorF ("MTRRIOC_ADD_ENTRY failed 0x%x 0x%x %d (%s)\n",
+ base, bound - base, type, strerror(errno));
+ }
+#endif
+}
+
+void
+KdResetMappedMode (CARD32 addr, CARD32 size, int mode)
+{
+#ifdef HAVE_ASM_MTRR_H
+ struct mtrr_sentry sentry;
+ unsigned long base, bound;
+ unsigned int type = MTRR_TYPE_WRBACK;
+
+ if (addr < 0x100000)
+ return;
+ if (!mtrr)
+ mtrr = open ("/proc/mtrr", 2);
+ if (mtrr > 0)
+ {
+ unsigned long nsize;
+ base = addr & ~((1<<22)-1);
+ bound = ((addr + size) + ((1<<22) - 1)) & ~((1<<22) - 1);
+ nsize = 1;
+ while (nsize < (bound - base))
+ nsize <<= 1;
+ switch (mode) {
+ case KD_MAPPED_MODE_REGISTERS:
+ type = MTRR_TYPE_UNCACHABLE;
+ break;
+ case KD_MAPPED_MODE_FRAMEBUFFER:
+ type = MTRR_TYPE_WRCOMB;
+ break;
+ }
+ sentry.base = base;
+ sentry.size = nsize;
+ sentry.type = type;
+
+ if (ioctl (mtrr, MTRRIOC_DEL_ENTRY, &sentry) < 0)
+ ErrorF ("MTRRIOC_DEL_ENTRY failed 0x%x 0x%x %d (%s)\n",
+ base, bound - base, type, strerror(errno));
+ }
+#endif
+}
diff --git a/xorg-server/hw/kdrive/src/kmode.c b/xorg-server/hw/kdrive/src/kmode.c
new file mode 100644
index 000000000..d02cb55e1
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kmode.c
@@ -0,0 +1,400 @@
+/*
+ * Copyright 1999 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+
+const KdMonitorTiming kdMonitorTimings[] = {
+ /* H V Hz KHz */
+ /* FP BP BLANK POLARITY */
+
+ /* IPAQ modeline:
+ *
+ * Modeline "320x240" 5.7222 320 337 340 352 240 241 244 254"
+ */
+ { 320, 240, 64, 16256,
+ 17, 12, 32, KdSyncNegative,
+ 1, 11, 14, KdSyncNegative,
+ },
+
+ /* Other VESA modes */
+ { 640, 350, 85, 31500, /* VESA */
+ 32, 96, 192, KdSyncPositive, /* 26.413 */
+ 32, 60, 95, KdSyncNegative, /* 59.354 */
+ },
+ { 640, 400, 60, 31500, /* VESA */
+ 32, 96, 192, KdSyncNegative, /* 26.413 */
+ 1, 41, 45, KdSyncPositive, /* 59.354 */
+ },
+ { 720, 400, 85, 35500, /* VESA */
+ 36, 108, 216, KdSyncNegative, /* 37.927 */
+ 1, 42, 46, KdSyncPositive, /* 85.039 */
+ },
+
+
+ /* Modeline "720x576" 29.000 720 736 800 880 576 577 580 625 */
+ {
+ 720, 576, 52, 32954, /* PAL Video */
+ 16, 80, 160, KdSyncPositive, /* 32.954 */
+ 1, 45, 49, KdSyncPositive, /* 52.727 */
+ },
+
+ /* 640x480 modes */
+ { 640, 480, 85, 36000, /* VESA */
+ 56, 80, 192, KdSyncNegative, /* 43.269 */
+ 1, 25, 29, KdSyncNegative, /* 85.008 */
+ },
+ { 640, 480, 75, 31500, /* VESA */
+ 16, 120, 200, KdSyncNegative, /* 37.500 */
+ 1, 16, 20, KdSyncNegative, /* 75.000 */
+ },
+ { 640, 480, 72, 31500, /* VESA */
+ 16, 120, 176, KdSyncNegative, /* 37.861 */
+ 1, 20, 24, KdSyncNegative, /* 72.809 */
+ },
+ { 640, 480, 60, 25175, /* VESA */
+ 16, 48, 160, KdSyncNegative, /* 31.469 */
+ 10, 33, 45, KdSyncNegative, /* 59.940 */
+ },
+
+ /* 800x600 modes */
+ { 800, 600, 85, 56250, /* VESA */
+ 32, 152, 248, KdSyncPositive, /* 53.674 */
+ 1, 27, 31, KdSyncPositive, /* 85.061 */
+ },
+ { 800, 600, 75, 49500, /* VESA */
+ 16, 160, 256, KdSyncPositive, /* 46.875 */
+ 1, 21, 25, KdSyncPositive, /* 75.000 */
+ },
+ /* DEFAULT */
+#define MONITOR_TIMING_DEFAULT 9
+ { 800, 600, 72, 50000, /* VESA */
+ 56, 64, 240, KdSyncPositive, /* 48.077 */
+ 37, 23, 66, KdSyncPositive, /* 72.188 */
+ },
+ { 800, 600, 60, 40000, /* VESA */
+ 40, 88, 256, KdSyncPositive, /* 37.879 */
+ 1, 23, 28, KdSyncPositive, /* 60.317 */
+ },
+ { 800, 600, 56, 36000, /* VESA */
+ 24, 128, 224, KdSyncPositive, /* 35.156 */
+ 1, 22, 25, KdSyncPositive, /* 56.250 */
+ },
+
+ /* 1024x768 modes */
+ { 1024, 768, 85, 94500, /* VESA */
+ 48, 208, 352, KdSyncPositive, /* 68.677 */
+ 1, 36, 40, KdSyncPositive, /* 84.997 */
+ },
+ { 1024, 768, 75, 78750, /* VESA */
+ 16, 176, 288, KdSyncPositive, /* 60.023 */
+ 1, 28, 32, KdSyncPositive, /* 75.029 */
+ },
+ { 1024, 768, 70, 75000, /* VESA */
+ 24, 144, 304, KdSyncNegative, /* 56.476 */
+ 3, 29, 38, KdSyncNegative, /* 70.069 */
+ },
+ { 1024, 768, 60, 65000, /* VESA */
+ 24, 160, 320, KdSyncNegative, /* 48.363 */
+ 3, 29, 38, KdSyncNegative, /* 60.004 */
+ },
+
+ /* 1152x864 mode */
+ { 1152, 864, 75, 108000, /* VESA */
+ 64, 256, 448, KdSyncPositive, /* 67.500 */
+ 1, 32, 36, KdSyncPositive, /* 75.000 */
+ },
+
+ /* 1152x900 modes */
+ { 1152, 900, 85, 122500, /* ADDED */
+ 48, 208, 384, KdSyncPositive, /* 79.753 */
+ 1, 32, 38, KdSyncPositive, /* 85.024 */
+ },
+ { 1152, 900, 75, 108250, /* ADDED */
+ 32, 208, 384, KdSyncPositive, /* 70.475 */
+ 1, 32, 38, KdSyncPositive, /* 75.133 */
+ },
+ { 1152, 900, 70, 100250, /* ADDED */
+ 32, 208, 384, KdSyncPositive, /* 65.267 */
+ 2, 32, 38, KdSyncPositive, /* 69.581 */
+ },
+ { 1152, 900, 66, 95000, /* ADDED */
+ 32, 208, 384, KdSyncPositive, /* 61.849 */
+ 1, 32, 38, KdSyncPositive, /* 65.937 */
+ },
+
+ /* 1280x854 modes */
+ { 1280, 854, 103, 12500, /* ADDED */
+ 56, 16, 128, KdSyncPositive, /* 102.554 */
+ 1, 216, 12, KdSyncPositive,
+ },
+
+ /* 1280x960 modes */
+ { 1280, 960, 85, 148500, /* VESA */
+ 64, 224, 448, KdSyncPositive, /* 85.938 */
+ 1, 47, 51, KdSyncPositive, /* 85.002 */
+ },
+ { 1280, 960, 60, 108000, /* VESA */
+ 96, 312, 520, KdSyncPositive, /* 60.000 */
+ 1, 36, 40, KdSyncPositive, /* 60.000 */
+ },
+
+ /* 1280x1024 modes */
+ { 1280, 1024, 85, 157500, /* VESA */
+ 64, 224, 448, KdSyncPositive, /* 91.146 */
+ 1, 44, 48, KdSyncPositive, /* 85.024 */
+ },
+ { 1280, 1024, 75, 135000, /* VESA */
+ 16, 248, 408, KdSyncPositive, /* 79.976 */
+ 1, 38, 42, KdSyncPositive, /* 75.025 */
+ },
+ { 1280, 1024, 60, 108000, /* VESA */
+ 48, 248, 408, KdSyncPositive, /* 63.981 */
+ 1, 38, 42, KdSyncPositive, /* 60.020 */
+ },
+
+ /* 1600x1200 modes */
+ { 1600, 1200, 85, 229500, /* VESA */
+ 64, 304, 560, KdSyncPositive, /* 106.250 */
+ 1, 46, 50, KdSyncPositive, /* 85.000 */
+ },
+ { 1600, 1200, 75, 202500, /* VESA */
+ 64, 304, 560, KdSyncPositive, /* 93.750 */
+ 1, 46, 50, KdSyncPositive, /* 75.000 */
+ },
+ { 1600, 1200, 70, 189000, /* VESA */
+ 64, 304, 560, KdSyncPositive, /* 87.500 */
+ 1, 46, 50, KdSyncPositive, /* 70.000 */
+ },
+ { 1600, 1200, 65, 175500, /* VESA */
+ 64, 304, 560, KdSyncPositive, /* 81.250 */
+ 1, 46, 50, KdSyncPositive, /* 65.000 */
+ },
+ { 1600, 1200, 60, 162000, /* VESA */
+ 64, 304, 560, KdSyncPositive, /* 75.000 */
+ 1, 46, 50, KdSyncPositive, /* 60.000 */
+ },
+
+ /* 1792x1344 modes */
+ { 1792, 1344, 85, 301500, /* ADDED */
+ 96, 352, 672, KdSyncNegative, /* 122.362 */
+ 1, 92, 96, KdSyncPositive, /* 84.974 */
+ },
+ { 1792, 1344, 75, 261000, /* VESA */
+ 96, 352, 664, KdSyncNegative, /* 106.270 */
+ 1, 69, 73, KdSyncPositive, /* 74.997 */
+ },
+ { 1792, 1344, 60, 204750, /* VESA */
+ 128, 328, 656, KdSyncNegative, /* 83.640 */
+ 1, 46, 50, KdSyncPositive, /* 60.000 */
+ },
+
+#if 0
+ { 1800, 1012, 75 },
+ { 1906, 1072, 68 },
+#endif
+
+ /* 1856x1392 modes */
+ { 1856, 1392, 85, 330500, /* ADDED */
+ 160, 352, 736, KdSyncNegative, /* 127.508 */
+ 1, 104, 108, KdSyncPositive, /* 85.001 */
+ },
+ { 1856, 1392, 75, 288000, /* VESA */
+ 128, 352, 704, KdSyncNegative, /* 112.500 */
+ 1, 104, 108, KdSyncPositive, /* 75.000 */
+ },
+ { 1856, 1392, 60, 218250, /* VESA */
+ 96, 352, 672, KdSyncNegative, /* 86.333 */
+ 1, 43, 47, KdSyncPositive, /* 59.995 */
+ },
+
+ /* 1920x1440 modes */
+ { 1920, 1440, 85, 341750, /* ADDED */
+ 160, 352, 760, KdSyncNegative, /* 127.512 */
+ 1, 56, 60, KdSyncPositive, /* 85.012 */
+ },
+ { 1920, 1440, 75, 297000, /* VESA */
+ 144, 352, 720, KdSyncNegative, /* 112.500 */
+ 1, 56, 60, KdSyncPositive, /* 75.000 */
+ },
+ { 1920, 1440, 60, 234000, /* VESA */
+ 128, 244, 680, KdSyncNegative, /* 90.000 */
+ 1, 56, 60, KdSyncPositive, /* 60.000 */
+ },
+};
+
+#define NUM_MONITOR_TIMINGS (sizeof kdMonitorTimings/sizeof kdMonitorTimings[0])
+
+const int kdNumMonitorTimings = NUM_MONITOR_TIMINGS;
+
+const KdMonitorTiming *
+KdFindMode (KdScreenInfo *screen,
+ Bool (*supported) (KdScreenInfo *,
+ const KdMonitorTiming *))
+{
+ int i;
+ const KdMonitorTiming *t;
+
+ for (i = 0, t = kdMonitorTimings; i < NUM_MONITOR_TIMINGS; i++, t++)
+ {
+ if ((*supported) (screen, t) &&
+ t->horizontal == screen->width &&
+ t->vertical == screen->height &&
+ (!screen->rate || t->rate <= screen->rate))
+ {
+ return t;
+ }
+ }
+ ErrorF("Warning: mode not found, using default\n");
+ return &kdMonitorTimings[MONITOR_TIMING_DEFAULT];
+}
+
+static const KdMonitorTiming *
+kdFindPrevSize (const KdMonitorTiming *old)
+{
+ const KdMonitorTiming *new, *prev;
+
+ if (old == kdMonitorTimings)
+ return 0;
+ new = old;
+ /*
+ * Search for the previous size
+ */
+ while (new != kdMonitorTimings)
+ {
+ new--;
+ if (new->horizontal != old->horizontal &&
+ new->vertical != old->vertical)
+ {
+ break;
+ }
+ }
+ /*
+ * Match the refresh rate (<=)
+ */
+ while (new != kdMonitorTimings)
+ {
+ prev = new - 1;
+ if (prev->horizontal == new->horizontal &&
+ prev->vertical == new->vertical &&
+ prev->rate > old->rate)
+ {
+ break;
+ }
+ new--;
+ }
+ return new;
+}
+
+Bool
+KdTuneMode (KdScreenInfo *screen,
+ Bool (*usable) (KdScreenInfo *),
+ Bool (*supported) (KdScreenInfo *,
+ const KdMonitorTiming *))
+{
+ const KdMonitorTiming *t;
+
+ while (!(*usable) (screen))
+ {
+ /*
+ * Fix requested depth and geometry until it works
+ */
+ if (screen->fb[1].depth)
+ screen->fb[1].depth = 0;
+ else if (screen->fb[0].depth > 16)
+ screen->fb[0].depth = 16;
+ else if (screen->fb[0].depth > 8)
+ screen->fb[0].depth = 8;
+ else
+ {
+ t = kdFindPrevSize (KdFindMode (screen, supported));
+ if (!t)
+ return FALSE;
+ screen->width = t->horizontal;
+ screen->height = t->vertical;
+ screen->rate = t->rate;
+ }
+ }
+ return TRUE;
+}
+
+#ifdef RANDR
+Bool
+KdRandRGetInfo (ScreenPtr pScreen,
+ int randr,
+ Bool (*supported) (ScreenPtr pScreen,
+ const KdMonitorTiming *))
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ int i;
+ const KdMonitorTiming *t;
+
+ for (i = 0, t = kdMonitorTimings; i < NUM_MONITOR_TIMINGS; i++, t++)
+ {
+ if ((*supported) (pScreen, t))
+ {
+ RRScreenSizePtr pSize;
+
+ pSize = RRRegisterSize (pScreen,
+ t->horizontal,
+ t->vertical,
+ screen->width_mm,
+ screen->height_mm);
+ if (!pSize)
+ return FALSE;
+ if (!RRRegisterRate (pScreen, pSize, t->rate))
+ return FALSE;
+ if (t->horizontal == screen->width &&
+ t->vertical == screen->height &&
+ t->rate == screen->rate)
+ RRSetCurrentConfig (pScreen, randr, t->rate, pSize);
+ }
+ }
+
+ return TRUE;
+}
+
+const KdMonitorTiming *
+KdRandRGetTiming (ScreenPtr pScreen,
+ Bool (*supported) (ScreenPtr pScreen,
+ const KdMonitorTiming *),
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ int i;
+ const KdMonitorTiming *t;
+
+ for (i = 0, t = kdMonitorTimings; i < NUM_MONITOR_TIMINGS; i++, t++)
+ {
+ if (t->horizontal == pSize->width &&
+ t->vertical == pSize->height &&
+ t->rate == rate &&
+ (*supported) (pScreen, t))
+ return t;
+ }
+ return 0;
+}
+#endif
diff --git a/xorg-server/hw/kdrive/src/knoop.c b/xorg-server/hw/kdrive/src/knoop.c
new file mode 100644
index 000000000..a3e9468ed
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/knoop.c
@@ -0,0 +1,251 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * GC ops that don't do anything
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include <gcstruct.h>
+
+typedef void (* typeFillSpans)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nInit*/,
+ DDXPointPtr /*pptInit*/,
+ int * /*pwidthInit*/,
+ int /*fSorted*/
+);
+
+typedef void (* typeSetSpans)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ char * /*psrc*/,
+ DDXPointPtr /*ppt*/,
+ int * /*pwidth*/,
+ int /*nspans*/,
+ int /*fSorted*/
+);
+
+typedef void (* typePutImage)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*depth*/,
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ int /*leftPad*/,
+ int /*format*/,
+ char * /*pBits*/
+);
+
+typedef RegionPtr (* typeCopyArea)(
+ DrawablePtr /*pSrc*/,
+ DrawablePtr /*pDst*/,
+ GCPtr /*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*w*/,
+ int /*h*/,
+ int /*dstx*/,
+ int /*dsty*/
+);
+
+typedef RegionPtr (* typeCopyPlane)(
+ DrawablePtr /*pSrcDrawable*/,
+ DrawablePtr /*pDstDrawable*/,
+ GCPtr /*pGC*/,
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*width*/,
+ int /*height*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ unsigned long /*bitPlane*/
+);
+typedef void (* typePolyPoint)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/
+);
+
+typedef void (* typePolylines)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*mode*/,
+ int /*npt*/,
+ DDXPointPtr /*pptInit*/
+);
+
+typedef void (* typePolySegment)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nseg*/,
+ xSegment * /*pSegs*/
+);
+
+typedef void (* typePolyRectangle)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nrects*/,
+ xRectangle * /*pRects*/
+);
+
+typedef void (* typePolyArc)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+
+typedef void (* typeFillPolygon)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*shape*/,
+ int /*mode*/,
+ int /*count*/,
+ DDXPointPtr /*pPts*/
+);
+
+typedef void (* typePolyFillRect)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*nrectFill*/,
+ xRectangle * /*prectInit*/
+);
+
+typedef void (* typePolyFillArc)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*narcs*/,
+ xArc * /*parcs*/
+);
+
+typedef int (* typePolyText8)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ char * /*chars*/
+);
+
+typedef int (* typePolyText16)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ unsigned short * /*chars*/
+);
+
+typedef void (* typeImageText8)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ char * /*chars*/
+);
+
+typedef void (* typeImageText16)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ unsigned short * /*chars*/
+);
+
+typedef void (* typeImageGlyphBlt)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+
+typedef void (* typePolyGlyphBlt)(
+ DrawablePtr /*pDrawable*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ unsigned int /*nglyph*/,
+ CharInfoPtr * /*ppci*/,
+ pointer /*pglyphBase*/
+);
+
+typedef void (* typePushPixels)(
+ GCPtr /*pGC*/,
+ PixmapPtr /*pBitMap*/,
+ DrawablePtr /*pDst*/,
+ int /*w*/,
+ int /*h*/,
+ int /*x*/,
+ int /*y*/
+);
+
+static RegionPtr
+KdNoopCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
+ int srcx, int srcy, int width, int height, int dstx, int dsty)
+{
+ return NullRegion;
+}
+
+static RegionPtr
+KdNoopCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
+ int srcx, int srcy, int width, int height,
+ int dstx, int dsty, unsigned long bitPlane)
+{
+ return NullRegion;
+}
+
+GCOps kdNoopOps = {
+ (typeFillSpans) NoopDDA, /* fill spans */
+ (typeSetSpans) NoopDDA, /* set spans */
+ (typePutImage) NoopDDA, /* put image */
+ KdNoopCopyArea, /* copy area */
+ KdNoopCopyPlane, /* copy plane */
+ (typePolyPoint) NoopDDA, /* poly point */
+ (typePolylines) NoopDDA, /* poly lines */
+ (typePolySegment) NoopDDA, /* poly segment */
+ (typePolyRectangle) NoopDDA, /* poly rectangle */
+ (typePolyArc) NoopDDA, /* poly arc */
+ (typeFillPolygon) NoopDDA, /* fill polygon */
+ (typePolyFillRect) NoopDDA, /* poly fillrect */
+ (typePolyFillArc) NoopDDA, /* poly fillarc */
+ (typePolyText8) NoopDDA, /* text 8 */
+ (typePolyText16) NoopDDA, /* text 16 */
+ (typeImageText8) NoopDDA, /* itext 8 */
+ (typeImageText16) NoopDDA, /* itext 16 */
+ (typePolyGlyphBlt) NoopDDA, /* glyph blt */
+ (typeImageGlyphBlt) NoopDDA, /* iglyph blt */
+ (typePushPixels) NoopDDA, /* push pixels */
+};
diff --git a/xorg-server/hw/kdrive/src/koffscreen.c b/xorg-server/hw/kdrive/src/koffscreen.c
new file mode 100644
index 000000000..efe03642f
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/koffscreen.c
@@ -0,0 +1,375 @@
+/*
+ * Copyright © 2003 Anders Carlsson
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Anders Carlsson not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Anders Carlsson makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ANDERS CARLSSON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+#include "kaa.h"
+
+#define DEBUG_OFFSCREEN 0
+#if DEBUG_OFFSCREEN
+#define DBG_OFFSCREEN(a) ErrorF a
+#else
+#define DBG_OFFSCREEN(a)
+#endif
+
+#if DEBUG_OFFSCREEN
+static void
+KdOffscreenValidate (ScreenPtr pScreen)
+{
+ KdScreenPriv (pScreen);
+ KdOffscreenArea *prev = 0, *area;
+
+ assert (pScreenPriv->screen->off_screen_areas->area.offset == 0);
+ for (area = pScreenPriv->off_screen_areas; area; area = area->next)
+ {
+ if (prev)
+ assert (prev->offset + prev->size == area->offset);
+
+ prev = area;
+ }
+ assert (prev->offset + prev->size == pScreenPriv->screen->memory_size);
+}
+#else
+#define KdOffscreenValidate(s)
+#endif
+
+static KdOffscreenArea *
+KdOffscreenKickOut (ScreenPtr pScreen, KdOffscreenArea *area)
+{
+ if (area->save)
+ (*area->save) (pScreen, area);
+ return KdOffscreenFree (pScreen, area);
+}
+
+KdOffscreenArea *
+KdOffscreenAlloc (ScreenPtr pScreen, int size, int align,
+ Bool locked,
+ KdOffscreenSaveProc save,
+ pointer privData)
+{
+ KdOffscreenArea *area, *begin, *best;
+ KdScreenPriv (pScreen);
+ int tmp, real_size = 0, best_score;
+
+ KdOffscreenValidate (pScreen);
+ if (!align)
+ align = 1;
+
+ if (!size)
+ {
+ DBG_OFFSCREEN (("Alloc 0x%x -> EMPTY\n", size));
+ return NULL;
+ }
+
+ /* throw out requests that cannot fit */
+ if (size > (pScreenPriv->screen->memory_size - pScreenPriv->screen->off_screen_base))
+ {
+ DBG_OFFSCREEN (("Alloc 0x%x -> TOBIG\n", size));
+ return NULL;
+ }
+
+ /* Try to find a free space that'll fit. */
+ for (area = pScreenPriv->off_screen_areas; area; area = area->next)
+ {
+ /* skip allocated areas */
+ if (area->state != KdOffscreenAvail)
+ continue;
+
+ /* adjust size to match alignment requirement */
+ real_size = size;
+ tmp = area->offset % align;
+ if (tmp)
+ real_size += (align - tmp);
+
+ /* does it fit? */
+ if (real_size <= area->size)
+ break;
+ }
+
+ if (!area)
+ {
+ /*
+ * Kick out existing users to make space.
+ *
+ * First, locate a region which can hold the desired object.
+ */
+
+ /* prev points at the first object to boot */
+ best = NULL;
+ best_score = MAXINT;
+ for (begin = pScreenPriv->off_screen_areas; begin != NULL;
+ begin = begin->next)
+ {
+ int avail, score;
+ KdOffscreenArea *scan;
+
+ if (begin->state == KdOffscreenLocked)
+ continue;
+
+ /* adjust size to match alignment requirement */
+ real_size = size;
+ tmp = begin->offset % align;
+ if (tmp)
+ real_size += (align - tmp);
+
+ avail = 0;
+ score = 0;
+ /* now see if we can make room here, and how "costly" it'll be. */
+ for (scan = begin; scan != NULL; scan = scan->next)
+ {
+ if (scan->state == KdOffscreenLocked) {
+ /* Can't make room here, start after this locked area. */
+ begin = scan->next;
+ break;
+ }
+ /* Score should only be non-zero for KdOffscreenRemovable */
+ score += scan->score;
+ avail += scan->size;
+ if (avail >= real_size)
+ break;
+ }
+ /* Is it the best option we've found so far? */
+ if (avail >= real_size && score < best_score) {
+ best = begin;
+ best_score = score;
+ }
+ }
+ area = best;
+ if (!area)
+ {
+ DBG_OFFSCREEN (("Alloc 0x%x -> NOSPACE\n", size));
+ /* Could not allocate memory */
+ KdOffscreenValidate (pScreen);
+ return NULL;
+ }
+
+ /* adjust size to match alignment requirement */
+ real_size = size;
+ tmp = begin->offset % align;
+ if (tmp)
+ real_size += (align - tmp);
+
+ /*
+ * Kick out first area if in use
+ */
+ if (area->state != KdOffscreenAvail)
+ area = KdOffscreenKickOut (pScreen, area);
+ /*
+ * Now get the system to merge the other needed areas together
+ */
+ while (area->size < real_size)
+ {
+ assert (area->next && area->next->state == KdOffscreenRemovable);
+ (void) KdOffscreenKickOut (pScreen, area->next);
+ }
+ }
+
+ /* save extra space in new area */
+ if (real_size < area->size)
+ {
+ KdOffscreenArea *new_area = xalloc (sizeof (KdOffscreenArea));
+ if (!new_area)
+ return NULL;
+ new_area->offset = area->offset + real_size;
+ new_area->size = area->size - real_size;
+ new_area->state = KdOffscreenAvail;
+ new_area->save = 0;
+ new_area->score = 0;
+ new_area->next = area->next;
+ area->next = new_area;
+ area->size = real_size;
+ }
+ /*
+ * Mark this area as in use
+ */
+ if (locked)
+ area->state = KdOffscreenLocked;
+ else
+ area->state = KdOffscreenRemovable;
+ area->privData = privData;
+ area->save = save;
+ area->score = 0;
+
+ area->save_offset = area->offset;
+ {
+ int tmp = area->offset % align;
+ if (tmp)
+ area->offset += (align - tmp);
+ }
+
+ KdOffscreenValidate (pScreen);
+
+ DBG_OFFSCREEN (("Alloc 0x%x -> 0x%x\n", size, area->offset));
+ return area;
+}
+
+void
+KdOffscreenSwapOut (ScreenPtr pScreen)
+{
+ KdScreenPriv (pScreen);
+
+ KdOffscreenValidate (pScreen);
+ /* loop until a single free area spans the space */
+ for (;;)
+ {
+ KdOffscreenArea *area = pScreenPriv->off_screen_areas;
+
+ if (!area)
+ break;
+ if (area->state == KdOffscreenAvail)
+ {
+ area = area->next;
+ if (!area)
+ break;
+ }
+ assert (area->state != KdOffscreenAvail);
+ (void) KdOffscreenKickOut (pScreen, area);
+ KdOffscreenValidate (pScreen);
+ }
+ KdOffscreenValidate (pScreen);
+ KdOffscreenFini (pScreen);
+}
+
+void
+KdOffscreenSwapIn (ScreenPtr pScreen)
+{
+ KdOffscreenInit (pScreen);
+}
+
+/* merge the next free area into this one */
+static void
+KdOffscreenMerge (KdOffscreenArea *area)
+{
+ KdOffscreenArea *next = area->next;
+
+ /* account for space */
+ area->size += next->size;
+ /* frob pointer */
+ area->next = next->next;
+ xfree (next);
+}
+
+KdOffscreenArea *
+KdOffscreenFree (ScreenPtr pScreen, KdOffscreenArea *area)
+{
+ KdScreenPriv(pScreen);
+ KdOffscreenArea *next = area->next;
+ KdOffscreenArea *prev;
+
+ DBG_OFFSCREEN (("Free 0x%x -> 0x%x\n", area->size, area->offset));
+ KdOffscreenValidate (pScreen);
+
+ area->state = KdOffscreenAvail;
+ area->save = 0;
+ area->offset = area->save_offset;
+ area->score = 0;
+
+ /*
+ * Find previous area
+ */
+ if (area == pScreenPriv->off_screen_areas)
+ prev = 0;
+ else
+ for (prev = pScreenPriv->off_screen_areas; prev; prev = prev->next)
+ if (prev->next == area)
+ break;
+
+ /* link with next area if free */
+ if (next && next->state == KdOffscreenAvail)
+ KdOffscreenMerge (area);
+
+ /* link with prev area if free */
+ if (prev && prev->state == KdOffscreenAvail)
+ {
+ area = prev;
+ KdOffscreenMerge (area);
+ }
+
+ KdOffscreenValidate (pScreen);
+ return area;
+}
+
+void
+KdOffscreenMarkUsed (PixmapPtr pPixmap)
+{
+ KaaPixmapPriv (pPixmap);
+ KdScreenPriv (pPixmap->drawable.pScreen);
+ static int iter = 0;
+
+ if (!pKaaPixmap->area)
+ return;
+
+ /* The numbers here are arbitrary. We may want to tune these. */
+ pKaaPixmap->area->score += 100;
+ if (++iter == 10) {
+ KdOffscreenArea *area;
+ for (area = pScreenPriv->off_screen_areas; area != NULL;
+ area = area->next)
+ {
+ if (area->state == KdOffscreenRemovable)
+ area->score = (area->score * 7) / 8;
+ }
+ }
+}
+
+Bool
+KdOffscreenInit (ScreenPtr pScreen)
+{
+ KdScreenPriv (pScreen);
+ KdOffscreenArea *area;
+
+ /* Allocate a big free area */
+ area = xalloc (sizeof (KdOffscreenArea));
+
+ if (!area)
+ return FALSE;
+
+ area->state = KdOffscreenAvail;
+ area->offset = pScreenPriv->screen->off_screen_base;
+ area->size = pScreenPriv->screen->memory_size - area->offset;
+ area->save = 0;
+ area->next = NULL;
+ area->score = 0;
+
+ /* Add it to the free areas */
+ pScreenPriv->off_screen_areas = area;
+
+ KdOffscreenValidate (pScreen);
+
+ return TRUE;
+}
+
+void
+KdOffscreenFini (ScreenPtr pScreen)
+{
+ KdScreenPriv (pScreen);
+ KdOffscreenArea *area;
+
+ /* just free all of the area records */
+ while ((area = pScreenPriv->off_screen_areas))
+ {
+ pScreenPriv->off_screen_areas = area->next;
+ xfree (area);
+ }
+}
diff --git a/xorg-server/hw/kdrive/src/kshadow.c b/xorg-server/hw/kdrive/src/kshadow.c
new file mode 100644
index 000000000..ea44812db
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kshadow.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+
+Bool
+KdShadowFbAlloc (KdScreenInfo *screen, int fb, Bool rotate)
+{
+ int paddedWidth;
+ void *buf;
+ int width = rotate ? screen->height : screen->width;
+ int height = rotate ? screen->width : screen->height;
+ int bpp = screen->fb[fb].bitsPerPixel;
+
+ /* use fb computation for width */
+ paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits);
+ buf = xalloc (paddedWidth * height);
+ if (!buf)
+ return FALSE;
+ if (screen->fb[fb].shadow)
+ xfree (screen->fb[fb].frameBuffer);
+ screen->fb[fb].shadow = TRUE;
+ screen->fb[fb].frameBuffer = buf;
+ screen->fb[fb].byteStride = paddedWidth;
+ screen->fb[fb].pixelStride = paddedWidth * 8 / bpp;
+ return TRUE;
+}
+
+void
+KdShadowFbFree (KdScreenInfo *screen, int fb)
+{
+ if (screen->fb[fb].shadow)
+ {
+ xfree (screen->fb[fb].frameBuffer);
+ screen->fb[fb].frameBuffer = 0;
+ screen->fb[fb].shadow = FALSE;
+ }
+}
+
+Bool
+KdShadowSet (ScreenPtr pScreen, int randr, ShadowUpdateProc update, ShadowWindowProc window)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ int fb;
+
+ shadowRemove (pScreen, pScreen->GetScreenPixmap(pScreen));
+ for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++)
+ {
+ if (screen->fb[fb].shadow)
+ return shadowAdd (pScreen, pScreen->GetScreenPixmap(pScreen),
+ update, window, randr, 0);
+ }
+ return TRUE;
+}
+
+void
+KdShadowUnset (ScreenPtr pScreen)
+{
+ shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen));
+}
diff --git a/xorg-server/hw/kdrive/src/ktest.c b/xorg-server/hw/kdrive/src/ktest.c
new file mode 100644
index 000000000..150af5639
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/ktest.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+
+
+static CARD8 memoryPatterns[] = { 0xff, 0x00, 0x5a, 0xa5, 0xaa, 0x55 };
+
+#define NUM_PATTERNS (sizeof (memoryPatterns) / sizeof (memoryPatterns[0]))
+
+Bool
+KdFrameBufferValid (CARD8 *base, int size)
+{
+ volatile CARD8 *b = (volatile CARD8 *) base;
+ CARD8 save, test, compare;
+ int i, j;
+
+ b = base + (size - 1);
+ save = *b;
+
+ for (i = 0; i < NUM_PATTERNS; i++)
+ {
+ test = memoryPatterns[i];
+ *b = test;
+ for (j = 0; j < 1000; j++)
+ {
+ compare = *b;
+ if (compare != test)
+ return FALSE;
+ }
+ }
+ *b = save;
+ return TRUE;
+}
+
+int
+KdFrameBufferSize (CARD8 *base, int max)
+{
+ int min, cur;
+
+ min = 0;
+ while (min + 1 < max)
+ {
+ cur = (max + min) / 2;
+ if (KdFrameBufferValid (base, cur))
+ min = cur;
+ else
+ max = cur;
+ }
+ if (KdFrameBufferValid (base, max))
+ return max;
+ else
+ return min;
+}
diff --git a/xorg-server/hw/kdrive/src/kxv.c b/xorg-server/hw/kdrive/src/kxv.c
new file mode 100644
index 000000000..0b8d1c4e0
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kxv.c
@@ -0,0 +1,1954 @@
+/*
+
+ XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com)
+ Adapted for KDrive by Pontus Lidman <pontus.lidman@nokia.com>
+
+ Copyright (C) 2000, 2001 - Nokia Home Communications
+ Copyright (C) 1998, 1999 - 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, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "kdrive.h"
+
+#include "scrnintstr.h"
+#include "regionstr.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "mivalidate.h"
+#include "validate.h"
+#include "resource.h"
+#include "gcstruct.h"
+#include "dixstruct.h"
+
+#include <X11/extensions/Xv.h>
+#include <X11/extensions/Xvproto.h>
+
+#include "kxv.h"
+#include "fourcc.h"
+
+
+/* XvScreenRec fields */
+
+static Bool KdXVCloseScreen(int, ScreenPtr);
+static int KdXVQueryAdaptors(ScreenPtr, XvAdaptorPtr *, int *);
+
+/* XvAdaptorRec fields */
+
+static int KdXVAllocatePort(unsigned long, XvPortPtr, XvPortPtr*);
+static int KdXVFreePort(XvPortPtr);
+static int KdXVPutVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int KdXVPutStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int KdXVGetVideo(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int KdXVGetStill(ClientPtr, DrawablePtr,XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16);
+static int KdXVStopVideo(ClientPtr, XvPortPtr, DrawablePtr);
+static int KdXVSetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32);
+static int KdXVGetPortAttribute(ClientPtr, XvPortPtr, Atom, INT32 *);
+static int KdXVQueryBestSize(ClientPtr, XvPortPtr, CARD8,
+ CARD16, CARD16,CARD16, CARD16,
+ unsigned int*, unsigned int*);
+static int KdXVPutImage(ClientPtr, DrawablePtr, XvPortPtr, GCPtr,
+ INT16, INT16, CARD16, CARD16,
+ INT16, INT16, CARD16, CARD16,
+ XvImagePtr, unsigned char*, Bool,
+ CARD16, CARD16);
+static int KdXVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr,
+ CARD16*, CARD16*, int*, int*);
+
+
+/* ScreenRec fields */
+
+static Bool KdXVCreateWindow(WindowPtr pWin);
+static Bool KdXVDestroyWindow(WindowPtr pWin);
+static void KdXVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2);
+static void KdXVClipNotify(WindowPtr pWin, int dx, int dy);
+
+/* misc */
+static Bool KdXVInitAdaptors(ScreenPtr, KdVideoAdaptorPtr*, int);
+
+
+DevPrivateKey KdXVWindowKey = &KdXVWindowKey;
+DevPrivateKey KdXvScreenKey = &KdXvScreenKey;
+static unsigned long KdXVGeneration = 0;
+static unsigned long PortResource = 0;
+
+DevPrivateKey (*XvGetScreenKeyProc)(void) = XvGetScreenKey;
+unsigned long (*XvGetRTPortProc)(void) = XvGetRTPort;
+int (*XvScreenInitProc)(ScreenPtr) = XvScreenInit;
+
+#define GET_XV_SCREEN(pScreen) ((XvScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, KdXvScreenKey))
+
+#define GET_KDXV_SCREEN(pScreen) \
+ ((KdXVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
+
+#define GET_KDXV_WINDOW(pWin) ((KdXVWindowPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, KdXVWindowKey))
+
+static KdXVInitGenericAdaptorPtr *GenDrivers = NULL;
+static int NumGenDrivers = 0;
+
+int
+KdXVRegisterGenericAdaptorDriver(
+ KdXVInitGenericAdaptorPtr InitFunc
+){
+ KdXVInitGenericAdaptorPtr *newdrivers;
+
+/* fprintf(stderr,"KdXVRegisterGenericAdaptorDriver\n"); */
+
+ newdrivers = xrealloc(GenDrivers, sizeof(KdXVInitGenericAdaptorPtr) *
+ (1 + NumGenDrivers));
+ if (!newdrivers)
+ return 0;
+ GenDrivers = newdrivers;
+
+ GenDrivers[NumGenDrivers++] = InitFunc;
+
+ return 1;
+}
+
+int
+KdXVListGenericAdaptors(
+ KdScreenInfo * screen,
+ KdVideoAdaptorPtr **adaptors
+){
+ int i,j,n,num;
+ KdVideoAdaptorPtr *DrivAdap,*new;
+
+ num = 0;
+ *adaptors = NULL;
+ for (i = 0; i < NumGenDrivers; i++) {
+ n = GenDrivers[i](screen,&DrivAdap);
+ if (0 == n)
+ continue;
+ new = xrealloc(*adaptors, sizeof(KdVideoAdaptorPtr) * (num+n));
+ if (NULL == new)
+ continue;
+ *adaptors = new;
+ for (j = 0; j < n; j++, num++)
+ (*adaptors)[num] = DrivAdap[j];
+ }
+ return num;
+}
+
+KdVideoAdaptorPtr
+KdXVAllocateVideoAdaptorRec(KdScreenInfo * screen)
+{
+ return xcalloc(1, sizeof(KdVideoAdaptorRec));
+}
+
+void
+KdXVFreeVideoAdaptorRec(KdVideoAdaptorPtr ptr)
+{
+ xfree(ptr);
+}
+
+
+Bool
+KdXVScreenInit(
+ ScreenPtr pScreen,
+ KdVideoAdaptorPtr *adaptors,
+ int num
+){
+ KdXVScreenPtr ScreenPriv;
+ XvScreenPtr pxvs;
+
+/* fprintf(stderr,"KdXVScreenInit initializing %d adaptors\n",num); */
+
+ if (KdXVGeneration != serverGeneration)
+ KdXVGeneration = serverGeneration;
+
+ if(!XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
+ return FALSE;
+
+ if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
+
+ KdXvScreenKey = (*XvGetScreenKeyProc)();
+ PortResource = (*XvGetRTPortProc)();
+
+ pxvs = GET_XV_SCREEN(pScreen);
+
+
+ /* Anyone initializing the Xv layer must provide these two.
+ The Xv di layer calls them without even checking if they exist! */
+
+ pxvs->ddCloseScreen = KdXVCloseScreen;
+ pxvs->ddQueryAdaptors = KdXVQueryAdaptors;
+
+ /* The Xv di layer provides us with a private hook so that we don't
+ have to allocate our own screen private. They also provide
+ a CloseScreen hook so that we don't have to wrap it. I'm not
+ sure that I appreciate that. */
+
+ ScreenPriv = xalloc(sizeof(KdXVScreenRec));
+ pxvs->devPriv.ptr = (pointer)ScreenPriv;
+
+ if(!ScreenPriv) return FALSE;
+
+
+ ScreenPriv->CreateWindow = pScreen->CreateWindow;
+ ScreenPriv->DestroyWindow = pScreen->DestroyWindow;
+ ScreenPriv->WindowExposures = pScreen->WindowExposures;
+ ScreenPriv->ClipNotify = pScreen->ClipNotify;
+
+/* fprintf(stderr,"XV: Wrapping screen funcs\n"); */
+
+ pScreen->CreateWindow = KdXVCreateWindow;
+ pScreen->DestroyWindow = KdXVDestroyWindow;
+ pScreen->WindowExposures = KdXVWindowExposures;
+ pScreen->ClipNotify = KdXVClipNotify;
+
+ if(!KdXVInitAdaptors(pScreen, adaptors, num))
+ return FALSE;
+
+ return TRUE;
+}
+
+static void
+KdXVFreeAdaptor(XvAdaptorPtr pAdaptor)
+{
+ int i;
+
+ if(pAdaptor->name)
+ xfree(pAdaptor->name);
+
+ if(pAdaptor->pEncodings) {
+ XvEncodingPtr pEncode = pAdaptor->pEncodings;
+
+ for(i = 0; i < pAdaptor->nEncodings; i++, pEncode++) {
+ if(pEncode->name) xfree(pEncode->name);
+ }
+ xfree(pAdaptor->pEncodings);
+ }
+
+ if(pAdaptor->pFormats)
+ xfree(pAdaptor->pFormats);
+
+ if(pAdaptor->pPorts) {
+ XvPortPtr pPort = pAdaptor->pPorts;
+ XvPortRecPrivatePtr pPriv;
+
+ for(i = 0; i < pAdaptor->nPorts; i++, pPort++) {
+ pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
+ if(pPriv) {
+ if(pPriv->clientClip)
+ REGION_DESTROY(pAdaptor->pScreen, pPriv->clientClip);
+ if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ REGION_DESTROY(pAdaptor->pScreen, pPriv->pCompositeClip);
+ xfree(pPriv);
+ }
+ }
+ xfree(pAdaptor->pPorts);
+ }
+
+ if(pAdaptor->nAttributes) {
+ XvAttributePtr pAttribute = pAdaptor->pAttributes;
+
+ for(i = 0; i < pAdaptor->nAttributes; i++, pAttribute++) {
+ if(pAttribute->name) xfree(pAttribute->name);
+ }
+
+ xfree(pAdaptor->pAttributes);
+ }
+
+ if(pAdaptor->nImages)
+ xfree(pAdaptor->pImages);
+
+ if(pAdaptor->devPriv.ptr)
+ xfree(pAdaptor->devPriv.ptr);
+}
+
+static Bool
+KdXVInitAdaptors(
+ ScreenPtr pScreen,
+ KdVideoAdaptorPtr *infoPtr,
+ int number
+) {
+ KdScreenPriv(pScreen);
+ KdScreenInfo * screen = pScreenPriv->screen;
+
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ KdVideoAdaptorPtr adaptorPtr;
+ XvAdaptorPtr pAdaptor, pa;
+ XvAdaptorRecPrivatePtr adaptorPriv;
+ int na, numAdaptor;
+ XvPortRecPrivatePtr portPriv;
+ XvPortPtr pPort, pp;
+ int numPort;
+ KdAttributePtr attributePtr;
+ XvAttributePtr pAttribute, pat;
+ KdVideoFormatPtr formatPtr;
+ XvFormatPtr pFormat, pf;
+ int numFormat, totFormat;
+ KdVideoEncodingPtr encodingPtr;
+ XvEncodingPtr pEncode, pe;
+ KdImagePtr imagePtr;
+ XvImagePtr pImage, pi;
+ int numVisuals;
+ VisualPtr pVisual;
+ int i;
+
+ pxvs->nAdaptors = 0;
+ pxvs->pAdaptors = NULL;
+
+ if(!(pAdaptor = xcalloc(number, sizeof(XvAdaptorRec))))
+ return FALSE;
+
+ for(pa = pAdaptor, na = 0, numAdaptor = 0; na < number; na++, adaptorPtr++) {
+ adaptorPtr = infoPtr[na];
+
+ if(!adaptorPtr->StopVideo || !adaptorPtr->SetPortAttribute ||
+ !adaptorPtr->GetPortAttribute || !adaptorPtr->QueryBestSize)
+ continue;
+
+ /* client libs expect at least one encoding */
+ if(!adaptorPtr->nEncodings || !adaptorPtr->pEncodings)
+ continue;
+
+ pa->type = adaptorPtr->type;
+
+ if(!adaptorPtr->PutVideo && !adaptorPtr->GetVideo)
+ pa->type &= ~XvVideoMask;
+
+ if(!adaptorPtr->PutStill && !adaptorPtr->GetStill)
+ pa->type &= ~XvStillMask;
+
+ if(!adaptorPtr->PutImage || !adaptorPtr->QueryImageAttributes)
+ pa->type &= ~XvImageMask;
+
+ if(!adaptorPtr->PutVideo && !adaptorPtr->PutImage &&
+ !adaptorPtr->PutStill)
+ pa->type &= ~XvInputMask;
+
+ if(!adaptorPtr->GetVideo && !adaptorPtr->GetStill)
+ pa->type &= ~XvOutputMask;
+
+ if(!(adaptorPtr->type & (XvPixmapMask | XvWindowMask)))
+ continue;
+ if(!(adaptorPtr->type & (XvImageMask | XvVideoMask | XvStillMask)))
+ continue;
+
+ pa->pScreen = pScreen;
+ pa->ddAllocatePort = KdXVAllocatePort;
+ pa->ddFreePort = KdXVFreePort;
+ pa->ddPutVideo = KdXVPutVideo;
+ pa->ddPutStill = KdXVPutStill;
+ pa->ddGetVideo = KdXVGetVideo;
+ pa->ddGetStill = KdXVGetStill;
+ pa->ddStopVideo = KdXVStopVideo;
+ pa->ddPutImage = KdXVPutImage;
+ pa->ddSetPortAttribute = KdXVSetPortAttribute;
+ pa->ddGetPortAttribute = KdXVGetPortAttribute;
+ pa->ddQueryBestSize = KdXVQueryBestSize;
+ pa->ddQueryImageAttributes = KdXVQueryImageAttributes;
+ if((pa->name = xalloc(strlen(adaptorPtr->name) + 1)))
+ strcpy(pa->name, adaptorPtr->name);
+
+ if(adaptorPtr->nEncodings &&
+ (pEncode = xcalloc(adaptorPtr->nEncodings, sizeof(XvEncodingRec)))) {
+
+ for(pe = pEncode, encodingPtr = adaptorPtr->pEncodings, i = 0;
+ i < adaptorPtr->nEncodings; pe++, i++, encodingPtr++)
+ {
+ pe->id = encodingPtr->id;
+ pe->pScreen = pScreen;
+ if((pe->name = xalloc(strlen(encodingPtr->name) + 1)))
+ strcpy(pe->name, encodingPtr->name);
+ pe->width = encodingPtr->width;
+ pe->height = encodingPtr->height;
+ pe->rate.numerator = encodingPtr->rate.numerator;
+ pe->rate.denominator = encodingPtr->rate.denominator;
+ }
+ pa->nEncodings = adaptorPtr->nEncodings;
+ pa->pEncodings = pEncode;
+ }
+
+ if(adaptorPtr->nImages &&
+ (pImage = xcalloc(adaptorPtr->nImages, sizeof(XvImageRec)))) {
+
+ for(i = 0, pi = pImage, imagePtr = adaptorPtr->pImages;
+ i < adaptorPtr->nImages; i++, pi++, imagePtr++)
+ {
+ pi->id = imagePtr->id;
+ pi->type = imagePtr->type;
+ pi->byte_order = imagePtr->byte_order;
+ memcpy(pi->guid, imagePtr->guid, 16);
+ pi->bits_per_pixel = imagePtr->bits_per_pixel;
+ pi->format = imagePtr->format;
+ pi->num_planes = imagePtr->num_planes;
+ pi->depth = imagePtr->depth;
+ pi->red_mask = imagePtr->red_mask;
+ pi->green_mask = imagePtr->green_mask;
+ pi->blue_mask = imagePtr->blue_mask;
+ pi->y_sample_bits = imagePtr->y_sample_bits;
+ pi->u_sample_bits = imagePtr->u_sample_bits;
+ pi->v_sample_bits = imagePtr->v_sample_bits;
+ pi->horz_y_period = imagePtr->horz_y_period;
+ pi->horz_u_period = imagePtr->horz_u_period;
+ pi->horz_v_period = imagePtr->horz_v_period;
+ pi->vert_y_period = imagePtr->vert_y_period;
+ pi->vert_u_period = imagePtr->vert_u_period;
+ pi->vert_v_period = imagePtr->vert_v_period;
+ memcpy(pi->component_order, imagePtr->component_order, 32);
+ pi->scanline_order = imagePtr->scanline_order;
+ }
+ pa->nImages = adaptorPtr->nImages;
+ pa->pImages = pImage;
+ }
+
+ if(adaptorPtr->nAttributes &&
+ (pAttribute = xcalloc(adaptorPtr->nAttributes, sizeof(XvAttributeRec))))
+ {
+ for(pat = pAttribute, attributePtr = adaptorPtr->pAttributes, i = 0;
+ i < adaptorPtr->nAttributes; pat++, i++, attributePtr++)
+ {
+ pat->flags = attributePtr->flags;
+ pat->min_value = attributePtr->min_value;
+ pat->max_value = attributePtr->max_value;
+ if((pat->name = xalloc(strlen(attributePtr->name) + 1)))
+ strcpy(pat->name, attributePtr->name);
+ }
+ pa->nAttributes = adaptorPtr->nAttributes;
+ pa->pAttributes = pAttribute;
+ }
+
+
+ totFormat = adaptorPtr->nFormats;
+
+ if(!(pFormat = xcalloc(totFormat, sizeof(XvFormatRec)))) {
+ KdXVFreeAdaptor(pa);
+ continue;
+ }
+ for(pf = pFormat, i = 0, numFormat = 0, formatPtr = adaptorPtr->pFormats;
+ i < adaptorPtr->nFormats; i++, formatPtr++)
+ {
+ numVisuals = pScreen->numVisuals;
+ pVisual = pScreen->visuals;
+
+ while(numVisuals--) {
+ if((pVisual->class == formatPtr->class) &&
+ (pVisual->nplanes == formatPtr->depth)) {
+
+ if(numFormat >= totFormat) {
+ void *moreSpace;
+ totFormat *= 2;
+ moreSpace = xrealloc(pFormat,
+ totFormat * sizeof(XvFormatRec));
+ if(!moreSpace) break;
+ pFormat = moreSpace;
+ pf = pFormat + numFormat;
+ }
+
+ pf->visual = pVisual->vid;
+ pf->depth = formatPtr->depth;
+
+ pf++;
+ numFormat++;
+ }
+ pVisual++;
+ }
+ }
+ pa->nFormats = numFormat;
+ pa->pFormats = pFormat;
+ if(!numFormat) {
+ KdXVFreeAdaptor(pa);
+ continue;
+ }
+
+ if(!(adaptorPriv = xcalloc(1, sizeof(XvAdaptorRecPrivate)))) {
+ KdXVFreeAdaptor(pa);
+ continue;
+ }
+
+ adaptorPriv->flags = adaptorPtr->flags;
+ adaptorPriv->PutVideo = adaptorPtr->PutVideo;
+ adaptorPriv->PutStill = adaptorPtr->PutStill;
+ adaptorPriv->GetVideo = adaptorPtr->GetVideo;
+ adaptorPriv->GetStill = adaptorPtr->GetStill;
+ adaptorPriv->StopVideo = adaptorPtr->StopVideo;
+ adaptorPriv->SetPortAttribute = adaptorPtr->SetPortAttribute;
+ adaptorPriv->GetPortAttribute = adaptorPtr->GetPortAttribute;
+ adaptorPriv->QueryBestSize = adaptorPtr->QueryBestSize;
+ adaptorPriv->QueryImageAttributes = adaptorPtr->QueryImageAttributes;
+ adaptorPriv->PutImage = adaptorPtr->PutImage;
+ adaptorPriv->ReputImage = adaptorPtr->ReputImage;
+
+ pa->devPriv.ptr = (pointer)adaptorPriv;
+
+ if(!(pPort = xcalloc(adaptorPtr->nPorts, sizeof(XvPortRec)))) {
+ KdXVFreeAdaptor(pa);
+ continue;
+ }
+ for(pp = pPort, i = 0, numPort = 0;
+ i < adaptorPtr->nPorts; i++) {
+
+ if(!(pp->id = FakeClientID(0)))
+ continue;
+
+ if(!(portPriv = xcalloc(1, sizeof(XvPortRecPrivate))))
+ continue;
+
+ if(!AddResource(pp->id, PortResource, pp)) {
+ xfree(portPriv);
+ continue;
+ }
+
+ pp->pAdaptor = pa;
+ pp->pNotify = (XvPortNotifyPtr)NULL;
+ pp->pDraw = (DrawablePtr)NULL;
+ pp->client = (ClientPtr)NULL;
+ pp->grab.client = (ClientPtr)NULL;
+ pp->time = currentTime;
+ pp->devPriv.ptr = portPriv;
+
+ portPriv->screen = screen;
+ portPriv->AdaptorRec = adaptorPriv;
+ portPriv->DevPriv.ptr = adaptorPtr->pPortPrivates[i].ptr;
+
+ pp++;
+ numPort++;
+ }
+ pa->nPorts = numPort;
+ pa->pPorts = pPort;
+ if(!numPort) {
+ KdXVFreeAdaptor(pa);
+ continue;
+ }
+
+ pa->base_id = pPort->id;
+
+ pa++;
+ numAdaptor++;
+ }
+
+ if(numAdaptor) {
+ pxvs->nAdaptors = numAdaptor;
+ pxvs->pAdaptors = pAdaptor;
+ } else {
+ xfree(pAdaptor);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Video should be clipped to the intersection of the window cliplist
+ and the client cliplist specified in the GC for which the video was
+ initialized. When we need to reclip a window, the GC that started
+ the video may not even be around anymore. That's why we save the
+ client clip from the GC when the video is initialized. We then
+ use KdXVUpdateCompositeClip to calculate the new composite clip
+ when we need it. This is different from what DEC did. They saved
+ the GC and used it's clip list when they needed to reclip the window,
+ even if the client clip was different from the one the video was
+ initialized with. If the original GC was destroyed, they had to stop
+ the video. I like the new method better (MArk).
+
+ This function only works for windows. Will need to rewrite when
+ (if) we support pixmap rendering.
+*/
+
+static void
+KdXVUpdateCompositeClip(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 = REGION_CREATE(pWin->pScreen, NullBox, 1);
+ REGION_COPY(pWin->pScreen, pCompositeClip, portPriv->clientClip);
+ REGION_TRANSLATE(pWin->pScreen, pCompositeClip,
+ portPriv->pDraw->x + portPriv->clipOrg.x,
+ portPriv->pDraw->y + portPriv->clipOrg.y);
+ REGION_INTERSECT(pWin->pScreen, pCompositeClip, pregWin, pCompositeClip);
+
+ portPriv->pCompositeClip = pCompositeClip;
+ portPriv->FreeCompositeClip = TRUE;
+
+ if(freeCompClip) {
+ REGION_DESTROY(pWin->pScreen, pregWin);
+ }
+}
+
+/* Save the current clientClip and update the CompositeClip whenever
+ we have a fresh GC */
+
+static void
+KdXVCopyClip(
+ XvPortRecPrivatePtr portPriv,
+ GCPtr pGC
+){
+ /* copy the new clip if it exists */
+ if((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
+ if(!portPriv->clientClip)
+ portPriv->clientClip = REGION_CREATE(pGC->pScreen, NullBox, 1);
+ /* Note: this is in window coordinates */
+ REGION_COPY(pGC->pScreen, portPriv->clientClip, pGC->clientClip);
+ } else if(portPriv->clientClip) { /* free the old clientClip */
+ REGION_DESTROY(pGC->pScreen, portPriv->clientClip);
+ portPriv->clientClip = NULL;
+ }
+
+ /* get rid of the old clip list */
+ if(portPriv->pCompositeClip && portPriv->FreeCompositeClip) {
+ REGION_DESTROY(pWin->pScreen, portPriv->pCompositeClip);
+ }
+
+ portPriv->clipOrg = pGC->clipOrg;
+ portPriv->pCompositeClip = pGC->pCompositeClip;
+ portPriv->FreeCompositeClip = FALSE;
+ portPriv->subWindowMode = pGC->subWindowMode;
+}
+
+static int
+KdXVRegetVideo(XvPortRecPrivatePtr portPriv)
+{
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ KdXVUpdateCompositeClip(portPriv);
+
+ /* translate the video region to the screen */
+ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
+ WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
+ WinBox.x2 = WinBox.x1 + portPriv->drw_w;
+ WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+
+ /* clip to the window composite clip */
+ REGION_INIT(portPriv->pDraw->pScreen, &WinRegion, &WinBox, 1);
+ REGION_INIT(portPriv->pDraw->pScreen, &ClipRegion, NullBox, 1);
+ REGION_INTERSECT(portPriv->pDraw->pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* that's all if it's totally obscured */
+ if(!REGION_NOTEMPTY(portPriv->pDraw->pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ REGION_SUBTRACT(portPriv->pDraw->pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->screen, portPriv->pDraw,
+ 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);
+
+ if(ret == Success)
+ portPriv->isOn = XV_ON;
+
+CLIP_VIDEO_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && portPriv->isOn == XV_ON) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->screen, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if(!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ REGION_UNINIT(portPriv->pDraw->pScreen, &WinRegion);
+ REGION_UNINIT(portPriv->pDraw->pScreen, &ClipRegion);
+
+ return ret;
+}
+
+
+static int
+KdXVReputVideo(XvPortRecPrivatePtr portPriv)
+{
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ ScreenPtr pScreen = portPriv->pDraw->pScreen;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen=pScreenPriv->screen;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ KdXVUpdateCompositeClip(portPriv);
+
+ /* translate the video region to the screen */
+ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
+ WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
+ WinBox.x2 = WinBox.x1 + portPriv->drw_w;
+ WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+
+ /* clip to the window composite clip */
+ REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
+ REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
+ REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* clip and translate to the viewport */
+ if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = 0;
+ VPBox.y1 = 0;
+ VPBox.x2 = screen->width;
+ VPBox.y2 = screen->height;
+
+ REGION_INIT(pScreen, &VPReg, &VPBox, 1);
+ REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
+ REGION_UNINIT(pScreen, &VPReg);
+ }
+
+ /* that's all if it's totally obscured */
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+
+ /* bailout if we have to clip but the hardware doesn't support it */
+ if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = REGION_RECTS(&ClipRegion);
+ if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->screen, portPriv->pDraw,
+ 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);
+
+ if(ret == Success) portPriv->isOn = XV_ON;
+
+CLIP_VIDEO_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->screen, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if(!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ REGION_UNINIT(pScreen, &WinRegion);
+ REGION_UNINIT(pScreen, &ClipRegion);
+
+ return ret;
+}
+
+static int
+KdXVReputImage(XvPortRecPrivatePtr portPriv)
+{
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ ScreenPtr pScreen = portPriv->pDraw->pScreen;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen=pScreenPriv->screen;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ KdXVUpdateCompositeClip(portPriv);
+
+ /* translate the video region to the screen */
+ WinBox.x1 = portPriv->pDraw->x + portPriv->drw_x;
+ WinBox.y1 = portPriv->pDraw->y + portPriv->drw_y;
+ WinBox.x2 = WinBox.x1 + portPriv->drw_w;
+ WinBox.y2 = WinBox.y1 + portPriv->drw_h;
+
+ /* clip to the window composite clip */
+ REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
+ REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
+ REGION_INTERSECT(Screen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+
+ /* clip and translate to the viewport */
+ if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = 0;
+ VPBox.y1 = 0;
+ VPBox.x2 = screen->width;
+ VPBox.y2 = screen->height;
+
+ REGION_INIT(pScreen, &VPReg, &VPBox, 1);
+ REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
+ REGION_UNINIT(pScreen, &VPReg);
+ }
+
+ /* that's all if it's totally obscured */
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+
+ /* bailout if we have to clip but the hardware doesn't support it */
+ if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = REGION_RECTS(&ClipRegion);
+ if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ {
+ clippedAway = TRUE;
+ goto CLIP_VIDEO_BAILOUT;
+ }
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->screen, portPriv->pDraw,
+ WinBox.x1, WinBox.y1,
+ &ClipRegion, portPriv->DevPriv.ptr);
+
+ portPriv->isOn = (ret == Success) ? XV_ON : XV_OFF;
+
+CLIP_VIDEO_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->screen, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ /* This clip was copied and only good for one shot */
+ if(!portPriv->FreeCompositeClip)
+ portPriv->pCompositeClip = NULL;
+
+ REGION_UNINIT(pScreen, &WinRegion);
+ REGION_UNINIT(pScreen, &ClipRegion);
+
+ return ret;
+}
+
+
+static int
+KdXVReputAllVideo(WindowPtr pWin, pointer data)
+{
+ KdXVWindowPtr WinPriv;
+
+ if (pWin->drawable.type != DRAWABLE_WINDOW)
+ return WT_DONTWALKCHILDREN;
+
+ WinPriv = GET_KDXV_WINDOW(pWin);
+
+ while(WinPriv) {
+ if(WinPriv->PortRec->type == XvInputMask)
+ KdXVReputVideo(WinPriv->PortRec);
+ else
+ KdXVRegetVideo(WinPriv->PortRec);
+ WinPriv = WinPriv->next;
+ }
+
+ return WT_WALKCHILDREN;
+}
+
+static int
+KdXVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
+{
+ KdXVWindowPtr winPriv, PrivRoot;
+
+ winPriv = PrivRoot = GET_KDXV_WINDOW(pWin);
+
+ /* Enlist our port in the window private */
+ while(winPriv) {
+ if(winPriv->PortRec == portPriv) /* we're already listed */
+ break;
+ winPriv = winPriv->next;
+ }
+
+ if(!winPriv) {
+ winPriv = xalloc(sizeof(KdXVWindowRec));
+ if(!winPriv) return BadAlloc;
+ winPriv->PortRec = portPriv;
+ winPriv->next = PrivRoot;
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv);
+ }
+ return Success;
+}
+
+
+static void
+KdXVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
+{
+ KdXVWindowPtr winPriv, prevPriv = NULL;
+
+ winPriv = GET_KDXV_WINDOW(pWin);
+
+ while(winPriv) {
+ if(winPriv->PortRec == portPriv) {
+ if(prevPriv)
+ prevPriv->next = winPriv->next;
+ else
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv->next);
+ xfree(winPriv);
+ break;
+ }
+ prevPriv = winPriv;
+ winPriv = winPriv->next;
+ }
+ portPriv->pDraw = NULL;
+}
+
+/**** ScreenRec fields ****/
+
+
+static Bool
+KdXVCreateWindow(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
+ int ret;
+
+ pScreen->CreateWindow = ScreenPriv->CreateWindow;
+ ret = (*pScreen->CreateWindow)(pWin);
+ pScreen->CreateWindow = KdXVCreateWindow;
+
+ if (ret)
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL);
+
+ return ret;
+}
+
+
+static Bool
+KdXVDestroyWindow(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
+ KdXVWindowPtr tmp, WinPriv = GET_KDXV_WINDOW(pWin);
+ int ret;
+
+ while(WinPriv) {
+ XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
+
+ if(pPriv->isOn > XV_OFF) {
+ (*pPriv->AdaptorRec->StopVideo)(
+ pPriv->screen, pPriv->DevPriv.ptr, TRUE);
+ pPriv->isOn = XV_OFF;
+ }
+
+ pPriv->pDraw = NULL;
+ tmp = WinPriv;
+ WinPriv = WinPriv->next;
+ xfree(tmp);
+ }
+
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL);
+
+ pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
+ ret = (*pScreen->DestroyWindow)(pWin);
+ pScreen->DestroyWindow = KdXVDestroyWindow;
+
+ return ret;
+}
+
+
+static void
+KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
+ KdXVWindowPtr WinPriv = GET_KDXV_WINDOW(pWin);
+ KdXVWindowPtr pPrev;
+ XvPortRecPrivatePtr pPriv;
+ Bool AreasExposed;
+
+ AreasExposed = (WinPriv && reg1 && REGION_NOTEMPTY(pScreen, reg1));
+
+ pScreen->WindowExposures = ScreenPriv->WindowExposures;
+ (*pScreen->WindowExposures)(pWin, reg1, reg2);
+ pScreen->WindowExposures = KdXVWindowExposures;
+
+ /* filter out XClearWindow/Area */
+ if (!pWin->valdata) return;
+
+ pPrev = NULL;
+
+ while(WinPriv) {
+ pPriv = WinPriv->PortRec;
+
+ /* Reput anyone with a reput function */
+
+ switch(pPriv->type) {
+ case XvInputMask:
+ KdXVReputVideo(pPriv);
+ break;
+ case XvOutputMask:
+ KdXVRegetVideo(pPriv);
+ break;
+ default: /* overlaid still/image*/
+ if (pPriv->AdaptorRec->ReputImage)
+ KdXVReputImage(pPriv);
+ else if(AreasExposed) {
+ KdXVWindowPtr tmp;
+
+ if (pPriv->isOn == XV_ON) {
+ (*pPriv->AdaptorRec->StopVideo)(
+ pPriv->screen, pPriv->DevPriv.ptr, FALSE);
+ pPriv->isOn = XV_PENDING;
+ }
+ pPriv->pDraw = NULL;
+
+ if(!pPrev)
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, WinPriv->next);
+ else
+ pPrev->next = WinPriv->next;
+ tmp = WinPriv;
+ WinPriv = WinPriv->next;
+ xfree(tmp);
+ continue;
+ }
+ break;
+ }
+ pPrev = WinPriv;
+ WinPriv = WinPriv->next;
+ }
+}
+
+
+static void
+KdXVClipNotify(WindowPtr pWin, int dx, int dy)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
+ KdXVWindowPtr WinPriv = GET_KDXV_WINDOW(pWin);
+ KdXVWindowPtr tmp, pPrev = NULL;
+ XvPortRecPrivatePtr pPriv;
+ Bool visible = (pWin->visibility == VisibilityUnobscured) ||
+ (pWin->visibility == VisibilityPartiallyObscured);
+
+ while(WinPriv) {
+ pPriv = WinPriv->PortRec;
+
+ if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+
+ pPriv->pCompositeClip = NULL;
+
+ /* Stop everything except images, but stop them too if the
+ window isn't visible. But we only remove the images. */
+
+ if(pPriv->type || !visible) {
+ if(pPriv->isOn == XV_ON) {
+ (*pPriv->AdaptorRec->StopVideo)(
+ pPriv->screen, pPriv->DevPriv.ptr, FALSE);
+ pPriv->isOn = XV_PENDING;
+ }
+
+ if(!pPriv->type) { /* overlaid still/image */
+ pPriv->pDraw = NULL;
+
+ if(!pPrev)
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, WinPriv->next);
+ else
+ pPrev->next = WinPriv->next;
+ tmp = WinPriv;
+ WinPriv = WinPriv->next;
+ xfree(tmp);
+ continue;
+ }
+ }
+
+ pPrev = WinPriv;
+ WinPriv = WinPriv->next;
+ }
+
+ if(ScreenPriv->ClipNotify) {
+ pScreen->ClipNotify = ScreenPriv->ClipNotify;
+ (*pScreen->ClipNotify)(pWin, dx, dy);
+ pScreen->ClipNotify = KdXVClipNotify;
+ }
+}
+
+
+
+/**** Required XvScreenRec fields ****/
+
+static Bool
+KdXVCloseScreen(int i, ScreenPtr pScreen)
+{
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
+ XvAdaptorPtr pa;
+ int c;
+
+ if(!ScreenPriv) return TRUE;
+
+ pScreen->CreateWindow = ScreenPriv->CreateWindow;
+ pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
+ pScreen->WindowExposures = ScreenPriv->WindowExposures;
+ pScreen->ClipNotify = ScreenPriv->ClipNotify;
+
+/* fprintf(stderr,"XV: Unwrapping screen funcs\n"); */
+
+ for(c = 0, pa = pxvs->pAdaptors; c < pxvs->nAdaptors; c++, pa++) {
+ KdXVFreeAdaptor(pa);
+ }
+
+ if(pxvs->pAdaptors)
+ xfree(pxvs->pAdaptors);
+
+ xfree(ScreenPriv);
+
+
+ return TRUE;
+}
+
+
+static int
+KdXVQueryAdaptors(
+ ScreenPtr pScreen,
+ XvAdaptorPtr *p_pAdaptors,
+ int *p_nAdaptors
+){
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+
+ *p_nAdaptors = pxvs->nAdaptors;
+ *p_pAdaptors = pxvs->pAdaptors;
+
+ return (Success);
+}
+
+static Bool
+KdXVRunning (ScreenPtr pScreen)
+{
+ return (KdXVGeneration == serverGeneration &&
+ GET_XV_SCREEN(pScreen) != 0);
+}
+
+Bool
+KdXVEnable(ScreenPtr pScreen)
+{
+ if (!KdXVRunning (pScreen))
+ return TRUE;
+
+ WalkTree(pScreen, KdXVReputAllVideo, 0);
+
+ return TRUE;
+}
+
+void
+KdXVDisable(ScreenPtr pScreen)
+{
+ XvScreenPtr pxvs;
+ KdXVScreenPtr ScreenPriv;
+ XvAdaptorPtr pAdaptor;
+ XvPortPtr pPort;
+ XvPortRecPrivatePtr pPriv;
+ int i, j;
+
+ if (!KdXVRunning (pScreen))
+ return;
+
+ pxvs = GET_XV_SCREEN(pScreen);
+ ScreenPriv = GET_KDXV_SCREEN(pScreen);
+
+ 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->screen, pPriv->DevPriv.ptr, TRUE);
+ pPriv->isOn = XV_OFF;
+
+ if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
+ REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+
+ pPriv->pCompositeClip = NULL;
+
+ if(!pPriv->type && pPriv->pDraw) { /* still */
+ KdXVRemovePortFromWindow((WindowPtr)pPriv->pDraw, pPriv);
+ }
+ }
+ }
+ }
+}
+
+/**** XvAdaptorRec fields ****/
+
+static int
+KdXVAllocatePort(
+ unsigned long port,
+ XvPortPtr pPort,
+ XvPortPtr *ppPort
+){
+ *ppPort = pPort;
+ return Success;
+}
+
+static int
+KdXVFreePort(XvPortPtr pPort)
+{
+ return Success;
+}
+
+static int
+KdXVPutVideo(
+ 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);
+ KdScreenPriv(portPriv->screen->pScreen);
+ 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))
+ KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+
+ /* Register our port with the new window */
+ result = KdXVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+ if(result != Success) return result;
+
+ portPriv->pDraw = pDraw;
+ 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 */
+ KdXVCopyClip(portPriv, pGC);
+
+ /* To indicate to the DI layer that we were successful */
+ pPort->pDraw = pDraw;
+
+ if (!pScreenPriv->enabled) return Success;
+
+ return(KdXVReputVideo(portPriv));
+}
+
+static int
+KdXVPutStill(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+ ScreenPtr pScreen = pDraw->pScreen;
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen=pScreenPriv->screen;
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if (!pScreenPriv->enabled) return 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;
+
+ REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
+ REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
+ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = 0;
+ VPBox.y1 = 0;
+ VPBox.x2 = screen->width;
+ VPBox.y2 = screen->height;
+
+ REGION_INIT(pScreen, &VPReg, &VPBox, 1);
+ REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
+ REGION_UNINIT(pScreen, &VPReg);
+ }
+
+ if(portPriv->pDraw) {
+ KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+ }
+
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
+ goto PUT_STILL_BAILOUT;
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = REGION_RECTS(&ClipRegion);
+ if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ {
+ clippedAway = TRUE;
+ goto PUT_STILL_BAILOUT;
+ }
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutStill)(portPriv->screen, pDraw,
+ vid_x, vid_y, WinBox.x1, WinBox.y1,
+ vid_w, vid_h, drw_w, drw_h,
+ &ClipRegion, portPriv->DevPriv.ptr);
+
+ if((ret == Success) &&
+ (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_STILLS)) {
+
+ KdXVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+ portPriv->isOn = XV_ON;
+ portPriv->pDraw = pDraw;
+ 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->screen, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ REGION_UNINIT(pScreen, &WinRegion);
+ REGION_UNINIT(pScreen, &ClipRegion);
+
+ return ret;
+}
+
+static int
+KdXVGetVideo(
+ 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;
+ KdScreenPriv(portPriv->screen->pScreen);
+
+ /* 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))
+ KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+
+ /* Register our port with the new window */
+ result = KdXVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+ if(result != Success) return result;
+
+ portPriv->pDraw = pDraw;
+ 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 */
+ KdXVCopyClip(portPriv, pGC);
+
+ /* To indicate to the DI layer that we were successful */
+ pPort->pDraw = pDraw;
+
+ if(!pScreenPriv->enabled) return Success;
+
+ return(KdXVRegetVideo(portPriv));
+}
+
+static int
+KdXVGetStill(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 vid_x, INT16 vid_y,
+ CARD16 vid_w, CARD16 vid_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+ ScreenPtr pScreen = pDraw->pScreen;
+ KdScreenPriv(pScreen);
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if(!pScreenPriv->enabled) return 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;
+
+ REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
+ REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
+ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if(portPriv->pDraw) {
+ KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+ }
+
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
+ goto GET_STILL_BAILOUT;
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->GetStill)(portPriv->screen, pDraw,
+ vid_x, vid_y, WinBox.x1, WinBox.y1,
+ vid_w, vid_h, drw_w, drw_h,
+ &ClipRegion, portPriv->DevPriv.ptr);
+
+GET_STILL_BAILOUT:
+
+ if((clippedAway || (ret != Success)) && (portPriv->isOn == XV_ON)) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->screen, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ REGION_UNINIT(pScreen, &WinRegion);
+ REGION_UNINIT(pScreen, &ClipRegion);
+
+ return ret;
+}
+
+
+
+static int
+KdXVStopVideo(
+ ClientPtr client,
+ XvPortPtr pPort,
+ DrawablePtr pDraw
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+ KdScreenPriv(portPriv->screen->pScreen);
+
+ if(pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ KdXVRemovePortFromWindow((WindowPtr)pDraw, portPriv);
+
+ if(!pScreenPriv->enabled) return Success;
+
+ /* Must free resources. */
+
+ if(portPriv->isOn > XV_OFF) {
+ (*portPriv->AdaptorRec->StopVideo)(
+ portPriv->screen, portPriv->DevPriv.ptr, TRUE);
+ portPriv->isOn = XV_OFF;
+ }
+
+ return Success;
+}
+
+static int
+KdXVSetPortAttribute(
+ ClientPtr client,
+ XvPortPtr pPort,
+ Atom attribute,
+ INT32 value
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+
+ return((*portPriv->AdaptorRec->SetPortAttribute)(portPriv->screen,
+ attribute, value, portPriv->DevPriv.ptr));
+}
+
+
+static int
+KdXVGetPortAttribute(
+ ClientPtr client,
+ XvPortPtr pPort,
+ Atom attribute,
+ INT32 *p_value
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+
+ return((*portPriv->AdaptorRec->GetPortAttribute)(portPriv->screen,
+ attribute, (int *) p_value, portPriv->DevPriv.ptr));
+}
+
+
+
+static int
+KdXVQueryBestSize(
+ 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->screen,
+ (Bool)motion, vid_w, vid_h, drw_w, drw_h,
+ p_w, p_h, portPriv->DevPriv.ptr);
+
+ return Success;
+}
+
+
+static int
+KdXVPutImage(
+ ClientPtr client,
+ DrawablePtr pDraw,
+ XvPortPtr pPort,
+ GCPtr pGC,
+ INT16 src_x, INT16 src_y,
+ CARD16 src_w, CARD16 src_h,
+ INT16 drw_x, INT16 drw_y,
+ CARD16 drw_w, CARD16 drw_h,
+ XvImagePtr format,
+ unsigned char* data,
+ Bool sync,
+ CARD16 width, CARD16 height
+){
+ XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
+ ScreenPtr pScreen = pDraw->pScreen;
+ KdScreenPriv(pScreen);
+ RegionRec WinRegion;
+ RegionRec ClipRegion;
+ BoxRec WinBox;
+ int ret = Success;
+ Bool clippedAway = FALSE;
+
+ if (pDraw->type != DRAWABLE_WINDOW)
+ return BadAlloc;
+
+ if(!pScreenPriv->enabled) return 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;
+
+ REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
+ REGION_INIT(pScreen, &ClipRegion, NullBox, 1);
+ REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+
+ if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ RegionRec VPReg;
+ BoxRec VPBox;
+
+ VPBox.x1 = 0;
+ VPBox.y1 = 0;
+ VPBox.x2 = pScreen->width;
+ VPBox.y2 = pScreen->height;
+
+ REGION_INIT(pScreen, &VPReg, &VPBox, 1);
+ REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
+ REGION_UNINIT(pScreen, &VPReg);
+ }
+
+ if(portPriv->pDraw) {
+ KdXVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
+ }
+
+ if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ clippedAway = TRUE;
+ goto PUT_IMAGE_BAILOUT;
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
+ BoxPtr clipBox = REGION_RECTS(&ClipRegion);
+ if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ (clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
+ (clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
+ {
+ clippedAway = TRUE;
+ goto PUT_IMAGE_BAILOUT;
+ }
+ }
+
+ if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
+ REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ }
+
+ ret = (*portPriv->AdaptorRec->PutImage)(portPriv->screen, pDraw,
+ 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);
+
+ if((ret == Success) &&
+ (portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) {
+
+ KdXVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+ portPriv->isOn = XV_ON;
+ portPriv->pDraw = pDraw;
+ 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->screen, portPriv->DevPriv.ptr, FALSE);
+ portPriv->isOn = XV_PENDING;
+ }
+
+ REGION_UNINIT(pScreen, &WinRegion);
+ REGION_UNINIT(pScreen, &ClipRegion);
+
+ return ret;
+}
+
+
+static int
+KdXVQueryImageAttributes(
+ 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->screen,
+ format->id, width, height, pitches, offsets);
+}
+
+
+/**************** Offscreen surface stuff *******************/
+
+typedef struct {
+ KdOffscreenImagePtr images;
+ int num;
+} OffscreenImageRec;
+
+static OffscreenImageRec OffscreenImages[MAXSCREENS];
+static Bool offscreenInited = FALSE;
+
+Bool
+KdXVRegisterOffscreenImages(
+ ScreenPtr pScreen,
+ KdOffscreenImagePtr images,
+ int num
+){
+ if(!offscreenInited) {
+ bzero(OffscreenImages, sizeof(OffscreenImages[MAXSCREENS]));
+ offscreenInited = TRUE;
+ }
+
+ OffscreenImages[pScreen->myNum].num = num;
+ OffscreenImages[pScreen->myNum].images = images;
+
+ return TRUE;
+}
+
+KdOffscreenImagePtr
+KdXVQueryOffscreenImages(
+ ScreenPtr pScreen,
+ int *num
+){
+ if(!offscreenInited) {
+ *num = 0;
+ return NULL;
+ }
+
+ *num = OffscreenImages[pScreen->myNum].num;
+ return OffscreenImages[pScreen->myNum].images;
+}
+
+/**************** Common video manipulation functions *******************/
+
+void
+KdXVCopyPackedData(KdScreenInfo *screen, CARD8 *src, CARD8 *dst, int randr,
+ int srcPitch, int dstPitch, int srcW, int srcH, int top, int left,
+ int h, int w)
+{
+ int srcDown = srcPitch, srcRight = 2, srcNext;
+ int p;
+
+ switch (randr & RR_Rotate_All) {
+ case RR_Rotate_0:
+ srcDown = srcPitch;
+ srcRight = 2;
+ break;
+ case RR_Rotate_90:
+ src += (srcH - 1) * 2;
+ srcDown = -2;
+ srcRight = srcPitch;
+ break;
+ case RR_Rotate_180:
+ src += srcPitch * (srcH - 1) + (srcW - 1) * 2;
+ srcDown = -srcPitch;
+ srcRight = -2;
+ break;
+ case RR_Rotate_270:
+ src += srcPitch * (srcW - 1);
+ srcDown = 2;
+ srcRight = -srcPitch;
+ break;
+ }
+
+ src = src + top * srcDown + left * srcRight;
+
+ w >>= 1;
+ /* srcRight >>= 1; */
+ srcNext = srcRight >> 1;
+ while (h--) {
+ CARD16 *s = (CARD16 *)src;
+ CARD32 *d = (CARD32 *)dst;
+ p = w;
+ while (p--) {
+ *d++ = s[0] | (s[srcNext] << 16);
+ s += srcRight;
+ }
+ src += srcPitch;
+ dst += dstPitch;
+ }
+}
+
+void
+KdXVCopyPlanarData(KdScreenInfo *screen, CARD8 *src, CARD8 *dst, int randr,
+ int srcPitch, int srcPitch2, int dstPitch, int srcW, int srcH, int height,
+ int top, int left, int h, int w, int id)
+{
+ int i, j;
+ CARD8 *src1, *src2, *src3, *dst1;
+ int srcDown = srcPitch, srcDown2 = srcPitch2;
+ int srcRight = 2, srcRight2 = 1, srcNext = 1;
+
+ /* compute source data pointers */
+ src1 = src;
+ src2 = src1 + height * srcPitch;
+ src3 = src2 + (height >> 1) * srcPitch2;
+ switch (randr & RR_Rotate_All) {
+ case RR_Rotate_0:
+ srcDown = srcPitch;
+ srcDown2 = srcPitch2;
+ srcRight = 2;
+ srcRight2 = 1;
+ srcNext = 1;
+ break;
+ case RR_Rotate_90:
+ src1 = src1 + srcH - 1;
+ src2 = src2 + (srcH >> 1) - 1;
+ src3 = src3 + (srcH >> 1) - 1;
+ srcDown = -1;
+ srcDown2 = -1;
+ srcRight = srcPitch * 2;
+ srcRight2 = srcPitch2;
+ srcNext = srcPitch;
+ break;
+ case RR_Rotate_180:
+ src1 = src1 + srcPitch * (srcH - 1) + (srcW - 1);
+ src2 = src2 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
+ src3 = src3 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
+ srcDown = -srcPitch;
+ srcDown2 = -srcPitch2;
+ srcRight = -2;
+ srcRight2 = -1;
+ srcNext = -1;
+ break;
+ case RR_Rotate_270:
+ src1 = src1 + srcPitch * (srcW - 1);
+ src2 = src2 + srcPitch2 * ((srcW >> 1) - 1);
+ src3 = src3 + srcPitch2 * ((srcW >> 1) - 1);
+ srcDown = 1;
+ srcDown2 = 1;
+ srcRight = -srcPitch * 2;
+ srcRight2 = -srcPitch2;
+ srcNext = -srcPitch;
+ break;
+ }
+
+ /* adjust for origin */
+ src1 += top * srcDown + left * srcNext;
+ src2 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
+ src3 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
+
+ if (id == FOURCC_I420) {
+ CARD8 *srct = src2;
+ src2 = src3;
+ src3 = srct;
+ }
+
+ dst1 = dst;
+
+ w >>= 1;
+ for (j = 0; j < h; j++) {
+ CARD32 *dst = (CARD32 *)dst1;
+ CARD8 *s1l = src1;
+ CARD8 *s1r = src1 + srcNext;
+ CARD8 *s2 = src2;
+ CARD8 *s3 = src3;
+
+ for (i = 0; i < w; i++) {
+ *dst++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24);
+ s1l += srcRight;
+ s1r += srcRight;
+ s2 += srcRight2;
+ s3 += srcRight2;
+ }
+ src1 += srcDown;
+ dst1 += dstPitch;
+ if (j & 1) {
+ src2 += srcDown2;
+ src3 += srcDown2;
+ }
+ }
+}
+
+void
+KXVPaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg)
+{
+ GCPtr pGC;
+ CARD32 val[2];
+ xRectangle *rects, *r;
+ BoxPtr pBox = REGION_RECTS (pRgn);
+ int nBox = REGION_NUM_RECTS (pRgn);
+
+ rects = xalloc (nBox * sizeof (xRectangle));
+ if (!rects)
+ goto bail0;
+ r = rects;
+ while (nBox--)
+ {
+ r->x = pBox->x1 - pDraw->x;
+ r->y = pBox->y1 - pDraw->y;
+ r->width = pBox->x2 - pBox->x1;
+ r->height = pBox->y2 - pBox->y1;
+ r++;
+ pBox++;
+ }
+
+ pGC = GetScratchGC (pDraw->depth, pDraw->pScreen);
+ if (!pGC)
+ goto bail1;
+
+ val[0] = fg;
+ val[1] = IncludeInferiors;
+ ChangeGC (pGC, GCForeground|GCSubwindowMode, val);
+
+ ValidateGC (pDraw, pGC);
+
+ (*pGC->ops->PolyFillRect) (pDraw, pGC,
+ REGION_NUM_RECTS (pRgn), rects);
+
+ FreeScratchGC (pGC);
+bail1:
+ xfree (rects);
+bail0:
+ ;
+}
diff --git a/xorg-server/hw/kdrive/src/kxv.h b/xorg-server/hw/kdrive/src/kxv.h
new file mode 100644
index 000000000..5d1441642
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/kxv.h
@@ -0,0 +1,316 @@
+/*
+
+ XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com)
+ Adapted for KDrive by Pontus Lidman <pontus.lidman@nokia.com>
+
+ Copyright (C) 2000, 2001 - Nokia Home Communications
+ Copyright (C) 1998, 1999 - 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, and/or sell copies of the Software, and to permit persons
+to whom the Software is furnished to do so, provided that the above
+copyright notice(s) and this permission notice appear in all copies of
+the Software and that both the above copyright notice(s) and this
+permission notice appear in supporting documentation.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
+SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Except as contained in this notice, the name of a copyright holder
+shall not be used in advertising or otherwise to promote the sale, use
+or other dealings in this Software without prior written authorization
+of the copyright holder.
+
+*/
+
+#ifndef _XVDIX_H_
+#define _XVDIX_H_
+
+#include "scrnintstr.h"
+#include "regionstr.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "mivalidate.h"
+#include "validate.h"
+#include "resource.h"
+#include "gcstruct.h"
+#include "dixstruct.h"
+
+#include "../../Xext/xvdix.h"
+
+#define VIDEO_NO_CLIPPING 0x00000001
+#define VIDEO_INVERT_CLIPLIST 0x00000002
+#define VIDEO_OVERLAID_IMAGES 0x00000004
+#define VIDEO_OVERLAID_STILLS 0x00000008
+#define VIDEO_CLIP_TO_VIEWPORT 0x00000010
+
+typedef struct {
+ int id;
+ int type;
+ int byte_order;
+ unsigned char guid[16];
+ int bits_per_pixel;
+ int format;
+ int num_planes;
+
+ /* for RGB formats only */
+ int depth;
+ unsigned int red_mask;
+ unsigned int green_mask;
+ unsigned int blue_mask;
+
+ /* for YUV formats only */
+ unsigned int y_sample_bits;
+ unsigned int u_sample_bits;
+ unsigned int v_sample_bits;
+ unsigned int horz_y_period;
+ unsigned int horz_u_period;
+ unsigned int horz_v_period;
+ unsigned int vert_y_period;
+ unsigned int vert_u_period;
+ unsigned int vert_v_period;
+ char component_order[32];
+ int scanline_order;
+} KdImageRec, *KdImagePtr;
+
+
+typedef struct {
+ KdScreenInfo * screen;
+ int id;
+ unsigned short width, height;
+ int *pitches; /* bytes */
+ int *offsets; /* in bytes from start of framebuffer */
+ DevUnion devPrivate;
+} KdSurfaceRec, *KdSurfacePtr;
+
+
+typedef int (* PutVideoFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
+ 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 );
+typedef int (* PutStillFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
+ 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 );
+typedef int (* GetVideoFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
+ 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 );
+typedef int (* GetStillFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
+ 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 );
+typedef void (* StopVideoFuncPtr)(KdScreenInfo * screen, pointer data, Bool Exit);
+typedef int (* SetPortAttributeFuncPtr)(KdScreenInfo * screen, Atom attribute,
+ int value, pointer data);
+typedef int (* GetPortAttributeFuncPtr)(KdScreenInfo * screen, Atom attribute,
+ int *value, pointer data);
+typedef void (* QueryBestSizeFuncPtr)(KdScreenInfo * screen, Bool motion,
+ short vid_w, short vid_h, short drw_w, short drw_h,
+ unsigned int *p_w, unsigned int *p_h, pointer data);
+typedef int (* PutImageFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
+ short src_x, short src_y, short drw_x, short drw_y,
+ short src_w, short src_h, short drw_w, short drw_h,
+ int image, unsigned char* buf, short width, short height, Bool Sync,
+ RegionPtr clipBoxes, pointer data );
+typedef int (* ReputImageFuncPtr)( KdScreenInfo * screen, DrawablePtr pDraw,
+ short drw_x, short drw_y,
+ RegionPtr clipBoxes, pointer data );
+typedef int (*QueryImageAttributesFuncPtr)(KdScreenInfo * screen,
+ int image, unsigned short *width, unsigned short *height,
+ int *pitches, int *offsets);
+
+typedef enum {
+ XV_OFF,
+ XV_PENDING,
+ XV_ON
+} XvStatus;
+
+/*** this is what the driver needs to fill out ***/
+
+typedef struct {
+ int id;
+ char *name;
+ unsigned short width, height;
+ XvRationalRec rate;
+} KdVideoEncodingRec, *KdVideoEncodingPtr;
+
+typedef struct {
+ char depth;
+ short class;
+} KdVideoFormatRec, *KdVideoFormatPtr;
+
+typedef struct {
+ int flags;
+ int min_value;
+ int max_value;
+ char *name;
+} KdAttributeRec, *KdAttributePtr;
+
+typedef struct {
+ unsigned int type;
+ int flags;
+ char *name;
+ int nEncodings;
+ KdVideoEncodingPtr pEncodings;
+ int nFormats;
+ KdVideoFormatPtr pFormats;
+ int nPorts;
+ DevUnion *pPortPrivates;
+ int nAttributes;
+ KdAttributePtr pAttributes;
+ int nImages;
+ KdImagePtr pImages;
+ PutVideoFuncPtr PutVideo;
+ PutStillFuncPtr PutStill;
+ GetVideoFuncPtr GetVideo;
+ GetStillFuncPtr GetStill;
+ StopVideoFuncPtr StopVideo;
+ SetPortAttributeFuncPtr SetPortAttribute;
+ GetPortAttributeFuncPtr GetPortAttribute;
+ QueryBestSizeFuncPtr QueryBestSize;
+ PutImageFuncPtr PutImage;
+ ReputImageFuncPtr ReputImage;
+ QueryImageAttributesFuncPtr QueryImageAttributes;
+} KdVideoAdaptorRec, *KdVideoAdaptorPtr;
+
+typedef struct {
+ KdImagePtr image;
+ int flags;
+ int (*alloc_surface)(KdScreenInfo * screen,
+ int id,
+ unsigned short width,
+ unsigned short height,
+ KdSurfacePtr surface);
+ int (*free_surface)(KdSurfacePtr surface);
+ int (*display) (KdSurfacePtr 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) (KdSurfacePtr surface);
+ int (*getAttribute) (KdScreenInfo * screen, Atom attr, INT32 *value);
+ int (*setAttribute) (KdScreenInfo * screen, Atom attr, INT32 value);
+ int max_width;
+ int max_height;
+ int num_attributes;
+ KdAttributePtr attributes;
+} KdOffscreenImageRec, *KdOffscreenImagePtr;
+
+Bool
+KdXVScreenInit(
+ ScreenPtr pScreen,
+ KdVideoAdaptorPtr *Adaptors,
+ int num
+);
+
+typedef int (* KdXVInitGenericAdaptorPtr)(KdScreenInfo * screen,
+ KdVideoAdaptorPtr **Adaptors);
+
+int
+KdXVRegisterGenericAdaptorDriver(
+ KdXVInitGenericAdaptorPtr InitFunc
+);
+
+int
+KdXVListGenericAdaptors(
+ KdScreenInfo * screen,
+ KdVideoAdaptorPtr **Adaptors
+);
+
+Bool
+KdXVRegisterOffscreenImages(
+ ScreenPtr pScreen,
+ KdOffscreenImagePtr images,
+ int num
+);
+
+KdOffscreenImagePtr
+KdXVQueryOffscreenImages(
+ ScreenPtr pScreen,
+ int *num
+);
+
+void
+KdXVCopyPackedData(KdScreenInfo *screen, CARD8 *src, CARD8 *dst, int randr,
+ int srcPitch, int dstPitch, int srcW, int srcH, int top, int left,
+ int h, int w);
+
+void
+KdXVCopyPlanarData(KdScreenInfo *screen, CARD8 *src, CARD8 *dst, int randr,
+ int srcPitch, int srcPitch2, int dstPitch, int srcW, int srcH, int height,
+ int top, int left, int h, int w, int id);
+
+void
+KXVPaintRegion (DrawablePtr pDraw, RegionPtr pRgn, Pixel fg);
+
+KdVideoAdaptorPtr KdXVAllocateVideoAdaptorRec(KdScreenInfo * screen);
+
+void KdXVFreeVideoAdaptorRec(KdVideoAdaptorPtr ptr);
+
+/* Must be called from KdCardInfo functions, can be called without Xv enabled */
+Bool KdXVEnable(ScreenPtr);
+void KdXVDisable(ScreenPtr);
+
+/*** These are DDX layer privates ***/
+
+
+typedef struct {
+ CreateWindowProcPtr CreateWindow;
+ DestroyWindowProcPtr DestroyWindow;
+ ClipNotifyProcPtr ClipNotify;
+ WindowExposuresProcPtr WindowExposures;
+} KdXVScreenRec, *KdXVScreenPtr;
+
+typedef struct {
+ int flags;
+ PutVideoFuncPtr PutVideo;
+ PutStillFuncPtr PutStill;
+ GetVideoFuncPtr GetVideo;
+ GetStillFuncPtr GetStill;
+ StopVideoFuncPtr StopVideo;
+ SetPortAttributeFuncPtr SetPortAttribute;
+ GetPortAttributeFuncPtr GetPortAttribute;
+ QueryBestSizeFuncPtr QueryBestSize;
+ PutImageFuncPtr PutImage;
+ ReputImageFuncPtr ReputImage;
+ QueryImageAttributesFuncPtr QueryImageAttributes;
+} XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr;
+
+typedef struct {
+ KdScreenInfo * screen;
+ DrawablePtr pDraw;
+ unsigned char type;
+ unsigned int subWindowMode;
+ DDXPointRec clipOrg;
+ RegionPtr clientClip;
+ RegionPtr pCompositeClip;
+ Bool FreeCompositeClip;
+ XvAdaptorRecPrivatePtr AdaptorRec;
+ XvStatus isOn;
+ Bool moved;
+ int vid_x, vid_y, vid_w, vid_h;
+ int drw_x, drw_y, drw_w, drw_h;
+ DevUnion DevPriv;
+} XvPortRecPrivate, *XvPortRecPrivatePtr;
+
+typedef struct _KdXVWindowRec{
+ XvPortRecPrivatePtr PortRec;
+ struct _KdXVWindowRec *next;
+} KdXVWindowRec, *KdXVWindowPtr;
+
+#endif /* _XVDIX_H_ */
+
diff --git a/xorg-server/hw/kdrive/src/vga.c b/xorg-server/hw/kdrive/src/vga.c
new file mode 100644
index 000000000..862f074a2
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/vga.c
@@ -0,0 +1,328 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "vga.h"
+#include <stdio.h>
+
+#ifdef linux
+#ifdef __i386__
+#define extern static
+#include <sys/io.h>
+#undef extern
+
+#define _VgaInb(r) inb(r)
+#define _VgaOutb(v,r) outb(v,r)
+#else
+#define _VgaInb(r) 0
+#define _VgaOutb(v,r)
+#endif
+
+#define _VgaByteAddr(a) ((VGAVOL8 *) (a))
+#define _VgaBytePort(a) (a)
+#endif
+
+#ifdef VXWORKS
+#define _VgaInb(r) 0
+#define _VgaOutb(v,r) 0
+
+#define _VgaByteAddr(a) ((VGAVOL8 *) ((VGA32) (a) ^ 3))
+#define _VgaBytePort(a) 0
+
+#undef stderr
+#define stderr stdout
+
+#endif
+
+#undef VGA_DEBUG_REGISTERS
+#ifdef VGA_DEBUG_REGISTERS
+#define VGA_DEBUG(a) fprintf a
+#else
+#define VGA_DEBUG(a)
+#endif
+
+VGA8
+VgaInb (VGA16 r)
+{
+ return _VgaInb(r);
+}
+
+void
+VgaOutb (VGA8 v, VGA16 r)
+{
+ _VgaOutb (v,r);
+}
+
+VGA8
+VgaReadMemb (VGA32 addr)
+{
+ return *_VgaByteAddr(addr);
+}
+
+void
+VgaWriteMemb (VGA8 v, VGA32 addr)
+{
+ *_VgaByteAddr(addr) = v;
+}
+
+VGA8
+VgaFetch (VgaCard *card, VGA16 reg)
+{
+ VgaMap map;
+ VGA8 value = 0;
+
+ (*card->map) (card, reg, &map, VGAFALSE);
+ switch (map.access) {
+ case VgaAccessMem:
+ value = VgaReadMemb (map.port);
+ VGA_DEBUG ((stderr, "%08x -> %2x\n", map.port, value));
+ break;
+ case VgaAccessIo:
+ value = _VgaInb (map.port);
+ VGA_DEBUG ((stderr, "%4x -> %2x\n", map.port, value));
+ break;
+ case VgaAccessIndMem:
+ VgaWriteMemb (map.index, map.port + map.addr);
+ value = VgaReadMemb (map.port + map.value);
+ VGA_DEBUG ((stderr, "%4x/%2x -> %2x\n", map.port, map.index, value));
+ break;
+ case VgaAccessIndIo:
+ _VgaOutb (map.index, map.port + map.addr);
+ value = _VgaInb (map.port + map.value);
+ VGA_DEBUG ((stderr, "%4x/%2x -> %2x\n", map.port, map.index, value));
+ break;
+ case VgaAccessDone:
+ value = map.value;
+ VGA_DEBUG ((stderr, "direct %4x -> %2x\n", reg, value));
+ break;
+ }
+ return value;
+}
+
+void
+VgaStore (VgaCard *card, VGA16 reg, VGA8 value)
+{
+ VgaMap map;
+
+ map.value = value;
+ (*card->map) (card, reg, &map, VGATRUE);
+ switch (map.access) {
+ case VgaAccessMem:
+ VGA_DEBUG ((stderr, "%8x <- %2x\n", map.port, value));
+ VgaWriteMemb (map.value, map.port);
+ break;
+ case VgaAccessIo:
+ VGA_DEBUG ((stderr, "%4x <- %2x\n", map.port, value));
+ _VgaOutb (value, map.port);
+ break;
+ case VgaAccessIndMem:
+ VgaWriteMemb (map.index, map.port + map.addr);
+ VgaWriteMemb (value, map.port + map.value);
+ VGA_DEBUG ((stderr, "%4x/%2x <- %2x\n", map.port, map.index, value));
+ break;
+ case VgaAccessIndIo:
+ VGA_DEBUG ((stderr, "%4x/%2x <- %2x\n", map.port, map.index, value));
+ _VgaOutb (map.index, map.port + map.addr);
+ _VgaOutb (value, map.port + map.value);
+ break;
+ case VgaAccessDone:
+ VGA_DEBUG ((stderr, "direct %4x <- %2x\n", reg, value));
+ break;
+ }
+}
+
+void
+VgaPreserve (VgaCard *card)
+{
+ VgaSave *s;
+ VGA16 id;
+
+ for (s = card->saves; s->first != VGA_REG_NONE; s++)
+ {
+ for (id = s->first; id <= s->last; id++)
+ {
+ card->values[id].cur = VgaFetch (card, id);
+ card->values[id].save = card->values[id].cur;
+ card->values[id].flags = VGA_VALUE_VALID | VGA_VALUE_SAVED;
+ }
+ }
+}
+
+void
+VgaRestore (VgaCard *card)
+{
+ VgaSave *s;
+ VGA16 id;
+
+ for (s = card->saves; s->first != VGA_REG_NONE; s++)
+ {
+ for (id = s->first; id <= s->last; id++)
+ {
+ if (card->values[id].flags & VGA_VALUE_SAVED)
+ {
+ VgaStore (card, id, card->values[id].save);
+ card->values[id].cur = card->values[id].save;
+ }
+ }
+ }
+}
+
+void
+VgaFinish (VgaCard *card)
+{
+ VGA16 id;
+
+ for (id = 0; id < card->max; id++)
+ card->values[id].flags = 0;
+}
+
+void
+VgaInvalidate (VgaCard *card)
+{
+ VGA16 id;
+
+ for (id = 0; id < card->max; id++)
+ card->values[id].flags &= ~VGA_VALUE_VALID;
+}
+
+
+static void
+_VgaSync (VgaCard *card, VGA16 id)
+{
+ if (!(card->values[id].flags & VGA_VALUE_VALID))
+ {
+ card->values[id].cur = VgaFetch (card, id);
+ card->values[id].flags |= VGA_VALUE_VALID;
+ }
+}
+
+void
+VgaSet (VgaCard *card, VgaReg *reg, VGA32 value)
+{
+ VGA8 v, mask, new;
+
+ while (reg->len)
+ {
+ if (reg->id != VGA_REG_NONE)
+ {
+ _VgaSync (card, reg->id);
+ mask = ((1 << reg->len) - 1);
+ new = value & mask;
+ mask <<= reg->base;
+ new <<= reg->base;
+ v = card->values[reg->id].cur;
+ v = (v & ~mask) | new;
+ card->values[reg->id].cur = v;
+ card->values[reg->id].flags |= VGA_VALUE_MODIFIED|VGA_VALUE_DIRTY;
+ }
+ value >>= reg->len;
+ reg++;
+ }
+}
+
+void
+VgaFlushReg (VgaCard *card, VgaReg *reg)
+{
+ while (reg->len)
+ {
+ if (reg->id != VGA_REG_NONE)
+ {
+ if (card->values[reg->id].flags & VGA_VALUE_DIRTY)
+ {
+ VgaStore (card, reg->id, card->values[reg->id].cur);
+ card->values[reg->id].flags &= ~VGA_VALUE_DIRTY;
+ }
+ }
+ reg++;
+ }
+
+}
+
+void
+VgaSetImm (VgaCard *card, VgaReg *reg, VGA32 value)
+{
+ VgaSet (card, reg, value);
+ VgaFlushReg (card, reg);
+}
+
+VGA32
+VgaGet (VgaCard *card, VgaReg *reg)
+{
+ VGA32 value, offset, v;
+ VGA8 mask;
+
+ value = 0;
+ offset = 0;
+ while (reg->len)
+ {
+ if (reg->id != VGA_REG_NONE)
+ {
+ _VgaSync (card, reg->id);
+ mask = ((1 << reg->len) - 1);
+ v = (card->values[reg->id].cur >> reg->base) & mask;
+ value |= (v << offset);
+ }
+ offset += reg->len;
+ reg++;
+ }
+ return value;
+}
+
+VGA32
+VgaGetImm (VgaCard *card, VgaReg *reg)
+{
+ VgaReg *r = reg;
+
+ while (r->len)
+ {
+ if (r->id != VGA_REG_NONE)
+ card->values[r->id].flags &= ~VGA_VALUE_VALID;
+ r++;
+ }
+ return VgaGet (card, reg);
+}
+
+void
+VgaFlush (VgaCard *card)
+{
+ VGA16 id;
+
+ for (id = 0; id < card->max; id++)
+ {
+ if (card->values[id].flags & VGA_VALUE_DIRTY)
+ {
+ VgaStore (card, id, card->values[id].cur);
+ card->values[id].flags &= ~VGA_VALUE_DIRTY;
+ }
+ }
+}
+
+void
+VgaFill (VgaCard *card, VGA16 low, VGA16 high)
+{
+ VGA16 id;
+
+ for (id = low; id < high; id++)
+ _VgaSync (card, id);
+}
diff --git a/xorg-server/hw/kdrive/src/vga.h b/xorg-server/hw/kdrive/src/vga.h
new file mode 100644
index 000000000..0615d5256
--- /dev/null
+++ b/xorg-server/hw/kdrive/src/vga.h
@@ -0,0 +1,144 @@
+/*
+ * Copyright © 1999 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _VGA_H_
+#define _VGA_H_
+
+typedef unsigned long VGA32;
+typedef unsigned short VGA16;
+typedef unsigned char VGA8;
+typedef int VGABOOL;
+typedef volatile VGA8 VGAVOL8;
+
+#define VGATRUE 1
+#define VGAFALSE 0
+
+typedef struct _vgaReg {
+ VGA16 id;
+ VGA8 base;
+ VGA8 len;
+} VgaReg;
+
+#define VGA_REG_NONE 0xffff
+#define VGA_REG_END VGA_REG_NONE, 0, 0
+
+typedef struct _vgaValue {
+ VGA8 save;
+ VGA8 cur;
+ VGA16 flags;
+} VgaValue;
+
+#define VGA_VALUE_VALID 1 /* value ever fetched */
+#define VGA_VALUE_MODIFIED 2 /* value ever changed */
+#define VGA_VALUE_DIRTY 4 /* value needs syncing */
+#define VGA_VALUE_SAVED 8 /* value preserved */
+
+typedef enum _vgaAccess {
+ VgaAccessMem, VgaAccessIo, VgaAccessIndMem, VgaAccessIndIo,
+ VgaAccessDone
+} VgaAccess;
+
+typedef struct _vgaMap {
+ VgaAccess access;
+ VGA32 port;
+ VGA8 addr; /* for Ind access; addr offset from port */
+ VGA8 value; /* for Ind access; value offset from port */
+ VGA8 index; /* for Ind access; index value */
+} VgaMap;
+
+#define VGA_UNLOCK_FIXED 1 /* dont save current value */
+#define VGA_UNLOCK_LOCK 2 /* execute only on relock */
+#define VGA_UNLOCK_UNLOCK 4 /* execute only on unlock */
+
+typedef struct _vgaSave {
+ VGA16 first;
+ VGA16 last;
+} VgaSave;
+
+#define VGA_SAVE_END VGA_REG_NONE, VGA_REG_NONE
+
+typedef struct _vgaCard {
+ void (*map) (struct _vgaCard *card, VGA16 reg, VgaMap *map, VGABOOL write);
+ void *closure;
+ int max;
+ VgaValue *values;
+ VgaSave *saves;
+} VgaCard;
+
+VGA8
+VgaInb (VGA16 r);
+
+void
+VgaOutb (VGA8 v, VGA16 r);
+
+VGA8
+VgaReadMemb (VGA32 addr);
+
+void
+VgaWriteMemb (VGA8 v, VGA32 addr);
+
+void
+VgaSetImm (VgaCard *card, VgaReg *reg, VGA32 value);
+
+VGA32
+VgaGetImm (VgaCard *card, VgaReg *reg);
+
+void
+VgaSet (VgaCard *card, VgaReg *reg, VGA32 value);
+
+VGA32
+VgaGet (VgaCard *card, VgaReg *reg);
+
+void
+VgaFlush (VgaCard *card);
+
+void
+VgaFill (VgaCard *card, VGA16 low, VGA16 high);
+
+void
+VgaPreserve (VgaCard *card);
+
+void
+VgaInvalidate (VgaCard *card);
+
+void
+VgaRestore (VgaCard *card);
+
+void
+VgaFinish (VgaCard *card);
+
+void
+VgaFlushReg (VgaCard *card, VgaReg *reg);
+
+VGA8
+VgaFetch (VgaCard *card, VGA16 id);
+
+void
+VgaStore (VgaCard *card, VGA16 id, VGA8 value);
+
+VGA8
+_VgaFetchInd (VGA16 port, VGA8 reg);
+
+void
+_VgaStoreInd (VGA16 port, VGA8 reg, VGA8 value);
+
+#endif /* _VGA_H_ */
diff --git a/xorg-server/hw/kdrive/vesa/Makefile.am b/xorg-server/hw/kdrive/vesa/Makefile.am
new file mode 100644
index 000000000..4225dcfbc
--- /dev/null
+++ b/xorg-server/hw/kdrive/vesa/Makefile.am
@@ -0,0 +1,33 @@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libvesa.a
+
+bin_PROGRAMS = Xvesa
+
+libvesa_a_SOURCES = \
+ vesa.c \
+ vesa.h \
+ vbe.c \
+ vbe.h \
+ vga.c \
+ vga.h \
+ vm86.c \
+ vm86.h
+
+Xvesa_SOURCES = \
+ vesainit.c
+
+Xvesa_LDADD = \
+ libvesa.a \
+ @KDRIVE_LIBS@
+
+Xvesa_DEPENDENCIES = \
+ libvesa.a \
+ @KDRIVE_LOCAL_LIBS@
+
+Xvesa_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/vesa/Makefile.in b/xorg-server/hw/kdrive/vesa/Makefile.in
new file mode 100644
index 000000000..0531ce07b
--- /dev/null
+++ b/xorg-server/hw/kdrive/vesa/Makefile.in
@@ -0,0 +1,717 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xvesa$(EXEEXT)
+subdir = hw/kdrive/vesa
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libvesa_a_AR = $(AR) $(ARFLAGS)
+libvesa_a_LIBADD =
+am_libvesa_a_OBJECTS = vesa.$(OBJEXT) vbe.$(OBJEXT) vga.$(OBJEXT) \
+ vm86.$(OBJEXT)
+libvesa_a_OBJECTS = $(am_libvesa_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xvesa_OBJECTS = vesainit.$(OBJEXT)
+Xvesa_OBJECTS = $(am_Xvesa_OBJECTS)
+Xvesa_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xvesa_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libvesa_a_SOURCES) $(Xvesa_SOURCES)
+DIST_SOURCES = $(libvesa_a_SOURCES) $(Xvesa_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libvesa.a
+libvesa_a_SOURCES = \
+ vesa.c \
+ vesa.h \
+ vbe.c \
+ vbe.h \
+ vga.c \
+ vga.h \
+ vm86.c \
+ vm86.h
+
+Xvesa_SOURCES = \
+ vesainit.c
+
+Xvesa_LDADD = \
+ libvesa.a \
+ @KDRIVE_LIBS@
+
+Xvesa_DEPENDENCIES = \
+ libvesa.a \
+ @KDRIVE_LOCAL_LIBS@
+
+Xvesa_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/vesa/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/vesa/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libvesa.a: $(libvesa_a_OBJECTS) $(libvesa_a_DEPENDENCIES)
+ -rm -f libvesa.a
+ $(libvesa_a_AR) libvesa.a $(libvesa_a_OBJECTS) $(libvesa_a_LIBADD)
+ $(RANLIB) libvesa.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xvesa$(EXEEXT): $(Xvesa_OBJECTS) $(Xvesa_DEPENDENCIES)
+ @rm -f Xvesa$(EXEEXT)
+ $(Xvesa_LINK) $(Xvesa_OBJECTS) $(Xvesa_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vbe.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vesa.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vesainit.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vga.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vm86.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/vesa/vbe.c b/xorg-server/hw/kdrive/vesa/vbe.c
new file mode 100644
index 000000000..cedefe9fc
--- /dev/null
+++ b/xorg-server/hw/kdrive/vesa/vbe.c
@@ -0,0 +1,706 @@
+/*
+Copyright (c) 2000 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "vesa.h"
+
+int
+VbeGetVib (Vm86InfoPtr vi, VbeInfoBlock *vib)
+{
+ int code;
+ int mark;
+ int vib_base;
+ VbeInfoBlock *vib_low;
+
+ mark = Vm86MarkMemory (vi);
+ vib_base = Vm86AllocateMemory (vi, sizeof (VbeInfoBlock));
+ vib_low = (VbeInfoBlock*)&(LM(vi, vib_base));
+ vi->vms.regs.eax = 0x4F00;
+ vi->vms.regs.es = POINTER_SEGMENT(vib_base);
+ vi->vms.regs.edi = POINTER_OFFSET(vib_base);
+ memcpy(vib_low->VbeSignature, "VBE2", 4);
+ code = VbeDoInterrupt10(vi);
+ if(code >= 0)
+ {
+ if(memcmp(vib_low->VbeSignature, "VESA", 4) == 0)
+ *vib = *vib_low;
+ else
+ code = -1;
+ }
+ Vm86ReleaseMemory (vi, mark);
+ return code;
+}
+
+int
+VbeGetVmib (Vm86InfoPtr vi, int mode, VbeModeInfoBlock *vmib)
+{
+ int code;
+ int mark;
+ int vmib_base;
+ VbeModeInfoBlock *vmib_low;
+
+ mark = Vm86MarkMemory (vi);
+
+ vmib_base = Vm86AllocateMemory (vi, sizeof (VbeModeInfoBlock));
+ vmib_low = (VbeModeInfoBlock*)&(LM(vi, vmib_base));
+
+ vi->vms.regs.eax = 0x4F01;
+ vi->vms.regs.ecx = mode&0xFFFF;
+ vi->vms.regs.es = POINTER_SEGMENT(vmib_base);
+ vi->vms.regs.edi = POINTER_OFFSET(vmib_base);
+ code = VbeDoInterrupt10(vi);
+
+ if(code >= 0)
+ *vmib = *vmib_low;
+ Vm86ReleaseMemory (vi, mark);
+ return code;
+}
+
+static int
+VbeReportVib(Vm86InfoPtr vi, VbeInfoBlock *vib)
+{
+ U32 i, p;
+ unsigned char c;
+ int error = 0;
+
+ ErrorF("VBE version %c.%c (",
+ ((vib->VbeVersion >> 8) & 0xFF) + '0',
+ (vib->VbeVersion & 0xFF)+'0');
+ p = vib->OemStringPtr;
+ for(i = 0; 1; i++) {
+ c = Vm86Memory(vi, MAKE_POINTER_1(p+i));
+ if(!c) break;
+ if (c >= ' ')
+ ErrorF("%c", c);
+ if (i > 32000) {
+ error = 1;
+ break;
+ }
+ }
+ ErrorF(")\n");
+ ErrorF("DAC is %s, controller is %sVGA compatible%s\n",
+ (vib->Capabilities[0]&1)?"switchable":"fixed",
+ (vib->Capabilities[0]&2)?"not ":"",
+ (vib->Capabilities[0]&3)?", RAMDAC causes snow":"");
+ ErrorF("Total memory: %lu kilobytes\n", 64L*vib->TotalMemory);
+ if(error)
+ return -1;
+ return 0;
+}
+
+#if 0
+static int
+VbeReportModeInfo(Vm86InfoPtr vi, U16 mode, VbeModeInfoBlock *vmib)
+{
+ int supported = (vmib->ModeAttributes&0x1)?1:0;
+ int colour = (vmib->ModeAttributes&0x8)?1:0;
+ int graphics = (vmib->ModeAttributes&0x10)?1:0;
+ int vga_compatible = !((vmib->ModeAttributes&0x20)?1:0);
+ int linear_fb = (vmib->ModeAttributes&0x80)?1:0;
+
+ ErrorF("0x%04X: %dx%dx%d%s",
+ (unsigned)mode,
+ (int)vmib->XResolution, (int)vmib->YResolution,
+ (int)vmib->BitsPerPixel,
+ colour?"":" (monochrome)",
+ graphics?"":" (graphics)",
+ vga_compatible?"":" (vga compatible)",
+ linear_fb?"":" (linear frame buffer)");
+ switch(vmib->MemoryModel) {
+ case 0:
+ ErrorF(" text mode (%dx%d)",
+ (int)vmib->XCharSize, (int)vmib->YCharSize);
+ break;
+ case 1:
+ ErrorF(" CGA graphics");
+ break;
+ case 2:
+ ErrorF(" Hercules graphics");
+ break;
+ case 3:
+ ErrorF(" Planar (%d planes)", vmib->NumberOfPlanes);
+ break;
+ case 4:
+ ErrorF(" PseudoColor");
+ break;
+ case 5:
+ ErrorF(" Non-chain 4, 256 colour");
+ break;
+ case 6:
+ if(vmib->DirectColorModeInfo & 1)
+ ErrorF(" DirectColor");
+ else
+ ErrorF(" TrueColor");
+ ErrorF(" [%d:%d:%d:%d]",
+ vmib->RedMaskSize, vmib->GreenMaskSize, vmib->BlueMaskSize,
+ vmib->RsvdMaskSize);
+ if(vmib->DirectColorModeInfo & 2)
+ ErrorF(" (reserved bits are reserved)");
+ break;
+ case 7: ErrorF("YUV");
+ break;
+ default:
+ ErrorF("unknown MemoryModel 0x%X ", vmib->MemoryModel);
+ }
+ if(!supported)
+ ErrorF(" (unsupported)");
+ else if(!linear_fb)
+ ErrorF(" (no linear framebuffer)");
+ ErrorF("\n");
+ return 0;
+}
+#endif
+
+void
+VbeReportInfo (Vm86InfoPtr vi)
+{
+ VbeInfoBlock vib;
+ int code;
+
+ code = VbeGetVib (vi, &vib);
+ if (code >= 0)
+ VbeReportVib(vi, &vib);
+}
+
+int
+VbeGetNmode (Vm86InfoPtr vi)
+{
+ VbeInfoBlock vib;
+ int code;
+ unsigned int p;
+ int n;
+ int mode;
+
+ code = VbeGetVib (vi, &vib);
+ if (code >= 0)
+ {
+ p = MAKE_POINTER_1(vib.VideoModePtr);
+ for (n = 0; ; n++)
+ {
+ mode = Vm86MemoryW(vi, p);
+ if (mode == 0xffff)
+ break;
+ p += 2;
+ }
+ code = n;
+ }
+ return code;
+}
+
+int
+VbeGetModes (Vm86InfoPtr vi, VesaModePtr modes, int nmode)
+{
+ VbeInfoBlock vib;
+ int code;
+ unsigned int p;
+ int n;
+ int mode;
+ VbeModeInfoBlock vmib;
+
+ code = VbeGetVib (vi, &vib);
+ if (code < 0)
+ return code;
+
+ memset (modes, '\0', nmode * sizeof (VesaModeRec));
+
+ p = MAKE_POINTER_1(vib.VideoModePtr);
+ for (n = 0; n < nmode; n++)
+ {
+ mode = Vm86MemoryW(vi, p);
+ if (mode == 0xffff)
+ break;
+ modes[n].mode = mode;
+ modes[n].vbe = 1;
+ p += 2;
+ }
+
+ nmode = n;
+
+ for (n = 0; n < nmode; n++)
+ {
+ code = VbeGetVmib (vi, modes[n].mode, &vmib);
+ if (code >= 0)
+ {
+ modes[n].ModeAttributes = vmib.ModeAttributes;
+ modes[n].NumberOfPlanes = vmib.NumberOfPlanes;
+ modes[n].BitsPerPixel = vmib.BitsPerPixel;
+ modes[n].MemoryModel = vmib.MemoryModel;
+ modes[n].RedMaskSize = vmib.RedMaskSize;
+ modes[n].RedFieldPosition = vmib.RedFieldPosition;
+ modes[n].GreenMaskSize = vmib.GreenMaskSize;
+ modes[n].GreenFieldPosition = vmib.GreenFieldPosition;
+ modes[n].BlueMaskSize = vmib.BlueMaskSize;
+ modes[n].BlueFieldPosition = vmib.BlueFieldPosition;
+ modes[n].RsvdMaskSize = vmib.RsvdMaskSize;
+ modes[n].RsvdFieldPosition = vmib.RsvdFieldPosition;
+ modes[n].DirectColorModeInfo = vmib.DirectColorModeInfo;
+ modes[n].XResolution = vmib.XResolution;
+ modes[n].YResolution = vmib.YResolution;
+ modes[n].BytesPerScanLine = vmib.BytesPerScanLine;
+ }
+ }
+
+ return nmode;
+}
+
+VbeInfoPtr
+VbeInit (Vm86InfoPtr vi)
+{
+ VbeInfoPtr vbe;
+ int code;
+ VbeInfoBlock vib;
+
+ code = VbeGetVib (vi, &vib);
+ if (code < 0)
+ return 0;
+
+ vbe = xalloc (sizeof (VbeInfoRec));
+ if (!vbe)
+ return 0;
+ vbe->palette_format = 6;
+ vbe->palette_wait = TRUE;
+ return vbe;
+}
+
+void
+VbeCleanup (Vm86InfoPtr vi, VbeInfoPtr vbe)
+{
+ xfree (vbe);
+}
+
+int
+VbeSetMode (Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int linear, int direct)
+{
+ int code;
+ VbeInfoBlock vib;
+ int palette_wait = 0, palette_hi = 0;
+
+ code = VbeGetVib (vi, &vib);
+ if (code < 0)
+ return -1;
+
+ code = VbeGetVmib (vi, mode, &vbe->vmib);
+ if (code < 0)
+ return -1;
+
+ mode = (mode & 0xffff) &~ 0x8000;
+ if (linear)
+ mode |= 0x4000;
+
+ vi->vms.regs.eax = 0x4F02;
+ vi->vms.regs.ebx = mode;
+ code = VbeDoInterrupt10(vi);
+ if(code < 0)
+ return -1;
+
+ vbe->windowA_offset = vbe->windowB_offset = -1;
+ vbe->last_window = 1;
+
+ if (!direct)
+ {
+ if(vib.Capabilities[0] & 1)
+ palette_hi = 1;
+ if(vib.Capabilities[0] & 4)
+ palette_wait = 1;
+
+ if(palette_hi || palette_wait)
+ VbeSetPaletteOptions(vi, vbe, palette_hi?8:6, palette_wait);
+ }
+
+ return 0;
+}
+
+int
+VbeGetMode(Vm86InfoPtr vi, int *mode)
+{
+ int code;
+
+ vi->vms.regs.eax = 0x4F03;
+ code = VbeDoInterrupt10(vi);
+ if(code < 0)
+ return - 1;
+ *mode = vi->vms.regs.ebx & 0xFFFF;
+ return 0;
+}
+
+void *
+VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *ret_size, CARD32 *ret_phys)
+{
+ U8 *fb;
+ VbeInfoBlock vib;
+ VbeModeInfoBlock vmib;
+ int size;
+ int pagesize = getpagesize();
+ int before, after;
+
+ if (VbeGetVib (vi, &vib) < 0)
+ return 0;
+
+ if (VbeGetVmib (vi, mode, &vmib) < 0)
+ return 0;
+
+ size = 1024 * 64L * vib.TotalMemory;
+
+ *ret_size = size;
+ *ret_phys = vmib.PhysBasePtr;
+
+ before = vmib.PhysBasePtr % pagesize;
+ after = pagesize - ((vmib.PhysBasePtr + size) % pagesize);
+ if(after == pagesize)
+ after = 0;
+
+ fb = KdMapDevice (vmib.PhysBasePtr - before, before + size + after);
+
+ if(fb == 0)
+ {
+ ErrorF("Failed to map framebuffer\n");
+ return NULL;
+ }
+
+ KdSetMappedMode (vmib.PhysBasePtr - before, before + size + after,
+ KD_MAPPED_MODE_FRAMEBUFFER);
+
+ return fb + before;
+}
+
+void
+VbeUnmapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, void *fb)
+{
+ VbeInfoBlock vib;
+ VbeModeInfoBlock vmib;
+ int size;
+ int pagesize = getpagesize();
+ int before, after;
+
+ if (VbeGetVib (vi, &vib) < 0)
+ return;
+
+ if (VbeGetVmib (vi, mode, &vmib) < 0)
+ return;
+
+ size = 1024 * 64L * vib.TotalMemory;
+
+ before = vmib.PhysBasePtr % pagesize;
+ after = pagesize - ((vmib.PhysBasePtr + size) % pagesize);
+ if(after == pagesize)
+ after = 0;
+
+ fb = (void *) ((char *) fb - before);
+
+ KdUnmapDevice (fb, before + size + after);
+ KdResetMappedMode (vmib.PhysBasePtr - before, before + size + after,
+ KD_MAPPED_MODE_FRAMEBUFFER);
+}
+
+int
+VbeSetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries)
+{
+ U8 *palette_scratch;
+ int mark;
+ int palette_base;
+ int i, code;
+
+ if(number == 0)
+ return 0;
+
+ if(first < 0 || number < 0 || first + number > 256) {
+ ErrorF("Cannot set %d, %d palette entries\n", first, number);
+ return -1;
+ }
+ if(vbe->palette_format < 6 || vbe->palette_format > 8) {
+ ErrorF("Impossible palette format %d\n", vbe->palette_format);
+ return -1;
+ }
+
+ mark = Vm86MarkMemory (vi);
+ palette_base = Vm86AllocateMemory (vi, 4 * 256);
+
+ palette_scratch = &LM(vi, palette_base);
+
+ for(i=0; i<number*4; i++)
+ palette_scratch[i] = entries[i] >> (8 - vbe->palette_format);
+
+ vi->vms.regs.eax = 0x4F09;
+ if(vbe->palette_wait)
+ vi->vms.regs.ebx = 0x80;
+ else
+ vi->vms.regs.ebx = 0x00;
+ vi->vms.regs.ecx = number;
+ vi->vms.regs.edx = first;
+ vi->vms.regs.es = POINTER_SEGMENT(palette_base);
+ vi->vms.regs.edi = POINTER_OFFSET(palette_base);
+ code = VbeDoInterrupt10(vi);
+ Vm86ReleaseMemory (vi, mark);
+
+ if(code < 0)
+ return -1;
+ return 0;
+}
+
+int
+VbeGetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries)
+{
+ U8 *palette_scratch;
+ int mark;
+ int palette_base;
+ int i, code;
+
+ if(number == 0)
+ return 0;
+
+ if(first < 0 || number < 0 || first + number > 256) {
+ ErrorF("Cannot get %d, %d palette entries\n", first, number);
+ return -1;
+ }
+ if(vbe->palette_format < 6 || vbe->palette_format > 8) {
+ ErrorF("Impossible palette format %d\n", vbe->palette_format);
+ return -1;
+ }
+
+ mark = Vm86MarkMemory (vi);
+ palette_base = Vm86AllocateMemory (vi, 4 * 256);
+
+ palette_scratch = &LM(vi, palette_base);
+
+ vi->vms.regs.eax = 0x4F09;
+ vi->vms.regs.ebx = 0x01;
+ vi->vms.regs.ecx = number;
+ vi->vms.regs.edx = first;
+ vi->vms.regs.es = POINTER_SEGMENT(palette_base);
+ vi->vms.regs.edi = POINTER_OFFSET(palette_base);
+ code = VbeDoInterrupt10(vi);
+ if(code >= 0)
+ {
+ for(i=0; i<number*4; i++)
+ entries[i] = palette_scratch[i] << (8-vbe->palette_format);
+ }
+ Vm86ReleaseMemory (vi, mark);
+
+ return 0;
+}
+
+int
+VbeSetPaletteOptions(Vm86InfoPtr vi, VbeInfoPtr vbe, U8 bits, int wait)
+{
+ int code;
+
+ if(bits < 6 || bits > 8) {
+ ErrorF("Impossible palette format %d\n", bits);
+ return -1;
+ }
+ if(bits != vbe->palette_format)
+ {
+ vbe->palette_format = 0;
+ vi->vms.regs.eax = 0x4F08;
+ vi->vms.regs.ebx = bits << 8;
+ code = VbeDoInterrupt10(vi);
+ if(code < 0)
+ return -1;
+ vbe->palette_format = bits;
+ }
+ vbe->palette_wait = wait;
+ return 0;
+}
+
+static int
+VbeReallySetWindow(Vm86InfoPtr vi, U8 window, U16 winnum)
+{
+ int code;
+ vi->vms.regs.eax = 0x4F05;
+ vi->vms.regs.ebx = window;
+ vi->vms.regs.edx = winnum;
+ code = VbeDoInterrupt10(vi);
+ if(code < 0)
+ return -1;
+ return 0;
+}
+
+void *
+VbeSetWindow(Vm86InfoPtr vi, VbeInfoPtr vbe, int offset, int purpose, int *size_return)
+{
+ int window_size = vbe->vmib.WinSize * 1024;
+ int code;
+ int winnum;
+
+ if(vbe->windowA_offset >= 0)
+ if(vbe->windowA_offset <= offset && vbe->windowA_offset + window_size > offset)
+ if(vbe->vmib.WinAAttributes & purpose)
+ goto windowA;
+
+ if(vbe->windowB_offset >= 0)
+ if(vbe->windowB_offset <= offset && vbe->windowB_offset + window_size > offset)
+ if(vbe->vmib.WinBAttributes & purpose)
+ goto windowB;
+
+ if(!(vbe->vmib.WinBAttributes & purpose) ||
+ !(vbe->vmib.WinBAttributes & VBE_WINDOW_RELOCATE))
+ goto set_windowA;
+
+ if(!(vbe->vmib.WinAAttributes & purpose) ||
+ !(vbe->vmib.WinAAttributes & VBE_WINDOW_RELOCATE))
+ goto set_windowB;
+
+ if(vbe->last_window)
+ goto set_windowA;
+ else
+ goto set_windowB;
+
+set_windowA:
+ winnum = offset / (vbe->vmib.WinGranularity * 1024);
+ code = VbeReallySetWindow(vi, 0, winnum);
+ if(code < 0) {
+ ErrorF("Couldn't set window A to %d*%d\n",
+ (int)winnum, (int)vbe->vmib.WinGranularity);
+ return NULL;
+ }
+ vbe->windowA_offset = winnum * vbe->vmib.WinGranularity * 1024;
+windowA:
+ vbe->last_window = 0;
+ *size_return = vbe->vmib.WinSize * 1024 - (offset - vbe->windowA_offset);
+ return ((U8*)&(LM(vi, MAKE_POINTER(vbe->vmib.WinASegment, 0)))) + offset - vbe->windowA_offset;
+
+set_windowB:
+ winnum = offset / (vbe->vmib.WinGranularity * 1024);
+ code = VbeReallySetWindow(vi, 1, winnum);
+ if(code < 0) {
+ ErrorF("Couldn't set window B to %d*%d\n",
+ (int)winnum, (int)vbe->vmib.WinGranularity);
+ return NULL;
+ }
+ vbe->windowB_offset = winnum * vbe->vmib.WinGranularity * 1024;
+windowB:
+ vbe->last_window = 1;
+ *size_return = vbe->vmib.WinSize * 1024 - (offset - vbe->windowB_offset);
+ return ((U8*)&(LM(vi, MAKE_POINTER(vbe->vmib.WinBSegment, 0)))) + offset - vbe->windowB_offset;
+}
+
+static const int VbeDPMSModes[4] = {
+ 0x00, /* KD_DPMS_NORMAL */
+ 0x01, /* KD_DPMS_STANDBY */
+ 0x02, /* KD_DPMS_SUSPEND */
+ 0x04, /* KD_DPMS_POWERDOWN */
+};
+
+Bool
+VbeDPMS(Vm86InfoPtr vi, int mode)
+{
+ int code;
+
+ /*
+ * Check which modes are supported
+ */
+ vi->vms.regs.eax = 0x4f10;
+ vi->vms.regs.ebx = 0x0000;
+ vi->vms.regs.es = 0;
+ vi->vms.regs.edi = 0;
+ code = VbeDoInterrupt10 (vi);
+ if (code < 0)
+ {
+ ErrorF ("No DPMS Support %d\n", code);
+ return FALSE;
+ }
+ /* Skip this stage if it's not supported */
+ if (((vi->vms.regs.ebx >> 4) & VbeDPMSModes[mode]) != VbeDPMSModes[mode])
+ return FALSE;
+
+ /* Select this mode */
+ vi->vms.regs.eax = 0x4f10;
+ vi->vms.regs.ebx = (VbeDPMSModes[mode] << 8) | 0x01;
+ code = VbeDoInterrupt10 (vi);
+ if (code < 0)
+ {
+ ErrorF ("DPMS failed %d\n", code);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool
+VbeBoot(Vm86InfoPtr vi)
+{
+ int code;
+ int bus = 1;
+ int device = 0;
+ int function = 0;
+
+ vi->vms.regs.eax = (bus << 8) | (device << 3) | (function & 0x7);
+ code = VbeDoInterruptE6 (vi);
+ ErrorF ("Boot: %d\n", code);
+ return TRUE;
+}
+
+int
+VbeDoInterrupt10(Vm86InfoPtr vi)
+{
+ int code;
+ int oldax;
+
+ oldax = vi->vms.regs.eax & 0xFFFF;
+
+ code = Vm86DoInterrupt(vi, 0x10);
+ if(code < 0)
+ return -1;
+
+ if((vi->vms.regs.eax & 0xFFFF) != 0x4F && (oldax & 0xFF00) == 0x4F00) {
+ ErrorF("Int 10h (0x%04X) failed: 0x%04X",
+ oldax, vi->vms.regs.eax & 0xFFFF);
+ if((oldax & 0xFF00) == 0x4F00) {
+ switch((vi->vms.regs.eax & 0xFF00)>>8) {
+ case 0:
+ ErrorF(" (success)\n");
+ return 0;
+ case 1:
+ ErrorF(" (function call failed)\n");
+ break;
+ case 2:
+ ErrorF(" (function not supported on this hardware)\n");
+ break;
+ case 3:
+ ErrorF(" (function call invalid in this video mode)\n");
+ break;
+ default:
+ ErrorF(" (unknown error)\n");
+ break;
+ } return -1;
+ } else {
+ ErrorF("\n");
+ }
+ }
+ return code;
+}
+
+int
+VbeDoInterruptE6(Vm86InfoPtr vi)
+{
+ int code;
+ int oldax;
+
+ oldax = vi->vms.regs.eax & 0xffff;
+
+ code = Vm86DoPOST (vi);
+ ErrorF("POST (0x%04X): 0x%04X\n",
+ oldax, vi->vms.regs.eax & 0xffff);
+ return code;
+}
diff --git a/xorg-server/hw/kdrive/vesa/vbe.h b/xorg-server/hw/kdrive/vesa/vbe.h
new file mode 100644
index 000000000..f67fbbe42
--- /dev/null
+++ b/xorg-server/hw/kdrive/vesa/vbe.h
@@ -0,0 +1,165 @@
+/*
+Copyright (c) 2000 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+*/
+
+#ifndef _VBE_H
+#define _VBE_H
+
+#define VBE_WINDOW_RELOCATE 1
+#define VBE_WINDOW_READ 2
+#define VBE_WINDOW_WRITE 4
+
+typedef struct _VbeInfoBlock {
+ U8 VbeSignature[4]; /* VBE Signature */
+ U16 VbeVersion; /* VBE Version */
+ U32 OemStringPtr; /* Pointer to OEM String */
+ U8 Capabilities[4]; /* Capabilities of graphics controller */
+ U32 VideoModePtr; /* Pointer to VideoModeList */
+ U16 TotalMemory; /* Number of 64kb memory blocks */
+/* Added for VBE 2.0 */
+ U16 OemSoftwareRev; /* VBE implementation Software revision */
+ U32 OemVendorNamePtr; /* Pointer to Vendor Name String */
+ U32 OemProductNamePtr; /* Pointer to Product Name String */
+ U32 OemProductRevPtr; /* Pointer to Product Revision String */
+ U8 Reserved[222]; /* Reserved for VBE implementation */
+ U8 OemData[256]; /* Data Area for OEM Strings*/
+} __attribute__((packed)) VbeInfoBlock;
+
+typedef struct _VbeModeInfoBlock {
+/* Mandatory information for all VBE revisions */
+ U16 ModeAttributes; /* mode attributes */
+ U8 WinAAttributes; /* window A attributes */
+ U8 WinBAttributes; /* window B attributes */
+ U16 WinGranularity; /* window granularity */
+ U16 WinSize; /* window size */
+ U16 WinASegment; /* window A start segment */
+ U16 WinBSegment; /* window B start segment */
+ U32 WinFuncPtr; /* pointer to window function */
+ U16 BytesPerScanLine; /* bytes per scan line */
+/* Mandatory information for VBE 1.2 and above */
+ U16 XResolution; /* horizontal resolution */
+ U16 YResolution; /* vertical resolution */
+ U8 XCharSize; /* character cell width in pixels */
+ U8 YCharSize; /* character cell height in pixels */
+ U8 NumberOfPlanes; /* number of memory planes */
+ U8 BitsPerPixel; /* bits per pixel */
+ U8 NumberOfBanks; /* number of banks */
+ U8 MemoryModel; /* memory model type */
+ U8 BankSize; /* bank size in KB */
+ U8 NumberOfImagePages; /* number of images */
+ U8 Reserved; /* reserved for page function */
+/* Direct Color fields (required for direct/6 and YUV/7 memory models) */
+ U8 RedMaskSize; /* size of direct color red mask in bits */
+ U8 RedFieldPosition; /* bit position of lsb of red mask */
+ U8 GreenMaskSize; /* size of direct color green mask in bits */
+ U8 GreenFieldPosition; /* bit position of lsb of green mask */
+ U8 BlueMaskSize; /* size of direct color blue mask in bits */
+ U8 BlueFieldPosition; /* bit position of lsb of blue mask */
+ U8 RsvdMaskSize; /* size of direct color reserved mask bits*/
+ U8 RsvdFieldPosition; /* bit position of lsb of reserved mask */
+ U8 DirectColorModeInfo; /* direct color mode attributes */
+/* Mandatory information for VBE 2.0 and above */
+ U32 PhysBasePtr; /* physical address for flat memory fb */
+ U32 OffScreenMemOffset; /* pointer to start of off screen memory */
+ U16 OffScreenMemSize; /* amount of off screen memory in 1k units */
+ U8 Reserved2[206]; /* remainder of ModeInfoBlock */
+} __attribute__((packed)) VbeModeInfoBlock;
+
+typedef struct _VbeInfoRec {
+ U8 palette_format;
+ int palette_wait;
+ int windowA_offset;
+ int windowB_offset;
+ int window_size;
+ int last_window;
+ VbeModeInfoBlock vmib;
+} VbeInfoRec, *VbeInfoPtr;
+
+typedef struct _SupVbeInfoBlock {
+ U8 SupVbeSignature[7]; /* Supplemental VBE Signature */
+ U16 SupVbeVersion; /* Supplemental VBE Version*/
+ U8 SupVbeSubFunc[8]; /* Bitfield of supported subfunctions */
+ U16 OemSoftwareRev; /* OEM Software revision */
+ U32 OemVendorNamePtr; /* Pointer to Vendor Name String */
+ U32 OemProductNamePtr; /* Pointer to Product Name String */
+ U32 OemProductRevPtr; /* Pointer to Product Revision String */
+ U32 OemStringPtr; /* Pointer to OEM String */
+ U8 Reserved[221]; /* Reserved */
+} __attribute__((packed)) SupVbeInfoBlock;
+
+int
+VbeGetVib (Vm86InfoPtr vi, VbeInfoBlock *vib);
+
+int
+VbeGetVmib (Vm86InfoPtr vi, int mode, VbeModeInfoBlock *vmib);
+
+void
+VbeReportInfo (Vm86InfoPtr vi);
+
+int
+VbeGetNmode (Vm86InfoPtr vi);
+
+int
+VbeGetModes (Vm86InfoPtr vi, VesaModePtr modes, int nmode);
+
+VbeInfoPtr
+VbeInit (Vm86InfoPtr vi);
+
+void
+VbeCleanup (Vm86InfoPtr vi, VbeInfoPtr vbe);
+
+int
+VbeSetMode (Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int linear, int direct);
+
+int
+VbeGetMode(Vm86InfoPtr vi, int *mode);
+
+void *
+VbeMapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, int *ret_size, CARD32 *ret_phys);
+
+void
+VbeUnmapFramebuffer(Vm86InfoPtr vi, VbeInfoPtr vbe, int mode, void *fb);
+
+int
+VbeSetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries);
+
+int
+VbeGetPalette(Vm86InfoPtr vi, VbeInfoPtr vbe, int first, int number, U8 *entries);
+
+int
+VbeSetPaletteOptions(Vm86InfoPtr vi, VbeInfoPtr vbe, U8 bits, int wait);
+
+void *
+VbeSetWindow(Vm86InfoPtr vi, VbeInfoPtr vbe, int offset, int purpose, int *size_return);
+
+Bool
+VbeDPMS(Vm86InfoPtr vi, int mode);
+
+int
+VbeDoInterrupt10(Vm86InfoPtr vi);
+
+Bool
+VbeBoot(Vm86InfoPtr vi);
+
+int
+VbeDoInterruptE6(Vm86InfoPtr vi);
+
+#endif
diff --git a/xorg-server/hw/kdrive/vesa/vesa.c b/xorg-server/hw/kdrive/vesa/vesa.c
new file mode 100644
index 000000000..d6fa5eb06
--- /dev/null
+++ b/xorg-server/hw/kdrive/vesa/vesa.c
@@ -0,0 +1,1823 @@
+/*
+Copyright (c) 2000 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "vesa.h"
+#include "vga.h"
+#include "vbe.h"
+#ifdef RANDR
+#include <randrstr.h>
+#endif
+
+int vesa_video_mode = 0;
+Bool vesa_force_mode = FALSE;
+Bool vesa_swap_rgb = FALSE;
+Bool vesa_shadow = FALSE;
+Bool vesa_linear_fb = TRUE;
+Bool vesa_restore = FALSE;
+Bool vesa_verbose = FALSE;
+Bool vesa_force_text = FALSE;
+Bool vesa_restore_font = TRUE;
+Bool vesa_map_holes = TRUE;
+Bool vesa_boot = FALSE;
+
+#define VesaPriv(scr) ((VesaScreenPrivPtr) (scr)->driver)
+
+#define vesaWidth(scr,vmib) ((vmib)->XResolution)
+#define vesaHeight(scr,vmib) ((vmib)->YResolution)
+
+static Bool
+vesaComputeFramebufferMapping (KdScreenInfo *screen);
+
+static Bool
+vesaMapFramebuffer (KdScreenInfo *screen);
+
+static Bool
+vesaModeSupportable (VesaModePtr mode, Bool complain)
+{
+ if((mode->ModeAttributes & 0x10) == 0) {
+ if(complain)
+ ErrorF("Text mode specified.\n");
+ return FALSE;
+ }
+ if(mode->MemoryModel != 0x06 && mode->MemoryModel != 0x04 && mode->MemoryModel != 0x03) {
+ if(complain)
+ ErrorF("Unsupported memory model 0x%X\n", mode->MemoryModel);
+ return FALSE;
+ }
+ if((mode->ModeAttributes & 0x80) == 0) {
+ if ((mode->ModeAttributes & 0x40) != 0) {
+ if(complain)
+ ErrorF("Neither linear nor windowed framebuffer available in this mode\n");
+ return FALSE;
+ }
+ }
+ if(!(mode->ModeAttributes & 1)) {
+ if(complain)
+ ErrorF("Mode not supported on this hardware\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static Bool
+vesaModeSupported (VesaCardPrivPtr priv, VesaModePtr mode, Bool complain)
+{
+ if (!priv->vbeInfo && mode->vbe) {
+ if (complain)
+ ErrorF("VBE bios mode not usable.\n");
+ return FALSE;
+ }
+ return vesaModeSupportable (mode, complain);
+}
+
+void
+vesaReportMode (VesaModePtr mode)
+{
+ int supported = (mode->ModeAttributes&MODE_SUPPORTED)?1:0;
+ int colour = (mode->ModeAttributes&MODE_COLOUR)?1:0;
+ int graphics = (mode->ModeAttributes&MODE_GRAPHICS)?1:0;
+ int vga_compatible = !((mode->ModeAttributes&MODE_VGA)?1:0);
+ int linear_fb = (mode->ModeAttributes&MODE_LINEAR)?1:0;
+
+ ErrorF("0x%04X: %dx%dx%d%s%s",
+ (unsigned)mode->mode,
+ (int)mode->XResolution, (int)mode->YResolution,
+ vesaDepth (mode),
+ colour?"":" (monochrome)",
+ graphics?"":" (graphics)",
+ vga_compatible?"":" (vga compatible)",
+ linear_fb?"":" (linear frame buffer)");
+ switch(mode->MemoryModel) {
+ case MEMORY_TEXT:
+ ErrorF(" text mode");
+ break;
+ case MEMORY_CGA:
+ ErrorF(" CGA graphics");
+ break;
+ case MEMORY_HERCULES:
+ ErrorF(" Hercules graphics");
+ break;
+ case MEMORY_PLANAR:
+ ErrorF(" Planar (%d planes)", mode->NumberOfPlanes);
+ break;
+ case MEMORY_PSEUDO:
+ ErrorF(" PseudoColor");
+ break;
+ case MEMORY_NONCHAIN:
+ ErrorF(" Non-chain 4, 256 colour");
+ break;
+ case MEMORY_DIRECT:
+ if(mode->DirectColorModeInfo & MODE_DIRECT)
+ ErrorF(" DirectColor");
+ else
+ ErrorF(" TrueColor");
+ ErrorF(" [%d:%d:%d:%d]",
+ mode->RedMaskSize, mode->GreenMaskSize, mode->BlueMaskSize,
+ mode->RsvdMaskSize);
+ if(mode->DirectColorModeInfo & 2)
+ ErrorF(" (reserved bits are reserved)");
+ break;
+ case MEMORY_YUV:
+ ErrorF("YUV");
+ break;
+ default:
+ ErrorF("unknown MemoryModel 0x%X ", mode->MemoryModel);
+ }
+ if(!supported)
+ ErrorF(" (unsupported)");
+ else if(!linear_fb)
+ ErrorF(" (no linear framebuffer)");
+ ErrorF("\n");
+}
+
+VesaModePtr
+vesaGetModes (Vm86InfoPtr vi, int *ret_nmode)
+{
+ VesaModePtr modes;
+ int nmode, nmodeVbe, nmodeVga;
+ int code;
+
+ code = VgaGetNmode (vi);
+ if (code <= 0)
+ nmodeVga = 0;
+ else
+ nmodeVga = code;
+
+ code = VbeGetNmode (vi);
+ if (code <= 0)
+ nmodeVbe = 0;
+ else
+ nmodeVbe = code;
+
+ nmode = nmodeVga + nmodeVbe;
+ if (nmode <= 0)
+ return 0;
+
+ modes = xalloc (nmode * sizeof (VesaModeRec));
+
+ memset (modes, '\0', nmode * sizeof (VesaModeRec));
+
+ if (nmodeVga)
+ {
+ code = VgaGetModes (vi, modes, nmodeVga);
+ if (code <= 0)
+ nmodeVga = 0;
+ else
+ nmodeVga = code;
+ }
+
+ if (nmodeVbe)
+ {
+ code = VbeGetModes (vi, modes + nmodeVga, nmodeVbe);
+ if (code <= 0)
+ nmodeVbe = 0;
+ else
+ nmodeVbe = code;
+ }
+
+ nmode = nmodeVga + nmodeVbe;
+
+ if (nmode == 0)
+ {
+ xfree (modes);
+ modes = 0;
+ return 0;
+ }
+ *ret_nmode = nmode;
+ return modes;
+}
+
+Bool
+vesaInitialize (KdCardInfo *card, VesaCardPrivPtr priv)
+{
+ priv->vi = Vm86Setup(vesa_map_holes);
+ if(!priv->vi)
+ goto fail;
+
+ if (vesa_boot)
+ VbeBoot (priv->vi);
+
+ priv->modes = vesaGetModes (priv->vi, &priv->nmode);
+
+ if (!priv->modes)
+ goto fail;
+
+ priv->vbeInfo = VbeInit (priv->vi);
+
+ card->driver = priv;
+
+ return TRUE;
+
+fail:
+ if(priv->vi)
+ Vm86Cleanup(priv->vi);
+ return FALSE;
+}
+
+void
+vesaListModes (void)
+{
+ Vm86InfoPtr vi;
+ VesaModePtr modes;
+ int nmode;
+ int n;
+
+ vi = Vm86Setup (vesa_map_holes);
+ if (!vi)
+ {
+ ErrorF ("Can't setup vm86\n");
+ }
+ else
+ {
+ modes = vesaGetModes (vi, &nmode);
+ if (!modes)
+ {
+ ErrorF ("No modes available\n");
+ }
+ else
+ {
+ VbeReportInfo (vi);
+ for (n = 0; n < nmode; n++)
+ {
+ if (vesa_force_mode || vesaModeSupportable (modes+n, 0))
+ vesaReportMode (modes+n);
+ }
+ xfree (modes);
+ }
+ Vm86Cleanup (vi);
+ }
+}
+
+void
+vesaTestMode (void)
+{
+ Vm86InfoPtr vi;
+ VesaModePtr modes;
+ VesaModePtr mode;
+ VbeInfoPtr vbeInfo;
+ int nmode;
+ int n;
+
+ vi = Vm86Setup (vesa_map_holes);
+ if (!vi)
+ {
+ ErrorF ("Can't setup vm86\n");
+ return;
+ }
+ modes = vesaGetModes (vi, &nmode);
+ if (!modes)
+ {
+ ErrorF ("No modes available\n");
+ return;
+ }
+ VbeReportInfo (vi);
+ vbeInfo = VbeInit (vi);
+ for (n = 0; n < nmode; n++)
+ {
+ if (modes[n].mode == vesa_video_mode)
+ break;
+ }
+ if (n == nmode)
+ {
+ ErrorF ("no mode specified\n");
+ return;
+ }
+ mode = &modes[n];
+ if (mode->vbe)
+ {
+ ErrorF ("Enable VBE mode 0x%x\n", mode->mode);
+ VbeSetMode(vi, vbeInfo, mode->mode, FALSE, FALSE);
+ }
+ else
+ {
+ ErrorF ("Enable BIOS mode 0x%x\n", mode->mode);
+ VgaSetMode (vi, mode->mode);
+ }
+ sleep (2);
+ ErrorF ("Restore BIOS mode 0x%x\n", 3);
+ VgaSetMode (vi, 3);
+ xfree (modes);
+ Vm86Cleanup (vi);
+}
+
+Bool
+vesaCardInit(KdCardInfo *card)
+{
+ VesaCardPrivPtr priv;
+
+ priv = xalloc(sizeof(VesaCardPrivRec));
+ if(!priv)
+ return FALSE;
+
+ if (!vesaInitialize (card, priv))
+ {
+ xfree(priv);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+int
+vesaDepth (VesaModePtr mode)
+{
+ if (mode->MemoryModel == MEMORY_DIRECT)
+ return (mode->RedMaskSize +
+ mode->GreenMaskSize +
+ mode->BlueMaskSize);
+ else
+ return mode->BitsPerPixel;
+}
+
+Bool
+vesaModeGood (KdScreenInfo *screen,
+ VesaModePtr a)
+{
+ if (vesaWidth(screen,a) <= screen->width &&
+ vesaHeight(screen,a) <= screen->height &&
+ vesaDepth (a) >= screen->fb[0].depth)
+ {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+#define vabs(a) ((a) >= 0 ? (a) : -(a))
+
+int
+vesaSizeError (KdScreenInfo *screen,
+ VesaModePtr a)
+{
+ int xdist, ydist;
+ xdist = vabs (screen->width - vesaWidth(screen,a));
+ ydist = vabs (screen->height - vesaHeight(screen,a));
+ return xdist * xdist + ydist * ydist;
+}
+
+Bool
+vesaModeBetter (KdScreenInfo *screen,
+ VesaModePtr a,
+ VesaModePtr b)
+{
+ int aerr, berr;
+
+ if (vesaModeGood (screen, a))
+ {
+ if (!vesaModeGood (screen, b))
+ return TRUE;
+ }
+ else
+ {
+ if (vesaModeGood (screen, b))
+ return FALSE;
+ }
+ aerr = vesaSizeError (screen, a);
+ berr = vesaSizeError (screen, b);
+ if (aerr < berr)
+ return TRUE;
+ if (berr < aerr)
+ return FALSE;
+ if (vabs (screen->fb[0].depth - vesaDepth (a)) <
+ vabs (screen->fb[0].depth - vesaDepth (b)))
+ return TRUE;
+ if (a->BitsPerPixel == 32 && b->BitsPerPixel == 24)
+ return TRUE;
+ return FALSE;
+}
+
+VesaModePtr
+vesaSelectMode (KdScreenInfo *screen)
+{
+ VesaCardPrivPtr priv = screen->card->driver;
+ int i, best;
+
+ if (vesa_video_mode)
+ {
+ for (best = 0; best < priv->nmode; best++)
+ if (priv->modes[best].mode == vesa_video_mode &&
+ (vesaModeSupported (priv, &priv->modes[best], FALSE) ||
+ vesa_force_mode))
+ return &priv->modes[best];
+ }
+ for (best = 0; best < priv->nmode; best++)
+ {
+ if (vesaModeSupported (priv, &priv->modes[best], FALSE))
+ break;
+ }
+ if (best == priv->nmode)
+ return 0;
+ for (i = best + 1; i < priv->nmode; i++)
+ if (vesaModeSupported (priv, &priv->modes[i], FALSE) &&
+ vesaModeBetter (screen, &priv->modes[i],
+ &priv->modes[best]))
+ best = i;
+ return &priv->modes[best];
+}
+
+Bool
+vesaScreenInitialize (KdScreenInfo *screen, VesaScreenPrivPtr pscr)
+{
+ VesaModePtr mode;
+
+ screen->driver = pscr;
+
+ if (!screen->width || !screen->height)
+ {
+ screen->width = 640;
+ screen->height = 480;
+ }
+ if (!screen->fb[0].depth)
+ screen->fb[0].depth = 4;
+
+ if (vesa_verbose)
+ ErrorF ("Mode requested %dx%dx%d\n",
+ screen->width, screen->height, screen->fb[0].depth);
+
+ mode = vesaSelectMode (screen);
+
+ if (!mode)
+ {
+ if (vesa_verbose)
+ ErrorF ("No selectable mode\n");
+ return FALSE;
+ }
+ pscr->mode = *mode;
+
+ if (vesa_verbose)
+ {
+ ErrorF ("\t");
+ vesaReportMode (&pscr->mode);
+ }
+
+ pscr->randr = screen->randr;
+ pscr->shadow = vesa_shadow;
+ pscr->origDepth = screen->fb[0].depth;
+ /*
+ * Compute visual support for the selected depth
+ */
+
+ switch (pscr->mode.MemoryModel) {
+ case MEMORY_DIRECT:
+ /* TrueColor or DirectColor */
+ screen->fb[0].visuals = (1 << TrueColor);
+ screen->fb[0].redMask =
+ FbStipMask(pscr->mode.RedFieldPosition, pscr->mode.RedMaskSize);
+ screen->fb[0].greenMask =
+ FbStipMask(pscr->mode.GreenFieldPosition, pscr->mode.GreenMaskSize);
+ screen->fb[0].blueMask =
+ FbStipMask(pscr->mode.BlueFieldPosition, pscr->mode.BlueMaskSize);
+ break;
+ case MEMORY_PSEUDO:
+ /* PseudoColor */
+ screen->fb[0].visuals = ((1 << StaticGray) |
+ (1 << GrayScale) |
+ (1 << StaticColor) |
+ (1 << PseudoColor) |
+ (1 << TrueColor) |
+ (1 << DirectColor));
+ screen->fb[0].blueMask = 0x00;
+ screen->fb[0].greenMask = 0x00;
+ screen->fb[0].redMask = 0x00;
+ break;
+ case MEMORY_PLANAR:
+ /* 4 plane planar */
+ if (pscr->mode.ModeAttributes & MODE_COLOUR)
+ screen->fb[0].visuals = (1 << StaticColor);
+ else
+ screen->fb[0].visuals = (1 << StaticGray);
+ screen->fb[0].blueMask = 0x00;
+ screen->fb[0].greenMask = 0x00;
+ screen->fb[0].redMask = 0x00;
+ break;
+ default:
+ ErrorF("Unsupported VESA MemoryModel 0x%02X\n",
+ pscr->mode.MemoryModel);
+ return FALSE;
+ }
+ screen->rate = 72;
+
+ if (!vesaComputeFramebufferMapping (screen))
+ return FALSE;
+ if (!vesaMapFramebuffer (screen))
+ return FALSE;
+ return TRUE;
+}
+
+Bool
+vesaScreenInit(KdScreenInfo *screen)
+{
+ VesaScreenPrivPtr pscr;
+
+ pscr = xcalloc (1, sizeof (VesaScreenPrivRec));
+ if (!pscr)
+ return FALSE;
+ if (!vesaScreenInitialize (screen, pscr))
+ return FALSE;
+ return TRUE;
+}
+
+void *
+vesaSetWindowPlanar(ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size)
+{
+ KdScreenPriv(pScreen);
+ VesaCardPrivPtr priv = pScreenPriv->card->driver;
+ VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+ static int plane;
+ int winSize;
+ void *base;
+
+ plane = offset & 3;
+ VgaSetWritePlaneMask (priv->vi, (1 << plane));
+ offset = offset >> 2;
+ if (pscr->mode.vbe)
+ {
+ base = VbeSetWindow (priv->vi,
+ priv->vbeInfo,
+ pscr->mode.BytesPerScanLine * row + offset,
+ mode,
+ &winSize);
+ }
+ else
+ {
+ base = VgaSetWindow (priv->vi,
+ pscr->mode.mode,
+ pscr->mode.BytesPerScanLine * row + offset,
+ mode,
+ &winSize);
+ }
+ *size = (CARD32) winSize;
+ return base;
+}
+
+void *
+vesaSetWindowLinear (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size)
+{
+ KdScreenPriv(pScreen);
+ VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+
+ *size = pscr->mode.BytesPerScanLine;
+ return (CARD8 *) pscr->fb + row * pscr->mode.BytesPerScanLine + offset;
+}
+
+void *
+vesaSetWindowWindowed (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size)
+{
+ KdScreenPriv(pScreen);
+ VesaCardPrivPtr priv = pScreenPriv->card->driver;
+ VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+ int winSize;
+ void *base;
+
+ if (pscr->mode.vbe)
+ {
+ base = VbeSetWindow (priv->vi,
+ priv->vbeInfo,
+ pscr->mode.BytesPerScanLine * row + offset,
+ mode,
+ &winSize);
+ }
+ else
+ {
+ base = VgaSetWindow (priv->vi,
+ pscr->mode.mode,
+ pscr->mode.BytesPerScanLine * row + offset,
+ mode,
+ &winSize);
+ }
+ *size = (CARD32) winSize;
+ return base;
+}
+
+void *
+vesaWindowPlanar (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure)
+{
+ KdScreenPriv(pScreen);
+
+ if (!pScreenPriv->enabled)
+ return 0;
+ return vesaSetWindowPlanar (pScreen, row, offset, mode, size);
+}
+
+void *
+vesaWindowLinear (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure)
+{
+ KdScreenPriv(pScreen);
+
+ if (!pScreenPriv->enabled)
+ return 0;
+ return vesaSetWindowLinear (pScreen, row, offset, mode, size);
+}
+
+void *
+vesaWindowWindowed (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure)
+{
+ KdScreenPriv(pScreen);
+
+ if (!pScreenPriv->enabled)
+ return 0;
+ return vesaSetWindowWindowed (pScreen, row, offset, mode, size);
+}
+
+#define vesaInvertBits32(v) { \
+ v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
+ v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
+ v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
+}
+
+void *
+vesaWindowCga (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure)
+{
+ KdScreenPriv(pScreen);
+ VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+ int line;
+
+ if (!pScreenPriv->enabled)
+ return 0;
+ *size = pscr->mode.BytesPerScanLine;
+ line = ((row & 1) << 13) + (row >> 1) * pscr->mode.BytesPerScanLine;
+ return (CARD8 *) pscr->fb + line + offset;
+}
+
+void
+vesaUpdateMono (ScreenPtr pScreen,
+ shadowBufPtr pBuf)
+{
+ RegionPtr damage = shadowDamage(pBuf);
+ PixmapPtr pShadow = pBuf->pPixmap;
+ int nbox = REGION_NUM_RECTS (damage);
+ BoxPtr pbox = REGION_RECTS (damage);
+ FbBits *shaBase, *shaLine, *sha;
+ FbStride shaStride;
+ int scrBase, scrLine, scr;
+ int shaBpp;
+ int shaXoff, shaYoff; /* XXX assumed to be zero */
+ int x, y, w, h, width;
+ int i;
+ FbBits *winBase = 0, *win;
+ CARD32 winSize;
+ FbBits bits;
+
+ fbGetDrawable (&pShadow->drawable, shaBase, shaStride, shaBpp, shaXoff, shaYoff);
+ while (nbox--)
+ {
+ x = pbox->x1 * shaBpp;
+ y = pbox->y1;
+ w = (pbox->x2 - pbox->x1) * shaBpp;
+ h = pbox->y2 - pbox->y1;
+
+ scrLine = (x >> FB_SHIFT);
+ shaLine = shaBase + y * shaStride + (x >> FB_SHIFT);
+
+ x &= FB_MASK;
+ w = (w + x + FB_MASK) >> FB_SHIFT;
+
+ while (h--)
+ {
+ winSize = 0;
+ scrBase = 0;
+ width = w;
+ scr = scrLine;
+ sha = shaLine;
+ while (width) {
+ /* how much remains in this window */
+ i = scrBase + winSize - scr;
+ if (i <= 0 || scr < scrBase)
+ {
+ winBase = (FbBits *) (*pBuf->window) (pScreen,
+ y,
+ scr * sizeof (FbBits),
+ SHADOW_WINDOW_WRITE,
+ &winSize,
+ pBuf->closure);
+ if(!winBase)
+ return;
+ scrBase = scr;
+ winSize /= sizeof (FbBits);
+ i = winSize;
+ }
+ win = winBase + (scr - scrBase);
+ if (i > width)
+ i = width;
+ width -= i;
+ scr += i;
+ while (i--)
+ {
+ bits = *sha++;
+ vesaInvertBits32(bits);
+ *win++ = bits;
+ }
+ }
+ shaLine += shaStride;
+ y++;
+ }
+ pbox++;
+ }
+}
+
+static const CARD16 vga16Colors[16][3] = {
+ { 0, 0, 0, }, /* 0 */
+ { 0, 0, 0xAA,}, /* 1 */
+ { 0, 0xAA,0, }, /* 2 */
+ { 0, 0xAA,0xAA,}, /* 3 */
+ { 0xAA,0, 0, }, /* 4 */
+ { 0xAA,0, 0xAA,}, /* 5 */
+ { 0xAA,0x55,0, }, /* 6 */
+ { 0xAA,0xAA,0xAA,}, /* 7 */
+ { 0x55,0x55,0x55,}, /* 8 */
+ { 0x55,0x55,0xFF,}, /* 9 */
+ { 0x55,0xFF,0x55,}, /* 10 */
+ { 0x55,0xFF,0xFF,}, /* 11 */
+ { 0xFF,0x55,0x55,}, /* 12 */
+ { 0xFF,0x55,0xFF,}, /* 13 */
+ { 0xFF,0xFF,0x55,}, /* 14 */
+ { 0xFF,0xFF,0xFF,}, /* 15 */
+};
+
+Bool
+vesaCreateColormap16 (ColormapPtr pmap)
+{
+ int i, j;
+
+ if (pmap->pVisual->ColormapEntries == 16)
+ for (i = 0; i < pmap->pVisual->ColormapEntries; i++)
+ {
+ j = i & 0xf;
+ pmap->red[i].co.local.red = (vga16Colors[j][0]<<8)|vga16Colors[j][0];
+ pmap->red[i].co.local.green = (vga16Colors[j][1]<<8)|vga16Colors[j][1];
+ pmap->red[i].co.local.blue = (vga16Colors[j][2]<<8)|vga16Colors[j][2];
+ }
+ return TRUE;
+}
+
+void
+vesaSetScreenSizes (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ VesaScreenPrivPtr pscr = screen->driver;
+
+ if (pscr->randr & (RR_Rotate_0|RR_Rotate_180))
+ {
+ pScreen->width = pscr->mode.XResolution;
+ pScreen->height = pscr->mode.YResolution;
+ pScreen->mmWidth = screen->width_mm;
+ pScreen->mmHeight = screen->height_mm;
+ }
+ else
+ {
+ pScreen->width = pscr->mode.YResolution;
+ pScreen->height = pscr->mode.XResolution;
+ pScreen->mmWidth = screen->height_mm;
+ pScreen->mmHeight = screen->width_mm;
+ }
+}
+
+Bool
+vesaSetShadow (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+ ShadowUpdateProc update;
+ ShadowWindowProc window = 0;
+
+ if (pscr->randr != RR_Rotate_0)
+ update = shadowUpdateRotatePacked;
+ else
+ update = shadowUpdatePacked;
+ switch (pscr->mapping) {
+ case VESA_LINEAR:
+ window = vesaWindowLinear;
+ break;
+ case VESA_WINDOWED:
+ window = vesaWindowWindowed;
+ break;
+ case VESA_PLANAR:
+ if (pScreenPriv->screen->fb[0].bitsPerPixel == 8)
+ update = shadowUpdatePlanar4x8;
+ else
+ update = shadowUpdatePlanar4;
+ window = vesaWindowPlanar;
+ break;
+ case VESA_MONO:
+ update = vesaUpdateMono;
+ if (pscr->mode.mode < 8)
+ window = vesaWindowCga;
+ else
+ window = vesaWindowLinear;
+ break;
+ }
+
+ return KdShadowSet (pScreen, pscr->randr, update, window);
+}
+
+static Bool
+vesaComputeFramebufferMapping (KdScreenInfo *screen)
+{
+ VesaScreenPrivPtr pscr = screen->driver;
+ int depth, bpp, fbbpp;
+ Pixel allbits;
+ KdPointerMatrix m;
+
+ if (vesa_linear_fb)
+ {
+ pscr->mapping = VESA_LINEAR;
+ pscr->shadow = FALSE;
+ }
+ else
+ {
+ pscr->mapping = VESA_WINDOWED;
+ pscr->shadow = TRUE;
+ }
+
+ depth = vesaDepth (&pscr->mode);
+ bpp = pscr->mode.BitsPerPixel;
+
+ if (bpp > 24)
+ bpp = 32;
+ else if (bpp > 16)
+ bpp = 24;
+ else if (bpp > 8)
+ bpp = 16;
+ else if (bpp > 4)
+ bpp = 8;
+ else if (bpp > 1)
+ bpp = 4;
+ else
+ bpp = 1;
+ fbbpp = bpp;
+
+ switch (pscr->mode.MemoryModel) {
+ case MEMORY_DIRECT:
+ allbits = (screen->fb[0].redMask |
+ screen->fb[0].greenMask |
+ screen->fb[0].blueMask);
+ depth = 32;
+ while (depth && !(allbits & (1 << (depth - 1))))
+ depth--;
+ if (vesa_verbose)
+ ErrorF ("\tTrue Color %d/%d red 0x%x green 0x%x blue 0x%x\n",
+ bpp, depth,
+ screen->fb[0].redMask,
+ screen->fb[0].greenMask,
+ screen->fb[0].blueMask);
+ break;
+ case MEMORY_PSEUDO:
+ if (vesa_verbose)
+ ErrorF ("\tPseudo Color bpp %d depth %d\n",
+ bpp, depth);
+ break;
+ case MEMORY_PLANAR:
+ if (bpp == 4)
+ {
+ bpp = screen->fb[0].bitsPerPixel;
+ if (bpp != 8)
+ bpp = 4;
+ depth = bpp;
+ }
+ if (bpp == 1)
+ {
+ pscr->mapping = VESA_MONO;
+ if (vesa_verbose)
+ ErrorF ("\tMonochrome\n");
+ }
+ else
+ {
+ pscr->mapping = VESA_PLANAR;
+ if (vesa_verbose)
+ ErrorF ("\tStatic color bpp %d depth %d\n",
+ bpp, depth);
+ }
+ pscr->randr = RR_Rotate_0;
+ pscr->shadow = TRUE;
+ break;
+ default:
+ return FALSE;
+ }
+
+ switch (fbbpp) {
+ case 8:
+ case 16:
+ case 32:
+ break;
+ default:
+ pscr->randr = RR_Rotate_0;
+ break;
+ }
+
+ if (pscr->randr != RR_Rotate_0)
+ pscr->shadow = TRUE;
+
+ if (vesa_shadow)
+ pscr->shadow = vesa_shadow;
+
+ if (pscr->mapping == VESA_LINEAR && !(pscr->mode.ModeAttributes & MODE_LINEAR))
+ {
+ pscr->mapping = VESA_WINDOWED;
+ pscr->shadow = TRUE;
+ }
+ KdComputePointerMatrix (&m, pscr->randr,
+ pscr->mode.XResolution, pscr->mode.YResolution);
+
+ KdSetPointerMatrix (&m);
+
+ screen->width = pscr->mode.XResolution;
+ screen->height = pscr->mode.YResolution;
+ screen->fb[0].depth = depth;
+ screen->fb[0].bitsPerPixel = bpp;
+
+ return TRUE;
+}
+
+static Bool
+vesaMapFramebuffer (KdScreenInfo *screen)
+{
+ VesaCardPrivPtr priv = screen->card->driver;
+ VesaScreenPrivPtr pscr = screen->driver;
+
+ if (pscr->mapped)
+ return TRUE;
+ switch (pscr->mapping) {
+ case VESA_MONO:
+ case VESA_LINEAR:
+ if (pscr->mode.vbe)
+ pscr->fb = VbeMapFramebuffer(priv->vi, priv->vbeInfo,
+ pscr->mode.mode,
+ &pscr->fb_size,
+ &pscr->fb_phys);
+ else
+ pscr->fb = VgaMapFramebuffer (priv->vi,
+ pscr->mode.mode,
+ &pscr->fb_size,
+ &pscr->fb_phys);
+ if (!pscr->fb)
+ return FALSE;
+ break;
+ case VESA_WINDOWED:
+ pscr->fb = NULL;
+ break;
+ case VESA_PLANAR:
+ pscr->fb = NULL;
+ break;
+ }
+
+ screen->memory_base = pscr->fb;
+ screen->memory_size = pscr->fb_size;
+
+ if (pscr->shadow)
+ {
+ if (!KdShadowFbAlloc (screen, 0,
+ pscr->randr & (RR_Rotate_90|RR_Rotate_270)))
+ return FALSE;
+ screen->off_screen_base = screen->memory_size;
+ }
+ else
+ {
+ screen->fb[0].frameBuffer = (CARD8 *) (pscr->fb);
+ screen->fb[0].byteStride = pscr->mode.BytesPerScanLine;
+ screen->fb[0].pixelStride = ((pscr->mode.BytesPerScanLine * 8) /
+ screen->fb[0].bitsPerPixel);
+ screen->off_screen_base = screen->fb[0].byteStride * screen->height;
+ }
+ pscr->mapped = TRUE;
+
+ return TRUE;
+}
+
+static void
+vesaUnmapFramebuffer (KdScreenInfo *screen)
+{
+ VesaCardPrivPtr priv = screen->card->driver;
+ VesaScreenPrivPtr pscr = screen->driver;
+
+ if (!pscr->mapped)
+ return;
+
+ pscr->mapped = FALSE;
+ KdShadowFbFree (screen, 0);
+ if (pscr->fb)
+ {
+ if (pscr->mode.vbe)
+ VbeUnmapFramebuffer(priv->vi, priv->vbeInfo, pscr->mode.mode, pscr->fb);
+ else
+ VgaUnmapFramebuffer (priv->vi);
+ pscr->fb = 0;
+ }
+}
+
+#ifdef RANDR
+Bool
+vesaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
+{
+ KdScreenPriv(pScreen);
+ VesaModePtr modes, mode;
+ KdScreenInfo *screen = pScreenPriv->screen;
+ VesaCardPrivPtr priv = pScreenPriv->card->driver;
+ VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+ int nmode;
+ int n;
+ RRScreenSizePtr pSize;
+
+ *rotations = (RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270|
+ RR_Reflect_X|RR_Reflect_Y);
+ /*
+ * Get mode information from BIOS -- every time in case
+ * something changes, like an external monitor is plugged in
+ */
+ modes = vesaGetModes (priv->vi, &nmode);
+ if (!modes)
+ return FALSE;
+ if (priv->modes)
+ xfree (priv->modes);
+ priv->modes = modes;
+ priv->nmode = nmode;
+ for (n = 0; n < nmode; n++)
+ {
+ mode = &priv->modes[n];
+ if (vesaModeSupported (priv, mode, FALSE))
+ {
+ /*
+ * XXX limit reported modes to those matching the current
+ * format
+ */
+ if (mode->NumberOfPlanes == pscr->mode.NumberOfPlanes &&
+ mode->BitsPerPixel == pscr->mode.BitsPerPixel &&
+ mode->MemoryModel == pscr->mode.MemoryModel &&
+ mode->RedMaskSize == pscr->mode.RedMaskSize &&
+ mode->RedFieldPosition == pscr->mode.RedFieldPosition &&
+ mode->GreenMaskSize == pscr->mode.GreenMaskSize &&
+ mode->GreenFieldPosition == pscr->mode.GreenFieldPosition &&
+ mode->BlueMaskSize == pscr->mode.BlueMaskSize &&
+ mode->BlueFieldPosition == pscr->mode.BlueFieldPosition)
+ {
+ int width, height, width_mm, height_mm;
+ if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
+ {
+ width = mode->XResolution;
+ height = mode->YResolution;
+ width_mm = screen->width_mm;
+ height_mm = screen->height_mm;
+ }
+ else
+ {
+ width = mode->YResolution;
+ height = mode->XResolution;
+ width_mm = screen->height_mm;
+ height_mm = screen->width_mm;
+ }
+ pSize = RRRegisterSize (pScreen,
+ width, height,
+ width_mm, height_mm);
+ if (mode->XResolution == screen->width &&
+ mode->YResolution == screen->height)
+ {
+ int randr = KdSubRotation (pscr->randr, screen->randr);
+ RRSetCurrentConfig (pScreen, randr, 0, pSize);
+ }
+ }
+ }
+ }
+ return TRUE;
+}
+
+Bool
+vesaRandRSetConfig (ScreenPtr pScreen,
+ Rotation randr,
+ int rate,
+ RRScreenSizePtr pSize)
+{
+ KdScreenPriv(pScreen);
+ VesaModePtr mode = 0;
+ KdScreenInfo *screen = pScreenPriv->screen;
+ VesaCardPrivPtr priv = pScreenPriv->card->driver;
+ VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+ int n;
+ Bool wasEnabled = pScreenPriv->enabled;
+ Bool ret = FALSE;
+ VesaScreenPrivRec oldscr;
+ int oldwidth;
+ int oldheight;
+ int oldmmwidth;
+ int oldmmheight;
+ int newwidth, newheight;
+
+ if (screen->randr & (RR_Rotate_0|RR_Rotate_180))
+ {
+ newwidth = pSize->width;
+ newheight = pSize->height;
+ }
+ else
+ {
+ newwidth = pSize->height;
+ newheight = pSize->width;
+ }
+ for (n = 0; n < priv->nmode; n++)
+ {
+ mode = &priv->modes[n];
+ if (vesaModeSupported (priv, mode, FALSE))
+ {
+ /*
+ * XXX all we have to match is the size
+ */
+ if (mode->XResolution == newwidth &&
+ mode->YResolution == newheight &&
+ mode->NumberOfPlanes == pscr->mode.NumberOfPlanes &&
+ mode->BitsPerPixel == pscr->mode.BitsPerPixel &&
+ mode->RedMaskSize == pscr->mode.RedMaskSize &&
+ mode->RedFieldPosition == pscr->mode.RedFieldPosition &&
+ mode->GreenMaskSize == pscr->mode.GreenMaskSize &&
+ mode->GreenFieldPosition == pscr->mode.GreenFieldPosition &&
+ mode->BlueMaskSize == pscr->mode.BlueMaskSize &&
+ mode->BlueFieldPosition == pscr->mode.BlueFieldPosition)
+ break;
+ }
+ }
+ if (n == priv->nmode)
+ goto bail0;
+
+ if (wasEnabled)
+ KdDisableScreen (pScreen);
+
+ if (mode->mode != pscr->mode.mode)
+ {
+ ret = vesaSetMode (pScreen, mode);
+ if (!ret)
+ goto bail1;
+ }
+
+ oldscr = *pscr;
+
+ oldwidth = screen->width;
+ oldheight = screen->height;
+ oldmmwidth = pScreen->mmWidth;
+ oldmmheight = pScreen->mmHeight;
+
+ /*
+ * Set new configuration
+ */
+
+ pscr->mode = *mode;
+ pscr->randr = KdAddRotation (screen->randr, randr);
+
+ /*
+ * Can't rotate some formats
+ */
+ switch (screen->fb[0].bitsPerPixel) {
+ case 8:
+ case 16:
+ case 32:
+ break;
+ default:
+ if (pscr->randr)
+ goto bail2;
+ break;
+ }
+
+ KdOffscreenSwapOut (screen->pScreen);
+
+ vesaUnmapFramebuffer (screen);
+
+ if (!vesaComputeFramebufferMapping (screen))
+ goto bail3;
+
+ if (!vesaMapFramebuffer (screen))
+ goto bail3;
+
+ vesaSetScreenSizes (screen->pScreen);
+
+ if (!vesaSetShadow (screen->pScreen))
+ goto bail4;
+
+ /*
+ * Set frame buffer mapping
+ */
+ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
+ pScreen->width,
+ pScreen->height,
+ screen->fb[0].depth,
+ screen->fb[0].bitsPerPixel,
+ screen->fb[0].byteStride,
+ screen->fb[0].frameBuffer);
+
+ /* set the subpixel order */
+ KdSetSubpixelOrder (pScreen, pscr->randr);
+
+ if (wasEnabled)
+ KdEnableScreen (pScreen);
+
+ return TRUE;
+
+bail4:
+ vesaUnmapFramebuffer (screen);
+ *pscr = oldscr;
+ (void) vesaComputeFramebufferMapping (screen);
+ (void) vesaMapFramebuffer (screen);
+
+bail3:
+ pScreen->width = oldwidth;
+ pScreen->height = oldheight;
+ pScreen->mmWidth = oldmmwidth;
+ pScreen->mmHeight = oldmmheight;
+
+bail2:
+ *pscr = oldscr;
+
+ (void) vesaSetMode (pScreen, &pscr->mode);
+bail1:
+ if (wasEnabled)
+ KdEnableScreen (pScreen);
+bail0:
+
+ return FALSE;
+}
+
+Bool
+vesaRandRInit (ScreenPtr pScreen)
+{
+ rrScrPrivPtr pScrPriv;
+
+ if (!RRScreenInit (pScreen))
+ return FALSE;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+ pScrPriv->rrGetInfo = vesaRandRGetInfo;
+ pScrPriv->rrSetConfig = vesaRandRSetConfig;
+ return TRUE;
+}
+#endif
+
+Bool
+vesaInitScreen(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+ switch (pscr->mapping) {
+ case VESA_PLANAR:
+ pScreen->CreateColormap = vesaCreateColormap16;
+ break;
+ }
+ return TRUE;
+}
+
+Bool
+vesaFinishInitScreen (ScreenPtr pScreen)
+{
+ if (!shadowSetup (pScreen))
+ return FALSE;
+
+#ifdef RANDR
+ if (!vesaRandRInit (pScreen))
+ return FALSE;
+#endif
+
+ return TRUE;
+}
+
+Bool
+vesaCreateResources (ScreenPtr pScreen)
+{
+ return vesaSetShadow (pScreen);
+}
+
+Bool
+vesaSetMode (ScreenPtr pScreen,
+ VesaModePtr mode)
+{
+ KdScreenPriv(pScreen);
+ VesaCardPrivPtr priv = pScreenPriv->card->driver;
+ VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+ int code;
+
+ if (mode->vbe)
+ {
+ if (vesa_verbose)
+ ErrorF ("Enable VBE mode 0x%x\n", mode->mode);
+ code = VbeSetMode(priv->vi, priv->vbeInfo, mode->mode,
+ pscr->mapping == VESA_LINEAR,
+ mode->MemoryModel == MEMORY_DIRECT);
+ }
+ else
+ {
+ if (vesa_verbose)
+ ErrorF ("Enable BIOS mode 0x%x\n", mode->mode);
+ code = VgaSetMode (priv->vi, mode->mode);
+ }
+
+ if(code < 0)
+ return FALSE;
+
+ return TRUE;
+}
+
+Bool
+vesaEnable(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ VesaCardPrivPtr priv = pScreenPriv->card->driver;
+ VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+ KdScreenInfo *screen = pScreenPriv->screen;
+ int i;
+ CARD32 size;
+ char *p;
+ Bool was_mapped = pscr->mapped;
+
+ if (!vesaMapFramebuffer (screen))
+ return FALSE;
+
+ if (!vesaSetMode (pScreen, &pscr->mode))
+ return FALSE;
+
+ switch (pscr->mapping) {
+ case VESA_MONO:
+ VgaSetWritePlaneMask (priv->vi, 0x1);
+ case VESA_LINEAR:
+ if (vesa_restore_font)
+ memcpy (priv->text, pscr->fb, VESA_TEXT_SAVE);
+ break;
+ case VESA_WINDOWED:
+ if (vesa_restore_font)
+ {
+ for (i = 0; i < VESA_TEXT_SAVE;)
+ {
+ p = vesaSetWindowWindowed (pScreen, 0, i, VBE_WINDOW_READ, &size);
+ if(!p) {
+ ErrorF("Couldn't set window for saving VGA font\n");
+ break;
+ }
+ if(i + size > VESA_TEXT_SAVE)
+ size = VESA_TEXT_SAVE - i;
+ memcpy(((char*)priv->text) + i, p, size);
+ i += size;
+ }
+ }
+ break;
+ case VESA_PLANAR:
+ if (vesa_restore_font)
+ {
+ for (i = 0; i < 4; i++)
+ {
+ p = vesaSetWindowPlanar (pScreen, 0, i, VBE_WINDOW_READ, &size);
+ memcpy (((char *)priv->text) + i * (VESA_TEXT_SAVE/4), p,
+ (VESA_TEXT_SAVE/4));
+ }
+ }
+ break;
+ }
+ if (!was_mapped)
+ {
+ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
+ pScreen->width,
+ pScreen->height,
+ screen->fb[0].depth,
+ screen->fb[0].bitsPerPixel,
+ screen->fb[0].byteStride,
+ screen->fb[0].frameBuffer);
+ }
+ return TRUE;
+}
+
+#ifndef TOSHIBA_SMM
+
+# ifdef linux
+# define TOSHIBA_SMM 1
+# endif
+
+# ifndef TOSHIBA_SMM
+# define TOSHIBA_SMM 0
+# endif
+
+#endif
+
+#if TOSHIBA_SMM
+/*
+ * Toshiba laptops use a special interface to operate the backlight
+ */
+#include <sys/ioctl.h>
+#define TOSH_PROC "/proc/toshiba"
+#define TOSH_DEVICE "/dev/toshiba"
+#define TOSH_SMM _IOWR('t', 0x90, SMMRegisters)
+
+typedef struct {
+ unsigned int eax;
+ unsigned int ebx __attribute__ ((packed));
+ unsigned int ecx __attribute__ ((packed));
+ unsigned int edx __attribute__ ((packed));
+ unsigned int esi __attribute__ ((packed));
+ unsigned int edi __attribute__ ((packed));
+} SMMRegisters;
+
+#define HCI_BACKLIGHT 0x0002
+#define HCI_DISABLE 0x0000
+#define HCI_ENABLE 0x0001
+#define HCI_GET 0xfe00,
+#define HCI_SET 0xff00
+
+Bool
+toshibaDPMS (ScreenPtr pScreen, int mode)
+{
+ SMMRegisters regs;
+ static int fd;
+
+ if (!fd)
+ fd = open (TOSH_DEVICE, 2);
+ if (fd < 0)
+ return FALSE;
+ regs.eax = HCI_SET;
+ regs.ebx = HCI_BACKLIGHT;
+ regs.ecx = mode ? HCI_DISABLE : HCI_ENABLE;
+ if (ioctl (fd, TOSH_SMM, &regs) < 0)
+ return FALSE;
+ return TRUE;
+}
+#endif /* TOSHIBA_SMM */
+
+Bool
+vesaDPMS (ScreenPtr pScreen, int mode)
+{
+ KdScreenPriv(pScreen);
+ VesaCardPrivPtr priv = pScreenPriv->card->driver;
+ VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+
+#if TOSHIBA_SMM
+ if (toshibaDPMS (pScreen, mode))
+ return TRUE;
+#endif
+ if (pscr->mode.vbe)
+ return VbeDPMS (priv->vi, mode);
+ return FALSE;
+}
+
+void
+vesaDisable(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ VesaCardPrivPtr priv = pScreenPriv->card->driver;
+ VesaScreenPrivPtr pscr = screen->driver;
+ int i=0;
+ CARD32 size;
+ char *p;
+
+ if (vesa_restore_font) {
+ switch (pscr->mapping) {
+ case VESA_LINEAR:
+ case VESA_MONO:
+ memcpy(pscr->fb, priv->text, VESA_TEXT_SAVE);
+ break;
+ case VESA_WINDOWED:
+ while(i < VESA_TEXT_SAVE) {
+ p = vesaSetWindowWindowed (pScreen, 0, i, VBE_WINDOW_WRITE, &size);
+ if(!p) {
+ ErrorF("Couldn't set window for restoring VGA font\n");
+ break;
+ }
+ if(i + size > VESA_TEXT_SAVE)
+ size = VESA_TEXT_SAVE - i;
+ memcpy(p, ((char*)priv->text) + i, size);
+ i += size;
+ }
+ break;
+ case VESA_PLANAR:
+ for (i = 0; i < 4; i++)
+ {
+ p = vesaSetWindowPlanar (pScreen, 0, i, VBE_WINDOW_WRITE, &size);
+ memcpy (p,
+ ((char *)priv->text) + i * (VESA_TEXT_SAVE/4),
+ (VESA_TEXT_SAVE/4));
+ }
+ break;
+ }
+ }
+ vesaUnmapFramebuffer (screen);
+}
+
+void
+vesaPreserve(KdCardInfo *card)
+{
+ VesaCardPrivPtr priv = card->driver;
+
+ /* The framebuffer might not be valid at this point, so we cannot
+ save the VGA fonts now; we do it in vesaEnable. */
+
+ if (VbeGetMode (priv->vi, &priv->old_vbe_mode) < 0)
+ priv->old_vbe_mode = -1;
+
+ if (VgaGetMode (priv->vi, &priv->old_vga_mode) < 0)
+ priv->old_vga_mode = -1;
+
+ if (vesa_verbose)
+ ErrorF ("Previous modes: VBE 0x%x BIOS 0x%x\n",
+ priv->old_vbe_mode, priv->old_vga_mode);
+}
+
+void
+vesaRestore(KdCardInfo *card)
+{
+ VesaCardPrivPtr priv = card->driver;
+ int n;
+
+ if (vesa_force_text)
+ {
+ if (vesa_verbose)
+ ErrorF ("Forcing switch back to mode 3 text\n");
+ priv->old_vbe_mode = -1;
+ priv->old_vga_mode = 3;
+ }
+ for (n = 0; n < priv->nmode; n++)
+ if (priv->modes[n].vbe && priv->modes[n].mode == (priv->old_vbe_mode&0x3fff))
+ break;
+
+ if (n < priv->nmode)
+ {
+ if (vesa_verbose)
+ ErrorF ("Restore VBE mode 0x%x\n", priv->old_vbe_mode);
+ VbeSetMode (priv->vi, priv->vbeInfo, priv->old_vbe_mode, 0, 0);
+ }
+ else
+ {
+ if (vesa_verbose)
+ ErrorF ("Restore BIOS mode 0x%x\n", priv->old_vga_mode);
+ VgaSetMode (priv->vi, priv->old_vga_mode);
+ }
+}
+
+void
+vesaCardFini(KdCardInfo *card)
+{
+ VesaCardPrivPtr priv = card->driver;
+
+ if (priv->vbeInfo)
+ VbeCleanup (priv->vi, priv->vbeInfo);
+ if (priv->modes)
+ xfree (priv->modes);
+ Vm86Cleanup(priv->vi);
+}
+
+void
+vesaScreenFini(KdScreenInfo *screen)
+{
+ VesaScreenPrivPtr pscr = screen->driver;
+
+ KdShadowFbFree (screen, 0);
+ vesaUnmapFramebuffer (screen);
+ screen->fb[0].depth = pscr->origDepth;
+}
+
+int
+vesaSetPalette(VesaCardPrivPtr priv, int first, int number, U8 *entries)
+{
+ if (priv->vga_palette)
+ return VgaSetPalette (priv->vi, first, number, entries);
+ else
+ return VbeSetPalette (priv->vi, priv->vbeInfo, first, number, entries);
+}
+
+
+int
+vesaGetPalette(VesaCardPrivPtr priv, int first, int number, U8 *entries)
+{
+ int code;
+
+ if (priv->vga_palette)
+ code = VgaGetPalette (priv->vi, first, number, entries);
+ else
+ {
+ code = VbeGetPalette (priv->vi, priv->vbeInfo, first, number, entries);
+ if (code < 0)
+ {
+ priv->vga_palette = 1;
+ code = VgaGetPalette (priv->vi, first, number, entries);
+ }
+ }
+ return code;
+}
+
+void
+vesaPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ KdScreenPriv(pScreen);
+ VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+ VesaCardPrivPtr priv = pScreenPriv->card->driver;
+ int p;
+ CARD8 *scratch;
+ int red, green, blue;
+ int min, max;
+
+ if (vesa_swap_rgb)
+ {
+ red = 2;
+ green = 1;
+ blue = 0;
+ }
+ else
+ {
+ red = 0;
+ green = 1;
+ blue = 2;
+ }
+
+ min = 256;
+ max = 0;
+ while (n--)
+ {
+ p = pdefs->pixel;
+ if (p < min)
+ min = p;
+ if (p > max)
+ max = p;
+ scratch = priv->cmap + (p * 4);
+ scratch[red] = pdefs->red >> 8;
+ scratch[green] = pdefs->green >> 8;
+ scratch[blue] = pdefs->blue >> 8;
+ scratch[3] = 0;
+ pdefs++;
+ if (pscr->mapping == VESA_PLANAR)
+ {
+ /*
+ * VGA modes are strange; this code covers all
+ * possible modes by duplicating the color information
+ * however the attribute registers might be set
+ */
+ if (p < 16)
+ {
+ vesaSetPalette (priv, p, 1, scratch);
+ if (p >= 8)
+ vesaSetPalette (priv, p+0x30, 1, scratch);
+ else if (p == 6)
+ vesaSetPalette (priv, 0x14, 1, scratch);
+ }
+ }
+ }
+ if (pscr->mapping != VESA_PLANAR)
+ vesaSetPalette (priv, min, max-min+1, priv->cmap + min * 4);
+}
+
+void
+vesaGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
+{
+ KdScreenPriv(pScreen);
+ VesaScreenPrivPtr pscr = pScreenPriv->screen->driver;
+ VesaCardPrivPtr priv = pScreenPriv->card->driver;
+ int i;
+ int red, green, blue;
+ int min, max;
+ int p;
+ CARD8 *scratch;
+
+ if (vesa_swap_rgb)
+ {
+ red = 2;
+ green = 1;
+ blue = 0;
+ }
+ else
+ {
+ red = 0;
+ green = 1;
+ blue = 2;
+ }
+
+ min = 256;
+ max = 0;
+ for(i = 0; i < n; i++)
+ {
+ p = pdefs[i].pixel;
+ if (p < min)
+ min = p;
+ if (p > max)
+ max = p;
+ if (pscr->mapping == VESA_PLANAR)
+ vesaGetPalette (priv, p, 1, priv->cmap + p * 4);
+ }
+ if (pscr->mapping != VESA_PLANAR)
+ vesaGetPalette (priv, min, max - min + 1, priv->cmap + min * 4);
+ for (i = 0; i < n; i++)
+ {
+ p = pdefs[i].pixel;
+ scratch = priv->cmap + p * 4;
+ pdefs[i].red = scratch[red]<<8;
+ pdefs[i].green = scratch[green]<<8;
+ pdefs[i].blue = scratch[blue]<<8;
+ }
+}
+
+void
+vesaUseMsg (void)
+{
+ ErrorF("\nTinyX VESA Usage:\n");
+ ErrorF("-mode VESA video mode to use (Be careful!)\n");
+ ErrorF("-listmodes List supported video modes\n");
+ ErrorF("-force Attempt even unsupported modes\n");
+ ErrorF("-shadow Always use shadow framebuffer (May increase performance)\n");
+ ErrorF("-nolinear Never use linear framebuffer (Not useful)\n");
+ ErrorF("-swaprgb Use if colors are wrong in PseudoColor and 16 color modes\n");
+ ErrorF("-map-holes Use contiguous memory map (For seg fault with rare BIOS)\n");
+ ErrorF("-verbose Emit diagnostic messages during BIOS initialization\n");
+ ErrorF("-force-text Always use standard 25x80 text mode on server exit or VT switch\n");
+ ErrorF("-boot Soft boot video card\n");
+ /* XXX: usage for -vesatest, -no-map-holes (don't need?),
+ * XXX: and -trash-font. Also in man page. */
+}
+
+int
+vesaProcessArgument (int argc, char **argv, int i)
+{
+ if(!strcmp(argv[i], "-mode")) {
+ if(i+1 < argc) {
+ vesa_video_mode = strtol(argv[i+1], NULL, 0);
+ } else
+ UseMsg();
+ return 2;
+ } else if(!strcmp(argv[i], "-force")) {
+ vesa_force_mode = TRUE;
+ return 1;
+ } else if(!strcmp(argv[i], "-listmodes")) {
+ vesaListModes();
+ exit(0);
+ } else if(!strcmp(argv[i], "-vesatest")) {
+ vesaTestMode();
+ exit (0);
+ } else if(!strcmp(argv[i], "-swaprgb")) {
+ vesa_swap_rgb = TRUE;
+ return 1;
+ } else if(!strcmp(argv[i], "-shadow")) {
+ vesa_shadow = TRUE;
+ return 1;
+ } else if(!strcmp(argv[i], "-nolinear")) {
+ vesa_linear_fb = FALSE;
+ return 1;
+ } else if(!strcmp(argv[i], "-verbose")) {
+ vesa_verbose = TRUE;
+ return 1;
+ } else if(!strcmp(argv[i], "-force-text")) {
+ vesa_force_text = TRUE;
+ return 1;
+ } else if(!strcmp(argv[i], "-map-holes")) {
+ vesa_map_holes = TRUE;
+ return 1;
+ } else if(!strcmp(argv[i], "-no-map-holes")) {
+ vesa_map_holes = FALSE;
+ return 1;
+ } else if(!strcmp(argv[i], "-trash-font")) {
+ vesa_restore_font = FALSE;
+ return 1;
+ } else if(!strcmp(argv[i], "-boot")) {
+ vesa_boot = TRUE;
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/xorg-server/hw/kdrive/vesa/vesa.h b/xorg-server/hw/kdrive/vesa/vesa.h
new file mode 100644
index 000000000..f6b21e9f5
--- /dev/null
+++ b/xorg-server/hw/kdrive/vesa/vesa.h
@@ -0,0 +1,295 @@
+/*
+Copyright (c) 2000 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+*/
+
+#ifndef _VESA_H_
+#define _VESA_H_
+
+#include "kdrive.h"
+#include "shadow.h"
+#include "vm86.h"
+#ifdef RANDR
+#include "randrstr.h"
+#endif
+
+#define VESA_TEXT_SAVE (64*1024)
+
+#define MODE_SUPPORTED 0x01
+#define MODE_COLOUR 0x08
+#define MODE_GRAPHICS 0x10
+#define MODE_VGA 0x20
+#define MODE_LINEAR 0x80
+
+#define MODE_DIRECT 0x1
+
+#define MEMORY_TEXT 0
+#define MEMORY_CGA 1
+#define MEMORY_HERCULES 2
+#define MEMORY_PLANAR 3
+#define MEMORY_PSEUDO 4
+#define MEMORY_NONCHAIN 5
+#define MEMORY_DIRECT 6
+#define MEMORY_YUV 7
+
+typedef struct _VesaMode {
+ int mode; /* mode number */
+ int vbe; /* a VBE mode */
+ int ModeAttributes; /* mode attributes */
+ int NumberOfPlanes; /* number of memory planes */
+ int BitsPerPixel; /* bits per pixel */
+ int MemoryModel; /* memory model type */
+ int RedMaskSize; /* size of direct color red mask in bits */
+ int RedFieldPosition; /* bit position of lsb of red mask */
+ int GreenMaskSize; /* size of direct color green mask in bits */
+ int GreenFieldPosition; /* bit position of lsb of green mask */
+ int BlueMaskSize; /* size of direct color blue mask in bits */
+ int BlueFieldPosition; /* bit position of lsb of blue mask */
+ int RsvdMaskSize; /* size of direct color reserved mask bits*/
+ int RsvdFieldPosition; /* bit position of lsb of reserved mask */
+ int DirectColorModeInfo; /* direct color mode attributes */
+ int XResolution; /* horizontal resolution */
+ int YResolution; /* vertical resolution */
+ int BytesPerScanLine; /* bytes per scan line */
+} VesaModeRec, *VesaModePtr;
+
+#include "vbe.h"
+#include "vga.h"
+
+typedef struct _VesaCardPriv {
+ int vbe;
+ VesaModePtr modes;
+ int nmode;
+ Vm86InfoPtr vi;
+ int vga_palette;
+ int old_vbe_mode;
+ int old_vga_mode;
+ VbeInfoPtr vbeInfo;
+ char text[VESA_TEXT_SAVE];
+ CARD8 cmap[256*4];
+} VesaCardPrivRec, *VesaCardPrivPtr;
+
+#define VESA_LINEAR 0
+#define VESA_WINDOWED 1
+#define VESA_PLANAR 2
+#define VESA_MONO 3
+
+typedef struct _VesaScreenPriv {
+ VesaModeRec mode;
+ Bool shadow;
+ Rotation randr;
+ int mapping;
+ int origDepth;
+ void *fb;
+ int fb_size;
+ CARD32 fb_phys;
+ PixmapPtr pShadow;
+ Bool mapped;
+} VesaScreenPrivRec, *VesaScreenPrivPtr;
+
+extern int vesa_video_mode;
+extern Bool vesa_force_mode;
+
+void
+vesaReportMode (VesaModePtr mode);
+
+VesaModePtr
+vesaGetModes (Vm86InfoPtr vi, int *ret_nmode);
+
+void
+vesaTestMode (void);
+
+void *
+vesaSetWindowPlanar(ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size);
+
+void *
+vesaSetWindowLinear (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size);
+
+void *
+vesaSetWindowWindowed (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size);
+
+void *
+vesaWindowPlanar (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure);
+
+void *
+vesaWindowLinear (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure);
+
+void *
+vesaWindowWindowed (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure);
+
+void *
+vesaWindowCga (ScreenPtr pScreen,
+ CARD32 row,
+ CARD32 offset,
+ int mode,
+ CARD32 *size,
+ void *closure);
+
+void
+vesaUpdateMono (ScreenPtr pScreen,
+ shadowBufPtr pBuf);
+
+Bool
+vesaCreateColormap16 (ColormapPtr pmap);
+
+void
+vesaSetScreenSizes (ScreenPtr pScreen);
+
+Bool
+vesaSetShadow (ScreenPtr pScreen);
+
+
+void
+vesaListModes(void);
+
+Bool
+vesaInitialize(KdCardInfo *card, VesaCardPrivPtr priv);
+
+Bool
+vesaCardInit(KdCardInfo *card);
+
+int
+vesaDepth (VesaModePtr mode);
+
+Bool
+vesaModeGood (KdScreenInfo *screen,
+ VesaModePtr a);
+
+int
+vesaSizeError (KdScreenInfo *screen,
+ VesaModePtr a);
+
+Bool
+vesaModeBetter (KdScreenInfo *screen,
+ VesaModePtr a,
+ VesaModePtr b);
+
+VesaModePtr
+vesaSelectMode (KdScreenInfo *screen);
+
+Bool
+vesaInitialize (KdCardInfo *card, VesaCardPrivPtr priv);
+
+Bool
+vesaScreenInitialize (KdScreenInfo *screen, VesaScreenPrivPtr pscr);
+
+Bool
+vesaScreenInit(KdScreenInfo *screen);
+
+PixmapPtr
+vesaGetPixmap (ScreenPtr pScreen);
+
+Bool
+vesaInitScreen(ScreenPtr pScreen);
+
+Bool
+vesaFinishInitScreen(ScreenPtr pScreen);
+
+Bool
+vesaCreateResources (ScreenPtr pScreen);
+
+Bool
+vesaSetMode (ScreenPtr pScreen,
+ VesaModePtr mode);
+
+Bool
+vesaEnable(ScreenPtr pScreen);
+
+Bool
+vesaDPMS (ScreenPtr pScreen, int mode);
+
+void
+vesaDisable(ScreenPtr pScreen);
+
+void
+vesaPreserve(KdCardInfo *card);
+
+void
+vesaRestore(KdCardInfo *card);
+
+void
+vesaCardFini(KdCardInfo *card);
+
+void
+vesaScreenFini(KdScreenInfo *screen);
+
+int
+vesaSetPalette(VesaCardPrivPtr priv, int first, int number, U8 *entries);
+
+int
+vesaGetPalette(VesaCardPrivPtr priv, int first, int number, U8 *entries);
+
+void
+vesaPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+
+void
+vesaGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
+
+void
+vesaUseMsg (void);
+
+int
+vesaProcessArgument (int argc, char **argv, int i);
+
+#ifdef RANDR
+Bool
+vesaRandRGetInfo (ScreenPtr pScreen, Rotation *rotations);
+
+Bool
+vesaRandRSetConfig (ScreenPtr pScreen,
+ Rotation randr,
+ int rate,
+ RRScreenSizePtr pSize);
+Bool
+vesaRandRInit (ScreenPtr pScreen);
+
+#endif
+
+Bool
+toshibaDPMS (ScreenPtr pScreen, int mode);
+
+#endif /* _VESA_H_ */
diff --git a/xorg-server/hw/kdrive/vesa/vesainit.c b/xorg-server/hw/kdrive/vesa/vesainit.c
new file mode 100644
index 000000000..a5e216cfd
--- /dev/null
+++ b/xorg-server/hw/kdrive/vesa/vesainit.c
@@ -0,0 +1,92 @@
+/*
+Copyright (c) 2000 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "vesa.h"
+
+const KdCardFuncs vesaFuncs = {
+ vesaCardInit, /* cardinit */
+ vesaScreenInit, /* scrinit */
+ vesaInitScreen, /* initScreen */
+ vesaFinishInitScreen, /* finishInitScreen */
+ vesaCreateResources, /* createRes */
+ vesaPreserve, /* preserve */
+ vesaEnable, /* enable */
+ vesaDPMS, /* dpms */
+ vesaDisable, /* disable */
+ vesaRestore, /* restore */
+ vesaScreenFini, /* scrfini */
+ vesaCardFini, /* cardfini */
+
+ 0, /* initCursor */
+ 0, /* enableCursor */
+ 0, /* disableCursor */
+ 0, /* finiCursor */
+ 0, /* recolorCursor */
+
+ 0, /* initAccel */
+ 0, /* enableAccel */
+ 0, /* disableAccel */
+ 0, /* finiAccel */
+
+ vesaGetColors, /* getColors */
+ vesaPutColors, /* putColors */
+};
+
+void
+InitCard(char *name)
+{
+ KdCardAttr attr;
+ KdCardInfoAdd((KdCardFuncs *) &vesaFuncs, &attr, 0);
+}
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdOsAddInputDrivers();
+ KdInitInput();
+}
+
+void
+ddxUseMsg (void)
+{
+ KdUseMsg();
+ vesaUseMsg();
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ int ret;
+
+ if (!(ret = vesaProcessArgument (argc, argv, i)))
+ ret = KdProcessArgument(argc, argv, i);
+ return ret;
+}
diff --git a/xorg-server/hw/kdrive/vesa/vga.c b/xorg-server/hw/kdrive/vesa/vga.c
new file mode 100644
index 000000000..0367a5f06
--- /dev/null
+++ b/xorg-server/hw/kdrive/vesa/vga.c
@@ -0,0 +1,242 @@
+/*
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "vesa.h"
+
+static const VesaModeRec vgaModes[] = {
+ {
+ 6, 0,
+ MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_LINEAR,
+ 1, 1, MEMORY_PLANAR,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 640, 200, 80,
+ },
+ {
+ 0xd, 0,
+ MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR,
+ 4, 4, MEMORY_PLANAR,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 320, 200, 40,
+ },
+ {
+ 0xe, 0,
+ MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR,
+ 4, 4, MEMORY_PLANAR,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 640, 200, 80,
+ },
+ {
+ 0x10, 0,
+ MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR,
+ 4, 4, MEMORY_PLANAR,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 640, 350, 80,
+ },
+ {
+ 0x11, 0,
+ MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_LINEAR,
+ 1, 1, MEMORY_PLANAR,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 640, 480, 80,
+ },
+ {
+ 0x12, 0,
+ MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR,
+ 4, 4, MEMORY_PLANAR,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 640, 480, 80,
+ },
+ {
+ 0x13, 0,
+ MODE_SUPPORTED | MODE_GRAPHICS | MODE_VGA | MODE_COLOUR | MODE_LINEAR,
+ 8, 8, MEMORY_PSEUDO,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 320, 200, 320,
+ },
+};
+
+#define NUM_VGA_MODE (sizeof vgaModes / sizeof vgaModes[0])
+
+int
+VgaGetNmode (Vm86InfoPtr vi)
+{
+ return NUM_VGA_MODE;
+}
+
+int
+VgaGetModes (Vm86InfoPtr vi, VesaModePtr mode, int nmode)
+{
+ if (nmode > NUM_VGA_MODE)
+ nmode = NUM_VGA_MODE;
+ memcpy (mode, vgaModes, nmode * sizeof (VesaModeRec));
+ return nmode;
+}
+
+int
+VgaSetMode(Vm86InfoPtr vi, int mode)
+{
+ int code;
+
+ vi->vms.regs.eax = mode & 0x7f;
+ code = Vm86DoInterrupt (vi, 0x10);
+ if(code < 0)
+ return -1;
+ return 0;
+}
+
+int
+VgaGetMode (Vm86InfoPtr vi, int *mode)
+{
+ *mode = Vm86Memory (vi, 0x449);
+ return 0;
+}
+
+void
+VgaSetWritePlaneMask(Vm86InfoPtr vi, int mask)
+{
+ asm volatile ("outb %b0,%w1" : : "a" (2), "d" (0x3c4));
+ asm volatile ("outb %b0,%w1" : : "a" (mask), "d" (0x3c5));
+}
+
+void
+VgaSetReadPlaneMap(Vm86InfoPtr vi, int map)
+{
+ asm volatile ("outb %b0,%w1" : : "a" (4), "d" (0x3ce));
+ asm volatile ("outb %b0,%w1" : : "a" (map), "d" (0x3cf));
+}
+
+int
+VgaSetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries)
+{
+ U8 *palette_scratch;
+ int mark;
+ int palette_base;
+ int i, j, code;
+
+ if(number == 0)
+ return 0;
+
+ if(first < 0 || number < 0 || first + number > 256) {
+ ErrorF("Cannot set %d, %d palette entries\n", first, number);
+ return -1;
+ }
+
+ mark = Vm86MarkMemory (vi);
+ palette_base = Vm86AllocateMemory (vi, 3 * 256);
+
+ palette_scratch = &LM(vi, palette_base);
+
+ vi->vms.regs.eax = 0x1012;
+ vi->vms.regs.ebx = first;
+ vi->vms.regs.ecx = number;
+ vi->vms.regs.es = POINTER_SEGMENT(palette_base);
+ vi->vms.regs.edx = POINTER_OFFSET(palette_base);
+ j = 0;
+ i = 0;
+ while (number--)
+ {
+ palette_scratch[j++] = entries[i++] >> 2;
+ palette_scratch[j++] = entries[i++] >> 2;
+ palette_scratch[j++] = entries[i++] >> 2;
+ i++;
+ }
+ code = Vm86DoInterrupt(vi, 0x10);
+ Vm86ReleaseMemory (vi, mark);
+
+ if(code < 0)
+ return -1;
+ return 0;
+}
+
+int
+VgaGetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries)
+{
+ U8 *palette_scratch;
+ int mark;
+ int palette_base;
+ int i, j, code;
+
+ if(number == 0)
+ return 0;
+
+ if(first < 0 || number < 0 || first + number > 256) {
+ ErrorF("Cannot get %d, %d palette entries\n", first, number);
+ return -1;
+ }
+
+ mark = Vm86MarkMemory (vi);
+ palette_base = Vm86AllocateMemory (vi, 3 * 256);
+
+ palette_scratch = &LM(vi, palette_base);
+
+ vi->vms.regs.eax = 0x1017;
+ vi->vms.regs.ebx = first;
+ vi->vms.regs.ecx = number;
+ vi->vms.regs.es = POINTER_SEGMENT(palette_base);
+ vi->vms.regs.edx = POINTER_OFFSET(palette_base);
+
+ code = VbeDoInterrupt10(vi);
+ if(code < 0)
+ return -1;
+
+ j = 0;
+ i = 0;
+ while (number--)
+ {
+ entries[i++] = palette_scratch[j++] << 2;
+ entries[i++] = palette_scratch[j++] << 2;
+ entries[i++] = palette_scratch[j++] << 2;
+ entries[i++] = 0;
+ }
+
+ Vm86ReleaseMemory (vi, mark);
+
+ return 0;
+}
+
+#define VGA_FB(vm) ((vm) < 8 ? 0xb8000 : 0xa0000)
+
+void *
+VgaSetWindow (Vm86InfoPtr vi, int vmode, int bytes, int mode, int *size)
+{
+ *size = 0x10000 - bytes;
+ return &LM(vi,VGA_FB(vmode) + bytes);
+}
+
+void *
+VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size, CARD32 *ret_phys)
+{
+ if (VGA_FB(vmode) == 0xa0000)
+ *size = 0x10000;
+ else
+ *size = 0x4000;
+ *ret_phys = VGA_FB(vmode);
+ return &LM(vi,VGA_FB(vmode));
+}
+
+void
+VgaUnmapFramebuffer (Vm86InfoPtr vi)
+{
+}
diff --git a/xorg-server/hw/kdrive/vesa/vga.h b/xorg-server/hw/kdrive/vesa/vga.h
new file mode 100644
index 000000000..9a368cef7
--- /dev/null
+++ b/xorg-server/hw/kdrive/vesa/vga.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _VGA_H_
+#define _VGA_H_
+
+int
+VgaGetNmode (Vm86InfoPtr vi);
+
+int
+VgaGetModes (Vm86InfoPtr vi, VesaModePtr mode, int nmode);
+
+int
+VgaSetMode(Vm86InfoPtr vi, int mode);
+
+int
+VgaGetMode (Vm86InfoPtr vi, int *mode);
+
+void
+VgaSetWritePlaneMask(Vm86InfoPtr vi, int mask);
+
+void
+VgaSetReadPlaneMap(Vm86InfoPtr vi, int map);
+
+int
+VgaSetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries);
+
+int
+VgaGetPalette(Vm86InfoPtr vi, int first, int number, U8 *entries);
+
+void *
+VgaSetWindow (Vm86InfoPtr vi, int vmode, int bytes, int mode, int *size);
+
+void *
+VgaMapFramebuffer (Vm86InfoPtr vi, int vmode, int *size, CARD32 *phys);
+
+void
+VgaUnmapFramebuffer (Vm86InfoPtr vi);
+
+#endif /* _VGA_H_ */
diff --git a/xorg-server/hw/kdrive/vesa/vm86.c b/xorg-server/hw/kdrive/vesa/vm86.c
new file mode 100644
index 000000000..0f7bb2262
--- /dev/null
+++ b/xorg-server/hw/kdrive/vesa/vm86.c
@@ -0,0 +1,764 @@
+/*
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+Copyright (c) 2000 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "vm86.h"
+
+#define PUSHW(vi, i) \
+{ vi->vms.regs.esp -= 2;\
+ LMW(vi,MAKE_POINTER(vi->vms.regs.ss, vi->vms.regs.esp)) = i;}
+
+static int vm86old(struct vm86_struct *vms);
+static int vm86_loop(Vm86InfoPtr vi);
+
+static const U8 rev_ints[32] =
+{ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0x80,
+};
+
+static const U8 retcode_data[2] =
+{ 0xCD, 0xFF };
+
+Vm86InfoPtr
+Vm86Setup(int mapHoles)
+{
+ int devmem = -1, devzero = -1;
+ void *magicMem, *loMem, *hiMem;
+ void *hole1, *hole2;
+ U32 stack_base, ret_code;
+ Vm86InfoPtr vi = NULL;
+
+ devmem = open("/dev/mem", O_RDWR);
+ if(devmem < 0) {
+ perror("open /dev/mem");
+ goto fail;
+ }
+
+ devzero = open("/dev/zero", O_RDWR);
+ if(devzero < 0) {
+ perror("open /dev/zero");
+ goto fail;
+ }
+
+ magicMem = MAP_FAILED;
+ loMem = MAP_FAILED;
+ hiMem = MAP_FAILED;
+ hole1 = MAP_FAILED;
+ hole2 = MAP_FAILED;
+
+
+ magicMem = mmap((void*)MAGICMEM_BASE, MAGICMEM_SIZE,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE | MAP_FIXED, devmem, MAGICMEM_BASE);
+
+ if(magicMem == MAP_FAILED) {
+ ErrorF("Couldn't map magic memory\n");
+ goto unmapfail;
+ }
+
+ if(mapHoles) {
+ hole1 = mmap((void*)HOLE1_BASE, HOLE1_SIZE,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE | MAP_FIXED, devzero, HOLE1_BASE);
+
+ if(hole1 == MAP_FAILED) {
+ ErrorF("Couldn't map first hole\n");
+ goto unmapfail;
+ }
+ }
+
+ loMem = mmap((void*)LOMEM_BASE, LOMEM_SIZE,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE | MAP_FIXED, devzero, LOMEM_BASE);
+ if(loMem == MAP_FAILED) {
+ ErrorF("Couldn't map low memory\n");
+ munmap(magicMem, MAGICMEM_SIZE);
+ goto unmapfail;
+ }
+
+ if(mapHoles) {
+ hole2 = mmap((void*)HOLE2_BASE, HOLE2_SIZE,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE | MAP_FIXED, devzero, HOLE2_BASE);
+
+ if(hole2 == MAP_FAILED) {
+ ErrorF("Couldn't map first hole\n");
+ goto unmapfail;
+ }
+ }
+
+ hiMem = mmap((void*)HIMEM_BASE, HIMEM_SIZE,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_SHARED | MAP_FIXED,
+ devmem, HIMEM_BASE);
+ if(hiMem == MAP_FAILED) {
+ ErrorF("Couldn't map high memory\n");
+ goto unmapfail;
+ }
+
+ vi = xalloc(sizeof(Vm86InfoRec));
+ if (!vi)
+ goto unmapfail;
+
+ vi->magicMem = magicMem;
+ vi->hole1 = hole1;
+ vi->loMem = loMem;
+ vi->hole2 = hole2;
+ vi->hiMem = hiMem;
+ vi->brk = LOMEM_BASE;
+
+ stack_base = Vm86AllocateMemory(vi, STACK_SIZE);
+ if(stack_base == ALLOC_FAIL)
+ goto unmapfail;
+ ret_code = Vm86AllocateMemory(vi, sizeof(retcode_data));
+ if(ret_code == ALLOC_FAIL)
+ goto unmapfail;
+
+ vi->stack_base = stack_base;
+ vi->ret_code = ret_code;
+
+ memset(&vi->vms, 0, sizeof(struct vm86_struct));
+ vi->vms.flags = 0;
+ vi->vms.screen_bitmap = 0;
+ vi->vms.cpu_type = CPU_586;
+ memcpy(&vi->vms.int_revectored, rev_ints, sizeof(rev_ints));
+
+ iopl(3);
+
+ if(devmem >= 0)
+ close(devmem);
+ if(devzero >= 0)
+ close(devzero);
+
+ return vi;
+
+unmapfail:
+ if(magicMem != MAP_FAILED) munmap(magicMem, MAGICMEM_SIZE);
+ if(hole1 != MAP_FAILED) munmap(hole1, HOLE1_SIZE);
+ if(loMem != MAP_FAILED) munmap(loMem, LOMEM_SIZE);
+ if(hole2 != MAP_FAILED) munmap(hole2, HOLE2_SIZE);
+ if(hiMem != MAP_FAILED) munmap(hiMem, HIMEM_SIZE);
+fail:
+ if(devmem >= 0)
+ close(devmem);
+ if(devzero >= 0)
+ close(devzero);
+ if(vi)
+ xfree(vi);
+ return NULL;
+}
+
+void
+Vm86Cleanup(Vm86InfoPtr vi)
+{
+ if(vi->magicMem != MAP_FAILED) munmap(vi->magicMem, MAGICMEM_SIZE);
+ if(vi->hole1 != MAP_FAILED) munmap(vi->hole1, HOLE1_SIZE);
+ if(vi->loMem != MAP_FAILED) munmap(vi->loMem, LOMEM_SIZE);
+ if(vi->hole2 != MAP_FAILED) munmap(vi->hole2, HOLE2_SIZE);
+ if(vi->hiMem != MAP_FAILED) munmap(vi->hiMem, HIMEM_SIZE);
+ xfree(vi);
+}
+
+int
+Vm86DoInterrupt(Vm86InfoPtr vi, int num)
+{
+ U16 seg, off;
+ int code;
+
+ if(num < 0 || num>256) {
+ ErrorF("Interrupt %d doesn't exist\n");
+ return -1;
+ }
+ seg = MMW(vi,num * 4 + 2);
+ off = MMW(vi,num * 4);
+ if(MAKE_POINTER(seg, off) < ROM_BASE ||
+ MAKE_POINTER(seg, off) >= ROM_BASE + ROM_SIZE) {
+ ErrorF("Interrupt pointer (seg %x off %x) doesn't point at ROM\n",
+ seg, off);
+ return -1;
+ }
+ memcpy(&(LM(vi,vi->ret_code)), retcode_data, sizeof(retcode_data));
+ vi->vms.regs.eflags = IF_MASK | IOPL_MASK;
+ vi->vms.regs.ss = POINTER_SEGMENT(vi->stack_base);
+ vi->vms.regs.esp = STACK_SIZE;
+ PUSHW(vi, IF_MASK | IOPL_MASK);
+ PUSHW(vi, POINTER_SEGMENT(vi->ret_code));
+ PUSHW(vi, POINTER_OFFSET(vi->ret_code));
+ vi->vms.regs.cs = seg;
+ vi->vms.regs.eip = off;
+ OsBlockSignals ();
+ code = vm86_loop(vi);
+ OsReleaseSignals ();
+ if(code != 0)
+ return -1;
+ else
+ return 0;
+}
+
+int
+Vm86DoPOST(Vm86InfoPtr vi)
+{
+ U16 seg, off;
+ int code;
+
+ seg = 0xC000;
+ off = 3;
+ if(MAKE_POINTER(seg, off) < ROM_BASE ||
+ MAKE_POINTER(seg, off) >= ROM_BASE + ROM_SIZE) {
+ ErrorF("BIOS pointer (seg %x off %x) doesn't point at ROM\n",
+ seg, off);
+ return -1;
+ }
+ memcpy(&(LM(vi,vi->ret_code)), retcode_data, sizeof(retcode_data));
+ vi->vms.regs.ss = POINTER_SEGMENT(vi->stack_base);
+ vi->vms.regs.esp = STACK_SIZE;
+ PUSHW(vi, POINTER_SEGMENT(vi->ret_code));
+ PUSHW(vi, POINTER_OFFSET(vi->ret_code));
+ vi->vms.regs.cs = seg;
+ vi->vms.regs.eip = off;
+ OsBlockSignals ();
+ code = vm86_loop(vi);
+ OsReleaseSignals ();
+ if(code != 0)
+ return -1;
+ else
+ return 0;
+}
+
+#define DEBUG_VBE 0
+#if DEBUG_VBE
+#define DBG(x) ErrorF x; usleep(10*1000)
+#else
+#define DBG(x)
+#endif
+
+static inline U8
+vm86_inb(U16 port)
+{
+ U8 value;
+
+ if (port != 0x3da)
+ {
+ DBG(("inb 0x%04x", port));
+ }
+ asm volatile ("inb %w1,%b0" : "=a" (value) : "d" (port));
+ if (port != 0x3da)
+ {
+ DBG((" = 0x%02x\n", value));
+ }
+ return value;
+}
+
+static inline U16
+vm86_inw(U16 port)
+{
+ U16 value;
+ DBG(("inw 0x%04x", port));
+ asm volatile ("inw %w1,%w0" : "=a" (value) : "d" (port));
+ DBG((" = 0x%04x\n", value));
+ return value;
+}
+
+static inline U32
+vm86_inl(U16 port)
+{
+ U32 value;
+ DBG(("inl 0x%04x", port));
+ asm volatile ("inl %w1,%0" : "=a" (value) : "d" (port));
+ DBG((" = 0x%08x\n", value));
+ return value;
+}
+
+static inline void
+vm86_outb(U16 port, U8 value)
+{
+#if 0
+ static U8 CR;
+
+ if (port == 0x3d4)
+ CR = value;
+ if (port == 0x3d5 && CR == 0xa4)
+ {
+ DBG(("outb 0x%04x = 0x%02x (skipped)\n", port, value));
+ return;
+ }
+#endif
+ DBG(("outb 0x%04x = 0x%02x\n", port, value));
+ asm volatile ("outb %b0,%w1" : : "a" (value), "d" (port));
+}
+
+static inline void
+vm86_outw(U16 port, U16 value)
+{
+ DBG(("outw 0x%04x = 0x%04x\n", port, value));
+ asm volatile ("outw %w0,%w1" : : "a" (value), "d" (port));
+}
+
+static inline void
+vm86_outl(U16 port, U32 value)
+{
+ DBG(("outl 0x%04x = 0x%08x\n", port, value));
+ asm volatile ("outl %0,%w1" : : "a" (value), "d" (port));
+}
+
+#define SEG_CS 1
+#define SEG_DS 2
+#define SEG_ES 3
+#define SEG_SS 4
+#define SEG_GS 5
+#define SEG_FS 6
+#define REP 1
+#define REPNZ 2
+#define SET_8(_x, _y) (_x) = ((_x) & ~0xFF) | ((_y) & 0xFF);
+#define SET_16(_x, _y) (_x) = ((_x) & ~0xFFFF) | ((_y) & 0xFFFF);
+#define INC_IP(_i) SET_16(regs->eip, (regs->eip + _i))
+#define AGAIN INC_IP(1); goto again;
+
+static int
+vm86_emulate(Vm86InfoPtr vi)
+{
+ struct vm86_regs *regs = &vi->vms.regs;
+ U8 opcode;
+ int size;
+ int pref_seg = 0, pref_rep = 0, pref_66 = 0, pref_67 = 0;
+
+ again:
+ if(!Vm86IsMemory(vi, MAKE_POINTER(regs->cs, regs->eip))) {
+ ErrorF("Trying to execute unmapped memory\n");
+ return -1;
+ }
+ opcode = Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip));
+ switch(opcode) {
+ case 0x2E: pref_seg = SEG_CS; AGAIN;
+ case 0x3E: pref_seg = SEG_DS; AGAIN;
+ case 0x26: pref_seg = SEG_ES; AGAIN;
+ case 0x36: pref_seg = SEG_SS; AGAIN;
+ case 0x65: pref_seg = SEG_GS; AGAIN;
+ case 0x64: pref_seg = SEG_FS; AGAIN;
+ case 0x66: pref_66 = 1; AGAIN;
+ case 0x67: pref_67 = 1; AGAIN;
+ case 0xF2: pref_rep = REPNZ; AGAIN;
+ case 0xF3: pref_rep = REP; AGAIN;
+
+ case 0xEC: /* IN AL, DX */
+ SET_8(regs->eax, vm86_inb(regs->edx & 0xFFFF));
+ INC_IP(1);
+ break;
+ case 0xED: /* IN AX, DX */
+ if(pref_66)
+ regs->eax = vm86_inl(regs->edx & 0xFFFF);
+ else
+ SET_16(regs->eax, vm86_inw(regs->edx & 0xFFFF));
+ INC_IP(1);
+ break;
+ case 0xE4: /* IN AL, imm8 */
+ SET_8(regs->eax,
+ vm86_inb(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1))));
+ INC_IP(2);
+ break;
+ case 0xE5: /* IN AX, imm8 */
+ if(pref_66)
+ regs->eax =
+ vm86_inl(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)));
+ else
+ SET_16(regs->eax,
+ vm86_inw(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1))));
+ INC_IP(2);
+ break;
+ case 0x6C: /* INSB */
+ case 0x6D: /* INSW */
+ if(opcode == 0x6C) {
+ Vm86WriteMemory(vi, MAKE_POINTER(regs->es, regs->edi),
+ vm86_inb(regs->edx & 0xFFFF));
+ size = 1;
+ } else if(pref_66) {
+ Vm86WriteMemoryL(vi, MAKE_POINTER(regs->es, regs->edi),
+ vm86_inl(regs->edx & 0xFFFF));
+ size = 4;
+ } else {
+ Vm86WriteMemoryW(vi, MAKE_POINTER(regs->es, regs->edi),
+ vm86_inw(regs->edx & 0xFFFF));
+ size = 2;
+ }
+ if(regs->eflags & (1<<10))
+ regs->edi -= size;
+ else
+ regs->edi += size;
+ if(pref_rep) {
+ if(pref_66) {
+ regs->ecx--;
+ if(regs->ecx != 0)
+ goto again;
+ } else {
+ SET_16(regs->ecx, regs->ecx - 1);
+ if((regs->ecx & 0xFFFF) != 0)
+ goto again;
+ }
+ }
+ INC_IP(1);
+ break;
+
+ case 0xEE: /* OUT DX, AL */
+ vm86_outb(regs->edx & 0xFFFF, regs->eax & 0xFF);
+ INC_IP(1);
+ break;
+ case 0xEF: /* OUT DX, AX */
+ if(pref_66)
+ vm86_outl(regs->edx & 0xFFFF, regs->eax);
+ else
+ vm86_outw(regs->edx & 0xFFFF, regs->eax & 0xFFFF);
+ INC_IP(1);
+ break;
+ case 0xE6: /* OUT imm8, AL */
+ vm86_outb(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)),
+ regs->eax & 0xFF);
+ INC_IP(2);
+ break;
+ case 0xE7: /* OUT imm8, AX */
+ if(pref_66)
+ vm86_outl(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)),
+ regs->eax);
+ else
+ vm86_outw(Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip+1)),
+ regs->eax & 0xFFFF);
+ INC_IP(2);
+ break;
+ case 0x6E: /* OUTSB */
+ case 0x6F: /* OUTSW */
+ if(opcode == 0x6E) {
+ vm86_outb(regs->edx & 0xFFFF,
+ Vm86Memory(vi, MAKE_POINTER(regs->es, regs->edi)));
+ size = 1;
+ } else if(pref_66) {
+ vm86_outl(regs->edx & 0xFFFF,
+ Vm86Memory(vi, MAKE_POINTER(regs->es, regs->edi)));
+ size = 4;
+ } else {
+ vm86_outw(regs->edx & 0xFFFF,
+ Vm86Memory(vi, MAKE_POINTER(regs->es, regs->edi)));
+ size = 2;
+ }
+ if(regs->eflags & (1<<10))
+ regs->edi -= size;
+ else
+ regs->edi += size;
+ if(pref_rep) {
+ if(pref_66) {
+ regs->ecx--;
+ if(regs->ecx != 0)
+ goto again;
+ } else {
+ SET_16(regs->ecx, regs->ecx - 1);
+ if((regs->ecx & 0xFFFF) != 0)
+ goto again;
+ }
+ }
+ INC_IP(1);
+ break;
+
+ case 0x0F:
+ ErrorF("Hit 0F trap in VM86 code\n");
+ return -1;
+ case 0xF0:
+ ErrorF("Hit lock prefix in VM86 code\n");
+ return -1;
+ case 0xF4:
+ ErrorF("Hit HLT in VM86 code\n");
+ return -1;
+
+ default:
+ ErrorF("Unhandled GP fault in VM86 code (opcode = 0x%02X)\n",
+ opcode);
+ return -1;
+ }
+ return 0;
+}
+#undef SEG_CS
+#undef SEG_DS
+#undef SEG_ES
+#undef SEG_SS
+#undef SEG_GS
+#undef SEG_FS
+#undef REP
+#undef REPNZ
+#undef SET_8
+#undef SET_16
+#undef INC_IP
+#undef AGAIN
+
+static int
+vm86_loop(Vm86InfoPtr vi)
+{
+ int code;
+
+ while(1) {
+ code = vm86old(&vi->vms);
+ switch(VM86_TYPE(code)) {
+ case VM86_SIGNAL:
+ continue;
+ case VM86_UNKNOWN:
+ code = vm86_emulate(vi);
+ if(code < 0) {
+ Vm86Debug(vi);
+ return -1;
+ }
+ break;
+ case VM86_INTx:
+ if(VM86_ARG(code) == 0xFF)
+ return 0;
+ else {
+ PUSHW(vi, vi->vms.regs.eflags)
+ PUSHW(vi, vi->vms.regs.cs);
+ PUSHW(vi, vi->vms.regs.eip);
+ vi->vms.regs.cs = MMW(vi,VM86_ARG(code) * 4 + 2);
+ vi->vms.regs.eip = MMW(vi,VM86_ARG(code) * 4);
+ }
+ break;
+ case VM86_STI:
+ ErrorF("VM86 code enabled interrupts\n");
+ Vm86Debug(vi);
+ return -1;
+ default:
+ if(code < 0) {
+ if(errno == ENOSYS) {
+ ErrorF("No vm86 support. Are you running on AMD64?\n");
+ } else {
+ ErrorF("vm86 failed (%s).\n", strerror(errno));
+ Vm86Debug(vi);
+ }
+ } else {
+ ErrorF("Unexpected result code 0x%X from vm86\n", code);
+ Vm86Debug(vi);
+ }
+ return -1;
+ }
+ }
+}
+
+int
+Vm86IsMemory(Vm86InfoPtr vi, U32 i)
+{
+ if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE)
+ return 1;
+ else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE)
+ return 1;
+ else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE)
+ return 1;
+ else
+ return 0;
+}
+
+U8
+Vm86Memory(Vm86InfoPtr vi, U32 i)
+{
+ if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE)
+ return MM(vi, i);
+ else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE)
+ return LM(vi, i);
+ else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE)
+ return HM(vi, i);
+ else {
+ ErrorF("Reading unmapped memory at 0x%08X\n", i);
+ return 0;
+ }
+}
+
+U16
+Vm86MemoryW(Vm86InfoPtr vi, U32 i)
+{
+ if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE)
+ return MMW(vi, i);
+ else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE)
+ return LMW(vi, i);
+ else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE)
+ return HMW(vi, i);
+ else {
+ ErrorF("Reading unmapped memory at 0x%08X\n", i);
+ return 0;
+ }
+}
+
+U32
+Vm86MemoryL(Vm86InfoPtr vi, U32 i)
+{
+ if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE)
+ return MML(vi, i);
+ else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE)
+ return LML(vi, i);
+ else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE)
+ return HML(vi, i);
+ else {
+ ErrorF("Reading unmapped memory at 0x%08X\n", i);
+ return 0;
+ }
+}
+
+void
+Vm86WriteMemory(Vm86InfoPtr vi, U32 i, U8 val)
+{
+ if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE)
+ MM(vi, i) = val;
+ else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE)
+ LM(vi, i) = val;
+ else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE)
+ HM(vi, i) = val;
+ else {
+ ErrorF("Writing unmapped memory at 0x%08X\n", i);
+ }
+}
+
+void
+Vm86WriteMemoryW(Vm86InfoPtr vi, U32 i, U16 val)
+{
+ if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE)
+ MMW(vi, i) = val;
+ else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE)
+ LMW(vi, i) = val;
+ else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE)
+ HMW(vi, i) = val;
+ else {
+ ErrorF("Writing unmapped memory at 0x%08X\n", i);
+ }
+}
+
+void
+Vm86WriteMemoryL(Vm86InfoPtr vi, U32 i, U32 val)
+{
+ if(i >= MAGICMEM_BASE && i< MAGICMEM_BASE + MAGICMEM_SIZE)
+ MML(vi, i) = val;
+ else if(i >= LOMEM_BASE && i< LOMEM_BASE + LOMEM_SIZE)
+ LML(vi, i) = val;
+ else if(i >= HIMEM_BASE && i< HIMEM_BASE + HIMEM_SIZE)
+ HML(vi, i) = val;
+ else {
+ ErrorF("Writing unmapped memory at 0x%08X\n", i);
+ }
+}
+
+int
+Vm86AllocateMemory(Vm86InfoPtr vi, int n)
+{
+ int ret;
+ if(n<0) {
+ ErrorF("Asked to allocate negative amount of memory\n");
+ return vi->brk;
+ }
+
+ n = (n + 15) & ~15;
+ if(vi->brk + n > LOMEM_BASE + LOMEM_SIZE) {
+ ErrorF("Out of low memory\n");
+ exit(2);
+ }
+ ret = vi->brk;
+ vi->brk += n;
+ return ret;
+}
+
+int
+Vm86MarkMemory (Vm86InfoPtr vi)
+{
+ return vi->brk;
+}
+
+void
+Vm86ReleaseMemory (Vm86InfoPtr vi, int mark)
+{
+ vi->brk = mark;
+}
+
+static int
+vm86old(struct vm86_struct *vm)
+{
+ int res;
+
+ 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" (113), "r" (vm));
+ if(res < 0) {
+ errno = -res;
+ res = -1;
+ } else
+ errno = 0;
+ return res;
+}
+
+void
+Vm86Debug(Vm86InfoPtr vi)
+{
+ struct vm86_regs *regs = &vi->vms.regs;
+ int i;
+
+ ErrorF("eax=0x%08lX ebx=0x%08lX ecx=0x%08lX edx=0x%08lX\n",
+ regs->eax, regs->ebx, regs->ecx, regs->edx);
+ ErrorF("esi=0x%08lX edi=0x%08lX ebp=0x%08lX\n",
+ regs->esi, regs->edi, regs->ebp);
+ ErrorF("eip=0x%08lX esp=0x%08lX eflags=0x%08lX\n",
+ regs->eip, regs->esp, regs->eflags);
+ ErrorF("cs=0x%04lX ds=0x%04lX es=0x%04lX fs=0x%04lX gs=0x%04lX\n",
+ regs->cs, regs->ds, regs->es, regs->fs, regs->gs);
+ for(i=-7; i<8; i++) {
+ ErrorF(" %s%02X",
+ i==0?"->":"",
+ Vm86Memory(vi, MAKE_POINTER(regs->cs, regs->eip + i)));
+ }
+ ErrorF("\n");
+}
+
+#ifdef NOT_IN_X_SERVER
+static void
+ErrorF(char *f, ...)
+{
+ va_list args;
+ va_start(args, f);
+ vfprintf(stderr, f, args);
+ va_end(args);
+}
+#endif
diff --git a/xorg-server/hw/kdrive/vesa/vm86.h b/xorg-server/hw/kdrive/vesa/vm86.h
new file mode 100644
index 000000000..81693081a
--- /dev/null
+++ b/xorg-server/hw/kdrive/vesa/vm86.h
@@ -0,0 +1,180 @@
+/*
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+Copyright (c) 2000 by Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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.
+*/
+
+#ifndef _VM86_H_
+#define _VM86_H_
+
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/vm86.h>
+#include <sys/io.h>
+
+#ifdef NOT_IN_X_SERVER
+#include <stdio.h>
+#include <stdarg.h>
+#include <malloc.h>
+static void ErrorF(char*, ...);
+#define xalloc(a) malloc(a)
+#define xcalloc(a,b) calloc(a,b)
+#define xfree(a) free(a)
+#else
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/Xos.h>
+#include "os.h"
+#endif
+
+#ifndef IF_MASK
+#define IF_MASK X86_EFLAGS_IF
+#endif
+#ifndef IOPL_MASK
+#define IOPL_MASK X86_EFLAGS_IOPL
+#endif
+
+typedef unsigned char U8;
+typedef unsigned short U16;
+typedef unsigned int U32;
+
+/* The whole addressable memory */
+#define SYSMEM_BASE 0x00000
+#define SYSMEM_SIZE 0x100000
+
+/* Interrupt vectors and BIOS data area */
+/* This is allocated privately from /dev/mem */
+#define MAGICMEM_BASE 0x00000
+#define MAGICMEM_SIZE 0x01000
+
+/* The low memory, allocated privately from /dev/zero */
+/* 64KB should be enough for anyone, as they used to say */
+#define LOMEM_BASE 0x10000
+#define LOMEM_SIZE 0x10000
+
+/* The video memory and BIOS ROM, allocated shared from /dev/mem */
+#define HIMEM_BASE 0xA0000
+#define HIMEM_SIZE (SYSMEM_BASE + SYSMEM_SIZE - HIMEM_BASE)
+
+#define HOLE1_BASE (MAGICMEM_BASE + MAGICMEM_SIZE)
+#define HOLE1_SIZE (LOMEM_BASE - HOLE1_BASE)
+
+#define HOLE2_BASE (LOMEM_BASE + LOMEM_SIZE)
+#define HOLE2_SIZE (HIMEM_BASE - HOLE2_BASE)
+
+/* The BIOS ROM */
+#define ROM_BASE 0xC0000
+#define ROM_SIZE 0x30000
+
+#define STACK_SIZE 0x1000
+
+#define POINTER_SEGMENT(ptr) (((unsigned int)ptr)>>4)
+#define POINTER_OFFSET(ptr) (((unsigned int)ptr)&0x000F)
+#define MAKE_POINTER(seg, off) (((((unsigned int)(seg))<<4) + (unsigned int)(off)))
+#define MAKE_POINTER_1(lw) MAKE_POINTER(((lw)&0xFFFF0000)/0x10000, (lw)&0xFFFF)
+#define ALLOC_FAIL ((U32)-1)
+
+typedef struct _Vm86InfoRec {
+ void *magicMem, *loMem, *hiMem;
+ void *hole1, *hole2;
+ U32 brk;
+ struct vm86_struct vms;
+ U32 ret_code, stack_base;
+} Vm86InfoRec, *Vm86InfoPtr;
+
+#define LM(vi,i) (((char*)vi->loMem)[i-LOMEM_BASE])
+#define LMW(vi,i) (*(U16*)(&LM(vi,i)))
+#define LML(vi,i) (*(U32*)(&LM(vi,i)))
+#define MM(vi,i) (((char*)vi->magicMem)[i-MAGICMEM_BASE])
+#define MMW(vi,i) (*(U16*)(&MM(vi,i)))
+#define MML(vi,i) (*(U32*)(&MM(vi,i)))
+#define HM(vi,i) (((char*)vi->hiMem)[i-HIMEM_BASE])
+#define HMW(vi,i) (*(U16*)(&MM(vi,i)))
+#define HML(vi,i) (*(U32*)(&MM(vi,i)))
+
+Vm86InfoPtr
+Vm86Setup(int);
+
+void
+Vm86Cleanup(Vm86InfoPtr vi);
+
+int
+Vm86DoInterrupt(Vm86InfoPtr vi, int num);
+
+int
+Vm86DoPOST(Vm86InfoPtr vi);
+
+int
+Vm86IsMemory(Vm86InfoPtr vi, U32 i);
+
+U8
+Vm86Memory(Vm86InfoPtr, U32);
+
+U16
+Vm86MemoryW(Vm86InfoPtr, U32);
+
+U32
+Vm86MemoryL(Vm86InfoPtr, U32);
+
+void
+Vm86WriteMemory(Vm86InfoPtr, U32, U8);
+
+void
+Vm86WriteMemoryW(Vm86InfoPtr, U32, U16);
+
+void
+Vm86WriteMemoryL(Vm86InfoPtr, U32, U32);
+
+int
+Vm86AllocateMemory(Vm86InfoPtr, int);
+
+int
+Vm86MarkMemory (Vm86InfoPtr vi);
+
+void
+Vm86ReleaseMemory (Vm86InfoPtr vi, int mark);
+
+void
+Vm86Debug(Vm86InfoPtr vi);
+
+#endif /* _VM86_H_ */
diff --git a/xorg-server/hw/kdrive/via/Makefile.am b/xorg-server/hw/kdrive/via/Makefile.am
new file mode 100644
index 000000000..c659379f0
--- /dev/null
+++ b/xorg-server/hw/kdrive/via/Makefile.am
@@ -0,0 +1,37 @@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_CFLAGS@
+
+bin_PROGRAMS = Xvia
+
+noinst_LIBRARIES = libvia.a
+
+libvia_a_SOURCES = \
+ via.c \
+ viadraw.c \
+ viadraw.h \
+ via.h \
+ via_regs.h
+
+Xvia_SOURCES = \
+ viastub.c
+
+VIA_LIBS = \
+ libvia.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a
+
+if GLX
+Xvia_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+endif
+
+Xvia_LDADD = \
+ $(VIA_LIBS) \
+ @KDRIVE_LIBS@
+
+Xvia_DEPENDENCIES = \
+ libvia.a \
+ @KDRIVE_LOCAL_LIBS@
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/xorg-server/hw/kdrive/via/Makefile.in b/xorg-server/hw/kdrive/via/Makefile.in
new file mode 100644
index 000000000..4f4327e21
--- /dev/null
+++ b/xorg-server/hw/kdrive/via/Makefile.in
@@ -0,0 +1,716 @@
+# Makefile.in generated by automake 1.10.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = Xvia$(EXEEXT)
+subdir = hw/kdrive/via
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/include/do-not-use-config.h \
+ $(top_builddir)/include/xorg-server.h \
+ $(top_builddir)/include/dix-config.h \
+ $(top_builddir)/include/xgl-config.h \
+ $(top_builddir)/include/xorg-config.h \
+ $(top_builddir)/include/xkb-config.h \
+ $(top_builddir)/include/xwin-config.h \
+ $(top_builddir)/include/kdrive-config.h
+CONFIG_CLEAN_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libvia_a_AR = $(AR) $(ARFLAGS)
+libvia_a_LIBADD =
+am_libvia_a_OBJECTS = via.$(OBJEXT) viadraw.$(OBJEXT)
+libvia_a_OBJECTS = $(am_libvia_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)"
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_Xvia_OBJECTS = viastub.$(OBJEXT)
+Xvia_OBJECTS = $(am_Xvia_OBJECTS)
+Xvia_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(Xvia_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libvia_a_SOURCES) $(Xvia_SOURCES)
+DIST_SOURCES = $(libvia_a_SOURCES) $(Xvia_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
+ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+APPDEFAULTDIR = @APPDEFAULTDIR@
+APPLE_APPLICATIONS_DIR = @APPLE_APPLICATIONS_DIR@
+APP_MAN_DIR = @APP_MAN_DIR@
+APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BASE_FONT_PATH = @BASE_FONT_PATH@
+BUILD_DATE = @BUILD_DATE@
+BUILD_TIME = @BUILD_TIME@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+COMPILEDDEFAULTFONTPATH = @COMPILEDDEFAULTFONTPATH@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DARWIN_LIBS = @DARWIN_LIBS@
+DBUS_CFLAGS = @DBUS_CFLAGS@
+DBUS_LIBS = @DBUS_LIBS@
+DEFAULT_LIBRARY_PATH = @DEFAULT_LIBRARY_PATH@
+DEFAULT_LOGPREFIX = @DEFAULT_LOGPREFIX@
+DEFAULT_MODULE_PATH = @DEFAULT_MODULE_PATH@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DGA_CFLAGS = @DGA_CFLAGS@
+DGA_LIBS = @DGA_LIBS@
+DIX_CFLAGS = @DIX_CFLAGS@
+DLLTOOL = @DLLTOOL@
+DMXEXAMPLES_DEP_CFLAGS = @DMXEXAMPLES_DEP_CFLAGS@
+DMXEXAMPLES_DEP_LIBS = @DMXEXAMPLES_DEP_LIBS@
+DMXMODULES_CFLAGS = @DMXMODULES_CFLAGS@
+DMXMODULES_LIBS = @DMXMODULES_LIBS@
+DMXXIEXAMPLES_DEP_CFLAGS = @DMXXIEXAMPLES_DEP_CFLAGS@
+DMXXIEXAMPLES_DEP_LIBS = @DMXXIEXAMPLES_DEP_LIBS@
+DMXXMUEXAMPLES_DEP_CFLAGS = @DMXXMUEXAMPLES_DEP_CFLAGS@
+DMXXMUEXAMPLES_DEP_LIBS = @DMXXMUEXAMPLES_DEP_LIBS@
+DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@
+DRI2PROTO_LIBS = @DRI2PROTO_LIBS@
+DRIPROTO_CFLAGS = @DRIPROTO_CFLAGS@
+DRIPROTO_LIBS = @DRIPROTO_LIBS@
+DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
+DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
+DRI_DRIVER_PATH = @DRI_DRIVER_PATH@
+DSYMUTIL = @DSYMUTIL@
+DTRACE = @DTRACE@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FILE_MAN_DIR = @FILE_MAN_DIR@
+FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GLX_ARCH_DEFINES = @GLX_ARCH_DEFINES@
+GLX_DEFINES = @GLX_DEFINES@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+HAL_CFLAGS = @HAL_CFLAGS@
+HAL_LIBS = @HAL_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KDRIVE_CFLAGS = @KDRIVE_CFLAGS@
+KDRIVE_INCS = @KDRIVE_INCS@
+KDRIVE_LIBS = @KDRIVE_LIBS@
+KDRIVE_LOCAL_LIBS = @KDRIVE_LOCAL_LIBS@
+KDRIVE_PURE_INCS = @KDRIVE_PURE_INCS@
+KDRIVE_PURE_LIBS = @KDRIVE_PURE_LIBS@
+LAUNCHD = @LAUNCHD@
+LDFLAGS = @LDFLAGS@
+LD_EXPORT_SYMBOLS_FLAG = @LD_EXPORT_SYMBOLS_FLAG@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBDRM_CFLAGS = @LIBDRM_CFLAGS@
+LIBDRM_LIBS = @LIBDRM_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_MAN_DIR = @LIB_MAN_DIR@
+LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
+LINUXDOC = @LINUXDOC@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MAKE_HTML = @MAKE_HTML@
+MAKE_PDF = @MAKE_PDF@
+MAKE_PS = @MAKE_PS@
+MAKE_TEXT = @MAKE_TEXT@
+MESA_SOURCE = @MESA_SOURCE@
+MISC_MAN_DIR = @MISC_MAN_DIR@
+MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
+MKDIR_P = @MKDIR_P@
+MKFONTDIR = @MKFONTDIR@
+MKFONTSCALE = @MKFONTSCALE@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCCLD = @OBJCCLD@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLINK = @OBJCLINK@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PCIACCESS_CFLAGS = @PCIACCESS_CFLAGS@
+PCIACCESS_LIBS = @PCIACCESS_LIBS@
+PCI_TXT_IDS_PATH = @PCI_TXT_IDS_PATH@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PROJECTROOT = @PROJECTROOT@
+PS2PDF = @PS2PDF@
+RANLIB = @RANLIB@
+RAWCPP = @RAWCPP@
+RAWCPPFLAGS = @RAWCPPFLAGS@
+SED = @SED@
+SERVER_MISC_CONFIG_PATH = @SERVER_MISC_CONFIG_PATH@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SOLARIS_ASM_CFLAGS = @SOLARIS_ASM_CFLAGS@
+SOLARIS_INOUT_ARCH = @SOLARIS_INOUT_ARCH@
+STRIP = @STRIP@
+TSLIB_CFLAGS = @TSLIB_CFLAGS@
+TSLIB_LIBS = @TSLIB_LIBS@
+UTILS_SYS_LIBS = @UTILS_SYS_LIBS@
+VENDOR_MAN_VERSION = @VENDOR_MAN_VERSION@
+VENDOR_NAME = @VENDOR_NAME@
+VENDOR_NAME_SHORT = @VENDOR_NAME_SHORT@
+VENDOR_RELEASE = @VENDOR_RELEASE@
+VERSION = @VERSION@
+X11APP_ARCHS = @X11APP_ARCHS@
+X11EXAMPLES_DEP_CFLAGS = @X11EXAMPLES_DEP_CFLAGS@
+X11EXAMPLES_DEP_LIBS = @X11EXAMPLES_DEP_LIBS@
+XDMCP_CFLAGS = @XDMCP_CFLAGS@
+XDMCP_LIBS = @XDMCP_LIBS@
+XDMXCONFIG_DEP_CFLAGS = @XDMXCONFIG_DEP_CFLAGS@
+XDMXCONFIG_DEP_LIBS = @XDMXCONFIG_DEP_LIBS@
+XDMX_CFLAGS = @XDMX_CFLAGS@
+XDMX_LIBS = @XDMX_LIBS@
+XDMX_SYS_LIBS = @XDMX_SYS_LIBS@
+XEGLMODULES_CFLAGS = @XEGLMODULES_CFLAGS@
+XEGL_LIBS = @XEGL_LIBS@
+XEGL_SYS_LIBS = @XEGL_SYS_LIBS@
+XEPHYR_CFLAGS = @XEPHYR_CFLAGS@
+XEPHYR_DRI_LIBS = @XEPHYR_DRI_LIBS@
+XEPHYR_INCS = @XEPHYR_INCS@
+XEPHYR_LIBS = @XEPHYR_LIBS@
+XF86CONFIGFILE = @XF86CONFIGFILE@
+XF86MISC_CFLAGS = @XF86MISC_CFLAGS@
+XF86MISC_LIBS = @XF86MISC_LIBS@
+XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@
+XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@
+XGLMODULES_CFLAGS = @XGLMODULES_CFLAGS@
+XGLMODULES_LIBS = @XGLMODULES_LIBS@
+XGLXMODULES_CFLAGS = @XGLXMODULES_CFLAGS@
+XGLXMODULES_LIBS = @XGLXMODULES_LIBS@
+XGLX_LIBS = @XGLX_LIBS@
+XGLX_SYS_LIBS = @XGLX_SYS_LIBS@
+XGL_LIBS = @XGL_LIBS@
+XGL_MODULE_PATH = @XGL_MODULE_PATH@
+XGL_SYS_LIBS = @XGL_SYS_LIBS@
+XKB_BASE_DIRECTORY = @XKB_BASE_DIRECTORY@
+XKB_BIN_DIRECTORY = @XKB_BIN_DIRECTORY@
+XKB_COMPILED_DIR = @XKB_COMPILED_DIR@
+XKM_OUTPUT_DIR = @XKM_OUTPUT_DIR@
+XLIB_CFLAGS = @XLIB_CFLAGS@
+XLIB_LIBS = @XLIB_LIBS@
+XNESTMODULES_CFLAGS = @XNESTMODULES_CFLAGS@
+XNESTMODULES_LIBS = @XNESTMODULES_LIBS@
+XNEST_LIBS = @XNEST_LIBS@
+XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
+XORGCFG_DEP_CFLAGS = @XORGCFG_DEP_CFLAGS@
+XORGCFG_DEP_LIBS = @XORGCFG_DEP_LIBS@
+XORGCONFIG_DEP_CFLAGS = @XORGCONFIG_DEP_CFLAGS@
+XORGCONFIG_DEP_LIBS = @XORGCONFIG_DEP_LIBS@
+XORG_CFLAGS = @XORG_CFLAGS@
+XORG_INCS = @XORG_INCS@
+XORG_LIBS = @XORG_LIBS@
+XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
+XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
+XORG_OS = @XORG_OS@
+XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
+XORG_SYS_LIBS = @XORG_SYS_LIBS@
+XPRINTMODULES_CFLAGS = @XPRINTMODULES_CFLAGS@
+XPRINTMODULES_LIBS = @XPRINTMODULES_LIBS@
+XPRINTPROTO_CFLAGS = @XPRINTPROTO_CFLAGS@
+XPRINTPROTO_LIBS = @XPRINTPROTO_LIBS@
+XPRINT_CFLAGS = @XPRINT_CFLAGS@
+XPRINT_LIBS = @XPRINT_LIBS@
+XPRINT_SYS_LIBS = @XPRINT_SYS_LIBS@
+XRESEXAMPLES_DEP_CFLAGS = @XRESEXAMPLES_DEP_CFLAGS@
+XRESEXAMPLES_DEP_LIBS = @XRESEXAMPLES_DEP_LIBS@
+XSDL_INCS = @XSDL_INCS@
+XSDL_LIBS = @XSDL_LIBS@
+XSERVERCFLAGS_CFLAGS = @XSERVERCFLAGS_CFLAGS@
+XSERVERCFLAGS_LIBS = @XSERVERCFLAGS_LIBS@
+XSERVERLIBS_CFLAGS = @XSERVERLIBS_CFLAGS@
+XSERVERLIBS_LIBS = @XSERVERLIBS_LIBS@
+XSERVER_LIBS = @XSERVER_LIBS@
+XSERVER_SYS_LIBS = @XSERVER_SYS_LIBS@
+XTSTEXAMPLES_DEP_CFLAGS = @XTSTEXAMPLES_DEP_CFLAGS@
+XTSTEXAMPLES_DEP_LIBS = @XTSTEXAMPLES_DEP_LIBS@
+XVFB_LIBS = @XVFB_LIBS@
+XVFB_SYS_LIBS = @XVFB_SYS_LIBS@
+XWINMODULES_CFLAGS = @XWINMODULES_CFLAGS@
+XWINMODULES_LIBS = @XWINMODULES_LIBS@
+XWIN_LIBS = @XWIN_LIBS@
+XWIN_SERVER_NAME = @XWIN_SERVER_NAME@
+XWIN_SYS_LIBS = @XWIN_SYS_LIBS@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+__XCONFIGFILE__ = @__XCONFIGFILE__@
+abi_ansic = @abi_ansic@
+abi_extension = @abi_extension@
+abi_font = @abi_font@
+abi_videodrv = @abi_videodrv@
+abi_xinput = @abi_xinput@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+driverdir = @driverdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extdir = @extdir@
+ft_config = @ft_config@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+launchagentsdir = @launchagentsdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+logdir = @logdir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+moduledir = @moduledir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sdkdir = @sdkdir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+xglmoduledir = @xglmoduledir@
+xpconfigdir = @xpconfigdir@
+INCLUDES = \
+ @KDRIVE_INCS@ \
+ -I$(top_srcdir)/hw/kdrive/vesa \
+ @KDRIVE_CFLAGS@
+
+noinst_LIBRARIES = libvia.a
+libvia_a_SOURCES = \
+ via.c \
+ viadraw.c \
+ viadraw.h \
+ via.h \
+ via_regs.h
+
+Xvia_SOURCES = \
+ viastub.c
+
+VIA_LIBS = \
+ libvia.a \
+ $(top_builddir)/hw/kdrive/vesa/libvesa.a
+
+@GLX_TRUE@Xvia_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
+Xvia_LDADD = \
+ $(VIA_LIBS) \
+ @KDRIVE_LIBS@
+
+Xvia_DEPENDENCIES = \
+ libvia.a \
+ @KDRIVE_LOCAL_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign hw/kdrive/via/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --foreign hw/kdrive/via/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libvia.a: $(libvia_a_OBJECTS) $(libvia_a_DEPENDENCIES)
+ -rm -f libvia.a
+ $(libvia_a_AR) libvia.a $(libvia_a_OBJECTS) $(libvia_a_LIBADD)
+ $(RANLIB) libvia.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+Xvia$(EXEEXT): $(Xvia_OBJECTS) $(Xvia_DEPENDENCIES)
+ @rm -f Xvia$(EXEEXT)
+ $(Xvia_LINK) $(Xvia_OBJECTS) $(Xvia_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/via.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/viadraw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/viastub.Po@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool \
+ clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-info: install-info-am
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-ps: install-ps-am
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool clean-noinstLIBRARIES ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-binPROGRAMS
+
+
+relink:
+ rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/xorg-server/hw/kdrive/via/via.c b/xorg-server/hw/kdrive/via/via.c
new file mode 100644
index 000000000..b8e1036aa
--- /dev/null
+++ b/xorg-server/hw/kdrive/via/via.c
@@ -0,0 +1,435 @@
+/*
+ * Copyright © 2004 Ralph Thomas
+ *
+ * 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 Ralph Thomas not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Ralph Thomas makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * RALPH THOMAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL RALPH THOMAS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+** VIA CLE266 driver
+** Copyright 2004 (C) Ralph Thomas <ralpht@gmail.com>
+**
+** http://www.viatech.com.tw/
+*/
+
+#include "via.h"
+#include "viadraw.h"
+
+/*
+** viaCardInit( KdCardInfo* card )
+**
+** Description:
+** Create card specific structures, map chip registers and initialize the
+** VESA driver. We make the VESA driver do boring stuff for us, like set
+** up a framebuffer and program a mode.
+**
+** Parameters:
+** card Information stucture for the card we want to bring up.
+** It should be a VIA card.
+**
+** Return:
+** TRUE Initialization went ok.
+** FALSE Initialization failed.
+*/
+static Bool
+viaCardInit( KdCardInfo* card ) {
+ ViaCardInfo* viac;
+
+ viac = (ViaCardInfo*) xalloc( sizeof( ViaCardInfo ) );
+ if( !viac ) return FALSE;
+ memset( viac, '\0', sizeof( ViaCardInfo ) );
+
+
+ viaMapReg( card, viac );
+
+ if( !vesaInitialize( card, &viac->vesa ) ) {
+ xfree( viac );
+ return FALSE;
+ }
+
+ card->driver = viac;
+
+ return TRUE;
+}
+
+/*
+** Bool viaScreenInit( KdScreenInfo* screen )
+**
+** Description:
+** Initialize a single screen, described by the screen parameter.
+** This is where fairly low-level screen related things get setup,
+** such as video mode and resolution. Currently that all gets
+** handed off to the VESA driver.
+**
+** Parameters:
+** screen Information structure for the screen to enable.
+**
+** Return:
+** TRUE Screen was initialized successfully
+** FALSE Screen initialization failed
+*/
+static Bool
+viaScreenInit( KdScreenInfo* screen ) {
+ ViaCardInfo* viac = screen->card->driver;
+ ViaScreenInfo* vias;
+
+ vias = (ViaScreenInfo*) xalloc( sizeof( ViaScreenInfo ) );
+ if( !vias ) return FALSE;
+ memset( vias, '\0', sizeof( ViaScreenInfo ) );
+
+ if( !vesaScreenInitialize( screen, &vias->vesa ) ) {
+ xfree( vias );
+ return FALSE;
+ }
+
+ /*
+ ** XXX: What does this do?
+ */
+ if( !viac->mapBase )
+ screen->dumb = TRUE;
+ if( vias->vesa.mapping != VESA_LINEAR )
+ screen->dumb = TRUE;
+
+ screen->driver = vias;
+ return TRUE;
+}
+
+/*
+** Bool viaInitScreen( ScreenPtr pScreen )
+**
+** Description:
+** High level screen initialization occurs here. We could register XV
+** adaptors, etc, here.
+**
+** Arguments:
+** pScreen X screen information
+**
+** Return:
+** TRUE Initialization was successful,
+** FALSE Initialization failed.
+*/
+static Bool
+viaInitScreen( ScreenPtr pScreen ) {
+ return vesaInitScreen( pScreen );
+}
+
+/*
+** Bool viaFinishInitScreen
+**
+** Description:
+** Finish up any high-level screen initialization. Per-Screen extension
+** initialization can be done here.
+**
+** Arguments:
+** pScreen X screen information
+**
+** Return:
+** TRUE Initialization was successful.
+** FALSE Initialization failed.
+*/
+static Bool
+viaFinishInitScreen( ScreenPtr pScreen ) {
+ return vesaFinishInitScreen( pScreen );
+}
+
+/*
+** Bool viaCreateResources( ScreenPtr pScreen )
+**
+** Description:
+** Do any screen specific configuration.
+**
+** Arguments:
+** pScreen X screen information
+**
+** Return:
+** TRUE configuration was successful.
+** FALSE configuration failed.
+*/
+static Bool
+viaCreateResources( ScreenPtr pScreen ) {
+ return vesaCreateResources( pScreen );
+}
+
+/*
+** void viaPreserve( KdCardInfo* card )
+**
+** Description:
+** Save the current state of the chip, so that it can be restored by
+** viaRestore at a later time.
+**
+** Arguments:
+** card Information structure for the chip we want to preserve the
+** state of.
+**
+** Return:
+** None.
+**
+** See Also:
+** viaRestore
+*/
+static void
+viaPreserve( KdCardInfo* card ) {
+ vesaPreserve( card );
+}
+
+/*
+** void viaRestore( KdCardInfo* card )
+**
+** Description:
+** Restore the previous state of the chip, as saved by viaPreserve
+** earlier.
+**
+** Arguments:
+** card Information structure for the chip we want to restore the
+** state of.
+**
+** Return:
+** None.
+**
+** See Also:
+** viaPreserve
+*/
+static void viaRestore( KdCardInfo* card ) {
+ ViaCardInfo* viac = card->driver;
+
+ viaResetMMIO( card, viac );
+ vesaRestore( card );
+}
+
+/*
+** Bool viaEnable( ScreenPtr pScreen )
+**
+** Description:
+** This is where we set the card up for drawing the specified screen, e.g.:
+** set the mode and mmap the framebuffer.
+**
+** Arguments:
+** pScreen X screen information
+**
+** Return:
+** TRUE the screen was enabled
+** FALSE the screen could not be enabled
+*/
+static Bool
+viaEnable( ScreenPtr pScreen ) {
+ KdScreenPriv( pScreen );
+ ViaCardInfo* viac = pScreenPriv->card->driver;
+
+ if( !vesaEnable( pScreen ) ) return FALSE;
+
+ viaSetMMIO( pScreenPriv->card, viac );
+
+ if( !viac->mapBase ) {
+ ErrorF( "Could not map CLE266 graphics registers" );
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*
+** void viaDisable( ScreenPtr pScreen )
+**
+** Description:
+** Shut down drawing: save some state and unmap the framebuffer.
+**
+** Arguments:
+** pScreen X screen information
+**
+** Return:
+** None.
+*/
+static void
+viaDisable( ScreenPtr pScreen ) {
+ KdScreenPriv( pScreen );
+ ViaCardInfo* viac = pScreenPriv->card->driver;
+
+ viaResetMMIO( pScreenPriv->card, viac );
+ vesaDisable( pScreen );
+}
+
+/*
+** void viaScreenFini( KdScreenInfo* screen )
+**
+** Description:
+** Release memory and resources allocated by viaScreenInit.
+**
+** Arguments:
+** screen Information structure for the screen to release.
+**
+** Return:
+** None.
+**
+** See Also:
+** viaScreenInit
+*/
+static void
+viaScreenFini( KdScreenInfo* screen ) {
+ ViaScreenInfo* vias = screen->driver;
+
+ vesaScreenFini( screen );
+ xfree( vias );
+ screen->driver = 0;
+}
+
+/*
+** void viaCardFini( KdCardInfo* card )
+**
+** Description:
+** Release memory and resources allocated by viaCardInit.
+**
+** Arguments:
+** card Information structure for the chip to release.
+**
+** Return:
+** None.
+**
+** See Also:
+** viaCardInit
+*/
+static void
+viaCardFini( KdCardInfo* card ) {
+ ViaCardInfo* viac = card->driver;
+
+ viaUnmapReg( card, viac );
+ vesaCardFini( card );
+ xfree( viac );
+}
+
+/*
+** void viaSetMMIO( KdCardInfo* card, ViaCardInfo* viac )
+**
+** Description:
+** Map the card's registers, if they're not already
+** mapped.
+**
+** Arguments:
+** card generic chip information
+** viac VIA-driver specific chip information
+**
+** Return:
+** None.
+*/
+void viaSetMMIO( KdCardInfo* card, ViaCardInfo* viac ) {
+ if( !viac->mapBase ) viaMapReg( card, viac );
+}
+
+/*
+** void viaResetMMIO( KdCardInfo* card, ViaCardInfo* viac )
+**
+** Description:
+** Unmap chip's registers.
+**
+** Arguments:
+** card generic chip information
+** viac VIA-driver specific chip information
+**
+** Return:
+** None.
+*/
+void viaResetMMIO( KdCardInfo* card, ViaCardInfo* viac ) {
+ viaUnmapReg( card, viac );
+}
+
+/*
+** Bool viaMapReg( KdCardInfo* card, ViaCardInfo* viac )
+**
+** Description:
+** Map the chip's registers into our address space.
+**
+** Arguments:
+** card the card information
+** viac the VIA-driver specific card information
+**
+** Return:
+** TRUE the registers were succesfully mapped
+** FALSE the registers could not be mapped
+*/
+Bool
+viaMapReg( KdCardInfo* card, ViaCardInfo* viac ) {
+ viac->mapBase = (VOL8*) KdMapDevice( VIA_REG_BASE( card ),
+ VIA_REG_SIZE( card ) );
+
+ if( !viac->mapBase ) {
+ ErrorF( "Couldn't allocate viac->mapBase\n" );
+ return FALSE;
+ }
+
+ KdSetMappedMode( VIA_REG_BASE( card ), VIA_REG_SIZE( card ),
+ KD_MAPPED_MODE_REGISTERS );
+
+ /*
+ ** Enable extended IO space
+ */
+ VGAOUT8( 0x3C4, 0x10 );
+ VGAOUT8( 0x3C5, 0x01 );
+
+ return TRUE;
+}
+
+/*
+** void viaUnmapReg( KdCardInfo* card, ViaCardInfo* viac )
+**
+** Description:
+** Unmap the the chip's registers.
+**
+** Arguments:
+** card the card information
+** viac the VIA-driver specific card information
+**
+** Return:
+** None.
+*/
+void
+viaUnmapReg( KdCardInfo* card, ViaCardInfo* viac ) {
+ if( !viac->mapBase ) return;
+
+ KdResetMappedMode( VIA_REG_BASE( card ), VIA_REG_SIZE( card ),
+ KD_MAPPED_MODE_REGISTERS );
+ KdUnmapDevice( (void*) viac->mapBase, VIA_REG_SIZE( card ) );
+ viac->mapBase = 0;
+}
+
+KdCardFuncs viaFuncs = {
+ viaCardInit, /* cardinit */
+ viaScreenInit, /* scrinit */
+ viaInitScreen, /* initScreen */
+ viaFinishInitScreen, /* finishInitScreen */
+ viaCreateResources, /* createRes */
+ viaPreserve, /* preserve */
+ viaEnable, /* enable */
+ vesaDPMS, /* dpms */
+ viaDisable, /* disable */
+ viaRestore, /* restore */
+ viaScreenFini, /* scrfini */
+ viaCardFini, /* cardfini */
+
+ 0, /* initCursor */
+ 0, /* enableCursor */
+ 0, /* disableCursor */
+ 0, /* finiCursor */
+ 0, /* recolorCursor */
+
+ viaDrawInit, /* initAccel */
+ viaDrawEnable, /* enableAccel */
+ viaDrawDisable, /* disableAccel */
+ viaDrawFini, /* finiAccel */
+
+ vesaGetColors, /* getColors */
+ vesaPutColors, /* putColors */
+};
+
diff --git a/xorg-server/hw/kdrive/via/via.h b/xorg-server/hw/kdrive/via/via.h
new file mode 100644
index 000000000..00f40bc04
--- /dev/null
+++ b/xorg-server/hw/kdrive/via/via.h
@@ -0,0 +1,129 @@
+/*
+ * Copyright © 2004 Ralph Thomas
+ *
+ * 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 Ralph Thomas not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Ralph Thomas makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * RALPH THOMAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL RALPH THOMAS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+** VIA CLE266 driver
+** Copyright 2004 (C) Ralph Thomas <ralpht@gmail.com>
+**
+** http://www.viatech.com.tw/
+*/
+
+#ifndef _VIA_H_
+#define _VIA_H_
+
+#include <vesa.h>
+#include <klinux.h>
+
+/*
+** Define DebugF so that we can spot debug statements easily.
+*/
+#define DebugF ErrorF
+
+typedef volatile CARD8 VOL8;
+typedef volatile CARD16 VOL16;
+typedef volatile CARD32 VOL32;
+
+/*
+** These macros provide access to data on the card. The VIA graphics chips
+** are only available on IA-32 architecture, so PCI address space and CPU
+** address space are always the same (hence accesses can be performed by
+** dereferencing a pointer into PCI space).
+*/
+#define MMIO_OUT32( mmio, a, v ) (*(VOL32 *)((mmio) + (a)) = (v))
+#define MMIO_IN32( mmio, a ) (*(VOL32 *)((mmio) + (a)))
+#define MMIO_OUT16( mmio, a, v ) (*(VOL16 *)((mmio) + (a)) = (v))
+#define MMIO_IN16( mmio, a ) (*(VOL16 *)((mmio) + (a)))
+#define MMIO_OUT8( mmio, a, v ) (*(VOL8 *)((mmio) + (a)) = (v))
+#define MMIO_IN8( mmio, a, v ) (*(VOL8 *)((mmio) + (a)))
+
+/*
+** VGA regisers are offset 0x8000 from the beginning of the mmap'd register
+** space.
+*/
+#define VIA_MMIO_VGABASE 0x8000
+
+/*
+** The size of the register space, used when we mmap the registers. The
+** argument "c" should be a KdCardInfo*.
+*/
+#define VIA_REG_SIZE(c) (0x9000)
+
+/*
+** The base of the register space, used when we mmap the registers. The
+** argument "c" should be a KdCardInfo*.
+*/
+#define VIA_REG_BASE(c) ((c)->attr.address[1])
+
+/*
+** Access to the mmap'd VGA registers. The VGA registers are offset from the
+** beginning of the 16M pci space by 0x8000. These macros get used just like
+** outb/inb would be used to access VGA.
+*/
+#define VGAOUT32( addr, v ) MMIO_OUT32( viac->mapBase + VIA_MMIO_VGABASE, addr, v )
+#define VGAIN32( addr ) MMIO_IN32( viac->mapBase + VIA_MMIO_VGABASE, addr )
+#define VGAOUT16( addr, v ) MMIO_OUT16( viac->mapBase + VIA_MMIO_VGABASE, addr, v )
+#define VGAIN16( addr ) MIIO_IN16( viac->mapBase + VIA_MMIO_VGABASE, addr )
+#define VGAOUT8( addr, v ) MMIO_OUT8( viac->mapBase + VIA_MMIO_VGABASE, addr, v )
+#define VGAIN8( addr ) MMIO_IN8( viac->mapBase + VIA_MMIO_VGABASE, addr )
+
+/*
+** Access to any of the registers on the chip.
+*/
+#define OUTREG32( addr, v ) MMIO_OUT32( viac->mapBase, addr, v )
+#define INREG32( addr ) MMIO_IN32( viac->mapBase, addr )
+#define OUTREG16( addr, v ) MMIO_OUT16( viac->mapBase, addr, v )
+#define INREG16( addr ) MMIO_IN16( viac->mapBase, addr )
+
+/*
+** We keep all of our chip specific data in a ViaCardInfo.
+*/
+typedef struct _viaCardInfo {
+ VesaCardPrivRec vesa; /* card info for VESA driver */
+ VOL8* mapBase; /* mmap'd registers */
+ CARD32 savedCommand; /* command to issue to GE */
+ CARD32 savedFgColor; /* color to issue to GE */
+} ViaCardInfo;
+
+/*
+** We keep all of our screen specific data in a ViaScreenInfo.
+*/
+typedef struct _viaScreenInfo {
+ VesaScreenPrivRec vesa;
+ KaaScreenInfoRec kaa;
+} ViaScreenInfo;
+
+/*
+** These function prototypes are for support functions. More infomation on each
+** function is available at the place the function is implemented, in via.c.
+*/
+Bool viaMapReg( KdCardInfo* card, ViaCardInfo* viac );
+void viaUnmapReg( KdCardInfo* card, ViaCardInfo* viac );
+void viaSetMMIO( KdCardInfo* card, ViaCardInfo* viac );
+void viaResetMMIO( KdCardInfo* card, ViaCardInfo* viac );
+
+/*
+** The viaFuncs structure gets filled with the addresses of the functions
+** that we use to talk to the graphics chip.
+*/
+extern KdCardFuncs viaFuncs;
+
+#endif
+
diff --git a/xorg-server/hw/kdrive/via/via_regs.h b/xorg-server/hw/kdrive/via/via_regs.h
new file mode 100644
index 000000000..2d8195d5d
--- /dev/null
+++ b/xorg-server/hw/kdrive/via/via_regs.h
@@ -0,0 +1,154 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+/*************************************************************************
+ *
+ * File: via_regs.h
+ * Content: The defines of Via registers
+ *
+ ************************************************************************/
+
+#ifndef _VIA_REGS_H_
+#define _VIA_REGS_H_
+
+/* defines for VIA 2D registers */
+#define VIA_REG_GECMD 0x000
+#define VIA_REG_GEMODE 0x004
+#define VIA_REG_GESTATUS 0x004 /* as same as VIA_REG_GEMODE */
+#define VIA_REG_SRCPOS 0x008
+#define VIA_REG_DSTPOS 0x00C
+#define VIA_REG_LINE_K1K2 0x008
+#define VIA_REG_LINE_XY 0x00C
+#define VIA_REG_DIMENSION 0x010 /* width and height */
+#define VIA_REG_PATADDR 0x014
+#define VIA_REG_FGCOLOR 0x018
+#define VIA_REG_DSTCOLORKEY 0x018 /* as same as VIA_REG_FG */
+#define VIA_REG_BGCOLOR 0x01C
+#define VIA_REG_SRCCOLORKEY 0x01C /* as same as VIA_REG_BG */
+#define VIA_REG_CLIPTL 0x020 /* top and left of clipping */
+#define VIA_REG_CLIPBR 0x024 /* bottom and right of clipping */
+#define VIA_REG_OFFSET 0x028
+#define VIA_REG_LINE_ERROR 0x028
+#define VIA_REG_KEYCONTROL 0x02C /* color key control */
+#define VIA_REG_SRCBASE 0x030
+#define VIA_REG_DSTBASE 0x034
+#define VIA_REG_PITCH 0x038 /* pitch of src and dst */
+#define VIA_REG_MONOPAT0 0x03C
+#define VIA_REG_MONOPAT1 0x040
+#define VIA_REG_COLORPAT 0x100 /* from 0x100 to 0x1ff */
+
+
+
+/* defines for VIA video registers */
+#define VIA_REG_INTERRUPT 0x200
+#define VIA_REG_CRTCSTART 0x214
+
+
+/* defines for VIA HW cursor registers */
+#define VIA_REG_CURSOR_MODE 0x2D0
+#define VIA_REG_CURSOR_POS 0x2D4
+#define VIA_REG_CURSOR_ORG 0x2D8
+#define VIA_REG_CURSOR_BG 0x2DC
+#define VIA_REG_CURSOR_FG 0x2E0
+
+
+/* defines for VIA 3D registers */
+#define VIA_REG_STATUS 0x400
+#define VIA_REG_TRANSET 0x43C
+#define VIA_REG_TRANSPACE 0x440
+
+/* VIA_REG_STATUS(0x400): Engine Status */
+#define VIA_CMD_RGTR_BUSY 0x00000080 /* Command Regulator is busy */
+#define VIA_2D_ENG_BUSY 0x00000001 /* 2D Engine is busy */
+#define VIA_3D_ENG_BUSY 0x00000002 /* 3D Engine is busy */
+#define VIA_VR_QUEUE_BUSY 0x00020000 /* Virtual Queue is busy */
+#define VIA_BUSY (VIA_CMD_RGTR_BUSY|VIA_2D_ENG_BUSY|VIA_3D_ENG_BUSY)
+
+
+/* VIA_REG_GECMD(0x00): 2D Engine Command */
+#define VIA_GEC_NOOP 0x00000000
+#define VIA_GEC_BLT 0x00000001
+#define VIA_GEC_LINE 0x00000005
+
+#define VIA_GEC_SRC_XY 0x00000000
+#define VIA_GEC_SRC_LINEAR 0x00000010
+#define VIA_GEC_DST_XY 0x00000000
+#define VIA_GEC_DST_LINRAT 0x00000020
+
+#define VIA_GEC_SRC_FB 0x00000000
+#define VIA_GEC_SRC_SYS 0x00000040
+#define VIA_GEC_DST_FB 0x00000000
+#define VIA_GEC_DST_SYS 0x00000080
+
+#define VIA_GEC_SRC_MONO 0x00000100 /* source is mono */
+#define VIA_GEC_PAT_MONO 0x00000200 /* pattern is mono */
+
+#define VIA_GEC_MSRC_OPAQUE 0x00000000 /* mono src is opaque */
+#define VIA_GEC_MSRC_TRANS 0x00000400 /* mono src is transparent */
+
+#define VIA_GEC_PAT_FB 0x00000000 /* pattern is in frame buffer */
+#define VIA_GEC_PAT_REG 0x00000800 /* pattern is from reg setting */
+
+#define VIA_GEC_CLIP_DISABLE 0x00000000
+#define VIA_GEC_CLIP_ENABLE 0x00001000
+
+#define VIA_GEC_FIXCOLOR_PAT 0x00002000
+
+#define VIA_GEC_INCX 0x00000000
+#define VIA_GEC_DECY 0x00004000
+#define VIA_GEC_INCY 0x00000000
+#define VIA_GEC_DECX 0x00008000
+
+#define VIA_GEC_MPAT_OPAQUE 0x00000000 /* mono pattern is opaque */
+#define VIA_GEC_MPAT_TRANS 0x00010000 /* mono pattern is transparent */
+
+#define VIA_GEC_MONO_UNPACK 0x00000000
+#define VIA_GEC_MONO_PACK 0x00020000
+#define VIA_GEC_MONO_DWORD 0x00000000
+#define VIA_GEC_MONO_WORD 0x00040000
+#define VIA_GEC_MONO_BYTE 0x00080000
+
+#define VIA_GEC_LASTPIXEL_ON 0x00000000
+#define VIA_GEC_LASTPIXEL_OFF 0x00100000
+#define VIA_GEC_X_MAJOR 0x00000000
+#define VIA_GEC_Y_MAJOR 0x00200000
+#define VIA_GEC_QUICK_START 0x00800000
+
+
+/* VIA_REG_GEMODE(0x04): GE mode */
+#define VIA_GEM_8bpp 0x00000000
+#define VIA_GEM_16bpp 0x00000100
+#define VIA_GEM_32bpp 0x00000300
+
+#define VIA_GEM_640 0x00000000 /* 640*480 */
+#define VIA_GEM_800 0x00000400 /* 800*600 */
+#define VIA_GEM_1024 0x00000800 /* 1024*768 */
+#define VIA_GEM_1280 0x00000C00 /* 1280*1024 */
+#define VIA_GEM_1600 0x00001000 /* 1600*1200 */
+#define VIA_GEM_2048 0x00001400 /* 2048*1536 */
+
+/* VIA_REG_PITCH(0x38): Pitch Setting */
+#define VIA_PITCH_ENABLE 0x80000000
+
+#endif /* _VIA_REGS_H_ */
diff --git a/xorg-server/hw/kdrive/via/viadraw.c b/xorg-server/hw/kdrive/via/viadraw.c
new file mode 100644
index 000000000..a6544ee36
--- /dev/null
+++ b/xorg-server/hw/kdrive/via/viadraw.c
@@ -0,0 +1,499 @@
+/*
+ * Copyright © 2004 Ralph Thomas
+ *
+ * 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 Ralph Thomas not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Ralph Thomas makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * RALPH THOMAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL RALPH THOMAS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+** VIA CLE266 driver
+** Copyright 2004 (C) Ralph Thomas <ralpht@gmail.com>
+**
+** http://www.viatech.com.tw/
+**
+** This code is for accelerated drawing of solids and accelerated
+** copies. Note that there is currently no software FIFO implemented,
+** and no documentation on any hardware FIFO.
+*/
+
+#include "via.h"
+#include "viadraw.h"
+#include "via_regs.h"
+#include <sched.h>
+#include "kdrive.h"
+#include "kaa.h"
+
+/*
+** A global to contain card information between calls into this file.
+** XXX: This is totally brain-damaged. Why don't I get the information
+** I want in viaSolid/viaCopy/viaDoneXXX?
+*/
+static ViaCardInfo* card;
+
+/*
+** Translation table from GC raster operation values into ROP3 values
+** that the VIA chip understands.
+**
+** viaPatternRop is used by viaPrepareSolid.
+** viaCopyRop is used by viaPrepareCopy.
+*/
+CARD8 viaPatternRop[16] = {
+ /* GXclear */ 0x00, /* ROP_0 0 */
+ /* GXand */ 0xA0, /* ROP_DPa src AND dst */
+ /* GXandReverse */ 0x50, /* ROP_PDna src AND NOT dst */
+ /* GXcopy */ 0xF0, /* ROP_P src */
+ /* GXandInverted*/ 0x0A, /* ROP_DPna NOT src AND dst */
+ /* GXnoop */ 0xAA, /* ROP_D dst */
+ /* GXxor */ 0x5A, /* ROP_DPx src XOR dst */
+ /* GXor */ 0xFA, /* ROP_DPo src OR dst */
+ /* GXnor */ 0x05, /* ROP_DPon NOT src AND NOT dst */
+ /* GXequiv */ 0xA5, /* ROP_PDxn NOT src XOR dst */
+ /* GXinvert */ 0x55, /* ROP_Dn NOT dst */
+ /* GXorReverse */ 0xF5, /* ROP_PDno src OR NOT dst */
+ /* GXcopyInverted*/ 0x0F, /* ROP_Pn NOT src */
+ /* GXorInverted */ 0xAF, /* ROP_DPno NOT src OR dst */
+ /* GXnand */ 0x5F, /* ROP_DPan NOT src OR NOT dst */
+ /* GXset */ 0xFF, /* ROP_1 1 */
+};
+
+CARD8 viaCopyRop[16] = {
+ /* GXclear */ 0x00, /* ROP_0 0 */
+ /* GXand */ 0x88, /* ROP_DSa src AND dst */
+ /* GXandReverse */ 0x44, /* ROP_SDna src AND NOT dst */
+ /* GXcopy */ 0xCC, /* ROP_S src */
+ /* GXandInverted*/ 0x22, /* ROP_DSna NOT src AND dst */
+ /* GXnoop */ 0xAA, /* ROP_D dst */
+ /* GXxor */ 0x66, /* ROP_DSx src XOR dst */
+ /* GXor */ 0xEE, /* ROP_DSo src OR dst */
+ /* GXnor */ 0x11, /* ROP_DSon NOT src AND NOT dst */
+ /* GXequiv */ 0x99, /* ROP_DSxn NOT src XOR dst */
+ /* GXinvert */ 0x55, /* ROP_Dn NOT dst */
+ /* GXorReverse */ 0xDD, /* ROP_SDno src OR NOT dst */
+ /* GXcopyInverted*/ 0x33, /* ROP_Sn NOT src */
+ /* GXorInverted */ 0xBB, /* ROP_DSno NOT src OR dst */
+ /* GXnand */ 0x77, /* ROP_DSan NOT src OR NOT dst */
+ /* GXset */ 0xFF, /* ROP_1 1 */
+};
+
+/*
+** void viaWaitIdle( ViaCardInfo* viac )
+**
+** Description:
+** Block up the CPU while waiting for the last command sent to
+** the chip to complete. As an experiment I'm going to try to
+** yield my process to others instead of just tight looping.
+**
+** Arguments:
+** viac VIA-driver specific chip information
+**
+** Return:
+** None.
+*/
+void
+viaWaitIdle( ViaCardInfo* viac ) {
+ while( INREG32( VIA_REG_STATUS ) & VIA_BUSY )
+ sched_yield();
+}
+
+/*
+** void viaDrawSync( ScreenPtr pScreen, int marker )
+**
+** Description:
+** Block until the graphics chip has finished all outstanding drawing
+** operations and the framebuffer contents is static.
+**
+** Arguments:
+** pScreen Pointer to screen strucutre for the screen we're
+** waiting for drawing to end on.
+**
+** Return:
+** None.
+*/
+static void
+viaWaitMarker( ScreenPtr pScreen, int marker ) {
+ KdScreenPriv( pScreen );
+ ViaCardInfo* viac = pScreenPriv->card->driver;
+
+ viaWaitIdle( viac );
+}
+
+
+/*
+** Bool viaPrepareSolid( PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg )
+**
+** Description:
+** Decide if the specified solid fill operation can be accelerated or not,
+** and if the fill can be accelerated, prepare the hardware for doing it.
+**
+** Arguments:
+** pPixmap Pixmap to draw solid into.
+** alu Raster operation to draw using, these are the same
+** values which get set by XSetFunction(3X). See the
+** Xlib PM p. 140 for a list of raster operations as
+** well as descriptions.
+** planemask This is the GC plane mask. We only copy bits which
+** match the plane mask.
+** fg The foreground pixel of the GC, the pixel to draw in.
+**
+** Return:
+** TRUE This operation can be accelerated, call viaSolid to actually
+** have it drawn.
+** FALSE This operation cannot be accelerated, fall back to software.
+**
+** See Also:
+** viaSolid - the function which actually draws the solid.
+*/
+static Bool
+viaPrepareSolid( PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg ) {
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ KdScreenPriv( pScreen );
+ ViaCardInfo* viac = pScreenPriv->card->driver;
+
+ /*
+ ** We don't accelerate when the plane mask is not everything.
+ */
+ if( ~planeMask & FbFullMask( pPixmap->drawable.depth ) ) return FALSE;
+
+ /*
+ ** Compose the command, then store the composed command and color
+ ** in the viac structure so that when viaSolid gets called we can
+ ** write them out.
+ */
+ viac->savedCommand = VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT |
+ (viaPatternRop[alu] << 24);
+ viac->savedFgColor = fg;
+
+ /*
+ ** Store pointer to chip information, due to brain-damaged KAA.
+ */
+ card = viac;
+
+ return TRUE;
+}
+
+/*
+** void viaSolid( int x1, int y1, int x2, int y2 )
+**
+** Description:
+** Perform a solid fill, using the data that was stored by viaPrepareSolid.
+**
+** Arguments:
+** x1 x-coordinate of fill origin
+** y1 y-coordinate of fill origin
+** x2 x-coordinate of fill end point
+** y2 y-coordinate of fill end point
+**
+** Return:
+** None.
+**
+** See Also:
+** viaPrepareSolid - the function that composes the GE command and saves
+** the color for us.
+*/
+static void
+viaSolid( int x1, int y1, int x2, int y2 ) {
+ ViaCardInfo* viac = card;
+ int w = x2 - x1; int h = y2 - y1;
+
+ if( !viac ) return;
+ if( !w || !h ) return;
+
+ /*
+ ** Wait for the card to finish the current draw.
+ */
+ viaWaitIdle( viac );
+
+ /*
+ ** Do the draw.
+ */
+ OUTREG32( VIA_REG_DSTPOS, ((y1 << 16) | x1) );
+ OUTREG32( VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)) );
+ OUTREG32( VIA_REG_FGCOLOR, viac->savedFgColor );
+ OUTREG32( VIA_REG_GECMD, viac->savedCommand );
+}
+
+/*
+** void viaDoneSolid
+**
+** Description:
+** Finish up drawing of the solid.
+**
+** Arguments:
+** None.
+**
+** Return:
+** None.
+*/
+static void
+viaDoneSolid(void) {
+}
+
+/*
+** Bool viaPrepareCopy( PixmapPtr pSrcPixmap, PixmapPtr pDestPixmap, int dx,
+** int dy, int alu, Pixel planeMask )
+**
+** Description:
+** Set up the VIA chip for a BitBlt.
+**
+** Arguments:
+** pSrcPixmap the source pixmap to copy from
+** pDestPixmap the destination pixmap to copy to
+** dx direction of copy in x
+** dy direction of copy in y
+** alu Raster operation to draw using, these are the same
+** values which get set by XSetFunction(3X). See the
+** Xlib PM p. 140 for a list of raster operations as
+** well as descriptions.
+** planeMask This is the GC plane mask. We only copy bits which
+** match the plane mask.
+**
+** Return:
+** TRUE the requested copy operation can be accelerated using hardware,
+** call viaCopy next.
+** FALSE the requested copy operation cannot be accelerated using
+** hardware - fallback to software.
+**
+** See Also:
+** viaCopy - the function which does the actual copy.
+*/
+static Bool
+viaPrepareCopy( PixmapPtr pSrcPixmap, PixmapPtr pDestPixmap, int dx, int dy,
+ int alu, Pixel planeMask ) {
+ ScreenPtr pScreen = pDestPixmap->drawable.pScreen;
+ KdScreenPriv( pScreen );
+ ViaCardInfo* viac = pScreenPriv->card->driver;
+
+ /*
+ ** Don't accelerate when the plane mask is set.
+ */
+ if( ~planeMask & FbFullMask( pDestPixmap->drawable.depth ) ) return FALSE;
+
+ viac->savedCommand = VIA_GEC_BLT | (viaCopyRop[alu] << 24);
+
+ if( dx < 0 ) viac->savedCommand |= VIA_GEC_DECX;
+ if( dy < 0 ) viac->savedCommand |= VIA_GEC_DECY;
+
+ /*
+ ** Store pointer to chip structure, due to brain-damaged KAA.
+ */
+ card = viac;
+
+ return TRUE;
+}
+
+/*
+** void viaCopy( int srcX, int srcY, int dstX, int dstY, int w, int h )
+**
+** Description:
+** Perform a BitBlt from one screen area to another.
+**
+** Arguments:
+** srcX source x-coordinate
+** srcY source y-coordinate
+** dstX destination x-coordinate
+** dstY destination y-coordinate
+** w width of area to copy (pixels)
+** h height of area to copy (pixels)
+**
+** Return:
+** None.
+**
+** See Also:
+** viaPrepareCopy - the function which sets up for the copy.
+*/
+static void
+viaCopy( int srcX, int srcY, int dstX, int dstY, int w, int h ) {
+ ViaCardInfo* viac = card;
+
+ if( !viac ) return;
+ if( !w | !h ) return;
+
+ /*
+ ** XXX: Check these two "if"s out.
+ */
+ if( viac->savedCommand & VIA_GEC_DECX ) {
+ srcX += ( w - 1 );
+ dstX += ( w - 1 );
+ }
+
+ if( viac->savedCommand & VIA_GEC_DECY ) {
+ srcY += ( h - 1 );
+ dstY += ( h - 1 );
+ }
+
+ OUTREG32( VIA_REG_SRCPOS, ((srcY << 16) | srcX) );
+ OUTREG32( VIA_REG_DSTPOS, ((dstY << 16) | dstX) );
+ OUTREG32( VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)) );
+ OUTREG32( VIA_REG_GECMD, viac->savedCommand );
+}
+
+/*
+** void viaDoneCopy()
+**
+** Description:
+** Finish up the copy.
+**
+** Arguments:
+** None.
+**
+** Return:
+** None.
+*/
+static void
+viaDoneCopy(void) {
+}
+
+
+/*
+** Bool viaDrawInit( ScreenPtr pScreen )
+**
+** Description:
+** Initialize the 2D acceleration hardware and register the KAA
+** acceleration layer with the VIA acceleration functions (above).
+**
+** Arguments:
+** pScreen Pointer to screen structure for the screen we're
+** enabling acceleration on.
+**
+** Return:
+** TRUE initialization and setup of KAA acceleration was successful.
+** FALSE initialization and setup of KAA acceleration failed.
+*/
+Bool
+viaDrawInit( ScreenPtr pScreen ) {
+ KdScreenPriv( pScreen );
+ ViaCardInfo* viac = pScreenPriv->card->driver;
+ ViaScreenInfo* vias = pScreenPriv->card->driver;
+ CARD32 geMode = 0;
+
+ if( !viac ) return FALSE;
+ DebugF( "viac->mapBase = 0x%x\n", viac->mapBase );
+
+ /*
+ ** We reset the 2D engine to a known state by setting all of it's
+ ** registers to zero.
+ */
+ OUTREG32( VIA_REG_GEMODE, 0x0 );
+ OUTREG32( VIA_REG_SRCPOS, 0x0 );
+ OUTREG32( VIA_REG_DSTPOS, 0x0 );
+ OUTREG32( VIA_REG_DIMENSION, 0x0 );
+ OUTREG32( VIA_REG_PATADDR, 0x0 );
+ OUTREG32( VIA_REG_FGCOLOR, 0x0 );
+ OUTREG32( VIA_REG_BGCOLOR, 0x0 );
+ OUTREG32( VIA_REG_CLIPTL, 0x0 );
+ OUTREG32( VIA_REG_CLIPBR, 0x0 );
+ OUTREG32( VIA_REG_OFFSET, 0x0 );
+ OUTREG32( VIA_REG_KEYCONTROL, 0x0 );
+ OUTREG32( VIA_REG_SRCBASE, 0x0 );
+ OUTREG32( VIA_REG_DSTBASE, 0x0 );
+ OUTREG32( VIA_REG_PITCH, 0x0 );
+ OUTREG32( VIA_REG_MONOPAT0, 0x0 );
+ OUTREG32( VIA_REG_MONOPAT1, 0x0 );
+
+ /*
+ ** Set the GE mode up.
+ ** XXX: What happens in 24bpp mode?
+ */
+ switch( pScreenPriv->screen->fb[0].bitsPerPixel ) {
+ case 16:
+ geMode = VIA_GEM_16bpp;
+ break;
+ case 32:
+ geMode = VIA_GEM_32bpp;
+ break;
+ default:
+ geMode = VIA_GEM_8bpp;
+ break;
+ }
+
+ OUTREG32( VIA_REG_GEMODE, geMode );
+
+ /*
+ ** Set the source and destination base addresses, and set pitch.
+ */
+ OUTREG32( VIA_REG_SRCBASE, 0x0 );
+ OUTREG32( VIA_REG_DSTBASE, 0x0 );
+ OUTREG32( VIA_REG_PITCH, VIA_PITCH_ENABLE |
+ ((pScreen->width * pScreenPriv->screen->fb[0].bitsPerPixel >> 3) >> 3) |
+ (((pScreen->width * pScreenPriv->screen->fb[0].bitsPerPixel >> 3) >> 3) << 16));
+
+ DebugF( "Initialized 2D engine!\n" );
+
+ memset(&vias->kaa, 0, sizeof(KaaScreenInfoRec));
+ vias->kaa.waitMarker = viaWaitMarker;
+ vias->kaa.PrepareSolid = viaPrepareSolid;
+ vias->kaa.Solid = viaSolid;
+ vias->kaa.DoneSolid = viaDoneSolid;
+ vias->kaa.PrepareCopy = viaPrepareCopy;
+ vias->kaa.Copy = viaCopy;
+ vias->kaa.DoneCopy = viaDoneCopy;
+
+ return kaaDrawInit( pScreen, &vias->kaa );
+}
+
+/*
+** void viaDrawEnable( ScreenPtr pScreen )
+**
+** Description:
+** Enable accelerated drawing on the specified screen.
+**
+** Arguments:
+** pScreen Pointer to screen structure for the screen we're
+** enabling acceleration on.
+**
+** Return:
+** None.
+*/
+void
+viaDrawEnable( ScreenPtr pScreen ) {
+ kaaMarkSync( pScreen );
+}
+
+/*
+** void viaDrawDisable( ScreenPtr pScreen )
+**
+** Description:
+** Disable accelerated drawing to the specified screen.
+**
+** Arguments:
+** pScreen Pointer to screen structure for the screen we're
+** disabling acceleration on.
+**
+** Return:
+** None
+*/
+void
+viaDrawDisable( ScreenPtr pScreen ) {
+}
+
+/*
+** void viaDrawFini( ScreenPtr pScreen )
+**
+** Description:
+** Shutdown accelerated drawing and free associated strucures and
+** resources.
+**
+** Arguments:
+** pScreen Pointer to screen structure for the screen we're
+** disabling acceleration on.
+**
+** Return:
+** None.
+*/
+void
+viaDrawFini( ScreenPtr pScreen ) {
+}
diff --git a/xorg-server/hw/kdrive/via/viadraw.h b/xorg-server/hw/kdrive/via/viadraw.h
new file mode 100644
index 000000000..404923053
--- /dev/null
+++ b/xorg-server/hw/kdrive/via/viadraw.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright © 2004 Ralph Thomas
+ *
+ * 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 Ralph Thomas not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Ralph Thomas makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * RALPH THOMAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL RALPH THOMAS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+** VIA CLE266 driver
+** Copyright 2004 (C) Ralph Thomas <ralpht@gmail.com>
+**
+** http://www.viatech.com.tw/
+**
+** This header has some function prototypes for the hardware
+** accelerated drawing code in viadraw.c.
+*/
+
+#ifndef _VIA_DRAW_H_
+#define _VIA_DRAW_H_
+
+/*
+** More information on these functions is in viadraw.c.
+*/
+void viaWaitIdle( ViaCardInfo* card );
+Bool viaDrawInit( ScreenPtr pScreen );
+void viaDrawEnable( ScreenPtr pScreen );
+void viaDrawDisable( ScreenPtr pScreen );
+void viaDrawFini( ScreenPtr pScreen );
+void viaDrawSync( ScreenPtr pScreen );
+
+#endif
diff --git a/xorg-server/hw/kdrive/via/viastub.c b/xorg-server/hw/kdrive/via/viastub.c
new file mode 100644
index 000000000..1439010a9
--- /dev/null
+++ b/xorg-server/hw/kdrive/via/viastub.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright © 2004 Ralph Thomas
+ *
+ * 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 Ralph Thomas not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Ralph Thomas makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * RALPH THOMAS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL RALPH THOMAS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/*
+** VIA CLE266 driver
+** Copyright 2004 (C) Ralph Thomas <ralpht@gmail.com>
+**
+** http://www.viatech.com.tw/
+**
+** This is the stub code which links the VIA drawing code into the kdrive
+** framework.
+*/
+
+#include "via.h"
+#include <klinux.h>
+
+/*
+** void InitCard( char* name )
+**
+** Description:
+** Initialize the graphics chip. We find the chip on the PCI bus,
+** register the functions to access the chip.
+**
+** Arguments:
+** name XXX: unknown.
+**
+** Return:
+** None.
+*/
+void
+InitCard( char* name ) {
+ KdCardAttr attr;
+
+ if( LinuxFindPci( 0x1106, 0x3122, 0, &attr ) )
+ KdCardInfoAdd( &viaFuncs, &attr, 0 );
+}
+
+/*
+** void InitOutput( ScreenInfo* pScreenInfo, int argc, char** argv )
+**
+** Description:
+** Initialize I/O, or something. XXX: Or what?
+**
+** Arguments:
+** pScreenInfo XXX
+** argc command line argument count
+** argv command line arguments
+**
+** Return:
+** None.
+*/
+void
+InitOutput( ScreenInfo* pScreenInfo, int argc, char** argv ) {
+ KdInitOutput( pScreenInfo, argc, argv );
+}
+
+/*
+** void InitInput( int argc, char** argv )
+**
+** Description:
+** Initialize keyboard and mouse input.
+**
+** Arguments:
+** argc command line argument count
+** argv command line arguments
+**
+** Return:
+** None.
+*/
+void
+InitInput( int argc, char** argv ) {
+ KdOsAddInputDrivers();
+ KdInitInput();
+}
+
+/*
+** void ddxUseMsg()
+**
+** Description:
+** Print the usage message for Xvia.
+**
+** Arguments:
+** None.
+**
+** Return:
+** None.
+*/
+void
+ddxUseMsg() {
+ KdUseMsg();
+ vesaUseMsg();
+}
+
+
+/*
+** int ddxProcessArgument( int argc, char** argv, int i )
+**
+** Description:
+** Process a single command line argument.
+**
+** Arguments:
+** argc command line argument count
+** argv command line arguments
+** i number of argument to process
+**
+** Return:
+** some values.
+*/
+int
+ddxProcessArgument( int argc, char** argv, int i ) {
+ int ret;
+
+ if( !( ret = vesaProcessArgument( argc, argv, i ) ))
+ ret = KdProcessArgument( argc, argv, i );
+ return ret;
+}
+