summaryrefslogtreecommitdiff
path: root/hw/kdrive/igs
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2000-05-06 22:17:53 +0000
committerKeith Packard <keithp@keithp.com>2000-05-06 22:17:53 +0000
commit3731c184d69e3c1face0c731926433d522d48067 (patch)
tree687fa152bbb27d72d12e64b248f71b255311d087 /hw/kdrive/igs
parent4b54f22b6accf438f31fbbe79877545c38375351 (diff)
Lots of Tiny-X changes:
Add overlay support in the Tiny-X Savage4 driver (required changing lots of Tiny-X code). Savage4 now support 8/16, 8/32 overlays. Add IGS Cyberpro 5050 driver. This chip has bus support for embeded systems.
Diffstat (limited to 'hw/kdrive/igs')
-rw-r--r--hw/kdrive/igs/Imakefile14
-rw-r--r--hw/kdrive/igs/igs.c201
-rw-r--r--hw/kdrive/igs/igs.h244
-rw-r--r--hw/kdrive/igs/igsdraw.c1114
-rw-r--r--hw/kdrive/igs/igsdraw.h188
-rw-r--r--hw/kdrive/igs/igsstub.c57
6 files changed, 1818 insertions, 0 deletions
diff --git a/hw/kdrive/igs/Imakefile b/hw/kdrive/igs/Imakefile
new file mode 100644
index 000000000..05d1e1c76
--- /dev/null
+++ b/hw/kdrive/igs/Imakefile
@@ -0,0 +1,14 @@
+XCOMM $XFree86$
+#include <Server.tmpl>
+
+SRCS = igs.c igsdraw.c igsstub.c
+
+OBJS = igs.o igsdraw.o igsstub.o
+
+INCLUDES = -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
+ -I../../../fb -I../../../mi -I../../../include -I../../../os \
+ -I$(EXTINCSRC) -I$(XINCLUDESRC)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(igs,$(OBJS))
+DependTarget()
diff --git a/hw/kdrive/igs/igs.c b/hw/kdrive/igs/igs.c
new file mode 100644
index 000000000..62b31af48
--- /dev/null
+++ b/hw/kdrive/igs/igs.c
@@ -0,0 +1,201 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 1999 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#include "igs.h"
+
+Bool
+igsCardInit (KdCardInfo *card)
+{
+ int k;
+ char *pixels;
+ IgsCardInfo *igsc;
+
+ igsc = (IgsCardInfo *) xalloc (sizeof (IgsCardInfo));
+ if (!igsc)
+ return FALSE;
+
+ memset (igsc, '\0', sizeof (IgsCardInfo));
+
+ igsc->frameBuffer = (CARD8 *) KdMapDevice (card->attr.address[0],
+ 4096 * 1024);
+
+ igsc->cop = (Cop5xxx *) KdMapDevice (card->attr.address[0] +
+ IGS_COP_OFFSET,
+ sizeof (Cop5xxx));
+
+ igsc->copData = (VOL32 *) KdMapDevice (card->attr.address[0] +
+ IGS_COP_DATA,
+ IGS_COP_DATA_LEN);
+
+ card->driver = igsc;
+
+ return TRUE;
+}
+
+Bool
+igsScreenInit (KdScreenInfo *screen)
+{
+ IgsCardInfo *igsc = screen->card->driver;
+ int fb = 0;
+
+ if (screen->fb[fb].depth >= 24)
+ {
+ screen->fb[fb].depth = 24;
+ if (screen->fb[fb].bitsPerPixel != 24)
+ screen->fb[fb].bitsPerPixel = 32;
+ }
+ else if (screen->fb[fb].depth >= 16)
+ {
+ screen->fb[fb].depth = 16;
+ screen->fb[fb].bitsPerPixel = 16;
+ }
+ else if (screen->fb[fb].depth >= 15)
+ {
+ screen->fb[fb].depth = 15;
+ screen->fb[fb].bitsPerPixel = 16;
+ }
+ else
+ {
+ screen->fb[fb].depth = 8;
+ screen->fb[fb].bitsPerPixel = 8;
+ }
+ switch (screen->fb[fb].depth) {
+ case 8:
+ screen->fb[fb].visuals = ((1 << StaticGray) |
+ (1 << GrayScale) |
+ (1 << StaticColor) |
+ (1 << PseudoColor) |
+ (1 << TrueColor) |
+ (1 << DirectColor));
+ screen->fb[fb].blueMask = 0x00;
+ screen->fb[fb].greenMask = 0x00;
+ screen->fb[fb].redMask = 0x00;
+ break;
+ case 15:
+ screen->fb[fb].visuals = (1 << TrueColor);
+ screen->fb[fb].blueMask = 0x001f;
+ screen->fb[fb].greenMask = 0x03e0;
+ screen->fb[fb].redMask = 0x7c00;
+ break;
+ case 16:
+ screen->fb[fb].visuals = (1 << TrueColor);
+ screen->fb[fb].blueMask = 0x001f;
+ screen->fb[fb].greenMask = 0x07e0;
+ screen->fb[fb].redMask = 0xf800;
+ break;
+ case 24:
+ screen->fb[fb].visuals = (1 << TrueColor);
+ screen->fb[fb].blueMask = 0x0000ff;
+ screen->fb[fb].greenMask = 0x00ff00;
+ screen->fb[fb].redMask = 0xff0000;
+ break;
+ }
+ screen->fb[fb].pixelStride = screen->width;
+ screen->fb[fb].byteStride = screen->width * (screen->fb[fb].bitsPerPixel >> 3);
+ screen->fb[fb].frameBuffer = igsc->frameBuffer;
+ if (!igsc->cop)
+ screen->dumb = TRUE;
+ return TRUE;
+}
+
+Bool
+igsInitScreen(ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+void
+igsPreserve (KdCardInfo *card)
+{
+}
+
+void
+igsEnable (ScreenPtr pScreen)
+{
+}
+
+Bool
+igsDPMS (ScreenPtr pScreen, int mode)
+{
+ return TRUE;
+}
+
+void
+igsDisable (ScreenPtr pScreen)
+{
+}
+
+void
+igsRestore (KdCardInfo *card)
+{
+}
+
+void
+igsScreenFini (KdScreenInfo *screen)
+{
+}
+
+void
+igsCardFini (KdCardInfo *card)
+{
+ IgsCardInfo *igsc = card->driver;
+
+ if (igsc->copData)
+ KdUnmapDevice ((void *) igsc->copData, IGS_COP_DATA_LEN);
+ if (igsc->cop)
+ KdUnmapDevice (igsc->cop, sizeof (Cop5xxx));
+ if (igsc->frameBuffer)
+ KdUnmapDevice (igsc->frameBuffer, 4096 * 1024);
+ xfree (igsc);
+ card->driver = 0;
+}
+
+KdCardFuncs igsFuncs = {
+ igsCardInit, /* cardinit */
+ igsScreenInit, /* scrinit */
+ igsInitScreen,
+ igsPreserve, /* preserve */
+ igsEnable, /* enable */
+ igsDPMS, /* dpms */
+ igsDisable, /* disable */
+ igsRestore, /* restore */
+ igsScreenFini, /* scrfini */
+ igsCardFini, /* cardfini */
+
+ 0, /* initCursor */
+ 0, /* enableCursor */
+ 0, /* disableCursor */
+ 0, /* finiCursor */
+ 0, /* recolorCursor */
+
+ igsDrawInit, /* initAccel */
+ igsDrawEnable, /* enableAccel */
+ igsDrawSync, /* drawSync */
+ igsDrawDisable, /* disableAccel */
+ igsDrawFini, /* finiAccel */
+
+ 0, /* getColors */
+ 0, /* putColors */
+};
diff --git a/hw/kdrive/igs/igs.h b/hw/kdrive/igs/igs.h
new file mode 100644
index 000000000..9316ef249
--- /dev/null
+++ b/hw/kdrive/igs/igs.h
@@ -0,0 +1,244 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 1999 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _IGS_H_
+#define _IGS_H_
+
+#include "kdrive.h"
+
+extern KdCardFuncs igsFuncs;
+
+/*
+ * FB 0x00000000
+ * VGA 0x00800000
+ * Blt window 0x008a0000
+ * Coprocessor 0x008bf000
+ */
+
+#define IGS_COP_DATA 0x008a0000
+#define IGS_COP_DATA_LEN 0x00010000
+#define IGS_COP_OFFSET 0x008bf000
+
+typedef volatile CARD8 VOL8;
+typedef volatile CARD16 VOL16;
+typedef volatile CARD32 VOL32;
+
+typedef struct _Cop5xxx {
+ VOL8 pad000[0x11]; /* 0x000 */
+
+ VOL8 control; /* 0x011 */
+#define IGS_CONTROL_HBLTW_RDYZ 0x01
+#define IGS_CONTROL_MALLWBEPTZ 0x02
+#define IGS_CONTROL_CMDFF 0x04
+#define IGS_CONTROL_SOP 0x08
+#define IGS_CONTROL_OPS 0x10
+#define IGS_CONTROL_TER 0x20
+#define IGS_CONTROL_HBACKZ 0x40
+#define IGS_CONTROL_BUSY 0x80
+
+ VOL8 pad012[0x06]; /* 0x012 */
+
+ VOL32 src1_stride; /* 0x018 */
+
+ VOL32 format; /* 0x01c */
+
+#define IGS_FORMAT_8BPP 0
+#define IGS_FORMAT_16BPP 1
+#define IGS_FORMAT_24BPP 2
+#define IGS_FORMAT_32BPP 3
+
+ VOL32 bres_error; /* 0x020 */
+ VOL32 bres_k1; /* 0x024 */
+ VOL32 bres_k2; /* 0x028 */
+ VOL8 pad02c[0x1c]; /* 0x02c */
+
+ VOL32 mix; /* 0x048 */
+#define IGS_MIX_FG 0x00ff
+#define IGS_MIX_BG 0xff00
+#define IGS_MAKE_MIX(fg,bg) ((fg) | ((bg) << 8))
+
+#define IGS_MIX_ZERO 0x0
+#define IGS_MIX_SRC_AND_DST 0x1
+#define IGS_MIX_SRC_AND_NOT_DST 0x2
+#define IGS_MIX_SRC 0x3
+#define IGS_MIX_NOT_SRC_AND_DST 0x4
+#define IGS_MIX_DST 0x5
+#define IGS_MIX_SRC_XOR_DST 0x6
+#define IGS_MIX_SRC_OR_DST 0x7
+#define IGS_MIX_NOT_SRC_AND_NOT_DST 0x8
+#define IGS_MIX_SRC_XOR_NOT_DST 0x9
+#define IGS_MIX_NOT_DST 0xa
+#define IGS_MIX_SRC_OR_NOT_DST 0xb
+#define IGS_MIX_NOT_SRC 0xc
+#define IGS_MIX_NOT_SRC_OR_DST 0xd
+#define IGS_MIX_NOT_SRC_OR_NOT_DST 0xe
+#define IGS_MIX_ONE 0xf
+
+ VOL32 colorComp; /* 0x04c */
+ VOL32 planemask; /* 0x050 */
+
+ VOL8 pad054[0x4]; /* 0x054 */
+
+ VOL32 fg; /* 0x058 */
+ VOL32 bg; /* 0x05c */
+ VOL32 dim; /* 0x060 */
+#define IGS_MAKE_DIM(w,h) ((w) | ((h) << 16))
+ VOL8 pad5[0x0c]; /* 0x064 */
+
+ VOL32 src1_base_address; /* 0x070 */
+ VOL8 pad074[0x04]; /* 0x074 */
+
+ VOL16 dst_x_rotate; /* 0x078 */
+ VOL16 pat_y_rotate; /* 0x07a */
+ VOL32 operation; /* 0x07c */
+
+/* OCT[2:0] */
+#define IGS_DRAW_X_MAJOR 0x00000000
+#define IGS_DRAW_Y_MAJOR 0x00000001
+#define IGS_DRAW_T_B 0x00000000
+#define IGS_DRAW_B_T 0x00000002
+#define IGS_DRAW_L_R 0x00000000
+#define IGS_DRAW_R_L 0x00000004
+
+/* Draw_Mode[1:0] */
+#define IGS_DRAW_ALL 0x00000000
+#define IGS_DRAW_NOT_FIRST 0x00000010
+#define IGS_DRAW_NOT_LAST 0x00000020
+#define IGS_DRAW_NOT_FIRST_LAST 0x00000030
+
+/* TRPS[1:0] */
+#define IGS_TRANS_SRC1 0x00000000
+#define IGS_TRANS_SRC2 0x00000100
+#define IGS_TRANS_DST 0x00000200
+/* TRPS2 Transparent Invert */
+#define IGS_TRANS_INVERT 0x00000400
+/* TRPS3, Transparent Enable */
+#define IGS_TRANS_ENABLE 0x00000800
+
+/* PPS[3:0], Pattern Pixel Select */
+#define IGS_PIXEL_TEXT_OPAQUE 0x00001000
+#define IGS_PIXEL_STIP_OPAQUE 0x00002000
+#define IGS_PIXEL_LINE_OPAQUE 0x00003000
+#define IGS_PIXEL_TEXT_TRANS 0x00005000
+#define IGS_PIXEL_STIP_TRANS 0x00006000
+#define IGS_PIXEL_LINE_TRANS 0x00007000
+#define IGS_PIXEL_FG 0x00008000
+#define IGS_PIXEL_TILE 0x00009000
+
+/* HostBltEnable[1:0] */
+#define IGS_HBLT_DISABLE 0x00000000
+#define IGS_HBLT_READ 0x00010000
+#define IGS_HBLT_WRITE_1 0x00020000
+#define IGS_HBLT_WRITE_2 0x00030000
+
+/* Src2MapSelect[2:0], Src2 map select mode */
+#define IGS_SRC2_NORMAL 0x00000000
+#define IGS_SRC2_MONO_OPAQUE 0x00100000
+#define IGS_SRC2_FG 0x00200000
+#define IGS_SRC2_MONO_TRANS 0x00500000
+
+/* StepFunction[3:0], Step function select */
+#define IGS_STEP_DRAW_AND_STEP 0x04000000
+#define IGS_STEP_LINE_DRAW 0x05000000
+#define IGS_STEP_PXBLT 0x08000000
+#define IGS_STEP_INVERT_PXBLT 0x09000000
+#define IGS_STEP_TERNARY_PXBLT 0x0b000000
+
+/* FGS */
+#define IGS_FGS_FG 0x00000000
+#define IGS_FGS_SRC 0x20000000
+
+/* BGS */
+#define IGS_BGS_BG 0x00000000
+#define IGS_BGS_SRC 0x80000000
+ VOL8 pad080[0x91]; /* 0x080 */
+
+ VOL8 debug_control_1; /* 0x111 */
+ VOL8 debug_control_2; /* 0x112 */
+ VOL8 pad113[0x05]; /* 0x113 */
+
+ VOL32 src2_stride; /* 0x118 */
+ VOL8 pad11c[0x14]; /* 0x11c */
+
+ VOL32 extension; /* 0x130 */
+
+#define IGS_BURST_ENABLE 0x01
+#define IGS_STYLE_LINE 0x02
+#define IGS_ADDITIONAL_WAIT 0x04
+#define IGS_BLOCK_COP_REG 0x08
+#define IGS_TURBO_MONO 0x10
+#define IGS_SELECT_SAMPLE 0x40
+#define IGS_MDSBL_RD_B_WR 0x80
+#define IGS_WRMRSTZ 0x100
+#define IGS_TEST_MTST 0x200
+
+ VOL8 style_line_roll_over; /* 0x134 */
+ VOL8 style_line_inc; /* 0x135 */
+ VOL8 style_line_pattern; /* 0x136 */
+ VOL8 style_line_accumulator; /* 0x137 */
+ VOL8 style_line_pattern_index; /* 0x138 */
+ VOL8 pad139[0x3]; /* 0x139 */
+
+ VOL16 mono_burst_total; /* 0x13c */
+ VOL8 pad13e[0x12]; /* 0x13e */
+
+ VOL8 pat_x_rotate; /* 0x150 */
+ VOL8 pad151[0x1f]; /* 0x151 */
+
+ VOL32 src1_start; /* 0x170 */
+ VOL32 src2_start; /* 0x174 */
+ VOL32 dst_start; /* 0x178 */
+ VOL8 pad17c[0x9c]; /* 0x17c */
+
+ VOL16 dst_stride; /* 0x218 */
+} Cop5xxx;
+
+typedef struct _igsCardInfo {
+ Cop5xxx *cop;
+ VOL32 *copData;
+ Bool need_sync;
+ CARD8 *frameBuffer;
+} IgsCardInfo;
+
+#define getIgsCardInfo(kd) ((IgsCardInfo *) ((kd)->card->driver))
+#define igsCardInfo(kd) IgsCardInfo *igsc = getIgsCardInfo(kd)
+
+Bool
+igsDrawInit (ScreenPtr pScreen);
+
+void
+igsDrawEnable (ScreenPtr pScreen);
+
+void
+igsDrawDisable (ScreenPtr pScreen);
+
+void
+igsDrawSync (ScreenPtr pScreen);
+
+void
+igsDrawFini (ScreenPtr pScreen);
+
+
+#endif /* _IGS_H_ */
diff --git a/hw/kdrive/igs/igsdraw.c b/hw/kdrive/igs/igsdraw.c
new file mode 100644
index 000000000..43ca7cf6e
--- /dev/null
+++ b/hw/kdrive/igs/igsdraw.c
@@ -0,0 +1,1114 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "igs.h"
+#include "igsdraw.h"
+
+#include "Xmd.h"
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mistruct.h"
+#include "fontstruct.h"
+#include "dixfontstr.h"
+#include "fb.h"
+#include "migc.h"
+#include "miline.h"
+
+CARD8 igsPatRop[16] = {
+ /* GXclear */ 0x00, /* 0 */
+ /* GXand */ 0xa0, /* src AND dst */
+ /* GXandReverse */ 0x50, /* src AND NOT dst */
+ /* GXcopy */ 0xf0, /* src */
+ /* GXandInverted*/ 0x0a, /* NOT src AND dst */
+ /* GXnoop */ 0xaa, /* dst */
+ /* GXxor */ 0x5a, /* src XOR dst */
+ /* GXor */ 0xfa, /* src OR dst */
+ /* GXnor */ 0x05, /* NOT src AND NOT dst */
+ /* GXequiv */ 0xa5, /* NOT src XOR dst */
+ /* GXinvert */ 0x55, /* NOT dst */
+ /* GXorReverse */ 0xf5, /* src OR NOT dst */
+ /* GXcopyInverted*/ 0x0f, /* NOT src */
+ /* GXorInverted */ 0xaf, /* NOT src OR dst */
+ /* GXnand */ 0x5f, /* NOT src OR NOT dst */
+ /* GXset */ 0xff, /* 1 */
+};
+
+/*
+ * Handle pixel transfers
+ */
+
+#define BURST
+#ifdef BURST
+#define PixTransDeclare VOL32 *pix_trans_base = igsc->copData,\
+ *pix_trans = pix_trans_base
+#define PixTransStart(n) if (pix_trans + (n) > pix_trans_base + 16384) pix_trans = pix_trans_base
+#define PixTransStore(t) *pix_trans++ = (t)
+#else
+#define PixTransDeclare VOL32 *pix_trans = igsc->copData
+#define PixTransStart(n)
+#define PixTransStore(t) *pix_trans = (t)
+#endif
+
+void
+igsFillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
+ unsigned long pixel, int alu, unsigned long planemask)
+{
+ SetupIgs(pDrawable->pScreen);
+ CARD32 cmd;
+
+ _igsSetSolidRect(cop,alu,planemask,pixel,cmd);
+ while (nBox--)
+ {
+ _igsRect(cop,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd);
+ pBox++;
+ }
+ KdMarkSync (pDrawable->pScreen);
+}
+
+void
+igsCopyNtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ SetupIgs(pDstDrawable->pScreen);
+ int srcX, srcY, dstX, dstY;
+ int w, h;
+ CARD32 flags;
+ CARD32 cmd;
+ CARD8 alu;
+
+ if (pGC)
+ {
+ alu = pGC->alu;
+ if (sourceInvarient (pGC->alu))
+ {
+ igsFillBoxSolid (pDstDrawable, nbox, pbox, 0, pGC->alu, pGC->planemask);
+ return;
+ }
+ }
+ else
+ alu = GXcopy;
+
+ _igsSetBlt(cop,alu,pGC->planemask,reverse,upsidedown,cmd);
+ while (nbox--)
+ {
+ w = pbox->x2 - pbox->x1;
+ h = pbox->y2 - pbox->y1;
+ if (reverse)
+ dstX = pbox->x2 - 1;
+ else
+ dstX = pbox->x1;
+ srcX = dstX + dx;
+
+ if (upsidedown)
+ dstY = pbox->y2 - 1;
+ else
+ dstY = pbox->y1;
+
+ srcY = dstY + dy;
+
+ _igsBlt (cop, srcX, srcY, dstX, dstY, w, h, cmd);
+ pbox++;
+ }
+ KdMarkSync (pDstDrawable->pScreen);
+}
+
+RegionPtr
+igsCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
+ int srcx, int srcy, int width, int height, int dstx, int dsty)
+{
+ KdScreenPriv(pDstDrawable->pScreen);
+ FbBits depthMask;
+
+ depthMask = FbFullMask (pDstDrawable->depth);
+ if ((pGC->planemask & depthMask) == depthMask &&
+ pSrcDrawable->type == DRAWABLE_WINDOW &&
+ pDstDrawable->type == DRAWABLE_WINDOW)
+ {
+ return fbDoCopy (pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height,
+ dstx, dsty, igsCopyNtoN, 0, 0);
+ }
+ return KdCheckCopyArea (pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height, dstx, dsty);
+}
+
+BOOL
+igsFillOk (GCPtr pGC)
+{
+ FbBits depthMask;
+
+ depthMask = FbFullMask(pGC->depth);
+ if ((pGC->planemask & depthMask) != depthMask)
+ return FALSE;
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ return TRUE;
+#if 0
+ case FillTiled:
+ return (igsPatternDimOk (pGC->tile.pixmap->drawable.width) &&
+ igsPatternDimOk (pGC->tile.pixmap->drawable.height));
+ case FillStippled:
+ case FillOpaqueStippled:
+ return (igsPatternDimOk (pGC->stipple->drawable.width) &&
+ igsPatternDimOk (pGC->stipple->drawable.height));
+#endif
+ }
+ return FALSE;
+}
+
+void
+igsFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
+ DDXPointPtr ppt, int *pwidth, int fSorted)
+{
+ SetupIgs(pDrawable->pScreen);
+ DDXPointPtr pptFree;
+ FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC);
+ int *pwidthFree;/* copies of the pointers to free */
+ CARD32 cmd;
+ int nTmp;
+ INT16 x, y;
+ int width;
+
+ if (!igsFillOk (pGC))
+ {
+ KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
+ return;
+ }
+ nTmp = n * miFindMaxBand(fbGetCompositeClip(pGC));
+ pwidthFree = (int *)ALLOCATE_LOCAL(nTmp * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(nTmp * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ n = miClipSpans(fbGetCompositeClip(pGC),
+ ppt, pwidth, n,
+ pptFree, pwidthFree, fSorted);
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ _igsSetSolidRect(cop,pGC->alu,pGC->planemask,pGC->fgPixel,cmd);
+ break;
+#if 0
+ case FillTiled:
+ cmd = igsTilePrepare (pGC->tile.pixmap,
+ pGC->patOrg.x + pDrawable->x,
+ pGC->patOrg.y + pDrawable->y,
+ pGC->alu);
+ break;
+ default:
+ cmd = igsStipplePrepare (pDrawable, pGC);
+ break;
+#endif
+ }
+ while (n--)
+ {
+ x = ppt->x;
+ y = ppt->y;
+ ppt++;
+ width = *pwidth++;
+ if (width)
+ {
+ _igsRect(cop,x,y,width,1,cmd);
+ }
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+ KdMarkSync (pDrawable->pScreen);
+}
+
+#define NUM_STACK_RECTS 1024
+
+void
+igsPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit)
+{
+ SetupIgs(pDrawable->pScreen);
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ register BoxPtr pbox;
+ register BoxPtr pboxClipped;
+ BoxPtr pboxClippedBase;
+ BoxPtr pextent;
+ BoxRec stackRects[NUM_STACK_RECTS];
+ FbGCPrivPtr fbPriv = fbGetGCPrivate (pGC);
+ int numRects;
+ int n;
+ int xorg, yorg;
+ int x, y;
+
+ if (!igsFillOk (pGC))
+ {
+ KdCheckPolyFillRect (pDrawable, pGC, nrectFill, prectInit);
+ return;
+ }
+ prgnClip = fbGetCompositeClip (pGC);
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+
+ if (xorg || yorg)
+ {
+ prect = prectInit;
+ n = nrectFill;
+ while(n--)
+ {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+ prect = prectInit;
+
+ numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
+ if (numRects > NUM_STACK_RECTS)
+ {
+ pboxClippedBase = (BoxPtr)xalloc(numRects * sizeof(BoxRec));
+ if (!pboxClippedBase)
+ return;
+ }
+ else
+ pboxClippedBase = stackRects;
+
+ pboxClipped = pboxClippedBase;
+
+ if (REGION_NUM_RECTS(prgnClip) == 1)
+ {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_RECTS(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--)
+ {
+ if ((pboxClipped->x1 = prect->x) < x1)
+ pboxClipped->x1 = x1;
+
+ if ((pboxClipped->y1 = prect->y) < y1)
+ pboxClipped->y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ pboxClipped->x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ pboxClipped->y2 = by2;
+
+ prect++;
+ if ((pboxClipped->x1 < pboxClipped->x2) &&
+ (pboxClipped->y1 < pboxClipped->y2))
+ {
+ pboxClipped++;
+ }
+ }
+ }
+ else
+ {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--)
+ {
+ BoxRec box;
+
+ if ((box.x1 = prect->x) < x1)
+ box.x1 = x1;
+
+ if ((box.y1 = prect->y) < y1)
+ box.y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ box.x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ box.y2 = by2;
+
+ prect++;
+
+ if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ continue;
+
+ n = REGION_NUM_RECTS (prgnClip);
+ pbox = REGION_RECTS(prgnClip);
+
+ /* clip the rectangle to each box in the clip region
+ this is logically equivalent to calling Intersect()
+ */
+ while(n--)
+ {
+ pboxClipped->x1 = max(box.x1, pbox->x1);
+ pboxClipped->y1 = max(box.y1, pbox->y1);
+ pboxClipped->x2 = min(box.x2, pbox->x2);
+ pboxClipped->y2 = min(box.y2, pbox->y2);
+ pbox++;
+
+ /* see if clipping left anything */
+ if(pboxClipped->x1 < pboxClipped->x2 &&
+ pboxClipped->y1 < pboxClipped->y2)
+ {
+ pboxClipped++;
+ }
+ }
+ }
+ }
+ if (pboxClipped != pboxClippedBase)
+ {
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ igsFillBoxSolid(pDrawable,
+ pboxClipped-pboxClippedBase, pboxClippedBase,
+ pGC->fgPixel, pGC->alu, pGC->planemask);
+ break;
+#if 0
+ case FillTiled:
+ igsFillBoxTiled(pDrawable,
+ pboxClipped-pboxClippedBase, pboxClippedBase,
+ pGC->tile.pixmap,
+ pGC->patOrg.x + pDrawable->x,
+ pGC->patOrg.y + pDrawable->y,
+ pGC->alu);
+ break;
+ case FillStippled:
+ case FillOpaqueStippled:
+ igsFillBoxStipple (pDrawable, pGC,
+ pboxClipped-pboxClippedBase, pboxClippedBase);
+ break;
+#endif
+ }
+ }
+ if (pboxClippedBase != stackRects)
+ xfree(pboxClippedBase);
+}
+
+int
+igsTextInRegion (GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci)
+{
+ int w;
+ FontPtr pfont = pGC->font;
+ BoxRec bbox;
+
+ if (FONTCONSTMETRICS(pfont))
+ w = FONTMAXBOUNDS(pfont,characterWidth) * nglyph;
+ else
+ {
+ w = 0;
+ while (nglyph--)
+ w += (*ppci++)->metrics.characterWidth;
+ }
+ if (w < 0)
+ {
+ bbox.x1 = x + w;
+ bbox.x2 = x;
+ }
+ else
+ {
+ bbox.x1 = x;
+ bbox.x2 = x + w;
+ }
+ w = FONTMINBOUNDS(pfont,leftSideBearing);
+ if (w < 0)
+ bbox.x1 += w;
+ w = FONTMAXBOUNDS(pfont, rightSideBearing) - FONTMINBOUNDS(pfont, characterWidth);
+ if (w > 0)
+ bbox.x2 += w;
+ bbox.y1 = y - FONTMAXBOUNDS(pfont,ascent);
+ bbox.y2 = y + FONTMAXBOUNDS(pfont,descent);
+
+ return RECT_IN_REGION(pGC->pScreen, fbGetCompositeClip(pGC), &bbox);
+}
+
+void
+igsGlyphBltClipped (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppciInit,
+ Bool image)
+{
+ SetupIgs(pDrawable->pScreen);
+ CARD32 cmd;
+ int h;
+ int w;
+ int xBack, yBack;
+ int hBack, wBack;
+ int lw;
+ FontPtr pfont = pGC->font;
+ CharInfoPtr pci;
+ unsigned long *bits;
+ BoxPtr extents;
+ BoxRec bbox;
+ CARD32 b;
+ CharInfoPtr *ppci;
+ FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC);
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ BoxPtr pBox;
+ int nbox;
+ int x1, y1, x2, y2;
+ unsigned char alu;
+ Bool set;
+ PixTransDeclare;
+
+ if (image)
+ {
+ xBack = x;
+ yBack = y - FONTASCENT(pGC->font);
+ wBack = 0;
+ hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+ if (hBack)
+ {
+ h = nglyph;
+ ppci = ppciInit;
+ while (h--)
+ wBack += (*ppci++)->metrics.characterWidth;
+ }
+ if (wBack < 0)
+ {
+ xBack = xBack + wBack;
+ wBack = -wBack;
+ }
+ if (hBack < 0)
+ {
+ yBack = yBack + hBack;
+ hBack = -hBack;
+ }
+ alu = GXcopy;
+ if (wBack)
+ {
+ _igsSetSolidRect (cop, GXcopy, pGC->planemask, pGC->bgPixel, cmd);
+ for (nbox = REGION_NUM_RECTS (pClip),
+ pBox = REGION_RECTS (pClip);
+ nbox--;
+ pBox++)
+ {
+ x1 = xBack;
+ x2 = xBack + wBack;
+ y1 = yBack;
+ y2 = yBack + hBack;
+ if (x1 < pBox->x1) x1 = pBox->x1;
+ if (x2 > pBox->x2) x2 = pBox->x2;
+ if (y1 < pBox->y1) y1 = pBox->y1;
+ if (y2 > pBox->y2) y2 = pBox->y2;
+ if (x1 < x2 && y1 < y2)
+ {
+ _igsRect (cop, x1, y1, x2 - x1, y2 - y1, cmd);
+ }
+ }
+ KdMarkSync (pDrawable->pScreen);
+ }
+ }
+ else
+ {
+ wBack = 0;
+ alu = pGC->alu;
+ }
+
+ ppci = ppciInit;
+ set = FALSE;
+ while (nglyph--)
+ {
+ pci = *ppci++;
+ h = pci->metrics.ascent + pci->metrics.descent;
+ w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
+ x1 = x + pci->metrics.leftSideBearing;
+ y1 = y - pci->metrics.ascent;
+ bbox.x1 = x1;
+ bbox.y1 = y1;
+ bbox.x2 = x1 + w;
+ bbox.y2 = y1 + h;
+ switch (RECT_IN_REGION(pGC->pScreen, pClip, &bbox))
+ {
+ case rgnIN:
+ lw = h * ((w + 31) >> 5);
+ if (lw)
+ {
+ if (!set)
+ {
+ _igsSetTransparentPlaneBlt (cop, alu, pGC->planemask, pGC->fgPixel, cmd);
+ set = TRUE;
+ }
+ _igsPlaneBlt(cop,
+ x + pci->metrics.leftSideBearing,
+ y - pci->metrics.ascent,
+ w, h, cmd);
+ bits = (unsigned long *) pci->bits;
+ PixTransStart (lw);
+ while (lw--)
+ {
+ b = *bits++;
+ IgsAdjustBits32 (b);
+ PixTransStore(b);
+ }
+ KdMarkSync (pDrawable->pScreen);
+ }
+ break;
+ case rgnPART:
+ set = FALSE;
+ KdCheckSync (pDrawable->pScreen);
+ fbPutXYImage (pDrawable,
+ pClip,
+ fbPriv->fg,
+ fbPriv->bg,
+ fbPriv->pm,
+ alu,
+ FALSE,
+ x1, y1,
+ w, h,
+ (FbStip *) pci->bits,
+ (w + 31) >> 5,
+ 0);
+ break;
+ case rgnOUT:
+ break;
+ }
+ x += pci->metrics.characterWidth;
+ }
+}
+
+void
+igsGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppciInit,
+ Bool image)
+{
+ SetupIgs(pDrawable->pScreen);
+ CARD32 cmd;
+ int h;
+ int w;
+ int xBack, yBack;
+ int hBack, wBack;
+ int lw;
+ FontPtr pfont = pGC->font;
+ CharInfoPtr pci;
+ unsigned long *bits;
+ BoxPtr extents;
+ BoxRec bbox;
+ CARD32 b;
+ CharInfoPtr *ppci;
+ unsigned char alu;
+ PixTransDeclare;
+
+ /*
+ * Paint background for image text
+ */
+ if (image)
+ {
+ xBack = x;
+ yBack = y - FONTASCENT(pGC->font);
+ wBack = 0;
+ hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+ if (hBack)
+ {
+ h = nglyph;
+ ppci = ppciInit;
+ while (h--)
+ wBack += (*ppci++)->metrics.characterWidth;
+ }
+ if (wBack < 0)
+ {
+ xBack = xBack + wBack;
+ wBack = -wBack;
+ }
+ if (hBack < 0)
+ {
+ yBack = yBack + hBack;
+ hBack = -hBack;
+ }
+ alu = GXcopy;
+ if (wBack)
+ {
+ _igsSetSolidRect (cop, GXcopy, pGC->planemask, pGC->bgPixel, cmd);
+ _igsRect (cop, xBack, yBack, wBack, hBack, cmd);
+ }
+ }
+ else
+ {
+ wBack = 0;
+ alu = pGC->alu;
+ }
+
+ _igsSetTransparentPlaneBlt (cop, alu, pGC->planemask, pGC->fgPixel, cmd);
+ ppci = ppciInit;
+ while (nglyph--)
+ {
+ pci = *ppci++;
+ h = pci->metrics.ascent + pci->metrics.descent;
+ w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
+ lw = h * ((w + 31) >> 5);
+ if (lw)
+ {
+ _igsPlaneBlt(cop,
+ x + pci->metrics.leftSideBearing,
+ y - pci->metrics.ascent,
+ w, h, cmd);
+ bits = (unsigned long *) pci->bits;
+ PixTransStart(lw);
+ while (lw--)
+ {
+ b = *bits++;
+ IgsAdjustBits32 (b);
+ PixTransStore(b);
+ }
+ }
+ x += pci->metrics.characterWidth;
+ }
+ KdMarkSync (pDrawable->pScreen);
+}
+
+void
+igsTEGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit,
+ int yInit,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ Bool image)
+{
+ SetupIgs(pDrawable->pScreen);
+ CARD32 cmd;
+ int x, y;
+ int h, lw, lwTmp;
+ int w;
+ FontPtr pfont = pGC->font;
+ unsigned long *char1, *char2, *char3, *char4;
+ int widthGlyphs, widthGlyph;
+ BoxRec bbox;
+ CARD32 tmp;
+ PixTransDeclare;
+
+ widthGlyph = FONTMAXBOUNDS(pfont,characterWidth);
+ if (!widthGlyph)
+ return;
+
+ h = FONTASCENT(pfont) + FONTDESCENT(pfont);
+ if (!h)
+ return;
+
+ x = xInit + FONTMAXBOUNDS(pfont,leftSideBearing);
+ y = yInit - FONTASCENT(pfont);
+
+ if (image)
+ {
+ _igsSetOpaquePlaneBlt (cop, GXcopy, pGC->planemask, pGC->fgPixel, pGC->bgPixel, cmd);
+ }
+ else
+ {
+ _igsSetTransparentPlaneBlt (cop, pGC->alu, pGC->planemask, pGC->fgPixel, cmd);
+ }
+
+#if BITMAP_BIT_ORDER == LSBFirst
+#define SHIFT <<
+#else
+#define SHIFT >>
+#endif
+
+#define LoopIt(count, w, loadup, fetch) \
+ while (nglyph >= count) \
+ { \
+ nglyph -= count; \
+ _igsPlaneBlt (cop, x, y, w, h, cmd); \
+ x += w; \
+ loadup \
+ lwTmp = h; \
+ PixTransStart(h); \
+ while (lwTmp--) { \
+ tmp = fetch; \
+ IgsAdjustBits32(tmp); \
+ PixTransStore(tmp); \
+ } \
+ }
+
+ if (widthGlyph <= 8)
+ {
+ widthGlyphs = widthGlyph << 2;
+ LoopIt(4, widthGlyphs,
+ char1 = (unsigned long *) (*ppci++)->bits;
+ char2 = (unsigned long *) (*ppci++)->bits;
+ char3 = (unsigned long *) (*ppci++)->bits;
+ char4 = (unsigned long *) (*ppci++)->bits;,
+ (*char1++ | ((*char2++ | ((*char3++ | (*char4++
+ SHIFT widthGlyph))
+ SHIFT widthGlyph))
+ SHIFT widthGlyph)))
+ }
+ else if (widthGlyph <= 10)
+ {
+ widthGlyphs = (widthGlyph << 1) + widthGlyph;
+ LoopIt(3, widthGlyphs,
+ char1 = (unsigned long *) (*ppci++)->bits;
+ char2 = (unsigned long *) (*ppci++)->bits;
+ char3 = (unsigned long *) (*ppci++)->bits;,
+ (*char1++ | ((*char2++ | (*char3++ SHIFT widthGlyph)) SHIFT widthGlyph)))
+ }
+ else if (widthGlyph <= 16)
+ {
+ widthGlyphs = widthGlyph << 1;
+ LoopIt(2, widthGlyphs,
+ char1 = (unsigned long *) (*ppci++)->bits;
+ char2 = (unsigned long *) (*ppci++)->bits;,
+ (*char1++ | (*char2++ SHIFT widthGlyph)))
+ }
+ lw = h * ((widthGlyph + 31) >> 5);
+ while (nglyph--)
+ {
+ _igsPlaneBlt (cop, x, y, widthGlyph, h, cmd);
+ x += widthGlyph;
+ char1 = (unsigned long *) (*ppci++)->bits;
+ lwTmp = lw;
+ PixTransStart(lw);
+ while (lwTmp--)
+ {
+ tmp = *char1++;
+ IgsAdjustBits32(tmp);
+ PixTransStore(tmp);
+ }
+ }
+ KdMarkSync (pDrawable->pScreen);
+}
+
+/*
+ * Blt glyphs using image transfer window
+ */
+
+void
+igsPolyGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase)
+{
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ switch (igsTextInRegion (pGC, x, y, nglyph, ppci)) {
+ case rgnIN:
+ if (TERMINALFONT(pGC->font))
+ igsTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, FALSE);
+ else
+ igsGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, FALSE);
+ break;
+ case rgnPART:
+ igsGlyphBltClipped (pDrawable, pGC, x, y, nglyph, ppci, FALSE);
+ break;
+ case rgnOUT:
+ break;
+ }
+}
+
+void
+igsImageGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x, int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase)
+{
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ switch (igsTextInRegion (pGC, x, y, nglyph, ppci)) {
+ case rgnIN:
+ if (TERMINALFONT(pGC->font))
+ igsTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, TRUE);
+ else
+ igsGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, TRUE);
+ break;
+ case rgnPART:
+ igsGlyphBltClipped (pDrawable, pGC, x, y, nglyph, ppci, TRUE);
+ break;
+ case rgnOUT:
+ break;
+ }
+}
+
+static const GCOps igsOps = {
+ igsFillSpans,
+ KdCheckSetSpans,
+ KdCheckPutImage,
+ igsCopyArea,
+ KdCheckCopyPlane,
+ KdCheckPolyPoint,
+ KdCheckPolylines,
+ KdCheckPolySegment,
+ miPolyRectangle,
+ KdCheckPolyArc,
+ miFillPolygon,
+ igsPolyFillRect,
+ KdCheckPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ igsImageGlyphBlt,
+ igsPolyGlyphBlt,
+ KdCheckPushPixels,
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+void
+igsValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
+{
+ FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC);
+
+ fbValidateGC (pGC, changes, pDrawable);
+
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ pGC->ops = (GCOps *) &igsOps;
+ else
+ pGC->ops = (GCOps *) &fbGCOps;
+}
+
+GCFuncs igsGCFuncs = {
+ igsValidateGC,
+ miChangeGC,
+ miCopyGC,
+ miDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip
+};
+
+int
+igsCreateGC (GCPtr pGC)
+{
+ if (!fbCreateGC (pGC))
+ return FALSE;
+
+ if (pGC->depth != 1)
+ pGC->funcs = &igsGCFuncs;
+
+ return TRUE;
+}
+
+void
+igsCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ RegionRec rgnDst;
+ int dx, dy;
+ WindowPtr pwinRoot;
+
+ pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+
+ REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
+
+ REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+
+ fbCopyRegion ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
+ 0,
+ &rgnDst, dx, dy, igsCopyNtoN, 0, 0);
+
+ REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+}
+
+void
+igsPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ KdScreenPriv(pWin->drawable.pScreen);
+ PixmapPtr pTile;
+
+ if (!REGION_NUM_RECTS(pRegion))
+ return;
+ switch (what) {
+ case PW_BACKGROUND:
+ switch (pWin->backgroundState) {
+ case None:
+ return;
+ case ParentRelative:
+ do {
+ pWin = pWin->parent;
+ } while (pWin->backgroundState == ParentRelative);
+ (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
+ what);
+ return;
+#if 0
+ case BackgroundPixmap:
+ pTile = pWin->background.pixmap;
+ if (igsPatternDimOk (pTile->drawable.width) &&
+ igsPatternDimOk (pTile->drawable.height))
+ {
+ igsFillBoxTiled ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pTile,
+ pWin->drawable.x, pWin->drawable.y, GXcopy);
+ return;
+ }
+ break;
+#endif
+ case BackgroundPixel:
+ igsFillBoxSolid((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->background.pixel, GXcopy, ~0);
+ return;
+ }
+ break;
+ case PW_BORDER:
+ if (pWin->borderIsPixel)
+ {
+ igsFillBoxSolid((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->border.pixel, GXcopy, ~0);
+ return;
+ }
+#if 0
+ else
+ {
+ pTile = pWin->border.pixmap;
+ if (igsPatternDimOk (pTile->drawable.width) &&
+ igsPatternDimOk (pTile->drawable.height))
+ {
+ igsFillBoxTiled ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pTile,
+ pWin->drawable.x, pWin->drawable.y, GXcopy);
+ return;
+ }
+ }
+#endif
+ break;
+ }
+ KdCheckPaintWindow (pWin, pRegion, what);
+}
+
+Bool
+igsDrawInit (ScreenPtr pScreen)
+{
+ /*
+ * Replace various fb screen functions
+ */
+ pScreen->CreateGC = igsCreateGC;
+ pScreen->CopyWindow = igsCopyWindow;
+ pScreen->PaintWindowBackground = igsPaintWindow;
+ pScreen->PaintWindowBorder = igsPaintWindow;
+
+ KdScreenInitAsync (pScreen);
+
+ return TRUE;
+}
+
+void
+igsDrawEnable (ScreenPtr pScreen)
+{
+ SetupIgs(pScreen);
+ CARD32 cmd;
+ CARD32 base;
+ CARD16 stride;
+ CARD32 format;
+
+ stride = pScreenPriv->screen->fb[0].pixelStride;
+ _igsWaitIdleEmpty(cop);
+ _igsReset(cop);
+ switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
+ case 8:
+ format = IGS_FORMAT_8BPP;
+ break;
+ case 16:
+ format = IGS_FORMAT_16BPP;
+ break;
+ case 24:
+ format = IGS_FORMAT_24BPP;
+ break;
+ case 32:
+ format = IGS_FORMAT_32BPP;
+ break;
+ }
+ cop->format = format;
+ cop->dst_stride = stride - 1;
+ cop->src1_stride = stride - 1;
+ cop->src2_stride = stride - 1;
+ cop->src1_start = 0;
+ cop->src2_start = 0;
+ cop->extension |= IGS_BLOCK_COP_REG | IGS_BURST_ENABLE;
+
+ _igsSetSolidRect(cop, GXcopy, ~0, pScreen->blackPixel, cmd);
+ _igsRect (cop, 0, 0,
+ pScreenPriv->screen->width, pScreenPriv->screen->height,
+ cmd);
+ _igsWaitIdleEmpty (cop);
+}
+
+void
+igsDrawDisable (ScreenPtr pScreen)
+{
+}
+
+void
+igsDrawFini (ScreenPtr pScreen)
+{
+}
+
+void
+igsDrawSync (ScreenPtr pScreen)
+{
+ SetupIgs(pScreen);
+
+ _igsWaitIdleEmpty(cop);
+}
diff --git a/hw/kdrive/igs/igsdraw.h b/hw/kdrive/igs/igsdraw.h
new file mode 100644
index 000000000..5388d8e34
--- /dev/null
+++ b/hw/kdrive/igs/igsdraw.h
@@ -0,0 +1,188 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _IGSDRAW_H_
+#define _IGSDRAW_H_
+
+extern CARD8 igsPatRop[];
+
+#define SetupIgs(s) KdScreenPriv(s); \
+ igsCardInfo(pScreenPriv); \
+ Cop5xxx *cop = igsc->cop; \
+ int cop_stride = pScreenPriv->screen->fb[0].pixelStride
+
+#define _igsWaitLoop(cop,mask,value) { \
+ int __loop = 1000000; \
+ while (((cop)->control & (mask)) != (value)) { \
+ if (--__loop <= 0) { \
+ FatalError("Warning: igsWaitLoop 0x%x 0x%x failed\n", mask, value); \
+ } \
+ } \
+}
+
+#define _igsWaitDone(cop) _igsWaitLoop(cop, \
+ (IGS_CONTROL_BUSY| \
+ IGS_CONTROL_MALLWBEPTZ), \
+ 0)
+
+#define _igsWaitFull(cop) _igsWaitLoop(cop, \
+ IGS_CONTROL_CMDFF, \
+ 0)
+
+#define _igsWaitIdleEmpty(cop) _igsWaitDone(cop)
+#define _igsWaitHostBltAck(cop) _igsWaitLoop(cop, \
+ (IGS_CONTROL_HBACKZ| \
+ IGS_CONTROL_CMDFF), \
+ 0)
+
+#define _igsReset(cop) ((cop)->control = 0)
+
+#define IgsInvertBits32(v) { \
+ v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
+ v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
+ v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
+}
+
+#define IgsInvertBits16(v) { \
+ v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \
+ v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \
+ v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \
+}
+
+#define IgsInvertBits8(v) { \
+ v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \
+ v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \
+ v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \
+}
+
+#define IgsAdjustBits32(b) IgsInvertBits32(b)
+
+#define _igsSetSolidRect(cop,alu,pm,pix,cmd) {\
+ _igsWaitFull(cop); \
+ (cop)->mix = IGS_MAKE_MIX(alu,alu); \
+ (cop)->fg = (pix); \
+ (cop)->planemask = (pm); \
+ (cmd) = (IGS_DRAW_T_B | \
+ IGS_DRAW_L_R | \
+ IGS_DRAW_ALL | \
+ IGS_PIXEL_FG | \
+ IGS_HBLT_DISABLE | \
+ IGS_SRC2_NORMAL | \
+ IGS_STEP_PXBLT | \
+ IGS_FGS_FG | \
+ IGS_BGS_BG); \
+}
+
+#define _igsRect(cop,x,y,w,h,cmd) { \
+ _igsWaitFull(cop); \
+ (cop)->dst_start = (x) + (y) * (cop_stride); \
+ (cop)->dim = IGS_MAKE_DIM(w-1,h-1); \
+ (cop)->operation = (cmd); \
+}
+
+#define _igsSetBlt(cop,alu,pm,backwards,upsidedown,cmd) { \
+ _igsWaitFull(cop); \
+ (cop)->mix = IGS_MAKE_MIX(alu,GXnoop); \
+ (cop)->planemask = (pm); \
+ (cop)->src1_stride = cop_stride - 1; \
+ (cmd) = (IGS_DRAW_ALL | \
+ IGS_PIXEL_FG | \
+ IGS_HBLT_DISABLE | \
+ IGS_SRC2_NORMAL | \
+ IGS_STEP_PXBLT | \
+ IGS_FGS_SRC | \
+ IGS_BGS_BG); \
+ if (backwards) (cmd) |= IGS_DRAW_R_L; \
+ if (upsidedown) (cmd) |= IGS_DRAW_B_T; \
+}
+
+#if 0
+#define _igsPreparePlaneBlt(cop) { \
+ _igsReset(cop); \
+ (cop)->dst_stride = cop_stride - 1; \
+ (cop)->src1_stride = cop_stride - 1; \
+ (cop)->src2_stride = cop_stride - 1; \
+ (cop)->format = IGS_FORMAT_16BPP; \
+ (cop)->src1_start = 0; \
+ (cop)->src2_start = 0; \
+}
+#else
+#define _igsPreparePlaneBlt(cop)
+#endif
+
+#define _igsSetTransparentPlaneBlt(cop,alu,pm,fg_pix,cmd) { \
+ _igsWaitIdleEmpty(cop); \
+ _igsPreparePlaneBlt(cop); \
+ (cop)->mix = IGS_MAKE_MIX(igsPatRop[alu],igsPatRop[GXnoop]); \
+ (cop)->fg = (fg_pix); \
+ (cop)->planemask = (pm); \
+ (cmd) = (IGS_DRAW_T_B | \
+ IGS_DRAW_L_R | \
+ IGS_DRAW_ALL | \
+ IGS_PIXEL_FG | \
+ IGS_HBLT_WRITE_2 | \
+ IGS_SRC2_MONO_TRANS | \
+ IGS_STEP_TERNARY_PXBLT | \
+ IGS_FGS_FG | \
+ IGS_BGS_BG); \
+}
+
+#define _igsSetOpaquePlaneBlt(cop,alu,pm,fg_pix,bg_pix,cmd) { \
+ _igsWaitIdleEmpty(cop); \
+ _igsPreparePlaneBlt(cop); \
+ (cop)->mix = IGS_MAKE_MIX(igsPatRop[alu],igsPatRop[alu]); \
+ (cop)->planemask = (pm); \
+ (cop)->fg = (fg_pix); \
+ (cop)->bg = (bg_pix); \
+ (cmd) = (IGS_DRAW_T_B | \
+ IGS_DRAW_L_R | \
+ IGS_DRAW_ALL | \
+ IGS_PIXEL_FG | \
+ IGS_HBLT_WRITE_2 | \
+ IGS_SRC2_MONO_OPAQUE | \
+ IGS_STEP_TERNARY_PXBLT | \
+ IGS_FGS_FG | \
+ IGS_BGS_BG); \
+}
+
+#define _igsPlaneBlt(cop,x,y,w,h,cmd) { \
+/* _igsWaitFull(cop); */ \
+ (cop)->dst_start = (x) + (y) * (cop_stride); \
+ (cop)->dim = IGS_MAKE_DIM((w)-1,(h)-1); \
+ (cop)->operation = (cmd); \
+/* _igsWaitHostBltAck(cop); */ \
+}
+
+#define _igsBlt(cop,sx,sy,dx,dy,w,h,cmd) { \
+ _igsWaitFull(cop); \
+ (cop)->dst_start = (dx) + (dy) * cop_stride; \
+ (cop)->src1_start = (sx) + (sy) * cop_stride; \
+ (cop)->src1_stride = cop_stride - 1; \
+ (cop)->dim = IGS_MAKE_DIM(w-1,h-1); \
+ (cop)->operation = (cmd); \
+}
+
+#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3))
+
+#endif
diff --git a/hw/kdrive/igs/igsstub.c b/hw/kdrive/igs/igsstub.c
new file mode 100644
index 000000000..9d4c3d854
--- /dev/null
+++ b/hw/kdrive/igs/igsstub.c
@@ -0,0 +1,57 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include "igs.h"
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+ CARD32 count;
+
+ count = 0;
+ while (LinuxFindPci (0x10ea, 0x5000, count, &attr))
+ {
+ KdCardInfoAdd (&igsFuncs, &attr, 0);
+ count++;
+ }
+}
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ return KdProcessArgument (argc, argv, i);
+}