ee0b5296bb8bdc6376fd5400a67e03afbde93a59
1 /* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
3 * Copyright 2000 Gareth Hughes
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * GARETH HUGHES BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Gareth Hughes <gareth@valinux.com>
28 * Leif Delgass <ldelgass@retinalburn.net>
29 * José Fonseca <j_r_fonseca@yahoo.co.uk>
32 #ifndef __MACH64_IOCTL_H__
33 #define __MACH64_IOCTL_H__
35 #ifdef GLX_DIRECT_RENDERING
37 #include "mach64_dri.h"
38 #include "mach64_reg.h"
39 #include "mach64_lock.h"
42 #include "mach64_common.h"
44 #define MACH64_BUFFER_MAX_DWORDS (MACH64_BUFFER_SIZE / sizeof(CARD32))
47 extern drmBufPtr
mach64GetBufferLocked( mach64ContextPtr mmesa
);
48 extern void mach64FlushVerticesLocked( mach64ContextPtr mmesa
);
49 extern void mach64FlushDMALocked( mach64ContextPtr mmesa
);
50 extern void mach64UploadHwStateLocked( mach64ContextPtr mmesa
);
52 static __inline
void *mach64AllocDmaLow( mach64ContextPtr mmesa
, int bytes
)
56 if ( mmesa
->vert_used
+ bytes
> mmesa
->vert_total
) {
57 LOCK_HARDWARE( mmesa
);
58 mach64FlushVerticesLocked( mmesa
);
59 UNLOCK_HARDWARE( mmesa
);
62 head
= (CARD32
*)((char *)mmesa
->vert_buf
+ mmesa
->vert_used
);
63 mmesa
->vert_used
+= bytes
;
68 static __inline
void *mach64AllocDmaLocked( mach64ContextPtr mmesa
, int bytes
)
72 if ( mmesa
->vert_used
+ bytes
> mmesa
->vert_total
) {
73 mach64FlushVerticesLocked( mmesa
);
76 head
= (CARD32
*)((char *)mmesa
->vert_buf
+ mmesa
->vert_used
);
77 mmesa
->vert_used
+= bytes
;
82 extern void mach64FireBlitLocked( mach64ContextPtr mmesa
, drmBufPtr buffer
,
83 GLint offset
, GLint pitch
, GLint format
,
84 GLint x
, GLint y
, GLint width
, GLint height
);
86 extern void mach64CopyBuffer( const __DRIdrawablePrivate
*dPriv
);
88 extern void mach64PerformanceCounters( mach64ContextPtr mmesa
);
89 extern void mach64PerformanceBoxesLocked( mach64ContextPtr mmesa
);
91 extern void mach64WaitForIdleLocked( mach64ContextPtr mmesa
);
93 extern void mach64InitIoctlFuncs( struct dd_function_table
*functions
);
95 /* ================================================================
99 #define FLUSH_BATCH( mmesa ) \
101 if ( MACH64_DEBUG & DEBUG_VERBOSE_IOCTL ) \
102 fprintf( stderr, "FLUSH_BATCH in %s\n", __FUNCTION__ ); \
103 if ( mmesa->vert_used ) { \
104 mach64FlushVertices( mmesa ); \
108 /* According to a comment in ATIMach64Sync (atimach64.c) in the DDX:
110 * "For VTB's and later, the first CPU read of the framebuffer will return
111 * zeroes [...] This appears to be due to some kind of engine
112 * caching of framebuffer data I haven't found any way of disabling, or
113 * otherwise circumventing."
115 #define FINISH_DMA_LOCKED( mmesa ) \
118 if ( MACH64_DEBUG & DEBUG_VERBOSE_IOCTL ) \
119 fprintf( stderr, "FINISH_DMA_LOCKED in %s\n", __FUNCTION__ ); \
120 if ( mmesa->vert_used ) { \
121 mach64FlushVerticesLocked( mmesa ); \
123 mach64WaitForIdleLocked( mmesa ); \
124 /* pre-read framebuffer to counter caching problem */ \
125 _tmp = *(volatile CARD32 *)mmesa->driScreen->pFB; \
128 #define FLUSH_DMA_LOCKED( mmesa ) \
130 if ( MACH64_DEBUG & DEBUG_VERBOSE_IOCTL ) \
131 fprintf( stderr, "FLUSH_DMA_LOCKED in %s\n", __FUNCTION__ ); \
132 if ( mmesa->vert_used ) { \
133 mach64FlushVerticesLocked( mmesa ); \
135 mach64FlushDMALocked( mmesa ); \
138 #define mach64FlushVertices( mmesa ) \
140 LOCK_HARDWARE( mmesa ); \
141 mach64FlushVerticesLocked( mmesa ); \
142 UNLOCK_HARDWARE( mmesa ); \
145 #define mach64WaitForIdle( mmesa ) \
147 LOCK_HARDWARE( mmesa ); \
148 mach64WaitForIdleLocked( mmesa ); \
149 UNLOCK_HARDWARE( mmesa ); \
154 #endif /* __MACH64_IOCTL_H__ */