1091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#ifndef _UAPI_MSM_KGSL_H
2091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define _UAPI_MSM_KGSL_H
3091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
4091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/*
5091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * The KGSL version has proven not to be very useful in userspace if features
6091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * are cherry picked into other trees out of order so it is frozen as of 3.14.
7091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * It is left here for backwards compatabilty and as a reminder that
8091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * software releases are never linear. Also, I like pie.
9091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
10091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
11091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_VERSION_MAJOR        3
12091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_VERSION_MINOR        14
13091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
14091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/*context flags */
15091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_SAVE_GMEM		0x00000001
16091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_NO_GMEM_ALLOC	0x00000002
17091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_SUBMIT_IB_LIST	0x00000004
18091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_CTX_SWITCH		0x00000008
19091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_PREAMBLE		0x00000010
20091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_TRASH_STATE	0x00000020
21091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_PER_CONTEXT_TS	0x00000040
22091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_USER_GENERATED_TS	0x00000080
23091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_END_OF_FRAME	0x00000100
24091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
25091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_NO_FAULT_TOLERANCE 0x00000200
26091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_SYNC               0x00000400
27091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_PWR_CONSTRAINT     0x00000800
28091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* bits [12:15] are reserved for future use */
29091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_PRIORITY_MASK      0x0000F000
30091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_PRIORITY_SHIFT     12
31091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_PRIORITY_UNDEF     0
32091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
33091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_TYPE_MASK          0x01F00000
34091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_TYPE_SHIFT         20
35091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
36091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_TYPE_ANY		0
37091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_TYPE_GL		1
38091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_TYPE_CL		2
39091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_TYPE_C2D		3
40091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_TYPE_RS		4
41091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_TYPE_UNKNOWN	0x1E
42091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
43091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONTEXT_INVALID 0xffffffff
44091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
45091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* --- Memory allocation flags --- */
46091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
47091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* General allocation hints */
48091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMFLAGS_GPUREADONLY 0x01000000
49091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMFLAGS_USE_CPU_MAP 0x10000000
50091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
51091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* Memory caching hints */
52091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CACHEMODE_MASK 0x0C000000
53091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CACHEMODE_SHIFT 26
54091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
55091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CACHEMODE_WRITECOMBINE 0
56091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CACHEMODE_UNCACHED 1
57091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CACHEMODE_WRITETHROUGH 2
58091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CACHEMODE_WRITEBACK 3
59091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
60091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* Memory types for which allocations are made */
61091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_MASK		0x0000FF00
62091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_SHIFT		8
63091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
64091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_OBJECTANY			0
65091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_FRAMEBUFFER		1
66091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_RENDERBUFFER		2
67091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_ARRAYBUFFER		3
68091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_ELEMENTARRAYBUFFER		4
69091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_VERTEXARRAYBUFFER		5
70091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_TEXTURE			6
71091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_SURFACE			7
72091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_EGL_SURFACE		8
73091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_GL				9
74091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_CL				10
75091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_CL_BUFFER_MAP		11
76091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_CL_BUFFER_NOMAP		12
77091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_CL_IMAGE_MAP		13
78091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_CL_IMAGE_NOMAP		14
79091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_CL_KERNEL_STACK		15
80091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_COMMAND			16
81091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_2D				17
82091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_EGL_IMAGE			18
83091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_EGL_SHADOW			19
84091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_MULTISAMPLE		20
85091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMTYPE_KERNEL			255
86091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
87091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/*
88091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * Alignment hint, passed as the power of 2 exponent.
89091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * i.e 4k (2^12) would be 12, 64k (2^16)would be 16.
90091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
91091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMALIGN_MASK		0x00FF0000
92091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMALIGN_SHIFT		16
93091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
94091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavaenum kgsl_user_mem_type {
95091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_USER_MEM_TYPE_PMEM		= 0x00000000,
96091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_USER_MEM_TYPE_ASHMEM	= 0x00000001,
97091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_USER_MEM_TYPE_ADDR		= 0x00000002,
98091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_USER_MEM_TYPE_ION		= 0x00000003,
99091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_USER_MEM_TYPE_MAX		= 0x00000004,
100091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
101091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMFLAGS_USERMEM_MASK 0x000000e0
102091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMFLAGS_USERMEM_SHIFT 5
103091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
104091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/*
105091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * Unfortunately, enum kgsl_user_mem_type starts at 0 which does not
106091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * leave a good value for allocated memory. In the flags we use
107091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * 0 to indicate allocated memory and thus need to add 1 to the enum
108091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * values.
109091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
110091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_USERMEM_FLAG(x) (((x) + 1) << KGSL_MEMFLAGS_USERMEM_SHIFT)
111091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
112091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMFLAGS_NOT_USERMEM 0
113091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMFLAGS_USERMEM_PMEM KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_PMEM)
114091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMFLAGS_USERMEM_ASHMEM \
115091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava		KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ASHMEM)
116091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMFLAGS_USERMEM_ADDR KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ADDR)
117091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMFLAGS_USERMEM_ION KGSL_USERMEM_FLAG(KGSL_USER_MEM_TYPE_ION)
118091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
119091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* --- generic KGSL flag values --- */
120091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
121091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_FLAGS_NORMALMODE  0x00000000
122091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_FLAGS_SAFEMODE    0x00000001
123091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_FLAGS_INITIALIZED0 0x00000002
124091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_FLAGS_INITIALIZED 0x00000004
125091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_FLAGS_STARTED     0x00000008
126091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_FLAGS_ACTIVE      0x00000010
127091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_FLAGS_RESERVED0   0x00000020
128091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_FLAGS_RESERVED1   0x00000040
129091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_FLAGS_RESERVED2   0x00000080
130091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_FLAGS_SOFT_RESET  0x00000100
131091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_FLAGS_PER_CONTEXT_TIMESTAMPS 0x00000200
132091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
133091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* Clock flags to show which clocks should be controled by a given platform */
134091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CLK_SRC	0x00000001
135091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CLK_CORE	0x00000002
136091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CLK_IFACE	0x00000004
137091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CLK_MEM	0x00000008
138091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CLK_MEM_IFACE 0x00000010
139091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CLK_AXI	0x00000020
140091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
141091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* Server Side Sync Timeout in milliseconds */
142091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_SYNCOBJ_SERVER_TIMEOUT 2000
143091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
144091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/*
145091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * Reset status values for context
146091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
147091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavaenum kgsl_ctx_reset_stat {
148091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_CTX_STAT_NO_ERROR				= 0x00000000,
149091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_CTX_STAT_GUILTY_CONTEXT_RESET_EXT		= 0x00000001,
150091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_CTX_STAT_INNOCENT_CONTEXT_RESET_EXT	= 0x00000002,
151091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_CTX_STAT_UNKNOWN_CONTEXT_RESET_EXT		= 0x00000003
152091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
153091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
154091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONVERT_TO_MBPS(val) \
155091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	(val*1000*1000U)
156091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
157091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* device id */
158091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavaenum kgsl_deviceid {
159091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_DEVICE_3D0		= 0x00000000,
160091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_DEVICE_2D0		= 0x00000001,
161091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_DEVICE_2D1		= 0x00000002,
162091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_DEVICE_MAX		= 0x00000003
163091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
164091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
165091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_devinfo {
166091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
167091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int device_id;
168091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	/* chip revision id
169091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	* coreid:8 majorrev:8 minorrev:8 patch:8
170091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	*/
171091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int chip_id;
172091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int mmu_enabled;
173091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long gmem_gpubaseaddr;
174091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	/*
175091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	* This field contains the adreno revision
176091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	* number 200, 205, 220, etc...
177091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	*/
178091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int gpu_id;
179091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t gmem_sizebytes;
180091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
181091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
182091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* this structure defines the region of memory that can be mmap()ed from this
183091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava   driver. The timestamp fields are volatile because they are written by the
184091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava   GPU
185091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava*/
186091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_devmemstore {
187091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	volatile unsigned int soptimestamp;
188091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int sbz;
189091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	volatile unsigned int eoptimestamp;
190091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int sbz2;
191091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	volatile unsigned int ts_cmp_enable;
192091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int sbz3;
193091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	volatile unsigned int ref_wait_ts;
194091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int sbz4;
195091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int current_context;
196091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int sbz5;
197091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
198091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
199091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_MEMSTORE_OFFSET(ctxt_id, field) \
200091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	((ctxt_id)*sizeof(struct kgsl_devmemstore) + \
201091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	 offsetof(struct kgsl_devmemstore, field))
202091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
203091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* timestamp id*/
204091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavaenum kgsl_timestamp_type {
205091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_TIMESTAMP_CONSUMED = 0x00000001, /* start-of-pipeline timestamp */
206091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_TIMESTAMP_RETIRED  = 0x00000002, /* end-of-pipeline timestamp*/
207091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_TIMESTAMP_QUEUED   = 0x00000003,
208091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
209091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
210091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* property types - used with kgsl_device_getproperty */
211091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavaenum kgsl_property_type {
212091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_PROP_DEVICE_INFO     = 0x00000001,
213091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_PROP_DEVICE_SHADOW   = 0x00000002,
214091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_PROP_DEVICE_POWER    = 0x00000003,
215091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_PROP_SHMEM           = 0x00000004,
216091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_PROP_SHMEM_APERTURES = 0x00000005,
217091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_PROP_MMU_ENABLE 	  = 0x00000006,
218091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_PROP_INTERRUPT_WAITS = 0x00000007,
219091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_PROP_VERSION         = 0x00000008,
220091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_PROP_GPU_RESET_STAT  = 0x00000009,
221091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_PROP_PWRCTRL         = 0x0000000E,
222091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_PROP_PWR_CONSTRAINT  = 0x00000012,
223091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
224091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
225091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_shadowprop {
226091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long gpuaddr;
227091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t size;
228091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int flags; /* contains KGSL_FLAGS_ values */
229091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
230091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
231091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_version {
232091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int drv_major;
233091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int drv_minor;
234091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int dev_major;
235091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int dev_minor;
236091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
237091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
238091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* Performance counter groups */
239091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
240091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_CP 0x0
241091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_RBBM 0x1
242091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_PC 0x2
243091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_VFD 0x3
244091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_HLSQ 0x4
245091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_VPC 0x5
246091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_TSE 0x6
247091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_RAS 0x7
248091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_UCHE 0x8
249091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_TP 0x9
250091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_SP 0xA
251091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_RB 0xB
252091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_PWR 0xC
253091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_VBIF 0xD
254091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_VBIF_PWR 0xE
255091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_MH 0xF
256091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_PA_SU 0x10
257091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_SQ 0x11
258091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_SX 0x12
259091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_TCF 0x13
260091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_TCM 0x14
261091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_TCR 0x15
262091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_L2 0x16
263091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_VSC 0x17
264091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_CCU 0x18
265091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_GROUP_MAX 0x19
266091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
267091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_NOT_USED 0xFFFFFFFF
268091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_PERFCOUNTER_BROKEN 0xFFFFFFFE
269091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
270091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* structure holds list of ibs */
271091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_ibdesc {
272091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long gpuaddr;
273091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long __pad;
274091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t sizedwords;
275091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int ctrl;
276091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
277091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
278091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* ioctls */
279091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_IOC_TYPE 0x09
280091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
281091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* get misc info about the GPU
282091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava   type should be a value from enum kgsl_property_type
283091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava   value points to a structure that varies based on type
284091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava   sizebytes is sizeof() that structure
285091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava   for KGSL_PROP_DEVICE_INFO, use struct kgsl_devinfo
286091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava   this structure contaings hardware versioning info.
287091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava   for KGSL_PROP_DEVICE_SHADOW, use struct kgsl_shadowprop
288091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava   this is used to find mmap() offset and sizes for mapping
289091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava   struct kgsl_memstore into userspace.
290091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava*/
291091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_device_getproperty {
292091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int type;
293091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	void __user *value;
294091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t sizebytes;
295091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
296091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
297091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_DEVICE_GETPROPERTY \
298091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x2, struct kgsl_device_getproperty)
299091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
300091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* IOCTL_KGSL_DEVICE_READ (0x3) - removed 03/2012
301091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
302091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
303091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* block until the GPU has executed past a given timestamp
304091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * timeout is in milliseconds.
305091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
306091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_device_waittimestamp {
307091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int timestamp;
308091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int timeout;
309091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
310091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
311091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_DEVICE_WAITTIMESTAMP \
312091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOW(KGSL_IOC_TYPE, 0x6, struct kgsl_device_waittimestamp)
313091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
314091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_device_waittimestamp_ctxtid {
315091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int context_id;
316091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int timestamp;
317091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int timeout;
318091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
319091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
320091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID \
321091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOW(KGSL_IOC_TYPE, 0x7, struct kgsl_device_waittimestamp_ctxtid)
322091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
323091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* DEPRECATED: issue indirect commands to the GPU.
324091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * drawctxt_id must have been created with IOCTL_KGSL_DRAWCTXT_CREATE
325091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * ibaddr and sizedwords must specify a subset of a buffer created
326091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * with IOCTL_KGSL_SHAREDMEM_FROM_PMEM
327091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * flags may be a mask of KGSL_CONTEXT_ values
328091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * timestamp is a returned counter value which can be passed to
329091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * other ioctls to determine when the commands have been executed by
330091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * the GPU.
331091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
332091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * This fucntion is deprecated - consider using IOCTL_KGSL_SUBMIT_COMMANDS
333091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * instead
334091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
335091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_ringbuffer_issueibcmds {
336091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int drawctxt_id;
337091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long ibdesc_addr;
338091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int numibs;
339091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int timestamp; /*output param */
340091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int flags;
341091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
342091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
343091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS \
344091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x10, struct kgsl_ringbuffer_issueibcmds)
345091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
346091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* read the most recently executed timestamp value
347091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * type should be a value from enum kgsl_timestamp_type
348091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
349091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_cmdstream_readtimestamp {
350091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int type;
351091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int timestamp; /*output param */
352091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
353091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
354091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_OLD \
355091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp)
356091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
357091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP \
358091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp)
359091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
360091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* free memory when the GPU reaches a given timestamp.
361091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * gpuaddr specify a memory region created by a
362091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * IOCTL_KGSL_SHAREDMEM_FROM_PMEM call
363091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * type should be a value from enum kgsl_timestamp_type
364091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
365091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_cmdstream_freememontimestamp {
366091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long gpuaddr;
367091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int type;
368091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int timestamp;
369091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
370091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
371091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP \
372091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOW(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp)
373091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
374091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* Previous versions of this header had incorrectly defined
375091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava   IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP as a read-only ioctl instead
376091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava   of a write only ioctl.  To ensure binary compatability, the following
377091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava   #define will be used to intercept the incorrect ioctl
378091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava*/
379091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
380091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_OLD \
381091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOR(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp)
382091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
383091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* create a draw context, which is used to preserve GPU state.
384091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * The flags field may contain a mask KGSL_CONTEXT_*  values
385091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
386091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_drawctxt_create {
387091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int flags;
388091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int drawctxt_id; /*output param */
389091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
390091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
391091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_DRAWCTXT_CREATE \
392091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x13, struct kgsl_drawctxt_create)
393091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
394091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* destroy a draw context */
395091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_drawctxt_destroy {
396091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int drawctxt_id;
397091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
398091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
399091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_DRAWCTXT_DESTROY \
400091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOW(KGSL_IOC_TYPE, 0x14, struct kgsl_drawctxt_destroy)
401091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
402091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* add a block of pmem, fb, ashmem or user allocated address
403091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * into the GPU address space */
404091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_map_user_mem {
405091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	int fd;
406091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long gpuaddr;   /*output param */
407091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t len;
408091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t offset;
409091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long hostptr;   /*input param */
410091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	enum kgsl_user_mem_type memtype;
411091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int flags;
412091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
413091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
414091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_MAP_USER_MEM \
415091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x15, struct kgsl_map_user_mem)
416091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
417091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_cmdstream_readtimestamp_ctxtid {
418091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int context_id;
419091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int type;
420091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int timestamp; /*output param */
421091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
422091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
423091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_CTXTID \
424091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x16, struct kgsl_cmdstream_readtimestamp_ctxtid)
425091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
426091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_cmdstream_freememontimestamp_ctxtid {
427091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int context_id;
428091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long gpuaddr;
429091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int type;
430091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int timestamp;
431091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
432091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
433091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_CTXTID \
434091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOW(KGSL_IOC_TYPE, 0x17, \
435091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	struct kgsl_cmdstream_freememontimestamp_ctxtid)
436091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
437091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* add a block of pmem or fb into the GPU address space */
438091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_sharedmem_from_pmem {
439091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	int pmem_fd;
440091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long gpuaddr;	/*output param */
441091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int len;
442091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int offset;
443091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
444091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
445091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_SHAREDMEM_FROM_PMEM \
446091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x20, struct kgsl_sharedmem_from_pmem)
447091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
448091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* remove memory from the GPU's address space */
449091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_sharedmem_free {
450091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long gpuaddr;
451091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
452091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
453091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_SHAREDMEM_FREE \
454091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOW(KGSL_IOC_TYPE, 0x21, struct kgsl_sharedmem_free)
455091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
456091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_cff_user_event {
457091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned char cff_opcode;
458091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int op1;
459091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int op2;
460091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int op3;
461091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int op4;
462091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int op5;
463091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int __pad[2];
464091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
465091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
466091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_CFF_USER_EVENT \
467091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_cff_user_event)
468091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
469091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_gmem_desc {
470091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int x;
471091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int y;
472091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int width;
473091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int height;
474091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int pitch;
475091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
476091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
477091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_buffer_desc {
478091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	void 			*hostptr;
479091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long	gpuaddr;
480091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	int				size;
481091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int	format;
482091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int  	pitch;
483091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int  	enabled;
484091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
485091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
486091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_bind_gmem_shadow {
487091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int drawctxt_id;
488091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	struct kgsl_gmem_desc gmem_desc;
489091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int shadow_x;
490091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int shadow_y;
491091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	struct kgsl_buffer_desc shadow_buffer;
492091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int buffer_id;
493091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
494091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
495091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_DRAWCTXT_BIND_GMEM_SHADOW \
496091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava    _IOW(KGSL_IOC_TYPE, 0x22, struct kgsl_bind_gmem_shadow)
497091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
498091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* add a block of memory into the GPU address space */
499091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
500091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/*
501091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC deprecated 09/2012
502091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * use IOCTL_KGSL_GPUMEM_ALLOC instead
503091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
504091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
505091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_sharedmem_from_vmalloc {
506091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long gpuaddr;	/*output param */
507091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int hostptr;
508091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int flags;
509091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
510091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
511091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC \
512091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x23, struct kgsl_sharedmem_from_vmalloc)
513091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
514091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/*
515091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * This is being deprecated in favor of IOCTL_KGSL_GPUMEM_CACHE_SYNC which
516091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * supports both directions (flush and invalidate). This code will still
517091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * work, but by definition it will do a flush of the cache which might not be
518091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * what you want to have happen on a buffer following a GPU operation.  It is
519091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * safer to go with IOCTL_KGSL_GPUMEM_CACHE_SYNC
520091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
521091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
522091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_SHAREDMEM_FLUSH_CACHE \
523091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOW(KGSL_IOC_TYPE, 0x24, struct kgsl_sharedmem_free)
524091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
525091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_drawctxt_set_bin_base_offset {
526091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int drawctxt_id;
527091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int offset;
528091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
529091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
530091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_DRAWCTXT_SET_BIN_BASE_OFFSET \
531091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOW(KGSL_IOC_TYPE, 0x25, struct kgsl_drawctxt_set_bin_base_offset)
532091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
533091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavaenum kgsl_cmdwindow_type {
534091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_CMDWINDOW_MIN     = 0x00000000,
535091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_CMDWINDOW_2D      = 0x00000000,
536091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_CMDWINDOW_3D      = 0x00000001, /* legacy */
537091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_CMDWINDOW_MMU     = 0x00000002,
538091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_CMDWINDOW_ARBITER = 0x000000FF,
539091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	KGSL_CMDWINDOW_MAX     = 0x000000FF,
540091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
541091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
542091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* write to the command window */
543091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_cmdwindow_write {
544091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	enum kgsl_cmdwindow_type target;
545091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int addr;
546091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int data;
547091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
548091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
549091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_CMDWINDOW_WRITE \
550091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOW(KGSL_IOC_TYPE, 0x2e, struct kgsl_cmdwindow_write)
551091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
552091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_gpumem_alloc {
553091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long gpuaddr; /* output param */
554091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t size;
555091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int flags;
556091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
557091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
558091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_GPUMEM_ALLOC \
559091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x2f, struct kgsl_gpumem_alloc)
560091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
561091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_cff_syncmem {
562091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long gpuaddr;
563091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t len;
564091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int __pad[2]; /* For future binary compatibility */
565091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
566091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
567091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_CFF_SYNCMEM \
568091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOW(KGSL_IOC_TYPE, 0x30, struct kgsl_cff_syncmem)
569091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
570091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/*
571091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * A timestamp event allows the user space to register an action following an
572091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * expired timestamp. Note IOCTL_KGSL_TIMESTAMP_EVENT has been redefined to
573091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * _IOWR to support fences which need to return a fd for the priv parameter.
574091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
575091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
576091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_timestamp_event {
577091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	int type;                /* Type of event (see list below) */
578091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int timestamp;  /* Timestamp to trigger event on */
579091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int context_id; /* Context for the timestamp */
580091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	void __user *priv;	 /* Pointer to the event specific blob */
581091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t len;              /* Size of the event specific blob */
582091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
583091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
584091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_TIMESTAMP_EVENT_OLD \
585091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_timestamp_event)
586091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
587091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* A genlock timestamp event releases an existing lock on timestamp expire */
588091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
589091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_TIMESTAMP_EVENT_GENLOCK 1
590091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
591091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_timestamp_event_genlock {
592091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	int handle; /* Handle of the genlock lock to release */
593091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
594091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
595091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* A fence timestamp event releases an existing lock on timestamp expire */
596091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
597091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_TIMESTAMP_EVENT_FENCE 2
598091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
599091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_timestamp_event_fence {
600091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	int fence_fd; /* Fence to signal */
601091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
602091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
603091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/*
604091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * Set a property within the kernel.  Uses the same structure as
605091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * IOCTL_KGSL_GETPROPERTY
606091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
607091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
608091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_SETPROPERTY \
609091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOW(KGSL_IOC_TYPE, 0x32, struct kgsl_device_getproperty)
610091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
611091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_TIMESTAMP_EVENT \
612091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x33, struct kgsl_timestamp_event)
613091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
614091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/**
615091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * struct kgsl_gpumem_alloc_id - argument to IOCTL_KGSL_GPUMEM_ALLOC_ID
616091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @id: returned id value for this allocation.
617091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @flags: mask of KGSL_MEM* values requested and actual flags on return.
618091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @size: requested size of the allocation and actual size on return.
619091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @mmapsize: returned size to pass to mmap() which may be larger than 'size'
620091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @gpuaddr: returned GPU address for the allocation
621091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
622091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * Allocate memory for access by the GPU. The flags and size fields are echoed
623091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * back by the kernel, so that the caller can know if the request was
624091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * adjusted.
625091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
626091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * Supported flags:
627091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * KGSL_MEMFLAGS_GPUREADONLY: the GPU will be unable to write to the buffer
628091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * KGSL_MEMTYPE*: usage hint for debugging aid
629091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * KGSL_MEMALIGN*: alignment hint, may be ignored or adjusted by the kernel.
630091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * KGSL_MEMFLAGS_USE_CPU_MAP: If set on call and return, the returned GPU
631091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * address will be 0. Calling mmap() will set the GPU address.
632091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
633091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_gpumem_alloc_id {
634091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int id;
635091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int flags;
636091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t size;
637091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t mmapsize;
638091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long gpuaddr;
639091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* private: reserved for future use*/
640091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long __pad[2];
641091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
642091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
643091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_GPUMEM_ALLOC_ID \
644091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x34, struct kgsl_gpumem_alloc_id)
645091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
646091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/**
647091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * struct kgsl_gpumem_free_id - argument to IOCTL_KGSL_GPUMEM_FREE_ID
648091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @id: GPU allocation id to free
649091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
650091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * Free an allocation by id, in case a GPU address has not been assigned or
651091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * is unknown. Freeing an allocation by id with this ioctl or by GPU address
652091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * with IOCTL_KGSL_SHAREDMEM_FREE are equivalent.
653091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
654091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_gpumem_free_id {
655091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int id;
656091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* private: reserved for future use*/
657091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int __pad;
658091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
659091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
660091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_GPUMEM_FREE_ID \
661091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x35, struct kgsl_gpumem_free_id)
662091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
663091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/**
664091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * struct kgsl_gpumem_get_info - argument to IOCTL_KGSL_GPUMEM_GET_INFO
665091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @gpuaddr: GPU address to query. Also set on return.
666091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @id: GPU allocation id to query. Also set on return.
667091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @flags: returned mask of KGSL_MEM* values.
668091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @size: returned size of the allocation.
669091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @mmapsize: returned size to pass mmap(), which may be larger than 'size'
670091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @useraddr: returned address of the userspace mapping for this buffer
671091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
672091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * This ioctl allows querying of all user visible attributes of an existing
673091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * allocation, by either the GPU address or the id returned by a previous
674091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * call to IOCTL_KGSL_GPUMEM_ALLOC_ID. Legacy allocation ioctls may not
675091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * return all attributes so this ioctl can be used to look them up if needed.
676091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
677091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
678091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_gpumem_get_info {
679091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long gpuaddr;
680091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int id;
681091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int flags;
682091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t size;
683091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t mmapsize;
684091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long useraddr;
685091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* private: reserved for future use*/
686091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long __pad[4];
687091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
688091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
689091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_GPUMEM_GET_INFO\
690091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x36, struct kgsl_gpumem_get_info)
691091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
692091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/**
693091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * struct kgsl_gpumem_sync_cache - argument to IOCTL_KGSL_GPUMEM_SYNC_CACHE
694091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @gpuaddr: GPU address of the buffer to sync.
695091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @id: id of the buffer to sync. Either gpuaddr or id is sufficient.
696091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @op: a mask of KGSL_GPUMEM_CACHE_* values
697091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @offset: offset into the buffer
698091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @length: number of bytes starting from offset to perform
699091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * the cache operation on
700091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
701091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * Sync the L2 cache for memory headed to and from the GPU - this replaces
702091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * KGSL_SHAREDMEM_FLUSH_CACHE since it can handle cache management for both
703091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * directions
704091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
705091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
706091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_gpumem_sync_cache {
707091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long gpuaddr;
708091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int id;
709091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int op;
710091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t offset;
711091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t length;
712091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
713091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
714091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_GPUMEM_CACHE_CLEAN (1 << 0)
715091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_GPUMEM_CACHE_TO_GPU KGSL_GPUMEM_CACHE_CLEAN
716091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
717091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_GPUMEM_CACHE_INV (1 << 1)
718091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_GPUMEM_CACHE_FROM_GPU KGSL_GPUMEM_CACHE_INV
719091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
720091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_GPUMEM_CACHE_FLUSH \
721091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	(KGSL_GPUMEM_CACHE_CLEAN | KGSL_GPUMEM_CACHE_INV)
722091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
723091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* Flag to ensure backwards compatibility of kgsl_gpumem_sync_cache struct */
724091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_GPUMEM_CACHE_RANGE (1 << 31U)
725091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
726091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_GPUMEM_SYNC_CACHE \
727091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOW(KGSL_IOC_TYPE, 0x37, struct kgsl_gpumem_sync_cache)
728091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
729091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/**
730091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * struct kgsl_perfcounter_get - argument to IOCTL_KGSL_PERFCOUNTER_GET
731091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @groupid: Performance counter group ID
732091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @countable: Countable to select within the group
733091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @offset: Return offset of the reserved LO counter
734091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @offset_hi: Return offset of the reserved HI counter
735091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
736091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * Get an available performance counter from a specified groupid.  The offset
737091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * of the performance counter will be returned after successfully assigning
738091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * the countable to the counter for the specified group.  An error will be
739091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * returned and an offset of 0 if the groupid is invalid or there are no
740091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * more counters left.  After successfully getting a perfcounter, the user
741091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * must call kgsl_perfcounter_put(groupid, contable) when finished with
742091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * the perfcounter to clear up perfcounter resources.
743091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
744091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
745091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_perfcounter_get {
746091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int groupid;
747091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int countable;
748091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int offset;
749091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int offset_hi;
750091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* private: reserved for future use */
751091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int __pad; /* For future binary compatibility */
752091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
753091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
754091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_PERFCOUNTER_GET \
755091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x38, struct kgsl_perfcounter_get)
756091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
757091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/**
758091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * struct kgsl_perfcounter_put - argument to IOCTL_KGSL_PERFCOUNTER_PUT
759091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @groupid: Performance counter group ID
760091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @countable: Countable to release within the group
761091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
762091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * Put an allocated performance counter to allow others to have access to the
763091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * resource that was previously taken.  This is only to be called after
764091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * successfully getting a performance counter from kgsl_perfcounter_get().
765091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
766091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
767091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_perfcounter_put {
768091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int groupid;
769091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int countable;
770091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* private: reserved for future use */
771091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int __pad[2]; /* For future binary compatibility */
772091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
773091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
774091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_PERFCOUNTER_PUT \
775091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOW(KGSL_IOC_TYPE, 0x39, struct kgsl_perfcounter_put)
776091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
777091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/**
778091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY
779091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @groupid: Performance counter group ID
780091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @countable: Return active countables array
781091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @size: Size of active countables array
782091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @max_counters: Return total number counters for the group ID
783091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
784091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * Query the available performance counters given a groupid.  The array
785091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * *countables is used to return the current active countables in counters.
786091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * The size of the array is passed in so the kernel will only write at most
787091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * size or counter->size for the group id.  The total number of available
788091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * counters for the group ID is returned in max_counters.
789091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * If the array or size passed in are invalid, then only the maximum number
790091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * of counters will be returned, no data will be written to *countables.
791091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * If the groupid is invalid an error code will be returned.
792091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
793091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
794091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_perfcounter_query {
795091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int groupid;
796091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	/* Array to return the current countable for up to size counters */
797091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int __user *countables;
798091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int count;
799091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int max_counters;
800091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* private: reserved for future use */
801091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int __pad[2]; /* For future binary compatibility */
802091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
803091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
804091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_PERFCOUNTER_QUERY \
805091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query)
806091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
807091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/**
808091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY
809091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @groupid: Performance counter group IDs
810091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @countable: Performance counter countable IDs
811091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @value: Return performance counter reads
812091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @size: Size of all arrays (groupid/countable pair and return value)
813091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
814091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * Read in the current value of a performance counter given by the groupid
815091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * and countable.
816091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
817091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
818091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
819091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_perfcounter_read_group {
820091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int groupid;
821091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int countable;
822091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned long long value;
823091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
824091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
825091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_perfcounter_read {
826091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	struct kgsl_perfcounter_read_group __user *reads;
827091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int count;
828091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* private: reserved for future use */
829091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int __pad[2]; /* For future binary compatibility */
830091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
831091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
832091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_PERFCOUNTER_READ \
833091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x3B, struct kgsl_perfcounter_read)
834091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/*
835091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * struct kgsl_gpumem_sync_cache_bulk - argument to
836091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK
837091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @id_list: list of GPU buffer ids of the buffers to sync
838091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @count: number of GPU buffer ids in id_list
839091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @op: a mask of KGSL_GPUMEM_CACHE_* values
840091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
841091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * Sync the cache for memory headed to and from the GPU. Certain
842091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * optimizations can be made on the cache operation based on the total
843091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * size of the working set of memory to be managed.
844091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
845091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_gpumem_sync_cache_bulk {
846091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int __user *id_list;
847091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int count;
848091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int op;
849091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* private: reserved for future use */
850091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int __pad[2]; /* For future binary compatibility */
851091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
852091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
853091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK \
854091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x3C, struct kgsl_gpumem_sync_cache_bulk)
855091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
856091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/*
857091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * struct kgsl_cmd_syncpoint_timestamp
858091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @context_id: ID of a KGSL context
859091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @timestamp: GPU timestamp
860091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
861091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * This structure defines a syncpoint comprising a context/timestamp pair. A
862091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * list of these may be passed by IOCTL_KGSL_SUBMIT_COMMANDS to define
863091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * dependencies that must be met before the command can be submitted to the
864091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * hardware
865091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
866091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_cmd_syncpoint_timestamp {
867091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int context_id;
868091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int timestamp;
869091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
870091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
871091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CMD_SYNCPOINT_TYPE_TIMESTAMP 0
872091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
873091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_cmd_syncpoint_fence {
874091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	int fd;
875091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
876091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
877091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CMD_SYNCPOINT_TYPE_FENCE 1
878091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
879091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/**
880091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * struct kgsl_cmd_syncpoint - Define a sync point for a command batch
881091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @type: type of sync point defined here
882091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @priv: Pointer to the type specific buffer
883091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @size: Size of the type specific buffer
884091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
885091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * This structure contains pointers defining a specific command sync point.
886091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * The pointer and size should point to a type appropriate structure.
887091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
888091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_cmd_syncpoint {
889091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	int type;
890091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	void __user *priv;
891091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t size;
892091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
893091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
894091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/**
895091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * struct kgsl_submit_commands - Argument to IOCTL_KGSL_SUBMIT_COMMANDS
896091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @context_id: KGSL context ID that owns the commands
897091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @flags:
898091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @cmdlist: User pointer to a list of kgsl_ibdesc structures
899091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @numcmds: Number of commands listed in cmdlist
900091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @synclist: User pointer to a list of kgsl_cmd_syncpoint structures
901091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @numsyncs: Number of sync points listed in synclist
902091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @timestamp: On entry the a user defined timestamp, on exist the timestamp
903091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * assigned to the command batch
904091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava *
905091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * This structure specifies a command to send to the GPU hardware.  This is
906091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * similar to kgsl_issueibcmds expect that it doesn't support the legacy way to
907091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * submit IB lists and it adds sync points to block the IB until the
908091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * dependencies are satisified.  This entry point is the new and preferred way
909091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * to submit commands to the GPU.
910091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
911091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
912091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_submit_commands {
913091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int context_id;
914091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int flags;
915091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	struct kgsl_ibdesc __user *cmdlist;
916091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int numcmds;
917091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	struct kgsl_cmd_syncpoint __user *synclist;
918091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int numsyncs;
919091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int timestamp;
920091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* private: reserved for future use */
921091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int __pad[4];
922091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
923091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
924091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define IOCTL_KGSL_SUBMIT_COMMANDS \
925091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	_IOWR(KGSL_IOC_TYPE, 0x3D, struct kgsl_submit_commands)
926091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
927091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/**
928091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * struct kgsl_device_constraint - device constraint argument
929091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @context_id: KGSL context ID
930091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @type: type of constraint i.e pwrlevel/none
931091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @data: constraint data
932091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava * @size: size of the constraint data
933091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava */
934091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_device_constraint {
935091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int type;
936091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int context_id;
937091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	void __user *data;
938091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	size_t size;
939091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
940091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
941091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* Constraint Type*/
942091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONSTRAINT_NONE 0
943091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONSTRAINT_PWRLEVEL 1
944091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
945091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* PWRLEVEL constraint level*/
946091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* set to min frequency */
947091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONSTRAINT_PWR_MIN    0
948091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava/* set to max frequency */
949091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#define KGSL_CONSTRAINT_PWR_MAX    1
950091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava
951091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastavastruct kgsl_device_constraint_pwrlevel {
952091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava	unsigned int level;
953091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava};
954091953c3c47a100bc45e3ea78bde88d945a983dbVineeta Srivastava#endif /* _UAPI_MSM_KGSL_H */
955