]> asedeno.scripts.mit.edu Git - linux.git/blob - include/uapi/drm/i915_drm.h
drm/i915: Don't use BIT() in UAPI section
[linux.git] / include / uapi / drm / i915_drm.h
1 /*
2  * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
3  * All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sub license, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the
14  * next paragraph) shall be included in all copies or substantial portions
15  * of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
21  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  *
25  */
26
27 #ifndef _UAPI_I915_DRM_H_
28 #define _UAPI_I915_DRM_H_
29
30 #include "drm.h"
31
32 #if defined(__cplusplus)
33 extern "C" {
34 #endif
35
36 /* Please note that modifications to all structs defined here are
37  * subject to backwards-compatibility constraints.
38  */
39
40 /**
41  * DOC: uevents generated by i915 on it's device node
42  *
43  * I915_L3_PARITY_UEVENT - Generated when the driver receives a parity mismatch
44  *      event from the gpu l3 cache. Additional information supplied is ROW,
45  *      BANK, SUBBANK, SLICE of the affected cacheline. Userspace should keep
46  *      track of these events and if a specific cache-line seems to have a
47  *      persistent error remap it with the l3 remapping tool supplied in
48  *      intel-gpu-tools.  The value supplied with the event is always 1.
49  *
50  * I915_ERROR_UEVENT - Generated upon error detection, currently only via
51  *      hangcheck. The error detection event is a good indicator of when things
52  *      began to go badly. The value supplied with the event is a 1 upon error
53  *      detection, and a 0 upon reset completion, signifying no more error
54  *      exists. NOTE: Disabling hangcheck or reset via module parameter will
55  *      cause the related events to not be seen.
56  *
57  * I915_RESET_UEVENT - Event is generated just before an attempt to reset the
58  *      the GPU. The value supplied with the event is always 1. NOTE: Disable
59  *      reset via module parameter will cause this event to not be seen.
60  */
61 #define I915_L3_PARITY_UEVENT           "L3_PARITY_ERROR"
62 #define I915_ERROR_UEVENT               "ERROR"
63 #define I915_RESET_UEVENT               "RESET"
64
65 /*
66  * MOCS indexes used for GPU surfaces, defining the cacheability of the
67  * surface data and the coherency for this data wrt. CPU vs. GPU accesses.
68  */
69 enum i915_mocs_table_index {
70         /*
71          * Not cached anywhere, coherency between CPU and GPU accesses is
72          * guaranteed.
73          */
74         I915_MOCS_UNCACHED,
75         /*
76          * Cacheability and coherency controlled by the kernel automatically
77          * based on the DRM_I915_GEM_SET_CACHING IOCTL setting and the current
78          * usage of the surface (used for display scanout or not).
79          */
80         I915_MOCS_PTE,
81         /*
82          * Cached in all GPU caches available on the platform.
83          * Coherency between CPU and GPU accesses to the surface is not
84          * guaranteed without extra synchronization.
85          */
86         I915_MOCS_CACHED,
87 };
88
89 /* Each region is a minimum of 16k, and there are at most 255 of them.
90  */
91 #define I915_NR_TEX_REGIONS 255 /* table size 2k - maximum due to use
92                                  * of chars for next/prev indices */
93 #define I915_LOG_MIN_TEX_REGION_SIZE 14
94
95 typedef struct _drm_i915_init {
96         enum {
97                 I915_INIT_DMA = 0x01,
98                 I915_CLEANUP_DMA = 0x02,
99                 I915_RESUME_DMA = 0x03
100         } func;
101         unsigned int mmio_offset;
102         int sarea_priv_offset;
103         unsigned int ring_start;
104         unsigned int ring_end;
105         unsigned int ring_size;
106         unsigned int front_offset;
107         unsigned int back_offset;
108         unsigned int depth_offset;
109         unsigned int w;
110         unsigned int h;
111         unsigned int pitch;
112         unsigned int pitch_bits;
113         unsigned int back_pitch;
114         unsigned int depth_pitch;
115         unsigned int cpp;
116         unsigned int chipset;
117 } drm_i915_init_t;
118
119 typedef struct _drm_i915_sarea {
120         struct drm_tex_region texList[I915_NR_TEX_REGIONS + 1];
121         int last_upload;        /* last time texture was uploaded */
122         int last_enqueue;       /* last time a buffer was enqueued */
123         int last_dispatch;      /* age of the most recently dispatched buffer */
124         int ctxOwner;           /* last context to upload state */
125         int texAge;
126         int pf_enabled;         /* is pageflipping allowed? */
127         int pf_active;
128         int pf_current_page;    /* which buffer is being displayed? */
129         int perf_boxes;         /* performance boxes to be displayed */
130         int width, height;      /* screen size in pixels */
131
132         drm_handle_t front_handle;
133         int front_offset;
134         int front_size;
135
136         drm_handle_t back_handle;
137         int back_offset;
138         int back_size;
139
140         drm_handle_t depth_handle;
141         int depth_offset;
142         int depth_size;
143
144         drm_handle_t tex_handle;
145         int tex_offset;
146         int tex_size;
147         int log_tex_granularity;
148         int pitch;
149         int rotation;           /* 0, 90, 180 or 270 */
150         int rotated_offset;
151         int rotated_size;
152         int rotated_pitch;
153         int virtualX, virtualY;
154
155         unsigned int front_tiled;
156         unsigned int back_tiled;
157         unsigned int depth_tiled;
158         unsigned int rotated_tiled;
159         unsigned int rotated2_tiled;
160
161         int pipeA_x;
162         int pipeA_y;
163         int pipeA_w;
164         int pipeA_h;
165         int pipeB_x;
166         int pipeB_y;
167         int pipeB_w;
168         int pipeB_h;
169
170         /* fill out some space for old userspace triple buffer */
171         drm_handle_t unused_handle;
172         __u32 unused1, unused2, unused3;
173
174         /* buffer object handles for static buffers. May change
175          * over the lifetime of the client.
176          */
177         __u32 front_bo_handle;
178         __u32 back_bo_handle;
179         __u32 unused_bo_handle;
180         __u32 depth_bo_handle;
181
182 } drm_i915_sarea_t;
183
184 /* due to userspace building against these headers we need some compat here */
185 #define planeA_x pipeA_x
186 #define planeA_y pipeA_y
187 #define planeA_w pipeA_w
188 #define planeA_h pipeA_h
189 #define planeB_x pipeB_x
190 #define planeB_y pipeB_y
191 #define planeB_w pipeB_w
192 #define planeB_h pipeB_h
193
194 /* Flags for perf_boxes
195  */
196 #define I915_BOX_RING_EMPTY    0x1
197 #define I915_BOX_FLIP          0x2
198 #define I915_BOX_WAIT          0x4
199 #define I915_BOX_TEXTURE_LOAD  0x8
200 #define I915_BOX_LOST_CONTEXT  0x10
201
202 /*
203  * i915 specific ioctls.
204  *
205  * The device specific ioctl range is [DRM_COMMAND_BASE, DRM_COMMAND_END) ie
206  * [0x40, 0xa0) (a0 is excluded). The numbers below are defined as offset
207  * against DRM_COMMAND_BASE and should be between [0x0, 0x60).
208  */
209 #define DRM_I915_INIT           0x00
210 #define DRM_I915_FLUSH          0x01
211 #define DRM_I915_FLIP           0x02
212 #define DRM_I915_BATCHBUFFER    0x03
213 #define DRM_I915_IRQ_EMIT       0x04
214 #define DRM_I915_IRQ_WAIT       0x05
215 #define DRM_I915_GETPARAM       0x06
216 #define DRM_I915_SETPARAM       0x07
217 #define DRM_I915_ALLOC          0x08
218 #define DRM_I915_FREE           0x09
219 #define DRM_I915_INIT_HEAP      0x0a
220 #define DRM_I915_CMDBUFFER      0x0b
221 #define DRM_I915_DESTROY_HEAP   0x0c
222 #define DRM_I915_SET_VBLANK_PIPE        0x0d
223 #define DRM_I915_GET_VBLANK_PIPE        0x0e
224 #define DRM_I915_VBLANK_SWAP    0x0f
225 #define DRM_I915_HWS_ADDR       0x11
226 #define DRM_I915_GEM_INIT       0x13
227 #define DRM_I915_GEM_EXECBUFFER 0x14
228 #define DRM_I915_GEM_PIN        0x15
229 #define DRM_I915_GEM_UNPIN      0x16
230 #define DRM_I915_GEM_BUSY       0x17
231 #define DRM_I915_GEM_THROTTLE   0x18
232 #define DRM_I915_GEM_ENTERVT    0x19
233 #define DRM_I915_GEM_LEAVEVT    0x1a
234 #define DRM_I915_GEM_CREATE     0x1b
235 #define DRM_I915_GEM_PREAD      0x1c
236 #define DRM_I915_GEM_PWRITE     0x1d
237 #define DRM_I915_GEM_MMAP       0x1e
238 #define DRM_I915_GEM_SET_DOMAIN 0x1f
239 #define DRM_I915_GEM_SW_FINISH  0x20
240 #define DRM_I915_GEM_SET_TILING 0x21
241 #define DRM_I915_GEM_GET_TILING 0x22
242 #define DRM_I915_GEM_GET_APERTURE 0x23
243 #define DRM_I915_GEM_MMAP_GTT   0x24
244 #define DRM_I915_GET_PIPE_FROM_CRTC_ID  0x25
245 #define DRM_I915_GEM_MADVISE    0x26
246 #define DRM_I915_OVERLAY_PUT_IMAGE      0x27
247 #define DRM_I915_OVERLAY_ATTRS  0x28
248 #define DRM_I915_GEM_EXECBUFFER2        0x29
249 #define DRM_I915_GEM_EXECBUFFER2_WR     DRM_I915_GEM_EXECBUFFER2
250 #define DRM_I915_GET_SPRITE_COLORKEY    0x2a
251 #define DRM_I915_SET_SPRITE_COLORKEY    0x2b
252 #define DRM_I915_GEM_WAIT       0x2c
253 #define DRM_I915_GEM_CONTEXT_CREATE     0x2d
254 #define DRM_I915_GEM_CONTEXT_DESTROY    0x2e
255 #define DRM_I915_GEM_SET_CACHING        0x2f
256 #define DRM_I915_GEM_GET_CACHING        0x30
257 #define DRM_I915_REG_READ               0x31
258 #define DRM_I915_GET_RESET_STATS        0x32
259 #define DRM_I915_GEM_USERPTR            0x33
260 #define DRM_I915_GEM_CONTEXT_GETPARAM   0x34
261 #define DRM_I915_GEM_CONTEXT_SETPARAM   0x35
262 #define DRM_I915_PERF_OPEN              0x36
263 #define DRM_I915_PERF_ADD_CONFIG        0x37
264 #define DRM_I915_PERF_REMOVE_CONFIG     0x38
265
266 #define DRM_IOCTL_I915_INIT             DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
267 #define DRM_IOCTL_I915_FLUSH            DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
268 #define DRM_IOCTL_I915_FLIP             DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLIP)
269 #define DRM_IOCTL_I915_BATCHBUFFER      DRM_IOW( DRM_COMMAND_BASE + DRM_I915_BATCHBUFFER, drm_i915_batchbuffer_t)
270 #define DRM_IOCTL_I915_IRQ_EMIT         DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_IRQ_EMIT, drm_i915_irq_emit_t)
271 #define DRM_IOCTL_I915_IRQ_WAIT         DRM_IOW( DRM_COMMAND_BASE + DRM_I915_IRQ_WAIT, drm_i915_irq_wait_t)
272 #define DRM_IOCTL_I915_GETPARAM         DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GETPARAM, drm_i915_getparam_t)
273 #define DRM_IOCTL_I915_SETPARAM         DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SETPARAM, drm_i915_setparam_t)
274 #define DRM_IOCTL_I915_ALLOC            DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_ALLOC, drm_i915_mem_alloc_t)
275 #define DRM_IOCTL_I915_FREE             DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)
276 #define DRM_IOCTL_I915_INIT_HEAP        DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
277 #define DRM_IOCTL_I915_CMDBUFFER        DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
278 #define DRM_IOCTL_I915_DESTROY_HEAP     DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t)
279 #define DRM_IOCTL_I915_SET_VBLANK_PIPE  DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
280 #define DRM_IOCTL_I915_GET_VBLANK_PIPE  DRM_IOR( DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
281 #define DRM_IOCTL_I915_VBLANK_SWAP      DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_VBLANK_SWAP, drm_i915_vblank_swap_t)
282 #define DRM_IOCTL_I915_HWS_ADDR         DRM_IOW(DRM_COMMAND_BASE + DRM_I915_HWS_ADDR, struct drm_i915_gem_init)
283 #define DRM_IOCTL_I915_GEM_INIT         DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_INIT, struct drm_i915_gem_init)
284 #define DRM_IOCTL_I915_GEM_EXECBUFFER   DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER, struct drm_i915_gem_execbuffer)
285 #define DRM_IOCTL_I915_GEM_EXECBUFFER2  DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
286 #define DRM_IOCTL_I915_GEM_EXECBUFFER2_WR       DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2_WR, struct drm_i915_gem_execbuffer2)
287 #define DRM_IOCTL_I915_GEM_PIN          DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_PIN, struct drm_i915_gem_pin)
288 #define DRM_IOCTL_I915_GEM_UNPIN        DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_UNPIN, struct drm_i915_gem_unpin)
289 #define DRM_IOCTL_I915_GEM_BUSY         DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_BUSY, struct drm_i915_gem_busy)
290 #define DRM_IOCTL_I915_GEM_SET_CACHING          DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_SET_CACHING, struct drm_i915_gem_caching)
291 #define DRM_IOCTL_I915_GEM_GET_CACHING          DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_GET_CACHING, struct drm_i915_gem_caching)
292 #define DRM_IOCTL_I915_GEM_THROTTLE     DRM_IO ( DRM_COMMAND_BASE + DRM_I915_GEM_THROTTLE)
293 #define DRM_IOCTL_I915_GEM_ENTERVT      DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_ENTERVT)
294 #define DRM_IOCTL_I915_GEM_LEAVEVT      DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_LEAVEVT)
295 #define DRM_IOCTL_I915_GEM_CREATE       DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE, struct drm_i915_gem_create)
296 #define DRM_IOCTL_I915_GEM_PREAD        DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PREAD, struct drm_i915_gem_pread)
297 #define DRM_IOCTL_I915_GEM_PWRITE       DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PWRITE, struct drm_i915_gem_pwrite)
298 #define DRM_IOCTL_I915_GEM_MMAP         DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct drm_i915_gem_mmap)
299 #define DRM_IOCTL_I915_GEM_MMAP_GTT     DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_gtt)
300 #define DRM_IOCTL_I915_GEM_SET_DOMAIN   DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SET_DOMAIN, struct drm_i915_gem_set_domain)
301 #define DRM_IOCTL_I915_GEM_SW_FINISH    DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish)
302 #define DRM_IOCTL_I915_GEM_SET_TILING   DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling)
303 #define DRM_IOCTL_I915_GEM_GET_TILING   DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_TILING, struct drm_i915_gem_get_tiling)
304 #define DRM_IOCTL_I915_GEM_GET_APERTURE DRM_IOR  (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct drm_i915_gem_get_aperture)
305 #define DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_PIPE_FROM_CRTC_ID, struct drm_i915_get_pipe_from_crtc_id)
306 #define DRM_IOCTL_I915_GEM_MADVISE      DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MADVISE, struct drm_i915_gem_madvise)
307 #define DRM_IOCTL_I915_OVERLAY_PUT_IMAGE        DRM_IOW(DRM_COMMAND_BASE + DRM_I915_OVERLAY_PUT_IMAGE, struct drm_intel_overlay_put_image)
308 #define DRM_IOCTL_I915_OVERLAY_ATTRS    DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_OVERLAY_ATTRS, struct drm_intel_overlay_attrs)
309 #define DRM_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
310 #define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
311 #define DRM_IOCTL_I915_GEM_WAIT         DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_WAIT, struct drm_i915_gem_wait)
312 #define DRM_IOCTL_I915_GEM_CONTEXT_CREATE       DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create)
313 #define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY      DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy)
314 #define DRM_IOCTL_I915_REG_READ                 DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_REG_READ, struct drm_i915_reg_read)
315 #define DRM_IOCTL_I915_GET_RESET_STATS          DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GET_RESET_STATS, struct drm_i915_reset_stats)
316 #define DRM_IOCTL_I915_GEM_USERPTR                      DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_USERPTR, struct drm_i915_gem_userptr)
317 #define DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM     DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_GETPARAM, struct drm_i915_gem_context_param)
318 #define DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM     DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_SETPARAM, struct drm_i915_gem_context_param)
319 #define DRM_IOCTL_I915_PERF_OPEN        DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_OPEN, struct drm_i915_perf_open_param)
320 #define DRM_IOCTL_I915_PERF_ADD_CONFIG  DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_ADD_CONFIG, struct drm_i915_perf_oa_config)
321 #define DRM_IOCTL_I915_PERF_REMOVE_CONFIG       DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_REMOVE_CONFIG, __u64)
322
323 /* Allow drivers to submit batchbuffers directly to hardware, relying
324  * on the security mechanisms provided by hardware.
325  */
326 typedef struct drm_i915_batchbuffer {
327         int start;              /* agp offset */
328         int used;               /* nr bytes in use */
329         int DR1;                /* hw flags for GFX_OP_DRAWRECT_INFO */
330         int DR4;                /* window origin for GFX_OP_DRAWRECT_INFO */
331         int num_cliprects;      /* mulitpass with multiple cliprects? */
332         struct drm_clip_rect __user *cliprects; /* pointer to userspace cliprects */
333 } drm_i915_batchbuffer_t;
334
335 /* As above, but pass a pointer to userspace buffer which can be
336  * validated by the kernel prior to sending to hardware.
337  */
338 typedef struct _drm_i915_cmdbuffer {
339         char __user *buf;       /* pointer to userspace command buffer */
340         int sz;                 /* nr bytes in buf */
341         int DR1;                /* hw flags for GFX_OP_DRAWRECT_INFO */
342         int DR4;                /* window origin for GFX_OP_DRAWRECT_INFO */
343         int num_cliprects;      /* mulitpass with multiple cliprects? */
344         struct drm_clip_rect __user *cliprects; /* pointer to userspace cliprects */
345 } drm_i915_cmdbuffer_t;
346
347 /* Userspace can request & wait on irq's:
348  */
349 typedef struct drm_i915_irq_emit {
350         int __user *irq_seq;
351 } drm_i915_irq_emit_t;
352
353 typedef struct drm_i915_irq_wait {
354         int irq_seq;
355 } drm_i915_irq_wait_t;
356
357 /* Ioctl to query kernel params:
358  */
359 #define I915_PARAM_IRQ_ACTIVE            1
360 #define I915_PARAM_ALLOW_BATCHBUFFER     2
361 #define I915_PARAM_LAST_DISPATCH         3
362 #define I915_PARAM_CHIPSET_ID            4
363 #define I915_PARAM_HAS_GEM               5
364 #define I915_PARAM_NUM_FENCES_AVAIL      6
365 #define I915_PARAM_HAS_OVERLAY           7
366 #define I915_PARAM_HAS_PAGEFLIPPING      8
367 #define I915_PARAM_HAS_EXECBUF2          9
368 #define I915_PARAM_HAS_BSD               10
369 #define I915_PARAM_HAS_BLT               11
370 #define I915_PARAM_HAS_RELAXED_FENCING   12
371 #define I915_PARAM_HAS_COHERENT_RINGS    13
372 #define I915_PARAM_HAS_EXEC_CONSTANTS    14
373 #define I915_PARAM_HAS_RELAXED_DELTA     15
374 #define I915_PARAM_HAS_GEN7_SOL_RESET    16
375 #define I915_PARAM_HAS_LLC               17
376 #define I915_PARAM_HAS_ALIASING_PPGTT    18
377 #define I915_PARAM_HAS_WAIT_TIMEOUT      19
378 #define I915_PARAM_HAS_SEMAPHORES        20
379 #define I915_PARAM_HAS_PRIME_VMAP_FLUSH  21
380 #define I915_PARAM_HAS_VEBOX             22
381 #define I915_PARAM_HAS_SECURE_BATCHES    23
382 #define I915_PARAM_HAS_PINNED_BATCHES    24
383 #define I915_PARAM_HAS_EXEC_NO_RELOC     25
384 #define I915_PARAM_HAS_EXEC_HANDLE_LUT   26
385 #define I915_PARAM_HAS_WT                27
386 #define I915_PARAM_CMD_PARSER_VERSION    28
387 #define I915_PARAM_HAS_COHERENT_PHYS_GTT 29
388 #define I915_PARAM_MMAP_VERSION          30
389 #define I915_PARAM_HAS_BSD2              31
390 #define I915_PARAM_REVISION              32
391 #define I915_PARAM_SUBSLICE_TOTAL        33
392 #define I915_PARAM_EU_TOTAL              34
393 #define I915_PARAM_HAS_GPU_RESET         35
394 #define I915_PARAM_HAS_RESOURCE_STREAMER 36
395 #define I915_PARAM_HAS_EXEC_SOFTPIN      37
396 #define I915_PARAM_HAS_POOLED_EU         38
397 #define I915_PARAM_MIN_EU_IN_POOL        39
398 #define I915_PARAM_MMAP_GTT_VERSION      40
399
400 /*
401  * Query whether DRM_I915_GEM_EXECBUFFER2 supports user defined execution
402  * priorities and the driver will attempt to execute batches in priority order.
403  * The param returns a capability bitmask, nonzero implies that the scheduler
404  * is enabled, with different features present according to the mask.
405  *
406  * The initial priority for each batch is supplied by the context and is
407  * controlled via I915_CONTEXT_PARAM_PRIORITY.
408  */
409 #define I915_PARAM_HAS_SCHEDULER         41
410 #define   I915_SCHEDULER_CAP_ENABLED    (1ul << 0)
411 #define   I915_SCHEDULER_CAP_PRIORITY   (1ul << 1)
412 #define   I915_SCHEDULER_CAP_PREEMPTION (1ul << 2)
413
414 #define I915_PARAM_HUC_STATUS            42
415
416 /* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to opt-out of
417  * synchronisation with implicit fencing on individual objects.
418  * See EXEC_OBJECT_ASYNC.
419  */
420 #define I915_PARAM_HAS_EXEC_ASYNC        43
421
422 /* Query whether DRM_I915_GEM_EXECBUFFER2 supports explicit fence support -
423  * both being able to pass in a sync_file fd to wait upon before executing,
424  * and being able to return a new sync_file fd that is signaled when the
425  * current request is complete. See I915_EXEC_FENCE_IN and I915_EXEC_FENCE_OUT.
426  */
427 #define I915_PARAM_HAS_EXEC_FENCE        44
428
429 /* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to capture
430  * user specified bufffers for post-mortem debugging of GPU hangs. See
431  * EXEC_OBJECT_CAPTURE.
432  */
433 #define I915_PARAM_HAS_EXEC_CAPTURE      45
434
435 #define I915_PARAM_SLICE_MASK            46
436
437 /* Assuming it's uniform for each slice, this queries the mask of subslices
438  * per-slice for this system.
439  */
440 #define I915_PARAM_SUBSLICE_MASK         47
441
442 /*
443  * Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying the batch buffer
444  * as the first execobject as opposed to the last. See I915_EXEC_BATCH_FIRST.
445  */
446 #define I915_PARAM_HAS_EXEC_BATCH_FIRST  48
447
448 /* Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying an array of
449  * drm_i915_gem_exec_fence structures.  See I915_EXEC_FENCE_ARRAY.
450  */
451 #define I915_PARAM_HAS_EXEC_FENCE_ARRAY  49
452
453 typedef struct drm_i915_getparam {
454         __s32 param;
455         /*
456          * WARNING: Using pointers instead of fixed-size u64 means we need to write
457          * compat32 code. Don't repeat this mistake.
458          */
459         int __user *value;
460 } drm_i915_getparam_t;
461
462 /* Ioctl to set kernel params:
463  */
464 #define I915_SETPARAM_USE_MI_BATCHBUFFER_START            1
465 #define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY             2
466 #define I915_SETPARAM_ALLOW_BATCHBUFFER                   3
467 #define I915_SETPARAM_NUM_USED_FENCES                     4
468
469 typedef struct drm_i915_setparam {
470         int param;
471         int value;
472 } drm_i915_setparam_t;
473
474 /* A memory manager for regions of shared memory:
475  */
476 #define I915_MEM_REGION_AGP 1
477
478 typedef struct drm_i915_mem_alloc {
479         int region;
480         int alignment;
481         int size;
482         int __user *region_offset;      /* offset from start of fb or agp */
483 } drm_i915_mem_alloc_t;
484
485 typedef struct drm_i915_mem_free {
486         int region;
487         int region_offset;
488 } drm_i915_mem_free_t;
489
490 typedef struct drm_i915_mem_init_heap {
491         int region;
492         int size;
493         int start;
494 } drm_i915_mem_init_heap_t;
495
496 /* Allow memory manager to be torn down and re-initialized (eg on
497  * rotate):
498  */
499 typedef struct drm_i915_mem_destroy_heap {
500         int region;
501 } drm_i915_mem_destroy_heap_t;
502
503 /* Allow X server to configure which pipes to monitor for vblank signals
504  */
505 #define DRM_I915_VBLANK_PIPE_A  1
506 #define DRM_I915_VBLANK_PIPE_B  2
507
508 typedef struct drm_i915_vblank_pipe {
509         int pipe;
510 } drm_i915_vblank_pipe_t;
511
512 /* Schedule buffer swap at given vertical blank:
513  */
514 typedef struct drm_i915_vblank_swap {
515         drm_drawable_t drawable;
516         enum drm_vblank_seq_type seqtype;
517         unsigned int sequence;
518 } drm_i915_vblank_swap_t;
519
520 typedef struct drm_i915_hws_addr {
521         __u64 addr;
522 } drm_i915_hws_addr_t;
523
524 struct drm_i915_gem_init {
525         /**
526          * Beginning offset in the GTT to be managed by the DRM memory
527          * manager.
528          */
529         __u64 gtt_start;
530         /**
531          * Ending offset in the GTT to be managed by the DRM memory
532          * manager.
533          */
534         __u64 gtt_end;
535 };
536
537 struct drm_i915_gem_create {
538         /**
539          * Requested size for the object.
540          *
541          * The (page-aligned) allocated size for the object will be returned.
542          */
543         __u64 size;
544         /**
545          * Returned handle for the object.
546          *
547          * Object handles are nonzero.
548          */
549         __u32 handle;
550         __u32 pad;
551 };
552
553 struct drm_i915_gem_pread {
554         /** Handle for the object being read. */
555         __u32 handle;
556         __u32 pad;
557         /** Offset into the object to read from */
558         __u64 offset;
559         /** Length of data to read */
560         __u64 size;
561         /**
562          * Pointer to write the data into.
563          *
564          * This is a fixed-size type for 32/64 compatibility.
565          */
566         __u64 data_ptr;
567 };
568
569 struct drm_i915_gem_pwrite {
570         /** Handle for the object being written to. */
571         __u32 handle;
572         __u32 pad;
573         /** Offset into the object to write to */
574         __u64 offset;
575         /** Length of data to write */
576         __u64 size;
577         /**
578          * Pointer to read the data from.
579          *
580          * This is a fixed-size type for 32/64 compatibility.
581          */
582         __u64 data_ptr;
583 };
584
585 struct drm_i915_gem_mmap {
586         /** Handle for the object being mapped. */
587         __u32 handle;
588         __u32 pad;
589         /** Offset in the object to map. */
590         __u64 offset;
591         /**
592          * Length of data to map.
593          *
594          * The value will be page-aligned.
595          */
596         __u64 size;
597         /**
598          * Returned pointer the data was mapped at.
599          *
600          * This is a fixed-size type for 32/64 compatibility.
601          */
602         __u64 addr_ptr;
603
604         /**
605          * Flags for extended behaviour.
606          *
607          * Added in version 2.
608          */
609         __u64 flags;
610 #define I915_MMAP_WC 0x1
611 };
612
613 struct drm_i915_gem_mmap_gtt {
614         /** Handle for the object being mapped. */
615         __u32 handle;
616         __u32 pad;
617         /**
618          * Fake offset to use for subsequent mmap call
619          *
620          * This is a fixed-size type for 32/64 compatibility.
621          */
622         __u64 offset;
623 };
624
625 struct drm_i915_gem_set_domain {
626         /** Handle for the object */
627         __u32 handle;
628
629         /** New read domains */
630         __u32 read_domains;
631
632         /** New write domain */
633         __u32 write_domain;
634 };
635
636 struct drm_i915_gem_sw_finish {
637         /** Handle for the object */
638         __u32 handle;
639 };
640
641 struct drm_i915_gem_relocation_entry {
642         /**
643          * Handle of the buffer being pointed to by this relocation entry.
644          *
645          * It's appealing to make this be an index into the mm_validate_entry
646          * list to refer to the buffer, but this allows the driver to create
647          * a relocation list for state buffers and not re-write it per
648          * exec using the buffer.
649          */
650         __u32 target_handle;
651
652         /**
653          * Value to be added to the offset of the target buffer to make up
654          * the relocation entry.
655          */
656         __u32 delta;
657
658         /** Offset in the buffer the relocation entry will be written into */
659         __u64 offset;
660
661         /**
662          * Offset value of the target buffer that the relocation entry was last
663          * written as.
664          *
665          * If the buffer has the same offset as last time, we can skip syncing
666          * and writing the relocation.  This value is written back out by
667          * the execbuffer ioctl when the relocation is written.
668          */
669         __u64 presumed_offset;
670
671         /**
672          * Target memory domains read by this operation.
673          */
674         __u32 read_domains;
675
676         /**
677          * Target memory domains written by this operation.
678          *
679          * Note that only one domain may be written by the whole
680          * execbuffer operation, so that where there are conflicts,
681          * the application will get -EINVAL back.
682          */
683         __u32 write_domain;
684 };
685
686 /** @{
687  * Intel memory domains
688  *
689  * Most of these just align with the various caches in
690  * the system and are used to flush and invalidate as
691  * objects end up cached in different domains.
692  */
693 /** CPU cache */
694 #define I915_GEM_DOMAIN_CPU             0x00000001
695 /** Render cache, used by 2D and 3D drawing */
696 #define I915_GEM_DOMAIN_RENDER          0x00000002
697 /** Sampler cache, used by texture engine */
698 #define I915_GEM_DOMAIN_SAMPLER         0x00000004
699 /** Command queue, used to load batch buffers */
700 #define I915_GEM_DOMAIN_COMMAND         0x00000008
701 /** Instruction cache, used by shader programs */
702 #define I915_GEM_DOMAIN_INSTRUCTION     0x00000010
703 /** Vertex address cache */
704 #define I915_GEM_DOMAIN_VERTEX          0x00000020
705 /** GTT domain - aperture and scanout */
706 #define I915_GEM_DOMAIN_GTT             0x00000040
707 /** WC domain - uncached access */
708 #define I915_GEM_DOMAIN_WC              0x00000080
709 /** @} */
710
711 struct drm_i915_gem_exec_object {
712         /**
713          * User's handle for a buffer to be bound into the GTT for this
714          * operation.
715          */
716         __u32 handle;
717
718         /** Number of relocations to be performed on this buffer */
719         __u32 relocation_count;
720         /**
721          * Pointer to array of struct drm_i915_gem_relocation_entry containing
722          * the relocations to be performed in this buffer.
723          */
724         __u64 relocs_ptr;
725
726         /** Required alignment in graphics aperture */
727         __u64 alignment;
728
729         /**
730          * Returned value of the updated offset of the object, for future
731          * presumed_offset writes.
732          */
733         __u64 offset;
734 };
735
736 struct drm_i915_gem_execbuffer {
737         /**
738          * List of buffers to be validated with their relocations to be
739          * performend on them.
740          *
741          * This is a pointer to an array of struct drm_i915_gem_validate_entry.
742          *
743          * These buffers must be listed in an order such that all relocations
744          * a buffer is performing refer to buffers that have already appeared
745          * in the validate list.
746          */
747         __u64 buffers_ptr;
748         __u32 buffer_count;
749
750         /** Offset in the batchbuffer to start execution from. */
751         __u32 batch_start_offset;
752         /** Bytes used in batchbuffer from batch_start_offset */
753         __u32 batch_len;
754         __u32 DR1;
755         __u32 DR4;
756         __u32 num_cliprects;
757         /** This is a struct drm_clip_rect *cliprects */
758         __u64 cliprects_ptr;
759 };
760
761 struct drm_i915_gem_exec_object2 {
762         /**
763          * User's handle for a buffer to be bound into the GTT for this
764          * operation.
765          */
766         __u32 handle;
767
768         /** Number of relocations to be performed on this buffer */
769         __u32 relocation_count;
770         /**
771          * Pointer to array of struct drm_i915_gem_relocation_entry containing
772          * the relocations to be performed in this buffer.
773          */
774         __u64 relocs_ptr;
775
776         /** Required alignment in graphics aperture */
777         __u64 alignment;
778
779         /**
780          * When the EXEC_OBJECT_PINNED flag is specified this is populated by
781          * the user with the GTT offset at which this object will be pinned.
782          * When the I915_EXEC_NO_RELOC flag is specified this must contain the
783          * presumed_offset of the object.
784          * During execbuffer2 the kernel populates it with the value of the
785          * current GTT offset of the object, for future presumed_offset writes.
786          */
787         __u64 offset;
788
789 #define EXEC_OBJECT_NEEDS_FENCE          (1<<0)
790 #define EXEC_OBJECT_NEEDS_GTT            (1<<1)
791 #define EXEC_OBJECT_WRITE                (1<<2)
792 #define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3)
793 #define EXEC_OBJECT_PINNED               (1<<4)
794 #define EXEC_OBJECT_PAD_TO_SIZE          (1<<5)
795 /* The kernel implicitly tracks GPU activity on all GEM objects, and
796  * synchronises operations with outstanding rendering. This includes
797  * rendering on other devices if exported via dma-buf. However, sometimes
798  * this tracking is too coarse and the user knows better. For example,
799  * if the object is split into non-overlapping ranges shared between different
800  * clients or engines (i.e. suballocating objects), the implicit tracking
801  * by kernel assumes that each operation affects the whole object rather
802  * than an individual range, causing needless synchronisation between clients.
803  * The kernel will also forgo any CPU cache flushes prior to rendering from
804  * the object as the client is expected to be also handling such domain
805  * tracking.
806  *
807  * The kernel maintains the implicit tracking in order to manage resources
808  * used by the GPU - this flag only disables the synchronisation prior to
809  * rendering with this object in this execbuf.
810  *
811  * Opting out of implicit synhronisation requires the user to do its own
812  * explicit tracking to avoid rendering corruption. See, for example,
813  * I915_PARAM_HAS_EXEC_FENCE to order execbufs and execute them asynchronously.
814  */
815 #define EXEC_OBJECT_ASYNC               (1<<6)
816 /* Request that the contents of this execobject be copied into the error
817  * state upon a GPU hang involving this batch for post-mortem debugging.
818  * These buffers are recorded in no particular order as "user" in
819  * /sys/class/drm/cardN/error. Query I915_PARAM_HAS_EXEC_CAPTURE to see
820  * if the kernel supports this flag.
821  */
822 #define EXEC_OBJECT_CAPTURE             (1<<7)
823 /* All remaining bits are MBZ and RESERVED FOR FUTURE USE */
824 #define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_CAPTURE<<1)
825         __u64 flags;
826
827         union {
828                 __u64 rsvd1;
829                 __u64 pad_to_size;
830         };
831         __u64 rsvd2;
832 };
833
834 struct drm_i915_gem_exec_fence {
835         /**
836          * User's handle for a drm_syncobj to wait on or signal.
837          */
838         __u32 handle;
839
840 #define I915_EXEC_FENCE_WAIT            (1<<0)
841 #define I915_EXEC_FENCE_SIGNAL          (1<<1)
842         __u32 flags;
843 };
844
845 struct drm_i915_gem_execbuffer2 {
846         /**
847          * List of gem_exec_object2 structs
848          */
849         __u64 buffers_ptr;
850         __u32 buffer_count;
851
852         /** Offset in the batchbuffer to start execution from. */
853         __u32 batch_start_offset;
854         /** Bytes used in batchbuffer from batch_start_offset */
855         __u32 batch_len;
856         __u32 DR1;
857         __u32 DR4;
858         __u32 num_cliprects;
859         /**
860          * This is a struct drm_clip_rect *cliprects if I915_EXEC_FENCE_ARRAY
861          * is not set.  If I915_EXEC_FENCE_ARRAY is set, then this is a
862          * struct drm_i915_gem_exec_fence *fences.
863          */
864         __u64 cliprects_ptr;
865 #define I915_EXEC_RING_MASK              (7<<0)
866 #define I915_EXEC_DEFAULT                (0<<0)
867 #define I915_EXEC_RENDER                 (1<<0)
868 #define I915_EXEC_BSD                    (2<<0)
869 #define I915_EXEC_BLT                    (3<<0)
870 #define I915_EXEC_VEBOX                  (4<<0)
871
872 /* Used for switching the constants addressing mode on gen4+ RENDER ring.
873  * Gen6+ only supports relative addressing to dynamic state (default) and
874  * absolute addressing.
875  *
876  * These flags are ignored for the BSD and BLT rings.
877  */
878 #define I915_EXEC_CONSTANTS_MASK        (3<<6)
879 #define I915_EXEC_CONSTANTS_REL_GENERAL (0<<6) /* default */
880 #define I915_EXEC_CONSTANTS_ABSOLUTE    (1<<6)
881 #define I915_EXEC_CONSTANTS_REL_SURFACE (2<<6) /* gen4/5 only */
882         __u64 flags;
883         __u64 rsvd1; /* now used for context info */
884         __u64 rsvd2;
885 };
886
887 /** Resets the SO write offset registers for transform feedback on gen7. */
888 #define I915_EXEC_GEN7_SOL_RESET        (1<<8)
889
890 /** Request a privileged ("secure") batch buffer. Note only available for
891  * DRM_ROOT_ONLY | DRM_MASTER processes.
892  */
893 #define I915_EXEC_SECURE                (1<<9)
894
895 /** Inform the kernel that the batch is and will always be pinned. This
896  * negates the requirement for a workaround to be performed to avoid
897  * an incoherent CS (such as can be found on 830/845). If this flag is
898  * not passed, the kernel will endeavour to make sure the batch is
899  * coherent with the CS before execution. If this flag is passed,
900  * userspace assumes the responsibility for ensuring the same.
901  */
902 #define I915_EXEC_IS_PINNED             (1<<10)
903
904 /** Provide a hint to the kernel that the command stream and auxiliary
905  * state buffers already holds the correct presumed addresses and so the
906  * relocation process may be skipped if no buffers need to be moved in
907  * preparation for the execbuffer.
908  */
909 #define I915_EXEC_NO_RELOC              (1<<11)
910
911 /** Use the reloc.handle as an index into the exec object array rather
912  * than as the per-file handle.
913  */
914 #define I915_EXEC_HANDLE_LUT            (1<<12)
915
916 /** Used for switching BSD rings on the platforms with two BSD rings */
917 #define I915_EXEC_BSD_SHIFT      (13)
918 #define I915_EXEC_BSD_MASK       (3 << I915_EXEC_BSD_SHIFT)
919 /* default ping-pong mode */
920 #define I915_EXEC_BSD_DEFAULT    (0 << I915_EXEC_BSD_SHIFT)
921 #define I915_EXEC_BSD_RING1      (1 << I915_EXEC_BSD_SHIFT)
922 #define I915_EXEC_BSD_RING2      (2 << I915_EXEC_BSD_SHIFT)
923
924 /** Tell the kernel that the batchbuffer is processed by
925  *  the resource streamer.
926  */
927 #define I915_EXEC_RESOURCE_STREAMER     (1<<15)
928
929 /* Setting I915_EXEC_FENCE_IN implies that lower_32_bits(rsvd2) represent
930  * a sync_file fd to wait upon (in a nonblocking manner) prior to executing
931  * the batch.
932  *
933  * Returns -EINVAL if the sync_file fd cannot be found.
934  */
935 #define I915_EXEC_FENCE_IN              (1<<16)
936
937 /* Setting I915_EXEC_FENCE_OUT causes the ioctl to return a sync_file fd
938  * in the upper_32_bits(rsvd2) upon success. Ownership of the fd is given
939  * to the caller, and it should be close() after use. (The fd is a regular
940  * file descriptor and will be cleaned up on process termination. It holds
941  * a reference to the request, but nothing else.)
942  *
943  * The sync_file fd can be combined with other sync_file and passed either
944  * to execbuf using I915_EXEC_FENCE_IN, to atomic KMS ioctls (so that a flip
945  * will only occur after this request completes), or to other devices.
946  *
947  * Using I915_EXEC_FENCE_OUT requires use of
948  * DRM_IOCTL_I915_GEM_EXECBUFFER2_WR ioctl so that the result is written
949  * back to userspace. Failure to do so will cause the out-fence to always
950  * be reported as zero, and the real fence fd to be leaked.
951  */
952 #define I915_EXEC_FENCE_OUT             (1<<17)
953
954 /*
955  * Traditionally the execbuf ioctl has only considered the final element in
956  * the execobject[] to be the executable batch. Often though, the client
957  * will known the batch object prior to construction and being able to place
958  * it into the execobject[] array first can simplify the relocation tracking.
959  * Setting I915_EXEC_BATCH_FIRST tells execbuf to use element 0 of the
960  * execobject[] as the * batch instead (the default is to use the last
961  * element).
962  */
963 #define I915_EXEC_BATCH_FIRST           (1<<18)
964
965 /* Setting I915_FENCE_ARRAY implies that num_cliprects and cliprects_ptr
966  * define an array of i915_gem_exec_fence structures which specify a set of
967  * dma fences to wait upon or signal.
968  */
969 #define I915_EXEC_FENCE_ARRAY   (1<<19)
970
971 #define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_ARRAY<<1))
972
973 #define I915_EXEC_CONTEXT_ID_MASK       (0xffffffff)
974 #define i915_execbuffer2_set_context_id(eb2, context) \
975         (eb2).rsvd1 = context & I915_EXEC_CONTEXT_ID_MASK
976 #define i915_execbuffer2_get_context_id(eb2) \
977         ((eb2).rsvd1 & I915_EXEC_CONTEXT_ID_MASK)
978
979 struct drm_i915_gem_pin {
980         /** Handle of the buffer to be pinned. */
981         __u32 handle;
982         __u32 pad;
983
984         /** alignment required within the aperture */
985         __u64 alignment;
986
987         /** Returned GTT offset of the buffer. */
988         __u64 offset;
989 };
990
991 struct drm_i915_gem_unpin {
992         /** Handle of the buffer to be unpinned. */
993         __u32 handle;
994         __u32 pad;
995 };
996
997 struct drm_i915_gem_busy {
998         /** Handle of the buffer to check for busy */
999         __u32 handle;
1000
1001         /** Return busy status
1002          *
1003          * A return of 0 implies that the object is idle (after
1004          * having flushed any pending activity), and a non-zero return that
1005          * the object is still in-flight on the GPU. (The GPU has not yet
1006          * signaled completion for all pending requests that reference the
1007          * object.) An object is guaranteed to become idle eventually (so
1008          * long as no new GPU commands are executed upon it). Due to the
1009          * asynchronous nature of the hardware, an object reported
1010          * as busy may become idle before the ioctl is completed.
1011          *
1012          * Furthermore, if the object is busy, which engine is busy is only
1013          * provided as a guide. There are race conditions which prevent the
1014          * report of which engines are busy from being always accurate.
1015          * However, the converse is not true. If the object is idle, the
1016          * result of the ioctl, that all engines are idle, is accurate.
1017          *
1018          * The returned dword is split into two fields to indicate both
1019          * the engines on which the object is being read, and the
1020          * engine on which it is currently being written (if any).
1021          *
1022          * The low word (bits 0:15) indicate if the object is being written
1023          * to by any engine (there can only be one, as the GEM implicit
1024          * synchronisation rules force writes to be serialised). Only the
1025          * engine for the last write is reported.
1026          *
1027          * The high word (bits 16:31) are a bitmask of which engines are
1028          * currently reading from the object. Multiple engines may be
1029          * reading from the object simultaneously.
1030          *
1031          * The value of each engine is the same as specified in the
1032          * EXECBUFFER2 ioctl, i.e. I915_EXEC_RENDER, I915_EXEC_BSD etc.
1033          * Note I915_EXEC_DEFAULT is a symbolic value and is mapped to
1034          * the I915_EXEC_RENDER engine for execution, and so it is never
1035          * reported as active itself. Some hardware may have parallel
1036          * execution engines, e.g. multiple media engines, which are
1037          * mapped to the same identifier in the EXECBUFFER2 ioctl and
1038          * so are not separately reported for busyness.
1039          *
1040          * Caveat emptor:
1041          * Only the boolean result of this query is reliable; that is whether
1042          * the object is idle or busy. The report of which engines are busy
1043          * should be only used as a heuristic.
1044          */
1045         __u32 busy;
1046 };
1047
1048 /**
1049  * I915_CACHING_NONE
1050  *
1051  * GPU access is not coherent with cpu caches. Default for machines without an
1052  * LLC.
1053  */
1054 #define I915_CACHING_NONE               0
1055 /**
1056  * I915_CACHING_CACHED
1057  *
1058  * GPU access is coherent with cpu caches and furthermore the data is cached in
1059  * last-level caches shared between cpu cores and the gpu GT. Default on
1060  * machines with HAS_LLC.
1061  */
1062 #define I915_CACHING_CACHED             1
1063 /**
1064  * I915_CACHING_DISPLAY
1065  *
1066  * Special GPU caching mode which is coherent with the scanout engines.
1067  * Transparently falls back to I915_CACHING_NONE on platforms where no special
1068  * cache mode (like write-through or gfdt flushing) is available. The kernel
1069  * automatically sets this mode when using a buffer as a scanout target.
1070  * Userspace can manually set this mode to avoid a costly stall and clflush in
1071  * the hotpath of drawing the first frame.
1072  */
1073 #define I915_CACHING_DISPLAY            2
1074
1075 struct drm_i915_gem_caching {
1076         /**
1077          * Handle of the buffer to set/get the caching level of. */
1078         __u32 handle;
1079
1080         /**
1081          * Cacheing level to apply or return value
1082          *
1083          * bits0-15 are for generic caching control (i.e. the above defined
1084          * values). bits16-31 are reserved for platform-specific variations
1085          * (e.g. l3$ caching on gen7). */
1086         __u32 caching;
1087 };
1088
1089 #define I915_TILING_NONE        0
1090 #define I915_TILING_X           1
1091 #define I915_TILING_Y           2
1092 #define I915_TILING_LAST        I915_TILING_Y
1093
1094 #define I915_BIT_6_SWIZZLE_NONE         0
1095 #define I915_BIT_6_SWIZZLE_9            1
1096 #define I915_BIT_6_SWIZZLE_9_10         2
1097 #define I915_BIT_6_SWIZZLE_9_11         3
1098 #define I915_BIT_6_SWIZZLE_9_10_11      4
1099 /* Not seen by userland */
1100 #define I915_BIT_6_SWIZZLE_UNKNOWN      5
1101 /* Seen by userland. */
1102 #define I915_BIT_6_SWIZZLE_9_17         6
1103 #define I915_BIT_6_SWIZZLE_9_10_17      7
1104
1105 struct drm_i915_gem_set_tiling {
1106         /** Handle of the buffer to have its tiling state updated */
1107         __u32 handle;
1108
1109         /**
1110          * Tiling mode for the object (I915_TILING_NONE, I915_TILING_X,
1111          * I915_TILING_Y).
1112          *
1113          * This value is to be set on request, and will be updated by the
1114          * kernel on successful return with the actual chosen tiling layout.
1115          *
1116          * The tiling mode may be demoted to I915_TILING_NONE when the system
1117          * has bit 6 swizzling that can't be managed correctly by GEM.
1118          *
1119          * Buffer contents become undefined when changing tiling_mode.
1120          */
1121         __u32 tiling_mode;
1122
1123         /**
1124          * Stride in bytes for the object when in I915_TILING_X or
1125          * I915_TILING_Y.
1126          */
1127         __u32 stride;
1128
1129         /**
1130          * Returned address bit 6 swizzling required for CPU access through
1131          * mmap mapping.
1132          */
1133         __u32 swizzle_mode;
1134 };
1135
1136 struct drm_i915_gem_get_tiling {
1137         /** Handle of the buffer to get tiling state for. */
1138         __u32 handle;
1139
1140         /**
1141          * Current tiling mode for the object (I915_TILING_NONE, I915_TILING_X,
1142          * I915_TILING_Y).
1143          */
1144         __u32 tiling_mode;
1145
1146         /**
1147          * Returned address bit 6 swizzling required for CPU access through
1148          * mmap mapping.
1149          */
1150         __u32 swizzle_mode;
1151
1152         /**
1153          * Returned address bit 6 swizzling required for CPU access through
1154          * mmap mapping whilst bound.
1155          */
1156         __u32 phys_swizzle_mode;
1157 };
1158
1159 struct drm_i915_gem_get_aperture {
1160         /** Total size of the aperture used by i915_gem_execbuffer, in bytes */
1161         __u64 aper_size;
1162
1163         /**
1164          * Available space in the aperture used by i915_gem_execbuffer, in
1165          * bytes
1166          */
1167         __u64 aper_available_size;
1168 };
1169
1170 struct drm_i915_get_pipe_from_crtc_id {
1171         /** ID of CRTC being requested **/
1172         __u32 crtc_id;
1173
1174         /** pipe of requested CRTC **/
1175         __u32 pipe;
1176 };
1177
1178 #define I915_MADV_WILLNEED 0
1179 #define I915_MADV_DONTNEED 1
1180 #define __I915_MADV_PURGED 2 /* internal state */
1181
1182 struct drm_i915_gem_madvise {
1183         /** Handle of the buffer to change the backing store advice */
1184         __u32 handle;
1185
1186         /* Advice: either the buffer will be needed again in the near future,
1187          *         or wont be and could be discarded under memory pressure.
1188          */
1189         __u32 madv;
1190
1191         /** Whether the backing store still exists. */
1192         __u32 retained;
1193 };
1194
1195 /* flags */
1196 #define I915_OVERLAY_TYPE_MASK          0xff
1197 #define I915_OVERLAY_YUV_PLANAR         0x01
1198 #define I915_OVERLAY_YUV_PACKED         0x02
1199 #define I915_OVERLAY_RGB                0x03
1200
1201 #define I915_OVERLAY_DEPTH_MASK         0xff00
1202 #define I915_OVERLAY_RGB24              0x1000
1203 #define I915_OVERLAY_RGB16              0x2000
1204 #define I915_OVERLAY_RGB15              0x3000
1205 #define I915_OVERLAY_YUV422             0x0100
1206 #define I915_OVERLAY_YUV411             0x0200
1207 #define I915_OVERLAY_YUV420             0x0300
1208 #define I915_OVERLAY_YUV410             0x0400
1209
1210 #define I915_OVERLAY_SWAP_MASK          0xff0000
1211 #define I915_OVERLAY_NO_SWAP            0x000000
1212 #define I915_OVERLAY_UV_SWAP            0x010000
1213 #define I915_OVERLAY_Y_SWAP             0x020000
1214 #define I915_OVERLAY_Y_AND_UV_SWAP      0x030000
1215
1216 #define I915_OVERLAY_FLAGS_MASK         0xff000000
1217 #define I915_OVERLAY_ENABLE             0x01000000
1218
1219 struct drm_intel_overlay_put_image {
1220         /* various flags and src format description */
1221         __u32 flags;
1222         /* source picture description */
1223         __u32 bo_handle;
1224         /* stride values and offsets are in bytes, buffer relative */
1225         __u16 stride_Y; /* stride for packed formats */
1226         __u16 stride_UV;
1227         __u32 offset_Y; /* offset for packet formats */
1228         __u32 offset_U;
1229         __u32 offset_V;
1230         /* in pixels */
1231         __u16 src_width;
1232         __u16 src_height;
1233         /* to compensate the scaling factors for partially covered surfaces */
1234         __u16 src_scan_width;
1235         __u16 src_scan_height;
1236         /* output crtc description */
1237         __u32 crtc_id;
1238         __u16 dst_x;
1239         __u16 dst_y;
1240         __u16 dst_width;
1241         __u16 dst_height;
1242 };
1243
1244 /* flags */
1245 #define I915_OVERLAY_UPDATE_ATTRS       (1<<0)
1246 #define I915_OVERLAY_UPDATE_GAMMA       (1<<1)
1247 #define I915_OVERLAY_DISABLE_DEST_COLORKEY      (1<<2)
1248 struct drm_intel_overlay_attrs {
1249         __u32 flags;
1250         __u32 color_key;
1251         __s32 brightness;
1252         __u32 contrast;
1253         __u32 saturation;
1254         __u32 gamma0;
1255         __u32 gamma1;
1256         __u32 gamma2;
1257         __u32 gamma3;
1258         __u32 gamma4;
1259         __u32 gamma5;
1260 };
1261
1262 /*
1263  * Intel sprite handling
1264  *
1265  * Color keying works with a min/mask/max tuple.  Both source and destination
1266  * color keying is allowed.
1267  *
1268  * Source keying:
1269  * Sprite pixels within the min & max values, masked against the color channels
1270  * specified in the mask field, will be transparent.  All other pixels will
1271  * be displayed on top of the primary plane.  For RGB surfaces, only the min
1272  * and mask fields will be used; ranged compares are not allowed.
1273  *
1274  * Destination keying:
1275  * Primary plane pixels that match the min value, masked against the color
1276  * channels specified in the mask field, will be replaced by corresponding
1277  * pixels from the sprite plane.
1278  *
1279  * Note that source & destination keying are exclusive; only one can be
1280  * active on a given plane.
1281  */
1282
1283 #define I915_SET_COLORKEY_NONE          (1<<0) /* disable color key matching */
1284 #define I915_SET_COLORKEY_DESTINATION   (1<<1)
1285 #define I915_SET_COLORKEY_SOURCE        (1<<2)
1286 struct drm_intel_sprite_colorkey {
1287         __u32 plane_id;
1288         __u32 min_value;
1289         __u32 channel_mask;
1290         __u32 max_value;
1291         __u32 flags;
1292 };
1293
1294 struct drm_i915_gem_wait {
1295         /** Handle of BO we shall wait on */
1296         __u32 bo_handle;
1297         __u32 flags;
1298         /** Number of nanoseconds to wait, Returns time remaining. */
1299         __s64 timeout_ns;
1300 };
1301
1302 struct drm_i915_gem_context_create {
1303         /*  output: id of new context*/
1304         __u32 ctx_id;
1305         __u32 pad;
1306 };
1307
1308 struct drm_i915_gem_context_destroy {
1309         __u32 ctx_id;
1310         __u32 pad;
1311 };
1312
1313 struct drm_i915_reg_read {
1314         /*
1315          * Register offset.
1316          * For 64bit wide registers where the upper 32bits don't immediately
1317          * follow the lower 32bits, the offset of the lower 32bits must
1318          * be specified
1319          */
1320         __u64 offset;
1321 #define I915_REG_READ_8B_WA (1ul << 0)
1322
1323         __u64 val; /* Return value */
1324 };
1325 /* Known registers:
1326  *
1327  * Render engine timestamp - 0x2358 + 64bit - gen7+
1328  * - Note this register returns an invalid value if using the default
1329  *   single instruction 8byte read, in order to workaround that pass
1330  *   flag I915_REG_READ_8B_WA in offset field.
1331  *
1332  */
1333
1334 struct drm_i915_reset_stats {
1335         __u32 ctx_id;
1336         __u32 flags;
1337
1338         /* All resets since boot/module reload, for all contexts */
1339         __u32 reset_count;
1340
1341         /* Number of batches lost when active in GPU, for this context */
1342         __u32 batch_active;
1343
1344         /* Number of batches lost pending for execution, for this context */
1345         __u32 batch_pending;
1346
1347         __u32 pad;
1348 };
1349
1350 struct drm_i915_gem_userptr {
1351         __u64 user_ptr;
1352         __u64 user_size;
1353         __u32 flags;
1354 #define I915_USERPTR_READ_ONLY 0x1
1355 #define I915_USERPTR_UNSYNCHRONIZED 0x80000000
1356         /**
1357          * Returned handle for the object.
1358          *
1359          * Object handles are nonzero.
1360          */
1361         __u32 handle;
1362 };
1363
1364 struct drm_i915_gem_context_param {
1365         __u32 ctx_id;
1366         __u32 size;
1367         __u64 param;
1368 #define I915_CONTEXT_PARAM_BAN_PERIOD   0x1
1369 #define I915_CONTEXT_PARAM_NO_ZEROMAP   0x2
1370 #define I915_CONTEXT_PARAM_GTT_SIZE     0x3
1371 #define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE     0x4
1372 #define I915_CONTEXT_PARAM_BANNABLE     0x5
1373 #define I915_CONTEXT_PARAM_PRIORITY     0x6
1374 #define   I915_CONTEXT_MAX_USER_PRIORITY        1023 /* inclusive */
1375 #define   I915_CONTEXT_DEFAULT_PRIORITY         0
1376 #define   I915_CONTEXT_MIN_USER_PRIORITY        -1023 /* inclusive */
1377         __u64 value;
1378 };
1379
1380 enum drm_i915_oa_format {
1381         I915_OA_FORMAT_A13 = 1,     /* HSW only */
1382         I915_OA_FORMAT_A29,         /* HSW only */
1383         I915_OA_FORMAT_A13_B8_C8,   /* HSW only */
1384         I915_OA_FORMAT_B4_C8,       /* HSW only */
1385         I915_OA_FORMAT_A45_B8_C8,   /* HSW only */
1386         I915_OA_FORMAT_B4_C8_A16,   /* HSW only */
1387         I915_OA_FORMAT_C4_B8,       /* HSW+ */
1388
1389         /* Gen8+ */
1390         I915_OA_FORMAT_A12,
1391         I915_OA_FORMAT_A12_B8_C8,
1392         I915_OA_FORMAT_A32u40_A4u32_B8_C8,
1393
1394         I915_OA_FORMAT_MAX          /* non-ABI */
1395 };
1396
1397 enum drm_i915_perf_property_id {
1398         /**
1399          * Open the stream for a specific context handle (as used with
1400          * execbuffer2). A stream opened for a specific context this way
1401          * won't typically require root privileges.
1402          */
1403         DRM_I915_PERF_PROP_CTX_HANDLE = 1,
1404
1405         /**
1406          * A value of 1 requests the inclusion of raw OA unit reports as
1407          * part of stream samples.
1408          */
1409         DRM_I915_PERF_PROP_SAMPLE_OA,
1410
1411         /**
1412          * The value specifies which set of OA unit metrics should be
1413          * be configured, defining the contents of any OA unit reports.
1414          */
1415         DRM_I915_PERF_PROP_OA_METRICS_SET,
1416
1417         /**
1418          * The value specifies the size and layout of OA unit reports.
1419          */
1420         DRM_I915_PERF_PROP_OA_FORMAT,
1421
1422         /**
1423          * Specifying this property implicitly requests periodic OA unit
1424          * sampling and (at least on Haswell) the sampling frequency is derived
1425          * from this exponent as follows:
1426          *
1427          *   80ns * 2^(period_exponent + 1)
1428          */
1429         DRM_I915_PERF_PROP_OA_EXPONENT,
1430
1431         DRM_I915_PERF_PROP_MAX /* non-ABI */
1432 };
1433
1434 struct drm_i915_perf_open_param {
1435         __u32 flags;
1436 #define I915_PERF_FLAG_FD_CLOEXEC       (1<<0)
1437 #define I915_PERF_FLAG_FD_NONBLOCK      (1<<1)
1438 #define I915_PERF_FLAG_DISABLED         (1<<2)
1439
1440         /** The number of u64 (id, value) pairs */
1441         __u32 num_properties;
1442
1443         /**
1444          * Pointer to array of u64 (id, value) pairs configuring the stream
1445          * to open.
1446          */
1447         __u64 properties_ptr;
1448 };
1449
1450 /**
1451  * Enable data capture for a stream that was either opened in a disabled state
1452  * via I915_PERF_FLAG_DISABLED or was later disabled via
1453  * I915_PERF_IOCTL_DISABLE.
1454  *
1455  * It is intended to be cheaper to disable and enable a stream than it may be
1456  * to close and re-open a stream with the same configuration.
1457  *
1458  * It's undefined whether any pending data for the stream will be lost.
1459  */
1460 #define I915_PERF_IOCTL_ENABLE  _IO('i', 0x0)
1461
1462 /**
1463  * Disable data capture for a stream.
1464  *
1465  * It is an error to try and read a stream that is disabled.
1466  */
1467 #define I915_PERF_IOCTL_DISABLE _IO('i', 0x1)
1468
1469 /**
1470  * Common to all i915 perf records
1471  */
1472 struct drm_i915_perf_record_header {
1473         __u32 type;
1474         __u16 pad;
1475         __u16 size;
1476 };
1477
1478 enum drm_i915_perf_record_type {
1479
1480         /**
1481          * Samples are the work horse record type whose contents are extensible
1482          * and defined when opening an i915 perf stream based on the given
1483          * properties.
1484          *
1485          * Boolean properties following the naming convention
1486          * DRM_I915_PERF_SAMPLE_xyz_PROP request the inclusion of 'xyz' data in
1487          * every sample.
1488          *
1489          * The order of these sample properties given by userspace has no
1490          * affect on the ordering of data within a sample. The order is
1491          * documented here.
1492          *
1493          * struct {
1494          *     struct drm_i915_perf_record_header header;
1495          *
1496          *     { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA
1497          * };
1498          */
1499         DRM_I915_PERF_RECORD_SAMPLE = 1,
1500
1501         /*
1502          * Indicates that one or more OA reports were not written by the
1503          * hardware. This can happen for example if an MI_REPORT_PERF_COUNT
1504          * command collides with periodic sampling - which would be more likely
1505          * at higher sampling frequencies.
1506          */
1507         DRM_I915_PERF_RECORD_OA_REPORT_LOST = 2,
1508
1509         /**
1510          * An error occurred that resulted in all pending OA reports being lost.
1511          */
1512         DRM_I915_PERF_RECORD_OA_BUFFER_LOST = 3,
1513
1514         DRM_I915_PERF_RECORD_MAX /* non-ABI */
1515 };
1516
1517 /**
1518  * Structure to upload perf dynamic configuration into the kernel.
1519  */
1520 struct drm_i915_perf_oa_config {
1521         /** String formatted like "%08x-%04x-%04x-%04x-%012x" */
1522         char uuid[36];
1523
1524         __u32 n_mux_regs;
1525         __u32 n_boolean_regs;
1526         __u32 n_flex_regs;
1527
1528         /*
1529          * These fields are pointers to tuples of u32 values (register
1530          * address, value). For example the expected length of the buffer
1531          * pointed by mux_regs_ptr is (2 * sizeof(u32) * n_mux_regs).
1532          */
1533         __u64 mux_regs_ptr;
1534         __u64 boolean_regs_ptr;
1535         __u64 flex_regs_ptr;
1536 };
1537
1538 #if defined(__cplusplus)
1539 }
1540 #endif
1541
1542 #endif /* _UAPI_I915_DRM_H_ */