blob: 17986b507255813c7dc24af204ec7165893bf2d0 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001#ifndef _MSM_KGSL_H
2#define _MSM_KGSL_H
3
Jordan Crousec3b866d2012-11-08 09:05:52 -07004/*
5 * The KGSL version has proven not to be very useful in userspace if features
6 * are cherry picked into other trees out of order so it is frozen as of 3.14.
7 * It is left here for backwards compatabilty and as a reminder that
8 * software releases are never linear. Also, I like pie.
9 */
10
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070011#define KGSL_VERSION_MAJOR 3
Vijay Krishnamoorthy52895312012-08-27 14:07:32 -070012#define KGSL_VERSION_MINOR 14
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070013
14/*context flags */
Carter Cooper7e7f02e2012-02-15 09:36:31 -070015#define KGSL_CONTEXT_SAVE_GMEM 0x00000001
16#define KGSL_CONTEXT_NO_GMEM_ALLOC 0x00000002
17#define KGSL_CONTEXT_SUBMIT_IB_LIST 0x00000004
18#define KGSL_CONTEXT_CTX_SWITCH 0x00000008
19#define KGSL_CONTEXT_PREAMBLE 0x00000010
20#define KGSL_CONTEXT_TRASH_STATE 0x00000020
21#define KGSL_CONTEXT_PER_CONTEXT_TS 0x00000040
Vijay Krishnamoorthy52895312012-08-27 14:07:32 -070022#define KGSL_CONTEXT_USER_GENERATED_TS 0x00000080
Jordan Crouse2371c9b2013-11-05 09:25:58 -070023#define KGSL_CONTEXT_END_OF_FRAME 0x00000100
24
Tarun Karra973ea7042013-02-05 19:45:49 -080025#define KGSL_CONTEXT_NO_FAULT_TOLERANCE 0x00000200
Jordan Crouse2371c9b2013-11-05 09:25:58 -070026#define KGSL_CONTEXT_SYNC 0x00000400
Suman Tatiraju0ea6b832013-11-18 18:31:19 -080027#define KGSL_CONTEXT_PWR_CONSTRAINT 0x00000800
Jordan Croused2a5a432013-03-25 15:30:48 -060028/* bits [12:15] are reserved for future use */
29#define KGSL_CONTEXT_TYPE_MASK 0x01F00000
30#define KGSL_CONTEXT_TYPE_SHIFT 20
Tarun Karra973ea7042013-02-05 19:45:49 -080031
Jordan Croused2a5a432013-03-25 15:30:48 -060032#define KGSL_CONTEXT_TYPE_ANY 0
33#define KGSL_CONTEXT_TYPE_GL 1
34#define KGSL_CONTEXT_TYPE_CL 2
35#define KGSL_CONTEXT_TYPE_C2D 3
36#define KGSL_CONTEXT_TYPE_RS 4
Carter Cooper9abac662013-05-31 18:14:15 -060037#define KGSL_CONTEXT_TYPE_UNKNOWN 0x1E
Carter Cooper7e7f02e2012-02-15 09:36:31 -070038
39#define KGSL_CONTEXT_INVALID 0xffffffff
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070040
Jordan Crousec3b866d2012-11-08 09:05:52 -070041/* --- Memory allocation flags --- */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070042
Jordan Crousec3b866d2012-11-08 09:05:52 -070043/* General allocation hints */
44#define KGSL_MEMFLAGS_GPUREADONLY 0x01000000
Jeremy Gebben0d6f1482012-10-30 15:40:58 -060045#define KGSL_MEMFLAGS_USE_CPU_MAP 0x10000000
Jordan Crousec3b866d2012-11-08 09:05:52 -070046
47/* Memory caching hints */
48#define KGSL_CACHEMODE_MASK 0x0C000000
49#define KGSL_CACHEMODE_SHIFT 26
50
51#define KGSL_CACHEMODE_WRITECOMBINE 0
52#define KGSL_CACHEMODE_UNCACHED 1
53#define KGSL_CACHEMODE_WRITETHROUGH 2
54#define KGSL_CACHEMODE_WRITEBACK 3
55
56/* Memory types for which allocations are made */
Jeremy Gebben955f8522012-09-24 13:05:39 -060057#define KGSL_MEMTYPE_MASK 0x0000FF00
58#define KGSL_MEMTYPE_SHIFT 8
59
Jeremy Gebben955f8522012-09-24 13:05:39 -060060#define KGSL_MEMTYPE_OBJECTANY 0
61#define KGSL_MEMTYPE_FRAMEBUFFER 1
62#define KGSL_MEMTYPE_RENDERBUFFER 2
63#define KGSL_MEMTYPE_ARRAYBUFFER 3
64#define KGSL_MEMTYPE_ELEMENTARRAYBUFFER 4
65#define KGSL_MEMTYPE_VERTEXARRAYBUFFER 5
66#define KGSL_MEMTYPE_TEXTURE 6
67#define KGSL_MEMTYPE_SURFACE 7
68#define KGSL_MEMTYPE_EGL_SURFACE 8
69#define KGSL_MEMTYPE_GL 9
70#define KGSL_MEMTYPE_CL 10
71#define KGSL_MEMTYPE_CL_BUFFER_MAP 11
72#define KGSL_MEMTYPE_CL_BUFFER_NOMAP 12
73#define KGSL_MEMTYPE_CL_IMAGE_MAP 13
74#define KGSL_MEMTYPE_CL_IMAGE_NOMAP 14
75#define KGSL_MEMTYPE_CL_KERNEL_STACK 15
76#define KGSL_MEMTYPE_COMMAND 16
77#define KGSL_MEMTYPE_2D 17
78#define KGSL_MEMTYPE_EGL_IMAGE 18
79#define KGSL_MEMTYPE_EGL_SHADOW 19
80#define KGSL_MEMTYPE_MULTISAMPLE 20
81#define KGSL_MEMTYPE_KERNEL 255
82
Jordan Crouse5f237842012-09-19 15:30:48 -060083/*
84 * Alignment hint, passed as the power of 2 exponent.
85 * i.e 4k (2^12) would be 12, 64k (2^16)would be 16.
86 */
87#define KGSL_MEMALIGN_MASK 0x00FF0000
88#define KGSL_MEMALIGN_SHIFT 16
89
Jordan Crousec3b866d2012-11-08 09:05:52 -070090/* --- generic KGSL flag values --- */
91
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070092#define KGSL_FLAGS_NORMALMODE 0x00000000
93#define KGSL_FLAGS_SAFEMODE 0x00000001
94#define KGSL_FLAGS_INITIALIZED0 0x00000002
95#define KGSL_FLAGS_INITIALIZED 0x00000004
96#define KGSL_FLAGS_STARTED 0x00000008
97#define KGSL_FLAGS_ACTIVE 0x00000010
98#define KGSL_FLAGS_RESERVED0 0x00000020
99#define KGSL_FLAGS_RESERVED1 0x00000040
100#define KGSL_FLAGS_RESERVED2 0x00000080
101#define KGSL_FLAGS_SOFT_RESET 0x00000100
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700102#define KGSL_FLAGS_PER_CONTEXT_TIMESTAMPS 0x00000200
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700103
Lucille Sylvesterdce84cd2011-10-12 14:15:37 -0600104/* Clock flags to show which clocks should be controled by a given platform */
105#define KGSL_CLK_SRC 0x00000001
106#define KGSL_CLK_CORE 0x00000002
107#define KGSL_CLK_IFACE 0x00000004
108#define KGSL_CLK_MEM 0x00000008
109#define KGSL_CLK_MEM_IFACE 0x00000010
110#define KGSL_CLK_AXI 0x00000020
111
Vijay Krishnamoorthy52895312012-08-27 14:07:32 -0700112/* Server Side Sync Timeout in milliseconds */
113#define KGSL_SYNCOBJ_SERVER_TIMEOUT 2000
114
Shubhraprakash Das2dfe5dd2012-02-10 13:49:53 -0700115/*
116 * Reset status values for context
117 */
118enum kgsl_ctx_reset_stat {
119 KGSL_CTX_STAT_NO_ERROR = 0x00000000,
120 KGSL_CTX_STAT_GUILTY_CONTEXT_RESET_EXT = 0x00000001,
121 KGSL_CTX_STAT_INNOCENT_CONTEXT_RESET_EXT = 0x00000002,
122 KGSL_CTX_STAT_UNKNOWN_CONTEXT_RESET_EXT = 0x00000003
123};
124
Suman Tatiraju0123d182011-09-30 14:59:06 -0700125#define KGSL_CONVERT_TO_MBPS(val) \
126 (val*1000*1000U)
127
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700128/* device id */
129enum kgsl_deviceid {
130 KGSL_DEVICE_3D0 = 0x00000000,
131 KGSL_DEVICE_2D0 = 0x00000001,
132 KGSL_DEVICE_2D1 = 0x00000002,
133 KGSL_DEVICE_MAX = 0x00000003
134};
135
136enum kgsl_user_mem_type {
137 KGSL_USER_MEM_TYPE_PMEM = 0x00000000,
138 KGSL_USER_MEM_TYPE_ASHMEM = 0x00000001,
Jordan Crouse8eab35a2011-10-12 16:57:48 -0600139 KGSL_USER_MEM_TYPE_ADDR = 0x00000002,
140 KGSL_USER_MEM_TYPE_ION = 0x00000003,
Lynus Vaz31b5290e2012-01-18 19:20:24 +0530141 KGSL_USER_MEM_TYPE_MAX = 0x00000004,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700142};
143
144struct kgsl_devinfo {
145
146 unsigned int device_id;
147 /* chip revision id
148 * coreid:8 majorrev:8 minorrev:8 patch:8
149 */
150 unsigned int chip_id;
151 unsigned int mmu_enabled;
152 unsigned int gmem_gpubaseaddr;
153 /*
154 * This field contains the adreno revision
155 * number 200, 205, 220, etc...
156 */
157 unsigned int gpu_id;
158 unsigned int gmem_sizebytes;
159};
160
161/* this structure defines the region of memory that can be mmap()ed from this
162 driver. The timestamp fields are volatile because they are written by the
163 GPU
164*/
165struct kgsl_devmemstore {
166 volatile unsigned int soptimestamp;
167 unsigned int sbz;
168 volatile unsigned int eoptimestamp;
169 unsigned int sbz2;
170 volatile unsigned int ts_cmp_enable;
171 unsigned int sbz3;
172 volatile unsigned int ref_wait_ts;
173 unsigned int sbz4;
174 unsigned int current_context;
175 unsigned int sbz5;
176};
177
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700178#define KGSL_MEMSTORE_OFFSET(ctxt_id, field) \
179 ((ctxt_id)*sizeof(struct kgsl_devmemstore) + \
180 offsetof(struct kgsl_devmemstore, field))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700181
182/* timestamp id*/
183enum kgsl_timestamp_type {
184 KGSL_TIMESTAMP_CONSUMED = 0x00000001, /* start-of-pipeline timestamp */
185 KGSL_TIMESTAMP_RETIRED = 0x00000002, /* end-of-pipeline timestamp*/
Jordan Crousec659f382012-04-16 11:10:41 -0600186 KGSL_TIMESTAMP_QUEUED = 0x00000003,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700187};
188
189/* property types - used with kgsl_device_getproperty */
190enum kgsl_property_type {
191 KGSL_PROP_DEVICE_INFO = 0x00000001,
192 KGSL_PROP_DEVICE_SHADOW = 0x00000002,
193 KGSL_PROP_DEVICE_POWER = 0x00000003,
194 KGSL_PROP_SHMEM = 0x00000004,
195 KGSL_PROP_SHMEM_APERTURES = 0x00000005,
196 KGSL_PROP_MMU_ENABLE = 0x00000006,
197 KGSL_PROP_INTERRUPT_WAITS = 0x00000007,
198 KGSL_PROP_VERSION = 0x00000008,
Jordan Crousef7370f82012-04-18 09:31:07 -0600199 KGSL_PROP_GPU_RESET_STAT = 0x00000009,
200 KGSL_PROP_PWRCTRL = 0x0000000E,
Suman Tatiraju0ea6b832013-11-18 18:31:19 -0800201 KGSL_PROP_PWR_CONSTRAINT = 0x00000012,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700202};
203
204struct kgsl_shadowprop {
205 unsigned int gpuaddr;
206 unsigned int size;
207 unsigned int flags; /* contains KGSL_FLAGS_ values */
208};
209
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700210struct kgsl_version {
211 unsigned int drv_major;
212 unsigned int drv_minor;
213 unsigned int dev_major;
214 unsigned int dev_minor;
215};
216
Jordan Crouse35b8fe92012-10-03 09:38:42 -0600217/* Performance counter groups */
218
219#define KGSL_PERFCOUNTER_GROUP_CP 0x0
220#define KGSL_PERFCOUNTER_GROUP_RBBM 0x1
221#define KGSL_PERFCOUNTER_GROUP_PC 0x2
222#define KGSL_PERFCOUNTER_GROUP_VFD 0x3
223#define KGSL_PERFCOUNTER_GROUP_HLSQ 0x4
224#define KGSL_PERFCOUNTER_GROUP_VPC 0x5
225#define KGSL_PERFCOUNTER_GROUP_TSE 0x6
226#define KGSL_PERFCOUNTER_GROUP_RAS 0x7
227#define KGSL_PERFCOUNTER_GROUP_UCHE 0x8
228#define KGSL_PERFCOUNTER_GROUP_TP 0x9
229#define KGSL_PERFCOUNTER_GROUP_SP 0xA
230#define KGSL_PERFCOUNTER_GROUP_RB 0xB
231#define KGSL_PERFCOUNTER_GROUP_PWR 0xC
232#define KGSL_PERFCOUNTER_GROUP_VBIF 0xD
233#define KGSL_PERFCOUNTER_GROUP_VBIF_PWR 0xE
234
235#define KGSL_PERFCOUNTER_NOT_USED 0xFFFFFFFF
Carter Cooper88484882013-06-11 11:32:07 -0600236#define KGSL_PERFCOUNTER_BROKEN 0xFFFFFFFE
Jordan Crouse35b8fe92012-10-03 09:38:42 -0600237
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700238/* structure holds list of ibs */
239struct kgsl_ibdesc {
240 unsigned int gpuaddr;
241 void *hostptr;
242 unsigned int sizedwords;
243 unsigned int ctrl;
244};
245
246/* ioctls */
247#define KGSL_IOC_TYPE 0x09
248
249/* get misc info about the GPU
250 type should be a value from enum kgsl_property_type
251 value points to a structure that varies based on type
252 sizebytes is sizeof() that structure
253 for KGSL_PROP_DEVICE_INFO, use struct kgsl_devinfo
254 this structure contaings hardware versioning info.
255 for KGSL_PROP_DEVICE_SHADOW, use struct kgsl_shadowprop
256 this is used to find mmap() offset and sizes for mapping
257 struct kgsl_memstore into userspace.
258*/
259struct kgsl_device_getproperty {
260 unsigned int type;
261 void *value;
262 unsigned int sizebytes;
263};
264
265#define IOCTL_KGSL_DEVICE_GETPROPERTY \
266 _IOWR(KGSL_IOC_TYPE, 0x2, struct kgsl_device_getproperty)
267
Harsh Vardhan Dwivedib6cebfe2012-03-15 18:20:59 -0600268/* IOCTL_KGSL_DEVICE_READ (0x3) - removed 03/2012
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700269 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700270
271/* block until the GPU has executed past a given timestamp
272 * timeout is in milliseconds.
273 */
274struct kgsl_device_waittimestamp {
275 unsigned int timestamp;
276 unsigned int timeout;
277};
278
279#define IOCTL_KGSL_DEVICE_WAITTIMESTAMP \
280 _IOW(KGSL_IOC_TYPE, 0x6, struct kgsl_device_waittimestamp)
281
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700282struct kgsl_device_waittimestamp_ctxtid {
283 unsigned int context_id;
284 unsigned int timestamp;
285 unsigned int timeout;
286};
287
288#define IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID \
289 _IOW(KGSL_IOC_TYPE, 0x7, struct kgsl_device_waittimestamp_ctxtid)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700290
Jordan Crouse2371c9b2013-11-05 09:25:58 -0700291/* DEPRECATED: issue indirect commands to the GPU.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700292 * drawctxt_id must have been created with IOCTL_KGSL_DRAWCTXT_CREATE
293 * ibaddr and sizedwords must specify a subset of a buffer created
294 * with IOCTL_KGSL_SHAREDMEM_FROM_PMEM
295 * flags may be a mask of KGSL_CONTEXT_ values
296 * timestamp is a returned counter value which can be passed to
297 * other ioctls to determine when the commands have been executed by
298 * the GPU.
Jordan Crouse2371c9b2013-11-05 09:25:58 -0700299 *
300 * This fucntion is deprecated - consider using IOCTL_KGSL_SUBMIT_COMMANDS
301 * instead
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700302 */
303struct kgsl_ringbuffer_issueibcmds {
304 unsigned int drawctxt_id;
305 unsigned int ibdesc_addr;
306 unsigned int numibs;
307 unsigned int timestamp; /*output param */
308 unsigned int flags;
309};
310
311#define IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS \
312 _IOWR(KGSL_IOC_TYPE, 0x10, struct kgsl_ringbuffer_issueibcmds)
313
314/* read the most recently executed timestamp value
315 * type should be a value from enum kgsl_timestamp_type
316 */
317struct kgsl_cmdstream_readtimestamp {
318 unsigned int type;
319 unsigned int timestamp; /*output param */
320};
321
Jason Varbedian80ba33d2011-07-11 17:29:05 -0700322#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_OLD \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700323 _IOR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp)
324
Jason Varbedian80ba33d2011-07-11 17:29:05 -0700325#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP \
326 _IOWR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp)
327
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700328/* free memory when the GPU reaches a given timestamp.
329 * gpuaddr specify a memory region created by a
330 * IOCTL_KGSL_SHAREDMEM_FROM_PMEM call
331 * type should be a value from enum kgsl_timestamp_type
332 */
333struct kgsl_cmdstream_freememontimestamp {
334 unsigned int gpuaddr;
335 unsigned int type;
336 unsigned int timestamp;
337};
338
339#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP \
340 _IOW(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp)
341
342/* Previous versions of this header had incorrectly defined
343 IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP as a read-only ioctl instead
344 of a write only ioctl. To ensure binary compatability, the following
345 #define will be used to intercept the incorrect ioctl
346*/
347
348#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_OLD \
349 _IOR(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp)
350
351/* create a draw context, which is used to preserve GPU state.
352 * The flags field may contain a mask KGSL_CONTEXT_* values
353 */
354struct kgsl_drawctxt_create {
355 unsigned int flags;
356 unsigned int drawctxt_id; /*output param */
357};
358
359#define IOCTL_KGSL_DRAWCTXT_CREATE \
360 _IOWR(KGSL_IOC_TYPE, 0x13, struct kgsl_drawctxt_create)
361
362/* destroy a draw context */
363struct kgsl_drawctxt_destroy {
364 unsigned int drawctxt_id;
365};
366
367#define IOCTL_KGSL_DRAWCTXT_DESTROY \
368 _IOW(KGSL_IOC_TYPE, 0x14, struct kgsl_drawctxt_destroy)
369
370/* add a block of pmem, fb, ashmem or user allocated address
371 * into the GPU address space */
372struct kgsl_map_user_mem {
373 int fd;
374 unsigned int gpuaddr; /*output param */
375 unsigned int len;
376 unsigned int offset;
377 unsigned int hostptr; /*input param */
378 enum kgsl_user_mem_type memtype;
Jeremy Gebben955f8522012-09-24 13:05:39 -0600379 unsigned int flags;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700380};
381
382#define IOCTL_KGSL_MAP_USER_MEM \
383 _IOWR(KGSL_IOC_TYPE, 0x15, struct kgsl_map_user_mem)
384
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700385struct kgsl_cmdstream_readtimestamp_ctxtid {
386 unsigned int context_id;
387 unsigned int type;
388 unsigned int timestamp; /*output param */
389};
390
391#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_CTXTID \
392 _IOWR(KGSL_IOC_TYPE, 0x16, struct kgsl_cmdstream_readtimestamp_ctxtid)
393
394struct kgsl_cmdstream_freememontimestamp_ctxtid {
395 unsigned int context_id;
396 unsigned int gpuaddr;
397 unsigned int type;
398 unsigned int timestamp;
399};
400
401#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_CTXTID \
402 _IOW(KGSL_IOC_TYPE, 0x17, \
403 struct kgsl_cmdstream_freememontimestamp_ctxtid)
404
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700405/* add a block of pmem or fb into the GPU address space */
406struct kgsl_sharedmem_from_pmem {
407 int pmem_fd;
408 unsigned int gpuaddr; /*output param */
409 unsigned int len;
410 unsigned int offset;
411};
412
413#define IOCTL_KGSL_SHAREDMEM_FROM_PMEM \
414 _IOWR(KGSL_IOC_TYPE, 0x20, struct kgsl_sharedmem_from_pmem)
415
416/* remove memory from the GPU's address space */
417struct kgsl_sharedmem_free {
418 unsigned int gpuaddr;
419};
420
421#define IOCTL_KGSL_SHAREDMEM_FREE \
422 _IOW(KGSL_IOC_TYPE, 0x21, struct kgsl_sharedmem_free)
423
Sushmita Susheelendra41f8fa32011-05-11 17:15:58 -0600424struct kgsl_cff_user_event {
425 unsigned char cff_opcode;
426 unsigned int op1;
427 unsigned int op2;
428 unsigned int op3;
429 unsigned int op4;
430 unsigned int op5;
431 unsigned int __pad[2];
432};
433
434#define IOCTL_KGSL_CFF_USER_EVENT \
435 _IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_cff_user_event)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700436
437struct kgsl_gmem_desc {
438 unsigned int x;
439 unsigned int y;
440 unsigned int width;
441 unsigned int height;
442 unsigned int pitch;
443};
444
445struct kgsl_buffer_desc {
446 void *hostptr;
447 unsigned int gpuaddr;
448 int size;
449 unsigned int format;
450 unsigned int pitch;
451 unsigned int enabled;
452};
453
454struct kgsl_bind_gmem_shadow {
455 unsigned int drawctxt_id;
456 struct kgsl_gmem_desc gmem_desc;
457 unsigned int shadow_x;
458 unsigned int shadow_y;
459 struct kgsl_buffer_desc shadow_buffer;
460 unsigned int buffer_id;
461};
462
463#define IOCTL_KGSL_DRAWCTXT_BIND_GMEM_SHADOW \
464 _IOW(KGSL_IOC_TYPE, 0x22, struct kgsl_bind_gmem_shadow)
465
466/* add a block of memory into the GPU address space */
Jordan Crousec6005102012-09-11 16:38:14 -0600467
468/*
469 * IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC deprecated 09/2012
470 * use IOCTL_KGSL_GPUMEM_ALLOC instead
471 */
472
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700473struct kgsl_sharedmem_from_vmalloc {
474 unsigned int gpuaddr; /*output param */
475 unsigned int hostptr;
476 unsigned int flags;
477};
478
479#define IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC \
480 _IOWR(KGSL_IOC_TYPE, 0x23, struct kgsl_sharedmem_from_vmalloc)
481
Jordan Crousec3b866d2012-11-08 09:05:52 -0700482/*
483 * This is being deprecated in favor of IOCTL_KGSL_GPUMEM_CACHE_SYNC which
484 * supports both directions (flush and invalidate). This code will still
485 * work, but by definition it will do a flush of the cache which might not be
486 * what you want to have happen on a buffer following a GPU operation. It is
487 * safer to go with IOCTL_KGSL_GPUMEM_CACHE_SYNC
488 */
489
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700490#define IOCTL_KGSL_SHAREDMEM_FLUSH_CACHE \
491 _IOW(KGSL_IOC_TYPE, 0x24, struct kgsl_sharedmem_free)
492
493struct kgsl_drawctxt_set_bin_base_offset {
494 unsigned int drawctxt_id;
495 unsigned int offset;
496};
497
498#define IOCTL_KGSL_DRAWCTXT_SET_BIN_BASE_OFFSET \
499 _IOW(KGSL_IOC_TYPE, 0x25, struct kgsl_drawctxt_set_bin_base_offset)
500
501enum kgsl_cmdwindow_type {
502 KGSL_CMDWINDOW_MIN = 0x00000000,
503 KGSL_CMDWINDOW_2D = 0x00000000,
504 KGSL_CMDWINDOW_3D = 0x00000001, /* legacy */
505 KGSL_CMDWINDOW_MMU = 0x00000002,
506 KGSL_CMDWINDOW_ARBITER = 0x000000FF,
507 KGSL_CMDWINDOW_MAX = 0x000000FF,
508};
509
510/* write to the command window */
511struct kgsl_cmdwindow_write {
512 enum kgsl_cmdwindow_type target;
513 unsigned int addr;
514 unsigned int data;
515};
516
517#define IOCTL_KGSL_CMDWINDOW_WRITE \
518 _IOW(KGSL_IOC_TYPE, 0x2e, struct kgsl_cmdwindow_write)
519
520struct kgsl_gpumem_alloc {
521 unsigned long gpuaddr;
522 size_t size;
523 unsigned int flags;
524};
525
526#define IOCTL_KGSL_GPUMEM_ALLOC \
527 _IOWR(KGSL_IOC_TYPE, 0x2f, struct kgsl_gpumem_alloc)
528
Jeremy Gebbena7423e42011-04-18 15:11:21 -0600529struct kgsl_cff_syncmem {
530 unsigned int gpuaddr;
531 unsigned int len;
532 unsigned int __pad[2]; /* For future binary compatibility */
533};
534
535#define IOCTL_KGSL_CFF_SYNCMEM \
536 _IOW(KGSL_IOC_TYPE, 0x30, struct kgsl_cff_syncmem)
537
Jordan Croused4bc9d22011-11-17 13:39:21 -0700538/*
539 * A timestamp event allows the user space to register an action following an
Jeff Boody97ae63d2012-08-09 13:54:50 -0600540 * expired timestamp. Note IOCTL_KGSL_TIMESTAMP_EVENT has been redefined to
541 * _IOWR to support fences which need to return a fd for the priv parameter.
Jordan Croused4bc9d22011-11-17 13:39:21 -0700542 */
543
544struct kgsl_timestamp_event {
545 int type; /* Type of event (see list below) */
546 unsigned int timestamp; /* Timestamp to trigger event on */
547 unsigned int context_id; /* Context for the timestamp */
548 void *priv; /* Pointer to the event specific blob */
549 size_t len; /* Size of the event specific blob */
550};
551
Jeff Boody97ae63d2012-08-09 13:54:50 -0600552#define IOCTL_KGSL_TIMESTAMP_EVENT_OLD \
Jordan Croused4bc9d22011-11-17 13:39:21 -0700553 _IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_timestamp_event)
554
555/* A genlock timestamp event releases an existing lock on timestamp expire */
556
557#define KGSL_TIMESTAMP_EVENT_GENLOCK 1
558
559struct kgsl_timestamp_event_genlock {
560 int handle; /* Handle of the genlock lock to release */
561};
562
Jeff Boody97ae63d2012-08-09 13:54:50 -0600563/* A fence timestamp event releases an existing lock on timestamp expire */
564
565#define KGSL_TIMESTAMP_EVENT_FENCE 2
566
567struct kgsl_timestamp_event_fence {
568 int fence_fd; /* Fence to signal */
569};
570
Jordan Crouseed7dd7f2012-03-29 13:16:02 -0600571/*
572 * Set a property within the kernel. Uses the same structure as
573 * IOCTL_KGSL_GETPROPERTY
574 */
575
576#define IOCTL_KGSL_SETPROPERTY \
577 _IOW(KGSL_IOC_TYPE, 0x32, struct kgsl_device_getproperty)
578
Jeff Boody97ae63d2012-08-09 13:54:50 -0600579#define IOCTL_KGSL_TIMESTAMP_EVENT \
580 _IOWR(KGSL_IOC_TYPE, 0x33, struct kgsl_timestamp_event)
581
Jeremy Gebben058cea02012-10-30 15:18:06 -0600582/**
583 * struct kgsl_gpumem_alloc_id - argument to IOCTL_KGSL_GPUMEM_ALLOC_ID
584 * @id: returned id value for this allocation.
585 * @flags: mask of KGSL_MEM* values requested and actual flags on return.
586 * @size: requested size of the allocation and actual size on return.
587 * @mmapsize: returned size to pass to mmap() which may be larger than 'size'
588 * @gpuaddr: returned GPU address for the allocation
589 *
590 * Allocate memory for access by the GPU. The flags and size fields are echoed
591 * back by the kernel, so that the caller can know if the request was
592 * adjusted.
593 *
594 * Supported flags:
595 * KGSL_MEMFLAGS_GPUREADONLY: the GPU will be unable to write to the buffer
596 * KGSL_MEMTYPE*: usage hint for debugging aid
597 * KGSL_MEMALIGN*: alignment hint, may be ignored or adjusted by the kernel.
Jeremy Gebben0d6f1482012-10-30 15:40:58 -0600598 * KGSL_MEMFLAGS_USE_CPU_MAP: If set on call and return, the returned GPU
599 * address will be 0. Calling mmap() will set the GPU address.
Jeremy Gebben058cea02012-10-30 15:18:06 -0600600 */
601struct kgsl_gpumem_alloc_id {
602 unsigned int id;
603 unsigned int flags;
604 unsigned int size;
605 unsigned int mmapsize;
606 unsigned long gpuaddr;
607/* private: reserved for future use*/
608 unsigned int __pad[2];
609};
610
611#define IOCTL_KGSL_GPUMEM_ALLOC_ID \
612 _IOWR(KGSL_IOC_TYPE, 0x34, struct kgsl_gpumem_alloc_id)
613
614/**
615 * struct kgsl_gpumem_free_id - argument to IOCTL_KGSL_GPUMEM_FREE_ID
616 * @id: GPU allocation id to free
617 *
618 * Free an allocation by id, in case a GPU address has not been assigned or
619 * is unknown. Freeing an allocation by id with this ioctl or by GPU address
620 * with IOCTL_KGSL_SHAREDMEM_FREE are equivalent.
621 */
622struct kgsl_gpumem_free_id {
623 unsigned int id;
624/* private: reserved for future use*/
625 unsigned int __pad;
626};
627
628#define IOCTL_KGSL_GPUMEM_FREE_ID \
629 _IOWR(KGSL_IOC_TYPE, 0x35, struct kgsl_gpumem_free_id)
630
631/**
632 * struct kgsl_gpumem_get_info - argument to IOCTL_KGSL_GPUMEM_GET_INFO
633 * @gpuaddr: GPU address to query. Also set on return.
634 * @id: GPU allocation id to query. Also set on return.
635 * @flags: returned mask of KGSL_MEM* values.
636 * @size: returned size of the allocation.
637 * @mmapsize: returned size to pass mmap(), which may be larger than 'size'
638 * @useraddr: returned address of the userspace mapping for this buffer
639 *
640 * This ioctl allows querying of all user visible attributes of an existing
641 * allocation, by either the GPU address or the id returned by a previous
642 * call to IOCTL_KGSL_GPUMEM_ALLOC_ID. Legacy allocation ioctls may not
643 * return all attributes so this ioctl can be used to look them up if needed.
644 *
645 */
646struct kgsl_gpumem_get_info {
647 unsigned long gpuaddr;
648 unsigned int id;
649 unsigned int flags;
650 unsigned int size;
651 unsigned int mmapsize;
652 unsigned long useraddr;
653/* private: reserved for future use*/
654 unsigned int __pad[4];
655};
656
657#define IOCTL_KGSL_GPUMEM_GET_INFO\
658 _IOWR(KGSL_IOC_TYPE, 0x36, struct kgsl_gpumem_get_info)
659
Jordan Crousec3b866d2012-11-08 09:05:52 -0700660/**
661 * struct kgsl_gpumem_sync_cache - argument to IOCTL_KGSL_GPUMEM_SYNC_CACHE
662 * @gpuaddr: GPU address of the buffer to sync.
663 * @id: id of the buffer to sync. Either gpuaddr or id is sufficient.
664 * @op: a mask of KGSL_GPUMEM_CACHE_* values
665 *
666 * Sync the L2 cache for memory headed to and from the GPU - this replaces
667 * KGSL_SHAREDMEM_FLUSH_CACHE since it can handle cache management for both
668 * directions
669 *
670 */
671struct kgsl_gpumem_sync_cache {
672 unsigned int gpuaddr;
673 unsigned int id;
674 unsigned int op;
675/* private: reserved for future use*/
676 unsigned int __pad[2]; /* For future binary compatibility */
677};
678
679#define KGSL_GPUMEM_CACHE_CLEAN (1 << 0)
680#define KGSL_GPUMEM_CACHE_TO_GPU KGSL_GPUMEM_CACHE_CLEAN
681
682#define KGSL_GPUMEM_CACHE_INV (1 << 1)
683#define KGSL_GPUMEM_CACHE_FROM_GPU KGSL_GPUMEM_CACHE_INV
684
685#define KGSL_GPUMEM_CACHE_FLUSH \
686 (KGSL_GPUMEM_CACHE_CLEAN | KGSL_GPUMEM_CACHE_INV)
687
688#define IOCTL_KGSL_GPUMEM_SYNC_CACHE \
689 _IOW(KGSL_IOC_TYPE, 0x37, struct kgsl_gpumem_sync_cache)
690
Jordan Crouse35b8fe92012-10-03 09:38:42 -0600691/**
692 * struct kgsl_perfcounter_get - argument to IOCTL_KGSL_PERFCOUNTER_GET
693 * @groupid: Performance counter group ID
694 * @countable: Countable to select within the group
695 * @offset: Return offset of the reserved counter
696 *
697 * Get an available performance counter from a specified groupid. The offset
698 * of the performance counter will be returned after successfully assigning
699 * the countable to the counter for the specified group. An error will be
700 * returned and an offset of 0 if the groupid is invalid or there are no
701 * more counters left. After successfully getting a perfcounter, the user
702 * must call kgsl_perfcounter_put(groupid, contable) when finished with
703 * the perfcounter to clear up perfcounter resources.
704 *
705 */
706struct kgsl_perfcounter_get {
707 unsigned int groupid;
708 unsigned int countable;
709 unsigned int offset;
710/* private: reserved for future use */
711 unsigned int __pad[2]; /* For future binary compatibility */
712};
713
714#define IOCTL_KGSL_PERFCOUNTER_GET \
715 _IOWR(KGSL_IOC_TYPE, 0x38, struct kgsl_perfcounter_get)
716
717/**
718 * struct kgsl_perfcounter_put - argument to IOCTL_KGSL_PERFCOUNTER_PUT
719 * @groupid: Performance counter group ID
720 * @countable: Countable to release within the group
721 *
722 * Put an allocated performance counter to allow others to have access to the
723 * resource that was previously taken. This is only to be called after
724 * successfully getting a performance counter from kgsl_perfcounter_get().
725 *
726 */
727struct kgsl_perfcounter_put {
728 unsigned int groupid;
729 unsigned int countable;
730/* private: reserved for future use */
731 unsigned int __pad[2]; /* For future binary compatibility */
732};
733
734#define IOCTL_KGSL_PERFCOUNTER_PUT \
735 _IOW(KGSL_IOC_TYPE, 0x39, struct kgsl_perfcounter_put)
736
737/**
738 * struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY
739 * @groupid: Performance counter group ID
740 * @countable: Return active countables array
741 * @size: Size of active countables array
742 * @max_counters: Return total number counters for the group ID
743 *
744 * Query the available performance counters given a groupid. The array
745 * *countables is used to return the current active countables in counters.
746 * The size of the array is passed in so the kernel will only write at most
747 * size or counter->size for the group id. The total number of available
748 * counters for the group ID is returned in max_counters.
749 * If the array or size passed in are invalid, then only the maximum number
750 * of counters will be returned, no data will be written to *countables.
751 * If the groupid is invalid an error code will be returned.
752 *
753 */
754struct kgsl_perfcounter_query {
755 unsigned int groupid;
756 /* Array to return the current countable for up to size counters */
757 unsigned int *countables;
758 unsigned int count;
759 unsigned int max_counters;
760/* private: reserved for future use */
761 unsigned int __pad[2]; /* For future binary compatibility */
762};
763
764#define IOCTL_KGSL_PERFCOUNTER_QUERY \
765 _IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query)
766
767/**
768 * struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY
769 * @groupid: Performance counter group IDs
770 * @countable: Performance counter countable IDs
771 * @value: Return performance counter reads
772 * @size: Size of all arrays (groupid/countable pair and return value)
773 *
774 * Read in the current value of a performance counter given by the groupid
775 * and countable.
776 *
777 */
778
779struct kgsl_perfcounter_read_group {
780 unsigned int groupid;
781 unsigned int countable;
Shubhraprakash Dase0345ca892013-04-30 16:20:32 -0700782 unsigned long long value;
Jordan Crouse35b8fe92012-10-03 09:38:42 -0600783};
784
785struct kgsl_perfcounter_read {
786 struct kgsl_perfcounter_read_group *reads;
787 unsigned int count;
788/* private: reserved for future use */
789 unsigned int __pad[2]; /* For future binary compatibility */
790};
791
792#define IOCTL_KGSL_PERFCOUNTER_READ \
793 _IOWR(KGSL_IOC_TYPE, 0x3B, struct kgsl_perfcounter_read)
Jeremy Gebbene4f2f972013-04-09 15:14:33 -0600794/*
795 * struct kgsl_gpumem_sync_cache_bulk - argument to
796 * IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK
797 * @id_list: list of GPU buffer ids of the buffers to sync
798 * @count: number of GPU buffer ids in id_list
799 * @op: a mask of KGSL_GPUMEM_CACHE_* values
800 *
801 * Sync the cache for memory headed to and from the GPU. Certain
802 * optimizations can be made on the cache operation based on the total
803 * size of the working set of memory to be managed.
804 */
805struct kgsl_gpumem_sync_cache_bulk {
806 unsigned int *id_list;
807 unsigned int count;
808 unsigned int op;
809/* private: reserved for future use */
810 unsigned int __pad[2]; /* For future binary compatibility */
811};
812
813#define IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK \
814 _IOWR(KGSL_IOC_TYPE, 0x3C, struct kgsl_gpumem_sync_cache_bulk)
Jordan Crouse35b8fe92012-10-03 09:38:42 -0600815
Jordan Crouse2371c9b2013-11-05 09:25:58 -0700816/*
817 * struct kgsl_cmd_syncpoint_timestamp
818 * @context_id: ID of a KGSL context
819 * @timestamp: GPU timestamp
820 *
821 * This structure defines a syncpoint comprising a context/timestamp pair. A
822 * list of these may be passed by IOCTL_KGSL_SUBMIT_COMMANDS to define
823 * dependencies that must be met before the command can be submitted to the
824 * hardware
825 */
826struct kgsl_cmd_syncpoint_timestamp {
827 unsigned int context_id;
828 unsigned int timestamp;
829};
830
831#define KGSL_CMD_SYNCPOINT_TYPE_TIMESTAMP 0
832
833struct kgsl_cmd_syncpoint_fence {
834 int fd;
835};
836
837#define KGSL_CMD_SYNCPOINT_TYPE_FENCE 1
838
839/**
840 * struct kgsl_cmd_syncpoint - Define a sync point for a command batch
841 * @type: type of sync point defined here
842 * @priv: Pointer to the type specific buffer
843 * @size: Size of the type specific buffer
844 *
845 * This structure contains pointers defining a specific command sync point.
846 * The pointer and size should point to a type appropriate structure.
847 */
848struct kgsl_cmd_syncpoint {
849 int type;
850 void __user *priv;
851 unsigned int size;
852};
853
854/**
855 * struct kgsl_submit_commands - Argument to IOCTL_KGSL_SUBMIT_COMMANDS
856 * @context_id: KGSL context ID that owns the commands
857 * @flags:
858 * @cmdlist: User pointer to a list of kgsl_ibdesc structures
859 * @numcmds: Number of commands listed in cmdlist
860 * @synclist: User pointer to a list of kgsl_cmd_syncpoint structures
861 * @numsyncs: Number of sync points listed in synclist
862 * @timestamp: On entry the a user defined timestamp, on exist the timestamp
863 * assigned to the command batch
864 *
865 * This structure specifies a command to send to the GPU hardware. This is
866 * similar to kgsl_issueibcmds expect that it doesn't support the legacy way to
867 * submit IB lists and it adds sync points to block the IB until the
868 * dependencies are satisified. This entry point is the new and preferred way
869 * to submit commands to the GPU.
870 */
871
872struct kgsl_submit_commands {
873 unsigned int context_id;
874 unsigned int flags;
875 struct kgsl_ibdesc __user *cmdlist;
876 unsigned int numcmds;
877 struct kgsl_cmd_syncpoint __user *synclist;
878 unsigned int numsyncs;
879 unsigned int timestamp;
880/* private: reserved for future use */
881 unsigned int __pad[4];
882};
883
884#define IOCTL_KGSL_SUBMIT_COMMANDS \
885 _IOWR(KGSL_IOC_TYPE, 0x3D, struct kgsl_submit_commands)
886
Suman Tatiraju0ea6b832013-11-18 18:31:19 -0800887/**
888 * struct kgsl_device_constraint - device constraint argument
889 * @context_id: KGSL context ID
890 * @type: type of constraint i.e pwrlevel/none
891 * @data: constraint data
892 * @size: size of the constraint data
893 */
894struct kgsl_device_constraint {
895 unsigned int type;
896 unsigned int context_id;
897 void __user *data;
898 size_t size;
899};
900
901/* Constraint Type*/
902#define KGSL_CONSTRAINT_NONE 0
903#define KGSL_CONSTRAINT_PWRLEVEL 1
904
905/* PWRLEVEL constraint level*/
906/* set to min frequency */
907#define KGSL_CONSTRAINT_PWR_MIN 0
908/* set to max frequency */
909#define KGSL_CONSTRAINT_PWR_MAX 1
910
911struct kgsl_device_constraint_pwrlevel {
912 unsigned int level;
913};
914
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700915#ifdef __KERNEL__
916#ifdef CONFIG_MSM_KGSL_DRM
917int kgsl_gem_obj_addr(int drm_fd, int handle, unsigned long *start,
918 unsigned long *len);
919#else
920#define kgsl_gem_obj_addr(...) 0
921#endif
922#endif
923#endif /* _MSM_KGSL_H */