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