diff -NaurbB newport.shadow/Imakefile newport.new/Imakefile
--- newport.shadow/Imakefile	Sun Aug 11 19:41:55 2002
+++ newport.new/Imakefile	Wed Oct 29 06:16:26 2003
@@ -3,9 +3,9 @@
 #define IHaveModules
 #include <Server.tmpl>
 
-SRCS = newport_driver.c newport_regs.c newport_cmap.c newport_shadow.c newport_cursor.c
+SRCS = newport_driver.c newport_regs.c newport_cmap.c newport_shadow.c newport_cursor.c newport_gc.c newport_fillspans.c newport_setspans.c newport_getspans.c newport_copyarea.c newport_fillrect.c newport_image.c newport_lines.c newport_polytext.c newport_util.c newport_window.c
 
-OBJS = newport_driver.o newport_regs.o newport_cmap.o newport_shadow.o newport_cursor.o
+OBJS = newport_driver.o newport_regs.o newport_cmap.o newport_shadow.o newport_cursor.o newport_gc.o newport_fillspans.o newport_setspans.o newport_getspans.o newport_copyarea.o newport_fillrect.o newport_image.o newport_lines.o newport_polytext.o newport_util.o newport_window.o
 
 XF86CONFIG = XF86Config.indy
 
@@ -14,7 +14,8 @@
 #else
 INCLUDES = -I. \
 	   -I$(XF86COMSRC) -I$(XF86OSSRC) \
-	   -I$(SERVERSRC)/mi -I$(SERVERSRC)/fb \
+	   -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi -I$(SERVERSRC)/fb \
+           -I$(SERVERSRC)/cfb \
 	   -I$(XF86SRC)/shadowfb \
 	   -I$(XF86SRC)/xaa -I$(XF86SRC)/ramdac \
 	   -I$(EXTINCSRC) -I$(SERVERSRC)/Xext -I$(SERVERSRC)/render \
diff -NaurbB newport.shadow/XF86Config.indy newport.new/XF86Config.indy
--- newport.shadow/XF86Config.indy	Sun Aug 11 19:41:29 2002
+++ newport.new/XF86Config.indy	Thu Nov  6 19:49:31 2003
@@ -282,7 +282,9 @@
     Identifier	"Newport Graphics"
     Driver	"newport"
 
+#    Option      "HWCursor"  "false"
 #    Option	"bitplanes" "24"
+#    Option      "ShadowFB" "false"
 EndSection
 
 # **********************************************************************
diff -NaurbB newport.shadow/newport.h newport.new/newport.h
--- newport.shadow/newport.h	Thu Jan 23 18:36:38 2003
+++ newport.new/newport.h	Thu Nov  6 20:17:53 2003
@@ -28,23 +28,71 @@
 #define NEWPORT_BASE_OFFSET 0x00400000
 #define NEWPORT_MAX_BOARDS 2
 
-#undef DEBUG
+/* gc definitions */
+#include "newport_gc.h"
 
-#ifdef DEBUG
-# define TRACE_ENTER(str)       ErrorF("newport: " str " %d\n",pScrn->scrnIndex)
-# define TRACE_EXIT(str)        ErrorF("newport: " str " done\n")
-# define TRACE(str)             ErrorF("newport trace: " str "\n")
-# define TRACE2(str,val)            ErrorF("newport trace: " str "\n",val)
+/*
+  Trace Defines 
+*/
+#undef DEBUG
+#ifndef DEBUG
+#define TRACE_ENTER(fct, str)
+#define TRACE_EXIT(fct, str)
+#define TRACE(fct, __x)
+#define TRACE2(fct, lvl, __x)
+#define NewportDumpPixmap( pPix )
 #else
-# define TRACE_ENTER(str)
-# define TRACE_EXIT(str)
-# define TRACE(str)
-# define TRACE2(str,val)
+
+extern unsigned long newportTrcFilter;
+extern int newportTrcLevel;
+extern int newportTrcInd;
+
+void NewportTrace(const char *s, ... ) ;
+
+#define TRACE_ENTER(fct, str) \
+  if (newportTrcLevel && (newportTrcFilter & fct)) \
+  { \
+    newportTrcInd++; \
+    NewportTrace("->"str"()",NULL); \
+    newportTrcInd++; \
+  }
+
+#define TRACE_EXIT(fct, str) \
+  if (newportTrcLevel && (newportTrcFilter & fct)) \
+  { \
+    newportTrcInd--; \
+    NewportTrace("<-"str"()",NULL); \
+    newportTrcInd--; \
+  }
+
+#define TRACE(fct, __x) if (newportTrcLevel > 1 && (newportTrcFilter & fct)) NewportTrace __x
+
+#define TRACE2(fct, lvl, __x) if (newportTrcLevel > lvl && (newportTrcFilter & fct)) NewportTrace __x
+
+void NewportDumpPixmap( PixmapPtr	pPix );
+
+#define NPTRC_ALL        0xffffffff
+#define NPTRC_MISC       0x00000001
+#define NPTRC_WRAPPERS   0x00000002
+#define NPTRC_SHADOW     0x00000004
+#define NPTRC_CURSOR     0x00000008
+#define NPTRC_GC         0x00000010
+#define NPTRC_GETSPANS   0x00000020
+#define NPTRC_SETSPANS   0x00000040
+#define NPTRC_FILLSPAN   0x00000080
+#define NPTRC_FILLRECT   0x00000100
+#define NPTRC_WINDOW     0x00000200
+#define NPTRC_TEXT       0x00000400
+#define NPTRC_IMAGE      0x00000800
+#define NPTRC_AREA       0x00001000
+#define NPTRC_LINES       0x00002000
+
 #endif
 
 typedef struct {
 	unsigned busID;
 	int bitplanes; 
+  Bool shadowFb;
 	/* revision numbers of the various pieces of silicon */
 	unsigned int board_rev, cmap_rev, rex3_rev, xmap9_rev, bt445_rev;
 	NewportRegsPtr pNewportRegs;	/* Pointer to REX3 registers */
@@ -90,6 +138,20 @@
 
 	OptionInfoPtr Options;
 
+  ScrnInfoPtr 				pScrn;
+  PaintWindowBackgroundProcPtr		PaintWindowBackground;
+  PaintWindowBorderProcPtr		PaintWindowBorder;
+  CopyWindowProcPtr			CopyWindow;
+  CreateGCProcPtr			CreateGC;
+  BackingStoreRestoreAreasProcPtr	RestoreAreas;  
+  ModifyPixmapHeaderProcPtr		ModifyPixmapHeader;
+  Bool				(*EnterVT)(int, int);
+  void				(*LeaveVT)(int, int);
+  void				(*EnableDisableFBAccess)(int, Bool);
+  Bool				vtSema;
+  
+  NewportGCPtr			pcPrivate;
+
 } NewportRec, *NewportPtr;
 
 #define NEWPORTPTR(p) ((NewportPtr)((p)->driverPrivate))
@@ -126,4 +188,114 @@
 Bool NewportHWCursorInit(ScreenPtr pScreen);
 void NewportLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *bits);
 
+/* newport_fillspans.c*/
+void
+NewportFillSpans(
+		 DrawablePtr pDraw,
+		 GC		*pGC,
+		 int		nInit,	
+		 DDXPointPtr pptInit,	
+		 int 	*pwidthInit,		
+		 int 	fSorted 
+		 );
+
+/* newport_fillrect.c*/
+void
+NewportFillRect(
+		DrawablePtr pDraw,
+		GC		*pGC,
+		int		nInit,	
+		xRectangle *pRect
+		);
+
+/* newport_setspans.c */
+void
+NewportSetSpans(
+		DrawablePtr		pDraw,
+		GCPtr		pGC,
+		char		*pcharsrc,
+		DDXPointPtr 	pptInit,
+		int			*pwidthInit,
+		int			nspans,
+		int			fSorted 
+		);
+
+/* newport_getspans.c */
+void NewportGetSpans(
+		     DrawablePtr pDrawable,
+		     int wMax,
+		     DDXPointPtr ppt,
+		     int* pwidth,
+		     int nspans,
+		     char * pdstStart
+		     );
+
+/* newport_copyarea.c */
+RegionPtr 
+NewportCopyArea(DrawablePtr pSrc,
+		DrawablePtr pDst,
+		GC * pGC,
+		int srcx,
+		int srcy,
+		int w,
+		int h,
+		int dstx,
+		int dsty
+		);
+
+
+/* newport_polytext.c */
+int
+NewportPolyText8(DrawablePtr pDraw, 
+		 GC *pGC, 
+		 int x, 
+		 int y, 
+		 int count,
+		 char *chars);
+
+void
+NewportImageText8(DrawablePtr pDraw, 
+		  GC *pGC, 
+		  int x, 
+		  int y, 
+		  int count,
+		  char *chars);
+
+int
+NewportPolyText16(DrawablePtr pDraw, 
+		  GC *pGC, 
+		  int x, 
+		  int y, 
+		  int count,
+		  unsigned short *chars);
+
+void
+NewportImageText16(DrawablePtr pDraw, 
+		   GC *pGC, 
+		   int x, 
+		   int y, 
+		   int count,
+		   unsigned short *chars);
+
+/* newport_image.c */
+void
+NewportPutImage(DrawablePtr pDraw, 
+		GCPtr pGC, 
+		int depth, int x, int y, int w, int h, int leftPad,
+		int format,
+		char *pImage );
+
+extern int NewportScreenIndex;
+extern int NewportGCIndex;
+
+/* newport_lines.c */
+void NewportPolyLines(
+		      DrawablePtr dst,
+		      GCPtr pGC,
+		      int mode,
+		      int n,
+		      DDXPointPtr pPoint);
+
+
 #endif /* __NEWPORT_H__ */
+
diff -NaurbB newport.shadow/newport_copyarea.c newport.new/newport_copyarea.c
--- newport.shadow/newport_copyarea.c	Thu Jan  1 01:00:00 1970
+++ newport.new/newport_copyarea.c	Wed Nov  5 05:19:52 2003
@@ -0,0 +1,150 @@
+/*
+ * Driver for the SGI Indy's Newport graphics card - Copy Areas
+ * 
+ * (c) 2003      Frank Foerstemann <Foerstemann@web.de>
+ *
+ * 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 fur-
+ * nished 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, FIT-
+ * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+ * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall not
+ * be used in advertising or otherwise to promote the sale, use or other deal-
+ * ings in this Software without prior written authorization from the XFree86
+ * Project.
+ *
+ */
+
+#include "X.h"
+#include "Xproto.h"
+#include "misc.h"
+#include "pixmapstr.h"
+#include "input.h"
+#include "font.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "dixfontstr.h"
+#include "fontstruct.h"
+#include "xf86.h"
+#include "xf86str.h"
+
+#include <newport.h>
+#include <newport_util.h>
+
+RegionPtr
+NewportCopyArea(DrawablePtr pSrc,
+		DrawablePtr pDst,
+		GC * pGC,
+		int srcx,
+		int srcy,
+		int w,
+		int h,
+		int dstx,
+		int dsty)
+{
+    ScreenPtr pScreen;
+    ScrnInfoPtr pScrn;
+    NewportPtr pPriv;
+    NewportRegsPtr pNewportRegs;
+    BoxPtr pbox, pboxLast;
+    RegionPtr prgnDst;
+    int x1, y1, x2, y2, xmove, ymove;
+
+    TRACE_ENTER(NPTRC_AREA, "NewportCopyArea");
+
+    TRACE(NPTRC_AREA, ("sx: %d, sy: %d, sw: %d, sh: %d, dx: %d, dy: %d",
+	   srcx, srcy, w, h, dstx, dsty));
+    TRACE(NPTRC_AREA, ("dsrc: (%d,%d)->(%d,%d)", pSrc->x, pSrc->y, pSrc->width, pSrc->height));
+    TRACE(NPTRC_AREA, ("ddst: (%d,%d)->(%d,%d)", pDst->x, pDst->y, pDst->width, pDst->height)); 
+    
+    if ( pSrc->type != DRAWABLE_WINDOW || pDst->type != DRAWABLE_WINDOW ) {
+
+      TRACE(NPTRC_AREA,("Calling miCopyArea ..."));
+      prgnDst=miCopyArea( pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty );
+      TRACE_EXIT(NPTRC_AREA,"NewportCopyArea");
+      return prgnDst;
+    }
+
+    pScreen = pGC->pScreen;
+    pScrn = xf86Screens[pScreen->myNum];
+    pPriv = NEWPORTPTR (pScrn);
+    pNewportRegs = pPriv->pNewportRegs;
+
+    prgnDst = pGC->pCompositeClip;
+    pbox = REGION_RECTS(prgnDst);
+    pboxLast = pbox + REGION_NUM_RECTS(prgnDst) -1;
+    TRACE(NPTRC_AREA,("nbox:%d\n", REGION_NUM_RECTS(prgnDst) ));
+
+    NewportWait (pNewportRegs);
+
+    pNewportRegs->set.drawmode0 = (NPORT_DMODE0_S2S |
+				   NPORT_DMODE0_BLOCK |
+				   NPORT_DMODE0_CHOST |
+				   NPORT_DMODE0_AHOST |
+				   NPORT_DMODE0_STOPX |
+				   NPORT_DMODE0_STOPY |
+				   NPORT_DMODE0_DOSETUP );
+
+    pNewportRegs->set.drawmode1 &= ~(NPORT_DMODE1_LOMASK |
+				     NPORT_DMODE1_DFMASK | 
+				     NPORT_DMODE1_SFMASK |
+				     NPORT_DMODE1_BBENAB );
+    pNewportRegs->set.drawmode1 |= (pGC->alu << 28);
+    pNewportRegs->set.drawmode1 |= NPORT_DMODE1_LOSRC;
+    /*
+    pNewportRegs->set.wrmask = pGC->planemask | 0xfff;
+    */
+    while ( pbox <= pboxLast ) {
+	pbox = NewportSMaskSet( pNewportRegs, pbox, pboxLast );
+	xmove = dstx -srcx +pDst->x -pSrc->x;
+	ymove = dsty -srcy +pDst->y -pSrc->y;
+	if ( xmove <= 0) {
+	    x1 = pSrc->x +srcx;
+	    x2 = pSrc->x +dstx +w -1;
+	} else {
+	    x1 = pSrc->x +srcx +w -1;
+	    x2 = pSrc->x +srcx;
+	}
+	if (ymove <= 0 ) {
+	    y1 = pSrc->y +srcy;
+	    y2 = pSrc->y +srcy +h -1;
+	} else {
+	    y1 = pSrc->y +srcy +h -1;
+	    y2 = pSrc->y +srcy;
+	}
+
+	TRACE(NPTRC_AREA,("Copy: (%d,%d)(%d,%d) -> (%d,%d)", x1,y1, x2,y2, xmove, ymove));
+	NewportWait (pNewportRegs);
+	pNewportRegs->set.xystarti = ((x1 & 0xffff) << 16) | (y1 & 0xffff);
+	pNewportRegs->set.xyendi = ((x2 & 0xffff) << 16) | (y2 & 0xffff);
+	pNewportRegs->go.xymove = ((xmove & 0xffff) << 16) | (ymove & 0xffff);
+
+    }
+    TRACE_EXIT(NPTRC_AREA,"NewportCopyArea");
+    return NULL;
+}
+
+
+
+
+
+
+
+
+
+
+
diff -NaurbB newport.shadow/newport_cursor.c newport.new/newport_cursor.c
--- newport.shadow/newport_cursor.c	Mon Aug 19 00:24:22 2002
+++ newport.new/newport_cursor.c	Tue Jul 15 06:44:18 2003
@@ -25,6 +25,8 @@
 	xf86CursorInfoPtr infoPtr;
 	CARD8 tmp;
 
+	TRACE_ENTER(NPTRC_CURSOR, "NewportHWCursorInit");
+
 	infoPtr = xf86CreateCursorInfoRec();
 	if(!infoPtr)
 		return FALSE;
@@ -58,6 +60,8 @@
 	pNewportRegs->set.dcbdata0.bytes.b3 = tmp;
 	pNewport->curs_cmap_base = (tmp << 5) & 0xffe0;
 
+	TRACE_EXIT(NPTRC_CURSOR, "NewportHWCursorInit");
+
 	return xf86InitCursor(pScreen, infoPtr);
 }
 
@@ -67,8 +71,10 @@
 	NewportPtr pNewport = NEWPORTPTR(pScrn);
 	NewportRegsPtr pNewportRegs = NEWPORTREGSPTR(pScrn);
 
+	TRACE_ENTER(NPTRC_CURSOR, "NewportShowCursor");
 	pNewport->vc2ctrl |= VC2_CTRL_ECDISP;
 	NewportVc2Set( pNewportRegs, VC2_IREG_CONTROL, pNewport->vc2ctrl);
+	TRACE_EXIT(NPTRC_CURSOR, "NewportShowCursor");
 }
 
 static void NewportHideCursor(ScrnInfoPtr pScrn)
@@ -76,8 +82,10 @@
 	NewportPtr pNewport = NEWPORTPTR(pScrn);
 	NewportRegsPtr pNewportRegs = NEWPORTREGSPTR(pScrn);
 
+	TRACE_ENTER(NPTRC_CURSOR, "NewportHideCursor");
 	pNewport->vc2ctrl &= ~VC2_CTRL_ECDISP;
 	NewportVc2Set( pNewportRegs, VC2_IREG_CONTROL, pNewport->vc2ctrl);
+	TRACE_EXIT(NPTRC_CURSOR, "NewportHideCursor");
 }
 
 static void NewportSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
@@ -95,6 +103,7 @@
 	NewportRegsPtr pNewportRegs = NEWPORTREGSPTR(pScrn);
 	LOCO color;
 
+	TRACE_ENTER(NPTRC_CURSOR, "NewportSetCursorColors");
 	color.red = fg & 0xff;
 	color.green = (fg & 0xff00) >> 8;
 	color.blue = (fg & 0xff0000) >> 16;
@@ -103,6 +112,7 @@
 	color.green = (bg & 0xff00) >> 8;
 	color.blue = (bg & 0xff0000) >> 16;
 	NewportCmapSetRGB( pNewportRegs, pNewport->curs_cmap_base+2, color);
+	TRACE_EXIT(NPTRC_CURSOR, "NewportSetCursorColors");
 }
 
 static unsigned char* NewportRealizeCursor(xf86CursorInfoPtr infoPtr, CursorPtr pCurs)
@@ -111,6 +121,8 @@
 	CARD32 *mem, *SrcS, *SrcM, *DstS;
 	unsigned int i;
 
+	TRACE_ENTER(NPTRC_CURSOR, "NewportRealizeCursor");
+
 	if (!(mem = xcalloc(1, size)))
         	return NULL;
 
@@ -130,6 +142,9 @@
 		*DstS = (~*SrcS) & *SrcM;
 		DstS++, SrcS++, SrcM++;
 	}
+
+	TRACE_EXIT(NPTRC_CURSOR, "NewportRealizeCursor");
+
 	return (unsigned char*) mem;
 }
 
@@ -139,6 +154,8 @@
 	CARD16 tmp;
 	NewportRegsPtr pNewportRegs = NEWPORTREGSPTR(pScrn);
 
+	TRACE_ENTER(NPTRC_CURSOR, "NewportLoadCursorImage");
+
 	/* address of cursor data in vc2's ram */
         tmp = NewportVc2Get( pNewportRegs, VC2_IREG_CENTRY);
  	/* this is where we want to write to: */
@@ -151,5 +168,6 @@
 		pNewportRegs->set.dcbdata0.hwords.s1 = *(unsigned short*)bits;
 		bits += sizeof(unsigned short);
         }
+	TRACE_EXIT(NPTRC_CURSOR, "NewportLoadCursorImage");
 }
 
diff -NaurbB newport.shadow/newport_driver.c newport.new/newport_driver.c
--- newport.shadow/newport_driver.c	Wed Jan  1 20:50:31 2003
+++ newport.new/newport_driver.c	Tue Nov  4 06:01:54 2003
@@ -6,6 +6,7 @@
  * This driver is based on the newport.c & newport_con.c kernel code
  *
  * (c) 2000-2002 Guido Guenther <agx@sigxcpu.org>
+ * (c) 2003      Frank Foerstemann <Foerstemann@web.de>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -32,8 +33,7 @@
  */
 /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/newport/newport_driver.c,v 1.19 2002/01/04 21:22:33 tsi Exp $ */
 
-/* function prototypes, common data structures & generic includes */
-#include "newport.h"
+#include <time.h>
 
 /* Drivers using the mi SW cursor need: */
 #include "mipointer.h"
@@ -42,16 +42,31 @@
 /* Drivers using the mi colourmap code need: */
 #include "micmap.h"
 
+#include "mi.h"
+#include "mipict.h"
+
+#include "mfb.h"
+
 /* Drivers using fb need: */
 #include "fb.h"
 
 /* Drivers using the shadow frame buffer need: */
 #include "shadowfb.h"
 
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
 /* Xv Extension */
 #include "xf86xv.h"
 #include "Xv.h"
 
+/* newport headers */
+#include "newport.h"
+#include "newport_gc.h"
+#include "newport_window.h"
+
 #define VERSION			4000
 #define NEWPORT_NAME		"NEWPORT"
 #define NEWPORT_DRIVER_NAME	"newport"
@@ -78,6 +93,24 @@
 static Bool NewportMapRegs(ScrnInfoPtr pScrn);
 static void NewportUnmapRegs(ScrnInfoPtr pScrn);
 static Bool NewportProbeCardInfo(ScrnInfoPtr pScrn);
+static void NewportEnableDisableFBAccess(int index, Bool enable);
+
+
+void
+NewportDummyComposite(CARD8	op,
+		      PicturePtr pSrc,
+		      PicturePtr pMask,
+		      PicturePtr pDst,
+		      INT16	xSrc,
+		      INT16	ySrc,
+		      INT16	xMask,
+		      INT16	yMask,
+		      INT16	xDst,
+		      INT16	yDst,
+		      CARD16	width,
+		      CARD16	height) {
+}
+
 /* ------------------------------------------------------------------ */
 
 DriverRec NEWPORT = {
@@ -122,7 +155,7 @@
 static MODULESETUPPROTO(newportSetup);
 
 static XF86ModuleVersionInfo newportVersRec =
-{
+  {
 	"newport",
 	MODULEVENDORSTRING,
 	MODINFOSTRING1,
@@ -133,7 +166,7 @@
 	ABI_VIDEODRV_VERSION,
 	MOD_CLASS_VIDEODRV,
 	{0,0,0,0}
-};
+  };
 
 XF86ModuleData newportModuleData = { &newportVersRec, newportSetup, NULL };
 
@@ -142,7 +175,7 @@
 {
 	static Bool setupDone = FALSE;
 
-/* This module should be loaded only once, but check to be sure. */
+  /* This module should be loaded only once, but check to be sure. */
 	if (!setupDone) {
 		/*
 		 * Modules that this driver always requires may be loaded
@@ -156,7 +189,8 @@
 		 * might refer to.
 		 *
 		 */
-		LoaderRefSymLists( fbSymbols, ramdacSymbols, shadowSymbols, NULL);
+    LoaderRefSymLists( ramdacSymbols, NULL);
+    /*		LoaderRefSymLists( fbSymbols, ramdacSymbols, shadowSymbols, NULL);*/
 
 
 		/*
@@ -175,7 +209,8 @@
 typedef enum {
 	OPTION_BITPLANES,
 	OPTION_BUS_ID,
-	OPTION_HWCURSOR
+  OPTION_HWCURSOR,
+  OPTION_SHADOWFB
 } NewportOpts;
 
 /* Supported options */
@@ -183,11 +218,28 @@
 	{ OPTION_BITPLANES, "bitplanes", OPTV_INTEGER, {0}, FALSE },
 	{ OPTION_BUS_ID, "BusID", OPTV_INTEGER, {0}, FALSE },
 	{ OPTION_HWCURSOR, "HWCursor", OPTV_BOOLEAN, {0}, FALSE },
+  { OPTION_SHADOWFB, "ShadowFB", OPTV_BOOLEAN, {0}, TRUE },
 	{ -1, NULL, OPTV_NONE, {0}, FALSE }
 };
 
+int NewportScreenIndex = -1;
+int NewportGCIndex = -1;
+static unsigned long NewportGeneration = 0;
+
 /* ------------------------------------------------------------------ */
 
+Bool                                                                                        
+NewportRealizeFont(ScreenPtr pScreen, FontPtr pFont)
+{
+  return (TRUE);
+}
+
+Bool
+NewportUnrealizeFont(ScreenPtr pScreen, FontPtr pFont)
+{
+  return (TRUE);
+}
+
 static Bool
 NewportGetRec(ScrnInfoPtr pScrn)
 {
@@ -446,12 +498,21 @@
 	xf86PrintModes(pScrn);
 	xf86SetDpi (pScrn, 0, 0);
 
+  from=X_DEFAULT;
+  pNewport->shadowFb = TRUE;
+  if (xf86GetOptValBool(pNewport->Options, OPTION_SHADOWFB, &pNewport->shadowFb))
+    from = X_CONFIG;
+  xf86DrvMsg(pScrn->scrnIndex, from, "%s shadow framebuffer\n",
+	     pNewport->shadowFb ? "Using" : "Not using");
+
 	/* Load FB module */
+  if ( pNewport->shadowFb ) {
 	if (!xf86LoadSubModule (pScrn, "fb")) {
 		NewportFreeRec(pScrn);
 		return FALSE;
 	}
 	xf86LoaderReqSymLists( fbSymbols, NULL);
+  }
 
 	/* Load ramdac modules */
     	if (pNewport->hwCursor) {
@@ -463,11 +524,26 @@
     	}
 
 	/* Load ShadowFB module */
+  if ( pNewport->shadowFb ) {
 	if (!xf86LoadSubModule(pScrn, "shadowfb")) {
 		NewportFreeRec(pScrn);
 		return FALSE;
 	}
 	xf86LoaderReqSymLists(shadowSymbols, NULL);
+  }
+
+  /* Set up debugging, if enabled */
+#ifdef DEBUG
+  {
+    char *filt = getenv("NPTRCFILTER");
+    char *lev  = getenv("NPTRCLEVEL");
+  
+    if ( filt ) newportTrcFilter = strtoul( filt, NULL, 16);
+    if ( lev )  newportTrcLevel = strtoul( lev, NULL, 16);
+
+    ErrorF("Newport Tracing: %x, %d\n", newportTrcFilter, newportTrcLevel );
+  }
+#endif
 
 	return TRUE;
 }
@@ -478,11 +554,13 @@
 	ScrnInfoPtr pScrn;
 	NewportPtr pNewport;
 	VisualPtr visual;
-	BOOL ret;
+  DepthPtr	depths;
+  int		nvisuals;
+  int		ndepths;
+  int		rootdepth;
+  VisualID	defaultVisual;
 	int i;
 
-	TRACE_ENTER("NewportScreenInit");
-
 	/* First get a pointer to our private info */
 	pScrn = xf86Screens[pScreen->myNum];
 	pNewport = NEWPORTPTR(pScrn);
@@ -491,34 +569,100 @@
 	if( ! NewportMapRegs(pScrn)) 
 		return FALSE;
 
+  /* ??? Allocate mfb privates */
+  if (!pNewport->shadowFb && !mfbAllocatePrivates(pScreen, (int*) 0, (int*) 0 ))
+    return FALSE;
+
 	/* Reset visual list. */
 	miClearVisualTypes();
 
-	if (!miSetVisualTypes(pScrn->depth, pScrn->depth != 8 ? TrueColorMask :
+  if ( !miSetVisualTypes(pScrn->depth, pScrn->depth != 8 ? TrueColorMask :
 					miGetDefaultVisualMask(pScrn->depth),
-				pScrn->rgbBits, pScrn->defaultVisual))
+			 pScrn->rgbBits, pScrn->defaultVisual) )
 		return FALSE;
 	
 	miSetPixmapDepths ();
 
 	pNewport->Bpp = pScrn->bitsPerPixel >> 3;
-	/* Setup the stuff for the shadow framebuffer */
-	pNewport->ShadowPitch = (( pScrn->virtualX * pNewport->Bpp ) + 3) & ~3L;
-	pNewport->ShadowPtr = xnfalloc(pNewport->ShadowPitch * pScrn->virtualY);
-	
 
 	if (!NewportModeInit(pScrn, pScrn->currentMode))
 			return FALSE;
 
-	ret = fbScreenInit(pScreen, pNewport->ShadowPtr,
+  /* Init Screen */
+  if ( pNewport->shadowFb ) {
+    pNewport->ShadowPitch = (( pScrn->virtualX * pNewport->Bpp ) + 3) & ~3L;
+    pNewport->ShadowPtr = xnfalloc(pNewport->ShadowPitch * pScrn->virtualY);
+    
+    if ( !fbScreenInit(pScreen, pNewport->ShadowPtr,
 			   pScrn->virtualX, pScrn->virtualY,
 			   pScrn->xDpi, pScrn->yDpi,
 			   pScrn->displayWidth,
-			   pScrn->bitsPerPixel);
+		       pScrn->bitsPerPixel) )
+      return FALSE;
+  } else {		
+    /* Init visual structures */
+    rootdepth = 0;
+    if (!miInitVisuals (&visual, &depths, &nvisuals, 
+			&ndepths, &rootdepth,
+			&defaultVisual,
+			((unsigned long)1<<(pScrn->bitsPerPixel-1)), 
+			8, -1))
+      return FALSE;
 
-	if(!ret)
+    if ( !miScreenInit(pScreen, NULL,
+		       pScrn->virtualX, pScrn->virtualY,
+		       pScrn->xDpi, pScrn->yDpi,
+		       pScrn->displayWidth,
+		       pScrn->bitsPerPixel,
+		       ndepths, depths,
+		       defaultVisual, 
+		       nvisuals, visual) )
 		return FALSE;
 
+    pScreen->SaveScreen = NewportSaveScreen;
+    /* Wrap the current CloseScreen function */
+    pNewport->CloseScreen = pScreen->CloseScreen;
+    pScreen->CloseScreen = NewportCloseScreen;
+    pScreen->CreateColormap = miInitializeColormap;
+    pScreen->InstallColormap = miInstallColormap;
+    pScreen->UninstallColormap = miUninstallColormap;
+    pScreen->ListInstalledColormaps = miListInstalledColormaps;
+    pScreen->DestroyColormap = (void (*)(ColormapPtr))NoopDDA;
+    pScreen->ResolveColor = miResolveColor;
+    pScreen->BitmapToRegion = mfbPixmapToRegion;
+    if ( pScrn->bitsPerPixel > 8 ) {
+      pScreen->CreatePixmap = cfb32CreatePixmap;
+      pScreen->DestroyPixmap = cfb32DestroyPixmap;
+    } else {
+      pScreen->CreatePixmap = cfbCreatePixmap;
+      pScreen->DestroyPixmap = cfbDestroyPixmap;
+    }
+    pScreen->QueryBestSize = NewportQueryBestSize;
+    pScreen->RealizeFont = NewportRealizeFont;
+    pScreen->UnrealizeFont = NewportUnrealizeFont;
+
+    pScreen->PaintWindowBackground = miPaintWindow;
+    pScreen->PaintWindowBorder = miPaintWindow;
+    pScreen->CreateWindow = NewportCreateWindow;
+    pScreen->DestroyWindow = NewportDestroyWindow;
+    pScreen->PositionWindow = NewportPositionWindow;
+    pScreen->ChangeWindowAttributes = NewportChangeWindowAttributes;
+    pScreen->RealizeWindow = NewportMapWindow;
+    pScreen->UnrealizeWindow = NewportUnmapWindow;
+    pScreen->CopyWindow = NewportCopyWindow;
+    pScreen->CreateGC = NewportCreateGC;
+    /*    pScreen->BackingStoreFuncs.RestoreAreas = NewportRestoreAreas;
+	  pScreen->BackingStoreFuncs.SaveAreas = NewportSaveAreas;
+    */    pScreen->ModifyPixmapHeader = miModifyPixmapHeader;
+    
+    pScreen->GetSpans = NewportGetSpans;
+    pScreen->GetImage = miGetImage;
+
+    pScrn->EnterVT = NewportEnterVT;
+    pScrn->LeaveVT = NewportLeaveVT;
+    pScrn->EnableDisableFBAccess = NewportEnableDisableFBAccess;
+  }
+
 	/* we need rgb ordering if bitsPerPixel > 8 */
 	if (pScrn->bitsPerPixel > 8) {
 		for (i = 0, visual = pScreen->visuals;
@@ -534,8 +678,40 @@
 		}
 	}
 
+  if (! pNewport->shadowFb ) {
+    pNewport->pScrn = pScrn;
+    pNewport->vtSema = TRUE;
+  }
+
+#ifdef XvExtension
+  {
+    XF86VideoAdaptorPtr *ptr;
+    int n;
+
+    n = xf86XVListGenericAdaptors(pScrn,&ptr);
+    if (n) {
+      xf86XVScreenInit(pScreen, ptr, n);
+    }
+  }
+#endif
+
+
+  pScreen->SaveScreen = NewportSaveScreen;
+  /* Wrap the current CloseScreen function */
+  pNewport->CloseScreen = pScreen->CloseScreen;
+  pScreen->CloseScreen = NewportCloseScreen;
+
 	/* must be after RGB ordering fixed */
-	fbPictureInit (pScreen, 0, 0);
+#ifdef RENDER
+  if (miPictureInit (pScreen, 0, 0)==TRUE) {
+    PictureScreenPtr ps = GetPictureScreen(pScreen);
+    /*
+      This is probably not the correct routine to call ... */
+    ps->Composite = NewportDummyComposite;
+    ps->Glyphs = miGlyphs;
+    ps->CompositeRects = miCompositeRects;
+  }
+#endif
 
 	miInitializeBackingStore(pScreen);
 	xf86SetBackingStore(pScreen);
@@ -563,34 +739,25 @@
 				CMAP_RELOAD_ON_MODE_SWITCH ))
 		return FALSE;
 
-	/* Initialise shadow frame buffer */
+  if ( !pNewport->shadowFb ) {
+    if (NewportGeneration != serverGeneration) {
+      if(((NewportScreenIndex = AllocateScreenPrivateIndex ()) < 0) ||
+	 ((NewportGCIndex = AllocateGCPrivateIndex()) < 0))
+	return FALSE;
+      NewportGeneration = serverGeneration;
+    }
+
+    if(!AllocateGCPrivate(pScreen, NewportGCIndex, sizeof(NewportGCRec)))
+      return FALSE;
+  } else {
 	ShadowFBInit(pScreen, (pNewport->Bpp == 1) ? &NewportRefreshArea8 :
 				&NewportRefreshArea24);
-
-#ifdef XvExtension
-	{
-		XF86VideoAdaptorPtr *ptr;
-		int n;
-
-		n = xf86XVListGenericAdaptors(pScrn,&ptr);
-		if (n) {
-			xf86XVScreenInit(pScreen, ptr, n);
 	        }
-        }
-#endif
-
-
-	pScreen->SaveScreen = NewportSaveScreen;
-	/* Wrap the current CloseScreen function */
-	pNewport->CloseScreen = pScreen->CloseScreen;
-	pScreen->CloseScreen = NewportCloseScreen;
 
 	if (serverGeneration == 1) {
 		xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
 	}
 	
-	TRACE_EXIT("NewportScreenInit");
-
 	return TRUE;
 }
 
@@ -626,6 +793,20 @@
 	pScrn->vtSema = FALSE;
  
 	pScreen->CloseScreen = pNewport->CloseScreen;
+
+
+  pScreen->CloseScreen = pNewport->CloseScreen;
+  pScreen->PaintWindowBackground = pNewport->PaintWindowBackground;
+  pScreen->PaintWindowBorder = pNewport->PaintWindowBorder;
+  pScreen->CopyWindow = pNewport->CopyWindow;
+  pScreen->CreateGC = pNewport->CreateGC;
+  pScreen->BackingStoreFuncs.RestoreAreas = pNewport->RestoreAreas;
+  pScreen->ModifyPixmapHeader = pNewport->ModifyPixmapHeader;
+
+  pScrn->EnterVT = pNewport->EnterVT;
+  pScrn->LeaveVT = pNewport->LeaveVT;
+  pScrn->EnableDisableFBAccess = pNewport->EnableDisableFBAccess;
+
 	return (*pScreen->CloseScreen)(scrnIndex, pScreen);
 }
 
@@ -659,6 +840,12 @@
 }
 
 
+static void
+NewportEnableDisableFBAccess(int index, Bool enable)
+{
+  /* nothing happens here; nothing touches the real frame buffer */
+}
+
 static const OptionInfoRec *
 NewportAvailableOptions(int chipid, int busid)
 {
@@ -676,12 +863,13 @@
 
 	width = mode->HDisplay;
 	height = mode->VDisplay;
-/*	if (width != 1280 || height != 1024) {
+  /*
+    if (width != 1280 || height != 1024) {
 		xf86DrvMsg(pScrn->scrnIndex, X_ERROR, \
 		"Width = %d and height = %d is not supported by by this driver\n", width, height);
 		return FALSE;
 	}
-*/
+  */
 	pScrn->vtSema = TRUE;
 	/* first backup the necessary registers... */
 	NewportBackupRex3(pScrn);
diff -NaurbB newport.shadow/newport_fillrect.c newport.new/newport_fillrect.c
--- newport.shadow/newport_fillrect.c	Thu Jan  1 01:00:00 1970
+++ newport.new/newport_fillrect.c	Wed Nov  5 05:13:45 2003
@@ -0,0 +1,425 @@
+/*
+ * Driver for the SGI Indy's Newport graphics card - Rectangle Filling
+ * 
+ * (c) 2003      Frank Foerstemann <Foerstemann@web.de>
+ *
+ * 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 fur-
+ * nished 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, FIT-
+ * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+ * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall not
+ * be used in advertising or otherwise to promote the sale, use or other deal-
+ * ings in this Software without prior written authorization from the XFree86
+ * Project.
+ *
+ */
+
+#include "X.h"
+#include "Xproto.h"
+#include "misc.h"
+#include "pixmapstr.h"
+#include "input.h"
+#include "font.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "dixfontstr.h"
+#include "fontstruct.h"
+#include "xf86.h"
+#include "xf86str.h"
+
+#include <newport.h>
+
+#include <newport_util.h>
+
+void NewportFillRectSolid(DrawablePtr pDraw,
+			  GC * pGC,
+			  int nInit,
+			  xRectangle *pRectInit)
+{
+  ScreenPtr pScreen;
+  ScrnInfoPtr pScrn;
+  NewportPtr pPriv;
+  NewportRegsPtr pNewportRegs;
+  BoxPtr pbox, pboxLast;
+  RegionPtr prgnDst;
+  xRectangle *pRect;
+  CARD32 dest;
+  int w, h, i;
+
+  TRACE_ENTER( NPTRC_FILLRECT, "NewportFillRectSolid");
+
+  pScreen = pGC->pScreen;
+  pScrn = xf86Screens[pScreen->myNum];
+  pPriv = NEWPORTPTR (pScrn);
+  pNewportRegs = pPriv->pNewportRegs;
+
+  prgnDst = pGC->pCompositeClip;
+  pbox = REGION_RECTS(prgnDst);
+  pboxLast = pbox + REGION_NUM_RECTS(prgnDst) -1;
+    
+  NewportWait (pNewportRegs);
+
+  pNewportRegs->set.drawmode0 = (NPORT_DMODE0_DRAW |
+				 NPORT_DMODE0_BLOCK |
+				 NPORT_DMODE0_CHOST |
+				 NPORT_DMODE0_AHOST |
+				 NPORT_DMODE0_STOPX |
+				 NPORT_DMODE0_STOPY |
+				 NPORT_DMODE0_DOSETUP );
+
+  pNewportRegs->set.drawmode1 &= ~(NPORT_DMODE1_LOMASK);
+  pNewportRegs->set.drawmode1 |= (pGC->alu << 28);
+
+  pNewportRegs->set.wrmask = pGC->planemask | 0xfff;
+    
+  pNewportRegs->set.colorback =
+    (pGC->bgPixel & 0xff00ff00) |
+    ((pGC->bgPixel & 0xff) << 16) | 
+    ((pGC->bgPixel & 0xff0000) >> 16);    
+  dest = 
+    (pGC->fgPixel & 0xff00ff00) |
+    ((pGC->fgPixel & 0xff) << 16) | 
+    ((pGC->fgPixel & 0xff0000) >> 16);
+
+  pNewportRegs->set.hostrw0 = dest;
+  pNewportRegs->set.hostrw1 = dest;
+
+  while ( pbox <= pboxLast ) {
+    pbox = NewportSMaskSet( pNewportRegs, pbox, pboxLast );
+    pRect = pRectInit;
+    i = nInit;
+    while (i--)
+      {
+	w = pRect->width;
+	if (w) w--;
+	h = pRect->height;
+	if (h) h--;
+	    
+	TRACE( NPTRC_FILLRECT, ("rect %d = (x:%d,y:%d),(w:%d,h:%d)", 
+				nInit-i, 
+				pDraw->x +pRect->x, pDraw->y +pRect->y, 
+				w, h)); 
+	NewportWait (pNewportRegs);
+	pNewportRegs->set._setup = 1;
+	pNewportRegs->set.xystarti = ((pRect->x +pDraw->x) << 16) 
+	  | (pRect->y +pDraw->y);
+	pNewportRegs->go.xyendi = ((pRect->x +pDraw->x +w) << 16) 
+	  | (pRect->y +pDraw->y +h);
+	pRect++;
+      }
+  }
+    
+  TRACE_EXIT( NPTRC_FILLRECT, "NewportFillRectSolid");
+}
+
+void NewportFillRectStippled(DrawablePtr pDraw,
+			     GC * pGC,
+			     int nInit,
+			     xRectangle *pRectInit)
+{
+  ScreenPtr pScreen;
+  ScrnInfoPtr pScrn;
+  NewportPtr pPriv;
+  NewportRegsPtr pNewportRegs;
+  BoxPtr pbox, pboxLast;
+  RegionPtr prgnDst;
+  xRectangle *pRect;
+  CARD32 dest;
+  int x, y, yEnd, xEnd, i;
+
+  TRACE_ENTER( NPTRC_FILLRECT, "NewportFillRectStippled");
+
+  pScreen = pGC->pScreen;
+  pScrn = xf86Screens[pScreen->myNum];
+  pPriv = NEWPORTPTR (pScrn);
+  pNewportRegs = pPriv->pNewportRegs;
+
+  prgnDst = pGC->pCompositeClip;
+  pbox = REGION_RECTS(prgnDst);
+  pboxLast = pbox + REGION_NUM_RECTS(prgnDst) -1;
+
+  NewportWait (pNewportRegs);
+
+  pNewportRegs->set.drawmode0 = (NPORT_DMODE0_DRAW |
+				 NPORT_DMODE0_SPAN |
+				 NPORT_DMODE0_CHOST |
+				 NPORT_DMODE0_AHOST |
+				 NPORT_DMODE0_STOPX |
+				 NPORT_DMODE0_DOSETUP |
+				 NPORT_DMODE0_ZPENAB );
+
+  if (pGC->fillStyle == FillOpaqueStippled)
+    pNewportRegs->set.drawmode0 |= NPORT_DMODE0_ZOPQ;
+    
+  pNewportRegs->set.drawmode1 =
+    (pNewportRegs->set.drawmode1 & 0x0fffffff) | (pGC->alu << 28);
+  pNewportRegs->set.wrmask = pGC->planemask | 0xfff;
+    
+    
+  pNewportRegs->set.colorback =
+    (pGC->bgPixel & 0xff00ff00) |
+    ((pGC->bgPixel & 0xff) << 16) | 
+    ((pGC->bgPixel & 0xff0000) >> 16);    
+  dest = 
+    (pGC->fgPixel & 0xff00ff00) |
+    ((pGC->fgPixel & 0xff) << 16) | 
+    ((pGC->fgPixel & 0xff0000) >> 16);
+
+  while ( pbox <= pboxLast ) {
+    pbox = NewportSMaskSet( pNewportRegs, pbox, pboxLast );
+    pRect = pRectInit;
+    i = nInit;
+    while (i--)
+      {
+	yEnd = pRect->y +pRect->height;
+	if ( pRect->height ) yEnd--;
+	xEnd = pRect->x +pRect->width;
+	if ( pRect->width ) xEnd--;
+	    
+	for( y=pRect->y; y<=yEnd; y++ ) {
+	  if ( pGC->stipple->drawable.width <= 32 ) {
+	    pNewportRegs->set.zpattern = 
+	      NewportStippleGet((unsigned int*) pGC->stipple->devPrivate.ptr,
+				pGC->stipple->drawable.width,
+				pGC->stipple->drawable.height,
+				pGC->patOrg.x, 
+				pGC->patOrg.y, 
+				pRect->x, 
+				y,
+				0);
+		    
+	    NewportWait (pNewportRegs);
+	    pNewportRegs->set._setup = 1;
+	    pNewportRegs->set.xystarti = ((pRect->x +pDraw->x) << 16) 
+	      | (pDraw->y +y);
+	    pNewportRegs->go.xyendi = ((pDraw->x +xEnd) << 16) 
+	      | (pDraw->y +y);
+	  } else {
+	    for( x=pRect->x; x <= xEnd; x+=32 ) {
+	      NewportStippleGet((unsigned int *) pGC->stipple->devPrivate.ptr,
+				pGC->stipple->drawable.width,
+				pGC->stipple->drawable.height,
+				pGC->patOrg.x, 
+				pGC->patOrg.y, 
+				x, 
+				y,
+				0);
+		    
+	      NewportWait (pNewportRegs);
+	      pNewportRegs->set._setup = 1;
+	      pNewportRegs->set.xystarti = ((x +pDraw->x) << 16) 
+		| (pDraw->y +y);
+	      pNewportRegs->go.xyendi = ((x +pDraw->x +31) << 16) 
+		| (pDraw->y +y);
+	    }
+	  }
+	}
+	pRect++;
+      }
+  }
+
+  TRACE_EXIT( NPTRC_FILLRECT, "NewportFillRectStippled");
+}
+
+void NewportFillRectTiled(DrawablePtr pDraw,
+			  GC * pGC,
+			  int nInit,
+			  xRectangle *pRectInit)
+{
+  ScreenPtr pScreen;
+  ScrnInfoPtr pScrn;
+  NewportPtr pPriv;
+  NewportRegsPtr pNewportRegs;
+  BoxPtr pbox, pboxLast, pboxStart;
+  RegionPtr prgnDst;
+  xRectangle *pRect;
+  int pxWidth = pGC->tile.pixmap->drawable.width;
+  int pxHeight = pGC->tile.pixmap->drawable.height;
+  int y, w, h, i, j, pxw, pxwInit, x1, y1, x2, y2, xd, yd;
+  CARD32 *pxBase = (CARD32 *) pGC->tile.pixmap->devPrivate.ptr;
+  CARD32 *pxLineBase, *pxSrc, dest;
+
+  TRACE_ENTER( NPTRC_FILLRECT, "NewportFillRectTiled");
+
+  pScreen = pGC->pScreen;
+  pScrn = xf86Screens[pScreen->myNum];
+  pPriv = NEWPORTPTR (pScrn);
+  pNewportRegs = pPriv->pNewportRegs;
+
+  prgnDst = pGC->pCompositeClip;
+  pboxStart = REGION_RECTS(prgnDst);
+  pboxLast = pboxStart + REGION_NUM_RECTS(prgnDst) -1;
+
+  NewportWait (pNewportRegs);
+	  
+  pNewportRegs->set.drawmode0 = (NPORT_DMODE0_DRAW |
+				 NPORT_DMODE0_BLOCK |
+				 NPORT_DMODE0_CHOST |
+				 NPORT_DMODE0_AHOST );
+  pNewportRegs->set.drawmode1 =
+    (pNewportRegs->set.drawmode1 & 0x0fffffff) | (pGC->alu << 28);
+  pNewportRegs->set.wrmask = pGC->planemask | 0xfff;
+  pNewportRegs->set.colorback = 
+    (pGC->bgPixel & 0xff00ff00) |
+    ((pGC->bgPixel & 0xff) << 16) | 
+    ((pGC->bgPixel & 0xff0000) >> 16);
+  pNewportRegs->cset.clipmode &= NPORT_CMODE_CMSK;
+    
+  TRACE( NPTRC_FILLRECT, ("num_pbox=%d", REGION_NUM_RECTS(prgnDst)));
+  TRACE( NPTRC_FILLRECT, ("pat.x=%d, pat.y=%d", 
+			  pGC->patOrg.x, pGC->patOrg.y));
+  TRACE( NPTRC_FILLRECT, ("px.width=%d, px.height=%d", 
+			  pGC->tile.pixmap->drawable.width, pGC->tile.pixmap->drawable.height));
+
+  if ( ! REGION_NUM_RECTS(prgnDst) ) {
+    TRACE_EXIT( NPTRC_FILLRECT, "NewportFillRectTiled");
+    return; 
+  }
+
+  pRect = pRectInit;
+  i = nInit;
+  while (i--)
+    {
+      w = pRect->width;
+      if (w) --w;
+      h = pRect->height;
+      if (h) --h;
+      x1 = pDraw->x +pRect->x;
+      x2 = x1 +w;
+      y1 = pDraw->y +pRect->y;
+      y2 = y1 +h;
+      
+      yd=pRect->y -pGC->patOrg.y;
+      xd=(pRect->x -pGC->patOrg.x) % pxWidth;
+      pxwInit = pxWidth -(xd % pxWidth);
+
+      TRACE( NPTRC_FILLRECT, ("rect1 %d = (%d, %d), (%d, %d) +(%d,%d)", 
+			      nInit-i, 
+			      x1, y1, 
+			      x2, y2, 
+			      h, w )); 
+      for(pbox=pboxStart; pbox<=pboxLast; ++pbox) {
+	TRACE(NPTRC_FILLRECT, ("pbox: x1=%d, x2=%d, y1=%d, y2=%d", 
+			       pbox->x1, pbox->x2, pbox->y1, pbox->y2));
+	if( (y1 < pbox->y2 || y2 >= pbox->y1) && 
+	    (x1 < pbox->x2 || x2 >= pbox->x1) ) {
+
+	  if ( x1 < pbox->x1 ) {
+	    w -= pbox->x1 -x1;
+	    x1=pbox->x1;
+	  }
+	  if ( x2 > pbox->x2 ) {
+	    w -= x2 -pbox->x2;
+	    x2=pbox->x2;
+	  }
+	  if ( y1 < pbox->y1 ) {
+	    h -= pbox->y1 -y1;
+	    y1=pbox->y1;
+	  }
+	  if ( y2 > pbox->y2 ) {
+	    h -= y2 -pbox->y2;
+	    y2=pbox->y2;
+	  }
+
+	  TRACE( NPTRC_FILLRECT, ("rect2 %d = (%d, %d), (%d, %d) +(%d,%d)", 
+				  nInit-i, 
+				  x1, y1, 
+				  x2, y2, 
+				  h, w )); 
+
+	  NewportWait (pNewportRegs);
+	  pNewportRegs->set.xystarti = ((x1) << 16) 
+	    | (y1);
+	  pNewportRegs->set.xyendi = ((x2) << 16) 
+	    | (y2);
+	  pNewportRegs->set._setup = 1;
+	  NewportWait (pNewportRegs);
+		
+	  for ( y=0; y <= h; ++y ) {
+	    pxLineBase = pxBase +((yd +y) % pxHeight)*pxWidth;
+	    pxw = pxwInit;
+	    pxSrc = pxLineBase +xd;
+	    for (j = w; j >= 0; --j)
+	      {
+		dest =
+		  (*pxSrc & 0xff00ff00) |
+		  ((*pxSrc & 0xff) << 16) | 
+		  (( *pxSrc & 0xff0000) >> 16);
+		
+		pNewportRegs->go.hostrw0 = dest;
+		--pxw;
+		++pxSrc;
+		if ( ! pxw ) {
+		  pxw = pxWidth;
+		  pxSrc = pxLineBase;
+		}
+	      }
+	    
+	  }
+	  w = pRect->width;
+	  if (w) --w;
+	  h = pRect->height;
+	  if (h) --h;
+	  x1 = pDraw->x +pRect->x;
+	  x2 = x1 +w;
+	  y1 = pDraw->y +pRect->y;
+	  y2 = y1 +h;
+	}
+      }
+      ++pRect;
+    }
+  
+  TRACE_EXIT( NPTRC_FILLRECT, "NewportFillRectTiled");
+}
+
+void
+NewportFillRect (DrawablePtr pDraw,
+		 GC * pGC,
+		 int nInit,
+		 xRectangle *pRect)
+{
+  if (((WindowPtr) pDraw)->visibility != VisibilityFullyObscured && nInit)
+    {
+      switch (pGC->fillStyle) {
+      case FillTiled:
+	NewportFillRectTiled(pDraw, pGC, nInit, pRect);
+	break;
+      case FillStippled:
+      case FillOpaqueStippled:
+	NewportFillRectStippled(pDraw, pGC, nInit, pRect);
+	break;
+      default:
+	NewportFillRectSolid(pDraw, pGC, nInit, pRect);
+      }
+    }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -NaurbB newport.shadow/newport_fillspans.c newport.new/newport_fillspans.c
--- newport.shadow/newport_fillspans.c	Thu Jan  1 01:00:00 1970
+++ newport.new/newport_fillspans.c	Wed Nov  5 05:15:39 2003
@@ -0,0 +1,380 @@
+/*
+ * Driver for the SGI Indy's Newport graphics card - Span Filling
+ * 
+ * (c) 2003      Frank Foerstemann <Foerstemann@web.de>
+ *
+ * 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 fur-
+ * nished 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, FIT-
+ * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+ * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall not
+ * be used in advertising or otherwise to promote the sale, use or other deal-
+ * ings in this Software without prior written authorization from the XFree86
+ * Project.
+ *
+ */
+
+#include "X.h"
+#include "Xproto.h"
+#include "misc.h"
+#include "pixmapstr.h"
+#include "input.h"
+#include "font.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "dixfontstr.h"
+#include "fontstruct.h"
+#include "xf86.h"
+#include "xf86str.h"
+
+#include <newport.h>
+
+#include <newport_util.h>
+
+void NewportFillSpansSolid(DrawablePtr pDraw,
+			   GC * pGC,
+			   int nInit,
+			   DDXPointPtr pptInit, int *pwidthInit, int fSorted)
+{
+  ScreenPtr pScreen;
+  ScrnInfoPtr pScrn;
+  NewportPtr pPriv;
+  NewportRegsPtr pNewportRegs;
+  BoxPtr pbox, pboxLast;
+  RegionPtr prgnDst;
+  DDXPointPtr ppt;
+  int *pwidth;
+  int x1, y, x2, yMax, i;
+  CARD32 dest;
+
+  TRACE_ENTER( NPTRC_FILLSPAN, "NewportFillSpansSolid");
+  pScreen = pGC->pScreen;
+  pScrn = xf86Screens[pScreen->myNum];
+  pPriv = NEWPORTPTR (pScrn); 
+  pNewportRegs = pPriv->pNewportRegs;
+
+  yMax = (int) pDraw->y + (int) pDraw->height;
+  prgnDst = pGC->pCompositeClip;
+  pbox = REGION_RECTS(prgnDst);
+  pboxLast = pbox + REGION_NUM_RECTS(prgnDst) -1;
+
+  NewportWait (pNewportRegs);
+
+  pNewportRegs->set.drawmode0 = (NPORT_DMODE0_DRAW |
+				 NPORT_DMODE0_SPAN |
+				 NPORT_DMODE0_CHOST |
+				 NPORT_DMODE0_AHOST |
+				 NPORT_DMODE0_STOPX |
+				 NPORT_DMODE0_DOSETUP );
+
+  pNewportRegs->set.drawmode1 =
+    (pNewportRegs->set.drawmode1 & 0x0fffffff) | (pGC->alu << 28);
+  pNewportRegs->set.wrmask = pGC->planemask | 0xfff;
+    
+    
+  pNewportRegs->set.colorback =
+    (pGC->bgPixel & 0xff00ff00) |
+    ((pGC->bgPixel & 0xff) << 16) | 
+    ((pGC->bgPixel & 0xff0000) >> 16);    
+  dest = 
+    (pGC->fgPixel & 0xff00ff00) |
+    ((pGC->fgPixel & 0xff) << 16) | 
+    ((pGC->fgPixel & 0xff0000) >> 16);
+
+  pNewportRegs->set.hostrw0 = dest;
+  pNewportRegs->set.hostrw1 = dest;
+
+  while ( pbox <= pboxLast ) {
+    pbox = NewportSMaskSet( pNewportRegs, pbox, pboxLast );
+
+    ppt = pptInit;
+    pwidth = pwidthInit;
+    i = nInit;
+    while (i--)
+      {
+	y = ppt->y;
+	if( y >= 0 && y < yMax ) {
+	  x1 = ppt->x;
+	  x2 = ppt->x + *pwidth;
+	  TRACE( NPTRC_FILLSPAN, ("fill: x1:%d x2:%d y:%d", x1, x2, y));
+		
+	  NewportWait (pNewportRegs);
+	  pNewportRegs->set._setup = 1;
+	  pNewportRegs->set.xystarti = (x1 << 16) | y;
+	  pNewportRegs->go.xyendi = ((x2-1) << 16) | y;
+	}
+	pwidth++;
+	ppt++;
+      }
+  }
+    
+  TRACE_EXIT( NPTRC_FILLSPAN, "NewportFillSpansSolid");
+}
+
+
+void NewportFillSpansStippled(DrawablePtr pDraw,
+			      GC * pGC,
+			      int nInit,
+			      DDXPointPtr pptInit, int *pwidthInit, int fSorted)
+{
+  ScreenPtr pScreen;
+  ScrnInfoPtr pScrn;
+  NewportPtr pPriv;
+  NewportRegsPtr pNewportRegs;
+  BoxPtr pbox, pboxLast;
+  RegionPtr prgnDst;
+  DDXPointPtr ppt = pptInit;
+  int *pwidth = pwidthInit;
+  int x, y, xEnd, yMax, i;
+  CARD32 dest;
+
+  TRACE_ENTER( NPTRC_FILLSPAN, "NewportFillSpansStippled");
+
+  pScreen = pGC->pScreen;
+  pScrn = xf86Screens[pScreen->myNum];
+  pPriv = NEWPORTPTR (pScrn);
+  pNewportRegs = pPriv->pNewportRegs;
+
+  yMax = (int) pDraw->y + (int) pDraw->height;
+  prgnDst = pGC->pCompositeClip;
+  pbox = REGION_RECTS(prgnDst);
+  pboxLast = pbox + REGION_NUM_RECTS(prgnDst) -1;
+    
+  NewportWait (pNewportRegs);
+
+  pNewportRegs->set.drawmode0 = (NPORT_DMODE0_DRAW |
+				 NPORT_DMODE0_SPAN |
+				 NPORT_DMODE0_CHOST |
+				 NPORT_DMODE0_AHOST |
+				 NPORT_DMODE0_STOPX |
+				 NPORT_DMODE0_DOSETUP |
+				 NPORT_DMODE0_ZPENAB );
+
+  if (pGC->fillStyle == FillOpaqueStippled)
+    pNewportRegs->set.drawmode0 |= NPORT_DMODE0_ZOPQ;
+    
+  pNewportRegs->set.drawmode1 =
+    (pNewportRegs->set.drawmode1 & 0x0fffffff) | (pGC->alu << 28);
+  pNewportRegs->set.wrmask = pGC->planemask | 0xfff;
+
+    
+  if ( pPriv->Bpp == 3 ) {
+    pNewportRegs->set.colorback =
+      (pGC->bgPixel & 0xff00ff00) |
+      ((pGC->bgPixel & 0xff) << 16) | 
+      ((pGC->bgPixel & 0xff0000) >> 16);    
+    dest = 
+      (pGC->fgPixel & 0xff00ff00) |
+      ((pGC->fgPixel & 0xff) << 16) | 
+      ((pGC->fgPixel & 0xff0000) >> 16);
+  } else {
+    pNewportRegs->set.colorback = pGC->bgPixel & 0xff00ff00;
+    dest = pGC->fgPixel & 0xff00ff00;
+  }
+
+  pNewportRegs->set.hostrw0 = dest;
+  pNewportRegs->set.hostrw1 = dest;
+
+  while ( pbox <= pboxLast ) {
+    pbox = NewportSMaskSet( pNewportRegs, pbox, pboxLast );
+    ppt = pptInit;
+    pwidth = pwidthInit;
+    i = nInit;
+    while (i--)
+      {
+	y = pDraw->y +ppt->y;
+	if( y >= 0 && y < yMax ) {
+	  xEnd = ppt->x + *pwidth;
+	  if ( pGC->stipple->drawable.width <= 32 ) {
+	    pNewportRegs->set.zpattern =
+	      NewportStippleGet((unsigned int*) pGC->stipple->devPrivate.ptr,
+				pGC->stipple->drawable.width,
+				pGC->stipple->drawable.height,
+				pGC->patOrg.x, 
+				pGC->patOrg.y, 
+				ppt->x, 
+				y,
+				0);
+		    
+	    NewportWait (pNewportRegs);
+	    pNewportRegs->set._setup = 1;
+	    pNewportRegs->set.xystarti = ((ppt->x +pDraw->x) << 16) 
+	      | y;
+	    pNewportRegs->go.xyendi = ((xEnd +pDraw->x) << 16) 
+	      | y;
+	  } else {
+	    for( x=ppt->x; x <= xEnd; x+=32 ) {
+	      pNewportRegs->set.zpattern = 
+		NewportStippleGet((unsigned int*) pGC->stipple->devPrivate.ptr,
+				  pGC->stipple->drawable.width,
+				  pGC->stipple->drawable.height,
+				  pGC->patOrg.x, 
+				  pGC->patOrg.y, 
+				  x, 
+				  y,
+				  0);
+			
+	      NewportWait (pNewportRegs);
+	      pNewportRegs->set._setup = 1;
+	      pNewportRegs->set.xystarti = ((x +pDraw->x) << 16) 
+		| y;
+	      pNewportRegs->go.xyendi = ((x +pDraw->x +31) << 16) 
+		| y;
+	    }
+	  }
+	} 
+	pwidth++;
+	ppt++;
+      }
+  }
+
+  TRACE_EXIT( NPTRC_FILLSPAN, "NewportFillSpansStippled");
+}
+
+void NewportFillSpansTiled(DrawablePtr pDraw,
+			   GC * pGC,
+			   int nInit,
+			   DDXPointPtr pptInit, int *pwidthInit, int fSorted)
+{
+  ScreenPtr pScreen;
+  ScrnInfoPtr pScrn;
+  NewportPtr pPriv;
+  NewportRegsPtr pNewportRegs;
+  BoxPtr pbox, pboxLast, pboxStart;
+  RegionPtr prgnDst;
+  DDXPointPtr ppt = pptInit;
+  int *pwidth = pwidthInit;
+  int pxWidth = pGC->tile.pixmap->drawable.width;
+  int pxHeight = pGC->tile.pixmap->drawable.height;
+  int x1, y, x2, yMax, i, j, pxw;
+  CARD32 *pxBase = (CARD32 *) pGC->tile.pixmap->devPrivate.ptr;
+  CARD32 *pxLineBase, *pxSrc, dest;
+
+  TRACE_ENTER( NPTRC_FILLSPAN, "NewportFillSpansTiled");
+
+  pScreen = pGC->pScreen;
+  pScrn = xf86Screens[pScreen->myNum];
+  pPriv = NEWPORTPTR (pScrn);
+  pNewportRegs = pPriv->pNewportRegs;
+
+  yMax = (int) pDraw->y + (int) pDraw->height;
+  prgnDst = pGC->pCompositeClip;
+  pboxStart = REGION_RECTS(prgnDst);
+  pboxLast = pboxStart + REGION_NUM_RECTS(prgnDst) -1;
+
+  NewportWait (pNewportRegs);
+	  
+  pNewportRegs->set.drawmode0 = (NPORT_DMODE0_DRAW |
+				 NPORT_DMODE0_SPAN |
+				 NPORT_DMODE0_CHOST |
+				 NPORT_DMODE0_AHOST );
+  pNewportRegs->set.drawmode1 =
+    (pNewportRegs->set.drawmode1 & 0x0fffffff) | (pGC->alu << 28);
+  pNewportRegs->set.wrmask = pGC->planemask | 0xfff;
+  pNewportRegs->set.colorback = 
+    (pGC->bgPixel & 0xff00ff00) |
+    ((pGC->bgPixel & 0xff) << 16) | 
+    (pGC->bgPixel & 0xff00) | 
+    ((pGC->bgPixel & 0xff0000) >> 16);
+  pNewportRegs->cset.clipmode &= NPORT_CMODE_CMSK;
+ 
+  TRACE( NPTRC_FILLSPAN, ("depth = %d", pGC->tile.pixmap->drawable.depth));
+  TRACE( NPTRC_FILLSPAN, ("patx  = %d", pGC->patOrg.x));
+  TRACE( NPTRC_FILLSPAN, ("paty  = %d", pGC->patOrg.y));
+  TRACE( NPTRC_FILLSPAN, ("width = %d", pGC->tile.pixmap->drawable.width));
+  TRACE( NPTRC_FILLSPAN, ("height= %d", pGC->tile.pixmap->drawable.height));
+
+  ppt = pptInit;
+  pwidth = pwidthInit;
+  i = nInit;
+  while (i--)
+    {
+      y = ppt->y;
+      x1 = ppt->x;
+      x2 = ppt->x + *pwidth;
+      pxLineBase = pxBase +((y-pGC->patOrg.y) % pxHeight)*pxWidth;
+      TRACE(NPTRC_SETSPANS, ("orig: x1=%d, x2=%d, y=%d", x1, x2, y));
+      
+      for(pbox=pboxStart; pbox<=pboxLast; ++pbox) {
+	TRACE(NPTRC_SETSPANS, ("pbox: x1=%d, x2=%d, y1=%d, y2=%d", 
+			       pbox->x1, pbox->x2, pbox->y1, pbox->y2));
+	if( pbox->y1<= y && y < pbox->y2 && 
+	    (x1 < pbox->x2 || x2 >= pbox->x1) ) {
+	  if ( x1 < pbox->x1 ) {
+	    x1=pbox->x1;
+	  }
+	  if ( x2 > pbox->x2 ) x2=pbox->x2;
+	      
+	  TRACE(NPTRC_SETSPANS, ("mod: x1=%d, x2=%d", x1, x2));    
+
+	  NewportWait (pNewportRegs);
+	  pNewportRegs->set.xystarti = (x1 << 16) | y;
+	  pNewportRegs->set.xyendi = ((x2-1) << 16) | y;
+	  pNewportRegs->set._setup = 1;
+		
+	  pxw = pxWidth -(x1 -pGC->patOrg.x) % pxWidth;
+	  pxSrc = pxLineBase +(x1 -pGC->patOrg.x) % pxWidth;
+		
+	  for (j = x2 -x1; j > 0; j--)
+	    {
+	      dest =
+		(*pxSrc & 0xff00ff00) |
+		((*pxSrc & 0xff) << 16) | 
+		(( *pxSrc & 0xff0000) >> 16);
+	      pNewportRegs->go.hostrw0 = dest;
+	      pxw--;
+	      pxSrc++;
+	      if ( pxw == 0 ) {
+		pxw = pxWidth;
+		pxSrc = pxLineBase;
+	      }
+	    }
+	}
+      }       
+      pwidth++;
+      ppt++;
+    }
+  TRACE_EXIT( NPTRC_FILLSPAN, "NewportFillSpansTiled");
+}
+
+
+void
+NewportFillSpans (DrawablePtr pDraw,
+		  GC * pGC,
+		  int nInit,
+		  DDXPointPtr pptInit, int *pwidthInit, int fSorted)
+{
+  if (((WindowPtr) pDraw)->visibility != VisibilityFullyObscured && nInit)
+    {
+      switch (pGC->fillStyle) {
+      case FillTiled:
+	NewportFillSpansTiled(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
+	break;
+      case FillStippled:
+      case FillOpaqueStippled:
+	NewportFillSpansStippled(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
+	break;
+      default:
+	NewportFillSpansSolid(pDraw, pGC, nInit, pptInit, pwidthInit, fSorted);
+      }
+    }
+}
+
+
+
+
diff -NaurbB newport.shadow/newport_gc.c newport.new/newport_gc.c
--- newport.shadow/newport_gc.c	Thu Jan  1 01:00:00 1970
+++ newport.new/newport_gc.c	Wed Nov  5 05:32:47 2003
@@ -0,0 +1,993 @@
+/*
+ * Driver for the SGI Indy's Newport graphics card - GC Operations
+ * 
+ * (c) 2003      Frank Foerstemann <Foerstemann@web.de>
+ *
+ * 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 fur-
+ * nished 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, FIT-
+ * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+ * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall not
+ * be used in advertising or otherwise to promote the sale, use or other deal-
+ * ings in this Software without prior written authorization from the XFree86
+ * Project.
+ *
+ */
+
+#include "X.h"
+#include "Xproto.h"
+#include "misc.h"
+#include "pixmapstr.h"
+#include "input.h"
+#include "font.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "dixfontstr.h"
+#include "fontstruct.h"
+#include "xf86.h"
+#include "xf86str.h"
+#include "migc.h"
+#include "fb.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+#include "cfbmskbits.h"
+
+#undef NEWPORT_GCSTUBS
+#include <newport.h>
+#include <newport_util.h>
+#include <newport_gc.h>
+
+#define GET_GC_PRIVATE(pGC) \
+	(NewportGCPtr)((pGC)->devPrivates[NewportGCIndex].ptr)
+
+#define NEWPORT_GC_FUNC_PROLOGUE(pGC)\
+    NewportGCPtr pGCPriv = GET_GC_PRIVATE(pGC);\
+    (pGC)->funcs = pGCPriv->funcs;\
+    if(pGCPriv->ops)\
+        (pGC)->ops = pGCPriv->ops
+
+#define NEWPORT_GC_FUNC_EPILOGUE(pGC)\
+    pGCPriv->funcs = (pGC)->funcs;\
+    (pGC)->funcs = &NewportGCFuncs;\
+    if(pGCPriv->ops) {\
+        pGCPriv->ops = (pGC)->ops;\
+        (pGC)->ops = &NewportGCOps;\
+    }
+
+
+#define NEWPORT_GC_OP_PROLOGUE(pGC)\
+    NewportGCPtr pGCPriv = GET_GC_PRIVATE(pGC);\
+    GCFuncs *oldFuncs = pGC->funcs;\
+    pGC->funcs = pGCPriv->funcs;\
+    pGC->ops = pGCPriv->ops
+
+    
+#define NEWPORT_GC_OP_EPILOGUE(pGC)\
+    pGCPriv->ops = pGC->ops;\
+    pGC->funcs = oldFuncs;\
+    pGC->ops   = &NewportGCOps
+
+/* Newport Stubs *********************************************************/
+
+#ifndef NEWPORT_GCSTUBS
+
+#define NewportCopyPlane miCopyPlane
+#define NewportPolyPoint miPolyPoint
+#define NewportPolySegment miPolySegment
+#define NewportPolyRectangle miPolyRectangle
+#define NewportPolyArc miPolyArc
+#define NewportFillPolygon miFillPolygon
+#define NewportPolyFillArc miPolyFillArc
+#define NewportImageGlyphBlt miImageGlyphBlt
+#define NewportPolyGlyphBlt miPolyGlyphBlt
+#define NewportPushPixels miPushPixels
+
+#else 
+
+RegionPtr NewportCopyPlane(
+			   DrawablePtr dst, DrawablePtr src,
+			   GCPtr pGC,
+			   int srcx, int srcy, int w, int h, int dstx, int dsty,
+			   unsigned long plane)
+{
+  RegionPtr result;
+  TRACE_ENTER(NPTRC_WRAPPERS, "miCopyPlane");
+  result = miCopyPlane( dst, src, pGC, srcx, srcy, w, h, dstx, dsty, plane);
+  TRACE_EXIT(NPTRC_WRAPPERS, "miCopyPlane");
+  return result;
+}
+
+void NewportPolyPoint(
+		      DrawablePtr dst,
+		      GCPtr pGC,
+		      int mode,
+		      int n,
+		      DDXPointPtr pPoint)
+{
+  TRACE_ENTER(NPTRC_WRAPPERS, "miPolyPoint");
+  miPolyPoint(dst, pGC, mode, n, pPoint );
+  TRACE_EXIT(NPTRC_WRAPPERS, "miPolyPoint");
+}
+
+
+void NewportPolySegment(
+			DrawablePtr dst,
+			GCPtr pGC,
+			int n,
+			xSegment *pSegment)
+{
+  TRACE_ENTER(NPTRC_WRAPPERS, "miPolySegment");
+  miPolySegment(dst, pGC, n, pSegment );
+  TRACE_EXIT(NPTRC_WRAPPERS, "miPolySegment");
+}
+
+void NewportPolyRectangle(
+			  DrawablePtr dst,
+			  GCPtr pGC,
+			  int n,
+			  xRectangle *pRect)
+{
+  TRACE_ENTER(NPTRC_WRAPPERS, "miPolyRectangle");
+  miPolyRectangle(dst, pGC, n, pRect );
+  TRACE_EXIT(NPTRC_WRAPPERS, "miPolyRectangle");
+}
+
+void NewportPolyArc(
+		    DrawablePtr dst,
+		    GCPtr pGC,
+		    int n,
+		    xArc *pArc)
+{
+  TRACE_ENTER(NPTRC_WRAPPERS, "miPolyArc");
+  TRACE(NPTRC_WRAPPERS, ("Calling miPolyArc ..."));
+  miPolyArc(dst, pGC, n, pArc );
+  TRACE_EXIT(NPTRC_WRAPPERS, "miPolyArc");
+}
+
+void NewportFillPolygon(
+			DrawablePtr dst,
+			GCPtr pGC,
+			int shape,
+			int mode,
+			int count,
+			DDXPointPtr pPoint)
+{
+  TRACE_ENTER(NPTRC_WRAPPERS, "miFillPolygon");
+  miFillPolygon(dst, pGC, shape, mode, count, pPoint);
+  TRACE_EXIT(NPTRC_WRAPPERS, "miFillPolygon");
+}
+
+void NewportPolyFillArc(
+			DrawablePtr dst,
+			GCPtr pGC,
+			int n,
+			xArc *pArc)
+{
+  TRACE_ENTER(NPTRC_WRAPPERS, "miPolyFillArc");
+  miPolyFillArc(dst, pGC, n, pArc );
+  TRACE_EXIT(NPTRC_WRAPPERS, "miPolyFillArc");
+}
+
+void NewportImageGlyphBlt(
+			  DrawablePtr pDrawable,
+			  GCPtr pGC,
+			  int x , int y,
+			  unsigned int nglyph,
+			  CharInfoRec **ppci, 
+			  pointer pglyphBase ) 
+{
+  TRACE_ENTER(NPTRC_WRAPPERS, "miImageGlyphBlt");
+  miImageGlyphBlt( pDrawable, pGC, x, y, nglyph, ppci, pglyphBase );
+  TRACE_EXIT(NPTRC_WRAPPERS, "miImageGlyphBlt");
+}
+
+void NewportPolyGlyphBlt(
+			 DrawablePtr pDrawable,
+			 GCPtr pGC,
+			 int x , int y,
+			 unsigned int nglyph,
+			 CharInfoRec **ppci,  
+			 pointer unused ) 
+{
+  TRACE_ENTER(NPTRC_WRAPPERS, "miPolyGlyphBlt");
+  miPolyGlyphBlt( pDrawable, pGC, x, y, nglyph, ppci, unused );
+  TRACE_EXIT(NPTRC_WRAPPERS, "miPolyGlyphBlt");
+}
+
+
+void NewportPushPixels(
+		       GCPtr pGC,
+		       PixmapPtr pBitMap,
+		       DrawablePtr pDrawable,
+		       int dx, int dy, int xOrg, int yOrg )
+{
+  TRACE_ENTER(NPTRC_WRAPPERS, "miPushPixels");
+  miPushPixels( pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg);
+  TRACE_EXIT(NPTRC_WRAPPERS, "miPushPixels");
+}
+
+#endif /* NEWPORT_GCSTUBS */
+/**********************************************************/
+
+
+GCOps NewportGCOps = {
+  NewportFillSpans, NewportSetSpans, 
+  miPutImage, NewportCopyArea, 
+  NewportCopyPlane, NewportPolyPoint, 
+  NewportPolyLines, NewportPolySegment, 
+  NewportPolyRectangle, NewportPolyArc, 
+  NewportFillPolygon, NewportFillRect, 
+  NewportPolyFillArc, NewportPolyText8, 
+  NewportPolyText16, NewportImageText8, 
+  NewportImageText16, NewportImageGlyphBlt, 
+  NewportPolyGlyphBlt, NewportPushPixels,
+#ifdef NEED_LINEHELPER
+  NULL,
+#endif
+  {NULL}		/* devPrivate */
+};
+
+GCOps NewportCfbGCOps = {
+  cfbSolidSpansCopy, cfbSetSpans, 
+  cfbPutImage, cfbCopyArea, 
+  cfbCopyPlane, cfbPolyPoint, 
+  cfbLineSS, cfbSegmentSS, 
+  miPolyRectangle, miPolyArc, 
+  cfbFillPoly1RectCopy, cfbPolyFillRect, 
+  miPolyFillArc, miPolyText8, 
+  miPolyText16, miImageText8, 
+  miImageText16, miImageGlyphBlt, 
+  miPolyGlyphBlt, miPushPixels,
+#ifdef NEED_LINEHELPER
+  NULL,
+#endif
+  {NULL}		/* devPrivate */
+};
+
+
+GCOps NewportCfb32GCOps = {
+  cfb32SolidSpansCopy, cfb32SetSpans, 
+  cfb32PutImage, cfb32CopyArea, 
+  cfb32CopyPlane, cfb32PolyPoint, 
+  cfb32LineSS, cfb32SegmentSS, 
+  miPolyRectangle, miPolyArc, 
+  cfb32FillPoly1RectCopy, cfb32PolyFillRect, 
+  miPolyFillArc, miPolyText8, 
+  miPolyText16, miImageText8, 
+  miImageText16, miImageGlyphBlt, 
+  miPolyGlyphBlt, miPushPixels,
+#ifdef NEED_LINEHELPER
+  NULL,
+#endif
+  {NULL}
+};
+
+/* Stubs ***************************************************/
+
+#ifdef NEWPORT_GCSTUBS
+
+void NewportWrapFillSpans(
+			  DrawablePtr pDrawable,
+			  GCPtr pGC,
+			  int nInit,
+			  DDXPointPtr pptInit,
+			  int * pwidthInit,
+			  int fSorted
+			  ) 
+{
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dst;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapFillSpans");
+  ops=(pDrawable->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", pDrawable->depth, ops->FillSpans));
+  _pPix = (PixmapPtr) (pDrawable);
+  dst = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dst));
+  ops->FillSpans(
+		 pDrawable,
+		 pGC,
+		 nInit,
+		 pptInit,
+		 pwidthInit,
+		 fSorted
+		 );
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapFillSpans");
+}
+
+
+void NewportWrapSetSpans(
+			 DrawablePtr pDrawable,
+			 GCPtr pGC,
+			 char * psrc,
+			 DDXPointPtr ppt,
+			 int * pwidth,
+			 int nspans,
+			 int fSorted
+			 )
+{
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dst;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapSetSpans");
+  ops=(pDrawable->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", pDrawable->depth, ops->SetSpans));
+  TRACE(NPTRC_WRAPPERS, ("src: %x", psrc ));
+  _pPix = (PixmapPtr) (pDrawable);
+  dst = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dst));
+  ops->SetSpans(
+		pDrawable,
+		pGC,
+		psrc,
+		ppt,
+		pwidth,
+		nspans,
+		fSorted
+		);
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapSetSpans");
+}
+
+
+void NewportWrapPutImage(
+			 DrawablePtr pDraw,
+			 GCPtr pGC,
+			 int depth,
+			 int x,
+			 int y,
+			 int w,
+			 int h,
+			 int leftPad,
+			 int format,
+			 char * pImage
+			 ) 
+{
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dst;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapPutImage");
+  ops=(pDraw->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", pDraw->depth, ops->PutImage));
+  TRACE(NPTRC_WRAPPERS, ("src: %x", pImage ));
+  _pPix = (PixmapPtr) (pDraw);
+  dst = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dst));
+
+  ops->PutImage(
+		pDraw,
+		pGC,
+		depth,
+		x,
+		y,
+		w,
+		h,
+		leftPad,
+		format,
+		pImage
+		);
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapPutImage");
+}
+
+RegionPtr NewportWrapCopyArea(
+			      DrawablePtr pSrcDrawable,
+			      DrawablePtr pDstDrawable,
+			      GCPtr pGC,
+			      int srcx,
+			      int srcy,
+			      int width,
+			      int height,
+			      int dstx,
+			      int dsty
+			      )
+{
+  GCOps *ops;
+  RegionPtr result;
+  PixmapPtr _pPix;
+  char* dst;
+
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapCopyArea");
+  ops=(pSrcDrawable->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", pSrcDrawable->depth, ops->CopyArea));
+
+  NewportDumpGC(pGC);
+
+  _pPix = (PixmapPtr) (pSrcDrawable);
+  dst = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("src: %x", dst));
+  NewportDumpPixmap(_pPix);
+
+  result=ops->CopyArea(
+		       pSrcDrawable,
+		       pDstDrawable,
+		       pGC,
+		       srcx,
+		       srcy,
+		       width,
+		       height,
+		       dstx,
+		       dsty
+		       );
+
+  _pPix = (PixmapPtr) (pDstDrawable);
+  dst = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dst));
+  NewportDumpPixmap(_pPix);
+
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapCopyArea");
+  return result;
+}
+
+RegionPtr NewportWrapCopyPlane(
+			       DrawablePtr dst, DrawablePtr src,
+			       GCPtr pGC,
+			       int srcx, int srcy, int w, int h, int dstx, int dsty,
+			       unsigned long plane)
+{
+  RegionPtr result;
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dstc;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapCopyPlane");
+  ops=(dst->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", dst->depth, ops->CopyPlane));
+  _pPix = (PixmapPtr) (dst);
+  dstc = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dstc));
+  result = ops->CopyPlane( dst, src, pGC, srcx, srcy, w, h, dstx, dsty, plane);
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapCopyPlane");
+  return result;
+}
+
+void NewportWrapPolyPoint(
+			  DrawablePtr dst,
+			  GCPtr pGC,
+			  int mode,
+			  int n,
+			  DDXPointPtr pPoint)
+{
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dstc;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapPolyPoint");
+  _pPix = (PixmapPtr) (dst);
+  dstc = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dstc));
+  ops=(dst->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", dst->depth, ops->PolyPoint));
+  ops->PolyPoint(dst, pGC, mode, n, pPoint );
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapPolyPoint");
+}
+
+
+void NewportWrapPolyLines(
+			  DrawablePtr dst,
+			  GCPtr pGC,
+			  int mode,
+			  int n,
+			  DDXPointPtr pPoint)
+{
+  GCOps *ops;
+  int i;
+  PixmapPtr _pPix;
+  char* dstc;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapPolyLines");
+  ops=(dst->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", dst->depth, ops->Polylines));
+  TRACE(NPTRC_WRAPPERS, ("mode=%d, n=%d", mode, n));
+  _pPix = (PixmapPtr) (dst);
+  dstc = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dstc));
+  for( i=0; i<n; i++ ) {
+    TRACE(NPTRC_WRAPPERS, ("Point(%d): x=%d, y=%d", i, pPoint[i].x, pPoint[i].y ));
+  }
+  ops->Polylines(dst, pGC, mode, n, pPoint ); 
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapPolyLines");
+}
+
+
+void NewportWrapPolySegment(
+			    DrawablePtr dst,
+			    GCPtr pGC,
+			    int n,
+			    xSegment *pSegment)
+{
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dstc;
+  int i;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapPolySegment");
+  ops=(dst->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", dst->depth, ops->PolySegment));
+  _pPix = (PixmapPtr) (dst);
+  dstc = (char*) _pPix->devPrivate.ptr;
+
+  TRACE(NPTRC_WRAPPERS, ("drawable: x:%d y:%d w:%d h:%d", dst->x, dst->y, dst->width, dst->height));
+  NewportDumpGC(pGC);
+
+  for(i=0; i<n; i++) {
+    TRACE(NPTRC_WRAPPERS, ("segment(%d):x1=%d, y1=%d, x2=%d, y2=%d", i, pSegment[i].x1, pSegment[i].y1, pSegment[i].x2, pSegment[i].y2));
+  }
+
+  TRACE(NPTRC_WRAPPERS, ("pre: %x", dstc));
+  NewportDumpPixmap(_pPix);
+  ops->PolySegment(dst, pGC, n, pSegment );
+  TRACE(NPTRC_WRAPPERS, ("post: %x", dstc));
+  NewportDumpPixmap(_pPix);
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapPolySegment");
+}
+
+void NewportWrapPolyRectangle(
+			      DrawablePtr dst,
+			      GCPtr pGC,
+			      int n,
+			      xRectangle *pRect)
+{
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dstc;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapPolyRectangle");
+  _pPix = (PixmapPtr) (dst);
+  dstc = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dstc));
+  ops=(dst->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", dst->depth, ops->PolyRectangle));
+  ops->PolyRectangle(dst, pGC, n, pRect );
+  TRACE_EXIT(NPTRC_WRAPPERS, "miPolyRectangle");
+}
+
+void NewportWrapPolyArc(
+			DrawablePtr dst,
+			GCPtr pGC,
+			int n,
+			xArc *pArc)
+{
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dstc;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapPolyArc");
+  ops=(dst->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", dst->depth, ops->PolyArc));
+  _pPix = (PixmapPtr) (dst);
+  dstc = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dstc));
+  ops->PolyArc(dst, pGC, n, pArc );
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapPolyArc");
+}
+
+
+void NewportWrapFillPolygon(
+			    DrawablePtr dst,
+			    GCPtr pGC,
+			    int shape,
+			    int mode,
+			    int count,
+			    DDXPointPtr pPoint)
+{
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dstc;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapFillPolygon");
+  ops=(dst->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", dst->depth, ops->FillPolygon));
+  _pPix = (PixmapPtr) (dst);
+  dstc = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dstc));
+  ops->FillPolygon(dst, pGC, shape, mode, count, pPoint);
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapFillPolygon");
+}
+
+
+void NewportWrapPolyFillRect(
+			     DrawablePtr pDrawable,
+			     GCPtr pGC,
+			     int nrectFill,
+			     xRectangle * prectInit
+			     )
+{
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dstc;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapPolyFillRect");
+  ops=(pDrawable->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", pDrawable->depth, ops->PolyFillRect));
+  _pPix = (PixmapPtr) (pDrawable);
+  dstc = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dstc));
+  ops->PolyFillRect(
+		    pDrawable,
+		    pGC,
+		    nrectFill,
+		    prectInit
+		    );
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapPolyFillRect");
+}
+
+void NewportWrapPolyFillArc(
+			    DrawablePtr dst,
+			    GCPtr pGC,
+			    int n,
+			    xArc *pArc)
+{
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dstc;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapPolyFillArc");
+  ops=(dst->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", dst->depth, ops->PolyFillArc));
+  _pPix = (PixmapPtr) (dst);
+  dstc = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dstc));
+  ops->PolyFillArc(dst, pGC, n, pArc );
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapPolyFillArc");
+}
+
+void NewportWrapImageText8(DrawablePtr pDraw, 
+			   GC *pGC, 
+			   int x, 
+			   int y, 
+			   int count,
+			   char *chars)
+{
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dstc;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapImageText8");
+  ops=(pDraw->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", pDraw->depth, ops->ImageText8));
+  _pPix = (PixmapPtr) (pDraw);
+  dstc = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dstc));
+  ops->ImageText8( pDraw, pGC, x, y, count, chars);
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapImageText8");
+}
+
+int NewportWrapPolyText8(DrawablePtr pDraw, 
+			 GC *pGC, 
+			 int x, 
+			 int y, 
+			 int count,
+			 char *chars)
+{
+  GCOps *ops;
+  int res;
+  PixmapPtr _pPix;
+  char* dstc;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapPolyText8");
+  ops=(pDraw->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", pDraw->depth, ops->PolyText8));
+
+  TRACE(NPTRC_WRAPPERS, ("drawable: x:%d y:%d w:%d h:%d", pDraw->x, pDraw->y, pDraw->width, pDraw->height));
+  NewportDumpGC(pGC);
+
+  _pPix = (PixmapPtr) (pDraw);
+  dstc = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("pre: %x", dstc));
+  NewportDumpPixmap(_pPix);
+  res=ops->PolyText8( pDraw, pGC, x, y, count, chars);
+  TRACE(NPTRC_WRAPPERS, ("post: %x", dstc));
+  NewportDumpPixmap(_pPix);
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapPolyText8");
+  return res;
+}
+
+
+void NewportWrapImageText16(DrawablePtr pDraw, 
+			    GC *pGC, 
+			    int x, 
+			    int y, 
+			    int count,
+			    unsigned short *chars)
+{
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dstc;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapImageText16");
+  ops=(pDraw->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", pDraw->depth, ops->ImageText16));
+  _pPix = (PixmapPtr) (pDraw);
+  dstc = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dstc));
+  ops->ImageText16( pDraw, pGC, x, y, count, chars);
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapImageText16");
+}
+
+int NewportWrapPolyText16(DrawablePtr pDraw, 
+			  GC *pGC, 
+			  int x, 
+			  int y, 
+			  int count,
+			  unsigned short *chars)
+{
+  GCOps *ops;
+  int res;
+  PixmapPtr _pPix;
+  char* dstc;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapImageText16");
+  ops=(pDraw->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", pDraw->depth, ops->PolyText16));
+  _pPix = (PixmapPtr) (pDraw);
+  dstc = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dstc));
+  res=ops->PolyText16( pDraw, pGC, x, y, count, chars);
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapImageText16");
+  return res;
+}
+
+void NewportWrapImageGlyphBlt(
+			      DrawablePtr pDrawable,
+			      GCPtr pGC,
+			      int x , int y,
+			      unsigned int nglyph,
+			      CharInfoRec **ppci,      /* array of character info */
+			      pointer pglyphBase ) 
+{
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dstc;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapImageGlyphBlt");
+  ops=(pDrawable->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", pDrawable->depth, ops->ImageGlyphBlt));
+  _pPix = (PixmapPtr) (pDrawable);
+  dstc = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dstc));
+  ops->ImageGlyphBlt( pDrawable, pGC, x, y, nglyph, ppci, pglyphBase );
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapImageGlyphBlt");
+}
+
+void NewportWrapPolyGlyphBlt(
+			     DrawablePtr pDrawable,
+			     GCPtr pGC,
+			     int x , int y,
+			     unsigned int nglyph,
+			     CharInfoRec **ppci,      /* array of character info */
+			     pointer unused ) 
+{
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dstc;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapPolyGlyphBlt");
+  ops=(pDrawable->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", pDrawable->depth, ops->PolyGlyphBlt));
+  _pPix = (PixmapPtr) (pDrawable);
+  dstc = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dstc));
+  ops->PolyGlyphBlt( pDrawable, pGC, x, y, nglyph, ppci, unused );
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapPolyGlyphBlt");
+}
+
+
+void NewportWrapPushPixels(
+			   GCPtr pGC,
+			   PixmapPtr pBitMap,
+			   DrawablePtr pDrawable,
+			   int dx, int dy, int xOrg, int yOrg )
+{
+  GCOps *ops;
+  PixmapPtr _pPix;
+  char* dstc;
+  TRACE_ENTER(NPTRC_WRAPPERS, "WrapPushPixels");
+  ops=(pDrawable->depth==8)?&NewportCfbGCOps:&NewportCfb32GCOps;
+  TRACE(NPTRC_WRAPPERS, ("Depth:%d, op=%x", pDrawable->depth, ops->PushPixels));
+  _pPix = (PixmapPtr) (pDrawable);
+  dstc = (char*) _pPix->devPrivate.ptr;
+  TRACE(NPTRC_WRAPPERS, ("dst: %x", dstc));
+  ops->PushPixels( pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg);
+  TRACE_EXIT(NPTRC_WRAPPERS, "WrapPushPixels");
+}
+
+
+GCOps NewportWrapGCOps = {
+  NewportWrapFillSpans, NewportWrapSetSpans, 
+  NewportWrapPutImage, NewportWrapCopyArea, 
+  NewportWrapCopyPlane, NewportWrapPolyPoint, 
+  NewportWrapPolyLines, NewportWrapPolySegment, 
+  NewportWrapPolyRectangle, NewportWrapPolyArc, 
+  NewportWrapFillPolygon, NewportWrapPolyFillRect, 
+  NewportWrapPolyFillArc, NewportWrapPolyText8, 
+  NewportWrapPolyText16, NewportWrapImageText8, 
+  NewportWrapImageText16, NewportWrapImageGlyphBlt, 
+  NewportWrapPolyGlyphBlt, NewportWrapPushPixels,
+#ifdef NEED_LINEHELPER
+  NULL,
+#endif
+  {NULL}
+};
+
+#endif
+
+/**********************************************************/
+
+
+
+Bool
+NewportCreateGC(GCPtr pGC)
+{
+  if (pGC->depth == 1) {
+    return mfbCreateGC(pGC);
+  }
+    
+  if (pGC->depth == 8) {
+    if (!cfbCreateGC(pGC))
+      return FALSE;
+  } else {
+    if (!cfb32CreateGC(pGC))
+      return FALSE;
+  }
+  TRACE_ENTER(NPTRC_GC, "NewportCreateGC");
+
+  pGC->clientClip = NULL;
+  pGC->clientClipType = CT_NONE;
+  pGC->freeCompClip = 0;
+  pGC->pCompositeClip = NULL;
+  pGC->pRotatedPixmap = NULL;
+  pGC->miTranslate = 1;
+
+  pGC->funcs = &NewportGCFuncs;    
+  pGC->ops = &NewportGCOps;
+
+  TRACE_EXIT(NPTRC_GC, "NewportCreateGC");
+  return TRUE;
+}
+
+void
+NewportValidateGC(
+		  GCPtr         pGC,
+		  unsigned long changes,
+		  DrawablePtr   pDraw 
+		  ){
+  int drawableChanged;
+  cfbPrivGCPtr devPriv;
+
+  TRACE_ENTER(NPTRC_GC, "NewportValidateGC");
+
+  drawableChanged = (pDraw->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS));
+
+  if(pDraw->type != DRAWABLE_WINDOW) {
+      
+    /*
+      Switch from NewportGCOps to CfbGCOps changes everything ....
+    */
+    if ( pGC->ops == &NewportGCOps ) {
+      changes = 0xffffffff;
+    }
+
+    devPriv=cfbGetGCPrivate(pGC);
+    switch ( pGC->depth ) {
+    case 8:
+      TRACE(NPTRC_GC, ("GC:%x Typ:cfb8 Changes:%x", pGC, changes ));
+      pGC->ops = &NewportCfbGCOps;
+	    
+      cfbValidateGC( pGC, changes, pDraw );
+
+      /*
+	Handle CopyArea & CopyPlane
+      */
+      pGC->ops->CopyArea = miCopyArea;
+      pGC->ops->CopyPlane = miCopyPlane;
+
+	    
+#ifdef NEWPORT_GCSTUBS
+      pGC->ops = &NewportWrapGCOps;
+#endif
+
+      break;
+    default:
+      TRACE(NPTRC_GC, ("GC:%x Typ:cfb32 Changes:%x", pGC, changes ));
+      pGC->ops = &NewportCfb32GCOps;
+
+      cfb32ValidateGC( pGC, changes, pDraw );
+
+      TRACE(NPTRC_GC, ("FillSpans.1: %x", pGC->ops->FillSpans));
+
+      /*
+	Handle CopyArea & CopyPlane
+      */
+      pGC->ops->CopyArea = NewportCopyArea;
+      pGC->ops->CopyPlane = miCopyPlane;
+
+
+#ifdef NEWPORT_GCSTUBS
+      pGC->ops = &NewportWrapGCOps;
+#endif
+
+      break;
+    }
+  } else {
+    TRACE(NPTRC_GC, ("GC:%x Typ:newp Changes:%x", pGC, changes ));
+    pGC->ops = &NewportGCOps;
+  }
+
+  if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) || 
+      drawableChanged
+      ) 
+    miComputeCompositeClip (pGC, pDraw);
+
+  TRACE_EXIT(NPTRC_GC, "NewportValidateGC");
+}
+
+
+void
+NewportDestroyGC(GCPtr pGC)
+{
+  NEWPORT_GC_FUNC_PROLOGUE (pGC);
+  (*pGC->funcs->DestroyGC)(pGC);
+  NEWPORT_GC_FUNC_EPILOGUE (pGC);
+}
+
+void
+NewportChangeGC (
+		 GCPtr	    pGC,
+		 unsigned long   mask
+		 ){
+  NEWPORT_GC_FUNC_PROLOGUE (pGC);
+  (*pGC->funcs->ChangeGC) (pGC, mask);
+  NEWPORT_GC_FUNC_EPILOGUE (pGC);
+}
+
+void
+NewportCopyGC (
+	       GCPtr	    pGCSrc, 
+	       unsigned long   mask,
+	       GCPtr	    pGCDst
+	       ){
+  NEWPORT_GC_FUNC_PROLOGUE (pGCDst);
+  (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst);
+  NEWPORT_GC_FUNC_EPILOGUE (pGCDst);
+}
+
+void
+NewportChangeClip (
+		   GCPtr   pGC,
+		   int		type,
+		   pointer	pvalue,
+		   int		nrects 
+		   ){
+  NEWPORT_GC_FUNC_PROLOGUE (pGC);
+  (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects);
+  NEWPORT_GC_FUNC_EPILOGUE (pGC);
+}
+
+void
+NewportCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
+{
+  NEWPORT_GC_FUNC_PROLOGUE (pgcDst);
+  (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc);
+  NEWPORT_GC_FUNC_EPILOGUE (pgcDst);
+}
+
+void
+NewportDestroyClip(GCPtr pGC)
+{
+  NEWPORT_GC_FUNC_PROLOGUE (pGC);
+  (* pGC->funcs->DestroyClip)(pGC);
+  NEWPORT_GC_FUNC_EPILOGUE (pGC);
+}
+
+
+
+/**********************************************************/
+
+GCFuncs NewportGCFuncs = {
+  NewportValidateGC, miChangeGC, miCopyGC, miDestroyGC,
+  miChangeClip, miDestroyClip, miCopyClip
+};
+
+
diff -NaurbB newport.shadow/newport_gc.h newport.new/newport_gc.h
--- newport.shadow/newport_gc.h	Thu Jan  1 01:00:00 1970
+++ newport.new/newport_gc.h	Sun Dec 29 12:50:20 2002
@@ -0,0 +1,50 @@
+#ifndef __NEWPORT_GC_H__
+#define __NEWPORT_GC_H__
+
+ void NewportRestoreAreas (    
+    PixmapPtr pPixmap,
+    RegionPtr prgn,
+    int       xorg,
+    int       yorg,
+    WindowPtr pWin 
+);
+
+ void NewportPaintWindow (
+    WindowPtr pWin,
+    RegionPtr prgn,
+    int what 
+);
+ void NewportCopyWindow(
+    WindowPtr pWin,
+    DDXPointRec ptOldOrg,
+    RegionPtr prgn 
+);
+ Bool NewportCreateGC(GCPtr pGC);
+ Bool NewportModifyPixmapHeader(
+    PixmapPtr pPixmap,
+    int width,
+    int height,
+    int depth,
+    int bitsPerPixel,
+    int devKind,
+    pointer pPixData
+);
+
+ void NewportValidateGC(GCPtr, unsigned long, DrawablePtr);
+ void NewportChangeGC(GCPtr, unsigned long);
+ void NewportCopyGC(GCPtr, unsigned long, GCPtr);
+ void NewportDestroyGC(GCPtr);
+ void NewportChangeClip(GCPtr, int, pointer, int);
+ void NewportDestroyClip(GCPtr);
+ void NewportCopyClip(GCPtr, GCPtr);
+
+ GCFuncs NewportGCFuncs;
+
+typedef struct {
+   GCOps   *ops;
+   GCFuncs *funcs;
+} NewportGCRec, *NewportGCPtr;
+
+ GCOps NewportGCOps;
+
+#endif
diff -NaurbB newport.shadow/newport_getspans.c newport.new/newport_getspans.c
--- newport.shadow/newport_getspans.c	Thu Jan  1 01:00:00 1970
+++ newport.new/newport_getspans.c	Wed Nov  5 05:21:36 2003
@@ -0,0 +1,123 @@
+/*
+ * Driver for the SGI Indy's Newport graphics card - Read Spans
+ * 
+ * (c) 2003      Frank Foerstemann <Foerstemann@web.de>
+ *
+ * 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 fur-
+ * nished 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, FIT-
+ * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+ * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall not
+ * be used in advertising or otherwise to promote the sale, use or other deal-
+ * ings in this Software without prior written authorization from the XFree86
+ * Project.
+ *
+ */
+
+#include "X.h"
+#include "Xproto.h"
+#include "misc.h"
+#include "pixmapstr.h"
+#include "input.h"
+#include "font.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "dixfontstr.h"
+#include "fontstruct.h"
+#include "xf86.h"
+#include "xf86str.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+#include <newport.h>
+#include <newport_util.h>
+
+void NewportGetSpans(
+		     DrawablePtr pDrawable,
+		     int wMax,
+		     DDXPointPtr ppt,
+		     int* pwidth,
+		     int nspans,
+		     char * pdstStart)
+{
+  int i;
+  CARD32 *pdst, *pdstSpan = (CARD32*) pdstStart;
+  CARD32 pixel;
+  ScreenPtr   pScreen = pDrawable->pScreen;
+  ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+  NewportPtr  pPriv = NEWPORTPTR (pScrn);
+  NewportRegsPtr pNewportRegs = pPriv->pNewportRegs;
+  
+
+  TRACE_ENTER(NPTRC_GETSPANS, "NewportGetSpans");
+
+  if(pDrawable->type != DRAWABLE_WINDOW) {
+    if(pDrawable->bitsPerPixel == 1) {
+      TRACE(NPTRC_GETSPANS, ("calling mfbGetSpans ..."));
+      mfbGetSpans(pDrawable, wMax, ppt, pwidth,
+		  nspans, pdstStart);
+    } else if (pDrawable->bitsPerPixel == 8) {
+      TRACE(NPTRC_GETSPANS, ("calling cfbGetSpans ..."));
+      cfbGetSpans(pDrawable, wMax, ppt, pwidth,
+		  nspans, pdstStart);
+    } else {
+      TRACE(NPTRC_GETSPANS, ("calling cfb32GetSpans ..."));
+      cfb32GetSpans(pDrawable, wMax, ppt, pwidth,
+		    nspans, pdstStart );
+    }
+	
+    TRACE_EXIT(NPTRC_GETSPANS, "NewportGetSpans");
+    return;
+  }
+
+  TRACE(NPTRC_GETSPANS, ("nspans: %d", nspans));
+ 
+  NewportWait (pNewportRegs);
+  pNewportRegs->set.drawmode0 = (NPORT_DMODE0_RD |
+				 NPORT_DMODE0_SPAN | 
+				 NPORT_DMODE0_CHOST |
+				 NPORT_DMODE0_AHOST);
+  pNewportRegs->set.drawmode1 |= NPORT_DMODE1_PFENAB;
+  
+  while ( nspans-- ) {
+    pdst = pdstSpan;
+    TRACE(NPTRC_GETSPANS, ("x : %d", ppt->x));
+    TRACE(NPTRC_GETSPANS, ("y : %d", ppt->y));
+    TRACE(NPTRC_GETSPANS, ("w : %d", *pwidth));
+    TRACE(NPTRC_GETSPANS, ("d : %x", pdst));
+    NewportWait (pNewportRegs);
+    pNewportRegs->set.xystarti = (ppt->x << 16) | ppt->y;
+    pNewportRegs->set.xyendi = ( (ppt->x + *pwidth -1) << 16) | ppt->y;
+    pNewportRegs->set._setup = 1;
+
+    for (i=*pwidth; i > 0; i--) {
+      pixel = pNewportRegs->go.hostrw0;
+      *pdst = (pixel & 0xff00ff00) |
+	((pixel & 0xff) << 16) | 
+	(( pixel & 0xff0000) >> 16);
+      pdst++;
+    }
+    pdstSpan += *pwidth;
+    ppt++;
+    pwidth++;
+  }
+  TRACE_EXIT(NPTRC_GETSPANS, "NewportGetSpans");
+}
diff -NaurbB newport.shadow/newport_image.c newport.new/newport_image.c
--- newport.shadow/newport_image.c	Thu Jan  1 01:00:00 1970
+++ newport.new/newport_image.c	Wed Nov  5 05:25:11 2003
@@ -0,0 +1,107 @@
+/*
+ * Driver for the SGI Indy's Newport graphics card - Image Drawing
+ * 
+ * (c) 2003      Frank Foerstemann <Foerstemann@web.de>
+ *
+ * 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 fur-
+ * nished 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, FIT-
+ * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+ * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall not
+ * be used in advertising or otherwise to promote the sale, use or other deal-
+ * ings in this Software without prior written authorization from the XFree86
+ * Project.
+ *
+ */
+
+#include "X.h"
+#include "Xproto.h"
+#include "misc.h"
+#include "pixmapstr.h"
+#include "input.h"
+#include "font.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "dixfontstr.h"
+#include "fontstruct.h"
+#include "xf86.h"
+#include "xf86str.h"
+
+#include <newport.h>
+
+#include <newport_util.h>
+
+void NewportFillRectTiled(DrawablePtr pDraw,
+			  GC * pGC,
+			  int nInit,
+			  xRectangle *pRectInit);
+
+void
+NewportPutImage(DrawablePtr pDraw, 
+		GCPtr pGC, 
+		int depth, int x, int y, int w, int h, int leftPad,
+		int format,
+		char *pImage ) 
+{
+  PixmapPtr	pPixmap = (PixmapPtr)NULL;
+  xRectangle  xRect;
+  int         oldFillStyle;
+  PixmapPtr	oldTile;
+  int i,j;
+
+  if ( !w || !h )
+    return;
+  /*
+  TRACE_ENTER(NPTRC_IMAGE,"NewportPutImage");
+  TRACE(NPTRC_IMAGE, ("x:%d, y:%d, w:%d, h:%d, p:%d, d:%d",x,y,w,h,leftPad,depth));
+
+  TRACE(NPTRC_IMAGE,("XYBitmap: Calling miPutImage ..."));
+  miPutImage( pDraw, pGC, depth, x, y, w, h, leftPad, format, pImage );
+
+  */
+  switch (format) {
+  case XYBitmap:
+    TRACE(NPTRC_IMAGE,("XYBitmap: Calling miPutImage ..."));
+    miPutImage( pDraw, pGC, depth, x, y, w, h, leftPad, format, pImage );
+    break;
+  default:
+    pPixmap = (*pDraw->pScreen->CreatePixmap)
+      (pDraw->pScreen, w, 0, depth);
+    pPixmap->devPrivate.ptr = pImage;
+    pPixmap->drawable.height = h;
+    
+    oldFillStyle = pGC->fillStyle;
+    oldTile = pGC->tile.pixmap;
+    
+    pGC->fillStyle = FillTiled;
+    pGC->tile.pixmap = pPixmap;
+    xRect.x = x;
+    xRect.y = y;
+    xRect.width = w;
+    xRect.height = h;
+    NewportFillRectTiled( pDraw, pGC, 1, &xRect );
+    
+    pGC->fillStyle = oldFillStyle;
+    pGC->tile.pixmap = pPixmap;
+  }
+  TRACE_EXIT(NPTRC_IMAGE,"NewportPutImage");
+}
+
+
+
+
diff -NaurbB newport.shadow/newport_lines.c newport.new/newport_lines.c
--- newport.shadow/newport_lines.c	Thu Jan  1 01:00:00 1970
+++ newport.new/newport_lines.c	Wed Nov  5 05:16:50 2003
@@ -0,0 +1,157 @@
+/*
+ * Driver for the SGI Indy's Newport graphics card - Line Drawing
+ * 
+ * (c) 2003      Frank Foerstemann <Foerstemann@web.de>
+ *
+ * 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 fur-
+ * nished 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, FIT-
+ * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+ * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall not
+ * be used in advertising or otherwise to promote the sale, use or other deal-
+ * ings in this Software without prior written authorization from the XFree86
+ * Project.
+ *
+ */
+
+#include "X.h"
+#include "Xproto.h"
+#include "misc.h"
+#include "pixmapstr.h"
+#include "input.h"
+#include "font.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "dixfontstr.h"
+#include "fontstruct.h"
+#include "xf86.h"
+#include "xf86str.h"
+
+#include <newport.h>
+
+#include <newport_util.h>
+
+void
+NewportPolyLines(
+    DrawablePtr pDraw,
+    GCPtr	pGC,
+    int		mode,		
+    int		npt,		
+    DDXPointPtr pptInit 
+){
+    ScreenPtr pScreen = pGC->pScreen;
+    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    NewportPtr pPriv = NEWPORTPTR(pScrn);
+    NewportRegsPtr pNewportRegs = pPriv->pNewportRegs;
+    DDXPointPtr pptFirst, pptNext; 
+    BoxPtr pbox, pboxLast;
+    RegionPtr prgnDst;
+    int n, x1, y1, x2, y2;
+    CARD32 dest;
+
+    TRACE_ENTER( NPTRC_LINES, "NewportPolyLines");
+
+    if ( pGC->lineWidth > 1 || pGC->lineStyle != LineSolid ) {
+      TRACE( NPTRC_LINES, ("lintWidth: %d -> calling miWideLine", pGC->lineWidth ));
+      
+      miWideLine(pDraw, pGC, mode, npt, pptInit );
+      TRACE_EXIT( NPTRC_LINES, "NewportPolyLines");
+      return;
+    }
+
+    prgnDst = pGC->pCompositeClip;
+    pbox = REGION_RECTS(prgnDst);
+    pboxLast = pbox + REGION_NUM_RECTS(prgnDst) -1;
+
+    NewportWait (pNewportRegs);
+
+    pNewportRegs->set.drawmode0 = (NPORT_DMODE0_DRAW |
+				   NPORT_DMODE0_ILINE |
+				   NPORT_DMODE0_CHOST |
+				   NPORT_DMODE0_AHOST |
+				   NPORT_DMODE0_STOPX |
+				   NPORT_DMODE0_STOPY |
+				   NPORT_DMODE0_DOSETUP );
+
+    pNewportRegs->set.drawmode1 =
+      (pNewportRegs->set.drawmode1 & 0x0fffffff) | (pGC->alu << 28);
+    pNewportRegs->set.wrmask = pGC->planemask | 0xfff;
+      
+    pNewportRegs->set.colorback =
+      (pGC->bgPixel & 0xff00ff00) |
+      ((pGC->bgPixel & 0xff) << 16) | 
+      ((pGC->bgPixel & 0xff0000) >> 16);    
+    dest = 
+      (pGC->fgPixel & 0xff00ff00) |
+      ((pGC->fgPixel & 0xff) << 16) | 
+      ((pGC->fgPixel & 0xff0000) >> 16);
+    
+    pNewportRegs->set.hostrw0 = dest;
+    pNewportRegs->set.hostrw1 = dest;
+    
+    TRACE( NPTRC_LINES, ("npt=%d, mode=%s", npt, (mode==CoordModeOrigin)? "Origin" : "Previous" ));
+
+    if ( mode == CoordModePrevious && pGC->miTranslate ) {
+      x1=0;
+      y1=0;
+      x2=pDraw->x +pptInit->x;
+      y2=pDraw->y +pptInit->y;
+    } else {
+      x1=0;
+      y1=0;
+      x2= pptInit->x;
+      y2= pptInit->y;
+    }
+
+    while ( pbox <= pboxLast ) {
+      pbox = NewportSMaskSet( pNewportRegs, pbox, pboxLast );
+      for( n=npt, pptFirst = pptInit, pptNext = pptInit+1;
+	   n > 1;
+	   n--, ++pptFirst, ++pptNext ) {
+	TRACE( NPTRC_LINES, ("%d: x1=%d, y1=%d, x2=%d, y2=%d", 
+			     n, pptFirst->x, pptFirst->y,
+			     pptNext->x, pptNext->y));
+	NewportWait (pNewportRegs);
+	pNewportRegs->set._setup = 1;
+	
+	if ( mode == CoordModeOrigin ) {
+	  if ( pGC->miTranslate ) {
+	    x1 = pDraw->x +pptFirst->x;
+	    y1 = pDraw->y +pptFirst->y;
+	    x2 = pDraw->x +pptNext->x;
+	    y2 = pDraw->y +pptNext->y;
+	  } else {
+	    x1 = pptFirst->x;
+	    y1 = pptFirst->y;
+	    x2 = pptNext->x;
+	    y2 = pptNext->y;
+	  }
+	} else {
+	  x1 = x2;
+	  y1 = y2;
+	  x2 = x1 +pptNext->x;
+	  y2 = y1 +pptNext->y;
+	}
+
+	pNewportRegs->set.xystarti = (x1 << 16) | y1;
+	pNewportRegs->go.xyendi = (x2 << 16) | y2;
+      }
+    }
+
+    TRACE_EXIT( NPTRC_LINES, "NewportPolyLines");
+}
diff -NaurbB newport.shadow/newport_polytext.c newport.new/newport_polytext.c
--- newport.shadow/newport_polytext.c	Thu Jan  1 01:00:00 1970
+++ newport.new/newport_polytext.c	Wed Nov  5 05:18:49 2003
@@ -0,0 +1,285 @@
+/*
+ * Driver for the SGI Indy's Newport graphics card - Text Output
+ * 
+ * (c) 2003      Frank Foerstemann <Foerstemann@web.de>
+ *
+ * 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 fur-
+ * nished 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, FIT-
+ * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+ * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall not
+ * be used in advertising or otherwise to promote the sale, use or other deal-
+ * ings in this Software without prior written authorization from the XFree86
+ * Project.
+ *
+ */
+
+#include "X.h"
+#include "Xproto.h"
+#include "misc.h"
+#include "pixmapstr.h"
+#include "input.h"
+#include "font.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "dixfontstr.h"
+#include "fontstruct.h"
+#include "xf86.h"
+#include "xf86str.h"
+
+#include <newport.h>
+
+#include <newport_util.h>
+
+int NewportText(DrawablePtr pDraw, 
+		GC *pGC, 
+		int xInit, 
+		int y, 
+		int count,
+		char *chars,
+		int opaque,
+		int EightBit) 
+{
+  ScreenPtr pScreen;
+  ScrnInfoPtr pScrn;
+  NewportPtr pPriv;
+  NewportRegsPtr pNewportRegs;
+  BoxPtr pbox, pboxLast;
+  RegionPtr prgnDst;
+  CARD32 dest;
+  unsigned long n, zPattern;
+  CharInfoPtr charinfo[255], pci;	/* encoding only has 1 byte for count */
+  int c, c1, w1, x=xInit, y1;
+  int blockWidth, blockNum, blockYMin, blockYMax;
+  int fontAsc=FONTASCENT(pGC->font), fontDesc=FONTDESCENT(pGC->font);
+  
+  if (((WindowPtr) pDraw)->visibility != VisibilityFullyObscured)
+    {
+      TRACE_ENTER(NPTRC_TEXT,"NewportText");
+      TRACE(NPTRC_TEXT, ("pDraw.x:%d, .y:%d", pDraw->x, pDraw->y));
+      TRACE(NPTRC_TEXT,("x: %d, y:%d", xInit, y));
+      TRACE(NPTRC_TEXT,("font: asc:%d, desc:%d", fontAsc, fontDesc));
+
+      pScreen = pGC->pScreen;
+      pScrn = xf86Screens[pScreen->myNum];
+      pPriv = NEWPORTPTR (pScrn);
+      pNewportRegs = pPriv->pNewportRegs;
+	
+      prgnDst = pGC->pCompositeClip;
+      pbox = REGION_RECTS(prgnDst);
+      pboxLast = pbox + REGION_NUM_RECTS(prgnDst) -1;
+	
+      GetGlyphs(pGC->font, 
+		(unsigned long)count, 
+		(unsigned char *)chars,
+		(EightBit==1) ? 
+		Linear8Bit : 
+		( (FONTLASTROW(pGC->font) == 0) ? Linear16Bit : TwoD16Bit ), 
+		&n, 
+		charinfo);
+	
+      NewportWait (pNewportRegs);
+	
+      pNewportRegs->set.drawmode0 = (NPORT_DMODE0_DRAW |
+				     NPORT_DMODE0_BLOCK |
+				     NPORT_DMODE0_CHOST |
+				     NPORT_DMODE0_AHOST |
+				     NPORT_DMODE0_STOPX |
+				     NPORT_DMODE0_STOPY |
+				     NPORT_DMODE0_DOSETUP |
+				     NPORT_DMODE0_ZPENAB );
+	
+      if ( opaque ) {
+	pNewportRegs->set.drawmode0 |= NPORT_DMODE0_ZOPQ;
+	pNewportRegs->set.drawmode1 =
+	  (pNewportRegs->set.drawmode1 & 0x0fffffff) | NPORT_DMODE1_LOSRC;
+      } else 
+	pNewportRegs->set.drawmode1 =
+	  (pNewportRegs->set.drawmode1 & 0x0fffffff) | (pGC->alu << 28);
+      
+      pNewportRegs->set.wrmask = pGC->planemask | 0xfff;
+	
+      pNewportRegs->set.colorback =
+	(pGC->bgPixel & 0xff00ff00) |
+	((pGC->bgPixel & 0xff) << 16) | 
+	((pGC->bgPixel & 0xff0000) >> 16);    
+      dest = 
+	(pGC->fgPixel & 0xff00ff00) |
+	((pGC->fgPixel & 0xff) << 16) | 
+	((pGC->fgPixel & 0xff0000) >> 16);
+
+      pNewportRegs->set.hostrw0 = dest;
+      pNewportRegs->set.hostrw1 = dest;
+	
+      TRACE( NPTRC_TEXT, 
+	     ("Colors: bg:%x, fg:%x", 
+	      pNewportRegs->set.colorback, dest ));
+
+      while ( pbox <= pboxLast ) {
+	pbox = NewportSMaskSet( pNewportRegs, pbox, pboxLast );
+	    
+	x = xInit;
+	c = 0;
+	TRACE( NPTRC_TEXT, ( "n:%d", n));
+
+	while ( c < n ) {
+	  blockWidth = 0;
+	  blockNum = c;
+	  blockYMax = 0;
+	  blockYMin = fontAsc +fontDesc; 
+
+	  /* Get minimum ascent and maximum descent for the next characters fitting
+	     in the 32bit stipple */
+	  for( pci = charinfo[blockNum];
+	       blockNum<n && blockWidth +pci->metrics.characterWidth < 33;
+	       ++blockNum, 
+		 blockWidth+=pci->metrics.characterWidth, 
+		 pci = charinfo[blockNum]) 
+	    {
+	      if ( fontAsc -pci->metrics.ascent < blockYMin ) 
+		blockYMin = fontAsc -pci->metrics.ascent;
+	      if ( fontAsc +pci->metrics.descent > blockYMax )
+		blockYMax = fontAsc +pci->metrics.descent;
+	      TRACE( NPTRC_TEXT, ( "xMin:%d, fontAsc:%d, pciAsc:%d", blockYMin, fontAsc, pci->metrics.ascent ));
+	      TRACE( NPTRC_TEXT, ( "xMax:%d, fontAsc:%d, pciDesc:%d", blockYMax, fontAsc, pci->metrics.descent ));
+	      TRACE( NPTRC_TEXT, ( "leftSideBearing:%d, rightSideBearing:%d", 
+				   pci->metrics.leftSideBearing, pci->metrics.rightSideBearing ));
+	    }
+	  TRACE( NPTRC_TEXT, ("block:%d..%d, width:%d, yMin:%d, yMax:%d", c, blockNum, blockWidth, blockYMin, blockYMax )); 
+	  
+	  /* Fill the background in image mode */
+	  if (opaque) {
+	    TRACE( NPTRC_TEXT, ( "opaque: (%d,%d),(%d,%d)", 
+				 (pDraw->x +x), 
+				 (pDraw->y +y -fontAsc),
+				 (pDraw->x +x  +blockWidth -1),
+				 (pDraw->y +y +fontDesc) ));
+	    pNewportRegs->set.hostrw0 = pNewportRegs->set.colorback;
+	    pNewportRegs->set.hostrw1 = pNewportRegs->set.colorback;
+	    pNewportRegs->set.zpattern = 0xffffffff;
+	    NewportWait (pNewportRegs);
+	    pNewportRegs->set._setup = 1;
+	    pNewportRegs->set.xystarti = 
+	      ((pDraw->x +x) << 16) 
+	      | (pDraw->y +y -fontAsc);
+	    pNewportRegs->go.xyendi = 
+	      ((pDraw->x +x +blockWidth -1) << 16) 
+	      | (pDraw->y +y +fontDesc);
+	    pNewportRegs->set.hostrw0 = dest;
+	    pNewportRegs->set.hostrw1 = dest;
+	  }
+	  
+	  /* Print the characters */
+	  for( y1= blockYMin; y1 <= blockYMax; ++y1 ) {
+	    zPattern=0;
+	    for(c1=c, w1=0; c1 < blockNum; ++c1 ) {
+	      pci = charinfo[c1];
+	      if ( y1 >= fontAsc -pci->metrics.ascent &&
+		   y1 < fontAsc +pci->metrics.descent)
+		zPattern |= ( (unsigned long )
+			      NewportStippleGet( (unsigned int*) FONTGLYPHBITS(pglyphBase, pci), 
+						 GLYPHWIDTHPIXELS(pci), 
+						 GLYPHHEIGHTPIXELS(pci), 
+						 0, 
+						 0, 
+						 0, 
+						 y1 -fontAsc +pci->metrics.ascent,
+						 1) >> (w1 +pci->metrics.leftSideBearing));
+	      w1 += pci->metrics.characterWidth;
+	    }
+	  
+	    TRACE( NPTRC_TEXT, ( "block:%d..%d, x:%d, #x:%d, y1:%d, zPattern=%x", c, blockNum, x, blockWidth, y1, zPattern ));
+	    pNewportRegs->set.zpattern = zPattern; 
+	    NewportWait (pNewportRegs);
+	    pNewportRegs->set._setup = 1;
+	    pNewportRegs->set.xystarti = 
+	      ((pDraw->x +x) << 16) 
+	      | (pDraw->y +y -fontAsc +y1);
+	    pNewportRegs->go.xyendi = 
+	      ((pDraw->x +x +blockWidth -1) << 16) 
+	      | (pDraw->y +y -fontAsc +y1);
+	  }
+
+	  c = blockNum;
+	  x += blockWidth;
+	}
+      }
+    }
+  TRACE_EXIT(NPTRC_TEXT,"NewportText");
+  return x;
+}
+		       
+
+void NewportImageText8(DrawablePtr pDraw, 
+		       GC *pGC, 
+		       int x, 
+		       int y, 
+		       int count,
+		       char *chars)
+{
+  TRACE_ENTER(NPTRC_TEXT,"NewportImageText8");
+  NewportText( pDraw, pGC, x, y, count, chars, 1, 1 );
+  TRACE_EXIT(NPTRC_TEXT,"NewportImageText8");
+}
+
+int NewportPolyText8(DrawablePtr pDraw, 
+		     GC *pGC, 
+		     int x, 
+		     int y, 
+		     int count,
+		     char *chars)
+{
+  int ret;
+
+  TRACE_ENTER(NPTRC_TEXT,"NewportPolyText8");
+  ret=NewportText( pDraw, pGC, x, y, count, chars, 0, 1 );
+  TRACE_EXIT(NPTRC_TEXT,"NewportPolyText8");
+  return ret;
+}
+
+
+void NewportImageText16(DrawablePtr pDraw, 
+			GC *pGC, 
+			int x, 
+			int y, 
+			int count,
+			unsigned short *chars)
+{
+  TRACE_ENTER(NPTRC_TEXT,"NewportImageText16");
+  NewportText( pDraw, pGC, x, y, count, (char*) chars, 1, 0 );
+  TRACE_EXIT(NPTRC_TEXT,"NewportImageText16");
+}
+
+int NewportPolyText16(DrawablePtr pDraw, 
+		      GC *pGC, 
+		      int x, 
+		      int y, 
+		      int count,
+		      unsigned short *chars)
+{
+  int ret;
+
+  TRACE_ENTER(NPTRC_TEXT,"NewportPolyText16");
+  ret = NewportText( pDraw, pGC, x, y, count, (char*) chars, 0, 0 );
+  TRACE_EXIT(NPTRC_TEXT,"NewportPolyText16");
+  return ret;
+}
+
+
+
+
diff -NaurbB newport.shadow/newport_setspans.c newport.new/newport_setspans.c
--- newport.shadow/newport_setspans.c	Thu Jan  1 01:00:00 1970
+++ newport.new/newport_setspans.c	Wed Nov  5 05:20:32 2003
@@ -0,0 +1,159 @@
+/*
+ * Driver for the SGI Indy's Newport graphics card - Write Spans
+ * 
+ * (c) 2003      Frank Foerstemann <Foerstemann@web.de>
+ *
+ * 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 fur-
+ * nished 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, FIT-
+ * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+ * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall not
+ * be used in advertising or otherwise to promote the sale, use or other deal-
+ * ings in this Software without prior written authorization from the XFree86
+ * Project.
+ *
+ */
+
+#include "unistd.h"
+#include "X.h"
+#include "Xproto.h"
+#include "misc.h"
+#include "pixmapstr.h"
+#include "input.h"
+#include "font.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "dixfontstr.h"
+#include "fontstruct.h"
+#include "xf86.h"
+#include "xf86str.h"
+
+#include <newport.h>
+
+#include <newport_util.h>
+
+void
+NewportSetSpans (DrawablePtr pDraw,
+		 GCPtr pGC,
+		 char *pcharsrc,
+		 DDXPointPtr pptInit,
+		 int *pwidthInit, int nspans, int fSorted)
+{
+  ScreenPtr pScreen = pGC->pScreen;
+  ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+  NewportPtr pPriv = NEWPORTPTR (pScrn);
+  NewportRegsPtr pNewportRegs = pPriv->pNewportRegs;
+
+  TRACE_ENTER(NPTRC_SETSPANS, "NewportSetSpans");
+
+  if (((WindowPtr) pDraw)->visibility != VisibilityFullyObscured && nspans)
+    {
+      BoxPtr pbox, pboxLast, pboxStart;
+      RegionPtr prgnDst;
+      DDXPointPtr ppt = pptInit;
+      int *pwidth = pwidthInit;
+      int i, j;
+      int x1, y, x2, yMax;
+      CARD32 *psrcSpan;
+      CARD32 *psrc, dest;
+
+      yMax = (int) pDraw->y + (int) pDraw->height;
+      prgnDst = pGC->pCompositeClip;
+      pboxStart = REGION_RECTS(prgnDst);
+      pboxLast = pboxStart + REGION_NUM_RECTS(prgnDst) -1;
+
+      NewportWait (pNewportRegs);
+      pNewportRegs->set.drawmode0 = (NPORT_DMODE0_DRAW |
+				     NPORT_DMODE0_SPAN | 
+				     NPORT_DMODE0_CHOST |
+				     NPORT_DMODE0_AHOST);
+      pNewportRegs->set.drawmode1 =
+	(pNewportRegs->set.drawmode1 & 0x0fffffff) | (pGC->alu << 28);
+      pNewportRegs->set.wrmask = pGC->planemask | 0xfff;
+
+      pNewportRegs->set.colorback =
+	(pGC->bgPixel & 0xff000000) |
+	((pGC->bgPixel & 0xff) << 16) | 
+	(pGC->bgPixel & 0xff00) | 
+	((pGC->bgPixel & 0xff0000) >> 16);
+
+      pNewportRegs->cset.clipmode &= NPORT_CMODE_CMSK;
+
+      TRACE(NPTRC_SETSPANS, ("Extents in Region : %d", REGION_NUM_RECTS(pGC->pCompositeClip)));
+      TRACE(NPTRC_SETSPANS, ("x     = %d", pGC->patOrg.x));
+      TRACE(NPTRC_SETSPANS, ("y     = %d", pGC->patOrg.y));
+
+      ppt = pptInit;
+      pwidth = pwidthInit;
+      psrcSpan = (CARD32*) pcharsrc;
+      i = nspans;
+      while (i--)
+	{
+	  y = ppt->y;
+	  x1 = ppt->x;
+	  x2 = ppt->x + *pwidth;
+	  TRACE(NPTRC_SETSPANS, ("orig: x1=%d, x2=%d, y=%d", x1, x2, y));
+	  for(pbox=pboxStart; pbox<=pboxLast; ++pbox) {
+	    TRACE(NPTRC_SETSPANS, ("pbox: x1=%d, x2=%d, y1=%d, y2=%d", 
+				   pbox->x1, pbox->x2, pbox->y1, pbox->y2));
+	    if( pbox->y1<= y && y < pbox->y2 && 
+		(x1 < pbox->x2 || x2 >= pbox->x1) ) {
+	      psrc = psrcSpan;
+	      if ( x1 < pbox->x1 ) {
+		psrc += pbox->x1 -x1;
+		x1=pbox->x1;
+	      }
+	      if ( x2 > pbox->x2 ) x2=pbox->x2;
+	      
+	      TRACE(NPTRC_SETSPANS, ("mod: x1=%d, x2=%d", x1, x2));
+	      
+	      NewportWait (pNewportRegs);
+	      pNewportRegs->set.xystarti = (x1 << 16) | y;
+	      pNewportRegs->set.xyendi = ((x2-1) << 16) | y;
+	      pNewportRegs->set._setup = 1;
+	      
+	      
+	      for (j = x2 -x1; j > 0; j--, psrc++)
+		{
+		  dest =
+		    (*psrc & 0xff00ff00) |
+		    ((*psrc & 0xff) << 16) | 
+		    (( *psrc & 0xff0000) >> 16);
+		  
+		  TRACE2(NPTRC_SETSPANS, 2, ("s=%x, *src=%x->%x",psrc, *psrc, dest));
+		  
+		  
+		  pNewportRegs->go.hostrw0 = dest;
+		}
+
+	      /*
+		Restore the original values for next pbox
+	      */
+	      y = ppt->y;
+	      x1 = ppt->x;
+	      x2 = ppt->x + *pwidth;
+	    }
+	  }
+	  psrcSpan += *pwidth;
+	  pwidth++;
+	  ppt++;
+	}
+    }
+  TRACE_EXIT(NPTRC_SETSPANS, "NewportSetSpans");
+}
+
diff -NaurbB newport.shadow/newport_shadow.c newport.new/newport_shadow.c
--- newport.shadow/newport_shadow.c	Sat Aug 17 21:59:51 2002
+++ newport.new/newport_shadow.c	Sat Aug 16 15:35:02 2003
@@ -18,7 +18,7 @@
 #define RA8_BYTE_SHIFT  2 	/* 4 Pixels on each burst, so divide ShadowPitch by 4 */
 #define RA8_MASK        0xffc   /* move to 4 byte boundary   */
 
-	TRACE_ENTER("NewportRefreshArea8");
+	TRACE_ENTER(NPTRC_SHADOW, "NewportRefreshArea8");
 	NewportWait(pNewportRegs);
 	pNewportRegs->set.drawmode0 = (NPORT_DMODE0_DRAW | 
 					NPORT_DMODE0_BLOCK | 
@@ -44,7 +44,7 @@
 		}
 		pbox++;
 	}
-	TRACE_EXIT("NewportRefreshArea8");
+	TRACE_EXIT(NPTRC_SHADOW, "NewportRefreshArea8");
 }
 
 
@@ -57,7 +57,7 @@
 	NewportPtr pNewport = NEWPORTPTR(pScrn);
 	NewportRegsPtr pNewportRegs = pNewport->pNewportRegs;
 
-	TRACE_ENTER("NewportRefreshArea24");
+	TRACE_ENTER(NPTRC_SHADOW, "NewportRefreshArea24");
 	NewportWait(pNewportRegs);
 
 	/* block transfers */
@@ -86,6 +86,6 @@
  		}
  		pbox++;
  	}
-	TRACE_EXIT("NewportRefreshArea24");
+	TRACE_EXIT(NPTRC_SHADOW, "NewportRefreshArea24");
 }
 
diff -NaurbB newport.shadow/newport_trace.h newport.new/newport_trace.h
--- newport.shadow/newport_trace.h	Thu Jan  1 01:00:00 1970
+++ newport.new/newport_trace.h	Sun Jul  6 05:05:18 2003
@@ -0,0 +1,18 @@
+#ifndef __NEWPORT_TRACE_H__
+#define __NEWPORT_TRACE_H__
+
+
+void NewportTraceInit( NewportPtr *np ):
+void NewportTrace(const char *s, ... );
+
+#define TRACE_ENTER(np, fct, str)       (np->traceEnter) ? np->traceEnter(fct,str)
+#define TRACE_LEAVE(np, fct, str)       (np->traceEnter) ? np->traceLeave(fct,str)
+#define TRACE(np, fct, __x)             (np->trace) ? np->trace(fct,__x)
+
+
+
+trcLevel++;NewportTrace("->"str"()",NULL);trcLevel++
+#define TRACE_EXIT(str)        trcLevel--;NewportTrace("<-"str"()",NULL);trcLevel--
+#define TRACE(__x)             NewportTrace __x
+
+#endif
diff -NaurbB newport.shadow/newport_util.c newport.new/newport_util.c
--- newport.shadow/newport_util.c	Thu Jan  1 01:00:00 1970
+++ newport.new/newport_util.c	Mon Nov  3 06:51:30 2003
@@ -0,0 +1,316 @@
+/*
+ * Driver for the SGI Indy's Newport graphics card - Common Functions
+ * 
+ * (c) 2003      Frank Foerstemann <Foerstemann@web.de>
+ *
+ * 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 fur-
+ * nished 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, FIT-
+ * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+ * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall not
+ * be used in advertising or otherwise to promote the sale, use or other deal-
+ * ings in this Software without prior written authorization from the XFree86
+ * Project.
+ *
+ */
+
+#include <time.h>
+#include <newport.h>
+
+BoxPtr NewportSMaskSet( NewportRegsPtr pNewportRegs, BoxPtr pbox, BoxPtr pboxLast ) {
+    TRACE_ENTER(NPTRC_MISC,"NewportSMaskSet");
+
+    NewportWait (pNewportRegs);
+    pNewportRegs->cset.clipmode &= NPORT_CMODE_CMSK;
+    TRACE(NPTRC_MISC, ("smask1: (%d,%d),(%d,%d)", pbox->x1, pbox->y1, pbox->x2, pbox->y2));
+    pNewportRegs->cset.smask1x = ((pbox->x1 +NPORT_SMASKXOFF) << 16) | 
+	(pbox->x2 +NPORT_SMASKXOFF-1);
+    pNewportRegs->cset.smask1y = ((pbox->y1 +NPORT_SMASKYOFF) << 16) | 
+	(pbox->y2 +NPORT_SMASKYOFF-1);
+    pNewportRegs->cset.clipmode |= NPORT_CMODE_SM1;
+    pbox++;
+    
+    if ( pbox <= pboxLast ) {
+	TRACE(NPTRC_MISC,("smask2: (%d,%d),(%d,%d)", pbox->x1, pbox->y1, pbox->x2, pbox->y2));
+	pNewportRegs->cset.smask2x = ((pbox->x1 +NPORT_SMASKXOFF) << 16) | 
+	    (pbox->x2 +NPORT_SMASKXOFF-1);
+	pNewportRegs->cset.smask2y = ((pbox->y1 +NPORT_SMASKYOFF) << 16) | 
+	    (pbox->y2 +NPORT_SMASKYOFF-1);
+	pNewportRegs->cset.clipmode |= NPORT_CMODE_SM2;
+	pbox++;
+
+	if ( pbox <= pboxLast ) {
+	    TRACE(NPTRC_MISC,("smask3: (%d,%d),(%d,%d)", pbox->x1, pbox->y1, pbox->x2, pbox->y2));
+	    pNewportRegs->cset.smask3x = ((pbox->x1 +NPORT_SMASKXOFF) << 16) | 
+		(pbox->x2 +NPORT_SMASKXOFF-1);
+	    pNewportRegs->cset.smask3y = ((pbox->y1 +NPORT_SMASKYOFF) << 16) | 
+		(pbox->y2 +NPORT_SMASKYOFF-1);
+	    pNewportRegs->cset.clipmode |= NPORT_CMODE_SM3;
+	    pbox++;
+	    
+	    if ( pbox <= pboxLast ) {
+		TRACE(NPTRC_MISC,("smask4: (%d,%d),(%d,%d)", pbox->x1, pbox->y1, pbox->x2, pbox->y2));
+		pNewportRegs->cset.smask4x = ((pbox->x1 +NPORT_SMASKXOFF) << 16) | 
+		    (pbox->x2 +NPORT_SMASKXOFF-1);
+		pNewportRegs->cset.smask4y = ((pbox->y1 +NPORT_SMASKYOFF) << 16) | 
+		    (pbox->y2 +NPORT_SMASKYOFF-1);
+		pNewportRegs->cset.clipmode |= NPORT_CMODE_SM4;
+		pbox++;
+	    }
+	}
+    }
+    TRACE_EXIT(NPTRC_MISC,"NewportSMaskSet");
+    return pbox;
+}
+
+
+
+int NewportStippleGet(unsigned int *stDataInit,
+		      int stWidth,
+		      int stHeight,
+		      int patOrgX,
+		      int patOrgY,
+		      int x,
+		      int y,
+		      int noRepl)
+{
+    unsigned int *stData = stDataInit;
+    unsigned int stTmp, stipple;
+    int xOffset;
+
+    TRACE_ENTER(NPTRC_MISC,"NewportStippleGet");
+    TRACE(NPTRC_MISC,("x:%d, y:%d", x, y));
+    TRACE(NPTRC_MISC,("st.w:%d, st.h:%d", stWidth, stHeight));
+
+    if ( stWidth <= 32 ) {
+	stData += ((y -patOrgY) % stHeight);
+	xOffset = (x -patOrgX) % stWidth;
+	if ( noRepl == 0 )
+	  noRepl  = 33 / stWidth;
+	
+	TRACE(NPTRC_MISC,("xOffset: %d", xOffset));
+	stTmp = *stData & (0xffffffff << (32 -stWidth));
+	stipple = stTmp;
+	TRACE(NPTRC_MISC,("data: %x, stipple: %x", *stData, stipple));
+	for( ; noRepl >1; noRepl-- ) {
+	    stipple = (stipple >> stWidth) | stTmp;
+	    TRACE(NPTRC_MISC, ("data: %x, stipple: %x", stTmp, stipple));
+	}
+    
+	TRACE(NPTRC_MISC,("stipple: %x -> %x", *stData, stipple));
+	TRACE_EXIT(NPTRC_MISC,"NewportStippleGet");
+	return (xOffset) ? (stipple << xOffset) | (stipple >> (32-xOffset)) : stipple;
+    } else {
+	int i, stStart, xPad;
+	int bStWidth = 1 +( stWidth -1 )/32;
+
+	stData += bStWidth *((y -patOrgY) % stHeight);
+	xOffset = ( x -patOrgX ) % stWidth;
+	stStart = (( x -patOrgX ) % stWidth ) / 32;
+	xPad = (( x -patOrgX +32) % stWidth )  % 32;
+	stipple = stData[stStart];
+
+	for(i=0; i < bStWidth; i++) {
+	    TRACE(NPTRC_MISC,("stData%d: %x", i, stData[i]));
+	}
+	TRACE(NPTRC_MISC,("bStWidth=%x, xOffset=%x, stStart=%x, xPad=%x", bStWidth, xOffset, stStart, xPad));
+
+	TRACE(NPTRC_MISC,("stipple1: %x", stipple ));
+	
+	if ( xPad ) {
+	    stStart = ( stStart +1 ) % bStWidth;
+	    stipple = (stipple << xPad) |
+		(stData[stStart] >> ( 32 -xPad));
+	    TRACE(NPTRC_MISC,("stipple2: %x", stipple ));
+	    if ( (stStart == bStWidth -1) && (xPad -(stWidth % 32) > 0) ) {
+		stStart = 0;
+		xPad -= (stWidth %32);
+		stipple &= 0xffffffff << xPad;
+		TRACE(NPTRC_MISC,("stipple3: %x, %x", stipple, 0xffffffff << xPad ));
+		stipple |= stData[stStart] >> (32-xPad);
+		TRACE(NPTRC_MISC,("stipple4: %x", stipple ));
+	    }
+	}
+	TRACE_EXIT(NPTRC_MISC,"NewportStippleGet");
+	return  stipple;;
+    }
+}    
+
+
+/*
+  Global variables to store the moving direction needed
+  for sorting the boxes 
+*/
+int NewportBoxSortXMove, NewportBoxSortYMove;
+
+/*
+  Box comparison function for qsort. Shifts the last boxes  
+  in move direction to the beginning to prevent overwriting
+  be the move of other boxes.
+*/
+int NewportBoxSort(const void* r1, const void* r2) {
+  if ( NewportBoxSortXMove >= 0 && NewportBoxSortYMove >= 0 ) {
+    if ( ((BoxPtr) r1)->y2 > ((BoxPtr) r2)->y2 ||
+	 (((BoxPtr) r1)->y2 == ((BoxPtr) r2)->y2 && 
+	  ((BoxPtr) r1)->x2 > ((BoxPtr) r2)->x2 ) )
+      return -1;
+    else
+      return 1;
+  }
+
+  if ( NewportBoxSortXMove <= 0 && NewportBoxSortYMove <= 0 ) {
+    if ( ((BoxPtr) r1)->y1 < ((BoxPtr) r2)->y1 ||
+	 (((BoxPtr) r1)->y1 == ((BoxPtr) r2)->y1 && 
+	  ((BoxPtr) r1)->x1 < ((BoxPtr) r2)->x1 ) )
+      return -1;
+    else
+      return 1;
+  }
+
+  if ( NewportBoxSortXMove <= 0 && NewportBoxSortYMove >= 0 ) {
+    if ( ((BoxPtr) r1)->y2 > ((BoxPtr) r2)->y2 ||
+	 (((BoxPtr) r1)->y2 == ((BoxPtr) r2)->y2 && 
+	  ((BoxPtr) r1)->x1 < ((BoxPtr) r2)->x1 ) )
+      return -1;
+    else
+      return 1;
+  }
+
+  if ( NewportBoxSortXMove >= 0 && NewportBoxSortYMove <= 0 ) {
+    if ( ((BoxPtr) r1)->y1 < ((BoxPtr) r2)->y1 ||
+	 (((BoxPtr) r1)->y1 == ((BoxPtr) r2)->y1 && 
+	  ((BoxPtr) r1)->x2 < ((BoxPtr) r2)->x2 ) )
+      return -1;
+    else
+      return 1;
+  }
+
+  return 0;
+}
+
+
+#ifdef DEBUG 
+
+unsigned long newportTrcFilter = 0;
+int newportTrcLevel = 0;
+int newportTrcInd = 0;
+
+/* Trace output */
+void NewportTrace(const char *s, ...) 
+{
+  va_list args;
+  time_t t;
+  char msg[128];
+
+  va_start(args, s);
+  t = time(0);
+  strftime( msg, 128, "NP %H%M%S", localtime(&t));
+  strncat( msg, "                          ", newportTrcInd);
+  strncat( msg, s, 128 );
+  strncat( msg, "\n", 128 );
+  VErrorF(msg,args);
+}
+
+void NewportDumpPixmap( PixmapPtr	pPix )
+{
+  unsigned int *pw;
+  unsigned int *psrc;
+  unsigned int colors[96];
+  char         line[81];
+  unsigned int numCol=0;
+  int i, j, k, w=81, overflow=0;
+
+  if ( newportTrcLevel <= 2 ) return;
+ 
+  NewportTrace( "pPixmap: 0x%x\n", pPix);
+  NewportTrace( "%d wide %d high %d deep", pPix->drawable.width, pPix->drawable.height, pPix->drawable.depth);
+  
+  pw = (unsigned int *) pPix->devPrivate.ptr;
+  psrc = pw;
+  if ( pPix->drawable.width < w ) w =  pPix->drawable.width;
+  for ( i = 0; i < pPix->drawable.height; ++i ) {
+    for(j = 0; j < w; j++) {
+      for (k=0; k<numCol && colors[k]!=*psrc; k++);
+      if ( k==numCol ) {
+	if ( k < 96 ) {
+	  colors[numCol++]=*psrc;
+	} else {
+	  k--;
+	  overflow=1;
+	}
+      }
+      line[j]=(char) 33+k;
+      psrc++;
+    }
+    line[j]=0;
+    NewportTrace( "%d: %s\n", i, line);
+  }
+  NewportTrace( "Colors:");
+  for (k=0; k<numCol; k++)
+    NewportTrace( " %c=%x", (char) 33+k, colors[k]);
+  NewportTrace( "\n");
+  if ( overflow )
+    NewportTrace( "Warning: More than 96 colors. Colormap overflow!\n");
+}
+
+void NewportDumpGC( GCPtr pGC ) 
+{
+  BoxPtr pbox, pboxLast;
+  RegionPtr prgnDst;
+
+
+  if ( newportTrcLevel <= 2 ) return;
+
+  prgnDst = pGC->pCompositeClip;
+  pbox = REGION_RECTS(prgnDst);
+  pboxLast = pbox + REGION_NUM_RECTS(prgnDst) -1;
+
+  NewportTrace( "patOrg  : x:%d y:%d", pGC->patOrg.x,  pGC->patOrg.y);
+  NewportTrace( "clipOrg : x:%d y:%d", pGC->clipOrg.x, pGC->clipOrg.y);
+  NewportTrace( "fg/bg   : %x, %x", pGC->fgPixel, pGC->bgPixel);
+  NewportTrace( "alu     : %x", pGC->alu);
+  NewportTrace( "planemsk: %x", pGC->planemask);
+  NewportTrace( "fillstyl: %x", pGC->fillStyle);
+
+  while ( pbox <= pboxLast ) {
+    NewportTrace( "region: (%d,%d),(%d,%d)", pbox->x1, pbox->y1, pbox->x2, pbox->y2);
+    pbox++;
+  }
+
+}
+
+#endif /* DEBUG */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -NaurbB newport.shadow/newport_util.h newport.new/newport_util.h
--- newport.shadow/newport_util.h	Thu Jan  1 01:00:00 1970
+++ newport.new/newport_util.h	Tue Jul 29 06:25:04 2003
@@ -0,0 +1,21 @@
+#ifndef NEWPORT_UTIL_H
+#define NEWPORT_UTIL_H
+
+BoxPtr NewportSMaskSet( NewportRegsPtr pNewportRegs, 
+		       BoxPtr pbox, 
+		       BoxPtr pboxLast );
+
+int NewportStippleGet(unsigned int *stData,
+		      int stWidth,
+		      int stHeight,
+		      int patOrgX,
+		      int patOrgY,
+		      int x,
+		      int y,
+		      int noRepl);
+
+extern int NewportBoxSortXMove, NewportBoxSortYMove;
+
+extern int NewportBoxSort(const void* r1, const void* r2);
+
+#endif
diff -NaurbB newport.shadow/newport_window.c newport.new/newport_window.c
--- newport.shadow/newport_window.c	Thu Jan  1 01:00:00 1970
+++ newport.new/newport_window.c	Sat Nov  1 15:40:25 2003
@@ -0,0 +1,208 @@
+/*
+ * Driver for the SGI Indy's Newport graphics card - Window Functions
+ * 
+ * (c) 2003      Frank Foerstemann <Foerstemann@web.de>
+ *
+ * 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 fur-
+ * nished 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, FIT-
+ * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+ * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
+ * NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the XFree86 Project shall not
+ * be used in advertising or otherwise to promote the sale, use or other deal-
+ * ings in this Software without prior written authorization from the XFree86
+ * Project.
+ *
+ */
+
+#include "X.h"
+#include "Xproto.h"
+#include "misc.h"
+#include "pixmapstr.h"
+#include "input.h"
+#include "font.h"
+#include "mi.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "dixfontstr.h"
+#include "fontstruct.h"
+#include "xf86.h"
+#include "xf86str.h"
+
+#include <newport.h>
+#include <newport_util.h>
+
+#include <newport_window.h>
+
+Bool
+NewportCreateWindow(WindowPtr pWin)
+{
+    TRACE( NPTRC_WINDOW, ("NewportCreateWindow"));
+    return TRUE;
+}
+
+Bool
+NewportDestroyWindow(WindowPtr pWin)
+{
+    TRACE( NPTRC_WINDOW, ("NewportDestroyWindow"));
+    return TRUE;
+}
+
+Bool
+NewportMapWindow(WindowPtr pWindow)
+{
+    TRACE( NPTRC_WINDOW, ("NewportMapWindow"));
+    return TRUE;
+}
+
+Bool
+NewportPositionWindow(WindowPtr pWin, int x, int y)
+{
+    TRACE( NPTRC_WINDOW, ("NewportPositionWindow: x=%d, y=%d",x,y));
+    return TRUE;
+}
+
+Bool
+NewportUnmapWindow(WindowPtr pWindow)
+{
+    TRACE( NPTRC_WINDOW, ("NewportUnmapWindow"));
+    return TRUE;
+}
+
+Bool
+NewportChangeWindowAttributes(WindowPtr pWindow, unsigned long mask)
+{
+    TRACE( NPTRC_WINDOW, ("NewportChangeWindowAttributes: mask=%x",mask));
+    return TRUE;
+}
+
+void
+NewportCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc )
+{
+    ScreenPtr pScreen = pWindow->drawable.pScreen;
+    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    NewportPtr  pPriv = NEWPORTPTR (pScrn);
+    NewportRegsPtr pNewportRegs = pPriv->pNewportRegs;
+    RegionRec rgnDst;
+    BoxPtr pbox, pboxSort;
+    int x1, x2, y1, y2;
+    int i, nbox;
+    
+    TRACE_ENTER( NPTRC_WINDOW, "NewportCopyWindow");
+
+    REGION_INIT(pScreen, &rgnDst, NullBox, 0);
+    
+    NewportBoxSortXMove = pWindow->drawable.x -ptOldOrg.x;
+    NewportBoxSortYMove = pWindow->drawable.y -ptOldOrg.y;
+    REGION_TRANSLATE(pScreen, prgnSrc, NewportBoxSortXMove, NewportBoxSortYMove);
+    REGION_INTERSECT(pScreen, &rgnDst, &pWindow->borderClip, prgnSrc);
+    
+    pbox = REGION_RECTS(&rgnDst);
+    nbox = REGION_NUM_RECTS(&rgnDst);
+
+    /* 
+       If there's more than on box, they must be sorted to prevent the 
+       first boxes to overwrite the contents of the others 
+    */
+    if ( nbox > 1 ) {
+      if(!(pboxSort = (BoxPtr)ALLOCATE_LOCAL(nbox * sizeof(struct _Box))))
+	return;
+      for( i=0; i<nbox; i++ ) {
+	TRACE( NPTRC_WINDOW, ("box1 %d: (%d,%d)(%d,%d)", 
+	       i, pbox[i].x1, pbox[i].y1, pbox[i].x2, pbox[i].y2 ));
+      }
+      memcpy( pboxSort, pbox, nbox * sizeof(struct _Box));
+      qsort( pboxSort, nbox, sizeof(struct _Box), NewportBoxSort );
+      for( i=0; i<nbox; i++ ) {
+	TRACE( NPTRC_WINDOW, ("box2 %d: (%d,%d)(%d,%d)", 
+	       i, pboxSort[i].x1, pboxSort[i].y1, pboxSort[i].x2, pboxSort[i].y2 ));
+      }
+      pbox = pboxSort;
+    }
+
+    NewportWait (pNewportRegs);
+
+    pNewportRegs->set.drawmode0 = (NPORT_DMODE0_S2S |
+				   NPORT_DMODE0_BLOCK |
+				   NPORT_DMODE0_CHOST |
+				   NPORT_DMODE0_AHOST |
+				   NPORT_DMODE0_STOPX |
+				   NPORT_DMODE0_STOPY |
+				   NPORT_DMODE0_DOSETUP );
+
+    pNewportRegs->set.drawmode1 &= ~(NPORT_DMODE1_LOMASK |
+				     NPORT_DMODE1_DFMASK | 
+				     NPORT_DMODE1_SFMASK |
+				     NPORT_DMODE1_BBENAB );
+    pNewportRegs->set.drawmode1 |= NPORT_DMODE1_LOSRC;
+    pNewportRegs->cset.clipmode &= NPORT_CMODE_CMSK;
+
+    for (i = nbox; --i >= 0; pbox++) {
+	if ( NewportBoxSortXMove <= 0) {
+	    x1 = pbox->x1 -NewportBoxSortXMove;
+	    x2 = pbox->x2 -NewportBoxSortXMove -1;
+	} else {
+	    x1 = pbox->x2 -NewportBoxSortXMove -1;
+	    x2 = pbox->x1 -NewportBoxSortXMove;
+	}
+	if ( NewportBoxSortYMove <= 0 ) {
+	    y1 = pbox->y1 -NewportBoxSortYMove;
+	    y2 = pbox->y2 -NewportBoxSortYMove -1;
+	} else {
+	    y1 = pbox->y2 -NewportBoxSortYMove -1;
+	    y2 = pbox->y1 -NewportBoxSortYMove;
+	}
+
+	TRACE( NPTRC_WINDOW, ("dest: (%d,%d),(%d,%d) by (%d,%d)", 
+	       x1, y1, x2, y2, NewportBoxSortXMove, NewportBoxSortYMove));
+	
+	NewportWait (pNewportRegs);
+	pNewportRegs->set.xystarti = ((x1 & 0xffff) << 16) | (y1 & 0xffff);
+	pNewportRegs->set.xyendi = ((x2 & 0xffff) << 16) | (y2 & 0xffff);
+	pNewportRegs->go.xymove = ((NewportBoxSortXMove & 0xffff) << 16) | (NewportBoxSortYMove & 0xffff);
+    }    
+    NewportWait (pNewportRegs);
+
+    if ( nbox > 1 ) {
+      DEALLOCATE_LOCAL(pboxSort);
+    }
+
+    TRACE_EXIT( NPTRC_WINDOW, "NewportCopyWindow");
+}
+
+void
+NewportQueryBestSize (int class, 
+		      unsigned short *width, unsigned short *height,
+		      ScreenPtr pScreen)
+{
+    TRACE_ENTER( NPTRC_WINDOW, "NewportQueryBestSize");
+    
+    switch (class) {
+      case CursorShape:
+	*width = 32;
+	*height = 32;
+	break;
+      case TileShape:
+	break;
+      case StippleShape:
+	if ( *width < 17 )
+	    *width = 17;
+	else if ( *width > 32 )
+	    *width = 32;
+    }
+
+    TRACE_EXIT( NPTRC_WINDOW, "NewportQueryBestSize");
+}
diff -NaurbB newport.shadow/newport_window.h newport.new/newport_window.h
--- newport.shadow/newport_window.h	Thu Jan  1 01:00:00 1970
+++ newport.new/newport_window.h	Sat Jan  4 05:21:30 2003
@@ -0,0 +1,27 @@
+#ifndef __NEWPORT_WINDOW_H
+#define __NEWPORT_WINDOW_H
+
+PixmapPtr
+NewportCreatePixmap (ScreenPtr pScreen, int width, int height, int depth);
+
+Bool NewportDestroyPixmap (PixmapPtr pPixmap);
+
+Bool NewportCreateWindow(WindowPtr pWin);
+
+Bool NewportDestroyWindow(WindowPtr pWin);
+
+Bool NewportMapWindow(WindowPtr pWindow);
+
+Bool NewportPositionWindow(WindowPtr pWin, int x, int y);
+
+Bool NewportChangeWindowAttributes(WindowPtr pWin, unsigned long mask);
+
+Bool NewportUnmapWindow(WindowPtr pWindow);
+
+void NewportCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc );
+
+void NewportQueryBestSize (int class, 
+			   unsigned short *width, unsigned short *height,
+			   ScreenPtr pScreen);
+
+#endif
diff -NaurbB newport.shadow/sgimc.h newport.new/sgimc.h
--- newport.shadow/sgimc.h	Fri Aug 16 22:42:05 2002
+++ newport.new/sgimc.h	Thu Jan  1 01:00:00 1970
@@ -1,228 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * sgimc.h: Definitions for memory controller hardware found on
- *          SGI IP20, IP22, IP26, and IP28 machines.
- *
- * Copyright (C) 1996 David S. Miller (dm@engr.sgi.com)
- * Copyright (C) 1999 Ralf Baechle
- * Copyright (C) 1999 Silicon Graphics, Inc.
- */
-#ifndef _ASM_SGI_SGIMC_H
-#define _ASM_SGI_SGIMC_H
-
-struct sgimc_misc_ctrl {
-	unsigned int _unused1;
-	volatile unsigned int cpuctrl0;     /* CPU control register 0, readwrite */
-#define SGIMC_CCTRL0_REFS         0x0000000f /* REFS mask */
-#define SGIMC_CCTRL0_EREFRESH     0x00000010 /* Memory refresh enable */
-#define SGIMC_CCTRL0_EPERRGIO     0x00000020 /* GIO parity error enable */
-#define SGIMC_CCTRL0_EPERRMEM     0x00000040 /* Main mem parity error enable */
-#define SGIMC_CCTRL0_EPERRCPU     0x00000080 /* CPU bus parity error enable */
-#define SGIMC_CCTRL0_WDOG         0x00000100 /* Watchdog timer enable */
-#define SGIMC_CCTRL0_SYSINIT      0x00000200 /* System init bit */
-#define SGIMC_CCTRL0_GFXRESET     0x00000400 /* Graphics interface reset */
-#define SGIMC_CCTRL0_EISALOCK     0x00000800 /* Lock CPU from memory for EISA */
-#define SGIMC_CCTRL0_EPERRSCMD    0x00001000 /* SysCMD bus parity error enable */
-#define SGIMC_CCTRL0_IENAB        0x00002000 /* Allow interrupts from MC */
-#define SGIMC_CCTRL0_ESNOOP       0x00004000 /* Snooping I/O enable */
-#define SGIMC_CCTRL0_EPROMWR      0x00008000 /* Prom writes from cpu enable */
-#define SGIMC_CCTRL0_WRESETPMEM   0x00010000 /* Perform warm reset, preserves mem */
-#define SGIMC_CCTRL0_LENDIAN      0x00020000 /* Put MC in little-endian mode */
-#define SGIMC_CCTRL0_WRESETDMEM   0x00040000 /* Warm reset, destroys mem contents */
-#define SGIMC_CCTRL0_CMEMBADPAR   0x02000000 /* Generate bad perr from cpu to mem */
-#define SGIMC_CCTRL0_R4KNOCHKPARR 0x04000000 /* Don't chk parity on mem data reads */
-#define SGIMC_CCTRL0_GIOBTOB      0x08000000 /* Allow GIO back to back writes */
-
-	unsigned int _unused2;
-	volatile unsigned int cpuctrl1;     /* CPU control register 1, readwrite */
-#define SGIMC_CCTRL1_EGIOTIMEO    0x00000010 /* GIO bus timeout enable */
-#define SGIMC_CCTRL1_FIXEDEHPC    0x00001000 /* Fixed HPC endianness */
-#define SGIMC_CCTRL1_LITTLEHPC    0x00002000 /* Little endian HPC */
-#define SGIMC_CCTRL1_FIXEDEEXP0   0x00004000 /* Fixed EXP0 endianness */
-#define SGIMC_CCTRL1_LITTLEEXP0   0x00008000 /* Little endian EXP0 */
-#define SGIMC_CCTRL1_FIXEDEEXP1   0x00010000 /* Fixed EXP1 endianness */
-#define SGIMC_CCTRL1_LITTLEEXP1   0x00020000 /* Little endian EXP1 */
-
-	unsigned int _unused3;
-	volatile unsigned int watchdogt;    /* Watchdog reg rdonly, write clears */
-
-	unsigned int _unused4;
-	volatile unsigned int systemid;     /* MC system ID register, readonly */
-#define SGIMC_SYSID_MASKREV       0x0000000f /* Revision of MC controller */
-#define SGIMC_SYSID_EPRESENT      0x00000010 /* Indicates presence of EISA bus */
-
-	unsigned int _unused5[3];
-	volatile unsigned int divider;      /* Divider reg for RPSS */
-
-	unsigned int _unused6;
-	volatile unsigned char eeprom;       /* EEPROM byte reg for r4k */
-#define SGIMC_EEPROM_PRE          0x00000001 /* eeprom chip PRE pin assertion */
-#define SGIMC_EEPROM_CSEL         0x00000002 /* Active high, eeprom chip select */
-#define SGIMC_EEPROM_SECLOCK      0x00000004 /* EEPROM serial clock */
-#define SGIMC_EEPROM_SDATAO       0x00000008 /* Serial EEPROM data-out */
-#define SGIMC_EEPROM_SDATAI       0x00000010 /* Serial EEPROM data-in */
-
-	unsigned char _unused7[3];
-	unsigned int _unused8[3];
-	volatile unsigned short rcntpre;     /* Preload refresh counter */
-
-	unsigned short _unused9;
-	unsigned int _unused9a;
-	volatile unsigned short rcounter;    /* Readonly refresh counter */
-
-	unsigned short _unused10;
-	unsigned int _unused11[13];
-	volatile unsigned int gioparm;      /* Parameter word for GIO64 */
-#define SGIMC_GIOPARM_HPC64       0x00000001 /* HPC talks to GIO using 64-bits */
-#define SGIMC_GIOPARM_GFX64       0x00000002 /* GFX talks to GIO using 64-bits */
-#define SGIMC_GIOPARM_EXP064      0x00000004 /* EXP(slot0) talks using 64-bits */
-#define SGIMC_GIOPARM_EXP164      0x00000008 /* EXP(slot1) talks using 64-bits */
-#define SGIMC_GIOPARM_EISA64      0x00000010 /* EISA bus talks 64-bits to GIO */
-#define SGIMC_GIOPARM_HPC264      0x00000020 /* 2nd HPX talks 64-bits to GIO */
-#define SGIMC_GIOPARM_RTIMEGFX    0x00000040 /* GFX device has realtime attr */
-#define SGIMC_GIOPARM_RTIMEEXP0   0x00000080 /* EXP(slot0) has realtime attr */
-#define SGIMC_GIOPARM_RTIMEEXP1   0x00000100 /* EXP(slot1) has realtime attr */
-#define SGIMC_GIOPARM_MASTEREISA  0x00000200 /* EISA bus can act as bus master */
-#define SGIMC_GIOPARM_ONEBUS      0x00000400 /* Exists one GIO64 pipelined bus */
-#define SGIMC_GIOPARM_MASTERGFX   0x00000800 /* GFX can act as a bus master */
-#define SGIMC_GIOPARM_MASTEREXP0  0x00001000 /* EXP(slot0) can bus master */
-#define SGIMC_GIOPARM_MASTEREXP1  0x00002000 /* EXP(slot1) can bus master */
-#define SGIMC_GIOPARM_PLINEEXP0   0x00004000 /* EXP(slot0) has pipeline attr */
-#define SGIMC_GIOPARM_PLINEEXP1   0x00008000 /* EXP(slot1) has pipeline attr */
-
-	unsigned int _unused13;
-	volatile unsigned short cputp;       /* CPU bus arb time period */
-
-	unsigned short _unused14;
-	unsigned int _unused15[3];
-	volatile unsigned short lbursttp;    /* Time period for long bursts */
-
-	unsigned short _unused16;
-	unsigned int _unused17[9];
-	volatile unsigned int mconfig0;     /* Memory config register zero */
-	unsigned int _unused18;
-	volatile unsigned int mconfig1;     /* Memory config register one */
-
-        /* These defines apply to both mconfig registers above. */
-#define SGIMC_MCONFIG_FOURMB     0x00000000  /* Physical ram = 4megs */
-#define SGIMC_MCONFIG_EIGHTMB    0x00000100  /* Physical ram = 8megs */
-#define SGIMC_MCONFIG_SXTEENMB   0x00000300  /* Physical ram = 16megs */
-#define SGIMC_MCONFIG_TTWOMB     0x00000700  /* Physical ram = 32megs */
-#define SGIMC_MCONFIG_SFOURMB    0x00000f00  /* Physical ram = 64megs */
-#define SGIMC_MCONFIG_OTEIGHTMB  0x00001f00  /* Physical ram = 128megs */
-#define SGIMC_MCONFIG_RMASK      0x00001f00  /* Ram config bitmask */
-
-	unsigned int _unused19;
-	volatile unsigned int cmacc;        /* Mem access config for CPU */
-	unsigned int _unused20;
-	volatile unsigned int gmacc;        /* Mem access config for GIO */
-
-	/* This define applies to both cmacc and gmacc registers above. */
-#define SGIMC_MACC_ALIASBIG       0x20000000 /* 512MB home for alias */
-
-	/* Error address/status regs from GIO and CPU perspectives. */
-	unsigned int _unused21;
-	volatile unsigned int cerr;         /* Error address reg for CPU */
-	unsigned int _unused22;
-	volatile unsigned int cstat;        /* Status reg for CPU */
-	unsigned int _unused23;
-	volatile unsigned int gerr;         /* Error address reg for GIO */
-	unsigned int _unused24;
-	volatile unsigned int gstat;        /* Status reg for GIO */
-
-	/* Special hard bus locking registers. */
-	unsigned int _unused25;
-	volatile unsigned char syssembit;    /* Uni-bit system semaphore */
-	unsigned char _unused26[3];
-	unsigned int _unused27;
-	volatile unsigned char mlock;        /* Global GIO memory access lock */
-	unsigned char _unused28[3];
-	unsigned int _unused29;
-	volatile unsigned char elock;        /* Locks EISA from GIO accesses */
-
-	/* GIO dma control registers. */
-	unsigned char _unused30[3];
-	unsigned int _unused31[14];
-	volatile unsigned int gio_dma_trans;/* DMA mask to translation GIO addrs */
-	unsigned int _unused32;
-	volatile unsigned int gio_dma_sbits;/* DMA GIO addr substitution bits */
-	unsigned int _unused33;
-	volatile unsigned int dma_intr_cause; /* DMA IRQ cause indicator bits */
-	unsigned int _unused34;
-	volatile unsigned int dma_ctrl;     /* Main DMA control reg */
-
-	/* DMA TLB entry 0 */
-	unsigned int _unused35;
-	volatile unsigned int dtlb_hi0;
-	unsigned int _unused36;
-	volatile unsigned int dtlb_lo0;
-
-	/* DMA TLB entry 1 */
-	unsigned int _unused37;
-	volatile unsigned int dtlb_hi1;
-	unsigned int _unused38;
-	volatile unsigned int dtlb_lo1;
-
-	/* DMA TLB entry 2 */
-	unsigned int _unused39;
-	volatile unsigned int dtlb_hi2;
-	unsigned int _unused40;
-	volatile unsigned int dtlb_lo2;
-
-	/* DMA TLB entry 3 */
-	unsigned int _unused41;
-	volatile unsigned int dtlb_hi3;
-	unsigned int _unused42;
-	volatile unsigned int dtlb_lo3;
-};
-
-/* MC misc control registers live at physical 0x1fa00000. */
-/*extern struct sgimc_misc_ctrl *mcmisc_regs;
-  extern unsigned int *rpsscounter;          *//* Chirps at 100ns */
-
-struct sgimc_dma_ctrl {
-	unsigned int _unused1;
-	volatile unsigned int maddronly;   /* Address DMA goes at */
-	unsigned int _unused2;
-	volatile unsigned int maddrpdeflts; /* Same as above, plus set defaults */
-	unsigned int _unused3;
-	volatile unsigned int dmasz;       /* DMA count */
-	unsigned int _unused4;
-	volatile unsigned int ssize;       /* DMA stride size */
-	unsigned int _unused5;
-	volatile unsigned int gmaddronly;  /* Set GIO DMA but do not start trans */
-	unsigned int _unused6;
-	volatile unsigned int dmaddnpgo;   /* Set GIO DMA addr + start transfer */
-	unsigned int _unused7;
-	volatile unsigned int dmamode;     /* DMA mode config bit settings */
-	unsigned int _unused8;
-	volatile unsigned int dmaccount;    /* Zoom and byte count for DMA */
-	unsigned int _unused9;
-	volatile unsigned int dmastart;    /* Pedal to the metal. */
-	unsigned int _unused10;
-	volatile unsigned int dmarunning;  /* DMA op is in progress */
-	unsigned int _unused11;
-
-	/* Set dma addr, defaults, and kick it */
-	volatile unsigned int maddr_defl_go; /* go go go! -lm */
-};
-
-/* MC controller dma regs live at physical 0x1fa02000. */
-/* extern struct sgimc_dma_ctrl *dmactrlregs;*/
-
-/* Base location of the two ram banks found in IP2[0268] machines. */
-#define SGIMC_SEG0_BADDR     0x08000000
-#define SGIMC_SEG1_BADDR     0x20000000
-
-/* Maximum size of the above banks are per machine. */
-/*extern unsigned int sgimc_seg0_size, sgimc_seg1_size;*/
-#define SGIMC_SEG0_SIZE_ALL         0x10000000 /* 256MB */
-#define SGIMC_SEG1_SIZE_IP20_IP22   0x08000000 /* 128MB */
-#define SGIMC_SEG1_SIZE_IP26_IP28   0x20000000 /* 512MB */
-
-/* extern void sgimc_init(void);*/
-
-#endif /* _ASM_SGI_SGIMC_H */
