patch to import Jon Smirl's work from Bitkeeper
[mesa.git] / src / mesa / drivers / dri / mga / mga_xmesa.h
1 /*
2 * Copyright 2000-2001 VA Linux Systems, Inc.
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Keith Whitwell <keith@tungstengraphics.com>
26 */
27 /* $XFree86: xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h,v 1.12 2002/12/16 16:18:52 dawes Exp $ */
28
29 #ifndef _MGA_INIT_H_
30 #define _MGA_INIT_H_
31
32 #ifdef GLX_DIRECT_RENDERING
33
34 #include <sys/time.h>
35 #include "dri_util.h"
36 #include "mtypes.h"
37 #include "mgaregs.h"
38 #include "mga_common.h"
39
40 typedef struct mga_screen_private_s {
41
42 int chipset;
43 int width;
44 int height;
45 int mem;
46
47 int cpp; /* for front and back buffers */
48 GLint agpMode;
49 unsigned int irq; /* IRQ number (0 means none) */
50 GLboolean linecomp_sane; /* GL_TRUE if line comp. programmed correctly
51 * by the DDX driver.
52 */
53
54 unsigned int mAccess;
55
56 unsigned int frontOffset;
57 unsigned int frontPitch;
58 unsigned int backOffset;
59 unsigned int backPitch;
60
61 unsigned int depthOffset;
62 unsigned int depthPitch;
63 int depthCpp;
64
65 unsigned int dmaOffset;
66
67 unsigned int textureOffset[DRM_MGA_NR_TEX_HEAPS];
68 unsigned int textureSize[DRM_MGA_NR_TEX_HEAPS];
69 int logTextureGranularity[DRM_MGA_NR_TEX_HEAPS];
70 char *texVirtual[DRM_MGA_NR_TEX_HEAPS];
71
72
73 __DRIscreenPrivate *sPriv;
74 drmBufMapPtr bufs;
75
76 drmRegion mmio;
77 drmRegion status;
78 drmRegion primary;
79 drmRegion buffers;
80 unsigned int sarea_priv_offset;
81 } mgaScreenPrivate;
82
83
84 #include "mgacontext.h"
85
86 extern void mgaGetLock( mgaContextPtr mmesa, GLuint flags );
87 extern void mgaEmitHwStateLocked( mgaContextPtr mmesa );
88 extern void mgaEmitScissorValues( mgaContextPtr mmesa, int box_nr, int emit );
89
90 #define GET_DISPATCH_AGE( mmesa ) mmesa->sarea->last_dispatch
91 #define GET_ENQUEUE_AGE( mmesa ) mmesa->sarea->last_enqueue
92
93
94
95 /* Lock the hardware and validate our state.
96 */
97 #define LOCK_HARDWARE( mmesa ) \
98 do { \
99 char __ret=0; \
100 DRM_CAS(mmesa->driHwLock, mmesa->hHWContext, \
101 (DRM_LOCK_HELD|mmesa->hHWContext), __ret); \
102 if (__ret) \
103 mgaGetLock( mmesa, 0 ); \
104 } while (0)
105
106
107 /*
108 */
109 #define LOCK_HARDWARE_QUIESCENT( mmesa ) do { \
110 LOCK_HARDWARE( mmesa ); \
111 UPDATE_LOCK( mmesa, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH ); \
112 } while (0)
113
114
115 /* Unlock the hardware using the global current context
116 */
117 #define UNLOCK_HARDWARE(mmesa) \
118 DRM_UNLOCK(mmesa->driFd, mmesa->driHwLock, mmesa->hHWContext);
119
120
121 /* Freshen our snapshot of the drawables
122 */
123 #define REFRESH_DRAWABLE_INFO( mmesa ) \
124 do { \
125 LOCK_HARDWARE( mmesa ); \
126 mmesa->lastX = mmesa->drawX; \
127 mmesa->lastY = mmesa->drawY; \
128 UNLOCK_HARDWARE( mmesa ); \
129 } while (0)
130
131
132 #define GET_DRAWABLE_LOCK( mmesa ) while(0)
133 #define RELEASE_DRAWABLE_LOCK( mmesa ) while(0)
134
135
136 /* The 2D driver macros are busted -- we can't use them here as they
137 * rely on the 2D driver data structures rather than taking an explicit
138 * base address.
139 */
140 #define MGA_BASE( reg ) ((unsigned long)(mmesa->mgaScreen->mmio.map))
141 #define MGA_ADDR( reg ) (MGA_BASE(reg) + reg)
142
143 #define MGA_DEREF( reg ) *(volatile CARD32 *)MGA_ADDR( reg )
144 #define MGA_READ( reg ) MGA_DEREF( reg )
145 #define MGA_WRITE( reg, val ) do { MGA_DEREF( reg ) = val; } while (0)
146
147 #endif
148 #endif