diff options
author | Eric Anholt <eric@anholt.net> | 2008-03-12 11:03:26 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2008-03-12 16:12:28 -0700 |
commit | abf11a274e14535630742fe4c41cc0ae92555293 (patch) | |
tree | 0b1b931205b9fcefbe357e5847d4475e5ff92494 /src | |
parent | e04908853db74dc76718f6bc0dfb23b5ab3c5837 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/common.h | 91 | ||||
-rw-r--r-- | src/i810.h | 1 | ||||
-rw-r--r-- | src/i810_ring.h | 90 | ||||
-rw-r--r-- | src/i830.h | 2 | ||||
-rw-r--r-- | src/i830_ring.h | 121 |
5 files changed, 213 insertions, 92 deletions
diff --git a/src/common.h b/src/common.h index da60d085..9a3e0ac3 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)) @@ -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 00000000..e6e354fd --- /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 */ @@ -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 00000000..dd55e6f1 --- /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 */ |