1fa225cbcSrjs/* i810_common.h -- common header definitions for I810 2D/3D/DRM suite
2fa225cbcSrjs *
3fa225cbcSrjs * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
4fa225cbcSrjs * All Rights Reserved.
5fa225cbcSrjs *
6fa225cbcSrjs * Permission is hereby granted, free of charge, to any person obtaining a
7fa225cbcSrjs * copy of this software and associated documentation files (the "Software"),
8fa225cbcSrjs * to deal in the Software without restriction, including without limitation
9fa225cbcSrjs * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10fa225cbcSrjs * and/or sell copies of the Software, and to permit persons to whom the
11fa225cbcSrjs * Software is furnished to do so, subject to the following conditions:
12fa225cbcSrjs *
13fa225cbcSrjs * The above copyright notice and this permission notice (including the next
14fa225cbcSrjs * paragraph) shall be included in all copies or substantial portions of the
15fa225cbcSrjs * Software.
16fa225cbcSrjs *
17fa225cbcSrjs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18fa225cbcSrjs * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19fa225cbcSrjs * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20fa225cbcSrjs * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21fa225cbcSrjs * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22fa225cbcSrjs * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23fa225cbcSrjs * DEALINGS IN THE SOFTWARE.
24fa225cbcSrjs *
25fa225cbcSrjs * Converted to common header format:
26fa225cbcSrjs *   Jens Owen <jens@tungstengraphics.com>
27fa225cbcSrjs *
28fa225cbcSrjs *
29fa225cbcSrjs */
30fa225cbcSrjs
31fa225cbcSrjs/* WARNING: If you change any of these defines, make sure to change
32fa225cbcSrjs * the kernel include file as well (i810_drm.h)
33fa225cbcSrjs */
34fa225cbcSrjs
35fa225cbcSrjs#ifndef _I810_COMMON_H_
36fa225cbcSrjs#define _I810_COMMON_H_
37fa225cbcSrjs
38fa225cbcSrjs#ifndef _I810_DEFINES_
39fa225cbcSrjs#define _I810_DEFINES_
40fa225cbcSrjs#define I810_USE_BATCH 1
41fa225cbcSrjs
42fa225cbcSrjs#define I810_DMA_BUF_ORDER     12
43fa225cbcSrjs#define I810_DMA_BUF_SZ        (1<<I810_DMA_BUF_ORDER)
44fa225cbcSrjs#define I810_DMA_BUF_NR        256
45fa225cbcSrjs
46fa225cbcSrjs#define I810_NR_SAREA_CLIPRECTS 8
47fa225cbcSrjs
48fa225cbcSrjs/* Each region is a minimum of 64k, and there are at most 64 of them.
49fa225cbcSrjs */
50fa225cbcSrjs#define I810_NR_TEX_REGIONS 64
51fa225cbcSrjs#define I810_LOG_MIN_TEX_REGION_SIZE 16
52fa225cbcSrjs
53fa225cbcSrjs/* Destbuffer state
54fa225cbcSrjs *    - backbuffer linear offset and pitch -- invarient in the current dri
55fa225cbcSrjs *    - zbuffer linear offset and pitch -- also invarient
56fa225cbcSrjs *    - drawing origin in back and depth buffers.
57fa225cbcSrjs *
58fa225cbcSrjs * Keep the depth/back buffer state here to acommodate private buffers
59fa225cbcSrjs * in the future.
60fa225cbcSrjs */
61fa225cbcSrjs#define I810_DESTREG_DI0  0		/* CMD_OP_DESTBUFFER_INFO (2 dwords) */
62fa225cbcSrjs#define I810_DESTREG_DI1  1
63fa225cbcSrjs#define I810_DESTREG_DV0  2		/* GFX_OP_DESTBUFFER_VARS (2 dwords) */
64fa225cbcSrjs#define I810_DESTREG_DV1  3
65fa225cbcSrjs#define I810_DESTREG_DR0  4		/* GFX_OP_DRAWRECT_INFO (4 dwords) */
66fa225cbcSrjs#define I810_DESTREG_DR1  5
67fa225cbcSrjs#define I810_DESTREG_DR2  6
68fa225cbcSrjs#define I810_DESTREG_DR3  7
69fa225cbcSrjs#define I810_DESTREG_DR4  8
70fa225cbcSrjs#define I810_DEST_SETUP_SIZE 10
71fa225cbcSrjs
72fa225cbcSrjs/* Context state
73fa225cbcSrjs */
74fa225cbcSrjs#define I810_CTXREG_CF0   0		/* GFX_OP_COLOR_FACTOR */
75fa225cbcSrjs#define I810_CTXREG_CF1   1
76fa225cbcSrjs#define I810_CTXREG_ST0   2		/* GFX_OP_STIPPLE */
77fa225cbcSrjs#define I810_CTXREG_ST1   3
78fa225cbcSrjs#define I810_CTXREG_VF    4		/* GFX_OP_VERTEX_FMT */
79fa225cbcSrjs#define I810_CTXREG_MT    5		/* GFX_OP_MAP_TEXELS */
80fa225cbcSrjs#define I810_CTXREG_MC0   6		/* GFX_OP_MAP_COLOR_STAGES - stage 0 */
81fa225cbcSrjs#define I810_CTXREG_MC1   7		/* GFX_OP_MAP_COLOR_STAGES - stage 1 */
82fa225cbcSrjs#define I810_CTXREG_MC2   8		/* GFX_OP_MAP_COLOR_STAGES - stage 2 */
83fa225cbcSrjs#define I810_CTXREG_MA0   9		/* GFX_OP_MAP_ALPHA_STAGES - stage 0 */
84fa225cbcSrjs#define I810_CTXREG_MA1   10		/* GFX_OP_MAP_ALPHA_STAGES - stage 1 */
85fa225cbcSrjs#define I810_CTXREG_MA2   11		/* GFX_OP_MAP_ALPHA_STAGES - stage 2 */
86fa225cbcSrjs#define I810_CTXREG_SDM   12		/* GFX_OP_SRC_DEST_MONO */
87fa225cbcSrjs#define I810_CTXREG_FOG   13		/* GFX_OP_FOG_COLOR */
88fa225cbcSrjs#define I810_CTXREG_B1    14		/* GFX_OP_BOOL_1 */
89fa225cbcSrjs#define I810_CTXREG_B2    15		/* GFX_OP_BOOL_2 */
90fa225cbcSrjs#define I810_CTXREG_LCS   16		/* GFX_OP_LINEWIDTH_CULL_SHADE_MODE */
91fa225cbcSrjs#define I810_CTXREG_PV    17		/* GFX_OP_PV_RULE -- Invarient! */
92fa225cbcSrjs#define I810_CTXREG_ZA    18		/* GFX_OP_ZBIAS_ALPHAFUNC */
93fa225cbcSrjs#define I810_CTXREG_AA    19		/* GFX_OP_ANTIALIAS */
94fa225cbcSrjs#define I810_CTX_SETUP_SIZE 20
95fa225cbcSrjs
96fa225cbcSrjs/* Texture state (per tex unit)
97fa225cbcSrjs */
98fa225cbcSrjs#define I810_TEXREG_MI0  0		/* GFX_OP_MAP_INFO (4 dwords) */
99fa225cbcSrjs#define I810_TEXREG_MI1  1
100fa225cbcSrjs#define I810_TEXREG_MI2  2
101fa225cbcSrjs#define I810_TEXREG_MI3  3
102fa225cbcSrjs#define I810_TEXREG_MF   4		/* GFX_OP_MAP_FILTER */
103fa225cbcSrjs#define I810_TEXREG_MLC  5		/* GFX_OP_MAP_LOD_CTL */
104fa225cbcSrjs#define I810_TEXREG_MLL  6		/* GFX_OP_MAP_LOD_LIMITS */
105fa225cbcSrjs#define I810_TEXREG_MCS  7		/* GFX_OP_MAP_COORD_SETS ??? */
106fa225cbcSrjs#define I810_TEX_SETUP_SIZE 8
107fa225cbcSrjs
108fa225cbcSrjs/* Driver specific DRM command indices
109fa225cbcSrjs * NOTE: these are not OS specific, but they are driver specific
110fa225cbcSrjs */
111fa225cbcSrjs#define DRM_I810_INIT                     0x00
112fa225cbcSrjs#define DRM_I810_VERTEX                   0x01
113fa225cbcSrjs#define DRM_I810_CLEAR                    0x02
114fa225cbcSrjs#define DRM_I810_FLUSH                    0x03
115fa225cbcSrjs#define DRM_I810_GETAGE                   0x04
116fa225cbcSrjs#define DRM_I810_GETBUF                   0x05
117fa225cbcSrjs#define DRM_I810_SWAP                     0x06
118fa225cbcSrjs#define DRM_I810_COPY                     0x07
119fa225cbcSrjs#define DRM_I810_DOCOPY                   0x08
120fa225cbcSrjs#define DRM_I810_OV0INFO                  0x09
121fa225cbcSrjs#define DRM_I810_FSTATUS                  0x0a
122fa225cbcSrjs#define DRM_I810_OV0FLIP                  0x0b
123fa225cbcSrjs#define DRM_I810_MC                       0x0c
124fa225cbcSrjs#define DRM_I810_RSTATUS                  0x0d
125fa225cbcSrjs#define DRM_I810_FLIP                     0x0e
126fa225cbcSrjs
127fa225cbcSrjs#endif
128fa225cbcSrjs
129fa225cbcSrjstypedef enum _drmI810Initfunc {
130fa225cbcSrjs	I810_INIT_DMA = 0x01,
131fa225cbcSrjs	I810_CLEANUP_DMA = 0x02,
132fa225cbcSrjs	I810_INIT_DMA_1_4 = 0x03
133fa225cbcSrjs} drmI810Initfunc;
134fa225cbcSrjs
135fa225cbcSrjstypedef struct {
136fa225cbcSrjs   drmI810Initfunc func;
137fa225cbcSrjs   unsigned int mmio_offset;
138fa225cbcSrjs   unsigned int buffers_offset;
139fa225cbcSrjs   int sarea_priv_offset;
140fa225cbcSrjs   unsigned int ring_start;
141fa225cbcSrjs   unsigned int ring_end;
142fa225cbcSrjs   unsigned int ring_size;
143fa225cbcSrjs   unsigned int front_offset;
144fa225cbcSrjs   unsigned int back_offset;
145fa225cbcSrjs   unsigned int depth_offset;
146fa225cbcSrjs   unsigned int overlay_offset;
147fa225cbcSrjs   unsigned int overlay_physical;
148fa225cbcSrjs   unsigned int w;
149fa225cbcSrjs   unsigned int h;
150fa225cbcSrjs   unsigned int pitch;
151fa225cbcSrjs   unsigned int pitch_bits;
152fa225cbcSrjs} drmI810Init;
153fa225cbcSrjs
154fa225cbcSrjstypedef struct {
155fa225cbcSrjs   void *virtual;
156fa225cbcSrjs   int request_idx;
157fa225cbcSrjs   int request_size;
158fa225cbcSrjs   int granted;
159fa225cbcSrjs} drmI810DMA;
160fa225cbcSrjs
161fa225cbcSrjs/* Flags for clear ioctl
162fa225cbcSrjs */
163fa225cbcSrjs#define I810_FRONT   0x1
164fa225cbcSrjs#define I810_BACK    0x2
165fa225cbcSrjs#define I810_DEPTH   0x4
166fa225cbcSrjs
167fa225cbcSrjstypedef struct {
168fa225cbcSrjs   int clear_color;
169fa225cbcSrjs   int clear_depth;
170fa225cbcSrjs   int flags;
171fa225cbcSrjs} drmI810Clear;
172fa225cbcSrjs
173fa225cbcSrjstypedef struct {
174fa225cbcSrjs   int idx;				/* buffer index */
175fa225cbcSrjs   int used;				/* nr bytes in use */
176fa225cbcSrjs   int discard;				/* client is finished with the buffer? */
177fa225cbcSrjs} drmI810Vertex;
178fa225cbcSrjs
179fa225cbcSrjs/* Flags for vertex ioctl
180fa225cbcSrjs */
181fa225cbcSrjs#define PR_TRIANGLES         (0x0<<18)
182fa225cbcSrjs#define PR_TRISTRIP_0        (0x1<<18)
183fa225cbcSrjs#define PR_TRISTRIP_1        (0x2<<18)
184fa225cbcSrjs#define PR_TRIFAN            (0x3<<18)
185fa225cbcSrjs#define PR_POLYGON           (0x4<<18)
186fa225cbcSrjs#define PR_LINES             (0x5<<18)
187fa225cbcSrjs#define PR_LINESTRIP         (0x6<<18)
188fa225cbcSrjs#define PR_RECTS             (0x7<<18)
189fa225cbcSrjs#define PR_MASK              (0x7<<18)
190fa225cbcSrjs
191fa225cbcSrjs#endif
192