103b705cfSriastradh/**************************************************************************
203b705cfSriastradh *
303b705cfSriastradh * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
403b705cfSriastradh * All Rights Reserved.
503b705cfSriastradh *
603b705cfSriastradh * Permission is hereby granted, free of charge, to any person obtaining a
703b705cfSriastradh * copy of this software and associated documentation files (the
803b705cfSriastradh * "Software"), to deal in the Software without restriction, including
903b705cfSriastradh * without limitation the rights to use, copy, modify, merge, publish,
1003b705cfSriastradh * distribute, sub license, and/or sell copies of the Software, and to
1103b705cfSriastradh * permit persons to whom the Software is furnished to do so, subject to
1203b705cfSriastradh * the following conditions:
1303b705cfSriastradh *
1403b705cfSriastradh * The above copyright notice and this permission notice (including the
1503b705cfSriastradh * next paragraph) shall be included in all copies or substantial portions
1603b705cfSriastradh * of the Software.
1703b705cfSriastradh *
1803b705cfSriastradh * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1903b705cfSriastradh * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2003b705cfSriastradh * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
2103b705cfSriastradh * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
2203b705cfSriastradh * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
2303b705cfSriastradh * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2403b705cfSriastradh * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2503b705cfSriastradh *
2603b705cfSriastradh **************************************************************************/
2703b705cfSriastradh
2803b705cfSriastradh#ifndef _I830_REG_H_
2903b705cfSriastradh#define _I830_REG_H_
3003b705cfSriastradh
3103b705cfSriastradh#define I830_SET_FIELD( var, mask, value ) (var &= ~(mask), var |= value)
3203b705cfSriastradh
3303b705cfSriastradh/* Flush */
3403b705cfSriastradh#define MI_FLUSH			(0x04<<23)
3503b705cfSriastradh#define MI_FLUSH_DW			(0x26<<23)
3603b705cfSriastradh
3703b705cfSriastradh#define MI_WRITE_DIRTY_STATE		(1<<4)
3803b705cfSriastradh#define MI_END_SCENE			(1<<3)
3903b705cfSriastradh#define MI_GLOBAL_SNAPSHOT_COUNT_RESET	(1<<3)
4003b705cfSriastradh#define MI_INHIBIT_RENDER_CACHE_FLUSH	(1<<2)
4103b705cfSriastradh#define MI_STATE_INSTRUCTION_CACHE_FLUSH (1<<1)
4203b705cfSriastradh#define MI_INVALIDATE_MAP_CACHE		(1<<0)
4303b705cfSriastradh/* broadwater flush bits */
4403b705cfSriastradh#define BRW_MI_GLOBAL_SNAPSHOT_RESET   (1 << 3)
4503b705cfSriastradh
4603b705cfSriastradh#define MI_BATCH_BUFFER_END	(0xA << 23)
4703b705cfSriastradh
4803b705cfSriastradh/* Noop */
4903b705cfSriastradh#define MI_NOOP				0x00
5003b705cfSriastradh#define MI_NOOP_WRITE_ID		(1<<22)
5103b705cfSriastradh#define MI_NOOP_ID_MASK			(1<<22 - 1)
5203b705cfSriastradh
5303b705cfSriastradh/* Wait for Events */
5403b705cfSriastradh#define MI_WAIT_FOR_EVENT			(0x03<<23)
5503b705cfSriastradh#define MI_WAIT_FOR_PIPEB_SVBLANK		(1<<18)
5603b705cfSriastradh#define MI_WAIT_FOR_PIPEA_SVBLANK		(1<<17)
5703b705cfSriastradh#define MI_WAIT_FOR_OVERLAY_FLIP		(1<<16)
5803b705cfSriastradh#define MI_WAIT_FOR_PIPEB_VBLANK		(1<<7)
5903b705cfSriastradh#define MI_WAIT_FOR_PIPEB_SCAN_LINE_WINDOW	(1<<5)
6003b705cfSriastradh#define MI_WAIT_FOR_PIPEA_VBLANK		(1<<3)
6103b705cfSriastradh#define MI_WAIT_FOR_PIPEA_SCAN_LINE_WINDOW	(1<<1)
6203b705cfSriastradh
6303b705cfSriastradh/* Set the scan line for MI_WAIT_FOR_PIPE?_SCAN_LINE_WINDOW */
6403b705cfSriastradh#define MI_LOAD_SCAN_LINES_INCL			(0x12<<23)
6503b705cfSriastradh#define MI_LOAD_SCAN_LINES_DISPLAY_PIPEA	(0)
6603b705cfSriastradh#define MI_LOAD_SCAN_LINES_DISPLAY_PIPEB	(0x1<<20)
6703b705cfSriastradh
68fe8aea9eSmrg#define MI_LOAD_REGISTER_IMM		(0x22<<23 | (3-2))
69fe8aea9eSmrg
70fe8aea9eSmrg#define BCS_SWCTRL                      0x22200
71fe8aea9eSmrg# define BCS_SWCTRL_SRC_Y               (1 << 0)
72fe8aea9eSmrg# define BCS_SWCTRL_DST_Y               (1 << 1)
73fe8aea9eSmrg
7403b705cfSriastradh/* BLT commands */
7503b705cfSriastradh#define COLOR_BLT_CMD		((2<<29)|(0x40<<22)|(0x3))
7603b705cfSriastradh#define COLOR_BLT_WRITE_ALPHA	(1<<21)
7703b705cfSriastradh#define COLOR_BLT_WRITE_RGB	(1<<20)
7803b705cfSriastradh
7942542f5fSchristos#define XY_COLOR_BLT_CMD		((2<<29)|(0x50<<22))
8003b705cfSriastradh#define XY_COLOR_BLT_WRITE_ALPHA	(1<<21)
8103b705cfSriastradh#define XY_COLOR_BLT_WRITE_RGB		(1<<20)
8203b705cfSriastradh#define XY_COLOR_BLT_TILED		(1<<11)
8303b705cfSriastradh
8442542f5fSchristos#define XY_SETUP_CLIP_BLT_CMD		((2<<29)|(3<<22))
8503b705cfSriastradh
8642542f5fSchristos#define XY_SRC_COPY_BLT_CMD		((2<<29)|(0x53<<22))
8703b705cfSriastradh#define XY_SRC_COPY_BLT_WRITE_ALPHA	(1<<21)
8803b705cfSriastradh#define XY_SRC_COPY_BLT_WRITE_RGB	(1<<20)
8903b705cfSriastradh#define XY_SRC_COPY_BLT_SRC_TILED	(1<<15)
9003b705cfSriastradh#define XY_SRC_COPY_BLT_DST_TILED	(1<<11)
9103b705cfSriastradh
9242542f5fSchristos#define SRC_COPY_BLT_CMD		((2<<29)|(0x43<<22))
9303b705cfSriastradh#define SRC_COPY_BLT_WRITE_ALPHA	(1<<21)
9403b705cfSriastradh#define SRC_COPY_BLT_WRITE_RGB		(1<<20)
9503b705cfSriastradh
9603b705cfSriastradh#define XY_PAT_BLT_IMMEDIATE		((2<<29)|(0x72<<22))
9703b705cfSriastradh
9842542f5fSchristos#define XY_MONO_PAT_BLT_CMD		((0x2<<29)|(0x52<<22))
9903b705cfSriastradh#define XY_MONO_PAT_VERT_SEED		((1<<10)|(1<<9)|(1<<8))
10003b705cfSriastradh#define XY_MONO_PAT_HORT_SEED		((1<<14)|(1<<13)|(1<<12))
10103b705cfSriastradh#define XY_MONO_PAT_BLT_WRITE_ALPHA	(1<<21)
10203b705cfSriastradh#define XY_MONO_PAT_BLT_WRITE_RGB	(1<<20)
10303b705cfSriastradh
10442542f5fSchristos#define XY_MONO_SRC_BLT_CMD		((0x2<<29)|(0x54<<22))
10503b705cfSriastradh#define XY_MONO_SRC_BLT_WRITE_ALPHA	(1<<21)
10603b705cfSriastradh#define XY_MONO_SRC_BLT_WRITE_RGB	(1<<20)
10703b705cfSriastradh
10803b705cfSriastradh#define CMD_3D (0x3<<29)
10903b705cfSriastradh
11003b705cfSriastradh#define PRIM3D_INLINE		(CMD_3D | (0x1f<<24))
11103b705cfSriastradh#define PRIM3D_TRILIST		(0x0<<18)
11203b705cfSriastradh#define PRIM3D_TRISTRIP 	(0x1<<18)
11303b705cfSriastradh#define PRIM3D_TRISTRIP_RVRSE	(0x2<<18)
11403b705cfSriastradh#define PRIM3D_TRIFAN		(0x3<<18)
11503b705cfSriastradh#define PRIM3D_POLY		(0x4<<18)
11603b705cfSriastradh#define PRIM3D_LINELIST 	(0x5<<18)
11703b705cfSriastradh#define PRIM3D_LINESTRIP	(0x6<<18)
11803b705cfSriastradh#define PRIM3D_RECTLIST 	(0x7<<18)
11903b705cfSriastradh#define PRIM3D_POINTLIST	(0x8<<18)
12003b705cfSriastradh#define PRIM3D_DIB		(0x9<<18)
12103b705cfSriastradh#define PRIM3D_CLEAR_RECT	(0xa<<18)
12203b705cfSriastradh#define PRIM3D_ZONE_INIT	(0xd<<18)
12303b705cfSriastradh#define PRIM3D_MASK		(0x1f<<18)
12403b705cfSriastradh
12503b705cfSriastradh#define _3DSTATE_AA_CMD			(CMD_3D | (0x06<<24))
12603b705cfSriastradh#define AA_LINE_ECAAR_WIDTH_ENABLE	(1<<16)
12703b705cfSriastradh#define AA_LINE_ECAAR_WIDTH_0_5 	0
12803b705cfSriastradh#define AA_LINE_ECAAR_WIDTH_1_0		(1<<14)
12903b705cfSriastradh#define AA_LINE_ECAAR_WIDTH_2_0 	(2<<14)
13003b705cfSriastradh#define AA_LINE_ECAAR_WIDTH_4_0 	(3<<14)
13103b705cfSriastradh#define AA_LINE_REGION_WIDTH_ENABLE	(1<<8)
13203b705cfSriastradh#define AA_LINE_REGION_WIDTH_0_5	0
13303b705cfSriastradh#define AA_LINE_REGION_WIDTH_1_0	(1<<6)
13403b705cfSriastradh#define AA_LINE_REGION_WIDTH_2_0	(2<<6)
13503b705cfSriastradh#define AA_LINE_REGION_WIDTH_4_0	(3<<6)
13603b705cfSriastradh#define AA_LINE_ENABLE			((1<<1) | 1)
13703b705cfSriastradh#define AA_LINE_DISABLE			(1<<1)
13803b705cfSriastradh
13903b705cfSriastradh#define _3DSTATE_BUF_INFO_CMD	(CMD_3D | (0x1d<<24) | (0x8e<<16) | 1)
14003b705cfSriastradh/* Dword 1 */
14103b705cfSriastradh#define BUF_3D_ID_COLOR_BACK	(0x3<<24)
14203b705cfSriastradh#define BUF_3D_ID_DEPTH 	(0x7<<24)
14303b705cfSriastradh#define BUF_3D_USE_FENCE	(1<<23)
14403b705cfSriastradh#define BUF_3D_TILED_SURFACE	(1<<22)
14503b705cfSriastradh#define BUF_3D_TILE_WALK_X	0
14603b705cfSriastradh#define BUF_3D_TILE_WALK_Y	(1<<21)
14703b705cfSriastradh#define BUF_3D_PITCH(x)         (((x)/4)<<2)
14803b705cfSriastradh/* Dword 2 */
14903b705cfSriastradh#define BUF_3D_ADDR(x)		((x) & ~0x3)
15003b705cfSriastradh
15103b705cfSriastradh#define _3DSTATE_COLOR_FACTOR_CMD	(CMD_3D | (0x1d<<24) | (0x1<<16))
15203b705cfSriastradh
15303b705cfSriastradh#define _3DSTATE_COLOR_FACTOR_N_CMD(stage)	(CMD_3D | (0x1d<<24) | \
15403b705cfSriastradh					         ((0x90+(stage))<<16))
15503b705cfSriastradh
15603b705cfSriastradh#define _3DSTATE_CONST_BLEND_COLOR_CMD	(CMD_3D | (0x1d<<24) | (0x88<<16))
15703b705cfSriastradh
15803b705cfSriastradh#define _3DSTATE_DFLT_DIFFUSE_CMD	(CMD_3D | (0x1d<<24) | (0x99<<16))
15903b705cfSriastradh
16003b705cfSriastradh#define _3DSTATE_DFLT_SPEC_CMD		(CMD_3D | (0x1d<<24) | (0x9a<<16))
16103b705cfSriastradh
16203b705cfSriastradh#define _3DSTATE_DFLT_Z_CMD		(CMD_3D | (0x1d<<24) | (0x98<<16))
16303b705cfSriastradh
16403b705cfSriastradh#define _3DSTATE_DST_BUF_VARS_CMD	(CMD_3D | (0x1d<<24) | (0x85<<16))
16503b705cfSriastradh/* Dword 1 */
16603b705cfSriastradh#define DSTORG_HORT_BIAS(x)		((x)<<20)
16703b705cfSriastradh#define DSTORG_VERT_BIAS(x)		((x)<<16)
16803b705cfSriastradh#define COLOR_4_2_2_CHNL_WRT_ALL	0
16903b705cfSriastradh#define COLOR_4_2_2_CHNL_WRT_Y		(1<<12)
17003b705cfSriastradh#define COLOR_4_2_2_CHNL_WRT_CR		(2<<12)
17103b705cfSriastradh#define COLOR_4_2_2_CHNL_WRT_CB		(3<<12)
17203b705cfSriastradh#define COLOR_4_2_2_CHNL_WRT_CRCB	(4<<12)
17303b705cfSriastradh#define COLR_BUF_8BIT			0
17403b705cfSriastradh#define COLR_BUF_RGB555 		(1<<8)
17503b705cfSriastradh#define COLR_BUF_RGB565 		(2<<8)
17603b705cfSriastradh#define COLR_BUF_ARGB8888		(3<<8)
17703b705cfSriastradh#define COLR_BUF_ARGB4444		(8<<8)
17803b705cfSriastradh#define COLR_BUF_ARGB1555		(9<<8)
17903b705cfSriastradh#define DEPTH_IS_Z			0
18003b705cfSriastradh#define DEPTH_IS_W			(1<<6)
18103b705cfSriastradh#define DEPTH_FRMT_16_FIXED		0
18203b705cfSriastradh#define DEPTH_FRMT_16_FLOAT		(1<<2)
18303b705cfSriastradh#define DEPTH_FRMT_24_FIXED_8_OTHER	(2<<2)
18403b705cfSriastradh#define DEPTH_FRMT_24_FLOAT_8_OTHER	(3<<2)
18503b705cfSriastradh#define VERT_LINE_STRIDE_1		(1<<1)
18603b705cfSriastradh#define VERT_LINE_STRIDE_0		0
18703b705cfSriastradh#define VERT_LINE_STRIDE_OFS_1		1
18803b705cfSriastradh#define VERT_LINE_STRIDE_OFS_0		0
18903b705cfSriastradh
19003b705cfSriastradh#define _3DSTATE_DRAW_RECT_CMD		(CMD_3D|(0x1d<<24)|(0x80<<16)|3)
19103b705cfSriastradh/* Dword 1 */
19203b705cfSriastradh#define DRAW_RECT_DIS_DEPTH_OFS 	(1<<30)
19303b705cfSriastradh#define DRAW_DITHER_OFS_X(x)		((x)<<26)
19403b705cfSriastradh#define DRAW_DITHER_OFS_Y(x)		((x)<<24)
19503b705cfSriastradh/* Dword 2 */
19603b705cfSriastradh#define DRAW_YMIN(x)			((x)<<16)
19703b705cfSriastradh#define DRAW_XMIN(x)			(x)
19803b705cfSriastradh/* Dword 3 */
19903b705cfSriastradh#define DRAW_YMAX(x)			((x)<<16)
20003b705cfSriastradh#define DRAW_XMAX(x)			(x)
20103b705cfSriastradh/* Dword 4 */
20203b705cfSriastradh#define DRAW_YORG(x)			((x)<<16)
20303b705cfSriastradh#define DRAW_XORG(x)			(x)
20403b705cfSriastradh
20503b705cfSriastradh#define _3DSTATE_ENABLES_1_CMD		(CMD_3D|(0x3<<24))
20603b705cfSriastradh#define ENABLE_LOGIC_OP_MASK		((1<<23)|(1<<22))
20703b705cfSriastradh#define ENABLE_LOGIC_OP 		((1<<23)|(1<<22))
20803b705cfSriastradh#define DISABLE_LOGIC_OP		(1<<23)
20903b705cfSriastradh#define ENABLE_STENCIL_TEST		((1<<21)|(1<<20))
21003b705cfSriastradh#define DISABLE_STENCIL_TEST		(1<<21)
21103b705cfSriastradh#define ENABLE_DEPTH_BIAS		((1<<11)|(1<<10))
21203b705cfSriastradh#define DISABLE_DEPTH_BIAS		(1<<11)
21303b705cfSriastradh#define ENABLE_SPEC_ADD_MASK		((1<<9)|(1<<8))
21403b705cfSriastradh#define ENABLE_SPEC_ADD 		((1<<9)|(1<<8))
21503b705cfSriastradh#define DISABLE_SPEC_ADD		(1<<9)
21603b705cfSriastradh#define ENABLE_DIS_FOG_MASK		((1<<7)|(1<<6))
21703b705cfSriastradh#define ENABLE_FOG			((1<<7)|(1<<6))
21803b705cfSriastradh#define DISABLE_FOG			(1<<7)
21903b705cfSriastradh#define ENABLE_DIS_ALPHA_TEST_MASK	((1<<5)|(1<<4))
22003b705cfSriastradh#define ENABLE_ALPHA_TEST		((1<<5)|(1<<4))
22103b705cfSriastradh#define DISABLE_ALPHA_TEST		(1<<5)
22203b705cfSriastradh#define ENABLE_DIS_CBLEND_MASK		((1<<3)|(1<<2))
22303b705cfSriastradh#define ENABLE_COLOR_BLEND		((1<<3)|(1<<2))
22403b705cfSriastradh#define DISABLE_COLOR_BLEND		(1<<3)
22503b705cfSriastradh#define ENABLE_DIS_DEPTH_TEST_MASK	((1<<1)|1)
22603b705cfSriastradh#define ENABLE_DEPTH_TEST		((1<<1)|1)
22703b705cfSriastradh#define DISABLE_DEPTH_TEST		(1<<1)
22803b705cfSriastradh
22903b705cfSriastradh/* _3DSTATE_ENABLES_2, p138 */
23003b705cfSriastradh#define _3DSTATE_ENABLES_2_CMD		(CMD_3D|(0x4<<24))
23103b705cfSriastradh#define ENABLE_STENCIL_WRITE		((1<<21)|(1<<20))
23203b705cfSriastradh#define DISABLE_STENCIL_WRITE		(1<<21)
23303b705cfSriastradh#define ENABLE_TEX_CACHE		((1<<17)|(1<<16))
23403b705cfSriastradh#define DISABLE_TEX_CACHE		(1<<17)
23503b705cfSriastradh#define ENABLE_DITHER			((1<<9)|(1<<8))
23603b705cfSriastradh#define DISABLE_DITHER			(1<<9)
23703b705cfSriastradh#define ENABLE_COLOR_MASK		(1<<10)
23803b705cfSriastradh#define WRITEMASK_ALPHA			(1<<7)
23903b705cfSriastradh#define WRITEMASK_ALPHA_SHIFT		7
24003b705cfSriastradh#define WRITEMASK_RED			(1<<6)
24103b705cfSriastradh#define WRITEMASK_RED_SHIFT		6
24203b705cfSriastradh#define WRITEMASK_GREEN 		(1<<5)
24303b705cfSriastradh#define WRITEMASK_GREEN_SHIFT		5
24403b705cfSriastradh#define WRITEMASK_BLUE			(1<<4)
24503b705cfSriastradh#define WRITEMASK_BLUE_SHIFT		4
24603b705cfSriastradh#define WRITEMASK_MASK			((1<<4)|(1<<5)|(1<<6)|(1<<7))
24703b705cfSriastradh#define ENABLE_COLOR_WRITE		((1<<3)|(1<<2))
24803b705cfSriastradh#define DISABLE_COLOR_WRITE		(1<<3)
24903b705cfSriastradh#define ENABLE_DIS_DEPTH_WRITE_MASK	0x3
25003b705cfSriastradh#define ENABLE_DEPTH_WRITE		((1<<1)|1)
25103b705cfSriastradh#define DISABLE_DEPTH_WRITE		(1<<1)
25203b705cfSriastradh
25303b705cfSriastradh/* _3DSTATE_FOG_COLOR, p139 */
25403b705cfSriastradh#define _3DSTATE_FOG_COLOR_CMD		(CMD_3D|(0x15<<24))
25503b705cfSriastradh#define FOG_COLOR_RED(x)		((x)<<16)
25603b705cfSriastradh#define FOG_COLOR_GREEN(x)		((x)<<8)
25703b705cfSriastradh#define FOG_COLOR_BLUE(x)		(x)
25803b705cfSriastradh
25903b705cfSriastradh/* _3DSTATE_FOG_MODE, p140 */
26003b705cfSriastradh#define _3DSTATE_FOG_MODE_CMD		(CMD_3D|(0x1d<<24)|(0x89<<16)|2)
26103b705cfSriastradh/* Dword 1 */
26203b705cfSriastradh#define FOGFUNC_ENABLE			(1<<31)
26303b705cfSriastradh#define FOGFUNC_VERTEX			0
26403b705cfSriastradh#define FOGFUNC_PIXEL_EXP		(1<<28)
26503b705cfSriastradh#define FOGFUNC_PIXEL_EXP2		(2<<28)
26603b705cfSriastradh#define FOGFUNC_PIXEL_LINEAR		(3<<28)
26703b705cfSriastradh#define FOGSRC_INDEX_Z			(1<<27)
26803b705cfSriastradh#define FOGSRC_INDEX_W			((1<<27)|(1<<25))
26903b705cfSriastradh#define FOG_LINEAR_CONST		(1<<24)
27003b705cfSriastradh#define FOG_CONST_1(x)			((x)<<4)
27103b705cfSriastradh#define ENABLE_FOG_DENSITY		(1<<23)
27203b705cfSriastradh/* Dword 2 */
27303b705cfSriastradh#define FOG_CONST_2(x)			(x)
27403b705cfSriastradh/* Dword 3 */
27503b705cfSriastradh#define FOG_DENSITY(x)			(x)
27603b705cfSriastradh
27703b705cfSriastradh/* _3DSTATE_INDEPENDENT_ALPHA_BLEND, p142 */
27803b705cfSriastradh#define _3DSTATE_INDPT_ALPHA_BLEND_CMD	(CMD_3D|(0x0b<<24))
27903b705cfSriastradh#define ENABLE_INDPT_ALPHA_BLEND	((1<<23)|(1<<22))
28003b705cfSriastradh#define DISABLE_INDPT_ALPHA_BLEND	(1<<23)
28103b705cfSriastradh#define ALPHA_BLENDFUNC_MASK		0x3f0000
28203b705cfSriastradh#define ENABLE_ALPHA_BLENDFUNC		(1<<21)
28303b705cfSriastradh#define ABLENDFUNC_ADD			0
28403b705cfSriastradh#define ABLENDFUNC_SUB			(1<<16)
28503b705cfSriastradh#define ABLENDFUNC_RVSE_SUB		(2<<16)
28603b705cfSriastradh#define ABLENDFUNC_MIN			(3<<16)
28703b705cfSriastradh#define ABLENDFUNC_MAX			(4<<16)
28803b705cfSriastradh#define SRC_DST_ABLEND_MASK		0xfff
28903b705cfSriastradh#define ENABLE_SRC_ABLEND_FACTOR	(1<<11)
29003b705cfSriastradh#define SRC_ABLEND_FACT(x)		((x)<<6)
29103b705cfSriastradh#define ENABLE_DST_ABLEND_FACTOR	(1<<5)
29203b705cfSriastradh#define DST_ABLEND_FACT(x)		(x)
29303b705cfSriastradh
29403b705cfSriastradh#define BLENDFACTOR_ZERO		0x01
29503b705cfSriastradh#define BLENDFACTOR_ONE 		0x02
29603b705cfSriastradh#define BLENDFACTOR_SRC_COLR		0x03
29703b705cfSriastradh#define BLENDFACTOR_INV_SRC_COLR	0x04
29803b705cfSriastradh#define BLENDFACTOR_SRC_ALPHA		0x05
29903b705cfSriastradh#define BLENDFACTOR_INV_SRC_ALPHA	0x06
30003b705cfSriastradh#define BLENDFACTOR_DST_ALPHA		0x07
30103b705cfSriastradh#define BLENDFACTOR_INV_DST_ALPHA	0x08
30203b705cfSriastradh#define BLENDFACTOR_DST_COLR		0x09
30303b705cfSriastradh#define BLENDFACTOR_INV_DST_COLR	0x0a
30403b705cfSriastradh#define BLENDFACTOR_SRC_ALPHA_SATURATE	0x0b
30503b705cfSriastradh#define BLENDFACTOR_CONST_COLOR		0x0c
30603b705cfSriastradh#define BLENDFACTOR_INV_CONST_COLOR	0x0d
30703b705cfSriastradh#define BLENDFACTOR_CONST_ALPHA		0x0e
30803b705cfSriastradh#define BLENDFACTOR_INV_CONST_ALPHA	0x0f
30903b705cfSriastradh#define BLENDFACTOR_MASK		0x0f
31003b705cfSriastradh
31103b705cfSriastradh/* _3DSTATE_MAP_BLEND_ARG, p152 */
31203b705cfSriastradh#define _3DSTATE_MAP_BLEND_ARG_CMD(stage)	(CMD_3D|(0x0e<<24)|((stage)<<20))
31303b705cfSriastradh
31403b705cfSriastradh#define TEXPIPE_COLOR			0
31503b705cfSriastradh#define TEXPIPE_ALPHA			(1<<18)
31603b705cfSriastradh#define TEXPIPE_KILL			(2<<18)
31703b705cfSriastradh#define TEXBLEND_ARG0			0
31803b705cfSriastradh#define TEXBLEND_ARG1			(1<<15)
31903b705cfSriastradh#define TEXBLEND_ARG2			(2<<15)
32003b705cfSriastradh#define TEXBLEND_ARG3			(3<<15)
32103b705cfSriastradh#define TEXBLENDARG_MODIFY_PARMS	(1<<6)
32203b705cfSriastradh#define TEXBLENDARG_REPLICATE_ALPHA 	(1<<5)
32303b705cfSriastradh#define TEXBLENDARG_INV_ARG 		(1<<4)
32403b705cfSriastradh#define TEXBLENDARG_ONE 		0
32503b705cfSriastradh#define TEXBLENDARG_FACTOR		0x01
32603b705cfSriastradh#define TEXBLENDARG_ACCUM		0x02
32703b705cfSriastradh#define TEXBLENDARG_DIFFUSE		0x03
32803b705cfSriastradh#define TEXBLENDARG_SPEC		0x04
32903b705cfSriastradh#define TEXBLENDARG_CURRENT		0x05
33003b705cfSriastradh#define TEXBLENDARG_TEXEL0		0x06
33103b705cfSriastradh#define TEXBLENDARG_TEXEL1		0x07
33203b705cfSriastradh#define TEXBLENDARG_TEXEL2		0x08
33303b705cfSriastradh#define TEXBLENDARG_TEXEL3		0x09
33403b705cfSriastradh#define TEXBLENDARG_FACTOR_N		0x0e
33503b705cfSriastradh
33603b705cfSriastradh/* _3DSTATE_MAP_BLEND_OP, p155 */
33703b705cfSriastradh#define _3DSTATE_MAP_BLEND_OP_CMD(stage)	(CMD_3D|(0x0d<<24)|((stage)<<20))
33803b705cfSriastradh#if 0
33903b705cfSriastradh#   define TEXPIPE_COLOR		0
34003b705cfSriastradh#   define TEXPIPE_ALPHA		(1<<18)
34103b705cfSriastradh#   define TEXPIPE_KILL			(2<<18)
34203b705cfSriastradh#endif
34303b705cfSriastradh#define ENABLE_TEXOUTPUT_WRT_SEL	(1<<17)
34403b705cfSriastradh#define TEXOP_OUTPUT_CURRENT		0
34503b705cfSriastradh#define TEXOP_OUTPUT_ACCUM		(1<<15)
34603b705cfSriastradh#define ENABLE_TEX_CNTRL_STAGE		((1<<12)|(1<<11))
34703b705cfSriastradh#define DISABLE_TEX_CNTRL_STAGE		(1<<12)
34803b705cfSriastradh#define TEXOP_SCALE_SHIFT		9
34903b705cfSriastradh#define TEXOP_SCALE_1X			(0 << TEXOP_SCALE_SHIFT)
35003b705cfSriastradh#define TEXOP_SCALE_2X			(1 << TEXOP_SCALE_SHIFT)
35103b705cfSriastradh#define TEXOP_SCALE_4X			(2 << TEXOP_SCALE_SHIFT)
35203b705cfSriastradh#define TEXOP_MODIFY_PARMS		(1<<8)
35303b705cfSriastradh#define TEXOP_LAST_STAGE		(1<<7)
35403b705cfSriastradh#define TEXBLENDOP_KILLPIXEL		0x02
35503b705cfSriastradh#define TEXBLENDOP_ARG1 		0x01
35603b705cfSriastradh#define TEXBLENDOP_ARG2 		0x02
35703b705cfSriastradh#define TEXBLENDOP_MODULATE		0x03
35803b705cfSriastradh#define TEXBLENDOP_ADD			0x06
35903b705cfSriastradh#define TEXBLENDOP_ADDSIGNED		0x07
36003b705cfSriastradh#define TEXBLENDOP_BLEND		0x08
36103b705cfSriastradh#define TEXBLENDOP_BLEND_AND_ADD	0x09
36203b705cfSriastradh#define TEXBLENDOP_SUBTRACT		0x0a
36303b705cfSriastradh#define TEXBLENDOP_DOT3 		0x0b
36403b705cfSriastradh#define TEXBLENDOP_DOT4 		0x0c
36503b705cfSriastradh#define TEXBLENDOP_MODULATE_AND_ADD	0x0d
36603b705cfSriastradh#define TEXBLENDOP_MODULATE_2X_AND_ADD	0x0e
36703b705cfSriastradh#define TEXBLENDOP_MODULATE_4X_AND_ADD	0x0f
36803b705cfSriastradh
36903b705cfSriastradh/* _3DSTATE_MAP_BUMP_TABLE, p160 TODO */
37003b705cfSriastradh/* _3DSTATE_MAP_COLOR_CHROMA_KEY, p161 TODO */
37103b705cfSriastradh
37203b705cfSriastradh#define _3DSTATE_MAP_COORD_TRANSFORM	((3<<29)|(0x1d<<24)|(0x8c<<16))
37303b705cfSriastradh#define DISABLE_TEX_TRANSFORM		(1<<28)
37403b705cfSriastradh#define TEXTURE_SET(x)			(x<<29)
37503b705cfSriastradh
37603b705cfSriastradh#define _3DSTATE_VERTEX_TRANSFORM	((3<<29)|(0x1d<<24)|(0x8b<<16))
37703b705cfSriastradh#define DISABLE_VIEWPORT_TRANSFORM	(1<<31)
37803b705cfSriastradh#define DISABLE_PERSPECTIVE_DIVIDE	(1<<29)
37903b705cfSriastradh
38003b705cfSriastradh/* _3DSTATE_MAP_COORD_SET_BINDINGS, p162 */
38103b705cfSriastradh#define _3DSTATE_MAP_COORD_SETBIND_CMD	(CMD_3D|(0x1d<<24)|(0x02<<16))
38203b705cfSriastradh#define TEXBIND_MASK3			((1<<15)|(1<<14)|(1<<13)|(1<<12))
38303b705cfSriastradh#define TEXBIND_MASK2			((1<<11)|(1<<10)|(1<<9)|(1<<8))
38403b705cfSriastradh#define TEXBIND_MASK1			((1<<7)|(1<<6)|(1<<5)|(1<<4))
38503b705cfSriastradh#define TEXBIND_MASK0			((1<<3)|(1<<2)|(1<<1)|1)
38603b705cfSriastradh
38703b705cfSriastradh#define TEXBIND_SET3(x) 		((x)<<12)
38803b705cfSriastradh#define TEXBIND_SET2(x) 		((x)<<8)
38903b705cfSriastradh#define TEXBIND_SET1(x) 		((x)<<4)
39003b705cfSriastradh#define TEXBIND_SET0(x) 		(x)
39103b705cfSriastradh
39203b705cfSriastradh#define TEXCOORDSRC_KEEP		0
39303b705cfSriastradh#define TEXCOORDSRC_DEFAULT		0x01
39403b705cfSriastradh#define TEXCOORDSRC_VTXSET_0		0x08
39503b705cfSriastradh#define TEXCOORDSRC_VTXSET_1		0x09
39603b705cfSriastradh#define TEXCOORDSRC_VTXSET_2		0x0a
39703b705cfSriastradh#define TEXCOORDSRC_VTXSET_3		0x0b
39803b705cfSriastradh#define TEXCOORDSRC_VTXSET_4		0x0c
39903b705cfSriastradh#define TEXCOORDSRC_VTXSET_5		0x0d
40003b705cfSriastradh#define TEXCOORDSRC_VTXSET_6		0x0e
40103b705cfSriastradh#define TEXCOORDSRC_VTXSET_7		0x0f
40203b705cfSriastradh
40303b705cfSriastradh#define MAP_UNIT(unit)			((unit)<<16)
40403b705cfSriastradh#define MAP_UNIT_MASK			(0x7<<16)
40503b705cfSriastradh
40603b705cfSriastradh/* _3DSTATE_MAP_COORD_SETS, p164 */
40703b705cfSriastradh#define _3DSTATE_MAP_COORD_SET_CMD	(CMD_3D|(0x1c<<24)|(0x01<<19))
40803b705cfSriastradh#define TEXCOORD_SET(n)			((n)<<16)
40903b705cfSriastradh#define ENABLE_TEXCOORD_PARAMS		(1<<15)
41003b705cfSriastradh#define TEXCOORDS_ARE_NORMAL		(1<<14)
41103b705cfSriastradh#define TEXCOORDS_ARE_IN_TEXELUNITS	0
41203b705cfSriastradh#define TEXCOORDTYPE_CARTESIAN		0
41303b705cfSriastradh#define TEXCOORDTYPE_HOMOGENEOUS	(1<<11)
41403b705cfSriastradh#define TEXCOORDTYPE_VECTOR		(2<<11)
41503b705cfSriastradh#define TEXCOORDTYPE_MASK	        (0x7<<11)
41603b705cfSriastradh#define ENABLE_ADDR_V_CNTL		(1<<7)
41703b705cfSriastradh#define ENABLE_ADDR_U_CNTL		(1<<3)
41803b705cfSriastradh#define TEXCOORD_ADDR_V_MODE(x) 	((x)<<4)
41903b705cfSriastradh#define TEXCOORD_ADDR_U_MODE(x) 	(x)
42003b705cfSriastradh#define TEXCOORDMODE_WRAP		0
42103b705cfSriastradh#define TEXCOORDMODE_MIRROR		1
42203b705cfSriastradh#define TEXCOORDMODE_CLAMP		2
42303b705cfSriastradh#define TEXCOORDMODE_WRAP_SHORTEST	3
42403b705cfSriastradh#define TEXCOORDMODE_CLAMP_BORDER	4
42503b705cfSriastradh#define TEXCOORD_ADDR_V_MASK		0x70
42603b705cfSriastradh#define TEXCOORD_ADDR_U_MASK		0x7
42703b705cfSriastradh
42803b705cfSriastradh/* _3DSTATE_MAP_CUBE, p168 TODO */
42903b705cfSriastradh#define _3DSTATE_MAP_CUBE		(CMD_3D|(0x1c<<24)|(0x0a<<19))
43003b705cfSriastradh#define CUBE_NEGX_ENABLE                (1<<5)
43103b705cfSriastradh#define CUBE_POSX_ENABLE                (1<<4)
43203b705cfSriastradh#define CUBE_NEGY_ENABLE                (1<<3)
43303b705cfSriastradh#define CUBE_POSY_ENABLE                (1<<2)
43403b705cfSriastradh#define CUBE_NEGZ_ENABLE                (1<<1)
43503b705cfSriastradh#define CUBE_POSZ_ENABLE                (1<<0)
43603b705cfSriastradh
43703b705cfSriastradh#define _3DSTATE_MAP_INFO_CMD		(CMD_3D|(0x1d<<24)|(0x0<<16)|3)
43803b705cfSriastradh#define TEXMAP_INDEX(x)			((x)<<28)
43903b705cfSriastradh#define MAP_SURFACE_8BIT		(1<<24)
44003b705cfSriastradh#define MAP_SURFACE_16BIT		(2<<24)
44103b705cfSriastradh#define MAP_SURFACE_32BIT		(3<<24)
44203b705cfSriastradh#define MAP_FORMAT_2D			(0)
44303b705cfSriastradh#define MAP_FORMAT_3D_CUBE		(1<<11)
44403b705cfSriastradh
44503b705cfSriastradh/* _3DSTATE_MODES_1, p190 */
44603b705cfSriastradh#define _3DSTATE_MODES_1_CMD		(CMD_3D|(0x08<<24))
44703b705cfSriastradh#define BLENDFUNC_MASK			0x3f0000
44803b705cfSriastradh#define ENABLE_COLR_BLND_FUNC		(1<<21)
44903b705cfSriastradh#define BLENDFUNC_ADD			0
45003b705cfSriastradh#define BLENDFUNC_SUB			(1<<16)
45103b705cfSriastradh#define BLENDFUNC_RVRSE_SUB		(2<<16)
45203b705cfSriastradh#define BLENDFUNC_MIN			(3<<16)
45303b705cfSriastradh#define BLENDFUNC_MAX			(4<<16)
45403b705cfSriastradh#define SRC_DST_BLND_MASK		0xfff
45503b705cfSriastradh#define ENABLE_SRC_BLND_FACTOR		(1<<11)
45603b705cfSriastradh#define ENABLE_DST_BLND_FACTOR		(1<<5)
45703b705cfSriastradh#define SRC_BLND_FACT(x)		((x)<<6)
45803b705cfSriastradh#define DST_BLND_FACT(x)		(x)
45903b705cfSriastradh
46003b705cfSriastradh/* _3DSTATE_MODES_2, p192 */
46103b705cfSriastradh#define _3DSTATE_MODES_2_CMD		(CMD_3D|(0x0f<<24))
46203b705cfSriastradh#define ENABLE_GLOBAL_DEPTH_BIAS	(1<<22)
46303b705cfSriastradh#define GLOBAL_DEPTH_BIAS(x)		((x)<<14)
46403b705cfSriastradh#define ENABLE_ALPHA_TEST_FUNC		(1<<13)
46503b705cfSriastradh#define ENABLE_ALPHA_REF_VALUE		(1<<8)
46603b705cfSriastradh#define ALPHA_TEST_FUNC(x)		((x)<<9)
46703b705cfSriastradh#define ALPHA_REF_VALUE(x)		(x)
46803b705cfSriastradh
46903b705cfSriastradh#define ALPHA_TEST_REF_MASK		0x3fff
47003b705cfSriastradh
47103b705cfSriastradh/* _3DSTATE_MODES_3, p193 */
47203b705cfSriastradh#define _3DSTATE_MODES_3_CMD		(CMD_3D|(0x02<<24))
47303b705cfSriastradh#define DEPTH_TEST_FUNC_MASK		0x1f0000
47403b705cfSriastradh#define ENABLE_DEPTH_TEST_FUNC		(1<<20)
47503b705cfSriastradh/* Uses COMPAREFUNC */
47603b705cfSriastradh#define DEPTH_TEST_FUNC(x)		((x)<<16)
47703b705cfSriastradh#define ENABLE_ALPHA_SHADE_MODE 	(1<<11)
47803b705cfSriastradh#define ENABLE_FOG_SHADE_MODE		(1<<9)
47903b705cfSriastradh#define ENABLE_SPEC_SHADE_MODE		(1<<7)
48003b705cfSriastradh#define ENABLE_COLOR_SHADE_MODE 	(1<<5)
48103b705cfSriastradh#define ALPHA_SHADE_MODE(x)		((x)<<10)
48203b705cfSriastradh#define FOG_SHADE_MODE(x)		((x)<<8)
48303b705cfSriastradh#define SPEC_SHADE_MODE(x)		((x)<<6)
48403b705cfSriastradh#define COLOR_SHADE_MODE(x)		((x)<<4)
48503b705cfSriastradh#define CULLMODE_MASK			0xf
48603b705cfSriastradh#define ENABLE_CULL_MODE		(1<<3)
48703b705cfSriastradh#define CULLMODE_BOTH			0
48803b705cfSriastradh#define CULLMODE_NONE			1
48903b705cfSriastradh#define CULLMODE_CW			2
49003b705cfSriastradh#define CULLMODE_CCW			3
49103b705cfSriastradh
49203b705cfSriastradh#define SHADE_MODE_LINEAR		0
49303b705cfSriastradh#define SHADE_MODE_FLAT 		0x1
49403b705cfSriastradh
49503b705cfSriastradh/* _3DSTATE_MODES_4, p195 */
49603b705cfSriastradh#define _3DSTATE_MODES_4_CMD		(CMD_3D|(0x16<<24))
49703b705cfSriastradh#define ENABLE_LOGIC_OP_FUNC		(1<<23)
49803b705cfSriastradh#define LOGIC_OP_FUNC(x)		((x)<<18)
49903b705cfSriastradh#define LOGICOP_MASK			((1<<18)|(1<<19)|(1<<20)|(1<<21))
50003b705cfSriastradh#define LOGICOP_CLEAR			0
50103b705cfSriastradh#define LOGICOP_NOR			0x1
50203b705cfSriastradh#define LOGICOP_AND_INV 		0x2
50303b705cfSriastradh#define LOGICOP_COPY_INV		0x3
50403b705cfSriastradh#define LOGICOP_AND_RVRSE		0x4
50503b705cfSriastradh#define LOGICOP_INV			0x5
50603b705cfSriastradh#define LOGICOP_XOR			0x6
50703b705cfSriastradh#define LOGICOP_NAND			0x7
50803b705cfSriastradh#define LOGICOP_AND			0x8
50903b705cfSriastradh#define LOGICOP_EQUIV			0x9
51003b705cfSriastradh#define LOGICOP_NOOP			0xa
51103b705cfSriastradh#define LOGICOP_OR_INV			0xb
51203b705cfSriastradh#define LOGICOP_COPY			0xc
51303b705cfSriastradh#define LOGICOP_OR_RVRSE		0xd
51403b705cfSriastradh#define LOGICOP_OR			0xe
51503b705cfSriastradh#define LOGICOP_SET			0xf
51603b705cfSriastradh#define MODE4_ENABLE_STENCIL_TEST_MASK	((1<<17)|(0xff00))
51703b705cfSriastradh#define ENABLE_STENCIL_TEST_MASK	(1<<17)
51803b705cfSriastradh#define STENCIL_TEST_MASK(x)		((x)<<8)
51903b705cfSriastradh#define MODE4_ENABLE_STENCIL_WRITE_MASK	((1<<16)|(0x00ff))
52003b705cfSriastradh#define ENABLE_STENCIL_WRITE_MASK	(1<<16)
52103b705cfSriastradh#define STENCIL_WRITE_MASK(x)		((x)&0xff)
52203b705cfSriastradh
52303b705cfSriastradh/* _3DSTATE_MODES_5, p196 */
52403b705cfSriastradh#define _3DSTATE_MODES_5_CMD		(CMD_3D|(0x0c<<24))
52503b705cfSriastradh#define ENABLE_SPRITE_POINT_TEX 	(1<<23)
52603b705cfSriastradh#define SPRITE_POINT_TEX_ON		(1<<22)
52703b705cfSriastradh#define SPRITE_POINT_TEX_OFF		0
52803b705cfSriastradh#define FLUSH_RENDER_CACHE		(1<<18)
52903b705cfSriastradh#define FLUSH_TEXTURE_CACHE		(1<<16)
53003b705cfSriastradh#define FIXED_LINE_WIDTH_MASK		0xfc00
53103b705cfSriastradh#define ENABLE_FIXED_LINE_WIDTH 	(1<<15)
53203b705cfSriastradh#define FIXED_LINE_WIDTH(x)		((x)<<10)
53303b705cfSriastradh#define FIXED_POINT_WIDTH_MASK		0x3ff
53403b705cfSriastradh#define ENABLE_FIXED_POINT_WIDTH	(1<<9)
53503b705cfSriastradh#define FIXED_POINT_WIDTH(x)		(x)
53603b705cfSriastradh
53703b705cfSriastradh/* _3DSTATE_RASTERIZATION_RULES, p198 */
53803b705cfSriastradh#define _3DSTATE_RASTER_RULES_CMD	(CMD_3D|(0x07<<24))
53903b705cfSriastradh#define ENABLE_POINT_RASTER_RULE	(1<<15)
54003b705cfSriastradh#define OGL_POINT_RASTER_RULE		(1<<13)
54103b705cfSriastradh#define ENABLE_LINE_STRIP_PROVOKE_VRTX	(1<<8)
54203b705cfSriastradh#define ENABLE_TRI_FAN_PROVOKE_VRTX	(1<<5)
54303b705cfSriastradh#define ENABLE_TRI_STRIP_PROVOKE_VRTX	(1<<2)
54403b705cfSriastradh#define LINE_STRIP_PROVOKE_VRTX(x)	((x)<<6)
54503b705cfSriastradh#define TRI_FAN_PROVOKE_VRTX(x) 	((x)<<3)
54603b705cfSriastradh#define TRI_STRIP_PROVOKE_VRTX(x)	(x)
54703b705cfSriastradh
54803b705cfSriastradh/* _3DSTATE_SCISSOR_ENABLE, p200 */
54903b705cfSriastradh#define _3DSTATE_SCISSOR_ENABLE_CMD	(CMD_3D|(0x1c<<24)|(0x10<<19))
55003b705cfSriastradh#define ENABLE_SCISSOR_RECT		((1<<1) | 1)
55103b705cfSriastradh#define DISABLE_SCISSOR_RECT		(1<<1)
55203b705cfSriastradh
55303b705cfSriastradh/* _3DSTATE_SCISSOR_RECTANGLE_0, p201 */
55403b705cfSriastradh#define _3DSTATE_SCISSOR_RECT_0_CMD	(CMD_3D|(0x1d<<24)|(0x81<<16)|1)
55503b705cfSriastradh/* Dword 1 */
55603b705cfSriastradh#define SCISSOR_RECT_0_YMIN(x)		((x)<<16)
55703b705cfSriastradh#define SCISSOR_RECT_0_XMIN(x)		(x)
55803b705cfSriastradh/* Dword 2 */
55903b705cfSriastradh#define SCISSOR_RECT_0_YMAX(x)		((x)<<16)
56003b705cfSriastradh#define SCISSOR_RECT_0_XMAX(x)		(x)
56103b705cfSriastradh
56203b705cfSriastradh/* _3DSTATE_STENCIL_TEST, p202 */
56303b705cfSriastradh#define _3DSTATE_STENCIL_TEST_CMD	(CMD_3D|(0x09<<24))
56403b705cfSriastradh#define ENABLE_STENCIL_PARMS		(1<<23)
56503b705cfSriastradh#define STENCIL_OPS_MASK		(0xffc000)
56603b705cfSriastradh#define STENCIL_FAIL_OP(x)		((x)<<20)
56703b705cfSriastradh#define STENCIL_PASS_DEPTH_FAIL_OP(x)	((x)<<17)
56803b705cfSriastradh#define STENCIL_PASS_DEPTH_PASS_OP(x)	((x)<<14)
56903b705cfSriastradh
57003b705cfSriastradh#define ENABLE_STENCIL_TEST_FUNC_MASK	((1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9))
57103b705cfSriastradh#define ENABLE_STENCIL_TEST_FUNC	(1<<13)
57203b705cfSriastradh/* Uses COMPAREFUNC */
57303b705cfSriastradh#define STENCIL_TEST_FUNC(x)		((x)<<9)
57403b705cfSriastradh#define STENCIL_REF_VALUE_MASK		((1<<8)|0xff)
57503b705cfSriastradh#define ENABLE_STENCIL_REF_VALUE	(1<<8)
57603b705cfSriastradh#define STENCIL_REF_VALUE(x)		(x)
57703b705cfSriastradh
57803b705cfSriastradh/* _3DSTATE_VERTEX_FORMAT, p204 */
57903b705cfSriastradh#define _3DSTATE_VFT0_CMD	(CMD_3D|(0x05<<24))
58003b705cfSriastradh#define VFT0_POINT_WIDTH	(1<<12)
58103b705cfSriastradh#define VFT0_TEX_COUNT_MASK    	(7<<8)
58203b705cfSriastradh#define VFT0_TEX_COUNT_SHIFT    8
58303b705cfSriastradh#define VFT0_TEX_COUNT(x) 	((x)<<8)
58403b705cfSriastradh#define VFT0_SPEC		(1<<7)
58503b705cfSriastradh#define VFT0_DIFFUSE		(1<<6)
58603b705cfSriastradh#define VFT0_DEPTH_OFFSET  	(1<<5)
58703b705cfSriastradh#define VFT0_XYZ		(1<<1)
58803b705cfSriastradh#define VFT0_XYZW		(2<<1)
58903b705cfSriastradh#define VFT0_XY			(3<<1)
59003b705cfSriastradh#define VFT0_XYW		(4<<1)
59103b705cfSriastradh#define VFT0_XYZW_MASK          (7<<1)
59203b705cfSriastradh
59303b705cfSriastradh/* _3DSTATE_VERTEX_FORMAT_2, p206 */
59403b705cfSriastradh#define _3DSTATE_VERTEX_FORMAT_2_CMD	(CMD_3D|(0x0a<<24))
59503b705cfSriastradh#define VFT1_TEX7_FMT(x)	((x)<<14)
59603b705cfSriastradh#define VFT1_TEX6_FMT(x)	((x)<<12)
59703b705cfSriastradh#define VFT1_TEX5_FMT(x)	((x)<<10)
59803b705cfSriastradh#define VFT1_TEX4_FMT(x)	((x)<<8)
59903b705cfSriastradh#define VFT1_TEX3_FMT(x)	((x)<<6)
60003b705cfSriastradh#define VFT1_TEX2_FMT(x)	((x)<<4)
60103b705cfSriastradh#define VFT1_TEX1_FMT(x)	((x)<<2)
60203b705cfSriastradh#define VFT1_TEX0_FMT(x)	(x)
60303b705cfSriastradh#define VFT1_TEX0_MASK          3
60403b705cfSriastradh#define VFT1_TEX1_SHIFT         2
60503b705cfSriastradh#define TEXCOORDFMT_2D		0
60603b705cfSriastradh#define TEXCOORDFMT_3D		1
60703b705cfSriastradh#define TEXCOORDFMT_4D		2
60803b705cfSriastradh#define TEXCOORDFMT_1D		3
60903b705cfSriastradh
61003b705cfSriastradh/*New stuff picked up along the way */
61103b705cfSriastradh
61203b705cfSriastradh#define MLC_LOD_BIAS_MASK ((1<<7)-1)
61303b705cfSriastradh
61403b705cfSriastradh/* _3DSTATE_VERTEX_TRANSFORM, p207 */
61503b705cfSriastradh#define _3DSTATE_VERTEX_TRANS_CMD	(CMD_3D|(0x1d<<24)|(0x8b<<16)|0)
61603b705cfSriastradh#define _3DSTATE_VERTEX_TRANS_MTX_CMD	(CMD_3D|(0x1d<<24)|(0x8b<<16)|6)
61703b705cfSriastradh/* Dword 1 */
61803b705cfSriastradh#define ENABLE_VIEWPORT_TRANSFORM	((1<<31)|(1<<30))
61903b705cfSriastradh#define DISABLE_VIEWPORT_TRANSFORM	(1<<31)
62003b705cfSriastradh#define ENABLE_PERSP_DIVIDE		((1<<29)|(1<<28))
62103b705cfSriastradh#define DISABLE_PERSP_DIVIDE		(1<<29)
62203b705cfSriastradh#define VRTX_TRANS_LOAD_MATRICES	0x7421
62303b705cfSriastradh#define VRTX_TRANS_NO_LOAD_MATRICES	0x0000
62403b705cfSriastradh/* Dword 2 -> 7  are matrix elements */
62503b705cfSriastradh
62603b705cfSriastradh/* _3DSTATE_W_STATE, p209 */
62703b705cfSriastradh#define _3DSTATE_W_STATE_CMD		(CMD_3D|(0x1d<<24)|(0x8d<<16)|1)
62803b705cfSriastradh/* Dword 1 */
62903b705cfSriastradh#define MAGIC_W_STATE_DWORD1		0x00000008
63003b705cfSriastradh/* Dword 2 */
63103b705cfSriastradh#define WFAR_VALUE(x)			(x)
63203b705cfSriastradh
63303b705cfSriastradh/* Stipple command, carried over from the i810, apparently:
63403b705cfSriastradh */
63503b705cfSriastradh#define _3DSTATE_STIPPLE           (CMD_3D|(0x1d<<24)|(0x83<<16))
63603b705cfSriastradh#define ST1_ENABLE               (1<<16)
63703b705cfSriastradh#define ST1_MASK                 (0xffff)
63803b705cfSriastradh
63903b705cfSriastradh#define _3DSTATE_LOAD_STATE_IMMEDIATE_1	     (CMD_3D|(0x1d<<24)|(0x04<<16))
64003b705cfSriastradh#define I1_LOAD_S(n)			     (1<<((n)+4))
64103b705cfSriastradh#define S3_POINT_WIDTH_SHIFT		     23
64203b705cfSriastradh#define S3_LINE_WIDTH_SHIFT		     19
64303b705cfSriastradh#define S3_ALPHA_SHADE_MODE_SHIFT	     18
64403b705cfSriastradh#define S3_FOG_SHADE_MODE_SHIFT		     17
64503b705cfSriastradh#define S3_SPEC_SHADE_MODE_SHIFT	     16
64603b705cfSriastradh#define S3_COLOR_SHADE_MODE_SHIFT	     15
64703b705cfSriastradh#define S3_CULL_MODE_SHIFT		     13
64803b705cfSriastradh#define    S3_CULLMODE_BOTH		     (0)
64903b705cfSriastradh#define    S3_CULLMODE_NONE		     (1<<13)
65003b705cfSriastradh#define    S3_CULLMODE_CW		     (2<<13)
65103b705cfSriastradh#define    S3_CULLMODE_CCW		     (3<<13)
65203b705cfSriastradh#define S3_POINT_WIDTH_PRESENT		     (1<<12)
65303b705cfSriastradh#define S3_SPEC_FOG_PRESENT		     (1<<11)
65403b705cfSriastradh#define S3_DIFFUSE_PRESENT		     (1<<10)
65503b705cfSriastradh#define S3_DEPTH_OFFSET_PRESENT		     (1<<9)
65603b705cfSriastradh#define S3_POSITION_SHIFT		     6
65703b705cfSriastradh#define    S3_VERTEXHAS_XYZ		     (1<<6)
65803b705cfSriastradh#define    S3_VERTEXHAS_XYZW		     (2<<6)
65903b705cfSriastradh#define    S3_VERTEXHAS_XY		     (3<<6)
66003b705cfSriastradh#define    S3_VERTEXHAS_XYW		     (4<<6)
66103b705cfSriastradh#define S3_ENABLE_SPEC_ADD		     (1<<5)
66203b705cfSriastradh#define S3_ENABLE_FOG			     (1<<4)
66303b705cfSriastradh#define S3_ENABLE_LOCAL_DEPTH_BIAS	     (1<<3)
66403b705cfSriastradh#define S3_ENABLE_SPRITE_POINT		     (1<<1)
66503b705cfSriastradh#define S3_ENABLE_ANTIALIASING		     1
66603b705cfSriastradh#define S8_ENABLE_ALPHA_TEST		     (1<<31)
66703b705cfSriastradh#define S8_ALPHA_TEST_FUNC_SHIFT	     28
66803b705cfSriastradh#define S8_ALPHA_REFVALUE_SHIFT		     20
66903b705cfSriastradh#define S8_ENABLE_DEPTH_TEST		     (1<<19)
67003b705cfSriastradh#define S8_DEPTH_TEST_FUNC_SHIFT	     16
67103b705cfSriastradh#define S8_ENABLE_COLOR_BLEND		     (1<<15)
67203b705cfSriastradh#define S8_COLOR_BLEND_FUNC_SHIFT	     12
67303b705cfSriastradh#define    S8_BLENDFUNC_ADD		     (0)
67403b705cfSriastradh#define    S8_BLENDFUNC_SUB		     (1<<12)
67503b705cfSriastradh#define    S8_BLENDFUNC_RVRSE_SUB	     (2<<12)
67603b705cfSriastradh#define    S8_BLENDFUNC_MIN		     (3<<12)
67703b705cfSriastradh#define    S8_BLENDFUNC_MAX			     (4<<12)
67803b705cfSriastradh#define S8_SRC_BLEND_FACTOR_SHIFT	     8
67903b705cfSriastradh#define S8_DST_BLEND_FACTOR_SHIFT	     4
68003b705cfSriastradh#define S8_ENABLE_DEPTH_BUFFER_WRITE	     (1<<3)
68103b705cfSriastradh#define S8_ENABLE_COLOR_BUFFER_WRITE	     (1<<2)
68203b705cfSriastradh
68303b705cfSriastradh#define _3DSTATE_LOAD_STATE_IMMEDIATE_2      (CMD_3D|(0x1d<<24)|(0x03<<16))
68403b705cfSriastradh#define LOAD_TEXTURE_MAP(x)                   (1<<((x)+11))
68503b705cfSriastradh#define LOAD_TEXTURE_BLEND_STAGE(x)	      (1<<((x)+7))
68603b705cfSriastradh#define LOAD_GLOBAL_COLOR_FACTOR            (1<<6)
68703b705cfSriastradh
68803b705cfSriastradh#define TM0S0_ADDRESS_MASK              0xfffffffc
68903b705cfSriastradh#define TM0S0_USE_FENCE                 (1<<1)
69003b705cfSriastradh
69103b705cfSriastradh#define TM0S1_HEIGHT_SHIFT              21
69203b705cfSriastradh#define TM0S1_WIDTH_SHIFT               10
69303b705cfSriastradh#define TM0S1_PALETTE_SELECT            (1<<9)
69403b705cfSriastradh#define TM0S1_MAPSURF_FORMAT_MASK       (0x7 << 6)
69503b705cfSriastradh#define TM0S1_MAPSURF_FORMAT_SHIFT      6
69603b705cfSriastradh#define    MAPSURF_8BIT_INDEXED		   (0<<6)
69703b705cfSriastradh#define    MAPSURF_8BIT		 	   (1<<6)
69803b705cfSriastradh#define    MAPSURF_16BIT		   (2<<6)
69903b705cfSriastradh#define    MAPSURF_32BIT		   (3<<6)
70003b705cfSriastradh#define    MAPSURF_411			   (4<<6)
70103b705cfSriastradh#define    MAPSURF_422			   (5<<6)
70203b705cfSriastradh#define    MAPSURF_COMPRESSED		   (6<<6)
70303b705cfSriastradh#define    MAPSURF_4BIT_INDEXED		   (7<<6)
70403b705cfSriastradh#define TM0S1_MT_FORMAT_MASK         (0x7 << 3)
70503b705cfSriastradh#define TM0S1_MT_FORMAT_SHIFT        3
70603b705cfSriastradh#define    MT_4BIT_IDX_ARGB8888	           (7<<3)	/* SURFACE_4BIT_INDEXED */
70703b705cfSriastradh#define    MT_8BIT_IDX_RGB565	           (0<<3)	/* SURFACE_8BIT_INDEXED */
70803b705cfSriastradh#define    MT_8BIT_IDX_ARGB1555	           (1<<3)
70903b705cfSriastradh#define    MT_8BIT_IDX_ARGB4444	           (2<<3)
71003b705cfSriastradh#define    MT_8BIT_IDX_AY88		   (3<<3)
71103b705cfSriastradh#define    MT_8BIT_IDX_ABGR8888	           (4<<3)
71203b705cfSriastradh#define    MT_8BIT_IDX_BUMP_88DVDU 	   (5<<3)
71303b705cfSriastradh#define    MT_8BIT_IDX_BUMP_655LDVDU	   (6<<3)
71403b705cfSriastradh#define    MT_8BIT_IDX_ARGB8888	           (7<<3)
71503b705cfSriastradh#define    MT_8BIT_I8		           (0<<3)	/* SURFACE_8BIT */
71603b705cfSriastradh#define    MT_8BIT_L8		           (1<<3)
71703b705cfSriastradh#define    MT_8BIT_A8		           (4<<3)
71803b705cfSriastradh#define    MT_16BIT_RGB565 		   (0<<3)	/* SURFACE_16BIT */
71903b705cfSriastradh#define    MT_16BIT_ARGB1555		   (1<<3)
72003b705cfSriastradh#define    MT_16BIT_ARGB4444		   (2<<3)
72103b705cfSriastradh#define    MT_16BIT_AY88		   (3<<3)
72203b705cfSriastradh#define    MT_16BIT_DIB_ARGB1555_8888      (4<<3)
72303b705cfSriastradh#define    MT_16BIT_BUMP_88DVDU	           (5<<3)
72403b705cfSriastradh#define    MT_16BIT_BUMP_655LDVDU	   (6<<3)
72503b705cfSriastradh#define    MT_16BIT_DIB_RGB565_8888	   (7<<3)
72603b705cfSriastradh#define    MT_32BIT_ARGB8888		   (0<<3)	/* SURFACE_32BIT */
72703b705cfSriastradh#define    MT_32BIT_ABGR8888		   (1<<3)
72803b705cfSriastradh#define    MT_32BIT_XRGB8888		   (2<<3)
72903b705cfSriastradh#define    MT_32BIT_XBGR8888		   (3<<3)
73003b705cfSriastradh#define    MT_32BIT_BUMP_XLDVDU_8888	   (6<<3)
73103b705cfSriastradh#define    MT_32BIT_DIB_8888		   (7<<3)
73203b705cfSriastradh#define    MT_411_YUV411		   (0<<3)	/* SURFACE_411 */
73303b705cfSriastradh#define    MT_422_YCRCB_SWAPY	           (0<<3)	/* SURFACE_422 */
73403b705cfSriastradh#define    MT_422_YCRCB_NORMAL	           (1<<3)
73503b705cfSriastradh#define    MT_422_YCRCB_SWAPUV	           (2<<3)
73603b705cfSriastradh#define    MT_422_YCRCB_SWAPUVY	           (3<<3)
73703b705cfSriastradh#define    MT_COMPRESS_DXT1		   (0<<3)	/* SURFACE_COMPRESSED */
73803b705cfSriastradh#define    MT_COMPRESS_DXT2_3	           (1<<3)
73903b705cfSriastradh#define    MT_COMPRESS_DXT4_5	           (2<<3)
74003b705cfSriastradh#define    MT_COMPRESS_FXT1		   (3<<3)
74103b705cfSriastradh#define TM0S1_COLORSPACE_CONVERSION     (1 << 2)
74203b705cfSriastradh#define TM0S1_TILED_SURFACE             (1 << 1)
74303b705cfSriastradh#define TM0S1_TILE_WALK                 (1 << 0)
74403b705cfSriastradh
74503b705cfSriastradh#define TM0S2_PITCH_SHIFT               21
74603b705cfSriastradh#define TM0S2_CUBE_FACE_ENA_SHIFT       15
74703b705cfSriastradh#define TM0S2_CUBE_FACE_ENA_MASK        (1<<15)
74803b705cfSriastradh#define TM0S2_MAP_FORMAT                (1<<14)
74903b705cfSriastradh#define    TM0S2_MAP_2D			(0<<14)
75003b705cfSriastradh#define    TM0S2_MAP_3D_CUBE		(1<<14)
75103b705cfSriastradh#define TM0S2_VERTICAL_LINE_STRIDE      (1<<13)
75203b705cfSriastradh#define TM0S2_VERITCAL_LINE_STRIDE_OFF  (1<<12)
75303b705cfSriastradh#define TM0S2_OUTPUT_CHAN_SHIFT         10
75403b705cfSriastradh#define TM0S2_OUTPUT_CHAN_MASK          (3<<10)
75503b705cfSriastradh
75603b705cfSriastradh#define TM0S3_MIP_FILTER_MASK           (0x3<<30)
75703b705cfSriastradh#define TM0S3_MIP_FILTER_SHIFT          30
75803b705cfSriastradh#define MIPFILTER_NONE		0
75903b705cfSriastradh#define MIPFILTER_NEAREST	1
76003b705cfSriastradh#define MIPFILTER_LINEAR	3
76103b705cfSriastradh#define TM0S3_MAG_FILTER_MASK           (0x3<<28)
76203b705cfSriastradh#define TM0S3_MAG_FILTER_SHIFT          28
76303b705cfSriastradh#define TM0S3_MIN_FILTER_MASK           (0x3<<26)
76403b705cfSriastradh#define TM0S3_MIN_FILTER_SHIFT          26
76503b705cfSriastradh#define FILTER_NEAREST		0
76603b705cfSriastradh#define FILTER_LINEAR		1
76703b705cfSriastradh#define FILTER_ANISOTROPIC	2
76803b705cfSriastradh
76903b705cfSriastradh#define TM0S3_LOD_BIAS_SHIFT		17
77003b705cfSriastradh#define TM0S3_LOD_BIAS_MASK		(0x1ff<<17)
77103b705cfSriastradh#define TM0S3_MAX_MIP_SHIFT		9
77203b705cfSriastradh#define TM0S3_MAX_MIP_MASK		(0xff<<9)
77303b705cfSriastradh#define TM0S3_MIN_MIP_SHIFT		3
77403b705cfSriastradh#define TM0S3_MIN_MIP_MASK		(0x3f<<3)
77503b705cfSriastradh#define TM0S3_KILL_PIXEL		(1<<2)
77603b705cfSriastradh#define TM0S3_KEYED_FILTER		(1<<1)
77703b705cfSriastradh#define TM0S3_CHROMA_KEY		(1<<0)
77803b705cfSriastradh
77903b705cfSriastradh/* _3DSTATE_MAP_TEXEL_STREAM, p188 */
78003b705cfSriastradh#define _3DSTATE_MAP_TEX_STREAM_CMD	(CMD_3D|(0x1c<<24)|(0x05<<19))
78103b705cfSriastradh#define DISABLE_TEX_STREAM_BUMP 	(1<<12)
78203b705cfSriastradh#define ENABLE_TEX_STREAM_BUMP		((1<<12)|(1<<11))
78303b705cfSriastradh#define TEX_MODIFY_UNIT_0		0
78403b705cfSriastradh#define TEX_MODIFY_UNIT_1		(1<<8)
78503b705cfSriastradh#define ENABLE_TEX_STREAM_COORD_SET	(1<<7)
78603b705cfSriastradh#define TEX_STREAM_COORD_SET(x) 	((x)<<4)
78703b705cfSriastradh#define ENABLE_TEX_STREAM_MAP_IDX	(1<<3)
78803b705cfSriastradh#define TEX_STREAM_MAP_IDX(x)		(x)
78903b705cfSriastradh
79003b705cfSriastradh#define FLUSH_MAP_CACHE    (1<<0)
79103b705cfSriastradh
79203b705cfSriastradh#define _3DSTATE_MAP_FILTER_CMD    (CMD_3D|(0x1c<<24)|(0x02<<19))
79303b705cfSriastradh#define FILTER_TEXMAP_INDEX(x) ((x) << 16)
79403b705cfSriastradh#define MAG_MODE_FILTER_ENABLE (1 << 5)
79503b705cfSriastradh#define MIN_MODE_FILTER_ENABLE (1 << 2)
79603b705cfSriastradh#define MAG_MAPFILTER_NEAREST (0 << 3)
79703b705cfSriastradh#define MAG_MAPFILTER_LINEAR  (1 << 3)
79803b705cfSriastradh#define MAG_MAPFILTER_ANISOTROPIC (2 << 3)
79903b705cfSriastradh#define MIN_MAPFILTER_NEAREST (0)
80003b705cfSriastradh#define MIN_MAPFILTER_LINEAR  (1)
80103b705cfSriastradh#define MIN_MAPFILTER_ANISOTROPIC (2)
80203b705cfSriastradh#define ENABLE_KEYS	(1<<15)
80303b705cfSriastradh#define DISABLE_COLOR_KEY	0
80403b705cfSriastradh#define DISABLE_CHROMA_KEY	0
80503b705cfSriastradh#define DISABLE_KILL_PIXEL	0
80603b705cfSriastradh#define ENABLE_MIP_MODE_FILTER	(1 << 9)
80703b705cfSriastradh#define MIPFILTER_NONE		0
80803b705cfSriastradh#define MIPFILTER_NEAREST	1
80903b705cfSriastradh#define MIPFILTER_LINEAR	3
81003b705cfSriastradh
81103b705cfSriastradh#endif
812