summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/kdrive/igs/Imakefile6
-rw-r--r--hw/kdrive/igs/igs.c492
-rw-r--r--hw/kdrive/igs/igs.h147
-rw-r--r--hw/kdrive/igs/igscmap.c61
-rw-r--r--hw/kdrive/igs/igscurs.c344
-rw-r--r--hw/kdrive/igs/igsdraw.c464
-rw-r--r--hw/kdrive/igs/igsdraw.h88
-rw-r--r--hw/kdrive/igs/igsreg.c968
-rw-r--r--hw/kdrive/igs/igsreg.h70
-rw-r--r--hw/kdrive/igs/igsstub.c8
10 files changed, 2568 insertions, 80 deletions
diff --git a/hw/kdrive/igs/Imakefile b/hw/kdrive/igs/Imakefile
index 05d1e1c76..788c91556 100644
--- a/hw/kdrive/igs/Imakefile
+++ b/hw/kdrive/igs/Imakefile
@@ -1,9 +1,9 @@
-XCOMM $XFree86$
+XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/igs/Imakefile,v 1.1 2000/05/06 22:17:42 keithp Exp $
#include <Server.tmpl>
-SRCS = igs.c igsdraw.c igsstub.c
+SRCS = igs.c igscmap.c igscurs.c igsdraw.c igsreg.c igsstub.c
-OBJS = igs.o igsdraw.o igsstub.o
+OBJS = igs.o igscmap.o igscurs.o igsdraw.o igsreg.o igsstub.o
INCLUDES = -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-I../../../fb -I../../../mi -I../../../include -I../../../os \
diff --git a/hw/kdrive/igs/igs.c b/hw/kdrive/igs/igs.c
index 62b31af48..29c2a88ac 100644
--- a/hw/kdrive/igs/igs.c
+++ b/hw/kdrive/igs/igs.c
@@ -1,5 +1,5 @@
/*
- * $XFree86$
+ * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igs.c,v 1.1 2000/05/06 22:17:43 keithp Exp $
*
* Copyright © 1999 SuSE, Inc.
*
@@ -38,9 +38,14 @@ igsCardInit (KdCardInfo *card)
memset (igsc, '\0', sizeof (IgsCardInfo));
- igsc->frameBuffer = (CARD8 *) KdMapDevice (card->attr.address[0],
- 4096 * 1024);
+ igsc->frameBuffer = (CARD8 *) KdMapDevice (card->attr.address[0] +
+ IGS_FB,
+ IGS_MEM);
+ igsc->vga = (VOL8 *) KdMapDevice (card->attr.address[0] +
+ IGS_VGA,
+ 64 * 1024);
+
igsc->cop = (Cop5xxx *) KdMapDevice (card->attr.address[0] +
IGS_COP_OFFSET,
sizeof (Cop5xxx));
@@ -49,17 +54,36 @@ igsCardInit (KdCardInfo *card)
IGS_COP_DATA,
IGS_COP_DATA_LEN);
+ igsRegInit (&igsc->igsvga, igsc->vga);
+
card->driver = igsc;
return TRUE;
}
Bool
-igsScreenInit (KdScreenInfo *screen)
+igsModeSupported (KdScreenInfo *screen,
+ const KdMonitorTiming *t)
{
- IgsCardInfo *igsc = screen->card->driver;
- int fb = 0;
+ /* make sure the clock isn't too fast */
+ if (t->clock > IGS_MAX_CLOCK)
+ return FALSE;
+ /* width must be a multiple of 16 */
+ if (t->horizontal & 0xf)
+ return FALSE;
+ return TRUE;
+}
+
+Bool
+igsModeUsable (KdScreenInfo *screen)
+{
+ KdCardInfo *card = screen->card;
+ int screen_size;
+ int pixel_width;
+ int byte_width;
+ int fb = 0;
+ screen_size = 0;
if (screen->fb[fb].depth >= 24)
{
screen->fb[fb].depth = 24;
@@ -76,11 +100,106 @@ igsScreenInit (KdScreenInfo *screen)
screen->fb[fb].depth = 15;
screen->fb[fb].bitsPerPixel = 16;
}
+ else if (screen->fb[fb].depth >= 12)
+ {
+ screen->fb[fb].depth = 12;
+ screen->fb[fb].bitsPerPixel = 16;
+ }
else
{
screen->fb[fb].depth = 8;
screen->fb[fb].bitsPerPixel = 8;
}
+
+ byte_width = screen->width * (screen->fb[fb].bitsPerPixel >> 3);
+ pixel_width = screen->width;
+ screen->fb[fb].pixelStride = pixel_width;
+ screen->fb[fb].byteStride = byte_width;
+ screen_size += byte_width * screen->height;
+
+ return TRUE;
+}
+
+Bool
+igsScreenInit (KdScreenInfo *screen)
+{
+ IgsCardInfo *igsc = screen->card->driver;
+ int fb = 0;
+ IgsScreenInfo *igss;
+ int screen_size, memory;
+ int pattern_size;
+ int tile_size;
+ int stipple_size;
+ int poffset, boffset;
+ const KdMonitorTiming *t;
+
+ if (!screen->width || !screen->height)
+ {
+ screen->width = 800;
+ screen->height = 600;
+ screen->rate = 72;
+ }
+ if (!screen->fb[0].depth)
+ screen->fb[0].depth = 8;
+
+ t = KdFindMode (screen, igsModeSupported);
+
+ screen->rate = t->rate;
+ screen->width = t->horizontal;
+ screen->height = t->vertical;
+
+ if (!KdTuneMode (screen, igsModeUsable, igsModeSupported))
+ {
+ return FALSE;
+ }
+
+ igss = (IgsScreenInfo *) xalloc (sizeof (IgsScreenInfo));
+ if (!igss)
+ return FALSE;
+
+ memset (igss, '\0', sizeof (IgsScreenInfo));
+
+ screen_size = screen->fb[fb].byteStride * screen->height;
+ memory = IGS_MEM;
+ memory -= screen_size;
+ if (memory >= 1024)
+ {
+ igss->cursor_offset = memory - 1024;
+#if BITMAP_BIT_ORDER == MSBFirst
+ igss->cursor_base = (CARD8 *) KdMapDevice (card->attr.address[0] +
+ igss->cursor_offset,
+ 1024);
+#else
+ igss->cursor_base = igsc->frameBuffer + igss->cursor_offset;
+#endif
+ memory -= 1024;
+ }
+ else
+ igss->cursor_base = 0;
+
+ tile_size = IgsTileSize(screen->fb[fb].bitsPerPixel) * IGS_NUM_PATTERN;
+ stipple_size = IgsStippleSize(screen->fb[fb].bitsPerPixel) * IGS_NUM_PATTERN;
+ pattern_size = tile_size + stipple_size;
+ if (memory >= pattern_size)
+ {
+ boffset = screen_size;
+ poffset = boffset * 8 / screen->fb[fb].bitsPerPixel;
+ igss->tile.offset = poffset;
+ igss->tile.base = igsc->frameBuffer + boffset;
+
+ boffset = screen_size + tile_size;
+ poffset = boffset * 8 / screen->fb[fb].bitsPerPixel;
+ igss->stipple.offset = poffset;
+ igss->stipple.base = igsc->frameBuffer + boffset;
+
+ memory -= pattern_size;
+ }
+ else
+ {
+ igss->tile.base = 0;
+ igss->stipple.base = 0;
+ }
+
switch (screen->fb[fb].depth) {
case 8:
screen->fb[fb].visuals = ((1 << StaticGray) |
@@ -112,11 +231,13 @@ igsScreenInit (KdScreenInfo *screen)
screen->fb[fb].redMask = 0xff0000;
break;
}
+
screen->fb[fb].pixelStride = screen->width;
screen->fb[fb].byteStride = screen->width * (screen->fb[fb].bitsPerPixel >> 3);
screen->fb[fb].frameBuffer = igsc->frameBuffer;
if (!igsc->cop)
screen->dumb = TRUE;
+ screen->driver = igss;
return TRUE;
}
@@ -129,16 +250,345 @@ igsInitScreen(ScreenPtr pScreen)
void
igsPreserve (KdCardInfo *card)
{
+ IgsCardInfo *igsc = card->driver;
+ IgsVga *igsvga = &igsc->igsvga;
+
+ igsSave (igsvga);
+}
+
+void
+igsSetBlank (IgsVga *igsvga, Bool blank)
+{
+ igsSetImm(igsvga, igs_screen_off, blank ? 1 : 0);
+}
+
+void
+igsSetSync (IgsCardInfo *igsc, int hsync, int vsync)
+{
+ IgsVga *igsvga = &igsc->igsvga;
+
+ igsSet (igsvga, igs_mexhsyn, hsync);
+ igsSet (igsvga, igs_mexvsyn, vsync);
+ VgaFlush (&igsvga->card);
+}
+
+
+/*
+ * Clock synthesis:
+ *
+ * scale = p ? (2 * p) : 1
+ * f_out = f_ref * ((M + 1) / ((N + 1) * scale))
+ *
+ * Constraints:
+ *
+ * 1. 115MHz <= f_ref * ((M + 1) / (N + 1)) <= 260 MHz
+ * 2. N >= 1
+ *
+ * Vertical refresh rate = clock / ((hsize + hblank) * (vsize + vblank))
+ * Horizontal refresh rate = clock / (hsize + hblank)
+ */
+
+/* all in kHz */
+
+void
+igsGetClock (int target, int *Mp, int *Np, int *Pp, int maxM, int maxN, int maxP, int minVco)
+{
+ int M, N, P, bestM, bestN;
+ int f_vco, f_out;
+ int err, abserr, besterr;
+
+ /*
+ * Compute correct P value to keep VCO in range
+ */
+ for (P = 0; P <= maxP; P++)
+ {
+ f_vco = target * IGS_SCALE(P);
+ if (f_vco >= minVco)
+ break;
+ }
+
+ /* M = f_out / f_ref * ((N + 1) * IGS_SCALE(P)); */
+ besterr = target;
+ for (N = 1; N <= maxN; N++)
+ {
+ M = ((target * (N + 1) * IGS_SCALE(P) + (IGS_CLOCK_REF/2)) + IGS_CLOCK_REF/2) / IGS_CLOCK_REF - 1;
+ if (0 <= M && M <= maxM)
+ {
+ f_out = IGS_CLOCK(M,N,P);
+ err = target - f_out;
+ if (err < 0)
+ err = -err;
+ if (err < besterr)
+ {
+ besterr = err;
+ bestM = M;
+ bestN = N;
+ }
+ }
+ }
+ *Mp = bestM;
+ *Np = bestN;
+ *Pp = P;
}
void
igsEnable (ScreenPtr pScreen)
{
+ KdScreenPriv(pScreen);
+ KdCardInfo *card = pScreenPriv->card;
+ KdScreenInfo *screen = pScreenPriv->screen;
+ IgsCardInfo *igsc = card->driver;
+ IgsVga *igsvga = &igsc->igsvga;
+ const KdMonitorTiming *t;
+ int hactive, hblank, hfp, hbp;
+ int vactive, vblank, vfp, vbp;
+ int hsize;
+ int fb = 0;
+ int m, n, r;
+ int h_total;
+ int h_display_end;
+ int h_blank_start;
+ int h_blank_end;
+ int h_sync_start;
+ int h_sync_end;
+ int h_screen_off;
+ int v_total;
+ int v_retrace_start;
+ int v_retrace_end;
+ int v_display_end;
+ int v_blank_start;
+ int v_blank_end;
+ int offset;
+ int num_fetch;
+ int m_m, m_n, m_r;
+
+
+ igsSetBlank (igsvga, TRUE);
+
+ t = KdFindMode (screen, igsModeSupported);
+
+ igsGetClock (t->clock, &m, &n, &r, 2047, 255, 7, IGS_MIN_VCO);
+
+ /*
+ * Set the chip so that 0x400000 is a big-endian frame buffer
+ * with the correct byte swapping enabled
+ */
+ igsSet (igsvga, igs_biga22force, 0);
+ igsSet (igsvga, igs_biga22en, 1);
+ igsSet (igsvga, igs_biga24en, 1);
+ /*
+ * Enable 8-bit DACs
+ */
+ igsSet (igsvga, igs_rampwdn, 0);
+ igsSet (igsvga, igs_dac6_8, 1);
+ igsSet (igsvga, igs_dacpwdn, 0);
+ /*
+ * Set overscan to black
+ */
+ igsSet (igsvga, igs_overscan_red, 0x00);
+ igsSet (igsvga, igs_overscan_green, 0x00);
+ igsSet (igsvga, igs_overscan_blue, 0x00);
+ /*
+ * Enable PCI retries
+ */
+ igsSet (igsvga, igs_iow_retry, 1);
+ igsSet (igsvga, igs_mw_retry, 1);
+ igsSet (igsvga, igs_mr_retry, 1);
+ igsSet (igsvga, igs_pci_burst_write, 1);
+ igsSet (igsvga, igs_pci_burst_read, 1);
+ /*
+ * Set FIFO
+ */
+ igsSet (igsvga, igs_memgopg, 1);
+ igsSet (igsvga, igs_memr2wpg, 0);
+ igsSet (igsvga, igs_crtff16, 0);
+ igsSet (igsvga, igs_fifomust, 0xff);
+ igsSet (igsvga, igs_fifogen, 0xff);
+ /*
+ * Enable CRT reg access
+ */
+ igsSetImm (igsvga, igs_ena_vr_access, 1);
+ igsSetImm (igsvga, igs_crt_protect, 0);
+
+ hfp = t->hfp;
+ hbp = t->hbp;
+ hblank = t->hblank;
+ hactive = t->horizontal;
+ offset = screen->fb[0].byteStride;
+
+ vfp = t->vfp;
+ vbp = t->vbp;
+ vblank = t->vblank;
+ vactive = t->vertical;
+
+ /*
+ * Compute character lengths for horizontal timing values
+ */
+ hactive = screen->width / 8;
+ hblank /= 8;
+ hfp /= 8;
+ hbp /= 8;
+ offset /= 8;
+
+ switch (screen->fb[fb].bitsPerPixel) {
+ case 8:
+ igsSet (igsvga, igs_overscan_red, pScreen->blackPixel);
+ igsSet (igsvga, igs_overscan_green, pScreen->blackPixel);
+ igsSet (igsvga, igs_overscan_blue, pScreen->blackPixel);
+ igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_8);
+ igsSet (igsvga, igs_mode_sel, IGS_MODE_8);
+ igsSet (igsvga, igs_ramdacbypass, 0);
+ break;
+ case 16:
+ igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_16);
+ igsSet (igsvga, igs_ramdacbypass, 1);
+ switch (screen->fb[fb].depth) {
+ case 12:
+ igsSet (igsvga, igs_mode_sel, IGS_MODE_4444);
+ break;
+ case 15:
+ igsSet (igsvga, igs_mode_sel, IGS_MODE_5551);
+ break;
+ case 16:
+ igsSet (igsvga, igs_mode_sel, IGS_MODE_565);
+ break;
+ }
+ break;
+ case 24:
+ igsSet (igsvga, igs_ramdacbypass, 1);
+ igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_8);
+ igsSet (igsvga, igs_mode_sel, IGS_MODE_888);
+ break;
+ case 32:
+ igsSet (igsvga, igs_ramdacbypass, 1);
+ igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_32);
+ igsSet (igsvga, igs_mode_sel, IGS_MODE_8888);
+ break;
+ }
+
+ /*
+ * Compute horizontal register values from timings
+ */
+ h_total = hactive + hblank - 5;
+ h_display_end = hactive - 1;
+
+ h_sync_start = hactive + hfp;
+ h_sync_end = hactive + hblank - hbp;
+ /*
+ * pad the blank values narrow a bit and use the border_select to
+ * eliminate the remaining border; don't know why, but it doesn't
+ * work in the documented fashion
+ */
+ h_blank_start = hactive - 1;
+ h_blank_end = hactive + hblank - 1 - 1;
+
+ num_fetch = (t->horizontal * screen->fb[fb].bitsPerPixel / 64) + 1;
+
+ v_total = vactive + vblank - 2;
+ v_display_end = vactive - 1;
+
+ v_blank_start = vactive - 1;
+ v_blank_end = v_blank_start + vblank - 1;
+
+ v_retrace_start = vactive + vfp;
+ v_retrace_end = vactive + vblank - vbp;
+
+#if 0
+#define chk(a,b,c) fprintf (stderr, "%20.20s: BIOS %6d X %6d\n", a, igsGet(igsvga, b), c);
+
+ chk("h_total", igs_h_total, h_total);
+ chk("h_display_end", igs_h_de_end, h_display_end);
+ chk("h_sync_start", igs_h_rstart, h_sync_start);
+ chk("h_sync_end", igs_h_rend, h_sync_end&0x1f);
+ chk("h_blank_start", igs_h_bstart, h_blank_start);
+ chk("h_blank_end", igs_h_bend, h_blank_end&0x3f);
+ chk("offset", igs_offset, offset);
+ chk("num_fetch", igs_num_fetch, num_fetch);
+
+ chk("v_total", igs_v_total, v_total);
+ chk("v_display_end", igs_v_de_end, v_display_end);
+ chk("v_blank_start", igs_v_bstart, v_blank_start);
+ chk("v_blank_end", igs_v_bend, v_blank_end&0xf);
+ chk("v_retrace_start", igs_v_rstart, v_retrace_start);
+ chk("v_retrace_end", igs_v_rend, v_retrace_end&0xf);
+ chk("vclk_m", igs_vclk_m, m);
+ chk("vclk_n", igs_vclk_n, n);
+ chk("vclk_p", igs_vclk_p, r);
+
+ fprintf (stderr, "%20.20s: BIOS %6d X %6d\n", "vclk",
+ IGS_CLOCK(igsGet(igsvga,igs_vclk_m),
+ igsGet(igsvga,igs_vclk_n),
+ igsGet(igsvga,igs_vclk_p)),
+ IGS_CLOCK(m,n,r));
+#endif
+ igsSet (igsvga, igs_h_total, h_total);
+ igsSet (igsvga, igs_h_de_end, h_display_end);
+ igsSet (igsvga, igs_h_rstart, h_sync_start);
+ igsSet (igsvga, igs_h_rend, h_sync_end);
+ igsSet (igsvga, igs_h_bstart, h_blank_start);
+ igsSet (igsvga, igs_h_bend, h_blank_end);
+ igsSet (igsvga, igs_offset, offset);
+ igsSet (igsvga, igs_num_fetch, num_fetch);
+
+ igsSet (igsvga, igs_v_total, v_total);
+ igsSet (igsvga, igs_v_de_end, v_display_end);
+ igsSet (igsvga, igs_v_bstart, v_blank_start);
+ igsSet (igsvga, igs_v_bend, v_blank_end&0xf);
+ igsSet (igsvga, igs_v_rstart, v_retrace_start);
+ igsSet (igsvga, igs_v_rend, v_retrace_end&0xf);
+
+ igsSet (igsvga, igs_vclk_m, m);
+ igsSet (igsvga, igs_vclk_n, n);
+ igsSet (igsvga, igs_vclk_p, r);
+ igsSet (igsvga, igs_vfsel, IGS_CLOCK(m, n, 0) >= 180000);
+ VgaFlush (&igsvga->card);
+
+ igsSetImm (igsvga, igs_frqlat, 0);
+ igsSetImm (igsvga, igs_frqlat, 1);
+ igsSetImm (igsvga, igs_frqlat, 0);
+
+ igsSetBlank (igsvga, FALSE);
+#if 0
+#define dbg(a,b) fprintf(stderr, "%20.20s = 0x%x\n", a, igsGet(igsvga,b))
+
+#include "reg.dbg"
+
+ {
+ VGA16 reg;
+ char buf[128];
+
+ for (reg = 0; reg < IGS_NREG; reg++)
+ fprintf(stderr, "%20.20s = 0x%02x\n", igsRegName(buf, reg),
+ VgaFetch (&igsvga->card, reg));
+ }
+#endif
}
Bool
igsDPMS (ScreenPtr pScreen, int mode)
{
+ KdScreenPriv(pScreen);
+ IgsCardInfo *igsc = pScreenPriv->card->driver;
+ IgsVga *igsvga = &igsc->igsvga;
+
+ switch (mode) {
+ case KD_DPMS_NORMAL:
+ igsSetSync (igsc, 0, 0);
+ igsSetBlank (igsvga, FALSE);
+ break;
+ case KD_DPMS_STANDBY:
+ igsSetBlank (igsvga, TRUE);
+ igsSetSync (igsc, 1, 0);
+ break;
+ case KD_DPMS_SUSPEND:
+ igsSetBlank (igsvga, TRUE);
+ igsSetSync (igsc, 0, 1);
+ break;
+ case KD_DPMS_POWERDOWN:
+ igsSetBlank (igsvga, TRUE);
+ igsSetSync (igsc, 1, 1);
+ break;
+ }
return TRUE;
}
@@ -150,11 +600,23 @@ igsDisable (ScreenPtr pScreen)
void
igsRestore (KdCardInfo *card)
{
+ IgsCardInfo *igsc = card->driver;
+ IgsVga *igsvga = &igsc->igsvga;
+
+ igsReset (igsvga);
}
void
igsScreenFini (KdScreenInfo *screen)
{
+ IgsScreenInfo *igss = (IgsScreenInfo *) screen->driver;
+
+#if BITMAP_BIT_ORDER == MSBFirst
+ if (igss->cursor_base)
+ KdUnmapDevice ((void *) igss->cursor_base, 1024);
+#endif
+ xfree (igss);
+ screen->driver = 0;
}
void
@@ -165,9 +627,11 @@ igsCardFini (KdCardInfo *card)
if (igsc->copData)
KdUnmapDevice ((void *) igsc->copData, IGS_COP_DATA_LEN);
if (igsc->cop)
- KdUnmapDevice (igsc->cop, sizeof (Cop5xxx));
+ KdUnmapDevice ((void *) igsc->cop, sizeof (Cop5xxx));
+ if (igsc->vga)
+ KdUnmapDevice ((void *) igsc->vga, 64 * 1024);
if (igsc->frameBuffer)
- KdUnmapDevice (igsc->frameBuffer, 4096 * 1024);
+ KdUnmapDevice (igsc->frameBuffer, IGS_MEM);
xfree (igsc);
card->driver = 0;
}
@@ -184,10 +648,10 @@ KdCardFuncs igsFuncs = {
igsScreenFini, /* scrfini */
igsCardFini, /* cardfini */
- 0, /* initCursor */
- 0, /* enableCursor */
- 0, /* disableCursor */
- 0, /* finiCursor */
+ igsCursorInit, /* initCursor */
+ igsCursorEnable, /* enableCursor */
+ igsCursorDisable, /* disableCursor */
+ igsCursorFini, /* finiCursor */
0, /* recolorCursor */
igsDrawInit, /* initAccel */
@@ -196,6 +660,6 @@ KdCardFuncs igsFuncs = {
igsDrawDisable, /* disableAccel */
igsDrawFini, /* finiAccel */
- 0, /* getColors */
- 0, /* putColors */
+ igsGetColors, /* getColors */
+ igsPutColors, /* putColors */
};
diff --git a/hw/kdrive/igs/igs.h b/hw/kdrive/igs/igs.h
index 9316ef249..86f65d9d6 100644
--- a/hw/kdrive/igs/igs.h
+++ b/hw/kdrive/igs/igs.h
@@ -1,5 +1,5 @@
/*
- * $XFree86$
+ * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igs.h,v 1.1 2000/05/06 22:17:43 keithp Exp $
*
* Copyright © 1999 SuSE, Inc.
*
@@ -27,6 +27,7 @@
#define _IGS_H_
#include "kdrive.h"
+#include "igsreg.h"
extern KdCardFuncs igsFuncs;
@@ -37,28 +38,50 @@ extern KdCardFuncs igsFuncs;
* Coprocessor 0x008bf000
*/
+#if BITMAP_BIT_ORDER == MSBFirst
+#define IGS_FB 0x00400000
+#else
+#define IGS_FB 0x00000000
+#endif
+#define IGS_VGA 0x00800000
#define IGS_COP_DATA 0x008a0000
#define IGS_COP_DATA_LEN 0x00010000
#define IGS_COP_OFFSET 0x008bf000
+/* give audio 1/2 meg at end */
+#if 1
+#define IGS_MEM ((4096-512)*1024)
+#else
+#define IGS_MEM ((4096)*1024)
+#endif
+
+#define IGS_CLOCK_REF 24576 /* KHz */
+
+#define IGS_SCALE(p) ((p) ? (2 * (p)) : 1)
+
+#define IGS_CLOCK(m,n,p) ((IGS_CLOCK_REF * ((m) + 1)) / (((n) + 1) * IGS_SCALE(p)))
+
+#define IGS_MAX_CLOCK 260000
+
+#define IGS_MIN_VCO 115000
typedef volatile CARD8 VOL8;
typedef volatile CARD16 VOL16;
typedef volatile CARD32 VOL32;
typedef struct _Cop5xxx {
- VOL8 pad000[0x11]; /* 0x000 */
+ VOL8 pad000[0x10]; /* 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
+ VOL32 control; /* 0x010 */
+#define IGS_CONTROL_HBLTW_RDYZ 0x0100
+#define IGS_CONTROL_MALLWBEPTZ 0x0200
+#define IGS_CONTROL_CMDFF 0x0400
+#define IGS_CONTROL_SOP 0x0800
+#define IGS_CONTROL_OPS 0x1000
+#define IGS_CONTROL_TER 0x2000
+#define IGS_CONTROL_HBACKZ 0x4000
+#define IGS_CONTROL_BUSY 0x8000
- VOL8 pad012[0x06]; /* 0x012 */
+ VOL8 pad014[0x04]; /* 0x014 */
VOL32 src1_stride; /* 0x018 */
@@ -110,8 +133,8 @@ typedef struct _Cop5xxx {
VOL32 src1_base_address; /* 0x070 */
VOL8 pad074[0x04]; /* 0x074 */
- VOL16 dst_x_rotate; /* 0x078 */
- VOL16 pat_y_rotate; /* 0x07a */
+ VOL32 rotate; /* 0x078 */
+#define IGS_MAKE_ROTATE(x,y) ((x) | ((y) << 16))
VOL32 operation; /* 0x07c */
/* OCT[2:0] */
@@ -146,6 +169,7 @@ typedef struct _Cop5xxx {
#define IGS_PIXEL_LINE_TRANS 0x00007000
#define IGS_PIXEL_FG 0x00008000
#define IGS_PIXEL_TILE 0x00009000
+#define IGS_PIXEL_TILE_OPAQUE 0x0000d000
/* HostBltEnable[1:0] */
#define IGS_HBLT_DISABLE 0x00000000
@@ -173,11 +197,10 @@ typedef struct _Cop5xxx {
/* BGS */
#define IGS_BGS_BG 0x00000000
#define IGS_BGS_SRC 0x80000000
- VOL8 pad080[0x91]; /* 0x080 */
+ VOL8 pad080[0x90]; /* 0x080 */
- VOL8 debug_control_1; /* 0x111 */
- VOL8 debug_control_2; /* 0x112 */
- VOL8 pad113[0x05]; /* 0x113 */
+ VOL32 debug_control; /* 0x110 */
+ VOL8 pad114[0x04]; /* 0x114 */
VOL32 src2_stride; /* 0x118 */
VOL8 pad11c[0x14]; /* 0x11c */
@@ -194,37 +217,82 @@ typedef struct _Cop5xxx {
#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 */
+ VOL32 style_line; /* 0x134 */
+#define IGS_MAKE_STILE_LINE(roll_over,inc,pattern,accumulator) \
+ ((roll_over) | \
+ ((style_line_inc) << 8) | \
+ ((style_line_patern) << 16) | \
+ ((style_line_accumullator) << 24))
+ VOL32 style_line_pattern_index; /* 0x138 */
- VOL16 mono_burst_total; /* 0x13c */
- VOL8 pad13e[0x12]; /* 0x13e */
+ VOL32 mono_burst_total; /* 0x13c */
+ VOL8 pad140[0x10]; /* 0x140 */
- VOL8 pat_x_rotate; /* 0x150 */
- VOL8 pad151[0x1f]; /* 0x151 */
+ VOL32 pat_x_rotate; /* 0x150 */
+ VOL8 pad154[0x1c]; /* 0x154 */
VOL32 src1_start; /* 0x170 */
VOL32 src2_start; /* 0x174 */
VOL32 dst_start; /* 0x178 */
VOL8 pad17c[0x9c]; /* 0x17c */
- VOL16 dst_stride; /* 0x218 */
+ VOL32 dst_stride; /* 0x218 */
} Cop5xxx;
typedef struct _igsCardInfo {
Cop5xxx *cop;
+ VOL8 *vga;
VOL32 *copData;
- Bool need_sync;
CARD8 *frameBuffer;
+ IgsVga igsvga;
} IgsCardInfo;
#define getIgsCardInfo(kd) ((IgsCardInfo *) ((kd)->card->driver))
#define igsCardInfo(kd) IgsCardInfo *igsc = getIgsCardInfo(kd)
+typedef struct _igsCursor {
+ int width, height;
+ int xhot, yhot;
+ Bool has_cursor;
+ CursorPtr pCursor;
+ Pixel source, mask;
+} IgsCursor;
+
+#define IGS_CURSOR_WIDTH 64
+#define IGS_CURSOR_HEIGHT 64
+
+typedef struct _igsPattern {
+ INT32 xrot, yrot;
+ CARD32 serial_number;
+ CARD8 *base;
+ CARD32 offset;
+} IgsPattern;
+
+#define IGS_NUM_PATTERN 8
+#define IGS_PATTERN_WIDTH 8
+#define IGS_PATTERN_HEIGHT 8
+
+typedef struct _igsPatternCache {
+ CARD8 *base;
+ CARD32 offset;
+ IgsPattern pattern[IGS_NUM_PATTERN];
+ int next;
+} IgsPatternCache;
+
+typedef struct _igsScreenInfo {
+ CARD8 *cursor_base;
+ CARD32 cursor_offset;
+ IgsCursor cursor;
+ IgsPatternCache tile;
+ IgsPatternCache stipple;
+} IgsScreenInfo;
+
+#define IgsTileSize(bpp) (IGS_PATTERN_WIDTH*(bpp)/8*IGS_PATTERN_HEIGHT)
+#define IgsStippleSize(bpp) (IGS_PATTERN_WIDTH/8*IGS_PATTERN_HEIGHT)
+
+#define getIgsScreenInfo(kd) ((IgsScreenInfo *) ((kd)->screen->driver))
+#define igsScreenInfo(kd) IgsScreenInfo *igss = getIgsScreenInfo(kd)
+
Bool
igsDrawInit (ScreenPtr pScreen);
@@ -240,5 +308,22 @@ igsDrawSync (ScreenPtr pScreen);
void
igsDrawFini (ScreenPtr pScreen);
-
+void
+igsGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs);
+
+void
+igsPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs);
+
+Bool
+igsCursorInit (ScreenPtr pScreen);
+
+void
+igsCursorEnable (ScreenPtr pScreen);
+
+void
+igsCursorDisable (ScreenPtr pScreen);
+
+void
+igsCursorFini (ScreenPtr pScreen);
+
#endif /* _IGS_H_ */
diff --git a/hw/kdrive/igs/igscmap.c b/hw/kdrive/igs/igscmap.c
new file mode 100644
index 000000000..b6cc93538
--- /dev/null
+++ b/hw/kdrive/igs/igscmap.c
@@ -0,0 +1,61 @@
+/*
+ * $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"
+
+#define IGS_DAC_SHIFT 8
+void
+igsGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
+{
+ KdScreenPriv(pScreen);
+ igsCardInfo(pScreenPriv);
+ IgsVga *igsvga = &igsc->igsvga;
+
+ while (ndef--)
+ {
+ igsSetImm (igsvga, igs_dac_read_index, pdefs->pixel);
+ pdefs->red = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT;
+ pdefs->green = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT;
+ pdefs->blue = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT;
+ pdefs++;
+ }
+}
+
+void
+igsPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
+{
+ KdScreenPriv(pScreen);
+ igsCardInfo(pScreenPriv);
+ IgsVga *igsvga = &igsc->igsvga;
+
+ while (ndef--)
+ {
+ igsSetImm (igsvga, igs_dac_write_index, pdefs->pixel);
+ igsSetImm (igsvga, igs_dac_data, pdefs->red >> IGS_DAC_SHIFT);
+ igsSetImm (igsvga, igs_dac_data, pdefs->green >> IGS_DAC_SHIFT);
+ igsSetImm (igsvga, igs_dac_data, pdefs->blue >> IGS_DAC_SHIFT);
+ pdefs++;
+ }
+}
+
diff --git a/hw/kdrive/igs/igscurs.c b/hw/kdrive/igs/igscurs.c
new file mode 100644
index 000000000..9c330b80f
--- /dev/null
+++ b/hw/kdrive/igs/igscurs.c
@@ -0,0 +1,344 @@
+/*
+ * $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 "cursorstr.h"
+
+#define SetupCursor(s) KdScreenPriv(s); \
+ igsCardInfo(pScreenPriv); \
+ igsScreenInfo(pScreenPriv); \
+ IgsCursor *pCurPriv = &igss->cursor; \
+ IgsVga *igsvga = &igsc->igsvga
+
+static void
+_igsMoveCursor (ScreenPtr pScreen, int x, int y)
+{
+ SetupCursor(pScreen);
+ CARD8 xoff, yoff;
+
+ x -= pCurPriv->xhot;
+ xoff = 0;
+ if (x < 0)
+ {
+ xoff = -x;
+ x = 0;
+ }
+ y -= pCurPriv->yhot;
+ yoff = 0;
+ if (y < 0)
+ {
+ yoff = -y;
+ y = 0;
+ }
+
+ igsSet (igsvga, igs_sprite_x, x);
+ igsSet (igsvga, igs_sprite_preset_x, xoff);
+ igsSet (igsvga, igs_sprite_y, y);
+ igsSet (igsvga, igs_sprite_preset_y, yoff);
+}
+
+static void
+igsMoveCursor (ScreenPtr pScreen, int x, int y)
+{
+ SetupCursor (pScreen);
+
+ if (!pCurPriv->has_cursor)
+ return;
+
+ if (!pScreenPriv->enabled)
+ return;
+
+ _igsMoveCursor (pScreen, x, y);
+ VgaFlush (&igsvga->card);
+}
+
+
+static void
+igsSetCursorColors (ScreenPtr pScreen)
+{
+ SetupCursor (pScreen);
+ CursorPtr pCursor = pCurPriv->pCursor;
+
+ igsSetImm (igsvga, igs_cursor_write_index, 0);
+ igsSetImm (igsvga, igs_cursor_data, pCursor->backRed >> 8);
+ igsSetImm (igsvga, igs_cursor_data, pCursor->backGreen >> 8);
+ igsSetImm (igsvga, igs_cursor_data, pCursor->backBlue >> 8);
+ igsSetImm (igsvga, igs_cursor_write_index, 1);
+ igsSetImm (igsvga, igs_cursor_data, pCursor->foreRed >> 8);
+ igsSetImm (igsvga, igs_cursor_data, pCursor->foreGreen >> 8);
+ igsSetImm (igsvga, igs_cursor_data, pCursor->foreBlue >> 8);
+}
+
+#if BITMAP_BIT_ORDER == MSBFirst
+#define IgsAdjustCursor(v) { \
+ v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
+ v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
+ v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
+ v = ((v & 0x00ff00ff) << 8) | ((v >> 8) & 0x00ff00ff); \
+ v = ((v & 0x0000ffff) <<16) | ((v >>16) & 0x0000ffff); \
+}
+#else
+#define IgsAdjustCursor(v)
+#endif
+
+#define ExplodeBits2(v) (((v) & 1) | (((v) & 2) << 1))
+#define ExplodeBits4(v) ((ExplodeBits2((v) >> 2) << 4) | \
+ (ExplodeBits2((v) & 0x3)))
+#define ExplodeBits8(v) ((ExplodeBits4((v) >> 4) << 8) | \
+ (ExplodeBits4((v) & 0xf)))
+#define ExplodeBits16(v) ((ExplodeBits8((v) >> 8) << 16) | \
+ (ExplodeBits8((v) & 0xff)))
+static void
+igsLoadCursor (ScreenPtr pScreen, int x, int y)
+{
+ SetupCursor(pScreen);
+ CursorPtr pCursor = pCurPriv->pCursor;
+ CursorBitsPtr bits = pCursor->bits;
+ int w, h;
+ CARD32 *ram, *msk, *mskLine, *src, *srcLine;
+ int i, j;
+ int cursor_address;
+ int lwsrc;
+ unsigned char ramdac_control_;
+ CARD32 offset;
+ CARD32 b0, b1;
+
+ pCurPriv->pCursor = pCursor;
+ pCurPriv->xhot = pCursor->bits->xhot;
+ pCurPriv->yhot = pCursor->bits->yhot;
+
+ /*
+ * Stick new image into cursor memory
+ */
+ ram = (CARD32 *) igss->cursor_base;
+ mskLine = (CARD32 *) bits->mask;
+ srcLine = (CARD32 *) bits->source;
+
+ h = bits->height;
+ if (h > IGS_CURSOR_HEIGHT)
+ h = IGS_CURSOR_HEIGHT;
+
+ lwsrc = BitmapBytePad(bits->width) / 4; /* words per line */
+
+ for (i = 0; i < IGS_CURSOR_HEIGHT; i++) {
+ msk = mskLine;
+ src = srcLine;
+ mskLine += lwsrc;
+ srcLine += lwsrc;
+ for (j = 0; j < IGS_CURSOR_WIDTH / 32; j++) {
+
+ CARD32 m, s;
+
+ if (i < h && j < lwsrc)
+ {
+ m = *msk++;
+ s = *src++;
+ IgsAdjustCursor(m);
+ IgsAdjustCursor(s);
+ }
+ else
+ {
+ m = 0;
+ s = 0;
+ }
+ s &= m;
+ m = ~m;
+ b0 = ExplodeBits16(s&0xffff) | (ExplodeBits16(m&0xffff)<<1);
+ b1 = ExplodeBits16(s>>16) | (ExplodeBits16(m>>16)<<1);
+ *ram++ = b0;
+ *ram++ = b1;
+ }
+ }
+
+ /* Set new color */
+ igsSetCursorColors (pScreen);
+
+ /* Set address for cursor bits */
+ offset = igss->cursor_offset;
+ offset >>= 10;
+ igsSet (igsvga, igs_sprite_addr, offset);
+
+ /* Assume TV interpolation off */
+ igsSet (igsvga, igs_hcshf, 3);
+ /* Enable the cursor */
+ igsSet (igsvga, igs_sprite_visible, 1);
+ igsSet (igsvga, igs_sprite_64x64, 1);
+ /* Move to new position */
+ _igsMoveCursor (pScreen, x, y);
+
+ VgaFlush (&igsvga->card);
+}
+
+static void
+igsUnloadCursor (ScreenPtr pScreen)
+{
+ SetupCursor (pScreen);
+
+ /* Disable cursor */
+ igsSet (igsvga, igs_sprite_visible, 0);
+ VgaFlush (&igsvga->card);
+}
+
+static Bool
+igsRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
+{
+ SetupCursor(pScreen);
+
+ if (!pScreenPriv->enabled)
+ return TRUE;
+
+ /* miRecolorCursor does this */
+ if (pCurPriv->pCursor == pCursor)
+ {
+ if (pCursor)
+ {
+ int x, y;
+
+ miPointerPosition (&x, &y);
+ igsLoadCursor (pScreen, x, y);
+ }
+ }
+ return TRUE;
+}
+
+static Bool
+igsUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
+{
+ return TRUE;
+}
+
+static void
+igsSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
+{
+ SetupCursor(pScreen);
+
+ pCurPriv->pCursor = pCursor;
+
+ if (!pScreenPriv->enabled)
+ return;
+
+ if (pCursor)
+ igsLoadCursor (pScreen, x, y);
+ else
+ igsUnloadCursor (pScreen);
+}
+
+miPointerSpriteFuncRec igsPointerSpriteFuncs = {
+ igsRealizeCursor,
+ igsUnrealizeCursor,
+ igsSetCursor,
+ igsMoveCursor,
+};
+
+static void
+igsQueryBestSize (int class,
+ unsigned short *pwidth, unsigned short *pheight,
+ ScreenPtr pScreen)
+{
+ SetupCursor (pScreen);
+
+ switch (class)
+ {
+ case CursorShape:
+ if (*pwidth > pCurPriv->width)
+ *pwidth = pCurPriv->width;
+ if (*pheight > pCurPriv->height)
+ *pheight = pCurPriv->height;
+ if (*pwidth > pScreen->width)
+ *pwidth = pScreen->width;
+ if (*pheight > pScreen->height)
+ *pheight = pScreen->height;
+ break;
+ default:
+ fbQueryBestSize (class, pwidth, pheight, pScreen);
+ break;
+ }
+}
+
+Bool
+igsCursorInit (ScreenPtr pScreen)
+{
+ SetupCursor (pScreen);
+
+ if (!igss->cursor_base)
+ {
+ pCurPriv->has_cursor = FALSE;
+ return FALSE;
+ }
+
+ pCurPriv->width = IGS_CURSOR_WIDTH;
+ pCurPriv->height= IGS_CURSOR_HEIGHT;
+ pScreen->QueryBestSize = igsQueryBestSize;
+ miPointerInitialize (pScreen,
+ &igsPointerSpriteFuncs,
+ &kdPointerScreenFuncs,
+ FALSE);
+ pCurPriv->has_cursor = TRUE;
+ pCurPriv->pCursor = NULL;
+ return TRUE;
+}
+
+void
+igsCursorEnable (ScreenPtr pScreen)
+{
+ SetupCursor (pScreen);
+
+ if (pCurPriv->has_cursor)
+ {
+ if (pCurPriv->pCursor)
+ {
+ int x, y;
+
+ miPointerPosition (&x, &y);
+ igsLoadCursor (pScreen, x, y);
+ }
+ else
+ igsUnloadCursor (pScreen);
+ }
+}
+
+void
+igsCursorDisable (ScreenPtr pScreen)
+{
+ SetupCursor (pScreen);
+
+ if (!pScreenPriv->enabled)
+ return;
+
+ if (pCurPriv->has_cursor)
+ {
+ if (pCurPriv->pCursor)
+ {
+ igsUnloadCursor (pScreen);
+ }
+ }
+}
+
+void
+igsCursorFini (ScreenPtr pScreen)
+{
+ SetupCursor (pScreen);
+
+ pCurPriv->pCursor = NULL;
+}
diff --git a/hw/kdrive/igs/igsdraw.c b/hw/kdrive/igs/igsdraw.c
index 43ca7cf6e..be46dc438 100644
--- a/hw/kdrive/igs/igsdraw.c
+++ b/hw/kdrive/igs/igsdraw.c
@@ -1,5 +1,5 @@
/*
- * $XFree86$
+ * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igsdraw.c,v 1.1 2000/05/06 22:17:43 keithp Exp $
*
* Copyright © 2000 Keith Packard
*
@@ -72,6 +72,105 @@ CARD8 igsPatRop[16] = {
#define PixTransStore(t) *pix_trans = (t)
#endif
+static IgsPattern *
+igsSetPattern (ScreenPtr pScreen,
+ PixmapPtr pPixmap,
+ CARD8 fillStyle,
+ INT32 xrot,
+ INT32 yrot)
+{
+ KdScreenPriv(pScreen);
+ igsCardInfo(pScreenPriv);
+ igsScreenInfo(pScreenPriv);
+ int i;
+ IgsPatternCache *c;
+ IgsPattern *p;
+
+ if (fillStyle == FillTiled)
+ c = &igss->tile;
+ else
+ c = &igss->stipple;
+ for (i = 0; i < IGS_NUM_PATTERN; i++)
+ {
+ p = &c->pattern[i];
+ if (p->serial_number == pPixmap->drawable.serialNumber &&
+ p->xrot == xrot &&
+ p->yrot == yrot)
+ {
+ return p;
+ }
+ }
+ p = &c->pattern[c->next];
+ if (++c->next == IGS_NUM_PATTERN)
+ c->next = 0;
+ p->serial_number = pPixmap->drawable.serialNumber;
+ p->xrot = xrot;
+ p->yrot = yrot;
+
+ if (fillStyle != FillTiled)
+ {
+ FbStip *pix;
+ FbStride pixStride;
+ int pixBpp;
+ CARD8 tmp[8];
+ CARD32 *pat;
+ int stipX, stipY;
+ int y;
+ FbStip bits;
+
+ modulus (-yrot, pPixmap->drawable.height, stipY);
+ modulus (-xrot, FB_UNIT, stipX);
+
+ pat = (CARD32 *) p->base;
+
+ fbGetStipDrawable (&pPixmap->drawable, pix, pixStride, pixBpp);
+
+ for (y = 0; y < 8; y++)
+ {
+ bits = pix[stipY * pixStride];
+ FbRotLeft (bits, stipX);
+ tmp[y] = (CARD8) bits;
+ stipY++;
+ if (stipY == pPixmap->drawable.height)
+ stipY = 0;
+ }
+ for (i = 0; i < 2; i++)
+ {
+ bits = (tmp[i*4+0] |
+ (tmp[i*4+1] << 8) |
+ (tmp[i*4+2] << 16) |
+ (tmp[i*4+3] << 24));
+ IgsAdjustBits32 (bits);
+ *pat++ = bits;
+ }
+ }
+ else
+ {
+ FbBits *pix;
+ FbStride pixStride;
+ int pixBpp;
+ FbBits *pat;
+ FbStride patStride;
+ int patBpp;
+
+ fbGetDrawable (&pPixmap->drawable, pix, pixStride, pixBpp);
+
+ pat = (FbBits *) p->base;
+ patBpp = pixBpp;
+ patStride = (patBpp * IGS_PATTERN_WIDTH) / (8 * sizeof (FbBits));
+
+ fbTile (pat, patStride, 0,
+ patBpp * IGS_PATTERN_WIDTH, IGS_PATTERN_HEIGHT,
+
+ pix, pixStride,
+ pPixmap->drawable.width * pixBpp,
+ pPixmap->drawable.height,
+ GXcopy, FB_ALLONES, pixBpp,
+ xrot * pixBpp, yrot);
+ }
+ return p;
+}
+
void
igsFillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
unsigned long pixel, int alu, unsigned long planemask)
@@ -89,6 +188,122 @@ igsFillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
}
void
+igsFillBoxTiled (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
+ PixmapPtr pPixmap, int xrot, int yrot, int alu)
+{
+ SetupIgs(pDrawable->pScreen);
+ CARD32 cmd;
+ IgsPattern *p = igsSetPattern (pDrawable->pScreen,
+ pPixmap,
+ FillTiled,
+ xrot, yrot);
+
+ _igsSetTiledRect(cop,alu,planemask,p->offset,cmd);
+ while (nBox--)
+ {
+ _igsPatRect(cop,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd);
+ pBox++;
+ }
+ KdMarkSync (pDrawable->pScreen);
+}
+
+void
+igsFillBoxStippled (DrawablePtr pDrawable, GCPtr pGC,
+ int nBox, BoxPtr pBox)
+{
+ SetupIgs(pDrawable->pScreen);
+ CARD32 cmd;
+ int xrot = pGC->patOrg.x + pDrawable->x;
+ int yrot = pGC->patOrg.y + pDrawable->y;
+ IgsPattern *p = igsSetPattern (pDrawable->pScreen,
+ pGC->stipple,
+ pGC->fillStyle,
+ xrot, yrot);
+ if (pGC->fillStyle == FillStippled)
+ {
+ _igsSetStippledRect (cop,pGC->alu,planemask,pGC->fgPixel,p->offset,cmd);
+ }
+ else
+ {
+ _igsSetOpaqueStippledRect (cop,pGC->alu,planemask,
+ pGC->fgPixel,pGC->bgPixel,p->offset,cmd);
+ }
+ while (nBox--)
+ {
+ _igsPatRect(cop,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd);
+ pBox++;
+ }
+ KdMarkSync (pDrawable->pScreen);
+}
+
+
+void
+igsStipple (ScreenPtr pScreen,
+ CARD32 cmd,
+ FbStip *psrcBase,
+ FbStride widthSrc,
+ int srcx,
+ int srcy,
+ int dstx,
+ int dsty,
+ int width,
+ int height)
+{
+ SetupIgs(pScreen);
+ FbStip *psrcLine, *psrc;
+ FbStride widthRest;
+ FbStip bits, tmp, lastTmp;
+ int leftShift, rightShift;
+ int nl, nlMiddle;
+ int r;
+ PixTransDeclare;
+
+ /* Compute blt address and parameters */
+ psrc = psrcBase + srcy * widthSrc + (srcx >> 5);
+ nlMiddle = (width + 31) >> 5;
+ leftShift = srcx & 0x1f;
+ rightShift = 32 - leftShift;
+ widthRest = widthSrc - nlMiddle;
+
+ _igsPlaneBlt(cop,dstx,dsty,width,height,cmd);
+
+ if (leftShift == 0)
+ {
+ while (height--)
+ {
+ nl = nlMiddle;
+ PixTransStart(nl);
+ while (nl--)
+ {
+ tmp = *psrc++;
+ IgsAdjustBits32 (tmp);
+ PixTransStore (tmp);
+ }
+ psrc += widthRest;
+ }
+ }
+ else
+ {
+ widthRest--;
+ while (height--)
+ {
+ bits = *psrc++;
+ nl = nlMiddle;
+ PixTransStart(nl);
+ while (nl--)
+ {
+ tmp = FbStipLeft(bits, leftShift);
+ bits = *psrc++;
+ tmp |= FbStipRight(bits, rightShift);
+ IgsAdjustBits32(tmp);
+ PixTransStore (tmp);
+ }
+ psrc += widthRest;
+ }
+ }
+}
+
+void
igsCopyNtoN (DrawablePtr pSrcDrawable,
DrawablePtr pDstDrawable,
GCPtr pGC,
@@ -164,6 +379,134 @@ igsCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
srcx, srcy, width, height, dstx, dsty);
}
+typedef struct _igs1toNargs {
+ unsigned long copyPlaneFG, copyPlaneBG;
+ Bool opaque;
+} igs1toNargs;
+
+void
+igsCopy1toN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ SetupIgs(pDstDrawable->pScreen);
+
+ igs1toNargs *args = closure;
+ int dstx, dsty;
+ FbStip *psrcBase;
+ FbStride widthSrc;
+ int srcBpp;
+ CARD32 cmd;
+
+ if (args->opaque && sourceInvarient (pGC->alu))
+ {
+ igsFillBoxSolid (pDstDrawable, nbox, pbox,
+ pGC->bgPixel, pGC->alu, pGC->planemask);
+ return;
+ }
+
+ fbGetStipDrawable (pSrcDrawable, psrcBase, widthSrc, srcBpp);
+
+ if (args->opaque)
+ {
+ _igsSetOpaquePlaneBlt (cop, pGC->alu, pGC->planemask, args->copyPlaneFG,
+ args->copyPlaneBG, cmd);
+ }
+ else
+ {
+ _igsSetTransparentPlaneBlt (cop, pGC->alu, pGC->planemask,
+ args->copyPlaneFG, cmd);
+ }
+
+ while (nbox--)
+ {
+ dstx = pbox->x1;
+ dsty = pbox->y1;
+
+ igsStipple (pDstDrawable->pScreen, cmd,
+ psrcBase, widthSrc,
+ dstx + dx, dsty + dy,
+ dstx, dsty,
+ pbox->x2 - dstx, pbox->y2 - dsty);
+ pbox++;
+ }
+ KdMarkSync (pDstDrawable->pScreen);
+}
+
+RegionPtr
+igsCopyPlane (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty,
+ unsigned long bitPlane)
+{
+ RegionPtr ret;
+ igs1toNargs args;
+ FbBits depthMask;
+
+ depthMask = FbFullMask (pDstDrawable->depth);
+ if ((pGC->planemask & depthMask) == depthMask &&
+ pDstDrawable->type == DRAWABLE_WINDOW &&
+ pSrcDrawable->depth == 1)
+ {
+ args.copyPlaneFG = pGC->fgPixel;
+ args.copyPlaneBG = pGC->bgPixel;
+ args.opaque = TRUE;
+ return fbDoCopy (pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height,
+ dstx, dsty, igsCopy1toN, bitPlane, &args);
+ }
+ return KdCheckCopyPlane(pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height,
+ dstx, dsty, bitPlane);
+}
+
+#if 0
+/* would you believe this is slower than fb? */
+void
+igsPushPixels (GCPtr pGC,
+ PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int w,
+ int h,
+ int x,
+ int y)
+{
+ igs1toNargs args;
+ FbBits depthMask;
+
+ depthMask = FbFullMask (pDstDrawable->depth);
+ if ((pGC->planemask & depthMask) == depthMask &&
+ pDrawable->type == DRAWABLE_WINDOW &&
+ pGC->fillStyle == FillSolid)
+ {
+ args.opaque = FALSE;
+ args.copyPlaneFG = pGC->fgPixel;
+ (void) fbDoCopy ((DrawablePtr) pBitmap, pDrawable, pGC,
+ 0, 0, w, h, x, y, igsCopy1toN, 1, &args);
+ }
+ else
+ {
+ KdCheckPushPixels (pGC, pBitmap, pDrawable, w, h, x, y);
+ }
+}
+#else
+#define igsPushPixels KdCheckPushPixels
+#endif
+
BOOL
igsFillOk (GCPtr pGC)
{
@@ -175,7 +518,6 @@ igsFillOk (GCPtr pGC)
switch (pGC->fillStyle) {
case FillSolid:
return TRUE;
-#if 0
case FillTiled:
return (igsPatternDimOk (pGC->tile.pixmap->drawable.width) &&
igsPatternDimOk (pGC->tile.pixmap->drawable.height));
@@ -183,7 +525,6 @@ igsFillOk (GCPtr pGC)
case FillOpaqueStippled:
return (igsPatternDimOk (pGC->stipple->drawable.width) &&
igsPatternDimOk (pGC->stipple->drawable.height));
-#endif
}
return FALSE;
}
@@ -200,6 +541,7 @@ igsFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
int nTmp;
INT16 x, y;
int width;
+ IgsPattern *p;
if (!igsFillOk (pGC))
{
@@ -224,17 +566,31 @@ igsFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
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);
+ p = igsSetPattern (pDrawable->pScreen,
+ pGC->tile.pixmap,
+ FillTiled,
+ pGC->patOrg.x + pDrawable->x,
+ pGC->patOrg.y + pDrawable->y);
+ _igsSetTiledRect (cop,pGC->alu,pGC->planemask,p->offset,cmd);
break;
default:
- cmd = igsStipplePrepare (pDrawable, pGC);
+ p = igsSetPattern (pDrawable->pScreen,
+ pGC->stipple,
+ pGC->fillStyle,
+ pGC->patOrg.x + pDrawable->x,
+ pGC->patOrg.y + pDrawable->y);
+ if (pGC->fillStyle == FillStippled)
+ {
+ _igsSetStippledRect (cop,pGC->alu,pGC->planemask,
+ pGC->fgPixel,p->offset,cmd);
+ }
+ else
+ {
+ _igsSetOpaqueStippledRect (cop,pGC->alu,pGC->planemask,
+ pGC->fgPixel,pGC->bgPixel,p->offset,cmd);
+ }
break;
-#endif
}
while (n--)
{
@@ -244,7 +600,7 @@ igsFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
width = *pwidth++;
if (width)
{
- _igsRect(cop,x,y,width,1,cmd);
+ _igsPatRect(cop,x,y,width,1,cmd);
}
}
DEALLOCATE_LOCAL(pptFree);
@@ -407,7 +763,6 @@ igsPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
pboxClipped-pboxClippedBase, pboxClippedBase,
pGC->fgPixel, pGC->alu, pGC->planemask);
break;
-#if 0
case FillTiled:
igsFillBoxTiled(pDrawable,
pboxClipped-pboxClippedBase, pboxClippedBase,
@@ -418,10 +773,9 @@ igsPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
break;
case FillStippled:
case FillOpaqueStippled:
- igsFillBoxStipple (pDrawable, pGC,
- pboxClipped-pboxClippedBase, pboxClippedBase);
+ igsFillBoxStippled (pDrawable, pGC,
+ pboxClipped-pboxClippedBase, pboxClippedBase);
break;
-#endif
}
}
if (pboxClippedBase != stackRects)
@@ -834,6 +1188,12 @@ igsPolyGlyphBlt (DrawablePtr pDrawable,
CharInfoPtr *ppci,
pointer pglyphBase)
{
+ if (pGC->fillStyle != FillSolid ||
+ fbGetGCPrivate(pGC)->pm != FB_ALLONES)
+ {
+ KdCheckPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ return;
+ }
x += pDrawable->x;
y += pDrawable->y;
@@ -860,6 +1220,11 @@ igsImageGlyphBlt (DrawablePtr pDrawable,
CharInfoPtr *ppci,
pointer pglyphBase)
{
+ if (fbGetGCPrivate(pGC)->pm != FB_ALLONES)
+ {
+ KdCheckImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ return;
+ }
x += pDrawable->x;
y += pDrawable->y;
@@ -878,12 +1243,48 @@ igsImageGlyphBlt (DrawablePtr pDrawable,
}
}
+static void
+igsInvalidatePattern (IgsPatternCache *c,
+ PixmapPtr pPixmap)
+{
+ int i;
+
+ if (c->base)
+ {
+ for (i = 0; i < IGS_NUM_PATTERN; i++)
+ {
+ if (c->pattern[i].serial_number == pPixmap->drawable.serialNumber)
+ c->pattern[i].serial_number = ~0;
+ }
+ }
+}
+
+static void
+igsInitPattern (IgsPatternCache *c, int bsize, int psize)
+{
+ int i;
+ int boffset;
+ int poffset;
+
+ for (i = 0; i < IGS_NUM_PATTERN; i++)
+ {
+ boffset = i * bsize;
+ poffset = i * psize;
+ c->pattern[i].xrot = -1;
+ c->pattern[i].yrot = -1;
+ c->pattern[i].serial_number = ~0;
+ c->pattern[i].offset = c->offset + poffset;
+ c->pattern[i].base = c->base + boffset;
+ }
+ c->next = 0;
+}
+
static const GCOps igsOps = {
igsFillSpans,
KdCheckSetSpans,
KdCheckPutImage,
igsCopyArea,
- KdCheckCopyPlane,
+ igsCopyPlane,
KdCheckPolyPoint,
KdCheckPolylines,
KdCheckPolySegment,
@@ -898,7 +1299,7 @@ static const GCOps igsOps = {
miImageText16,
igsImageGlyphBlt,
igsPolyGlyphBlt,
- KdCheckPushPixels,
+ igsPushPixels,
#ifdef NEED_LINEHELPER
,NULL
#endif
@@ -985,7 +1386,6 @@ igsPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
(*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
what);
return;
-#if 0
case BackgroundPixmap:
pTile = pWin->background.pixmap;
if (igsPatternDimOk (pTile->drawable.width) &&
@@ -999,7 +1399,6 @@ igsPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
return;
}
break;
-#endif
case BackgroundPixel:
igsFillBoxSolid((DrawablePtr)pWin,
(int)REGION_NUM_RECTS(pRegion),
@@ -1017,7 +1416,6 @@ igsPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
pWin->border.pixel, GXcopy, ~0);
return;
}
-#if 0
else
{
pTile = pWin->border.pixmap;
@@ -1032,7 +1430,6 @@ igsPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
return;
}
}
-#endif
break;
}
KdCheckPaintWindow (pWin, pRegion, what);
@@ -1041,6 +1438,15 @@ igsPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
Bool
igsDrawInit (ScreenPtr pScreen)
{
+ KdScreenPriv(pScreen);
+ igsCardInfo(pScreenPriv);
+ igsScreenInfo(pScreenPriv);
+ int i;
+ int pattern_size;
+ int boffset, poffset;
+
+ KdScreenInitAsync (pScreen);
+
/*
* Replace various fb screen functions
*/
@@ -1049,8 +1455,20 @@ igsDrawInit (ScreenPtr pScreen)
pScreen->PaintWindowBackground = igsPaintWindow;
pScreen->PaintWindowBorder = igsPaintWindow;
- KdScreenInitAsync (pScreen);
-
+ /*
+ * Initialize patterns
+ */
+ if (igss->tile.base)
+ {
+ pattern_size = IgsTileSize(pScreenPriv->screen->fb[0].bitsPerPixel);
+ igsInitPattern (&igss->tile,
+ pattern_size,
+ pattern_size * 8 / pScreenPriv->screen->fb[0].bitsPerPixel);
+ pattern_size = IgsStippleSize(pScreenPriv->screen->fb[0].bitsPerPixel);
+ igsInitPattern (&igss->stipple,
+ pattern_size,
+ pattern_size * 8 / pScreenPriv->screen->fb[0].bitsPerPixel);
+ }
return TRUE;
}
diff --git a/hw/kdrive/igs/igsdraw.h b/hw/kdrive/igs/igsdraw.h
index 5388d8e34..7b561fd55 100644
--- a/hw/kdrive/igs/igsdraw.h
+++ b/hw/kdrive/igs/igsdraw.h
@@ -1,5 +1,5 @@
/*
- * $XFree86$
+ * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igsdraw.h,v 1.1 2000/05/06 22:17:43 keithp Exp $
*
* Copyright © 2000 Keith Packard
*
@@ -46,9 +46,13 @@ extern CARD8 igsPatRop[];
IGS_CONTROL_MALLWBEPTZ), \
0)
+#if 1
#define _igsWaitFull(cop) _igsWaitLoop(cop, \
IGS_CONTROL_CMDFF, \
0)
+#else
+#define _igsWaitFull(cop) _igsWaitDone(cop)
+#endif
#define _igsWaitIdleEmpty(cop) _igsWaitDone(cop)
#define _igsWaitHostBltAck(cop) _igsWaitLoop(cop, \
@@ -76,13 +80,27 @@ extern CARD8 igsPatRop[];
v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \
}
-#define IgsAdjustBits32(b) IgsInvertBits32(b)
+#define IgsByteSwap32(x) ((x) = (((x) >> 24) | \
+ (((x) >> 8) & 0xff00) | \
+ (((x) << 8) & 0xff0000) | \
+ ((x) << 24)))
+
+#define IgsByteSwap16(x) ((x) = ((x) << 8) | ((x) >> 8))
+
+#define igsPatternDimOk(d) ((d) <= IGS_PATTERN_WIDTH && (((d) & ((d) - 1)) == 0))
+
+#if BITMAP_BIT_ORDER == LSBFirst
+#define IgsAdjustBits32(b) IgsInvertBits32(b)
+#define IgsAdjustBits16(x) IgsInvertBits16(x)
+#else
+#define IgsAdjustBits32(x) IgsByteSwap32(x)
+#define IgsAdjustBits16(x) IgsByteSwap16(x)
+#endif
#define _igsSetSolidRect(cop,alu,pm,pix,cmd) {\
_igsWaitFull(cop); \
(cop)->mix = IGS_MAKE_MIX(alu,alu); \
(cop)->fg = (pix); \
- (cop)->planemask = (pm); \
(cmd) = (IGS_DRAW_T_B | \
IGS_DRAW_L_R | \
IGS_DRAW_ALL | \
@@ -94,6 +112,55 @@ extern CARD8 igsPatRop[];
IGS_BGS_BG); \
}
+#define _igsSetTiledRect(cop,alu,pm,base,cmd) {\
+ _igsWaitFull(cop); \
+ (cop)->mix = IGS_MAKE_MIX(alu,alu); \
+ (cop)->src1_stride = IGS_PATTERN_WIDTH - 1; \
+ (cop)->src1_start = (base); \
+ (cmd) = (IGS_DRAW_T_B | \
+ IGS_DRAW_L_R | \
+ IGS_DRAW_ALL | \
+ IGS_PIXEL_TILE | \
+ IGS_HBLT_DISABLE | \
+ IGS_SRC2_NORMAL | \
+ IGS_STEP_PXBLT | \
+ IGS_FGS_SRC | \
+ IGS_BGS_BG); \
+}
+
+#define _igsSetStippledRect(cop,alu,pm,pix,base,cmd) {\
+ _igsWaitFull(cop); \
+ (cop)->mix = IGS_MAKE_MIX(alu,alu); \
+ (cop)->src1_start = (base); \
+ (cop)->fg = (pix); \
+ (cmd) = (IGS_DRAW_T_B | \
+ IGS_DRAW_L_R | \
+ IGS_DRAW_ALL | \
+ IGS_PIXEL_STIP_TRANS | \
+ IGS_HBLT_DISABLE | \
+ IGS_SRC2_NORMAL | \
+ IGS_STEP_PXBLT | \
+ IGS_FGS_FG | \
+ IGS_BGS_BG); \
+}
+
+#define _igsSetOpaqueStippledRect(cop,alu,pm,_fg,_bg,base,cmd) {\
+ _igsWaitFull(cop); \
+ (cop)->mix = IGS_MAKE_MIX(alu,alu); \
+ (cop)->src1_start = (base); \
+ (cop)->fg = (_fg); \
+ (cop)->bg = (_bg); \
+ (cmd) = (IGS_DRAW_T_B | \
+ IGS_DRAW_L_R | \
+ IGS_DRAW_ALL | \
+ IGS_PIXEL_STIP_OPAQUE | \
+ IGS_HBLT_DISABLE | \
+ IGS_SRC2_NORMAL | \
+ IGS_STEP_PXBLT | \
+ IGS_FGS_FG | \
+ IGS_BGS_BG); \
+}
+
#define _igsRect(cop,x,y,w,h,cmd) { \
_igsWaitFull(cop); \
(cop)->dst_start = (x) + (y) * (cop_stride); \
@@ -101,10 +168,17 @@ extern CARD8 igsPatRop[];
(cop)->operation = (cmd); \
}
+#define _igsPatRect(cop,x,y,w,h,cmd) { \
+ _igsWaitFull(cop); \
+ (cop)->dst_start = (x) + (y) * (cop_stride); \
+ (cop)->rotate = IGS_MAKE_ROTATE(x&7,y&7); \
+ (cop)->dim = IGS_MAKE_DIM(w-1,h-1); \
+ (cop)->operation = (cmd); \
+}
+
#define _igsSetBlt(cop,alu,pm,backwards,upsidedown,cmd) { \
_igsWaitFull(cop); \
- (cop)->mix = IGS_MAKE_MIX(alu,GXnoop); \
- (cop)->planemask = (pm); \
+ (cop)->mix = IGS_MAKE_MIX(alu,alu); \
(cop)->src1_stride = cop_stride - 1; \
(cmd) = (IGS_DRAW_ALL | \
IGS_PIXEL_FG | \
@@ -134,9 +208,8 @@ extern CARD8 igsPatRop[];
#define _igsSetTransparentPlaneBlt(cop,alu,pm,fg_pix,cmd) { \
_igsWaitIdleEmpty(cop); \
_igsPreparePlaneBlt(cop); \
- (cop)->mix = IGS_MAKE_MIX(igsPatRop[alu],igsPatRop[GXnoop]); \
+ (cop)->mix = IGS_MAKE_MIX(igsPatRop[alu],igsPatRop[alu]); \
(cop)->fg = (fg_pix); \
- (cop)->planemask = (pm); \
(cmd) = (IGS_DRAW_T_B | \
IGS_DRAW_L_R | \
IGS_DRAW_ALL | \
@@ -152,7 +225,6 @@ extern CARD8 igsPatRop[];
_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 | \
diff --git a/hw/kdrive/igs/igsreg.c b/hw/kdrive/igs/igsreg.c
new file mode 100644
index 000000000..7e4e095d0
--- /dev/null
+++ b/hw/kdrive/igs/igsreg.c
@@ -0,0 +1,968 @@
+/*
+ * $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 "igsreg.h"
+#include <stdio.h>
+
+#define CR00 IGS_CR+0x00
+#define CR01 IGS_CR+0x01
+#define CR02 IGS_CR+0x02
+#define CR03 IGS_CR+0x03
+#define CR04 IGS_CR+0x04
+#define CR05 IGS_CR+0x05
+#define CR06 IGS_CR+0x06
+#define CR07 IGS_CR+0x07
+#define CR08 IGS_CR+0x08
+#define CR09 IGS_CR+0x09
+#define CR0A IGS_CR+0x0A
+#define CR0B IGS_CR+0x0B
+#define CR0C IGS_CR+0x0C
+#define CR0D IGS_CR+0x0D
+#define CR0E IGS_CR+0x0E
+#define CR0F IGS_CR+0x0F
+#define CR10 IGS_CR+0x10
+#define CR11 IGS_CR+0x11
+#define CR12 IGS_CR+0x12
+#define CR13 IGS_CR+0x13
+#define CR14 IGS_CR+0x14
+#define CR15 IGS_CR+0x15
+#define CR16 IGS_CR+0x16
+#define CR17 IGS_CR+0x17
+#define CR18 IGS_CR+0x18
+#define CR19 IGS_CR+0x19
+#define CR1A IGS_CR+0x1A
+#define CR1B IGS_CR+0x1B
+#define CR1C IGS_CR+0x1C
+#define CR1D IGS_CR+0x1D
+#define CR1E IGS_CR+0x1E
+#define CR1F IGS_CR+0x1F
+#define CR20 IGS_CR+0x20
+#define CR21 IGS_CR+0x21
+#define CR22 IGS_CR+0x22
+#define CR23 IGS_CR+0x23
+#define CR24 IGS_CR+0x24
+#define CR25 IGS_CR+0x25
+#define CR26 IGS_CR+0x26
+#define CR27 IGS_CR+0x27
+#define CR28 IGS_CR+0x28
+#define CR29 IGS_CR+0x29
+#define CR2A IGS_CR+0x2A
+#define CR2B IGS_CR+0x2B
+#define CR2C IGS_CR+0x2C
+#define CR2D IGS_CR+0x2D
+#define CR2E IGS_CR+0x2E
+#define CR2F IGS_CR+0x2F
+#define CR30 IGS_CR+0x30
+#define CR31 IGS_CR+0x31
+#define CR32 IGS_CR+0x32
+#define CR33 IGS_CR+0x33
+#define CR34 IGS_CR+0x34
+#define CR35 IGS_CR+0x35
+#define CR36 IGS_CR+0x36
+#define CR37 IGS_CR+0x37
+#define CR38 IGS_CR+0x38
+#define CR39 IGS_CR+0x39
+#define CR3A IGS_CR+0x3A
+#define CR3B IGS_CR+0x3B
+#define CR3C IGS_CR+0x3C
+#define CR3D IGS_CR+0x3D
+#define CR3E IGS_CR+0x3E
+#define CR3F IGS_CR+0x3F
+#define CR40 IGS_CR+0x40
+#define CR41 IGS_CR+0x41
+#define CR42 IGS_CR+0x42
+#define CR43 IGS_CR+0x43
+#define CR44 IGS_CR+0x44
+#define CR45 IGS_CR+0x45
+#define CR46 IGS_CR+0x46
+#define CR47 IGS_CR+0x47
+#define CR48 IGS_CR+0x48
+
+#define CR_FIRST CR00
+#define CR_LAST CR48
+
+#define SR00 IGS_SR+0x00
+#define SR01 IGS_SR+0x01
+#define SR02 IGS_SR+0x02
+#define SR03 IGS_SR+0x03
+#define SR04 IGS_SR+0x04
+
+#define SR_FIRST SR00
+#define SR_LAST SR04
+
+#define AR00 IGS_AR+0x00
+#define AR01 IGS_AR+0x01
+#define AR02 IGS_AR+0x02
+#define AR03 IGS_AR+0x03
+#define AR04 IGS_AR+0x04
+#define AR05 IGS_AR+0x05
+#define AR06 IGS_AR+0x06
+#define AR07 IGS_AR+0x07
+#define AR08 IGS_AR+0x08
+#define AR09 IGS_AR+0x09
+#define AR0A IGS_AR+0x0A
+#define AR0B IGS_AR+0x0B
+#define AR0C IGS_AR+0x0C
+#define AR0D IGS_AR+0x0D
+#define AR0E IGS_AR+0x0E
+#define AR0F IGS_AR+0x0F
+#define AR10 IGS_AR+0x10
+#define AR11 IGS_AR+0x11
+#define AR12 IGS_AR+0x12
+#define AR13 IGS_AR+0x13
+#define AR14 IGS_AR+0x14
+
+#define AR_FIRST AR00
+#define AR_LAST AR14
+
+#define GR00 IGS_GR+0x00
+#define GR01 IGS_GR+0x01
+#define GR02 IGS_GR+0x02
+#define GR03 IGS_GR+0x03
+#define GR04 IGS_GR+0x04
+#define GR05 IGS_GR+0x05
+#define GR06 IGS_GR+0x06
+#define GR07 IGS_GR+0x07
+#define GR08 IGS_GR+0x08
+#define GR09 IGS_GR+0x09
+#define GR0A IGS_GR+0x0A
+#define GR0B IGS_GR+0x0B
+#define GR0C IGS_GR+0x0C
+#define GR0D IGS_GR+0x0D
+#define GR0E IGS_GR+0x0E
+#define GR0F IGS_GR+0x0F
+#define GR10 IGS_GR+0x10
+#define GR11 IGS_GR+0x11
+#define GR12 IGS_GR+0x12
+#define GR13 IGS_GR+0x13
+#define GR14 IGS_GR+0x14
+#define GR15 IGS_GR+0x15
+#define GR16 IGS_GR+0x16
+#define GR17 IGS_GR+0x17
+#define GR18 IGS_GR+0x18
+#define GR19 IGS_GR+0x19
+#define GR1A IGS_GR+0x1A
+#define GR1B IGS_GR+0x1B
+#define GR1C IGS_GR+0x1C
+#define GR1D IGS_GR+0x1D
+#define GR1E IGS_GR+0x1E
+#define GR1F IGS_GR+0x1F
+#define GR20 IGS_GR+0x20
+#define GR21 IGS_GR+0x21
+#define GR22 IGS_GR+0x22
+#define GR23 IGS_GR+0x23
+#define GR24 IGS_GR+0x24
+#define GR25 IGS_GR+0x25
+#define GR26 IGS_GR+0x26
+#define GR27 IGS_GR+0x27
+#define GR28 IGS_GR+0x28
+#define GR29 IGS_GR+0x29
+#define GR2A IGS_GR+0x2A
+#define GR2B IGS_GR+0x2B
+#define GR2C IGS_GR+0x2C
+#define GR2D IGS_GR+0x2D
+#define GR2E IGS_GR+0x2E
+#define GR2F IGS_GR+0x2F
+#define GR30 IGS_GR+0x30
+#define GR31 IGS_GR+0x31
+#define GR32 IGS_GR+0x32
+#define GR33 IGS_GR+0x33
+#define GR34 IGS_GR+0x34
+#define GR35 IGS_GR+0x35
+#define GR36 IGS_GR+0x36
+#define GR37 IGS_GR+0x37
+#define GR38 IGS_GR+0x38
+#define GR39 IGS_GR+0x39
+#define GR3A IGS_GR+0x3A
+#define GR3B IGS_GR+0x3B
+#define GR3C IGS_GR+0x3C
+#define GR3D IGS_GR+0x3D
+#define GR3E IGS_GR+0x3E
+#define GR3F IGS_GR+0x3F
+#define GR40 IGS_GR+0x40
+#define GR41 IGS_GR+0x41
+#define GR42 IGS_GR+0x42
+#define GR43 IGS_GR+0x43
+#define GR44 IGS_GR+0x44
+#define GR45 IGS_GR+0x45
+#define GR46 IGS_GR+0x46
+#define GR47 IGS_GR+0x47
+#define GR48 IGS_GR+0x48
+#define GR49 IGS_GR+0x49
+#define GR4A IGS_GR+0x4A
+#define GR4B IGS_GR+0x4B
+#define GR4C IGS_GR+0x4C
+#define GR4D IGS_GR+0x4D
+#define GR4E IGS_GR+0x4E
+#define GR4F IGS_GR+0x4F
+#define GR50 IGS_GR+0x50
+#define GR51 IGS_GR+0x51
+#define GR52 IGS_GR+0x52
+#define GR53 IGS_GR+0x53
+#define GR54 IGS_GR+0x54
+#define GR55 IGS_GR+0x55
+#define GR56 IGS_GR+0x56
+#define GR57 IGS_GR+0x57
+#define GR58 IGS_GR+0x58
+#define GR59 IGS_GR+0x59
+#define GR5A IGS_GR+0x5A
+#define GR5B IGS_GR+0x5B
+#define GR5C IGS_GR+0x5C
+#define GR5D IGS_GR+0x5D
+#define GR5E IGS_GR+0x5E
+#define GR5F IGS_GR+0x5F
+#define GR60 IGS_GR+0x60
+#define GR61 IGS_GR+0x61
+#define GR62 IGS_GR+0x62
+#define GR63 IGS_GR+0x63
+#define GR64 IGS_GR+0x64
+#define GR65 IGS_GR+0x65
+#define GR66 IGS_GR+0x66
+#define GR67 IGS_GR+0x67
+#define GR68 IGS_GR+0x68
+#define GR69 IGS_GR+0x69
+#define GR6A IGS_GR+0x6A
+#define GR6B IGS_GR+0x6B
+#define GR6C IGS_GR+0x6C
+#define GR6D IGS_GR+0x6D
+#define GR6E IGS_GR+0x6E
+#define GR6F IGS_GR+0x6F
+#define GR70 IGS_GR+0x70
+#define GR71 IGS_GR+0x71
+#define GR72 IGS_GR+0x72
+#define GR73 IGS_GR+0x73
+#define GR74 IGS_GR+0x74
+#define GR75 IGS_GR+0x75
+#define GR76 IGS_GR+0x76
+#define GR77 IGS_GR+0x77
+#define GR78 IGS_GR+0x78
+#define GR79 IGS_GR+0x79
+#define GR7A IGS_GR+0x7A
+#define GR7B IGS_GR+0x7B
+#define GR7C IGS_GR+0x7C
+#define GR7D IGS_GR+0x7D
+#define GR7E IGS_GR+0x7E
+#define GR7F IGS_GR+0x7F
+#define GR80 IGS_GR+0x80
+#define GR81 IGS_GR+0x81
+#define GR82 IGS_GR+0x82
+#define GR83 IGS_GR+0x83
+#define GR84 IGS_GR+0x84
+#define GR85 IGS_GR+0x85
+#define GR86 IGS_GR+0x86
+#define GR87 IGS_GR+0x87
+#define GR88 IGS_GR+0x88
+#define GR89 IGS_GR+0x89
+#define GR8A IGS_GR+0x8A
+#define GR8B IGS_GR+0x8B
+#define GR8C IGS_GR+0x8C
+#define GR8D IGS_GR+0x8D
+#define GR8E IGS_GR+0x8E
+#define GR8F IGS_GR+0x8F
+#define GR90 IGS_GR+0x90
+#define GR91 IGS_GR+0x91
+#define GR92 IGS_GR+0x92
+#define GR93 IGS_GR+0x93
+#define GR94 IGS_GR+0x94
+#define GR95 IGS_GR+0x95
+#define GR96 IGS_GR+0x96
+#define GR97 IGS_GR+0x97
+#define GR98 IGS_GR+0x98
+#define GR99 IGS_GR+0x99
+#define GR9A IGS_GR+0x9A
+#define GR9B IGS_GR+0x9B
+#define GR9C IGS_GR+0x9C
+#define GR9D IGS_GR+0x9D
+#define GR9E IGS_GR+0x9E
+#define GR9F IGS_GR+0x9F
+#define GRA0 IGS_GR+0xA0
+#define GRA1 IGS_GR+0xA1
+#define GRA2 IGS_GR+0xA2
+#define GRA3 IGS_GR+0xA3
+#define GRA4 IGS_GR+0xA4
+#define GRA5 IGS_GR+0xA5
+#define GRA6 IGS_GR+0xA6
+#define GRA7 IGS_GR+0xA7
+#define GRA8 IGS_GR+0xA8
+#define GRA9 IGS_GR+0xA9
+#define GRAA IGS_GR+0xAA
+#define GRAB IGS_GR+0xAB
+#define GRAC IGS_GR+0xAC
+#define GRAD IGS_GR+0xAD
+#define GRAE IGS_GR+0xAE
+#define GRAF IGS_GR+0xAF
+#define GRB0 IGS_GR+0xB0
+#define GRB1 IGS_GR+0xB1
+#define GRB2 IGS_GR+0xB2
+#define GRB3 IGS_GR+0xB3
+#define GRB4 IGS_GR+0xB4
+#define GRB5 IGS_GR+0xB5
+#define GRB6 IGS_GR+0xB6
+#define GRB7 IGS_GR+0xB7
+#define GRB8 IGS_GR+0xB8
+#define GRB9 IGS_GR+0xB9
+#define GRBA IGS_GR+0xBA
+#define GRBB IGS_GR+0xBB
+#define GRBC IGS_GR+0xBC
+#define GRBD IGS_GR+0xBD
+#define GRBE IGS_GR+0xBE
+#define GRBF IGS_GR+0xBF
+
+#define GR_FIRST GR00
+#define GR_LAST GRBF
+
+#define GREX3C IGS_GREX+(0x3c-IGS_GREXBASE)
+
+VgaReg igs_h_total[] = {
+ CR00, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_h_de_end[] = {
+ CR01, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_h_bstart[] = {
+ CR02, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_h_bend[] = {
+ CR03, 0, 5,
+ CR05, 7, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_de_skew[] = {
+ CR03, 5, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_ena_vr_access[] = {
+ CR03, 7, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_h_rstart[] = {
+ CR04, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_h_rend[] = {
+ CR05, 0, 5,
+ VGA_REG_END
+};
+
+VgaReg igs_h_rdelay[] = {
+ CR05, 5, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_v_total[] = {
+ CR06, 0, 8,
+ CR07, 0, 1,
+ CR07, 5, 1,
+ GR11, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_v_rstart[] = {
+ CR10, 0, 8,
+ CR07, 2, 1,
+ CR07, 7, 1,
+ GR11, 2, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_v_rend[] = {
+ CR11, 0, 4,
+ VGA_REG_END
+};
+
+VgaReg igs_clear_v_int[] = {
+ CR11, 4, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_disable_v_int[] = {
+ CR11, 5, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_bandwidth[] = {
+ CR11, 6, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_crt_protect[] = {
+ CR11, 7, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_v_de_end[] = {
+ CR12, 0, 8,
+ CR07, 1, 1,
+ CR07, 6, 1,
+ GR11, 1, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_offset[] = {
+ CR13, 0, 8,
+ GR15, 4, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_v_bstart[] = {
+ CR15, 0, 8,
+ CR07, 3, 1,
+ CR09, 5, 1,
+ GR11, 3, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_v_bend[] = {
+ CR16, 0, 7,
+ VGA_REG_END
+};
+
+VgaReg igs_linecomp[] = {
+ CR18, 0, 8,
+ CR07, 4, 1,
+ CR09, 6, 1,
+ GR11, 4, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_ivideo[] = {
+ GR11, 5, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_num_fetch[] = {
+ GR14, 0, 8,
+ GR15, 0, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_wcrt0[] = {
+ CR1F, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_wcrt1[] = {
+ CR1F, 1, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_rcrts1[] = {
+ CR1F, 4, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_selwk[] = {
+ CR1F, 6, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_dot_clock_8[] = {
+ SR01, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_screen_off[] = {
+ SR01, 5, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_enable_write_plane[] = {
+ SR02, 0, 4,
+ VGA_REG_END
+};
+
+VgaReg igs_mexhsyn[] = {
+ GR16, 0, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_mexvsyn[] = {
+ GR16, 2, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_pci_burst_write[] = {
+ GR30, 5, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_pci_burst_read[] = {
+ GR30, 7, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_iow_retry[] = {
+ GREX3C, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_mw_retry[] = {
+ GREX3C, 1, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_mr_retry[] = {
+ GREX3C, 2, 1,
+ VGA_REG_END
+};
+
+
+
+VgaReg igs_biga22en[] = {
+ GR3D, 4, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_biga24en[] = {
+ GR3D, 5, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_biga22force[] = {
+ GR3D, 6, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_bigswap[] = {
+ GR3F, 0, 6,
+ VGA_REG_END
+};
+
+/* #define IGS_BIGSWAP_8 0x3f */
+/* #define IGS_BIGSWAP_16 0x2a */
+/* #define IGS_BIGSWAP_32 0x00 */
+
+VgaReg igs_sprite_x[] = {
+ GR50, 0, 8,
+ GR51, 0, 3,
+ VGA_REG_END
+};
+
+VgaReg igs_sprite_preset_x[] = {
+ GR52, 0, 6,
+ VGA_REG_END
+};
+
+VgaReg igs_sprite_y[] = {
+ GR53, 0, 8,
+ GR54, 0, 3,
+ VGA_REG_END
+};
+
+VgaReg igs_sprite_preset_y[] = {
+ GR55, 0, 6,
+ VGA_REG_END
+};
+
+VgaReg igs_sprite_visible[] = {
+ GR56, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_sprite_64x64[] = {
+ GR56, 1, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_mgrext[] = {
+ GR57, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_hcshf[] = {
+ GR57, 4, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_mbpfix[] = {
+ GR57, 6, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_overscan_red[] = {
+ GR58, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_overscan_green[] = {
+ GR59, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_overscan_blue[] = {
+ GR5A, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_memgopg[] = {
+ GR73, 2, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_memr2wpg[] = {
+ GR73, 1, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_crtff16[] = {
+ GR73, 3, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_fifomust[] = {
+ GR74, 0, 5,
+ VGA_REG_END
+};
+
+VgaReg igs_fifogen[] = {
+ GR75, 0, 5,
+ VGA_REG_END
+};
+
+VgaReg igs_mode_sel[] = {
+ GR77, 0, 4,
+ VGA_REG_END
+};
+
+/* #define IGS_MODE_TEXT 0 */
+/* #define IGS_MODE_8 1 */
+/* #define IGS_MODE_565 2 */
+/* #define IGS_MODE_5551 6 */
+/* #define IGS_MODE_8888 3 */
+/* #define IGS_MODE_888 4 */
+/* #define IGS_MODE_332 9 */
+/* #define IGS_MODE_4444 10 */
+
+VgaReg igs_sprite_addr[] = {
+ GR7E, 0, 8,
+ GR7F, 0, 4,
+ VGA_REG_END
+};
+
+VgaReg igs_fastmpie[] = {
+ GR9E, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_vclk_m[] = {
+ GRB0, 0, 8,
+ GRBA, 0, 3,
+ VGA_REG_END
+};
+
+VgaReg igs_vclk_n[] = {
+ GRB1, 0, 5,
+ GRBA, 3, 3,
+ VGA_REG_END
+};
+
+VgaReg igs_vfsel[] = {
+ GRB1, 5, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_vclk_p[] = {
+ GRB1, 6, 2,
+ GRBA, 6, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_frqlat[] = {
+ GRB9, 7, 1,
+ VGA_REG_END
+};
+
+
+VgaReg igs_dac_mask[] = {
+ IGS_DAC + 0, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_dac_read_index[] = {
+ IGS_DAC + 1, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_dac_write_index[] = {
+ IGS_DAC + 2, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_dac_data[] = {
+ IGS_DAC + 3, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_rampwdn[] = {
+ IGS_DACEX + 0, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_dac6_8[] = {
+ IGS_DACEX + 0, 1, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_ramdacbypass[] = {
+ IGS_DACEX + 0, 4, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_dacpwdn[] = {
+ IGS_DACEX + 0, 6, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_cursor_read_index[] = {
+ IGS_DACEX + 1, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_cursor_write_index[] = {
+ IGS_DACEX + 2, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_cursor_data[] = {
+ IGS_DACEX + 3, 0, 8,
+ VGA_REG_END
+};
+
+VGA8
+_igsInb (VgaCard *card, VGA16 port)
+{
+ VGAVOL8 *reg;
+
+ if (card->closure)
+ return VgaReadMemb ((VGA32) card->closure + port);
+ else
+ return VgaInb (port);
+}
+
+void
+_igsOutb (VgaCard *card, VGA8 value, VGA16 port)
+{
+ if (card->closure)
+ VgaWriteMemb (value, (VGA32) card->closure + port);
+ else
+ VgaOutb (value, port);
+}
+
+void
+_igsRegMap (VgaCard *card, VGA16 reg, VgaMap *map, VGABOOL write)
+{
+ if (reg < IGS_SR + IGS_NSR)
+ {
+ map->access = VgaAccessIndIo;
+ map->port = 0x3c4;
+ map->addr = 0;
+ map->value = 1;
+ map->index = reg - IGS_SR;
+ }
+ else if (reg < IGS_GR + IGS_NGR)
+ {
+ map->access = VgaAccessIndIo;
+ map->port = 0x3ce;
+ map->addr = 0;
+ map->value = 1;
+ map->index = reg - IGS_GR;
+ }
+ else if (reg < IGS_GREX + IGS_NGREX)
+ {
+ VGA8 gr33;
+
+ map->access = VgaAccessDone;
+ _igsOutb (card, 0x33, 0x3ce);
+ gr33 = _igsInb (card, 0x3cf);
+ _igsOutb (card, gr33 | 0x40, 0x3cf);
+ _igsOutb (card, IGS_GREXBASE + reg - IGS_GREX, 0x3ce);
+ if (write)
+ _igsOutb (card, map->value, 0x3cf);
+ else
+ map->value = _igsInb (card, 0x3cf);
+ _igsOutb (card, 0x33, 0x3ce);
+ _igsOutb (card, gr33, 0x3cf);
+ return;
+ }
+ else if (reg < IGS_AR + IGS_NAR)
+ {
+ reg -= IGS_AR;
+ map->access = VgaAccessDone;
+ /* reset AFF to index */
+ (void) _igsInb (card, 0x3da);
+ if (reg >= 16)
+ reg |= 0x20;
+ _igsOutb (card, reg, 0x3c0);
+ if (write)
+ _igsOutb (card, map->value, 0x3c0);
+ else
+ map->value = _igsInb (card, 0x3c1);
+ if (!(reg & 0x20))
+ {
+ /* enable video display again */
+ (void) _igsInb (card, 0x3da);
+ _igsOutb (card, 0x20, 0x3c0);
+ }
+ return;
+ }
+ else if (reg < IGS_CR + IGS_NCR)
+ {
+ map->access = VgaAccessIndIo;
+ map->port = 0x3d4;
+ map->addr = 0;
+ map->value = 1;
+ map->index = reg - IGS_CR;
+ }
+ else if (reg < IGS_DAC + IGS_NDAC)
+ {
+ map->access = VgaAccessIo;
+ map->port = 0x3c6 + reg - IGS_DAC;
+ }
+ else if (reg < IGS_DACEX + IGS_NDACEX)
+ {
+ VGA8 gr56;
+ reg = 0x3c6 + reg - IGS_DACEX;
+ map->access = VgaAccessDone;
+ _igsOutb (card, 0x56, 0x3ce);
+ gr56 = _igsInb (card, 0x3cf);
+ _igsOutb (card, gr56 | 4, 0x3cf);
+ if (write)
+ _igsOutb (card, map->value, reg);
+ else
+ map->value = _igsInb (card, reg);
+ _igsOutb (card, gr56, 0x3cf);
+ return;
+ }
+ else switch (reg) {
+ case IGS_MISC_OUT:
+ map->access = VgaAccessIo;
+ if (write)
+ map->port = 0x3c2;
+ else
+ map->port = 0x3cc;
+ break;
+ case IGS_INPUT_STATUS_1:
+ map->access = VgaAccessIo;
+ map->port = 0x3da;
+ break;
+ }
+ if (card->closure)
+ {
+ map->port = map->port + (VGA32) card->closure;
+ if (map->access == VgaAccessIo)
+ map->access = VgaAccessMem;
+ if (map->access == VgaAccessIndIo)
+ map->access = VgaAccessIndMem;
+ }
+}
+
+VgaSave igsSaves[] = {
+ CR00, CR18,
+ SR01, SR02,
+ GR11, GRBA,
+ IGS_MISC_OUT, IGS_MISC_OUT,
+ VGA_SAVE_END
+};
+
+void
+igsRegInit (IgsVga *igsvga, VGAVOL8 *mmio)
+{
+ igsvga->card.map = _igsRegMap;
+ igsvga->card.closure = (void *) mmio;
+ igsvga->card.max = IGS_NREG;
+ igsvga->card.values = igsvga->values;
+ igsvga->card.saves = igsSaves;
+}
+
+void
+igsSave (IgsVga *igsvga)
+{
+ igsSetImm (igsvga, igs_wcrt0, 1);
+ igsSetImm (igsvga, igs_wcrt1, 1);
+ igsSetImm (igsvga, igs_rcrts1, 1);
+ igsSetImm (igsvga, igs_selwk, 1);
+ VgaPreserve (&igsvga->card);
+}
+
+void
+igsReset (IgsVga *igsvga)
+{
+ VgaRestore (&igsvga->card);
+ igsSetImm (igsvga, igs_frqlat, 0);
+ igsSetImm (igsvga, igs_frqlat, 1);
+ igsSetImm (igsvga, igs_frqlat, 0);
+ VgaFinish (&igsvga->card);
+}
+
+char *
+igsRegName(char *buf, VGA16 reg)
+{
+ if (reg < IGS_SR + IGS_NSR)
+ {
+ sprintf (buf, " SR%02X", reg - IGS_SR);
+ }
+ else if (reg < IGS_GR + IGS_NGR)
+ {
+ sprintf (buf, " GR%02X", reg - IGS_GR);
+ }
+ else if (reg < IGS_GREX + IGS_NGREX)
+ {
+ sprintf (buf, " GRX%02X", reg - IGS_GREX + IGS_GREXBASE);
+ }
+ else if (reg < IGS_AR + IGS_NAR)
+ {
+ sprintf (buf, " AR%02X", reg - IGS_AR);
+ }
+ else if (reg < IGS_CR + IGS_NCR)
+ {
+ sprintf (buf, " CR%02X", reg - IGS_CR);
+ }
+ else if (reg < IGS_DAC + IGS_NDAC)
+ {
+ sprintf (buf, " DAC%02X", reg - IGS_DAC);
+ }
+ else if (reg < IGS_DACEX + IGS_NDACEX)
+ {
+ sprintf (buf, "DACX%02X", reg - IGS_DACEX);
+ }
+ else switch (reg) {
+ case IGS_MISC_OUT:
+ sprintf (buf, "MISC_O");
+ break;
+ case IGS_INPUT_STATUS_1:
+ sprintf (buf, "IN_S_1");
+ break;
+ }
+ return buf;
+}
diff --git a/hw/kdrive/igs/igsreg.h b/hw/kdrive/igs/igsreg.h
new file mode 100644
index 000000000..88676328a
--- /dev/null
+++ b/hw/kdrive/igs/igsreg.h
@@ -0,0 +1,70 @@
+/*
+ * $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 _IGSREG_H_
+#define _IGSREG_H_
+
+#include "vga.h"
+
+#define IGS_SR 0
+#define IGS_NSR 5
+#define IGS_GR (IGS_SR+IGS_NSR)
+#define IGS_NGR 0xC0
+#define IGS_GREX (IGS_GR+IGS_NGR)
+#define IGS_GREXBASE 0x3c
+#define IGS_NGREX 1
+#define IGS_AR (IGS_GREX+IGS_NGREX)
+#define IGS_NAR 0x15
+#define IGS_CR (IGS_AR+IGS_NAR)
+#define IGS_NCR 0x48
+#define IGS_DAC (IGS_CR+IGS_NCR)
+#define IGS_NDAC 4
+#define IGS_DACEX (IGS_DAC+IGS_NDAC)
+#define IGS_NDACEX 4
+#define IGS_MISC_OUT (IGS_DACEX + IGS_NDACEX)
+#define IGS_INPUT_STATUS_1 (IGS_MISC_OUT+1)
+#define IGS_NREG (IGS_INPUT_STATUS_1+1)
+
+#include "igsregs.t"
+
+#define igsGet(sv,r) VgaGet(&(sv)->card, (r))
+#define igsGetImm(sv,r) VgaGetImm(&(sv)->card, (r))
+#define igsSet(sv,r,v) VgaSet(&(sv)->card, (r), (v))
+#define igsSetImm(sv,r,v) VgaSetImm(&(sv)->card, (r), (v))
+
+typedef struct _igsVga {
+ VgaCard card;
+ VgaValue values[IGS_NREG];
+} IgsVga;
+
+void
+igsRegInit (IgsVga *igsvga, VGAVOL8 *mmio);
+
+void
+igsSave (IgsVga *igsvga);
+
+void
+igsReset (IgsVga *igsvga);
+
+#endif /* _IGSREG_H_ */
diff --git a/hw/kdrive/igs/igsstub.c b/hw/kdrive/igs/igsstub.c
index 9d4c3d854..af526a0e0 100644
--- a/hw/kdrive/igs/igsstub.c
+++ b/hw/kdrive/igs/igsstub.c
@@ -1,5 +1,5 @@
/*
- * $XFree86$
+ * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igsstub.c,v 1.1 2000/05/06 22:17:44 keithp Exp $
*
* Copyright © 2000 Keith Packard
*
@@ -31,7 +31,13 @@ InitCard (char *name)
CARD32 count;
count = 0;
+#ifdef EMBED
+ attr.address[0] = 0x10000000; /* Adomo Wing video base address */
+ attr.io = 0;
+ attr.naddr = 1;
+#else
while (LinuxFindPci (0x10ea, 0x5000, count, &attr))
+#endif
{
KdCardInfoAdd (&igsFuncs, &attr, 0);
count++;