1 /**************************************************************************
2  *
3  * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  **************************************************************************/
27 
28 #ifndef _I830_REG_H_
29 #define _I830_REG_H_
30 
31 #define I830_SET_FIELD( var, mask, value ) (var &= ~(mask), var |= value)
32 
33 /* Flush */
34 #define MI_FLUSH			(0x04<<23)
35 #define MI_FLUSH_DW			(0x26<<23)
36 
37 #define MI_WRITE_DIRTY_STATE		(1<<4)
38 #define MI_END_SCENE			(1<<3)
39 #define MI_GLOBAL_SNAPSHOT_COUNT_RESET	(1<<3)
40 #define MI_INHIBIT_RENDER_CACHE_FLUSH	(1<<2)
41 #define MI_STATE_INSTRUCTION_CACHE_FLUSH (1<<1)
42 #define MI_INVALIDATE_MAP_CACHE		(1<<0)
43 /* broadwater flush bits */
44 #define BRW_MI_GLOBAL_SNAPSHOT_RESET   (1 << 3)
45 
46 #define MI_COND_BATCH_BUFFER_END	(0x36<<23 | 1)
47 #define MI_DO_COMPARE			(1<<21)
48 
49 #define MI_BATCH_BUFFER_END	(0xA << 23)
50 
51 /* Noop */
52 #define MI_NOOP				0x00
53 #define MI_NOOP_WRITE_ID		(1<<22)
54 #define MI_NOOP_ID_MASK			(1<<22 - 1)
55 
56 /* Wait for Events */
57 #define MI_WAIT_FOR_EVENT			(0x03<<23)
58 #define MI_WAIT_FOR_PIPEB_SVBLANK		(1<<18)
59 #define MI_WAIT_FOR_PIPEA_SVBLANK		(1<<17)
60 #define MI_WAIT_FOR_OVERLAY_FLIP		(1<<16)
61 #define MI_WAIT_FOR_PIPEB_VBLANK		(1<<7)
62 #define MI_WAIT_FOR_PIPEB_SCAN_LINE_WINDOW	(1<<5)
63 #define MI_WAIT_FOR_PIPEA_VBLANK		(1<<3)
64 #define MI_WAIT_FOR_PIPEA_SCAN_LINE_WINDOW	(1<<1)
65 
66 /* Set the scan line for MI_WAIT_FOR_PIPE?_SCAN_LINE_WINDOW */
67 #define MI_LOAD_SCAN_LINES_INCL			(0x12<<23)
68 #define MI_LOAD_SCAN_LINES_DISPLAY_PIPEA	(0)
69 #define MI_LOAD_SCAN_LINES_DISPLAY_PIPEB	(0x1<<20)
70 
71 /* BLT commands */
72 #define COLOR_BLT_CMD		((2<<29)|(0x40<<22)|(0x3))
73 #define COLOR_BLT_WRITE_ALPHA	(1<<21)
74 #define COLOR_BLT_WRITE_RGB	(1<<20)
75 
76 #define XY_COLOR_BLT_WRITE_ALPHA	(1<<21)
77 #define XY_COLOR_BLT_WRITE_RGB		(1<<20)
78 #define XY_COLOR_BLT_TILED		(1<<11)
79 
80 #define XY_SETUP_CLIP_BLT_CMD		((2<<29)|(3<<22)|1)
81 
82 #define XY_SRC_COPY_BLT_CMD		((2<<29)|(0x53<<22))
83 #define XY_SRC_COPY_BLT_WRITE_ALPHA	(1<<21)
84 #define XY_SRC_COPY_BLT_WRITE_RGB	(1<<20)
85 #define XY_SRC_COPY_BLT_SRC_TILED	(1<<15)
86 #define XY_SRC_COPY_BLT_DST_TILED	(1<<11)
87 
88 #define SRC_COPY_BLT_CMD		((2<<29)|(0x43<<22)|0x4)
89 #define SRC_COPY_BLT_WRITE_ALPHA	(1<<21)
90 #define SRC_COPY_BLT_WRITE_RGB		(1<<20)
91 
92 #define XY_PAT_BLT_IMMEDIATE		((2<<29)|(0x72<<22))
93 
94 #define XY_MONO_PAT_BLT_CMD		((0x2<<29)|(0x52<<22)|0x7)
95 #define XY_MONO_PAT_VERT_SEED		((1<<10)|(1<<9)|(1<<8))
96 #define XY_MONO_PAT_HORT_SEED		((1<<14)|(1<<13)|(1<<12))
97 #define XY_MONO_PAT_BLT_WRITE_ALPHA	(1<<21)
98 #define XY_MONO_PAT_BLT_WRITE_RGB	(1<<20)
99 
100 #define XY_MONO_SRC_BLT_CMD		((0x2<<29)|(0x54<<22)|(0x6))
101 #define XY_MONO_SRC_BLT_WRITE_ALPHA	(1<<21)
102 #define XY_MONO_SRC_BLT_WRITE_RGB	(1<<20)
103 
104 #define CMD_3D (0x3<<29)
105 
106 #define PRIM3D_INLINE		(CMD_3D | (0x1f<<24))
107 #define PRIM3D_TRILIST		(0x0<<18)
108 #define PRIM3D_TRISTRIP 	(0x1<<18)
109 #define PRIM3D_TRISTRIP_RVRSE	(0x2<<18)
110 #define PRIM3D_TRIFAN		(0x3<<18)
111 #define PRIM3D_POLY		(0x4<<18)
112 #define PRIM3D_LINELIST 	(0x5<<18)
113 #define PRIM3D_LINESTRIP	(0x6<<18)
114 #define PRIM3D_RECTLIST 	(0x7<<18)
115 #define PRIM3D_POINTLIST	(0x8<<18)
116 #define PRIM3D_DIB		(0x9<<18)
117 #define PRIM3D_CLEAR_RECT	(0xa<<18)
118 #define PRIM3D_ZONE_INIT	(0xd<<18)
119 #define PRIM3D_MASK		(0x1f<<18)
120 
121 #define _3DSTATE_AA_CMD			(CMD_3D | (0x06<<24))
122 #define AA_LINE_ECAAR_WIDTH_ENABLE	(1<<16)
123 #define AA_LINE_ECAAR_WIDTH_0_5 	0
124 #define AA_LINE_ECAAR_WIDTH_1_0		(1<<14)
125 #define AA_LINE_ECAAR_WIDTH_2_0 	(2<<14)
126 #define AA_LINE_ECAAR_WIDTH_4_0 	(3<<14)
127 #define AA_LINE_REGION_WIDTH_ENABLE	(1<<8)
128 #define AA_LINE_REGION_WIDTH_0_5	0
129 #define AA_LINE_REGION_WIDTH_1_0	(1<<6)
130 #define AA_LINE_REGION_WIDTH_2_0	(2<<6)
131 #define AA_LINE_REGION_WIDTH_4_0	(3<<6)
132 #define AA_LINE_ENABLE			((1<<1) | 1)
133 #define AA_LINE_DISABLE			(1<<1)
134 
135 #define _3DSTATE_BUF_INFO_CMD	(CMD_3D | (0x1d<<24) | (0x8e<<16) | 1)
136 /* Dword 1 */
137 #define BUF_3D_ID_COLOR_BACK	(0x3<<24)
138 #define BUF_3D_ID_DEPTH 	(0x7<<24)
139 #define BUF_3D_USE_FENCE	(1<<23)
140 #define BUF_3D_TILED_SURFACE	(1<<22)
141 #define BUF_3D_TILE_WALK_X	0
142 #define BUF_3D_TILE_WALK_Y	(1<<21)
143 #define BUF_3D_PITCH(x)         (((x)/4)<<2)
144 /* Dword 2 */
145 #define BUF_3D_ADDR(x)		((x) & ~0x3)
146 
147 #define _3DSTATE_COLOR_FACTOR_CMD	(CMD_3D | (0x1d<<24) | (0x1<<16))
148 
149 #define _3DSTATE_COLOR_FACTOR_N_CMD(stage)	(CMD_3D | (0x1d<<24) | \
150 					         ((0x90+(stage))<<16))
151 
152 #define _3DSTATE_CONST_BLEND_COLOR_CMD	(CMD_3D | (0x1d<<24) | (0x88<<16))
153 
154 #define _3DSTATE_DFLT_DIFFUSE_CMD	(CMD_3D | (0x1d<<24) | (0x99<<16))
155 
156 #define _3DSTATE_DFLT_SPEC_CMD		(CMD_3D | (0x1d<<24) | (0x9a<<16))
157 
158 #define _3DSTATE_DFLT_Z_CMD		(CMD_3D | (0x1d<<24) | (0x98<<16))
159 
160 #define _3DSTATE_DST_BUF_VARS_CMD	(CMD_3D | (0x1d<<24) | (0x85<<16))
161 /* Dword 1 */
162 #define DSTORG_HORT_BIAS(x)		((x)<<20)
163 #define DSTORG_VERT_BIAS(x)		((x)<<16)
164 #define COLOR_4_2_2_CHNL_WRT_ALL	0
165 #define COLOR_4_2_2_CHNL_WRT_Y		(1<<12)
166 #define COLOR_4_2_2_CHNL_WRT_CR		(2<<12)
167 #define COLOR_4_2_2_CHNL_WRT_CB		(3<<12)
168 #define COLOR_4_2_2_CHNL_WRT_CRCB	(4<<12)
169 #define COLR_BUF_8BIT			0
170 #define COLR_BUF_RGB555 		(1<<8)
171 #define COLR_BUF_RGB565 		(2<<8)
172 #define COLR_BUF_ARGB8888		(3<<8)
173 #define COLR_BUF_ARGB4444		(8<<8)
174 #define COLR_BUF_ARGB1555		(9<<8)
175 #define DEPTH_IS_Z			0
176 #define DEPTH_IS_W			(1<<6)
177 #define DEPTH_FRMT_16_FIXED		0
178 #define DEPTH_FRMT_16_FLOAT		(1<<2)
179 #define DEPTH_FRMT_24_FIXED_8_OTHER	(2<<2)
180 #define DEPTH_FRMT_24_FLOAT_8_OTHER	(3<<2)
181 #define VERT_LINE_STRIDE_1		(1<<1)
182 #define VERT_LINE_STRIDE_0		0
183 #define VERT_LINE_STRIDE_OFS_1		1
184 #define VERT_LINE_STRIDE_OFS_0		0
185 
186 #define _3DSTATE_DRAW_RECT_CMD		(CMD_3D|(0x1d<<24)|(0x80<<16)|3)
187 /* Dword 1 */
188 #define DRAW_RECT_DIS_DEPTH_OFS 	(1<<30)
189 #define DRAW_DITHER_OFS_X(x)		((x)<<26)
190 #define DRAW_DITHER_OFS_Y(x)		((x)<<24)
191 /* Dword 2 */
192 #define DRAW_YMIN(x)			((x)<<16)
193 #define DRAW_XMIN(x)			(x)
194 /* Dword 3 */
195 #define DRAW_YMAX(x)			((x)<<16)
196 #define DRAW_XMAX(x)			(x)
197 /* Dword 4 */
198 #define DRAW_YORG(x)			((x)<<16)
199 #define DRAW_XORG(x)			(x)
200 
201 #define _3DSTATE_ENABLES_1_CMD		(CMD_3D|(0x3<<24))
202 #define ENABLE_LOGIC_OP_MASK		((1<<23)|(1<<22))
203 #define ENABLE_LOGIC_OP 		((1<<23)|(1<<22))
204 #define DISABLE_LOGIC_OP		(1<<23)
205 #define ENABLE_STENCIL_TEST		((1<<21)|(1<<20))
206 #define DISABLE_STENCIL_TEST		(1<<21)
207 #define ENABLE_DEPTH_BIAS		((1<<11)|(1<<10))
208 #define DISABLE_DEPTH_BIAS		(1<<11)
209 #define ENABLE_SPEC_ADD_MASK		((1<<9)|(1<<8))
210 #define ENABLE_SPEC_ADD 		((1<<9)|(1<<8))
211 #define DISABLE_SPEC_ADD		(1<<9)
212 #define ENABLE_DIS_FOG_MASK		((1<<7)|(1<<6))
213 #define ENABLE_FOG			((1<<7)|(1<<6))
214 #define DISABLE_FOG			(1<<7)
215 #define ENABLE_DIS_ALPHA_TEST_MASK	((1<<5)|(1<<4))
216 #define ENABLE_ALPHA_TEST		((1<<5)|(1<<4))
217 #define DISABLE_ALPHA_TEST		(1<<5)
218 #define ENABLE_DIS_CBLEND_MASK		((1<<3)|(1<<2))
219 #define ENABLE_COLOR_BLEND		((1<<3)|(1<<2))
220 #define DISABLE_COLOR_BLEND		(1<<3)
221 #define ENABLE_DIS_DEPTH_TEST_MASK	((1<<1)|1)
222 #define ENABLE_DEPTH_TEST		((1<<1)|1)
223 #define DISABLE_DEPTH_TEST		(1<<1)
224 
225 /* _3DSTATE_ENABLES_2, p138 */
226 #define _3DSTATE_ENABLES_2_CMD		(CMD_3D|(0x4<<24))
227 #define ENABLE_STENCIL_WRITE		((1<<21)|(1<<20))
228 #define DISABLE_STENCIL_WRITE		(1<<21)
229 #define ENABLE_TEX_CACHE		((1<<17)|(1<<16))
230 #define DISABLE_TEX_CACHE		(1<<17)
231 #define ENABLE_DITHER			((1<<9)|(1<<8))
232 #define DISABLE_DITHER			(1<<9)
233 #define ENABLE_COLOR_MASK		(1<<10)
234 #define WRITEMASK_ALPHA			(1<<7)
235 #define WRITEMASK_ALPHA_SHIFT		7
236 #define WRITEMASK_RED			(1<<6)
237 #define WRITEMASK_RED_SHIFT		6
238 #define WRITEMASK_GREEN 		(1<<5)
239 #define WRITEMASK_GREEN_SHIFT		5
240 #define WRITEMASK_BLUE			(1<<4)
241 #define WRITEMASK_BLUE_SHIFT		4
242 #define WRITEMASK_MASK			((1<<4)|(1<<5)|(1<<6)|(1<<7))
243 #define ENABLE_COLOR_WRITE		((1<<3)|(1<<2))
244 #define DISABLE_COLOR_WRITE		(1<<3)
245 #define ENABLE_DIS_DEPTH_WRITE_MASK	0x3
246 #define ENABLE_DEPTH_WRITE		((1<<1)|1)
247 #define DISABLE_DEPTH_WRITE		(1<<1)
248 
249 /* _3DSTATE_FOG_COLOR, p139 */
250 #define _3DSTATE_FOG_COLOR_CMD		(CMD_3D|(0x15<<24))
251 #define FOG_COLOR_RED(x)		((x)<<16)
252 #define FOG_COLOR_GREEN(x)		((x)<<8)
253 #define FOG_COLOR_BLUE(x)		(x)
254 
255 /* _3DSTATE_FOG_MODE, p140 */
256 #define _3DSTATE_FOG_MODE_CMD		(CMD_3D|(0x1d<<24)|(0x89<<16)|2)
257 /* Dword 1 */
258 #define FOGFUNC_ENABLE			(1<<31)
259 #define FOGFUNC_VERTEX			0
260 #define FOGFUNC_PIXEL_EXP		(1<<28)
261 #define FOGFUNC_PIXEL_EXP2		(2<<28)
262 #define FOGFUNC_PIXEL_LINEAR		(3<<28)
263 #define FOGSRC_INDEX_Z			(1<<27)
264 #define FOGSRC_INDEX_W			((1<<27)|(1<<25))
265 #define FOG_LINEAR_CONST		(1<<24)
266 #define FOG_CONST_1(x)			((x)<<4)
267 #define ENABLE_FOG_DENSITY		(1<<23)
268 /* Dword 2 */
269 #define FOG_CONST_2(x)			(x)
270 /* Dword 3 */
271 #define FOG_DENSITY(x)			(x)
272 
273 /* _3DSTATE_INDEPENDENT_ALPHA_BLEND, p142 */
274 #define _3DSTATE_INDPT_ALPHA_BLEND_CMD	(CMD_3D|(0x0b<<24))
275 #define ENABLE_INDPT_ALPHA_BLEND	((1<<23)|(1<<22))
276 #define DISABLE_INDPT_ALPHA_BLEND	(1<<23)
277 #define ALPHA_BLENDFUNC_MASK		0x3f0000
278 #define ENABLE_ALPHA_BLENDFUNC		(1<<21)
279 #define ABLENDFUNC_ADD			0
280 #define ABLENDFUNC_SUB			(1<<16)
281 #define ABLENDFUNC_RVSE_SUB		(2<<16)
282 #define ABLENDFUNC_MIN			(3<<16)
283 #define ABLENDFUNC_MAX			(4<<16)
284 #define SRC_DST_ABLEND_MASK		0xfff
285 #define ENABLE_SRC_ABLEND_FACTOR	(1<<11)
286 #define SRC_ABLEND_FACT(x)		((x)<<6)
287 #define ENABLE_DST_ABLEND_FACTOR	(1<<5)
288 #define DST_ABLEND_FACT(x)		(x)
289 
290 #define BLENDFACTOR_ZERO		0x01
291 #define BLENDFACTOR_ONE 		0x02
292 #define BLENDFACTOR_SRC_COLR		0x03
293 #define BLENDFACTOR_INV_SRC_COLR	0x04
294 #define BLENDFACTOR_SRC_ALPHA		0x05
295 #define BLENDFACTOR_INV_SRC_ALPHA	0x06
296 #define BLENDFACTOR_DST_ALPHA		0x07
297 #define BLENDFACTOR_INV_DST_ALPHA	0x08
298 #define BLENDFACTOR_DST_COLR		0x09
299 #define BLENDFACTOR_INV_DST_COLR	0x0a
300 #define BLENDFACTOR_SRC_ALPHA_SATURATE	0x0b
301 #define BLENDFACTOR_CONST_COLOR		0x0c
302 #define BLENDFACTOR_INV_CONST_COLOR	0x0d
303 #define BLENDFACTOR_CONST_ALPHA		0x0e
304 #define BLENDFACTOR_INV_CONST_ALPHA	0x0f
305 #define BLENDFACTOR_MASK		0x0f
306 
307 /* _3DSTATE_MAP_BLEND_ARG, p152 */
308 #define _3DSTATE_MAP_BLEND_ARG_CMD(stage)	(CMD_3D|(0x0e<<24)|((stage)<<20))
309 
310 #define TEXPIPE_COLOR			0
311 #define TEXPIPE_ALPHA			(1<<18)
312 #define TEXPIPE_KILL			(2<<18)
313 #define TEXBLEND_ARG0			0
314 #define TEXBLEND_ARG1			(1<<15)
315 #define TEXBLEND_ARG2			(2<<15)
316 #define TEXBLEND_ARG3			(3<<15)
317 #define TEXBLENDARG_MODIFY_PARMS	(1<<6)
318 #define TEXBLENDARG_REPLICATE_ALPHA 	(1<<5)
319 #define TEXBLENDARG_INV_ARG 		(1<<4)
320 #define TEXBLENDARG_ONE 		0
321 #define TEXBLENDARG_FACTOR		0x01
322 #define TEXBLENDARG_ACCUM		0x02
323 #define TEXBLENDARG_DIFFUSE		0x03
324 #define TEXBLENDARG_SPEC		0x04
325 #define TEXBLENDARG_CURRENT		0x05
326 #define TEXBLENDARG_TEXEL0		0x06
327 #define TEXBLENDARG_TEXEL1		0x07
328 #define TEXBLENDARG_TEXEL2		0x08
329 #define TEXBLENDARG_TEXEL3		0x09
330 #define TEXBLENDARG_FACTOR_N		0x0e
331 
332 /* _3DSTATE_MAP_BLEND_OP, p155 */
333 #define _3DSTATE_MAP_BLEND_OP_CMD(stage)	(CMD_3D|(0x0d<<24)|((stage)<<20))
334 #if 0
335 #   define TEXPIPE_COLOR		0
336 #   define TEXPIPE_ALPHA		(1<<18)
337 #   define TEXPIPE_KILL			(2<<18)
338 #endif
339 #define ENABLE_TEXOUTPUT_WRT_SEL	(1<<17)
340 #define TEXOP_OUTPUT_CURRENT		0
341 #define TEXOP_OUTPUT_ACCUM		(1<<15)
342 #define ENABLE_TEX_CNTRL_STAGE		((1<<12)|(1<<11))
343 #define DISABLE_TEX_CNTRL_STAGE		(1<<12)
344 #define TEXOP_SCALE_SHIFT		9
345 #define TEXOP_SCALE_1X			(0 << TEXOP_SCALE_SHIFT)
346 #define TEXOP_SCALE_2X			(1 << TEXOP_SCALE_SHIFT)
347 #define TEXOP_SCALE_4X			(2 << TEXOP_SCALE_SHIFT)
348 #define TEXOP_MODIFY_PARMS		(1<<8)
349 #define TEXOP_LAST_STAGE		(1<<7)
350 #define TEXBLENDOP_KILLPIXEL		0x02
351 #define TEXBLENDOP_ARG1 		0x01
352 #define TEXBLENDOP_ARG2 		0x02
353 #define TEXBLENDOP_MODULATE		0x03
354 #define TEXBLENDOP_ADD			0x06
355 #define TEXBLENDOP_ADDSIGNED		0x07
356 #define TEXBLENDOP_BLEND		0x08
357 #define TEXBLENDOP_BLEND_AND_ADD	0x09
358 #define TEXBLENDOP_SUBTRACT		0x0a
359 #define TEXBLENDOP_DOT3 		0x0b
360 #define TEXBLENDOP_DOT4 		0x0c
361 #define TEXBLENDOP_MODULATE_AND_ADD	0x0d
362 #define TEXBLENDOP_MODULATE_2X_AND_ADD	0x0e
363 #define TEXBLENDOP_MODULATE_4X_AND_ADD	0x0f
364 
365 /* _3DSTATE_MAP_BUMP_TABLE, p160 TODO */
366 /* _3DSTATE_MAP_COLOR_CHROMA_KEY, p161 TODO */
367 
368 #define _3DSTATE_MAP_COORD_TRANSFORM	((3<<29)|(0x1d<<24)|(0x8c<<16))
369 #define DISABLE_TEX_TRANSFORM		(1<<28)
370 #define TEXTURE_SET(x)			(x<<29)
371 
372 #define _3DSTATE_VERTEX_TRANSFORM	((3<<29)|(0x1d<<24)|(0x8b<<16))
373 #define DISABLE_VIEWPORT_TRANSFORM	(1<<31)
374 #define DISABLE_PERSPECTIVE_DIVIDE	(1<<29)
375 
376 /* _3DSTATE_MAP_COORD_SET_BINDINGS, p162 */
377 #define _3DSTATE_MAP_COORD_SETBIND_CMD	(CMD_3D|(0x1d<<24)|(0x02<<16))
378 #define TEXBIND_MASK3			((1<<15)|(1<<14)|(1<<13)|(1<<12))
379 #define TEXBIND_MASK2			((1<<11)|(1<<10)|(1<<9)|(1<<8))
380 #define TEXBIND_MASK1			((1<<7)|(1<<6)|(1<<5)|(1<<4))
381 #define TEXBIND_MASK0			((1<<3)|(1<<2)|(1<<1)|1)
382 
383 #define TEXBIND_SET3(x) 		((x)<<12)
384 #define TEXBIND_SET2(x) 		((x)<<8)
385 #define TEXBIND_SET1(x) 		((x)<<4)
386 #define TEXBIND_SET0(x) 		(x)
387 
388 #define TEXCOORDSRC_KEEP		0
389 #define TEXCOORDSRC_DEFAULT		0x01
390 #define TEXCOORDSRC_VTXSET_0		0x08
391 #define TEXCOORDSRC_VTXSET_1		0x09
392 #define TEXCOORDSRC_VTXSET_2		0x0a
393 #define TEXCOORDSRC_VTXSET_3		0x0b
394 #define TEXCOORDSRC_VTXSET_4		0x0c
395 #define TEXCOORDSRC_VTXSET_5		0x0d
396 #define TEXCOORDSRC_VTXSET_6		0x0e
397 #define TEXCOORDSRC_VTXSET_7		0x0f
398 
399 #define MAP_UNIT(unit)			((unit)<<16)
400 #define MAP_UNIT_MASK			(0x7<<16)
401 
402 /* _3DSTATE_MAP_COORD_SETS, p164 */
403 #define _3DSTATE_MAP_COORD_SET_CMD	(CMD_3D|(0x1c<<24)|(0x01<<19))
404 #define TEXCOORD_SET(n)			((n)<<16)
405 #define ENABLE_TEXCOORD_PARAMS		(1<<15)
406 #define TEXCOORDS_ARE_NORMAL		(1<<14)
407 #define TEXCOORDS_ARE_IN_TEXELUNITS	0
408 #define TEXCOORDTYPE_CARTESIAN		0
409 #define TEXCOORDTYPE_HOMOGENEOUS	(1<<11)
410 #define TEXCOORDTYPE_VECTOR		(2<<11)
411 #define TEXCOORDTYPE_MASK	        (0x7<<11)
412 #define ENABLE_ADDR_V_CNTL		(1<<7)
413 #define ENABLE_ADDR_U_CNTL		(1<<3)
414 #define TEXCOORD_ADDR_V_MODE(x) 	((x)<<4)
415 #define TEXCOORD_ADDR_U_MODE(x) 	(x)
416 #define TEXCOORDMODE_WRAP		0
417 #define TEXCOORDMODE_MIRROR		1
418 #define TEXCOORDMODE_CLAMP		2
419 #define TEXCOORDMODE_WRAP_SHORTEST	3
420 #define TEXCOORDMODE_CLAMP_BORDER	4
421 #define TEXCOORD_ADDR_V_MASK		0x70
422 #define TEXCOORD_ADDR_U_MASK		0x7
423 
424 /* _3DSTATE_MAP_CUBE, p168 TODO */
425 #define _3DSTATE_MAP_CUBE		(CMD_3D|(0x1c<<24)|(0x0a<<19))
426 #define CUBE_NEGX_ENABLE                (1<<5)
427 #define CUBE_POSX_ENABLE                (1<<4)
428 #define CUBE_NEGY_ENABLE                (1<<3)
429 #define CUBE_POSY_ENABLE                (1<<2)
430 #define CUBE_NEGZ_ENABLE                (1<<1)
431 #define CUBE_POSZ_ENABLE                (1<<0)
432 
433 #define _3DSTATE_MAP_INFO_CMD		(CMD_3D|(0x1d<<24)|(0x0<<16)|3)
434 #define TEXMAP_INDEX(x)			((x)<<28)
435 #define MAP_SURFACE_8BIT		(1<<24)
436 #define MAP_SURFACE_16BIT		(2<<24)
437 #define MAP_SURFACE_32BIT		(3<<24)
438 #define MAP_FORMAT_2D			(0)
439 #define MAP_FORMAT_3D_CUBE		(1<<11)
440 
441 /* _3DSTATE_MODES_1, p190 */
442 #define _3DSTATE_MODES_1_CMD		(CMD_3D|(0x08<<24))
443 #define BLENDFUNC_MASK			0x3f0000
444 #define ENABLE_COLR_BLND_FUNC		(1<<21)
445 #define BLENDFUNC_ADD			0
446 #define BLENDFUNC_SUB			(1<<16)
447 #define BLENDFUNC_RVRSE_SUB		(2<<16)
448 #define BLENDFUNC_MIN			(3<<16)
449 #define BLENDFUNC_MAX			(4<<16)
450 #define SRC_DST_BLND_MASK		0xfff
451 #define ENABLE_SRC_BLND_FACTOR		(1<<11)
452 #define ENABLE_DST_BLND_FACTOR		(1<<5)
453 #define SRC_BLND_FACT(x)		((x)<<6)
454 #define DST_BLND_FACT(x)		(x)
455 
456 /* _3DSTATE_MODES_2, p192 */
457 #define _3DSTATE_MODES_2_CMD		(CMD_3D|(0x0f<<24))
458 #define ENABLE_GLOBAL_DEPTH_BIAS	(1<<22)
459 #define GLOBAL_DEPTH_BIAS(x)		((x)<<14)
460 #define ENABLE_ALPHA_TEST_FUNC		(1<<13)
461 #define ENABLE_ALPHA_REF_VALUE		(1<<8)
462 #define ALPHA_TEST_FUNC(x)		((x)<<9)
463 #define ALPHA_REF_VALUE(x)		(x)
464 
465 #define ALPHA_TEST_REF_MASK		0x3fff
466 
467 /* _3DSTATE_MODES_3, p193 */
468 #define _3DSTATE_MODES_3_CMD		(CMD_3D|(0x02<<24))
469 #define DEPTH_TEST_FUNC_MASK		0x1f0000
470 #define ENABLE_DEPTH_TEST_FUNC		(1<<20)
471 /* Uses COMPAREFUNC */
472 #define DEPTH_TEST_FUNC(x)		((x)<<16)
473 #define ENABLE_ALPHA_SHADE_MODE 	(1<<11)
474 #define ENABLE_FOG_SHADE_MODE		(1<<9)
475 #define ENABLE_SPEC_SHADE_MODE		(1<<7)
476 #define ENABLE_COLOR_SHADE_MODE 	(1<<5)
477 #define ALPHA_SHADE_MODE(x)		((x)<<10)
478 #define FOG_SHADE_MODE(x)		((x)<<8)
479 #define SPEC_SHADE_MODE(x)		((x)<<6)
480 #define COLOR_SHADE_MODE(x)		((x)<<4)
481 #define CULLMODE_MASK			0xf
482 #define ENABLE_CULL_MODE		(1<<3)
483 #define CULLMODE_BOTH			0
484 #define CULLMODE_NONE			1
485 #define CULLMODE_CW			2
486 #define CULLMODE_CCW			3
487 
488 #define SHADE_MODE_LINEAR		0
489 #define SHADE_MODE_FLAT 		0x1
490 
491 /* _3DSTATE_MODES_4, p195 */
492 #define _3DSTATE_MODES_4_CMD		(CMD_3D|(0x16<<24))
493 #define ENABLE_LOGIC_OP_FUNC		(1<<23)
494 #define LOGIC_OP_FUNC(x)		((x)<<18)
495 #define LOGICOP_MASK			((1<<18)|(1<<19)|(1<<20)|(1<<21))
496 #define LOGICOP_CLEAR			0
497 #define LOGICOP_NOR			0x1
498 #define LOGICOP_AND_INV 		0x2
499 #define LOGICOP_COPY_INV		0x3
500 #define LOGICOP_AND_RVRSE		0x4
501 #define LOGICOP_INV			0x5
502 #define LOGICOP_XOR			0x6
503 #define LOGICOP_NAND			0x7
504 #define LOGICOP_AND			0x8
505 #define LOGICOP_EQUIV			0x9
506 #define LOGICOP_NOOP			0xa
507 #define LOGICOP_OR_INV			0xb
508 #define LOGICOP_COPY			0xc
509 #define LOGICOP_OR_RVRSE		0xd
510 #define LOGICOP_OR			0xe
511 #define LOGICOP_SET			0xf
512 #define MODE4_ENABLE_STENCIL_TEST_MASK	((1<<17)|(0xff00))
513 #define ENABLE_STENCIL_TEST_MASK	(1<<17)
514 #define STENCIL_TEST_MASK(x)		((x)<<8)
515 #define MODE4_ENABLE_STENCIL_WRITE_MASK	((1<<16)|(0x00ff))
516 #define ENABLE_STENCIL_WRITE_MASK	(1<<16)
517 #define STENCIL_WRITE_MASK(x)		((x)&0xff)
518 
519 /* _3DSTATE_MODES_5, p196 */
520 #define _3DSTATE_MODES_5_CMD		(CMD_3D|(0x0c<<24))
521 #define ENABLE_SPRITE_POINT_TEX 	(1<<23)
522 #define SPRITE_POINT_TEX_ON		(1<<22)
523 #define SPRITE_POINT_TEX_OFF		0
524 #define FLUSH_RENDER_CACHE		(1<<18)
525 #define FLUSH_TEXTURE_CACHE		(1<<16)
526 #define FIXED_LINE_WIDTH_MASK		0xfc00
527 #define ENABLE_FIXED_LINE_WIDTH 	(1<<15)
528 #define FIXED_LINE_WIDTH(x)		((x)<<10)
529 #define FIXED_POINT_WIDTH_MASK		0x3ff
530 #define ENABLE_FIXED_POINT_WIDTH	(1<<9)
531 #define FIXED_POINT_WIDTH(x)		(x)
532 
533 /* _3DSTATE_RASTERIZATION_RULES, p198 */
534 #define _3DSTATE_RASTER_RULES_CMD	(CMD_3D|(0x07<<24))
535 #define ENABLE_POINT_RASTER_RULE	(1<<15)
536 #define OGL_POINT_RASTER_RULE		(1<<13)
537 #define ENABLE_LINE_STRIP_PROVOKE_VRTX	(1<<8)
538 #define ENABLE_TRI_FAN_PROVOKE_VRTX	(1<<5)
539 #define ENABLE_TRI_STRIP_PROVOKE_VRTX	(1<<2)
540 #define LINE_STRIP_PROVOKE_VRTX(x)	((x)<<6)
541 #define TRI_FAN_PROVOKE_VRTX(x) 	((x)<<3)
542 #define TRI_STRIP_PROVOKE_VRTX(x)	(x)
543 
544 /* _3DSTATE_SCISSOR_ENABLE, p200 */
545 #define _3DSTATE_SCISSOR_ENABLE_CMD	(CMD_3D|(0x1c<<24)|(0x10<<19))
546 #define ENABLE_SCISSOR_RECT		((1<<1) | 1)
547 #define DISABLE_SCISSOR_RECT		(1<<1)
548 
549 /* _3DSTATE_SCISSOR_RECTANGLE_0, p201 */
550 #define _3DSTATE_SCISSOR_RECT_0_CMD	(CMD_3D|(0x1d<<24)|(0x81<<16)|1)
551 /* Dword 1 */
552 #define SCISSOR_RECT_0_YMIN(x)		((x)<<16)
553 #define SCISSOR_RECT_0_XMIN(x)		(x)
554 /* Dword 2 */
555 #define SCISSOR_RECT_0_YMAX(x)		((x)<<16)
556 #define SCISSOR_RECT_0_XMAX(x)		(x)
557 
558 /* _3DSTATE_STENCIL_TEST, p202 */
559 #define _3DSTATE_STENCIL_TEST_CMD	(CMD_3D|(0x09<<24))
560 #define ENABLE_STENCIL_PARMS		(1<<23)
561 #define STENCIL_OPS_MASK		(0xffc000)
562 #define STENCIL_FAIL_OP(x)		((x)<<20)
563 #define STENCIL_PASS_DEPTH_FAIL_OP(x)	((x)<<17)
564 #define STENCIL_PASS_DEPTH_PASS_OP(x)	((x)<<14)
565 
566 #define ENABLE_STENCIL_TEST_FUNC_MASK	((1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9))
567 #define ENABLE_STENCIL_TEST_FUNC	(1<<13)
568 /* Uses COMPAREFUNC */
569 #define STENCIL_TEST_FUNC(x)		((x)<<9)
570 #define STENCIL_REF_VALUE_MASK		((1<<8)|0xff)
571 #define ENABLE_STENCIL_REF_VALUE	(1<<8)
572 #define STENCIL_REF_VALUE(x)		(x)
573 
574 /* _3DSTATE_VERTEX_FORMAT, p204 */
575 #define _3DSTATE_VFT0_CMD	(CMD_3D|(0x05<<24))
576 #define VFT0_POINT_WIDTH	(1<<12)
577 #define VFT0_TEX_COUNT_MASK    	(7<<8)
578 #define VFT0_TEX_COUNT_SHIFT    8
579 #define VFT0_TEX_COUNT(x) 	((x)<<8)
580 #define VFT0_SPEC		(1<<7)
581 #define VFT0_DIFFUSE		(1<<6)
582 #define VFT0_DEPTH_OFFSET  	(1<<5)
583 #define VFT0_XYZ		(1<<1)
584 #define VFT0_XYZW		(2<<1)
585 #define VFT0_XY			(3<<1)
586 #define VFT0_XYW		(4<<1)
587 #define VFT0_XYZW_MASK          (7<<1)
588 
589 /* _3DSTATE_VERTEX_FORMAT_2, p206 */
590 #define _3DSTATE_VERTEX_FORMAT_2_CMD	(CMD_3D|(0x0a<<24))
591 #define VFT1_TEX7_FMT(x)	((x)<<14)
592 #define VFT1_TEX6_FMT(x)	((x)<<12)
593 #define VFT1_TEX5_FMT(x)	((x)<<10)
594 #define VFT1_TEX4_FMT(x)	((x)<<8)
595 #define VFT1_TEX3_FMT(x)	((x)<<6)
596 #define VFT1_TEX2_FMT(x)	((x)<<4)
597 #define VFT1_TEX1_FMT(x)	((x)<<2)
598 #define VFT1_TEX0_FMT(x)	(x)
599 #define VFT1_TEX0_MASK          3
600 #define VFT1_TEX1_SHIFT         2
601 #define TEXCOORDFMT_2D		0
602 #define TEXCOORDFMT_3D		1
603 #define TEXCOORDFMT_4D		2
604 #define TEXCOORDFMT_1D		3
605 
606 /*New stuff picked up along the way */
607 
608 #define MLC_LOD_BIAS_MASK ((1<<7)-1)
609 
610 /* _3DSTATE_VERTEX_TRANSFORM, p207 */
611 #define _3DSTATE_VERTEX_TRANS_CMD	(CMD_3D|(0x1d<<24)|(0x8b<<16)|0)
612 #define _3DSTATE_VERTEX_TRANS_MTX_CMD	(CMD_3D|(0x1d<<24)|(0x8b<<16)|6)
613 /* Dword 1 */
614 #define ENABLE_VIEWPORT_TRANSFORM	((1<<31)|(1<<30))
615 #define DISABLE_VIEWPORT_TRANSFORM	(1<<31)
616 #define ENABLE_PERSP_DIVIDE		((1<<29)|(1<<28))
617 #define DISABLE_PERSP_DIVIDE		(1<<29)
618 #define VRTX_TRANS_LOAD_MATRICES	0x7421
619 #define VRTX_TRANS_NO_LOAD_MATRICES	0x0000
620 /* Dword 2 -> 7  are matrix elements */
621 
622 /* _3DSTATE_W_STATE, p209 */
623 #define _3DSTATE_W_STATE_CMD		(CMD_3D|(0x1d<<24)|(0x8d<<16)|1)
624 /* Dword 1 */
625 #define MAGIC_W_STATE_DWORD1		0x00000008
626 /* Dword 2 */
627 #define WFAR_VALUE(x)			(x)
628 
629 /* Stipple command, carried over from the i810, apparently:
630  */
631 #define _3DSTATE_STIPPLE           (CMD_3D|(0x1d<<24)|(0x83<<16))
632 #define ST1_ENABLE               (1<<16)
633 #define ST1_MASK                 (0xffff)
634 
635 #define _3DSTATE_LOAD_STATE_IMMEDIATE_1	     (CMD_3D|(0x1d<<24)|(0x04<<16))
636 #define I1_LOAD_S(n)			     (1<<((n)+4))
637 #define S3_POINT_WIDTH_SHIFT		     23
638 #define S3_LINE_WIDTH_SHIFT		     19
639 #define S3_ALPHA_SHADE_MODE_SHIFT	     18
640 #define S3_FOG_SHADE_MODE_SHIFT		     17
641 #define S3_SPEC_SHADE_MODE_SHIFT	     16
642 #define S3_COLOR_SHADE_MODE_SHIFT	     15
643 #define S3_CULL_MODE_SHIFT		     13
644 #define    S3_CULLMODE_BOTH		     (0)
645 #define    S3_CULLMODE_NONE		     (1<<13)
646 #define    S3_CULLMODE_CW		     (2<<13)
647 #define    S3_CULLMODE_CCW		     (3<<13)
648 #define S3_POINT_WIDTH_PRESENT		     (1<<12)
649 #define S3_SPEC_FOG_PRESENT		     (1<<11)
650 #define S3_DIFFUSE_PRESENT		     (1<<10)
651 #define S3_DEPTH_OFFSET_PRESENT		     (1<<9)
652 #define S3_POSITION_SHIFT		     6
653 #define    S3_VERTEXHAS_XYZ		     (1<<6)
654 #define    S3_VERTEXHAS_XYZW		     (2<<6)
655 #define    S3_VERTEXHAS_XY		     (3<<6)
656 #define    S3_VERTEXHAS_XYW		     (4<<6)
657 #define S3_ENABLE_SPEC_ADD		     (1<<5)
658 #define S3_ENABLE_FOG			     (1<<4)
659 #define S3_ENABLE_LOCAL_DEPTH_BIAS	     (1<<3)
660 #define S3_ENABLE_SPRITE_POINT		     (1<<1)
661 #define S3_ENABLE_ANTIALIASING		     1
662 #define S8_ENABLE_ALPHA_TEST		     (1<<31)
663 #define S8_ALPHA_TEST_FUNC_SHIFT	     28
664 #define S8_ALPHA_REFVALUE_SHIFT		     20
665 #define S8_ENABLE_DEPTH_TEST		     (1<<19)
666 #define S8_DEPTH_TEST_FUNC_SHIFT	     16
667 #define S8_ENABLE_COLOR_BLEND		     (1<<15)
668 #define S8_COLOR_BLEND_FUNC_SHIFT	     12
669 #define    S8_BLENDFUNC_ADD		     (0)
670 #define    S8_BLENDFUNC_SUB		     (1<<12)
671 #define    S8_BLENDFUNC_RVRSE_SUB	     (2<<12)
672 #define    S8_BLENDFUNC_MIN		     (3<<12)
673 #define    S8_BLENDFUNC_MAX			     (4<<12)
674 #define S8_SRC_BLEND_FACTOR_SHIFT	     8
675 #define S8_DST_BLEND_FACTOR_SHIFT	     4
676 #define S8_ENABLE_DEPTH_BUFFER_WRITE	     (1<<3)
677 #define S8_ENABLE_COLOR_BUFFER_WRITE	     (1<<2)
678 
679 #define _3DSTATE_LOAD_STATE_IMMEDIATE_2      (CMD_3D|(0x1d<<24)|(0x03<<16))
680 #define LOAD_TEXTURE_MAP(x)                   (1<<((x)+11))
681 #define LOAD_TEXTURE_BLEND_STAGE(x)	      (1<<((x)+7))
682 #define LOAD_GLOBAL_COLOR_FACTOR            (1<<6)
683 
684 #define TM0S0_ADDRESS_MASK              0xfffffffc
685 #define TM0S0_USE_FENCE                 (1<<1)
686 
687 #define TM0S1_HEIGHT_SHIFT              21
688 #define TM0S1_WIDTH_SHIFT               10
689 #define TM0S1_PALETTE_SELECT            (1<<9)
690 #define TM0S1_MAPSURF_FORMAT_MASK       (0x7 << 6)
691 #define TM0S1_MAPSURF_FORMAT_SHIFT      6
692 #define    MAPSURF_8BIT_INDEXED		   (0<<6)
693 #define    MAPSURF_8BIT		 	   (1<<6)
694 #define    MAPSURF_16BIT		   (2<<6)
695 #define    MAPSURF_32BIT		   (3<<6)
696 #define    MAPSURF_411			   (4<<6)
697 #define    MAPSURF_422			   (5<<6)
698 #define    MAPSURF_COMPRESSED		   (6<<6)
699 #define    MAPSURF_4BIT_INDEXED		   (7<<6)
700 #define TM0S1_MT_FORMAT_MASK         (0x7 << 3)
701 #define TM0S1_MT_FORMAT_SHIFT        3
702 #define    MT_4BIT_IDX_ARGB8888	           (7<<3)	/* SURFACE_4BIT_INDEXED */
703 #define    MT_8BIT_IDX_RGB565	           (0<<3)	/* SURFACE_8BIT_INDEXED */
704 #define    MT_8BIT_IDX_ARGB1555	           (1<<3)
705 #define    MT_8BIT_IDX_ARGB4444	           (2<<3)
706 #define    MT_8BIT_IDX_AY88		   (3<<3)
707 #define    MT_8BIT_IDX_ABGR8888	           (4<<3)
708 #define    MT_8BIT_IDX_BUMP_88DVDU 	   (5<<3)
709 #define    MT_8BIT_IDX_BUMP_655LDVDU	   (6<<3)
710 #define    MT_8BIT_IDX_ARGB8888	           (7<<3)
711 #define    MT_8BIT_I8		           (0<<3)	/* SURFACE_8BIT */
712 #define    MT_8BIT_L8		           (1<<3)
713 #define    MT_8BIT_A8		           (4<<3)
714 #define    MT_16BIT_RGB565 		   (0<<3)	/* SURFACE_16BIT */
715 #define    MT_16BIT_ARGB1555		   (1<<3)
716 #define    MT_16BIT_ARGB4444		   (2<<3)
717 #define    MT_16BIT_AY88		   (3<<3)
718 #define    MT_16BIT_DIB_ARGB1555_8888      (4<<3)
719 #define    MT_16BIT_BUMP_88DVDU	           (5<<3)
720 #define    MT_16BIT_BUMP_655LDVDU	   (6<<3)
721 #define    MT_16BIT_DIB_RGB565_8888	   (7<<3)
722 #define    MT_32BIT_ARGB8888		   (0<<3)	/* SURFACE_32BIT */
723 #define    MT_32BIT_ABGR8888		   (1<<3)
724 #define    MT_32BIT_XRGB8888		   (2<<3)
725 #define    MT_32BIT_XBGR8888		   (3<<3)
726 #define    MT_32BIT_BUMP_XLDVDU_8888	   (6<<3)
727 #define    MT_32BIT_DIB_8888		   (7<<3)
728 #define    MT_411_YUV411		   (0<<3)	/* SURFACE_411 */
729 #define    MT_422_YCRCB_SWAPY	           (0<<3)	/* SURFACE_422 */
730 #define    MT_422_YCRCB_NORMAL	           (1<<3)
731 #define    MT_422_YCRCB_SWAPUV	           (2<<3)
732 #define    MT_422_YCRCB_SWAPUVY	           (3<<3)
733 #define    MT_COMPRESS_DXT1		   (0<<3)	/* SURFACE_COMPRESSED */
734 #define    MT_COMPRESS_DXT2_3	           (1<<3)
735 #define    MT_COMPRESS_DXT4_5	           (2<<3)
736 #define    MT_COMPRESS_FXT1		   (3<<3)
737 #define TM0S1_COLORSPACE_CONVERSION     (1 << 2)
738 #define TM0S1_TILED_SURFACE             (1 << 1)
739 #define TM0S1_TILE_WALK                 (1 << 0)
740 
741 #define TM0S2_PITCH_SHIFT               21
742 #define TM0S2_CUBE_FACE_ENA_SHIFT       15
743 #define TM0S2_CUBE_FACE_ENA_MASK        (1<<15)
744 #define TM0S2_MAP_FORMAT                (1<<14)
745 #define    TM0S2_MAP_2D			(0<<14)
746 #define    TM0S2_MAP_3D_CUBE		(1<<14)
747 #define TM0S2_VERTICAL_LINE_STRIDE      (1<<13)
748 #define TM0S2_VERITCAL_LINE_STRIDE_OFF  (1<<12)
749 #define TM0S2_OUTPUT_CHAN_SHIFT         10
750 #define TM0S2_OUTPUT_CHAN_MASK          (3<<10)
751 
752 #define TM0S3_MIP_FILTER_MASK           (0x3<<30)
753 #define TM0S3_MIP_FILTER_SHIFT          30
754 #define MIPFILTER_NONE		0
755 #define MIPFILTER_NEAREST	1
756 #define MIPFILTER_LINEAR	3
757 #define TM0S3_MAG_FILTER_MASK           (0x3<<28)
758 #define TM0S3_MAG_FILTER_SHIFT          28
759 #define TM0S3_MIN_FILTER_MASK           (0x3<<26)
760 #define TM0S3_MIN_FILTER_SHIFT          26
761 #define FILTER_NEAREST		0
762 #define FILTER_LINEAR		1
763 #define FILTER_ANISOTROPIC	2
764 
765 #define TM0S3_LOD_BIAS_SHIFT		17
766 #define TM0S3_LOD_BIAS_MASK		(0x1ff<<17)
767 #define TM0S3_MAX_MIP_SHIFT		9
768 #define TM0S3_MAX_MIP_MASK		(0xff<<9)
769 #define TM0S3_MIN_MIP_SHIFT		3
770 #define TM0S3_MIN_MIP_MASK		(0x3f<<3)
771 #define TM0S3_KILL_PIXEL		(1<<2)
772 #define TM0S3_KEYED_FILTER		(1<<1)
773 #define TM0S3_CHROMA_KEY		(1<<0)
774 
775 /* _3DSTATE_MAP_TEXEL_STREAM, p188 */
776 #define _3DSTATE_MAP_TEX_STREAM_CMD	(CMD_3D|(0x1c<<24)|(0x05<<19))
777 #define DISABLE_TEX_STREAM_BUMP 	(1<<12)
778 #define ENABLE_TEX_STREAM_BUMP		((1<<12)|(1<<11))
779 #define TEX_MODIFY_UNIT_0		0
780 #define TEX_MODIFY_UNIT_1		(1<<8)
781 #define ENABLE_TEX_STREAM_COORD_SET	(1<<7)
782 #define TEX_STREAM_COORD_SET(x) 	((x)<<4)
783 #define ENABLE_TEX_STREAM_MAP_IDX	(1<<3)
784 #define TEX_STREAM_MAP_IDX(x)		(x)
785 
786 #define FLUSH_MAP_CACHE    (1<<0)
787 
788 #define _3DSTATE_MAP_FILTER_CMD    (CMD_3D|(0x1c<<24)|(0x02<<19))
789 #define FILTER_TEXMAP_INDEX(x) ((x) << 16)
790 #define MAG_MODE_FILTER_ENABLE (1 << 5)
791 #define MIN_MODE_FILTER_ENABLE (1 << 2)
792 #define MAG_MAPFILTER_NEAREST (0 << 3)
793 #define MAG_MAPFILTER_LINEAR  (1 << 3)
794 #define MAG_MAPFILTER_ANISOTROPIC (2 << 3)
795 #define MIN_MAPFILTER_NEAREST (0)
796 #define MIN_MAPFILTER_LINEAR  (1)
797 #define MIN_MAPFILTER_ANISOTROPIC (2)
798 #define ENABLE_KEYS	(1<<15)
799 #define DISABLE_COLOR_KEY	0
800 #define DISABLE_CHROMA_KEY	0
801 #define DISABLE_KILL_PIXEL	0
802 #define ENABLE_MIP_MODE_FILTER	(1 << 9)
803 #define MIPFILTER_NONE		0
804 #define MIPFILTER_NEAREST	1
805 #define MIPFILTER_LINEAR	3
806 
807 #endif
808