uint*t -> u_int*t changes
[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 "mga_drm.h"
37 #include "mtypes.h"
38 #include "mgaregs.h"
39 #include "xmlconfig.h"
40
41 typedef struct mga_screen_private_s {
42
43 int chipset;
44 int width;
45 int height;
46 int mem;
47
48 int cpp; /* for front and back buffers */
49 GLint agpMode;
50 unsigned int irq; /* IRQ number (0 means none) */
51 GLboolean linecomp_sane; /* GL_TRUE if line comp. programmed correctly
52 * by the DDX driver.
53 */
54
55 unsigned int mAccess;
56
57 unsigned int frontOffset;
58 unsigned int frontPitch;
59 unsigned int backOffset;
60 unsigned int backPitch;
61
62 unsigned int depthOffset;
63 unsigned int depthPitch;
64 int depthCpp;
65
66 unsigned int dmaOffset;
67
68 unsigned int textureOffset[MGA_NR_TEX_HEAPS];
69 unsigned int textureSize[MGA_NR_TEX_HEAPS];
70 int logTextureGranularity[MGA_NR_TEX_HEAPS];
71 char *texVirtual[MGA_NR_TEX_HEAPS];
72
73
74 __DRIscreenPrivate *sPriv;
75 drmBufMapPtr bufs;
76
77 drmRegion mmio;
78 drmRegion status;
79 drmRegion primary;
80 drmRegion buffers;
81 unsigned int sarea_priv_offset;
82
83 /* Configuration cache with default values for all contexts */
84 driOptionCache optionCache;
85 } mgaScreenPrivate;
86
87
88 #include "mgacontext.h"
89
90 extern void mgaGetLock( mgaContextPtr mmesa, GLuint flags );
91 extern void mgaEmitHwStateLocked( mgaContextPtr mmesa );
92 extern void mgaEmitScissorValues( mgaContextPtr mmesa, int box_nr, int emit );
93
94 #define GET_DISPATCH_AGE( mmesa ) mmesa->sarea->last_dispatch
95 #define GET_ENQUEUE_AGE( mmesa ) mmesa->sarea->last_enqueue
96
97
98
99 /* Lock the hardware and validate our state.
100 */
101 #define LOCK_HARDWARE( mmesa ) \
102 do { \
103 char __ret=0; \
104 DRM_CAS(mmesa->driHwLock, mmesa->hHWContext, \
105 (DRM_LOCK_HELD|mmesa->hHWContext), __ret); \
106 if (__ret) \
107 mgaGetLock( mmesa, 0 ); \
108 } while (0)
109
110
111 /*
112 */
113 #define LOCK_HARDWARE_QUIESCENT( mmesa ) do { \
114 LOCK_HARDWARE( mmesa ); \
115 UPDATE_LOCK( mmesa, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH ); \
116 } while (0)
117
118
119 /* Unlock the hardware using the global current context
120 */
121 #define UNLOCK_HARDWARE(mmesa) \
122 DRM_UNLOCK(mmesa->driFd, mmesa->driHwLock, mmesa->hHWContext);
123
124
125 /* Freshen our snapshot of the drawables
126 */
127 #define REFRESH_DRAWABLE_INFO( mmesa ) \
128 do { \
129 LOCK_HARDWARE( mmesa ); \
130 mmesa->lastX = mmesa->drawX; \
131 mmesa->lastY = mmesa->drawY; \
132 UNLOCK_HARDWARE( mmesa ); \
133 } while (0)
134
135
136 #define GET_DRAWABLE_LOCK( mmesa ) while(0)
137 #define RELEASE_DRAWABLE_LOCK( mmesa ) while(0)
138
139
140 /* The 2D driver macros are busted -- we can't use them here as they
141 * rely on the 2D driver data structures rather than taking an explicit
142 * base address.
143 */
144 #define MGA_BASE( reg ) ((unsigned long)(mmesa->mgaScreen->mmio.map))
145 #define MGA_ADDR( reg ) (MGA_BASE(reg) + reg)
146
147 #define MGA_DEREF( reg ) *(volatile u_int32_t *)MGA_ADDR( reg )
148 #define MGA_READ( reg ) MGA_DEREF( reg )
149 #define MGA_WRITE( reg, val ) do { MGA_DEREF( reg ) = val; } while (0)
150
151 #endif
152 #endif