xref: /OK3568_Linux_fs/kernel/include/uapi/drm/i810_drm.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2*4882a593Smuzhiyun #ifndef _I810_DRM_H_
3*4882a593Smuzhiyun #define _I810_DRM_H_
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include "drm.h"
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #if defined(__cplusplus)
8*4882a593Smuzhiyun extern "C" {
9*4882a593Smuzhiyun #endif
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun /* WARNING: These defines must be the same as what the Xserver uses.
12*4882a593Smuzhiyun  * if you change them, you must change the defines in the Xserver.
13*4882a593Smuzhiyun  */
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #ifndef _I810_DEFINES_
16*4882a593Smuzhiyun #define _I810_DEFINES_
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun #define I810_DMA_BUF_ORDER		12
19*4882a593Smuzhiyun #define I810_DMA_BUF_SZ 		(1<<I810_DMA_BUF_ORDER)
20*4882a593Smuzhiyun #define I810_DMA_BUF_NR 		256
21*4882a593Smuzhiyun #define I810_NR_SAREA_CLIPRECTS 	8
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun /* Each region is a minimum of 64k, and there are at most 64 of them.
24*4882a593Smuzhiyun  */
25*4882a593Smuzhiyun #define I810_NR_TEX_REGIONS 64
26*4882a593Smuzhiyun #define I810_LOG_MIN_TEX_REGION_SIZE 16
27*4882a593Smuzhiyun #endif
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun #define I810_UPLOAD_TEX0IMAGE  0x1	/* handled clientside */
30*4882a593Smuzhiyun #define I810_UPLOAD_TEX1IMAGE  0x2	/* handled clientside */
31*4882a593Smuzhiyun #define I810_UPLOAD_CTX        0x4
32*4882a593Smuzhiyun #define I810_UPLOAD_BUFFERS    0x8
33*4882a593Smuzhiyun #define I810_UPLOAD_TEX0       0x10
34*4882a593Smuzhiyun #define I810_UPLOAD_TEX1       0x20
35*4882a593Smuzhiyun #define I810_UPLOAD_CLIPRECTS  0x40
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun /* Indices into buf.Setup where various bits of state are mirrored per
38*4882a593Smuzhiyun  * context and per buffer.  These can be fired at the card as a unit,
39*4882a593Smuzhiyun  * or in a piecewise fashion as required.
40*4882a593Smuzhiyun  */
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun /* Destbuffer state
43*4882a593Smuzhiyun  *    - backbuffer linear offset and pitch -- invarient in the current dri
44*4882a593Smuzhiyun  *    - zbuffer linear offset and pitch -- also invarient
45*4882a593Smuzhiyun  *    - drawing origin in back and depth buffers.
46*4882a593Smuzhiyun  *
47*4882a593Smuzhiyun  * Keep the depth/back buffer state here to accommodate private buffers
48*4882a593Smuzhiyun  * in the future.
49*4882a593Smuzhiyun  */
50*4882a593Smuzhiyun #define I810_DESTREG_DI0  0	/* CMD_OP_DESTBUFFER_INFO (2 dwords) */
51*4882a593Smuzhiyun #define I810_DESTREG_DI1  1
52*4882a593Smuzhiyun #define I810_DESTREG_DV0  2	/* GFX_OP_DESTBUFFER_VARS (2 dwords) */
53*4882a593Smuzhiyun #define I810_DESTREG_DV1  3
54*4882a593Smuzhiyun #define I810_DESTREG_DR0  4	/* GFX_OP_DRAWRECT_INFO (4 dwords) */
55*4882a593Smuzhiyun #define I810_DESTREG_DR1  5
56*4882a593Smuzhiyun #define I810_DESTREG_DR2  6
57*4882a593Smuzhiyun #define I810_DESTREG_DR3  7
58*4882a593Smuzhiyun #define I810_DESTREG_DR4  8
59*4882a593Smuzhiyun #define I810_DEST_SETUP_SIZE 10
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun /* Context state
62*4882a593Smuzhiyun  */
63*4882a593Smuzhiyun #define I810_CTXREG_CF0   0	/* GFX_OP_COLOR_FACTOR */
64*4882a593Smuzhiyun #define I810_CTXREG_CF1   1
65*4882a593Smuzhiyun #define I810_CTXREG_ST0   2	/* GFX_OP_STIPPLE */
66*4882a593Smuzhiyun #define I810_CTXREG_ST1   3
67*4882a593Smuzhiyun #define I810_CTXREG_VF    4	/* GFX_OP_VERTEX_FMT */
68*4882a593Smuzhiyun #define I810_CTXREG_MT    5	/* GFX_OP_MAP_TEXELS */
69*4882a593Smuzhiyun #define I810_CTXREG_MC0   6	/* GFX_OP_MAP_COLOR_STAGES - stage 0 */
70*4882a593Smuzhiyun #define I810_CTXREG_MC1   7	/* GFX_OP_MAP_COLOR_STAGES - stage 1 */
71*4882a593Smuzhiyun #define I810_CTXREG_MC2   8	/* GFX_OP_MAP_COLOR_STAGES - stage 2 */
72*4882a593Smuzhiyun #define I810_CTXREG_MA0   9	/* GFX_OP_MAP_ALPHA_STAGES - stage 0 */
73*4882a593Smuzhiyun #define I810_CTXREG_MA1   10	/* GFX_OP_MAP_ALPHA_STAGES - stage 1 */
74*4882a593Smuzhiyun #define I810_CTXREG_MA2   11	/* GFX_OP_MAP_ALPHA_STAGES - stage 2 */
75*4882a593Smuzhiyun #define I810_CTXREG_SDM   12	/* GFX_OP_SRC_DEST_MONO */
76*4882a593Smuzhiyun #define I810_CTXREG_FOG   13	/* GFX_OP_FOG_COLOR */
77*4882a593Smuzhiyun #define I810_CTXREG_B1    14	/* GFX_OP_BOOL_1 */
78*4882a593Smuzhiyun #define I810_CTXREG_B2    15	/* GFX_OP_BOOL_2 */
79*4882a593Smuzhiyun #define I810_CTXREG_LCS   16	/* GFX_OP_LINEWIDTH_CULL_SHADE_MODE */
80*4882a593Smuzhiyun #define I810_CTXREG_PV    17	/* GFX_OP_PV_RULE -- Invarient! */
81*4882a593Smuzhiyun #define I810_CTXREG_ZA    18	/* GFX_OP_ZBIAS_ALPHAFUNC */
82*4882a593Smuzhiyun #define I810_CTXREG_AA    19	/* GFX_OP_ANTIALIAS */
83*4882a593Smuzhiyun #define I810_CTX_SETUP_SIZE 20
84*4882a593Smuzhiyun 
85*4882a593Smuzhiyun /* Texture state (per tex unit)
86*4882a593Smuzhiyun  */
87*4882a593Smuzhiyun #define I810_TEXREG_MI0  0	/* GFX_OP_MAP_INFO (4 dwords) */
88*4882a593Smuzhiyun #define I810_TEXREG_MI1  1
89*4882a593Smuzhiyun #define I810_TEXREG_MI2  2
90*4882a593Smuzhiyun #define I810_TEXREG_MI3  3
91*4882a593Smuzhiyun #define I810_TEXREG_MF   4	/* GFX_OP_MAP_FILTER */
92*4882a593Smuzhiyun #define I810_TEXREG_MLC  5	/* GFX_OP_MAP_LOD_CTL */
93*4882a593Smuzhiyun #define I810_TEXREG_MLL  6	/* GFX_OP_MAP_LOD_LIMITS */
94*4882a593Smuzhiyun #define I810_TEXREG_MCS  7	/* GFX_OP_MAP_COORD_SETS ??? */
95*4882a593Smuzhiyun #define I810_TEX_SETUP_SIZE 8
96*4882a593Smuzhiyun 
97*4882a593Smuzhiyun /* Flags for clear ioctl
98*4882a593Smuzhiyun  */
99*4882a593Smuzhiyun #define I810_FRONT   0x1
100*4882a593Smuzhiyun #define I810_BACK    0x2
101*4882a593Smuzhiyun #define I810_DEPTH   0x4
102*4882a593Smuzhiyun 
103*4882a593Smuzhiyun typedef enum _drm_i810_init_func {
104*4882a593Smuzhiyun 	I810_INIT_DMA = 0x01,
105*4882a593Smuzhiyun 	I810_CLEANUP_DMA = 0x02,
106*4882a593Smuzhiyun 	I810_INIT_DMA_1_4 = 0x03
107*4882a593Smuzhiyun } drm_i810_init_func_t;
108*4882a593Smuzhiyun 
109*4882a593Smuzhiyun /* This is the init structure after v1.2 */
110*4882a593Smuzhiyun typedef struct _drm_i810_init {
111*4882a593Smuzhiyun 	drm_i810_init_func_t func;
112*4882a593Smuzhiyun 	unsigned int mmio_offset;
113*4882a593Smuzhiyun 	unsigned int buffers_offset;
114*4882a593Smuzhiyun 	int sarea_priv_offset;
115*4882a593Smuzhiyun 	unsigned int ring_start;
116*4882a593Smuzhiyun 	unsigned int ring_end;
117*4882a593Smuzhiyun 	unsigned int ring_size;
118*4882a593Smuzhiyun 	unsigned int front_offset;
119*4882a593Smuzhiyun 	unsigned int back_offset;
120*4882a593Smuzhiyun 	unsigned int depth_offset;
121*4882a593Smuzhiyun 	unsigned int overlay_offset;
122*4882a593Smuzhiyun 	unsigned int overlay_physical;
123*4882a593Smuzhiyun 	unsigned int w;
124*4882a593Smuzhiyun 	unsigned int h;
125*4882a593Smuzhiyun 	unsigned int pitch;
126*4882a593Smuzhiyun 	unsigned int pitch_bits;
127*4882a593Smuzhiyun } drm_i810_init_t;
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun /* This is the init structure prior to v1.2 */
130*4882a593Smuzhiyun typedef struct _drm_i810_pre12_init {
131*4882a593Smuzhiyun 	drm_i810_init_func_t func;
132*4882a593Smuzhiyun 	unsigned int mmio_offset;
133*4882a593Smuzhiyun 	unsigned int buffers_offset;
134*4882a593Smuzhiyun 	int sarea_priv_offset;
135*4882a593Smuzhiyun 	unsigned int ring_start;
136*4882a593Smuzhiyun 	unsigned int ring_end;
137*4882a593Smuzhiyun 	unsigned int ring_size;
138*4882a593Smuzhiyun 	unsigned int front_offset;
139*4882a593Smuzhiyun 	unsigned int back_offset;
140*4882a593Smuzhiyun 	unsigned int depth_offset;
141*4882a593Smuzhiyun 	unsigned int w;
142*4882a593Smuzhiyun 	unsigned int h;
143*4882a593Smuzhiyun 	unsigned int pitch;
144*4882a593Smuzhiyun 	unsigned int pitch_bits;
145*4882a593Smuzhiyun } drm_i810_pre12_init_t;
146*4882a593Smuzhiyun 
147*4882a593Smuzhiyun /* Warning: If you change the SAREA structure you must change the Xserver
148*4882a593Smuzhiyun  * structure as well */
149*4882a593Smuzhiyun 
150*4882a593Smuzhiyun typedef struct _drm_i810_tex_region {
151*4882a593Smuzhiyun 	unsigned char next, prev;	/* indices to form a circular LRU  */
152*4882a593Smuzhiyun 	unsigned char in_use;	/* owned by a client, or free? */
153*4882a593Smuzhiyun 	int age;		/* tracked by clients to update local LRU's */
154*4882a593Smuzhiyun } drm_i810_tex_region_t;
155*4882a593Smuzhiyun 
156*4882a593Smuzhiyun typedef struct _drm_i810_sarea {
157*4882a593Smuzhiyun 	unsigned int ContextState[I810_CTX_SETUP_SIZE];
158*4882a593Smuzhiyun 	unsigned int BufferState[I810_DEST_SETUP_SIZE];
159*4882a593Smuzhiyun 	unsigned int TexState[2][I810_TEX_SETUP_SIZE];
160*4882a593Smuzhiyun 	unsigned int dirty;
161*4882a593Smuzhiyun 
162*4882a593Smuzhiyun 	unsigned int nbox;
163*4882a593Smuzhiyun 	struct drm_clip_rect boxes[I810_NR_SAREA_CLIPRECTS];
164*4882a593Smuzhiyun 
165*4882a593Smuzhiyun 	/* Maintain an LRU of contiguous regions of texture space.  If
166*4882a593Smuzhiyun 	 * you think you own a region of texture memory, and it has an
167*4882a593Smuzhiyun 	 * age different to the one you set, then you are mistaken and
168*4882a593Smuzhiyun 	 * it has been stolen by another client.  If global texAge
169*4882a593Smuzhiyun 	 * hasn't changed, there is no need to walk the list.
170*4882a593Smuzhiyun 	 *
171*4882a593Smuzhiyun 	 * These regions can be used as a proxy for the fine-grained
172*4882a593Smuzhiyun 	 * texture information of other clients - by maintaining them
173*4882a593Smuzhiyun 	 * in the same lru which is used to age their own textures,
174*4882a593Smuzhiyun 	 * clients have an approximate lru for the whole of global
175*4882a593Smuzhiyun 	 * texture space, and can make informed decisions as to which
176*4882a593Smuzhiyun 	 * areas to kick out.  There is no need to choose whether to
177*4882a593Smuzhiyun 	 * kick out your own texture or someone else's - simply eject
178*4882a593Smuzhiyun 	 * them all in LRU order.
179*4882a593Smuzhiyun 	 */
180*4882a593Smuzhiyun 
181*4882a593Smuzhiyun 	drm_i810_tex_region_t texList[I810_NR_TEX_REGIONS + 1];
182*4882a593Smuzhiyun 	/* Last elt is sentinal */
183*4882a593Smuzhiyun 	int texAge;		/* last time texture was uploaded */
184*4882a593Smuzhiyun 	int last_enqueue;	/* last time a buffer was enqueued */
185*4882a593Smuzhiyun 	int last_dispatch;	/* age of the most recently dispatched buffer */
186*4882a593Smuzhiyun 	int last_quiescent;	/*  */
187*4882a593Smuzhiyun 	int ctxOwner;		/* last context to upload state */
188*4882a593Smuzhiyun 
189*4882a593Smuzhiyun 	int vertex_prim;
190*4882a593Smuzhiyun 
191*4882a593Smuzhiyun 	int pf_enabled;		/* is pageflipping allowed? */
192*4882a593Smuzhiyun 	int pf_active;
193*4882a593Smuzhiyun 	int pf_current_page;	/* which buffer is being displayed? */
194*4882a593Smuzhiyun } drm_i810_sarea_t;
195*4882a593Smuzhiyun 
196*4882a593Smuzhiyun /* WARNING: If you change any of these defines, make sure to change the
197*4882a593Smuzhiyun  * defines in the Xserver file (xf86drmMga.h)
198*4882a593Smuzhiyun  */
199*4882a593Smuzhiyun 
200*4882a593Smuzhiyun /* i810 specific ioctls
201*4882a593Smuzhiyun  * The device specific ioctl range is 0x40 to 0x79.
202*4882a593Smuzhiyun  */
203*4882a593Smuzhiyun #define DRM_I810_INIT		0x00
204*4882a593Smuzhiyun #define DRM_I810_VERTEX		0x01
205*4882a593Smuzhiyun #define DRM_I810_CLEAR		0x02
206*4882a593Smuzhiyun #define DRM_I810_FLUSH		0x03
207*4882a593Smuzhiyun #define DRM_I810_GETAGE		0x04
208*4882a593Smuzhiyun #define DRM_I810_GETBUF		0x05
209*4882a593Smuzhiyun #define DRM_I810_SWAP		0x06
210*4882a593Smuzhiyun #define DRM_I810_COPY		0x07
211*4882a593Smuzhiyun #define DRM_I810_DOCOPY		0x08
212*4882a593Smuzhiyun #define DRM_I810_OV0INFO	0x09
213*4882a593Smuzhiyun #define DRM_I810_FSTATUS	0x0a
214*4882a593Smuzhiyun #define DRM_I810_OV0FLIP	0x0b
215*4882a593Smuzhiyun #define DRM_I810_MC		0x0c
216*4882a593Smuzhiyun #define DRM_I810_RSTATUS	0x0d
217*4882a593Smuzhiyun #define DRM_I810_FLIP		0x0e
218*4882a593Smuzhiyun 
219*4882a593Smuzhiyun #define DRM_IOCTL_I810_INIT		DRM_IOW( DRM_COMMAND_BASE + DRM_I810_INIT, drm_i810_init_t)
220*4882a593Smuzhiyun #define DRM_IOCTL_I810_VERTEX		DRM_IOW( DRM_COMMAND_BASE + DRM_I810_VERTEX, drm_i810_vertex_t)
221*4882a593Smuzhiyun #define DRM_IOCTL_I810_CLEAR		DRM_IOW( DRM_COMMAND_BASE + DRM_I810_CLEAR, drm_i810_clear_t)
222*4882a593Smuzhiyun #define DRM_IOCTL_I810_FLUSH		DRM_IO(  DRM_COMMAND_BASE + DRM_I810_FLUSH)
223*4882a593Smuzhiyun #define DRM_IOCTL_I810_GETAGE		DRM_IO(  DRM_COMMAND_BASE + DRM_I810_GETAGE)
224*4882a593Smuzhiyun #define DRM_IOCTL_I810_GETBUF		DRM_IOWR(DRM_COMMAND_BASE + DRM_I810_GETBUF, drm_i810_dma_t)
225*4882a593Smuzhiyun #define DRM_IOCTL_I810_SWAP		DRM_IO(  DRM_COMMAND_BASE + DRM_I810_SWAP)
226*4882a593Smuzhiyun #define DRM_IOCTL_I810_COPY		DRM_IOW( DRM_COMMAND_BASE + DRM_I810_COPY, drm_i810_copy_t)
227*4882a593Smuzhiyun #define DRM_IOCTL_I810_DOCOPY		DRM_IO(  DRM_COMMAND_BASE + DRM_I810_DOCOPY)
228*4882a593Smuzhiyun #define DRM_IOCTL_I810_OV0INFO		DRM_IOR( DRM_COMMAND_BASE + DRM_I810_OV0INFO, drm_i810_overlay_t)
229*4882a593Smuzhiyun #define DRM_IOCTL_I810_FSTATUS		DRM_IO ( DRM_COMMAND_BASE + DRM_I810_FSTATUS)
230*4882a593Smuzhiyun #define DRM_IOCTL_I810_OV0FLIP		DRM_IO ( DRM_COMMAND_BASE + DRM_I810_OV0FLIP)
231*4882a593Smuzhiyun #define DRM_IOCTL_I810_MC		DRM_IOW( DRM_COMMAND_BASE + DRM_I810_MC, drm_i810_mc_t)
232*4882a593Smuzhiyun #define DRM_IOCTL_I810_RSTATUS		DRM_IO ( DRM_COMMAND_BASE + DRM_I810_RSTATUS)
233*4882a593Smuzhiyun #define DRM_IOCTL_I810_FLIP             DRM_IO ( DRM_COMMAND_BASE + DRM_I810_FLIP)
234*4882a593Smuzhiyun 
235*4882a593Smuzhiyun typedef struct _drm_i810_clear {
236*4882a593Smuzhiyun 	int clear_color;
237*4882a593Smuzhiyun 	int clear_depth;
238*4882a593Smuzhiyun 	int flags;
239*4882a593Smuzhiyun } drm_i810_clear_t;
240*4882a593Smuzhiyun 
241*4882a593Smuzhiyun /* These may be placeholders if we have more cliprects than
242*4882a593Smuzhiyun  * I810_NR_SAREA_CLIPRECTS.  In that case, the client sets discard to
243*4882a593Smuzhiyun  * false, indicating that the buffer will be dispatched again with a
244*4882a593Smuzhiyun  * new set of cliprects.
245*4882a593Smuzhiyun  */
246*4882a593Smuzhiyun typedef struct _drm_i810_vertex {
247*4882a593Smuzhiyun 	int idx;		/* buffer index */
248*4882a593Smuzhiyun 	int used;		/* nr bytes in use */
249*4882a593Smuzhiyun 	int discard;		/* client is finished with the buffer? */
250*4882a593Smuzhiyun } drm_i810_vertex_t;
251*4882a593Smuzhiyun 
252*4882a593Smuzhiyun typedef struct _drm_i810_copy_t {
253*4882a593Smuzhiyun 	int idx;		/* buffer index */
254*4882a593Smuzhiyun 	int used;		/* nr bytes in use */
255*4882a593Smuzhiyun 	void *address;		/* Address to copy from */
256*4882a593Smuzhiyun } drm_i810_copy_t;
257*4882a593Smuzhiyun 
258*4882a593Smuzhiyun #define PR_TRIANGLES         (0x0<<18)
259*4882a593Smuzhiyun #define PR_TRISTRIP_0        (0x1<<18)
260*4882a593Smuzhiyun #define PR_TRISTRIP_1        (0x2<<18)
261*4882a593Smuzhiyun #define PR_TRIFAN            (0x3<<18)
262*4882a593Smuzhiyun #define PR_POLYGON           (0x4<<18)
263*4882a593Smuzhiyun #define PR_LINES             (0x5<<18)
264*4882a593Smuzhiyun #define PR_LINESTRIP         (0x6<<18)
265*4882a593Smuzhiyun #define PR_RECTS             (0x7<<18)
266*4882a593Smuzhiyun #define PR_MASK              (0x7<<18)
267*4882a593Smuzhiyun 
268*4882a593Smuzhiyun typedef struct drm_i810_dma {
269*4882a593Smuzhiyun 	void *virtual;
270*4882a593Smuzhiyun 	int request_idx;
271*4882a593Smuzhiyun 	int request_size;
272*4882a593Smuzhiyun 	int granted;
273*4882a593Smuzhiyun } drm_i810_dma_t;
274*4882a593Smuzhiyun 
275*4882a593Smuzhiyun typedef struct _drm_i810_overlay_t {
276*4882a593Smuzhiyun 	unsigned int offset;	/* Address of the Overlay Regs */
277*4882a593Smuzhiyun 	unsigned int physical;
278*4882a593Smuzhiyun } drm_i810_overlay_t;
279*4882a593Smuzhiyun 
280*4882a593Smuzhiyun typedef struct _drm_i810_mc {
281*4882a593Smuzhiyun 	int idx;		/* buffer index */
282*4882a593Smuzhiyun 	int used;		/* nr bytes in use */
283*4882a593Smuzhiyun 	int num_blocks;		/* number of GFXBlocks */
284*4882a593Smuzhiyun 	int *length;		/* List of lengths for GFXBlocks (FUTURE) */
285*4882a593Smuzhiyun 	unsigned int last_render;	/* Last Render Request */
286*4882a593Smuzhiyun } drm_i810_mc_t;
287*4882a593Smuzhiyun 
288*4882a593Smuzhiyun #if defined(__cplusplus)
289*4882a593Smuzhiyun }
290*4882a593Smuzhiyun #endif
291*4882a593Smuzhiyun 
292*4882a593Smuzhiyun #endif				/* _I810_DRM_H_ */
293