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