2
* Copyright � 2004 Eric Anholt
4
* Permission to use, copy, modify, distribute, and sell this software and its
5
* documentation for any purpose is hereby granted without fee, provided that
6
* the above copyright notice appear in all copies and that both that
7
* copyright notice and this permission notice appear in supporting
8
* documentation, and that the name of Eric Anholt not be used in
9
* advertising or publicity pertaining to distribution of the software without
10
* specific, written prior permission. Eric Anholt makes no
11
* representations about the suitability of this software for any purpose. It
12
* is provided "as is" without express or implied warranty.
14
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16
* EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
* PERFORMANCE OF THIS SOFTWARE.
22
/* $Header: /cvs/xorg/xserver/xorg/hw/kdrive/ati/ati_dma.h,v 1.6 2005/12/27 08:25:55 ajax Exp $ */
30
#define DMA_PACKET0(reg, count) \
31
(ATI_CCE_PACKET0 | (((count) - 1) << 16) | ((reg) >> 2))
33
#define DMA_PACKET0(reg, count) \
34
(__packet0count = (count), __reg = (reg), \
35
ATI_CCE_PACKET0 | (((count) - 1) << 16) | ((reg) >> 2))
37
#define DMA_PACKET1(reg1, reg2) \
39
(((reg2) >> 2) << ATI_CCE_PACKET1_REG_2_SHIFT) | ((reg1) >> 2))
40
#define DMA_PACKET3(type, count) \
41
((type) | (((count) - 1) << 16))
45
#define RING_LOCALS CARD32 *__head; int __count
46
#define BEGIN_DMA(n) \
48
if ((atis->indirectBuffer->used + 4*(n)) > \
49
atis->indirectBuffer->size) { \
50
ATIFlushIndirect(atis, 1); \
52
__head = (CARD32 *)((char *)atis->indirectBuffer->address + \
53
atis->indirectBuffer->used); \
56
#define END_DMA() do { \
57
atis->indirectBuffer->used += __count * 4; \
63
CARD32 *__head; int __count, __total, __reg, __packet0count
64
#define BEGIN_DMA(n) \
66
if ((atis->indirectBuffer->used + 4*(n)) > \
67
atis->indirectBuffer->size) { \
68
ATIFlushIndirect(atis, 1); \
70
__head = (CARD32 *)((char *)atis->indirectBuffer->address + \
71
atis->indirectBuffer->used); \
77
#define END_DMA() do { \
78
if (__count != __total) \
79
FatalError("count != total (%d vs %d) at %s:%d\n", \
80
__count, __total, __FILE__, __LINE__); \
81
atis->indirectBuffer->used += __count * 4; \
86
#define OUT_RING(val) do { \
87
__head[__count++] = (val); \
90
#define OUT_RING_REG(reg, val) do { \
92
FatalError("unexpected reg (0x%x vs 0x%x) at %s:%d\n", \
93
reg, __reg, __FILE__, __LINE__); \
94
if (__packet0count-- <= 0) \
95
FatalError("overrun of packet0 at %s:%d\n", \
96
__FILE__, __LINE__); \
97
__head[__count++] = (val); \
101
#define OUT_RING_F(x) OUT_RING(GET_FLOAT_BITS(x))
103
#define OUT_REG(reg, val) \
105
OUT_RING(DMA_PACKET0(reg, 1)); \
109
#define TIMEOUT_LOCALS struct timeval _target, _curtime
112
tv_le(struct timeval *tv1, struct timeval *tv2)
114
if (tv1->tv_sec < tv2->tv_sec ||
115
(tv1->tv_sec == tv2->tv_sec && tv1->tv_usec < tv2->tv_usec))
121
#define WHILE_NOT_TIMEOUT(_timeout) \
122
gettimeofday(&_target, NULL); \
123
_target.tv_usec += ((_timeout) * 1000000); \
124
_target.tv_sec += _target.tv_usec / 1000000; \
125
_target.tv_usec = _target.tv_usec % 1000000; \
126
while (gettimeofday(&_curtime, NULL), tv_le(&_curtime, &_target))
128
#define TIMEDOUT() (!tv_le(&_curtime, &_target))
131
ATIGetDMABuffer(ATIScreenInfo *atis);
134
ATIFlushIndirect(ATIScreenInfo *atis, Bool discard);
137
ATIDMASetup(ScreenPtr pScreen);
140
ATIDMATeardown(ScreenPtr pScreen);
142
#endif /* _ATI_DMA_H_ */