1 /**************************************************************************
3 Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
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:
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
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.
26 **************************************************************************/
30 * Gareth Hughes <gareth@valinux.com>
34 #ifndef __R128_IOCTL_H__
35 #define __R128_IOCTL_H__
39 #include "r128_lock.h"
41 #define R128_BUFFER_MAX_DWORDS (R128_BUFFER_SIZE / sizeof(uint32_t))
44 extern drmBufPtr
r128GetBufferLocked( r128ContextPtr rmesa
);
45 extern void r128FlushVerticesLocked( r128ContextPtr rmesa
);
47 static INLINE
void *r128AllocDmaLow( r128ContextPtr rmesa
, int count
,
51 int bytes
= count
* vert_size
;
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
);
64 head
= (uint32_t *)((char *)rmesa
->vert_buf
->address
+ rmesa
->vert_buf
->used
);
65 rmesa
->vert_buf
->used
+= bytes
;
66 rmesa
->num_verts
+= count
;
71 extern void r128FireBlitLocked( r128ContextPtr rmesa
, drmBufPtr buffer
,
72 GLint offset
, GLint pitch
, GLint format
,
73 GLint x
, GLint y
, GLint width
, GLint height
);
75 extern void r128WriteDepthSpanLocked( r128ContextPtr rmesa
,
76 GLuint n
, GLint x
, GLint y
,
78 const GLubyte mask
[] );
79 extern void r128WriteDepthPixelsLocked( r128ContextPtr rmesa
, GLuint n
,
80 const GLint x
[], const GLint y
[],
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
[] );
88 extern void r128CopyBuffer( __DRIdrawablePrivate
*dPriv
);
89 extern void r128PageFlip( __DRIdrawablePrivate
*dPriv
);
90 void r128WaitForVBlank( r128ContextPtr rmesa
);
92 extern void r128WaitForIdleLocked( r128ContextPtr rmesa
);
95 extern void r128InitIoctlFuncs( struct dd_function_table
*functions
);
98 /* ================================================================
102 #define FLUSH_BATCH( rmesa ) \
104 if ( R128_DEBUG & DEBUG_VERBOSE_IOCTL ) \
105 fprintf( stderr, "FLUSH_BATCH in %s\n", __FUNCTION__ ); \
106 if ( rmesa->vert_buf ) { \
107 r128FlushVertices( rmesa ); \
111 /* 64-bit align the next element address, and then make room for the
112 * next indexed prim packet header.
114 #define ALIGN_NEXT_ELT( rmesa ) \
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); \
122 #define r128FlushVertices( rmesa ) \
124 LOCK_HARDWARE( rmesa ); \
125 r128FlushVerticesLocked( rmesa ); \
126 UNLOCK_HARDWARE( rmesa ); \
129 #define r128FlushElts( rmesa ) \
131 LOCK_HARDWARE( rmesa ); \
132 r128FlushEltsLocked( rmesa ); \
133 UNLOCK_HARDWARE( rmesa ); \
136 #define r128WaitForIdle( rmesa ) \
138 LOCK_HARDWARE( rmesa ); \
139 r128WaitForIdleLocked( rmesa ); \
140 UNLOCK_HARDWARE( rmesa ); \
143 #endif /* __R128_IOCTL_H__ */