i915_drm.h revision bf6cc7dc
122944501Smrg/*
222944501Smrg * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
322944501Smrg * All Rights Reserved.
422944501Smrg *
522944501Smrg * Permission is hereby granted, free of charge, to any person obtaining a
622944501Smrg * copy of this software and associated documentation files (the
722944501Smrg * "Software"), to deal in the Software without restriction, including
822944501Smrg * without limitation the rights to use, copy, modify, merge, publish,
922944501Smrg * distribute, sub license, and/or sell copies of the Software, and to
1022944501Smrg * permit persons to whom the Software is furnished to do so, subject to
1122944501Smrg * the following conditions:
1222944501Smrg *
1322944501Smrg * The above copyright notice and this permission notice (including the
1422944501Smrg * next paragraph) shall be included in all copies or substantial portions
1522944501Smrg * of the Software.
1622944501Smrg *
1722944501Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1822944501Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1922944501Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
2022944501Smrg * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
2122944501Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
2222944501Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
2322944501Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2422944501Smrg *
2522944501Smrg */
2622944501Smrg
2722944501Smrg#ifndef _I915_DRM_H_
2822944501Smrg#define _I915_DRM_H_
2922944501Smrg
30fe517fc9Smrg#include "drm.h"
3122944501Smrg
322ee35494Smrg#if defined(__cplusplus)
332ee35494Smrgextern "C" {
342ee35494Smrg#endif
352ee35494Smrg
3622944501Smrg/* Please note that modifications to all structs defined here are
3722944501Smrg * subject to backwards-compatibility constraints.
3822944501Smrg */
3922944501Smrg
40e88f27b3Smrg/**
41e88f27b3Smrg * DOC: uevents generated by i915 on it's device node
42e88f27b3Smrg *
43e88f27b3Smrg * I915_L3_PARITY_UEVENT - Generated when the driver receives a parity mismatch
44e88f27b3Smrg *	event from the gpu l3 cache. Additional information supplied is ROW,
45e88f27b3Smrg *	BANK, SUBBANK, SLICE of the affected cacheline. Userspace should keep
46e88f27b3Smrg *	track of these events and if a specific cache-line seems to have a
47e88f27b3Smrg *	persistent error remap it with the l3 remapping tool supplied in
48e88f27b3Smrg *	intel-gpu-tools.  The value supplied with the event is always 1.
49e88f27b3Smrg *
50e88f27b3Smrg * I915_ERROR_UEVENT - Generated upon error detection, currently only via
51e88f27b3Smrg *	hangcheck. The error detection event is a good indicator of when things
52e88f27b3Smrg *	began to go badly. The value supplied with the event is a 1 upon error
53e88f27b3Smrg *	detection, and a 0 upon reset completion, signifying no more error
54e88f27b3Smrg *	exists. NOTE: Disabling hangcheck or reset via module parameter will
55e88f27b3Smrg *	cause the related events to not be seen.
56e88f27b3Smrg *
57e88f27b3Smrg * I915_RESET_UEVENT - Event is generated just before an attempt to reset the
58e88f27b3Smrg *	the GPU. The value supplied with the event is always 1. NOTE: Disable
59e88f27b3Smrg *	reset via module parameter will cause this event to not be seen.
60e88f27b3Smrg */
61e88f27b3Smrg#define I915_L3_PARITY_UEVENT		"L3_PARITY_ERROR"
62e88f27b3Smrg#define I915_ERROR_UEVENT		"ERROR"
63e88f27b3Smrg#define I915_RESET_UEVENT		"RESET"
64e88f27b3Smrg
65bf6cc7dcSmrg/*
66bf6cc7dcSmrg * i915_user_extension: Base class for defining a chain of extensions
67bf6cc7dcSmrg *
68bf6cc7dcSmrg * Many interfaces need to grow over time. In most cases we can simply
69bf6cc7dcSmrg * extend the struct and have userspace pass in more data. Another option,
70bf6cc7dcSmrg * as demonstrated by Vulkan's approach to providing extensions for forward
71bf6cc7dcSmrg * and backward compatibility, is to use a list of optional structs to
72bf6cc7dcSmrg * provide those extra details.
73bf6cc7dcSmrg *
74bf6cc7dcSmrg * The key advantage to using an extension chain is that it allows us to
75bf6cc7dcSmrg * redefine the interface more easily than an ever growing struct of
76bf6cc7dcSmrg * increasing complexity, and for large parts of that interface to be
77bf6cc7dcSmrg * entirely optional. The downside is more pointer chasing; chasing across
78bf6cc7dcSmrg * the boundary with pointers encapsulated inside u64.
79bf6cc7dcSmrg */
80bf6cc7dcSmrgstruct i915_user_extension {
81bf6cc7dcSmrg	__u64 next_extension;
82bf6cc7dcSmrg	__u32 name;
83bf6cc7dcSmrg	__u32 flags; /* All undefined bits must be zero. */
84bf6cc7dcSmrg	__u32 rsvd[4]; /* Reserved for future use; must be zero. */
85bf6cc7dcSmrg};
86bf6cc7dcSmrg
872ee35494Smrg/*
882ee35494Smrg * MOCS indexes used for GPU surfaces, defining the cacheability of the
892ee35494Smrg * surface data and the coherency for this data wrt. CPU vs. GPU accesses.
902ee35494Smrg */
912ee35494Smrgenum i915_mocs_table_index {
922ee35494Smrg	/*
932ee35494Smrg	 * Not cached anywhere, coherency between CPU and GPU accesses is
942ee35494Smrg	 * guaranteed.
952ee35494Smrg	 */
962ee35494Smrg	I915_MOCS_UNCACHED,
972ee35494Smrg	/*
982ee35494Smrg	 * Cacheability and coherency controlled by the kernel automatically
992ee35494Smrg	 * based on the DRM_I915_GEM_SET_CACHING IOCTL setting and the current
1002ee35494Smrg	 * usage of the surface (used for display scanout or not).
1012ee35494Smrg	 */
1022ee35494Smrg	I915_MOCS_PTE,
1032ee35494Smrg	/*
1042ee35494Smrg	 * Cached in all GPU caches available on the platform.
1052ee35494Smrg	 * Coherency between CPU and GPU accesses to the surface is not
1062ee35494Smrg	 * guaranteed without extra synchronization.
1072ee35494Smrg	 */
1082ee35494Smrg	I915_MOCS_CACHED,
1092ee35494Smrg};
1102ee35494Smrg
1116260e5d5Smrg/*
1126260e5d5Smrg * Different engines serve different roles, and there may be more than one
1136260e5d5Smrg * engine serving each role. enum drm_i915_gem_engine_class provides a
1146260e5d5Smrg * classification of the role of the engine, which may be used when requesting
1156260e5d5Smrg * operations to be performed on a certain subset of engines, or for providing
1166260e5d5Smrg * information about that group.
1176260e5d5Smrg */
1186260e5d5Smrgenum drm_i915_gem_engine_class {
1196260e5d5Smrg	I915_ENGINE_CLASS_RENDER	= 0,
1206260e5d5Smrg	I915_ENGINE_CLASS_COPY		= 1,
1216260e5d5Smrg	I915_ENGINE_CLASS_VIDEO		= 2,
1226260e5d5Smrg	I915_ENGINE_CLASS_VIDEO_ENHANCE	= 3,
1236260e5d5Smrg
124bf6cc7dcSmrg	/* should be kept compact */
125bf6cc7dcSmrg
1266260e5d5Smrg	I915_ENGINE_CLASS_INVALID	= -1
1276260e5d5Smrg};
1286260e5d5Smrg
1296260e5d5Smrg/**
1306260e5d5Smrg * DOC: perf_events exposed by i915 through /sys/bus/event_sources/drivers/i915
1316260e5d5Smrg *
1326260e5d5Smrg */
1336260e5d5Smrg
1346260e5d5Smrgenum drm_i915_pmu_engine_sample {
1356260e5d5Smrg	I915_SAMPLE_BUSY = 0,
1366260e5d5Smrg	I915_SAMPLE_WAIT = 1,
1376260e5d5Smrg	I915_SAMPLE_SEMA = 2
1386260e5d5Smrg};
1396260e5d5Smrg
1406260e5d5Smrg#define I915_PMU_SAMPLE_BITS (4)
1416260e5d5Smrg#define I915_PMU_SAMPLE_MASK (0xf)
1426260e5d5Smrg#define I915_PMU_SAMPLE_INSTANCE_BITS (8)
1436260e5d5Smrg#define I915_PMU_CLASS_SHIFT \
1446260e5d5Smrg	(I915_PMU_SAMPLE_BITS + I915_PMU_SAMPLE_INSTANCE_BITS)
1456260e5d5Smrg
1466260e5d5Smrg#define __I915_PMU_ENGINE(class, instance, sample) \
1476260e5d5Smrg	((class) << I915_PMU_CLASS_SHIFT | \
1486260e5d5Smrg	(instance) << I915_PMU_SAMPLE_BITS | \
1496260e5d5Smrg	(sample))
1506260e5d5Smrg
1516260e5d5Smrg#define I915_PMU_ENGINE_BUSY(class, instance) \
1526260e5d5Smrg	__I915_PMU_ENGINE(class, instance, I915_SAMPLE_BUSY)
1536260e5d5Smrg
1546260e5d5Smrg#define I915_PMU_ENGINE_WAIT(class, instance) \
1556260e5d5Smrg	__I915_PMU_ENGINE(class, instance, I915_SAMPLE_WAIT)
1566260e5d5Smrg
1576260e5d5Smrg#define I915_PMU_ENGINE_SEMA(class, instance) \
1586260e5d5Smrg	__I915_PMU_ENGINE(class, instance, I915_SAMPLE_SEMA)
1596260e5d5Smrg
1606260e5d5Smrg#define __I915_PMU_OTHER(x) (__I915_PMU_ENGINE(0xff, 0xff, 0xf) + 1 + (x))
1616260e5d5Smrg
1626260e5d5Smrg#define I915_PMU_ACTUAL_FREQUENCY	__I915_PMU_OTHER(0)
1636260e5d5Smrg#define I915_PMU_REQUESTED_FREQUENCY	__I915_PMU_OTHER(1)
1646260e5d5Smrg#define I915_PMU_INTERRUPTS		__I915_PMU_OTHER(2)
1656260e5d5Smrg#define I915_PMU_RC6_RESIDENCY		__I915_PMU_OTHER(3)
1666260e5d5Smrg
1676260e5d5Smrg#define I915_PMU_LAST I915_PMU_RC6_RESIDENCY
1686260e5d5Smrg
16922944501Smrg/* Each region is a minimum of 16k, and there are at most 255 of them.
17022944501Smrg */
17122944501Smrg#define I915_NR_TEX_REGIONS 255	/* table size 2k - maximum due to use
17222944501Smrg				 * of chars for next/prev indices */
17322944501Smrg#define I915_LOG_MIN_TEX_REGION_SIZE 14
17422944501Smrg
17522944501Smrgtypedef struct _drm_i915_init {
17622944501Smrg	enum {
17722944501Smrg		I915_INIT_DMA = 0x01,
17822944501Smrg		I915_CLEANUP_DMA = 0x02,
17922944501Smrg		I915_RESUME_DMA = 0x03
18022944501Smrg	} func;
18122944501Smrg	unsigned int mmio_offset;
18222944501Smrg	int sarea_priv_offset;
18322944501Smrg	unsigned int ring_start;
18422944501Smrg	unsigned int ring_end;
18522944501Smrg	unsigned int ring_size;
18622944501Smrg	unsigned int front_offset;
18722944501Smrg	unsigned int back_offset;
18822944501Smrg	unsigned int depth_offset;
18922944501Smrg	unsigned int w;
19022944501Smrg	unsigned int h;
19122944501Smrg	unsigned int pitch;
19222944501Smrg	unsigned int pitch_bits;
19322944501Smrg	unsigned int back_pitch;
19422944501Smrg	unsigned int depth_pitch;
19522944501Smrg	unsigned int cpp;
19622944501Smrg	unsigned int chipset;
19722944501Smrg} drm_i915_init_t;
19822944501Smrg
19922944501Smrgtypedef struct _drm_i915_sarea {
20022944501Smrg	struct drm_tex_region texList[I915_NR_TEX_REGIONS + 1];
20122944501Smrg	int last_upload;	/* last time texture was uploaded */
20222944501Smrg	int last_enqueue;	/* last time a buffer was enqueued */
20322944501Smrg	int last_dispatch;	/* age of the most recently dispatched buffer */
20422944501Smrg	int ctxOwner;		/* last context to upload state */
20522944501Smrg	int texAge;
20622944501Smrg	int pf_enabled;		/* is pageflipping allowed? */
20722944501Smrg	int pf_active;
20822944501Smrg	int pf_current_page;	/* which buffer is being displayed? */
20922944501Smrg	int perf_boxes;		/* performance boxes to be displayed */
21022944501Smrg	int width, height;      /* screen size in pixels */
21122944501Smrg
21222944501Smrg	drm_handle_t front_handle;
21322944501Smrg	int front_offset;
21422944501Smrg	int front_size;
21522944501Smrg
21622944501Smrg	drm_handle_t back_handle;
21722944501Smrg	int back_offset;
21822944501Smrg	int back_size;
21922944501Smrg
22022944501Smrg	drm_handle_t depth_handle;
22122944501Smrg	int depth_offset;
22222944501Smrg	int depth_size;
22322944501Smrg
22422944501Smrg	drm_handle_t tex_handle;
22522944501Smrg	int tex_offset;
22622944501Smrg	int tex_size;
22722944501Smrg	int log_tex_granularity;
22822944501Smrg	int pitch;
22922944501Smrg	int rotation;           /* 0, 90, 180 or 270 */
23022944501Smrg	int rotated_offset;
23122944501Smrg	int rotated_size;
23222944501Smrg	int rotated_pitch;
23322944501Smrg	int virtualX, virtualY;
23422944501Smrg
23522944501Smrg	unsigned int front_tiled;
23622944501Smrg	unsigned int back_tiled;
23722944501Smrg	unsigned int depth_tiled;
23822944501Smrg	unsigned int rotated_tiled;
23922944501Smrg	unsigned int rotated2_tiled;
24022944501Smrg
24122944501Smrg	int pipeA_x;
24222944501Smrg	int pipeA_y;
24322944501Smrg	int pipeA_w;
24422944501Smrg	int pipeA_h;
24522944501Smrg	int pipeB_x;
24622944501Smrg	int pipeB_y;
24722944501Smrg	int pipeB_w;
24822944501Smrg	int pipeB_h;
24922944501Smrg
25022944501Smrg	/* fill out some space for old userspace triple buffer */
25122944501Smrg	drm_handle_t unused_handle;
25222944501Smrg	__u32 unused1, unused2, unused3;
25322944501Smrg
25422944501Smrg	/* buffer object handles for static buffers. May change
25522944501Smrg	 * over the lifetime of the client.
25622944501Smrg	 */
25722944501Smrg	__u32 front_bo_handle;
25822944501Smrg	__u32 back_bo_handle;
25922944501Smrg	__u32 unused_bo_handle;
26022944501Smrg	__u32 depth_bo_handle;
26122944501Smrg
26222944501Smrg} drm_i915_sarea_t;
26322944501Smrg
26422944501Smrg/* due to userspace building against these headers we need some compat here */
26522944501Smrg#define planeA_x pipeA_x
26622944501Smrg#define planeA_y pipeA_y
26722944501Smrg#define planeA_w pipeA_w
26822944501Smrg#define planeA_h pipeA_h
26922944501Smrg#define planeB_x pipeB_x
27022944501Smrg#define planeB_y pipeB_y
27122944501Smrg#define planeB_w pipeB_w
27222944501Smrg#define planeB_h pipeB_h
27322944501Smrg
27422944501Smrg/* Flags for perf_boxes
27522944501Smrg */
27622944501Smrg#define I915_BOX_RING_EMPTY    0x1
27722944501Smrg#define I915_BOX_FLIP          0x2
27822944501Smrg#define I915_BOX_WAIT          0x4
27922944501Smrg#define I915_BOX_TEXTURE_LOAD  0x8
28022944501Smrg#define I915_BOX_LOST_CONTEXT  0x10
28122944501Smrg
282fe517fc9Smrg/*
283fe517fc9Smrg * i915 specific ioctls.
284fe517fc9Smrg *
285fe517fc9Smrg * The device specific ioctl range is [DRM_COMMAND_BASE, DRM_COMMAND_END) ie
286fe517fc9Smrg * [0x40, 0xa0) (a0 is excluded). The numbers below are defined as offset
287fe517fc9Smrg * against DRM_COMMAND_BASE and should be between [0x0, 0x60).
28822944501Smrg */
28922944501Smrg#define DRM_I915_INIT		0x00
29022944501Smrg#define DRM_I915_FLUSH		0x01
29122944501Smrg#define DRM_I915_FLIP		0x02
29222944501Smrg#define DRM_I915_BATCHBUFFER	0x03
29322944501Smrg#define DRM_I915_IRQ_EMIT	0x04
29422944501Smrg#define DRM_I915_IRQ_WAIT	0x05
29522944501Smrg#define DRM_I915_GETPARAM	0x06
29622944501Smrg#define DRM_I915_SETPARAM	0x07
29722944501Smrg#define DRM_I915_ALLOC		0x08
29822944501Smrg#define DRM_I915_FREE		0x09
29922944501Smrg#define DRM_I915_INIT_HEAP	0x0a
30022944501Smrg#define DRM_I915_CMDBUFFER	0x0b
30122944501Smrg#define DRM_I915_DESTROY_HEAP	0x0c
30222944501Smrg#define DRM_I915_SET_VBLANK_PIPE	0x0d
30322944501Smrg#define DRM_I915_GET_VBLANK_PIPE	0x0e
30422944501Smrg#define DRM_I915_VBLANK_SWAP	0x0f
30522944501Smrg#define DRM_I915_HWS_ADDR	0x11
30622944501Smrg#define DRM_I915_GEM_INIT	0x13
30722944501Smrg#define DRM_I915_GEM_EXECBUFFER	0x14
30822944501Smrg#define DRM_I915_GEM_PIN	0x15
30922944501Smrg#define DRM_I915_GEM_UNPIN	0x16
31022944501Smrg#define DRM_I915_GEM_BUSY	0x17
31122944501Smrg#define DRM_I915_GEM_THROTTLE	0x18
31222944501Smrg#define DRM_I915_GEM_ENTERVT	0x19
31322944501Smrg#define DRM_I915_GEM_LEAVEVT	0x1a
31422944501Smrg#define DRM_I915_GEM_CREATE	0x1b
31522944501Smrg#define DRM_I915_GEM_PREAD	0x1c
31622944501Smrg#define DRM_I915_GEM_PWRITE	0x1d
31722944501Smrg#define DRM_I915_GEM_MMAP	0x1e
31822944501Smrg#define DRM_I915_GEM_SET_DOMAIN	0x1f
31922944501Smrg#define DRM_I915_GEM_SW_FINISH	0x20
32022944501Smrg#define DRM_I915_GEM_SET_TILING	0x21
32122944501Smrg#define DRM_I915_GEM_GET_TILING	0x22
32222944501Smrg#define DRM_I915_GEM_GET_APERTURE 0x23
32322944501Smrg#define DRM_I915_GEM_MMAP_GTT	0x24
32422944501Smrg#define DRM_I915_GET_PIPE_FROM_CRTC_ID	0x25
32522944501Smrg#define DRM_I915_GEM_MADVISE	0x26
32622944501Smrg#define DRM_I915_OVERLAY_PUT_IMAGE	0x27
32722944501Smrg#define DRM_I915_OVERLAY_ATTRS	0x28
32822944501Smrg#define DRM_I915_GEM_EXECBUFFER2	0x29
3292ee35494Smrg#define DRM_I915_GEM_EXECBUFFER2_WR	DRM_I915_GEM_EXECBUFFER2
330e88f27b3Smrg#define DRM_I915_GET_SPRITE_COLORKEY	0x2a
331e88f27b3Smrg#define DRM_I915_SET_SPRITE_COLORKEY	0x2b
332e88f27b3Smrg#define DRM_I915_GEM_WAIT	0x2c
333e88f27b3Smrg#define DRM_I915_GEM_CONTEXT_CREATE	0x2d
334e88f27b3Smrg#define DRM_I915_GEM_CONTEXT_DESTROY	0x2e
335e88f27b3Smrg#define DRM_I915_GEM_SET_CACHING	0x2f
336e88f27b3Smrg#define DRM_I915_GEM_GET_CACHING	0x30
337e88f27b3Smrg#define DRM_I915_REG_READ		0x31
338e88f27b3Smrg#define DRM_I915_GET_RESET_STATS	0x32
339baaff307Smrg#define DRM_I915_GEM_USERPTR		0x33
340424e9256Smrg#define DRM_I915_GEM_CONTEXT_GETPARAM	0x34
341424e9256Smrg#define DRM_I915_GEM_CONTEXT_SETPARAM	0x35
3422ee35494Smrg#define DRM_I915_PERF_OPEN		0x36
3436260e5d5Smrg#define DRM_I915_PERF_ADD_CONFIG	0x37
3446260e5d5Smrg#define DRM_I915_PERF_REMOVE_CONFIG	0x38
3456260e5d5Smrg#define DRM_I915_QUERY			0x39
346bf6cc7dcSmrg/* Must be kept compact -- no holes */
34722944501Smrg
34822944501Smrg#define DRM_IOCTL_I915_INIT		DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
34922944501Smrg#define DRM_IOCTL_I915_FLUSH		DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
35022944501Smrg#define DRM_IOCTL_I915_FLIP		DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLIP)
35122944501Smrg#define DRM_IOCTL_I915_BATCHBUFFER	DRM_IOW( DRM_COMMAND_BASE + DRM_I915_BATCHBUFFER, drm_i915_batchbuffer_t)
35222944501Smrg#define DRM_IOCTL_I915_IRQ_EMIT         DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_IRQ_EMIT, drm_i915_irq_emit_t)
35322944501Smrg#define DRM_IOCTL_I915_IRQ_WAIT         DRM_IOW( DRM_COMMAND_BASE + DRM_I915_IRQ_WAIT, drm_i915_irq_wait_t)
35422944501Smrg#define DRM_IOCTL_I915_GETPARAM         DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GETPARAM, drm_i915_getparam_t)
35522944501Smrg#define DRM_IOCTL_I915_SETPARAM         DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SETPARAM, drm_i915_setparam_t)
35622944501Smrg#define DRM_IOCTL_I915_ALLOC            DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_ALLOC, drm_i915_mem_alloc_t)
35722944501Smrg#define DRM_IOCTL_I915_FREE             DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)
35822944501Smrg#define DRM_IOCTL_I915_INIT_HEAP        DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
35922944501Smrg#define DRM_IOCTL_I915_CMDBUFFER	DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
36022944501Smrg#define DRM_IOCTL_I915_DESTROY_HEAP	DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t)
36122944501Smrg#define DRM_IOCTL_I915_SET_VBLANK_PIPE	DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
36222944501Smrg#define DRM_IOCTL_I915_GET_VBLANK_PIPE	DRM_IOR( DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
36322944501Smrg#define DRM_IOCTL_I915_VBLANK_SWAP	DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_VBLANK_SWAP, drm_i915_vblank_swap_t)
36469dda199Smrg#define DRM_IOCTL_I915_HWS_ADDR		DRM_IOW(DRM_COMMAND_BASE + DRM_I915_HWS_ADDR, struct drm_i915_gem_init)
36522944501Smrg#define DRM_IOCTL_I915_GEM_INIT		DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_INIT, struct drm_i915_gem_init)
36622944501Smrg#define DRM_IOCTL_I915_GEM_EXECBUFFER	DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER, struct drm_i915_gem_execbuffer)
36722944501Smrg#define DRM_IOCTL_I915_GEM_EXECBUFFER2	DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
3682ee35494Smrg#define DRM_IOCTL_I915_GEM_EXECBUFFER2_WR	DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2_WR, struct drm_i915_gem_execbuffer2)
36922944501Smrg#define DRM_IOCTL_I915_GEM_PIN		DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_PIN, struct drm_i915_gem_pin)
37022944501Smrg#define DRM_IOCTL_I915_GEM_UNPIN	DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_UNPIN, struct drm_i915_gem_unpin)
37122944501Smrg#define DRM_IOCTL_I915_GEM_BUSY		DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_BUSY, struct drm_i915_gem_busy)
372e88f27b3Smrg#define DRM_IOCTL_I915_GEM_SET_CACHING		DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_SET_CACHING, struct drm_i915_gem_caching)
373e88f27b3Smrg#define DRM_IOCTL_I915_GEM_GET_CACHING		DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_GET_CACHING, struct drm_i915_gem_caching)
37422944501Smrg#define DRM_IOCTL_I915_GEM_THROTTLE	DRM_IO ( DRM_COMMAND_BASE + DRM_I915_GEM_THROTTLE)
37522944501Smrg#define DRM_IOCTL_I915_GEM_ENTERVT	DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_ENTERVT)
37622944501Smrg#define DRM_IOCTL_I915_GEM_LEAVEVT	DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_LEAVEVT)
37722944501Smrg#define DRM_IOCTL_I915_GEM_CREATE	DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE, struct drm_i915_gem_create)
37822944501Smrg#define DRM_IOCTL_I915_GEM_PREAD	DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PREAD, struct drm_i915_gem_pread)
37922944501Smrg#define DRM_IOCTL_I915_GEM_PWRITE	DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PWRITE, struct drm_i915_gem_pwrite)
38022944501Smrg#define DRM_IOCTL_I915_GEM_MMAP		DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct drm_i915_gem_mmap)
38122944501Smrg#define DRM_IOCTL_I915_GEM_MMAP_GTT	DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_gtt)
38222944501Smrg#define DRM_IOCTL_I915_GEM_SET_DOMAIN	DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SET_DOMAIN, struct drm_i915_gem_set_domain)
38322944501Smrg#define DRM_IOCTL_I915_GEM_SW_FINISH	DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish)
38422944501Smrg#define DRM_IOCTL_I915_GEM_SET_TILING	DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling)
38522944501Smrg#define DRM_IOCTL_I915_GEM_GET_TILING	DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_TILING, struct drm_i915_gem_get_tiling)
38622944501Smrg#define DRM_IOCTL_I915_GEM_GET_APERTURE	DRM_IOR  (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct drm_i915_gem_get_aperture)
38722944501Smrg#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)
38822944501Smrg#define DRM_IOCTL_I915_GEM_MADVISE	DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MADVISE, struct drm_i915_gem_madvise)
389e88f27b3Smrg#define DRM_IOCTL_I915_OVERLAY_PUT_IMAGE	DRM_IOW(DRM_COMMAND_BASE + DRM_I915_OVERLAY_PUT_IMAGE, struct drm_intel_overlay_put_image)
39022944501Smrg#define DRM_IOCTL_I915_OVERLAY_ATTRS	DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_OVERLAY_ATTRS, struct drm_intel_overlay_attrs)
391e88f27b3Smrg#define DRM_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
392b7926a35Schristos#define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
393e88f27b3Smrg#define DRM_IOCTL_I915_GEM_WAIT		DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_WAIT, struct drm_i915_gem_wait)
394e88f27b3Smrg#define DRM_IOCTL_I915_GEM_CONTEXT_CREATE	DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create)
395bf6cc7dcSmrg#define DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT	DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create_ext)
396e88f27b3Smrg#define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY	DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy)
397e88f27b3Smrg#define DRM_IOCTL_I915_REG_READ			DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_REG_READ, struct drm_i915_reg_read)
398e88f27b3Smrg#define DRM_IOCTL_I915_GET_RESET_STATS		DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GET_RESET_STATS, struct drm_i915_reset_stats)
399424e9256Smrg#define DRM_IOCTL_I915_GEM_USERPTR			DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_USERPTR, struct drm_i915_gem_userptr)
400424e9256Smrg#define DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM	DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_GETPARAM, struct drm_i915_gem_context_param)
401424e9256Smrg#define DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM	DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_SETPARAM, struct drm_i915_gem_context_param)
4022ee35494Smrg#define DRM_IOCTL_I915_PERF_OPEN	DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_OPEN, struct drm_i915_perf_open_param)
4036260e5d5Smrg#define DRM_IOCTL_I915_PERF_ADD_CONFIG	DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_ADD_CONFIG, struct drm_i915_perf_oa_config)
4046260e5d5Smrg#define DRM_IOCTL_I915_PERF_REMOVE_CONFIG	DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_REMOVE_CONFIG, __u64)
4056260e5d5Smrg#define DRM_IOCTL_I915_QUERY			DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_QUERY, struct drm_i915_query)
40622944501Smrg
40722944501Smrg/* Allow drivers to submit batchbuffers directly to hardware, relying
40822944501Smrg * on the security mechanisms provided by hardware.
40922944501Smrg */
41022944501Smrgtypedef struct drm_i915_batchbuffer {
41122944501Smrg	int start;		/* agp offset */
41222944501Smrg	int used;		/* nr bytes in use */
41322944501Smrg	int DR1;		/* hw flags for GFX_OP_DRAWRECT_INFO */
41422944501Smrg	int DR4;		/* window origin for GFX_OP_DRAWRECT_INFO */
41522944501Smrg	int num_cliprects;	/* mulitpass with multiple cliprects? */
41622944501Smrg	struct drm_clip_rect *cliprects;	/* pointer to userspace cliprects */
41722944501Smrg} drm_i915_batchbuffer_t;
41822944501Smrg
41922944501Smrg/* As above, but pass a pointer to userspace buffer which can be
42022944501Smrg * validated by the kernel prior to sending to hardware.
42122944501Smrg */
42222944501Smrgtypedef struct _drm_i915_cmdbuffer {
42322944501Smrg	char *buf;	/* pointer to userspace command buffer */
42422944501Smrg	int sz;			/* nr bytes in buf */
42522944501Smrg	int DR1;		/* hw flags for GFX_OP_DRAWRECT_INFO */
42622944501Smrg	int DR4;		/* window origin for GFX_OP_DRAWRECT_INFO */
42722944501Smrg	int num_cliprects;	/* mulitpass with multiple cliprects? */
42822944501Smrg	struct drm_clip_rect *cliprects;	/* pointer to userspace cliprects */
42922944501Smrg} drm_i915_cmdbuffer_t;
43022944501Smrg
43122944501Smrg/* Userspace can request & wait on irq's:
43222944501Smrg */
43322944501Smrgtypedef struct drm_i915_irq_emit {
43422944501Smrg	int *irq_seq;
43522944501Smrg} drm_i915_irq_emit_t;
43622944501Smrg
43722944501Smrgtypedef struct drm_i915_irq_wait {
43822944501Smrg	int irq_seq;
43922944501Smrg} drm_i915_irq_wait_t;
44022944501Smrg
441bf6cc7dcSmrg/*
442bf6cc7dcSmrg * Different modes of per-process Graphics Translation Table,
443bf6cc7dcSmrg * see I915_PARAM_HAS_ALIASING_PPGTT
444bf6cc7dcSmrg */
445bf6cc7dcSmrg#define I915_GEM_PPGTT_NONE	0
446bf6cc7dcSmrg#define I915_GEM_PPGTT_ALIASING	1
447bf6cc7dcSmrg#define I915_GEM_PPGTT_FULL	2
448bf6cc7dcSmrg
44922944501Smrg/* Ioctl to query kernel params:
45022944501Smrg */
45122944501Smrg#define I915_PARAM_IRQ_ACTIVE            1
45222944501Smrg#define I915_PARAM_ALLOW_BATCHBUFFER     2
45322944501Smrg#define I915_PARAM_LAST_DISPATCH         3
45422944501Smrg#define I915_PARAM_CHIPSET_ID            4
45522944501Smrg#define I915_PARAM_HAS_GEM               5
45622944501Smrg#define I915_PARAM_NUM_FENCES_AVAIL      6
45722944501Smrg#define I915_PARAM_HAS_OVERLAY           7
45822944501Smrg#define I915_PARAM_HAS_PAGEFLIPPING	 8
45922944501Smrg#define I915_PARAM_HAS_EXECBUF2          9
46013d1d17dSmrg#define I915_PARAM_HAS_BSD		 10
46169dda199Smrg#define I915_PARAM_HAS_BLT		 11
46269dda199Smrg#define I915_PARAM_HAS_RELAXED_FENCING	 12
463e88f27b3Smrg#define I915_PARAM_HAS_COHERENT_RINGS	 13
464e88f27b3Smrg#define I915_PARAM_HAS_EXEC_CONSTANTS	 14
465e88f27b3Smrg#define I915_PARAM_HAS_RELAXED_DELTA	 15
466e88f27b3Smrg#define I915_PARAM_HAS_GEN7_SOL_RESET	 16
467e88f27b3Smrg#define I915_PARAM_HAS_LLC     	 	 17
468e88f27b3Smrg#define I915_PARAM_HAS_ALIASING_PPGTT	 18
469e88f27b3Smrg#define I915_PARAM_HAS_WAIT_TIMEOUT	 19
470e88f27b3Smrg#define I915_PARAM_HAS_SEMAPHORES	 20
471e88f27b3Smrg#define I915_PARAM_HAS_PRIME_VMAP_FLUSH	 21
472e88f27b3Smrg#define I915_PARAM_HAS_VEBOX		 22
473e88f27b3Smrg#define I915_PARAM_HAS_SECURE_BATCHES	 23
474e88f27b3Smrg#define I915_PARAM_HAS_PINNED_BATCHES	 24
475e88f27b3Smrg#define I915_PARAM_HAS_EXEC_NO_RELOC	 25
476e88f27b3Smrg#define I915_PARAM_HAS_EXEC_HANDLE_LUT   26
477e88f27b3Smrg#define I915_PARAM_HAS_WT     	 	 27
478baaff307Smrg#define I915_PARAM_CMD_PARSER_VERSION	 28
479424e9256Smrg#define I915_PARAM_HAS_COHERENT_PHYS_GTT 29
480424e9256Smrg#define I915_PARAM_MMAP_VERSION          30
481424e9256Smrg#define I915_PARAM_HAS_BSD2		 31
482424e9256Smrg#define I915_PARAM_REVISION              32
483424e9256Smrg#define I915_PARAM_SUBSLICE_TOTAL	 33
484424e9256Smrg#define I915_PARAM_EU_TOTAL		 34
485fe517fc9Smrg#define I915_PARAM_HAS_GPU_RESET	 35
486fe517fc9Smrg#define I915_PARAM_HAS_RESOURCE_STREAMER 36
487fe517fc9Smrg#define I915_PARAM_HAS_EXEC_SOFTPIN	 37
4882ee35494Smrg#define I915_PARAM_HAS_POOLED_EU	 38
4892ee35494Smrg#define I915_PARAM_MIN_EU_IN_POOL	 39
4902ee35494Smrg#define I915_PARAM_MMAP_GTT_VERSION	 40
4912ee35494Smrg
4926260e5d5Smrg/*
4936260e5d5Smrg * Query whether DRM_I915_GEM_EXECBUFFER2 supports user defined execution
4942ee35494Smrg * priorities and the driver will attempt to execute batches in priority order.
4956260e5d5Smrg * The param returns a capability bitmask, nonzero implies that the scheduler
4966260e5d5Smrg * is enabled, with different features present according to the mask.
4976260e5d5Smrg *
4986260e5d5Smrg * The initial priority for each batch is supplied by the context and is
4996260e5d5Smrg * controlled via I915_CONTEXT_PARAM_PRIORITY.
5002ee35494Smrg */
5012ee35494Smrg#define I915_PARAM_HAS_SCHEDULER	 41
5026260e5d5Smrg#define   I915_SCHEDULER_CAP_ENABLED	(1ul << 0)
5036260e5d5Smrg#define   I915_SCHEDULER_CAP_PRIORITY	(1ul << 1)
5046260e5d5Smrg#define   I915_SCHEDULER_CAP_PREEMPTION	(1ul << 2)
505bf6cc7dcSmrg#define   I915_SCHEDULER_CAP_SEMAPHORES	(1ul << 3)
5066260e5d5Smrg
5072ee35494Smrg#define I915_PARAM_HUC_STATUS		 42
5082ee35494Smrg
5092ee35494Smrg/* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to opt-out of
5102ee35494Smrg * synchronisation with implicit fencing on individual objects.
5112ee35494Smrg * See EXEC_OBJECT_ASYNC.
5122ee35494Smrg */
5132ee35494Smrg#define I915_PARAM_HAS_EXEC_ASYNC	 43
5142ee35494Smrg
5152ee35494Smrg/* Query whether DRM_I915_GEM_EXECBUFFER2 supports explicit fence support -
5162ee35494Smrg * both being able to pass in a sync_file fd to wait upon before executing,
5172ee35494Smrg * and being able to return a new sync_file fd that is signaled when the
5182ee35494Smrg * current request is complete. See I915_EXEC_FENCE_IN and I915_EXEC_FENCE_OUT.
5192ee35494Smrg */
5202ee35494Smrg#define I915_PARAM_HAS_EXEC_FENCE	 44
52122944501Smrg
5226260e5d5Smrg/* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to capture
523bf6cc7dcSmrg * user specified buffers for post-mortem debugging of GPU hangs. See
5246260e5d5Smrg * EXEC_OBJECT_CAPTURE.
5256260e5d5Smrg */
5266260e5d5Smrg#define I915_PARAM_HAS_EXEC_CAPTURE	 45
5276260e5d5Smrg
5286260e5d5Smrg#define I915_PARAM_SLICE_MASK		 46
5296260e5d5Smrg
5306260e5d5Smrg/* Assuming it's uniform for each slice, this queries the mask of subslices
5316260e5d5Smrg * per-slice for this system.
5326260e5d5Smrg */
5336260e5d5Smrg#define I915_PARAM_SUBSLICE_MASK	 47
5346260e5d5Smrg
5356260e5d5Smrg/*
5366260e5d5Smrg * Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying the batch buffer
5376260e5d5Smrg * as the first execobject as opposed to the last. See I915_EXEC_BATCH_FIRST.
5386260e5d5Smrg */
5396260e5d5Smrg#define I915_PARAM_HAS_EXEC_BATCH_FIRST	 48
5406260e5d5Smrg
5416260e5d5Smrg/* Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying an array of
5426260e5d5Smrg * drm_i915_gem_exec_fence structures.  See I915_EXEC_FENCE_ARRAY.
5436260e5d5Smrg */
5446260e5d5Smrg#define I915_PARAM_HAS_EXEC_FENCE_ARRAY  49
5456260e5d5Smrg
5466260e5d5Smrg/*
5476260e5d5Smrg * Query whether every context (both per-file default and user created) is
5486260e5d5Smrg * isolated (insofar as HW supports). If this parameter is not true, then
5496260e5d5Smrg * freshly created contexts may inherit values from an existing context,
5506260e5d5Smrg * rather than default HW values. If true, it also ensures (insofar as HW
5516260e5d5Smrg * supports) that all state set by this context will not leak to any other
5526260e5d5Smrg * context.
5536260e5d5Smrg *
5546260e5d5Smrg * As not every engine across every gen support contexts, the returned
5556260e5d5Smrg * value reports the support of context isolation for individual engines by
5566260e5d5Smrg * returning a bitmask of each engine class set to true if that class supports
5576260e5d5Smrg * isolation.
5586260e5d5Smrg */
5596260e5d5Smrg#define I915_PARAM_HAS_CONTEXT_ISOLATION 50
5606260e5d5Smrg
5616260e5d5Smrg/* Frequency of the command streamer timestamps given by the *_TIMESTAMP
5626260e5d5Smrg * registers. This used to be fixed per platform but from CNL onwards, this
5636260e5d5Smrg * might vary depending on the parts.
5646260e5d5Smrg */
5656260e5d5Smrg#define I915_PARAM_CS_TIMESTAMP_FREQUENCY 51
5666260e5d5Smrg
5676260e5d5Smrg/*
5686260e5d5Smrg * Once upon a time we supposed that writes through the GGTT would be
5696260e5d5Smrg * immediately in physical memory (once flushed out of the CPU path). However,
5706260e5d5Smrg * on a few different processors and chipsets, this is not necessarily the case
5716260e5d5Smrg * as the writes appear to be buffered internally. Thus a read of the backing
5726260e5d5Smrg * storage (physical memory) via a different path (with different physical tags
5736260e5d5Smrg * to the indirect write via the GGTT) will see stale values from before
5746260e5d5Smrg * the GGTT write. Inside the kernel, we can for the most part keep track of
5756260e5d5Smrg * the different read/write domains in use (e.g. set-domain), but the assumption
5766260e5d5Smrg * of coherency is baked into the ABI, hence reporting its true state in this
5776260e5d5Smrg * parameter.
5786260e5d5Smrg *
5796260e5d5Smrg * Reports true when writes via mmap_gtt are immediately visible following an
5806260e5d5Smrg * lfence to flush the WCB.
5816260e5d5Smrg *
5826260e5d5Smrg * Reports false when writes via mmap_gtt are indeterminately delayed in an in
5836260e5d5Smrg * internal buffer and are _not_ immediately visible to third parties accessing
5846260e5d5Smrg * directly via mmap_cpu/mmap_wc. Use of mmap_gtt as part of an IPC
5856260e5d5Smrg * communications channel when reporting false is strongly disadvised.
5866260e5d5Smrg */
5876260e5d5Smrg#define I915_PARAM_MMAP_GTT_COHERENT	52
5886260e5d5Smrg
589bf6cc7dcSmrg/* Must be kept compact -- no holes and well documented */
590bf6cc7dcSmrg
59122944501Smrgtypedef struct drm_i915_getparam {
592fe517fc9Smrg	__s32 param;
593fe517fc9Smrg	/*
594fe517fc9Smrg	 * WARNING: Using pointers instead of fixed-size u64 means we need to write
595fe517fc9Smrg	 * compat32 code. Don't repeat this mistake.
596fe517fc9Smrg	 */
59722944501Smrg	int *value;
59822944501Smrg} drm_i915_getparam_t;
59922944501Smrg
60022944501Smrg/* Ioctl to set kernel params:
60122944501Smrg */
60222944501Smrg#define I915_SETPARAM_USE_MI_BATCHBUFFER_START            1
60322944501Smrg#define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY             2
60422944501Smrg#define I915_SETPARAM_ALLOW_BATCHBUFFER                   3
60522944501Smrg#define I915_SETPARAM_NUM_USED_FENCES                     4
606bf6cc7dcSmrg/* Must be kept compact -- no holes */
60722944501Smrg
60822944501Smrgtypedef struct drm_i915_setparam {
60922944501Smrg	int param;
61022944501Smrg	int value;
61122944501Smrg} drm_i915_setparam_t;
61222944501Smrg
61322944501Smrg/* A memory manager for regions of shared memory:
61422944501Smrg */
61522944501Smrg#define I915_MEM_REGION_AGP 1
61622944501Smrg
61722944501Smrgtypedef struct drm_i915_mem_alloc {
61822944501Smrg	int region;
61922944501Smrg	int alignment;
62022944501Smrg	int size;
62122944501Smrg	int *region_offset;	/* offset from start of fb or agp */
62222944501Smrg} drm_i915_mem_alloc_t;
62322944501Smrg
62422944501Smrgtypedef struct drm_i915_mem_free {
62522944501Smrg	int region;
62622944501Smrg	int region_offset;
62722944501Smrg} drm_i915_mem_free_t;
62822944501Smrg
62922944501Smrgtypedef struct drm_i915_mem_init_heap {
63022944501Smrg	int region;
63122944501Smrg	int size;
63222944501Smrg	int start;
63322944501Smrg} drm_i915_mem_init_heap_t;
63422944501Smrg
63522944501Smrg/* Allow memory manager to be torn down and re-initialized (eg on
63622944501Smrg * rotate):
63722944501Smrg */
63822944501Smrgtypedef struct drm_i915_mem_destroy_heap {
63922944501Smrg	int region;
64022944501Smrg} drm_i915_mem_destroy_heap_t;
64122944501Smrg
64222944501Smrg/* Allow X server to configure which pipes to monitor for vblank signals
64322944501Smrg */
64422944501Smrg#define	DRM_I915_VBLANK_PIPE_A	1
64522944501Smrg#define	DRM_I915_VBLANK_PIPE_B	2
64622944501Smrg
64722944501Smrgtypedef struct drm_i915_vblank_pipe {
64822944501Smrg	int pipe;
64922944501Smrg} drm_i915_vblank_pipe_t;
65022944501Smrg
65122944501Smrg/* Schedule buffer swap at given vertical blank:
65222944501Smrg */
65322944501Smrgtypedef struct drm_i915_vblank_swap {
65422944501Smrg	drm_drawable_t drawable;
65522944501Smrg	enum drm_vblank_seq_type seqtype;
65622944501Smrg	unsigned int sequence;
65722944501Smrg} drm_i915_vblank_swap_t;
65822944501Smrg
65922944501Smrgtypedef struct drm_i915_hws_addr {
66022944501Smrg	__u64 addr;
66122944501Smrg} drm_i915_hws_addr_t;
66222944501Smrg
66322944501Smrgstruct drm_i915_gem_init {
66422944501Smrg	/**
66522944501Smrg	 * Beginning offset in the GTT to be managed by the DRM memory
66622944501Smrg	 * manager.
66722944501Smrg	 */
66822944501Smrg	__u64 gtt_start;
66922944501Smrg	/**
67022944501Smrg	 * Ending offset in the GTT to be managed by the DRM memory
67122944501Smrg	 * manager.
67222944501Smrg	 */
67322944501Smrg	__u64 gtt_end;
67422944501Smrg};
67522944501Smrg
67622944501Smrgstruct drm_i915_gem_create {
67722944501Smrg	/**
67822944501Smrg	 * Requested size for the object.
67922944501Smrg	 *
68022944501Smrg	 * The (page-aligned) allocated size for the object will be returned.
68122944501Smrg	 */
68222944501Smrg	__u64 size;
68322944501Smrg	/**
68422944501Smrg	 * Returned handle for the object.
68522944501Smrg	 *
68622944501Smrg	 * Object handles are nonzero.
68722944501Smrg	 */
68822944501Smrg	__u32 handle;
68922944501Smrg	__u32 pad;
69022944501Smrg};
69122944501Smrg
69222944501Smrgstruct drm_i915_gem_pread {
69322944501Smrg	/** Handle for the object being read. */
69422944501Smrg	__u32 handle;
69522944501Smrg	__u32 pad;
69622944501Smrg	/** Offset into the object to read from */
69722944501Smrg	__u64 offset;
69822944501Smrg	/** Length of data to read */
69922944501Smrg	__u64 size;
70022944501Smrg	/**
70122944501Smrg	 * Pointer to write the data into.
70222944501Smrg	 *
70322944501Smrg	 * This is a fixed-size type for 32/64 compatibility.
70422944501Smrg	 */
70522944501Smrg	__u64 data_ptr;
70622944501Smrg};
70722944501Smrg
70822944501Smrgstruct drm_i915_gem_pwrite {
70922944501Smrg	/** Handle for the object being written to. */
71022944501Smrg	__u32 handle;
71122944501Smrg	__u32 pad;
71222944501Smrg	/** Offset into the object to write to */
71322944501Smrg	__u64 offset;
71422944501Smrg	/** Length of data to write */
71522944501Smrg	__u64 size;
71622944501Smrg	/**
71722944501Smrg	 * Pointer to read the data from.
71822944501Smrg	 *
71922944501Smrg	 * This is a fixed-size type for 32/64 compatibility.
72022944501Smrg	 */
72122944501Smrg	__u64 data_ptr;
72222944501Smrg};
72322944501Smrg
72422944501Smrgstruct drm_i915_gem_mmap {
72522944501Smrg	/** Handle for the object being mapped. */
72622944501Smrg	__u32 handle;
72722944501Smrg	__u32 pad;
72822944501Smrg	/** Offset in the object to map. */
72922944501Smrg	__u64 offset;
73022944501Smrg	/**
73122944501Smrg	 * Length of data to map.
73222944501Smrg	 *
73322944501Smrg	 * The value will be page-aligned.
73422944501Smrg	 */
73522944501Smrg	__u64 size;
73622944501Smrg	/**
73722944501Smrg	 * Returned pointer the data was mapped at.
73822944501Smrg	 *
73922944501Smrg	 * This is a fixed-size type for 32/64 compatibility.
74022944501Smrg	 */
74122944501Smrg	__u64 addr_ptr;
742424e9256Smrg
743424e9256Smrg	/**
744424e9256Smrg	 * Flags for extended behaviour.
745424e9256Smrg	 *
746424e9256Smrg	 * Added in version 2.
747424e9256Smrg	 */
748424e9256Smrg	__u64 flags;
749424e9256Smrg#define I915_MMAP_WC 0x1
75022944501Smrg};
75122944501Smrg
75222944501Smrgstruct drm_i915_gem_mmap_gtt {
75322944501Smrg	/** Handle for the object being mapped. */
75422944501Smrg	__u32 handle;
75522944501Smrg	__u32 pad;
75622944501Smrg	/**
75722944501Smrg	 * Fake offset to use for subsequent mmap call
75822944501Smrg	 *
75922944501Smrg	 * This is a fixed-size type for 32/64 compatibility.
76022944501Smrg	 */
76122944501Smrg	__u64 offset;
76222944501Smrg};
76322944501Smrg
76422944501Smrgstruct drm_i915_gem_set_domain {
76522944501Smrg	/** Handle for the object */
76622944501Smrg	__u32 handle;
76722944501Smrg
76822944501Smrg	/** New read domains */
76922944501Smrg	__u32 read_domains;
77022944501Smrg
77122944501Smrg	/** New write domain */
77222944501Smrg	__u32 write_domain;
77322944501Smrg};
77422944501Smrg
77522944501Smrgstruct drm_i915_gem_sw_finish {
77622944501Smrg	/** Handle for the object */
77722944501Smrg	__u32 handle;
77822944501Smrg};
77922944501Smrg
78022944501Smrgstruct drm_i915_gem_relocation_entry {
78122944501Smrg	/**
78222944501Smrg	 * Handle of the buffer being pointed to by this relocation entry.
78322944501Smrg	 *
78422944501Smrg	 * It's appealing to make this be an index into the mm_validate_entry
78522944501Smrg	 * list to refer to the buffer, but this allows the driver to create
78622944501Smrg	 * a relocation list for state buffers and not re-write it per
78722944501Smrg	 * exec using the buffer.
78822944501Smrg	 */
78922944501Smrg	__u32 target_handle;
79022944501Smrg
79122944501Smrg	/**
79222944501Smrg	 * Value to be added to the offset of the target buffer to make up
79322944501Smrg	 * the relocation entry.
79422944501Smrg	 */
79522944501Smrg	__u32 delta;
79622944501Smrg
79722944501Smrg	/** Offset in the buffer the relocation entry will be written into */
79822944501Smrg	__u64 offset;
79922944501Smrg
80022944501Smrg	/**
80122944501Smrg	 * Offset value of the target buffer that the relocation entry was last
80222944501Smrg	 * written as.
80322944501Smrg	 *
80422944501Smrg	 * If the buffer has the same offset as last time, we can skip syncing
80522944501Smrg	 * and writing the relocation.  This value is written back out by
80622944501Smrg	 * the execbuffer ioctl when the relocation is written.
80722944501Smrg	 */
80822944501Smrg	__u64 presumed_offset;
80922944501Smrg
81022944501Smrg	/**
81122944501Smrg	 * Target memory domains read by this operation.
81222944501Smrg	 */
81322944501Smrg	__u32 read_domains;
81422944501Smrg
81522944501Smrg	/**
81622944501Smrg	 * Target memory domains written by this operation.
81722944501Smrg	 *
81822944501Smrg	 * Note that only one domain may be written by the whole
81922944501Smrg	 * execbuffer operation, so that where there are conflicts,
82022944501Smrg	 * the application will get -EINVAL back.
82122944501Smrg	 */
82222944501Smrg	__u32 write_domain;
82322944501Smrg};
82422944501Smrg
82522944501Smrg/** @{
82622944501Smrg * Intel memory domains
82722944501Smrg *
82822944501Smrg * Most of these just align with the various caches in
82922944501Smrg * the system and are used to flush and invalidate as
83022944501Smrg * objects end up cached in different domains.
83122944501Smrg */
83222944501Smrg/** CPU cache */
83322944501Smrg#define I915_GEM_DOMAIN_CPU		0x00000001
83422944501Smrg/** Render cache, used by 2D and 3D drawing */
83522944501Smrg#define I915_GEM_DOMAIN_RENDER		0x00000002
83622944501Smrg/** Sampler cache, used by texture engine */
83722944501Smrg#define I915_GEM_DOMAIN_SAMPLER		0x00000004
83822944501Smrg/** Command queue, used to load batch buffers */
83922944501Smrg#define I915_GEM_DOMAIN_COMMAND		0x00000008
84022944501Smrg/** Instruction cache, used by shader programs */
84122944501Smrg#define I915_GEM_DOMAIN_INSTRUCTION	0x00000010
84222944501Smrg/** Vertex address cache */
84322944501Smrg#define I915_GEM_DOMAIN_VERTEX		0x00000020
84422944501Smrg/** GTT domain - aperture and scanout */
84522944501Smrg#define I915_GEM_DOMAIN_GTT		0x00000040
8466260e5d5Smrg/** WC domain - uncached access */
8476260e5d5Smrg#define I915_GEM_DOMAIN_WC		0x00000080
84822944501Smrg/** @} */
84922944501Smrg
85022944501Smrgstruct drm_i915_gem_exec_object {
85122944501Smrg	/**
85222944501Smrg	 * User's handle for a buffer to be bound into the GTT for this
85322944501Smrg	 * operation.
85422944501Smrg	 */
85522944501Smrg	__u32 handle;
85622944501Smrg
85722944501Smrg	/** Number of relocations to be performed on this buffer */
85822944501Smrg	__u32 relocation_count;
85922944501Smrg	/**
86022944501Smrg	 * Pointer to array of struct drm_i915_gem_relocation_entry containing
86122944501Smrg	 * the relocations to be performed in this buffer.
86222944501Smrg	 */
86322944501Smrg	__u64 relocs_ptr;
86422944501Smrg
86522944501Smrg	/** Required alignment in graphics aperture */
86622944501Smrg	__u64 alignment;
86722944501Smrg
86822944501Smrg	/**
86922944501Smrg	 * Returned value of the updated offset of the object, for future
87022944501Smrg	 * presumed_offset writes.
87122944501Smrg	 */
87222944501Smrg	__u64 offset;
87322944501Smrg};
87422944501Smrg
87522944501Smrgstruct drm_i915_gem_execbuffer {
87622944501Smrg	/**
87722944501Smrg	 * List of buffers to be validated with their relocations to be
87822944501Smrg	 * performend on them.
87922944501Smrg	 *
88022944501Smrg	 * This is a pointer to an array of struct drm_i915_gem_validate_entry.
88122944501Smrg	 *
88222944501Smrg	 * These buffers must be listed in an order such that all relocations
88322944501Smrg	 * a buffer is performing refer to buffers that have already appeared
88422944501Smrg	 * in the validate list.
88522944501Smrg	 */
88622944501Smrg	__u64 buffers_ptr;
88722944501Smrg	__u32 buffer_count;
88822944501Smrg
88922944501Smrg	/** Offset in the batchbuffer to start execution from. */
89022944501Smrg	__u32 batch_start_offset;
89122944501Smrg	/** Bytes used in batchbuffer from batch_start_offset */
89222944501Smrg	__u32 batch_len;
89322944501Smrg	__u32 DR1;
89422944501Smrg	__u32 DR4;
89522944501Smrg	__u32 num_cliprects;
89622944501Smrg	/** This is a struct drm_clip_rect *cliprects */
89722944501Smrg	__u64 cliprects_ptr;
89822944501Smrg};
89922944501Smrg
90022944501Smrgstruct drm_i915_gem_exec_object2 {
90122944501Smrg	/**
90222944501Smrg	 * User's handle for a buffer to be bound into the GTT for this
90322944501Smrg	 * operation.
90422944501Smrg	 */
90522944501Smrg	__u32 handle;
90622944501Smrg
90722944501Smrg	/** Number of relocations to be performed on this buffer */
90822944501Smrg	__u32 relocation_count;
90922944501Smrg	/**
91022944501Smrg	 * Pointer to array of struct drm_i915_gem_relocation_entry containing
91122944501Smrg	 * the relocations to be performed in this buffer.
91222944501Smrg	 */
91322944501Smrg	__u64 relocs_ptr;
91422944501Smrg
91522944501Smrg	/** Required alignment in graphics aperture */
91622944501Smrg	__u64 alignment;
91722944501Smrg
91822944501Smrg	/**
919fe517fc9Smrg	 * When the EXEC_OBJECT_PINNED flag is specified this is populated by
920fe517fc9Smrg	 * the user with the GTT offset at which this object will be pinned.
921fe517fc9Smrg	 * When the I915_EXEC_NO_RELOC flag is specified this must contain the
922fe517fc9Smrg	 * presumed_offset of the object.
923fe517fc9Smrg	 * During execbuffer2 the kernel populates it with the value of the
924fe517fc9Smrg	 * current GTT offset of the object, for future presumed_offset writes.
92522944501Smrg	 */
92622944501Smrg	__u64 offset;
92722944501Smrg
9282ee35494Smrg#define EXEC_OBJECT_NEEDS_FENCE		 (1<<0)
9292ee35494Smrg#define EXEC_OBJECT_NEEDS_GTT		 (1<<1)
9302ee35494Smrg#define EXEC_OBJECT_WRITE		 (1<<2)
931fe517fc9Smrg#define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3)
9322ee35494Smrg#define EXEC_OBJECT_PINNED		 (1<<4)
9332ee35494Smrg#define EXEC_OBJECT_PAD_TO_SIZE		 (1<<5)
9342ee35494Smrg/* The kernel implicitly tracks GPU activity on all GEM objects, and
9352ee35494Smrg * synchronises operations with outstanding rendering. This includes
9362ee35494Smrg * rendering on other devices if exported via dma-buf. However, sometimes
9372ee35494Smrg * this tracking is too coarse and the user knows better. For example,
9382ee35494Smrg * if the object is split into non-overlapping ranges shared between different
9392ee35494Smrg * clients or engines (i.e. suballocating objects), the implicit tracking
9402ee35494Smrg * by kernel assumes that each operation affects the whole object rather
9412ee35494Smrg * than an individual range, causing needless synchronisation between clients.
9422ee35494Smrg * The kernel will also forgo any CPU cache flushes prior to rendering from
9432ee35494Smrg * the object as the client is expected to be also handling such domain
9442ee35494Smrg * tracking.
9452ee35494Smrg *
9462ee35494Smrg * The kernel maintains the implicit tracking in order to manage resources
9472ee35494Smrg * used by the GPU - this flag only disables the synchronisation prior to
9482ee35494Smrg * rendering with this object in this execbuf.
9492ee35494Smrg *
9502ee35494Smrg * Opting out of implicit synhronisation requires the user to do its own
9512ee35494Smrg * explicit tracking to avoid rendering corruption. See, for example,
9522ee35494Smrg * I915_PARAM_HAS_EXEC_FENCE to order execbufs and execute them asynchronously.
9532ee35494Smrg */
9542ee35494Smrg#define EXEC_OBJECT_ASYNC		(1<<6)
9556260e5d5Smrg/* Request that the contents of this execobject be copied into the error
9566260e5d5Smrg * state upon a GPU hang involving this batch for post-mortem debugging.
9576260e5d5Smrg * These buffers are recorded in no particular order as "user" in
9586260e5d5Smrg * /sys/class/drm/cardN/error. Query I915_PARAM_HAS_EXEC_CAPTURE to see
9596260e5d5Smrg * if the kernel supports this flag.
9606260e5d5Smrg */
9616260e5d5Smrg#define EXEC_OBJECT_CAPTURE		(1<<7)
9622ee35494Smrg/* All remaining bits are MBZ and RESERVED FOR FUTURE USE */
9636260e5d5Smrg#define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_CAPTURE<<1)
96422944501Smrg	__u64 flags;
965e88f27b3Smrg
9662ee35494Smrg	union {
9672ee35494Smrg		__u64 rsvd1;
9682ee35494Smrg		__u64 pad_to_size;
9692ee35494Smrg	};
97022944501Smrg	__u64 rsvd2;
97122944501Smrg};
97222944501Smrg
9736260e5d5Smrgstruct drm_i915_gem_exec_fence {
9746260e5d5Smrg	/**
9756260e5d5Smrg	 * User's handle for a drm_syncobj to wait on or signal.
9766260e5d5Smrg	 */
9776260e5d5Smrg	__u32 handle;
9786260e5d5Smrg
9796260e5d5Smrg#define I915_EXEC_FENCE_WAIT            (1<<0)
9806260e5d5Smrg#define I915_EXEC_FENCE_SIGNAL          (1<<1)
9816260e5d5Smrg#define __I915_EXEC_FENCE_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_SIGNAL << 1))
9826260e5d5Smrg	__u32 flags;
9836260e5d5Smrg};
9846260e5d5Smrg
98522944501Smrgstruct drm_i915_gem_execbuffer2 {
98622944501Smrg	/**
98722944501Smrg	 * List of gem_exec_object2 structs
98822944501Smrg	 */
98922944501Smrg	__u64 buffers_ptr;
99022944501Smrg	__u32 buffer_count;
99122944501Smrg
99222944501Smrg	/** Offset in the batchbuffer to start execution from. */
99322944501Smrg	__u32 batch_start_offset;
99422944501Smrg	/** Bytes used in batchbuffer from batch_start_offset */
99522944501Smrg	__u32 batch_len;
99622944501Smrg	__u32 DR1;
99722944501Smrg	__u32 DR4;
99822944501Smrg	__u32 num_cliprects;
9996260e5d5Smrg	/**
10006260e5d5Smrg	 * This is a struct drm_clip_rect *cliprects if I915_EXEC_FENCE_ARRAY
10016260e5d5Smrg	 * is not set.  If I915_EXEC_FENCE_ARRAY is set, then this is a
10026260e5d5Smrg	 * struct drm_i915_gem_exec_fence *fences.
10036260e5d5Smrg	 */
100422944501Smrg	__u64 cliprects_ptr;
1005bf6cc7dcSmrg#define I915_EXEC_RING_MASK              (0x3f)
100669dda199Smrg#define I915_EXEC_DEFAULT                (0<<0)
1007d049871aSmrg#define I915_EXEC_RENDER                 (1<<0)
100869dda199Smrg#define I915_EXEC_BSD                    (2<<0)
100969dda199Smrg#define I915_EXEC_BLT                    (3<<0)
1010e88f27b3Smrg#define I915_EXEC_VEBOX                  (4<<0)
1011e88f27b3Smrg
1012e88f27b3Smrg/* Used for switching the constants addressing mode on gen4+ RENDER ring.
1013e88f27b3Smrg * Gen6+ only supports relative addressing to dynamic state (default) and
1014e88f27b3Smrg * absolute addressing.
1015e88f27b3Smrg *
1016e88f27b3Smrg * These flags are ignored for the BSD and BLT rings.
1017e88f27b3Smrg */
1018e88f27b3Smrg#define I915_EXEC_CONSTANTS_MASK 	(3<<6)
1019e88f27b3Smrg#define I915_EXEC_CONSTANTS_REL_GENERAL (0<<6) /* default */
1020e88f27b3Smrg#define I915_EXEC_CONSTANTS_ABSOLUTE 	(1<<6)
1021e88f27b3Smrg#define I915_EXEC_CONSTANTS_REL_SURFACE (2<<6) /* gen4/5 only */
102213d1d17dSmrg	__u64 flags;
1023e88f27b3Smrg	__u64 rsvd1; /* now used for context info */
102422944501Smrg	__u64 rsvd2;
102522944501Smrg};
102622944501Smrg
1027e88f27b3Smrg/** Resets the SO write offset registers for transform feedback on gen7. */
1028e88f27b3Smrg#define I915_EXEC_GEN7_SOL_RESET	(1<<8)
1029e88f27b3Smrg
1030e88f27b3Smrg/** Request a privileged ("secure") batch buffer. Note only available for
1031e88f27b3Smrg * DRM_ROOT_ONLY | DRM_MASTER processes.
1032e88f27b3Smrg */
1033e88f27b3Smrg#define I915_EXEC_SECURE		(1<<9)
1034e88f27b3Smrg
1035e88f27b3Smrg/** Inform the kernel that the batch is and will always be pinned. This
1036e88f27b3Smrg * negates the requirement for a workaround to be performed to avoid
1037e88f27b3Smrg * an incoherent CS (such as can be found on 830/845). If this flag is
1038e88f27b3Smrg * not passed, the kernel will endeavour to make sure the batch is
1039e88f27b3Smrg * coherent with the CS before execution. If this flag is passed,
1040e88f27b3Smrg * userspace assumes the responsibility for ensuring the same.
1041e88f27b3Smrg */
1042e88f27b3Smrg#define I915_EXEC_IS_PINNED		(1<<10)
1043e88f27b3Smrg
1044baaff307Smrg/** Provide a hint to the kernel that the command stream and auxiliary
1045e88f27b3Smrg * state buffers already holds the correct presumed addresses and so the
1046e88f27b3Smrg * relocation process may be skipped if no buffers need to be moved in
1047e88f27b3Smrg * preparation for the execbuffer.
1048e88f27b3Smrg */
1049e88f27b3Smrg#define I915_EXEC_NO_RELOC		(1<<11)
1050e88f27b3Smrg
1051e88f27b3Smrg/** Use the reloc.handle as an index into the exec object array rather
1052e88f27b3Smrg * than as the per-file handle.
1053e88f27b3Smrg */
1054e88f27b3Smrg#define I915_EXEC_HANDLE_LUT		(1<<12)
1055e88f27b3Smrg
1056424e9256Smrg/** Used for switching BSD rings on the platforms with two BSD rings */
1057fe517fc9Smrg#define I915_EXEC_BSD_SHIFT	 (13)
1058fe517fc9Smrg#define I915_EXEC_BSD_MASK	 (3 << I915_EXEC_BSD_SHIFT)
1059fe517fc9Smrg/* default ping-pong mode */
1060fe517fc9Smrg#define I915_EXEC_BSD_DEFAULT	 (0 << I915_EXEC_BSD_SHIFT)
1061fe517fc9Smrg#define I915_EXEC_BSD_RING1	 (1 << I915_EXEC_BSD_SHIFT)
1062fe517fc9Smrg#define I915_EXEC_BSD_RING2	 (2 << I915_EXEC_BSD_SHIFT)
1063fe517fc9Smrg
1064fe517fc9Smrg/** Tell the kernel that the batchbuffer is processed by
1065fe517fc9Smrg *  the resource streamer.
1066fe517fc9Smrg */
1067fe517fc9Smrg#define I915_EXEC_RESOURCE_STREAMER     (1<<15)
1068424e9256Smrg
10692ee35494Smrg/* Setting I915_EXEC_FENCE_IN implies that lower_32_bits(rsvd2) represent
10702ee35494Smrg * a sync_file fd to wait upon (in a nonblocking manner) prior to executing
10712ee35494Smrg * the batch.
10722ee35494Smrg *
10732ee35494Smrg * Returns -EINVAL if the sync_file fd cannot be found.
10742ee35494Smrg */
10752ee35494Smrg#define I915_EXEC_FENCE_IN		(1<<16)
10762ee35494Smrg
10772ee35494Smrg/* Setting I915_EXEC_FENCE_OUT causes the ioctl to return a sync_file fd
10782ee35494Smrg * in the upper_32_bits(rsvd2) upon success. Ownership of the fd is given
10792ee35494Smrg * to the caller, and it should be close() after use. (The fd is a regular
10802ee35494Smrg * file descriptor and will be cleaned up on process termination. It holds
10812ee35494Smrg * a reference to the request, but nothing else.)
10822ee35494Smrg *
10832ee35494Smrg * The sync_file fd can be combined with other sync_file and passed either
10842ee35494Smrg * to execbuf using I915_EXEC_FENCE_IN, to atomic KMS ioctls (so that a flip
10852ee35494Smrg * will only occur after this request completes), or to other devices.
10862ee35494Smrg *
10872ee35494Smrg * Using I915_EXEC_FENCE_OUT requires use of
10882ee35494Smrg * DRM_IOCTL_I915_GEM_EXECBUFFER2_WR ioctl so that the result is written
10892ee35494Smrg * back to userspace. Failure to do so will cause the out-fence to always
10902ee35494Smrg * be reported as zero, and the real fence fd to be leaked.
10912ee35494Smrg */
10922ee35494Smrg#define I915_EXEC_FENCE_OUT		(1<<17)
10932ee35494Smrg
10946260e5d5Smrg/*
10956260e5d5Smrg * Traditionally the execbuf ioctl has only considered the final element in
10966260e5d5Smrg * the execobject[] to be the executable batch. Often though, the client
10976260e5d5Smrg * will known the batch object prior to construction and being able to place
10986260e5d5Smrg * it into the execobject[] array first can simplify the relocation tracking.
10996260e5d5Smrg * Setting I915_EXEC_BATCH_FIRST tells execbuf to use element 0 of the
11006260e5d5Smrg * execobject[] as the * batch instead (the default is to use the last
11016260e5d5Smrg * element).
11026260e5d5Smrg */
11036260e5d5Smrg#define I915_EXEC_BATCH_FIRST		(1<<18)
11046260e5d5Smrg
11056260e5d5Smrg/* Setting I915_FENCE_ARRAY implies that num_cliprects and cliprects_ptr
11066260e5d5Smrg * define an array of i915_gem_exec_fence structures which specify a set of
11076260e5d5Smrg * dma fences to wait upon or signal.
11086260e5d5Smrg */
11096260e5d5Smrg#define I915_EXEC_FENCE_ARRAY   (1<<19)
11106260e5d5Smrg
11116260e5d5Smrg#define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_ARRAY<<1))
1112e88f27b3Smrg
1113e88f27b3Smrg#define I915_EXEC_CONTEXT_ID_MASK	(0xffffffff)
1114e88f27b3Smrg#define i915_execbuffer2_set_context_id(eb2, context) \
1115e88f27b3Smrg	(eb2).rsvd1 = context & I915_EXEC_CONTEXT_ID_MASK
1116e88f27b3Smrg#define i915_execbuffer2_get_context_id(eb2) \
1117e88f27b3Smrg	((eb2).rsvd1 & I915_EXEC_CONTEXT_ID_MASK)
1118e88f27b3Smrg
111922944501Smrgstruct drm_i915_gem_pin {
112022944501Smrg	/** Handle of the buffer to be pinned. */
112122944501Smrg	__u32 handle;
112222944501Smrg	__u32 pad;
112322944501Smrg
112422944501Smrg	/** alignment required within the aperture */
112522944501Smrg	__u64 alignment;
112622944501Smrg
112722944501Smrg	/** Returned GTT offset of the buffer. */
112822944501Smrg	__u64 offset;
112922944501Smrg};
113022944501Smrg
113122944501Smrgstruct drm_i915_gem_unpin {
113222944501Smrg	/** Handle of the buffer to be unpinned. */
113322944501Smrg	__u32 handle;
113422944501Smrg	__u32 pad;
113522944501Smrg};
113622944501Smrg
113722944501Smrgstruct drm_i915_gem_busy {
113822944501Smrg	/** Handle of the buffer to check for busy */
113922944501Smrg	__u32 handle;
114022944501Smrg
1141fe517fc9Smrg	/** Return busy status
1142fe517fc9Smrg	 *
1143fe517fc9Smrg	 * A return of 0 implies that the object is idle (after
1144fe517fc9Smrg	 * having flushed any pending activity), and a non-zero return that
1145fe517fc9Smrg	 * the object is still in-flight on the GPU. (The GPU has not yet
1146fe517fc9Smrg	 * signaled completion for all pending requests that reference the
11472ee35494Smrg	 * object.) An object is guaranteed to become idle eventually (so
11482ee35494Smrg	 * long as no new GPU commands are executed upon it). Due to the
11492ee35494Smrg	 * asynchronous nature of the hardware, an object reported
11502ee35494Smrg	 * as busy may become idle before the ioctl is completed.
11512ee35494Smrg	 *
11522ee35494Smrg	 * Furthermore, if the object is busy, which engine is busy is only
1153bf6cc7dcSmrg	 * provided as a guide and only indirectly by reporting its class
1154bf6cc7dcSmrg	 * (there may be more than one engine in each class). There are race
1155bf6cc7dcSmrg	 * conditions which prevent the report of which engines are busy from
1156bf6cc7dcSmrg	 * being always accurate.  However, the converse is not true. If the
1157bf6cc7dcSmrg	 * object is idle, the result of the ioctl, that all engines are idle,
1158bf6cc7dcSmrg	 * is accurate.
1159fe517fc9Smrg	 *
1160fe517fc9Smrg	 * The returned dword is split into two fields to indicate both
1161bf6cc7dcSmrg	 * the engine classess on which the object is being read, and the
1162bf6cc7dcSmrg	 * engine class on which it is currently being written (if any).
1163fe517fc9Smrg	 *
1164fe517fc9Smrg	 * The low word (bits 0:15) indicate if the object is being written
1165fe517fc9Smrg	 * to by any engine (there can only be one, as the GEM implicit
1166fe517fc9Smrg	 * synchronisation rules force writes to be serialised). Only the
1167bf6cc7dcSmrg	 * engine class (offset by 1, I915_ENGINE_CLASS_RENDER is reported as
1168bf6cc7dcSmrg	 * 1 not 0 etc) for the last write is reported.
1169fe517fc9Smrg	 *
1170bf6cc7dcSmrg	 * The high word (bits 16:31) are a bitmask of which engines classes
1171bf6cc7dcSmrg	 * are currently reading from the object. Multiple engines may be
1172fe517fc9Smrg	 * reading from the object simultaneously.
1173fe517fc9Smrg	 *
1174bf6cc7dcSmrg	 * The value of each engine class is the same as specified in the
1175bf6cc7dcSmrg	 * I915_CONTEXT_SET_ENGINES parameter and via perf, i.e.
1176bf6cc7dcSmrg	 * I915_ENGINE_CLASS_RENDER, I915_ENGINE_CLASS_COPY, etc.
1177fe517fc9Smrg	 * reported as active itself. Some hardware may have parallel
1178fe517fc9Smrg	 * execution engines, e.g. multiple media engines, which are
1179bf6cc7dcSmrg	 * mapped to the same class identifier and so are not separately
1180bf6cc7dcSmrg	 * reported for busyness.
11812ee35494Smrg	 *
11822ee35494Smrg	 * Caveat emptor:
11832ee35494Smrg	 * Only the boolean result of this query is reliable; that is whether
11842ee35494Smrg	 * the object is idle or busy. The report of which engines are busy
11852ee35494Smrg	 * should be only used as a heuristic.
1186e88f27b3Smrg	 */
118722944501Smrg	__u32 busy;
118822944501Smrg};
118922944501Smrg
1190e88f27b3Smrg/**
1191e88f27b3Smrg * I915_CACHING_NONE
1192e88f27b3Smrg *
1193e88f27b3Smrg * GPU access is not coherent with cpu caches. Default for machines without an
1194e88f27b3Smrg * LLC.
1195e88f27b3Smrg */
1196e88f27b3Smrg#define I915_CACHING_NONE		0
1197e88f27b3Smrg/**
1198e88f27b3Smrg * I915_CACHING_CACHED
1199e88f27b3Smrg *
1200e88f27b3Smrg * GPU access is coherent with cpu caches and furthermore the data is cached in
1201e88f27b3Smrg * last-level caches shared between cpu cores and the gpu GT. Default on
1202e88f27b3Smrg * machines with HAS_LLC.
1203e88f27b3Smrg */
1204e88f27b3Smrg#define I915_CACHING_CACHED		1
1205e88f27b3Smrg/**
1206e88f27b3Smrg * I915_CACHING_DISPLAY
1207e88f27b3Smrg *
1208e88f27b3Smrg * Special GPU caching mode which is coherent with the scanout engines.
1209e88f27b3Smrg * Transparently falls back to I915_CACHING_NONE on platforms where no special
1210e88f27b3Smrg * cache mode (like write-through or gfdt flushing) is available. The kernel
1211e88f27b3Smrg * automatically sets this mode when using a buffer as a scanout target.
1212e88f27b3Smrg * Userspace can manually set this mode to avoid a costly stall and clflush in
1213e88f27b3Smrg * the hotpath of drawing the first frame.
1214e88f27b3Smrg */
1215e88f27b3Smrg#define I915_CACHING_DISPLAY		2
1216e88f27b3Smrg
1217e88f27b3Smrgstruct drm_i915_gem_caching {
1218e88f27b3Smrg	/**
1219e88f27b3Smrg	 * Handle of the buffer to set/get the caching level of. */
1220e88f27b3Smrg	__u32 handle;
1221e88f27b3Smrg
1222e88f27b3Smrg	/**
1223bf6cc7dcSmrg	 * Caching level to apply or return value
1224e88f27b3Smrg	 *
1225e88f27b3Smrg	 * bits0-15 are for generic caching control (i.e. the above defined
1226e88f27b3Smrg	 * values). bits16-31 are reserved for platform-specific variations
1227e88f27b3Smrg	 * (e.g. l3$ caching on gen7). */
1228e88f27b3Smrg	__u32 caching;
1229e88f27b3Smrg};
1230e88f27b3Smrg
123122944501Smrg#define I915_TILING_NONE	0
123222944501Smrg#define I915_TILING_X		1
123322944501Smrg#define I915_TILING_Y		2
12342ee35494Smrg#define I915_TILING_LAST	I915_TILING_Y
123522944501Smrg
123622944501Smrg#define I915_BIT_6_SWIZZLE_NONE		0
123722944501Smrg#define I915_BIT_6_SWIZZLE_9		1
123822944501Smrg#define I915_BIT_6_SWIZZLE_9_10		2
123922944501Smrg#define I915_BIT_6_SWIZZLE_9_11		3
124022944501Smrg#define I915_BIT_6_SWIZZLE_9_10_11	4
124122944501Smrg/* Not seen by userland */
124222944501Smrg#define I915_BIT_6_SWIZZLE_UNKNOWN	5
124322944501Smrg/* Seen by userland. */
124422944501Smrg#define I915_BIT_6_SWIZZLE_9_17		6
124522944501Smrg#define I915_BIT_6_SWIZZLE_9_10_17	7
124622944501Smrg
124722944501Smrgstruct drm_i915_gem_set_tiling {
124822944501Smrg	/** Handle of the buffer to have its tiling state updated */
124922944501Smrg	__u32 handle;
125022944501Smrg
125122944501Smrg	/**
125222944501Smrg	 * Tiling mode for the object (I915_TILING_NONE, I915_TILING_X,
125322944501Smrg	 * I915_TILING_Y).
125422944501Smrg	 *
125522944501Smrg	 * This value is to be set on request, and will be updated by the
125622944501Smrg	 * kernel on successful return with the actual chosen tiling layout.
125722944501Smrg	 *
125822944501Smrg	 * The tiling mode may be demoted to I915_TILING_NONE when the system
125922944501Smrg	 * has bit 6 swizzling that can't be managed correctly by GEM.
126022944501Smrg	 *
126122944501Smrg	 * Buffer contents become undefined when changing tiling_mode.
126222944501Smrg	 */
126322944501Smrg	__u32 tiling_mode;
126422944501Smrg
126522944501Smrg	/**
126622944501Smrg	 * Stride in bytes for the object when in I915_TILING_X or
126722944501Smrg	 * I915_TILING_Y.
126822944501Smrg	 */
126922944501Smrg	__u32 stride;
127022944501Smrg
127122944501Smrg	/**
127222944501Smrg	 * Returned address bit 6 swizzling required for CPU access through
127322944501Smrg	 * mmap mapping.
127422944501Smrg	 */
127522944501Smrg	__u32 swizzle_mode;
127622944501Smrg};
127722944501Smrg
127822944501Smrgstruct drm_i915_gem_get_tiling {
127922944501Smrg	/** Handle of the buffer to get tiling state for. */
128022944501Smrg	__u32 handle;
128122944501Smrg
128222944501Smrg	/**
128322944501Smrg	 * Current tiling mode for the object (I915_TILING_NONE, I915_TILING_X,
128422944501Smrg	 * I915_TILING_Y).
128522944501Smrg	 */
128622944501Smrg	__u32 tiling_mode;
128722944501Smrg
128822944501Smrg	/**
128922944501Smrg	 * Returned address bit 6 swizzling required for CPU access through
129022944501Smrg	 * mmap mapping.
129122944501Smrg	 */
129222944501Smrg	__u32 swizzle_mode;
1293424e9256Smrg
1294424e9256Smrg	/**
1295424e9256Smrg	 * Returned address bit 6 swizzling required for CPU access through
1296424e9256Smrg	 * mmap mapping whilst bound.
1297424e9256Smrg	 */
1298424e9256Smrg	__u32 phys_swizzle_mode;
129922944501Smrg};
130022944501Smrg
130122944501Smrgstruct drm_i915_gem_get_aperture {
130222944501Smrg	/** Total size of the aperture used by i915_gem_execbuffer, in bytes */
130322944501Smrg	__u64 aper_size;
130422944501Smrg
130522944501Smrg	/**
130622944501Smrg	 * Available space in the aperture used by i915_gem_execbuffer, in
130722944501Smrg	 * bytes
130822944501Smrg	 */
130922944501Smrg	__u64 aper_available_size;
131022944501Smrg};
131122944501Smrg
131222944501Smrgstruct drm_i915_get_pipe_from_crtc_id {
131322944501Smrg	/** ID of CRTC being requested **/
131422944501Smrg	__u32 crtc_id;
131522944501Smrg
131622944501Smrg	/** pipe of requested CRTC **/
131722944501Smrg	__u32 pipe;
131822944501Smrg};
131922944501Smrg
132022944501Smrg#define I915_MADV_WILLNEED 0
132122944501Smrg#define I915_MADV_DONTNEED 1
132222944501Smrg#define __I915_MADV_PURGED 2 /* internal state */
132322944501Smrg
132422944501Smrgstruct drm_i915_gem_madvise {
132522944501Smrg	/** Handle of the buffer to change the backing store advice */
132622944501Smrg	__u32 handle;
132722944501Smrg
132822944501Smrg	/* Advice: either the buffer will be needed again in the near future,
132922944501Smrg	 *         or wont be and could be discarded under memory pressure.
133022944501Smrg	 */
133122944501Smrg	__u32 madv;
133222944501Smrg
133322944501Smrg	/** Whether the backing store still exists. */
133422944501Smrg	__u32 retained;
133522944501Smrg};
133622944501Smrg
133722944501Smrg/* flags */
133822944501Smrg#define I915_OVERLAY_TYPE_MASK 		0xff
133922944501Smrg#define I915_OVERLAY_YUV_PLANAR 	0x01
134022944501Smrg#define I915_OVERLAY_YUV_PACKED 	0x02
134122944501Smrg#define I915_OVERLAY_RGB		0x03
134222944501Smrg
134322944501Smrg#define I915_OVERLAY_DEPTH_MASK		0xff00
134422944501Smrg#define I915_OVERLAY_RGB24		0x1000
134522944501Smrg#define I915_OVERLAY_RGB16		0x2000
134622944501Smrg#define I915_OVERLAY_RGB15		0x3000
134722944501Smrg#define I915_OVERLAY_YUV422		0x0100
134822944501Smrg#define I915_OVERLAY_YUV411		0x0200
134922944501Smrg#define I915_OVERLAY_YUV420		0x0300
135022944501Smrg#define I915_OVERLAY_YUV410		0x0400
135122944501Smrg
135222944501Smrg#define I915_OVERLAY_SWAP_MASK		0xff0000
135322944501Smrg#define I915_OVERLAY_NO_SWAP		0x000000
135422944501Smrg#define I915_OVERLAY_UV_SWAP		0x010000
135522944501Smrg#define I915_OVERLAY_Y_SWAP		0x020000
135622944501Smrg#define I915_OVERLAY_Y_AND_UV_SWAP	0x030000
135722944501Smrg
135822944501Smrg#define I915_OVERLAY_FLAGS_MASK		0xff000000
135922944501Smrg#define I915_OVERLAY_ENABLE		0x01000000
136022944501Smrg
136122944501Smrgstruct drm_intel_overlay_put_image {
136222944501Smrg	/* various flags and src format description */
136322944501Smrg	__u32 flags;
136422944501Smrg	/* source picture description */
136522944501Smrg	__u32 bo_handle;
136622944501Smrg	/* stride values and offsets are in bytes, buffer relative */
136722944501Smrg	__u16 stride_Y; /* stride for packed formats */
136822944501Smrg	__u16 stride_UV;
136922944501Smrg	__u32 offset_Y; /* offset for packet formats */
137022944501Smrg	__u32 offset_U;
137122944501Smrg	__u32 offset_V;
137222944501Smrg	/* in pixels */
137322944501Smrg	__u16 src_width;
137422944501Smrg	__u16 src_height;
137522944501Smrg	/* to compensate the scaling factors for partially covered surfaces */
137622944501Smrg	__u16 src_scan_width;
137722944501Smrg	__u16 src_scan_height;
137822944501Smrg	/* output crtc description */
137922944501Smrg	__u32 crtc_id;
138022944501Smrg	__u16 dst_x;
138122944501Smrg	__u16 dst_y;
138222944501Smrg	__u16 dst_width;
138322944501Smrg	__u16 dst_height;
138422944501Smrg};
138522944501Smrg
138622944501Smrg/* flags */
138722944501Smrg#define I915_OVERLAY_UPDATE_ATTRS	(1<<0)
138822944501Smrg#define I915_OVERLAY_UPDATE_GAMMA	(1<<1)
1389fe517fc9Smrg#define I915_OVERLAY_DISABLE_DEST_COLORKEY	(1<<2)
139022944501Smrgstruct drm_intel_overlay_attrs {
139122944501Smrg	__u32 flags;
139222944501Smrg	__u32 color_key;
139322944501Smrg	__s32 brightness;
139422944501Smrg	__u32 contrast;
139522944501Smrg	__u32 saturation;
139622944501Smrg	__u32 gamma0;
139722944501Smrg	__u32 gamma1;
139822944501Smrg	__u32 gamma2;
139922944501Smrg	__u32 gamma3;
140022944501Smrg	__u32 gamma4;
140122944501Smrg	__u32 gamma5;
140222944501Smrg};
140322944501Smrg
1404e88f27b3Smrg/*
1405e88f27b3Smrg * Intel sprite handling
1406e88f27b3Smrg *
1407e88f27b3Smrg * Color keying works with a min/mask/max tuple.  Both source and destination
1408e88f27b3Smrg * color keying is allowed.
1409e88f27b3Smrg *
1410e88f27b3Smrg * Source keying:
1411e88f27b3Smrg * Sprite pixels within the min & max values, masked against the color channels
1412e88f27b3Smrg * specified in the mask field, will be transparent.  All other pixels will
1413e88f27b3Smrg * be displayed on top of the primary plane.  For RGB surfaces, only the min
1414e88f27b3Smrg * and mask fields will be used; ranged compares are not allowed.
1415e88f27b3Smrg *
1416e88f27b3Smrg * Destination keying:
1417e88f27b3Smrg * Primary plane pixels that match the min value, masked against the color
1418e88f27b3Smrg * channels specified in the mask field, will be replaced by corresponding
1419e88f27b3Smrg * pixels from the sprite plane.
1420e88f27b3Smrg *
1421e88f27b3Smrg * Note that source & destination keying are exclusive; only one can be
1422e88f27b3Smrg * active on a given plane.
1423e88f27b3Smrg */
1424e88f27b3Smrg
14256260e5d5Smrg#define I915_SET_COLORKEY_NONE		(1<<0) /* Deprecated. Instead set
14266260e5d5Smrg						* flags==0 to disable colorkeying.
14276260e5d5Smrg						*/
1428e88f27b3Smrg#define I915_SET_COLORKEY_DESTINATION	(1<<1)
1429e88f27b3Smrg#define I915_SET_COLORKEY_SOURCE	(1<<2)
1430e88f27b3Smrgstruct drm_intel_sprite_colorkey {
1431e88f27b3Smrg	__u32 plane_id;
1432e88f27b3Smrg	__u32 min_value;
1433e88f27b3Smrg	__u32 channel_mask;
1434e88f27b3Smrg	__u32 max_value;
1435e88f27b3Smrg	__u32 flags;
1436e88f27b3Smrg};
1437e88f27b3Smrg
1438e88f27b3Smrgstruct drm_i915_gem_wait {
1439e88f27b3Smrg	/** Handle of BO we shall wait on */
1440e88f27b3Smrg	__u32 bo_handle;
1441e88f27b3Smrg	__u32 flags;
1442e88f27b3Smrg	/** Number of nanoseconds to wait, Returns time remaining. */
1443e88f27b3Smrg	__s64 timeout_ns;
1444e88f27b3Smrg};
1445e88f27b3Smrg
1446e88f27b3Smrgstruct drm_i915_gem_context_create {
1447bf6cc7dcSmrg	__u32 ctx_id; /* output: id of new context*/
1448e88f27b3Smrg	__u32 pad;
1449e88f27b3Smrg};
1450e88f27b3Smrg
1451bf6cc7dcSmrgstruct drm_i915_gem_context_create_ext {
1452bf6cc7dcSmrg	__u32 ctx_id; /* output: id of new context*/
1453bf6cc7dcSmrg	__u32 flags;
1454bf6cc7dcSmrg#define I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS	(1u << 0)
1455bf6cc7dcSmrg#define I915_CONTEXT_CREATE_FLAGS_UNKNOWN \
1456bf6cc7dcSmrg	(-(I915_CONTEXT_CREATE_FLAGS_USE_EXTENSIONS << 1))
1457bf6cc7dcSmrg	__u64 extensions;
1458bf6cc7dcSmrg};
1459bf6cc7dcSmrg
1460bf6cc7dcSmrgstruct drm_i915_gem_context_param {
1461bf6cc7dcSmrg	__u32 ctx_id;
1462bf6cc7dcSmrg	__u32 size;
1463bf6cc7dcSmrg	__u64 param;
1464bf6cc7dcSmrg#define I915_CONTEXT_PARAM_BAN_PERIOD	0x1
1465bf6cc7dcSmrg#define I915_CONTEXT_PARAM_NO_ZEROMAP	0x2
1466bf6cc7dcSmrg#define I915_CONTEXT_PARAM_GTT_SIZE	0x3
1467bf6cc7dcSmrg#define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE	0x4
1468bf6cc7dcSmrg#define I915_CONTEXT_PARAM_BANNABLE	0x5
1469bf6cc7dcSmrg#define I915_CONTEXT_PARAM_PRIORITY	0x6
1470bf6cc7dcSmrg#define   I915_CONTEXT_MAX_USER_PRIORITY	1023 /* inclusive */
1471bf6cc7dcSmrg#define   I915_CONTEXT_DEFAULT_PRIORITY		0
1472bf6cc7dcSmrg#define   I915_CONTEXT_MIN_USER_PRIORITY	-1023 /* inclusive */
1473bf6cc7dcSmrg	/*
1474bf6cc7dcSmrg	 * When using the following param, value should be a pointer to
1475bf6cc7dcSmrg	 * drm_i915_gem_context_param_sseu.
1476bf6cc7dcSmrg	 */
1477bf6cc7dcSmrg#define I915_CONTEXT_PARAM_SSEU		0x7
1478bf6cc7dcSmrg
1479bf6cc7dcSmrg/*
1480bf6cc7dcSmrg * Not all clients may want to attempt automatic recover of a context after
1481bf6cc7dcSmrg * a hang (for example, some clients may only submit very small incremental
1482bf6cc7dcSmrg * batches relying on known logical state of previous batches which will never
1483bf6cc7dcSmrg * recover correctly and each attempt will hang), and so would prefer that
1484bf6cc7dcSmrg * the context is forever banned instead.
1485bf6cc7dcSmrg *
1486bf6cc7dcSmrg * If set to false (0), after a reset, subsequent (and in flight) rendering
1487bf6cc7dcSmrg * from this context is discarded, and the client will need to create a new
1488bf6cc7dcSmrg * context to use instead.
1489bf6cc7dcSmrg *
1490bf6cc7dcSmrg * If set to true (1), the kernel will automatically attempt to recover the
1491bf6cc7dcSmrg * context by skipping the hanging batch and executing the next batch starting
1492bf6cc7dcSmrg * from the default context state (discarding the incomplete logical context
1493bf6cc7dcSmrg * state lost due to the reset).
1494bf6cc7dcSmrg *
1495bf6cc7dcSmrg * On creation, all new contexts are marked as recoverable.
1496bf6cc7dcSmrg */
1497bf6cc7dcSmrg#define I915_CONTEXT_PARAM_RECOVERABLE	0x8
1498bf6cc7dcSmrg/* Must be kept compact -- no holes and well documented */
1499bf6cc7dcSmrg
1500bf6cc7dcSmrg	__u64 value;
1501bf6cc7dcSmrg};
1502bf6cc7dcSmrg
1503bf6cc7dcSmrg/**
1504bf6cc7dcSmrg * Context SSEU programming
1505bf6cc7dcSmrg *
1506bf6cc7dcSmrg * It may be necessary for either functional or performance reason to configure
1507bf6cc7dcSmrg * a context to run with a reduced number of SSEU (where SSEU stands for Slice/
1508bf6cc7dcSmrg * Sub-slice/EU).
1509bf6cc7dcSmrg *
1510bf6cc7dcSmrg * This is done by configuring SSEU configuration using the below
1511bf6cc7dcSmrg * @struct drm_i915_gem_context_param_sseu for every supported engine which
1512bf6cc7dcSmrg * userspace intends to use.
1513bf6cc7dcSmrg *
1514bf6cc7dcSmrg * Not all GPUs or engines support this functionality in which case an error
1515bf6cc7dcSmrg * code -ENODEV will be returned.
1516bf6cc7dcSmrg *
1517bf6cc7dcSmrg * Also, flexibility of possible SSEU configuration permutations varies between
1518bf6cc7dcSmrg * GPU generations and software imposed limitations. Requesting such a
1519bf6cc7dcSmrg * combination will return an error code of -EINVAL.
1520bf6cc7dcSmrg *
1521bf6cc7dcSmrg * NOTE: When perf/OA is active the context's SSEU configuration is ignored in
1522bf6cc7dcSmrg * favour of a single global setting.
1523bf6cc7dcSmrg */
1524bf6cc7dcSmrgstruct drm_i915_gem_context_param_sseu {
1525bf6cc7dcSmrg	/*
1526bf6cc7dcSmrg	 * Engine class & instance to be configured or queried.
1527bf6cc7dcSmrg	 */
1528bf6cc7dcSmrg	__u16 engine_class;
1529bf6cc7dcSmrg	__u16 engine_instance;
1530bf6cc7dcSmrg
1531bf6cc7dcSmrg	/*
1532bf6cc7dcSmrg	 * Unused for now. Must be cleared to zero.
1533bf6cc7dcSmrg	 */
1534bf6cc7dcSmrg	__u32 flags;
1535bf6cc7dcSmrg
1536bf6cc7dcSmrg	/*
1537bf6cc7dcSmrg	 * Mask of slices to enable for the context. Valid values are a subset
1538bf6cc7dcSmrg	 * of the bitmask value returned for I915_PARAM_SLICE_MASK.
1539bf6cc7dcSmrg	 */
1540bf6cc7dcSmrg	__u64 slice_mask;
1541bf6cc7dcSmrg
1542bf6cc7dcSmrg	/*
1543bf6cc7dcSmrg	 * Mask of subslices to enable for the context. Valid values are a
1544bf6cc7dcSmrg	 * subset of the bitmask value return by I915_PARAM_SUBSLICE_MASK.
1545bf6cc7dcSmrg	 */
1546bf6cc7dcSmrg	__u64 subslice_mask;
1547bf6cc7dcSmrg
1548bf6cc7dcSmrg	/*
1549bf6cc7dcSmrg	 * Minimum/Maximum number of EUs to enable per subslice for the
1550bf6cc7dcSmrg	 * context. min_eus_per_subslice must be inferior or equal to
1551bf6cc7dcSmrg	 * max_eus_per_subslice.
1552bf6cc7dcSmrg	 */
1553bf6cc7dcSmrg	__u16 min_eus_per_subslice;
1554bf6cc7dcSmrg	__u16 max_eus_per_subslice;
1555bf6cc7dcSmrg
1556bf6cc7dcSmrg	/*
1557bf6cc7dcSmrg	 * Unused for now. Must be cleared to zero.
1558bf6cc7dcSmrg	 */
1559bf6cc7dcSmrg	__u32 rsvd;
1560bf6cc7dcSmrg};
1561bf6cc7dcSmrg
1562bf6cc7dcSmrgstruct drm_i915_gem_context_create_ext_setparam {
1563bf6cc7dcSmrg#define I915_CONTEXT_CREATE_EXT_SETPARAM 0
1564bf6cc7dcSmrg	struct i915_user_extension base;
1565bf6cc7dcSmrg	struct drm_i915_gem_context_param param;
1566bf6cc7dcSmrg};
1567bf6cc7dcSmrg
1568e88f27b3Smrgstruct drm_i915_gem_context_destroy {
1569e88f27b3Smrg	__u32 ctx_id;
1570e88f27b3Smrg	__u32 pad;
1571e88f27b3Smrg};
1572e88f27b3Smrg
1573bf6cc7dcSmrg/*
1574bf6cc7dcSmrg * DRM_I915_GEM_VM_CREATE -
1575bf6cc7dcSmrg *
1576bf6cc7dcSmrg * Create a new virtual memory address space (ppGTT) for use within a context
1577bf6cc7dcSmrg * on the same file. Extensions can be provided to configure exactly how the
1578bf6cc7dcSmrg * address space is setup upon creation.
1579bf6cc7dcSmrg *
1580bf6cc7dcSmrg * The id of new VM (bound to the fd) for use with I915_CONTEXT_PARAM_VM is
1581bf6cc7dcSmrg * returned in the outparam @id.
1582bf6cc7dcSmrg *
1583bf6cc7dcSmrg * No flags are defined, with all bits reserved and must be zero.
1584bf6cc7dcSmrg *
1585bf6cc7dcSmrg * An extension chain maybe provided, starting with @extensions, and terminated
1586bf6cc7dcSmrg * by the @next_extension being 0. Currently, no extensions are defined.
1587bf6cc7dcSmrg *
1588bf6cc7dcSmrg * DRM_I915_GEM_VM_DESTROY -
1589bf6cc7dcSmrg *
1590bf6cc7dcSmrg * Destroys a previously created VM id, specified in @id.
1591bf6cc7dcSmrg *
1592bf6cc7dcSmrg * No extensions or flags are allowed currently, and so must be zero.
1593bf6cc7dcSmrg */
1594bf6cc7dcSmrgstruct drm_i915_gem_vm_control {
1595bf6cc7dcSmrg	__u64 extensions;
1596bf6cc7dcSmrg	__u32 flags;
1597bf6cc7dcSmrg	__u32 vm_id;
1598bf6cc7dcSmrg};
1599bf6cc7dcSmrg
1600e88f27b3Smrgstruct drm_i915_reg_read {
1601fe517fc9Smrg	/*
1602fe517fc9Smrg	 * Register offset.
1603fe517fc9Smrg	 * For 64bit wide registers where the upper 32bits don't immediately
1604fe517fc9Smrg	 * follow the lower 32bits, the offset of the lower 32bits must
1605fe517fc9Smrg	 * be specified
1606fe517fc9Smrg	 */
1607e88f27b3Smrg	__u64 offset;
16086260e5d5Smrg#define I915_REG_READ_8B_WA (1ul << 0)
16096260e5d5Smrg
1610e88f27b3Smrg	__u64 val; /* Return value */
1611e88f27b3Smrg};
1612bf6cc7dcSmrg
1613fe517fc9Smrg/* Known registers:
1614fe517fc9Smrg *
1615fe517fc9Smrg * Render engine timestamp - 0x2358 + 64bit - gen7+
1616fe517fc9Smrg * - Note this register returns an invalid value if using the default
16176260e5d5Smrg *   single instruction 8byte read, in order to workaround that pass
16186260e5d5Smrg *   flag I915_REG_READ_8B_WA in offset field.
1619fe517fc9Smrg *
1620fe517fc9Smrg */
1621e88f27b3Smrg
1622e88f27b3Smrgstruct drm_i915_reset_stats {
1623e88f27b3Smrg	__u32 ctx_id;
1624e88f27b3Smrg	__u32 flags;
1625e88f27b3Smrg
1626e88f27b3Smrg	/* All resets since boot/module reload, for all contexts */
1627e88f27b3Smrg	__u32 reset_count;
1628e88f27b3Smrg
1629e88f27b3Smrg	/* Number of batches lost when active in GPU, for this context */
1630e88f27b3Smrg	__u32 batch_active;
1631e88f27b3Smrg
1632e88f27b3Smrg	/* Number of batches lost pending for execution, for this context */
1633e88f27b3Smrg	__u32 batch_pending;
1634e88f27b3Smrg
1635e88f27b3Smrg	__u32 pad;
1636e88f27b3Smrg};
1637e88f27b3Smrg
1638baaff307Smrgstruct drm_i915_gem_userptr {
1639baaff307Smrg	__u64 user_ptr;
1640baaff307Smrg	__u64 user_size;
1641baaff307Smrg	__u32 flags;
1642baaff307Smrg#define I915_USERPTR_READ_ONLY 0x1
1643baaff307Smrg#define I915_USERPTR_UNSYNCHRONIZED 0x80000000
1644baaff307Smrg	/**
1645424e9256Smrg	 * Returned handle for the object.
1646424e9256Smrg	 *
1647424e9256Smrg	 * Object handles are nonzero.
1648424e9256Smrg	 */
1649baaff307Smrg	__u32 handle;
1650baaff307Smrg};
1651baaff307Smrg
16522ee35494Smrgenum drm_i915_oa_format {
16536260e5d5Smrg	I915_OA_FORMAT_A13 = 1,	    /* HSW only */
16546260e5d5Smrg	I915_OA_FORMAT_A29,	    /* HSW only */
16556260e5d5Smrg	I915_OA_FORMAT_A13_B8_C8,   /* HSW only */
16566260e5d5Smrg	I915_OA_FORMAT_B4_C8,	    /* HSW only */
16576260e5d5Smrg	I915_OA_FORMAT_A45_B8_C8,   /* HSW only */
16586260e5d5Smrg	I915_OA_FORMAT_B4_C8_A16,   /* HSW only */
16596260e5d5Smrg	I915_OA_FORMAT_C4_B8,	    /* HSW+ */
16606260e5d5Smrg
16616260e5d5Smrg	/* Gen8+ */
16626260e5d5Smrg	I915_OA_FORMAT_A12,
16636260e5d5Smrg	I915_OA_FORMAT_A12_B8_C8,
16646260e5d5Smrg	I915_OA_FORMAT_A32u40_A4u32_B8_C8,
16652ee35494Smrg
16662ee35494Smrg	I915_OA_FORMAT_MAX	    /* non-ABI */
16672ee35494Smrg};
16682ee35494Smrg
16692ee35494Smrgenum drm_i915_perf_property_id {
16702ee35494Smrg	/**
16712ee35494Smrg	 * Open the stream for a specific context handle (as used with
16722ee35494Smrg	 * execbuffer2). A stream opened for a specific context this way
16732ee35494Smrg	 * won't typically require root privileges.
16742ee35494Smrg	 */
16752ee35494Smrg	DRM_I915_PERF_PROP_CTX_HANDLE = 1,
16762ee35494Smrg
16772ee35494Smrg	/**
16782ee35494Smrg	 * A value of 1 requests the inclusion of raw OA unit reports as
16792ee35494Smrg	 * part of stream samples.
16802ee35494Smrg	 */
16812ee35494Smrg	DRM_I915_PERF_PROP_SAMPLE_OA,
16822ee35494Smrg
16832ee35494Smrg	/**
16842ee35494Smrg	 * The value specifies which set of OA unit metrics should be
16852ee35494Smrg	 * be configured, defining the contents of any OA unit reports.
16862ee35494Smrg	 */
16872ee35494Smrg	DRM_I915_PERF_PROP_OA_METRICS_SET,
16882ee35494Smrg
16892ee35494Smrg	/**
16902ee35494Smrg	 * The value specifies the size and layout of OA unit reports.
16912ee35494Smrg	 */
16922ee35494Smrg	DRM_I915_PERF_PROP_OA_FORMAT,
16932ee35494Smrg
16942ee35494Smrg	/**
16952ee35494Smrg	 * Specifying this property implicitly requests periodic OA unit
16962ee35494Smrg	 * sampling and (at least on Haswell) the sampling frequency is derived
16972ee35494Smrg	 * from this exponent as follows:
16982ee35494Smrg	 *
16992ee35494Smrg	 *   80ns * 2^(period_exponent + 1)
17002ee35494Smrg	 */
17012ee35494Smrg	DRM_I915_PERF_PROP_OA_EXPONENT,
17022ee35494Smrg
17032ee35494Smrg	DRM_I915_PERF_PROP_MAX /* non-ABI */
17042ee35494Smrg};
17052ee35494Smrg
17062ee35494Smrgstruct drm_i915_perf_open_param {
17072ee35494Smrg	__u32 flags;
17082ee35494Smrg#define I915_PERF_FLAG_FD_CLOEXEC	(1<<0)
17092ee35494Smrg#define I915_PERF_FLAG_FD_NONBLOCK	(1<<1)
17102ee35494Smrg#define I915_PERF_FLAG_DISABLED		(1<<2)
17112ee35494Smrg
17122ee35494Smrg	/** The number of u64 (id, value) pairs */
17132ee35494Smrg	__u32 num_properties;
17142ee35494Smrg
17152ee35494Smrg	/**
17162ee35494Smrg	 * Pointer to array of u64 (id, value) pairs configuring the stream
17172ee35494Smrg	 * to open.
17182ee35494Smrg	 */
17192ee35494Smrg	__u64 properties_ptr;
17202ee35494Smrg};
17212ee35494Smrg
17222ee35494Smrg/**
17232ee35494Smrg * Enable data capture for a stream that was either opened in a disabled state
17242ee35494Smrg * via I915_PERF_FLAG_DISABLED or was later disabled via
17252ee35494Smrg * I915_PERF_IOCTL_DISABLE.
17262ee35494Smrg *
17272ee35494Smrg * It is intended to be cheaper to disable and enable a stream than it may be
17282ee35494Smrg * to close and re-open a stream with the same configuration.
17292ee35494Smrg *
17302ee35494Smrg * It's undefined whether any pending data for the stream will be lost.
17312ee35494Smrg */
17322ee35494Smrg#define I915_PERF_IOCTL_ENABLE	_IO('i', 0x0)
17332ee35494Smrg
17342ee35494Smrg/**
17352ee35494Smrg * Disable data capture for a stream.
17362ee35494Smrg *
17372ee35494Smrg * It is an error to try and read a stream that is disabled.
17382ee35494Smrg */
17392ee35494Smrg#define I915_PERF_IOCTL_DISABLE	_IO('i', 0x1)
17402ee35494Smrg
17412ee35494Smrg/**
17422ee35494Smrg * Common to all i915 perf records
17432ee35494Smrg */
17442ee35494Smrgstruct drm_i915_perf_record_header {
17452ee35494Smrg	__u32 type;
17462ee35494Smrg	__u16 pad;
17472ee35494Smrg	__u16 size;
17482ee35494Smrg};
17492ee35494Smrg
17502ee35494Smrgenum drm_i915_perf_record_type {
17512ee35494Smrg
17522ee35494Smrg	/**
17532ee35494Smrg	 * Samples are the work horse record type whose contents are extensible
17542ee35494Smrg	 * and defined when opening an i915 perf stream based on the given
17552ee35494Smrg	 * properties.
17562ee35494Smrg	 *
17572ee35494Smrg	 * Boolean properties following the naming convention
17582ee35494Smrg	 * DRM_I915_PERF_SAMPLE_xyz_PROP request the inclusion of 'xyz' data in
17592ee35494Smrg	 * every sample.
17602ee35494Smrg	 *
17612ee35494Smrg	 * The order of these sample properties given by userspace has no
17622ee35494Smrg	 * affect on the ordering of data within a sample. The order is
17632ee35494Smrg	 * documented here.
17642ee35494Smrg	 *
17652ee35494Smrg	 * struct {
17662ee35494Smrg	 *     struct drm_i915_perf_record_header header;
17672ee35494Smrg	 *
17682ee35494Smrg	 *     { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA
17692ee35494Smrg	 * };
17702ee35494Smrg	 */
17712ee35494Smrg	DRM_I915_PERF_RECORD_SAMPLE = 1,
17722ee35494Smrg
17732ee35494Smrg	/*
17742ee35494Smrg	 * Indicates that one or more OA reports were not written by the
17752ee35494Smrg	 * hardware. This can happen for example if an MI_REPORT_PERF_COUNT
17762ee35494Smrg	 * command collides with periodic sampling - which would be more likely
17772ee35494Smrg	 * at higher sampling frequencies.
17782ee35494Smrg	 */
17792ee35494Smrg	DRM_I915_PERF_RECORD_OA_REPORT_LOST = 2,
17802ee35494Smrg
17812ee35494Smrg	/**
17822ee35494Smrg	 * An error occurred that resulted in all pending OA reports being lost.
17832ee35494Smrg	 */
17842ee35494Smrg	DRM_I915_PERF_RECORD_OA_BUFFER_LOST = 3,
17852ee35494Smrg
17862ee35494Smrg	DRM_I915_PERF_RECORD_MAX /* non-ABI */
17872ee35494Smrg};
17882ee35494Smrg
17896260e5d5Smrg/**
17906260e5d5Smrg * Structure to upload perf dynamic configuration into the kernel.
17916260e5d5Smrg */
17926260e5d5Smrgstruct drm_i915_perf_oa_config {
17936260e5d5Smrg	/** String formatted like "%08x-%04x-%04x-%04x-%012x" */
17946260e5d5Smrg	char uuid[36];
17956260e5d5Smrg
17966260e5d5Smrg	__u32 n_mux_regs;
17976260e5d5Smrg	__u32 n_boolean_regs;
17986260e5d5Smrg	__u32 n_flex_regs;
17996260e5d5Smrg
18006260e5d5Smrg	/*
18016260e5d5Smrg	 * These fields are pointers to tuples of u32 values (register address,
18026260e5d5Smrg	 * value). For example the expected length of the buffer pointed by
18036260e5d5Smrg	 * mux_regs_ptr is (2 * sizeof(u32) * n_mux_regs).
18046260e5d5Smrg	 */
18056260e5d5Smrg	__u64 mux_regs_ptr;
18066260e5d5Smrg	__u64 boolean_regs_ptr;
18076260e5d5Smrg	__u64 flex_regs_ptr;
18086260e5d5Smrg};
18096260e5d5Smrg
18106260e5d5Smrgstruct drm_i915_query_item {
18116260e5d5Smrg	__u64 query_id;
18126260e5d5Smrg#define DRM_I915_QUERY_TOPOLOGY_INFO    1
1813bf6cc7dcSmrg/* Must be kept compact -- no holes and well documented */
18146260e5d5Smrg
18156260e5d5Smrg	/*
18166260e5d5Smrg	 * When set to zero by userspace, this is filled with the size of the
18176260e5d5Smrg	 * data to be written at the data_ptr pointer. The kernel sets this
18186260e5d5Smrg	 * value to a negative value to signal an error on a particular query
18196260e5d5Smrg	 * item.
18206260e5d5Smrg	 */
18216260e5d5Smrg	__s32 length;
18226260e5d5Smrg
18236260e5d5Smrg	/*
18246260e5d5Smrg	 * Unused for now. Must be cleared to zero.
18256260e5d5Smrg	 */
18266260e5d5Smrg	__u32 flags;
18276260e5d5Smrg
18286260e5d5Smrg	/*
18296260e5d5Smrg	 * Data will be written at the location pointed by data_ptr when the
18306260e5d5Smrg	 * value of length matches the length of the data to be written by the
18316260e5d5Smrg	 * kernel.
18326260e5d5Smrg	 */
18336260e5d5Smrg	__u64 data_ptr;
18346260e5d5Smrg};
18356260e5d5Smrg
18366260e5d5Smrgstruct drm_i915_query {
18376260e5d5Smrg	__u32 num_items;
18386260e5d5Smrg
18396260e5d5Smrg	/*
18406260e5d5Smrg	 * Unused for now. Must be cleared to zero.
18416260e5d5Smrg	 */
18426260e5d5Smrg	__u32 flags;
18436260e5d5Smrg
18446260e5d5Smrg	/*
18456260e5d5Smrg	 * This points to an array of num_items drm_i915_query_item structures.
18466260e5d5Smrg	 */
18476260e5d5Smrg	__u64 items_ptr;
18486260e5d5Smrg};
18496260e5d5Smrg
18506260e5d5Smrg/*
18516260e5d5Smrg * Data written by the kernel with query DRM_I915_QUERY_TOPOLOGY_INFO :
18526260e5d5Smrg *
18536260e5d5Smrg * data: contains the 3 pieces of information :
18546260e5d5Smrg *
18556260e5d5Smrg * - the slice mask with one bit per slice telling whether a slice is
18566260e5d5Smrg *   available. The availability of slice X can be queried with the following
18576260e5d5Smrg *   formula :
18586260e5d5Smrg *
18596260e5d5Smrg *           (data[X / 8] >> (X % 8)) & 1
18606260e5d5Smrg *
18616260e5d5Smrg * - the subslice mask for each slice with one bit per subslice telling
18626260e5d5Smrg *   whether a subslice is available. The availability of subslice Y in slice
18636260e5d5Smrg *   X can be queried with the following formula :
18646260e5d5Smrg *
18656260e5d5Smrg *           (data[subslice_offset +
18666260e5d5Smrg *                 X * subslice_stride +
18676260e5d5Smrg *                 Y / 8] >> (Y % 8)) & 1
18686260e5d5Smrg *
18696260e5d5Smrg * - the EU mask for each subslice in each slice with one bit per EU telling
18706260e5d5Smrg *   whether an EU is available. The availability of EU Z in subslice Y in
18716260e5d5Smrg *   slice X can be queried with the following formula :
18726260e5d5Smrg *
18736260e5d5Smrg *           (data[eu_offset +
18746260e5d5Smrg *                 (X * max_subslices + Y) * eu_stride +
18756260e5d5Smrg *                 Z / 8] >> (Z % 8)) & 1
18766260e5d5Smrg */
18776260e5d5Smrgstruct drm_i915_query_topology_info {
18786260e5d5Smrg	/*
18796260e5d5Smrg	 * Unused for now. Must be cleared to zero.
18806260e5d5Smrg	 */
18816260e5d5Smrg	__u16 flags;
18826260e5d5Smrg
18836260e5d5Smrg	__u16 max_slices;
18846260e5d5Smrg	__u16 max_subslices;
18856260e5d5Smrg	__u16 max_eus_per_subslice;
18866260e5d5Smrg
18876260e5d5Smrg	/*
18886260e5d5Smrg	 * Offset in data[] at which the subslice masks are stored.
18896260e5d5Smrg	 */
18906260e5d5Smrg	__u16 subslice_offset;
18916260e5d5Smrg
18926260e5d5Smrg	/*
18936260e5d5Smrg	 * Stride at which each of the subslice masks for each slice are
18946260e5d5Smrg	 * stored.
18956260e5d5Smrg	 */
18966260e5d5Smrg	__u16 subslice_stride;
18976260e5d5Smrg
18986260e5d5Smrg	/*
18996260e5d5Smrg	 * Offset in data[] at which the EU masks are stored.
19006260e5d5Smrg	 */
19016260e5d5Smrg	__u16 eu_offset;
19026260e5d5Smrg
19036260e5d5Smrg	/*
19046260e5d5Smrg	 * Stride at which each of the EU masks for each subslice are stored.
19056260e5d5Smrg	 */
19066260e5d5Smrg	__u16 eu_stride;
19076260e5d5Smrg
19086260e5d5Smrg	__u8 data[];
19096260e5d5Smrg};
19106260e5d5Smrg
19112ee35494Smrg#if defined(__cplusplus)
19122ee35494Smrg}
19132ee35494Smrg#endif
19142ee35494Smrg
1915e88f27b3Smrg#endif /* _I915_DRM_H_ */
1916