summaryrefslogtreecommitdiff
path: root/xc/programs/Xserver/hw/xfree86
diff options
context:
space:
mode:
Diffstat (limited to 'xc/programs/Xserver/hw/xfree86')
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/agx/Bt481.c361
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/agx/Bt481.h95
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/agx/Bt485.c378
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/agx/Bt485.h96
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/8514cach.h63
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/8514im.h28
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/bcach.c91
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/blt.c873
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/bstor.c105
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/cmap.c198
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/dsline.c546
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/dsseg.c485
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/fc.c204
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/fcach.c97
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/font.c54
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/frect.c831
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/fs.c428
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/gc.c1074
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/gs.c121
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/gtimg.c83
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/im.c507
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/imfill.s429
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/imread.s259
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/imstip.s569
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/imwrite.s203
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/init.c241
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/line.c434
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/plypt.c126
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/scrin.c187
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/seg.c395
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/ss.c236
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/text.c396
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/ibm8514/win.c190
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/p9000/I2061Acal.c245
-rw-r--r--xc/programs/Xserver/hw/xfree86/accel/p9000/I2061Aset.c161
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/Mach32.c62
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/Mach64.c59
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/Mach8.c57
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c467
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c595
-rw-r--r--xc/programs/Xserver/hw/xfree86/common_hw/I2061Aalt.c249
-rw-r--r--xc/programs/Xserver/hw/xfree86/common_hw/I2061Acal.c139
-rw-r--r--xc/programs/Xserver/hw/xfree86/common_hw/I2061Aset.c142
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/install.sv3218
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/install.sv437
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/sun.tcap28
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/sun.tinfo52
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/svr3_rem_pch121
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/svr4_rem_pch120
-rw-r--r--xc/programs/Xserver/hw/xfree86/vga16/ibm/ppcPixFS.c506
-rw-r--r--xc/programs/Xserver/hw/xfree86/vga16/ibm/ppcWinFS.c290
51 files changed, 13931 insertions, 0 deletions
diff --git a/xc/programs/Xserver/hw/xfree86/accel/agx/Bt481.c b/xc/programs/Xserver/hw/xfree86/accel/agx/Bt481.c
new file mode 100644
index 000000000..2676531fc
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/agx/Bt481.c
@@ -0,0 +1,361 @@
+/* $XConsortium: $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/agx/Bt481.c,v 3.2 1995/01/26 02:16:43 dawes Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ * Copyright 1994 by Henry A. Worth, Sunnyvale, California.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT AND HENRY A. WORTH DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE AUTHORS
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Rewritten for the AGX and BT481/2 by Henry A. Worth <haw30@eng.amdahl.com>
+ *
+ */
+
+#define NEED_EVENTS
+#include <X.h>
+#include "Xproto.h"
+#include <misc.h>
+#include <input.h>
+#include <cursorstr.h>
+#include <regionstr.h>
+#include <scrnintstr.h>
+#include <servermd.h>
+#include <windowstr.h>
+#include "xf86.h"
+#include "inputstr.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86RamDac.h"
+#include "Bt481.h"
+
+static unsigned char xf86BtYPosMask = 0xFF;
+
+#ifndef __GNUC__
+# define __inline__ /**/
+#endif
+
+/*
+ * Some registers in the Bt481, like "Command Register B",
+ * must be accessed indirectly.
+ */
+#ifdef __STDC__
+void
+xf86OutBt481IndReg( unsigned char reg,
+ unsigned char mask,
+ unsigned char data )
+#else
+void
+xf86OutBt481IndReg(reg, mask, data)
+ unsigned char reg;
+ unsigned char mask;
+ unsigned char data;
+#endif
+{
+ unsigned char tmp;
+
+ tmp = xf86InRamDacReg(BT481_COMMAND_REG_A) & 0xFE;
+ xf86OutRamDacData(BT481_COMMAND_REG_A, 0x01);
+ xf86OutRamDacData(BT481_WRITE_ADDR, reg);
+ xf86OutRamDacReg(BT481_PIXEL_MASK, mask, data);
+ xf86OutRamDacData(BT481_COMMAND_REG_A, tmp);
+}
+
+#ifdef __STDC__
+unsigned char
+xf86InBt481IndReg( unsigned char reg )
+#else
+unsigned char
+xf86InBt481IndReg(reg)
+ unsigned char reg;
+#endif
+{
+ unsigned char ret;
+ unsigned char tmp;
+
+ tmp = xf86InRamDacReg(BT481_COMMAND_REG_A) & 0xFE;
+ xf86OutRamDacData(BT481_COMMAND_REG_A, 0x01);
+ xf86OutRamDacData(BT481_WRITE_ADDR, reg);
+ ret = xf86InRamDacReg(BT481_PIXEL_MASK);
+ xf86OutRamDacData(BT481_COMMAND_REG_A, tmp);
+ return(ret);
+}
+
+#ifdef __STDC__
+void
+xf86Bt481HWSave( union xf86RamDacSave * save )
+#else
+void
+xf86Bt481HWSave( save )
+ union xf86RamDacSave *save;
+#endif
+{
+ save->Bt481.ComA = xf86InRamDacReg( BT481_COMMAND_REG_A );
+ save->Bt481.ComB = xf86InBt481IndReg( BT481_COMMAND_REG_B );
+}
+
+#ifdef __STDC__
+void
+xf86Bt481HWRestore( union xf86RamDacSave * save )
+#else
+void
+xf86Bt481HWRestore( save )
+ union xf86RamDacSave *save;
+#endif
+{
+ xf86OutBt481IndReg( BT481_COMMAND_REG_B, 0x00, save->Bt481.ComB );
+ xf86OutRamDacData( BT481_COMMAND_REG_A, save->Bt481.ComA );
+}
+
+#ifdef __STDC__
+void
+xf86Bt481Init( void )
+#else
+void
+xf86Bt481Init()
+#endif
+{
+ xf86OutRamDacData( BT481_COMMAND_REG_A, 0x00 );
+ xf86OutBt481IndReg( BT481_COMMAND_REG_B, 0x7E, 0x00 ); /* powerup */
+
+ if (xf86Dac8Bit)
+ xf86OutBt481IndReg( BT481_COMMAND_REG_B, 0x7C, 0x2 );
+ else
+ xf86OutBt481IndReg( BT481_COMMAND_REG_B, 0x7C, 0x0 );
+
+ if (xf86DacSyncOnGreen)
+ xf86OutBt481IndReg( BT481_COMMAND_REG_B, 0x73, 0x4 );
+ else
+ xf86OutBt481IndReg( BT481_COMMAND_REG_B, 0x73, 0x0 );
+
+}
+
+/*
+ * Convert the cursor from server-format to hardware-format. The Bt482
+ * has two planes, output sequentially.
+ */
+Bool
+xf86Bt482RealizeCursor(pScr, pCurs)
+ ScreenPtr pScr;
+ CursorPtr pCurs;
+{
+ extern unsigned char xf86SwapBits[256];
+ register int i, j;
+ unsigned char *pServMsk;
+ unsigned char *pServSrc;
+ int index = pScr->myNum;
+ pointer *pPriv = &pCurs->bits->devPriv[index];
+ int wsrc, h;
+ unsigned char *ram, *plane0, *plane1;
+ CursorBitsPtr bits = pCurs->bits;
+
+ if (pCurs->bits->refcnt > 1)
+ return TRUE;
+
+ ram = (unsigned char *)xalloc(1024);
+ *pPriv = (pointer) ram;
+ plane0 = ram;
+ plane1 = ram+512;
+
+ if (!ram)
+ return FALSE;
+
+ pServSrc = (unsigned char *)bits->source;
+ pServMsk = (unsigned char *)bits->mask;
+
+ h = bits->height;
+ if (h > xf86MaxCurs)
+ h = xf86MaxCurs;
+
+ wsrc = PixmapBytePad(bits->width, 1); /* bytes per line */
+
+ for (i = 0; i < xf86MaxCurs; i++) {
+ for (j = 0; j < xf86MaxCurs / 8; j++) {
+ unsigned char mask, source;
+
+ if (i < h && j < wsrc) {
+ source = *pServSrc++;
+ mask = *pServMsk++;
+
+ source = xf86SwapBits[source];
+ mask = xf86SwapBits[mask];
+
+ if (j < xf86MaxCurs / 8) {
+ *plane0++ = source & mask;
+ *plane1++ = mask;
+ }
+ } else {
+ *plane0++ = 0x00;
+ *plane1++ = 0x00;
+ }
+ }
+ /*
+ * if we still have more bytes on this line (j < wsrc),
+ * we have to ignore the rest of the line.
+ */
+ while (j++ < wsrc) pServMsk++,pServSrc++;
+ }
+ return TRUE;
+}
+
+
+void
+xf86Bt482CursorOn()
+{
+ /* Enable cursor mode 3 - X11 mode */
+ xf86OutBt481IndReg(BT482_CURSOR_REG, 0xFC, 0x03);
+
+ return;
+}
+
+void
+xf86Bt482CursorOff()
+{
+ /* Disable cursor */
+ xf86OutBt481IndReg(BT482_CURSOR_REG, 0xFC, 0x00);
+
+ return;
+}
+
+void
+xf86Bt482MoveCursor(pScr, x, y)
+ ScreenPtr pScr;
+ int x, y;
+{
+ extern int xf86hotX, xf86hotY;
+
+ if (!xf86VTSema)
+ return;
+
+ x -= xf86FrameX0;
+ x += xf86MaxCurs;
+ x -= xf86hotX;
+ if (x < 0)
+ return;
+
+ y -= xf86FrameY0;
+ y += xf86MaxCurs;
+ y -= xf86hotY;
+ if (y < 0)
+ return;
+
+ /* Output position - "only" 12 bits of location documented */
+ xf86OutBt481IndReg(BT482_CURS_X_LOW, 0x00, x & 0xFF);
+ xf86OutBt481IndReg(BT482_CURS_X_HIGH, 0x00, (x >> 8) & 0x0F);
+ xf86OutBt481IndReg(BT482_CURS_Y_LOW, 0x00, y & xf86BtYPosMask);
+ xf86OutBt481IndReg(BT482_CURS_Y_HIGH, 0x00, (y >> 8) & 0x0F);
+
+ return;
+}
+
+void
+xf86Bt482RecolorCursor(pScr, pCurs)
+ ScreenPtr pScr;
+ CursorPtr pCurs;
+{
+ /* Start writing at address 1 (0 is overscan color) */
+ xf86OutBt481IndReg(BT482_CURSOR_REG, 0xF7, 0x00);
+ xf86OutRamDacData(BT482_CURS_WR_ADDR, 0x01);
+
+ /* Background color */
+ xf86OutRamDacData(BT482_CURS_RAM_DATA, (pCurs->backRed >> 8) & 0xFF);
+ xf86OutRamDacData(BT482_CURS_RAM_DATA, (pCurs->backGreen >> 8) & 0xFF);
+ xf86OutRamDacData(BT482_CURS_RAM_DATA, (pCurs->backBlue >> 8) & 0xFF);
+
+ /* Foreground color */
+ xf86OutRamDacData(BT482_CURS_RAM_DATA, (pCurs->foreRed >> 8) & 0xFF);
+ xf86OutRamDacData(BT482_CURS_RAM_DATA, (pCurs->foreGreen >> 8) & 0xFF);
+ xf86OutRamDacData(BT482_CURS_RAM_DATA, (pCurs->foreBlue >> 8) & 0xFF);
+
+ return;
+}
+
+void
+xf86Bt482LoadCursor(pScr, pCurs, modesFlags, x, y)
+ ScreenPtr pScr;
+ CursorPtr pCurs;
+ int modesFlags;
+ int x, y;
+{
+ int index = pScr->myNum;
+ register int i, j;
+ unsigned char *ram, *p;
+ unsigned char bytesPerRow = xf86MaxCurs >> 3;
+
+ if (!xf86VTSema)
+ return;
+
+ if (!pCurs)
+ return;
+
+ /* turn the cursor off */
+ xf86Bt482CursorOff();
+
+ /* load colormap */
+ xf86Bt482RecolorCursor(pScr, pCurs);
+
+ ram = (unsigned char *)pCurs->bits->devPriv[index];
+
+ if (modesFlags & V_INTERLACE) {
+ /* Start data output */
+ xf86OutBt481IndReg(BT482_CURSOR_REG, 0xF7, 0x08);
+ xf86OutRamDacReg(BT481_WRITE_ADDR, 0x00, 0x00);
+
+ for (i=0; i < xf86MaxCurs; i++) { /* rows in cursor */
+ p = ram + (((i % 2) ? i-1 : i+1)*8);
+ for (j=0; j < bytesPerRow; j++,p++) { /* bytes per row */
+ xf86OutRamDacData(BT482_CURS_RAM_DATA, *p);
+ }
+ }
+ ram += 512;
+ for (i=0; i < xf86MaxCurs; i++) { /* rows in cursor */
+ p = ram + (((i % 2) ? i-1 : i+1)*8);
+ for (j=0; j < bytesPerRow; j++,p++) { /* bytes per row */
+ xf86OutRamDacData(BT482_CURS_RAM_DATA, *p);
+ }
+ }
+
+ xf86BtYPosMask = 0xFE;
+ xf86OutBt481IndReg(BT482_CURSOR_REG, 0xCF, 0x10);
+ } else {
+ /* Start data output */
+ xf86OutBt481IndReg(BT482_CURSOR_REG, 0xF7, 0x08);
+ xf86OutRamDacReg(BT481_WRITE_ADDR, 0x00, 0x00);
+
+ /*
+ * Output the cursor data. The realize function has put the planes into
+ * their correct order, so we can just blast this out.
+ */
+ p = ram;
+ for (i = 0; i < 1024; i++,p++)
+ xf86OutRamDacData(BT482_CURS_RAM_DATA, *p);
+
+ xf86BtYPosMask = 0xFF;
+ xf86OutBt481IndReg(BT482_CURSOR_REG, 0xCF, 0x00);
+ }
+
+ /* position cursor */
+ xf86Bt482MoveCursor(0, x, y);
+
+ /* turn the cursor on */
+ xf86Bt482CursorOn();
+
+ return;
+}
+
+
diff --git a/xc/programs/Xserver/hw/xfree86/accel/agx/Bt481.h b/xc/programs/Xserver/hw/xfree86/accel/agx/Bt481.h
new file mode 100644
index 000000000..0500e94c0
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/agx/Bt481.h
@@ -0,0 +1,95 @@
+/* $XConsortium: $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/agx/Bt481.h,v 3.0 1994/06/15 15:35:50 dawes Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ * Copyright 1994 by Henry A. Worth <haw30@eng.amdahl.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT AND HENRY A. WORTH DISCLAIM ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE AUTORS BE LIABLE
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+ * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Modified for the AGX and Bt481/2 by Henry. A. Worth
+ *
+ */
+
+#ifndef XF86_BT481_H
+#define XF86_BT481_H
+
+#include "compiler.h"
+#include <X11/Xfuncproto.h>
+
+/* directly addressed registers */
+
+#define BT481_WRITE_ADDR 0x00
+#define BT481_RAMDAC_DATA 0x01
+#define BT481_PIXEL_MASK 0x02
+#define BT481_READ_ADDR 0x03
+#define BT482_CURS_WR_ADDR 0x04
+#define BT482_CURS_RAM_DATA 0x05
+#define BT481_COMMAND_REG_A 0x06
+#define BT482_CURS_RD_ADDR 0x07
+
+/* indirectly addressed register addresses */
+
+#define BT481_IND_PIXEL_MASK 0x00
+#define BT481_OVERLAY_MASK 0x01
+#define BT481_COMMAND_REG_B 0x02
+#define BT482_CURSOR_REG 0x03
+#define BT482_CURS_X_LOW 0x04
+#define BT482_CURS_X_HIGH 0x05
+#define BT482_CURS_Y_LOW 0x06
+#define BT482_CURS_Y_HIGH 0x07
+
+_XFUNCPROTOBEGIN
+
+
+extern void xf86OutBt481IndReg(
+#if NeedFunctionPrototypes
+ unsigned char,
+ unsigned char,
+ unsigned char
+#endif
+);
+
+extern unsigned char xf86InBt481IndReg(
+#if NeedFunctionPrototypes
+ unsigned char
+#endif
+);
+
+extern void xf86Bt481HWSave(
+#if NeedFunctionPrototypes
+ union xf86RamDacSave *
+#endif
+);
+
+extern void xf86Bt481HWRestore(
+#if NeedFunctionPrototypes
+ union xf86RamDacSave *
+#endif
+);
+
+extern void xf86Bt481Init(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* XF86_BT481_H */
diff --git a/xc/programs/Xserver/hw/xfree86/accel/agx/Bt485.c b/xc/programs/Xserver/hw/xfree86/accel/agx/Bt485.c
new file mode 100644
index 000000000..21a7cf07e
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/agx/Bt485.c
@@ -0,0 +1,378 @@
+/* $XConsortium: $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/agx/Bt485.c,v 3.2 1995/01/26 02:16:46 dawes Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ * Copyright 1994 by Henry A. Worth <haw30@eng.amdahl.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT AND HENRY A. WORTH 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.
+ *
+ * Modified for the AGX server and to increase portability by Henry A. Worth
+ *
+ */
+
+#define NEED_EVENTS
+#include <X.h>
+#include "Xproto.h"
+#include <misc.h>
+#include <input.h>
+#include <cursorstr.h>
+#include <regionstr.h>
+#include <scrnintstr.h>
+#include <servermd.h>
+#include <windowstr.h>
+#include "xf86.h"
+#include "inputstr.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86RamDac.h"
+#include "Bt485.h"
+
+static unsigned char xf86BtYPosMask = 0xFF;
+
+#ifndef __GNUC__
+# define __inline__ /**/
+#endif
+
+/*
+ * The indirect registers in the Bt485, like "Command Reg 3",
+ * must be accessed by setting a bit CR0, placing the indirect
+ * registers address into the the write address register, and
+ * then reading/writeing the status register.
+ */
+#ifdef __STDC__
+void xf86OutBt485IndReg( unsigned char reg,
+ unsigned char mask,
+ unsigned char data )
+#else
+void xf86OutBt485IndReg( reg, mask, data )
+ unsigned char reg;
+ unsigned char mask;
+ unsigned char data;
+#endif
+{
+ xf86OutRamDacReg(BT485_COMMAND_REG_0, 0x7F, 0x80);
+ xf86OutRamDacData(BT485_WRITE_ADDR, reg);
+ xf86OutRamDacReg(BT485_STATUS_REG, mask, data);
+ xf86OutRamDacReg(BT485_COMMAND_REG_0, 0x7F, 0x00);
+}
+
+#ifdef __STDC__
+unsigned char
+xf86InBt485IndReg( unsigned char reg )
+#else
+unsigned char
+xf86InBt485IndReg( reg )
+ unsigned char reg;
+#endif
+{
+ unsigned char ret;
+
+ xf86OutRamDacReg(BT485_COMMAND_REG_0, 0x7F, 0x80);
+ xf86OutRamDacData(BT485_WRITE_ADDR, reg);
+ ret = xf86InRamDacReg(BT485_STATUS_REG);
+ xf86OutRamDacReg(BT485_COMMAND_REG_0, 0x7F, 0x00);
+ return(ret);
+}
+
+/*
+ * Status register may be hidden behind Command Register 3; need to check
+ * both possibilities. (is this really needed now?)
+ */
+unsigned char xf86InBt485StatReg()
+{
+ unsigned char tmp, ret;
+
+ tmp = xf86InRamDacReg(BT485_COMMAND_REG_0);
+ if ((tmp & 0x80) == 0x80) {
+ /* Behind Command Register 3 */
+ tmp = xf86InRamDacReg(BT485_WRITE_ADDR);
+ xf86OutRamDacReg(BT485_WRITE_ADDR, 0x00, 0x00);
+ ret = xf86InRamDacReg(BT485_STATUS_REG);
+ xf86OutRamDacReg(BT485_WRITE_ADDR, 0x00, tmp);
+ } else {
+ ret = xf86InRamDacReg(BT485_STATUS_REG);
+ }
+ return(ret);
+}
+
+/*
+ * Convert the cursor from server-format to hardware-format. The Bt485
+ * has two planes, output sequentially.
+ */
+Bool
+xf86Bt485RealizeCursor(pScr, pCurs)
+ ScreenPtr pScr;
+ CursorPtr pCurs;
+{
+ extern unsigned char xf86SwapBits[256];
+ register int i, j;
+ unsigned char *pServMsk;
+ unsigned char *pServSrc;
+ int index = pScr->myNum;
+ pointer *pPriv = &pCurs->bits->devPriv[index];
+ int wsrc, h;
+ unsigned char *ram, *plane0, *plane1;
+ CursorBitsPtr bits = pCurs->bits;
+
+ if (pCurs->bits->refcnt > 1)
+ return TRUE;
+
+ ram = (unsigned char *)xalloc(1024);
+ *pPriv = (pointer) ram;
+ plane0 = ram;
+ plane1 = ram+512;
+
+ if (!ram)
+ return FALSE;
+
+ pServSrc = (unsigned char *)bits->source;
+ pServMsk = (unsigned char *)bits->mask;
+
+ h = bits->height;
+ if (h > xf86MaxCurs)
+ h = xf86MaxCurs;
+
+ wsrc = PixmapBytePad(bits->width, 1); /* bytes per line */
+
+ for (i = 0; i < xf86MaxCurs; i++) {
+ for (j = 0; j < xf86MaxCurs / 8; j++) {
+ unsigned char mask, source;
+
+ if (i < h && j < wsrc) {
+ source = *pServSrc++;
+ mask = *pServMsk++;
+
+ source = xf86SwapBits[source];
+ mask = xf86SwapBits[mask];
+
+ if (j < xf86MaxCurs / 8) {
+ *plane0++ = source & mask;
+ *plane1++ = mask;
+ }
+ } else {
+ *plane0++ = 0x00;
+ *plane1++ = 0x00;
+ }
+ }
+ /*
+ * if we still have more bytes on this line (j < wsrc),
+ * we have to ignore the rest of the line.
+ */
+ while (j++ < wsrc) pServMsk++,pServSrc++;
+ }
+ return TRUE;
+}
+
+void
+xf86Bt485CursorOn()
+{
+ /* Enable cursor mode 3 - X11 mode */
+ xf86OutRamDacReg(BT485_COMMAND_REG_2, 0xFC, 0x03);
+
+ return;
+}
+
+void
+xf86Bt485CursorOff()
+{
+ /* Disable cursor */
+ xf86OutRamDacReg(BT485_COMMAND_REG_2, 0xFC, 0x00);
+
+ return;
+}
+
+void
+xf86Bt485MoveCursor(pScr, x, y)
+ ScreenPtr pScr;
+ int x, y;
+{
+ extern int xf86hotX, xf86hotY;
+
+ if (!xf86VTSema)
+ return;
+
+ x -= xf86FrameX0;
+ x += 64;
+ x -= xf86hotX;
+ if (x < 0)
+ return;
+
+ y -= xf86FrameY0;
+ y += 64;
+ y -= xf86hotY;
+ if (y < 0)
+ return;
+
+ /* Output position - "only" 12 bits of location documented */
+ xf86OutRamDacReg(BT485_CURS_X_LOW, 0x00, x & 0xFF);
+ xf86OutRamDacReg(BT485_CURS_X_HIGH, 0x00, (x >> 8) & 0x0F);
+ xf86OutRamDacReg(BT485_CURS_Y_LOW, 0x00, y & xf86BtYPosMask);
+ xf86OutRamDacReg(BT485_CURS_Y_HIGH, 0x00, (y >> 8) & 0x0F);
+
+ return;
+}
+
+void
+xf86Bt485RecolorCursor(pScr, pCurs)
+ ScreenPtr pScr;
+ CursorPtr pCurs;
+{
+ /* Start writing at address 1 (0 is overscan color) */
+ xf86OutRamDacData(BT485_CURS_WR_ADDR, 0x01);
+
+ /* Background color */
+ xf86OutRamDacData(BT485_CURS_DATA, (pCurs->backRed >> 8) & 0xFF);
+ xf86OutRamDacData(BT485_CURS_DATA, (pCurs->backGreen >> 8) & 0xFF);
+ xf86OutRamDacData(BT485_CURS_DATA, (pCurs->backBlue >> 8) & 0xFF);
+
+ /* Foreground color */
+ xf86OutRamDacData(BT485_CURS_DATA, (pCurs->foreRed >> 8) & 0xFF);
+ xf86OutRamDacData(BT485_CURS_DATA, (pCurs->foreGreen >> 8) & 0xFF);
+ xf86OutRamDacData(BT485_CURS_DATA, (pCurs->foreBlue >> 8) & 0xFF);
+
+ return;
+}
+
+void
+xf86Bt485LoadCursor(pScr, pCurs, modesFlags, x, y)
+ ScreenPtr pScr;
+ CursorPtr pCurs;
+ int modesFlags;
+ int x, y;
+{
+ int index = pScr->myNum;
+ register int i, j;
+ unsigned char *ram, *p;
+
+ if (!xf86VTSema)
+ return;
+
+ if (!pCurs)
+ return;
+
+ /* turn the cursor off */
+ xf86Bt485CursorOff();
+
+ /* load colormap */
+ xf86Bt485RecolorCursor(pScr, pCurs);
+
+ ram = (unsigned char *)pCurs->bits->devPriv[index];
+
+ /*
+ * Bit 2 == 1 ==> 64x64 cursor; 2 low-order bits are extensions to the
+ * address register, and must be cleared since we're going to start
+ * writing data at address 0.
+ */
+ xf86OutBt485IndReg(BT485_COMMAND_REG_3, 0xF8, 0x04);
+
+ if (modesFlags & V_INTERLACE) {
+ xf86OutRamDacReg(BT485_WRITE_ADDR, 0x00, 0x00);
+
+ for (i=0; i < 64; i++) { /* 64 rows in cursor */
+ p = ram + (((i % 2) ? i-1 : i+1)*8);
+ for (j=0; j < 8; j++,p++) { /* 8 bytes per row */
+ xf86OutRamDacData(BT485_CURS_RAM_DATA, *p);
+ }
+ }
+ ram += 512;
+ for (i=0; i < 64; i++) { /* 64 rows in cursor */
+ p = ram + (((i % 2) ? i-1 : i+1)*8);
+ for (j=0; j < 8; j++,p++) { /* 8 bytes per row */
+ xf86OutRamDacData(BT485_CURS_RAM_DATA, *p);
+ }
+ }
+
+ xf86BtYPosMask = 0xFE;
+ xf86OutRamDacReg(BT485_COMMAND_REG_2, 0xF7, 0x08);
+ } else {
+ /* Start data output */
+ xf86OutRamDacReg(BT485_WRITE_ADDR, 0x00, 0x00);
+
+ /*
+ * Output the cursor data. The realize function has put the planes into
+ * their correct order, so we can just blast this out.
+ */
+ p = ram;
+ for (i = 0; i < 1024; i++,p++)
+ xf86OutRamDacData(BT485_CURS_RAM_DATA, *p);
+
+ xf86BtYPosMask = 0xFF;
+ xf86OutRamDacReg(BT485_COMMAND_REG_2, 0xF7, 0x00);
+ }
+
+ /* position cursor */
+ xf86Bt485MoveCursor(0, x, y);
+
+ /* turn the cursor on */
+ xf86Bt485CursorOn();
+
+ return;
+}
+
+
+#ifdef __STDC__
+void
+xf86Bt485HWSave( union xf86RamDacSave * save )
+#else
+void
+xf86Bt485HWSave( save )
+ union xf86RamDacSave *save;
+#endif
+{
+ save->Bt485.Com0 = xf86InRamDacReg( BT485_COMMAND_REG_0 );
+ save->Bt485.Com1 = xf86InRamDacReg( BT485_COMMAND_REG_1 );
+ save->Bt485.Com2 = xf86InRamDacReg( BT485_COMMAND_REG_2 );
+ save->Bt485.Com3 = xf86InBt485IndReg( BT485_COMMAND_REG_3 );
+}
+
+#ifdef __STDC__
+void
+xf86Bt485HWRestore( union xf86RamDacSave * save )
+#else
+void
+xf86Bt485HWRestore( save )
+ union xf86RamDacSave *save;
+#endif
+{
+ xf86OutBt485IndReg( BT485_COMMAND_REG_3, 0x00, save->Bt485.Com3 );
+ xf86OutRamDacReg( BT485_COMMAND_REG_2, 0x00, save->Bt485.Com2 );
+ xf86OutRamDacReg( BT485_COMMAND_REG_1, 0x00, save->Bt485.Com1 );
+ xf86OutRamDacReg( BT485_COMMAND_REG_0, 0x00, save->Bt485.Com0 );
+}
+
+#ifdef __STDC__
+void
+xf86Bt485Init( void )
+#else
+void
+xf86Bt485Init()
+#endif
+{
+ if (xf86Dac8Bit)
+ xf86OutRamDacReg( BT485_COMMAND_REG_0, 0xFC, 0x02 );
+ else
+ xf86OutRamDacReg( BT485_COMMAND_REG_0, 0xFC, 0x00 );
+
+ if (xf86DacSyncOnGreen)
+ xf86OutRamDacReg( BT485_COMMAND_REG_0, 0xE3, 0x08 );
+ else
+ xf86OutRamDacReg( BT485_COMMAND_REG_0, 0xE3, 0x00 );
+}
+
diff --git a/xc/programs/Xserver/hw/xfree86/accel/agx/Bt485.h b/xc/programs/Xserver/hw/xfree86/accel/agx/Bt485.h
new file mode 100644
index 000000000..ed0ac3daa
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/agx/Bt485.h
@@ -0,0 +1,96 @@
+/* $XConsortium: $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/agx/Bt485.h,v 3.1 1994/09/07 15:47:44 dawes Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ * Copyright 1994 by Henry A. Worth <haw30@eng.amdahl.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT AND HENRY A. WORTH 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.
+ *
+ * Modified for the AGX by Henry A. Worth
+ *
+ */
+
+#include "compiler.h"
+#include <X11/Xfuncproto.h>
+
+/* Directly Accessable RamDac Registers */
+
+#define BT485_WRITE_ADDR 0x00
+#define BT485_RAMDAC_DATA 0x01
+#define BT485_PIXEL_MASK 0x02
+#define BT485_READ_ADDR 0x03
+#define BT485_CURS_WR_ADDR 0x04
+#define BT485_CURS_DATA 0x05
+#define BT485_COMMAND_REG_0 0x06
+#define BT485_CURS_RD_ADDR 0x07
+#define BT485_COMMAND_REG_1 0x08
+#define BT485_COMMAND_REG_2 0x09
+#define BT485_STATUS_REG 0x0A
+#define BT485_CURS_RAM_DATA 0x0B
+#define BT485_CURS_X_LOW 0x0C
+#define BT485_CURS_X_HIGH 0x0D
+#define BT485_CURS_Y_LOW 0x0E
+#define BT485_CURS_Y_HIGH 0x0F
+
+/* Indirectly Accessable RamDac Registers */
+
+#define BT485_COMMAND_REG_3 0x01
+
+_XFUNCPROTOBEGIN
+
+extern void xf86OutBt485IndReg(
+#if NeedFunctionPrototypes
+ unsigned char,
+ unsigned char,
+ unsigned char
+#endif
+);
+
+extern unsigned char xf86InBt485IndReg(
+#if NeedFunctionPrototypes
+ unsigned char
+#endif
+);
+
+extern unsigned char xf86InBt485StatReg(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern void xf86Bt485HWSave(
+#if NeedFunctionPrototypes
+ union xf86RamDacSave *
+#endif
+);
+
+extern void xf86Bt485HWRestore(
+#if NeedFunctionPrototypes
+ union xf86RamDacSave *
+#endif
+);
+
+extern void xf86Bt485Init(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+_XFUNCPROTOEND
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/8514cach.h b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/8514cach.h
new file mode 100644
index 000000000..aef55c44d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/8514cach.h
@@ -0,0 +1,63 @@
+/* $XConsortium: ibm8514cach.h,v 1.1 94/03/28 21:03:26 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/ibm8514/8514cach.h,v 3.1 1994/09/07 15:48:24 dawes Exp $ */
+void ibm8514GlyphWrite(
+#if NeedFunctionPrototypes
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ unsigned char */*chars*/,
+ CacheFont8Ptr /*fentry*/,
+ GCPtr /*pGC*/,
+ BoxPtr /*pBox*/,
+ int /*numRects*/
+#endif
+);
+
+int ibm8514NoCPolyText(
+#if NeedFunctionPrototypes
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ char */*chars*/,
+ Bool /*is8bit*/
+#endif
+);
+
+int ibm8514NoCImageText(
+#if NeedFunctionPrototypes
+ DrawablePtr /*pDraw*/,
+ GCPtr /*pGC*/,
+ int /*x*/,
+ int /*y*/,
+ int /*count*/,
+ char */*chars*/,
+ Bool /*is8bit*/
+#endif
+);
+
+void ibm8514CacheMoveBlock(
+#if NeedFunctionPrototypes
+ int /*srcx*/,
+ int /*srcy*/,
+ int /*dstx*/,
+ int /*dsty*/,
+ int /*h*/,
+ int /*len*/,
+ unsigned int /*id*/
+#endif
+);
+
+
+void ibm8514FontOpStipple(
+#if NeedFunctionPrototypes
+ int /*x*/,
+ int /*y*/,
+ int /*w*/,
+ int /*h*/,
+ unsigned char */*psrc*/,
+ int /*pwidth*/,
+ Pixel /*id*/
+#endif
+);
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/8514im.h b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/8514im.h
new file mode 100644
index 000000000..b1e139bba
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/8514im.h
@@ -0,0 +1,28 @@
+/* $XConsortium: ibm8514im.h,v 1.1 94/03/28 21:04:48 dpw Exp $ */
+/*
+ * Copyright 1992 by Kevin E. Martin, Chapel Hill, North Carolina.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Kevin E. Martin not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Kevin E. Martin makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * KEVIN E. MARTIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEVIN E. MARTIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER 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 modulus
+#define modulus(a,b,d) if (((d) = (a) % (b)) < 0) (d) += (b)
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/bcach.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/bcach.c
new file mode 100644
index 000000000..e3718fee7
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/bcach.c
@@ -0,0 +1,91 @@
+/* $XConsortium: ibm8514bc.c,v 1.1 94/03/28 21:03:08 dpw Exp $ */
+/*
+ * Copyright 1993 by Jon Tombs. Oxford University
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Jon Tombs or Oxford University shall
+ * 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.
+ *
+ * JON TOMBS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Extract from s3bcach.c
+ * Adapted to 8514, Hans Nasten. (nasten@everyware.se).
+ */
+
+#include "X.h"
+#include "Xmd.h"
+#include "Xproto.h"
+#include "cfb.h"
+#include "misc.h"
+#include "xf86.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "fontstruct.h"
+#include "dixfontstr.h"
+#include "xf86bcache.h"
+#include "ibm8514.h"
+#include "reg8514.h"
+
+
+extern unsigned char ibm8514cachemask[8];
+extern unsigned char ibm8514cachemaskswapped[8];
+
+/*
+ * Use the GE to move a block of cache memory when compacting the cache.
+ *
+ * The id field in the cache blocks is used as a bitplane number, except
+ * for full depth blocks when 0xff is used.
+ */
+void ibm8514CacheMoveBlock( srcx, srcy, dstx, dsty, h, w, id )
+int srcx, srcy, dstx, dsty, h, w;
+unsigned int id;
+
+{
+ WaitQueue(8);
+ outw(MULTIFUNC_CNTL, SCISSORS_T | 0);
+ outw(MULTIFUNC_CNTL, SCISSORS_L | 0);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | 1023);
+ outw(MULTIFUNC_CNTL, SCISSORS_B | 1023);
+ outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX);
+ outw(FRGD_MIX, FSS_BITBLT | MIX_SRC);
+ outw(BKGD_MIX, BSS_BITBLT | MIX_SRC);
+ if( id != 0xff )
+ outw(WRT_MASK, ibm8514cachemask[id]);
+ else
+ outw(WRT_MASK, (short) id);
+
+ WaitQueue(8); /* now shift the cache */
+ if( id != 0xff )
+ outw(RD_MASK, ibm8514cachemaskswapped[id]);
+ else
+ outw(RD_MASK, (short) id);
+ outw(CUR_Y, srcy);
+ outw(CUR_X, srcx);
+ outw(DESTX_DIASTP, dstx);
+ outw(DESTY_AXSTP, dsty);
+ outw(MAJ_AXIS_PCNT, w - 1);
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (h - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+
+ WaitQueue(4); /* sanity returns */
+ outw(RD_MASK, 0xff);
+ outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/blt.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/blt.c
new file mode 100644
index 000000000..b9b28caa2
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/blt.c
@@ -0,0 +1,873 @@
+/* $XConsortium: ibm8514blt.c,v 1.2 94/04/17 20:30:29 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/ibm8514/blt.c,v 3.0 1994/06/06 06:44:14 dawes Exp $ */
+/*
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+Author: Keith Packard
+
+Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+
+KEVIN E. MARTIN AND TIAGO GONS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL KEVIN E. MARTIN OR TIAGO GONS BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Modified by Tiago Gons (tiago@comosjn.hobby.nl)
+
+*/
+
+
+/* $XConsortium: ibm8514blt.c,v 1.2 94/04/17 20:30:29 dpw Exp $ */
+
+#include "X.h"
+#include "Xmd.h"
+#include "Xproto.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mi.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "cfb8bit.h"
+#include "fastblt.h"
+
+#include "reg8514.h"
+#include "ibm8514.h"
+
+extern RegionPtr cfbBitBlt();
+
+RegionPtr
+ibm8514CopyArea(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty)
+ register DrawablePtr pSrcDrawable;
+ register DrawablePtr pDstDrawable;
+ GC *pGC;
+ int srcx, srcy;
+ int width, height;
+ int dstx, dsty;
+{
+ RegionPtr prgnSrcClip; /* may be a new region, or just a copy */
+ Bool freeSrcClip = FALSE;
+
+ RegionPtr prgnExposed;
+ RegionRec rgnDst;
+ register BoxPtr pbox;
+ int i;
+ register int dx;
+ register int dy;
+ xRectangle origSource;
+ DDXPointRec origDest;
+ int numRects;
+ BoxRec fastBox;
+ int fastClip = 0; /* for fast clipping with pixmap source */
+ int fastExpose = 0; /* for fast exposures with pixmap source */
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema ||
+ ((pSrcDrawable->type != DRAWABLE_WINDOW) &&
+ (pDstDrawable->type != DRAWABLE_WINDOW)))
+ {
+ return cfbCopyArea(pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height, dstx, dsty);
+ }
+
+ origSource.x = srcx;
+ origSource.y = srcy;
+ origSource.width = width;
+ origSource.height = height;
+ origDest.x = dstx;
+ origDest.y = dsty;
+
+ if ((pSrcDrawable != pDstDrawable) &&
+ pSrcDrawable->pScreen->SourceValidate)
+ {
+ (*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, srcx, srcy, width, height);
+ }
+
+ srcx += pSrcDrawable->x;
+ srcy += pSrcDrawable->y;
+
+ /* clip the source */
+
+ if (pSrcDrawable->type == DRAWABLE_PIXMAP)
+ {
+ if ((pSrcDrawable == pDstDrawable) &&
+ (pGC->clientClipType == CT_NONE))
+ {
+ prgnSrcClip = ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
+ }
+ else
+ {
+ fastClip = 1;
+ }
+ }
+ else
+ {
+ if (pGC->subWindowMode == IncludeInferiors)
+ {
+ if (!((WindowPtr) pSrcDrawable)->parent)
+ {
+ /*
+ * special case bitblt from root window in
+ * IncludeInferiors mode; just like from a pixmap
+ */
+ fastClip = 1;
+ }
+ else if ((pSrcDrawable == pDstDrawable) &&
+ (pGC->clientClipType == CT_NONE))
+ {
+ prgnSrcClip = ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
+ }
+ else
+ {
+ prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable);
+ freeSrcClip = TRUE;
+ }
+ }
+ else
+ {
+ prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList;
+ }
+ }
+
+ fastBox.x1 = srcx;
+ fastBox.y1 = srcy;
+ fastBox.x2 = srcx + width;
+ fastBox.y2 = srcy + height;
+
+ /* Don't create a source region if we are doing a fast clip */
+ if (fastClip)
+ {
+ fastExpose = 1;
+ /*
+ * clip the source; if regions extend beyond the source size,
+ * make sure exposure events get sent
+ */
+ if (fastBox.x1 < pSrcDrawable->x)
+ {
+ fastBox.x1 = pSrcDrawable->x;
+ fastExpose = 0;
+ }
+ if (fastBox.y1 < pSrcDrawable->y)
+ {
+ fastBox.y1 = pSrcDrawable->y;
+ fastExpose = 0;
+ }
+ if (fastBox.x2 > pSrcDrawable->x + (int) pSrcDrawable->width)
+ {
+ fastBox.x2 = pSrcDrawable->x + (int) pSrcDrawable->width;
+ fastExpose = 0;
+ }
+ if (fastBox.y2 > pSrcDrawable->y + (int) pSrcDrawable->height)
+ {
+ fastBox.y2 = pSrcDrawable->y + (int) pSrcDrawable->height;
+ fastExpose = 0;
+ }
+ }
+ else
+ {
+ (*pGC->pScreen->RegionInit)(&rgnDst, &fastBox, 1);
+ (*pGC->pScreen->Intersect)(&rgnDst, &rgnDst, prgnSrcClip);
+ }
+
+ dstx += pDstDrawable->x;
+ dsty += pDstDrawable->y;
+
+ if (pDstDrawable->type == DRAWABLE_WINDOW)
+ {
+ if (!((WindowPtr)pDstDrawable)->realized)
+ {
+ if (!fastClip)
+ (*pGC->pScreen->RegionUninit)(&rgnDst);
+ if (freeSrcClip)
+ (*pGC->pScreen->RegionDestroy)(prgnSrcClip);
+ return NULL;
+ }
+ }
+
+ dx = srcx - dstx;
+ dy = srcy - dsty;
+
+ /* Translate and clip the dst to the destination composite clip */
+ if (fastClip)
+ {
+ RegionPtr cclip;
+
+ /* Translate the region directly */
+ fastBox.x1 -= dx;
+ fastBox.x2 -= dx;
+ fastBox.y1 -= dy;
+ fastBox.y2 -= dy;
+
+ /* If the destination composite clip is one rectangle we can
+ do the clip directly. Otherwise we have to create a full
+ blown region and call intersect */
+
+ /* XXX because CopyPlane uses this routine for 8-to-1 bit
+ * copies, this next line *must* also correctly fetch the
+ * composite clip from an mfb gc
+ */
+
+ cclip = ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
+ if (REGION_NUM_RECTS(cclip) == 1)
+ {
+ BoxPtr pBox = REGION_RECTS(cclip);
+
+ if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1;
+ if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2;
+ if (fastBox.y1 < pBox->y1) fastBox.y1 = pBox->y1;
+ if (fastBox.y2 > pBox->y2) fastBox.y2 = pBox->y2;
+
+ /* Check to see if the region is empty */
+ if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2)
+ (*pGC->pScreen->RegionInit)(&rgnDst, NullBox, 0);
+ else
+ (*pGC->pScreen->RegionInit)(&rgnDst, &fastBox, 1);
+ }
+ else
+ {
+ /* We must turn off fastClip now, since we must create
+ a full blown region. It is intersected with the
+ composite clip below. */
+ fastClip = 0;
+ (*pGC->pScreen->RegionInit)(&rgnDst, &fastBox,1);
+ }
+ }
+ else
+ {
+ (*pGC->pScreen->TranslateRegion)(&rgnDst, -dx, -dy);
+ }
+
+ if (!fastClip)
+ {
+ (*pGC->pScreen->Intersect)(&rgnDst,
+ &rgnDst,
+ ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip);
+ }
+
+ /* Do bit blitting */
+ numRects = REGION_NUM_RECTS(&rgnDst);
+ if (numRects && width && height)
+ {
+ pbox = REGION_RECTS(&rgnDst);
+
+ if (pSrcDrawable->type == DRAWABLE_WINDOW && pDstDrawable->type == DRAWABLE_WINDOW) {
+ /* Window --> Window */
+ unsigned int *ordering;
+ BoxPtr prect;
+ short direction = 0;
+
+ ordering = (unsigned int *) ALLOCATE_LOCAL(numRects * sizeof(unsigned int));
+ if(!ordering) {
+ DEALLOCATE_LOCAL(ordering);
+ return (RegionPtr)NULL;
+ }
+
+ ibm8514FindOrdering(pSrcDrawable, pDstDrawable, pGC, numRects, pbox, srcx, srcy, dstx, dsty, ordering);
+
+ if (dx > 0) direction |= INC_X;
+ if (dy > 0) direction |= INC_Y;
+
+ WaitQueue(3);
+ outw(FRGD_MIX, FSS_BITBLT | ibm8514alu[pGC->alu]);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+ outw(WRT_MASK, pGC->planemask);
+
+ if (direction == (INC_X | INC_Y)) {
+ for (i = 0; i < numRects; i++) {
+ prect = &pbox[ordering[i]];
+
+ WaitQueue(7);
+ outw(CUR_X, (short)(prect->x1 + dx));
+ outw(CUR_Y, (short)(prect->y1 + dy));
+ outw(DESTX_DIASTP, (short)(prect->x1));
+ outw(DESTY_AXSTP, (short)(prect->y1));
+ outw(MAJ_AXIS_PCNT, (short)(prect->x2 - prect->x1 - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(prect->y2 - prect->y1 - 1));
+ outw(CMD, CMD_BITBLT | direction | DRAW | PLANAR | WRTDATA);
+ }
+ } else if (direction == INC_X) {
+ for (i = 0; i < numRects; i++) {
+ prect = &pbox[ordering[i]];
+
+ WaitQueue(7);
+ outw(CUR_X, (short)(prect->x1 + dx));
+ outw(CUR_Y, (short)(prect->y2 + dy - 1));
+ outw(DESTX_DIASTP, (short)(prect->x1));
+ outw(DESTY_AXSTP, (short)(prect->y2 - 1));
+ outw(MAJ_AXIS_PCNT, (short)(prect->x2 - prect->x1 - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(prect->y2 - prect->y1 - 1));
+ outw(CMD, CMD_BITBLT | direction | DRAW | PLANAR | WRTDATA);
+ }
+ } else if (direction == INC_Y) {
+ for (i = 0; i < numRects; i++) {
+ prect = &pbox[ordering[i]];
+
+ WaitQueue(7);
+ outw(CUR_X, (short)(prect->x2 + dx - 1));
+ outw(CUR_Y, (short)(prect->y1 + dy));
+ outw(DESTX_DIASTP, (short)(prect->x2 - 1));
+ outw(DESTY_AXSTP, (short)(prect->y1));
+ outw(MAJ_AXIS_PCNT, (short)(prect->x2 - prect->x1 - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(prect->y2 - prect->y1 - 1));
+ outw(CMD, CMD_BITBLT | direction | DRAW | PLANAR | WRTDATA);
+ }
+ } else {
+ for (i = 0; i < numRects; i++) {
+ prect = &pbox[ordering[i]];
+
+ WaitQueue(7);
+ outw(CUR_X, (short)(prect->x2 + dx - 1));
+ outw(CUR_Y, (short)(prect->y2 + dy - 1));
+ outw(DESTX_DIASTP, (short)(prect->x2 - 1));
+ outw(DESTY_AXSTP, (short)(prect->y2 - 1));
+ outw(MAJ_AXIS_PCNT, (short)(prect->x2 - prect->x1 - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(prect->y2 - prect->y1 - 1));
+ outw(CMD, CMD_BITBLT | direction | DRAW | PLANAR | WRTDATA);
+ }
+ }
+ DEALLOCATE_LOCAL(ordering);
+
+ WaitQueue(3);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+ outw(WRT_MASK, 0xffff);
+ } else if (pSrcDrawable->type == DRAWABLE_WINDOW && pDstDrawable->type != DRAWABLE_WINDOW) {
+ /* Window --> Pixmap */
+ int pixWidth = PixmapBytePad(pDstDrawable->width, pDstDrawable->depth);
+ char *pdst = ((PixmapPtr)pDstDrawable)->devPrivate.ptr;
+
+ for (i = numRects; --i >= 0; pbox++)
+ ibm8514ImageRead(pbox->x1 + dx, pbox->y1 + dy,
+ pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
+ pdst, pixWidth, pbox->x1, pbox->y1, 0xff);
+ } else if (pSrcDrawable->type != DRAWABLE_WINDOW && pDstDrawable->type == DRAWABLE_WINDOW) {
+ /* Pixmap --> Window */
+ int pixWidth = PixmapBytePad(pSrcDrawable->width, pSrcDrawable->depth);
+ char *psrc = ((PixmapPtr)pSrcDrawable)->devPrivate.ptr;
+
+ for (i = numRects; --i >= 0; pbox++)
+ ibm8514ImageWrite(pbox->x1, pbox->y1,
+ pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
+ psrc, pixWidth, pbox->x1 + dx, pbox->y1 + dy,
+ ibm8514alu[pGC->alu], pGC->planemask);
+ } else {
+ /* Pixmap --> Pixmap */
+ ErrorF("ibm8514CopyArea: Tried to do a Pixmap to Pixmap copy\n");
+ }
+
+/*
+ (*localDoBitBlt) (pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc, pGC->planemask);
+*/
+ }
+
+ prgnExposed = NULL;
+ if (((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->fExpose)
+ {
+ extern RegionPtr miHandleExposures();
+
+ /* Pixmap sources generate a NoExposed (we return NULL to do this) */
+ if (!fastExpose)
+ prgnExposed =
+ miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
+ origSource.x, origSource.y,
+ (int)origSource.width,
+ (int)origSource.height,
+ origDest.x, origDest.y, 0);
+ }
+ (*pGC->pScreen->RegionUninit)(&rgnDst);
+ if (freeSrcClip)
+ (*pGC->pScreen->RegionDestroy)(prgnSrcClip);
+ return prgnExposed;
+}
+
+void
+ibm8514FindOrdering(pSrcDrawable, pDstDrawable, pGC, numRects, boxes, srcx, srcy, dstx, dsty, ordering)
+ DrawablePtr pSrcDrawable;
+ DrawablePtr pDstDrawable;
+ GC *pGC;
+ int numRects;
+ BoxPtr boxes;
+ int srcx;
+ int srcy;
+ int dstx;
+ int dsty;
+ unsigned int *ordering;
+{
+ int i, j, y;
+ int xMax, yMin, yMax;
+
+ /* If not the same drawable then order of move doesn't matter.
+ Following assumes that boxes are sorted from top
+ to bottom and left to right.
+ */
+ if ((pSrcDrawable != pDstDrawable) &&
+ ((pGC->subWindowMode != IncludeInferiors) ||
+ (pSrcDrawable->type == DRAWABLE_PIXMAP) ||
+ (pDstDrawable->type == DRAWABLE_PIXMAP))) {
+ for (i=0; i < numRects; i++)
+ ordering[i] = i;
+ } else { /* within same drawable, must sequence moves carefully! */
+ if (dsty <= srcy) { /* Scroll up or stationary vertical. Vertical order OK */
+ if (dstx <= srcx) { /* Scroll left or stationary horizontal. Horizontal order OK as well */
+ for (i=0; i < numRects; i++)
+ ordering[i] = i;
+ } else { /* scroll right. must reverse horizontal banding of rects. */
+ for (i=0, j=1, xMax=0; i < numRects; j=i+1, xMax=i) {
+ /* find extent of current horizontal band */
+ y=boxes[i].y1; /* band has this y coordinate */
+ while ((j < numRects) && (boxes[j].y1 == y))
+ j++;
+ /* reverse the horizontal band in the output ordering */
+ for (j-- ; j >= xMax; j--, i++)
+ ordering[i] = j;
+ }
+ }
+ } else { /* Scroll down. Must reverse vertical banding. */
+ if (dstx < srcx) { /* Scroll left. Horizontal order OK. */
+ for (i=numRects-1, j=i-1, yMin=i, yMax=0; i >= 0; j=i-1, yMin=i) {
+ /* find extent of current horizontal band */
+ y=boxes[i].y1; /* band has this y coordinate */
+ while ((j >= 0) && (boxes[j].y1 == y))
+ j--;
+ /* reverse the horizontal band in the output ordering */
+ for (j++ ; j <= yMin; j++, i--, yMax++)
+ ordering[yMax] = j;
+ }
+ } else { /* Scroll right or horizontal stationary.
+ Reverse horizontal order as well (if stationary, horizontal
+ order can be swapped without penalty and this is faster
+ to compute). */
+ for (i=0, j=numRects-1; i < numRects; i++, j--)
+ ordering[i] = j;
+ }
+ }
+ }
+}
+
+RegionPtr
+ibm8514CopyPlane(pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, bitPlane)
+ DrawablePtr pSrcDrawable;
+ DrawablePtr pDstDrawable;
+ GCPtr pGC;
+ int srcx, srcy;
+ int width, height;
+ int dstx, dsty;
+ unsigned long bitPlane;
+{
+ PixmapPtr pBitmap = NULL;
+ RegionPtr prgnSrcClip; /* may be a new region, or just a copy */
+ Bool freeSrcClip = FALSE;
+
+ RegionPtr prgnExposed;
+ RegionRec rgnDst;
+ register BoxPtr pbox;
+ int i;
+ register int dx;
+ register int dy;
+ xRectangle origSource;
+ DDXPointRec origDest;
+ int numRects;
+ BoxRec fastBox;
+ int fastClip = 0; /* for fast clipping with pixmap source */
+ int fastExpose = 0; /* for fast exposures with pixmap source */
+
+ if (!xf86VTSema ||
+ ((pSrcDrawable->type != DRAWABLE_WINDOW) &&
+ (pDstDrawable->type != DRAWABLE_WINDOW)))
+ {
+ return cfbCopyPlane(pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height, dstx, dsty, bitPlane);
+ }
+
+ if ((pSrcDrawable->type != DRAWABLE_WINDOW) &&
+ (pDstDrawable->type == DRAWABLE_WINDOW) &&
+ (pSrcDrawable->bitsPerPixel == 8)) {
+ /*
+ * Shortcut - we can do Pixmap->Window when the source depth is
+ * 8 by using the handy-dandy cfbCopyPlane8to1 to create a bitmap
+ * for us to use.
+ */
+ GCPtr pGC1;
+
+ pBitmap=(*pSrcDrawable->pScreen->CreatePixmap)(pSrcDrawable->pScreen,
+ pSrcDrawable->width,
+ pSrcDrawable->height, 1);
+ if (!pBitmap)
+ return(NULL);
+ pGC1 = GetScratchGC(1, pSrcDrawable->pScreen);
+ if (!pGC1) {
+ (*pSrcDrawable->pScreen->DestroyPixmap)(pBitmap);
+ return(NULL);
+ }
+ ValidateGC((DrawablePtr)pBitmap, pGC1);
+ (void) cfbBitBlt(pSrcDrawable, (DrawablePtr)pBitmap, pGC1, srcx, srcy,
+ width, height, srcx, srcy, cfbCopyPlane8to1, bitPlane);
+ FreeScratchGC(pGC1);
+ pSrcDrawable = (DrawablePtr)pBitmap;
+ } else if ((pSrcDrawable->type == DRAWABLE_WINDOW) &&
+ (pDstDrawable->type != DRAWABLE_WINDOW)) {
+ /*
+ * Shortcut - we can do Window->Pixmap by copying the window to
+ * a pixmap, then we have a Pixmap->Pixmap operation
+ */
+ GCPtr pGC1;
+ RegionPtr retval;
+ PixmapPtr pPixmap;
+
+ pPixmap=(*pSrcDrawable->pScreen->CreatePixmap)(pSrcDrawable->pScreen,
+ width, height, 8);
+ if (!pPixmap)
+ return(NULL);
+ pGC1 = GetScratchGC(8, pSrcDrawable->pScreen);
+ if (!pGC1) {
+ (*pSrcDrawable->pScreen->DestroyPixmap)(pPixmap);
+ return(NULL);
+ }
+ ValidateGC((DrawablePtr)pPixmap, pGC1);
+ ibm8514CopyArea(pSrcDrawable, (DrawablePtr)pPixmap, pGC1, srcx, srcy,
+ width, height, 0, 0);
+ retval = cfbCopyPlane((DrawablePtr)pPixmap, pDstDrawable, pGC,
+ 0, 0, width, height, dstx, dsty, bitPlane);
+ FreeScratchGC(pGC1);
+ (*pSrcDrawable->pScreen->DestroyPixmap)(pPixmap);
+ return(retval);
+ } else if (((pSrcDrawable->type == DRAWABLE_WINDOW) &&
+ (pDstDrawable->type != DRAWABLE_WINDOW)) ||
+ ((pSrcDrawable->type != DRAWABLE_WINDOW) &&
+ (pDstDrawable->type == DRAWABLE_WINDOW) &&
+ (pSrcDrawable->bitsPerPixel != 1))) {
+ /*
+ * Cases we can't handle, and must do another way:
+ * - copy Window->Pixmap
+ * - copy Pixmap->Window, Pixmap depth != 1
+ *
+ * Simplest thing to do is to let miCopyPlane deal with it for us.
+ */
+ return miCopyPlane(pSrcDrawable, pDstDrawable, pGC, srcx, srcy,
+ width, height, dstx, dsty, bitPlane);
+ }
+
+ origSource.x = srcx;
+ origSource.y = srcy;
+ origSource.width = width;
+ origSource.height = height;
+ origDest.x = dstx;
+ origDest.y = dsty;
+
+ if ((pSrcDrawable != pDstDrawable) &&
+ pSrcDrawable->pScreen->SourceValidate) {
+ (*pSrcDrawable->pScreen->SourceValidate)(pSrcDrawable, srcx, srcy,
+ width, height);
+ }
+ srcx += pSrcDrawable->x;
+ srcy += pSrcDrawable->y;
+
+ /* clip the source */
+ if (pSrcDrawable->type == DRAWABLE_PIXMAP) {
+ if ((pSrcDrawable == pDstDrawable) &&
+ (pGC->clientClipType == CT_NONE)) {
+ prgnSrcClip = ((cfbPrivGC *) (pGC->devPrivates[cfbGCPrivateIndex].ptr)) ->pCompositeClip;
+ } else {
+ fastClip = 1;
+ }
+ } else {
+ if (pGC->subWindowMode == IncludeInferiors) {
+ if (!((WindowPtr) pSrcDrawable)->parent) {
+
+ /*
+ * special case bitblt from root window in IncludeInferiors mode;
+ * just like from a pixmap
+ */
+ fastClip = 1;
+ } else if ((pSrcDrawable == pDstDrawable) &&
+ (pGC->clientClipType == CT_NONE)) {
+ prgnSrcClip = ((cfbPrivGC *) (pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
+ } else {
+ prgnSrcClip = NotClippedByChildren((WindowPtr) pSrcDrawable);
+ freeSrcClip = TRUE;
+ }
+ } else {
+ prgnSrcClip = &((WindowPtr) pSrcDrawable)->clipList;
+ }
+ }
+
+ fastBox.x1 = srcx;
+ fastBox.y1 = srcy;
+ fastBox.x2 = srcx + width;
+ fastBox.y2 = srcy + height;
+
+ /* Don't create a source region if we are doing a fast clip */
+ if (fastClip) {
+ fastExpose = 1;
+
+ /*
+ * clip the source; if regions extend beyond the source size, make sure
+ * exposure events get sent
+ */
+ if (fastBox.x1 < pSrcDrawable->x) {
+ fastBox.x1 = pSrcDrawable->x;
+ fastExpose = 0;
+ }
+ if (fastBox.y1 < pSrcDrawable->y) {
+ fastBox.y1 = pSrcDrawable->y;
+ fastExpose = 0;
+ }
+ if (fastBox.x2 > pSrcDrawable->x + (int)pSrcDrawable->width) {
+ fastBox.x2 = pSrcDrawable->x + (int)pSrcDrawable->width;
+ fastExpose = 0;
+ }
+ if (fastBox.y2 > pSrcDrawable->y + (int)pSrcDrawable->height) {
+ fastBox.y2 = pSrcDrawable->y + (int)pSrcDrawable->height;
+ fastExpose = 0;
+ }
+ } else {
+ (*pGC->pScreen->RegionInit) (&rgnDst, &fastBox, 1);
+ (*pGC->pScreen->Intersect) (&rgnDst, &rgnDst, prgnSrcClip);
+ }
+
+ dstx += pDstDrawable->x;
+ dsty += pDstDrawable->y;
+
+ if (pDstDrawable->type == DRAWABLE_WINDOW) {
+ if (!((WindowPtr) pDstDrawable)->realized) {
+ if (!fastClip)
+ (*pGC->pScreen->RegionUninit) (&rgnDst);
+ if (freeSrcClip)
+ (*pGC->pScreen->RegionDestroy) (prgnSrcClip);
+ if (pBitmap)
+ (*pSrcDrawable->pScreen->DestroyPixmap)(pBitmap);
+ return NULL;
+ }
+ }
+ dx = srcx - dstx;
+ dy = srcy - dsty;
+
+ /* Translate and clip the dst to the destination composite clip */
+ if (fastClip) {
+ RegionPtr cclip;
+
+ /* Translate the region directly */
+ fastBox.x1 -= dx;
+ fastBox.x2 -= dx;
+ fastBox.y1 -= dy;
+ fastBox.y2 -= dy;
+
+ /*
+ * If the destination composite clip is one rectangle we can do the clip
+ * directly. Otherwise we have to create a full blown region and call
+ * intersect
+ */
+ cclip = ((cfbPrivGC *) (pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
+ if (REGION_NUM_RECTS(cclip) == 1) {
+ BoxPtr pBox = REGION_RECTS(cclip);
+
+ if (fastBox.x1 < pBox->x1)
+ fastBox.x1 = pBox->x1;
+ if (fastBox.x2 > pBox->x2)
+ fastBox.x2 = pBox->x2;
+ if (fastBox.y1 < pBox->y1)
+ fastBox.y1 = pBox->y1;
+ if (fastBox.y2 > pBox->y2)
+ fastBox.y2 = pBox->y2;
+
+ /* Check to see if the region is empty */
+ if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2)
+ (*pGC->pScreen->RegionInit) (&rgnDst, NullBox, 0);
+ else
+ (*pGC->pScreen->RegionInit) (&rgnDst, &fastBox, 1);
+ } else {
+ /*
+ * We must turn off fastClip now, since we must create a full blown
+ * region. It is intersected with the composite clip below.
+ */
+ fastClip = 0;
+ (*pGC->pScreen->RegionInit) (&rgnDst, &fastBox, 1);
+ }
+ } else {
+ (*pGC->pScreen->TranslateRegion) (&rgnDst, -dx, -dy);
+ }
+
+ if (!fastClip) {
+ (*pGC->pScreen->Intersect) (&rgnDst,
+ &rgnDst,
+ ((cfbPrivGC *) (pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip);
+ }
+
+ /* Do bit blitting */
+ numRects = REGION_NUM_RECTS(&rgnDst);
+ if (numRects && width && height) {
+ pbox = REGION_RECTS(&rgnDst);
+
+ if (pSrcDrawable->type == DRAWABLE_WINDOW &&
+ pDstDrawable->type == DRAWABLE_WINDOW) {
+ /* Window --> Window */
+ unsigned int *ordering;
+ BoxPtr prect;
+ short direction = 0;
+
+ ordering = (unsigned int *)ALLOCATE_LOCAL(numRects *
+ sizeof(unsigned int));
+
+ if (!ordering) {
+ DEALLOCATE_LOCAL(ordering);
+ return (RegionPtr) NULL;
+ }
+ ibm8514FindOrdering(pSrcDrawable, pDstDrawable, pGC, numRects, pbox,
+ srcx, srcy, dstx, dsty, ordering);
+
+ if (dx > 0)
+ direction |= INC_X;
+ if (dy > 0)
+ direction |= INC_Y;
+
+ WaitQueue(6);
+ outw(FRGD_MIX, FSS_FRGDCOL | ibm8514alu[pGC->alu]);
+ outw(RD_MASK, (unsigned short) (((bitPlane & 0x7f) << 1)
+ | ((bitPlane & 0x80) >> 7)));
+ outw(WRT_MASK, pGC->planemask);
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(BKGD_COLOR, (short)pGC->bgPixel);
+ outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_EXPBLT);
+
+ if (direction == (INC_X | INC_Y)) {
+ for (i = 0; i < numRects; i++) {
+ prect = &pbox[ordering[i]];
+
+ WaitQueue(7);
+ outw(CUR_X, (short)(prect->x1 + dx));
+ outw(CUR_Y, (short)(prect->y1 + dy));
+ outw(DESTX_DIASTP, (short)(prect->x1));
+ outw(DESTY_AXSTP, (short)(prect->y1));
+ outw(MAJ_AXIS_PCNT, (short)(prect->x2 - prect->x1 - 1));
+ outw(MULTIFUNC_CNTL,
+ MIN_AXIS_PCNT | (short)(prect->y2 - prect->y1 - 1));
+ outw(CMD, CMD_BITBLT | direction | DRAW | PLANAR | WRTDATA);
+ }
+ } else if (direction == INC_X) {
+ for (i = 0; i < numRects; i++) {
+ prect = &pbox[ordering[i]];
+
+ WaitQueue(7);
+ outw(CUR_X, (short)(prect->x1 + dx));
+ outw(CUR_Y, (short)(prect->y2 + dy - 1));
+ outw(DESTX_DIASTP, (short)(prect->x1));
+ outw(DESTY_AXSTP, (short)(prect->y2 - 1));
+ outw(MAJ_AXIS_PCNT, (short)(prect->x2 - prect->x1 - 1));
+ outw(MULTIFUNC_CNTL,
+ MIN_AXIS_PCNT | (short)(prect->y2 - prect->y1 - 1));
+ outw(CMD, CMD_BITBLT | direction | DRAW | PLANAR | WRTDATA);
+ }
+ } else if (direction == INC_Y) {
+ for (i = 0; i < numRects; i++) {
+ prect = &pbox[ordering[i]];
+
+ WaitQueue(7);
+ outw(CUR_X, (short)(prect->x2 + dx - 1));
+ outw(CUR_Y, (short)(prect->y1 + dy));
+ outw(DESTX_DIASTP, (short)(prect->x2 - 1));
+ outw(DESTY_AXSTP, (short)(prect->y1));
+ outw(MAJ_AXIS_PCNT, (short)(prect->x2 - prect->x1 - 1));
+ outw(MULTIFUNC_CNTL,
+ MIN_AXIS_PCNT | (short)(prect->y2 - prect->y1 - 1));
+ outw(CMD, CMD_BITBLT | direction | DRAW | PLANAR | WRTDATA);
+ }
+ } else {
+ for (i = 0; i < numRects; i++) {
+ prect = &pbox[ordering[i]];
+
+ WaitQueue(7);
+ outw(CUR_X, (short)(prect->x2 + dx - 1));
+ outw(CUR_Y, (short)(prect->y2 + dy - 1));
+ outw(DESTX_DIASTP, (short)(prect->x2 - 1));
+ outw(DESTY_AXSTP, (short)(prect->y2 - 1));
+ outw(MAJ_AXIS_PCNT, (short)(prect->x2 - prect->x1 - 1));
+ outw(MULTIFUNC_CNTL,
+ MIN_AXIS_PCNT | (short)(prect->y2 - prect->y1 - 1));
+ outw(CMD, CMD_BITBLT | direction | DRAW | PLANAR | WRTDATA);
+ }
+ }
+ DEALLOCATE_LOCAL(ordering);
+
+ WaitQueue(4);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(RD_MASK, 0xffff);
+ outw(WRT_MASK, 0xffff);
+ outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);
+ } else if (pSrcDrawable->type == DRAWABLE_WINDOW &&
+ pDstDrawable->type != DRAWABLE_WINDOW) {
+ /* Window --> Pixmap */
+ /* THIS IS NOT IMPLEMENTED - IT GETS PASSED TO miCopyPlane ABOVE */
+ } else if (pSrcDrawable->type != DRAWABLE_WINDOW &&
+ pDstDrawable->type == DRAWABLE_WINDOW) {
+ /* Pixmap --> Window */
+ PixmapPtr pix = (PixmapPtr) pSrcDrawable;
+ int pixWidth;
+ char *psrc;
+
+ pixWidth = PixmapBytePad(pSrcDrawable->width, pSrcDrawable->depth);
+ psrc = pix->devPrivate.ptr;
+
+ for (i = numRects; --i >= 0; pbox++) {
+ ibm8514ImageStipple(pbox->x1, pbox->y1,
+ pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
+ psrc, pixWidth,
+ pix->drawable.width, pix->drawable.height,
+ -dx, -dy, pGC->fgPixel, pGC->bgPixel,
+ ibm8514alu[pGC->alu],
+ (short) pGC->planemask, 1);
+ }
+ } else {
+ /* Pixmap --> Pixmap */
+ ErrorF("ibm8514CopyPlane: Tried to do a Pixmap to Pixmap copy\n");
+ }
+ }
+ prgnExposed = NULL;
+ if (((cfbPrivGC *) (pGC->devPrivates[cfbGCPrivateIndex].ptr))->fExpose) {
+ extern RegionPtr miHandleExposures();
+
+ /* Pixmap sources generate a NoExposed (we return NULL to do this) */
+ if (!fastExpose)
+ prgnExposed =
+ miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
+ origSource.x, origSource.y,
+ (int)origSource.width,
+ (int)origSource.height,
+ origDest.x, origDest.y, 0);
+ }
+ (*pGC->pScreen->RegionUninit) (&rgnDst);
+ if (freeSrcClip)
+ (*pGC->pScreen->RegionDestroy) (prgnSrcClip);
+ if (pBitmap)
+ (*pSrcDrawable->pScreen->DestroyPixmap)(pBitmap);
+ return prgnExposed;
+}
+
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/bstor.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/bstor.c
new file mode 100644
index 000000000..08938112e
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/bstor.c
@@ -0,0 +1,105 @@
+/* $XConsortium: ibm8514bsto.c,v 1.1 94/03/28 21:03:20 dpw Exp $ */
+/*-
+ * ibm8514bstore.c --
+ * Functions required by the backing-store implementation in MI.
+ *
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ *
+ * Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+ *
+ * KEVIN E. MARTIN AND TIAGO GONS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL KEVIN E. MARTIN OR TIAGO GONS BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Modified by Tiago Gons (tiago@comosjn.hobby.nl)
+ */
+
+
+#include "cfb.h"
+#include "X.h"
+#include "mibstore.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include "ibm8514.h"
+
+void
+ibm8514SaveAreas(pPixmap, prgnSave, xorg, yorg, pWin)
+ PixmapPtr pPixmap; /* Backing pixmap */
+ RegionPtr prgnSave; /* Region to save (pixmap-relative) */
+ int xorg; /* X origin of region */
+ int yorg; /* Y origin of region */
+ WindowPtr pWin;
+{
+ register BoxPtr pBox;
+ register int i;
+ int pixWidth;
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema)
+ {
+ cfbSaveAreas(pPixmap, prgnSave, xorg, yorg, pWin);
+ return;
+ }
+
+
+ i = REGION_NUM_RECTS(prgnSave);
+ pBox = REGION_RECTS(prgnSave);
+
+ pixWidth = PixmapBytePad(pPixmap->drawable.width, pPixmap->drawable.depth);
+
+ while (i--) {
+ ibm8514ImageRead(pBox->x1 + xorg, pBox->y1 + yorg,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
+ pPixmap->devPrivate.ptr, pixWidth,
+ pBox->x1, pBox->y1, 0xff);
+ pBox++;
+ }
+}
+
+void
+ibm8514RestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin)
+ PixmapPtr pPixmap; /* Backing pixmap */
+ RegionPtr prgnRestore; /* Region to restore (screen-relative)*/
+ int xorg; /* X origin of window */
+ int yorg; /* Y origin of window */
+ WindowPtr pWin;
+{
+ register BoxPtr pBox;
+ register int i;
+ int pixWidth;
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema)
+ {
+ cfbRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin);
+ return;
+ }
+
+ i = REGION_NUM_RECTS(prgnRestore);
+ pBox = REGION_RECTS(prgnRestore);
+
+ pixWidth = PixmapBytePad(pPixmap->drawable.width, pPixmap->drawable.depth);
+
+ while (i--) {
+ ibm8514ImageWrite(pBox->x1, pBox->y1,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
+ pPixmap->devPrivate.ptr, pixWidth,
+ pBox->x1 - xorg, pBox->y1 - yorg,
+ ibm8514alu[GXcopy], 0xffffffff);
+ pBox++;
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/cmap.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/cmap.c
new file mode 100644
index 000000000..d982a1e7b
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/cmap.c
@@ -0,0 +1,198 @@
+/* $XConsortium: ibm8514cmap.c,v 1.1 94/03/28 21:03:32 dpw Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL, KEVIN E. MARTIN, AND TIAGO GONS DISCLAIM ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL THOMAS ROELL, KEVIN E. MARTIN, OR TIAGO GONS
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Rewritten for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+ * Modified by Tiago Gons (tiago@comosjn.hobby.nl)
+ *
+ * Header: /proj/X11/mit/server/ddx/xf86/vga/RCS/vgaCmap.c,v 1.2 1991/06/27 00:03:01 root Exp
+ */
+
+
+#include "X.h"
+#include "Xproto.h"
+#include "scrnintstr.h"
+#include "colormapst.h"
+#include "windowstr.h"
+#include "compiler.h"
+
+#include "ibm8514.h"
+#include "reg8514.h"
+
+#define NOMAPYET (ColormapPtr) 0
+
+static ColormapPtr InstalledMaps[MAXSCREENS];
+ /* current colormap for each screen */
+
+static LUTENTRY current8514dac[256];
+
+
+int
+ibm8514ListInstalledColormaps(pScreen, pmaps)
+ ScreenPtr pScreen;
+ Colormap *pmaps;
+{
+ /* By the time we are processing requests, we can guarantee that there
+ * is always a colormap installed */
+
+ *pmaps = InstalledMaps[pScreen->myNum]->mid;
+ return(1);
+}
+
+void
+ibm8514RestoreDACvalues()
+{
+ int i;
+
+ if (xf86VTSema) {
+ outb(DAC_W_INDEX, 0);
+
+ for (i = 0; i < 256; i++) {
+ outb(DAC_DATA, current8514dac[i].r);
+ outb(DAC_DATA, current8514dac[i].g);
+ outb(DAC_DATA, current8514dac[i].b);
+ }
+ }
+}
+
+
+void
+ibm8514StoreColors(pmap, ndef, pdefs)
+ ColormapPtr pmap;
+ int ndef;
+ xColorItem *pdefs;
+{
+ int i;
+ xColorItem directDefs[256];
+
+ if (pmap != InstalledMaps[pmap->pScreen->myNum])
+ return;
+
+ if ((pmap->pVisual->class | DynamicClass) == DirectColor) {
+ ndef = cfbExpandDirectColors (pmap, ndef, pdefs, directDefs);
+ pdefs = directDefs;
+ }
+
+ for (i = 0; i < ndef; i++) {
+ current8514dac[pdefs[i].pixel].r = pdefs[i].red >> 10;
+ current8514dac[pdefs[i].pixel].g = pdefs[i].green >> 10;
+ current8514dac[pdefs[i].pixel].b = pdefs[i].blue >> 10;
+ if (xf86VTSema) {
+ outb(DAC_W_INDEX, pdefs[i].pixel);
+ outb(DAC_DATA, pdefs[i].red >> 10);
+ outb(DAC_DATA, pdefs[i].green >> 10);
+ outb(DAC_DATA, pdefs[i].blue >> 10);
+ }
+ }
+}
+
+
+void
+ibm8514InstallColormap(pmap)
+ ColormapPtr pmap;
+{
+ ColormapPtr oldmap = InstalledMaps[pmap->pScreen->myNum];
+ int entries;
+ Pixel * ppix;
+ xrgb * prgb;
+ xColorItem *defs;
+ int i;
+
+
+ if (pmap == oldmap)
+ return;
+
+ if ((pmap->pVisual->class | DynamicClass) == DirectColor)
+ entries = (pmap->pVisual->redMask |
+ pmap->pVisual->greenMask |
+ pmap->pVisual->blueMask) + 1;
+ else
+ entries = pmap->pVisual->ColormapEntries;
+
+ ppix = (Pixel *)ALLOCATE_LOCAL( entries * sizeof(Pixel));
+ prgb = (xrgb *)ALLOCATE_LOCAL( entries * sizeof(xrgb));
+ defs = (xColorItem *)ALLOCATE_LOCAL(entries * sizeof(xColorItem));
+
+ if ( oldmap != NOMAPYET)
+ WalkTree( pmap->pScreen, TellLostMap, &oldmap->mid);
+
+ InstalledMaps[pmap->pScreen->myNum] = pmap;
+
+ for ( i=0; i<entries; i++) ppix[i] = i;
+
+ QueryColors( pmap, entries, ppix, prgb);
+
+ for ( i=0; i<entries; i++) /* convert xrgbs to xColorItems */
+ {
+ defs[i].pixel = ppix[i];
+ defs[i].red = prgb[i].red;
+ defs[i].green = prgb[i].green;
+ defs[i].blue = prgb[i].blue;
+ defs[i].flags = DoRed|DoGreen|DoBlue;
+ }
+
+ ibm8514StoreColors( pmap, entries, defs);
+
+ WalkTree(pmap->pScreen, TellGainedMap, &pmap->mid);
+
+ DEALLOCATE_LOCAL(ppix);
+ DEALLOCATE_LOCAL(prgb);
+ DEALLOCATE_LOCAL(defs);
+}
+
+
+void
+ibm8514UninstallColormap(pmap)
+ ColormapPtr pmap;
+{
+ ColormapPtr defColormap;
+
+ if ( pmap != InstalledMaps[pmap->pScreen->myNum] )
+ return;
+
+ defColormap = (ColormapPtr) LookupIDByType( pmap->pScreen->defColormap,
+ RT_COLORMAP);
+
+ if (defColormap == InstalledMaps[pmap->pScreen->myNum])
+ return;
+
+ (*pmap->pScreen->InstallColormap) (defColormap);
+}
+
+
+/* This is for the screen saver */
+void
+ibm8514RestoreColor0(pScreen)
+ ScreenPtr pScreen;
+{
+ Pixel pix = 0;
+ xrgb rgb;
+
+ if (InstalledMaps[pScreen->myNum] == NOMAPYET)
+ return;
+
+ QueryColors(InstalledMaps[pScreen->myNum], 1, &pix, &rgb);
+
+ outb(DAC_W_INDEX, 0);
+ outb(DAC_DATA, rgb.red >> 10);
+ outb(DAC_DATA, rgb.green >> 10);
+ outb(DAC_DATA, rgb.blue >> 10);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/dsline.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/dsline.c
new file mode 100644
index 000000000..0d3f8be04
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/dsline.c
@@ -0,0 +1,546 @@
+/* $XConsortium: ibm8514dsln.c,v 1.2 94/04/17 20:30:30 dpw Exp $ */
+/*
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL, KEVIN E. MARTIN, AND TIAGO GONS DISCLAIM ALL WARRANTIES WITH REGARD TO
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL DIGITAL, KEVIN E. MARTIN, OR TIAGO GONS BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+Further modifications by Tiago Gons (tiago@comosjn.hobby.nl)
+
+*/
+
+/* 14-sep-93 TCG: ibm8514dsln.c based on ibm8514line.c */
+
+
+#include "X.h"
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "mistruct.h"
+#include "miline.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "reg8514.h"
+#include "ibm8514.h"
+
+void
+#ifdef I8514DoubleDash
+ibm8514DoubleDashLine(pDrawable, pGC, mode, npt, pptInit)
+#else
+ibm8514DashLine(pDrawable, pGC, mode, npt, pptInit)
+#endif
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt; /* number of points */
+ DDXPointPtr pptInit;
+{
+ int nboxInit;
+ register int nbox;
+ BoxPtr pboxInit;
+ register BoxPtr pbox;
+ register DDXPointPtr ppt; /* pointer to list of translated points */
+
+ unsigned int oc1; /* outcode of point 1 */
+ unsigned int oc2; /* outcode of point 2 */
+
+ int xorg, yorg; /* origin of window */
+
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ short cmd = CMD_LINE | PLANAR | WRTDATA | LASTPIX;
+ short cmd2;
+ short fix;
+
+ int dashidx, dashnum, dashrem;
+ unsigned char *pDash;
+ Bool dashupdated;
+ /* a bunch of temporaries */
+ register int y1, y2;
+ register int x1, x2;
+ RegionPtr cclip;
+ cfbPrivGCPtr devPriv;
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema)
+ {
+ cfbLineSD(pDrawable, pGC, mode, npt, pptInit);
+ return;
+ }
+
+ devPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr);
+ cclip = devPriv->pCompositeClip;
+ pboxInit = REGION_RECTS(cclip);
+ nboxInit = REGION_NUM_RECTS(cclip);
+
+#ifdef I8514DoubleDash
+ WaitQueue(2);
+#else
+ WaitQueue(3);
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+#endif
+ outw(FRGD_MIX, FSS_FRGDCOL | ibm8514alu[pGC->alu]);
+ outw(WRT_MASK, (short)pGC->planemask);
+
+ pDash = (unsigned char *) pGC->dash;
+ dashnum = pGC->numInDashList;
+ dashidx = 0;
+ dashrem = 0;
+ miStepDash((int)pGC->dashOffset, &dashidx, pDash, dashnum, &dashrem);
+ dashrem = pDash[dashidx] - dashrem;
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+
+ while(--npt)
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious)
+ {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+
+ /* sloped line */
+ {
+ cmd2 = cmd;
+ signdx = 1;
+ if ((adx = x2 - x1) < 0)
+ {
+ adx = -adx;
+ signdx = -1;
+ fix = 0;
+ }
+ else
+ {
+ cmd2 |= INC_X;
+ fix = -1;
+ }
+ signdy = 1;
+ if ((ady = y2 - y1) < 0)
+ {
+ ady = -ady;
+ signdy = -1;
+ }
+ else
+ {
+ cmd2 |= INC_Y;
+ }
+
+ if (adx > ady)
+ {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ }
+ else
+ {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ cmd2 |= YMAJAXIS;
+ }
+
+ /* we have bresenham parameters and two points.
+ */
+ dashupdated = FALSE;
+
+ while(nbox--)
+ {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if ((oc1 | oc2) == 0)
+ {
+ if (axis == X_AXIS)
+ len = adx;
+ else
+ len = ady;
+
+ /* setup 8514/A for (dashed) line */
+ WaitQueue(5);
+ outw(CUR_X, (short)x1);
+ outw(CUR_Y, (short)y1);
+ outw(ERR_TERM, (short)(e + fix));
+ outw(DESTY_AXSTP, (short)e1);
+ outw(DESTX_DIASTP, (short)e2);
+
+ if (len < dashrem)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ if (dashidx & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ dashrem -= len;
+ } else
+ {
+ if (dashrem > 0)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)dashrem);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)dashrem);
+ if (dashidx & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ len -= dashrem;
+ dashrem = 0;
+ dashidx++;
+ if (dashidx == dashnum)
+ dashidx = 0;
+ }
+ while (pDash[dashidx] <= len)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)pDash[dashidx]);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)pDash[dashidx]);
+ if (dashidx & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ len -= pDash[dashidx];
+ dashidx++;
+ if (dashidx == dashnum)
+ dashidx = 0;
+ }
+ if (len > 0)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ if (dashidx & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ dashrem = pDash[dashidx] - len;
+ }
+ }
+ dashupdated = TRUE;
+
+ break;
+ }
+ else if (oc1 & oc2)
+ {
+ pbox++;
+ }
+ else
+ {
+ /*
+ * let the mi helper routine do our work;
+ * better than duplicating code...
+ */
+ int err; /* modified bresenham error term */
+ int clip1=0, clip2=0;/* clippedness of the endpoints */
+ int clipdx = 0; /* difference between clipped and */
+ int clipdy = 0; /* unclipped start point */
+ int dashrem2, dashidx2;
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+
+ if (miZeroClipLine(pbox->x1, pbox->y1,
+ pbox->x2-1, pbox->y2-1,
+ &new_x1, &new_y1,
+ &new_x2, &new_y2,
+ adx, ady,
+ &clip1, &clip2,
+ axis, (signdx == signdy),
+ oc1, oc2) == -1)
+ {
+ pbox++;;
+ continue;
+ }
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+
+ len += (clip2 != 0);
+ if (len)
+ {
+ /* unwind bresenham error term to first point */
+ if (clip1)
+ {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
+ else
+ err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
+ }
+ else
+ err = e;
+
+ WaitQueue(5);
+ outw(CUR_X, (short)new_x1);
+ outw(CUR_Y, (short)new_y1);
+ outw(ERR_TERM, (short)(err + fix));
+ outw(DESTY_AXSTP, (short)e1);
+ outw(DESTX_DIASTP, (short)e2);
+
+ dashidx2 = dashidx;
+ dashrem2 = pDash[dashidx2] - dashrem;
+ if (axis == X_AXIS)
+ miStepDash(clipdx, &dashidx2, pDash,
+ dashnum, &dashrem2);
+ else
+ miStepDash(clipdy, &dashidx2, pDash,
+ dashnum, &dashrem2);
+ dashrem2 = pDash[dashidx2] - dashrem2;
+
+ if (len < dashrem2)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx2 & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ if (dashidx2 & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ } else
+ {
+ if (dashrem2 > 0)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx2 & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)dashrem2);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)dashrem2);
+ if (dashidx2 & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ len -= dashrem2;
+ dashrem2 = 0;
+ dashidx2++;
+ if (dashidx2 == dashnum)
+ dashidx2 = 0;
+ }
+ while (pDash[dashidx2] <= len)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx2 & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)pDash[dashidx2]);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)pDash[dashidx2]);
+ if (dashidx2 & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ len -= pDash[dashidx2];
+ dashidx2++;
+ if (dashidx2 == dashnum)
+ dashidx2 = 0;
+ }
+ if (len > 0)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx2 & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ if (dashidx2 & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ }
+ }
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+
+ if (!dashupdated)
+ {
+ /* update dash position */
+ dashrem = pDash[dashidx] - dashrem;
+ if (axis == X_AXIS)
+ miStepDash(adx, &dashidx, pDash, dashnum, &dashrem);
+ else
+ miStepDash(ady, &dashidx, pDash, dashnum, &dashrem);
+ dashrem = pDash[dashidx] - dashrem;
+ }
+
+ } /* sloped line */
+ } /* while (--npt) */
+
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+#ifndef I8514DoubleDash
+ ((dashidx & 1) == 0) &&
+#endif
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1)))
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--)
+ {
+ if ((x2 >= pbox->x1) &&
+ (y2 >= pbox->y1) &&
+ (x2 < pbox->x2) &&
+ (y2 < pbox->y2))
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(5);
+ if (dashidx & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+#else
+ WaitQueue(4);
+#endif
+ outw(CUR_X, (short)x2);
+ outw(CUR_Y, (short)y2);
+ outw(MAJ_AXIS_PCNT, 0);
+ outw(CMD, CMD_LINE | DRAW | LINETYPE | PLANAR | WRTDATA);
+
+ break;
+ }
+ else
+ pbox++;
+ }
+ }
+
+ WaitQueue(2);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/dsseg.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/dsseg.c
new file mode 100644
index 000000000..b265468c1
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/dsseg.c
@@ -0,0 +1,485 @@
+/* $XConsortium: ibm8514dssg.c,v 1.2 94/04/17 20:30:31 dpw Exp $ */
+/*
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL, KEVIN E. MARTIN, AND TIAGO GONS DISCLAIM ALL WARRANTIES WITH REGARD TO
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL DIGITAL, KEVIN E. MARTIN, OR TIAGO GONS BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+Further modifications by Tiago Gons (tiago@comosjn.hobby.nl)
+
+*/
+
+/* 16-sep-93 TCG: ibm8514dssg.c from ibm8514dsln.c */
+
+
+
+#include "X.h"
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "mistruct.h"
+#include "miline.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "reg8514.h"
+#include "ibm8514.h"
+
+void
+#ifdef I8514DoubleDash
+ibm8514DoubleDashSegment(pDrawable, pGC, nseg, pSeg)
+#else
+ibm8514DashSegment(pDrawable, pGC, nseg, pSeg)
+#endif
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nseg;
+ register xSegment *pSeg;
+{
+ int nboxInit;
+ register int nbox;
+ BoxPtr pboxInit;
+ register BoxPtr pbox;
+
+ unsigned int oc1; /* outcode of point 1 */
+ unsigned int oc2; /* outcode of point 2 */
+
+ int xorg, yorg; /* origin of window */
+
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ short cmd = CMD_LINE | PLANAR | WRTDATA | LASTPIX;
+ short cmd2;
+ short fix;
+
+ int dash0len, dashidx, dashstartidx, dashnum, dashrem;
+ unsigned char *pDash;
+ /* a bunch of temporaries */
+ register int y1, y2;
+ register int x1, x2;
+ RegionPtr cclip;
+ cfbPrivGCPtr devPriv;
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema)
+ {
+ cfbSegmentSD(pDrawable, pGC, nseg, pSeg);
+ return;
+ }
+
+ devPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr);
+ cclip = devPriv->pCompositeClip;
+ pboxInit = REGION_RECTS(cclip);
+ nboxInit = REGION_NUM_RECTS(cclip);
+
+#ifdef I8514DoubleDash
+ WaitQueue(2);
+#else
+ WaitQueue(3);
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+#endif
+ outw(FRGD_MIX, FSS_FRGDCOL | ibm8514alu[pGC->alu]);
+ outw(WRT_MASK, (short)pGC->planemask);
+
+ pDash = (unsigned char *) pGC->dash;
+ dashnum = pGC->numInDashList;
+ dashstartidx = 0;
+ dash0len = 0;
+ miStepDash((int)pGC->dashOffset, &dashstartidx, pDash, dashnum, &dash0len);
+ dash0len = pDash[dashstartidx] - dash0len;
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+
+ while(nseg--)
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+
+ /* sloped line */
+ {
+ cmd2 = cmd;
+ signdx = 1;
+ if ((adx = x2 - x1) < 0)
+ {
+ adx = -adx;
+ signdx = -1;
+ fix = 0;
+ }
+ else
+ {
+ cmd2 |= INC_X;
+ fix = -1;
+ }
+ signdy = 1;
+ if ((ady = y2 - y1) < 0)
+ {
+ ady = -ady;
+ signdy = -1;
+ }
+ else
+ {
+ cmd2 |= INC_Y;
+ }
+
+ if (adx > ady)
+ {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ }
+ else
+ {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ cmd2 |= YMAJAXIS;
+ }
+
+ /* we have bresenham parameters and two points.
+ */
+
+ while(nbox--)
+ {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if ((oc1 | oc2) == 0)
+ {
+ if (axis == X_AXIS)
+ len = adx;
+ else
+ len = ady;
+
+ if (pGC->capStyle != CapNotLast)
+ len++;
+
+ /* setup 8514/A for (dashed) line */
+ WaitQueue(5);
+ outw(CUR_X, (short)x1);
+ outw(CUR_Y, (short)y1);
+ outw(ERR_TERM, (short)(e + fix));
+ outw(DESTY_AXSTP, (short)e1);
+ outw(DESTX_DIASTP, (short)e2);
+
+ dashidx = dashstartidx;
+ dashrem = dash0len;
+
+ if (len < dashrem)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ if (dashidx & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ } else
+ {
+ if (dashrem > 0)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)dashrem);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)dashrem);
+ if (dashidx & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ len -= dashrem;
+ dashrem = 0;
+ dashidx++;
+ if (dashidx == dashnum)
+ dashidx = 0;
+ }
+ while (pDash[dashidx] <= len)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)pDash[dashidx]);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)pDash[dashidx]);
+ if (dashidx & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ len -= pDash[dashidx];
+ dashidx++;
+ if (dashidx == dashnum)
+ dashidx = 0;
+ }
+ if (len > 0)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ if (dashidx & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ }
+ }
+
+ break;
+ }
+ else if (oc1 & oc2)
+ {
+ pbox++;
+ }
+ else
+ {
+ /*
+ * let the mfb helper routine do our work;
+ * better than duplicating code...
+ */
+ int err; /* modified bresenham error term */
+ int clip1=0, clip2=0;/* clippedness of the endpoints */
+ int clipdx = 0; /* difference between clipped and */
+ int clipdy = 0; /* unclipped start point */
+ DDXPointRec pt1;
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+
+ if (miZeroClipLine(pbox->x1, pbox->y1,
+ pbox->x2-1, pbox->y2-1,
+ &new_x1, &new_y1,
+ &new_x2, &new_y2,
+ adx, ady,
+ &clip1, &clip2,
+ axis, (signdx == signdy),
+ oc1, oc2) == -1)
+ {
+ pbox++;
+ continue;
+ }
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+
+ if (len)
+ {
+ /* unwind bresenham error term to first point */
+ if (clip1)
+ {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
+ else
+ err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
+ }
+ else
+ err = e;
+
+ WaitQueue(5);
+ outw(CUR_X, (short)new_x1);
+ outw(CUR_Y, (short)new_y1);
+ outw(ERR_TERM, (short)(err + fix));
+ outw(DESTY_AXSTP, (short)e1);
+ outw(DESTX_DIASTP, (short)e2);
+
+ dashidx = dashstartidx;
+ dashrem = pDash[dashidx] - dash0len;
+ if (axis == X_AXIS)
+ miStepDash(clipdx, &dashidx, pDash,
+ dashnum, &dashrem);
+ else
+ miStepDash(clipdy, &dashidx, pDash,
+ dashnum, &dashrem);
+ dashrem = pDash[dashidx] - dashrem;
+
+ if (len < dashrem)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ if (dashidx & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ } else
+ {
+ if (dashrem > 0)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)dashrem);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)dashrem);
+ if (dashidx & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ len -= dashrem;
+ dashrem = 0;
+ dashidx++;
+ if (dashidx == dashnum)
+ dashidx = 0;
+ }
+ while (pDash[dashidx] <= len)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)pDash[dashidx]);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)pDash[dashidx]);
+ if (dashidx & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ len -= pDash[dashidx];
+ dashidx++;
+ if (dashidx == dashnum)
+ dashidx = 0;
+ }
+ if (len > 0)
+ {
+#ifdef I8514DoubleDash
+ WaitQueue(3);
+ if (dashidx & 1)
+ outw(FRGD_COLOR, (short)pGC->bgPixel);
+ else
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ outw(CMD, cmd2 | DRAW);
+#else
+ WaitQueue(2);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ if (dashidx & 1)
+ outw(CMD, cmd2);
+ else
+ outw(CMD, cmd2 | DRAW);
+#endif
+ }
+ }
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+ } /* sloped line */
+ } /* while (nseg--) */
+
+ WaitQueue(2);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/fc.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/fc.c
new file mode 100644
index 000000000..65b55eb16
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/fc.c
@@ -0,0 +1,204 @@
+/* $XConsortium: ibm8514fc.c,v 1.1 94/03/28 21:03:51 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/ibm8514/fc.c,v 3.1 1994/08/01 12:09:37 dawes Exp $ */
+/*
+ * Copyright 1992 by Kevin E. Martin, Chapel Hill, North Carolina.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Kevin E. Martin not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. Kevin E. Martin makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEVIN E. MARTIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEVIN E. MARTIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/*
+ * Extract from s3fcach.c
+ * Adapted to 8514, Hans Nasten. (nasten@everyware.se).
+ */
+
+#include "X.h"
+#include "Xmd.h"
+#include "Xproto.h"
+#include "cfb.h"
+#include "misc.h"
+#include "xf86.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "fontstruct.h"
+#include "dixfontstr.h"
+#include "xf86bcache.h"
+#include "xf86fcache.h"
+#include "ibm8514.h"
+#include "reg8514.h"
+
+
+static unsigned long FontAge;
+#define NEXT_FONT_AGE ++FontAge
+
+/*
+ * When using the 8514 compatible read mask, the read mask
+ * is rotated right 1 bit compared to the write mask.
+ */
+
+unsigned char ibm8514cachemask[ 8 ] = { 0x01, 0x02, 0x04, 0x08,
+ 0x10, 0x20, 0x40, 0x80
+};
+unsigned char ibm8514cachemaskswapped[ 8 ] = { 0x02, 0x04, 0x08, 0x10,
+ 0x20, 0x40, 0x80, 0x01
+};
+
+/*
+ * Move the glyphs to the screen using the GE.
+ */
+static void
+Doibm8514CPolyText8(x, y, count, chars, fentry, pGC, pBox)
+ int x, y, count;
+ unsigned char *chars;
+ CacheFont8Ptr fentry;
+ GCPtr pGC;
+ BoxPtr pBox;
+{
+ int gHeight;
+ int w = fentry->w;
+ int blocki = 255;
+ unsigned short height = 0; /* Cache for height, width and */
+ unsigned short width = 0; /* readmask registers. */
+ unsigned short pmsk = 0; /* ( Out instructions _are_ expensive ). */
+
+ for (;count > 0; count--, chars++) {
+ CharInfoPtr pci;
+ short xoff;
+
+ pci = fentry->pci[*chars];
+ if (pci != NULL) {
+ gHeight = GLYPHHEIGHTPIXELS(pci);
+ if (gHeight) {
+ if (*chars / 32 != blocki) {
+ bitMapBlockPtr block;
+
+ blocki = *chars / 32;
+ if( ( block = fentry->fblock[blocki] ) == NULL) {
+ /*
+ * Reset the GE context to a known state before
+ * calling the xf86loadfontblock function.
+ */
+ WaitQueue(8);
+ outw(MULTIFUNC_CNTL, SCISSORS_T | 0);
+ outw(MULTIFUNC_CNTL, SCISSORS_L | 0);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | 1023);
+ outw(MULTIFUNC_CNTL, SCISSORS_B | 1023);
+ outw(RD_MASK, 0xff);
+ outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+ xf86loadFontBlock(fentry, blocki);
+ block = fentry->fblock[blocki];
+ /*
+ * Restore the GE context.
+ */
+ WaitQueue(4);
+ outw(MULTIFUNC_CNTL, SCISSORS_L | (short)pBox->x1);
+ outw(MULTIFUNC_CNTL, SCISSORS_T | (short)pBox->y1);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | (short)(pBox->x2 - 1));
+ outw(MULTIFUNC_CNTL, SCISSORS_B | (short)(pBox->y2 - 1));
+ WaitQueue(5);
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_EXPBLT | COLCMPOP_F);
+ outw(FRGD_MIX, FSS_FRGDCOL | ibm8514alu[pGC->alu]);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_DST);
+ outw(WRT_MASK, (short)pGC->planemask);
+ height = width = pmsk = 0; /* Invalidate register caches. */
+ }
+ WaitQueue(2);
+ outw(CUR_Y, block->y);
+ /*
+ * Is the readmask altered ?
+ */
+ if( ibm8514cachemaskswapped[block->id] != pmsk ) {
+ pmsk = ibm8514cachemaskswapped[block->id];
+ outw(RD_MASK, pmsk);
+ }
+ xoff = block->x;
+ block->lru = NEXT_FONT_AGE;
+ }
+
+ WaitQueue(6);
+ outw(CUR_X, (short) (xoff + (*chars & 0x1f) * w));
+ outw(DESTX_DIASTP,
+ (short)(x + pci->metrics.leftSideBearing));
+ outw(DESTY_AXSTP, (short)(y - pci->metrics.ascent));
+ /*
+ * Need to update width register ?
+ */
+ if( (short)(GLYPHWIDTHPIXELS(pci)) != width) {
+ width = (short)(GLYPHWIDTHPIXELS(pci));
+ outw(MAJ_AXIS_PCNT, width - 1);
+ }
+ /*
+ * How about the height register ?
+ */
+ if( (short)(gHeight) != height ) {
+ height = (short)(gHeight);
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | height - 1);
+ }
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+ }
+ x += pci->metrics.characterWidth;
+ }
+ }
+
+}
+
+/*
+ * Set the hardware scissors to match the clipping rectangles and
+ * call the glyph output routine.
+ */
+void ibm8514GlyphWrite( x, y, count, chars, fentry, pGC, pBox, numRects )
+int x, y, count, numRects;
+unsigned char *chars;
+CacheFont8Ptr fentry;
+GCPtr pGC;
+BoxPtr pBox;
+
+{
+
+ WaitQueue(5);
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_EXPBLT | COLCMPOP_F);
+ outw(FRGD_MIX, FSS_FRGDCOL | ibm8514alu[pGC->alu]);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_DST);
+ outw(WRT_MASK, (short)pGC->planemask);
+
+ for (; --numRects >= 0; ++pBox) {
+ WaitQueue(4);
+ outw(MULTIFUNC_CNTL, SCISSORS_L | (short)pBox->x1);
+ outw(MULTIFUNC_CNTL, SCISSORS_T | (short)pBox->y1);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | (short)(pBox->x2 - 1));
+ outw(MULTIFUNC_CNTL, SCISSORS_B | (short)(pBox->y2 - 1));
+
+ Doibm8514CPolyText8(x, y, count, chars, fentry, pGC, pBox);
+ }
+
+ WaitQueue(8);
+ outw(MULTIFUNC_CNTL, SCISSORS_T | 0);
+ outw(MULTIFUNC_CNTL, SCISSORS_L | 0);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | 1023);
+ outw(MULTIFUNC_CNTL, SCISSORS_B | 1023);
+ outw(RD_MASK, 0xff);
+ outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/fcach.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/fcach.c
new file mode 100644
index 000000000..9fd81b19d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/fcach.c
@@ -0,0 +1,97 @@
+/* $XConsortium: ibm8514fcac.c,v 1.1 94/03/28 21:03:58 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/ibm8514/fcach.c,v 3.3 1995/01/26 02:17:18 dawes Exp $ */
+/*
+ * Copyright 1992 by Kevin E. Martin, Chapel Hill, North Carolina.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Kevin E. Martin not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Kevin E. Martin makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * KEVIN E. MARTIN AND RICKARD E. FAITH DISCLAIM ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL KEVIN E. MARTIN OR RICKARD E. FAITH BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+#include "X.h"
+#include "Xmd.h"
+#include "Xproto.h"
+#include "cfb.h"
+#include "misc.h"
+#include "reg8514.h"
+#include "ibm8514.h"
+#include "xf86bcache.h"
+#include "xf86fcache.h"
+#include "xf86text.h"
+#include "8514cach.h"
+
+#define XCONFIG_FLAGS_ONLY
+#include "xf86_Config.h"
+extern Bool xf86Verbose;
+
+#define ALIGNMENT 8
+#define N_PLANES 8
+#define PIXMAP_WIDTH 64
+
+void
+ibm8514FontCache8Init()
+{
+ static int first = 1;
+ int x, y, w, h;
+ unsigned int BitPlane;
+ CachePool FontPool;
+
+ x = PIXMAP_WIDTH;
+ y = ibm8514InfoRec.virtualY;
+ w = ibm8514InfoRec.virtualX - x;
+ h = 1024 - ibm8514InfoRec.virtualY;
+ if( h >= PIXMAP_WIDTH && first ) {
+ ibm8514InitFrect( 0, y, PIXMAP_WIDTH );
+ ErrorF( "%s %s: Using a single %dx%d area for expanding pixmaps\n",
+ XCONFIG_PROBED, ibm8514InfoRec.name, PIXMAP_WIDTH,PIXMAP_WIDTH );
+ }
+ else if( first )
+ ErrorF( "%s %s: No pixmap expanding area available\n",
+ XCONFIG_PROBED, ibm8514InfoRec.name );
+
+ /*
+ * Don't allow a font cache if we don't have room for at least
+ * 2 complete 6x13 fonts.
+ */
+ if( w >= 6*32 && h >= 2*13 ) {
+ if( first ) {
+ FontPool = xf86CreateCachePool( ALIGNMENT );
+ for( BitPlane = 0; BitPlane < N_PLANES; BitPlane++ )
+ xf86AddToCachePool( FontPool, x, y, w, h, BitPlane );
+
+ xf86InitFontCache( FontPool, w, h, ibm8514FontOpStipple );
+ xf86InitText( ibm8514GlyphWrite, ibm8514NoCPolyText,
+ ibm8514NoCImageText );
+
+ ErrorF( "%s %s: Using %d planes of %dx%d at %dx%d aligned %d as font cache\n",
+ XCONFIG_PROBED, ibm8514InfoRec.name,
+ N_PLANES, w, h, x, y, ALIGNMENT );
+ }
+ else
+ xf86ReleaseFontCache();
+ }
+ else if( first ) {
+ /*
+ * Crash and burn if the cached glyph write function gets called.
+ */
+ xf86InitText( NULL, ibm8514NoCPolyText, ibm8514NoCImageText );
+ ErrorF( "%s %s: No font cache available\n",
+ XCONFIG_PROBED, ibm8514InfoRec.name );
+ }
+ first = 0;
+
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/font.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/font.c
new file mode 100644
index 000000000..71a1fc833
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/font.c
@@ -0,0 +1,54 @@
+/* $XConsortium: ibm8514font.c,v 1.1 94/03/28 21:04:04 dpw Exp $ */
+/*
+ * Copyright 1992 by Kevin E. Martin, Chapel Hill, North Carolina.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Kevin E. Martin not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Kevin E. Martin makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * KEVIN E. MARTIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEVIN E. MARTIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+
+#include "X.h"
+#include "Xmd.h"
+#include "Xproto.h"
+#include "mfb.h"
+#include "fontstruct.h"
+#include "dixfontstr.h"
+#include "scrnintstr.h"
+#include "ibm8514.h"
+#include "xf86bcache.h"
+#include "xf86fcache.h"
+
+Bool
+ibm8514RealizeFont(pScreen, font)
+ ScreenPtr pScreen;
+ FontPtr font;
+{
+ /* We _should_ probably be caching things here */
+ /* (void)xf86CacheFont8(font); */
+ return mfbRealizeFont(pScreen, font);
+}
+
+Bool
+ibm8514UnrealizeFont(pScreen, font)
+ ScreenPtr pScreen;
+ FontPtr font;
+{
+ xf86UnCacheFont8(font);
+ return mfbUnrealizeFont(pScreen, font);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/frect.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/frect.c
new file mode 100644
index 000000000..e533bbb3d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/frect.c
@@ -0,0 +1,831 @@
+/* $XConsortium: ibm8514frec.c,v 1.2 94/04/17 20:30:32 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/ibm8514/frect.c,v 3.1 1994/11/26 12:40:53 dawes Exp $ */
+/*
+ * Fill rectangles.
+ */
+
+/*
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+
+KEVIN E. MARTIN AND TIAGO GONS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL KEVIN E. MARTIN OR TIAGO GONS BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Modified by Tiago Gons (tiago@comosjn.hobby.nl)
+
+Simple expansion of tiles added by incorporating parts of the code from
+mach8pcach.c 94-07-12, Hans Nasten ( nasten@everyware.se ).
+
+*/
+
+
+/* $XConsortium: ibm8514frec.c,v 1.2 94/04/17 20:30:32 dpw Exp $ */
+
+#include "X.h"
+#include "Xmd.h"
+#include "servermd.h"
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "mergerop.h"
+
+#include "reg8514.h"
+#include "ibm8514.h"
+
+#define NUM_STACK_RECTS 1024
+
+
+typedef struct _CacheInfo {
+ int x;
+ int y;
+ int w;
+ int h;
+ int nx;
+ int ny;
+ int pix_w;
+ int pix_h;
+} CacheInfo, *CacheInfoPtr;
+
+static CacheInfo cInfo;
+static int pixmap_x;
+static int pixmap_y;
+static int pixmap_size = 0;
+
+void ibm8514InitFrect( x, y, size )
+int x, y, size;
+{
+
+ pixmap_x = x;
+ pixmap_y = y;
+ pixmap_size = size;
+
+}
+
+static void DoCacheExpandPixmap( pci )
+CacheInfoPtr pci;
+{
+ int cur_w = pci->pix_w;
+ int cur_h = pci->pix_h;
+
+ WaitQueue(7);
+ outw(MULTIFUNC_CNTL, SCISSORS_T | 0);
+ outw(MULTIFUNC_CNTL, SCISSORS_L | 0);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | 1023);
+ outw(MULTIFUNC_CNTL, SCISSORS_B | 1023);
+ outw(FRGD_MIX, FSS_BITBLT | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+ outw(WRT_MASK, 0xffff);
+
+ /* Expand in the x direction */
+ while (cur_w * 2 <= pci->w) {
+ WaitQueue(7);
+ outw(CUR_X, (short)pci->x);
+ outw(CUR_Y, (short)pci->y);
+ outw(DESTX_DIASTP, (short)(pci->x + cur_w));
+ outw(DESTY_AXSTP, (short)pci->y);
+ outw(MAJ_AXIS_PCNT, (short)(cur_w - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(cur_h - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+
+ cur_w *= 2;
+ }
+
+ if (cur_w != pci->w) {
+ WaitQueue(7);
+ outw(CUR_X, (short)pci->x);
+ outw(CUR_Y, (short)pci->y);
+ outw(DESTX_DIASTP, (short)(pci->x + cur_w));
+ outw(DESTY_AXSTP, (short)pci->y);
+ outw(MAJ_AXIS_PCNT, (short)(pci->w - cur_w - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(cur_h - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+
+ cur_w = pci->w;
+ }
+
+ /* Expand in the y direction */
+ while (cur_h * 2 <= pci->h) {
+ WaitQueue(7);
+ outw(CUR_X, (short)pci->x);
+ outw(CUR_Y, (short)pci->y);
+ outw(DESTX_DIASTP, (short)pci->x);
+ outw(DESTY_AXSTP, (short)(pci->y + cur_h));
+ outw(MAJ_AXIS_PCNT, (short)(cur_w - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(cur_h - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+
+ cur_h *= 2;
+ }
+
+ if (cur_h != pci->h) {
+ WaitQueue(7);
+ outw(CUR_X, (short)pci->x);
+ outw(CUR_Y, (short)pci->y);
+ outw(DESTX_DIASTP, (short)pci->x);
+ outw(DESTY_AXSTP, (short)(pci->y + cur_h));
+ outw(MAJ_AXIS_PCNT, (short)(cur_w - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(pci->h - cur_h - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+ }
+
+ WaitQueue(2);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+}
+
+
+static CacheInfoPtr DoCacheTile( pix )
+PixmapPtr pix;
+{
+ CacheInfoPtr pci = &cInfo;
+
+ if( pixmap_size && pix->drawable.width <= pixmap_size
+ && pix->drawable.height <= pixmap_size ) {
+ pci->pix_w = pix->drawable.width;
+ pci->pix_h = pix->drawable.height;
+ pci->nx = pixmap_size/pix->drawable.width;
+ pci->ny = pixmap_size/pix->drawable.height;
+ pci->x = pixmap_x;
+ pci->y = pixmap_y;
+ pci->w = pci->nx * pci->pix_w;
+ pci->h = pci->ny * pci->pix_h;
+ ibm8514ImageWrite( pci->x, pci->y, pci->pix_w, pci->pix_h,
+ pix->devPrivate.ptr, pix->devKind, 0, 0,
+ MIX_SRC, 0xffff );
+
+ DoCacheExpandPixmap( pci );
+ return( pci );
+ }
+ else
+ return( NULL );
+}
+
+static CacheInfoPtr DoCacheOpStipple( pix )
+PixmapPtr pix;
+{
+ CacheInfoPtr pci = &cInfo;
+
+ if( pixmap_size && pix->drawable.width <= pixmap_size
+ && pix->drawable.height <= pixmap_size ) {
+ pci->pix_w = pix->drawable.width;
+ pci->pix_h = pix->drawable.height;
+ pci->nx = pixmap_size/pix->drawable.width;
+ pci->ny = pixmap_size/pix->drawable.height;
+ pci->x = pixmap_x;
+ pci->y = pixmap_y;
+ pci->w = pci->nx * pci->pix_w;
+ pci->h = pci->ny * pci->pix_h;
+ ibm8514ImageStipple( pci->x, pci->y, pci->pix_w, pci->pix_h,
+ pix->devPrivate.ptr, pix->devKind,
+ pci->pix_w, pci->pix_h, pci->x, pci->y,
+ 255, 0, MIX_SRC, 0xffff, 1 );
+
+ DoCacheExpandPixmap( pci );
+ return( pci );
+ }
+ else
+ return( NULL );
+}
+
+
+static void DoCacheImageFill( pci, x, y, w, h, pox, poy, fgalu, bgalu,
+ fgmix, bgmix, planemask)
+CacheInfoPtr pci;
+int x;
+int y;
+int w;
+int h;
+int pox;
+int poy;
+short fgalu;
+short bgalu;
+short fgmix;
+short bgmix;
+unsigned long planemask;
+{
+ int xwmid, ywmid, orig_xwmid;
+ int startx, starty, endx, endy;
+ int orig_x = x;
+
+ if (w == 0 || h == 0)
+ return;
+
+ modulus(x - pox, pci->w, startx);
+ modulus(y - poy, pci->h, starty);
+ modulus(x - pox + w - 1, pci->w, endx);
+ modulus(y - poy + h - 1, pci->h, endy);
+
+ orig_xwmid = xwmid = w - (pci->w - startx + endx + 1);
+ ywmid = h - (pci->h - starty + endy + 1);
+
+ WaitQueue(7);
+ outw(MULTIFUNC_CNTL, SCISSORS_T | 0);
+ outw(MULTIFUNC_CNTL, SCISSORS_L | 0);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | 1023);
+ outw(MULTIFUNC_CNTL, SCISSORS_B | 1023);
+ outw(FRGD_MIX, fgmix | fgalu);
+ outw(BKGD_MIX, bgmix | bgalu);
+ outw(WRT_MASK, planemask);
+
+ if (starty + h - 1 < pci->h) {
+ if (startx + w - 1 < pci->w) {
+ WaitQueue(7);
+ outw(CUR_X, (short)(pci->x + startx));
+ outw(CUR_Y, (short)(pci->y + starty));
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)(w - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(h - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+ } else {
+ WaitQueue(7);
+ outw(CUR_X, (short)(pci->x + startx));
+ outw(CUR_Y, (short)(pci->y + starty));
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)(pci->w - startx - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(h - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+
+ x += pci->w - startx;
+
+ while (xwmid > 0) {
+ WaitQueue(7);
+ outw(CUR_X, (short)pci->x);
+ outw(CUR_Y, (short)(pci-> y + starty));
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)(pci->w - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(h - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR |
+ WRTDATA);
+ x += pci->w;
+ xwmid -= pci->w;
+ }
+
+ WaitQueue(7);
+ outw(CUR_X, (short)pci->x);
+ outw(CUR_Y, (short)(pci->y + starty));
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)endx);
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(h - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+ }
+ } else if (startx + w - 1 < pci->w) {
+ WaitQueue(7);
+ outw(CUR_X, (short)(pci->x + startx));
+ outw(CUR_Y, (short)(pci->y + starty));
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)(w - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(pci->h - starty - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+
+ y += pci->h - starty;
+
+ while (ywmid > 0) {
+ WaitQueue(7);
+ outw(CUR_X, (short)(pci->x + startx));
+ outw(CUR_Y, (short)pci->y);
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)(w - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(pci->h - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+
+ y += pci->h;
+ ywmid -= pci->h;
+ }
+
+ WaitQueue(7);
+ outw(CUR_X, (short)(pci->x + startx));
+ outw(CUR_Y, (short)pci->y);
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)(w - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)endy);
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+ } else {
+ WaitQueue(7);
+ outw(CUR_X, (short)(pci->x + startx));
+ outw(CUR_Y, (short)(pci->y + starty));
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)(pci->w - startx - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(pci->h - starty - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+
+ x += pci->w - startx;
+
+ while (xwmid > 0) {
+ WaitQueue(7);
+ outw(CUR_X, (short)pci->x);
+ outw(CUR_Y, (short)(pci->y + starty));
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)(pci->w - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT |
+ (short)(pci->h - starty - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+
+ x += pci->w;
+ xwmid -= pci->w;
+ }
+
+ WaitQueue(7);
+ outw(CUR_X, (short)pci->x);
+ outw(CUR_Y, (short)(pci->y + starty));
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)endx);
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(pci->h - starty - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+
+ y += pci->h - starty;
+
+ while (ywmid > 0) {
+ x = orig_x;
+ xwmid = orig_xwmid;
+
+ WaitQueue(7);
+ outw(CUR_X, (short)(pci-> x + startx));
+ outw(CUR_Y, (short)pci->y);
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)(pci->w - startx - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(pci->h - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+
+ x += pci->w - startx;
+
+ while (xwmid > 0) {
+ WaitQueue(7);
+ outw(CUR_X, (short)pci->x);
+ outw(CUR_Y, (short)pci->y);
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)(pci->w - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(pci->h - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR |
+ WRTDATA);
+
+ x += pci->w;
+ xwmid -= pci->w;
+ }
+
+ WaitQueue(7);
+ outw(CUR_X, (short)pci->x);
+ outw(CUR_Y, (short)pci->y);
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)endx);
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(pci->h - 1));
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+
+ y += pci->h;
+ ywmid -= pci->h;
+ }
+
+ x = orig_x;
+ xwmid = orig_xwmid;
+
+ WaitQueue(7);
+ outw(CUR_X, (short)(pci->x + startx));
+ outw(CUR_Y, (short)pci->y);
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)(pci->w - startx - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)endy);
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+
+ x += pci->w - startx;
+
+ while (xwmid > 0) {
+ WaitQueue(7);
+ outw(CUR_X, (short)pci->x);
+ outw(CUR_Y, (short)pci->y);
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)(pci->w - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)endy);
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+
+ x += pci->w;
+ xwmid -= pci->w;
+ }
+
+ WaitQueue(7);
+ outw(CUR_X, (short)pci->x);
+ outw(CUR_Y, (short)pci->y);
+ outw(DESTX_DIASTP, (short)x);
+ outw(DESTY_AXSTP, (short)y);
+ outw(MAJ_AXIS_PCNT, (short)endx);
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)endy);
+ outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
+ }
+
+ WaitQueue(2);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+}
+
+
+static void ibm8514CImageFill( pci, x, y, w, h, pox, poy, alu, planemask )
+CacheInfoPtr pci;
+int x;
+int y;
+int w;
+int h;
+int pox;
+int poy;
+short alu;
+unsigned long planemask;
+{
+
+ DoCacheImageFill( pci, x, y, w, h, pox, poy, alu,
+ MIX_SRC, FSS_BITBLT, BSS_BITBLT, planemask );
+
+}
+
+static void ibm8514CImageStipple( pci, x, y, w, h, pox, poy,
+ fg, alu, planemask )
+CacheInfoPtr pci;
+int x;
+int y;
+int w;
+int h;
+int pox;
+int poy;
+unsigned long fg;
+short alu;
+unsigned long planemask;
+{
+
+ WaitQueue(3);
+ outw(FRGD_COLOR, fg);
+ outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_EXPBLT | COLCMPOP_F);
+ outw(RD_MASK, 0x01);
+
+ DoCacheImageFill( pci, x, y, w, h, pox, poy, alu,
+ MIX_DST, FSS_FRGDCOL, BSS_BKGDCOL, planemask );
+
+ WaitQueue(2);
+ outw(RD_MASK, 0xff);
+ outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);
+
+}
+
+static void ibm8514CImageOpStipple( pci, x, y, w, h, pox, poy,
+ fg, bg, alu, planemask )
+CacheInfoPtr pci;
+int x;
+int y;
+int w;
+int h;
+int pox;
+int poy;
+unsigned long fg;
+unsigned long bg;
+short alu;
+unsigned long planemask;
+{
+
+ WaitQueue(4);
+ outw(FRGD_COLOR, fg);
+ outw(BKGD_COLOR, bg);
+ outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_EXPBLT | COLCMPOP_F);
+ outw(RD_MASK, 0x01);
+
+ DoCacheImageFill( pci, x, y, w, h, pox, poy, alu, alu,
+ FSS_FRGDCOL, BSS_BKGDCOL, planemask );
+
+ WaitQueue(2);
+ outw(RD_MASK, 0xff);
+ outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);
+
+}
+
+void
+ibm8514PolyFillRect(pDrawable, pGC, nrectFill, prectInit)
+ DrawablePtr pDrawable;
+ register GCPtr pGC;
+ int nrectFill; /* number of rectangles to fill */
+ xRectangle *prectInit; /* Pointer to first rectangle to fill */
+{
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ register BoxPtr pbox;
+ register BoxPtr pboxClipped;
+ BoxPtr pboxClippedBase;
+ BoxPtr pextent;
+ BoxRec stackRects[NUM_STACK_RECTS];
+ cfbPrivGC *priv;
+ int numRects;
+ int n;
+ int xorg, yorg;
+ int width, height;
+ PixmapPtr pPix;
+ int pixWidth;
+ int xrot, yrot;
+ CacheInfoPtr pci;
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema)
+ {
+ cfbPolyFillRect(pDrawable, pGC, nrectFill, prectInit);
+ return;
+ }
+
+ priv = (cfbPrivGC *) pGC->devPrivates[cfbGCPrivateIndex].ptr;
+ prgnClip = priv->pCompositeClip;
+
+ prect = prectInit;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ if (xorg || yorg)
+ {
+ prect = prectInit;
+ n = nrectFill;
+ while(n--)
+ {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+ prect = prectInit;
+
+ numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
+ if (numRects > NUM_STACK_RECTS)
+ {
+ pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(numRects * sizeof(BoxRec));
+ if (!pboxClippedBase)
+ return;
+ }
+ else
+ pboxClippedBase = stackRects;
+
+ pboxClipped = pboxClippedBase;
+
+ if (REGION_NUM_RECTS(prgnClip) == 1)
+ {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_RECTS(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--)
+ {
+ if ((pboxClipped->x1 = prect->x) < x1)
+ pboxClipped->x1 = x1;
+
+ if ((pboxClipped->y1 = prect->y) < y1)
+ pboxClipped->y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ pboxClipped->x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ pboxClipped->y2 = by2;
+
+ prect++;
+ if ((pboxClipped->x1 < pboxClipped->x2) &&
+ (pboxClipped->y1 < pboxClipped->y2))
+ {
+ pboxClipped++;
+ }
+ }
+ }
+ else
+ {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = (*pGC->pScreen->RegionExtents)(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--)
+ {
+ BoxRec box;
+
+ if ((box.x1 = prect->x) < x1)
+ box.x1 = x1;
+
+ if ((box.y1 = prect->y) < y1)
+ box.y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ box.x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ box.y2 = by2;
+
+ prect++;
+
+ if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ continue;
+
+ n = REGION_NUM_RECTS (prgnClip);
+ pbox = REGION_RECTS(prgnClip);
+
+ /* clip the rectangle to each box in the clip region
+ this is logically equivalent to calling Intersect()
+ */
+ while(n--)
+ {
+ pboxClipped->x1 = max(box.x1, pbox->x1);
+ pboxClipped->y1 = max(box.y1, pbox->y1);
+ pboxClipped->x2 = min(box.x2, pbox->x2);
+ pboxClipped->y2 = min(box.y2, pbox->y2);
+ pbox++;
+
+ /* see if clipping left anything */
+ if(pboxClipped->x1 < pboxClipped->x2 &&
+ pboxClipped->y1 < pboxClipped->y2)
+ {
+ pboxClipped++;
+ }
+ }
+ }
+ }
+
+ if (pboxClipped != pboxClippedBase) {
+ n = pboxClipped-pboxClippedBase;
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ WaitQueue(3);
+ outw(FRGD_COLOR, (short)(pGC->fgPixel));
+ outw(FRGD_MIX, FSS_FRGDCOL | ibm8514alu[pGC->alu]);
+ outw(WRT_MASK, (short)pGC->planemask);
+
+ pboxClipped = pboxClippedBase;
+ while (n--) {
+ WaitQueue(5);
+ outw(CUR_X, (short)(pboxClipped->x1));
+ outw(CUR_Y, (short)(pboxClipped->y1));
+ outw(MAJ_AXIS_PCNT,
+ (short)(pboxClipped->x2 - pboxClipped->x1 - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT |
+ (short)(pboxClipped->y2 - pboxClipped->y1 - 1));
+ outw(CMD, CMD_RECT | INC_Y | INC_X | DRAW | PLANAR | WRTDATA);
+
+ pboxClipped++;
+ }
+
+ WaitQueue(2);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+ break;
+ case FillTiled:
+ xrot = pDrawable->x + pGC->patOrg.x;
+ yrot = pDrawable->y + pGC->patOrg.y;
+
+ pPix = pGC->tile.pixmap;
+ width = pPix->drawable.width;
+ height = pPix->drawable.height;
+ pixWidth = PixmapBytePad(width, pPix->drawable.depth);
+
+ pboxClipped = pboxClippedBase;
+ if( pci = DoCacheTile( pPix ) ) {
+ while (n--) {
+ ibm8514CImageFill(pci,
+ pboxClipped->x1, pboxClipped->y1,
+ pboxClipped->x2 - pboxClipped->x1,
+ pboxClipped->y2 - pboxClipped->y1,
+ xrot, yrot,
+ ibm8514alu[pGC->alu], pGC->planemask);
+ pboxClipped++;
+ }
+ } else {
+ while (n--) {
+ ibm8514ImageFill(pboxClipped->x1, pboxClipped->y1,
+ pboxClipped->x2 - pboxClipped->x1,
+ pboxClipped->y2 - pboxClipped->y1,
+ pPix->devPrivate.ptr, pixWidth,
+ width, height, xrot, yrot,
+ ibm8514alu[pGC->alu], pGC->planemask);
+ pboxClipped++;
+ }
+ }
+ break;
+ case FillStippled:
+ xrot = pDrawable->x + pGC->patOrg.x;
+ yrot = pDrawable->y + pGC->patOrg.y;
+
+ pPix = pGC->stipple;
+ width = pPix->drawable.width;
+ height = pPix->drawable.height;
+ pixWidth = PixmapBytePad(width, pPix->drawable.depth);
+
+ pboxClipped = pboxClippedBase;
+ if( pci = DoCacheOpStipple( pPix ) ) {
+ while (n--) {
+ ibm8514CImageStipple(pci,
+ pboxClipped->x1, pboxClipped->y1,
+ pboxClipped->x2 - pboxClipped->x1,
+ pboxClipped->y2 - pboxClipped->y1,
+ xrot, yrot, pGC->fgPixel,
+ ibm8514alu[pGC->alu], pGC->planemask);
+ pboxClipped++;
+ }
+ } else {
+ while (n--) {
+ ibm8514ImageStipple(pboxClipped->x1, pboxClipped->y1,
+ pboxClipped->x2 - pboxClipped->x1,
+ pboxClipped->y2 - pboxClipped->y1,
+ pPix->devPrivate.ptr, pixWidth,
+ width, height, xrot, yrot,
+ pGC->fgPixel, 0,
+ ibm8514alu[pGC->alu],
+ pGC->planemask, 0);
+ pboxClipped++;
+ }
+ }
+ break;
+ case FillOpaqueStippled:
+ xrot = pDrawable->x + pGC->patOrg.x;
+ yrot = pDrawable->y + pGC->patOrg.y;
+
+ pPix = pGC->stipple;
+ width = pPix->drawable.width;
+ height = pPix->drawable.height;
+ pixWidth = PixmapBytePad(width, pPix->drawable.depth);
+
+ pboxClipped = pboxClippedBase;
+ if( pci = DoCacheOpStipple( pPix ) ) {
+ while (n--) {
+ ibm8514CImageOpStipple(pci,
+ pboxClipped->x1, pboxClipped->y1,
+ pboxClipped->x2 - pboxClipped->x1,
+ pboxClipped->y2 - pboxClipped->y1,
+ xrot, yrot,
+ pGC->fgPixel, pGC->bgPixel,
+ ibm8514alu[pGC->alu],
+ pGC->planemask);
+ pboxClipped++;
+ }
+ } else {
+ while (n--) {
+ ibm8514ImageStipple(pboxClipped->x1, pboxClipped->y1,
+ pboxClipped->x2 - pboxClipped->x1,
+ pboxClipped->y2 - pboxClipped->y1,
+ pPix->devPrivate.ptr, pixWidth,
+ width, height, xrot, yrot,
+ pGC->fgPixel, pGC->bgPixel,
+ ibm8514alu[pGC->alu],
+ pGC->planemask, 1);
+ pboxClipped++;
+ }
+ }
+ break;
+ }
+ }
+ if (pboxClippedBase != stackRects)
+ DEALLOCATE_LOCAL(pboxClippedBase);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/fs.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/fs.c
new file mode 100644
index 000000000..12b4c3572
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/fs.c
@@ -0,0 +1,428 @@
+/* $XConsortium: ibm8514fs.c,v 1.2 94/04/17 20:30:33 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/ibm8514/fs.c,v 3.1 1994/08/01 12:09:38 dawes Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/***********************************************************
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+Rewritten for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+
+KEVIN E. MARTIN AND TIAGO GONS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL KEVIN E. MARTIN OR TIAGO GONS BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Modified by Tiago Gons (tiago@comosjn.hobby.nl)
+
+******************************************************************/
+
+
+#include "X.h"
+#include "Xmd.h"
+#include "servermd.h"
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+#include "cfb.h"
+
+#include "reg8514.h"
+#include "ibm8514.h"
+
+void
+ibm8514SolidFSpans (pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ DDXPointPtr initPpt;
+ int *initPwidth;
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema)
+ {
+ cfbSolidSpansGeneral(pDrawable, pGC,
+ nInit, pptInit, pwidthInit, fSorted);
+ return;
+ }
+
+ if (pDrawable->type != DRAWABLE_WINDOW) {
+ switch (pDrawable->depth) {
+ case 1:
+ ErrorF("should call mfbSolidFillSpans\n");
+ break;
+ case 8:
+ ErrorF("should call cfbSolidFillSpans\n");
+ break;
+ default:
+ ErrorF("Unsupported pixmap depth\n");
+ break;
+ }
+ return;
+ }
+
+ if (!(pGC->planemask))
+ return;
+
+ n = nInit * miFindMaxBand(((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip);
+ initPwidth = pwidth = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ initPpt = ppt = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!ppt || !pwidth)
+ {
+ if (ppt) DEALLOCATE_LOCAL(ppt);
+ if (pwidth) DEALLOCATE_LOCAL(pwidth);
+ return;
+ }
+ n = miClipSpans(((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip,
+ pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ WaitQueue(3);
+ outw(FRGD_COLOR, (short)(pGC->fgPixel));
+ outw(FRGD_MIX, FSS_FRGDCOL | ibm8514alu[pGC->alu]);
+ outw(WRT_MASK, (short)pGC->planemask);
+
+ while (n--) {
+ WaitQueue(5);
+ outw(CUR_X, (short)(ppt->x));
+ outw(CUR_Y, (short)(ppt->y));
+ outw(MAJ_AXIS_PCNT, ((short)*pwidth)-1);
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | 0);
+ outw(CMD, CMD_RECT | INC_Y | INC_X | DRAW | PLANAR | WRTDATA);
+
+ ppt++;
+ pwidth++;
+ }
+
+ WaitQueue(2);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+
+ DEALLOCATE_LOCAL(initPpt);
+ DEALLOCATE_LOCAL(initPwidth);
+}
+
+void
+ibm8514TiledFSpans (pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ int xrot, yrot, width, height, pixWidth;
+ PixmapPtr pPix = pGC->tile.pixmap;
+ DDXPointPtr initPpt;
+ int *initPwidth;
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema)
+ {
+ cfbUnnaturalTileFS(pDrawable, pGC,
+ nInit, pptInit, pwidthInit, fSorted);
+ return;
+ }
+
+ if (pDrawable->type != DRAWABLE_WINDOW) {
+ switch (pDrawable->depth) {
+ case 1:
+ ErrorF("should call mfbTiledFillSpans\n");
+ break;
+ case 8:
+ ErrorF("should call cfbTiledFillSpans\n");
+ break;
+ default:
+ ErrorF("Unsupported pixmap depth\n");
+ break;
+ }
+ return;
+ }
+
+ if (!(pGC->planemask))
+ return;
+
+ n = nInit * miFindMaxBand(((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip);
+ initPwidth = pwidth = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ initPpt = ppt = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!ppt || !pwidth)
+ {
+ if (ppt) DEALLOCATE_LOCAL(ppt);
+ if (pwidth) DEALLOCATE_LOCAL(pwidth);
+ return;
+ }
+ n = miClipSpans(((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip,
+ pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ xrot = pDrawable->x + pGC->patOrg.x;
+ yrot = pDrawable->y + pGC->patOrg.y;
+
+ if (pPix == (PixmapPtr)0) {
+ ErrorF("ibm8514TiledFSpans: PixmapPtr tile.pixmap == NULL\n");
+ return;
+ }
+
+ width = pPix->drawable.width;
+ height = pPix->drawable.height;
+ pixWidth = PixmapBytePad(width, pPix->drawable.depth);
+
+ while (n--) {
+ ibm8514ImageFill(ppt->x, ppt->y, *pwidth, 1,
+ pPix->devPrivate.ptr, pixWidth,
+ width, height, xrot, yrot,
+ ibm8514alu[pGC->alu], pGC->planemask);
+ ppt++;
+ pwidth++;
+ }
+
+ DEALLOCATE_LOCAL(initPpt);
+ DEALLOCATE_LOCAL(initPwidth);
+}
+
+void
+ibm8514StipFSpans (pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ int xrot, yrot, width, height, pixWidth;
+ PixmapPtr pPix = pGC->stipple;
+ DDXPointPtr initPpt;
+ int *initPwidth;
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema)
+ {
+ cfbUnnaturalStippleFS(pDrawable, pGC,
+ nInit, pptInit, pwidthInit, fSorted);
+ return;
+ }
+
+ if (pDrawable->type != DRAWABLE_WINDOW) {
+ switch (pDrawable->depth) {
+ case 1:
+ ErrorF("should call mfbStippleFillSpans\n");
+ break;
+ case 8:
+ ErrorF("should call cfbStippleFillSpans\n");
+ break;
+ default:
+ ErrorF("Unsupported pixmap depth\n");
+ break;
+ }
+ return;
+ }
+
+ if (!(pGC->planemask))
+ return;
+
+ n = nInit * miFindMaxBand(((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip);
+ initPwidth = pwidth = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ initPpt = ppt = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!ppt || !pwidth)
+ {
+ if (ppt) DEALLOCATE_LOCAL(ppt);
+ if (pwidth) DEALLOCATE_LOCAL(pwidth);
+ return;
+ }
+ n = miClipSpans(((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip,
+ pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ xrot = pDrawable->x + pGC->patOrg.x;
+ yrot = pDrawable->y + pGC->patOrg.y;
+
+ if (pPix == (PixmapPtr)0) {
+ ErrorF("ibm8514StipFSpans: PixmapPtr stipple == NULL\n");
+ return;
+ }
+
+ width = pPix->drawable.width;
+ height = pPix->drawable.height;
+ pixWidth = PixmapBytePad(width, pPix->drawable.depth);
+
+ while (n--) {
+ ibm8514ImageStipple(ppt->x, ppt->y, *pwidth, 1,
+ pPix->devPrivate.ptr, pixWidth, width, height,
+ xrot, yrot, pGC->fgPixel, 0,
+ ibm8514alu[pGC->alu], pGC->planemask, 0);
+ ppt++;
+ pwidth++;
+ }
+
+ DEALLOCATE_LOCAL(initPpt);
+ DEALLOCATE_LOCAL(initPwidth);
+}
+
+void
+ibm8514OStipFSpans (pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nInit; /* number of spans to fill */
+ DDXPointPtr pptInit; /* pointer to list of start points */
+ int *pwidthInit; /* pointer to list of n widths */
+ int fSorted;
+{
+ int n; /* number of spans to fill */
+ register DDXPointPtr ppt; /* pointer to list of start points */
+ register int *pwidth; /* pointer to list of n widths */
+ int xrot, yrot, width, height, pixWidth;
+ PixmapPtr pPix = pGC->stipple;
+ DDXPointPtr initPpt;
+ int *initPwidth;
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema)
+ {
+ cfbUnnaturalStippleFS(pDrawable, pGC,
+ nInit, pptInit, pwidthInit, fSorted);
+ return;
+ }
+
+ if (pDrawable->type != DRAWABLE_WINDOW) {
+ switch (pDrawable->depth) {
+ case 1:
+ ErrorF("should call mfbOpStippleFillSpans\n");
+ break;
+ case 8:
+ ErrorF("should call cfbOpStippleFillSpans\n");
+ break;
+ default:
+ ErrorF("Unsupported pixmap depth\n");
+ break;
+ }
+ return;
+ }
+
+ if (!(pGC->planemask))
+ return;
+
+ n = nInit * miFindMaxBand(((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip);
+ initPwidth = pwidth = (int *)ALLOCATE_LOCAL(n * sizeof(int));
+ initPpt = ppt = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec));
+ if(!ppt || !pwidth)
+ {
+ if (ppt) DEALLOCATE_LOCAL(ppt);
+ if (pwidth) DEALLOCATE_LOCAL(pwidth);
+ return;
+ }
+ n = miClipSpans(((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip,
+ pptInit, pwidthInit, nInit,
+ ppt, pwidth, fSorted);
+
+ xrot = pDrawable->x + pGC->patOrg.x;
+ yrot = pDrawable->y + pGC->patOrg.y;
+
+ if (pPix == (PixmapPtr)0) {
+ ErrorF("ibm8514StipFSpans: PixmapPtr stipple == NULL\n");
+ return;
+ }
+
+ width = pPix->drawable.width;
+ height = pPix->drawable.height;
+ pixWidth = PixmapBytePad(width, pPix->drawable.depth);
+
+ while (n--) {
+ ibm8514ImageStipple(ppt->x, ppt->y, *pwidth, 1,
+ pPix->devPrivate.ptr, pixWidth,
+ width, height,
+ xrot, yrot, pGC->fgPixel, pGC->bgPixel,
+ ibm8514alu[pGC->alu], pGC->planemask, 1);
+ ppt++;
+ pwidth++;
+ }
+
+ DEALLOCATE_LOCAL(initPpt);
+ DEALLOCATE_LOCAL(initPwidth);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/gc.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/gc.c
new file mode 100644
index 000000000..420f6c953
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/gc.c
@@ -0,0 +1,1074 @@
+/* $XConsortium: ibm8514gc.c,v 1.2 94/04/17 20:30:33 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/ibm8514/gc.c,v 3.1 1994/09/07 15:48:26 dawes Exp $ */
+/*
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL AND KEVIN E. MARTIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL DIGITAL OR KEVIN E. MARTIN BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
+Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+
+*/
+
+
+#include "X.h"
+#include "Xmd.h"
+#include "Xproto.h"
+#include "cfb.h"
+#include "fontstruct.h"
+#include "dixfontstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "region.h"
+
+#include "mistruct.h"
+#include "mibstore.h"
+
+#include "cfbmskbits.h"
+#include "cfb8bit.h"
+
+#include "xf86bcache.h"
+#include "xf86fcache.h"
+#include "xf86text.h"
+#include "ibm8514.h"
+
+static void cfbChangeGC(), cfbCopyGC(), cfbDestroyGC();
+static void cfbChangeClip(), cfbDestroyClip(), cfbCopyClip();
+static void cfbDestroyOps(), ibm8514ValidateGC();
+
+static GCFuncs cfbFuncs = {
+ ibm8514ValidateGC,
+ cfbChangeGC,
+ cfbCopyGC,
+ cfbDestroyGC,
+ cfbChangeClip,
+ cfbDestroyClip,
+ cfbCopyClip,
+};
+
+static GCOps ibm8514Ops = {
+ ibm8514SolidFSpans,
+ ibm8514SetSpans,
+ cfbPutImage,
+ ibm8514CopyArea,
+ ibm8514CopyPlane,
+ ibm8514PolyPoint,
+ miWideLine,
+ miPolySegment,
+ miPolyRectangle,
+ miPolyArc,
+ miFillPolygon,
+ ibm8514PolyFillRect,
+ miPolyFillArc,
+ xf86PolyText8,
+ xf86PolyText16,
+ xf86ImageText8,
+ xf86ImageText16,
+ miImageGlyphBlt,
+ miPolyGlyphBlt,
+ miPushPixels,
+ NULL,
+};
+
+static GCOps cfbTEOps1Rect = {
+ cfbSolidSpansCopy,
+ cfbSetSpans,
+ cfbPutImage,
+ ibm8514CopyArea,
+ ibm8514CopyPlane,
+ cfbPolyPoint,
+ cfbLineSS,
+ cfbSegmentSS,
+ miPolyRectangle,
+#if PPW == 4
+ cfbZeroPolyArcSS8Copy,
+#else
+ miZeroPolyArc,
+#endif
+ cfbFillPoly1RectCopy,
+ cfbPolyFillRect,
+ cfbPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ cfbTEGlyphBlt8,
+ cfbPolyGlyphBlt8,
+ cfbPushPixels8,
+ NULL,
+};
+
+static GCOps cfbTEOps = {
+ cfbSolidSpansCopy,
+ cfbSetSpans,
+ cfbPutImage,
+ ibm8514CopyArea,
+ ibm8514CopyPlane,
+ cfbPolyPoint,
+ cfbLineSS,
+ cfbSegmentSS,
+ miPolyRectangle,
+#if PPW == 4
+ cfbZeroPolyArcSS8Copy,
+#else
+ miZeroPolyArc,
+#endif
+ miFillPolygon,
+ cfbPolyFillRect,
+ cfbPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ cfbTEGlyphBlt8,
+ cfbPolyGlyphBlt8,
+ cfbPushPixels8,
+ NULL,
+};
+
+static GCOps cfbNonTEOps1Rect = {
+ cfbSolidSpansCopy,
+ cfbSetSpans,
+ cfbPutImage,
+ ibm8514CopyArea,
+ ibm8514CopyPlane,
+ cfbPolyPoint,
+ cfbLineSS,
+ cfbSegmentSS,
+ miPolyRectangle,
+#if PPW == 4
+ cfbZeroPolyArcSS8Copy,
+#else
+ miZeroPolyArc,
+#endif
+ cfbFillPoly1RectCopy,
+ cfbPolyFillRect,
+ cfbPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ cfbImageGlyphBlt8,
+ cfbPolyGlyphBlt8,
+ cfbPushPixels8,
+ NULL,
+};
+
+static GCOps cfbNonTEOps = {
+ cfbSolidSpansCopy,
+ cfbSetSpans,
+ cfbPutImage,
+ ibm8514CopyArea,
+ ibm8514CopyPlane,
+ cfbPolyPoint,
+ cfbLineSS,
+ cfbSegmentSS,
+ miPolyRectangle,
+#if PPW == 4
+ cfbZeroPolyArcSS8Copy,
+#else
+ miZeroPolyArc,
+#endif
+ miFillPolygon,
+ cfbPolyFillRect,
+ cfbPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ cfbImageGlyphBlt8,
+ cfbPolyGlyphBlt8,
+ cfbPushPixels8,
+ NULL,
+};
+
+static GCOps *
+matchCommon (pGC, devPriv)
+ GCPtr pGC;
+ cfbPrivGCPtr devPriv;
+{
+ if (pGC->lineWidth != 0)
+ return 0;
+ if (pGC->lineStyle != LineSolid)
+ return 0;
+ if (pGC->fillStyle != FillSolid)
+ return 0;
+ if (devPriv->rop != GXcopy)
+ return 0;
+ if (pGC->font &&
+ FONTMAXBOUNDS(pGC->font,rightSideBearing) -
+ FONTMINBOUNDS(pGC->font,leftSideBearing) <= 32 &&
+ FONTMINBOUNDS(pGC->font,characterWidth) >= 0)
+ {
+ if (TERMINALFONT(pGC->font)
+#if PPW == 4
+ && FONTMAXBOUNDS(pGC->font,characterWidth) >= 4
+#endif
+ )
+ if (devPriv->oneRect)
+ return &cfbTEOps1Rect;
+ else
+ return &cfbTEOps;
+ else
+ if (devPriv->oneRect)
+ return &cfbNonTEOps1Rect;
+ else
+ return &cfbNonTEOps;
+ }
+ return 0;
+}
+
+Bool
+ibm8514CreateGC(pGC)
+ register GCPtr pGC;
+{
+ cfbPrivGC *pPriv;
+
+ switch (pGC->depth) {
+ case 1:
+ return (mfbCreateGC(pGC));
+ case PSZ:
+ break;
+ default:
+ ErrorF("cfbCreateGC: unsupported depth: %d\n", pGC->depth);
+ return FALSE;
+ }
+ pGC->clientClip = NULL;
+ pGC->clientClipType = CT_NONE;
+
+ /*
+ * some of the output primitives aren't really necessary, since they
+ * will be filled in ValidateGC because of dix/CreateGC() setting all
+ * the change bits. Others are necessary because although they depend
+ * on being a color frame buffer, they don't change
+ */
+
+ pGC->ops = &cfbNonTEOps;
+ pGC->funcs = &cfbFuncs;
+
+ /* cfb wants to translate before scan conversion */
+ pGC->miTranslate = 1;
+
+ pPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr);
+ pPriv->rop = pGC->alu;
+ pPriv->oneRect = FALSE;
+ pPriv->fExpose = TRUE;
+ pPriv->freeCompClip = FALSE;
+ pPriv->pRotatedPixmap = (PixmapPtr) NULL;
+ return TRUE;
+}
+
+/*ARGSUSED*/
+static void
+cfbChangeGC(pGC, mask)
+ GC *pGC;
+ BITS32 mask;
+{
+ return;
+}
+
+static void
+cfbDestroyGC(pGC)
+ GC *pGC;
+{
+ cfbPrivGC *pPriv;
+
+ pPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr);
+ if (pPriv->pRotatedPixmap)
+ cfbDestroyPixmap(pPriv->pRotatedPixmap);
+ if (pPriv->freeCompClip)
+ (*pGC->pScreen->RegionDestroy)(pPriv->pCompositeClip);
+ cfbDestroyOps (pGC->ops);
+}
+
+/*
+ * create a private op array for a gc
+ */
+
+static GCOps *
+cfbCreateOps (prototype)
+ GCOps *prototype;
+{
+ GCOps *ret;
+ extern Bool Must_have_memory;
+
+ /* XXX */ Must_have_memory = TRUE;
+ ret = (GCOps *) xalloc (sizeof(GCOps));
+ /* XXX */ Must_have_memory = FALSE;
+ if (!ret)
+ return 0;
+ *ret = *prototype;
+ ret->devPrivate.val = 1;
+ return ret;
+}
+
+static void
+cfbDestroyOps (ops)
+ GCOps *ops;
+{
+ if (ops->devPrivate.val)
+ xfree (ops);
+}
+
+/* Clipping conventions
+ if the drawable is a window
+ CT_REGION ==> pCompositeClip really is the composite
+ CT_other ==> pCompositeClip is the window clip region
+ if the drawable is a pixmap
+ CT_REGION ==> pCompositeClip is the translated client region
+ clipped to the pixmap boundary
+ CT_other ==> pCompositeClip is the pixmap bounding box
+*/
+
+static void
+ibm8514ValidateGC(pGC, changes, pDrawable)
+ register GCPtr pGC;
+ Mask changes;
+ DrawablePtr pDrawable;
+{
+ WindowPtr pWin;
+ int mask; /* stateChanges */
+ int index; /* used for stepping through bitfields */
+ int new_rrop;
+ int new_line, new_text, new_fillspans, new_fillarea;
+ int new_rotate;
+ int xrot, yrot;
+ /* flags for changing the proc vector */
+ cfbPrivGCPtr devPriv;
+ int oneRect;
+
+ new_rotate = pGC->lastWinOrg.x != pDrawable->x ||
+ pGC->lastWinOrg.y != pDrawable->y;
+
+ pGC->lastWinOrg.x = pDrawable->x;
+ pGC->lastWinOrg.y = pDrawable->y;
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ {
+ pWin = (WindowPtr) pDrawable;
+ }
+ else
+ {
+ pWin = (WindowPtr) NULL;
+ }
+
+ devPriv = ((cfbPrivGCPtr) (pGC->devPrivates[cfbGCPrivateIndex].ptr));
+
+ new_rrop = FALSE;
+ new_line = FALSE;
+ new_text = FALSE;
+ new_fillspans = FALSE;
+ new_fillarea = FALSE;
+
+ /*
+ * if the client clip is different or moved OR the subwindowMode has
+ * changed OR the window's clip has changed since the last validation
+ * we need to recompute the composite clip
+ */
+
+ if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
+ (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
+ )
+ {
+ ScreenPtr pScreen = pGC->pScreen;
+
+ if (pWin) {
+ RegionPtr pregWin;
+ Bool freeTmpClip, freeCompClip;
+
+ if (pGC->subWindowMode == IncludeInferiors) {
+ pregWin = NotClippedByChildren(pWin);
+ freeTmpClip = TRUE;
+ }
+ else {
+ pregWin = &pWin->clipList;
+ freeTmpClip = FALSE;
+ }
+ freeCompClip = devPriv->freeCompClip;
+
+ /*
+ * if there is no client clip, we can get by with just keeping
+ * the pointer we got, and remembering whether or not should
+ * destroy (or maybe re-use) it later. this way, we avoid
+ * unnecessary copying of regions. (this wins especially if
+ * many clients clip by children and have no client clip.)
+ */
+ if (pGC->clientClipType == CT_NONE) {
+ if (freeCompClip)
+ (*pScreen->RegionDestroy) (devPriv->pCompositeClip);
+ devPriv->pCompositeClip = pregWin;
+ devPriv->freeCompClip = freeTmpClip;
+ }
+ else {
+ /*
+ * we need one 'real' region to put into the composite
+ * clip. if pregWin the current composite clip are real,
+ * we can get rid of one. if pregWin is real and the
+ * current composite clip isn't, use pregWin for the
+ * composite clip. if the current composite clip is real
+ * and pregWin isn't, use the current composite clip. if
+ * neither is real, create a new region.
+ */
+
+ (*pScreen->TranslateRegion)(pGC->clientClip,
+ pDrawable->x + pGC->clipOrg.x,
+ pDrawable->y + pGC->clipOrg.y);
+
+ if (freeCompClip)
+ {
+ (*pGC->pScreen->Intersect)(devPriv->pCompositeClip,
+ pregWin, pGC->clientClip);
+ if (freeTmpClip)
+ (*pScreen->RegionDestroy)(pregWin);
+ }
+ else if (freeTmpClip)
+ {
+ (*pScreen->Intersect)(pregWin, pregWin, pGC->clientClip);
+ devPriv->pCompositeClip = pregWin;
+ }
+ else
+ {
+ devPriv->pCompositeClip = (*pScreen->RegionCreate)(NullBox,
+ 0);
+ (*pScreen->Intersect)(devPriv->pCompositeClip,
+ pregWin, pGC->clientClip);
+ }
+ devPriv->freeCompClip = TRUE;
+ (*pScreen->TranslateRegion)(pGC->clientClip,
+ -(pDrawable->x + pGC->clipOrg.x),
+ -(pDrawable->y + pGC->clipOrg.y));
+
+ }
+ } /* end of composite clip for a window */
+ else {
+ BoxRec pixbounds;
+
+ /* XXX should we translate by drawable.x/y here ? */
+ pixbounds.x1 = 0;
+ pixbounds.y1 = 0;
+ pixbounds.x2 = pDrawable->width;
+ pixbounds.y2 = pDrawable->height;
+
+ if (devPriv->freeCompClip)
+ (*pScreen->RegionReset)(devPriv->pCompositeClip, &pixbounds);
+ else {
+ devPriv->freeCompClip = TRUE;
+ devPriv->pCompositeClip = (*pScreen->RegionCreate)(&pixbounds,
+ 1);
+ }
+
+ if (pGC->clientClipType == CT_REGION)
+ {
+ (*pScreen->TranslateRegion)(devPriv->pCompositeClip,
+ -pGC->clipOrg.x, -pGC->clipOrg.y);
+ (*pScreen->Intersect)(devPriv->pCompositeClip,
+ devPriv->pCompositeClip,
+ pGC->clientClip);
+ (*pScreen->TranslateRegion)(devPriv->pCompositeClip,
+ pGC->clipOrg.x, pGC->clipOrg.y);
+ }
+ } /* end of composute clip for pixmap */
+ oneRect = REGION_NUM_RECTS(devPriv->pCompositeClip) == 1;
+ if (oneRect != devPriv->oneRect)
+ new_line = TRUE;
+ devPriv->oneRect = oneRect;
+ }
+
+ mask = changes;
+ while (mask) {
+ index = lowbit (mask);
+ mask &= ~index;
+
+ /*
+ * this switch acculmulates a list of which procedures might have
+ * to change due to changes in the GC. in some cases (e.g.
+ * changing one 16 bit tile for another) we might not really need
+ * a change, but the code is being paranoid. this sort of batching
+ * wins if, for example, the alu and the font have been changed,
+ * or any other pair of items that both change the same thing.
+ */
+ switch (index) {
+ case GCFunction:
+ case GCForeground:
+ new_rrop = TRUE;
+ break;
+ case GCPlaneMask:
+ new_rrop = TRUE;
+ new_text = TRUE;
+ break;
+ case GCBackground:
+ break;
+ case GCLineStyle:
+ case GCLineWidth:
+ new_line = TRUE;
+ break;
+ case GCJoinStyle:
+ case GCCapStyle:
+ break;
+ case GCFillStyle:
+ new_text = TRUE;
+ new_fillspans = TRUE;
+ new_line = TRUE;
+ new_fillarea = TRUE;
+ break;
+ case GCFillRule:
+ break;
+ case GCTile:
+ new_fillspans = TRUE;
+ new_fillarea = TRUE;
+ break;
+
+ case GCStipple:
+ if (pGC->stipple)
+ {
+ int width = pGC->stipple->drawable.width;
+ PixmapPtr nstipple;
+
+ if ((width <= 32) && !(width & (width - 1)) &&
+ (nstipple = cfbCopyPixmap(pGC->stipple)))
+ {
+ cfbPadPixmap(nstipple);
+ cfbDestroyPixmap(pGC->stipple);
+ pGC->stipple = nstipple;
+ }
+ }
+ new_fillspans = TRUE;
+ new_fillarea = TRUE;
+ break;
+
+ case GCTileStipXOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCTileStipYOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCFont:
+ new_text = TRUE;
+ break;
+ case GCSubwindowMode:
+ break;
+ case GCGraphicsExposures:
+ break;
+ case GCClipXOrigin:
+ break;
+ case GCClipYOrigin:
+ break;
+ case GCClipMask:
+ break;
+ case GCDashOffset:
+ break;
+ case GCDashList:
+ break;
+ case GCArcMode:
+ break;
+ default:
+ break;
+ }
+ }
+
+ /*
+ * If the drawable has changed, check its depth & ensure suitable
+ * entries are in the proc vector.
+ */
+ if (pDrawable->serialNumber != (pGC->serialNumber & (DRAWABLE_SERIAL_BITS))) {
+ new_fillspans = TRUE; /* deal with FillSpans later */
+ }
+
+ if (new_rotate || new_fillspans)
+ {
+ Bool new_pix = FALSE;
+
+ xrot = pGC->patOrg.x + pDrawable->x;
+ yrot = pGC->patOrg.y + pDrawable->y;
+
+ switch (pGC->fillStyle)
+ {
+ case FillTiled:
+ if (!pGC->tileIsPixel)
+ {
+ int width = pGC->tile.pixmap->drawable.width * PSZ;
+
+ if ((width <= 32) && !(width & (width - 1)))
+ {
+ cfbCopyRotatePixmap(pGC->tile.pixmap,
+ &devPriv->pRotatedPixmap,
+ xrot, yrot);
+ new_pix = TRUE;
+ }
+ }
+ break;
+#if (PPW == 4)
+ case FillStippled:
+ case FillOpaqueStippled:
+ {
+ int width = pGC->stipple->drawable.width;
+
+ if ((width <= 32) && !(width & (width - 1)))
+ {
+ mfbCopyRotatePixmap(pGC->stipple,
+ &devPriv->pRotatedPixmap, xrot, yrot);
+ new_pix = TRUE;
+ }
+ }
+ break;
+#endif
+ }
+ if (!new_pix && devPriv->pRotatedPixmap)
+ {
+ cfbDestroyPixmap(devPriv->pRotatedPixmap);
+ devPriv->pRotatedPixmap = (PixmapPtr) NULL;
+ }
+ }
+
+ if (new_rrop)
+ {
+ int old_rrop;
+
+ old_rrop = devPriv->rop;
+ devPriv->rop = cfbReduceRasterOp (pGC->alu, pGC->fgPixel,
+ pGC->planemask,
+ &devPriv->and, &devPriv->xor);
+ if (old_rrop == devPriv->rop)
+ new_rrop = FALSE;
+ else
+ {
+#if PPW == 4
+ new_line = TRUE;
+ new_text = TRUE;
+#endif
+ new_fillspans = TRUE;
+ new_fillarea = TRUE;
+ }
+ }
+
+ if (pWin && pGC->ops->devPrivate.val != 2)
+ {
+ if (pGC->ops->devPrivate.val == 1)
+ cfbDestroyOps (pGC->ops);
+
+ pGC->ops = cfbCreateOps (&ibm8514Ops);
+ pGC->ops->devPrivate.val = 2;
+
+ /* Make sure that everything is properly initialized the first time through */
+ new_rrop = new_line = new_text = new_fillspans = new_fillarea = TRUE;
+ }
+ else if (!pWin && (new_rrop || new_fillspans || new_text || new_fillarea || new_line))
+ {
+ GCOps *newops;
+
+ if (newops = matchCommon (pGC, devPriv))
+ {
+ if (pGC->ops->devPrivate.val)
+ cfbDestroyOps (pGC->ops);
+ pGC->ops = newops;
+ new_rrop = new_line = new_fillspans = new_text = new_fillarea = 0;
+ }
+ else
+ {
+ if (!pGC->ops->devPrivate.val)
+ {
+ pGC->ops = cfbCreateOps (pGC->ops);
+ pGC->ops->devPrivate.val = 1;
+ }
+ else if (pGC->ops->devPrivate.val != 1)
+ {
+ cfbDestroyOps (pGC->ops);
+ pGC->ops = cfbCreateOps (&cfbNonTEOps);
+ pGC->ops->devPrivate.val = 1;
+ new_rrop = new_line = new_text = new_fillspans = new_fillarea = TRUE;
+ }
+ }
+ }
+
+ /* deal with the changes we've collected */
+ if (new_line)
+ {
+ if (pWin) {
+ if (pGC->lineWidth == 0)
+ pGC->ops->PolyArc = miZeroPolyArc;
+ else
+ pGC->ops->PolyArc = miPolyArc;
+ pGC->ops->PolySegment = miPolySegment;
+ switch (pGC->lineStyle)
+ {
+ case LineSolid:
+ if(pGC->lineWidth == 0)
+ {
+ if (pGC->fillStyle == FillSolid)
+ {
+ pGC->ops->Polylines = ibm8514Line;
+ pGC->ops->PolySegment = ibm8514Segment;
+ }
+ else
+ pGC->ops->Polylines = miZeroLine;
+ }
+ else
+ pGC->ops->Polylines = miWideLine;
+ break;
+ case LineOnOffDash:
+ pGC->ops->Polylines = miWideDash;
+ if ((pGC->lineWidth == 0) && (pGC->fillStyle == FillSolid))
+ {
+ pGC->ops->Polylines = ibm8514DashLine;
+ pGC->ops->PolySegment = ibm8514DashSegment;
+ }
+ break;
+ case LineDoubleDash:
+ pGC->ops->Polylines = miWideDash;
+ if ((pGC->lineWidth == 0) && (pGC->fillStyle == FillSolid))
+ {
+ pGC->ops->Polylines = ibm8514DoubleDashLine;
+ pGC->ops->PolySegment = ibm8514DoubleDashSegment;
+ }
+ break;
+ }
+ } else {
+ pGC->ops->FillPolygon = miFillPolygon;
+ if (devPriv->oneRect && pGC->fillStyle == FillSolid)
+ {
+ switch (devPriv->rop) {
+ case GXcopy:
+ pGC->ops->FillPolygon = cfbFillPoly1RectCopy;
+ break;
+ default:
+ pGC->ops->FillPolygon = cfbFillPoly1RectGeneral;
+ break;
+ }
+ }
+ if (pGC->lineWidth == 0)
+ {
+#if PPW == 4
+ if ((pGC->lineStyle == LineSolid) && (pGC->fillStyle == FillSolid))
+ {
+ switch (devPriv->rop)
+ {
+ case GXxor:
+ pGC->ops->PolyArc = cfbZeroPolyArcSS8Xor;
+ break;
+ case GXcopy:
+ pGC->ops->PolyArc = cfbZeroPolyArcSS8Copy;
+ break;
+ default:
+ pGC->ops->PolyArc = cfbZeroPolyArcSS8General;
+ break;
+ }
+ }
+ else
+#endif
+ pGC->ops->PolyArc = miZeroPolyArc;
+ }
+ else
+ pGC->ops->PolyArc = miPolyArc;
+ pGC->ops->PolySegment = miPolySegment;
+ switch (pGC->lineStyle)
+ {
+ case LineSolid:
+ if(pGC->lineWidth == 0)
+ {
+ if (pGC->fillStyle == FillSolid)
+ {
+ pGC->ops->Polylines = cfbLineSS;
+ pGC->ops->PolySegment = cfbSegmentSS;
+ }
+ else
+ pGC->ops->Polylines = miZeroLine;
+ }
+ else
+ pGC->ops->Polylines = miWideLine;
+ break;
+ case LineOnOffDash:
+ case LineDoubleDash:
+ if (pGC->lineWidth == 0 && pGC->fillStyle == FillSolid)
+ {
+ pGC->ops->Polylines = cfbLineSD;
+ pGC->ops->PolySegment = cfbSegmentSD;
+ } else
+ pGC->ops->Polylines = miWideDash;
+ break;
+ }
+ }
+ }
+
+ if (new_text && (pGC->font))
+ {
+ if (pWin) {
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
+ } else {
+ if (FONTMAXBOUNDS(pGC->font,rightSideBearing) -
+ FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 ||
+ FONTMINBOUNDS(pGC->font,characterWidth) < 0)
+ {
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
+ }
+ else
+ {
+#if PPW == 4
+ if (pGC->fillStyle == FillSolid)
+ {
+ if (devPriv->rop == GXcopy)
+ pGC->ops->PolyGlyphBlt = cfbPolyGlyphBlt8;
+ else
+ pGC->ops->PolyGlyphBlt = cfbPolyGlyphRop8;
+ }
+ else
+#endif
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ /* special case ImageGlyphBlt for terminal emulator fonts */
+ if (TERMINALFONT(pGC->font) &&
+ (pGC->planemask & PMSK) == PMSK
+#if PPW == 4
+ && FONTMAXBOUNDS(pGC->font,characterWidth) >= 4
+#endif
+ )
+ {
+#if PPW == 4
+ pGC->ops->ImageGlyphBlt = cfbTEGlyphBlt8;
+#else
+ pGC->ops->ImageGlyphBlt = cfbTEGlyphBlt;
+#endif
+ }
+ else
+ {
+#if PPW == 4
+ pGC->ops->ImageGlyphBlt = cfbImageGlyphBlt8;
+#else
+ pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
+#endif
+ }
+ }
+ }
+ }
+
+
+ if (new_fillspans) {
+ if (pWin) {
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ pGC->ops->FillSpans = ibm8514SolidFSpans;
+ break;
+ case FillTiled:
+ pGC->ops->FillSpans = ibm8514TiledFSpans;
+ break;
+ case FillStippled:
+ pGC->ops->FillSpans = ibm8514StipFSpans;
+ break;
+ case FillOpaqueStippled:
+ pGC->ops->FillSpans = ibm8514OStipFSpans;
+ break;
+ default:
+ FatalError("ibm8514ValidateGC: illegal fillStyle\n");
+ }
+ } else {
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ switch (devPriv->rop) {
+ case GXcopy:
+ pGC->ops->FillSpans = cfbSolidSpansCopy;
+ break;
+ case GXxor:
+ pGC->ops->FillSpans = cfbSolidSpansXor;
+ break;
+ default:
+ pGC->ops->FillSpans = cfbSolidSpansGeneral;
+ break;
+ }
+ break;
+ case FillTiled:
+ if (devPriv->pRotatedPixmap)
+ {
+ if (pGC->alu == GXcopy && (pGC->planemask & PMSK) == PMSK)
+ pGC->ops->FillSpans = cfbTile32FSCopy;
+ else
+ pGC->ops->FillSpans = cfbTile32FSGeneral;
+ }
+ else
+ pGC->ops->FillSpans = cfbUnnaturalTileFS;
+ break;
+ case FillStippled:
+#if PPW == 4
+ if (devPriv->pRotatedPixmap)
+ pGC->ops->FillSpans = cfb8Stipple32FS;
+ else
+#endif
+ pGC->ops->FillSpans = cfbUnnaturalStippleFS;
+ break;
+ case FillOpaqueStippled:
+#if PPW == 4
+ if (devPriv->pRotatedPixmap)
+ pGC->ops->FillSpans = cfb8OpaqueStipple32FS;
+ else
+#endif
+ pGC->ops->FillSpans = cfbUnnaturalStippleFS;
+ break;
+ default:
+ FatalError("ibm8514ValidateGC: illegal fillStyle\n");
+ }
+ }
+ } /* end of new_fillspans */
+
+ if (new_fillarea) {
+ if (pWin) {
+ pGC->ops->PolyFillRect = ibm8514PolyFillRect;
+ pGC->ops->PolyFillArc = miPolyFillArc;
+ pGC->ops->PushPixels = miPushPixels;
+ } else {
+#if PPW != 4
+ pGC->ops->PolyFillRect = miPolyFillRect;
+ if (pGC->fillStyle == FillSolid || pGC->fillStyle == FillTiled)
+ {
+ pGC->ops->PolyFillRect = cfbPolyFillRect;
+ }
+#endif
+#if PPW == 4
+ pGC->ops->PushPixels = mfbPushPixels;
+ if (pGC->fillStyle == FillSolid && devPriv->rop == GXcopy)
+ pGC->ops->PushPixels = cfbPushPixels8;
+#endif
+ pGC->ops->PolyFillArc = miPolyFillArc;
+ if (pGC->fillStyle == FillSolid)
+ {
+ switch (devPriv->rop)
+ {
+ case GXcopy:
+ pGC->ops->PolyFillArc = cfbPolyFillArcSolidCopy;
+ break;
+ default:
+ pGC->ops->PolyFillArc = cfbPolyFillArcSolidGeneral;
+ break;
+ }
+ }
+ }
+ }
+}
+
+static void
+cfbDestroyClip(pGC)
+ GCPtr pGC;
+{
+ if(pGC->clientClipType == CT_NONE)
+ return;
+ else if (pGC->clientClipType == CT_PIXMAP)
+ {
+ cfbDestroyPixmap((PixmapPtr)(pGC->clientClip));
+ }
+ else
+ {
+ /* we know we'll never have a list of rectangles, since
+ ChangeClip immediately turns them into a region
+ */
+ (*pGC->pScreen->RegionDestroy)(pGC->clientClip);
+ }
+ pGC->clientClip = NULL;
+ pGC->clientClipType = CT_NONE;
+}
+
+static void
+cfbChangeClip(pGC, type, pvalue, nrects)
+ GCPtr pGC;
+ int type;
+ pointer pvalue;
+ int nrects;
+{
+ cfbDestroyClip(pGC);
+ if(type == CT_PIXMAP)
+ {
+ pGC->clientClip = (pointer) (*pGC->pScreen->BitmapToRegion)((PixmapPtr)pvalue);
+ (*pGC->pScreen->DestroyPixmap)(pvalue);
+ }
+ else if (type == CT_REGION) {
+ /* stuff the region in the GC */
+ pGC->clientClip = pvalue;
+ }
+ else if (type != CT_NONE)
+ {
+ pGC->clientClip = (pointer) (*pGC->pScreen->RectsToRegion)(nrects,
+ (xRectangle *)pvalue,
+ type);
+ xfree(pvalue);
+ }
+ pGC->clientClipType = (type != CT_NONE && pGC->clientClip) ? CT_REGION :
+ CT_NONE;
+ pGC->stateChanges |= GCClipMask;
+}
+
+static void
+cfbCopyClip (pgcDst, pgcSrc)
+ GCPtr pgcDst, pgcSrc;
+{
+ RegionPtr prgnNew;
+
+ switch(pgcSrc->clientClipType)
+ {
+ case CT_PIXMAP:
+ ((PixmapPtr) pgcSrc->clientClip)->refcnt++;
+ /* Fall through !! */
+ case CT_NONE:
+ cfbChangeClip(pgcDst, (int)pgcSrc->clientClipType, pgcSrc->clientClip,
+ 0);
+ break;
+ case CT_REGION:
+ prgnNew = (*pgcSrc->pScreen->RegionCreate)(NULL, 1);
+ (*pgcSrc->pScreen->RegionCopy)(prgnNew,
+ (RegionPtr)(pgcSrc->clientClip));
+ cfbChangeClip(pgcDst, CT_REGION, (pointer)prgnNew, 0);
+ break;
+ }
+}
+
+/*ARGSUSED*/
+static void
+cfbCopyGC (pGCSrc, changes, pGCDst)
+ GCPtr pGCSrc;
+ Mask changes;
+ GCPtr pGCDst;
+{
+ return;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/gs.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/gs.c
new file mode 100644
index 000000000..f1e13b31f
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/gs.c
@@ -0,0 +1,121 @@
+/* $XConsortium: ibm8514gs.c,v 1.2 94/04/17 20:30:34 dpw Exp $ */
+/*
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL, KEVIN E. MARTIN, AND TIAGO GONS DISCLAIM ALL WARRANTIES WITH REGARD TO
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL DIGITAL, KEVIN E. MARTIN, OR TIAGO GONS BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+Further modifications by Tiago Gons (tiago@comosjn.hobby.nl)
+
+*/
+
+
+#include "X.h"
+#include "Xmd.h"
+#include "servermd.h"
+
+#include "misc.h"
+#include "region.h"
+#include "gc.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "ibm8514.h"
+
+/* GetSpans -- for each span, gets bits from drawable starting at ppt[i]
+ * and continuing for pwidth[i] bits
+ * Each scanline returned will be server scanline padded, i.e., it will come
+ * out to an integral number of words.
+ */
+void
+ibm8514GetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdst)
+ DrawablePtr pDrawable; /* drawable from which to get bits */
+ int wMax; /* largest value of all *pwidths */
+ register DDXPointPtr ppt; /* points to start copying from */
+ int *pwidth; /* list of number of bits to copy */
+ int nspans; /* number of scanlines to copy */
+ char *pdst; /* where to put the bits */
+{
+ int j;
+ int pixmapStride;
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema)
+ {
+ cfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdst);
+ return;
+ }
+
+ if (pDrawable->type != DRAWABLE_WINDOW) {
+ switch (pDrawable->depth) {
+ case 1:
+ mfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdst);
+ break;
+ case 8:
+ cfbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdst);
+ break;
+ default:
+ ErrorF("Unsupported pixmap depth\n");
+ break;
+ }
+ return;
+ }
+
+ pixmapStride = PixmapBytePad(wMax, pDrawable->depth);
+
+ for (; nspans--; ppt++, pwidth++) {
+ ibm8514ImageRead(ppt->x, ppt->y, j = *pwidth, 1, pdst, pixmapStride,
+ 0, 0, 0xff);
+ pdst += j; /* width is in 32 bit words */
+ j = (-j) & 3;
+ while (j--) /* Pad out to 32-bit boundary */
+ *pdst++ = 0;
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/gtimg.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/gtimg.c
new file mode 100644
index 000000000..6f595e4f4
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/gtimg.c
@@ -0,0 +1,83 @@
+/* $XConsortium: ibm8514gtim.c,v 1.1 94/03/28 21:04:35 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/ibm8514/gtimg.c,v 3.0 1994/07/24 11:43:19 dawes Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. David Wexelblat makes
+ * no representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
+ * OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/*
+ * Stolen from the S3 server and adapted to the 8514 server.
+ * Hans Nasten. (nasten@everyware.se).
+ */
+
+
+#include "X.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "ibm8514.h"
+
+extern void mfbGetImage();
+
+void
+ibm8514GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine)
+ DrawablePtr pDrawable;
+ int sx, sy, w, h;
+ unsigned int format;
+ unsigned long planeMask;
+ char *pdstLine;
+{
+ int width;
+
+ if ((w == 0) || (h == 0))
+ return;
+
+ if (pDrawable->bitsPerPixel == 1)
+ {
+ mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+ return;
+ }
+
+ if (pDrawable->type != DRAWABLE_WINDOW)
+ {
+ cfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+ return;
+ }
+
+ width = PixmapBytePad(w, pDrawable->depth);
+ if (format == ZPixmap)
+ {
+ ibm8514ImageRead(sx+pDrawable->x, sy+pDrawable->y, w, h,
+ pdstLine, width, 0, 0, planeMask);
+ }
+ else
+ {
+ /*
+ * Worry about this later (much!). Should be straighforward, though.
+ * Read an image into a dummy pixmap, then use cfbCopyPlane8to1 to
+ * copy each plane in planeMask into the destination. At least
+ * this is the theory.
+ */
+ miGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+ }
+}
+
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/im.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/im.c
new file mode 100644
index 000000000..95da1d29b
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/im.c
@@ -0,0 +1,507 @@
+/* $XConsortium: ibm8514im.c,v 1.1 94/03/28 21:04:41 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/ibm8514/im.c,v 3.4 1995/01/26 02:17:26 dawes Exp $ */
+/*
+ * Copyright 1992 by Kevin E. Martin, Chapel Hill, North Carolina.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Kevin E. Martin not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Kevin E. Martin makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * KEVIN E. MARTIN AND TIAGO GONS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL KEVIN E. MARTIN OR TIAGO GONS BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Modified by Tiago Gons (tiago@comosjn.hobby.nl)
+ */
+
+
+#include "os.h"
+#include "reg8514.h"
+#include "8514im.h"
+#include "ibm8514.h"
+
+#define ASM_IMAGE
+
+#define reorder(a) ( \
+ (a & 0x80) >> 7 | \
+ (a & 0x40) >> 5 | \
+ (a & 0x20) >> 3 | \
+ (a & 0x10) >> 1 | \
+ (a & 0x08) << 1 | \
+ (a & 0x04) << 3 | \
+ (a & 0x02) << 5 | \
+ (a & 0x01) << 7 )
+
+unsigned short ibm8514stipple_tab[256];
+
+static unsigned short _internal_ibm8514_mskbits[17] = {
+ 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff,
+ 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
+};
+
+#define MSKBIT(n) (_internal_ibm8514_mskbits[(n)])
+
+void
+ibm8514ImageInit()
+{
+ int i;
+
+ for (i = 0; i < 256; i++) {
+ ibm8514stipple_tab[i] = ((reorder(i) & 0xf0) << 5) |
+ ((reorder(i) & 0x0f) << 1);
+ }
+}
+
+#ifdef ASM_IMAGE
+
+void
+#if NeedFunctionPrototypes
+ibm8514ImageFill(
+ int x,
+ int y,
+ int w,
+ int h,
+ char *psrc,
+ int pwidth,
+ int pw,
+ int ph,
+ int pox,
+ int poy,
+ short alu,
+ unsigned long planemask)
+#else
+ibm8514ImageFill(x, y, w, h, psrc, pwidth, pw, ph, pox, poy, alu, planemask)
+ int x;
+ int y;
+ int w;
+ int h;
+ char *psrc;
+ int pwidth;
+ int pw;
+ int ph;
+ int pox;
+ int poy;
+ short alu;
+ unsigned long planemask;
+#endif
+{
+ if (alu == MIX_DST)
+ return;
+
+ if( pox == 0 && poy == 0 && pw >= x+w && ph >= y+h )
+ ibm8514ImageWrite(x, y, w, h, psrc, pwidth, x, y, alu, planemask);
+ else
+ ibm8514RealImageFill(x, y, w, h, psrc, pwidth,
+ pw, ph, pox, poy, alu, planemask);
+}
+
+#else /* ASM_IMAGE */
+
+void
+#if NeedFunctionPrototypes
+ibm8514ImageWrite(
+ int x,
+ int y,
+ int w,
+ int h,
+ char *psrc,
+ int pwidth,
+ int px,
+ int py,
+ short alu,
+ unsigned long planemask)
+#else
+ibm8514ImageWrite(x, y, w, h, psrc, pwidth, px, py, alu, planemask)
+ int x;
+ int y;
+ int w;
+ int h;
+ char *psrc;
+ int pwidth;
+ int px;
+ int py;
+ short alu;
+ unsigned long planemask;
+#endif
+{
+ unsigned short *p;
+ int i,j;
+ int count = (w + 1) >> 1;
+
+ if (alu == MIX_DST)
+ return;
+
+ if ((w == 0) || (h == 0))
+ return;
+
+ WaitQueue(2);
+ outw(FRGD_MIX, FSS_PCDATA | alu);
+ outw(WRT_MASK, planemask);
+ WaitQueue(7);
+ outw(CUR_X, (short)x);
+ outw(CUR_Y, (short)y);
+ if (w&1)
+ outw(MAJ_AXIS_PCNT, (short)w);
+ else
+ outw(MAJ_AXIS_PCNT, (short)w-1);
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | h-1);
+ outw(MULTIFUNC_CNTL, SCISSORS_L | x);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | (x+w-1));
+ outw(CMD, CMD_RECT | INC_Y | INC_X | DRAW |
+ PCDATA | WRTDATA | _16BIT | BYTSEQ);
+ psrc += pwidth * py + px;
+ WaitQueue(8);
+ /* ASSUMPTION: it is ok to read one byte past
+ the psrc structure (for odd width). */
+ for (j = 0; j < h; j++) {
+ p = (unsigned short *)psrc;
+ for( i = 0; i < count; i++ )
+ outw( PIX_TRANS, *p++ );
+
+ psrc += pwidth;
+ }
+ WaitQueue(3);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(MULTIFUNC_CNTL, SCISSORS_L);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | 1023);
+}
+
+void
+#if NeedFunctionPrototypes
+ibm8514ImageRead(
+ int x,
+ int y,
+ int w,
+ int h,
+ char *psrc,
+ int pwidth,
+ int px,
+ int py,
+ unsigned long planemask)
+#else
+ibm8514ImageRead(x, y, w, h, psrc, pwidth, px, py, planemask)
+ int x;
+ int y;
+ int w;
+ int h;
+ char *psrc;
+ int pwidth;
+ int px;
+ int py;
+ unsigned long planemask;
+#endif
+{
+ int i,j;
+ unsigned short *sp;
+
+
+ WaitQueue(6);
+ outw(FRGD_MIX, FSS_PCDATA | MIX_SRC);
+ outw(CUR_X, (short)x);
+ outw(CUR_Y, (short)y);
+ if( w & 1 )
+ outw(MAJ_AXIS_PCNT, (short)w);
+ else
+ outw(MAJ_AXIS_PCNT, (short)w-1);
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | h-1);
+ outw(CMD, CMD_RECT | INC_Y | INC_X | DRAW | BYTSEQ |_16BIT | PCDATA);
+ sp = (unsigned short*)(psrc + pwidth * py + px);
+ pwidth = pwidth / 2 - w / 2;
+ planemask = (planemask & 0x00ff) | ((planemask << 8) & 0xff00);
+ WaitDataReady();
+ if( w & 1 ) {
+ w /= 2;
+ for (j = 0; j < h; j++) {
+ for (i = 0; i < w; i++)
+ *sp++ = inw(PIX_TRANS) & planemask;
+ *((unsigned char *)(sp)) = (unsigned char)(inw(PIX_TRANS))
+ & (unsigned char)(planemask);
+ sp += pwidth;
+ }
+ }
+ else {
+ w /= 2;
+ for (j = 0; j < h; j++) {
+ for (i = 0; i < w; i++)
+ *sp++ = inw(PIX_TRANS) & planemask;
+ sp += pwidth;
+ }
+ }
+ WaitQueue(1);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+}
+
+void
+#if NeedFunctionPrototypes
+ibm8514ImageFill(
+ int x,
+ int y,
+ int w,
+ int h,
+ char *psrc,
+ int pwidth,
+ int pw,
+ int ph,
+ int pox,
+ int poy,
+ short alu,
+ unsigned long planemask)
+#else
+ibm8514ImageFill(x, y, w, h, psrc, pwidth, pw, ph, pox, poy, alu, planemask)
+ int x;
+ int y;
+ int w;
+ int h;
+ char *psrc;
+ int pwidth;
+ int pw;
+ int ph;
+ int pox;
+ int poy;
+ short alu;
+ unsigned long planemask;
+#endif
+{
+ int srcxsave, srcx, srcy, dstw, srcw, srch;
+ int wtemp, count, i, j;
+ unsigned short btemp, *p;
+
+
+ if (alu == MIX_DST)
+ return;
+
+ if( pox == 0 && poy == 0 && pw >= x+w && ph >= y+h )
+ ibm8514ImageWrite(x, y, w, h, psrc, pwidth, x, y, alu, planemask);
+ else {
+ WaitQueue(2);
+ outw(FRGD_MIX, FSS_PCDATA | alu);
+ outw(WRT_MASK, planemask);
+ WaitQueue(7);
+ outw(CUR_X, (short)x);
+ outw(CUR_Y, (short)y);
+ if (w&1)
+ outw(MAJ_AXIS_PCNT, (short)w);
+ else
+ outw(MAJ_AXIS_PCNT, (short)w-1);
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | h-1);
+ outw(MULTIFUNC_CNTL, SCISSORS_L | x);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | (x+w-1));
+ outw(CMD, CMD_RECT | INC_Y | INC_X | DRAW |
+ PCDATA | WRTDATA | _16BIT | BYTSEQ);
+ WaitQueue(8);
+ modulus(x-pox,pw,srcxsave);
+ modulus(y-poy,ph,srcy);
+ while( h > 0 ) {
+ srch = ( srcy+h > ph ? ph - srcy : h );
+ for( i = 0; i < srch; i++ ) {
+ dstw = w;
+ srcx = srcxsave;
+ srcw = ( srcx+w > pw ? pw - srcx : w );
+ wtemp = 0;
+ while( dstw > 0 ) {
+ p = (unsigned short *)((unsigned char *)(psrc + pwidth * srcy + srcx));
+ if( wtemp & 1 ) {
+ outw( PIX_TRANS, (btemp & 0x00ff) | (*p << 8 ) );
+ p = (unsigned short *)((unsigned char *)(p)++);
+ wtemp = srcw - 1;
+ }
+ else
+ wtemp = srcw;
+
+ count = wtemp / 2;
+ for( j = 0; j < count; j++ )
+ outw( PIX_TRANS, *p++ );
+
+ dstw -= srcw;
+ srcx = 0;
+ if( wtemp & 1 ) {
+ if( dstw != 0 )
+ btemp = *p;
+ else
+ outw( PIX_TRANS, *p );
+ }
+ srcw = ( dstw < pw ? dstw : pw );
+ }
+ srcy++;
+ h--;
+ }
+ srcy = 0;
+ }
+ WaitQueue(3);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(MULTIFUNC_CNTL, SCISSORS_L);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | 1023);
+ }
+}
+
+void
+#if NeedFunctionPrototypes
+ibm8514ImageStipple(
+ int x,
+ int y,
+ int w,
+ int h,
+ char *psrc,
+ int pwidth,
+ int pw,
+ int ph,
+ int pox,
+ int poy,
+ Pixel fgPixel,
+ Pixel bgPixel,
+ short alu,
+ unsigned long planemask,
+ int opaque)
+#else
+ibm8514ImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy,
+ fgPixel, bgPixel, alu, planemask, opaque)
+ int x;
+ int y;
+ int w;
+ int h;
+ char *psrc;
+ int pwidth;
+ int pw, ph, pox, poy;
+ Pixel fgPixel;
+ Pixel bgPixel;
+ short alu;
+ unsigned long planemask;
+ int opaque;
+#endif
+{
+ int srcx, srch, dstw;
+ unsigned short *ptmp;
+
+
+ if (alu == MIX_DST || w == 0 || h == 0)
+ return;
+
+ WaitQueue(6);
+ outw(MULTIFUNC_CNTL, SCISSORS_L | x);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | (x+w-1));
+ outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_EXPPC | COLCMPOP_F);
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | h-1);
+ outw(WRT_MASK, planemask);
+ outw(FRGD_MIX, FSS_FRGDCOL | alu);
+ WaitQueue(7);
+ if( opaque ) {
+ outw(BKGD_MIX, BSS_BKGDCOL | alu);
+ outw(BKGD_COLOR, (short)bgPixel);
+ }
+ else
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_DST);
+ outw(FRGD_COLOR, (short)fgPixel);
+ w += (x & 3); /* Adjust for nibble mode. */
+ x &= ~3;
+ outw(MAJ_AXIS_PCNT, (short)(((w + 7) & ~7)-1));
+ outw(CUR_X, (short)x);
+ outw(CUR_Y, (short)y);
+ outw(CMD, CMD_RECT | PCDATA | _16BIT | INC_Y | INC_X |
+ YMAJAXIS | DRAW | PLANAR | WRTDATA);
+ modulus(x - pox, pw, x);
+ modulus(y - poy, ph, y);
+ WaitQueue(8);
+ /*
+ * When the source bitmap is properly aligned, max 16 pixels wide,
+ * and nonrepeating use this faster loop instead.
+ * This speeds up all copying to the font cache.
+ */
+ if( (x & 7) == 0 && w <= 16 && x+w <= pw && y+h <= ph ) {
+ unsigned short pix;
+ unsigned char *pnt;
+
+ pnt = (unsigned char *)(psrc + pwidth * y + (x >> 3));
+ while( h-- > 0 ) {
+ pix = *((unsigned short *)(pnt));
+ outw( PIX_TRANS, ibm8514stipple_tab[ pix & 0xff ] );
+ if( w > 8 )
+ outw( PIX_TRANS, ibm8514stipple_tab[ ( pix >> 8 ) & 0xff ] );
+
+ pnt += pwidth;
+ }
+ }
+ else {
+ while( h > 0 ) {
+ srch = ( y+h > ph ? ph - y : h );
+ while( srch > 0 ) {
+ dstw = w;
+ srcx = x;
+ ptmp = (unsigned short *)(psrc + pwidth * y);
+ while( dstw > 0 ) {
+ int np, x2;
+ unsigned short *pnt, pix;
+ /*
+ * Assemble 16 bits and feed them to the draw engine.
+ */
+ np = pw - srcx; /* No. pixels left in bitmap.*/
+ pnt =(unsigned short *)
+ ((unsigned char *)(ptmp) + (srcx >> 3));
+ x2 = srcx & 7; /* Offset within byte. */
+ if( np >= 16 ) {
+ pix = (unsigned short)(*((unsigned int *)(pnt)) >> x2);
+ }
+ else if( pw >= 16 ) {
+ pix = (unsigned short)((*((unsigned int *)(pnt)) >> x2)
+ & MSKBIT(np)) | (*ptmp << np);
+ }
+ else if( pw >= 8 ) {
+ pix = ((*pnt >> x2) & MSKBIT(np)) | (*ptmp << np)
+ | (*pnt << (np+pw));
+ }
+ else {
+ pix = (*ptmp >> x2) & MSKBIT(np);
+ while( np < 16 && np < dstw ) {
+ pix |= *ptmp << np;
+ np += pw;
+ }
+ }
+ outw( PIX_TRANS, ibm8514stipple_tab[ pix & 0xff ] );
+ if( dstw > 8 )
+ outw( PIX_TRANS,
+ ibm8514stipple_tab[ ( pix >> 8 ) & 0xff ] );
+ srcx += 16;
+ if( srcx >= pw )
+ srcx -= pw;
+ dstw -= 16;
+ }
+ y++;
+ h--;
+ srch--;
+ }
+ y = 0;
+ }
+ }
+ WaitQueue(5);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+ outw(MULTIFUNC_CNTL, SCISSORS_L | 0);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | 1023);
+ outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);
+}
+
+#endif /* ASM_IMAGE */
+
+void
+ibm8514FontOpStipple(x, y, w, h, psrc, pwidth, id)
+ int x;
+ int y;
+ int w;
+ int h;
+ char *psrc;
+ int pwidth;
+ Pixel id;
+{
+
+ ibm8514ImageStipple(x, y, w, h, psrc, pwidth, w, h, x, y,
+ ~0, 0, ibm8514alu[GXcopy], 1 << id, 1 );
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/imfill.s b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/imfill.s
new file mode 100644
index 000000000..5a0ef505e
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/imfill.s
@@ -0,0 +1,429 @@
+/* $XConsortium: ibm8514imfl.s,v 1.2 94/03/29 09:37:34 dpw Exp $ */
+/******************************************************************************
+
+This is a assembly language version of the ibm8514ImageFill routine.
+It is renamed to enable a filter routine to catch the simplest
+cases and dispatch them to the more efficent ibm8514Imagewrite.
+
+Written by Hans Nasten ( nasten@everyware.se ) AUG 29, 1993.
+
+
+The equivalent C-code looks like this.
+
+void
+ibm8514RealImageFill(x, y, w, h, psrc, pwidth, pw, ph, pox, poy, alu, planemask)
+ int x;
+ int y;
+ int w;
+ int h;
+ unsigned char *psrc;
+ int pwidth;
+ int pw;
+ int ph;
+ int pox;
+ int poy;
+ short alu;
+ short planemask;
+{
+ int srcxsave, srcx, srcy, dstw, srcw, srch;
+ int wtemp, count, i, j;
+ unsigned short btemp, *p;
+
+
+ WaitQueue(2);
+ outw(FRGD_MIX, FSS_PCDATA | alu);
+ outw(WRT_MASK, planemask);
+ WaitQueue(7);
+ outw(CUR_X, (short)x);
+ outw(CUR_Y, (short)y);
+ if (w&1)
+ outw(MAJ_AXIS_PCNT, (short)w);
+ else
+ outw(MAJ_AXIS_PCNT, (short)w-1);
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | h-1);
+ outw(MULTIFUNC_CNTL, SCISSORS_L | x);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | (x+w-1));
+ outw(CMD, CMD_RECT | INC_Y | INC_X | DRAW |
+ PCDATA | WRTDATA | _16BIT | BYTSEQ);
+ WaitQueue(8);
+
+ modulus(y-poy,ph,srcy);
+ while( h > 0 ) {
+ srch = ( srcy+h > ph ? ph - srcy : h );
+ modulus(x-pox,pw,srcxsave);
+ for( i = 0; i < srch; i++ ) {
+ dstw = w;
+ srcx = srcxsave;
+ srcw = ( srcx+w > pw ? pw - srcx : w );
+ wtemp = 0;
+ while( dstw > 0 ) {
+ p = (unsigned short *)((unsigned char *)(psrc + pwidth * srcy + srcx));
+ if( wtemp & 1 ) {
+ outw( PIX_TRANS, (btemp & 0x00ff) | (*p << 8 ) );
+ p = (unsigned short *)((unsigned char *)(p)++);
+ wtemp = srcw - 1;
+ }
+ else
+ wtemp = srcw;
+
+ count = wtemp / 2;
+ for( j = 0; j < count; j++ )
+ outw( PIX_TRANS, *p++ );
+
+ dstw -= srcw;
+ srcx = 0;
+ if( wtemp & 1 ) {
+ if( dstw != 0 ) {
+ btemp = *p;
+ }
+ else
+ outw( PIX_TRANS, *p );
+ }
+ srcw = ( dstw < pw ? dstw : pw );
+ }
+ srcy++;
+ h--;
+ }
+ srcy = 0;
+ }
+ WaitQueue(3);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(MULTIFUNC_CNTL, SCISSORS_L);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | 1023);
+}
+
+******************************************************************************/
+
+#define _8514_ASM_
+#include "assyntax.h"
+#include "reg8514.h"
+
+ AS_BEGIN
+
+/*
+ * Defines for in arguments.
+ */
+#define x_arg REGOFF(8,EBP)
+#define y_arg REGOFF(12,EBP)
+#define w_arg REGOFF(16,EBP)
+#define h_arg REGOFF(20,EBP)
+#define psrc_arg REGOFF(24,EBP)
+#define pwidth_arg REGOFF(28,EBP)
+#define pw_arg REGOFF(32,EBP)
+#define ph_arg REGOFF(36,EBP)
+#define pox_arg REGOFF(40,EBP)
+#define poy_arg REGOFF(44,EBP)
+#define alu_arg REGOFF(48,EBP)
+#define planemask_arg REGOFF(52,EBP)
+
+/*
+ * Defines for local variables.
+ */
+#define srcy_loc REGOFF(-4,EBP)
+#define srch_loc REGOFF(-8,EBP)
+#define srcx_loc REGOFF(-12,EBP)
+#define srcxsave_loc REGOFF(-16,EBP)
+
+
+ SEG_TEXT
+ ALIGNTEXT4
+
+GLOBL GLNAME(ibm8514RealImageFill)
+
+GLNAME(ibm8514RealImageFill):
+ PUSH_L (EBP)
+ MOV_L (ESP,EBP)
+ SUB_L (CONST(16),ESP)
+ PUSH_L (EDI)
+ PUSH_L (ESI)
+ PUSH_L (EBX)
+/*
+ * Check if height or width is 0.
+ */
+ MOV_L (w_arg,EDI)
+ MOV_L (h_arg,EBX)
+ OR_L (EDI,EDI)
+ JZ (.finish)
+ OR_L (EBX,EBX)
+ JZ (.finish)
+/*
+ * Wait for 2 queue entries
+ */
+ MOV_L (GP_STAT,EDX)
+.wait_queue_0:
+ IN_B
+ TEST_B (CONST(0x40),AL)
+ JNZ (.wait_queue_0)
+/*
+ * Init 8514 registers.
+ */
+ MOV_L (FRGD_MIX,EDX)
+ MOV_W (alu_arg,AX)
+ OR_W (FSS_PCDATA,AX)
+ OUT_W
+
+ MOV_L (WRT_MASK,EDX)
+ MOV_W (planemask_arg,AX)
+ OUT_W
+/*
+ * Wait for 7 queue entries
+ */
+ MOV_L (GP_STAT,EDX)
+.wait_queue_1:
+ IN_B
+ TEST_B (CONST(0x02),AL)
+ JNZ (.wait_queue_1)
+
+ MOV_L (CUR_X,EDX)
+ MOV_W (x_arg,AX)
+ OUT_W
+
+ MOV_L (CUR_Y,EDX)
+ MOV_W (y_arg,AX)
+ OUT_W
+/*
+ * If the width is odd, program the 8514 registers for width+1.
+ */
+ MOV_L (MAJ_AXIS_PCNT,EDX)
+ MOV_W (w_arg,AX)
+ TEST_W (CONST(1),AX)
+ JNZ (.odd)
+
+ DEC_W (AX)
+.odd:
+ OUT_W
+
+.cont1:
+/*
+ * Set height and scissors registers.
+ * The scissors is used to clip the last unwanted pixel on
+ * lines with a odd length.
+ */
+ MOV_L (MULTIFUNC_CNTL,EDX)
+ MOV_W (h_arg,AX)
+ DEC_W (AX)
+/* OR_W (MIN_AXIS_PCNT,AX)*/
+ OUT_W
+ MOV_W (x_arg,AX)
+ OR_W (SCISSORS_L,AX)
+ OUT_W
+ MOV_W (x_arg,AX)
+ ADD_W (w_arg,AX)
+ DEC_W (AX)
+ OR_W (SCISSORS_R,AX)
+ OUT_W
+/*
+ * Give command to 8514.
+ * The command is : CMD_RECT | INC_Y | INC_X | DRAW
+ * | PCDATA | WRTDATA | _16BIT | BYTSEQ);
+ */
+ MOV_L (CMD,EDX)
+ MOV_W (GP_WRITE_CMD,AX)
+ OUT_W
+/*
+ * Do the modulo trick for the y coordinate.
+ * This is stolen from the gcc 2.4.5 output.
+ */
+ MOV_L (y_arg,EAX)
+ SUB_L (poy_arg,EAX)
+ CDQ
+ IDIV_L (ph_arg)
+ TEST_L (EDX,EDX)
+ JGE (.mod1)
+ ADD_L (ph_arg,EDX)
+.mod1:
+ MOV_L (EDX,srcy_loc)
+/*
+ * Wait until the fifo is empty.
+ */
+ MOV_L (GP_STAT,EDX)
+.wait_queue_2:
+ IN_B
+ TEST_B (CONST(1),AL)
+ JNZ (.wait_queue_2)
+
+ CLD
+/*
+ * Process all lines on screen repeating the pixmap if needed.
+ * This loop paints from the present y location to the end of
+ * the pixmap. ( or to the end of the screen area if the pixmap
+ * is nonrepeating ).
+ * Start by checking if the pixmap is high enough to completely
+ * cover the screen area vertically.
+ */
+.next_pixmap_vertical:
+ MOV_L (srcy_loc,EAX)
+ ADD_L (h_arg,EAX)
+ MOV_L (ph_arg,EBX)
+ CMP_L (EBX,EAX)
+ JLE (.cmp_get_h)
+
+ SUB_L (srcy_loc,EBX)
+ JMP (.cmp2)
+.cmp_get_h:
+ MOV_L (h_arg,EBX)
+.cmp2:
+ MOV_L (EBX,srch_loc)
+ SUB_L (EBX,h_arg)
+/*
+ * Do the modulo trick for the x coordinate.
+ */
+ MOV_L (x_arg,EAX)
+ SUB_L (pox_arg,EAX)
+ CDQ
+ IDIV_L (pw_arg)
+ TEST_L (EDX,EDX)
+ JGE (.mod2)
+ ADD_L (pw_arg,EDX)
+.mod2:
+ MOV_L (EDX,srcxsave_loc)
+/*
+ * Process one line of pixels in the pixmap,
+ * repeating the pixmap horisontally if needed.
+ * Start by checking if the pixmap is wide enough to completely
+ * cover the screen area horisontally.
+ */
+.next_pixmap_line:
+ MOV_L (w_arg,EBX)
+ MOV_L (srcxsave_loc,EAX)
+ ADD_L (EBX,EAX)
+ MOV_L (pw_arg,EDI)
+ CMP_L (EDI,EAX)
+ JLE (.cmp_get_w)
+
+ SUB_L (srcxsave_loc,EDI)
+ JMP (.cmp4)
+
+.cmp_get_w:
+ MOV_L (EBX,EDI)
+.cmp4:
+ SUB_L (ECX,ECX)
+/*
+ * Calculate and save a pointer to the first pixel on this line in
+ * the pixmap. Add the x offset for the first lap and then skip the
+ * first part of the loop.
+ * ( all this just to avoid one multiplication and two add's in the loop ).
+ */
+ MOV_L (pwidth_arg,EAX)
+ MUL_L (srcy_loc)
+ ADD_L (psrc_arg,EAX)
+ MOV_L (EAX,srcx_loc)
+ MOV_L (srcxsave_loc,ESI)
+ ADD_L (EAX,ESI)
+ JMP (.previously_even)
+/*
+ * Copy one line of the pixmap to the screen.
+ * This loop paints one line of pixels from the pixmap onto the screen.
+ */
+.next_pixmap_horizontal:
+ MOV_L (srcx_loc,ESI)
+/*
+ * Is there a pixel leftover from the previous lap in the loop ?
+ * ( since CH is used to store the saved pixel, only CL is in scope ).
+ */
+ TEST_B (CONST(1),CL)
+ JZ (.previously_even)
+/*
+ * Yes there was, combine it with the first pixel and write them
+ * to the 8514 engine.
+ */
+ MOV_B (CH,AL)
+ MOV_B (REGIND(ESI),AH)
+ MOV_L (PIX_TRANS,EDX)
+ OUT_W
+ INC_L (ESI)
+ MOV_L (EDI,ECX)
+ DEC_L (ECX)
+ JMP (.move_pixels)
+
+.previously_even:
+ MOV_L (EDI,ECX)
+ MOV_L (PIX_TRANS,EDX)
+/*
+ * Move the rest of the line using a "rep outsw" instruction.
+ */
+.move_pixels:
+ MOV_L (ECX,EAX)
+ SHR_L (CONST(1),ECX)
+ REP
+ OUTS_W
+ MOV_L (EAX,ECX)
+ SUB_L (EDI,EBX)
+/*
+ * Is there a pixel left unwritten ?
+ */
+ TEST_W (CONST(1),CX)
+ JZ (.all_written)
+/*
+ * Yes, check if this is the last ( or only ) repetition of the pixmap.
+ */
+ AND_L (EBX,EBX)
+ JZ (.write_pixel)
+/*
+ * No, there is more to come. Save this pixel for later.
+ */
+ MOV_B (REGIND(ESI),CH)
+ JMP (.all_written)
+/*
+ * Yes, this is the last pixel displayed on this line.
+ * Write it and let the scissors cut the unwanted extra pixel.
+ */
+.write_pixel:
+ MOV_B (REGIND(ESI),AL)
+ OUT_W
+/*
+ * Check if the next repetition of the pixmap is using the entire
+ * pixmap width.
+ */
+.all_written:
+ MOV_L (pw_arg,EAX)
+ CMP_L (EAX,EBX)
+ JG (.cmp6)
+
+ MOV_L (EBX,EAX)
+.cmp6:
+ MOV_L (EAX,EDI)
+ AND_L (EBX,EBX)
+ JNZ (.next_pixmap_horizontal)
+
+ INC_L (srcy_loc)
+ DEC_L (srch_loc)
+ JNZ (.next_pixmap_line)
+
+ SUB_L (EDX,EDX)
+ MOV_L (EDX,srcy_loc)
+ CMP_L (EDX,h_arg)
+ JNZ (.next_pixmap_vertical)
+
+/*
+ * Wait until room for 3 entries in the fifo.
+ */
+ MOV_L (GP_STAT,EDX)
+.wait_queue_3:
+ IN_B
+ TEST_B (CONST(0x20),AL)
+ JNZ (.wait_queue_3)
+/*
+ * Reset FRGD_MIX to default.
+ */
+ MOV_L (FRGD_MIX,EDX)
+ MOV_W (GP_DEF_FRGD_MIX,AX)
+ OUT_W
+
+/*
+ * Reset the scissors regsiters.
+ */
+ MOV_L (MULTIFUNC_CNTL,EDX)
+ MOV_W (SCISSORS_L,AX)
+ OUT_W
+ MOV_W (SCISSORS_R,AX)
+ OR_W (CONST(1023),AX)
+ OUT_W
+
+.finish:
+ POP_L (EBX)
+ POP_L (ESI)
+ POP_L (EDI)
+ ADD_L (CONST(16),ESP)
+ POP_L (EBP)
+ RET
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/imread.s b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/imread.s
new file mode 100644
index 000000000..87abeb4f2
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/imread.s
@@ -0,0 +1,259 @@
+/* $XConsortium: ibm8514imrd.s,v 1.2 94/03/29 09:37:41 dpw Exp $ */
+/******************************************************************************
+
+This is a assembly language version of the ibm8514ImageRead routine.
+Written by Hans Nasten ( nasten@everyware.se ) AUG 29, 1993.
+
+void
+ibm8514ImageRead(x, y, w, h, psrc, pwidth, px, py, planemask)
+ int x;
+ int y;
+ int w;
+ int h;
+ unsigned char *psrc;
+ int pwidth;
+ int px;
+ int py;
+ short planemask;
+
+******************************************************************************/
+
+
+#define _8514_ASM_
+#include "assyntax.h"
+#include "reg8514.h"
+
+ AS_BEGIN
+
+/*
+ * Defines for in arguments.
+ */
+#define x_arg REGOFF(8,EBP)
+#define y_arg REGOFF(12,EBP)
+#define w_arg REGOFF(16,EBP)
+#define h_arg REGOFF(20,EBP)
+#define psrc_arg REGOFF(24,EBP)
+#define pwidth_arg REGOFF(28,EBP)
+#define px_arg REGOFF(32,EBP)
+#define py_arg REGOFF(36,EBP)
+#define planemask_arg REGOFF(40,EBP)
+
+
+ SEG_TEXT
+ ALIGNTEXT4
+
+GLOBL GLNAME(ibm8514ImageRead)
+
+GLNAME(ibm8514ImageRead):
+ PUSH_L (EBP)
+ MOV_L (ESP,EBP)
+ PUSH_L (EDI)
+ PUSH_L (ESI)
+ PUSH_L (EBX)
+/*
+ * Check if height or width is 0.
+ */
+ MOV_L (w_arg,EDI)
+ MOV_L (h_arg,EBX)
+ OR_L (EDI,EDI)
+ JZ (.finish)
+ OR_L (EBX,EBX)
+ JZ (.finish)
+/*
+ * Wait for 6 queue entries
+ */
+ MOV_L (GP_STAT,EDX)
+.wait_queue_0:
+ IN_B
+ TEST_B (CONST(0x04),AL)
+ JNZ (.wait_queue_0)
+/*
+ * Init 8514 registers.
+ */
+ MOV_L (FRGD_MIX,EDX)
+ MOV_W (CONST(0x0047),AX)
+ OUT_W
+
+ MOV_L (CUR_X,EDX)
+ MOV_W (x_arg,AX)
+ OUT_W
+
+ MOV_L (CUR_Y,EDX)
+ MOV_W (y_arg,AX)
+ OUT_W
+/*
+ * If the width is odd, program the 8514 registers for width+1.
+ */
+ MOV_L (MAJ_AXIS_PCNT,EDX)
+ MOV_W (w_arg,AX)
+ TEST_W (CONST(1),AX)
+ JNZ (.odd)
+
+ DEC_W (AX)
+.odd:
+ OUT_W
+
+.cont1:
+/*
+ * Set height registers.
+ */
+ MOV_L (MULTIFUNC_CNTL,EDX)
+ MOV_W (h_arg,AX)
+ DEC_W (AX)
+/* OR_W (MIN_AXIS_PCNT,AX)*/
+ OUT_W
+
+/*
+ * Give command to 8514.
+ * The command is : CMD_RECT | INC_Y | INC_X | DRAW
+ * | PCDATA | _16BIT | BYTSEQ);
+ */
+ MOV_L (CMD,EDX)
+ MOV_W (GP_READ_CMD,AX)
+ OUT_W
+/*
+ * Calculate a pointer to the first pixel on the first line.
+ */
+ MOV_L (pwidth_arg,EAX)
+ MUL_L (py_arg)
+ ADD_L (px_arg,EAX)
+ MOV_L (psrc_arg,EDI)
+ ADD_L (EAX,EDI)
+/*
+ * Wait until data is ready in the fifo.
+ */
+ MOV_L (GP_STAT,EDX)
+.wait_ready_1:
+ IN_W
+ TEST_W (DATARDY,AX)
+ JZ (.wait_ready_1)
+/*
+ * Read the pixels line by line from the fifo.
+ */
+ CLD
+ MOV_L (PIX_TRANS,EDX)
+
+ MOV_L (pwidth_arg,ESI)
+ SHR_L (CONST(1),ESI)
+ MOV_L (w_arg,EBX)
+ SHR_L (CONST(1),EBX)
+ SUB_L (EBX,ESI)
+ SHL_L (CONST(1),ESI)
+
+ MOV_W (planemask_arg,BX)
+ CMP_W (CONST(0xff),BX)
+ JZ (.get_all_planes)
+
+ MOV_L (ESI,pwidth_arg)
+ MOV_L (h_arg,ESI)
+ MOV_B (BL,BH)
+ TEST_W (CONST(1),w_arg)
+ JNZ (.odd_width_masked)
+/*
+ * Even number of pixels on each line, but some of the bitplanes
+ * should be masked out.
+ */
+ SHR_L (CONST(1),w_arg)
+.next_even_line_masked:
+ MOV_L (w_arg,ECX)
+.next_even_word_masked:
+ IN_W
+ AND_W (BX,AX)
+ STOS_W
+ LOOP (.next_even_word_masked)
+
+ ADD_L (pwidth_arg,EDI)
+ DEC_W (SI)
+ JNZ (.next_even_line_masked)
+
+ JMP (.all_done)
+/*
+ * Odd number of pixels on each line, but some of the bitplanes
+ * should be masked out. Read an additional pixel on each line.
+ */
+.odd_width_masked:
+ SHR_L (CONST(1),w_arg)
+.next_odd_line_masked:
+ MOV_L (w_arg,ECX)
+ AND_L (ECX,ECX)
+ JZ (.odd_masked_skip)
+
+.next_odd_word_masked:
+ IN_W
+ AND_W (BX,AX)
+ STOS_W
+ LOOP (.next_odd_word_masked)
+
+.odd_masked_skip:
+ IN_W
+ AND_B (BL,AL)
+ MOV_B (AL,REGIND(EDI))
+ ADD_L (pwidth_arg,EDI)
+ DEC_W (SI)
+ JNZ (.next_odd_line_masked)
+
+ JMP (.all_done)
+/*
+ * All bitplanes is to be stored. Skip planemask anding.
+ */
+.get_all_planes:
+ MOV_W (h_arg,BX)
+ TEST_W (CONST(1),w_arg)
+ JNZ (.odd_width)
+/*
+ * Even number of pixels on each line,
+ * read entire line with insw.
+ */
+ MOV_L (w_arg,EBP)
+ SHR_L (CONST(1),EBP)
+.next_even_line:
+ MOV_L (EBP,ECX)
+ REP
+ INS_W
+ ADD_L (ESI,EDI)
+ DEC_W (BX)
+ JNZ (.next_even_line)
+
+ JMP (.all_done)
+/*
+ * Odd number of pixels on each line,
+ * read line with insw but read last pixel with inw.
+ */
+.odd_width:
+ MOV_L (w_arg,EBP)
+ SHR_L (CONST(1),EBP)
+.next_odd_line:
+ MOV_L (EBP,ECX)
+ REP
+ INS_W
+ IN_W
+ MOV_B (AL,REGIND(EDI))
+ ADD_L (ESI,EDI)
+ DEC_W (BX)
+ JNZ (.next_odd_line)
+
+/*
+ * Wait until room for 1 entry in the fifo.
+ */
+
+.all_done:
+ MOV_L (GP_STAT,EDX)
+.wait_queue_2:
+ IN_B
+ TEST_B (CONST(0x80),AL)
+ JNZ (.wait_queue_2)
+/*
+ * Reset FRGD_MIX to default.
+ */
+ MOV_L (FRGD_MIX,EDX)
+ MOV_W (GP_DEF_FRGD_MIX,AX)
+ OUT_W
+
+.finish:
+ POP_L (EBX)
+ POP_L (ESI)
+ POP_L (EDI)
+ POP_L (EBP)
+ RET
+
+
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/imstip.s b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/imstip.s
new file mode 100644
index 000000000..482540cbc
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/imstip.s
@@ -0,0 +1,569 @@
+/* $XConsortium: ibm8514imst.s,v 1.2 94/03/29 09:37:45 dpw Exp $ */
+/******************************************************************************
+
+This is a assembly language version of the ibm8514ImageStipple routine.
+
+Written by Hans Nasten ( nasten@everyware.se ) SEP 16, 1993.
+
+
+This is a assembly language version of the C code in ibm8514im.c
+
+******************************************************************************/
+
+#define _8514_ASM_
+#include "assyntax.h"
+#include "reg8514.h"
+
+ AS_BEGIN
+
+/*
+ * Defines for in arguments.
+ */
+#define x_arg REGOFF(8,EBP)
+#define y_arg REGOFF(12,EBP)
+#define w_arg REGOFF(16,EBP)
+#define h_arg REGOFF(20,EBP)
+#define psrc_arg REGOFF(24,EBP)
+#define pwidth_arg REGOFF(28,EBP)
+#define pw_arg REGOFF(32,EBP)
+#define ph_arg REGOFF(36,EBP)
+#define pox_arg REGOFF(40,EBP)
+#define poy_arg REGOFF(44,EBP)
+#define fgpix_arg REGOFF(48,EBP)
+#define bgpix_arg REGOFF(52,EBP)
+#define alu_arg REGOFF(56,EBP)
+#define planemask_arg REGOFF(60,EBP)
+#define opaque_arg REGOFF(64,EBP)
+
+/*
+ * Defines for local variables.
+ */
+#define srcx_loc REGOFF(-4,EBP)
+#define srch_loc REGOFF(-8,EBP)
+#define dstw_loc REGOFF(-12,EBP)
+
+
+ SEG_TEXT
+ ALIGNTEXT4
+
+.mskbit:
+ D_WORD 0x0000
+ D_WORD 0x0001
+ D_WORD 0x0003
+ D_WORD 0x0007
+ D_WORD 0x000f
+ D_WORD 0x001f
+ D_WORD 0x003f
+ D_WORD 0x007f
+ D_WORD 0x00ff
+ D_WORD 0x01ff
+ D_WORD 0x03ff
+ D_WORD 0x07ff
+ D_WORD 0x0fff
+ D_WORD 0x1fff
+ D_WORD 0x3fff
+ D_WORD 0x7fff
+ D_WORD 0xffff
+ D_WORD 0x0000
+
+
+GLOBL GLNAME(ibm8514ImageStipple)
+
+GLNAME(ibm8514ImageStipple):
+ PUSH_L (EBP)
+ MOV_L (ESP,EBP)
+ SUB_L (CONST(12),ESP)
+ PUSH_L (EDI)
+ PUSH_L (ESI)
+ PUSH_L (EBX)
+/*
+ * Check if alu = MIX_DST or height == 0 or width == 0.
+ */
+ MOV_L (alu_arg,EAX)
+ CMP_L (MIX_DST,EAX)
+ JZ (.finish)
+ MOV_L (w_arg,EDI)
+ OR_L (EDI,EDI)
+ JZ (.finish)
+ MOV_L (h_arg,EBX)
+ OR_L (EBX,EBX)
+ JZ (.finish)
+/*
+ * Wait for 6 queue entries
+ */
+ MOV_L (GP_STAT,EDX)
+.wait_queue_0:
+ IN_W
+ TEST_W (CONST(0x04),AX)
+ JNZ (.wait_queue_0)
+/*
+ * Set scissors, pixcntl and height registers.
+ */
+ MOV_L (MULTIFUNC_CNTL,EDX)
+ MOV_W (x_arg,AX)
+ OR_W (SCISSORS_L,AX)
+ OUT_W
+ MOV_W (x_arg,AX)
+ ADD_W (w_arg,AX)
+ DEC_W (AX)
+ OR_W (SCISSORS_R,AX)
+ OUT_W
+ MOV_W (PIXCNTL_STIP,AX)
+ OUT_W
+ MOV_W (h_arg,AX)
+ DEC_W (AX)
+/* OR_W (MIN_AXIS_PCNT,AX)*/
+ OUT_W
+/*
+ * Init write mask and frgd mix.
+ */
+ MOV_L (WRT_MASK,EDX)
+ MOV_W (planemask_arg,AX)
+ OUT_W
+ MOV_L (FRGD_MIX,EDX)
+ MOV_W (alu_arg,AX)
+ OR_W (FSS_FRGDCOL,AX)
+ OUT_W
+/*
+ * Wait for 7 queue entries
+ */
+ MOV_L (GP_STAT,EDX)
+.wait_queue_1:
+ IN_W
+ TEST_W (CONST(0x02),AX)
+ JNZ (.wait_queue_1)
+/*
+ * Init bkgd mix and bkgd colour according to opaque argument.
+ */
+ CMP_L (CONST(0),opaque_arg)
+ JZ (.not_opaque)
+
+ MOV_L (BKGD_MIX,EDX)
+ MOV_W (alu_arg,AX)
+/* OR_W (BSS_BKGDCOL,AX)*/
+ OUT_W
+ MOV_L (BKGD_COLOR,EDX)
+ MOV_W (bgpix_arg,AX)
+ OUT_W
+ JMP (.set_frgdcol)
+.not_opaque:
+ MOV_L (BKGD_MIX,EDX)
+ MOV_W (MIX_DST,AX)
+/* OR_W (BSS_BKGDCOL,AX)*/
+ OUT_W
+.set_frgdcol:
+ MOV_L (FRGD_COLOR,EDX)
+ MOV_W (fgpix_arg,AX)
+ OUT_W
+/*
+ * Adjust width and x arguments to even nibbles.
+ */
+ MOV_L (x_arg,EAX)
+ AND_L (CONST(3),EAX)
+ ADD_L (w_arg,EAX)
+ MOV_L (EAX,w_arg)
+ MOV_L (x_arg,EBX)
+ AND_L (CONST(0xfffffffc),EBX)
+ MOV_L (EBX,x_arg)
+/*
+ * Set major axis count, x and y registers.
+ */
+ MOV_L (MAJ_AXIS_PCNT,EDX)
+ ADD_L (CONST(7),EAX)
+ AND_L (CONST(0xfffffff8),EAX)
+ DEC_L (EAX)
+ OUT_W
+ MOV_L (CUR_X,EDX)
+ MOV_W (BX,AX)
+ OUT_W
+ MOV_L (CUR_Y,EDX)
+ MOV_W (y_arg,AX)
+ OUT_W
+/*
+ * Give command to 8514.
+ * The command is : CMD_RECT | INC_Y | INC_X | DRAW
+ * | PCDATA | WRTDATA | _16BIT | YMAJAXIS | PLANAR);
+ */
+ MOV_L (CMD,EDX)
+ MOV_W (GP_STIP_CMD,AX)
+ OUT_W
+/*
+ * Do the modulo trick for the x coordinate.
+ */
+ MOV_L (x_arg,EAX)
+ SUB_L (pox_arg,EAX)
+ CDQ
+ IDIV_L (pw_arg)
+ TEST_L (EDX,EDX)
+ JGE (.mod2)
+ ADD_L (pw_arg,EDX)
+.mod2:
+ MOV_L (EDX,x_arg)
+/*
+ * Do the modulo trick for the y coordinate.
+ */
+ MOV_L (y_arg,EAX)
+ SUB_L (poy_arg,EAX)
+ CDQ
+ IDIV_L (ph_arg)
+ TEST_L (EDX,EDX)
+ JGE (.mod1)
+ ADD_L (ph_arg,EDX)
+.mod1:
+ MOV_L (EDX,y_arg)
+/*
+ * Wait until the fifo is empty.
+ */
+ MOV_L (GP_STAT,EDX)
+.wait_queue_2:
+ IN_W
+ TEST_W (CONST(1),AX)
+ JNZ (.wait_queue_2)
+/*
+ * When the source bitmap is properly aligned, max 16 pixels wide,
+ * and nonrepeating use this faster loop instead.
+ * This speeds up all copying to the font cache.
+ */
+ MOV_L (x_arg,EAX)
+ AND_L (CONST(7),EAX)
+ JNZ (.next_bitmap_vertical)
+
+ MOV_L (w_arg,EAX)
+ CMP_L (CONST(16),EAX)
+ JG (.next_bitmap_vertical)
+
+ ADD_L (x_arg,EAX)
+ CMP_L (pw_arg,EAX)
+ JG (.next_bitmap_vertical)
+
+ MOV_L (y_arg,EAX)
+ ADD_L (h_arg,EAX)
+ CMP_L (ph_arg,EAX)
+ JG (.next_bitmap_vertical)
+
+ MOV_L (y_arg,EAX)
+ MUL_L (pwidth_arg)
+ MOV_L (x_arg,EDX)
+ SHR_L (CONST(3),EDX)
+ ADD_L (EDX,EAX)
+ MOV_L (psrc_arg,ESI)
+ ADD_L (EAX,ESI)
+ MOV_L (PIX_TRANS,EDX)
+ MOV_L (h_arg,EDI)
+ CMP_L (CONST(8),w_arg)
+ JLE (.fast_loop_8)
+/*
+ * This loop is for max 16 pixels wide bitmaps.
+ */
+.fast_loop_16:
+ MOV_W (REGIND(ESI),CX)
+ XOR_L (EBX,EBX)
+ MOV_B (CL,BL)
+ SHL_L (CONST(1),EBX)
+ MOV_W (REGOFF(GLNAME(ibm8514stipple_tab),EBX),AX)
+ OUT_W
+ XOR_L (EBX,EBX)
+ MOV_B (CH,BL)
+ SHL_L (CONST(1),EBX)
+ MOV_W (REGOFF(GLNAME(ibm8514stipple_tab),EBX),AX)
+ OUT_W
+ ADD_L (pwidth_arg,ESI)
+ DEC_L (EDI)
+ JNZ (.fast_loop_16)
+
+ JMP (.stipple_exit)
+/*
+ * This loop is for max 8 pixels wide bitmaps.
+ */
+.fast_loop_8:
+ XOR_L (EBX,EBX)
+ MOV_B (REGIND(ESI),BL)
+ SHL_L (CONST(1),EBX)
+ MOV_W (REGOFF(GLNAME(ibm8514stipple_tab),EBX),AX)
+ OUT_W
+ ADD_L (pwidth_arg,ESI)
+ DEC_L (EDI)
+ JNZ (.fast_loop_8)
+
+ JMP (.stipple_exit)
+/*
+ * Process all lines on screen repeating the bitmap if needed.
+ * This loop paints from the present y location to the end of
+ * the bitmap. ( or to the end of the screen area if the bitmap
+ * is nonrepeating ).
+ * Start by checking if the bitmap is high enough to completely
+ * cover the screen area vertically.
+ */
+.next_bitmap_vertical:
+ MOV_L (y_arg,EAX)
+ ADD_L (h_arg,EAX)
+ MOV_L (ph_arg,EBX)
+ CMP_L (EBX,EAX)
+ JLE (.cmp_get_h)
+
+ SUB_L (y_arg,EBX)
+ JMP (.cmp2)
+.cmp_get_h:
+ MOV_L (h_arg,EBX)
+.cmp2:
+ MOV_L (EBX,srch_loc)
+/*
+ * Process one line of pixels in the bitmap,
+ * repeating the bitmap horisontally if needed.
+ */
+.next_bitmap_line:
+ MOV_L (w_arg,EAX)
+ MOV_L (EAX,dstw_loc)
+ MOV_L (x_arg,ESI)
+ MOV_L (ESI,srcx_loc)
+ MOV_L (y_arg,EAX)
+ MUL_L (pwidth_arg)
+ MOV_L (psrc_arg,EDI)
+ ADD_L (EAX,EDI)
+/*
+ * Copy one line of the bitmap to the screen.
+ * This loop paints one line of pixels from the bitmap onto the screen.
+ */
+.next_byte_horizontal:
+ MOV_L (ESI,ECX)
+ MOV_L (pw_arg,EBX)
+ MOV_L (EBX,EDX)
+ SUB_L (ESI,EBX)
+
+ SHR_L (CONST(3),ESI)
+ ADD_L (EDI,ESI)
+
+ AND_B (CONST(7),CL)
+
+ CMP_L (CONST(16),EBX)
+ JL (.less_than_16_left)
+/*
+ * In this case we have at least 16 pixels left in the bitmap.
+ */
+ MOV_L (REGIND(ESI),EAX)
+ SHR_L (CL,EAX)
+
+ MOV_L (srcx_loc,ESI)
+ ADD_L (CONST(16),ESI)
+ CMP_L (EDX,ESI)
+ JL (.no_wrap2)
+
+ SUB_L (EDX,ESI)
+
+.no_wrap2:
+ MOV_L (ESI,srcx_loc)
+ MOV_L (PIX_TRANS,EDX)
+ MOV_W (AX,CX)
+ XOR_L (EBX,EBX)
+ MOV_B (AL,BL)
+ SHL_L (CONST(1),EBX)
+ MOV_W (REGOFF(GLNAME(ibm8514stipple_tab),EBX),AX)
+ OUT_W
+ CMP_L (CONST(8),dstw_loc)
+ JLE (.chk_next_line)
+
+ XOR_L (EBX,EBX)
+ MOV_B (CH,BL)
+ SHL_L (CONST(1),EBX)
+ MOV_W (REGOFF(GLNAME(ibm8514stipple_tab),EBX),AX)
+ OUT_W
+ SUB_L (CONST(16),dstw_loc)
+ JG (.next_byte_horizontal)
+
+ JMP (.chk_next_line)
+/*
+ * Here we have less than 16 pixels left in the bitmap.
+ */
+.less_than_16_left:
+ CMP_L (CONST(16),EDX)
+ JL (.less_than_16_wide)
+
+ MOV_L (REGIND(ESI),EAX)
+ SHR_L (CL,EAX)
+ MOV_B (BL,CL)
+ SHL_L (CONST(1),EBX)
+ AND_W (REGOFF(.mskbit,EBX),AX)
+ MOV_W (REGIND(EDI),BX)
+ SHL_W (CL,BX)
+ OR_W (BX,AX)
+
+ MOV_L (srcx_loc,ESI)
+ ADD_L (CONST(16),ESI)
+ CMP_L (EDX,ESI)
+ JL (.no_wrap3)
+
+ SUB_L (EDX,ESI)
+
+.no_wrap3:
+ MOV_L (ESI,srcx_loc)
+ MOV_L (PIX_TRANS,EDX)
+ MOV_W (AX,CX)
+ XOR_L (EBX,EBX)
+ MOV_B (AL,BL)
+ SHL_L (CONST(1),EBX)
+ MOV_W (REGOFF(GLNAME(ibm8514stipple_tab),EBX),AX)
+ OUT_W
+ CMP_L (CONST(8),dstw_loc)
+ JLE (.chk_next_line)
+
+ XOR_L (EBX,EBX)
+ MOV_B (CH,BL)
+ SHL_L (CONST(1),EBX)
+ MOV_W (REGOFF(GLNAME(ibm8514stipple_tab),EBX),AX)
+ OUT_W
+ SUB_L (CONST(16),dstw_loc)
+ JG (.next_byte_horizontal)
+
+ JMP (.chk_next_line)
+/*
+ * Here the entire pixmap is less than 16 pixels wide.
+ */
+.less_than_16_wide:
+ CMP_L (CONST(8),EDX)
+ JL (.less_than_8_wide)
+
+ MOV_W (REGIND(ESI),AX)
+ SHR_W (CL,AX)
+ MOV_B (BL,CL)
+ SHL_L (CONST(1),EBX)
+ AND_W (REGOFF(.mskbit,EBX),AX)
+ MOV_W (REGIND(EDI),BX)
+ SHL_W (CL,BX)
+ OR_W (BX,AX)
+ MOV_W (REGIND(ESI),BX)
+ ADD_B (DL,CL)
+ SHL_W (CL,BX)
+ OR_W (BX,AX)
+
+ MOV_L (srcx_loc,ESI)
+ ADD_L (CONST(16),ESI)
+ CMP_L (EDX,ESI)
+ JL (.no_wrap4)
+
+ SUB_L (EDX,ESI)
+
+.no_wrap4:
+ MOV_L (ESI,srcx_loc)
+ MOV_L (PIX_TRANS,EDX)
+ MOV_W (AX,CX)
+ XOR_L (EBX,EBX)
+ MOV_B (AL,BL)
+ SHL_L (CONST(1),EBX)
+ MOV_W (REGOFF(GLNAME(ibm8514stipple_tab),EBX),AX)
+ OUT_W
+ CMP_L (CONST(8),dstw_loc)
+ JLE (.chk_next_line)
+
+ XOR_L (EBX,EBX)
+ MOV_B (CH,BL)
+ SHL_L (CONST(1),EBX)
+ MOV_W (REGOFF(GLNAME(ibm8514stipple_tab),EBX),AX)
+ OUT_W
+ SUB_L (CONST(16),dstw_loc)
+ JG (.next_byte_horizontal)
+
+ JMP (.chk_next_line)
+/*
+ * Here the entire pixmap is less than 8 pixels wide.
+ */
+.less_than_8_wide:
+ MOV_B (REGIND(EDI),AL)
+ MOV_L (EDX,ESI)
+ MOV_B (AL,DH)
+ SHR_B (CL,AL)
+ MOV_L (EBX,ECX)
+ SHL_L (CONST(1),EBX)
+ AND_W (REGOFF(.mskbit,EBX),AX)
+ MOV_B (DH,BL)
+
+.thin_loop:
+ CMP_L (CONST(16),ECX)
+ JGE (.store_pix)
+
+ CMP_L (dstw_loc,ECX)
+ JGE (.store_pix)
+
+ XOR_W (DX,DX)
+ MOV_B (BL,DL)
+ SHL_W (CL,DX)
+ OR_W (DX,AX)
+ ADD_L (ESI,ECX)
+ JMP (.thin_loop)
+
+.store_pix:
+ MOV_L (ESI,EDX)
+ MOV_L (srcx_loc,ESI)
+ ADD_L (CONST(16),ESI)
+ CMP_L (EDX,ESI)
+ JL (.no_wrap5)
+
+ SUB_L (EDX,ESI)
+
+.no_wrap5:
+ MOV_L (ESI,srcx_loc)
+ MOV_L (PIX_TRANS,EDX)
+ MOV_W (AX,CX)
+ XOR_L (EBX,EBX)
+ MOV_B (AL,BL)
+ SHL_L (CONST(1),EBX)
+ MOV_W (REGOFF(GLNAME(ibm8514stipple_tab),EBX),AX)
+ OUT_W
+ CMP_L (CONST(8),dstw_loc)
+ JLE (.chk_next_line)
+
+ XOR_L (EBX,EBX)
+ MOV_B (CH,BL)
+ SHL_L (CONST(1),EBX)
+ MOV_W (REGOFF(GLNAME(ibm8514stipple_tab),EBX),AX)
+ OUT_W
+ SUB_L (CONST(16),dstw_loc)
+ JG (.next_byte_horizontal)
+
+.chk_next_line:
+ INC_L (y_arg)
+ DEC_L (h_arg)
+ DEC_L (srch_loc)
+ JNZ (.next_bitmap_line)
+
+ SUB_L (EDX,EDX)
+ MOV_L (EDX,y_arg)
+ CMP_L (EDX,h_arg)
+ JNZ (.next_bitmap_vertical)
+
+/*
+ * Wait until room for 5 entries in the fifo.
+ */
+.stipple_exit:
+ MOV_L (GP_STAT,EDX)
+.wait_queue_3:
+ IN_W
+ TEST_W (CONST(0x08),AX)
+ JNZ (.wait_queue_3)
+/*
+ * Reset FRGD_MIX and BKGD_MIX to default.
+ */
+ MOV_L (FRGD_MIX,EDX)
+ MOV_W (GP_DEF_FRGD_MIX,AX)
+ OUT_W
+ MOV_L (BKGD_MIX,EDX)
+ MOV_W (GP_DEF_BKGD_MIX,AX)
+ OUT_W
+/*
+ * Reset the scissors and pixcntl registers.
+ */
+ MOV_L (MULTIFUNC_CNTL,EDX)
+ MOV_W (SCISSORS_L,AX)
+ OUT_W
+ MOV_W (SCISSORS_R,AX)
+ OR_W (CONST(1023),AX)
+ OUT_W
+ MOV_W (GP_DEF_PIXCNTL,AX)
+ OUT_W
+
+.finish:
+ POP_L (EBX)
+ POP_L (ESI)
+ POP_L (EDI)
+ ADD_L (CONST(12),ESP)
+ POP_L (EBP)
+ RET
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/imwrite.s b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/imwrite.s
new file mode 100644
index 000000000..db025f409
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/imwrite.s
@@ -0,0 +1,203 @@
+/* $XConsortium: ibm8514imwr.s,v 1.2 94/03/29 09:37:47 dpw Exp $ */
+/******************************************************************************
+
+This is a assembly language version of the ibm8514ImageWrite routine.
+Written by Hans Nasten ( nasten@everyware.se ) AUG 28, 1993.
+
+void
+ibm8514ImageWrite(x, y, w, h, psrc, pwidth, px, py, alu, planemask)
+ int x;
+ int y;
+ int w;
+ int h;
+ unsigned char *psrc;
+ int pwidth;
+ int px;
+ int py;
+ short alu;
+ short planemask;
+
+******************************************************************************/
+
+
+#define _8514_ASM_
+#include "assyntax.h"
+#include "reg8514.h"
+
+ AS_BEGIN
+
+/*
+ * Defines for in arguments.
+ */
+#define x_arg REGOFF(8,EBP)
+#define y_arg REGOFF(12,EBP)
+#define w_arg REGOFF(16,EBP)
+#define h_arg REGOFF(20,EBP)
+#define psrc_arg REGOFF(24,EBP)
+#define pwidth_arg REGOFF(28,EBP)
+#define px_arg REGOFF(32,EBP)
+#define py_arg REGOFF(36,EBP)
+#define alu_arg REGOFF(40,EBP)
+#define planemask_arg REGOFF(44,EBP)
+
+ SEG_TEXT
+ ALIGNTEXT4
+
+GLOBL GLNAME(ibm8514ImageWrite)
+
+GLNAME(ibm8514ImageWrite):
+ PUSH_L (EBP)
+ MOV_L (ESP,EBP)
+ PUSH_L (EDI)
+ PUSH_L (ESI)
+ PUSH_L (EBX)
+/*
+ * Check if height or width is 0.
+ */
+ MOV_L (w_arg,EDI)
+ MOV_L (h_arg,EBX)
+ OR_L (EDI,EDI)
+ JZ (.finish)
+ OR_L (EBX,EBX)
+ JZ (.finish)
+/*
+ * Wait for 2 queue entries
+ */
+ MOV_L (GP_STAT,EDX)
+.wait_queue_0:
+ IN_B
+ TEST_B (CONST(0x40),AL)
+ JNZ (.wait_queue_0)
+/*
+ * Init 8514 registers.
+ */
+ MOV_L (FRGD_MIX,EDX)
+ MOV_W (alu_arg,AX)
+ OR_W (FSS_PCDATA,AX)
+ OUT_W
+
+ MOV_L (WRT_MASK,EDX)
+ MOV_W (planemask_arg,AX)
+ OUT_W
+/*
+ * Wait for 7 queue entries
+ */
+ MOV_L (GP_STAT,EDX)
+.wait_queue_1:
+ IN_B
+ TEST_B (CONST(0x02),AL)
+ JNZ (.wait_queue_1)
+
+ MOV_L (CUR_X,EDX)
+ MOV_W (x_arg,AX)
+ OUT_W
+
+ MOV_L (CUR_Y,EDX)
+ MOV_W (y_arg,AX)
+ OUT_W
+/*
+ * If the width is odd, program the 8514 registers for width+1.
+ */
+ MOV_L (MAJ_AXIS_PCNT,EDX)
+ MOV_W (w_arg,AX)
+ TEST_W (CONST(1),AX)
+ JNZ (.odd)
+
+ DEC_W (AX)
+.odd:
+ OUT_W
+
+.cont1:
+/*
+ * Set height and scissors registers.
+ * The scissors is used to clip the last unwanted pixel on
+ * lines with a odd length.
+ */
+ MOV_L (MULTIFUNC_CNTL,EDX)
+ MOV_W (h_arg,AX)
+ DEC_W (AX)
+/* OR_W (MIN_AXIS_PCNT,AX)*/
+ OUT_W
+ MOV_W (x_arg,AX)
+ OR_W (SCISSORS_L,AX)
+ OUT_W
+ MOV_W (x_arg,AX)
+ ADD_W (w_arg,AX)
+ DEC_W (AX)
+ OR_W (SCISSORS_R,AX)
+ OUT_W
+
+/*
+ * Give command to 8514.
+ * The command is : CMD_RECT | INC_Y | INC_X | DRAW
+ * | PCDATA | WRTDATA | _16BIT | BYTSEQ);
+ */
+ MOV_L (CMD,EDX)
+ MOV_W (GP_WRITE_CMD,AX)
+ OUT_W
+/*
+ * Calculate a pointer to the first pixel on the first line.
+ */
+ MOV_L (pwidth_arg,EAX)
+ MUL_L (py_arg)
+ ADD_L (px_arg,EAX)
+ MOV_L (psrc_arg,EDI)
+ ADD_L (EAX,EDI)
+/*
+ * Wait until the fifo is empty.
+ */
+ MOV_L (GP_STAT,EDX)
+.wait_queue_2:
+ IN_B
+ TEST_B (CONST(1),AL)
+ JNZ (.wait_queue_2)
+/*
+ * Copy the pixels line by line to the fifo.
+ */
+ CLD
+ MOV_L (PIX_TRANS,EDX)
+ MOV_W (h_arg,BX)
+ MOV_L (pwidth_arg,EAX)
+ MOV_L (w_arg,EBP)
+ INC_L (EBP)
+ SHR_L (CONST(1),EBP)
+.next_line:
+ MOV_L (EDI,ESI)
+ MOV_L (EBP,ECX)
+ REP
+ OUTS_W
+ ADD_L (EAX,EDI)
+ DEC_W (BX)
+ JNZ (.next_line)
+/*
+ * Wait until room for 3 entries in the fifo.
+ */
+ MOV_L (GP_STAT,EDX)
+.wait_queue_3:
+ IN_B
+ TEST_B (CONST(0x20),AL)
+ JNZ (.wait_queue_3)
+
+/*
+ * Reset FRGD_MIX to default.
+ */
+ MOV_L (FRGD_MIX,EDX)
+ MOV_W (GP_DEF_FRGD_MIX,AX)
+ OUT_W
+
+/*
+ * Reset the scissors regsiters.
+ */
+ MOV_L (MULTIFUNC_CNTL,EDX)
+ MOV_W (SCISSORS_L,AX)
+ OUT_W
+ MOV_W (SCISSORS_R,AX)
+ OR_W (CONST(1023),AX)
+ OUT_W
+
+.finish:
+ POP_L (EBX)
+ POP_L (ESI)
+ POP_L (EDI)
+ POP_L (EBP)
+ RET
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/init.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/init.c
new file mode 100644
index 000000000..edf659880
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/init.c
@@ -0,0 +1,241 @@
+/* $XConsortium: ibm8514init.c,v 1.1 94/03/28 21:05:21 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/ibm8514/init.c,v 3.1 1994/08/01 13:18:07 dawes Exp $ */
+/*
+ * Written by Jake Richter
+ * Copyright (c) 1989, 1990 Panacea Inc., Londonderry, NH - All Rights Reserved
+ *
+ * This code may be freely incorporated in any program without royalty, as
+ * long as the copyright notice stays intact.
+ *
+ * Additions by Kevin E. Martin (martin@cs.unc.edu)
+ *
+ * KEVIN E. MARTIN AND TIAGO GONS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL KEVIN E. MARTIN OR TIAGO GONS BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Modified by Tiago Gons (tiago@comosjn.hobby.nl)
+ */
+
+
+#include "X.h"
+#include "input.h"
+#include "reg8514.h"
+#include "ibm8514.h"
+#include "xf86.h"
+#include "xf86_OSlib.h"
+
+static short numPlanes = -1;
+static short resolution = -1;
+static short old_DAC_MASK = -1;
+static LUTENTRY oldlut[256];
+static short LUTInited = -1;
+
+
+void ibm8514CleanUp(void)
+{
+ int i;
+
+ if (LUTInited != -1) {
+ outb(DAC_W_INDEX, 0);
+ for (i = 0; i < 256; i++) {
+ outb(DAC_DATA, oldlut[i].r);
+ outb(DAC_DATA, oldlut[i].g);
+ outb(DAC_DATA, oldlut[i].b);
+ }
+ }
+
+ if (old_DAC_MASK != -1) {
+ outb(DAC_MASK, old_DAC_MASK);
+ }
+ outw(ADVFUNC_CNTL, 6);
+
+ xf86DisableIOPorts(ibm8514InfoRec.scrnIndex);
+}
+
+/* ibm8514Init(res)
+
+ Initializes the 8514/A into the requested resolution. Valid input
+ values are 0 for 640x480 and 1 for 1024x768.
+*/
+void ibm8514Init(short res)
+{
+ static short initRegs[] = {
+ DISP_CNTL, ADVFUNC_CNTL, V_TOTAL, V_SYNC_STRT,
+ V_DISP, H_TOTAL, H_SYNC_STRT, H_DISP,
+ H_SYNC_WID, V_SYNC_WID, DISP_CNTL, 0
+ };
+
+ static short mode640x4[] = {
+ 0x0041, 0x0003, 0x0830, 0x07a8,
+ 0x0779, 0x0063, 0x0052, 0x004f,
+ 0x002c, 0x0022, 0x0021
+ };
+
+ static short mode640x8[] = {
+ 0x0043, 0x0003, 0x0418, 0x03d2,
+ 0x033b, 0x0063, 0x0052, 0x004f,
+ 0x002c, 0x0022, 0x0023
+ };
+
+ static short mode1024x4[] = {
+ 0x0053, 0x0007, 0x0660, 0x0600,
+ 0x05fb, 0x009d, 0x0081, 0x007f,
+ 0x0016, 0x0008, 0x0033
+ };
+
+ static short mode1024x8[] = {
+ 0x0053, 0x0007, 0x0660, 0x0600,
+ 0x05fb, 0x009d, 0x0081, 0x007f,
+ 0x0016, 0x0008, 0x0033
+ };
+
+ static short *modeList[] = {mode640x4, mode1024x4, mode640x8, mode1024x8};
+
+ short i;
+
+ /* Get board status information */
+ i = inw(SUBSYS_STAT);
+
+#if 0
+ /* Check if monitor capable of 1024x768 is attached.
+ * If not, print error message and abort.
+ * In this case, we want an IBM 8514 compatible monitor.
+ */
+ if ((i & MONITORID_MASK) != MONITORID_8514) {
+ ibm8514CleanUp();
+ FatalError("Attached monitor not capable of displaying 8514!\n");
+ }
+#endif
+
+ old_DAC_MASK = inb(DAC_MASK);
+ outb(DAC_MASK, 0x00);
+
+ /* Determine the pixel depth of the board. Then, based on depth,
+ * set the memory control register use the appropriate CAS (VRAM
+ * Column Address Select) configuration.
+ */
+ if (i & _8PLANE) {
+ numPlanes = 8;
+ outw(MULTIFUNC_CNTL, MEM_CNTL | VRTCFG_4 | HORCFG_8);
+ } else {
+ numPlanes = 4;
+ ibm8514CleanUp();
+ FatalError("Video card only has 512Kb (1Mb required)!\n");
+ }
+
+ /* Now initialize the display controller part of the 8514/A.
+ * We have set up the initialization values in two sets of
+ * tables: 4 bpp and 8 bpp. The "numPlanes" comparison below
+ * determines which set of values to use (dual indices).
+ */
+ for (i = 0; initRegs[i] != 0; i++)
+ outw(initRegs[i], modeList[res + (numPlanes == 4 ? 0:2)][i]);
+
+ /* Now reenable the screen, but only the planes that actually exist.
+ * Otherwise, you end up with bus noise on the display.
+ */
+ if (numPlanes == 8)
+ outb(DAC_MASK, 0xff);
+ else
+ outb(DAC_MASK, 0x0f);
+
+ resolution = res;
+}
+
+/* InitLUT()
+
+ Loads the Look-Up Table with all black.
+ Assumes 8-bit board is in use. If 4 bit board, the only the first
+ 16 entries in LUT will be used.
+*/
+void InitLUT(void)
+{
+ short i, j;
+
+ outb(DAC_R_INDEX, 0);
+ for (i = 0; i < 256; i++) {
+ oldlut[i].r = inb(DAC_DATA);
+ oldlut[i].g = inb(DAC_DATA);
+ oldlut[i].b = inb(DAC_DATA);
+ }
+ LUTInited = 1;
+
+ outb(DAC_W_INDEX, 0);
+
+ /* Load the first 16 LUT entries */
+ for (i = 0; i < 16; i++) {
+ outb(DAC_DATA, 0);
+ outb(DAC_DATA, 0);
+ outb(DAC_DATA, 0);
+ }
+
+ if (numPlanes == 8) {
+ /* Load the remaining 240 LUT entries */
+ for (i = 1; i < 16; i++) {
+ for (j = 0; j < 16; j++) {
+ outb(DAC_DATA, 0);
+ outb(DAC_DATA, 0);
+ outb(DAC_DATA, 0);
+ }
+ }
+ }
+}
+
+/* InitEnvironment()
+
+ Initializes the 8514/A's drawing environment and clears the display.
+*/
+void InitEnvironment(void)
+{
+
+ InitLUT();
+
+ /* Current mixes, src, foreground active */
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+
+ /* Clipping rectangle to full drawable space */
+ outw(MULTIFUNC_CNTL, SCISSORS_T | 0x000);
+ outw(MULTIFUNC_CNTL, SCISSORS_L | 0x000);
+ if (resolution == MODE_640) {
+ outw(MULTIFUNC_CNTL, SCISSORS_R | 0x3ff); /* Should these be */
+ outw(MULTIFUNC_CNTL, SCISSORS_B | 0x3ff); /* different??? */
+ } else {
+ outw(MULTIFUNC_CNTL, SCISSORS_R | 0x3ff);
+ outw(MULTIFUNC_CNTL, SCISSORS_B | 0x3ff);
+ }
+
+ /* Enable writes to all planes and reset color compare */
+ outw(WRT_MASK, 0xffff);
+ outw(MULTIFUNC_CNTL, PIX_CNTL | 0x0000);
+
+#ifndef DIRTY_STARTUP
+ if (serverGeneration == 1) /* 5-5-93 TCG : servergen.. is always 1 ? */
+ {
+ /* Clear the display. Need to set the color, origin, and size.
+ * Then draw.
+ */
+ WaitQueue(6);
+ outw(FRGD_COLOR, 1);
+ outw(CUR_X, 0);
+ outw(CUR_Y, 0);
+ outw(MAJ_AXIS_PCNT, 1023);
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | 1023);
+ outw(CMD, CMD_RECT | INC_Y | INC_X | DRAW | PLANAR | WRTDATA);
+ }
+#endif /* ! DIRTY_STARTUP */
+
+ WaitQueue(4);
+
+ /* Reset current draw position */
+ outw(CUR_X, 0);
+ outw(CUR_Y, 0);
+
+ /* Reset current colors, foreground is all on, background is 0. */
+ outw(FRGD_COLOR, 0xffff);
+ outw(BKGD_COLOR, 0x0000);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/line.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/line.c
new file mode 100644
index 000000000..d651ce7d4
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/line.c
@@ -0,0 +1,434 @@
+/* $XConsortium: ibm8514line.c,v 1.2 94/04/17 20:30:35 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/ibm8514/line.c,v 3.0 1994/06/06 06:44:16 dawes Exp $ */
+/*
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL, KEVIN E. MARTIN, AND TIAGO GONS DISCLAIM ALL WARRANTIES WITH REGARD TO
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL DIGITAL, KEVIN E. MARTIN, OR TIAGO GONS BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+Further modifications by Tiago Gons (tiago@comosjn.hobby.nl)
+
+*/
+
+#include "X.h"
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "mistruct.h"
+#include "miline.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "reg8514.h"
+#include "ibm8514.h"
+
+void
+ibm8514Line(pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode; /* Origin or Previous */
+ int npt; /* number of points */
+ DDXPointPtr pptInit;
+{
+ int nboxInit;
+ register int nbox;
+ BoxPtr pboxInit;
+ register BoxPtr pbox;
+ register DDXPointPtr ppt; /* pointer to list of translated points */
+
+ unsigned int oc1; /* outcode of point 1 */
+ unsigned int oc2; /* outcode of point 2 */
+
+ int xorg, yorg; /* origin of window */
+
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ short cmd = CMD_LINE | DRAW | PLANAR | WRTDATA | LASTPIX;
+ short cmd2;
+ short fix;
+
+ /* a bunch of temporaries */
+ int tmp;
+ register int y1, y2;
+ register int x1, x2;
+ RegionPtr cclip;
+ cfbPrivGCPtr devPriv;
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema)
+ {
+ cfbLineSS(pDrawable, pGC, mode, npt, pptInit);
+ return;
+ }
+
+ devPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr);
+ cclip = devPriv->pCompositeClip;
+ pboxInit = REGION_RECTS(cclip);
+ nboxInit = REGION_NUM_RECTS(cclip);
+
+ WaitQueue(3);
+ outw(FRGD_MIX, FSS_FRGDCOL | ibm8514alu[pGC->alu]);
+ outw(WRT_MASK, (short)pGC->planemask);
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while(--npt)
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious)
+ {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+
+ if (x1 == x2)
+ {
+ /* make the line go top to bottom of screen, keeping
+ endpoint semantics
+ */
+ if (y1 > y2)
+ {
+ register int tmp;
+
+ tmp = y2;
+ y2 = y1 + 1;
+ y1 = tmp + 1;
+ }
+ /* get to first band that might contain part of line */
+ while ((nbox) && (pbox->y2 <= y1))
+ {
+ pbox++;
+ nbox--;
+ }
+
+ if (nbox)
+ {
+ /* stop when lower edge of box is beyond end of line */
+ while((nbox) && (y2 >= pbox->y1))
+ {
+ if ((x1 >= pbox->x1) && (x1 < pbox->x2))
+ {
+ int y1t, y2t;
+ /* this box has part of the line in it */
+ y1t = max(y1, pbox->y1);
+ y2t = min(y2, pbox->y2);
+ if (y1t != y2t)
+ {
+ WaitQueue(4);
+ outw(CUR_X, (short)x1);
+ outw(CUR_Y, (short)y1t);
+ outw(MAJ_AXIS_PCNT, (short)(y2t-y1t-1));
+ outw(CMD, CMD_LINE | DRAW | LINETYPE | PLANAR |
+ WRTDATA | (6 << 5));
+ }
+ }
+ nbox--;
+ pbox++;
+ }
+ }
+ y2 = ppt->y + yorg;
+ }
+ else if (y1 == y2)
+ {
+ /* force line from left to right, keeping
+ endpoint semantics
+ */
+ if (x1 > x2)
+ {
+ register int tmp;
+
+ tmp = x2;
+ x2 = x1 + 1;
+ x1 = tmp + 1;
+ }
+
+ /* find the correct band */
+ while( (nbox) && (pbox->y2 <= y1))
+ {
+ pbox++;
+ nbox--;
+ }
+
+ /* try to draw the line, if we haven't gone beyond it */
+ if ((nbox) && (pbox->y1 <= y1))
+ {
+ /* when we leave this band, we're done */
+ tmp = pbox->y1;
+ while((nbox) && (pbox->y1 == tmp))
+ {
+ int x1t, x2t;
+
+ if (pbox->x2 <= x1)
+ {
+ /* skip boxes until one might contain start point */
+ nbox--;
+ pbox++;
+ continue;
+ }
+
+ /* stop if left of box is beyond right of line */
+ if (pbox->x1 >= x2)
+ {
+ nbox = 0;
+ break;
+ }
+
+ x1t = max(x1, pbox->x1);
+ x2t = min(x2, pbox->x2);
+ if (x1t != x2t)
+ {
+ WaitQueue(4);
+ outw(CUR_X, (short)x1t);
+ outw(CUR_Y, (short)y1);
+ outw(MAJ_AXIS_PCNT, (short)(x2t-x1t-1));
+ outw(CMD, CMD_LINE | DRAW | LINETYPE | PLANAR |
+ WRTDATA);
+ }
+ nbox--;
+ pbox++;
+ }
+ }
+ x2 = ppt->x + xorg;
+ }
+ else /* sloped line */
+ {
+ cmd2 = cmd;
+ signdx = 1;
+ if ((adx = x2 - x1) < 0)
+ {
+ adx = -adx;
+ signdx = -1;
+ fix = 0;
+ }
+ else
+ {
+ cmd2 |= INC_X;
+ fix = -1;
+ }
+ signdy = 1;
+ if ((ady = y2 - y1) < 0)
+ {
+ ady = -ady;
+ signdy = -1;
+ }
+ else
+ {
+ cmd2 |= INC_Y;
+ }
+
+ if (adx > ady)
+ {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+ }
+ else
+ {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ cmd2 |= YMAJAXIS;
+ }
+
+ /* we have bresenham parameters and two points.
+ all we have to do now is clip and draw.
+ */
+
+ while(nbox--)
+ {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if ((oc1 | oc2) == 0)
+ {
+ if (axis == X_AXIS)
+ len = adx;
+ else
+ len = ady;
+
+ /* NOTE: The 8514/A hardware routines for generating
+ lines do not match the software generated lines
+ of mi, cfb, and mfb. This is a problem, and if I
+ ever get time, I'll figure out the 8514/A algorithm
+ and implement it in software for mi, cfb, and mfb.
+ 14-sep-93 TCG: apparently only change needed is
+ addition of 'fix' stuff in cfbline.c
+ */
+ WaitQueue(7);
+ outw(CUR_X, (short)x1);
+ outw(CUR_Y, (short)y1);
+ outw(ERR_TERM, (short)(e + fix));
+ outw(DESTY_AXSTP, (short)e1);
+ outw(DESTX_DIASTP, (short)e2);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ outw(CMD, cmd2);
+
+ break;
+ }
+ else if (oc1 & oc2)
+ {
+ pbox++;
+ }
+ else
+ {
+ /*
+ * let the mi helper routine do our work;
+ * better than duplicating code...
+ */
+ int err; /* modified bresenham error term */
+ int clip1=0, clip2=0;/* clippedness of the endpoints */
+
+ int clipdx, clipdy; /* difference between clipped and
+ unclipped start point */
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+
+ if (miZeroClipLine(pbox->x1, pbox->y1,
+ pbox->x2-1, pbox->y2-1,
+ &new_x1, &new_y1,
+ &new_x2, &new_y2,
+ adx, ady,
+ &clip1, &clip2,
+ axis, (signdx == signdy),
+ oc1, oc2) == -1)
+ {
+ pbox++;
+ continue;
+ }
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+
+ len += (clip2 != 0);
+ if (len)
+ {
+ /* unwind bresenham error term to first point */
+ if (clip1)
+ {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
+ else
+ err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
+ }
+ else
+ err = e;
+
+ WaitQueue(7);
+ outw(CUR_X, (short)new_x1);
+ outw(CUR_Y, (short)new_y1);
+ outw(ERR_TERM, (short)(err + fix));
+ outw(DESTY_AXSTP, (short)e1);
+ outw(DESTX_DIASTP, (short)e2);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ outw(CMD, cmd2);
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+ } /* sloped line */
+ } /* while (nline--) */
+
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1)))
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--)
+ {
+ if ((x2 >= pbox->x1) &&
+ (y2 >= pbox->y1) &&
+ (x2 < pbox->x2) &&
+ (y2 < pbox->y2))
+ {
+ WaitQueue(4);
+ outw(CUR_X, (short)x2);
+ outw(CUR_Y, (short)y2);
+ outw(MAJ_AXIS_PCNT, 0);
+ outw(CMD, CMD_LINE | DRAW | LINETYPE | PLANAR | WRTDATA);
+
+ break;
+ }
+ else
+ pbox++;
+ }
+ }
+
+ WaitQueue(2);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/plypt.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/plypt.c
new file mode 100644
index 000000000..63bd340db
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/plypt.c
@@ -0,0 +1,126 @@
+/* $XConsortium: ibm8514plyp.c,v 1.2 94/04/17 20:30:36 dpw Exp $ */
+/************************************************************
+
+Copyright (c) 1989 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+
+Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+
+DIGITAL, KEVIN E. MARTIN, AND TIAGO GONS DISCLAIM ALL WARRANTIES WITH REGARD TO
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL DIGITAL, KEVIN E. MARTIN, OR TIAGO GONS BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Modified by Tiago Gons (tiago@comosjn.hobby.nl)
+
+********************************************************/
+
+
+/* $XConsortium: ibm8514plyp.c,v 1.2 94/04/17 20:30:36 dpw Exp $ */
+
+#include "X.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "reg8514.h"
+#include "ibm8514.h"
+
+#define isClipped(c,ul,lr) ((((c) - (ul)) | ((lr) - (c))) & ClipMask)
+
+void
+ibm8514PolyPoint(pDrawable, pGC, mode, npt, pptInit)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int mode;
+ int npt;
+ xPoint *pptInit;
+{
+ register long pt;
+ register long c1, c2;
+ register unsigned long ClipMask = 0x80008000;
+ register long *ppt;
+ RegionPtr cclip;
+ int nbox;
+ register int i;
+ register BoxPtr pbox;
+ int off;
+ cfbPrivGCPtr devPriv;
+ xPoint *pptPrev;
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema)
+ {
+ cfbPolyPoint(pDrawable, pGC, mode, npt, pptInit);
+ return;
+ }
+
+ devPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr);
+ if (pGC->alu == GXnoop)
+ return;
+ cclip = devPriv->pCompositeClip;
+ if ((mode == CoordModePrevious) && (npt > 1))
+ {
+ for (pptPrev = pptInit + 1, i = npt - 1; --i >= 0; pptPrev++)
+ {
+ pptPrev->x += (pptPrev-1)->x;
+ pptPrev->y += (pptPrev-1)->y;
+ }
+ }
+ off = *((int *) &pDrawable->x);
+ off -= (off & 0x8000) << 1;
+
+ WaitQueue(4);
+ outw(FRGD_MIX, FSS_FRGDCOL | ibm8514alu[pGC->alu]);
+ outw(WRT_MASK, (short)pGC->planemask);
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+ outw(MAJ_AXIS_PCNT, 0);
+
+ for (nbox = REGION_NUM_RECTS(cclip), pbox = REGION_RECTS(cclip);
+ --nbox >= 0;
+ pbox++)
+ {
+ c1 = *((long *) &pbox->x1) - off;
+ c2 = *((long *) &pbox->x2) - off - 0x00010001;
+ for (ppt = (long *) pptInit, i = npt; --i >= 0;)
+ {
+ pt = *ppt++;
+ if (!isClipped(pt,c1,c2)) {
+ WaitQueue(3);
+ outw(CUR_X, (short)(intToX(pt)+pDrawable->x));
+ outw(CUR_Y, (short)(intToY(pt)+pDrawable->y));
+ outw(CMD, CMD_LINE | DRAW | LINETYPE | PLANAR | WRTDATA);
+ }
+ }
+ }
+
+ WaitQueue(2);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/scrin.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/scrin.c
new file mode 100644
index 000000000..e9575e2f4
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/scrin.c
@@ -0,0 +1,187 @@
+/* $XConsortium: ibm8514scri.c,v 1.2 94/04/17 20:30:37 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/ibm8514/scrin.c,v 3.1 1994/12/10 03:00:01 dawes Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+
+KEVIN E. MARTIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL KEVIN E. MARTIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+
+/* $XConsortium: ibm8514scri.c,v 1.2 94/04/17 20:30:37 dpw Exp $ */
+
+#include "X.h"
+#include "Xmd.h"
+#include "servermd.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "resource.h"
+#include "colormap.h"
+#include "colormapst.h"
+#include "cfb.h"
+#include "mi.h"
+#include "mistruct.h"
+#include "dix.h"
+#include "cfbmskbits.h"
+#include "mibstore.h"
+#include "ibm8514.h"
+
+extern RegionPtr mfbPixmapToRegion();
+extern Bool mfbAllocatePrivates();
+extern Bool mfbRegisterCopyPlaneProc();
+extern Bool miScreenInit();
+
+extern int defaultColorVisualClass;
+
+#define _BP 6 /**** VGA ****/
+#define _RZ ((PSZ + 2) / 3)
+#define _RS 0
+#define _RM ((1 << _RZ) - 1)
+#define _GZ ((PSZ - _RZ + 1) / 2)
+#define _GS _RZ
+#define _GM (((1 << _GZ) - 1) << _GS)
+#define _BZ (PSZ - _RZ - _GZ)
+#define _BS (_RZ + _GZ)
+#define _BM (((1 << _BZ) - 1) << _BS)
+#define _CE (1 << _RZ)
+
+static VisualRec visuals[] = {
+/* vid class bpRGB cmpE nplan rMask gMask bMask oRed oGreen oBlue */
+ 0, PseudoColor, _BP, 1<<PSZ, PSZ, 0, 0, 0, 0, 0, 0,
+ 0, DirectColor, _BP, _CE, PSZ, _RM, _GM, _BM, _RS, _GS, _BS,
+ 0, GrayScale, _BP, 1<<PSZ, PSZ, 0, 0, 0, 0, 0, 0,
+ 0, StaticGray, _BP, 1<<PSZ, PSZ, 0, 0, 0, 0, 0, 0,
+ 0, StaticColor, _BP, 1<<PSZ, PSZ, _RM, _GM, _BM, _RS, _GS, _BS,
+ 0, TrueColor, _BP, _CE, PSZ, _RM, _GM, _BM, _RS, _GS, _BS
+};
+
+#define NUMVISUALS ((sizeof visuals)/(sizeof visuals[0]))
+
+static VisualID VIDs[NUMVISUALS];
+
+static DepthRec depths[] = {
+/* depth numVid vids */
+ 1, 0, NULL,
+ 8, NUMVISUALS, VIDs
+};
+
+#define NUMDEPTHS ((sizeof depths)/(sizeof depths[0]))
+
+static unsigned long cfbGeneration = 0;
+
+miBSFuncRec ibm8514BSFuncRec = {
+ ibm8514SaveAreas,
+ ibm8514RestoreAreas,
+ (void (*)()) 0,
+ (PixmapPtr (*)()) 0,
+ (PixmapPtr (*)()) 0,
+};
+
+/* dts * (inch/dot) * (25.4 mm / inch) = mm */
+Bool
+ibm8514ScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+{
+ int i;
+
+ if (cfbGeneration != serverGeneration)
+ {
+ /* Set up the visual IDs */
+ for (i = 0; i < NUMVISUALS; i++) {
+ visuals[i].vid = FakeClientID(0);
+ VIDs[i] = visuals[i].vid;
+ }
+ cfbGeneration = serverGeneration;
+ }
+ if (!mfbAllocatePrivates(pScreen,
+ &cfbWindowPrivateIndex, &cfbGCPrivateIndex))
+ return FALSE;
+ if (!AllocateWindowPrivate(pScreen, cfbWindowPrivateIndex,
+ sizeof(cfbPrivWin)) ||
+ !AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC)))
+ return FALSE;
+ if (defaultColorVisualClass < 0)
+ {
+ i = 0;
+ }
+ else
+ {
+ for (i = 0;
+ (i < NUMVISUALS) && (visuals[i].class != defaultColorVisualClass);
+ i++)
+ ;
+ if (i >= NUMVISUALS)
+ i = 0;
+ }
+ pScreen->defColormap = FakeClientID(0);
+ /* let CreateDefColormap do whatever it wants for pixels */
+ pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
+ pScreen->QueryBestSize = mfbQueryBestSize;
+ /* SaveScreen */
+ pScreen->GetImage = ibm8514GetImage;
+ pScreen->GetSpans = ibm8514GetSpans;
+ pScreen->CreateWindow = cfbCreateWindow;
+ pScreen->DestroyWindow = cfbDestroyWindow;
+ pScreen->PositionWindow = cfbPositionWindow;
+ pScreen->ChangeWindowAttributes = cfbChangeWindowAttributes;
+ pScreen->RealizeWindow = cfbMapWindow;
+ pScreen->UnrealizeWindow = cfbUnmapWindow;
+ pScreen->PaintWindowBackground = miPaintWindow;
+ pScreen->PaintWindowBorder = miPaintWindow;
+ pScreen->CopyWindow = ibm8514CopyWindow;
+ pScreen->CreatePixmap = cfbCreatePixmap;
+ pScreen->DestroyPixmap = cfbDestroyPixmap;
+ pScreen->RealizeFont = ibm8514RealizeFont;
+ pScreen->UnrealizeFont = ibm8514UnrealizeFont;
+ pScreen->CreateGC = ibm8514CreateGC;
+ pScreen->CreateColormap = cfbInitializeColormap;
+ pScreen->DestroyColormap = (void (*)())NoopDDA;
+ pScreen->InstallColormap = ibm8514InstallColormap;
+ pScreen->UninstallColormap = ibm8514UninstallColormap;
+ pScreen->ListInstalledColormaps = ibm8514ListInstalledColormaps;
+ pScreen->StoreColors = ibm8514StoreColors;
+ pScreen->ResolveColor = cfbResolveColor;
+ pScreen->BitmapToRegion = mfbPixmapToRegion;
+ mfbRegisterCopyPlaneProc (pScreen, miCopyPlane);
+ return miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
+ 8, NUMDEPTHS, depths,
+ visuals[i].vid, NUMVISUALS, visuals,
+ &ibm8514BSFuncRec);
+
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/seg.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/seg.c
new file mode 100644
index 000000000..260a05b2c
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/seg.c
@@ -0,0 +1,395 @@
+/* $XConsortium: ibm8514seg.c,v 1.2 94/04/17 20:30:37 dpw Exp $ */
+/*
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL, KEVIN E. MARTIN, AND TIAGO GONS DISCLAIM ALL WARRANTIES WITH REGARD TO
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL DIGITAL, KEVIN E. MARTIN, OR TIAGO GONS BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+Further modifications by Tiago Gons (tiago@comosjn.hobby.nl)
+
+*/
+
+
+#include "X.h"
+
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "scrnintstr.h"
+#include "mistruct.h"
+#include "miline.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "reg8514.h"
+#include "ibm8514.h"
+
+void
+ibm8514Segment(pDrawable, pGC, nseg, pSeg)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ int nseg;
+ register xSegment *pSeg;
+{
+ int nboxInit;
+ register int nbox;
+ BoxPtr pboxInit;
+ register BoxPtr pbox;
+
+ unsigned int oc1; /* outcode of point 1 */
+ unsigned int oc2; /* outcode of point 2 */
+
+ int xorg, yorg; /* origin of window */
+
+ int adx; /* abs values of dx and dy */
+ int ady;
+ int signdx; /* sign of dx and dy */
+ int signdy;
+ int e, e1, e2; /* bresenham error and increments */
+ int len; /* length of segment */
+ int axis; /* major axis */
+ short cmd = CMD_LINE | DRAW | PLANAR | WRTDATA | LASTPIX;
+ short cmd2;
+ short fix;
+
+ /* a bunch of temporaries */
+ int tmp;
+ register int y1, y2;
+ register int x1, x2;
+ RegionPtr cclip;
+ cfbPrivGCPtr devPriv;
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema)
+ {
+ cfbSegmentSS(pDrawable, pGC, nseg, pSeg);
+ return;
+ }
+
+ devPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr);
+ cclip = devPriv->pCompositeClip;
+ pboxInit = REGION_RECTS(cclip);
+ nboxInit = REGION_NUM_RECTS(cclip);
+
+ WaitQueue(3);
+ outw(FRGD_MIX, FSS_FRGDCOL | ibm8514alu[pGC->alu]);
+ outw(WRT_MASK, (short)pGC->planemask);
+ outw(FRGD_COLOR, (short)pGC->fgPixel);
+
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+
+ while (nseg--)
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+
+ if (x1 == x2)
+ {
+ /* make the line go top to bottom of screen, keeping
+ endpoint semantics
+ */
+ if (y1 > y2)
+ {
+ register int tmp;
+
+ tmp = y2;
+ y2 = y1 + 1;
+ y1 = tmp + 1;
+ if (pGC->capStyle != CapNotLast)
+ y1--;
+ }
+ else if (pGC->capStyle != CapNotLast)
+ y2++;
+ /* get to first band that might contain part of line */
+ while ((nbox) && (pbox->y2 <= y1))
+ {
+ pbox++;
+ nbox--;
+ }
+
+ if (nbox)
+ {
+ /* stop when lower edge of box is beyond end of line */
+ while((nbox) && (y2 >= pbox->y1))
+ {
+ if ((x1 >= pbox->x1) && (x1 < pbox->x2))
+ {
+ int y1t, y2t;
+ /* this box has part of the line in it */
+ y1t = max(y1, pbox->y1);
+ y2t = min(y2, pbox->y2);
+ if (y1t != y2t)
+ {
+ WaitQueue(4);
+ outw(CUR_X, (short)x1);
+ outw(CUR_Y, (short)y1t);
+ outw(MAJ_AXIS_PCNT, (short)(y2t-y1t-1));
+ outw(CMD, CMD_LINE | DRAW | LINETYPE | PLANAR |
+ WRTDATA | (6 << 5));
+ }
+ }
+ nbox--;
+ pbox++;
+ }
+ }
+ }
+ else if (y1 == y2)
+ {
+ /* force line from left to right, keeping
+ endpoint semantics
+ */
+ if (x1 > x2)
+ {
+ register int tmp;
+
+ tmp = x2;
+ x2 = x1 + 1;
+ x1 = tmp + 1;
+ if (pGC->capStyle != CapNotLast)
+ x1--;
+ }
+ else if (pGC->capStyle != CapNotLast)
+ x2++;
+
+ /* find the correct band */
+ while( (nbox) && (pbox->y2 <= y1))
+ {
+ pbox++;
+ nbox--;
+ }
+
+ /* try to draw the line, if we haven't gone beyond it */
+ if ((nbox) && (pbox->y1 <= y1))
+ {
+ /* when we leave this band, we're done */
+ tmp = pbox->y1;
+ while((nbox) && (pbox->y1 == tmp))
+ {
+ int x1t, x2t;
+
+ if (pbox->x2 <= x1)
+ {
+ /* skip boxes until one might contain start point */
+ nbox--;
+ pbox++;
+ continue;
+ }
+
+ /* stop if left of box is beyond right of line */
+ if (pbox->x1 >= x2)
+ {
+ nbox = 0;
+ break;
+ }
+
+ x1t = max(x1, pbox->x1);
+ x2t = min(x2, pbox->x2);
+ if (x1t != x2t)
+ {
+ WaitQueue(4);
+ outw(CUR_X, (short)x1t);
+ outw(CUR_Y, (short)y1);
+ outw(MAJ_AXIS_PCNT, (short)(x2t-x1t-1));
+ outw(CMD, CMD_LINE | DRAW | LINETYPE | PLANAR |
+ WRTDATA);
+ }
+ nbox--;
+ pbox++;
+ }
+ }
+ }
+ else /* sloped line */
+ {
+ cmd2 = cmd;
+ signdx = 1;
+ if ((adx = x2 - x1) < 0)
+ {
+ adx = -adx;
+ signdx = -1;
+ fix = 0;
+ }
+ else
+ {
+ cmd2 |= INC_X;
+ fix = -1;
+ }
+ signdy = 1;
+ if ((ady = y2 - y1) < 0)
+ {
+ ady = -ady;
+ signdy = -1;
+ }
+ else
+ {
+ cmd2 |= INC_Y;
+ }
+
+ if (adx > ady)
+ {
+ axis = X_AXIS;
+ e1 = ady << 1;
+ e2 = e1 - (adx << 1);
+ e = e1 - adx;
+
+ }
+ else
+ {
+ axis = Y_AXIS;
+ e1 = adx << 1;
+ e2 = e1 - (ady << 1);
+ e = e1 - ady;
+ cmd2 |= YMAJAXIS;
+ }
+
+ /* we have bresenham parameters and two points.
+ all we have to do now is clip and draw.
+ */
+
+ while(nbox--)
+ {
+ oc1 = 0;
+ oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if ((oc1 | oc2) == 0)
+ {
+ if (axis == X_AXIS)
+ len = adx;
+ else
+ len = ady;
+ if (pGC->capStyle != CapNotLast)
+ len++;
+
+ WaitQueue(7);
+ outw(CUR_X, (short)x1);
+ outw(CUR_Y, (short)y1);
+ outw(ERR_TERM, (short)(e + fix));
+ outw(DESTY_AXSTP, (short)e1);
+ outw(DESTX_DIASTP, (short)e2);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ outw(CMD, cmd2);
+
+ break;
+ }
+ else if (oc1 & oc2)
+ {
+ pbox++;
+ }
+ else
+ {
+ /*
+ * let the mi helper routine do our work;
+ * better than duplicating code...
+ */
+ int err; /* modified bresenham error term */
+ int clip1=0, clip2=0;/* clippedness of the endpoints */
+
+ int clipdx, clipdy; /* difference between clipped and
+ unclipped start point */
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+
+ if (miZeroClipLine(pbox->x1, pbox->y1,
+ pbox->x2-1, pbox->y2-1,
+ &new_x1, &new_y1,
+ &new_x2, &new_y2,
+ adx, ady,
+ &clip1, &clip2,
+ axis, (signdx == signdy),
+ oc1, oc2) == -1)
+ {
+ pbox++;
+ continue;
+ }
+ if (axis == X_AXIS)
+ len = abs(new_x2 - new_x1);
+ else
+ len = abs(new_y2 - new_y1);
+
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+ if (len)
+ {
+ /* unwind bresenham error term to first point */
+ if (clip1)
+ {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+ if (axis == X_AXIS)
+ err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
+ else
+ err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
+ }
+ else
+ err = e;
+
+ WaitQueue(7);
+ outw(CUR_X, (short)new_x1);
+ outw(CUR_Y, (short)new_y1);
+ outw(ERR_TERM, (short)(err + fix));
+ outw(DESTY_AXSTP, (short)e1);
+ outw(DESTX_DIASTP, (short)e2);
+ outw(MAJ_AXIS_PCNT, (short)len);
+ outw(CMD, cmd2);
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+ } /* sloped line */
+ } /* while (nline--) */
+
+ WaitQueue(2);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/ss.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/ss.c
new file mode 100644
index 000000000..81dbcf75f
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/ss.c
@@ -0,0 +1,236 @@
+/* $XConsortium: ibm8514ss.c,v 1.2 94/04/17 20:30:39 dpw Exp $ */
+/*
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL, KEVIN E. MARTIN, AND TIAGO GONS DISCLAIM ALL WARRANTIES WITH REGARD TO
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL DIGITAL, KEVIN E. MARTIN, OR TIAGO GONS BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+Further modifications by Tiago Gons (tiago@comosjn.hobby.nl)
+
+*/
+
+
+#include "X.h"
+#include "Xmd.h"
+#include "servermd.h"
+
+#include "misc.h"
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+
+#include "ibm8514.h"
+
+/* SetSpans -- for each span copy pwidth[i] bits from psrc to pDrawable at
+ * ppt[i] using the raster op from the GC. If fSorted is TRUE, the scanlines
+ * are in increasing Y order.
+ * Source bit lines are server scanline padded so that they always begin
+ * on a word boundary.
+ */
+void
+ibm8514SetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted)
+ DrawablePtr pDrawable;
+ GCPtr pGC;
+ char *psrc;
+ register DDXPointPtr ppt;
+ int *pwidth;
+ int nspans;
+ int fSorted;
+{
+ register BoxPtr pbox, pboxLast, pboxTest;
+ register DDXPointPtr pptLast;
+ int alu;
+ RegionPtr prgnDst;
+ int xStart, xEnd;
+ int yMax;
+
+/* ErrorF("Set Spans: n = %d, (%d, %d, %d)\n", nspans, ppt->x, ppt->y, *pwidth); */
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema)
+ {
+ cfbSetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
+ return;
+ }
+
+ if (pDrawable->type != DRAWABLE_WINDOW) {
+ switch (pDrawable->depth) {
+ case 1:
+ mfbSetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
+ break;
+ case 8:
+ cfbSetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
+ break;
+ default:
+ ErrorF("Unsupported pixmap depth\n");
+ break;
+ }
+ return;
+ }
+
+ alu = pGC->alu;
+ prgnDst = ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
+
+ pptLast = ppt + nspans;
+
+ yMax = (int) pDrawable->y + (int) pDrawable->height;
+
+ pbox = REGION_RECTS(prgnDst);
+ pboxLast = pbox + REGION_NUM_RECTS(prgnDst);
+
+ if(fSorted)
+ {
+ /* scan lines sorted in ascending order. Because they are sorted, we
+ * don't have to check each scanline against each clip box. We can be
+ * sure that this scanline only has to be clipped to boxes at or after the
+ * beginning of this y-band
+ */
+ pboxTest = pbox;
+ while(ppt < pptLast)
+ {
+ pbox = pboxTest;
+ if(ppt->y >= yMax)
+ break;
+ while(pbox < pboxLast)
+ {
+ if(pbox->y1 > ppt->y)
+ {
+ /* scanline is before clip box */
+ break;
+ }
+ else if(pbox->y2 <= ppt->y)
+ {
+ /* clip box is before scanline */
+ pboxTest = ++pbox;
+ continue;
+ }
+ else if(pbox->x1 > ppt->x + *pwidth)
+ {
+ /* clip box is to right of scanline */
+ break;
+ }
+ else if(pbox->x2 <= ppt->x)
+ {
+ /* scanline is to right of clip box */
+ pbox++;
+ continue;
+ }
+
+ /* at least some of the scanline is in the current clip box */
+ xStart = max(pbox->x1, ppt->x);
+ xEnd = min(ppt->x + *pwidth, pbox->x2);
+/***************
+ cfbSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu,
+ pdstBase, widthDst, pGC->planemask);
+***************/
+ ibm8514ImageWrite(xStart, ppt->y, xEnd-xStart, 1,
+ psrc + (xStart-ppt->x), xEnd-xStart, 0, 0,
+ ibm8514alu[alu], pGC->planemask);
+ if(ppt->x + *pwidth <= pbox->x2)
+ {
+ /* End of the line, as it were */
+ break;
+ }
+ else
+ pbox++;
+ }
+ /* We've tried this line against every box; it must be outside them
+ * all. move on to the next point */
+ ppt++;
+ psrc += PixmapBytePad(*pwidth, PSZ);
+ pwidth++;
+ }
+ }
+ else
+ {
+ /* scan lines not sorted. We must clip each line against all the boxes */
+ while(ppt < pptLast)
+ {
+ if(ppt->y >= 0 && ppt->y < yMax)
+ {
+
+ for(pbox = REGION_RECTS(prgnDst); pbox< pboxLast; pbox++)
+ {
+ if(pbox->y1 > ppt->y)
+ {
+ /* rest of clip region is above this scanline,
+ * skip it */
+ break;
+ }
+ if(pbox->y2 <= ppt->y)
+ {
+ /* clip box is below scanline */
+ pbox++;
+ break;
+ }
+ if(pbox->x1 <= ppt->x + *pwidth &&
+ pbox->x2 > ppt->x)
+ {
+ xStart = max(pbox->x1, ppt->x);
+ xEnd = min(pbox->x2, ppt->x + *pwidth);
+/**************
+ cfbSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu,
+ pdstBase, widthDst, pGC->planemask);
+**************/
+ ibm8514ImageWrite(xStart, ppt->y, xEnd-xStart, 1,
+ psrc + (xStart-ppt->x), xEnd-xStart, 0, 0,
+ ibm8514alu[alu], pGC->planemask);
+ }
+
+ }
+ }
+ psrc += PixmapBytePad(*pwidth, PSZ);
+ ppt++;
+ pwidth++;
+ }
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/text.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/text.c
new file mode 100644
index 000000000..12db422d8
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/text.c
@@ -0,0 +1,396 @@
+/* $XConsortium: ibm8514text.c,v 1.1 94/03/28 21:06:05 dpw Exp $ */
+/*
+ * Copyright 1992 by Kevin E. Martin, Chapel Hill, North Carolina.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Kevin E. Martin not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. Kevin E. Martin makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEVIN E. MARTIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEVIN E. MARTIN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/*
+ * Extracted from s3text.c
+ * Modified for 8514, Hans Nasten. (nasten@everyware.se)
+ */
+
+#include "X.h"
+#include "Xmd.h"
+#include "Xproto.h"
+#include "cfb.h"
+#include "misc.h"
+#include "xf86.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "fontstruct.h"
+#include "dixfontstr.h"
+#include "mi.h"
+#include "ibm8514.h"
+#include "reg8514.h"
+
+extern unsigned short ibm8514stipple_tab[];
+
+
+/*
+ * The guts of this should possibly be tidied up and put in xxxxim.c.
+ * The generic Stipple functions in xxxxim.c have quite a large unnecessary
+ * overhead for bitmap copies in the case that we are doing an exacy copy
+ * with no tiling and starting from (0,0) in the source bitmap. - Jon.
+ */
+__inline__ static void
+ibm8514PolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+ DrawablePtr pDrawable;
+ GC *pGC;
+ int x, y;
+ unsigned int nglyph;
+ CharInfoPtr *ppci; /* array of character info */
+ unsigned char *pglyphBase; /* start of array of glyphs */
+{
+ int width, height;
+ int nbyLine; /* bytes per line of padded pixmap */
+ FontPtr pfont;
+ int i;
+ int j;
+ unsigned char *pbits; /* buffer for PutImage */
+ unsigned char *pb; /* temp pointer into buffer */
+ CharInfoPtr pci; /* currect char info */
+ unsigned char *pglyph; /* pointer bits in glyph */
+ int gWidth, gHeight; /* width and height of glyph */
+ register int nbyGlyphWidth; /* bytes per scanline of glyph */
+ int nbyPadGlyph; /* server padded line of glyph */
+
+
+ pfont = pGC->font;
+ width = FONTMAXBOUNDS(pfont,rightSideBearing) -
+ FONTMINBOUNDS(pfont,leftSideBearing);
+ height = FONTMAXBOUNDS(pfont,ascent) +
+ FONTMAXBOUNDS(pfont,descent);
+
+ nbyLine = PixmapBytePad(width, 1);
+ pbits = (unsigned char *)ALLOCATE_LOCAL(height*nbyLine);
+ if (!pbits)
+ {
+ return;
+ }
+ while(nglyph--)
+ {
+ pci = *ppci++;
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ gWidth = GLYPHWIDTHPIXELS(pci);
+ gHeight = GLYPHHEIGHTPIXELS(pci);
+ if (gWidth && gHeight)
+ {
+ nbyGlyphWidth = GLYPHWIDTHBYTESPADDED(pci);
+ nbyPadGlyph = PixmapBytePad(gWidth, 1);
+
+ if (nbyGlyphWidth == nbyPadGlyph
+#if GLYPHPADBYTES != 4
+ && (((int) pglyph) & 3) == 0
+#endif
+ )
+ {
+ pb = pglyph;
+ }
+ else
+ {
+ for (i=0, pb = pbits; i<gHeight; i++, pb = pbits+(i*nbyPadGlyph))
+ for (j = 0; j < nbyGlyphWidth; j++)
+ *pb++ = *pglyph++;
+ pb = pbits;
+ }
+ WaitQueue(5);
+ outw(CUR_X, (short)(x+pci->metrics.leftSideBearing));
+ outw(CUR_Y, (short)(y - pci->metrics.ascent));
+ outw(MAJ_AXIS_PCNT, (short)(gWidth - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (gHeight-1));
+ outw(CMD, CMD_RECT | PCDATA | INC_Y | INC_X |
+ DRAW | PLANAR | WRTDATA);
+
+ { /* The stipple code */
+ int h;
+ register int xp = x+pci->metrics.leftSideBearing;
+ int w = gWidth + (xp & 3);
+ register unsigned char ui;
+ unsigned char *cp;
+
+ for (h = 0; h < gHeight; h++) {
+ cp = pb+(h*nbyPadGlyph);
+ for (i = 0; i < w; i += 8) {
+ ui = (ui >> 4 | (*cp << 4));
+ outw(PIX_TRANS,
+ ibm8514stipple_tab[(ui << (xp & 3)) & 0xf0]);
+ if( i + 4 < w ) {
+ ui = (ui >> 4 | (*cp++ & 0xf0));
+ outw(PIX_TRANS,
+ ibm8514stipple_tab[(ui << (xp & 3)) & 0xf0]);
+ }
+ }
+ }
+
+ }
+ }
+
+ x += pci->metrics.characterWidth;
+ }
+ DEALLOCATE_LOCAL(pbits);
+}
+
+int ibm8514NoCPolyText(pDraw, pGC, x, y, count, chars, is8bit)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int x;
+ int y;
+ int count;
+ char *chars;
+ Bool is8bit;
+{
+ int i;
+ BoxPtr pBox;
+ int numRects;
+ RegionPtr pRegion;
+ int yBand;
+ int maxAscent, maxDescent;
+ int minLeftBearing;
+ FontPtr pfont = pGC->font;
+ int ret_x;
+ unsigned long n;
+ CharInfoPtr *charinfo;
+
+
+ if(!(charinfo = (CharInfoPtr *)ALLOCATE_LOCAL(count*sizeof(CharInfoPtr ))))
+ return x ;
+
+ if (is8bit)
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
+ Linear8Bit, &n, charinfo);
+ else
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
+ (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
+ &n, charinfo);
+
+ /*
+ * If miPolyText8() is to be believed, the returned new X value is
+ * completely independent of what happens during rendering.
+ */
+ ret_x = x;
+ for (i = 0; i < n; i++) {
+ ret_x += charinfo[i]->metrics.characterWidth;
+ }
+
+ if (n == 0) {
+ DEALLOCATE_LOCAL(charinfo);
+ return ret_x;
+ }
+
+ x += pDraw->x;
+ y += pDraw->y;
+ maxAscent = FONTMAXBOUNDS(pfont, ascent);
+ maxDescent = FONTMAXBOUNDS(pfont, descent);
+ minLeftBearing = FONTMINBOUNDS(pfont, leftSideBearing);
+ pRegion = ((cfbPrivGC *) (pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
+
+ pBox = REGION_RECTS(pRegion);
+ numRects = REGION_NUM_RECTS(pRegion);
+ while (numRects && pBox->y2 <= y - maxAscent) {
+ ++pBox;
+ --numRects;
+ }
+ if (!numRects || pBox->y1 >= y + maxDescent) {
+ DEALLOCATE_LOCAL(charinfo);
+ return ret_x;
+ }
+ yBand = pBox->y1;
+ while (numRects && pBox->y1 == yBand && pBox->x2 <= x + minLeftBearing) {
+ ++pBox;
+ --numRects;
+ }
+ if (!numRects) {
+ DEALLOCATE_LOCAL(charinfo);
+ return ret_x;
+ }
+
+ WaitQueue (6);
+ outw (WRT_MASK, pGC->planemask);
+ outw (FRGD_MIX, FSS_FRGDCOL | ibm8514alu[pGC->alu]);
+ outw (BKGD_MIX, BSS_BKGDCOL | MIX_DST);
+ outw (MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_EXPPC | COLCMPOP_F);
+ outw (FRGD_COLOR, (short) pGC->fgPixel);
+ outw (BKGD_COLOR, (short) pGC->bgPixel);
+
+ for (; --numRects >= 0; ++pBox) {
+ WaitQueue(4);
+ outw (MULTIFUNC_CNTL, SCISSORS_L | (short)pBox->x1);
+ outw(MULTIFUNC_CNTL, SCISSORS_T | (short)pBox->y1);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | (short)(pBox->x2 - 1));
+ outw(MULTIFUNC_CNTL, SCISSORS_B | (short)(pBox->y2 - 1));
+
+ ibm8514PolyGlyphBlt(pDraw, pGC, x, y, (unsigned int)n, charinfo,
+ FONTGLYPHS(pGC->font));
+
+ }
+
+ WaitQueue(7);
+ outw (FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw (BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+ outw (MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);
+ outw(MULTIFUNC_CNTL, SCISSORS_T | 0);
+ outw(MULTIFUNC_CNTL, SCISSORS_L | 0);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | 1023);
+ outw(MULTIFUNC_CNTL, SCISSORS_B | 1023);
+
+ return ret_x;
+}
+
+
+/*
+ * Imagetext is all in one function to avoid calling GetGlyphs() twice.
+ * - Jon.
+ */
+
+int ibm8514NoCImageText(pDraw, pGC, x, y, count, chars, is8bit)
+ DrawablePtr pDraw;
+ GCPtr pGC;
+ int x;
+ int y;
+ int count;
+ char *chars;
+ Bool is8bit;
+{
+ ExtentInfoRec info; /* used by QueryGlyphExtents() */
+ XID gcvals[3];
+ int oldAlu, oldFS;
+ unsigned long oldFG;
+ xRectangle backrect;
+ CharInfoPtr *charinfo;
+ unsigned long n;
+
+ if (!(charinfo = (CharInfoPtr *) ALLOCATE_LOCAL(count * sizeof(CharInfoPtr))))
+ return 0;
+
+
+ if (is8bit)
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
+ Linear8Bit, &n, charinfo);
+ else
+ GetGlyphs(pGC->font, (unsigned long)count, (unsigned char *)chars,
+ (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit,
+ &n, charinfo);
+
+
+ QueryGlyphExtents(pGC->font, charinfo, n, &info);
+
+ if (info.overallWidth >= 0) {
+ backrect.x = x;
+ backrect.width = info.overallWidth;
+ } else {
+ backrect.x = x + info.overallWidth;
+ backrect.width = -info.overallWidth;
+ }
+ backrect.y = y - FONTASCENT(pGC->font);
+ backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+
+ oldAlu = pGC->alu;
+ oldFG = pGC->fgPixel;
+ oldFS = pGC->fillStyle;
+
+ /* fill in the background */
+ gcvals[0] = GXcopy;
+ gcvals[1] = pGC->bgPixel;
+ gcvals[2] = FillSolid;
+ DoChangeGC(pGC, GCFunction | GCForeground | GCFillStyle, gcvals, 0);
+ ValidateGC(pDraw, pGC);
+ (*pGC->ops->PolyFillRect) (pDraw, pGC, 1, &backrect);
+
+ /* put down the glyphs */
+ gcvals[0] = oldFG;
+ DoChangeGC(pGC, GCForeground, gcvals, 0);
+ ValidateGC(pDraw, pGC);
+
+ /* begin the font blitting */
+ {
+ BoxPtr pBox;
+ int numRects;
+ RegionPtr pRegion;
+ int maxAscent, maxDescent;
+ int yBand;
+ int minLeftBearing;
+ FontPtr pfont = pGC->font;
+
+ x += pDraw->x;
+ y += pDraw->y;
+ maxAscent = FONTMAXBOUNDS(pfont, ascent);
+ maxDescent = FONTMAXBOUNDS(pfont, descent);
+ minLeftBearing = FONTMINBOUNDS(pfont, leftSideBearing);
+ pRegion = ((cfbPrivGC *) (pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
+
+ pBox = REGION_RECTS(pRegion);
+ numRects = REGION_NUM_RECTS(pRegion);
+ while (numRects && pBox->y2 <= y - maxAscent) {
+ ++pBox;
+ --numRects;
+ }
+ if (!numRects || pBox->y1 >= y + maxDescent) {
+ DEALLOCATE_LOCAL(charinfo);
+ return 0;
+ }
+ yBand = pBox->y1;
+ while (numRects && pBox->y1 == yBand && pBox->x2 <= x + minLeftBearing) {
+ ++pBox;
+ --numRects;
+ }
+ if (!numRects) {
+ DEALLOCATE_LOCAL(charinfo);
+ return 0;
+ }
+
+ WaitQueue (6);
+ outw (WRT_MASK, pGC->planemask);
+ outw (FRGD_MIX, FSS_FRGDCOL | ibm8514alu[pGC->alu]);
+ outw (BKGD_MIX, BSS_BKGDCOL | MIX_DST);
+ outw (MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_EXPPC | COLCMPOP_F);
+ outw (FRGD_COLOR, (short) pGC->fgPixel);
+
+ outw (BKGD_COLOR, (short) pGC->bgPixel);
+
+ for (; --numRects >= 0; ++pBox) {
+ WaitQueue(4);
+ outw (MULTIFUNC_CNTL, SCISSORS_L | (short)pBox->x1);
+ outw(MULTIFUNC_CNTL, SCISSORS_T | (short)pBox->y1);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | (short)(pBox->x2 - 1));
+ outw(MULTIFUNC_CNTL, SCISSORS_B | (short)(pBox->y2 - 1));
+
+ ibm8514PolyGlyphBlt(pDraw, pGC, x, y, (unsigned int)n, charinfo,
+ FONTGLYPHS(pGC->font));
+
+ }
+
+ WaitQueue(7);
+ outw (FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw (BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+ outw (MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);
+ outw(MULTIFUNC_CNTL, SCISSORS_T | 0);
+ outw(MULTIFUNC_CNTL, SCISSORS_L | 0);
+ outw(MULTIFUNC_CNTL, SCISSORS_R | 1023);
+ outw(MULTIFUNC_CNTL, SCISSORS_B | 1023);
+ }
+
+ /* put all the toys away when done playing */
+ gcvals[0] = oldAlu;
+ gcvals[1] = oldFG;
+ gcvals[2] = oldFS;
+ DoChangeGC(pGC, GCFunction | GCForeground | GCFillStyle, gcvals, 0);
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/accel/ibm8514/win.c b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/win.c
new file mode 100644
index 000000000..75eb75dce
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/ibm8514/win.c
@@ -0,0 +1,190 @@
+/* $XConsortium: ibm8514win.c,v 1.2 94/04/17 20:30:40 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/ibm8514/win.c,v 3.1 1994/09/07 16:19:12 dawes Exp $ */
+/*
+
+Copyright (c) 1987 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the X Consortium.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL, KEVIN E. MARTIN, AND TIAGO GONS DISCLAIM ALL WARRANTIES WITH REGARD TO
+THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL DIGITAL, KEVIN E. MARTIN, OR TIAGO GONS BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Rewritten for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+Further modifications by Tiago Gons (tiago@comosjn.hobby.nl)
+
+*/
+
+
+#include "X.h"
+#include "input.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "cfb.h"
+#include "mistruct.h"
+#include "regionstr.h"
+#include "cfbmskbits.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "reg8514.h"
+#include "ibm8514.h"
+
+void
+ibm8514CopyWindow(pWin, ptOldOrg, prgnSrc)
+ WindowPtr pWin;
+ DDXPointRec ptOldOrg;
+ RegionPtr prgnSrc;
+{
+ RegionPtr prgnDst;
+ register BoxPtr pbox, pboxOrig;
+ register int dx, dy;
+ register int i, nbox;
+ short direction = 0;
+ unsigned int *ordering;
+ GC dummyGC;
+
+/* 4-5-93 TCG : is VT visible */
+ if (!xf86VTSema)
+ {
+ cfbCopyWindow(pWin, ptOldOrg, prgnSrc);
+ return;
+ }
+
+ dummyGC.subWindowMode = ~IncludeInferiors;
+
+ prgnDst = (* pWin->drawable.pScreen->RegionCreate)(NULL, 1);
+
+ if ((dx = ptOldOrg.x - pWin->drawable.x) > 0)
+ direction |= INC_X;
+
+ if ((dy = ptOldOrg.y - pWin->drawable.y) > 0)
+ direction |= INC_Y;
+
+ (* pWin->drawable.pScreen->TranslateRegion)(prgnSrc, -dx, -dy);
+ (* pWin->drawable.pScreen->Intersect)(prgnDst, &pWin->borderClip, prgnSrc);
+
+ pboxOrig = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+
+ ordering = (unsigned int *) ALLOCATE_LOCAL(nbox * sizeof(unsigned int));
+ if (!ordering) {
+ (* pWin->drawable.pScreen->RegionDestroy)(prgnDst);
+ return;
+ }
+
+ ibm8514FindOrdering((DrawablePtr)pWin, (DrawablePtr)pWin, &dummyGC, nbox,
+ pboxOrig, ptOldOrg.x, ptOldOrg.y, pWin->drawable.x,
+ pWin->drawable.y, ordering);
+
+ WaitQueue(3);
+ outw(FRGD_MIX, FSS_BITBLT | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+ outw(WRT_MASK, 0xffff);
+
+ if (direction == (INC_X | INC_Y)) {
+ for (i = 0; i < nbox; i++)
+ {
+ pbox = &pboxOrig[ordering[i]];
+
+ WaitQueue(7);
+ outw(CUR_X, (short)(pbox->x1 + dx));
+ outw(CUR_Y, (short)(pbox->y1 + dy));
+ outw(DESTX_DIASTP, (short)(pbox->x1));
+ outw(DESTY_AXSTP, (short)(pbox->y1));
+ outw(MAJ_AXIS_PCNT, (short)(pbox->x2 - pbox->x1 - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(pbox->y2 - pbox->y1 - 1));
+ outw(CMD, CMD_BITBLT | direction | DRAW | PLANAR | WRTDATA);
+ }
+ } else if (direction == INC_X) {
+ for (i = 0; i < nbox; i++)
+ {
+ pbox = &pboxOrig[ordering[i]];
+
+ WaitQueue(7);
+ outw(CUR_X, (short)(pbox->x1 + dx));
+ outw(CUR_Y, (short)(pbox->y2 + dy - 1));
+ outw(DESTX_DIASTP, (short)(pbox->x1));
+ outw(DESTY_AXSTP, (short)(pbox->y2 - 1));
+ outw(MAJ_AXIS_PCNT, (short)(pbox->x2 - pbox->x1 - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(pbox->y2 - pbox->y1 - 1));
+ outw(CMD, CMD_BITBLT | direction | DRAW | PLANAR | WRTDATA);
+ }
+ } else if (direction == INC_Y) {
+ for (i = 0; i < nbox; i++)
+ {
+ pbox = &pboxOrig[ordering[i]];
+
+ WaitQueue(7);
+ outw(CUR_X, (short)(pbox->x2 + dx - 1));
+ outw(CUR_Y, (short)(pbox->y1 + dy));
+ outw(DESTX_DIASTP, (short)(pbox->x2 - 1));
+ outw(DESTY_AXSTP, (short)(pbox->y1));
+ outw(MAJ_AXIS_PCNT, (short)(pbox->x2 - pbox->x1 - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(pbox->y2 - pbox->y1 - 1));
+ outw(CMD, CMD_BITBLT | direction | DRAW | PLANAR | WRTDATA);
+ }
+ } else {
+ for (i = 0; i < nbox; i++)
+ {
+ pbox = &pboxOrig[ordering[i]];
+
+ WaitQueue(7);
+ outw(CUR_X, (short)(pbox->x2 + dx - 1));
+ outw(CUR_Y, (short)(pbox->y2 + dy - 1));
+ outw(DESTX_DIASTP, (short)(pbox->x2 - 1));
+ outw(DESTY_AXSTP, (short)(pbox->y2 - 1));
+ outw(MAJ_AXIS_PCNT, (short)(pbox->x2 - pbox->x1 - 1));
+ outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (short)(pbox->y2 - pbox->y1 - 1));
+ outw(CMD, CMD_BITBLT | direction | DRAW | PLANAR | WRTDATA);
+ }
+ }
+
+ WaitQueue(2);
+ outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+ outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+
+ (* pWin->drawable.pScreen->RegionDestroy)(prgnDst);
+ DEALLOCATE_LOCAL(ordering);
+}
+
diff --git a/xc/programs/Xserver/hw/xfree86/accel/p9000/I2061Acal.c b/xc/programs/Xserver/hw/xfree86/accel/p9000/I2061Acal.c
new file mode 100644
index 000000000..bf4cde495
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/p9000/I2061Acal.c
@@ -0,0 +1,245 @@
+/* $XConsortium: $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/p9000/I2061Acal.c,v 3.1 1994/09/07 15:50:41 dawes Exp $ */
+/* Id: ICD2061Acal.c,v 4.0 1994/05/28 01:24:17 nygren Exp */
+/* Based on the number 9 Inc code */
+/* Copyright (c) 1992, Number Nine Computer Corp. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Number Nine Computer Corp not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. Number Nine Computer Corp
+ * makes no representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ * NUMBER NINE COMPUTER CORP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL NUMBER NINE COMPUTER CORP BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Modifications - Copyright (c) 1994, Harry Langenbacher,All Rights Reserved.
+ * HARRY LANGENBACHER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL HARRY LANGENBACHER BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation. Harry Langenbacher
+ * makes no representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ */
+
+#include "X.h"
+#include "input.h"
+#include "xf86_OSlib.h"
+#include "xf86.h"
+#include "ICD2061A.h"
+
+#undef MIN
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#undef MAX
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+
+#define MAX_NUMERATOR 130
+#define MAX_DENOMINATOR MIN(129, CRYSTAL_FREQUENCY / 400000)
+#define MIN_DENOMINATOR MAX(3, CRYSTAL_FREQUENCY / 2000000)
+
+/* Index register frequency ranges for ICD2061A chip */
+/* "The Index Field is used to preset the VCO to an appropriate range." pg. 13 */
+static long vclk_range[14] =
+ {
+ 51000000,
+ 53200000,
+ 58500000,
+ 60700000,
+ 64400000,
+ 66800000,
+ 73500000,
+ 75600000,
+ 80900000,
+ 83200000,
+ 91500000,
+ 100000000,
+ 120000000,
+ 135000000 /* BE WARNED THIS COULD BE VERY VERY BAD (i.e. , I'm guessing)!!!!!!! */
+ } ;
+
+unsigned long ICD2061ACalcClock
+ ( long frequency , int chipreg ) /* frequency in Hz */
+ /* chipreg - select one of 3 registers in icd2061a to be selected
+ to hold new frequency parameters */
+ {
+ int Q_Divider ;
+ int P_Divider ;
+ int Mux ; /* divider after vco */
+
+ register int index;
+ unsigned long temp;
+ int Best_Qdivider, Best_Pdivider;
+ long min_diff;
+ long diff;
+
+ min_diff = 0xFFFFFFF;
+ Best_Pdivider = 1;
+ Best_Qdivider = 1;
+#ifdef DEBUG
+ ErrorF ( "Buiding clock control word for freq=%d, chipreg=%d\n" ,
+ frequency , chipreg ) ;
+#endif
+ /* Calculate 17 bit ( 7 + 3 + 7 ) frequency control field */
+
+ /* find what post VCO divider we need */
+ Mux = 0;
+ if (frequency < MIN_VCO_FREQUENCY)
+ Mux = 1;
+ if (frequency < MIN_VCO_FREQUENCY / 2)
+ Mux = 2;
+ if (frequency < MIN_VCO_FREQUENCY / 4)
+ Mux = 3; /* boy, this is a really low frequency (50Mhz/4?)*/
+
+ frequency <<= Mux ; /* make frequency = the VCO frequency we have to get */
+ for (P_Divider = 4; P_Divider <= MAX_NUMERATOR; P_Divider++)
+ {
+ index = CRYSTAL_FREQUENCY / (frequency / P_Divider);
+ if (index > MAX_DENOMINATOR)
+ index = MAX_DENOMINATOR;
+ if (index < MIN_DENOMINATOR)
+ index = MIN_DENOMINATOR;
+ for (Q_Divider = index - 3; Q_Divider < index + 4; Q_Divider++)
+ if (Q_Divider >= MIN_DENOMINATOR && Q_Divider <= MAX_DENOMINATOR)
+ {
+ diff = (CRYSTAL_FREQUENCY / Q_Divider) * P_Divider - frequency;
+ if (diff < 0)
+ diff = -diff;
+ if ( Best_Qdivider * ICD2061AGCD(Q_Divider, P_Divider) /
+ ICD2061AGCD(Best_Qdivider, Best_Pdivider) == Q_Divider
+ &&
+ Best_Pdivider * ICD2061AGCD(Q_Divider, P_Divider) /
+ ICD2061AGCD(Best_Qdivider, Best_Pdivider) == P_Divider )
+ {
+ if (diff > min_diff)
+ diff = min_diff;
+ }
+ if (diff <= min_diff)
+ {
+ min_diff = diff;
+ Best_Qdivider = Q_Divider;
+ Best_Pdivider = P_Divider;
+ }
+ }
+ }
+ Q_Divider = Best_Qdivider;
+ P_Divider = Best_Pdivider;
+
+ /* Calculate the resultant VCO frequency */
+ temp = CalcVCOfreq ( Q_Divider , P_Divider ) ;
+
+ /* look up the index field value appropriate for this vco freq */
+ index = 0 ;
+ while ( ( vclk_range [ index ] < temp ) && ( index < 14 ) )
+ index ++ ;
+
+ if ( index == 14 ) /* vco freq too high */
+ {
+ ErrorF ("\a\aProgram error - vco freq too high !\n" ) ;
+ }
+
+ /* Pack the control word for the frequency snthesizer ,
+ packed into bits 0-23, not 1-24 like before */
+
+ temp = ( (long) chipreg << 21 ) |
+ ( (long) index << 17 ) |
+ ( (long) ( P_Divider - 3 ) << 10 ) |
+ ( (long) Mux << 7 ) |
+ ( Q_Divider - 2 ) ;
+
+#ifdef DEBUG
+ ErrorF ("Clock Control Word is 0x%06X\n" , temp ) ;
+#endif
+
+ return temp;
+}
+
+/* Number theoretic function - GCD (Greatest Common Divisor) */
+int ICD2061AGCD ( int number1 , int number2 )
+ {
+ register int remainder = number1 % number2 ;
+ while ( remainder )
+ {
+ number1 = number2 ;
+ number2 = remainder ;
+ remainder = number1 % number2 ;
+ }
+ return number2 ;
+ }
+
+unsigned int ICD2061AGetClock ( unsigned long control_word )
+ /* value now in bits 0-23 ( not 1-24 like before ) */
+ {
+ unsigned int Q_Divider ;
+ unsigned int Feedback_Divider_P ;
+ unsigned int Post_VCO_Divider_M ;
+ unsigned int FinalFreq ;
+ unsigned int VCOFreq ;
+ unsigned int Index ;
+ unsigned int select ;
+
+ /* Unpack the clock value */
+ select = ( control_word >> 21 ) & 7 ;
+ Index = ( ( control_word >> 17 ) & 0x0F) ; /* P */
+ Feedback_Divider_P = ( ( control_word >> 10 ) & 0x7F) + 3 ; /* P */
+ Post_VCO_Divider_M = ( ( control_word >> 7 ) & 0x07) ; /* M */
+ Q_Divider = ( ( control_word ) & 0x7F) + 2 ; /* Q */
+
+ /* f(VCO) = Prescale * f(ref) * P / Q */
+ /* where Prescale is determined by a bit in the control reg, and will
+ be 2 or 4 , default 2 */
+ /* then the VCO output is divided by 2^^M */
+
+ VCOFreq = CalcVCOfreq ( Q_Divider , Feedback_Divider_P ) ;
+ FinalFreq = VCOFreq >> Post_VCO_Divider_M ;
+ /* (2*f(ref)*P/Q)/2^^Post_VCO_Divider_M */
+
+#ifdef DEBUG
+ ErrorF ("\
+ register select=%d\n\
+ Index Field =%d=0x%X\n\
+ Feedback_Divider_P=%d=0x%X\n\
+ Post_VCO_Divider_M=%d\n\
+ Q_Divider=%d=0x%X\n\
+ VCOFreq=%d Hz, FinalFreq=%d Hz\n" ,
+ select , Index , Index , Feedback_Divider_P , Feedback_Divider_P ,
+ Post_VCO_Divider_M , Q_Divider , Q_Divider ,
+ VCOFreq , FinalFreq ) ;
+#endif
+
+ return FinalFreq ;
+ }
+
+unsigned long CalcVCOfreq
+ ( unsigned int Q_Divider , unsigned int Feedback_Divider_P )
+ {
+ unsigned long VCO_Freq ;
+
+ /* f(VCO) = Prescale * f(ref) * P / Q */
+ /* where Prescale is determined by a bit in the control reg, and will
+ be 2 or 4 , default 2 */
+ /* assume a (standard?) 14.318180 Mhz Crystal */
+ VCO_Freq = ( 2 * 14318180 * Feedback_Divider_P ) / Q_Divider ;
+ return VCO_Freq ;
+ }
+
+
+
+
+
diff --git a/xc/programs/Xserver/hw/xfree86/accel/p9000/I2061Aset.c b/xc/programs/Xserver/hw/xfree86/accel/p9000/I2061Aset.c
new file mode 100644
index 000000000..ae43bf9ac
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/accel/p9000/I2061Aset.c
@@ -0,0 +1,161 @@
+/* $XConsortium: $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/accel/p9000/I2061Aset.c,v 3.1 1994/09/07 15:50:42 dawes Exp $ */
+/* Id: ICD2061Aset.c,v 4.0 1994/05/28 01:24:17 nygren Exp */
+/* Based on the number 9 Inc code */
+/* Copyright (c) 1992, Number Nine Computer Corp. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Number Nine Computer Corp not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. Number Nine Computer Corp
+ * makes no representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ * NUMBER NINE COMPUTER CORP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL NUMBER NINE COMPUTER CORP BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Modifications - Copyright (c) 1994, Harry Langenbacher,All Rights Reserved.
+ * HARRY LANGENBACHER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL HARRY LANGENBACHER BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notices appear in all copies and that both that
+ * copyright notices and this permission notice appear in supporting
+ * documentation. Harry Langenbacher makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ */
+
+#include "X.h"
+#include "input.h"
+#include "xf86_OSlib.h"
+#include "xf86.h"
+#include "ICD2061A.h"
+#include "p9000reg.h"
+
+void ICD2061ASetClock ( unsigned long control_word )
+ /* value now in bits 0-23 ( not 1-24 like #9 ) */
+ {
+ register int index;
+ int savemisc ;
+ int select ;
+
+ select = (control_word >> 21) & 7; /* extract register address for icd2061 */
+ /* if it's not vid clk we dont need it here */
+ /* 000 reg0 video clk reg 0 */
+ /* 001 reg1 video clk reg 1 */
+ /* 010 reg2 video clk reg 2 */
+ /* 011 mreg memory clk reg */
+ /* 100 pwrdwn divisor for power down mode */
+ /* 110 cntl reg control reg */
+ /* 111 not used */
+ /* 101 reserved */
+ if ( ( select == 7 ) || ( select == 5 ) )
+ ErrorF("\aERROR illegal icd2061 register select=%d\n" , select ) ;
+
+
+ /* Shut off screen */ /* why bother ?? */
+ /* If you want to turn off the screen it might make more sense to turn it off
+ for a few ms AFTER shifting out the number and setting MISCOUT -
+ because the icd2061 output will not change 'till ~2ms after you
+ quit wiggling the sel/clk/data inputs */
+
+ /* Set up the bits and regs for sending serial data to the icd2061 */
+#define CLOCK(xx) outb((short)MISC_OUT_REG, (char)(savemisc & 0xF3)| (xx) )
+#define C_DATA 8
+#define C_CLK 4
+#define C_BOTH 0xC
+#define C_NONE 0
+
+ savemisc = inb ( (short) MISC_IN_REG ) ; /* read MISCOUT reg */
+#ifdef DEBUG
+ ErrorF("ICD2061ASetClock: Debug info: savemisc=MISC_IN_REG=0x%X\n" , (int) savemisc ) ;
+#endif
+
+ /* refer to ICD2061A data sheet, and Power 9000 EISA App. Note, pg 16 */
+ /* Program the IC Designs ICD2061A frequency generator */
+ /* the initial Unlock sequence consists of at least 5 low to high transitions
+ of CLK with DATA high, */
+
+ for ( index = 0 ; index < 5 ; index ++ )
+ {
+ CLOCK(C_DATA) ; /* data held high */
+ CLOCK(C_BOTH) ; /* clock goes hi while data stays hi */
+ }
+ /* followed immediately by a single low to high transition of CLK with DATA
+ low */
+
+ CLOCK(C_NONE); /* let them both go low */
+ CLOCK(C_CLK); /* clock goes high */
+ CLOCK(C_NONE); /* start bit = 0 */
+ CLOCK(C_CLK); /* clock the start bit */
+
+ /* shift in the 24 bit clock control word */
+ for ( index = 1 ; index < 0x1000000 ; index <<= 1 )
+ { /* march a 1-bit mask across the clock control word */
+
+ /* Clock in the next magic bit - manchester style ! */
+ if (control_word & index )
+ { /* clock in a one */
+ CLOCK(C_CLK); /* with clock still high, data = ! bit */
+ CLOCK(C_NONE); /* lower clock, dont change data */
+ CLOCK(C_DATA); /* data = bit */
+ CLOCK(C_BOTH); /* clock the bit */
+ }
+ else
+ { /* clock in a zero */
+ CLOCK(C_BOTH); /* with clock still high, data = ! bit */
+ CLOCK(C_DATA); /* lower clock, dont change data */
+ CLOCK(C_NONE); /* data = bit */
+ CLOCK(C_CLK); /* clock the bit */
+ }
+ }
+
+ /* following the entry of the last data bit, a stop bit ... is issued */
+ /* by bringing DATA high and toggling CLK high-to-low and low-to-high */
+ CLOCK ( C_BOTH ) ; /* clock still high, bring data high */
+ CLOCK ( C_DATA ) ; /* toggle clock low */
+ CLOCK ( C_BOTH ) ; /* toggle clock hi */
+
+ /* Select the CLOCK in the frequency synthesizer */
+ /* if we set anything but video clocks (regs 0-2) then restore clock */
+ /* select bits, otherwise set new select video freq. reg. */
+
+ if ( ( select >= 0 ) && ( select <= 2 ) ) /* if it's a vclk reg */
+ {
+ CLOCK ( select << 2 ) ; /* this will set SEL1 (bit 3) and SEL0 (bit 2) */
+#ifdef DEBUG
+ ErrorF("ICD2061ASetClock: Debug info: savemisc=MISC_IN_REG=0x%X\n" ,
+ (int) ((savemisc & 0xF3)| (select << 2) ) ) ;
+#endif
+ }
+ else
+ {
+ outb ( (short) MISC_OUT_REG , (char) savemisc ) ; /* not a vclk reg restore old select bits so that old vclk is selected */
+#ifdef DEBUG
+ ErrorF("ICD2061ASetClock: Debug info: MISC_OUT_REG set to=0x%X\n" ,
+ (int) savemisc ) ;
+#endif
+ }
+}
+
+
+
+
+
+
+
+
diff --git a/xc/programs/Xserver/hw/xfree86/common/Mach32.c b/xc/programs/Xserver/hw/xfree86/common/Mach32.c
new file mode 100644
index 000000000..3d66c5c05
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common/Mach32.c
@@ -0,0 +1,62 @@
+/* $XConsortium: XF86_Mach32.c,v 1.1 94/03/28 21:21:46 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/Mach32.c,v 3.3 1994/09/17 13:46:26 dawes Exp $ */
+#include "X.h"
+#include "os.h"
+
+#define _NO_XF86_PROTOTYPES
+
+#include "xf86.h"
+#include "xf86_Config.h"
+
+extern ScrnInfoRec mach32InfoRec;
+
+/*
+ * This limit is currently set to 80MHz because this is the limit of many
+ * ramdacs when running in 1:1 mode. It will be increased when support
+ * is added for using the ramdacs in 2:1 mode. Increasing this limit
+ * could result in damage to your hardware.
+ */
+#define MAX_MACH32_CLOCK 80000
+#define MAX_MACH32_TLC34075_CLOCK 135000
+#define MAX_MACH32_16BPP_CLOCK 67500
+
+int mach32MaxClock = MAX_MACH32_CLOCK;
+int mach32MaxTlc34075Clock = MAX_MACH32_TLC34075_CLOCK;
+int mach32Max16bppClock = MAX_MACH32_16BPP_CLOCK;
+
+ScrnInfoPtr xf86Screens[] =
+{
+ &mach32InfoRec,
+};
+
+int xf86MaxScreens = sizeof(xf86Screens) / sizeof(ScrnInfoPtr);
+
+int xf86ScreenNames[] =
+{
+ ACCEL,
+ -1
+};
+
+int mach32ValidTokens[] =
+{
+ STATICGRAY,
+ GRAYSCALE,
+ STATICCOLOR,
+ PSEUDOCOLOR,
+ TRUECOLOR,
+ DIRECTCOLOR,
+ CHIPSET,
+ CLOCKS,
+ MODES,
+ OPTION,
+ VIDEORAM,
+ VIEWPORT,
+ VIRTUAL,
+ CLOCKPROG,
+ BIOSBASE,
+ MEMBASE,
+ -1
+};
+
+#include "xf86ExtInit.h"
+
diff --git a/xc/programs/Xserver/hw/xfree86/common/Mach64.c b/xc/programs/Xserver/hw/xfree86/common/Mach64.c
new file mode 100644
index 000000000..ae86e7928
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common/Mach64.c
@@ -0,0 +1,59 @@
+/* $XConsortium: XF86_Mach64.c,v 1.1 94/03/28 21:21:46 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/Mach64.c,v 3.0 1994/11/27 20:42:39 dawes Exp $ */
+#include "X.h"
+#include "os.h"
+
+#define _NO_XF86_PROTOTYPES
+
+#include "xf86.h"
+#include "xf86_Config.h"
+
+extern ScrnInfoRec mach64InfoRec;
+
+/*
+ * This limit is currently set to 80MHz because this is the limit of many
+ * ramdacs when running in 1:1 mode. It will be increased when support
+ * is added for using the ramdacs in 2:1 mode. Increasing this limit
+ * could result in damage to your hardware.
+ */
+#define MAX_MACH64_CLOCK 80000
+#define MAX_MACH64_ATI68860_CLOCK 135000
+
+int mach64MaxClock = MAX_MACH64_CLOCK;
+int mach64MaxATI68860Clock = MAX_MACH64_ATI68860_CLOCK;
+
+ScrnInfoPtr xf86Screens[] =
+{
+ &mach64InfoRec,
+};
+
+int xf86MaxScreens = sizeof(xf86Screens) / sizeof(ScrnInfoPtr);
+
+int xf86ScreenNames[] =
+{
+ ACCEL,
+ -1
+};
+
+int mach64ValidTokens[] =
+{
+ STATICGRAY,
+ GRAYSCALE,
+ STATICCOLOR,
+ PSEUDOCOLOR,
+ TRUECOLOR,
+ DIRECTCOLOR,
+ CHIPSET,
+ CLOCKS,
+ MODES,
+ OPTION,
+ VIDEORAM,
+ VIEWPORT,
+ VIRTUAL,
+ CLOCKPROG,
+ BIOSBASE,
+ MEMBASE,
+ -1
+};
+
+#include "xf86ExtInit.h"
diff --git a/xc/programs/Xserver/hw/xfree86/common/Mach8.c b/xc/programs/Xserver/hw/xfree86/common/Mach8.c
new file mode 100644
index 000000000..118ad5316
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common/Mach8.c
@@ -0,0 +1,57 @@
+/* $XConsortium: XF86_Mach8.c,v 1.1 94/03/28 21:21:52 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/Mach8.c,v 3.2 1994/09/07 15:51:41 dawes Exp $ */
+#include "X.h"
+#include "os.h"
+
+#define _NO_XF86_PROTOTYPES
+
+#include "xf86.h"
+#include "xf86_Config.h"
+
+extern ScrnInfoRec mach8InfoRec;
+
+/*
+ * This limit is set to a value which is typical for many of the ramdacs
+ * used on Mach8 cards. Increasing this limit could result in damage to
+ * to your hardware.
+ */
+/* XXXX This value needs to be checked (currently using 80MHz) */
+#define MAX_MACH8_CLOCK 80000
+
+int mach8MaxClock = MAX_MACH8_CLOCK;
+
+ScrnInfoPtr xf86Screens[] =
+{
+ &mach8InfoRec,
+};
+
+int xf86MaxScreens = sizeof(xf86Screens) / sizeof(ScrnInfoPtr);
+
+int xf86ScreenNames[] =
+{
+ ACCEL,
+ -1
+};
+
+int mach8ValidTokens[] =
+{
+ STATICGRAY,
+ GRAYSCALE,
+ STATICCOLOR,
+ PSEUDOCOLOR,
+ TRUECOLOR,
+ DIRECTCOLOR,
+ CHIPSET,
+ CLOCKS,
+ MODES,
+ OPTION,
+ VIDEORAM,
+ VIEWPORT,
+ VIRTUAL,
+ CLOCKPROG,
+ BIOSBASE,
+ -1
+};
+
+#include "xf86ExtInit.h"
+
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c b/xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c
new file mode 100644
index 000000000..943b98b89
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c
@@ -0,0 +1,467 @@
+/* $XConsortium: xf86_KbdBSD.c,v 1.1 94/03/28 21:23:59 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c,v 3.4 1995/01/10 10:23:50 dawes Exp $ */
+/*
+ * Derived from xf86Kbd.c by S_ren Schmidt (sos@login.dkuug.dk)
+ * which is Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ * and from xf86KbdCODrv.c by Holger Veit
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "X.h"
+#include "Xmd.h"
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+#include "atKeynames.h"
+#include "xf86_Config.h"
+#include "coKeynames.h"
+#include "xf86Keymap.h"
+
+#define KD_GET_ENTRY(i,n) \
+ eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]]
+
+#ifndef __bsdi__
+static KeySym coGetKeysym();
+#endif
+
+static unsigned char remap[128] = {
+ 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */
+ 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, /* 0x30 - 0x37 */
+ 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38 - 0x3f */
+ 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0, /* 0x40 - 0x47 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */
+ 0, 0, 0, 0, 0, 0, 0x56, 0x57, /* 0x50 - 0x57 */
+ 0x58, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x67 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68 - 0x6f */
+ 0, 0, 0x69, 0x65, 0, 0, 0, 0, /* 0x70 - 0x77 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */
+};
+
+static KeySym eascii_to_x[512] = {
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol,
+ NoSymbol, XK_Return, 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_Delete,
+ XK_Ccedilla, XK_udiaeresis, XK_eacute, XK_acircumflex,
+ XK_adiaeresis, XK_agrave, XK_aring, XK_ccedilla,
+ XK_ecircumflex, XK_ediaeresis, XK_egrave, XK_idiaeresis,
+ XK_icircumflex, XK_igrave, XK_Adiaeresis, XK_Aring,
+ XK_Eacute, XK_ae, XK_AE, XK_ocircumflex,
+ XK_odiaeresis, XK_ograve, XK_ucircumflex, XK_ugrave,
+ XK_ydiaeresis, XK_Odiaeresis, XK_Udiaeresis, XK_cent,
+ XK_sterling, XK_yen, XK_paragraph, XK_section,
+ XK_aacute, XK_iacute, XK_oacute, XK_uacute,
+ XK_ntilde, XK_Ntilde, XK_ordfeminine, XK_masculine,
+ XK_questiondown,XK_hyphen, XK_notsign, XK_onehalf,
+ XK_onequarter, XK_exclamdown, XK_guillemotleft,XK_guillemotright,
+ 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,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ XK_Greek_alpha, XK_ssharp, XK_Greek_GAMMA, XK_Greek_pi,
+ XK_Greek_SIGMA, XK_Greek_sigma, XK_mu, XK_Greek_tau,
+ XK_Greek_PHI, XK_Greek_THETA, XK_Greek_OMEGA, XK_Greek_delta,
+ XK_infinity, XK_Ooblique, XK_Greek_epsilon, XK_intersection,
+ XK_identical, XK_plusminus, XK_greaterthanequal, XK_lessthanequal,
+ XK_topintegral, XK_botintegral, XK_division, XK_similarequal,
+ XK_degree, NoSymbol, NoSymbol, XK_radical,
+ XK_Greek_eta, XK_twosuperior, XK_periodcentered, NoSymbol,
+
+ /*
+ * special marked entries (256 + x)
+ */
+
+ NoSymbol, NoSymbol, XK_Shift_L, XK_Shift_R,
+ XK_Caps_Lock, XK_Num_Lock, XK_Scroll_Lock, XK_Alt_L,
+ NoSymbol, XK_Control_L, XK_Alt_L, XK_Alt_R,
+ XK_Control_L, XK_Control_R, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, XK_F1,
+ XK_F2, XK_F3, XK_F4, XK_F5,
+ XK_F6, XK_F7, XK_F8, XK_F9,
+ XK_F10, XK_F11, XK_F12, 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, 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, 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, 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, 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, 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, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol,
+ };
+
+/*
+ * LegalModifier --
+ * determine whether a key is a legal modifier key, i.e send a
+ * press/release sequence.
+ */
+
+/*ARGSUSED*/
+Bool
+LegalModifier(key, pDev)
+ unsigned int key;
+ DevicePtr pDev;
+{
+ return (TRUE);
+}
+
+/*
+ * xf86KbdGetMapping --
+ * Get the national keyboard mapping. The keyboard type is set, a new map
+ * and the modifiermap is computed.
+ */
+
+void
+xf86KbdGetMapping (pKeySyms, pModMap)
+ KeySymsPtr pKeySyms;
+ CARD8 *pModMap;
+{
+ KeySym *k;
+ char type;
+ int i, j;
+
+#ifndef __bsdi__
+ switch (xf86Info.consType) {
+
+#ifdef PCCONS_SUPPORT
+ case PCCONS:
+ break;
+#endif
+
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ case PCVT:
+ {
+ keymap_t keymap;
+
+ if (ioctl(xf86Info.consoleFd, GIO_KEYMAP, &keymap) != -1) {
+ for (i = 0; i < keymap.n_keys && i < NUM_KEYCODES; i++)
+ if (remap[i]) {
+ k = map + (remap[i] << 2);
+ k[0] = KD_GET_ENTRY(i,0); /* non-shifed */
+ k[1] = KD_GET_ENTRY(i,1); /* shifted */
+ k[2] = KD_GET_ENTRY(i,4); /* alt */
+ k[3] = KD_GET_ENTRY(i,5); /* alt - shifted */
+ 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;
+ }
+ }
+ }
+ break;
+#endif /* SYSCONS || PCVT */
+
+#ifdef CODRV_SUPPORT
+ case CODRV011:
+ case CODRV01X:
+ for (i=1; i<= 128; i++) {
+ struct kbd_ovlkey cokeymap;
+ struct oldkbd_ovlkey ocokeymap;
+ KeySym coGetKeysym();
+
+ if (xf86Info.consType == CODRV011) {
+ ocokeymap.keynum = i;
+ if (ioctl(xf86Info.consoleFd, OLDKBDGCKEY, &ocokeymap) < 0)
+ break; /* Don't try again if it fails once */
+ if ((ocokeymap.type & KBD_OVERLOAD)) { /* changed from default setting */
+ k = map + (xf86CodrvMap[i] << 2);
+ k[0] = coGetKeysym(ocokeymap.type,(CARD8*)&ocokeymap.unshift,k[0]);
+ k[1] = coGetKeysym(ocokeymap.type,(CARD8*)&ocokeymap.shift,k[1]);
+ k[2] = coGetKeysym(ocokeymap.type,(CARD8*)&ocokeymap.altgr,k[2]);
+ k[3] = NoSymbol;
+ }
+ } else {
+ cokeymap.keynum = i;
+ if (ioctl(xf86Info.consoleFd, KBDGCKEY, &cokeymap) < 0)
+ break; /* Don't try again if it fails once */
+ if ((cokeymap.type & KBD_OVERLOAD)) { /* changed from default setting */
+ k = map + (xf86CodrvMap[i] << 2);
+ k[0] = coGetKeysym(cokeymap.type,(CARD8*)&cokeymap.unshift,k[0]);
+ k[1] = coGetKeysym(cokeymap.type,(CARD8*)&cokeymap.shift,k[1]);
+ k[2] = coGetKeysym(cokeymap.type,(CARD8*)&cokeymap.altgr,k[2]);
+ k[3] = coGetKeysym(cokeymap.type,(CARD8*)&cokeymap.shiftaltgr,k[3]);
+ }
+ }
+ if ((cokeymap.type & KBD_OVERLOAD)) { /* changed from default setting */
+ 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;
+ }
+ }
+ break;
+#endif /* CODRV */
+ }
+#endif /* !bsdi */
+
+ /*
+ * Apply the special key mapping specified in XF86Config
+ */
+ for (k = map, i = MIN_KEYCODE;
+ i < (NUM_KEYCODES + MIN_KEYCODE);
+ i++, k += 4) {
+ switch (k[0]) {
+ case XK_Alt_L:
+ j = K_INDEX_LEFTALT;
+ break;
+ case XK_Alt_R:
+ j = K_INDEX_RIGHTALT;
+ break;
+ case XK_Scroll_Lock:
+ j = K_INDEX_SCROLLLOCK;
+ break;
+ case XK_Control_R:
+ j = K_INDEX_RIGHTCTL;
+ break;
+ default:
+ j = -1;
+ }
+ if (j >= 0)
+ switch (xf86Info.specialKeyMap[j]) {
+ case KM_META:
+ if (k[0] == XK_Alt_R)
+ k[1] = XK_Meta_R;
+ else {
+ k[0] = XK_Alt_L;
+ k[1] = XK_Meta_L;
+ }
+ break;
+ case KM_COMPOSE:
+ k[0] = XK_Multi_key;
+ break;
+ case KM_MODESHIFT:
+ k[0] = XK_Mode_switch;
+ k[1] = NoSymbol;
+ break;
+ case KM_MODELOCK:
+ k[0] = XK_Mode_switch;
+ k[1] = XK_Mode_Lock;
+ break;
+ case KM_SCROLLLOCK:
+ k[0] = XK_Scroll_Lock;
+ break;
+ case KM_CONTROL:
+ k[0] = XK_Control_R;
+ break;
+ }
+ }
+
+ /*
+ * compute the modifier map
+ */
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = NoSymbol; /* make sure it is restored */
+
+ for (k = map, i = MIN_KEYCODE;
+ i < (NUM_KEYCODES + MIN_KEYCODE);
+ i++, k += 4)
+
+ switch(*k) {
+
+ case XK_Shift_L:
+ case XK_Shift_R:
+ pModMap[i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ case XK_Control_R:
+ pModMap[i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ pModMap[i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ case XK_Alt_R:
+ pModMap[i] = AltMask;
+ break;
+
+ case XK_Num_Lock:
+ if (!xf86Info.serverNumLock) pModMap[i] = NumLockMask;
+ break;
+
+ case XK_Scroll_Lock:
+ pModMap[i] = ScrollLockMask;
+ break;
+
+ /* kana support */
+ case XK_Kana_Lock:
+ case XK_Kana_Shift:
+ pModMap[i] = KanaMask;
+ break;
+
+ /* alternate toggle for multinational support */
+ case XK_Mode_switch:
+ pModMap[i] = AltLangMask;
+ break;
+
+ }
+
+ xf86Info.kbdType = 0;
+
+ pKeySyms->map = map;
+ pKeySyms->mapWidth = GLYPHS_PER_KEY;
+ pKeySyms->minKeyCode = MIN_KEYCODE;
+ if (xf86Info.serverNumLock)
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
+ else
+ pKeySyms->maxKeyCode = MAX_STD_KEYCODE;
+
+}
+
+#ifdef CODRV_SUPPORT
+/* Converts a CoDriver ASCII+Special combination into a KeySym
+ */
+static KeySym
+coGetKeysym(typ,str,old)
+ int typ;
+ CARD8 *str;
+ KeySym old;
+{
+ if (strlen((char *)str) > 1) return old;
+ switch (typ & KBD_MASK) {
+ case KBD_NONE:
+ return NoSymbol;
+ case KBD_SHIFT:
+ if (old==XK_Shift_L || old==XK_Shift_R) return old;
+ else return XK_Shift_L;
+ case KBD_NUM:
+ return XK_Num_Lock;
+ case KBD_CTL:
+ if (old==XK_Control_L || old==XK_Control_R) return old;
+ else return XK_Control_L;
+ case KBD_ALTGR:
+ return XK_Mode_switch;
+ case KBD_META:
+ if (old==XK_Alt_L || old==XK_Alt_R) return old;
+ else return XK_Alt_L;
+ case KBD_SHFTLOCK:
+ case KBD_CAPS:
+ return XK_Caps_Lock;
+ case KBD_SCROLL:
+ return XK_Scroll_Lock;
+ case KBD_BREAK:
+ return XK_Break;
+ default:
+ case KBD_KP: /* there are few good reasons to overload
+ * F Keys and KP Keys, so we ignore any attempt
+ * at all
+ */
+ return old;
+ case KBD_ASCII:
+ return *str;
+ }
+}
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c b/xc/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c
new file mode 100644
index 000000000..35b56494d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c
@@ -0,0 +1,595 @@
+/* $XConsortium: xf86_KbdLnx.c,v 1.1 94/03/28 21:24:06 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c,v 3.4 1994/12/11 10:54:45 dawes Exp $ */
+/*
+ * Linux version of keymapping setup. The kernel (since 0.99.14) has support
+ * for fully remapping the keyboard, but there are some differences between
+ * the Linux map and the SVR4 map (esp. in the extended keycodes). We also
+ * remove the restriction on what keycodes can be remapped.
+ * Orest Zborowski.
+ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Roell makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#include "X.h"
+#include "Xmd.h"
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+#include "atKeynames.h"
+#include "xf86_Config.h"
+
+#include "xf86Keymap.h"
+#include "DECkeysym.h"
+
+/*
+ * LegalModifier --
+ * determine whether a key is a legal modifier key, i.e send a
+ * press/release sequence.
+ */
+
+/*ARGSUSED*/
+Bool
+LegalModifier(unsigned int key, DevicePtr pDev)
+{
+ return (TRUE);
+}
+
+/*
+ * xf86KbdGetMapping --
+ * Get the national keyboard mapping. The keyboard type is set, a new map
+ * and the modifiermap is computed.
+ */
+
+static void readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap);
+
+void
+xf86KbdGetMapping (KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ KeySym *k;
+ char type;
+ int i, j;
+
+ readKernelMapping(pKeySyms, pModMap);
+
+ /*
+ * Apply the special key mapping specified in XF86Config
+ */
+ for (k = map, i = MIN_KEYCODE;
+ i < (NUM_KEYCODES + MIN_KEYCODE);
+ i++, k += 4) {
+ switch (k[0]) {
+ case XK_Alt_L:
+ j = K_INDEX_LEFTALT;
+ break;
+ case XK_Alt_R:
+ j = K_INDEX_RIGHTALT;
+ break;
+ case XK_Scroll_Lock:
+ j = K_INDEX_SCROLLLOCK;
+ break;
+ case XK_Control_R:
+ j = K_INDEX_RIGHTCTL;
+ break;
+ default:
+ j = -1;
+ }
+ if (j >= 0)
+ switch (xf86Info.specialKeyMap[j]) {
+ case KM_META:
+ if (k[0] == XK_Alt_R)
+ k[1] = XK_Meta_R;
+ else {
+ k[0] = XK_Alt_L;
+ k[1] = XK_Meta_L;
+ }
+ break;
+ case KM_COMPOSE:
+ k[0] = XK_Multi_key;
+ break;
+ case KM_MODESHIFT:
+ k[0] = XK_Mode_switch;
+ k[1] = NoSymbol;
+ break;
+ case KM_MODELOCK:
+ k[0] = XK_Mode_switch;
+ k[1] = XK_Mode_Lock;
+ break;
+ case KM_SCROLLLOCK:
+ k[0] = XK_Scroll_Lock;
+ break;
+ case KM_CONTROL:
+ k[0] = XK_Control_R;
+ break;
+ }
+ }
+
+ /*
+ * compute the modifier map
+ */
+ for (i = 0; i < MAP_LENGTH; i++)
+ pModMap[i] = NoSymbol; /* make sure it is restored */
+
+ for (k = map, i = MIN_KEYCODE;
+ i < (NUM_KEYCODES + MIN_KEYCODE);
+ i++, k += 4)
+
+ switch(*k) {
+
+ case XK_Shift_L:
+ case XK_Shift_R:
+ pModMap[i] = ShiftMask;
+ break;
+
+ case XK_Control_L:
+ case XK_Control_R:
+ pModMap[i] = ControlMask;
+ break;
+
+ case XK_Caps_Lock:
+ pModMap[i] = LockMask;
+ break;
+
+ case XK_Alt_L:
+ case XK_Alt_R:
+ pModMap[i] = AltMask;
+ break;
+
+ case XK_Num_Lock:
+ if (!xf86Info.serverNumLock) pModMap[i] = NumLockMask;
+ break;
+
+ case XK_Scroll_Lock:
+ pModMap[i] = ScrollLockMask;
+ break;
+
+ /* kana support */
+ case XK_Kana_Lock:
+ case XK_Kana_Shift:
+ pModMap[i] = KanaMask;
+ break;
+
+ /* alternate toggle for multinational support */
+ case XK_Mode_switch:
+ pModMap[i] = AltLangMask;
+ break;
+
+ }
+
+ xf86Info.kbdType =
+ ioctl(xf86Info.consoleFd, KDGKBTYPE, &type) != -1 ? type : KB_101;
+
+ pKeySyms->map = map;
+ pKeySyms->mapWidth = GLYPHS_PER_KEY;
+ pKeySyms->minKeyCode = MIN_KEYCODE;
+ if (xf86Info.serverNumLock)
+ pKeySyms->maxKeyCode = MAX_KEYCODE;
+ else
+ pKeySyms->maxKeyCode = MAX_STD_KEYCODE;
+
+}
+
+#include <linux/keyboard.h>
+
+static 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_Delete,
+ 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
+};
+
+/*
+ * Maps the AT keycodes to Linux keycodes
+ */
+static unsigned char at2lnx[] =
+{
+ 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 */
+ 0x55, /* unused */ 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, /* ??????????? */ 0x00, /* ??????????? */
+ 0x7A, /* FOCUS_PF11 */ 0x00, /* ??????????? */
+ 0x7B, /* FOCUS_PF12 */ 0x00, /* ??????????? */
+ 0x00, /* ??????????? */ 0x00, /* ??????????? */
+ 0x59, /* FOCUS_PF2 */ 0x78, /* FOCUS_PF9 */
+ 0x00, /* ??????????? */ 0x00, /* ??????????? */
+ 0x5A, /* FOCUS_PF3 */ 0x5B, /* FOCUS_PF4 */
+ 0x5C, /* FOCUS_PF5 */ 0x5D, /* FOCUS_PF6 */
+ 0x5E, /* FOCUS_PF7 */ 0x5F, /* FOCUS_PF8 */
+ 0x7C, /* JAP_86 */ 0x79 /* FOCUS_PF10 */
+};
+#define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0]))
+
+static void
+readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+ KeySym *k;
+ char type;
+ int i, j;
+ static unsigned char tbl[GLYPHS_PER_KEY] =
+ {
+ 0, /* unshifted */
+ 1, /* shifted */
+ 0, /* modeswitch unshifted */
+ 0 /* modeswitch shifted */
+ };
+
+ for (k = map, i = GLYPHS_PER_KEY * NUM_KEYCODES; i--; )
+ *k++ = NoSymbol;
+
+ /*
+ * Read the mapping from the kernel.
+ * Since we're still using the XFree86 scancode->AT keycode mapping
+ * routines, we need to convert the AT keycodes to Linux keycodes,
+ * then translate the Linux keysyms into X keysyms.
+ *
+ * First, figure out which tables to use for the modeswitch columns
+ * above, from the XF86Config fields.
+ */
+ if (xf86Info.specialKeyMap[K_INDEX_RIGHTCTL] == KM_MODESHIFT ||
+ xf86Info.specialKeyMap[K_INDEX_RIGHTCTL] == KM_MODELOCK)
+ tbl[2] = 4; /* control */
+ else if (xf86Info.specialKeyMap[K_INDEX_RIGHTALT] == KM_MODESHIFT ||
+ xf86Info.specialKeyMap[K_INDEX_RIGHTALT] == KM_MODELOCK)
+ tbl[2] = 2; /* AltGr */
+ else
+ tbl[2] = 8; /* alt */
+ tbl[3] = tbl[2] | 1;
+
+ for (i = 0, k = map+GLYPHS_PER_KEY; i < NUM_AT2LNX; ++i)
+ {
+ struct kbentry kbe;
+ int j;
+
+ kbe.kb_index = at2lnx[i];
+ for (j = 0; j < GLYPHS_PER_KEY; ++j, ++k)
+ {
+ unsigned short kval;
+
+ kbe.kb_table = tbl[j];
+ if (ioctl(xf86Info.consoleFd, KDGKBENT, &kbe))
+ continue;
+
+ kval = KVAL(kbe.kb_value);
+ switch (KTYP(kbe.kb_value))
+ {
+ case KT_LATIN:
+ case KT_LETTER:
+ *k = linux_to_x[kval];
+ break;
+
+ case KT_FN:
+ if (kval <= 19)
+ *k = XK_F1 + kval;
+ else switch (kbe.kb_value)
+ {
+ case K_FIND:
+ *k = XK_Home; /* or XK_Find */
+ break;
+ case K_INSERT:
+ *k = XK_Insert;
+ break;
+ case K_REMOVE:
+ *k = XK_Delete;
+ break;
+ case K_SELECT:
+ *k = XK_End; /* or XK_Select */
+ break;
+ case K_PGUP:
+ *k = XK_Prior;
+ break;
+ case K_PGDN:
+ *k = XK_Next;
+ break;
+ case K_HELP:
+ *k = XK_Help;
+ break;
+ case K_DO:
+ *k = XK_Execute;
+ break;
+ case K_PAUSE:
+ *k = XK_Pause;
+ break;
+ case K_MACRO:
+ *k = XK_Menu;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case KT_SPEC:
+ switch (kbe.kb_value)
+ {
+ case K_ENTER:
+ *k = XK_Return;
+ break;
+ case K_BREAK:
+ *k = XK_Break;
+ break;
+ case K_CAPS:
+ *k = XK_Caps_Lock;
+ break;
+ case K_NUM:
+ *k = XK_Num_Lock;
+ break;
+ case K_HOLD:
+ *k = XK_Scroll_Lock;
+ break;
+ case K_COMPOSE:
+ *k = XK_Multi_key;
+ break;
+ default:
+ break;
+ }
+ break;
+
+ case KT_PAD:
+ switch (kbe.kb_value)
+ {
+ case K_PPLUS:
+ *k = XK_KP_Add;
+ break;
+ case K_PMINUS:
+ *k = XK_KP_Subtract;
+ break;
+ case K_PSTAR:
+ *k = XK_KP_Multiply;
+ break;
+ case K_PSLASH:
+ *k = XK_KP_Divide;
+ break;
+ case K_PENTER:
+ *k = XK_KP_Enter;
+ break;
+ case K_PCOMMA:
+ *k = XK_KP_Separator;
+ break;
+ case K_PDOT:
+ *k = XK_KP_Decimal;
+ break;
+ default:
+ if (kval <= 9)
+ *k = XK_KP_0 + kval;
+ break;
+ }
+ break;
+
+ /*
+ * KT_DEAD keys are for accelerated diacritical creation.
+ * We should generate "XK_Compose XK_xxx" but can only map to one
+ * keysym.
+ * There is support for these in DECkeysym.h. At the same place support
+ * for dead cedilla and dead degree sign can be found, too (these are
+ * not yet supported by the Linux kernel)
+ */
+ case KT_DEAD:
+ switch (kbe.kb_value)
+ {
+ case K_DGRAVE:
+ *k = DXK_grave_accent;
+ break;
+ case K_DACUTE:
+ *k = DXK_acute_accent;
+ break;
+ case K_DCIRCM:
+ *k = DXK_circumflex_accent;
+ break;
+ case K_DTILDE:
+ *k = DXK_tilde;
+ break;
+ case K_DDIERE:
+ *k = DXK_diaeresis;
+ break;
+ }
+ break;
+
+ case KT_CUR:
+ switch (kbe.kb_value)
+ {
+ case K_DOWN:
+ *k = XK_Down;
+ break;
+ case K_LEFT:
+ *k = XK_Left;
+ break;
+ case K_RIGHT:
+ *k = XK_Right;
+ break;
+ case K_UP:
+ *k = XK_Up;
+ break;
+ }
+ break;
+
+ case KT_SHIFT:
+ switch (kbe.kb_value)
+ {
+ case K_ALTGR:
+ *k = XK_Alt_R;
+ break;
+ case K_ALT:
+ *k = (kbe.kb_index == 0x64 ?
+ XK_Alt_R : XK_Alt_L);
+ break;
+ case K_CTRL:
+ *k = (kbe.kb_index == 0x61 ?
+ XK_Control_R : XK_Control_L);
+ break;
+ case K_CTRLL:
+ *k = XK_Control_L;
+ break;
+ case K_CTRLR:
+ *k = XK_Control_R;
+ break;
+ case K_SHIFT:
+ *k = (kbe.kb_index == 0x36 ?
+ XK_Shift_R : XK_Shift_L);
+ break;
+ case K_SHIFTL:
+ *k = XK_Shift_L;
+ break;
+ case K_SHIFTR:
+ *k = 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 = XK_Shift_Lock;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if (k[-1] == k[-2]) k[-1] = NoSymbol;
+ if (k[-2] == k[-3]) k[-2] = NoSymbol;
+ if (k[-3] == k[-4]) k[-3] = NoSymbol;
+ if (k[-4] == k[-2] && k[-3] == k[-1]) k[-2] = k[-1] = NoSymbol;
+ if (k[-1] == k[-4] && k[-2] == k[-3] && k[-2] == NoSymbol) k[-1] =NoSymbol;
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/common_hw/I2061Aalt.c b/xc/programs/Xserver/hw/xfree86/common_hw/I2061Aalt.c
new file mode 100644
index 000000000..ae333f3af
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common_hw/I2061Aalt.c
@@ -0,0 +1,249 @@
+/* $XConsortium: ICD2061Aalt.c,v 1.1 94/03/28 21:24:51 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common_hw/I2061Aalt.c,v 3.3 1995/01/20 04:21:16 dawes Exp $ */
+
+/*
+ * This code is derived from code available from the STB bulletin board
+ */
+
+#include "compiler.h"
+
+#define SEQREG 0x03C4
+#define MISCREG 0x03C2
+#define MISCREAD 0x03CC
+
+double fref = 14.31818 * 2.0;
+char ascclk[] = "VIDEO CLOCK ?";
+
+unsigned short clknum;
+unsigned short vlbus_flag;
+unsigned short card;
+unsigned short crtcaddr;
+unsigned short clockreg;
+
+static double range[15] = {50.0, 51.0, 53.2, 58.5, 60.7, 64.4, 66.8, 73.5,
+ 75.6, 80.9, 83.2, 91.5, 100.0, 120.0, 120.0000001};
+
+#ifdef __STDC__
+#if 0
+static void prtbinary(unsigned int size, unsigned int val);
+#endif
+static void wait_vb();
+static void wrt_clk_bit(unsigned int value);
+static void init_clock(unsigned long setup, unsigned short crtcport);
+#else
+#if 0
+static void prtbinary();
+#endif
+static void wait_vb();
+static void wrt_clk_bit();
+static void init_clock();
+#endif
+
+void AltICD2061SetClock(frequency, select)
+register long frequency; /* in Hz */
+int select;
+{
+ unsigned int m;
+ int i;
+ long dwv;
+ double realval;
+ double freq, fvco;
+ double dev, devx;
+ double delta, deltax;
+ double f0;
+ unsigned int p, q;
+ unsigned int bestp=0, bestq=0, bestm=0, besti=0;
+ unsigned char tmp;
+
+ crtcaddr=(inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4;
+
+
+ outb(crtcaddr, 0x11); /* Unlock CRTC registers */
+ tmp = inb(crtcaddr + 1);
+ outb(crtcaddr + 1, tmp & ~0x80);
+
+ outw(crtcaddr, 0x4838); /* Unlock S3 register set */
+ outw(crtcaddr, 0xA039);
+
+ clknum = select;
+
+ freq = ((double)frequency)/1000000.0;
+ if (freq > range[13])
+ freq = range[13];
+ else if (freq < 7.0)
+ freq = 7.0;
+
+/*
+ * Calculate values to load into ICD 2061A clock chip to set frequency
+ */
+ delta = 999.0;
+ dev = 999.0;
+
+ for (m = 0; m < 8; m++) {
+ fvco = freq * (1<<m);
+ if (fvco < 50.0 || fvco > 120.0) continue;
+
+ f0 = fvco / fref;
+
+ for (q = 14; q <= 71; q++) { /* q={15..71}:Constraint 2 on page 14 */
+ p = (int)(f0 * q + 0.5);
+ if (p < 4 || p > 130) /* p={4..130}:Constraint 5 on page 14 */
+ continue;
+ deltax = (double)(p) / (double)(q) - f0;
+ if (deltax < 0) deltax = -deltax;
+ if (deltax <= delta) {
+ for (i = 13; i >= 0; i--)
+ if (fvco >= range[i])
+ break;
+ devx = (fvco - (range[i] + range[i+1])/2)/fvco;
+ if (devx < 0)
+ devx = -devx;
+ if (deltax < delta || devx < dev) {
+ delta = deltax;
+ dev = devx;
+ bestp = p;
+ bestq = q;
+ bestm = m;
+ besti = i;
+ }
+ }
+ }
+ }
+ fvco = fref / (1<<bestm);
+ realval = (fvco * bestp) / bestq;
+ dwv = ((((((long)besti << 7) | (bestp-3)) << 3) | bestm) << 7) | (bestq-2);
+
+/*
+ * Write ICD 2061A clock chip
+ */
+ init_clock(((unsigned long)dwv) | (((long)clknum) << 21), crtcaddr);
+
+ wait_vb();
+ wait_vb();
+ wait_vb();
+ wait_vb();
+ wait_vb();
+ wait_vb();
+ wait_vb(); /* 0.10 second delay... */
+}
+
+
+#if 0
+static void prtbinary(size, val)
+ unsigned int size;
+ unsigned int val;
+ {
+ unsigned int mask;
+ int k;
+
+ mask = 1;
+
+ for (k=size; --k > 0 || mask <= val/2;)
+ mask <<= 1;
+
+ while (mask) {
+ fputc((mask&val)? '1': '0' , stderr);
+ mask >>= 1;
+ }
+ }
+#endif
+
+static void wait_vb()
+ {
+ while ((inb(crtcaddr+6) & 0x08) == 0)
+ ;
+ while (inb(crtcaddr+6) & 0x08)
+ ;
+ }
+
+
+#ifdef __STDC__
+static void init_clock(unsigned long setup, unsigned short crtcport)
+#else
+static void init_clock(setup, crtcport)
+ unsigned long setup;
+ unsigned short crtcport;
+#endif
+ {
+ unsigned char nclk[2], clk[2];
+ unsigned short restore42;
+ unsigned short oldclk;
+ unsigned short bitval;
+ int i;
+ unsigned char c;
+
+ (void)xf86DisableInterrupts();
+
+ oldclk = inb(0x3CC);
+
+ outb(crtcport, 0x42);
+ restore42 = inb(crtcport+1);
+
+ outw(0x3C4, 0x0100);
+
+ outb(0x3C4, 1);
+ c = inb(0x3C5);
+ outb(0x3C5, 0x20 | c);
+
+ outb(crtcport, 0x42);
+ outb(crtcport+1, 0x03);
+
+ outw(0x3C4, 0x0300);
+
+ nclk[0] = oldclk & 0xF3;
+ nclk[1] = nclk[0] | 0x08;
+ clk[0] = nclk[0] | 0x04;
+ clk[1] = nclk[0] | 0x0C;
+
+ outb(crtcport, 0x42);
+ i = inw(crtcport);
+
+ outw(0x3C4, 0x0100);
+
+ wrt_clk_bit(oldclk | 0x08);
+ wrt_clk_bit(oldclk | 0x0C);
+ for (i=0; i<5; i++) {
+ wrt_clk_bit(nclk[1]);
+ wrt_clk_bit(clk[1]);
+ }
+ wrt_clk_bit(nclk[1]);
+ wrt_clk_bit(nclk[0]);
+ wrt_clk_bit(clk[0]);
+ wrt_clk_bit(nclk[0]);
+ wrt_clk_bit(clk[0]);
+ for (i=0; i<24; i++) {
+ bitval = setup & 0x01;
+ setup >>= 1;
+ wrt_clk_bit(clk[1-bitval]);
+ wrt_clk_bit(nclk[1-bitval]);
+ wrt_clk_bit(nclk[bitval]);
+ wrt_clk_bit(clk[bitval]);
+ }
+ wrt_clk_bit(clk[1]);
+ wrt_clk_bit(nclk[1]);
+ wrt_clk_bit(clk[1]);
+
+ outb(0x3C4, 1);
+ c = inb(0x3C5);
+ outb(0x3C5, 0xDF & c);
+
+ outb(crtcport, 0x42);
+ outb(crtcport+1, restore42);
+
+ outb(0x3C2, oldclk);
+
+ outw(0x3C4, 0x0300);
+
+ xf86EnableInterrupts();
+
+ }
+
+static void wrt_clk_bit(value)
+ unsigned int value;
+ {
+ int j;
+
+ outb(0x3C2, value);
+ for (j=2; --j; )
+ inb(0x200);
+ }
diff --git a/xc/programs/Xserver/hw/xfree86/common_hw/I2061Acal.c b/xc/programs/Xserver/hw/xfree86/common_hw/I2061Acal.c
new file mode 100644
index 000000000..f33f1ba90
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common_hw/I2061Acal.c
@@ -0,0 +1,139 @@
+/* $XConsortium: ICD2061Acal.c,v 1.1 94/03/28 21:24:57 dpw Exp $ */
+/* Based on the number 9 Inc code */
+/* Copyright (c) 1992, Number Nine Computer Corp. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Number Nine Computer Corp not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. Number Nine Computer Corp
+ * makes no representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ * NUMBER NINE COMPUTER CORP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL NUMBER NINE COMPUTER CORP BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* Header: /home/src/xfree86/mit/server/ddx/xf86/common_hw/RCS/ICD2061Acalc.c,v 1.1 1993/03/22 00:25:21 jon Exp jon
+ */
+
+#include "compiler.h"
+#include "ICD2061A.h"
+
+#undef MIN
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#undef MAX
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+
+#define MAX_NUMERATOR 130
+#define MAX_DENOMINATOR MIN(129, CRYSTAL_FREQUENCY / 400000)
+#define MIN_DENOMINATOR MAX(3, CRYSTAL_FREQUENCY / 2000000)
+
+int clock_m;
+int clock_n;
+int clock_p;
+
+/* Index register frequency ranges for ICD2061A chip */
+static long vclk_range[16] = {
+ 0, /* should be MIN_VCO_FREQUENCY, but that causes problems. */
+ 51000000,
+ 53200000,
+ 58500000,
+ 60700000,
+ 64400000,
+ 66800000,
+ 73500000,
+ 75600000,
+ 80900000,
+ 83200000,
+ 91500000,
+ 100000000,
+ 120000000,
+ MAX_POST_SCALE,
+ 0,
+ };
+
+long
+ICD2061ACalcClock(frequency, select)
+register long frequency; /* in Hz */
+int select;
+{
+ register long index;
+ long temp;
+ long min_m, min_n, min_diff;
+ long diff;
+
+ min_diff = 0xFFFFFFF;
+ min_n = 1;
+ min_m = 1;
+
+ /* Calculate 18 bit clock value */
+ clock_p = 0;
+ if (frequency < MIN_VCO_FREQUENCY)
+ clock_p = 1;
+ if (frequency < MIN_VCO_FREQUENCY / 2)
+ clock_p = 2;
+ if (frequency < MIN_VCO_FREQUENCY / 4)
+ clock_p = 3;
+ frequency <<= clock_p;
+ for (clock_n = 4; clock_n <= MAX_NUMERATOR; clock_n++)
+ {
+ index = CRYSTAL_FREQUENCY / (frequency / clock_n);
+ if (index > MAX_DENOMINATOR)
+ index = MAX_DENOMINATOR;
+ if (index < MIN_DENOMINATOR)
+ index = MIN_DENOMINATOR;
+ for (clock_m = index - 3; clock_m < index + 4; clock_m++)
+ if (clock_m >= MIN_DENOMINATOR && clock_m <= MAX_DENOMINATOR)
+ {
+ diff = (CRYSTAL_FREQUENCY / clock_m) * clock_n - frequency;
+ if (diff < 0)
+ diff = -diff;
+ if (min_m * ICD2061AGCD(clock_m, clock_n) / ICD2061AGCD(min_m, min_n) == clock_m &&
+ min_n * ICD2061AGCD(clock_m, clock_n) / ICD2061AGCD(min_m, min_n) == clock_n)
+ if (diff > min_diff)
+ diff = min_diff;
+ if (diff <= min_diff)
+ {
+ min_diff = diff;
+ min_m = clock_m;
+ min_n = clock_n;
+ }
+ }
+ }
+ clock_m = min_m;
+ clock_n = min_n;
+
+ /* Calculate the index */
+ temp = (((CRYSTAL_FREQUENCY / 2) * clock_n) / clock_m) << 1;
+ for (index = 0; vclk_range[index + 1] < temp && index < 15; index++)
+ ;
+
+ /* Pack the clock value for the frequency snthesizer */
+ temp = (((long)clock_n - 3) << 11) + ((clock_m - 2) << 1)
+ + (clock_p << 8) + (index << 18) + ((long)select << 22);
+
+ return temp;
+}
+
+
+/* Number theoretic function - GCD (Greatest Common Divisor) */
+long
+ICD2061AGCD(a, b)
+register long a, b;
+{
+ register long c = a % b;
+ while (c)
+ a = b, b = c, c = a % b;
+ return b;
+}
+
+
+
diff --git a/xc/programs/Xserver/hw/xfree86/common_hw/I2061Aset.c b/xc/programs/Xserver/hw/xfree86/common_hw/I2061Aset.c
new file mode 100644
index 000000000..271c66e4a
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common_hw/I2061Aset.c
@@ -0,0 +1,142 @@
+/* $XConsortium: ICD2061Aset.c,v 1.1 94/03/28 21:25:04 dpw Exp $ */
+/* Based on the number 9 Inc code */
+/* Copyright (c) 1992, Number Nine Computer Corp. All Rights Reserved.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Number Nine Computer Corp not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission. Number Nine Computer Corp
+ * makes no representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied warranty.
+ *
+ * NUMBER NINE COMPUTER CORP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL NUMBER NINE COMPUTER CORP BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* Header: /home/src/xfree86/mit/server/ddx/xf86/common_hw/RCS/ICD2061Aset.c,v 1.1 1993/03/22 00:25:21 jon Exp jon
+ */
+
+#include "compiler.h"
+#include "ICD2061A.h"
+
+
+int clock_m;
+int clock_n;
+int clock_p;
+
+void
+ICD2061ASetClock(clock_value)
+register long clock_value; /* 7bits M, 7bits N, 2bits P */
+{
+ register long index;
+ register char iotemp;
+ int select;
+ unsigned short crtcaddr;
+
+ select = (clock_value >> 22) & 3;
+
+ crtcaddr = (inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4;
+
+ /* Unlock the S3 registers */
+ outb(crtcaddr, LOCK_INDEX);
+ outb(crtcaddr+1, UNLOCK_PATTERN);
+
+ /* Shut off screen */
+ outb(0x3C4, 0x01);
+ iotemp = inb(0x3C5);
+ outb(0x3C5, iotemp | 0x20);
+
+ /* set clock inbut to 11 binary */
+ iotemp = inb(0x3CC);
+ outb(0x3C2, iotemp | 0x0C);
+
+ outb(crtcaddr, SSW_WRITE_INDEX);
+ outb(crtcaddr+1, 0);
+
+ outb(crtcaddr, MODE_CTRL_INDEX);
+ iotemp = inb(crtcaddr+1) & 0xF0;
+
+ /* Set up the softswitch write value */
+#define CLOCK(x) outb(crtcaddr+1, iotemp | (x))
+#define C_DATA 2
+#define C_CLK 1
+#define C_BOTH 3
+#define C_NONE 0
+
+ /* Program the IC Designs ICD2061A frequency generator */
+ CLOCK(C_NONE);
+
+ /* Unlock sequence */
+ CLOCK(C_DATA);
+ for (index = 0; index < 6; index++)
+ {
+ CLOCK(C_BOTH);
+ CLOCK(C_DATA);
+ }
+ CLOCK(C_NONE);
+ CLOCK(C_CLK);
+ CLOCK(C_NONE);
+ CLOCK(C_CLK);
+
+ /* Program the 24 bit value into REG0 */
+ for (index = 0; index < 24; index++)
+ {
+ /* Clock in the next bit */
+ clock_value >>= 1;
+ if (clock_value & 1)
+ {
+ CLOCK(C_CLK);
+ CLOCK(C_NONE);
+ CLOCK(C_DATA);
+ CLOCK(C_BOTH);
+ }
+ else
+ {
+ CLOCK(C_BOTH);
+ CLOCK(C_DATA);
+ CLOCK(C_NONE);
+ CLOCK(C_CLK);
+ }
+ }
+
+ CLOCK(C_BOTH);
+ CLOCK(C_DATA);
+ CLOCK(C_BOTH);
+
+ /* If necessary, reprogram other ICD2061A registers to defaults */
+
+ /* Select the CLOCK in the frequency synthesizer */
+ CLOCK(C_NONE | select);
+
+ /* Turn screen back on */
+ outb(0x3C4, 0x01);
+ iotemp = inb(0x3C5);
+ outb(0x3C5, iotemp & 0xDF);
+
+}
+
+
+long
+ICD2061AGetClock(clock_value)
+register long clock_value; /* 7bits M, 7bits N, 2bits P */
+{
+ long temp;
+
+ /* Unpack the clock value */
+ clock_m = ((clock_value >> 1) & 0x7F) + 2;
+ clock_n = ((clock_value >> 11) & 0x7F) + 3;
+ clock_p = ((clock_value >> 8) & 0x03);
+
+ temp = (((CRYSTAL_FREQUENCY / 2) * clock_n) / clock_m) << 1;
+ temp >>= clock_p;
+
+ return temp;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/etc/install.sv3 b/xc/programs/Xserver/hw/xfree86/etc/install.sv3
new file mode 100644
index 000000000..f2f4c49bd
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/install.sv3
@@ -0,0 +1,218 @@
+#
+# Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of Thomas Roell not be used in
+# advertising or publicity pertaining to distribution of the software without
+# specific, written prior permission. Thomas Roell makes no representations
+# about the suitability of this software for any purpose. It is provided
+# "as is" without express or implied warranty.
+#
+# THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+# EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+#
+# Author: Thomas Roell, roell@informatik.tu-muenchen.de
+#
+
+# Changed for XFree86 by Thomas Wolfram,
+# (thomas@aeon.in-berlin.de, wolf@prz.tu-berlin.de)
+# Changed for XFree86 3.1 to coexist with Interactive X11 by Michael Rohleder
+# (michael.rohleder%iktffm.uucp@Germany.EU.net)
+
+# $XConsortium: $
+# $XFree86: xc/programs/Xserver/hw/xfree86/etc/install.sv3,v 3.1 1995/01/11 03:51:22 dawes Exp $
+
+#
+# XFree86 version
+#
+VERSION=3.1.1
+
+#
+# dependencies
+#
+if [ ! -s /usr/options/kc.name ]
+then
+ echo "Please make first sure that the Kernel Configuration is installed"
+ echo "correctly. Then try a reinstall of XFree86 $VERSION."
+ exit 1
+fi
+
+if [ ! -s /usr/options/st.name ]
+then
+ echo "Please make first sure that the STREAMS Facilities are installed"
+ echo "correctly. Then try a reinstall of XFree86 $VERSION."
+ exit 1
+fi
+
+#
+# Make a X11 label, so that following commercial products can be installed
+#
+if [ ! -s /usr/options/xfree86.name ]
+then
+ echo "X11R6 XFree86 Version $VERSION" >/usr/options/xfree86.name
+fi
+
+if [ ! -s /usr/options/xu.name ]
+then
+ echo "There's no Interactive X11 installed"
+ echo "Generating links, so following commercial products can be installed"
+ ln /usr/options/xfree86.name /usr/options/xu.name
+fi
+
+#
+# Install remove script
+#
+if [ ! -s /usr/lib/installed/Remove/xfree86.name ]
+then
+ echo -n 'echo "Removing XFree86 Version ' >/usr/lib/installed/Remove/xfree86.name
+ echo -n $VERSION >>/usr/lib/installed/Remove/xfree86.name
+ echo '"' >>/usr/lib/installed/Remove/xfree86.name
+ echo '/bin/rm -rf /usr/X11R6' >>/usr/lib/installed/Remove/xfree86.name
+ echo '/bin/rm -f /usr/options/xfree86.name' >>/usr/lib/installed/Remove/xfree86.name
+fi
+
+echo "Setting up node and sdevice"
+cd /usr/X11R6/lib/X11/etc
+cp pts.node /etc/conf/node.d/pts 2>/dev/null
+cp sp.node /etc/conf/node.d/sp 2>/dev/null
+cp ldterm.sdevice /etc/conf/sdevice.d/ldterm 2>/dev/null
+cp ptem.sdevice /etc/conf/sdevice.d/ptem 2>/dev/null
+cp ptm.sdevice /etc/conf/sdevice.d/ptm 2>/dev/null
+cp pts.sdevice /etc/conf/sdevice.d/pts 2>/dev/null
+cp sp.sdevice /etc/conf/sdevice.d/sp 2>/dev/null
+
+
+#
+# Setup STREAMS for maximum performance
+#
+echo "Setup STREAMS for maximum performance..."
+echo "if you allready tuned the STREAMS parameters - enter s to skip"
+read skip
+[ "$skip" != "s" ] && {
+ /bin/sh /etc/conf/bin/idtune -m NSTREAM 128
+ /bin/sh /etc/conf/bin/idtune -m NQUEUE 512
+ /bin/sh /etc/conf/bin/idtune -m NBLK4096 4
+ /bin/sh /etc/conf/bin/idtune -m NBLK2048 32
+ /bin/sh /etc/conf/bin/idtune -m NBLK1024 32
+ /bin/sh /etc/conf/bin/idtune -m NBLK512 32
+ /bin/sh /etc/conf/bin/idtune -m NBLK256 64
+ /bin/sh /etc/conf/bin/idtune -m NBLK128 256
+ /bin/sh /etc/conf/bin/idtune -m NBLK64 256
+ /bin/sh /etc/conf/bin/idtune -m NBLK16 256
+ /bin/sh /etc/conf/bin/idtune -m NBLK4 128
+ /bin/sh /etc/conf/bin/idtune -m SHLBMAX 8
+}
+
+# increase number of pseudo terminals from 16 to 32
+
+echo "Adjust kernel configuration files for 32 pseudo terminals..."
+
+if [ `grep pty /etc/conf/sdevice.d/pty | cut -f3` != 16 ] ; then
+ echo "There are already more then 16 pty's."
+else
+
+
+mv /etc/conf/sdevice.d/pty /etc/conf/sdevice.d/pty.old
+nawk '{
+ if ($1 == "pty") {
+ print $1 "\t" $2 "\t" 32 "\t" $4 "\t" $5 "\t" $6 "\t" $7 "\t" $8 "\t" $9 "\t" $10
+ }
+ else
+ print
+}' </etc/conf/sdevice.d/pty.old >/etc/conf/sdevice.d/pty
+rm /etc/conf/sdevice.d/pty.old
+
+mv /etc/conf/sdevice.d/ptx /etc/conf/sdevice.d/ptx.old
+nawk '{
+ if ($1 == "ptx") {
+ print $1 "\t" $2 "\t" 32 "\t" $4 "\t" $5 "\t" $6 "\t" $7 "\t" $8 "\t" $9 "\t" $10
+ }
+ else
+ print
+}' </etc/conf/sdevice.d/ptx.old >/etc/conf/sdevice.d/ptx
+rm /etc/conf/sdevice.d/ptx.old
+
+mv /etc/conf/cf.d/mdevice /etc/conf/cf.d/mdevice.old
+nawk '{
+ if ($1 ~ "pt[y|x]") {
+ print $1 "\t" $2 "\t" $3 "\t\t" $4 "\t" $5 "\t" $6 "\t" $7 "\t" 32 "\t" $9
+ }
+ else
+ print
+ }' </etc/conf/cf.d/mdevice.old >/etc/conf/cf.d/mdevice
+rm /etc/conf/cf.d/mdevice.old
+
+echo "pty ptyq0 c 16
+pty ptyq1 c 17
+pty ptyq2 c 18
+pty ptyq3 c 19
+pty ptyq4 c 20
+pty ptyq5 c 21
+pty ptyq6 c 22
+pty ptyq7 c 23
+pty ptyq8 c 24
+pty ptyq9 c 25
+pty ptyqa c 26
+pty ptyqb c 27
+pty ptyqc c 28
+pty ptyqd c 29
+pty ptyqe c 30
+pty ptyqf c 31" >>/etc/conf/node.d/pty
+
+echo "ptx ttyq0 c 16
+ptx ttyq1 c 17
+ptx ttyq2 c 18
+ptx ttyq3 c 19
+ptx ttyq4 c 20
+ptx ttyq5 c 21
+ptx ttyq6 c 22
+ptx ttyq7 c 23
+ptx ttyq8 c 24
+ptx ttyq9 c 25
+ptx ttyqa c 26
+ptx ttyqb c 27
+ptx ttyqc c 28
+ptx ttyqd c 29
+ptx ttyqe c 30
+ptx ttyqf c 31" >>/etc/conf/node.d/ptx
+
+fi
+
+echo "*** New Installation ***"
+echo "If this is a new installation of XFree86 $VERSION use \"kconfig\" to build a new"
+echo "kernel. XFree86 won't run without this new kernel."
+echo ""
+echo "<press return>"
+read answer
+
+#
+# install additional termcap & terminfo entries
+#
+echo "Do you want me to Install additional termcap & terminfo entries...[y/n]"
+read answer
+[ "$answer" = "y" ] && {
+grep xterm /etc/termcap >/dev/null || cat xterm.termcap >>/etc/termcap
+grep sun-cmd /etc/termcap >/dev/null || cat sun.termcap >>/etc/termcap
+
+tic sun.terminfo 2>/dev/null
+tic xterm.terminfo 2>/dev/null
+
+if [ -s /usr/lib/loadfont/vga437.bdf ]
+then
+ echo "Convert VGA font for using under X11..."
+ sed -e 's/FONT 8x16/FONT vga/' </usr/lib/loadfont/vga437.bdf \
+ | bdftopcf -t >/usr/X11R6/lib/X11/fonts/misc/vga.pcf
+ chmod 644 /usr/X11R6/lib/X11/fonts/misc/fonts.dir
+ mkfontdir /usr/X11R6/lib/X11/fonts/misc
+fi
+}
+echo READY
+
diff --git a/xc/programs/Xserver/hw/xfree86/etc/install.sv4 b/xc/programs/Xserver/hw/xfree86/etc/install.sv4
new file mode 100644
index 000000000..c44a414aa
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/install.sv4
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of Thomas Roell not be used in
+# advertising or publicity pertaining to distribution of the software without
+# specific, written prior permission. Thomas Roell makes no representations
+# about the suitability of this software for any purpose. It is provided
+# "as is" without express or implied warranty.
+#
+# THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+# EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+#
+# Author: Thomas Roell, roell@informatik.tu-muenchen.de
+#
+
+# $XConsortium: $
+# $XFree86: xc/programs/Xserver/hw/xfree86/etc/install.sv4,v 3.0 1994/06/05 05:57:05 dawes Exp $
+
+#
+# install addtional termcap & terminfo entries
+#
+grep xterm /etc/termcap >/dev/null || cat xterm.termcap >>/etc/termcap
+grep sun-cmd /etc/termcap >/dev/null || cat sun.termcap >>/etc/termcap
+
+tic sun.terminfo 2>/dev/null
+tic xterm.terminfo 2>/dev/null
+
diff --git a/xc/programs/Xserver/hw/xfree86/etc/sun.tcap b/xc/programs/Xserver/hw/xfree86/etc/sun.tcap
new file mode 100644
index 000000000..02c099ab7
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/sun.tcap
@@ -0,0 +1,28 @@
+# $XConsortium: $
+# $XFree86: xc/programs/Xserver/hw/xfree86/etc/sun.tcap,v 3.0 1994/06/05 05:57:20 dawes Exp $
+#
+Mu|sun|Sun Microsystems Workstation console:\
+ :am:bs:km:mi:ms:pt:li#34:co#80:cl=^L:cm=\E[%i%d;%dH:\
+ :ce=\E[K:cd=\E[J:so=\E[7m:se=\E[m:rs=\E[s:\
+ :al=\E[L:dl=\E[M:im=:ei=:ic=\E[@:dc=\E[P:\
+ :up=\E[A:nd=\E[C:ku=\E[A:kd=\E[B:kr=\E[C:kl=\E[D:\
+ :k1=\E[224z:k2=\E[225z:k3=\E[226z:k4=\E[227z:k5=\E[228z:\
+ :k6=\E[229z:k7=\E[230z:k8=\E[231z:k9=\E[232z:\
+
+M+|sun-cmd|Sun Microsystems Workstation console with scrollable history:\
+ :te=\E[>4h:ti=\E[>4l:tc=sun:\
+
+M-|sun-e|sun-nic|sune|Sun Microsystems Workstation without insert character:\
+ :ic@:im@:ei@:tc=sun:
+Mu|sun-s|Sun Microsystems Workstation window with status line:\
+ :hs:ts=\E]l:fs=\E\\:ds=\E]l\E\\:tc=sun:
+Mu|sun-e-s|sun-s-e|Sun Microsystems Workstation with status hacked for emacs:\
+ :hs:ts=\E]l:fs=\E\\:ds=\E]l\E\\:tc=sun-e:
+M0|sun-48|Sun 48-line window:\
+ :li#48:co#80:tc=sun:
+M1|sun-34|Sun 34-line window:\
+ :li#34:co#80:tc=sun:
+M2|sun-24|Sun 24-line window:\
+ :li#24:co#80:tc=sun:
+M3|sun-17|Sun 17-line window:\
+ :li#17:co#80:tc=sun:
diff --git a/xc/programs/Xserver/hw/xfree86/etc/sun.tinfo b/xc/programs/Xserver/hw/xfree86/etc/sun.tinfo
new file mode 100644
index 000000000..016254705
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/sun.tinfo
@@ -0,0 +1,52 @@
+# $XConsortium: $
+# $XFree86: xc/programs/Xserver/hw/xfree86/etc/sun.tinfo,v 3.0 1994/06/05 05:57:21 dawes Exp $
+#
+sun|Sun Microsystems Workstation console,
+ am, km, mir, msgr, xon,
+ cols#80, lines#34,
+ bel=^G, clear=\f, cr=\r, cub1=\b, cud1=\n, cuf1=\E[C,
+ cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P, dl1=\E[M,
+ ed=\E[J, el=\E[K, ht=\t, ich1=\E[@, il1=\E[L, ind=\n,
+ kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
+ kf1=\E[224z, kf2=\E[225z, kf3=\E[226z, kf4=\E[227z,
+ kf5=\E[228z, kf6=\E[229z, kf7=\E[230z, kf8=\E[231z,
+ kf9=\E[232z, rmso=\E[m, rs2=\E[s, smso=\E[7m,
+
+sun-cmd|Sun Microsystems Workstation console with scrollable history,
+ rmcup=\E[>4h, smcup=\E[>4l,
+ use=sun,
+
+sun-e|sun-nic|sune|Sun Microsystems Workstation without insert character,
+ ich1@,
+ use=sun,
+sun|Sun Microsystems Workstation console,
+ am, km, mir, msgr, xon,
+ cols#80, lines#34,
+ bel=^G, clear=\f, cr=\r, cub1=\b, cud1=\n, cuf1=\E[C,
+ cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P, dl1=\E[M,
+ ed=\E[J, el=\E[K, ht=\t, ich1=\E[@, il1=\E[L, ind=\n,
+ kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
+ kf1=\E[224z, kf2=\E[225z, kf3=\E[226z, kf4=\E[227z,
+ kf5=\E[228z, kf6=\E[229z, kf7=\E[230z, kf8=\E[231z,
+ kf9=\E[232z, rmso=\E[m, rs2=\E[s, smso=\E[7m,
+sun|Sun Microsystems Workstation console,
+ am, km, mir, msgr, xon,
+ cols#80, lines#34,
+ bel=^G, clear=\f, cr=\r, cub1=\b, cud1=\n, cuf1=\E[C,
+ cup=\E[%i%p1%d;%p2%dH, cuu1=\E[A, dch1=\E[P, dl1=\E[M,
+ ed=\E[J, el=\E[K, ht=\t, ich1=\E[@, il1=\E[L, ind=\n,
+ kcub1=\E[D, kcud1=\E[B, kcuf1=\E[C, kcuu1=\E[A,
+ kf1=\E[224z, kf2=\E[225z, kf3=\E[226z, kf4=\E[227z,
+ kf5=\E[228z, kf6=\E[229z, kf7=\E[230z, kf8=\E[231z,
+ kf9=\E[232z, rmso=\E[m, rs2=\E[s, smso=\E[7m,
+sun-48|Sun 48-line window,
+ lines#48,
+ use=sun,
+sun-34|Sun 34-line window,
+ use=sun,
+sun-24|Sun 24-line window,
+ lines#24,
+ use=sun,
+sun-17|Sun 17-line window,
+ lines#17,
+ use=sun,
diff --git a/xc/programs/Xserver/hw/xfree86/etc/svr3_rem_pch b/xc/programs/Xserver/hw/xfree86/etc/svr3_rem_pch
new file mode 100644
index 000000000..8c3afae56
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/svr3_rem_pch
@@ -0,0 +1,121 @@
+#!/bin/sh
+######################################################################
+#
+# $XConsortium: $
+# $XFree86: xc/programs/Xserver/hw/xfree86/etc/svr3_rem_pch,v 3.0 1994/06/05 05:57:24 dawes Exp $
+#
+# Back out the patch to kernel that prevents losing IOPL on signals.
+#
+# Version 1.0 - 10/08/93
+# adapted for svr3 by Steve Forsythe (forsse@meaddata.com) from initial
+# svr4 version by David Wexelblat (dwex@goblin.org, dwex@aib.com)
+#
+
+N=`basename $0`
+
+#
+# Make sure we're running on SVR3!
+#
+uname -r | grep '3.2' > /dev/null
+if [ "$?" != "0" ]
+then
+ echo "$N: This only applies to SVR3!"
+ exit 1
+fi
+
+#
+# Next make sure we are running as root
+#
+id | grep 'uid=0' > /dev/null
+if [ "$?" != "0" ]
+then
+ echo "$N: Must be run as root!"
+ exit 1
+fi
+
+#
+# OK. Now undo the patch.
+#
+PACK=/etc/conf/pack.d/kernel
+BKUP=${PACK}/.xfree86
+if [ ! -d ${BKUP} ]
+then
+ echo "$N: Backup directory ${BKUP} does not exist!"
+ exit 1
+fi
+OWD=${PWD}
+cd ${BKUP}
+
+./patcher -c ../os.o
+if [ "$?" != "0" ]
+then
+ echo "$N: Patch not applied. Aborting"
+ cd ${OWD}
+ exit 1
+fi
+
+LOC=`./patcher -u ../os.o ./Nos.o`
+if [ "$?" != "0" ]
+then
+ echo "$N: Patch removal failed!!!"
+ cd ${OWD}
+ exit 1
+fi
+LOC1=`cmp -l ../os.o ./Nos.o | awk '{print $1; exit}'`
+if [ "$LOC" != "$LOC1" ]
+then
+ echo "$N: Patch sanity check failed!!!"
+ cd ${OWD}
+ exit 1
+fi
+echo "$N: Patch successfully removed. Installing unpatched module."
+mv ./Nos.o ../os.o
+
+#
+# OK. Patch is removed. Now do an idbuild
+#
+echo "$N: Building the new kernel."
+/etc/conf/bin/idbuild 2>/tmp/idb.$$
+if [ "$?" != "0" ]
+then
+ echo "$N: Kernel build failed! Errors are in /tmp/idb.$$"
+ cd ${OWD}
+ exit 1
+fi
+rm -f /tmp/idb.$$
+
+#
+# Kernel is now rebuilt.
+#
+echo "$N: Kernel successfully rebuilt."
+cd ${OWD}
+rm -fr ${BKUP}
+
+#
+# Kernel is now rebuilt. Check if we should reboot now.
+#
+REBOOT=0
+echo "$N: You must reboot before patch takes effect. Reboot now? \c"
+read RESP
+case ${RESP} in
+ [yY]*)
+ REBOOT=1
+ ;;
+ *)
+ echo "$N: OK. But remember to reboot later"
+ ;;
+esac
+
+cd ${OWD}
+rm -fr ${BKUP}
+#
+# All done. Reboot if necessary
+#
+if [ ${REBOOT} = "1" ]
+then
+ cd /
+ sync
+ /etc/shutdown -i6 -g15 -y &
+fi
+exit 0
+######################################################################
diff --git a/xc/programs/Xserver/hw/xfree86/etc/svr4_rem_pch b/xc/programs/Xserver/hw/xfree86/etc/svr4_rem_pch
new file mode 100644
index 000000000..a1363d312
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/svr4_rem_pch
@@ -0,0 +1,120 @@
+#!/bin/sh
+######################################################################
+#
+# $XConsortium: $
+# $XFree86: xc/programs/Xserver/hw/xfree86/etc/svr4_rem_pch,v 3.0 1994/06/05 05:57:26 dawes Exp $
+#
+# Back out the patch to kernel that prevents losing IOPL on signals.
+#
+# Version 1.0 - 11/18/92
+# initial version - dwex@goblin.org, dwex@aib.com
+#
+
+N=`basename $0`
+
+#
+# Make sure we're running on SVR4!
+#
+uname -r | grep '4' > /dev/null
+if [ "$?" != "0" ]
+then
+ echo "$N: This only applies to SVR4!"
+ exit 1
+fi
+
+#
+# Next make sure we are running as root
+#
+id | grep 'uid=0' > /dev/null
+if [ "$?" != "0" ]
+then
+ echo "$N: Must be run as root!"
+ exit 1
+fi
+
+#
+# OK. Now undo the patch.
+#
+PACK=/etc/conf/pack.d/kernel
+BKUP=${PACK}/.xfree86
+if [ ! -d ${BKUP} ]
+then
+ echo "$N: Backup directory ${BKUP} does not exist!"
+ exit 1
+fi
+OWD=${PWD}
+cd ${BKUP}
+
+./patcher -c ../os.o
+if [ "$?" != "0" ]
+then
+ echo "$N: Patch not applied. Aborting"
+ cd ${OWD}
+ exit 1
+fi
+
+LOC=`./patcher -u ../os.o ./Nos.o`
+if [ "$?" != "0" ]
+then
+ echo "$N: Patch removal failed!!!"
+ cd ${OWD}
+ exit 1
+fi
+LOC1=`cmp -l ../os.o ./Nos.o | awk '{print $1; exit}'`
+if [ "$LOC" != "$LOC1" ]
+then
+ echo "$N: Patch sanity check failed!!!"
+ cd ${OWD}
+ exit 1
+fi
+echo "$N: Patch successfully removed. Installing unpatched module."
+mv ./Nos.o ../os.o
+
+#
+# OK. Patch is removed. Now do an idbuild
+#
+echo "$N: Building the new kernel."
+/etc/conf/bin/idbuild 2>/tmp/idb.$$
+if [ "$?" != "0" ]
+then
+ echo "$N: Kernel build failed! Errors are in /tmp/idb.$$"
+ cd ${OWD}
+ exit 1
+fi
+rm -f /tmp/idb.$$
+
+#
+# Kernel is now rebuilt.
+#
+echo "$N: Kernel successfully rebuilt."
+cd ${OWD}
+rm -rf ${BKUP}
+
+#
+# Kernel is now rebuilt. Check if we should reboot now.
+#
+REBOOT=0
+echo "$N: You must reboot before patch takes effect. Reboot now? \c"
+read RESP
+case ${RESP} in
+ [yY]*)
+ REBOOT=1
+ ;;
+ *)
+ echo "$N: OK. But remember to reboot later"
+ ;;
+esac
+
+cd ${OWD}
+rm -rf ${BKUP}
+#
+# All done. Reboot if necessary
+#
+if [ ${REBOOT} = "1" ]
+then
+ cd /
+ sync
+ /usr/sbin/shutdown -i6 -g15 -y &
+fi
+exit 0
+######################################################################
diff --git a/xc/programs/Xserver/hw/xfree86/vga16/ibm/ppcPixFS.c b/xc/programs/Xserver/hw/xfree86/vga16/ibm/ppcPixFS.c
new file mode 100644
index 000000000..2668c28fc
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/vga16/ibm/ppcPixFS.c
@@ -0,0 +1,506 @@
+/* $XConsortium: ppcPixmapFS.c,v 1.2 94/04/17 20:31:53 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/vga16/ibm/ppcPixFS.c,v 3.0 1994/05/04 15:03:29 dawes Exp $ */
+/*
+ * Copyright IBM Corporation 1987,1988,1989
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of IBM not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+*/
+
+/******************************************************************
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* Header: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/ppcPixmapFS.c,v 1.2 89/04/29 22:13:30 jeff Exp */
+/* Source: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/ppcPixmapFS.c,v */
+
+#include "X.h"
+#include "misc.h"
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+#include "maskbits.h"
+
+#include "OScompiler.h"
+
+#include "ppc.h"
+#include "ppcSpMcro.h"
+
+#include "ibmTrace.h"
+extern int mfbGCPrivateIndex;
+
+#define LeftMostBitInScreenLongWord SCRLEFT( 0xFFFFFFFF, 31 )
+
+/* GJA -- copied this from VGA */
+#define SCRLEFT8(lw, n) ( (unsigned char) (((unsigned char) lw) << (n)) )
+#define SCRRIGHT8(lw, n) ( (unsigned char) (((unsigned char)lw) >> (n)) )
+/*
+********** ********** ********** ********** ********** ********** **********
+ these routines all clip. they assume that anything that has called
+them has already translated the points (i.e. pGC->miTranslate is
+non-zero, which is howit gets set in mfbCreateGC().)
+
+ the number of new scnalines created by clipping ==
+MaxRectsPerBand * nSpans.
+********** ********** ********** ********** ********** ********** **********
+*/
+/* A mod definition that goes smoothly into the negative.
+ */
+int mod(n1,n2)
+int n1, n2;
+{
+ int tmp;
+ if ( n1 < 0 ) {
+ tmp = (-n1) % n2;
+ if ( tmp == 0 ) {
+ return 0;
+ } else {
+ return n2 - tmp;
+ }
+ } else {
+ return n1 % n2;
+ }
+}
+
+void
+ppcSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
+ DrawablePtr pDrawable ;
+ GCPtr pGC ;
+ int nInit ; /* number of spans to fill */
+ DDXPointPtr pptInit ; /* pointer to list of start points */
+ int *pwidthInit ; /* pointer to list of n widths */
+ int fSorted ;
+{
+ register unsigned long int pm, npm ;
+ register unsigned long int fg ;
+ register int alu ;
+ /* next three parameters are post-clip */
+ int n ; /* number of spans to fill */
+ register DDXPointPtr ppt ; /* pointer to list of start points */
+ register int *pwidth ; /* pointer to list of n widths */
+ register unsigned char *addrl ; /* pointer to current longword in bitmap */
+ int i ;
+ int *pwidthFree ; /* copies of the pointers to free */
+ DDXPointPtr pptFree ;
+
+ TRACE(("ppcSolidPixmapFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n", pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
+
+ if ( pDrawable->type != DRAWABLE_PIXMAP ) {
+ ErrorF("ppcSolidPixmapFS: drawable is not a pixmap\n") ;
+ return ;
+ }
+
+ if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop )
+ return ;
+
+ n = nInit * miFindMaxBand( ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->pCompositeClip) ;
+ if ( !( pwidth = (int *) ALLOCATE_LOCAL( n * sizeof( int ) ) ) )
+ return ;
+ pwidthFree = pwidth ;
+
+ if ( !( ppt = (DDXPointRec *)
+ ALLOCATE_LOCAL( n * sizeof( DDXPointRec ) ) ) ) {
+ DEALLOCATE_LOCAL( pwidth ) ;
+ return ;
+ }
+ pptFree = ppt ;
+
+ n = miClipSpans( ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->pCompositeClip,
+ pptInit, pwidthInit, nInit, ppt, pwidth, fSorted ) ;
+
+ pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ;
+ npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
+
+ for ( ; n-- ; ppt++, pwidth++ ) {
+ addrl = ( (unsigned char *) ( ( (PixmapPtr) pDrawable )->devPrivate.ptr ) )
+ + ( ppt->y * ( (int) ( ( (PixmapPtr) pDrawable )->devKind ) ) )
+ + ppt->x ;
+ for ( i = *pwidth ; i-- ; addrl++ )
+ {
+ unsigned _p;
+ DoRop( _p, alu, fg, *addrl );
+ *addrl = ( *addrl & npm ) | ( pm & _p ) ;
+ }
+#ifdef notdef /* PURDUE */
+ *addrl = ( *addrl & npm ) | ( pm & DoRop( alu, fg, *addrl ) ) ;
+#endif /* PURDUE */
+ }
+ DEALLOCATE_LOCAL( pptFree ) ;
+ DEALLOCATE_LOCAL( pwidthFree ) ;
+ return ;
+}
+
+/* GJA -- copied from vgaStipple.c */
+static unsigned char
+vgagetbits( x, patternWidth, lineptr )
+register const int x ;
+register const unsigned int patternWidth ;
+register const unsigned char * const lineptr ;
+{
+register unsigned char bits ;
+register const unsigned char *cptr ;
+register shift ;
+register wrap ;
+
+cptr = lineptr + ( x >> 3 ) ;
+bits = *cptr ;
+if ( shift = x & 7 )
+ bits = SCRLEFT8( bits, shift ) | SCRRIGHT8( cptr[1], ( 8 - shift ) ) ;
+if ( ( wrap = x + 8 - patternWidth ) > 0 ) {
+ bits &= SCRLEFT8( 0xFF, wrap ) ;
+ bits |= SCRRIGHT8( *lineptr, ( 8 - wrap ) ) ;
+}
+
+/* GJA -- Handle extraction of 8 bits from < 8 bits wide stipple.
+ * I duplicated case 4,5,6,7 to give the compiler a chance to optimize.
+ */
+switch (patternWidth) {
+case 1: /* Not really useful. */
+ bits &= ~SCRRIGHT8(0xFF,1);
+ bits |= SCRRIGHT8(bits,1);
+ bits |= SCRRIGHT8(bits,2);
+ bits |= SCRRIGHT8(bits,4);
+ break;
+case 2:
+ bits &= ~SCRRIGHT8(0xFF,2);
+ bits |= SCRRIGHT8(bits,2); bits |= SCRRIGHT8(bits,4); break;
+case 3:
+ bits &= ~SCRRIGHT8(0xFF,3);
+ bits |= (SCRRIGHT8(bits,3) | SCRRIGHT8(bits,6)); break;
+case 4:
+ bits = (bits & ~SCRRIGHT8(0xFF,4)) | SCRRIGHT8(bits,4); break;
+case 5:
+ bits = (bits & ~SCRRIGHT8(0xFF,5)) | SCRRIGHT8(bits,5); break;
+case 6:
+ bits = (bits & ~SCRRIGHT8(0xFF,6)) | SCRRIGHT8(bits,6); break;
+case 7:
+ bits = (bits & ~SCRRIGHT8(0xFF,7)) | SCRRIGHT8(bits,7); break;
+default:
+ ;
+ /* Do nothing, of course */
+}
+
+return bits ;
+}
+
+void
+ppcStipplePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
+register DrawablePtr pDrawable ;
+GC *pGC ;
+int nInit ; /* number of spans to fill */
+DDXPointPtr pptInit ; /* pointer to list of start points */
+int *pwidthInit ; /* pointer to list of n widths */
+int fSorted ;
+{
+ register unsigned char *pdst ; /* pointer to current word in bitmap */
+ register int *psrc ; /* pointer to current word in tile */
+ register unsigned long int pm, npm ;
+ register unsigned long int fg ;
+ register int alu ;
+ /* next three parameters are post-clip */
+ int n ; /* number of spans to fill */
+ register DDXPointPtr ppt ; /* pointer to list of start points */
+ register int *pwidth ; /* pointer to list of n widths */
+ PixmapPtr pTile ; /* pointer to tile we want to fill with */
+ int width, x, xSrc, ySrc ;
+ int tlwidth, tileWidth ;
+ unsigned char *psrcT ;
+ int *pwidthFree ; /* copies of the pointers to free */
+ DDXPointPtr pptFree ;
+ int xoff, count, stip, i ;
+
+ TRACE(("ppcStipplePixmapFS(pDrawable=0x%x, pGC=0x%x, nInit=%d, pptInit=0x%x, pwidthInit=0x%x, fSorted=%d)\n",
+ pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)) ;
+
+ if ( pDrawable->type != DRAWABLE_PIXMAP ) {
+ ErrorF( "ppcStippleWindowFS: drawable is not a pixmap\n") ;
+ return ;
+ }
+ if ( pGC->stipple->drawable.depth != 1 ) {
+ ErrorF( "ppcStippleFS: bad depth\ntype = %d, depth = %d\n",
+ pDrawable->type, pGC->stipple->drawable.depth ) ;
+ return ;
+ }
+
+ if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop )
+ return ;
+
+ SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit,
+ ppt, pwidthFree, pptFree, fSorted ) ;
+
+ pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ;
+
+ pTile = pGC->stipple ;
+ tlwidth = pTile->devKind ;
+
+ tileWidth = pTile->drawable.width ;
+
+ npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
+
+ /* this replaces rotating the stipple. Instead, we just adjust the offset
+ * at which we start grabbing bits from the stipple */
+ xSrc = pGC->patOrg.x + pDrawable->x;
+ ySrc = pGC->patOrg.y + pDrawable->y;
+
+ while ( n-- ) {
+ pdst = ( (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr )
+ + ( ppt->y * ( (int) ( ( (PixmapPtr) pDrawable )->devKind ) ) )
+ + ppt->x ;
+ psrcT = (unsigned char *)pTile->devPrivate.ptr
+ + ( mod( ppt->y - ySrc, pTile->drawable.height ) * tlwidth ) ;
+ x = ppt->x ;
+
+ xoff = mod( x - xSrc, tileWidth) ;
+ for ( width = *pwidth ; width ; psrc++, width -= count, xoff+=count ) {
+
+ if ( xoff >= tileWidth ) xoff -= tileWidth;
+
+ if ( width < 8 )
+ count = width;
+ else
+ count = 8;
+
+ stip = vgagetbits( xoff, tileWidth, psrcT ) ;
+
+ for ( i = count ; i-- ; ) {
+ if ( stip & 128 )
+ {
+ unsigned _p;
+ DoRop( _p, alu, fg, *pdst ) ;
+ *pdst = ( *pdst & npm ) | ( pm & _p ) ;
+ }
+#ifdef notdef /* PURDUE */
+ *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, fg, *pdst ) ) ;
+#endif /* PURDUE */
+ pdst++ ;
+ stip = SCRLEFT( stip, 1 ) ;
+ }
+ }
+ ppt++ ;
+ pwidth++ ;
+ }
+ DEALLOCATE_LOCAL( pptFree ) ;
+ DEALLOCATE_LOCAL( pwidthFree ) ;
+ return ;
+}
+
+void
+ppcOpStipplePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
+DrawablePtr pDrawable ;
+GC *pGC ;
+int nInit ; /* number of spans to fill */
+DDXPointPtr pptInit ; /* pointer to list of start points */
+int *pwidthInit ; /* pointer to list of n widths */
+int fSorted ;
+{
+ register unsigned char *pdst ; /* pointer to current word in bitmap */
+ register unsigned long int pm, npm ;
+ register unsigned long int fg, bg ;
+ register int alu ;
+ /* next three parameters are post-clip */
+ int n ; /* number of spans to fill */
+ register DDXPointPtr ppt ; /* pointer to list of start points */
+ register int *pwidth ; /* pointer to list of n widths */
+ register int *psrc ; /* pointer to current word in tile */
+ PixmapPtr pTile ; /* pointer to tile we want to fill with */
+ int width ;
+ int xSrc, ySrc ;
+ int tlwidth, tileWidth ;
+ unsigned char *psrcT ;
+ int *pwidthFree ; /* copies of the pointers to free */
+ DDXPointPtr pptFree ;
+ int xoff, count, stip, i ;
+
+ TRACE( ( "ppcOpStipplePixmapFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n",
+ pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ;
+
+ if ( pGC->stipple->drawable.depth != 1 ) {
+ ErrorF( "ppcOpStipplePixmapFS: bad depth\ntype = %d, depth = %d\n",
+ pDrawable->type, pGC->stipple->drawable.depth ) ;
+ return ;
+ }
+
+ if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop )
+ return ;
+
+ SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit,
+ ppt, pwidthFree, pptFree, fSorted ) ;
+
+ fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ;
+ bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.bgPixel ;
+ pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
+ npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
+
+ pTile = pGC->stipple ;
+ tlwidth = pTile->devKind ;
+ tileWidth = pTile->drawable.width ;
+
+ xSrc = pGC->patOrg.x + pDrawable->x;
+ ySrc = pGC->patOrg.y + pDrawable->y;
+
+ /* this replaces rotating the stipple. Instead, we just adjust the offset
+ * at which we start grabbing bits from the stipple */
+ for ( ; n-- ; ppt++, pwidth++ ) {
+ pdst = ( (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr )
+ + ( ppt->y * ( (int) ( (PixmapPtr) pDrawable )->devKind ) )
+ + ppt->x ;
+ psrcT = (unsigned char *)pTile->devPrivate.ptr
+ + ( mod( ppt->y - ySrc, pTile->drawable.height ) * tlwidth ) ;
+
+ xoff = mod( ppt->x - xSrc, tileWidth) ;
+
+ for ( width = *pwidth ; width ; psrc++, width -= count, xoff+=count ) {
+
+ if ( xoff >= tileWidth ) xoff -= tileWidth;
+
+ if ( width < 8 )
+ count = width;
+ else
+ count = 8;
+
+ stip = vgagetbits( xoff, tileWidth, psrcT ) ;
+ for ( i = count ; i-- ; pdst++, stip = SCRLEFT( stip, 1 ) )
+ if ( stip & 128 )
+ {
+ unsigned _p;
+ DoRop( _p, alu, fg, *pdst ) ;
+ *pdst = ( *pdst & npm ) | ( pm & _p ) ;
+ }
+#ifdef notdef /* PURDUE */
+ *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, fg, *pdst ) ) ;
+#endif /* PURDUE */
+ else
+ {
+ unsigned _p;
+ DoRop( _p, alu, bg, *pdst ) ;
+ *pdst = ( *pdst & npm ) | ( pm & _p ) ;
+ }
+#ifdef notdef /* PURDUE */
+ *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, bg, *pdst ) ) ;
+#endif /* PURDUE */
+ }
+ }
+ DEALLOCATE_LOCAL( pptFree ) ;
+ DEALLOCATE_LOCAL( pwidthFree ) ;
+ return ;
+}
+
+void
+ppcTilePixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
+register DrawablePtr pDrawable ;
+GC *pGC ;
+int nInit ; /* number of spans to fill */
+DDXPointPtr pptInit ; /* pointer to list of start points */
+int *pwidthInit ; /* pointer to list of n widths */
+int fSorted ;
+{
+ register DDXPointPtr ppt ; /* pointer to list of start points */
+ register int *pwidth ; /* pointer to list of n widths */
+ register unsigned char *pdst ; /* pointer to current word in bitmap */
+ register unsigned char *psrc ; /* pointer to current word in tile */
+ register PixmapPtr pTile ; /* pointer to tile we want to fill with */
+ int i ;
+ int alu ;
+ unsigned char pm, npm ;
+ /* next three parameters are post-clip */
+ int n ; /* number of spans to fill */
+ int tileWidth ;
+ int xSrc, ySrc;
+ unsigned char *psrcT ;
+ int *pwidthFree ; /* copies of the pointers to free */
+ DDXPointPtr pptFree ;
+
+ TRACE( ( "ppcTileFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n",
+ pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ;
+
+ if ( ( pDrawable->depth == 1 ) && ( pDrawable->type == DRAWABLE_PIXMAP ) ) {
+ mfbTileFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ;
+ return ;
+ }
+ if ( !ppcDepthOK( pDrawable, pGC->tile.pixmap->drawable.depth ) ) {
+ ErrorF( "ppcTileFS: bad depth\ntype = %d, depth = %d\n",
+ pDrawable->type, pDrawable->depth) ;
+ return ;
+ }
+
+ if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop )
+ return ;
+
+ SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit,
+ ppt, pwidthFree, pptFree, fSorted ) ;
+
+ /* the following code is for 8 bits per pixel addressable memory only */
+ pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
+ npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
+ pTile = pGC->tile.pixmap ;
+ tileWidth = pTile->drawable.width ;
+
+ xSrc = pGC->patOrg.x + pDrawable->x;
+ ySrc = pGC->patOrg.y + pDrawable->y;
+ /* this replaces rotating the tile. Instead we just adjust the offset
+ * at which we start grabbing bits from the tile */
+ for ( ; n-- ; ppt++, pwidth++ ) {
+ pdst = ( (unsigned char *) ( (PixmapPtr) pDrawable )->devPrivate.ptr )
+ + ( ppt->y * ( (int) ( (PixmapPtr) pDrawable )->devKind ) )
+ + ppt->x ;
+ psrcT = (unsigned char *) pTile->devPrivate.ptr
+ + ( mod( ppt->y - ySrc, pTile->drawable.height) * pTile->devKind ) ;
+
+ psrc = psrcT + mod( ppt->x - xSrc, tileWidth ) ;
+ for ( i = *pwidth ; i-- ; pdst++, psrc++ ) {
+ if ( psrc >= ( psrcT + tileWidth ) )
+ psrc = psrcT ;
+ {
+ unsigned _p;
+ DoRop( _p, alu, *psrc, *pdst ) ;
+ *pdst = ( *pdst & npm ) | ( pm & _p ) ;
+ }
+#ifdef notdef /* PURDUE */
+ *pdst = ( *pdst & npm ) | ( pm & DoRop( alu, *psrc, *pdst ) ) ;
+#endif /* PURDUE */
+ }
+ }
+ DEALLOCATE_LOCAL( pptFree ) ;
+ DEALLOCATE_LOCAL( pwidthFree ) ;
+ return ;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/vga16/ibm/ppcWinFS.c b/xc/programs/Xserver/hw/xfree86/vga16/ibm/ppcWinFS.c
new file mode 100644
index 000000000..bcc5e7712
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/vga16/ibm/ppcWinFS.c
@@ -0,0 +1,290 @@
+/* $XConsortium: ppcWindowFS.c,v 1.2 94/04/17 20:31:58 dpw Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/vga16/ibm/ppcWinFS.c,v 3.0 1994/05/04 15:03:40 dawes Exp $ */
+/*
+ * Copyright IBM Corporation 1987,1988,1989
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * provided that the above copyright notice appear in all copies and that
+ * both that copyright notice and this permission notice appear in
+ * supporting documentation, and that the name of IBM not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+*/
+
+/******************************************************************
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/* Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcWindowFS.c,v 1.1 89/05/07 15:23:36 jeff Exp */
+/* Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcWindowFS.c,v */
+
+#include "X.h"
+#include "misc.h"
+#include "gcstruct.h"
+#include "window.h"
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+#include "maskbits.h"
+
+#include "OScompiler.h"
+
+#include "ppc.h"
+#include "ppcSpMcro.h"
+
+#include "ibmTrace.h"
+extern int mfbGCPrivateIndex;
+
+#define LeftMostBitInScreenLongWord SCRLEFT( 0xFFFFFFFF, 31 )
+/*
+********** ********** ********** ********** ********** ********** **********
+ these routines all clip. they assume that anything that has called
+them has already translated the points (i.e. pGC->miTranslate is
+non-zero, which is howit gets set in mfbCreateGC().)
+
+ the number of new scanlines created by clipping ==
+MaxRectsPerBand * nSpans.
+********** ********** ********** ********** ********** ********** **********
+*/
+
+void
+ppcSolidWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
+ DrawablePtr pDrawable ;
+ GCPtr pGC ;
+ int nInit ; /* number of spans to fill */
+ DDXPointPtr pptInit ; /* pointer to list of start points */
+ int *pwidthInit ; /* pointer to list of n widths */
+ int fSorted ;
+{
+ register unsigned long int pm ;
+ register unsigned long int fg ;
+ register int alu ;
+ /* next three parameters are post-clip */
+ int n ; /* number of spans to fill */
+ register DDXPointPtr ppt ; /* pointer to list of start points */
+ register int *pwidth ; /* pointer to list of n widths */
+ int *pwidthFree ; /* copies of the pointers to free */
+ DDXPointPtr pptFree ;
+
+ TRACE( ( "ppcSolidWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n",
+ pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ;
+
+ if ( pDrawable->type != DRAWABLE_WINDOW ) {
+ ErrorF( "ppcSolidWindowFS: drawable is not a window\n") ;
+ return ;
+ }
+
+ if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop )
+ return ;
+
+ n = nInit * miFindMaxBand( ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->pCompositeClip ) ;
+ if ( !( pwidth = (int *) ALLOCATE_LOCAL( n * sizeof( int ) ) ) )
+ return ;
+ pwidthFree = pwidth ;
+
+ if ( !( ppt = (DDXPointRec *)
+ ALLOCATE_LOCAL( n * sizeof( DDXPointRec ) ) ) ) {
+ DEALLOCATE_LOCAL( pwidth ) ;
+ return ;
+ }
+ pptFree = ppt ;
+
+ n = miClipSpans( ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->pCompositeClip,
+ pptInit, pwidthInit, nInit, ppt, pwidth, fSorted ) ;
+
+ pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ;
+
+ for ( ; n-- ; ppt++, pwidth++ )
+ if ( *pwidth )
+ vgaFillSolid( (WindowPtr)pDrawable,
+ fg, alu, pm, ppt->x, ppt->y, *pwidth, 1 ) ;
+
+ DEALLOCATE_LOCAL( pptFree ) ;
+ DEALLOCATE_LOCAL( pwidthFree ) ;
+ return ;
+}
+
+void
+ppcStippleWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
+DrawablePtr pDrawable ;
+register GC *pGC ;
+int nInit ; /* number of spans to fill */
+DDXPointPtr pptInit ; /* pointer to list of start points */
+int *pwidthInit ; /* pointer to list of n widths */
+int fSorted ;
+{
+ register unsigned long int pm ;
+ register unsigned long int fg ;
+ register int alu ;
+ /* next three parameters are post-clip */
+ int n ; /* number of spans to fill */
+ register DDXPointPtr ppt ; /* pointer to list of start points */
+ register int *pwidth ; /* pointer to list of n widths */
+ PixmapPtr pTile ; /* pointer to tile we want to fill with */
+ int xSrc ;
+ int ySrc ;
+ int *pwidthFree ; /* copies of the pointers to free */
+ DDXPointPtr pptFree ;
+
+ TRACE( ( "ppcStippleWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n",
+ pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ;
+
+ if ( pDrawable->type != DRAWABLE_WINDOW ) {
+ ErrorF( "ppcStippleWindowFS: drawable is not a window\n" ) ;
+ return ;
+ }
+
+ if ( pGC->stipple->drawable.depth != 1 ) {
+ ErrorF("ppcStippleFS: bad depth\ntype = %d, depth = %d\n",
+ pDrawable->type, pGC->stipple->drawable.depth ) ;
+ return ;
+ }
+
+ if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop )
+ return ;
+
+ SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit,
+ ppt, pwidthFree, pptFree, fSorted ) ;
+
+ pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ;
+
+ xSrc = pGC->patOrg.x + pDrawable->x ;
+ ySrc = pGC->patOrg.y + pDrawable->y ;
+ pTile = pGC->stipple ;
+
+ for ( ; n-- ; ppt++, pwidth++ )
+ vgaFillStipple( (WindowPtr)pDrawable, pTile, fg, alu, pm,
+ ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ;
+
+ DEALLOCATE_LOCAL( pptFree ) ;
+ DEALLOCATE_LOCAL( pwidthFree ) ;
+
+ return ;
+}
+
+void
+ppcOpStippleWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
+DrawablePtr pDrawable ;
+register GC *pGC ;
+int nInit ; /* number of spans to fill */
+DDXPointPtr pptInit ; /* pointer to list of start points */
+int *pwidthInit ; /* pointer to list of n widths */
+int fSorted ;
+{
+ register DDXPointPtr ppt ; /* pointer to list of start points */
+ register int *pwidth ; /* pointer to list of n widths */
+ int n ; /* number of spans to fill */
+ int xSrc ;
+ int ySrc ;
+ unsigned long int pm ;
+ unsigned long int fg, bg ;
+ int alu ;
+ int *pwidthFree ; /* copies of the pointers to free */
+ DDXPointPtr pptFree ;
+
+ TRACE( ( "ppcOpStippleWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n",
+ pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ;
+
+ if ( pGC->stipple->drawable.depth != 1 ) {
+ ErrorF( "ppcOpStippleWindowFS: bad depth\ntype = %d, depth = %d\n",
+ pDrawable->type, pGC->stipple->drawable.depth ) ;
+ return ;
+ }
+
+ if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop )
+ return ;
+
+ SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit,
+ ppt, pwidthFree, pptFree, fSorted ) ;
+
+ pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ;
+ bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.bgPixel ;
+
+ xSrc = pGC->patOrg.x + pDrawable->x ;
+ ySrc = pGC->patOrg.y + pDrawable->y ;
+
+ for ( ; n-- ; ppt++, pwidth++ )
+ ppcOpaqueStipple( (WindowPtr)pDrawable, pGC->stipple, fg, bg, alu, pm,
+ ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ;
+
+ DEALLOCATE_LOCAL( pptFree ) ;
+ DEALLOCATE_LOCAL( pwidthFree ) ;
+ return ;
+}
+
+void
+ppcTileWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
+DrawablePtr pDrawable ;
+register GC *pGC ;
+int nInit ; /* number of spans to fill */
+DDXPointPtr pptInit ; /* pointer to list of start points */
+int *pwidthInit ; /* pointer to list of n widths */
+int fSorted ;
+{
+ /* next three parameters are post-clip */
+ register DDXPointPtr ppt ; /* pointer to list of start points */
+ register int *pwidth ; /* pointer to list of n widths */
+ int n ; /* number of spans to fill */
+ unsigned char pm ;
+ int alu ;
+ int xSrc ;
+ int ySrc ;
+ int *pwidthFree ; /* copies of the pointers to free */
+ DDXPointPtr pptFree ;
+
+ TRACE( ( "ppcTileWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n",
+ pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ;
+
+ if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu ) == GXnoop )
+ return ;
+
+ SETSPANPTRS( nInit, n, pwidthInit, pwidth, pptInit,
+ ppt, pwidthFree, pptFree, fSorted ) ;
+
+ xSrc = pGC->patOrg.x + pDrawable->x ;
+ ySrc = pGC->patOrg.y + pDrawable->y ;
+ pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
+
+ for ( ; n-- ; ppt++, pwidth++ )
+ ppcTileRect( (WindowPtr)pDrawable, pGC->tile.pixmap, alu, pm,
+ ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ;
+
+ DEALLOCATE_LOCAL( pptFree ) ;
+ DEALLOCATE_LOCAL( pwidthFree ) ;
+ return ;
+}