xref: /titanic_41/usr/src/uts/intel/io/drm/i915_drm.h (revision 8275a87e46b79352e8c1a918b91373159c477438)
1 /* BEGIN CSTYLED */
2 
3 /*
4  * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
5  * All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sub license, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice (including the
16  * next paragraph) shall be included in all copies or substantial portions
17  * of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
23  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  *
27  */
28 
29 /*
30  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
31  * Use is subject to license terms.
32  */
33 
34 #ifndef _I915_DRM_H
35 #define _I915_DRM_H
36 
37 #pragma ident	"%Z%%M%	%I%	%E% SMI"
38 
39 /* Please note that modifications to all structs defined here are
40  * subject to backwards-compatibility constraints.
41  */
42 
43 #include "drm.h"
44 
45 /* Each region is a minimum of 16k, and there are at most 255 of them.
46  */
47 #define I915_NR_TEX_REGIONS 255	/* table size 2k - maximum due to use
48 				 * of chars for next/prev indices */
49 #define I915_LOG_MIN_TEX_REGION_SIZE 14
50 
51 typedef struct _drm_i915_init {
52 	enum {
53 		I915_INIT_DMA = 0x01,
54 		I915_CLEANUP_DMA = 0x02,
55 		I915_RESUME_DMA = 0x03
56 	} func;
57 	unsigned int mmio_offset;
58 	int sarea_priv_offset;
59 	unsigned int ring_start;
60 	unsigned int ring_end;
61 	unsigned int ring_size;
62 	unsigned int front_offset;
63 	unsigned int back_offset;
64 	unsigned int depth_offset;
65 	unsigned int w;
66 	unsigned int h;
67 	unsigned int pitch;
68 	unsigned int pitch_bits;
69 	unsigned int back_pitch;
70 	unsigned int depth_pitch;
71 	unsigned int cpp;
72 	unsigned int chipset;
73 } drm_i915_init_t;
74 
75 typedef struct _drm_i915_sarea {
76 	drm_tex_region_t texList[I915_NR_TEX_REGIONS + 1];
77 	int last_upload;	/* last time texture was uploaded */
78 	int last_enqueue;	/* last time a buffer was enqueued */
79 	int last_dispatch;	/* age of the most recently dispatched buffer */
80 	int ctxOwner;		/* last context to upload state */
81 	int texAge;
82 	int pf_enabled;		/* is pageflipping allowed? */
83 	int pf_active;
84 	int pf_current_page;	/* which buffer is being displayed? */
85 	int perf_boxes;		/* performance boxes to be displayed */
86 	int width, height;      /* screen size in pixels */
87 
88 	drm_handle_t front_handle;
89 	int front_offset;
90 	int front_size;
91 
92 	drm_handle_t back_handle;
93 	int back_offset;
94 	int back_size;
95 
96 	drm_handle_t depth_handle;
97 	int depth_offset;
98 	int depth_size;
99 
100 	drm_handle_t tex_handle;
101 	int tex_offset;
102 	int tex_size;
103 	int log_tex_granularity;
104 	int pitch;
105 	int rotation;           /* 0, 90, 180 or 270 */
106 	int rotated_offset;
107 	int rotated_size;
108 	int rotated_pitch;
109 	int virtualX, virtualY;
110 
111 	unsigned int front_tiled;
112 	unsigned int back_tiled;
113 	unsigned int depth_tiled;
114 	unsigned int rotated_tiled;
115 	unsigned int rotated2_tiled;
116 
117 	int pipeA_x;
118 	int pipeA_y;
119 	int pipeA_w;
120 	int pipeA_h;
121 	int pipeB_x;
122 	int pipeB_y;
123 	int pipeB_w;
124 	int pipeB_h;
125 } drm_i915_sarea_t;
126 
127 /* Driver specific fence types and classes.
128  */
129 
130 /* The only fence class we support */
131 #define DRM_I915_FENCE_CLASS_ACCEL 0
132 /* Fence type that guarantees read-write flush */
133 #define DRM_I915_FENCE_TYPE_RW 2
134 /* MI_FLUSH programmed just before the fence */
135 #define DRM_I915_FENCE_FLAG_FLUSHED 0x01000000
136 
137 /* Flags for perf_boxes
138  */
139 #define I915_BOX_RING_EMPTY    0x1
140 #define I915_BOX_FLIP          0x2
141 #define I915_BOX_WAIT          0x4
142 #define I915_BOX_TEXTURE_LOAD  0x8
143 #define I915_BOX_LOST_CONTEXT  0x10
144 
145 /* I915 specific ioctls
146  * The device specific ioctl range is 0x40 to 0x79.
147  */
148 #define DRM_I915_INIT		0x00
149 #define DRM_I915_FLUSH		0x01
150 #define DRM_I915_FLIP		0x02
151 #define DRM_I915_BATCHBUFFER	0x03
152 #define DRM_I915_IRQ_EMIT	0x04
153 #define DRM_I915_IRQ_WAIT	0x05
154 #define DRM_I915_GETPARAM	0x06
155 #define DRM_I915_SETPARAM	0x07
156 #define DRM_I915_ALLOC		0x08
157 #define DRM_I915_FREE		0x09
158 #define DRM_I915_INIT_HEAP	0x0a
159 #define DRM_I915_CMDBUFFER	0x0b
160 #define DRM_I915_DESTROY_HEAP	0x0c
161 
162 #define DRM_IOCTL_I915_INIT		DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
163 #define DRM_IOCTL_I915_FLUSH		DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
164 #define DRM_IOCTL_I915_FLIP		DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLIP)
165 #define DRM_IOCTL_I915_BATCHBUFFER	DRM_IOW( DRM_COMMAND_BASE + DRM_I915_BATCHBUFFER, drm_i915_batchbuffer_t)
166 #define DRM_IOCTL_I915_IRQ_EMIT         DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_IRQ_EMIT, drm_i915_irq_emit_t)
167 #define DRM_IOCTL_I915_IRQ_WAIT         DRM_IOW( DRM_COMMAND_BASE + DRM_I915_IRQ_WAIT, drm_i915_irq_wait_t)
168 #define DRM_IOCTL_I915_GETPARAM         DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GETPARAM, drm_i915_getparam_t)
169 #define DRM_IOCTL_I915_SETPARAM         DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SETPARAM, drm_i915_setparam_t)
170 #define DRM_IOCTL_I915_ALLOC            DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_ALLOC, drm_i915_mem_alloc_t)
171 #define DRM_IOCTL_I915_FREE             DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)
172 #define DRM_IOCTL_I915_INIT_HEAP        DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
173 #define DRM_IOCTL_I915_CMDBUFFER	DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
174 #define DRM_IOCTL_I915_DESTROY_HEAP	DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t)
175 
176 /* Allow drivers to submit batchbuffers directly to hardware, relying
177  * on the security mechanisms provided by hardware.
178  */
179 typedef struct _drm_i915_batchbuffer {
180 	int start;		/* agp offset */
181 	int used;		/* nr bytes in use */
182 	int DR1;		/* hw flags for GFX_OP_DRAWRECT_INFO */
183 	int DR4;		/* window origin for GFX_OP_DRAWRECT_INFO */
184 	int num_cliprects;	/* mulitpass with multiple cliprects? */
185 	drm_clip_rect_t __user *cliprects;	/* pointer to userspace cliprects */
186 } drm_i915_batchbuffer_t;
187 
188 typedef struct _drm_i915_batchbuffer32 {
189 	int start;		/* agp offset */
190 	int used;		/* nr bytes in use */
191 	int DR1;		/* hw flags for GFX_OP_DRAWRECT_INFO */
192 	int DR4;		/* window origin for GFX_OP_DRAWRECT_INFO */
193 	int num_cliprects;	/* mulitpass with multiple cliprects? */
194 	caddr32_t cliprects;	/* pointer to userspace cliprects */
195 } drm_i915_batchbuffer32_t;
196 
197 /* As above, but pass a pointer to userspace buffer which can be
198  * validated by the kernel prior to sending to hardware.
199  */
200 typedef struct _drm_i915_cmdbuffer {
201 	char __user *buf;	/* pointer to userspace command buffer */
202 	int sz;			/* nr bytes in buf */
203 	int DR1;		/* hw flags for GFX_OP_DRAWRECT_INFO */
204 	int DR4;		/* window origin for GFX_OP_DRAWRECT_INFO */
205 	int num_cliprects;	/* mulitpass with multiple cliprects? */
206 	drm_clip_rect_t __user *cliprects;	/* pointer to userspace cliprects */
207 } drm_i915_cmdbuffer_t;
208 
209 typedef struct _drm_i915_cmdbuffer32 {
210 	caddr32_t buf;	/* pointer to userspace command buffer */
211 	int sz;			/* nr bytes in buf */
212 	int DR1;		/* hw flags for GFX_OP_DRAWRECT_INFO */
213 	int DR4;		/* window origin for GFX_OP_DRAWRECT_INFO */
214 	int num_cliprects;	/* mulitpass with multiple cliprects? */
215 	caddr32_t cliprects;	/* pointer to userspace cliprects */
216 } drm_i915_cmdbuffer32_t;
217 
218 /* Userspace can request & wait on irq's:
219  */
220 typedef struct drm_i915_irq_emit {
221 	int __user *irq_seq;
222 } drm_i915_irq_emit_t;
223 
224 typedef struct drm_i915_irq_emit32 {
225 	caddr32_t irq_seq;
226 } drm_i915_irq_emit32_t;
227 
228 typedef struct drm_i915_irq_wait {
229 	int irq_seq;
230 } drm_i915_irq_wait_t;
231 
232 /* Ioctl to query kernel params:
233  */
234 #define I915_PARAM_IRQ_ACTIVE            1
235 #define I915_PARAM_ALLOW_BATCHBUFFER     2
236 #define I915_PARAM_LAST_DISPATCH         3
237 
238 typedef struct drm_i915_getparam {
239 	int param;
240 	int __user *value;
241 } drm_i915_getparam_t;
242 
243 typedef struct drm_i915_getparam32 {
244 	int param;
245 	caddr32_t value;
246 } drm_i915_getparam32_t;
247 
248 /* Ioctl to set kernel params:
249  */
250 #define I915_SETPARAM_USE_MI_BATCHBUFFER_START            1
251 #define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY             2
252 #define I915_SETPARAM_ALLOW_BATCHBUFFER                   3
253 
254 typedef struct drm_i915_setparam {
255 	int param;
256 	int value;
257 } drm_i915_setparam_t;
258 
259 /* A memory manager for regions of shared memory:
260  */
261 #define I915_MEM_REGION_AGP 1
262 
263 typedef struct drm_i915_mem_alloc {
264 	int region;
265 	int alignment;
266 	int size;
267 	int __user *region_offset;	/* offset from start of fb or agp */
268 } drm_i915_mem_alloc_t;
269 
270 typedef struct drm_i915_mem_alloc32 {
271 	int region;
272 	int alignment;
273 	int size;
274 	caddr32_t region_offset;	/* offset from start of fb or agp */
275 } drm_i915_mem_alloc32_t;
276 
277 typedef struct drm_i915_mem_free {
278 	int region;
279 	int region_offset;
280 } drm_i915_mem_free_t;
281 
282 typedef struct drm_i915_mem_init_heap {
283 	int region;
284 	int size;
285 	int start;
286 } drm_i915_mem_init_heap_t;
287 
288 /* Allow memory manager to be torn down and re-initialized (eg on
289  * rotate):
290  */
291 typedef struct drm_i915_mem_destroy_heap {
292 	        int region;
293 } drm_i915_mem_destroy_heap_t;
294 
295 /* Allow X server to configure which pipes to monitor for vblank signals
296  */
297 #define	DRM_I915_VBLANK_PIPE_A	1
298 #define	DRM_I915_VBLANK_PIPE_B	2
299 
300 typedef struct drm_i915_vblank_pipe {
301 	int pipe;
302 } drm_i915_vblank_pipe_t;
303 
304 /* Schedule buffer swap at given vertical blank:
305  */
306 typedef struct drm_i915_vblank_swap {
307 	drm_drawable_t drawable;
308 	drm_vblank_seq_type_t seqtype;
309 	unsigned int sequence;
310 } drm_i915_vblank_swap_t;
311 
312 #endif /* _I915_DRM_H */
313