xf86-video-intel: 2 commits - src/common.h src/i810.h src/i810_ring.h src/i830.h src/i830_ring.h

Eric Anholt anholt at kemper.freedesktop.org
Wed Mar 12 16:11:15 PDT 2008


 src/common.h    |   91 -------------------------------------
 src/i810.h      |    1 
 src/i810_ring.h |   90 +++++++++++++++++++++++++++++++++++++
 src/i830.h      |    9 +++
 src/i830_ring.h |  135 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 234 insertions(+), 92 deletions(-)

New commits:
commit 2e2372912ed9bc0d86e8960653ef0bfce5cf99ab
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Mar 12 11:38:56 2008 -0700

    Eliminate local variables defined in i830 BEGIN_LP_RING().
    
    This lets us get better sanity asserts, and avoid mysterious braces when you
    do two BEGIN_LP_RING()s in a single function.  Potential minor performance
    loss isn't too exciting, as ring access is about to become a compat path
    anyway.  This change also removes the requirement for ring emits to be aligned
    to dwords.

diff --git a/src/i830.h b/src/i830.h
index 68a71c5..6c3fa52 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -395,6 +395,13 @@ typedef struct _I830Rec {
    /* Regions allocated either from the above pools, or from agpgart. */
    I830RingBuffer *LpRing;
 
+   /** Number of bytes being emitted in the current BEGIN_LP_RING */
+   unsigned int ring_emitting;
+   /** Number of bytes that have been emitted in the current BEGIN_LP_RING */
+   unsigned int ring_used;
+   /** Offset in the ring for the next DWORD emit */
+   uint32_t ring_next;
+
 #ifdef I830_XV
    /* For Xvideo */
    i830_memory *overlay_regs;
diff --git a/src/i830_ring.h b/src/i830_ring.h
index dd55e6f..177b0d5 100644
--- a/src/i830_ring.h
+++ b/src/i830_ring.h
@@ -31,32 +31,37 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define _INTEL_RING_H
 
 #define OUT_RING(n) do {						\
-   if (I810_DEBUG & DEBUG_VERBOSE_RING)					\
-      ErrorF( "OUT_RING %lx: %x, (mask %x)\n",				\
-		(unsigned long)(outring), (unsigned int)(n), ringmask);	\
-   *(volatile unsigned int *)(virt + outring) = n;			\
-   outring += 4; ringused += 4;						\
-   outring &= ringmask;							\
+    if (I810_DEBUG & DEBUG_VERBOSE_RING)				\
+	ErrorF("OUT_RING 0x%08x: 0x%08x, (mask %x)\n",			\
+	       pI830->ring_next, (unsigned int)(n),			\
+	       pI830->LpRing->tail_mask);				\
+    *(volatile uint32_t *)(pI830->LpRing->virtual_start +		\
+			   pI830->ring_next) = n;			\
+    pI830->ring_used += 4;						\
+    pI830->ring_next += 4;						\
+    pI830->ring_next &= pI830->LpRing->tail_mask;			\
 } while (0)
 
 /** Copies a given number of bytes to the ring */
 #define OUT_RING_COPY(n, ptr) do {					\
     if (I810_DEBUG & DEBUG_VERBOSE_RING)				\
 	ErrorF("OUT_RING_DATA %d bytes\n", n);				\
-    memcpy_volatile(virt + outring, ptr, n);				\
-    outring += n;							\
-    ringused += n;							\
-    outring &= ringmask;						\
+    memcpy_volatile(pI830->LpRing->virtual_start + pI830->ring_next,	\
+		    ptr, n);						\
+    pI830->ring_used += n;						\
+    pI830->ring_next += n;						\
+    pI830->ring_next &= pI830->LpRing->tail_mask;			\
 } while (0)
 
 /** Pads the ring with a given number of zero bytes */
 #define OUT_RING_PAD(n) do {						\
     if (I810_DEBUG & DEBUG_VERBOSE_RING)				\
 	ErrorF("OUT_RING_PAD %d bytes\n", n);				\
-    memset_volatile(virt + outring, 0, n);				\
-    outring += n;							\
-    ringused += n;							\
-    outring &= ringmask;						\
+    memset_volatile(pI830->LpRing->virtual_start + pI830->ring_next,	\
+		    0, n);						\
+    pI830->ring_used += n;						\
+    pI830->ring_next += n;						\
+    pI830->ring_next &= pI830->LpRing->tail_mask;			\
 } while (0)
 
 union intfloat {
@@ -68,22 +73,28 @@ union intfloat {
 	union intfloat tmp;			\
 	tmp.f = (float)(x);			\
 	OUT_RING(tmp.ui);			\
-} while(0)				
+} while(0)
 
 #define ADVANCE_LP_RING() do {						\
-   if (ringused > needed)          \
-      FatalError("%s: ADVANCE_LP_RING: exceeded allocation %d/%d\n ",	\
-	     __FUNCTION__, ringused, needed);   			\
-   else if (ringused < needed)						\
-      FatalError("%s: ADVANCE_LP_RING: under-used allocation %d/%d\n ",	\
-	     __FUNCTION__, ringused, needed);   			\
-   pI830->LpRing->tail = outring;					\
-   pI830->LpRing->space -= ringused;					\
-   if (outring & 0x07)							\
-      FatalError("%s: ADVANCE_LP_RING: "				\
-	     "outring (0x%x) isn't on a QWord boundary\n",		\
-	     __FUNCTION__, outring);					\
-   OUTREG(LP_RING + RING_TAIL, outring);				\
+    if (pI830->ring_emitting == 0)					\
+	FatalError("%s: ADVANCE_LP_RING called with no matching "	\
+		   "BEGIN_LP_RING\n", __FUNCTION__);			\
+    if (pI830->ring_used > pI830->ring_emitting)			\
+	FatalError("%s: ADVANCE_LP_RING: exceeded allocation %d/%d\n ",	\
+		   __FUNCTION__, pI830->ring_used,			\
+		   pI830->ring_emitting);				\
+    if (pI830->ring_used < pI830->ring_emitting)			\
+	FatalError("%s: ADVANCE_LP_RING: under-used allocation %d/%d\n ", \
+		   __FUNCTION__, pI830->ring_used,			\
+		   pI830->ring_emitting);				\
+    pI830->LpRing->tail = pI830->ring_next;				\
+    pI830->LpRing->space -= pI830->ring_used;				\
+    if (pI830->ring_next & 0x07)					\
+	FatalError("%s: ADVANCE_LP_RING: "				\
+		   "ring_next (0x%x) isn't on a QWord boundary\n",	\
+		   __FUNCTION__, pI830->ring_next);			\
+    OUTREG(LP_RING + RING_TAIL, pI830->ring_next);			\
+    pI830->ring_emitting = 0;						\
 } while (0)
 
 /*
@@ -92,30 +103,33 @@ union intfloat {
  * a problem.  Check this!
  */
 #define DO_RING_IDLE() do {						\
-   int _head;								\
-   int _tail;								\
-   do {									\
-      _head = INREG(LP_RING + RING_HEAD) & I830_HEAD_MASK;		\
-      _tail = INREG(LP_RING + RING_TAIL) & I830_TAIL_MASK;		\
-      DELAY(10);							\
-   } while (_head != _tail);						\
-} while( 0)
+    int _head;								\
+    int _tail;								\
+    do {								\
+	_head = INREG(LP_RING + RING_HEAD) & I830_HEAD_MASK;		\
+	_tail = INREG(LP_RING + RING_TAIL) & I830_TAIL_MASK;		\
+	DELAY(10);							\
+    } while (_head != _tail);						\
+} while (0)
 
 #define BEGIN_LP_RING(n)						\
-   unsigned int outring, ringmask, ringused = 0;			\
-   volatile unsigned char *virt;					\
-   int needed;								\
-   if ((n) & 1)								\
-      ErrorF("BEGIN_LP_RING called with odd argument: %d\n", n);	\
-   if ((n) > 2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC))			\
-      DO_RING_IDLE();							\
-   needed = (n) * 4;							\
-   if (pI830->LpRing->space < needed)					\
-      WaitRingFunc(pScrn, needed, 0);					\
-   outring = pI830->LpRing->tail;					\
-   ringmask = pI830->LpRing->tail_mask;					\
-   virt = pI830->LpRing->virtual_start;					\
-   if (I810_DEBUG & DEBUG_VERBOSE_RING)					\
-      ErrorF( "BEGIN_LP_RING %d in %s\n", n, FUNCTION_NAME);
+do {									\
+    if (pI830->ring_emitting != 0)					\
+	FatalError("%s: BEGIN_LP_RING called without closing "		\
+		   "ADVANCE_LP_RING\n", __FUNCTION__);			\
+    if ((n) > 2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC))			\
+	DO_RING_IDLE();							\
+    pI830->ring_emitting = (n) * 4;					\
+    if ((n) & 1)							\
+	pI830->ring_emitting += 4;					\
+    if (pI830->LpRing->space < pI830->ring_emitting)			\
+	WaitRingFunc(pScrn, pI830->ring_emitting, 0);			\
+    pI830->ring_next = pI830->LpRing->tail;				\
+    if (I810_DEBUG & DEBUG_VERBOSE_RING)				\
+	ErrorF( "BEGIN_LP_RING %d in %s\n", n, FUNCTION_NAME);		\
+    pI830->ring_used = 0;						\
+    if ((n) & 1)							\
+	OUT_RING(MI_NOOP);						\
+} while (0)
 
 #endif /* _INTEL_RING_H */
commit abf11a274e14535630742fe4c41cc0ae92555293
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Mar 12 11:03:26 2008 -0700

    Separate i810 and i830 ring macros out into separate files.
    
    I want to hack on i830 for changing it into a compat path for batchbuffer
    without having to worry about the i810 stuff getting broken.

diff --git a/src/common.h b/src/common.h
index da60d08..9a3e0ac 100644
--- a/src/common.h
+++ b/src/common.h
@@ -121,15 +121,6 @@ extern void I830DPRINTF_stub(const char *filename, int line,
    }									\
 } while (0)
 
-#define OUT_RING(n) do {						\
-   if (I810_DEBUG & DEBUG_VERBOSE_RING)					\
-      ErrorF( "OUT_RING %lx: %x, (mask %x)\n",				\
-		(unsigned long)(outring), (unsigned int)(n), ringmask);	\
-   *(volatile unsigned int *)(virt + outring) = n;			\
-   outring += 4; ringused += 4;							\
-   outring &= ringmask;							\
-} while (0)
-
 static inline void memset_volatile(volatile void *b, int c, size_t len)
 {
     int i;
@@ -147,88 +138,6 @@ static inline void memcpy_volatile(volatile void *dst, const void *src,
 	((volatile char *)dst)[i] = ((volatile char *)src)[i];
 }
 
-/** Copies a given number of bytes to the ring */
-#define OUT_RING_COPY(n, ptr) do {					\
-    if (I810_DEBUG & DEBUG_VERBOSE_RING)				\
-	ErrorF("OUT_RING_DATA %d bytes\n", n);				\
-    memcpy_volatile(virt + outring, ptr, n);				\
-    outring += n;							\
-    ringused += n;							\
-    outring &= ringmask;						\
-} while (0)
-
-/** Pads the ring with a given number of zero bytes */
-#define OUT_RING_PAD(n) do {						\
-    if (I810_DEBUG & DEBUG_VERBOSE_RING)				\
-	ErrorF("OUT_RING_PAD %d bytes\n", n);				\
-    memset_volatile(virt + outring, 0, n);				\
-    outring += n;							\
-    ringused += n;							\
-    outring &= ringmask;						\
-} while (0)
-
-union intfloat {
-	float f;
-	unsigned int ui;
-};
-
-#define OUT_RING_F(x) do {			\
-	union intfloat tmp;			\
-	tmp.f = (float)(x);			\
-	OUT_RING(tmp.ui);			\
-} while(0)				
-
-#define ADVANCE_LP_RING() do {						\
-   if (ringused > needed)          \
-      FatalError("%s: ADVANCE_LP_RING: exceeded allocation %d/%d\n ",	\
-	     __FUNCTION__, ringused, needed);   			\
-   else if (ringused < needed)						\
-      FatalError("%s: ADVANCE_LP_RING: under-used allocation %d/%d\n ",	\
-	     __FUNCTION__, ringused, needed);   			\
-   RecPtr->LpRing->tail = outring;					\
-   RecPtr->LpRing->space -= ringused;					\
-   if (outring & 0x07)							\
-      FatalError("%s: ADVANCE_LP_RING: "					\
-	     "outring (0x%x) isn't on a QWord boundary\n",		\
-	     __FUNCTION__, outring);					\
-   OUTREG(LP_RING + RING_TAIL, outring);				\
-} while (0)
-
-/*
- * XXX Note: the head/tail masks are different for 810 and i830.
- * If the i810 always sets the higher bits to 0, then this shouldn't be
- * a problem.  Check this!
- */
-#define DO_RING_IDLE() do {						\
-   int _head;								\
-   int _tail;								\
-   do {									\
-      _head = INREG(LP_RING + RING_HEAD) & I830_HEAD_MASK;		\
-      _tail = INREG(LP_RING + RING_TAIL) & I830_TAIL_MASK;		\
-      DELAY(10);							\
-   } while (_head != _tail);						\
-} while( 0)
-
-
-#define BEGIN_LP_RING(n)						\
-   unsigned int outring, ringmask, ringused = 0;			\
-   volatile unsigned char *virt;					\
-   int needed;								\
-   if ((n) & 1)								\
-      ErrorF("BEGIN_LP_RING called with odd argument: %d\n", n);	\
-   if ((n) > 2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC))			\
-      DO_RING_IDLE();							\
-   needed = (n) * 4;							\
-   if (RecPtr->LpRing->space < needed)					\
-      WaitRingFunc(pScrn, needed, 0);					\
-   outring = RecPtr->LpRing->tail;					\
-   ringmask = RecPtr->LpRing->tail_mask;				\
-   virt = RecPtr->LpRing->virtual_start;				\
-   if (I810_DEBUG & DEBUG_VERBOSE_RING)					\
-      ErrorF( "BEGIN_LP_RING %d in %s\n", n, FUNCTION_NAME);
-
-
-
 /* Memory mapped register access macros */
 #define INREG8(addr)        *(volatile uint8_t *)(RecPtr->MMIOBase + (addr))
 #define INREG16(addr)       *(volatile uint16_t *)(RecPtr->MMIOBase + (addr))
diff --git a/src/i810.h b/src/i810.h
index bd2985c..b798021 100644
--- a/src/i810.h
+++ b/src/i810.h
@@ -65,6 +65,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #endif
 
 #include "common.h"
+#include "i810_ring.h"
 
 #define I810_VERSION 4000
 #define I810_NAME "intel"
diff --git a/src/i810_ring.h b/src/i810_ring.h
new file mode 100644
index 0000000..e6e354f
--- /dev/null
+++ b/src/i810_ring.h
@@ -0,0 +1,90 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright © 2002 David Dawes
+
+All Rights Reserved.
+
+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, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef _INTEL_RING_H
+#define _INTEL_RING_H
+
+#define OUT_RING(n) do {						\
+    if (I810_DEBUG & DEBUG_VERBOSE_RING)				\
+	ErrorF("OUT_RING %lx: %x, (mask %x)\n",				\
+	       (unsigned long)(outring), (unsigned int)(n), ringmask);	\
+    *(volatile unsigned int *)(virt + outring) = n;			\
+    outring += 4; ringused += 4;					\
+    outring &= ringmask;						\
+} while (0)
+
+#define ADVANCE_LP_RING() do {						\
+    if (ringused > needed)						\
+	FatalError("%s: ADVANCE_LP_RING: exceeded allocation %d/%d\n ",	\
+		   __FUNCTION__, ringused, needed);   			\
+    else if (ringused < needed)						\
+	FatalError("%s: ADVANCE_LP_RING: under-used allocation %d/%d\n ", \
+		   __FUNCTION__, ringused, needed);   			\
+    pI810->LpRing->tail = outring;					\
+    pI810->LpRing->space -= ringused;					\
+    if (outring & 0x07)							\
+	FatalError("%s: ADVANCE_LP_RING: "				\
+		   "outring (0x%x) isn't on a QWord boundary\n",	\
+		   __FUNCTION__, outring);				\
+    OUTREG(LP_RING + RING_TAIL, outring);				\
+} while (0)
+
+/*
+ * XXX Note: the head/tail masks are different for 810 and i830.
+ * If the i810 always sets the higher bits to 0, then this shouldn't be
+ * a problem.  Check this!
+ */
+#define DO_RING_IDLE() do {						\
+    int _head;								\
+    int _tail;								\
+    do {								\
+	_head = INREG(LP_RING + RING_HEAD) & I830_HEAD_MASK;		\
+	_tail = INREG(LP_RING + RING_TAIL) & I830_TAIL_MASK;		\
+	DELAY(10);							\
+    } while (_head != _tail);						\
+} while( 0)
+
+#define BEGIN_LP_RING(n)						\
+    unsigned int outring, ringmask, ringused = 0;			\
+    volatile unsigned char *virt;					\
+    int needed;								\
+    if ((n) & 1)							\
+	ErrorF("BEGIN_LP_RING called with odd argument: %d\n", n);	\
+    if ((n) > 2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC))			\
+	DO_RING_IDLE();							\
+    needed = (n) * 4;							\
+    if (pI810->LpRing->space < needed)					\
+	WaitRingFunc(pScrn, needed, 0);					\
+    outring = pI810->LpRing->tail;					\
+    ringmask = pI810->LpRing->tail_mask;				\
+    virt = pI810->LpRing->virtual_start;				\
+    if (I810_DEBUG & DEBUG_VERBOSE_RING)				\
+	ErrorF( "BEGIN_LP_RING %d in %s\n", n, FUNCTION_NAME);
+
+#endif /* _INTEL_RING_H */
diff --git a/src/i830.h b/src/i830.h
index 3866a25..68a71c5 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -1,4 +1,3 @@
-
 /**************************************************************************
 
 Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -97,6 +96,7 @@ Bool I830XAAInit(ScreenPtr pScreen);
 typedef struct _I830OutputRec I830OutputRec, *I830OutputPtr;
 
 #include "common.h"
+#include "i830_ring.h"
 #include "i830_sdvo.h"
 #include "i2c_vid.h"
 
diff --git a/src/i830_ring.h b/src/i830_ring.h
new file mode 100644
index 0000000..dd55e6f
--- /dev/null
+++ b/src/i830_ring.h
@@ -0,0 +1,121 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright © 2002 David Dawes
+
+All Rights Reserved.
+
+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, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#ifndef _INTEL_RING_H
+#define _INTEL_RING_H
+
+#define OUT_RING(n) do {						\
+   if (I810_DEBUG & DEBUG_VERBOSE_RING)					\
+      ErrorF( "OUT_RING %lx: %x, (mask %x)\n",				\
+		(unsigned long)(outring), (unsigned int)(n), ringmask);	\
+   *(volatile unsigned int *)(virt + outring) = n;			\
+   outring += 4; ringused += 4;						\
+   outring &= ringmask;							\
+} while (0)
+
+/** Copies a given number of bytes to the ring */
+#define OUT_RING_COPY(n, ptr) do {					\
+    if (I810_DEBUG & DEBUG_VERBOSE_RING)				\
+	ErrorF("OUT_RING_DATA %d bytes\n", n);				\
+    memcpy_volatile(virt + outring, ptr, n);				\
+    outring += n;							\
+    ringused += n;							\
+    outring &= ringmask;						\
+} while (0)
+
+/** Pads the ring with a given number of zero bytes */
+#define OUT_RING_PAD(n) do {						\
+    if (I810_DEBUG & DEBUG_VERBOSE_RING)				\
+	ErrorF("OUT_RING_PAD %d bytes\n", n);				\
+    memset_volatile(virt + outring, 0, n);				\
+    outring += n;							\
+    ringused += n;							\
+    outring &= ringmask;						\
+} while (0)
+
+union intfloat {
+	float f;
+	unsigned int ui;
+};
+
+#define OUT_RING_F(x) do {			\
+	union intfloat tmp;			\
+	tmp.f = (float)(x);			\
+	OUT_RING(tmp.ui);			\
+} while(0)				
+
+#define ADVANCE_LP_RING() do {						\
+   if (ringused > needed)          \
+      FatalError("%s: ADVANCE_LP_RING: exceeded allocation %d/%d\n ",	\
+	     __FUNCTION__, ringused, needed);   			\
+   else if (ringused < needed)						\
+      FatalError("%s: ADVANCE_LP_RING: under-used allocation %d/%d\n ",	\
+	     __FUNCTION__, ringused, needed);   			\
+   pI830->LpRing->tail = outring;					\
+   pI830->LpRing->space -= ringused;					\
+   if (outring & 0x07)							\
+      FatalError("%s: ADVANCE_LP_RING: "				\
+	     "outring (0x%x) isn't on a QWord boundary\n",		\
+	     __FUNCTION__, outring);					\
+   OUTREG(LP_RING + RING_TAIL, outring);				\
+} while (0)
+
+/*
+ * XXX Note: the head/tail masks are different for 810 and i830.
+ * If the i810 always sets the higher bits to 0, then this shouldn't be
+ * a problem.  Check this!
+ */
+#define DO_RING_IDLE() do {						\
+   int _head;								\
+   int _tail;								\
+   do {									\
+      _head = INREG(LP_RING + RING_HEAD) & I830_HEAD_MASK;		\
+      _tail = INREG(LP_RING + RING_TAIL) & I830_TAIL_MASK;		\
+      DELAY(10);							\
+   } while (_head != _tail);						\
+} while( 0)
+
+#define BEGIN_LP_RING(n)						\
+   unsigned int outring, ringmask, ringused = 0;			\
+   volatile unsigned char *virt;					\
+   int needed;								\
+   if ((n) & 1)								\
+      ErrorF("BEGIN_LP_RING called with odd argument: %d\n", n);	\
+   if ((n) > 2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC))			\
+      DO_RING_IDLE();							\
+   needed = (n) * 4;							\
+   if (pI830->LpRing->space < needed)					\
+      WaitRingFunc(pScrn, needed, 0);					\
+   outring = pI830->LpRing->tail;					\
+   ringmask = pI830->LpRing->tail_mask;					\
+   virt = pI830->LpRing->virtual_start;					\
+   if (I810_DEBUG & DEBUG_VERBOSE_RING)					\
+      ErrorF( "BEGIN_LP_RING %d in %s\n", n, FUNCTION_NAME);
+
+#endif /* _INTEL_RING_H */


More information about the xorg-commit mailing list