xserver/hw/kdrive/i810 i810.c, 1.5, 1.6 i810.h, 1.2, 1.3 i810_video.c, 1.5, 1.6 i810draw.c, 1.3, 1.4 i810stub.c, 1.6, 1.7

Eric Anholt <xserver-commit-u7BhqnqprCWvj1b/[email protected]> Thu, 9 Jun 2005 03:44:47 -0700 (PDT)
Newsgroups gmane.comp.freedesktop.xserver.cvs
Message-ID <[email protected]>
Committed by: anholt

Update of /cvs/xserver/xserver/hw/kdrive/i810
In directory gabe:/tmp/cvs-serv30863/hw/kdrive/i810

Modified Files:
	i810.c i810.h i810_video.c i810draw.c i810stub.c 
Log Message:
- Replace the syncAccel hook in the kdrive structure with a pair of
  hooks in the kaa structure: markSync and waitMarker.  The first, if
  set, returns a hardware-dependent marker number which can then be
  waited for with waitMarker.  If markSync is absent (which is the case
  on all drivers currently), waitMarker must wait for idle on any given
  marker number.  The intention is to allow for more parallelism when
  we get downloading from framebuffer, or more fine-grained idling.
- Replace the KdMarkSync/KdCheckSync functions with kaaMarkSync and
  kaaWaitSync.  These will need to be refined when KAA starts being
  smart about using them.  Merge kpict.c into kasync.c since kasyn.c has
  all the rest of these fallback funcs.
- Restructure all drivers to initialize a KaaInfo structure by hand
  rather than statically in dubious order.
- Whack the i810 driver into shape in hopes that it'll work after this
  change (it certainly wouldn't have before this).  Doesn't support my
  i845 though.
- Make a new KXV helper to avoid duplicated code to fill the region
  with the necessary color key.  Use it in i810 and mach64 (tested).


Index: i810.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/i810/i810.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- i810.c	15 Jul 2004 09:56:39 -0000	1.5
+++ i810.c	9 Jun 2005 10:44:45 -0000	1.6
@@ -176,7 +176,7 @@
     return TRUE;
 }
 
-void
+static void
 i810ScreenFini (KdScreenInfo *screen)
 {
     I810ScreenInfo    *i810s = (I810ScreenInfo *) screen->driver;
@@ -185,7 +185,7 @@
     screen->driver = 0;    
 }
 
-Bool
+static Bool
 i810InitScreen (ScreenPtr pScreen) {
 
 #ifdef XV
@@ -194,7 +194,14 @@
     return TRUE;
 }
 
-void
+static Bool
+i810FinishInitScreen(ScreenPtr pScreen)
+{
+    /* XXX: RandR init */
+    return TRUE;
+}
+
+static void
 i810CardFini (KdCardInfo *card)
 {
     I810CardInfo	*i810c = (I810CardInfo *) card->driver;
@@ -415,7 +422,7 @@
   return minb(addr+1);
 }
 
-Bool
+static Bool
 i810ModeSupported (KdScreenInfo *screen, const KdMonitorTiming *t)
 {
     /* This is just a guess. */
@@ -424,7 +431,7 @@
     return TRUE;
 }
 
-Bool
+static Bool
 i810ModeUsable (KdScreenInfo *screen)
 {
     KdCardInfo	    *card = screen->card;
@@ -465,7 +472,7 @@
     return screen_size <= (i810c->videoRam * 1024);
 }
 
-int i810AllocateGARTMemory( KdScreenInfo *screen ) 
+static int i810AllocateGARTMemory( KdScreenInfo *screen ) 
 {
    KdCardInfo	    *card = screen->card;
    I810CardInfo    *i810c = (I810CardInfo *) card->driver;
@@ -589,7 +596,7 @@
 
 /* Allocate from a memrange, returns success */
 
-int i810AllocLow( I810MemRange *result, I810MemRange *pool, int size )
+static int i810AllocLow( I810MemRange *result, I810MemRange *pool, int size )
 {
    if (size > pool->Size) return FALSE;
 
@@ -600,7 +607,7 @@
    return TRUE;
 }
 
-int i810AllocHigh( I810MemRange *result, I810MemRange *pool, int size )
+static int i810AllocHigh( I810MemRange *result, I810MemRange *pool, int size )
 {
    if (size > pool->Size) return 0;
 
@@ -611,7 +618,7 @@
    return 1;
 }
 
-Bool
+static Bool
 i810AllocateFront(KdScreenInfo *screen) {
 
     KdCardInfo	    *card = screen->card;
@@ -719,6 +726,8 @@
 
     memset (i810s, '\0', sizeof (I810ScreenInfo));
 
+    i810s->i810c = i810c;
+
     /* Default dimensions */
     if (!screen->width || !screen->height)
     {
@@ -933,7 +942,7 @@
 
     if ((i810Reg->LprbTail & TAIL_ADDR) != (i810Reg->LprbHead & HEAD_ADDR) &&
         i810Reg->LprbLen & RING_VALID) {
-        i810PrintErrorState( card );
+        i810PrintErrorState( i810c );
         FatalError( "Active ring not flushed\n");
     }
 
@@ -943,7 +952,9 @@
     }       
 }
 
-void i810Preserve(KdCardInfo *card) {
+static void
+i810Preserve(KdCardInfo *card)
+{
     I810CardInfo    *i810c = card->driver;
     i810VGAPtr      vgap = &i810c->vga;
 
@@ -954,10 +965,8 @@
 /* Famous last words
  */
 void 
-i810PrintErrorState(KdCardInfo *card)
+i810PrintErrorState(i810CardInfo *i810c)
 {
-
-    I810CardInfo    *i810c = card->driver;
     
    fprintf(stderr, "pgetbl_ctl: 0x%lx pgetbl_err: 0x%lx\n", 
 	   INREG(PGETBL_CTL),
@@ -993,7 +1002,7 @@
 	   INREG16(IIR));
 }
 
-Bool
+static Bool
 i810BindGARTMemory( KdScreenInfo *screen ) 
 {
     
@@ -1022,7 +1031,7 @@
     return TRUE;
 }
 
-Bool
+static Bool
 i810UnbindGARTMemory(KdScreenInfo  *screen) 
 {
     KdCardInfo	    *card = screen->card;
@@ -1124,7 +1133,7 @@
 
 #define Elements(x) (sizeof(x)/sizeof(*x))
 
-unsigned int 
+static unsigned int 
 i810CalcWatermark( KdScreenInfo *screen, double freq, Bool dcache )
 {
 
@@ -1268,7 +1277,7 @@
  * HW, but still warns about not programming them...
  */
 
-void
+static void
 i810VGASeqReset(i810VGAPtr vgap, Bool start)
 {
     if (start)
@@ -1281,7 +1290,7 @@
     }
 }
 
-void
+static void
 i810VGAProtect(KdCardInfo *card, Bool on)
 {
 
@@ -1666,7 +1675,7 @@
 
     int hactive, hblank, hbp, hfp;
     int vactive, vblank, vbp, vfp;
-    int h_screen_off, h_adjust, h_total, h_display_end, h_blank_start;
+    int h_screen_off = 0, h_adjust = 0, h_total, h_display_end, h_blank_start;
     int h_blank_end, h_sync_start, h_sync_end, v_total, v_retrace_start;
     int v_retrace_end, v_display_end, v_blank_start, v_blank_end;
 
@@ -1911,7 +1920,7 @@
     DoRestore(card, &vgap->SavedReg, &i810c->SavedReg, TRUE);
 }
 
-Bool
+static Bool
 i810Enable (ScreenPtr pScreen)
 {
     KdScreenPriv(pScreen);
@@ -1964,7 +1973,7 @@
 }
 
 
-void
+static void
 i810Disable(ScreenPtr pScreen) {
 
     KdScreenPriv(pScreen);
@@ -2035,7 +2044,9 @@
 }
 
 
-void i810GetColors (ScreenPtr pScreen, int fb, int ndefs, xColorItem *c) {
+static void
+i810GetColors (ScreenPtr pScreen, int fb, int ndefs, xColorItem *c)
+{
 
     if (I810_DEBUG)
         fprintf(stderr,"i810GetColors (NOT IMPLEMENTED)\n");
@@ -2047,7 +2058,9 @@
 	    temp = Vminb((hw)->IOBase + VGA_IN_STAT_1_OFFSET);		     \
 	} while (0)
 
-void i810PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs) {
+static void
+i810PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
+{
 
     KdScreenPriv(pScreen);
     KdScreenInfo    *screen = pScreenPriv->screen;
@@ -2079,6 +2092,8 @@
     i810CardInit,               /* cardinit */
     i810ScreenInit,             /* scrinit */
     i810InitScreen,             /* initScreen */
+    i810FinishInitScreen,       /* finishInitScreen */
+    NULL,			/* createResources */
     i810Preserve,               /* preserve */
     i810Enable,                 /* enable */
     i810DPMS,                   /* dpms */
@@ -2095,7 +2110,6 @@
 
     i810InitAccel,              /* initAccel */
     i810EnableAccel,            /* enableAccel */
-    i810SyncAccel,              /* syncAccel */
     i810DisableAccel,           /* disableAccel */
     i810FiniAccel,              /* finiAccel */
     

Index: i810.h
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/i810/i810.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- i810.h	7 Jul 2003 19:12:58 -0000	1.2
+++ i810.h	9 Jun 2005 10:44:45 -0000	1.3
@@ -122,17 +122,20 @@
    ErrorF("BEGIN_LP_RING %d in %s:%d\n", n, __FILE__, __LINE__)
 #endif
 
+#define LP_RING_LOCALS \
+    unsigned int outring, ringmask;					\
+    volatile unsigned char *virt
+
 #define BEGIN_LP_RING(n)						\
-   unsigned int outring, ringmask;					\
-   volatile unsigned char *virt;							\
-   if (n>2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC)) i810Sync( screen );	\
-   if (i810c->LpRing.space < n*4) i810WaitLpRing( screen, n*4, 0);	\
-   i810c->LpRing.space -= n*4;						\
-   if (I810_DEBUG & DEBUG_VERBOSE_RING) 				\
-      LP_RING_MESSAGE(n);						\
-   outring = i810c->LpRing.tail;					\
-   ringmask = i810c->LpRing.tail_mask;					\
-   virt = i810c->LpRing.virtual_start;			
+    if (n>2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC))				\
+	i810Sync(i810s);	\
+    if (i810c->LpRing.space < n*4) i810WaitLpRing(i810s, n*4, 0);	\
+    i810c->LpRing.space -= n*4;						\
+    if (I810_DEBUG & DEBUG_VERBOSE_RING) 				\
+	LP_RING_MESSAGE(n);						\
+    outring = i810c->LpRing.tail;					\
+    ringmask = i810c->LpRing.tail_mask;					\
+    virt = i810c->LpRing.virtual_start;			
 
 /* Memory mapped register access macros */
 #define INREG8(addr)        *(volatile CARD8  *)(i810c->MMIOBase + (addr))
@@ -193,6 +196,7 @@
 #define PCI_CHIP_I810_DC100_BRIDGE 0x7122
 #define PCI_CHIP_I810_E_BRIDGE     0x7124
 #define PCI_CHIP_I815_BRIDGE       0x1130
+#define PCI_CHIP_I845G             0x2562
 #endif
 
 
@@ -277,7 +281,7 @@
     I810RegRec ModeReg;
     I810RingBuffer LpRing;
 
-   unsigned int BR[20]; 
+    unsigned int BR[20]; 
 
     int CursorOffset;
     unsigned long CursorPhysical;
@@ -286,8 +290,6 @@
     unsigned long OverlayStart;
     int colorKey;
 
-    Bool NeedToSync; /* Need to sync accel stuff */
-
     int nextColorExpandBuf;
 
     ScreenBlockHandlerProcPtr BlockHandler;
@@ -296,7 +298,9 @@
     KdVideoAdaptorPtr adaptor;
 #endif
 
-} I810CardInfo;
+} i810CardInfo;
+
+typedef struct _i810CardInfo I810CardInfo;	/* compatibility */
 
 #define getI810CardInfo(kd)	((I810CardInfo *) ((kd)->card->driver))
 #define i810CardInfo(kd)	I810CardInfo *i810c = getI810CardInfo(kd)
@@ -312,8 +316,14 @@
 } i810Cursor, *i810CursorPtr;
 
 typedef struct _i810ScreenInfo {
+    i810CardInfo *i810c;
     i810Cursor cursor;
-} I810ScreenInfo;
+
+    int pitch;
+    KaaScreenInfoRec kaa;
+} i810ScreenInfo;
+
+typedef struct _i810ScreenInfo I810ScreenInfo;	/* compatibility */
 
 #define I810_CURSOR_HEIGHT 64
 #define I810_CURSOR_WIDTH 64
@@ -348,9 +358,6 @@
 void        
 i810EnableAccel (ScreenPtr);
 
-void	
-i810SyncAccel (ScreenPtr);
-
 void        
 i810DisableAccel (ScreenPtr);
 
@@ -423,7 +430,7 @@
 i810VGASave(KdCardInfo *card, vgaRegPtr save, int flags);
 
 void 
-i810PrintErrorState(KdCardInfo *card);
+i810PrintErrorState(i810CardInfo *i810c);
 
 void
 i810VGAGetIOBase(i810VGAPtr vgap);

Index: i810_video.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/i810/i810_video.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- i810_video.c	15 Jul 2004 09:56:39 -0000	1.5
+++ i810_video.c	9 Jun 2005 10:44:45 -0000	1.6
@@ -99,7 +99,7 @@
 static int i810GetPortAttribute(KdScreenInfo *, Atom, int *, pointer);
 static void i810QueryBestSize(KdScreenInfo *, Bool,
 	short, short, short, short, unsigned int *, unsigned int *, pointer);
-static int i810PutImage( KdScreenInfo *, 
+static int i810PutImage( KdScreenInfo *, DrawablePtr, 
 	short, short, short, short, short, short, short, short,
 	int, unsigned char*, short, short, Bool, RegionPtr, pointer);
 static int i810QueryImageAttributes(KdScreenInfo *, 
@@ -929,20 +929,27 @@
    return new_linear;
 }
 
-static int 
-i810PutImage( 
-  KdScreenInfo *screen, 
-  short src_x, short src_y, 
-  short drw_x, short drw_y,
-  short src_w, short src_h, 
-  short drw_w, short drw_h,
-  int id, unsigned char* buf, 
-  short width, short height, 
-  Bool sync,
-  RegionPtr clipBoxes, pointer data
-){
-  KdCardInfo *card = screen->card;
-  I810CardInfo	*i810c = (I810CardInfo *) card->driver;
+static int
+i810PutImage(KdScreenInfo	    *screen, 
+	       DrawablePtr	    pDraw,
+	       short		    src_x,
+	       short		    src_y,
+	       short		    drw_x,
+	       short		    drw_y,
+	       short		    src_w,
+	       short		    src_h,
+	       short		    drw_w,
+	       short		    drw_h,
+	       int		     id,
+	       unsigned char	    *buf,
+	       short		    width,
+	       short		    height,
+	       Bool		    sync,
+	       RegionPtr	    clipBoxes,
+	       pointer		    data)
+{
+    KdCardInfo *card = screen->card;
+    I810CardInfo *i810c = (I810CardInfo *) card->driver;
     I810PortPrivPtr pPriv = (I810PortPrivPtr)data;
     INT32 x1, x2, y1, y2;
     int srcPitch, dstPitch;
@@ -1029,14 +1036,7 @@
     /* update cliplist */
     if(!REGION_EQUAL(screen->pScreen, &pPriv->clip, clipBoxes)) {
 	REGION_COPY(screen->pScreen, &pPriv->clip, clipBoxes);
-        i810FillBoxSolid(screen, REGION_NUM_RECTS(clipBoxes),
-                         REGION_RECTS(clipBoxes),
-                         pPriv->colorKey, GXcopy, ~0);
-        /*
-	XAAFillSolidRects(screen, pPriv->colorKey, GXcopy, ~0, 
-					REGION_NUM_RECTS(clipBoxes),
-					REGION_RECTS(clipBoxes));
-        */
+	KXVPaintRegion (pDraw, &pPriv->clip, pPriv->colorKey);
     }
 
 

Index: i810draw.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/i810/i810draw.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- i810draw.c	15 Jul 2004 09:56:40 -0000	1.3
+++ i810draw.c	9 Jun 2005 10:44:45 -0000	1.4
@@ -39,6 +39,7 @@
 #include <config.h>
 #endif
 #include "kdrive.h"
+#include "kaa.h"
 #ifdef XV
 #include "kxv.h"
 #endif
@@ -60,318 +61,12 @@
 
 #define NUM_STACK_RECTS	1024
 
-void
-i810Sync( KdScreenInfo *screen );
-int
-i810WaitLpRing( KdScreenInfo *screen, int n, int timeout_millis );
-
-void 
-i810EmitInvarientState(KdScreenInfo *screen)
-{
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = (I810CardInfo *) card->driver;
-
-    BEGIN_LP_RING( 10 );
-
-    OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE );
-    OUT_RING( GFX_CMD_CONTEXT_SEL | CS_UPDATE_USE | CS_USE_CTX0 );
-    OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE);
-    OUT_RING( 0 );
-
-
-    OUT_RING( GFX_OP_COLOR_CHROMA_KEY );
-    OUT_RING( CC1_UPDATE_KILL_WRITE | 
-              CC1_DISABLE_KILL_WRITE | 
-              CC1_UPDATE_COLOR_IDX |
-              CC1_UPDATE_CHROMA_LOW |
-              CC1_UPDATE_CHROMA_HI |
-              0);
-    OUT_RING( 0 );
-    OUT_RING( 0 );
-
-    /* No depth buffer in KDrive yet */
-    /*     OUT_RING( CMD_OP_Z_BUFFER_INFO ); */
-    /*     OUT_RING( pI810->DepthBuffer.Start | pI810->auxPitchBits); */
-
-    ADVANCE_LP_RING();      
-}
-
-static unsigned int i810PatternRop[16] = {
-    0x00, /* GXclear      */
-    0xA0, /* GXand        */
-    0x50, /* GXandReverse */
-    0xF0, /* GXcopy       */
-    0x0A, /* GXandInvert  */
-    0xAA, /* GXnoop       */
-    0x5A, /* GXxor        */
-    0xFA, /* GXor         */
-    0x05, /* GXnor        */
-    0xA5, /* GXequiv      */
-    0x55, /* GXinvert     */
-    0xF5, /* GXorReverse  */
-    0x0F, /* GXcopyInvert */
-    0xAF, /* GXorInverted */
-    0x5F, /* GXnand       */
-    0xFF  /* GXset        */
-};
-
-void 
-i810SetupForSolidFill(KdScreenInfo *screen, int color, int rop,
-		      unsigned int planemask)
-{
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = (I810CardInfo *) card->driver;
-
-   if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
-      ErrorF( "i810SetupForFillRectSolid color: %x rop: %x mask: %x\n", 
-	      color, rop, planemask);
-
-   /* Color blit, p166 */
-   i810c->BR[13] = (BR13_SOLID_PATTERN | 
-		    (i810PatternRop[rop] << 16) |
-		    (screen->width * i810c->cpp));
-   i810c->BR[16] = color;
-}
-
-
-void 
-i810SubsequentSolidFillRect(KdScreenInfo *screen, int x, int y, int w, int h)
-{
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = (I810CardInfo *) card->driver;
-
-   if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
-      ErrorF( "i810SubsequentFillRectSolid %d,%d %dx%d\n",
-	      x,y,w,h);
-
-   {   
-      BEGIN_LP_RING(6);
-   
-      OUT_RING( BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3 );
-      OUT_RING( i810c->BR[13] );
-      OUT_RING( (h << 16) | (w * i810c->cpp));
-      OUT_RING( i810c->bufferOffset + 
-		(y * screen->width + x) * i810c->cpp);
-
-      OUT_RING( i810c->BR[16]);
-      OUT_RING( 0 );		/* pad to quadword */
-
-      ADVANCE_LP_RING();
-   }
-}
-
-
-BOOL
-i810FillOk (GCPtr pGC)
-{
-    FbBits  depthMask;
-
-    switch (pGC->fillStyle) {
-    case FillSolid:
-	return TRUE;
-        /* More cases later... */
-    }
-    return FALSE;
-}
-
-void
-i810FillBoxSolid (KdScreenInfo *screen, int nBox, BoxPtr pBox, 
-                  unsigned long pixel, int alu, unsigned long planemask)
-{
-    i810SetupForSolidFill(screen, pixel, alu, planemask);
-    while (nBox--) 
-    {
-        i810SubsequentSolidFillRect(screen, pBox->x1, pBox->y1, 
-                                    pBox->x2-pBox->x1, pBox->y2-pBox->y1);
-	pBox++;
-    }
-    KdMarkSync(screen->pScreen);
-}
-
-
-void
-i810PolyFillRect (DrawablePtr pDrawable, GCPtr pGC, 
-		int nrectFill, xRectangle *prectInit)
-{
-
-
-    xRectangle	    *prect;
-    RegionPtr	    prgnClip;
-    register BoxPtr pbox;
-    register BoxPtr pboxClipped;
-    BoxPtr	    pboxClippedBase;
-    BoxPtr	    pextent;
-    BoxRec	    stackRects[NUM_STACK_RECTS];
-    FbGCPrivPtr	    fbPriv = fbGetGCPrivate (pGC);
-    int		    numRects;
-    int		    n;
-    int		    xorg, yorg;
-    int		    x, y;
-    KdScreenPriv(pDrawable->pScreen);
-    KdScreenInfo *screen = pScreenPriv->screen;
-    
-    if (!i810FillOk (pGC))
-    {
-	KdCheckPolyFillRect (pDrawable, pGC, nrectFill, prectInit);
-	return;
-    }
-    prgnClip = fbGetCompositeClip(pGC);
-    xorg = pDrawable->x;
-    yorg = pDrawable->y;
-    
-    if (xorg || yorg)
-    {
-	prect = prectInit;
-	n = nrectFill;
-	while(n--)
-	{
-	    prect->x += xorg;
-	    prect->y += yorg;
-	    prect++;
-	}
-    }
-    
-    prect = prectInit;
-
-    numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
-    if (numRects > NUM_STACK_RECTS)
-    {
-	pboxClippedBase = (BoxPtr)xalloc(numRects * sizeof(BoxRec));
-	if (!pboxClippedBase)
-	    return;
-    }
-    else
-	pboxClippedBase = stackRects;
-
-    pboxClipped = pboxClippedBase;
-	
-    if (REGION_NUM_RECTS(prgnClip) == 1)
-    {
-	int x1, y1, x2, y2, bx2, by2;
-
-	pextent = REGION_RECTS(prgnClip);
-	x1 = pextent->x1;
-	y1 = pextent->y1;
-	x2 = pextent->x2;
-	y2 = pextent->y2;
-    	while (nrectFill--)
-    	{
-	    if ((pboxClipped->x1 = prect->x) < x1)
-		pboxClipped->x1 = x1;
-    
-	    if ((pboxClipped->y1 = prect->y) < y1)
-		pboxClipped->y1 = y1;
-    
-	    bx2 = (int) prect->x + (int) prect->width;
-	    if (bx2 > x2)
-		bx2 = x2;
-	    pboxClipped->x2 = bx2;
-    
-	    by2 = (int) prect->y + (int) prect->height;
-	    if (by2 > y2)
-		by2 = y2;
-	    pboxClipped->y2 = by2;
-
-	    prect++;
-	    if ((pboxClipped->x1 < pboxClipped->x2) &&
-		(pboxClipped->y1 < pboxClipped->y2))
-	    {
-		pboxClipped++;
-	    }
-    	}
-    }
-    else
-    {
-	int x1, y1, x2, y2, bx2, by2;
-
-	pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
-	x1 = pextent->x1;
-	y1 = pextent->y1;
-	x2 = pextent->x2;
-	y2 = pextent->y2;
-    	while (nrectFill--)
-    	{
-	    BoxRec box;
-    
-	    if ((box.x1 = prect->x) < x1)
-		box.x1 = x1;
-    
-	    if ((box.y1 = prect->y) < y1)
-		box.y1 = y1;
-    
-	    bx2 = (int) prect->x + (int) prect->width;
-	    if (bx2 > x2)
-		bx2 = x2;
-	    box.x2 = bx2;
-    
-	    by2 = (int) prect->y + (int) prect->height;
-	    if (by2 > y2)
-		by2 = y2;
-	    box.y2 = by2;
-    
-	    prect++;
-    
-	    if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
-	    	continue;
-    
-	    n = REGION_NUM_RECTS (prgnClip);
-	    pbox = REGION_RECTS(prgnClip);
-    
-	    /* clip the rectangle to each box in the clip region
-	       this is logically equivalent to calling Intersect()
-	    */
-	    while(n--)
-	    {
-		pboxClipped->x1 = max(box.x1, pbox->x1);
-		pboxClipped->y1 = max(box.y1, pbox->y1);
-		pboxClipped->x2 = min(box.x2, pbox->x2);
-		pboxClipped->y2 = min(box.y2, pbox->y2);
-		pbox++;
-
-		/* see if clipping left anything */
-		if(pboxClipped->x1 < pboxClipped->x2 && 
-		   pboxClipped->y1 < pboxClipped->y2)
-		{
-		    pboxClipped++;
-		}
-	    }
-    	}
-    }
-    if (pboxClipped != pboxClippedBase)
-    {
-	switch (pGC->fillStyle) {
-	case FillSolid:
-	    i810FillBoxSolid(screen,
-                             pboxClipped-pboxClippedBase, pboxClippedBase,
-                             pGC->fgPixel, pGC->alu, pGC->planemask);
-	    break;
-            /* More cases later... */
-	}
-    }
-    if (pboxClippedBase != stackRects)
-    	xfree(pboxClippedBase);
-}
-
-void 
-i810RefreshRing(KdScreenInfo *screen)
-{
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = (I810CardInfo *) card->driver;
-      
-   i810c->LpRing.head = INREG(LP_RING + RING_HEAD) & HEAD_ADDR;
-   i810c->LpRing.tail = INREG(LP_RING + RING_TAIL);
-   i810c->LpRing.space = i810c->LpRing.head - (i810c->LpRing.tail+8);
-   if (i810c->LpRing.space < 0) 
-      i810c->LpRing.space += i810c->LpRing.mem.Size;
-
-   i810c->NeedToSync = TRUE;
-}
+i810ScreenInfo    *accel_i810s;
 
-int
-i810WaitLpRing( KdScreenInfo *screen, int n, int timeout_millis )
+static int
+i810WaitLpRing(i810ScreenInfo *i810s, int n, int timeout_millis)
 {
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = (I810CardInfo *) card->driver;
+    i810CardInfo *i810c = i810s->i810c;
     I810RingBuffer *ring = &(i810c->LpRing);
     int iters = 0;
     int start = 0;
@@ -410,7 +105,7 @@
 	 last_head = ring->head;
       } else if ( now - start > timeout_millis ) { 
 
-	 i810PrintErrorState( screen->card ); 
+	 i810PrintErrorState(i810c); 
 	 fprintf(stderr, "space: %d wanted %d\n", ring->space, n );
 	 FatalError("lockup\n"); 
       }
@@ -431,100 +126,165 @@
    return iters;
 }
 
-void
-i810Sync( KdScreenInfo *screen ) 
+static void
+i810Sync(i810ScreenInfo *i810s) 
 {
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = card->driver;
+    i810CardInfo *i810c = i810s->i810c;
+    LP_RING_LOCALS;
 
-   if (I810_DEBUG)
-      fprintf(stderr, "i810Sync\n");
+    if (I810_DEBUG)
+	fprintf(stderr, "i810Sync\n");
    
    /* Send a flush instruction and then wait till the ring is empty.
     * This is stronger than waiting for the blitter to finish as it also
     * flushes the internal graphics caches.
     */
-   {
-       BEGIN_LP_RING(2);   
-       OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE );
-       OUT_RING( 0 );		/* pad to quadword */
-       ADVANCE_LP_RING();
-   }
+    BEGIN_LP_RING(2);
+    OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE );
+    OUT_RING( 0 );		/* pad to quadword */
+    ADVANCE_LP_RING();
 
-   i810WaitLpRing(screen, i810c->LpRing.mem.Size - 8, 0 );	
+    i810WaitLpRing(i810s, i810c->LpRing.mem.Size - 8, 0);
 
-   i810c->LpRing.space = i810c->LpRing.mem.Size - 8;			
-   i810c->nextColorExpandBuf = 0;
+    i810c->LpRing.space = i810c->LpRing.mem.Size - 8;
+    i810c->nextColorExpandBuf = 0;
 }
 
-static const GCOps	i810Ops = {
-    KdCheckFillSpans,
-    KdCheckSetSpans,
-    KdCheckPutImage,
-    KdCheckCopyArea,
-    KdCheckCopyPlane,
-    KdCheckPolyPoint,
-    KdCheckPolylines,
-    KdCheckPolySegment,
-    miPolyRectangle,
-    KdCheckPolyArc,
-    miFillPolygon,
-    i810PolyFillRect,
-    miPolyFillArc,
-    miPolyText8,
-    miPolyText16,
-    miImageText8,
-    miImageText16,
-    KdCheckImageGlyphBlt,
-    KdCheckPolyGlyphBlt,
-    KdCheckPushPixels,
-#ifdef NEED_LINEHELPER
-    ,NULL
+static void
+i810WaitMarker(ScreenPtr pScreen, int marker)
+{
+    KdScreenPriv(pScreen);
+    i810ScreenInfo(pScreenPriv);
+
+    i810Sync(i810s);
+}
+
+#if 0
+static void
+i810EmitInvarientState(ScreenPtr pScreen)
+{
+    KdScreenPriv(pScreen);
+    i810CardInfo(pScreenPriv);
+    i810ScreenInfo(pScreenPriv);
+    LP_RING_LOCALS;
+
+    BEGIN_LP_RING( 10 );
+
+    OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE );
+    OUT_RING( GFX_CMD_CONTEXT_SEL | CS_UPDATE_USE | CS_USE_CTX0 );
+    OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE);
+    OUT_RING( 0 );
+
+
+    OUT_RING( GFX_OP_COLOR_CHROMA_KEY );
+    OUT_RING( CC1_UPDATE_KILL_WRITE | 
+              CC1_DISABLE_KILL_WRITE | 
+              CC1_UPDATE_COLOR_IDX |
+              CC1_UPDATE_CHROMA_LOW |
+              CC1_UPDATE_CHROMA_HI |
+              0);
+    OUT_RING( 0 );
+    OUT_RING( 0 );
+
+    /* No depth buffer in KDrive yet */
+    /*     OUT_RING( CMD_OP_Z_BUFFER_INFO ); */
+    /*     OUT_RING( pI810->DepthBuffer.Start | pI810->auxPitchBits); */
+
+    ADVANCE_LP_RING();
+}
 #endif
+
+static unsigned int i810PatternRop[16] = {
+    0x00, /* GXclear      */
+    0xA0, /* GXand        */
+    0x50, /* GXandReverse */
+    0xF0, /* GXcopy       */
+    0x0A, /* GXandInvert  */
+    0xAA, /* GXnoop       */
+    0x5A, /* GXxor        */
+    0xFA, /* GXor         */
+    0x05, /* GXnor        */
+    0xA5, /* GXequiv      */
+    0x55, /* GXinvert     */
+    0xF5, /* GXorReverse  */
+    0x0F, /* GXcopyInvert */
+    0xAF, /* GXorInverted */
+    0x5F, /* GXnand       */
+    0xFF  /* GXset        */
 };
 
-void
-i810ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
+static Bool
+i810PrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg)
 {
-    FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC);
-    
-    fbValidateGC (pGC, changes, pDrawable);
-    
-    if (pDrawable->type == DRAWABLE_WINDOW)
-	pGC->ops = (GCOps *) &i810Ops;
-    else
-	pGC->ops = (GCOps *) &kdAsyncPixmapGCOps;
+    KdScreenPriv(pPix->drawable.pScreen);
+    i810ScreenInfo(pScreenPriv);
+    i810CardInfo(pScreenPriv);
+
+    if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
+      ErrorF( "i810PrepareSolid color: %x rop: %x mask: %x\n", 
+	      fg, alu, pm);
+
+    /* Color blit, p166 */
+    i810c->BR[13] = BR13_SOLID_PATTERN | 
+		    (i810PatternRop[alu] << 16) |
+		    (pPix->drawable.pScreen->width * i810c->cpp);
+    i810c->BR[16] = fg;
+
+    accel_i810s = i810s;
+
+    return TRUE;
 }
 
-GCFuncs	i810GCFuncs = {
-    i810ValidateGC,
-    miChangeGC,
-    miCopyGC,
-    miDestroyGC,
-    miChangeClip,
-    miDestroyClip,
-    miCopyClip
-};
+static void
+i810Solid(int x1, int y1, int x2, int y2)
+{
+    I810ScreenInfo *i810s = accel_i810s;
+    I810CardInfo *i810c = i810s->i810c;
+    LP_RING_LOCALS;
 
-int
-i810CreateGC (GCPtr pGC)
+    if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
+	ErrorF( "i810SubsequentFillRectSolid %d,%d %d,%d\n", x1, y1, x2, y2);
+
+    BEGIN_LP_RING(6);
+
+    OUT_RING( BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3 );
+    OUT_RING( i810c->BR[13] );
+    OUT_RING( ((y2 - y1) << 16) | ((x2 - x1) * i810c->cpp));
+    OUT_RING( i810c->bufferOffset + y1 * i810s->pitch + x1 * i810c->cpp );
+
+    OUT_RING( i810c->BR[16]);
+    OUT_RING( 0 );		/* pad to quadword */
+
+    ADVANCE_LP_RING();
+}
+
+static void
+i810DoneSolid(void)
+{
+}
+
+static Bool
+i810PrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu, Pixel pm)
 {
-    if (!fbCreateGC (pGC))
 	return FALSE;
+}
 
-    if (pGC->depth != 1)
-	pGC->funcs = &i810GCFuncs;
-    
-    return TRUE;
+static void 
+i810RefreshRing(i810CardInfo *i810c)
+{
+    i810c->LpRing.head = INREG(LP_RING + RING_HEAD) & HEAD_ADDR;
+    i810c->LpRing.tail = INREG(LP_RING + RING_TAIL);
+    i810c->LpRing.space = i810c->LpRing.head - (i810c->LpRing.tail+8);
+    if (i810c->LpRing.space < 0) 
+	i810c->LpRing.space += i810c->LpRing.mem.Size;
 }
 
+
 static void
-i810SetRingRegs( KdScreenInfo *screen ) {
+i810SetRingRegs(i810CardInfo *i810c)
+{
    unsigned int itemp;
 
-   KdCardInfo	    *card = screen->card;
-   I810CardInfo    *i810c = (I810CardInfo *) card->driver;
-
    OUTREG(LP_RING + RING_TAIL, 0 );
    OUTREG(LP_RING + RING_HEAD, 0 );
 
@@ -542,65 +302,52 @@
 Bool
 i810InitAccel(ScreenPtr pScreen)
 {
+    KdScreenPriv(pScreen);
+    i810ScreenInfo(pScreenPriv);
+    i810CardInfo(pScreenPriv);
 
-/*     fprintf(stderr,"i810InitAccel\n"); */
+    memset(&i810s->kaa, 0, sizeof(KaaScreenInfoRec));
+    i810s->kaa.waitMarker	= i810WaitMarker;
+    i810s->kaa.PrepareSolid	= i810PrepareSolid;
+    i810s->kaa.Solid		= i810Solid;
+    i810s->kaa.DoneSolid	= i810DoneSolid;
+    i810s->kaa.PrepareCopy	= i810PrepareCopy;
+    i810s->kaa.Copy		= NULL;
+    i810s->kaa.DoneCopy		= NULL;
 
-    /*
-     * Hook up asynchronous drawing
-     */
-    KdScreenInitAsync (pScreen);
-    /*
-     * Replace various fb screen functions
-     */
-    pScreen->CreateGC = i810CreateGC;
+    i810s->pitch = pScreen->width * i810c->cpp;
 
-    return TRUE;
+    return FALSE;
 }
 
 void
 i810EnableAccel(ScreenPtr pScreen)
 {
-
     KdScreenPriv(pScreen);
-    KdScreenInfo    *screen = pScreenPriv->screen;
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = (I810CardInfo *) card->driver;
-
-/*     fprintf(stderr,"i810EnableAccel\n"); */
+    i810CardInfo(pScreenPriv);
 
     if (i810c->LpRing.mem.Size == 0) {
         ErrorF("No memory for LpRing!! Acceleration not functional!!\n");
     }
 
-    i810SetRingRegs( screen );
+    i810SetRingRegs(i810c);
 
-    KdMarkSync (pScreen);
+    kaaMarkSync (pScreen);
 }
 
 
 void
-i810SyncAccel(ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    KdScreenInfo    *screen = pScreenPriv->screen;
-
-    i810Sync(screen);
-}
-
-void
 i810DisableAccel(ScreenPtr pScreen)
 {
     KdScreenPriv(pScreen);
-    KdScreenInfo    *screen = pScreenPriv->screen;
+    i810CardInfo(pScreenPriv);
+    i810ScreenInfo(pScreenPriv);
     
-/*     fprintf(stderr,"i810DisableAccel\n"); */
-    i810RefreshRing( screen );
-    i810Sync( screen );
+    i810RefreshRing(i810c);
+    i810Sync(i810s);
 }
 
 void
 i810FiniAccel(ScreenPtr pScreen)
 {
-/*     fprintf(stderr,"i810FiniAccel\n"); */
-
 }

Index: i810stub.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/i810/i810stub.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- i810stub.c	18 Nov 2003 04:53:15 -0000	1.6
+++ i810stub.c	9 Jun 2005 10:44:45 -0000	1.7
@@ -42,8 +42,13 @@
 #include "kdrive.h"
 #include "kxv.h"
 #include "i810.h"
+#include "klinux.h"
 
-static const int i810Cards[]={ PCI_CHIP_I810, PCI_CHIP_I810_DC100, PCI_CHIP_I810_E };
+static const int i810Cards[]={
+    PCI_CHIP_I810,
+    PCI_CHIP_I810_DC100,
+    PCI_CHIP_I810_E
+};
 
 #define numI810Cards (sizeof(i810Cards) / sizeof(i810Cards[0]))
 
@@ -53,8 +58,6 @@
     KdCardAttr	attr;
     int		i;
 
-    Bool LinuxFindPci(CARD16, CARD16, CARD32, KdCardAttr *); 
-
     for (i = 0; i < numI810Cards; i++)
 	if (LinuxFindPci (0x8086, i810Cards[i], 0, &attr))
 	    KdCardInfoAdd (&i810Funcs, &attr, (void *) i810Cards[i]);
@@ -83,7 +86,6 @@
 ddxProcessArgument (int argc, char **argv, int i)
 {
     int	ret;
-    int KdProcessArgument(int, char **, int);
     
     ret = KdProcessArgument(argc, argv, i);
     return ret;