1 /**************************************************************************
2  *
3  * Copyright 2003 VMware, Inc.
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 VMWARE 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 
29 #ifndef _I830_REG_H_
30 #define _I830_REG_H_
31 
32 
33 #include "intel_reg.h"
34 
35 #define I830_SET_FIELD( var, mask, value ) (var &= ~(mask), var |= value)
36 
37 #define _3DSTATE_AA_CMD			(CMD_3D | (0x06<<24))
38 #define AA_LINE_ECAAR_WIDTH_ENABLE	(1<<16)
39 #define AA_LINE_ECAAR_WIDTH_0_5 	0
40 #define AA_LINE_ECAAR_WIDTH_1_0		(1<<14)
41 #define AA_LINE_ECAAR_WIDTH_2_0 	(2<<14)
42 #define AA_LINE_ECAAR_WIDTH_4_0 	(3<<14)
43 #define AA_LINE_REGION_WIDTH_ENABLE	(1<<8)
44 #define AA_LINE_REGION_WIDTH_0_5	0
45 #define AA_LINE_REGION_WIDTH_1_0	(1<<6)
46 #define AA_LINE_REGION_WIDTH_2_0	(2<<6)
47 #define AA_LINE_REGION_WIDTH_4_0	(3<<6)
48 #define AA_LINE_ENABLE			((1<<1) | 1)
49 #define AA_LINE_DISABLE			(1<<1)
50 
51 #define _3DSTATE_COLOR_FACTOR_CMD	(CMD_3D | (0x1d<<24) | (0x1<<16))
52 
53 #define _3DSTATE_COLOR_FACTOR_N_CMD(stage)	(CMD_3D | (0x1d<<24) | \
54 					         ((0x90+(stage))<<16))
55 
56 #define _3DSTATE_CONST_BLEND_COLOR_CMD	(CMD_3D | (0x1d<<24) | (0x88<<16))
57 
58 #define _3DSTATE_DFLT_DIFFUSE_CMD	(CMD_3D | (0x1d<<24) | (0x99<<16))
59 
60 #define _3DSTATE_DFLT_SPEC_CMD		(CMD_3D | (0x1d<<24) | (0x9a<<16))
61 
62 #define _3DSTATE_DFLT_Z_CMD		(CMD_3D | (0x1d<<24) | (0x98<<16))
63 
64 
65 #define _3DSTATE_DST_BUF_VARS_CMD	(CMD_3D | (0x1d<<24) | (0x85<<16))
66 /* Dword 1 */
67 #define DSTORG_HORT_BIAS(x)		((x)<<20)
68 #define DSTORG_VERT_BIAS(x)		((x)<<16)
69 #define COLOR_4_2_2_CHNL_WRT_ALL	0
70 #define COLOR_4_2_2_CHNL_WRT_Y		(1<<12)
71 #define COLOR_4_2_2_CHNL_WRT_CR		(2<<12)
72 #define COLOR_4_2_2_CHNL_WRT_CB		(3<<12)
73 #define COLOR_4_2_2_CHNL_WRT_CRCB	(4<<12)
74 #define COLR_BUF_8BIT			0
75 #define COLR_BUF_RGB555 		(1<<8)
76 #define COLR_BUF_RGB565 		(2<<8)
77 #define COLR_BUF_ARGB8888		(3<<8)
78 #define DEPTH_IS_Z			0
79 #define DEPTH_IS_W			(1<<6)
80 #define DEPTH_FRMT_16_FIXED		0
81 #define DEPTH_FRMT_16_FLOAT		(1<<2)
82 #define DEPTH_FRMT_24_FIXED_8_OTHER	(2<<2)
83 #define DEPTH_FRMT_24_FLOAT_8_OTHER	(3<<2)
84 #define VERT_LINE_STRIDE_1		(1<<1)
85 #define VERT_LINE_STRIDE_0		0
86 #define VERT_LINE_STRIDE_OFS_1		1
87 #define VERT_LINE_STRIDE_OFS_0		0
88 
89 
90 #define _3DSTATE_DRAW_RECT_CMD		(CMD_3D|(0x1d<<24)|(0x80<<16)|3)
91 /* Dword 1 */
92 #define DRAW_RECT_DIS_DEPTH_OFS 	(1<<30)
93 #define DRAW_DITHER_OFS_X(x)		((x)<<26)
94 #define DRAW_DITHER_OFS_Y(x)		((x)<<24)
95 /* Dword 2 */
96 #define DRAW_YMIN(x)			((x)<<16)
97 #define DRAW_XMIN(x)			(x)
98 /* Dword 3 */
99 #define DRAW_YMAX(x)			((x)<<16)
100 #define DRAW_XMAX(x)			(x)
101 /* Dword 4 */
102 #define DRAW_YORG(x)			((x)<<16)
103 #define DRAW_XORG(x)			(x)
104 
105 
106 #define _3DSTATE_ENABLES_1_CMD		(CMD_3D|(0x3<<24))
107 #define ENABLE_LOGIC_OP_MASK		((1<<23)|(1<<22))
108 #define ENABLE_LOGIC_OP 		((1<<23)|(1<<22))
109 #define DISABLE_LOGIC_OP		(1<<23)
110 #define ENABLE_STENCIL_TEST		((1<<21)|(1<<20))
111 #define DISABLE_STENCIL_TEST		(1<<21)
112 #define ENABLE_DEPTH_BIAS		((1<<11)|(1<<10))
113 #define DISABLE_DEPTH_BIAS		(1<<11)
114 #define ENABLE_SPEC_ADD_MASK		((1<<9)|(1<<8))
115 #define ENABLE_SPEC_ADD 		((1<<9)|(1<<8))
116 #define DISABLE_SPEC_ADD		(1<<9)
117 #define ENABLE_DIS_FOG_MASK		((1<<7)|(1<<6))
118 #define ENABLE_FOG			((1<<7)|(1<<6))
119 #define DISABLE_FOG			(1<<7)
120 #define ENABLE_DIS_ALPHA_TEST_MASK	((1<<5)|(1<<4))
121 #define ENABLE_ALPHA_TEST		((1<<5)|(1<<4))
122 #define DISABLE_ALPHA_TEST		(1<<5)
123 #define ENABLE_DIS_CBLEND_MASK		((1<<3)|(1<<2))
124 #define ENABLE_COLOR_BLEND		((1<<3)|(1<<2))
125 #define DISABLE_COLOR_BLEND		(1<<3)
126 #define ENABLE_DIS_DEPTH_TEST_MASK	((1<<1)|1)
127 #define ENABLE_DEPTH_TEST		((1<<1)|1)
128 #define DISABLE_DEPTH_TEST		(1<<1)
129 
130 /* _3DSTATE_ENABLES_2, p138 */
131 #define _3DSTATE_ENABLES_2_CMD		(CMD_3D|(0x4<<24))
132 #define ENABLE_STENCIL_WRITE		((1<<21)|(1<<20))
133 #define DISABLE_STENCIL_WRITE		(1<<21)
134 #define ENABLE_TEX_CACHE		((1<<17)|(1<<16))
135 #define DISABLE_TEX_CACHE		(1<<17)
136 #define ENABLE_DITHER			((1<<9)|(1<<8))
137 #define DISABLE_DITHER			(1<<9)
138 #define ENABLE_COLOR_MASK		(1<<10)
139 #define WRITEMASK_ALPHA			(1<<7)
140 #define WRITEMASK_ALPHA_SHIFT		7
141 #define WRITEMASK_RED			(1<<6)
142 #define WRITEMASK_RED_SHIFT		6
143 #define WRITEMASK_GREEN 		(1<<5)
144 #define WRITEMASK_GREEN_SHIFT		5
145 #define WRITEMASK_BLUE			(1<<4)
146 #define WRITEMASK_BLUE_SHIFT		4
147 #define WRITEMASK_MASK			((1<<4)|(1<<5)|(1<<6)|(1<<7))
148 #define ENABLE_COLOR_WRITE		((1<<3)|(1<<2))
149 #define DISABLE_COLOR_WRITE		(1<<3)
150 #define ENABLE_DIS_DEPTH_WRITE_MASK	0x3
151 #define ENABLE_DEPTH_WRITE		((1<<1)|1)
152 #define DISABLE_DEPTH_WRITE		(1<<1)
153 
154 /* _3DSTATE_FOG_COLOR, p139 */
155 #define _3DSTATE_FOG_COLOR_CMD		(CMD_3D|(0x15<<24))
156 #define FOG_COLOR_RED(x)		((x)<<16)
157 #define FOG_COLOR_GREEN(x)		((x)<<8)
158 #define FOG_COLOR_BLUE(x)		(x)
159 
160 /* _3DSTATE_FOG_MODE, p140 */
161 #define _3DSTATE_FOG_MODE_CMD		(CMD_3D|(0x1d<<24)|(0x89<<16)|2)
162 /* Dword 1 */
163 #define FOGFUNC_ENABLE			(1<<31)
164 #define FOGFUNC_VERTEX			0
165 #define FOGFUNC_PIXEL_EXP		(1<<28)
166 #define FOGFUNC_PIXEL_EXP2		(2<<28)
167 #define FOGFUNC_PIXEL_LINEAR		(3<<28)
168 #define FOGSRC_INDEX_Z			(1<<27)
169 #define FOGSRC_INDEX_W			((1<<27)|(1<<25))
170 #define FOG_LINEAR_CONST		(1<<24)
171 #define FOG_CONST_1(x)			((x)<<4)
172 #define ENABLE_FOG_DENSITY		(1<<23)
173 /* Dword 2 */
174 #define FOG_CONST_2(x)			(x)
175 /* Dword 3 */
176 #define FOG_DENSITY(x)			(x)
177 
178 /* _3DSTATE_INDEPENDENT_ALPHA_BLEND, p142 */
179 #define _3DSTATE_INDPT_ALPHA_BLEND_CMD	(CMD_3D|(0x0b<<24))
180 #define ENABLE_INDPT_ALPHA_BLEND	((1<<23)|(1<<22))
181 #define DISABLE_INDPT_ALPHA_BLEND	(1<<23)
182 #define ALPHA_BLENDFUNC_MASK		0x3f0000
183 #define ENABLE_ALPHA_BLENDFUNC		(1<<21)
184 #define ABLENDFUNC_ADD			0
185 #define ABLENDFUNC_SUB			(1<<16)
186 #define ABLENDFUNC_RVSE_SUB		(2<<16)
187 #define ABLENDFUNC_MIN			(3<<16)
188 #define ABLENDFUNC_MAX			(4<<16)
189 #define SRC_DST_ABLEND_MASK		0xfff
190 #define ENABLE_SRC_ABLEND_FACTOR	(1<<11)
191 #define SRC_ABLEND_FACT(x)		((x)<<6)
192 #define ENABLE_DST_ABLEND_FACTOR	(1<<5)
193 #define DST_ABLEND_FACT(x)		(x)
194 
195 
196 /* _3DSTATE_MAP_BLEND_ARG, p152 */
197 #define _3DSTATE_MAP_BLEND_ARG_CMD(stage)	(CMD_3D|(0x0e<<24)|((stage)<<20))
198 
199 #define TEXPIPE_COLOR			0
200 #define TEXPIPE_ALPHA			(1<<18)
201 #define TEXPIPE_KILL			(2<<18)
202 #define TEXBLEND_ARG0			0
203 #define TEXBLEND_ARG1			(1<<15)
204 #define TEXBLEND_ARG2			(2<<15)
205 #define TEXBLEND_ARG3			(3<<15)
206 #define TEXBLENDARG_MODIFY_PARMS	(1<<6)
207 #define TEXBLENDARG_REPLICATE_ALPHA 	(1<<5)
208 #define TEXBLENDARG_INV_ARG 		(1<<4)
209 #define TEXBLENDARG_ONE 		0
210 #define TEXBLENDARG_FACTOR		0x01
211 #define TEXBLENDARG_ACCUM		0x02
212 #define TEXBLENDARG_DIFFUSE		0x03
213 #define TEXBLENDARG_SPEC		0x04
214 #define TEXBLENDARG_CURRENT		0x05
215 #define TEXBLENDARG_TEXEL0		0x06
216 #define TEXBLENDARG_TEXEL1		0x07
217 #define TEXBLENDARG_TEXEL2		0x08
218 #define TEXBLENDARG_TEXEL3		0x09
219 #define TEXBLENDARG_FACTOR_N		0x0e
220 
221 /* _3DSTATE_MAP_BLEND_OP, p155 */
222 #define _3DSTATE_MAP_BLEND_OP_CMD(stage)	(CMD_3D|(0x0d<<24)|((stage)<<20))
223 #if 0
224 #   define TEXPIPE_COLOR		0
225 #   define TEXPIPE_ALPHA		(1<<18)
226 #   define TEXPIPE_KILL			(2<<18)
227 #endif
228 #define ENABLE_TEXOUTPUT_WRT_SEL	(1<<17)
229 #define TEXOP_OUTPUT_CURRENT		0
230 #define TEXOP_OUTPUT_ACCUM		(1<<15)
231 #define ENABLE_TEX_CNTRL_STAGE		((1<<12)|(1<<11))
232 #define DISABLE_TEX_CNTRL_STAGE		(1<<12)
233 #define TEXOP_SCALE_SHIFT		9
234 #define TEXOP_SCALE_1X			(0 << TEXOP_SCALE_SHIFT)
235 #define TEXOP_SCALE_2X			(1 << TEXOP_SCALE_SHIFT)
236 #define TEXOP_SCALE_4X			(2 << TEXOP_SCALE_SHIFT)
237 #define TEXOP_MODIFY_PARMS		(1<<8)
238 #define TEXOP_LAST_STAGE		(1<<7)
239 #define TEXBLENDOP_KILLPIXEL		0x02
240 #define TEXBLENDOP_ARG1 		0x01
241 #define TEXBLENDOP_ARG2 		0x02
242 #define TEXBLENDOP_MODULATE		0x03
243 #define TEXBLENDOP_ADD			0x06
244 #define TEXBLENDOP_ADDSIGNED		0x07
245 #define TEXBLENDOP_BLEND		0x08
246 #define TEXBLENDOP_BLEND_AND_ADD	0x09
247 #define TEXBLENDOP_SUBTRACT		0x0a
248 #define TEXBLENDOP_DOT3 		0x0b
249 #define TEXBLENDOP_DOT4 		0x0c
250 #define TEXBLENDOP_MODULATE_AND_ADD	0x0d
251 #define TEXBLENDOP_MODULATE_2X_AND_ADD	0x0e
252 #define TEXBLENDOP_MODULATE_4X_AND_ADD	0x0f
253 
254 /* _3DSTATE_MAP_BUMP_TABLE, p160 TODO */
255 /* _3DSTATE_MAP_COLOR_CHROMA_KEY, p161 TODO */
256 
257 #define _3DSTATE_MAP_COORD_TRANSFORM	((3<<29)|(0x1d<<24)|(0x8c<<16))
258 #define DISABLE_TEX_TRANSFORM		(1<<28)
259 #define TEXTURE_SET(x)			((x)<<29)
260 
261 #define _3DSTATE_VERTEX_TRANSFORM	((3<<29)|(0x1d<<24)|(0x8b<<16))
262 #define DISABLE_VIEWPORT_TRANSFORM	(1<<31)
263 #define DISABLE_PERSPECTIVE_DIVIDE	(1<<29)
264 
265 
266 /* _3DSTATE_MAP_COORD_SET_BINDINGS, p162 */
267 #define _3DSTATE_MAP_COORD_SETBIND_CMD	(CMD_3D|(0x1d<<24)|(0x02<<16))
268 #define TEXBIND_MASK3			((1<<15)|(1<<14)|(1<<13)|(1<<12))
269 #define TEXBIND_MASK2			((1<<11)|(1<<10)|(1<<9)|(1<<8))
270 #define TEXBIND_MASK1			((1<<7)|(1<<6)|(1<<5)|(1<<4))
271 #define TEXBIND_MASK0			((1<<3)|(1<<2)|(1<<1)|1)
272 
273 #define TEXBIND_SET3(x) 		((x)<<12)
274 #define TEXBIND_SET2(x) 		((x)<<8)
275 #define TEXBIND_SET1(x) 		((x)<<4)
276 #define TEXBIND_SET0(x) 		(x)
277 
278 #define TEXCOORDSRC_KEEP		0
279 #define TEXCOORDSRC_DEFAULT		0x01
280 #define TEXCOORDSRC_VTXSET_0		0x08
281 #define TEXCOORDSRC_VTXSET_1		0x09
282 #define TEXCOORDSRC_VTXSET_2		0x0a
283 #define TEXCOORDSRC_VTXSET_3		0x0b
284 #define TEXCOORDSRC_VTXSET_4		0x0c
285 #define TEXCOORDSRC_VTXSET_5		0x0d
286 #define TEXCOORDSRC_VTXSET_6		0x0e
287 #define TEXCOORDSRC_VTXSET_7		0x0f
288 
289 #define MAP_UNIT(unit)			((unit)<<16)
290 #define MAP_UNIT_MASK			(0x7<<16)
291 
292 /* _3DSTATE_MAP_COORD_SETS, p164 */
293 #define _3DSTATE_MAP_COORD_SET_CMD	(CMD_3D|(0x1c<<24)|(0x01<<19))
294 #define ENABLE_TEXCOORD_PARAMS		(1<<15)
295 #define TEXCOORDS_ARE_NORMAL		(1<<14)
296 #define TEXCOORDS_ARE_IN_TEXELUNITS	0
297 #define TEXCOORDTYPE_CARTESIAN		0
298 #define TEXCOORDTYPE_HOMOGENEOUS	(1<<11)
299 #define TEXCOORDTYPE_VECTOR		(2<<11)
300 #define TEXCOORDTYPE_MASK	        (0x7<<11)
301 #define ENABLE_ADDR_V_CNTL		(1<<7)
302 #define ENABLE_ADDR_U_CNTL		(1<<3)
303 #define TEXCOORD_ADDR_V_MODE(x) 	((x)<<4)
304 #define TEXCOORD_ADDR_U_MODE(x) 	(x)
305 #define TEXCOORDMODE_WRAP		0
306 #define TEXCOORDMODE_MIRROR		1
307 #define TEXCOORDMODE_CLAMP		2
308 #define TEXCOORDMODE_WRAP_SHORTEST	3
309 #define TEXCOORDMODE_CLAMP_BORDER	4
310 #define TEXCOORD_ADDR_V_MASK		0x70
311 #define TEXCOORD_ADDR_U_MASK		0x7
312 
313 /* _3DSTATE_MAP_CUBE, p168 TODO */
314 #define _3DSTATE_MAP_CUBE		(CMD_3D|(0x1c<<24)|(0x0a<<19))
315 #define CUBE_NEGX_ENABLE                (1<<5)
316 #define CUBE_POSX_ENABLE                (1<<4)
317 #define CUBE_NEGY_ENABLE                (1<<3)
318 #define CUBE_POSY_ENABLE                (1<<2)
319 #define CUBE_NEGZ_ENABLE                (1<<1)
320 #define CUBE_POSZ_ENABLE                (1<<0)
321 
322 
323 /* _3DSTATE_MODES_1, p190 */
324 #define _3DSTATE_MODES_1_CMD		(CMD_3D|(0x08<<24))
325 #define BLENDFUNC_MASK			0x3f0000
326 #define ENABLE_COLR_BLND_FUNC		(1<<21)
327 #define BLENDFUNC_ADD			0
328 #define BLENDFUNC_SUB			(1<<16)
329 #define BLENDFUNC_RVRSE_SUB		(2<<16)
330 #define BLENDFUNC_MIN			(3<<16)
331 #define BLENDFUNC_MAX			(4<<16)
332 #define SRC_DST_BLND_MASK		0xfff
333 #define ENABLE_SRC_BLND_FACTOR		(1<<11)
334 #define ENABLE_DST_BLND_FACTOR		(1<<5)
335 #define SRC_BLND_FACT(x)		((x)<<6)
336 #define DST_BLND_FACT(x)		(x)
337 
338 
339 /* _3DSTATE_MODES_2, p192 */
340 #define _3DSTATE_MODES_2_CMD		(CMD_3D|(0x0f<<24))
341 #define ENABLE_GLOBAL_DEPTH_BIAS	(1<<22)
342 #define GLOBAL_DEPTH_BIAS(x)		((x)<<14)
343 #define ENABLE_ALPHA_TEST_FUNC		(1<<13)
344 #define ENABLE_ALPHA_REF_VALUE		(1<<8)
345 #define ALPHA_TEST_FUNC(x)		((x)<<9)
346 #define ALPHA_REF_VALUE(x)		(x)
347 
348 #define ALPHA_TEST_REF_MASK		0x3fff
349 
350 /* _3DSTATE_MODES_3, p193 */
351 #define _3DSTATE_MODES_3_CMD		(CMD_3D|(0x02<<24))
352 #define DEPTH_TEST_FUNC_MASK		0x1f0000
353 #define ENABLE_DEPTH_TEST_FUNC		(1<<20)
354 /* Uses COMPAREFUNC */
355 #define DEPTH_TEST_FUNC(x)		((x)<<16)
356 #define ENABLE_ALPHA_SHADE_MODE 	(1<<11)
357 #define ENABLE_FOG_SHADE_MODE		(1<<9)
358 #define ENABLE_SPEC_SHADE_MODE		(1<<7)
359 #define ENABLE_COLOR_SHADE_MODE 	(1<<5)
360 #define ALPHA_SHADE_MODE(x)		((x)<<10)
361 #define FOG_SHADE_MODE(x)		((x)<<8)
362 #define SPEC_SHADE_MODE(x)		((x)<<6)
363 #define COLOR_SHADE_MODE(x)		((x)<<4)
364 #define CULLMODE_MASK			0xf
365 #define ENABLE_CULL_MODE		(1<<3)
366 #define CULLMODE_BOTH			0
367 #define CULLMODE_NONE			1
368 #define CULLMODE_CW			2
369 #define CULLMODE_CCW			3
370 
371 #define SHADE_MODE_LINEAR		0
372 #define SHADE_MODE_FLAT 		0x1
373 
374 /* _3DSTATE_MODES_4, p195 */
375 #define _3DSTATE_MODES_4_CMD		(CMD_3D|(0x16<<24))
376 #define ENABLE_LOGIC_OP_FUNC		(1<<23)
377 #define LOGIC_OP_FUNC(x)		((x)<<18)
378 #define LOGICOP_MASK			((1<<18)|(1<<19)|(1<<20)|(1<<21))
379 #define LOGICOP_CLEAR			0
380 #define LOGICOP_NOR			0x1
381 #define LOGICOP_AND_INV 		0x2
382 #define LOGICOP_COPY_INV		0x3
383 #define LOGICOP_AND_RVRSE		0x4
384 #define LOGICOP_INV			0x5
385 #define LOGICOP_XOR			0x6
386 #define LOGICOP_NAND			0x7
387 #define LOGICOP_AND			0x8
388 #define LOGICOP_EQUIV			0x9
389 #define LOGICOP_NOOP			0xa
390 #define LOGICOP_OR_INV			0xb
391 #define LOGICOP_COPY			0xc
392 #define LOGICOP_OR_RVRSE		0xd
393 #define LOGICOP_OR			0xe
394 #define LOGICOP_SET			0xf
395 #define MODE4_ENABLE_STENCIL_TEST_MASK	((1<<17)|(0xff00))
396 #define ENABLE_STENCIL_TEST_MASK	(1<<17)
397 #define STENCIL_TEST_MASK(x)		(((x)&0xff)<<8)
398 #define MODE4_ENABLE_STENCIL_WRITE_MASK	((1<<16)|(0x00ff))
399 #define ENABLE_STENCIL_WRITE_MASK	(1<<16)
400 #define STENCIL_WRITE_MASK(x)		((x)&0xff)
401 
402 /* _3DSTATE_MODES_5, p196 */
403 #define _3DSTATE_MODES_5_CMD		(CMD_3D|(0x0c<<24))
404 #define ENABLE_SPRITE_POINT_TEX 	(1<<23)
405 #define SPRITE_POINT_TEX_ON		(1<<22)
406 #define SPRITE_POINT_TEX_OFF		0
407 #define FLUSH_RENDER_CACHE		(1<<18)
408 #define FLUSH_TEXTURE_CACHE		(1<<16)
409 #define FIXED_LINE_WIDTH_MASK		0xfc00
410 #define ENABLE_FIXED_LINE_WIDTH 	(1<<15)
411 #define FIXED_LINE_WIDTH(x)		((x)<<10)
412 #define FIXED_POINT_WIDTH_MASK		0x3ff
413 #define ENABLE_FIXED_POINT_WIDTH	(1<<9)
414 #define FIXED_POINT_WIDTH(x)		(x)
415 
416 /* _3DSTATE_RASTERIZATION_RULES, p198 */
417 #define _3DSTATE_RASTER_RULES_CMD	(CMD_3D|(0x07<<24))
418 #define ENABLE_POINT_RASTER_RULE	(1<<15)
419 #define OGL_POINT_RASTER_RULE		(1<<13)
420 #define ENABLE_LINE_STRIP_PROVOKE_VRTX	(1<<8)
421 #define ENABLE_TRI_FAN_PROVOKE_VRTX	(1<<5)
422 #define ENABLE_TRI_STRIP_PROVOKE_VRTX	(1<<2)
423 #define LINE_STRIP_PROVOKE_VRTX_MASK	(3<<6)
424 #define LINE_STRIP_PROVOKE_VRTX(x)	((x)<<6)
425 #define TRI_FAN_PROVOKE_VRTX_MASK	(3<<3)
426 #define TRI_FAN_PROVOKE_VRTX(x) 	((x)<<3)
427 #define TRI_STRIP_PROVOKE_VRTX_MASK	(3<<0)
428 #define TRI_STRIP_PROVOKE_VRTX(x)	(x)
429 
430 /* _3DSTATE_SCISSOR_ENABLE, p200 */
431 #define _3DSTATE_SCISSOR_ENABLE_CMD	(CMD_3D|(0x1c<<24)|(0x10<<19))
432 #define ENABLE_SCISSOR_RECT		((1<<1) | 1)
433 #define DISABLE_SCISSOR_RECT		(1<<1)
434 
435 /* _3DSTATE_SCISSOR_RECTANGLE_0, p201 */
436 #define _3DSTATE_SCISSOR_RECT_0_CMD	(CMD_3D|(0x1d<<24)|(0x81<<16)|1)
437 /* Dword 1 */
438 #define SCISSOR_RECT_0_YMIN(x)		((x)<<16)
439 #define SCISSOR_RECT_0_XMIN(x)		(x)
440 /* Dword 2 */
441 #define SCISSOR_RECT_0_YMAX(x)		((x)<<16)
442 #define SCISSOR_RECT_0_XMAX(x)		(x)
443 
444 /* _3DSTATE_STENCIL_TEST, p202 */
445 #define _3DSTATE_STENCIL_TEST_CMD	(CMD_3D|(0x09<<24))
446 #define ENABLE_STENCIL_PARMS		(1<<23)
447 #define STENCIL_OPS_MASK		(0xffc000)
448 #define STENCIL_FAIL_OP(x)		((x)<<20)
449 #define STENCIL_PASS_DEPTH_FAIL_OP(x)	((x)<<17)
450 #define STENCIL_PASS_DEPTH_PASS_OP(x)	((x)<<14)
451 
452 #define ENABLE_STENCIL_TEST_FUNC_MASK	((1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9))
453 #define ENABLE_STENCIL_TEST_FUNC	(1<<13)
454 /* Uses COMPAREFUNC */
455 #define STENCIL_TEST_FUNC(x)		((x)<<9)
456 #define STENCIL_REF_VALUE_MASK		((1<<8)|0xff)
457 #define ENABLE_STENCIL_REF_VALUE	(1<<8)
458 #define STENCIL_REF_VALUE(x)		(x)
459 
460 /* _3DSTATE_VERTEX_FORMAT, p204 */
461 #define _3DSTATE_VFT0_CMD	(CMD_3D|(0x05<<24))
462 #define VFT0_POINT_WIDTH	(1<<12)
463 #define VFT0_TEX_COUNT_MASK    	(7<<8)
464 #define VFT0_TEX_COUNT_SHIFT    8
465 #define VFT0_TEX_COUNT(x) 	((x)<<8)
466 #define VFT0_SPEC		(1<<7)
467 #define VFT0_DIFFUSE		(1<<6)
468 #define VFT0_DEPTH_OFFSET  	(1<<5)
469 #define VFT0_XYZ		(1<<1)
470 #define VFT0_XYZW		(2<<1)
471 #define VFT0_XY			(3<<1)
472 #define VFT0_XYW		(4<<1)
473 #define VFT0_XYZW_MASK          (7<<1)
474 
475 /* _3DSTATE_VERTEX_FORMAT_2, p206 */
476 #define _3DSTATE_VFT1_CMD	(CMD_3D|(0x0a<<24))
477 #define VFT1_TEX7_FMT(x)	((x)<<14)
478 #define VFT1_TEX6_FMT(x)	((x)<<12)
479 #define VFT1_TEX5_FMT(x)	((x)<<10)
480 #define VFT1_TEX4_FMT(x)	((x)<<8)
481 #define VFT1_TEX3_FMT(x)	((x)<<6)
482 #define VFT1_TEX2_FMT(x)	((x)<<4)
483 #define VFT1_TEX1_FMT(x)	((x)<<2)
484 #define VFT1_TEX0_FMT(x)	(x)
485 #define VFT1_TEX0_MASK          3
486 #define VFT1_TEX1_SHIFT         2
487 
488 /*New stuff picked up along the way */
489 
490 #define MLC_LOD_BIAS_MASK ((1<<7)-1)
491 
492 
493 /* _3DSTATE_VERTEX_TRANSFORM, p207 */
494 #define _3DSTATE_VERTEX_TRANS_CMD	(CMD_3D|(0x1d<<24)|(0x8b<<16)|0)
495 #define _3DSTATE_VERTEX_TRANS_MTX_CMD	(CMD_3D|(0x1d<<24)|(0x8b<<16)|6)
496 /* Dword 1 */
497 #define ENABLE_VIEWPORT_TRANSFORM	((1<<31)|(1<<30))
498 #define DISABLE_VIEWPORT_TRANSFORM	(1<<31)
499 #define ENABLE_PERSP_DIVIDE		((1<<29)|(1<<28))
500 #define DISABLE_PERSP_DIVIDE		(1<<29)
501 #define VRTX_TRANS_LOAD_MATRICES	0x7421
502 #define VRTX_TRANS_NO_LOAD_MATRICES	0x0000
503 /* Dword 2 -> 7  are matrix elements */
504 
505 /* _3DSTATE_W_STATE, p209 */
506 #define _3DSTATE_W_STATE_CMD		(CMD_3D|(0x1d<<24)|(0x8d<<16)|1)
507 /* Dword 1 */
508 #define MAGIC_W_STATE_DWORD1		0x00000008
509 /* Dword 2 */
510 #define WFAR_VALUE(x)			(x)
511 
512 
513 /* Stipple command, carried over from the i810, apparently:
514  */
515 #define _3DSTATE_STIPPLE           ((0x3<<29)|(0x1d<<24)|(0x83<<16))
516 #define ST1_ENABLE               (1<<16)
517 #define ST1_MASK                 (0xffff)
518 
519 
520 
521 #define _3DSTATE_LOAD_STATE_IMMEDIATE_2      ((0x3<<29)|(0x1d<<24)|(0x03<<16))
522 #define LOAD_TEXTURE_MAP0                   (1<<11)
523 #define LOAD_GLOBAL_COLOR_FACTOR            (1<<6)
524 
525 #define TM0S0_ADDRESS_MASK              0xfffffffc
526 #define TM0S0_USE_FENCE                 (1<<1)
527 
528 #define TM0S1_HEIGHT_SHIFT              21
529 #define TM0S1_WIDTH_SHIFT               10
530 #define TM0S1_PALETTE_SELECT            (1<<9)
531 #define TM0S1_MAPSURF_FORMAT_MASK       (0x7 << 6)
532 #define TM0S1_MAPSURF_FORMAT_SHIFT      6
533 #define    MAPSURF_8BIT_INDEXED		   (0<<6)
534 #define    MAPSURF_8BIT		 	   (1<<6)
535 #define    MAPSURF_16BIT		   (2<<6)
536 #define    MAPSURF_32BIT		   (3<<6)
537 #define    MAPSURF_411			   (4<<6)
538 #define    MAPSURF_422			   (5<<6)
539 #define    MAPSURF_COMPRESSED		   (6<<6)
540 #define    MAPSURF_4BIT_INDEXED		   (7<<6)
541 #define TM0S1_MT_FORMAT_MASK         (0x7 << 3)
542 #define TM0S1_MT_FORMAT_SHIFT        3
543 #define    MT_4BIT_IDX_ARGB8888	           (7<<3)       /* SURFACE_4BIT_INDEXED */
544 #define    MT_8BIT_IDX_RGB565	           (0<<3)       /* SURFACE_8BIT_INDEXED */
545 #define    MT_8BIT_IDX_ARGB1555	           (1<<3)
546 #define    MT_8BIT_IDX_ARGB4444	           (2<<3)
547 #define    MT_8BIT_IDX_AY88		   (3<<3)
548 #define    MT_8BIT_IDX_ABGR8888	           (4<<3)
549 #define    MT_8BIT_IDX_BUMP_88DVDU 	   (5<<3)
550 #define    MT_8BIT_IDX_BUMP_655LDVDU	   (6<<3)
551 #define    MT_8BIT_IDX_ARGB8888	           (7<<3)
552 #define    MT_8BIT_I8		           (0<<3)       /* SURFACE_8BIT */
553 #define    MT_8BIT_L8		           (1<<3)
554 #define    MT_16BIT_RGB565 		   (0<<3)       /* SURFACE_16BIT */
555 #define    MT_16BIT_ARGB1555		   (1<<3)
556 #define    MT_16BIT_ARGB4444		   (2<<3)
557 #define    MT_16BIT_AY88		   (3<<3)
558 #define    MT_16BIT_DIB_ARGB1555_8888      (4<<3)
559 #define    MT_16BIT_BUMP_88DVDU	           (5<<3)
560 #define    MT_16BIT_BUMP_655LDVDU	   (6<<3)
561 #define    MT_16BIT_DIB_RGB565_8888	   (7<<3)
562 #define    MT_32BIT_ARGB8888		   (0<<3)       /* SURFACE_32BIT */
563 #define    MT_32BIT_ABGR8888		   (1<<3)
564 #define    MT_32BIT_XRGB8888		   (2<<3)       /* XXX: Guess from i915_reg.h */
565 #define    MT_32BIT_BUMP_XLDVDU_8888	   (6<<3)
566 #define    MT_32BIT_DIB_8888		   (7<<3)
567 #define    MT_411_YUV411		   (0<<3)       /* SURFACE_411 */
568 #define    MT_422_YCRCB_SWAPY	           (0<<3)       /* SURFACE_422 */
569 #define    MT_422_YCRCB_NORMAL	           (1<<3)
570 #define    MT_422_YCRCB_SWAPUV	           (2<<3)
571 #define    MT_422_YCRCB_SWAPUVY	           (3<<3)
572 #define    MT_COMPRESS_DXT1		   (0<<3)       /* SURFACE_COMPRESSED */
573 #define    MT_COMPRESS_DXT2_3	           (1<<3)
574 #define    MT_COMPRESS_DXT4_5	           (2<<3)
575 #define    MT_COMPRESS_FXT1		   (3<<3)
576 #define TM0S1_COLORSPACE_CONVERSION     (1 << 2)
577 #define TM0S1_TILED_SURFACE             (1 << 1)
578 #define TM0S1_TILE_WALK                 (1 << 0)
579 
580 #define TM0S2_PITCH_SHIFT               21
581 #define TM0S2_CUBE_FACE_ENA_SHIFT       15
582 #define TM0S2_CUBE_FACE_ENA_MASK        (1<<15)
583 #define TM0S2_MAP_FORMAT                (1<<14)
584 #define TM0S2_VERTICAL_LINE_STRIDE      (1<<13)
585 #define TM0S2_VERITCAL_LINE_STRIDE_OFF  (1<<12)
586 #define TM0S2_OUTPUT_CHAN_SHIFT         10
587 #define TM0S2_OUTPUT_CHAN_MASK          (3<<10)
588 #define TM0S2_BASE_MIP_LEVEL_SHIFT      1
589 #define TM0S2_LOD_PRECLAMP              (1 << 0)
590 
591 #define TM0S3_MIP_FILTER_MASK           (0x3<<30)
592 #define TM0S3_MIP_FILTER_SHIFT          30
593 #define MIPFILTER_NONE		0
594 #define MIPFILTER_NEAREST	1
595 #define MIPFILTER_LINEAR	3
596 #define TM0S3_MAG_FILTER_MASK           (0x3<<28)
597 #define TM0S3_MAG_FILTER_SHIFT          28
598 #define TM0S3_MIN_FILTER_MASK           (0x3<<26)
599 #define TM0S3_MIN_FILTER_SHIFT          26
600 #define FILTER_NEAREST		0
601 #define FILTER_LINEAR		1
602 #define FILTER_ANISOTROPIC	2
603 
604 #define TM0S3_LOD_BIAS_SHIFT		17
605 #define TM0S3_LOD_BIAS_MASK		(0x1ff<<17)
606 #define TM0S3_MAX_MIP_SHIFT		9
607 #define TM0S3_MAX_MIP_MASK		(0xff<<9)
608 #define TM0S3_MIN_MIP_SHIFT		3
609 #define TM0S3_MIN_MIP_MASK		(0x3f<<3)
610 #define TM0S3_MIN_MIP_SHIFT_830		5
611 #define TM0S3_MIN_MIP_MASK_830		(0x3f<<5)
612 #define TM0S3_KILL_PIXEL		(1<<2)
613 #define TM0S3_KEYED_FILTER		(1<<1)
614 #define TM0S3_CHROMA_KEY		(1<<0)
615 
616 
617 /* _3DSTATE_MAP_TEXEL_STREAM, p188 */
618 #define _3DSTATE_MAP_TEX_STREAM_CMD	(CMD_3D|(0x1c<<24)|(0x05<<19))
619 #define DISABLE_TEX_STREAM_BUMP 	(1<<12)
620 #define ENABLE_TEX_STREAM_BUMP		((1<<12)|(1<<11))
621 #define TEX_MODIFY_UNIT_0		0
622 #define TEX_MODIFY_UNIT_1		(1<<8)
623 #define ENABLE_TEX_STREAM_COORD_SET	(1<<7)
624 #define TEX_STREAM_COORD_SET(x) 	((x)<<4)
625 #define ENABLE_TEX_STREAM_MAP_IDX	(1<<3)
626 #define TEX_STREAM_MAP_IDX(x)		(x)
627 
628 #endif
629