1 /* mga_drm.h -- Public header for the Matrox g200/g400 driver -*- linux-c -*-
2 * Created: Tue Jan 25 01:50:01 1999 by jhartmann@precisioninsight.com
4 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * 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 NONINFRINGEMENT. IN NO EVENT SHALL
21 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 * DEALINGS IN THE SOFTWARE.
26 * Authors: Jeff Hartmann <jhartmann@precisioninsight.com>
27 * Keith Whitwell <keithw@precisioninsight.com>
35 /* WARNING: If you change any of these defines, make sure to change the
36 * defines in the Xserver file (xf86drmMga.h)
40 #define MGA_F 0x1 /* fog */
41 #define MGA_A 0x2 /* alpha */
42 #define MGA_S 0x4 /* specular */
43 #define MGA_T2 0x8 /* multitexture */
45 #define MGA_WARP_TGZ 0
46 #define MGA_WARP_TGZF (MGA_F)
47 #define MGA_WARP_TGZA (MGA_A)
48 #define MGA_WARP_TGZAF (MGA_F|MGA_A)
49 #define MGA_WARP_TGZS (MGA_S)
50 #define MGA_WARP_TGZSF (MGA_S|MGA_F)
51 #define MGA_WARP_TGZSA (MGA_S|MGA_A)
52 #define MGA_WARP_TGZSAF (MGA_S|MGA_F|MGA_A)
53 #define MGA_WARP_T2GZ (MGA_T2)
54 #define MGA_WARP_T2GZF (MGA_T2|MGA_F)
55 #define MGA_WARP_T2GZA (MGA_T2|MGA_A)
56 #define MGA_WARP_T2GZAF (MGA_T2|MGA_A|MGA_F)
57 #define MGA_WARP_T2GZS (MGA_T2|MGA_S)
58 #define MGA_WARP_T2GZSF (MGA_T2|MGA_S|MGA_F)
59 #define MGA_WARP_T2GZSA (MGA_T2|MGA_S|MGA_A)
60 #define MGA_WARP_T2GZSAF (MGA_T2|MGA_S|MGA_F|MGA_A)
62 #define MGA_MAX_G400_PIPES 16
63 #define MGA_MAX_G200_PIPES 8 /* no multitex */
65 #define MGA_MAX_WARP_PIPES MGA_MAX_G400_PIPES
67 #define MGA_CARD_TYPE_G200 1
68 #define MGA_CARD_TYPE_G400 2
73 /* 3d state excluding texture units:
75 #define MGA_CTXREG_DSTORG 0 /* validated */
76 #define MGA_CTXREG_MACCESS 1
77 #define MGA_CTXREG_PLNWT 2
78 #define MGA_CTXREG_DWGCTL 3
79 #define MGA_CTXREG_ALPHACTRL 4
80 #define MGA_CTXREG_FOGCOLOR 5
81 #define MGA_CTXREG_WFLAG 6
82 #define MGA_CTXREG_TDUAL0 7
83 #define MGA_CTXREG_TDUAL1 8
84 #define MGA_CTXREG_FCOL 9
85 #define MGA_CTX_SETUP_SIZE 10
89 #define MGA_2DREG_PITCH 0
90 #define MGA_2D_SETUP_SIZE 1
92 /* Each texture unit has a state:
94 #define MGA_TEXREG_CTL 0
95 #define MGA_TEXREG_CTL2 1
96 #define MGA_TEXREG_FILTER 2
97 #define MGA_TEXREG_BORDERCOL 3
98 #define MGA_TEXREG_ORG 4 /* validated */
99 #define MGA_TEXREG_ORG1 5
100 #define MGA_TEXREG_ORG2 6
101 #define MGA_TEXREG_ORG3 7
102 #define MGA_TEXREG_ORG4 8
103 #define MGA_TEXREG_WIDTH 9
104 #define MGA_TEXREG_HEIGHT 10
105 #define MGA_TEX_SETUP_SIZE 11
107 /* What needs to be changed for the current vertex dma buffer?
109 #define MGA_UPLOAD_CTX 0x1
110 #define MGA_UPLOAD_TEX0 0x2
111 #define MGA_UPLOAD_TEX1 0x4
112 #define MGA_UPLOAD_PIPE 0x8
113 #define MGA_UPLOAD_TEX0IMAGE 0x10
114 #define MGA_UPLOAD_TEX1IMAGE 0x20
115 #define MGA_UPLOAD_2D 0x40
116 #define MGA_WAIT_AGE 0x80 /* handled client-side */
117 #define MGA_UPLOAD_CLIPRECTS 0x100 /* handled client-side */
118 #define MGA_DMA_FLUSH 0x200 /* set when someone gets the lock
121 /* 64 buffers of 16k each, total 1 meg.
123 #define MGA_DMA_BUF_ORDER 14
124 #define MGA_DMA_BUF_SZ (1<<MGA_DMA_BUF_ORDER)
125 #define MGA_DMA_BUF_NR 63
127 /* Keep these small for testing.
129 #define MGA_NR_SAREA_CLIPRECTS 8
131 /* 2 heaps (1 for card, 1 for agp), each divided into upto 128
132 * regions, subject to a minimum region size of (1<<16) == 64k.
134 * Clients may subdivide regions internally, but when sharing between
135 * clients, the region size is the minimum granularity.
138 #define MGA_CARD_HEAP 0
139 #define MGA_AGP_HEAP 1
140 #define MGA_NR_TEX_HEAPS 2
141 #define MGA_NR_TEX_REGIONS 16
142 #define MGA_LOG_MIN_TEX_REGION_SIZE 16
145 typedef struct _drm_mga_warp_index {
147 unsigned long phys_addr;
149 } drm_mga_warp_index_t;
151 typedef struct drm_mga_init {
154 MGA_CLEANUP_DMA = 0x02
156 int reserved_map_agpstart;
157 int reserved_map_idx;
159 int sarea_priv_offset;
167 int agpTextureOffset;
173 drm_mga_warp_index_t WarpIndex[MGA_MAX_WARP_PIPES];
177 /* Warning: if you change the sarea structure, you must change the Xserver
178 * structures as well */
180 typedef struct _drm_mga_tex_region {
181 unsigned char next, prev;
182 unsigned char in_use;
184 } drm_mga_tex_region_t;
186 typedef struct _drm_mga_sarea {
187 /* The channel for communication of state information to the kernel
188 * on firing a vertex dma buffer.
190 unsigned int ContextState[MGA_CTX_SETUP_SIZE];
191 unsigned int ServerState[MGA_2D_SETUP_SIZE];
192 unsigned int TexState[2][MGA_TEX_SETUP_SIZE];
193 unsigned int WarpPipe;
197 drm_clip_rect_t boxes[MGA_NR_SAREA_CLIPRECTS];
200 /* Information about the most recently used 3d drawable. The
201 * client fills in the req_* fields, the server fills in the
202 * exported_ fields and puts the cliprects into boxes, above.
204 * The client clears the exported_drawable field before
205 * clobbering the boxes data.
207 unsigned int req_drawable; /* the X drawable id */
208 unsigned int req_draw_buffer; /* MGA_FRONT or MGA_BACK */
210 unsigned int exported_drawable;
211 unsigned int exported_index;
212 unsigned int exported_stamp;
213 unsigned int exported_buffers;
214 unsigned int exported_nfront;
215 unsigned int exported_nback;
216 int exported_back_x, exported_front_x, exported_w;
217 int exported_back_y, exported_front_y, exported_h;
218 drm_clip_rect_t exported_boxes[MGA_NR_SAREA_CLIPRECTS];
220 /* Counters for aging textures and for client-side throttling.
222 int last_enqueue; /* last time a buffer was enqueued */
223 int last_dispatch; /* age of the most recently dispatched buffer */
224 int last_quiescent; /* */
227 /* LRU lists for texture memory in agp space and on the card
229 drm_mga_tex_region_t texList[MGA_NR_TEX_HEAPS][MGA_NR_TEX_REGIONS+1];
230 unsigned int texAge[MGA_NR_TEX_HEAPS];
232 /* Mechanism to validate card state.
237 /* Device specific ioctls:
239 typedef struct _drm_mga_clear {
245 typedef struct _drm_mga_swap {
249 typedef struct _drm_mga_iload {
252 unsigned int destOrg;
255 typedef struct _drm_mga_vertex {
256 int idx; /* buffer to queue */
257 int used; /* bytes in use */
258 int discard; /* client finished with buffer? */