Remove CVS keywords.
[mesa.git] / src / mesa / drivers / dri / r128 / r128_ioctl.h
1 /**************************************************************************
2
3 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
4 Cedar Park, Texas.
5 All Rights Reserved.
6
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files (the "Software"),
9 to deal in the Software without restriction, including without limitation
10 on the rights to use, copy, modify, merge, publish, distribute, sub
11 license, and/or sell copies of the Software, and to permit persons to whom
12 the Software is furnished to do so, subject to the following conditions:
13
14 The above copyright notice and this permission notice (including the next
15 paragraph) shall be included in all copies or substantial portions of the
16 Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 USE OR OTHER DEALINGS IN THE SOFTWARE.
25
26 **************************************************************************/
27
28 /*
29 * Authors:
30 * Gareth Hughes <gareth@valinux.com>
31 *
32 */
33
34 #ifndef __R128_IOCTL_H__
35 #define __R128_IOCTL_H__
36
37 #include "r128_dri.h"
38 #include "r128_reg.h"
39 #include "r128_lock.h"
40
41 #define R128_BUFFER_MAX_DWORDS (R128_BUFFER_SIZE / sizeof(u_int32_t))
42
43
44 extern drmBufPtr r128GetBufferLocked( r128ContextPtr rmesa );
45 extern void r128FlushVerticesLocked( r128ContextPtr rmesa );
46
47 static __inline void *r128AllocDmaLow( r128ContextPtr rmesa, int count,
48 int vert_size )
49 {
50 u_int32_t *head;
51 int bytes = count * vert_size;
52
53 if ( !rmesa->vert_buf ) {
54 LOCK_HARDWARE( rmesa );
55 rmesa->vert_buf = r128GetBufferLocked( rmesa );
56 UNLOCK_HARDWARE( rmesa );
57 } else if ( rmesa->vert_buf->used + bytes > rmesa->vert_buf->total ) {
58 LOCK_HARDWARE( rmesa );
59 r128FlushVerticesLocked( rmesa );
60 rmesa->vert_buf = r128GetBufferLocked( rmesa );
61 UNLOCK_HARDWARE( rmesa );
62 }
63
64 head = (u_int32_t *)((char *)rmesa->vert_buf->address + rmesa->vert_buf->used);
65 rmesa->vert_buf->used += bytes;
66 rmesa->num_verts += count;
67
68 return head;
69 }
70
71 extern void r128FireBlitLocked( r128ContextPtr rmesa, drmBufPtr buffer,
72 GLint offset, GLint pitch, GLint format,
73 GLint x, GLint y, GLint width, GLint height );
74
75 extern void r128WriteDepthSpanLocked( r128ContextPtr rmesa,
76 GLuint n, GLint x, GLint y,
77 const GLuint depth[],
78 const GLubyte mask[] );
79 extern void r128WriteDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
80 const GLint x[], const GLint y[],
81 const GLuint depth[],
82 const GLubyte mask[] );
83 extern void r128ReadDepthSpanLocked( r128ContextPtr rmesa,
84 GLuint n, GLint x, GLint y );
85 extern void r128ReadDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
86 const GLint x[], const GLint y[] );
87
88 extern void r128CopyBuffer( const __DRIdrawablePrivate *dPriv );
89 extern void r128PageFlip( const __DRIdrawablePrivate *dPriv );
90 void r128WaitForVBlank( r128ContextPtr rmesa );
91
92 extern void r128WaitForIdleLocked( r128ContextPtr rmesa );
93
94
95 extern void r128InitIoctlFuncs( struct dd_function_table *functions );
96
97
98 /* ================================================================
99 * Helper macros:
100 */
101
102 #define FLUSH_BATCH( rmesa ) \
103 do { \
104 if ( R128_DEBUG & DEBUG_VERBOSE_IOCTL ) \
105 fprintf( stderr, "FLUSH_BATCH in %s\n", __FUNCTION__ ); \
106 if ( rmesa->vert_buf ) { \
107 r128FlushVertices( rmesa ); \
108 } \
109 } while (0)
110
111 /* 64-bit align the next element address, and then make room for the
112 * next indexed prim packet header.
113 */
114 #define ALIGN_NEXT_ELT( rmesa ) \
115 do { \
116 rmesa->next_elt = (GLushort *) \
117 (((GLuint)rmesa->next_elt + 7) & ~0x7); \
118 rmesa->next_elt = (GLushort *) \
119 ((GLubyte *)rmesa->next_elt + R128_INDEX_PRIM_OFFSET); \
120 } while (0)
121
122 #define r128FlushVertices( rmesa ) \
123 do { \
124 LOCK_HARDWARE( rmesa ); \
125 r128FlushVerticesLocked( rmesa ); \
126 UNLOCK_HARDWARE( rmesa ); \
127 } while (0)
128
129 #define r128FlushElts( rmesa ) \
130 do { \
131 LOCK_HARDWARE( rmesa ); \
132 r128FlushEltsLocked( rmesa ); \
133 UNLOCK_HARDWARE( rmesa ); \
134 } while (0)
135
136 #define r128WaitForIdle( rmesa ) \
137 do { \
138 LOCK_HARDWARE( rmesa ); \
139 r128WaitForIdleLocked( rmesa ); \
140 UNLOCK_HARDWARE( rmesa ); \
141 } while (0)
142
143 #endif /* __R128_IOCTL_H__ */