summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:55 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 16:48:55 +0000
commit5bae453e013714717370c788d0a92ecf41a900ec (patch)
treeaf9a62c30918984ead069cc169632fbe871ee155
Initial revisionXORG-STABLE
-rw-r--r--man/sunleo.man30
-rw-r--r--src/leo.h108
-rw-r--r--src/leo_accel.c197
-rw-r--r--src/leo_checks.c180
-rw-r--r--src/leo_cursor.c155
-rw-r--r--src/leo_driver.c698
-rw-r--r--src/leo_frect.c233
-rw-r--r--src/leo_frectsp.c276
-rw-r--r--src/leo_fspans.c127
-rw-r--r--src/leo_fspanssp.c166
-rw-r--r--src/leo_glyph.c325
-rw-r--r--src/leo_regs.h198
12 files changed, 2693 insertions, 0 deletions
diff --git a/man/sunleo.man b/man/sunleo.man
new file mode 100644
index 0000000..513cf10
--- /dev/null
+++ b/man/sunleo.man
@@ -0,0 +1,30 @@
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/sunleo.man,v 1.2 2001/01/27 18:20:54 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH SUNLEO __drivermansuffix__ __vendorversion__
+.SH NAME
+sunleo \- Leo video driver
+.SH SYNOPSIS
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qsunleo\*q"
+\ \ ...
+.B EndSection
+.fi
+.SH DESCRIPTION
+.B leo
+is an XFree86 driver for Sun Leo (ZX) video cards.
+THIS MAN PAGE NEEDS TO BE FILLED IN.
+.SH SUPPORTED HARDWARE
+The
+.B leo
+driver supports...
+.SH CONFIGURATION DETAILS
+Please refer to XF86Config(__filemansuffix__) for general configuration
+details. This section only covers configuration details specific to this
+driver.
+.SH "SEE ALSO"
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
+.SH AUTHORS
+Authors include: Jakub Jelinek <jakub@redhat.com>
diff --git a/src/leo.h b/src/leo.h
new file mode 100644
index 0000000..8df9302
--- /dev/null
+++ b/src/leo.h
@@ -0,0 +1,108 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - defines.
+ *
+ * Copyright (C) 1999, 2000 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo.h,v 1.4 2001/05/04 19:05:46 dawes Exp $ */
+
+#ifndef LEO_H
+#define LEO_H
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86RamDac.h"
+#include "Xmd.h"
+#include "gcstruct.h"
+#include "leo_regs.h"
+#include "xf86sbusBus.h"
+
+/* Various offsets in virtual (ie. mmap()) spaces Linux and Solaris support. */
+#define LEO_FB0_VOFF 0x00000000
+#define LEO_LC0_VOFF 0x00800000
+#define LEO_LD0_VOFF 0x00801000
+#define LEO_LX0_CURSOR_VOFF 0x00802000
+#define LEO_FB1_VOFF 0x00803000
+#define LEO_LC1_VOFF 0x01003000
+#define LEO_LD1 0x01004000
+#define LEO_LX0_VERT_VOFF 0x01005000
+#define LEO_LX_KRN_VOFF 0x01006000
+#define LEO_LC0_KRN_VOFF 0x01007000
+#define LEO_LC1_KRN_VOFF 0x01008000
+#define LEO_LD_GBL_VOFF 0x01009000
+
+typedef struct {
+ unsigned int fg, bg; /* FG/BG colors for stipple */
+ unsigned int patalign; /* X/Y alignment of bits */
+ unsigned int alu; /* Transparent/Opaque + rop */
+ unsigned int bits[32]; /* The stipple bits themselves */
+} LeoStippleRec, *LeoStipplePtr;
+
+typedef struct {
+ int type;
+ LeoStipplePtr stipple;
+} LeoPrivGCRec, *LeoPrivGCPtr;
+
+typedef struct {
+ LeoCommand0 *lc0;
+ LeoDraw *ld0;
+ LeoCursor *dac;
+ unsigned *fb;
+ int vclipmax;
+ int width;
+ int height;
+ /* cache one stipple; figuring out if we can use the stipple is as hard as
+ * computing it, so we just use this one and leave it here if it
+ * can't be used this time
+ */
+ LeoStipplePtr tmpStipple;
+
+ sbusDevicePtr psdp;
+ Bool HWCursor;
+ Bool NoAccel;
+ Bool vtSema;
+ CloseScreenProcPtr CloseScreen;
+ xf86CursorInfoPtr CursorInfoRec;
+ unsigned char CursorShiftX, CursorShiftY;
+ unsigned char *CursorData;
+ OptionInfoPtr Options;
+} LeoRec, *LeoPtr;
+
+extern int LeoScreenPrivateIndex;
+extern int LeoGCPrivateIndex;
+extern int LeoWindowPrivateIndex;
+
+#define GET_LEO_FROM_SCRN(p) ((LeoPtr)((p)->driverPrivate))
+
+#define LeoGetScreenPrivate(s) \
+((LeoPtr) (s)->devPrivates[LeoScreenPrivateIndex].ptr)
+
+#define LeoGetGCPrivate(g) \
+((LeoPrivGCPtr) (g)->devPrivates [LeoGCPrivateIndex].ptr)
+
+#define LeoGetWindowPrivate(w) \
+((LeoStipplePtr) (w)->devPrivates[LeoWindowPrivateIndex].ptr)
+
+#define LeoSetWindowPrivate(w,p) \
+((w)->devPrivates[LeoWindowPrivateIndex].ptr = (pointer) p)
+
+extern int leoRopTable[];
+
+#endif /* LEO_H */
diff --git a/src/leo_accel.c b/src/leo_accel.c
new file mode 100644
index 0000000..ee62310
--- /dev/null
+++ b/src/leo_accel.c
@@ -0,0 +1,197 @@
+/*
+ * Acceleration for the LEO (ZX) framebuffer.
+ *
+ * Copyright (C) 1999, 2000 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_accel.c,v 1.3 2001/03/03 22:41:34 tsi Exp $ */
+
+#define PSZ 32
+
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mistruct.h"
+#include "fontstruct.h"
+#include "dixfontstr.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "cfb8bit.h"
+#include "mibstore.h"
+#include "mifillarc.h"
+#include "miwideline.h"
+#include "fastblt.h"
+#include "mergerop.h"
+#include "migc.h"
+#include "mi.h"
+
+#include "leo.h"
+#include "leo_gc.h"
+
+int LeoScreenPrivateIndex;
+int LeoGCPrivateIndex;
+int LeoWindowPrivateIndex;
+int LeoGeneration;
+
+int leoRopTable[16] = {
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_ZERO, /* GXclear */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_AND_OLD, /* GXand */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_AND_NOLD, /* GXandReverse */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW, /* GXcopy */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_AND_OLD, /* GXandInverted */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_OLD, /* GXnoop */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_XOR_OLD, /* GXxor */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_OR_OLD, /* GXor */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_AND_NOLD, /* GXnor */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_XOR_NOLD, /* GXequiv */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NOLD, /* GXinvert */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_OR_NOLD, /* GXorReverse */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW, /* GXcopyInverted */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_OR_OLD, /* GXorInverted */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_OR_NOLD, /* GXnand */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_ONES /* GXset */
+};
+
+static void
+LeoCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ LeoPtr pLeo = LeoGetScreenPrivate (pScreen);
+ DDXPointPtr pptSrc;
+ DDXPointPtr ppt;
+ RegionPtr prgnDst;
+ BoxPtr pbox;
+ int dx, dy;
+ int i, nbox;
+ WindowPtr pwinRoot;
+
+ if (pLeo->vtSema)
+ return;
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+
+ pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
+
+ prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
+
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+ REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, &pWin->borderClip, prgnSrc);
+
+ pbox = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+ if(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
+ return;
+ ppt = pptSrc;
+
+ for (i = nbox; --i >= 0; ppt++, pbox++) {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ LeoDoBitblt ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
+ GXcopy, prgnDst, pptSrc, ~0L);
+ DEALLOCATE_LOCAL(pptSrc);
+ REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
+}
+
+void LeoVtChange (ScreenPtr pScreen, int enter)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pScreen);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+
+ ld0->wid = 1;
+ ld0->widclip = 0;
+ ld0->wmask = 0xffff;
+ ld0->planemask = 0xffffff;
+ ld0->rop = LEO_ATTR_WE_ENABLE|LEO_ATTR_RGBE_ENABLE|LEO_ATTR_FORCE_WID;
+ ld0->fg = 0;
+ ld0->vclipmin = 0;
+ ld0->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16);
+
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+
+ lc0->extent = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 11);
+ lc0->fill = 0;
+
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+
+ lc0->addrspace = LEO_ADDRSPC_OBGR;
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+}
+
+extern Bool LeoCreateGC (GCPtr pGC);
+
+Bool LeoAccelInit (ScreenPtr pScreen, LeoPtr pLeo)
+{
+ LeoCommand0 *lc0;
+ LeoDraw *ld0;
+
+ if (serverGeneration != LeoGeneration) {
+ LeoScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ if (LeoScreenPrivateIndex == -1) return FALSE;
+ LeoGCPrivateIndex = AllocateGCPrivateIndex ();
+ LeoWindowPrivateIndex = AllocateWindowPrivateIndex ();
+ LeoGeneration = serverGeneration;
+ }
+
+ /* Allocate private structures holding pointer to both videoRAM and control registers.
+ We do not have to map these by ourselves, because the XServer did it for us; we
+ only copy the pointers to out structures. */
+ if (!AllocateGCPrivate(pScreen, LeoGCPrivateIndex, sizeof(LeoPrivGCRec))) return FALSE;
+ if (!AllocateWindowPrivate(pScreen, LeoWindowPrivateIndex, 0)) return FALSE;
+ pScreen->devPrivates[LeoScreenPrivateIndex].ptr = pLeo;
+ pLeo->lc0 = lc0 = (LeoCommand0 *) ((char *)pLeo->fb + LEO_LC0_VOFF);
+ pLeo->ld0 = ld0 = (LeoDraw *) ((char *)pLeo->fb + LEO_LD0_VOFF);
+
+ if (!pLeo->NoAccel) {
+ /* Replace various screen functions. */
+ pScreen->CreateGC = LeoCreateGC;
+ pScreen->CopyWindow = LeoCopyWindow;
+ }
+
+ /* We will now clear the screen: we'll draw a rectangle covering all the
+ * viewscreen, using a 'blackness' ROP.
+ */
+ ld0->wid = 1;
+ ld0->widclip = 0;
+ ld0->wmask = 0xffff;
+ ld0->planemask = 0xffffff;
+ ld0->rop = LEO_ATTR_WE_ENABLE|LEO_ATTR_RGBE_ENABLE|LEO_ATTR_FORCE_WID;
+ ld0->fg = 0;
+ ld0->vclipmin = 0;
+ ld0->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16);
+ pLeo->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16);
+ pLeo->width = pLeo->psdp->width;
+ pLeo->height = pLeo->psdp->height;
+
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+
+ lc0->extent = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 11);
+ lc0->fill = 0;
+
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+
+ lc0->addrspace = LEO_ADDRSPC_OBGR;
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+
+ /* Success */
+ return TRUE;
+}
diff --git a/src/leo_checks.c b/src/leo_checks.c
new file mode 100644
index 0000000..e0ad8ab
--- /dev/null
+++ b/src/leo_checks.c
@@ -0,0 +1,180 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - stipple/tile verification.
+ *
+ * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_checks.c,v 1.1 2000/05/18 23:21:39 dawes Exp $ */
+
+#define PSZ 32
+
+#include "leo.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+
+int
+LeoCheckTile (PixmapPtr pPixmap, LeoStipplePtr stipple, int ox, int oy)
+{
+ unsigned int *sbits;
+ unsigned int fg = 0, bg = 0;
+ int fgset = 0, bgset = 0;
+ unsigned int *tilebitsLine, *tilebits, tilebit;
+ unsigned int sbit, mask;
+ int nbwidth;
+ int h, w;
+ int x, y;
+ int s_y, s_x;
+
+ h = pPixmap->drawable.height;
+ if (h > 32 || (h & (h - 1)))
+ return FALSE;
+ w = pPixmap->drawable.width;
+ if (w > 32 || (w & (w - 1)))
+ return FALSE;
+ stipple->patalign = (oy << 16) | ox;
+ sbits = stipple->bits;
+ tilebitsLine = (unsigned int *) pPixmap->devPrivate.ptr;
+ nbwidth = pPixmap->devKind / sizeof(unsigned int);
+
+ for (y = 0; y < h; y++) {
+ tilebits = tilebitsLine;
+ tilebitsLine += nbwidth;
+ sbit = 0;
+ mask = 1 << 31;
+ for (x = 0; x < w; x++) {
+ tilebit = *tilebits++;
+ if (fgset && tilebit == fg)
+ sbit |= mask;
+ else if (!bgset || tilebit != bg) {
+ if (!fgset) {
+ fgset = 1;
+ fg = tilebit;
+ sbit |= mask;
+ } else if (!bgset) {
+ bgset = 1;
+ bg = tilebit;
+ } else
+ return FALSE;
+ }
+ mask >>= 1;
+ }
+ for (s_x = w; s_x < 32; s_x <<= 1)
+ sbit = sbit | (sbit >> s_x);
+ sbit = (sbit >> ox) | (sbit << (32 - ox));
+ for (s_y = y; s_y < 32; s_y += h)
+ sbits[(s_y + oy) & 31] = sbit;
+ }
+ stipple->fg = fg;
+ stipple->bg = bg;
+ return TRUE;
+}
+
+int
+LeoCheckStipple (PixmapPtr pPixmap, LeoStipplePtr stipple, int ox, int oy)
+{
+ unsigned int *sbits;
+ unsigned int *stippleBits;
+ unsigned int sbit, mask, nbwidth;
+ int h, w;
+ int y;
+ int s_y, s_x;
+
+ h = pPixmap->drawable.height;
+ if (h > 32 || (h & (h - 1)))
+ return FALSE;
+ w = pPixmap->drawable.width;
+ if (w > 32 || (w & (w - 1)))
+ return FALSE;
+ stipple->patalign = (oy << 16) | ox;
+ sbits = stipple->bits;
+ stippleBits = (unsigned int *) pPixmap->devPrivate.ptr;
+ nbwidth = pPixmap->devKind / sizeof(unsigned int);
+ mask = ~0 << (32 - w);
+ for (y = 0; y < h; y++) {
+ sbit = (*stippleBits) & mask;
+ stippleBits += nbwidth;
+ for (s_x = w; s_x < 32; s_x <<= 1)
+ sbit = sbit | (sbit >> s_x);
+ sbit = (sbit >> ox) | (sbit << (32 - ox));
+ for (s_y = y; s_y < 32; s_y += h)
+ sbits[(s_y + oy) & 31] = sbit;
+ }
+ return TRUE;
+}
+
+int
+LeoCheckFill (GCPtr pGC, DrawablePtr pDrawable)
+{
+ LeoPrivGCPtr gcPriv = LeoGetGCPrivate (pGC);
+ LeoPtr pLeo = LeoGetScreenPrivate(pDrawable->pScreen);
+ LeoStipplePtr stipple;
+ unsigned int alu;
+ int xrot, yrot;
+
+ if (pGC->fillStyle == FillSolid) {
+ if (gcPriv->stipple) {
+ xfree (gcPriv->stipple);
+ gcPriv->stipple = 0;
+ }
+ return TRUE;
+ }
+ if (!(stipple = gcPriv->stipple)) {
+ if (!pLeo->tmpStipple) {
+ pLeo->tmpStipple = (LeoStipplePtr) xalloc (sizeof *pLeo->tmpStipple);
+ if (!pLeo->tmpStipple)
+ return FALSE;
+ }
+ stipple = pLeo->tmpStipple;
+ }
+ xrot = (pGC->patOrg.x + pDrawable->x) & 31;
+ yrot = (pGC->patOrg.y + pDrawable->y) & 31;
+ alu = pGC->alu;
+ switch (pGC->fillStyle) {
+ case FillTiled:
+ if (!LeoCheckTile (pGC->tile.pixmap, stipple, xrot, yrot)) {
+ if (gcPriv->stipple) {
+ xfree (gcPriv->stipple);
+ gcPriv->stipple = 0;
+ }
+ return FALSE;
+ }
+ break;
+ case FillStippled:
+ alu |= 0x80;
+ case FillOpaqueStippled:
+ if (!LeoCheckStipple (pGC->stipple, stipple, xrot, yrot)) {
+ if (gcPriv->stipple) {
+ xfree (gcPriv->stipple);
+ gcPriv->stipple = 0;
+ }
+ return FALSE;
+ }
+ stipple->fg = pGC->fgPixel;
+ stipple->bg = pGC->bgPixel;
+ break;
+ }
+ stipple->alu = alu;
+ gcPriv->stipple = stipple;
+ if (stipple == pLeo->tmpStipple)
+ pLeo->tmpStipple = 0;
+ return TRUE;
+}
diff --git a/src/leo_cursor.c b/src/leo_cursor.c
new file mode 100644
index 0000000..271a222
--- /dev/null
+++ b/src/leo_cursor.c
@@ -0,0 +1,155 @@
+/*
+ * Hardware cursor support for Leo (ZX)
+ *
+ * Copyright 2000 by Jakub Jelinek <jakub@redhat.com>.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of Jakub
+ * Jelinek not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Jakub Jelinek makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * JAKUB JELINEK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL JAKUB JELINEK 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_cursor.c,v 1.1 2000/05/18 23:21:39 dawes Exp $ */
+
+#include "leo.h"
+
+static void LeoLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src);
+static void LeoShowCursor(ScrnInfoPtr pScrn);
+static void LeoHideCursor(ScrnInfoPtr pScrn);
+static void LeoSetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
+static void LeoSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg);
+
+static void
+LeoLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+ LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
+ int i, j, x, y;
+ unsigned int *data = (unsigned int *)src, value;
+
+ pLeo->CursorData = src;
+ x = pLeo->CursorShiftX;
+ y = pLeo->CursorShiftY;
+ if (x >= 32 || y >= 32)
+ y = 32;
+ pLeo->dac->cur_type = 0;
+ for (j = 0; j < 2; j++) {
+ data += y;
+ for (i = y; i < 32; i++, data++) {
+ value = (*data >> 16) | (*data << 16);
+ value = ((value & 0xff00ff00) >> 8) |
+ ((value & 0x00ff00ff) << 8);
+ pLeo->dac->cur_data = value >> x;
+ }
+ for (i = 0; i < y; i++)
+ pLeo->dac->cur_data = 0;
+ }
+}
+
+static void
+LeoShowCursor(ScrnInfoPtr pScrn)
+{
+ LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ pLeo->dac->cur_misc |= 0x80;
+}
+
+static void
+LeoHideCursor(ScrnInfoPtr pScrn)
+{
+ LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ pLeo->dac->cur_misc &= ~0x80;
+ pLeo->CursorData = NULL;
+}
+
+static void
+LeoSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+ LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
+ int CursorShiftX = 0, CursorShiftY = 0;
+
+ if (x < 0) {
+ CursorShiftX = -x;
+ x = 0;
+ if (CursorShiftX > 32)
+ CursorShiftX = 32;
+ }
+ if (y < 0) {
+ CursorShiftY = -y;
+ y = 0;
+ if (CursorShiftY > 32)
+ CursorShiftY = 32;
+ }
+ pLeo->dac->cur_misc &= ~0x80;
+ if ((CursorShiftX != pLeo->CursorShiftX ||
+ CursorShiftY != pLeo->CursorShiftY) &&
+ pLeo->CursorData != NULL) {
+ pLeo->CursorShiftX = CursorShiftX;
+ pLeo->CursorShiftY = CursorShiftY;
+ LeoLoadCursorImage(pScrn, pLeo->CursorData);
+ }
+
+ pLeo->dac->cur_cursxy = ((y & 0x7ff) << 11) | (x & 0x7ff);
+ pLeo->dac->cur_misc |= 0x30;
+ pLeo->dac->cur_misc |= 0x80;
+}
+
+static void
+LeoSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ pLeo->dac->cur_type = 0x50;
+ pLeo->dac->cur_data = bg;
+ pLeo->dac->cur_data = fg;
+ pLeo->dac->cur_misc |= 0x03;
+}
+
+Bool
+LeoHWCursorInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ LeoPtr pLeo;
+ xf86CursorInfoPtr infoPtr;
+
+ pLeo = GET_LEO_FROM_SCRN(pScrn);
+ pLeo->CursorShiftX = 0;
+ pLeo->CursorShiftY = 0;
+ pLeo->CursorData = NULL;
+
+ infoPtr = xf86CreateCursorInfoRec();
+ if(!infoPtr) return FALSE;
+
+ pLeo->CursorInfoRec = infoPtr;
+ pLeo->dac = (LeoCursor *)((char *)pLeo->fb + LEO_LX0_CURSOR_VOFF);
+
+ infoPtr->MaxWidth = 32;
+ infoPtr->MaxHeight = 32;
+ infoPtr->Flags = HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+ HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK |
+ HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
+ HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED;
+
+ infoPtr->SetCursorColors = LeoSetCursorColors;
+ infoPtr->SetCursorPosition = LeoSetCursorPosition;
+ infoPtr->LoadCursorImage = LeoLoadCursorImage;
+ infoPtr->HideCursor = LeoHideCursor;
+ infoPtr->ShowCursor = LeoShowCursor;
+ infoPtr->UseHWCursor = NULL;
+
+ return xf86InitCursor(pScreen, infoPtr);
+}
diff --git a/src/leo_driver.c b/src/leo_driver.c
new file mode 100644
index 0000000..e5f402a
--- /dev/null
+++ b/src/leo_driver.c
@@ -0,0 +1,698 @@
+
+/*
+ * Leo (ZX) framebuffer driver.
+ *
+ * Copyright (C) 2000 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_driver.c,v 1.8 2001/10/01 13:44:10 eich Exp $ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Version.h"
+#include "mipointer.h"
+#include "mibstore.h"
+#include "micmap.h"
+
+#define PSZ 32
+#include "cfb.h"
+#undef PSZ
+#include "xf86cmap.h"
+#include "leo.h"
+
+static const OptionInfoRec * LeoAvailableOptions(int chipid, int busid);
+static void LeoIdentify(int flags);
+static Bool LeoProbe(DriverPtr drv, int flags);
+static Bool LeoPreInit(ScrnInfoPtr pScrn, int flags);
+static Bool LeoScreenInit(int Index, ScreenPtr pScreen, int argc,
+ char **argv);
+static Bool LeoEnterVT(int scrnIndex, int flags);
+static void LeoLeaveVT(int scrnIndex, int flags);
+static Bool LeoCloseScreen(int scrnIndex, ScreenPtr pScreen);
+static Bool LeoSaveScreen(ScreenPtr pScreen, int mode);
+
+/* Required if the driver supports mode switching */
+static Bool LeoSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+/* Required if the driver supports moving the viewport */
+static void LeoAdjustFrame(int scrnIndex, int x, int y, int flags);
+
+/* Optional functions */
+static void LeoFreeScreen(int scrnIndex, int flags);
+static int LeoValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
+ int flags);
+
+void LeoSync(ScrnInfoPtr pScrn);
+
+#define VERSION 4000
+#define LEO_NAME "SUNLEO"
+#define LEO_DRIVER_NAME "sunleo"
+#define LEO_MAJOR_VERSION 1
+#define LEO_MINOR_VERSION 0
+#define LEO_PATCHLEVEL 0
+
+/*
+ * This contains the functions needed by the server after loading the driver
+ * module. It must be supplied, and gets passed back by the SetupProc
+ * function in the dynamic case. In the static case, a reference to this
+ * is compiled in, and this requires that the name of this DriverRec be
+ * an upper-case version of the driver name.
+ */
+
+DriverRec SUNLEO = {
+ VERSION,
+ LEO_DRIVER_NAME,
+ LeoIdentify,
+ LeoProbe,
+ LeoAvailableOptions,
+ NULL,
+ 0
+};
+
+typedef enum {
+ OPTION_SW_CURSOR,
+ OPTION_HW_CURSOR,
+ OPTION_NOACCEL
+} LeoOpts;
+
+static const OptionInfoRec LeoOptions[] = {
+ { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+#ifdef XFree86LOADER
+
+static MODULESETUPPROTO(leoSetup);
+
+static XF86ModuleVersionInfo sunleoVersRec =
+{
+ "sunleo",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XF86_VERSION_CURRENT,
+ LEO_MAJOR_VERSION, LEO_MINOR_VERSION, LEO_PATCHLEVEL,
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0,0,0,0}
+};
+
+XF86ModuleData sunleoModuleData = { &sunleoVersRec, leoSetup, NULL };
+
+pointer
+leoSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ if (!setupDone) {
+ setupDone = TRUE;
+ xf86AddDriver(&SUNLEO, module, 0);
+
+ /*
+ * Modules that this driver always requires can be loaded here
+ * by calling LoadSubModule().
+ */
+
+ /*
+ * The return value must be non-NULL on success even though there
+ * is no TearDownProc.
+ */
+ return (pointer)TRUE;
+ } else {
+ if (errmaj) *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+#endif /* XFree86LOADER */
+
+static Bool
+LeoGetRec(ScrnInfoPtr pScrn)
+{
+ /*
+ * Allocate an LeoRec, and hook it into pScrn->driverPrivate.
+ * pScrn->driverPrivate is initialised to NULL, so we can check if
+ * the allocation has already been done.
+ */
+ if (pScrn->driverPrivate != NULL)
+ return TRUE;
+
+ pScrn->driverPrivate = xnfcalloc(sizeof(LeoRec), 1);
+ return TRUE;
+}
+
+static void
+LeoFreeRec(ScrnInfoPtr pScrn)
+{
+ LeoPtr pLeo;
+
+ if (pScrn->driverPrivate == NULL)
+ return;
+
+ pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ xfree(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+
+ return;
+}
+
+static const OptionInfoRec *
+LeoAvailableOptions(int chipid, int busid)
+{
+ return LeoOptions;
+}
+
+/* Mandatory */
+static void
+LeoIdentify(int flags)
+{
+ xf86Msg(X_INFO, "%s: driver for Leo (ZX)\n", LEO_NAME);
+}
+
+
+/* Mandatory */
+static Bool
+LeoProbe(DriverPtr drv, int flags)
+{
+ int i;
+ GDevPtr *devSections;
+ int *usedChips;
+ int numDevSections;
+ int numUsed;
+ Bool foundScreen = FALSE;
+ EntityInfoPtr pEnt;
+
+ /*
+ * The aim here is to find all cards that this driver can handle,
+ * and for the ones not already claimed by another driver, claim the
+ * slot, and allocate a ScrnInfoRec.
+ *
+ * This should be a minimal probe, and it should under no circumstances
+ * change the state of the hardware. Because a device is found, don't
+ * assume that it will be used. Don't do any initialisations other than
+ * the required ScrnInfoRec initialisations. Don't allocate any new
+ * data structures.
+ */
+
+ /*
+ * Next we check, if there has been a chipset override in the config file.
+ * For this we must find out if there is an active device section which
+ * is relevant, i.e., which has no driver specified or has THIS driver
+ * specified.
+ */
+
+ if ((numDevSections = xf86MatchDevice(LEO_DRIVER_NAME,
+ &devSections)) <= 0) {
+ /*
+ * There's no matching device section in the config file, so quit
+ * now.
+ */
+ return FALSE;
+ }
+
+ /*
+ * We need to probe the hardware first. We then need to see how this
+ * fits in with what is given in the config file, and allow the config
+ * file info to override any contradictions.
+ */
+
+ numUsed = xf86MatchSbusInstances(LEO_NAME, SBUS_DEVICE_LEO,
+ devSections, numDevSections,
+ drv, &usedChips);
+
+ xfree(devSections);
+ if (numUsed <= 0)
+ return FALSE;
+
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i = 0; i < numUsed; i++) {
+ pEnt = xf86GetEntityInfo(usedChips[i]);
+
+ /*
+ * Check that nothing else has claimed the slots.
+ */
+ if(pEnt->active) {
+ ScrnInfoPtr pScrn;
+
+ /* Allocate a ScrnInfoRec and claim the slot */
+ pScrn = xf86AllocateScreen(drv, 0);
+
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = LEO_DRIVER_NAME;
+ pScrn->name = LEO_NAME;
+ pScrn->Probe = LeoProbe;
+ pScrn->PreInit = LeoPreInit;
+ pScrn->ScreenInit = LeoScreenInit;
+ pScrn->SwitchMode = LeoSwitchMode;
+ pScrn->AdjustFrame = LeoAdjustFrame;
+ pScrn->EnterVT = LeoEnterVT;
+ pScrn->LeaveVT = LeoLeaveVT;
+ pScrn->FreeScreen = LeoFreeScreen;
+ pScrn->ValidMode = LeoValidMode;
+ xf86AddEntityToScreen(pScrn, pEnt->index);
+ foundScreen = TRUE;
+ }
+ xfree(pEnt);
+ }
+ xfree(usedChips);
+ return foundScreen;
+}
+
+/* Mandatory */
+static Bool
+LeoPreInit(ScrnInfoPtr pScrn, int flags)
+{
+ LeoPtr pLeo;
+ sbusDevicePtr psdp;
+ MessageType from;
+ int i;
+
+ if (flags & PROBE_DETECT) return FALSE;
+
+ /*
+ * Note: This function is only called once at server startup, and
+ * not at the start of each server generation. This means that
+ * only things that are persistent across server generations can
+ * be initialised here. xf86Screens[] is (pScrn is a pointer to one
+ * of these). Privates allocated using xf86AllocateScrnInfoPrivateIndex()
+ * are too, and should be used for data that must persist across
+ * server generations.
+ *
+ * Per-generation data should be allocated with
+ * AllocateScreenPrivateIndex() from the ScreenInit() function.
+ */
+
+ /* Allocate the LeoRec driverPrivate */
+ if (!LeoGetRec(pScrn)) {
+ return FALSE;
+ }
+ pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ /* Set pScrn->monitor */
+ pScrn->monitor = pScrn->confScreen->monitor;
+
+ /* This driver doesn't expect more than one entity per screen */
+ if (pScrn->numEntities > 1)
+ return FALSE;
+ /* This is the general case */
+ for (i = 0; i < pScrn->numEntities; i++) {
+ EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[i]);
+
+ /* LEO is purely SBUS */
+ if (pEnt->location.type == BUS_SBUS) {
+ psdp = xf86GetSbusInfoForEntity(pEnt->index);
+ pLeo->psdp = psdp;
+ } else
+ return FALSE;
+ }
+
+ /*********************
+ deal with depth
+ *********************/
+
+ if (!xf86SetDepthBpp(pScrn, 32, 0, 32, Support32bppFb)) {
+ return FALSE;
+ } else {
+ /* Check that the returned depth is one we support */
+ switch (pScrn->depth) {
+ case 32:
+ /* OK */
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Given depth (%d) is not supported by this driver\n",
+ pScrn->depth);
+ return FALSE;
+ }
+ }
+
+ /* Collect all of the relevant option flags (fill in pScrn->options) */
+ xf86CollectOptions(pScrn, NULL);
+ /* Process the options */
+ if (!(pLeo->Options = xalloc(sizeof(LeoOptions))))
+ return FALSE;
+ memcpy(pLeo->Options, LeoOptions, sizeof(LeoOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pLeo->Options);
+
+ /*
+ * This must happen after pScrn->display has been set because
+ * xf86SetWeight references it.
+ */
+ if (pScrn->depth > 8) {
+ rgb weight = {10, 11, 11};
+ rgb mask = {0xff, 0xff00, 0xff0000};
+
+ if (!xf86SetWeight(pScrn, weight, mask)) {
+ return FALSE;
+ }
+ }
+
+ if (!xf86SetDefaultVisual(pScrn, -1)) {
+ return FALSE;
+ } else {
+ /* We don't currently support DirectColor */
+ if (pScrn->defaultVisual != TrueColor) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual"
+ " (%s) is not supported\n",
+ xf86GetVisualName(pScrn->defaultVisual));
+ return FALSE;
+ }
+ }
+
+ /*
+ * The new cmap code requires this to be initialised.
+ */
+
+ {
+ Gamma zeros = {0.0, 0.0, 0.0};
+
+ if (!xf86SetGamma(pScrn, zeros)) {
+ return FALSE;
+ }
+ }
+
+ /* Set the bits per RGB for 8bpp mode */
+ from = X_DEFAULT;
+
+ /* determine whether we use hardware or software cursor */
+
+ pLeo->HWCursor = TRUE;
+ if (xf86GetOptValBool(pLeo->Options, OPTION_HW_CURSOR, &pLeo->HWCursor))
+ from = X_CONFIG;
+ if (xf86ReturnOptValBool(pLeo->Options, OPTION_SW_CURSOR, FALSE)) {
+ from = X_CONFIG;
+ pLeo->HWCursor = FALSE;
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
+ pLeo->HWCursor ? "HW" : "SW");
+
+ if (xf86ReturnOptValBool(pLeo->Options, OPTION_NOACCEL, FALSE)) {
+ pLeo->NoAccel = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n");
+ }
+
+ if (xf86LoadSubModule(pScrn, "cfb32") == NULL) {
+ LeoFreeRec(pScrn);
+ return FALSE;
+ }
+
+ if (pLeo->HWCursor && xf86LoadSubModule(pScrn, "ramdac") == NULL) {
+ LeoFreeRec(pScrn);
+ return FALSE;
+ }
+
+ /*********************
+ set up clock and mode stuff
+ *********************/
+
+ pScrn->progClock = TRUE;
+
+ if(pScrn->display->virtualX || pScrn->display->virtualY) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Leo does not support a virtual desktop\n");
+ pScrn->display->virtualX = 0;
+ pScrn->display->virtualY = 0;
+ }
+
+ xf86SbusUseBuiltinMode(pScrn, pLeo->psdp);
+ pScrn->currentMode = pScrn->modes;
+ pScrn->displayWidth = pScrn->virtualX;
+
+ /* Set display resolution */
+ xf86SetDpi(pScrn, 0, 0);
+
+ return TRUE;
+}
+
+/* Mandatory */
+
+/* This gets called at the start of each server generation */
+
+static Bool
+LeoScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
+ ScrnInfoPtr pScrn;
+ LeoPtr pLeo;
+ int ret;
+ VisualPtr visual;
+ extern Bool LeoAccelInit(ScreenPtr pScreen, LeoPtr pLeo);
+
+ /*
+ * First get the ScrnInfoRec
+ */
+ pScrn = xf86Screens[pScreen->myNum];
+
+ pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ /* Map the Leo memory */
+ pLeo->fb =
+ xf86MapSbusMem (pLeo->psdp, LEO_FB0_VOFF, 0x803000);
+
+ if (! pLeo->fb)
+ return FALSE;
+
+ /* Darken the screen for aesthetic reasons and set the viewport */
+ LeoSaveScreen(pScreen, SCREEN_SAVER_ON);
+
+ /*
+ * The next step is to setup the screen's visuals, and initialise the
+ * framebuffer code. In cases where the framebuffer's default
+ * choices for things like visual layouts and bits per RGB are OK,
+ * this may be as simple as calling the framebuffer's ScreenInit()
+ * function. If not, the visuals will need to be setup before calling
+ * a fb ScreenInit() function and fixed up after.
+ */
+
+ /*
+ * Reset visual list.
+ */
+ miClearVisualTypes();
+
+ /* Setup the visuals we support. */
+
+ if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits,
+ pScrn->defaultVisual))
+ return FALSE;
+
+ /*
+ * Call the framebuffer layer's ScreenInit function, and fill in other
+ * pScreen fields.
+ */
+
+ ret = cfb32ScreenInit(pScreen, pLeo->fb, pScrn->virtualX,
+ pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
+ 2048);
+ if (!ret)
+ return FALSE;
+
+ miInitializeBackingStore(pScreen);
+ xf86SetBackingStore(pScreen);
+ xf86SetSilkenMouse(pScreen);
+
+ xf86SetBlackWhitePixels(pScreen);
+
+ if (pScrn->bitsPerPixel > 8) {
+ /* Fixup RGB ordering */
+ visual = pScreen->visuals + pScreen->numVisuals;
+ while (--visual >= pScreen->visuals) {
+ if ((visual->class | DynamicClass) == DirectColor) {
+ visual->offsetRed = pScrn->offset.red;
+ visual->offsetGreen = pScrn->offset.green;
+ visual->offsetBlue = pScrn->offset.blue;
+ visual->redMask = pScrn->mask.red;
+ visual->greenMask = pScrn->mask.green;
+ visual->blueMask = pScrn->mask.blue;
+ }
+ }
+ }
+
+ if (!LeoAccelInit(pScreen, pLeo))
+ return FALSE;
+
+ if (!pLeo->NoAccel)
+ xf86Msg(X_INFO, "%s: Using acceleration\n", pLeo->psdp->device);
+
+ /* Initialise cursor functions */
+ miDCInitialize (pScreen, xf86GetPointerScreenFuncs());
+
+ /* Initialize HW cursor layer.
+ Must follow software cursor initialization*/
+ if (pLeo->HWCursor) {
+ extern Bool LeoHWCursorInit(ScreenPtr pScreen);
+
+ if(!LeoHWCursorInit(pScreen)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Hardware cursor initialization failed\n");
+ return(FALSE);
+ }
+ xf86SbusHideOsHwCursor(pLeo->psdp);
+ }
+
+ /* Initialise default colourmap */
+ if (!miCreateDefColormap(pScreen))
+ return FALSE;
+
+ pLeo->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = LeoCloseScreen;
+ pScreen->SaveScreen = LeoSaveScreen;
+
+ /* Report any unused options (only for the first generation) */
+ if (serverGeneration == 1) {
+ xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+ }
+
+ /* unblank the screen */
+ LeoSaveScreen(pScreen, SCREEN_SAVER_OFF);
+
+ /* Done */
+ return TRUE;
+}
+
+
+/* Usually mandatory */
+static Bool
+LeoSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+{
+ return TRUE;
+}
+
+
+/*
+ * This function is used to initialize the Start Address - the first
+ * displayed location in the video memory.
+ */
+/* Usually mandatory */
+static void
+LeoAdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ /* we don't support virtual desktops */
+ return;
+}
+
+extern void LeoVtChange (ScreenPtr pScreen, int enter);
+
+/*
+ * This is called when VT switching back to the X server. Its job is
+ * to reinitialise the video mode.
+ */
+
+/* Mandatory */
+static Bool
+LeoEnterVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ pLeo->vtSema = FALSE;
+ LeoVtChange (pScrn->pScreen, TRUE);
+ if (pLeo->HWCursor)
+ xf86SbusHideOsHwCursor (pLeo->psdp);
+ return TRUE;
+}
+
+
+/*
+ * This is called when VT switching away from the X server.
+ */
+
+/* Mandatory */
+static void
+LeoLeaveVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ LeoVtChange (pScrn->pScreen, FALSE);
+ pLeo->vtSema = TRUE;
+}
+
+
+/*
+ * This is called at the end of each server generation. It restores the
+ * original (text) mode. It should really also unmap the video memory too.
+ */
+
+/* Mandatory */
+static Bool
+LeoCloseScreen(int scrnIndex, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ pScrn->vtSema = FALSE;
+ xf86UnmapSbusMem(pLeo->psdp, pLeo->fb, 0x803000);
+
+ if (pLeo->HWCursor)
+ xf86SbusHideOsHwCursor (pLeo->psdp);
+
+ pScreen->CloseScreen = pLeo->CloseScreen;
+ return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+ return FALSE;
+}
+
+
+/* Free up any per-generation data structures */
+
+/* Optional */
+static void
+LeoFreeScreen(int scrnIndex, int flags)
+{
+ LeoFreeRec(xf86Screens[scrnIndex]);
+}
+
+
+/* Checks if a mode is suitable for the selected chipset. */
+
+/* Optional */
+static int
+LeoValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+{
+ if (mode->Flags & V_INTERLACE)
+ return(MODE_BAD);
+
+ return(MODE_OK);
+}
+
+/* Do screen blanking */
+
+/* Mandatory */
+static Bool
+LeoSaveScreen(ScreenPtr pScreen, int mode)
+ /* this function should blank the screen when unblank is FALSE and
+ unblank it when unblank is TRUE -- it doesn't actually seem to be
+ used for much though */
+{
+ return TRUE;
+}
+
+/*
+ * This is the implementation of the Sync() function.
+ */
+void
+LeoSync(ScrnInfoPtr pScrn)
+{
+ return;
+}
diff --git a/src/leo_frect.c b/src/leo_frect.c
new file mode 100644
index 0000000..4f1e854
--- /dev/null
+++ b/src/leo_frect.c
@@ -0,0 +1,233 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - Rectangle filling.
+ *
+ * Copyright (C) 1999, 2000 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_frect.c,v 1.2 2000/05/23 04:47:47 dawes Exp $ */
+
+#define PSZ 32
+
+#include "leo.h"
+#include "leo_regs.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+
+void
+LeoPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *prectInit)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pDrawable->pScreen);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ register BoxPtr pbox;
+ BoxPtr pextent;
+ int n;
+ int xorg, yorg;
+
+ /* No garbage please. */
+ if(nrectFill <= 0)
+ return;
+
+ prgnClip = cfbGetCompositeClip(pGC);
+
+ prect = prectInit;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ if (xorg || yorg) {
+ prect = prectInit;
+ n = nrectFill;
+ while(n--) {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+ prect = prectInit;
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ ld0->fg = pGC->fgPixel;
+
+ if (REGION_NUM_RECTS(prgnClip) == 1) {
+ int x1, y1, x2, y2;
+ int x, y, xx, yy;
+
+ pextent = REGION_RECTS(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--) {
+ x = prect->x;
+ y = prect->y;
+ xx = x + prect->width;
+ yy = y + prect->height;
+ if (x < x1)
+ x = x1;
+ if (y < y1)
+ y = y1;
+ prect++;
+ if (xx > x2) xx = x2;
+ if (yy > y2) yy = y2;
+ if (x >= xx) continue;
+ if (y >= yy) continue;
+
+ lc0->extent = (xx - x - 1) | ((yy - y - 1) << 11);
+ lc0->fill = x | (y << 11);
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+ }
+ } else {
+ int x1, y1, x2, y2, bx1, by1, bx2, by2;
+ int x, y, w, h;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--) {
+ if ((bx1 = prect->x) < x1)
+ bx1 = x1;
+
+ if ((by1 = prect->y) < y1)
+ by1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+
+ prect++;
+
+ if (bx1 >= bx2 || by1 >= by2)
+ 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--) {
+ x = max(bx1, pbox->x1);
+ y = max(by1, pbox->y1);
+ w = min(bx2, pbox->x2) - x;
+ h = min(by2, pbox->y2) - y;
+ pbox++;
+
+ /* see if clipping left anything */
+ if (w > 0 && h > 0) {
+ lc0->extent = (w - 1) | ((h - 1) << 11);
+ lc0->fill = x | (y << 11);
+
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+ }
+ }
+ }
+ }
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+}
+
+void
+LeoPolyFillRect1Rect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *prectInit)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pDrawable->pScreen);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ BoxPtr pextent;
+ int n;
+ int xorg, yorg;
+ int x1, y1, x2, y2;
+ int x, y, xx, yy;
+
+ /* No garbage please. */
+ if(nrectFill <= 0)
+ return;
+
+ prgnClip = cfbGetCompositeClip(pGC);
+
+ prect = prectInit;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ if (xorg || yorg) {
+ prect = prectInit;
+ n = nrectFill;
+ while(n--) {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+ prect = prectInit;
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ ld0->fg = pGC->fgPixel;
+
+ pextent = REGION_RECTS(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--) {
+ x = prect->x;
+ y = prect->y;
+ xx = x + prect->width;
+ yy = y + prect->height;
+ if (x < x1)
+ x = x1;
+ if (y < y1)
+ y = y1;
+ prect++;
+ if (xx > x2) xx = x2;
+ if (x >= xx) continue;
+ if (yy > y2) yy = y2;
+ if (y >= yy) continue;
+
+ lc0->extent = (xx - x - 1) | ((yy - y - 1) << 11);
+ lc0->fill = x | (y << 11);
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+ }
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+}
diff --git a/src/leo_frectsp.c b/src/leo_frectsp.c
new file mode 100644
index 0000000..8784acc
--- /dev/null
+++ b/src/leo_frectsp.c
@@ -0,0 +1,276 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - Tiled/stippled rectangle filling.
+ *
+ * Copyright (C) 1999, 2000 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_frectsp.c,v 1.2 2000/05/23 04:47:47 dawes Exp $ */
+
+#define PSZ 32
+
+#include "leo.h"
+#include "leo_regs.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+
+void
+LeoPolyFillStippledRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *prectInit)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pDrawable->pScreen);
+ LeoPrivGCPtr gcPriv = LeoGetGCPrivate (pGC);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ register BoxPtr pbox;
+ BoxPtr pextent;
+ int n;
+ int xorg, yorg;
+ unsigned char *fb;
+ unsigned int *dst, *dline, *src, *srcstart, *srcend;
+
+ /* No garbage please. */
+ if(nrectFill <= 0)
+ return;
+
+ prgnClip = cfbGetCompositeClip(pGC);
+
+ prect = prectInit;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ if (xorg || yorg) {
+ prect = prectInit;
+ n = nrectFill;
+ while(n--) {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+ prect = prectInit;
+
+ if ((gcPriv->stipple->alu & 0xf) != GXcopy)
+ ld0->rop = leoRopTable[gcPriv->stipple->alu & 0xf];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ ld0->fg = gcPriv->stipple->fg;
+ lc0->addrspace = LEO_ADDRSPC_FONT_OBGR;
+ if (gcPriv->stipple->alu & 0x80) {
+ lc0->fontt = 1;
+ } else {
+ lc0->fontt = 0;
+ ld0->bg = gcPriv->stipple->bg;
+ }
+ fb = (unsigned char *)pLeo->fb;
+ srcstart = &gcPriv->stipple->bits[0];
+ srcend = &gcPriv->stipple->bits[32];
+
+ if (REGION_NUM_RECTS(prgnClip) == 1) {
+ int x1, y1, x2, y2;
+ int x, y, xx, yy, w, h;
+ int i, j, sw, sm, ew, em, s;
+
+ pextent = REGION_RECTS(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--) {
+ x = prect->x;
+ y = prect->y;
+ xx = x + prect->width;
+ yy = y + prect->height;
+ if (x < x1) x = x1;
+ if (y < y1) y = y1;
+ if (xx > x2) xx = x2;
+ if (yy > y2) yy = y2;
+ prect++;
+ if (x >= xx) continue;
+ if (y >= yy) continue;
+ prect++;
+ w = xx - x;
+ h = yy - y;
+ if (x & 31) {
+ sw = 32 - (x & 31);
+ sm = 0xffffffff >> (x & 31);
+ } else {
+ sw = 0;
+ sm = 0xffffffff;
+ }
+ dline = (unsigned int *)(fb + (y << 13) + ((x & ~31) << 2));
+ src = srcstart + (y & 31);
+ w -= sw;
+ if (w <= 0) {
+ if (w)
+ sm &= 0xffffffff << (32 - (w & 31));
+ lc0->fontmsk = sm;
+
+ for (i = 0; i < h; i++) {
+ s = *src++;
+ *dline = s;
+ if (src == srcend)
+ src = srcstart;
+ dline += 2048;
+ }
+ } else {
+ ew = w & 31;
+ em = 0xffffffff << (32 - ew);
+ w &= ~31;
+
+ if (!sw && !ew)
+ lc0->fontmsk = 0xffffffff;
+ for (i = 0; i < h; i++) {
+ s = *src++;
+ dst = dline;
+ if (sw) {
+ lc0->fontmsk = sm;
+ *dst = s;
+ dst += 32;
+ lc0->fontmsk = 0xffffffff;
+ } else if (ew)
+ lc0->fontmsk = 0xffffffff;
+ for (j = 0; j < w; j += 32) {
+ *dst = s;
+ dst += 32;
+ }
+ if (ew) {
+ lc0->fontmsk = em;
+ *dst = s;
+ }
+ if (src == srcend)
+ src = srcstart;
+ dline += 2048;
+ }
+ }
+ }
+ } else {
+ int x1, y1, x2, y2, bx1, by1, bx2, by2;
+ int x, y, w, h;
+ int i, j, sw, sm, ew, em, s;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--) {
+ if ((bx1 = prect->x) < x1)
+ bx1 = x1;
+
+ if ((by1 = prect->y) < y1)
+ by1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+
+ prect++;
+
+ if (bx1 >= bx2 || by1 >= by2)
+ 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--) {
+ x = max(bx1, pbox->x1);
+ y = max(by1, pbox->y1);
+ w = min(bx2, pbox->x2) - x;
+ h = min(by2, pbox->y2) - y;
+ pbox++;
+
+ /* see if clipping left anything */
+ if (w > 0 && h > 0) {
+ if (x & 31) {
+ sw = 32 - (x & 31);
+ sm = 0xffffffff >> (x & 31);
+ } else {
+ sw = 0;
+ sm = 0xffffffff;
+ }
+ dline = (unsigned int *)(fb + (y << 13) + ((x & ~31) << 2));
+ src = srcstart + (y & 31);
+ w -= sw;
+ if (w <= 0) {
+ w += 32;
+ if (w != 32)
+ sm &= 0xffffffff << (32 - (w & 31));
+ lc0->fontmsk = sm;
+
+ for (i = 0; i < h; i++) {
+ s = *src++;
+ *dline = s;
+ if (src == srcend)
+ src = srcstart;
+ dline += 2048;
+ }
+ } else {
+ ew = w & 31;
+ em = 0xffffffff << (32 - ew);
+ w &= ~31;
+
+ if (!sw && !ew)
+ lc0->fontmsk = 0xffffffff;
+
+ for (i = 0; i < h; i++) {
+ s = *src++;
+ dst = dline;
+ if (sw) {
+ lc0->fontmsk = sm;
+ *dst = s;
+ dst += 32;
+ lc0->fontmsk = 0xffffffff;
+ } else if (ew)
+ lc0->fontmsk = 0xffffffff;
+ for (j = 0; j < w; j += 32) {
+ *dst = s;
+ dst += 32;
+ }
+ if (ew) {
+ lc0->fontmsk = em;
+ *dst = s;
+ }
+ if (src == srcend)
+ src = srcstart;
+ dline += 2048;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+ lc0->addrspace = LEO_ADDRSPC_OBGR;
+}
diff --git a/src/leo_fspans.c b/src/leo_fspans.c
new file mode 100644
index 0000000..755870c
--- /dev/null
+++ b/src/leo_fspans.c
@@ -0,0 +1,127 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - Fill spans.
+ *
+ * Copyright (C) 1999, 2000 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_fspans.c,v 1.1 2000/05/18 23:21:40 dawes Exp $ */
+
+#define PSZ 32
+
+#include "leo.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+#include "mi.h"
+#include "mispans.h"
+
+void
+LeoFillSpansSolid (DrawablePtr pDrawable, GCPtr pGC,
+ int n, DDXPointPtr ppt,
+ int *pwidth, int fSorted)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pGC->pScreen);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+ int numRects, *pwidthFree;
+ DDXPointPtr pptFree;
+ RegionPtr clip;
+ unsigned char *fb;
+ int fg;
+ int cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0;
+
+ clip = cfbGetCompositeClip(pGC);
+ numRects = REGION_NUM_RECTS(clip);
+
+ if (!numRects)
+ return;
+
+ if (numRects == 1) {
+ cx1 = clip->extents.x1;
+ cx2 = clip->extents.x2;
+ cy1 = clip->extents.y1;
+ cy2 = clip->extents.y2;
+ } else {
+ int nTmp = n * miFindMaxBand(clip);
+
+ 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(clip,
+ ppt, pwidth, n,
+ pptFree, pwidthFree, fSorted);
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ }
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ ld0->fg = fg = pGC->fgPixel;
+ fb = (unsigned char *)pLeo->fb;
+
+ while (n--) {
+ int x, y, w;
+ unsigned int *fbf;
+
+ w = *pwidth++;
+ x = ppt->x;
+ y = ppt->y;
+ ppt++;
+
+ if (numRects == 1) {
+ if (y < cy1 || y >= cy2) continue;
+ if (x < cx1) {
+ w -= (cx1 - x);
+ if (w <= 0) continue;
+ x = cx1;
+ }
+ if (x + w > cx2) {
+ if (x >= cx2) continue;
+ w = cx2 - x;
+ }
+ }
+
+ if (w > 12) {
+ lc0->extent = w - 1;
+ lc0->fill = (y << 11) | x;
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+ } else {
+ fbf = (unsigned int *)(fb + (y << 13) + (x << 2));
+ while (w--)
+ *fbf++ = fg;
+ }
+ }
+
+ if (numRects != 1) {
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+ }
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+}
diff --git a/src/leo_fspanssp.c b/src/leo_fspanssp.c
new file mode 100644
index 0000000..92b46a1
--- /dev/null
+++ b/src/leo_fspanssp.c
@@ -0,0 +1,166 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - Fill tiled/stippled spans.
+ *
+ * Copyright (C) 1999, 2000 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_fspanssp.c,v 1.1 2000/05/18 23:21:40 dawes Exp $ */
+
+#define PSZ 32
+
+#include "leo.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+#include "mi.h"
+#include "mispans.h"
+
+void
+LeoFillSpansStippled (DrawablePtr pDrawable, GCPtr pGC,
+ int n, DDXPointPtr ppt,
+ int *pwidth, int fSorted)
+{
+ LeoPrivGCPtr gcPriv = LeoGetGCPrivate (pGC);
+ LeoPtr pLeo = LeoGetScreenPrivate (pGC->pScreen);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+ int numRects, *pwidthFree;
+ DDXPointPtr pptFree;
+ RegionPtr clip;
+ unsigned char *fb;
+ unsigned int *bits, msk;
+ int cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0;
+
+ clip = cfbGetCompositeClip(pGC);
+ numRects = REGION_NUM_RECTS(clip);
+
+ if (!numRects)
+ return;
+
+ if (numRects == 1) {
+ cx1 = clip->extents.x1;
+ cx2 = clip->extents.x2;
+ cy1 = clip->extents.y1;
+ cy2 = clip->extents.y2;
+ } else {
+ int nTmp = n * miFindMaxBand(clip);
+
+ 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(clip,
+ ppt, pwidth, n,
+ pptFree, pwidthFree, fSorted);
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ }
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ ld0->fg = gcPriv->stipple->fg;
+ fb = (unsigned char *)pLeo->fb;
+ lc0->addrspace = LEO_ADDRSPC_FONT_OBGR;
+ if (gcPriv->stipple->alu & 0x80) {
+ lc0->fontt = 1;
+ } else {
+ lc0->fontt = 0;
+ ld0->bg = gcPriv->stipple->bg;
+ }
+ lc0->fontmsk = 0xffffffff;
+ msk = 0xffffffff;
+ bits = &gcPriv->stipple->bits[0];
+ while (n--) {
+ int x, y, w;
+ unsigned int *dst, s, i, sw, sm;
+
+ w = *pwidth++;
+ x = ppt->x;
+ y = ppt->y;
+ ppt++;
+ if (numRects == 1) {
+ if (y < cy1 || y >= cy2) continue;
+ if (x < cx1) {
+ w -= (cx1 - x);
+ if (w <= 0) continue;
+ x = cx1;
+ }
+ if (x + w > cx2) {
+ if (x >= cx2) continue;
+ w = cx2 - x;
+ }
+ }
+ s = bits[y & 31];
+ dst = (unsigned int *)(fb + (y << 13) + ((x & ~31) << 2));
+ if (x & 31) {
+ sw = 32 - (x & 31);
+ sm = 0xffffffff >> (x & 31);
+ w -= sw;
+ if (w <= 0) {
+ if (w) sm &= 0xffffffff << (32 - (w & 31));
+ if (msk != sm) {
+ msk = sm;
+ lc0->fontmsk = sm;
+ }
+ *dst = s;
+ continue;
+ }
+ if (msk != sm) {
+ msk = sm;
+ lc0->fontmsk = sm;
+ }
+ *dst = s;
+ dst += 32;
+ } else {
+ sw = 0;
+ }
+ sw = w & 31;
+ w &= ~31;
+ if (w && msk != 0xffffffff) {
+ msk = 0xffffffff;
+ lc0->fontmsk = 0xffffffff;
+ for (i = 0; i < w; i += 32) {
+ *dst = s;
+ dst += 32;
+ }
+ }
+ if (sw) {
+ msk = 0xffffffff << (32 - sw);
+ lc0->fontmsk = msk;
+ *dst = s;
+ }
+ }
+
+ if (numRects != 1) {
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+ }
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+ lc0->addrspace = LEO_ADDRSPC_OBGR;
+}
diff --git a/src/leo_glyph.c b/src/leo_glyph.c
new file mode 100644
index 0000000..747865c
--- /dev/null
+++ b/src/leo_glyph.c
@@ -0,0 +1,325 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - Glyph rops.
+ *
+ * Copyright (C) 1999, 2000 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_glyph.c,v 1.1 2000/05/18 23:21:40 dawes Exp $ */
+
+#define PSZ 32
+
+#include "leo.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "fontstruct.h"
+#include "dixfontstr.h"
+
+#include "cfb.h"
+#include "mi.h"
+
+void
+LeoPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci, pointer pGlyphBase)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pGC->pScreen);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+ RegionPtr clip;
+ CharInfoPtr pci;
+ int w, h, x0, y0, i;
+ unsigned int *bits;
+ BoxRec box;
+ int curw = -1;
+ unsigned int *fbf;
+ unsigned char *fb;
+ int height, width;
+
+ clip = cfbGetCompositeClip(pGC);
+ /* compute an approximate (but covering) bounding box */
+ box.x1 = 0;
+ if (ppci[0]->metrics.leftSideBearing < 0)
+ box.x1 = ppci[0]->metrics.leftSideBearing;
+ h = nglyph - 1;
+ w = ppci[h]->metrics.rightSideBearing;
+ while (--h >= 0)
+ w += ppci[h]->metrics.characterWidth;
+ box.x2 = w;
+ box.y1 = -FONTMAXBOUNDS(pGC->font,ascent);
+ box.y2 = FONTMAXBOUNDS(pGC->font,descent);
+
+ box.x1 += pDrawable->x + x;
+ box.x2 += pDrawable->x + x;
+ box.y1 += pDrawable->y + y;
+ box.y2 += pDrawable->y + y;
+
+ switch (RECT_IN_REGION(pGC->pScreen, clip, &box)) {
+ case rgnPART:
+ if (REGION_NUM_RECTS(clip) == 1) {
+ ld0->vclipmin = (clip->extents.y1 << 16) | clip->extents.x1;
+ ld0->vclipmax = ((clip->extents.y2 - 1) << 16) | (clip->extents.x2 - 1);
+ break;
+ }
+ cfbPolyGlyphBlt8 (pDrawable, pGC, x, y, nglyph, ppci, pGlyphBase);
+ case rgnOUT:
+ return;
+ default:
+ clip = NULL;
+ break;
+ }
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ lc0->fontt = 1;
+ lc0->addrspace = LEO_ADDRSPC_FONT_OBGR;
+ ld0->fg = pGC->fgPixel;
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ height = pLeo->height;
+ width = pLeo->width;
+
+ fb = (unsigned char *)pLeo->fb;
+
+ while (nglyph--) {
+ pci = *ppci++;
+
+ w = GLYPHWIDTHPIXELS (pci);
+ h = GLYPHHEIGHTPIXELS (pci);
+ if (!w || !h)
+ goto next_glyph;
+
+ x0 = x + pci->metrics.leftSideBearing;
+ y0 = y - pci->metrics.ascent;
+
+ /* We're off the screen to the left, making our way
+ * back onto the screen.
+ */
+ if((x0 >> 31) == -1)
+ goto next_glyph;
+
+ /* We walked off the screen (to the right or downwards)
+ * or we started there, we're never going to work our
+ * way back so stop now.
+ */
+ if(x0 >= width || y0 >= height)
+ break;
+
+ bits = (unsigned int *) pci->bits;
+
+ if (w != curw) {
+ curw = w;
+ if (w)
+ lc0->fontmsk = 0xffffffff << (32 - w);
+ else
+ lc0->fontmsk = 0;
+ }
+
+ fbf = (unsigned *)(fb + (y0 << 13) + (x0 << 2));
+ if (y0 + h <= height)
+ for (i = 0; i < h; i++) {
+ *fbf = *bits++;
+ fbf += 2048;
+ }
+ else
+ for (i = 0; i < h && y0 + i < height; i++) {
+ *fbf = *bits++;
+ fbf += 2048;
+ }
+ next_glyph:
+ x += pci->metrics.characterWidth;
+ }
+
+ lc0->addrspace = LEO_ADDRSPC_OBGR;
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+ if (clip) {
+ ld0->vclipmin = 0;
+ ld0->vclipmax = pLeo->vclipmax;
+ }
+}
+
+void
+LeoTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci, pointer pGlyphBase)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pGC->pScreen);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+ RegionPtr clip;
+ int h, hTmp;
+ int widthGlyph, widthGlyphs;
+ BoxRec bbox;
+ FontPtr pfont = pGC->font;
+ int curw = -1;
+ unsigned int *fbf;
+ unsigned char *fb;
+ int height, width;
+
+ widthGlyph = FONTMAXBOUNDS(pfont,characterWidth);
+ h = FONTASCENT(pfont) + FONTDESCENT(pfont);
+ clip = cfbGetCompositeClip(pGC);
+ bbox.x1 = x + pDrawable->x;
+ bbox.x2 = bbox.x1 + (widthGlyph * nglyph);
+ bbox.y1 = y + pDrawable->y - FONTASCENT(pfont);
+ bbox.y2 = bbox.y1 + h;
+
+ /* If fully out of range, and we have no chance of getting back
+ * in range, no work to do.
+ */
+ y = y + pDrawable->y - FONTASCENT(pfont);
+ x += pDrawable->x;
+ height = pLeo->height;
+ width = pLeo->width;
+
+ if (x >= width)
+ return;
+
+ switch (RECT_IN_REGION(pGC->pScreen, clip, &bbox)) {
+ case rgnPART:
+ if (REGION_NUM_RECTS(clip) == 1) {
+ ld0->vclipmin = (clip->extents.y1 << 16) | clip->extents.x1;
+ ld0->vclipmax = ((clip->extents.y2 - 1) << 16) | (clip->extents.x2 - 1);
+ break;
+ }
+ x -= pDrawable->x;
+ y = y - pDrawable->y + FONTASCENT(pfont);
+ if (pGlyphBase)
+ cfbPolyGlyphBlt8 (pDrawable, pGC, x, y, nglyph, ppci, NULL);
+ else
+ miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pGlyphBase);
+ case rgnOUT:
+ return;
+ default:
+ clip = NULL;
+ break;
+ }
+
+ lc0->addrspace = LEO_ADDRSPC_FONT_OBGR;
+ ld0->fg = pGC->fgPixel;
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+
+ fb = (unsigned char *)pLeo->fb;
+
+ if(pGlyphBase)
+ lc0->fontt = 1;
+ else {
+ lc0->fontt = 0;
+ ld0->bg = pGC->bgPixel;
+ }
+
+#define LoopIt(count, w, loadup, fetch) \
+ if (w != curw) { \
+ curw = w; \
+ lc0->fontmsk = 0xffffffff << (32 - w); \
+ } \
+ while (nglyph >= count) { \
+ loadup \
+ nglyph -= count; \
+ fbf = (unsigned *)(fb + (y << 13) + (x << 2)); \
+ hTmp = h; \
+ if (y + h <= height) \
+ while (hTmp--) { \
+ *fbf = fetch; \
+ fbf += 2048; \
+ } \
+ else \
+ for (hTmp = 0; hTmp < h && y + hTmp < height; hTmp++) { \
+ *fbf = fetch; \
+ fbf += 2048; \
+ } \
+ x += w; \
+ if(x >= width) \
+ goto out; \
+ }
+
+ if (widthGlyph <= 8) {
+ widthGlyphs = widthGlyph << 2;
+ LoopIt(4, widthGlyphs,
+ unsigned int *char1 = (unsigned int *) (*ppci++)->bits;
+ unsigned int *char2 = (unsigned int *) (*ppci++)->bits;
+ unsigned int *char3 = (unsigned int *) (*ppci++)->bits;
+ unsigned int *char4 = (unsigned int *) (*ppci++)->bits;,
+ (*char1++ | ((*char2++ | ((*char3++ | (*char4++
+ >> widthGlyph))
+ >> widthGlyph))
+ >> widthGlyph)))
+ } else if (widthGlyph <= 10) {
+ widthGlyphs = (widthGlyph << 1) + widthGlyph;
+ LoopIt(3, widthGlyphs,
+ unsigned int *char1 = (unsigned int *) (*ppci++)->bits;
+ unsigned int *char2 = (unsigned int *) (*ppci++)->bits;
+ unsigned int *char3 = (unsigned int *) (*ppci++)->bits;,
+ (*char1++ | ((*char2++ | (*char3++ >> widthGlyph)) >> widthGlyph)))
+ } else if (widthGlyph <= 16) {
+ widthGlyphs = widthGlyph << 1;
+ LoopIt(2, widthGlyphs,
+ unsigned int *char1 = (unsigned int *) (*ppci++)->bits;
+ unsigned int *char2 = (unsigned int *) (*ppci++)->bits;,
+ (*char1++ | (*char2++ >> widthGlyph)))
+ }
+ if(nglyph != 0) {
+ if (widthGlyph != curw) {
+ curw = widthGlyph;
+ lc0->fontmsk = 0xffffffff << (32 - widthGlyph);
+ }
+ while (nglyph--) {
+ unsigned int *char1 = (unsigned int *) (*ppci++)->bits;
+ fbf = (unsigned *)(fb + (y << 13) + (x << 2));
+ hTmp = h;
+ if (y + h <= height)
+ while (hTmp--) {
+ *fbf = *char1++;
+ fbf += 2048;
+ }
+ else
+ for (hTmp = 0; hTmp < h && y + hTmp < height; hTmp++) {
+ *fbf = *char1++;
+ fbf += 2048;
+ }
+ x += widthGlyph;
+ if (x >= width)
+ goto out;
+ }
+ }
+
+out: lc0->addrspace = LEO_ADDRSPC_OBGR;
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+ if (clip) {
+ ld0->vclipmin = 0;
+ ld0->vclipmax = pLeo->vclipmax;
+ }
+}
+
+void
+LeoPolyTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci, pointer pGlyphBase)
+{
+ LeoTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, (char *) 1);
+}
diff --git a/src/leo_regs.h b/src/leo_regs.h
new file mode 100644
index 0000000..e001587
--- /dev/null
+++ b/src/leo_regs.h
@@ -0,0 +1,198 @@
+/*
+ * Acceleration for the Leo(ZX) framebuffer - register layout.
+ *
+ * Copyright (C) 1999, 2000 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * JAKUB JELINEK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_regs.h,v 1.1 2000/05/18 23:21:40 dawes Exp $ */
+
+#ifndef LEOREGS_H
+#define LEOREGS_H
+
+/* rop register */
+#define LEO_ATTR_PICK_DISABLE 0x00000000
+#define LEO_ATTR_PICK_2D 0x80000000
+#define LEO_ATTR_PICK_3D 0xa0000000
+#define LEO_ATTR_PICK_2D_REND 0xc0000000
+#define LEO_ATTR_PICK_3D_REND 0xe0000000
+
+#define LEO_ATTR_DCE_DISABLE 0x00000000
+#define LEO_ATTR_DCE_ENABLE 0x10000000
+
+#define LEO_ATTR_APE_DISABLE 0x00000000
+#define LEO_ATTR_APE_ENABLE 0x08000000
+
+#define LEO_ATTR_COLOR_VAR 0x00000000
+#define LEO_ATTR_COLOR_CONST 0x04000000
+
+#define LEO_ATTR_AA_DISABLE 0x02000000
+#define LEO_ATTR_AA_ENABLE 0x01000000
+
+#define LEO_ATTR_ABE_BG 0x00000000 /* dst + alpha * (src - bg) */
+#define LEO_ATTR_ABE_FB 0x00800000 /* dst + alpha * (src - dst) */
+
+#define LEO_ATTR_ABE_DISABLE 0x00000000
+#define LEO_ATTR_ABE_ENABLE 0x00400000
+
+#define LEO_ATTR_BLTSRC_A 0x00000000
+#define LEO_ATTR_BLTSRC_B 0x00200000
+
+#define LEO_ROP_ZERO (0x0 << 18)
+#define LEO_ROP_NEW_AND_OLD (0x8 << 18)
+#define LEO_ROP_NEW_AND_NOLD (0x4 << 18)
+#define LEO_ROP_NEW (0xc << 18)
+#define LEO_ROP_NNEW_AND_OLD (0x2 << 18)
+#define LEO_ROP_OLD (0xa << 18)
+#define LEO_ROP_NEW_XOR_OLD (0x6 << 18)
+#define LEO_ROP_NEW_OR_OLD (0xe << 18)
+#define LEO_ROP_NNEW_AND_NOLD (0x1 << 18)
+#define LEO_ROP_NNEW_XOR_NOLD (0x9 << 18)
+#define LEO_ROP_NOLD (0x5 << 18)
+#define LEO_ROP_NEW_OR_NOLD (0xd << 18)
+#define LEO_ROP_NNEW (0x3 << 18)
+#define LEO_ROP_NNEW_OR_OLD (0xb << 18)
+#define LEO_ROP_NNEW_OR_NOLD (0x7 << 18)
+#define LEO_ROP_ONES (0xf << 18)
+
+#define LEO_ATTR_HSR_DISABLE 0x00000000
+#define LEO_ATTR_HSR_ENABLE 0x00020000
+
+#define LEO_ATTR_WRITEZ_DISABLE 0x00000000
+#define LEO_ATTR_WRITEZ_ENABLE 0x00010000
+
+#define LEO_ATTR_Z_VAR 0x00000000
+#define LEO_ATTR_Z_CONST 0x00008000
+
+#define LEO_ATTR_WCLIP_DISABLE 0x00000000
+#define LEO_ATTR_WCLIP_ENABLE 0x00004000
+
+#define LEO_ATTR_MONO 0x00000000
+#define LEO_ATTR_STEREO_LEFT 0x00001000
+#define LEO_ATTR_STEREO_RIGHT 0x00003000
+
+#define LEO_ATTR_WE_DISABLE 0x00000000
+#define LEO_ATTR_WE_ENABLE 0x00000800
+
+#define LEO_ATTR_FCE_DISABLE 0x00000000
+#define LEO_ATTR_FCE_ENABLE 0x00000400
+
+#define LEO_ATTR_RE_DISABLE 0x00000000
+#define LEO_ATTR_RE_ENABLE 0x00000200
+
+#define LEO_ATTR_GE_DISABLE 0x00000000
+#define LEO_ATTR_GE_ENABLE 0x00000100
+
+#define LEO_ATTR_BE_DISABLE 0x00000000
+#define LEO_ATTR_BE_ENABLE 0x00000080
+
+#define LEO_ATTR_RGBE_DISABLE 0x00000000
+#define LEO_ATTR_RGBE_ENABLE 0x00000380
+
+#define LEO_ATTR_OE_DISABLE 0x00000000
+#define LEO_ATTR_OE_ENABLE 0x00000040
+
+#define LEO_ATTR_ZE_DISABLE 0x00000000
+#define LEO_ATTR_ZE_ENABLE 0x00000020
+
+#define LEO_ATTR_FORCE_WID 0x00000010
+
+#define LEO_ATTR_FC_PLANE_MASK 0x0000000e
+
+#define LEO_ATTR_BUFFER_A 0x00000000
+#define LEO_ATTR_BUFFER_B 0x00000001
+
+/* csr */
+#define LEO_CSR_BLT_BUSY 0x20000000
+
+typedef struct LeoDraw {
+ unsigned char xxx0[0xe00];
+ volatile unsigned int csr;
+ volatile unsigned int wid;
+ volatile unsigned int wmask;
+ volatile unsigned int widclip;
+ volatile unsigned int vclipmin;
+ volatile unsigned int vclipmax;
+ volatile unsigned int pickmin; /* SS1 only */
+ volatile unsigned int pickmax; /* SS1 only */
+ volatile unsigned int fg;
+ volatile unsigned int bg;
+ volatile unsigned int src; /* Copy/Scroll (SS0 only) */
+ volatile unsigned int dst; /* Copy/Scroll/Fill (SS0 only) */
+ volatile unsigned int extent; /* Copy/Scroll/Fill size (SS0 only) */
+ unsigned int xxx1[3];
+ volatile unsigned int setsem; /* SS1 only */
+ volatile unsigned int clrsem; /* SS1 only */
+ volatile unsigned int clrpick; /* SS1 only */
+ volatile unsigned int clrdat; /* SS1 only */
+ volatile unsigned int alpha; /* SS1 only */
+ unsigned char xxx2[0x2c];
+ volatile unsigned int winbg;
+ volatile unsigned int planemask;
+ volatile unsigned int rop;
+ volatile unsigned int z;
+ volatile unsigned int dczf; /* SS1 only */
+ volatile unsigned int dczb; /* SS1 only */
+ volatile unsigned int dcs; /* SS1 only */
+ volatile unsigned int dczs; /* SS1 only */
+ volatile unsigned int pickfb; /* SS1 only */
+ volatile unsigned int pickbb; /* SS1 only */
+ volatile unsigned int dcfc; /* SS1 only */
+ volatile unsigned int forcecol; /* SS1 only */
+ volatile unsigned int door[8]; /* SS1 only */
+ volatile unsigned int pick[5]; /* SS1 only */
+} LeoDraw;
+
+#define LEO_ADDRSPC_OBGR 0x00
+#define LEO_ADDRSPC_Z 0x01
+#define LEO_ADDRSPC_W 0x02
+#define LEO_ADDRSPC_FONT_OBGR 0x04
+#define LEO_ADDRSPC_FONT_Z 0x05
+#define LEO_ADDRSPC_FONT_W 0x06
+#define LEO_ADDRSPC_O 0x08
+#define LEO_ADDRSPC_B 0x09
+#define LEO_ADDRSPC_G 0x0a
+#define LEO_ADDRSPC_R 0x0b
+
+typedef struct LeoCommand0 {
+ volatile unsigned int csr;
+ volatile unsigned int addrspace;
+ volatile unsigned int fontmsk;
+ volatile unsigned int fontt;
+ volatile unsigned int extent;
+ volatile unsigned int src;
+ unsigned int dst;
+ volatile unsigned int copy;
+ volatile unsigned int fill;
+} LeoCommand0;
+
+typedef struct LeoCross {
+ volatile unsigned int type;
+ volatile unsigned int csr;
+ volatile unsigned int value;
+} LeoCross;
+
+typedef struct LeoCursor {
+ unsigned char xxx0[16];
+ volatile unsigned int cur_type;
+ volatile unsigned int cur_misc;
+ volatile unsigned int cur_cursxy;
+ volatile unsigned int cur_data;
+} LeoCursor;
+
+#endif /* LEOREGS_H */