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