patch to import Jon Smirl's work from Bitkeeper
[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 #include "xf86drm.h"
45 #include "r128_common.h"
46
47 #define R128_BUFFER_MAX_DWORDS (R128_BUFFER_SIZE / sizeof(CARD32))
48
49
50 extern drmBufPtr r128GetBufferLocked( r128ContextPtr rmesa );
51 extern void r128FlushVerticesLocked( r128ContextPtr rmesa );
52
53 static __inline void *r128AllocDmaLow( r128ContextPtr rmesa, int bytes )
54 {
55 CARD32 *head;
56
57 if ( !rmesa->vert_buf ) {
58 LOCK_HARDWARE( rmesa );
59 rmesa->vert_buf = r128GetBufferLocked( rmesa );
60 UNLOCK_HARDWARE( rmesa );
61 } else if ( rmesa->vert_buf->used + bytes > rmesa->vert_buf->total ) {
62 LOCK_HARDWARE( rmesa );
63 r128FlushVerticesLocked( rmesa );
64 rmesa->vert_buf = r128GetBufferLocked( rmesa );
65 UNLOCK_HARDWARE( rmesa );
66 }
67
68 head = (CARD32 *)((char *)rmesa->vert_buf->address + rmesa->vert_buf->used);
69 rmesa->vert_buf->used += bytes;
70 return head;
71 }
72
73 extern void r128FireBlitLocked( r128ContextPtr rmesa, drmBufPtr buffer,
74 GLint offset, GLint pitch, GLint format,
75 GLint x, GLint y, GLint width, GLint height );
76
77 extern void r128WriteDepthSpanLocked( r128ContextPtr rmesa,
78 GLuint n, GLint x, GLint y,
79 const GLdepth depth[],
80 const GLubyte mask[] );
81 extern void r128WriteDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
82 const GLint x[], const GLint y[],
83 const GLdepth depth[],
84 const GLubyte mask[] );
85 extern void r128ReadDepthSpanLocked( r128ContextPtr rmesa,
86 GLuint n, GLint x, GLint y );
87 extern void r128ReadDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
88 const GLint x[], const GLint y[] );
89
90 extern void r128CopyBuffer( const __DRIdrawablePrivate *dPriv );
91 extern void r128PageFlip( const __DRIdrawablePrivate *dPriv );
92 void r128WaitForVBlank( r128ContextPtr rmesa );
93
94 extern void r128WaitForIdleLocked( r128ContextPtr rmesa );
95
96
97 extern void r128DDInitIoctlFuncs( GLcontext *ctx );
98
99
100 /* ================================================================
101 * Helper macros:
102 */
103
104 #define FLUSH_BATCH( rmesa ) \
105 do { \
106 if ( R128_DEBUG & DEBUG_VERBOSE_IOCTL ) \
107 fprintf( stderr, "FLUSH_BATCH in %s\n", __FUNCTION__ ); \
108 if ( rmesa->vert_buf ) { \
109 r128FlushVertices( rmesa ); \
110 } \
111 } while (0)
112
113 /* 64-bit align the next element address, and then make room for the
114 * next indexed prim packet header.
115 */
116 #define ALIGN_NEXT_ELT( rmesa ) \
117 do { \
118 rmesa->next_elt = (GLushort *) \
119 (((GLuint)rmesa->next_elt + 7) & ~0x7); \
120 rmesa->next_elt = (GLushort *) \
121 ((GLubyte *)rmesa->next_elt + R128_INDEX_PRIM_OFFSET); \
122 } while (0)
123
124 #define r128FlushVertices( rmesa ) \
125 do { \
126 LOCK_HARDWARE( rmesa ); \
127 r128FlushVerticesLocked( rmesa ); \
128 UNLOCK_HARDWARE( rmesa ); \
129 } while (0)
130
131 #define r128FlushElts( rmesa ) \
132 do { \
133 LOCK_HARDWARE( rmesa ); \
134 r128FlushEltsLocked( rmesa ); \
135 UNLOCK_HARDWARE( rmesa ); \
136 } while (0)
137
138 #define r128WaitForIdle( rmesa ) \
139 do { \
140 LOCK_HARDWARE( rmesa ); \
141 r128WaitForIdleLocked( rmesa ); \
142 UNLOCK_HARDWARE( rmesa ); \
143 } while (0)
144
145 #endif
146 #endif /* __R128_IOCTL_H__ */