blob: 1eb346be559573892acb37f89b6b9bef6a3cc634 [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 Croused2a5a432013-03-25 15:30:48 -060026/* bits [12:15] are reserved for future use */
27#define KGSL_CONTEXT_TYPE_MASK 0x01F00000
28#define KGSL_CONTEXT_TYPE_SHIFT 20
Tarun Karra973ea7042013-02-05 19:45:49 -080029
Jordan Croused2a5a432013-03-25 15:30:48 -060030#define KGSL_CONTEXT_TYPE_ANY 0
31#define KGSL_CONTEXT_TYPE_GL 1
32#define KGSL_CONTEXT_TYPE_CL 2
33#define KGSL_CONTEXT_TYPE_C2D 3
34#define KGSL_CONTEXT_TYPE_RS 4
Carter Cooper9abac662013-05-31 18:14:15 -060035#define KGSL_CONTEXT_TYPE_UNKNOWN 0x1E
Carter Cooper7e7f02e2012-02-15 09:36:31 -070036
37#define KGSL_CONTEXT_INVALID 0xffffffff
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070038
Jordan Crousec3b866d2012-11-08 09:05:52 -070039/* --- Memory allocation flags --- */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070040
Jordan Crousec3b866d2012-11-08 09:05:52 -070041/* General allocation hints */
42#define KGSL_MEMFLAGS_GPUREADONLY 0x01000000
Jeremy Gebben0d6f1482012-10-30 15:40:58 -060043#define KGSL_MEMFLAGS_USE_CPU_MAP 0x10000000
Jordan Crousec3b866d2012-11-08 09:05:52 -070044
45/* Memory caching hints */
46#define KGSL_CACHEMODE_MASK 0x0C000000
47#define KGSL_CACHEMODE_SHIFT 26
48
49#define KGSL_CACHEMODE_WRITECOMBINE 0
50#define KGSL_CACHEMODE_UNCACHED 1
51#define KGSL_CACHEMODE_WRITETHROUGH 2
52#define KGSL_CACHEMODE_WRITEBACK 3
53
54/* Memory types for which allocations are made */
Jeremy Gebben955f8522012-09-24 13:05:39 -060055#define KGSL_MEMTYPE_MASK 0x0000FF00
56#define KGSL_MEMTYPE_SHIFT 8
57
Jeremy Gebben955f8522012-09-24 13:05:39 -060058#define KGSL_MEMTYPE_OBJECTANY 0
59#define KGSL_MEMTYPE_FRAMEBUFFER 1
60#define KGSL_MEMTYPE_RENDERBUFFER 2
61#define KGSL_MEMTYPE_ARRAYBUFFER 3
62#define KGSL_MEMTYPE_ELEMENTARRAYBUFFER 4
63#define KGSL_MEMTYPE_VERTEXARRAYBUFFER 5
64#define KGSL_MEMTYPE_TEXTURE 6
65#define KGSL_MEMTYPE_SURFACE 7
66#define KGSL_MEMTYPE_EGL_SURFACE 8
67#define KGSL_MEMTYPE_GL 9
68#define KGSL_MEMTYPE_CL 10
69#define KGSL_MEMTYPE_CL_BUFFER_MAP 11
70#define KGSL_MEMTYPE_CL_BUFFER_NOMAP 12
71#define KGSL_MEMTYPE_CL_IMAGE_MAP 13
72#define KGSL_MEMTYPE_CL_IMAGE_NOMAP 14
73#define KGSL_MEMTYPE_CL_KERNEL_STACK 15
74#define KGSL_MEMTYPE_COMMAND 16
75#define KGSL_MEMTYPE_2D 17
76#define KGSL_MEMTYPE_EGL_IMAGE 18
77#define KGSL_MEMTYPE_EGL_SHADOW 19
78#define KGSL_MEMTYPE_MULTISAMPLE 20
79#define KGSL_MEMTYPE_KERNEL 255
80
Jordan Crouse5f237842012-09-19 15:30:48 -060081/*
82 * Alignment hint, passed as the power of 2 exponent.
83 * i.e 4k (2^12) would be 12, 64k (2^16)would be 16.
84 */
85#define KGSL_MEMALIGN_MASK 0x00FF0000
86#define KGSL_MEMALIGN_SHIFT 16
87
Jordan Crousec3b866d2012-11-08 09:05:52 -070088/* --- generic KGSL flag values --- */
89
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070090#define KGSL_FLAGS_NORMALMODE 0x00000000
91#define KGSL_FLAGS_SAFEMODE 0x00000001
92#define KGSL_FLAGS_INITIALIZED0 0x00000002
93#define KGSL_FLAGS_INITIALIZED 0x00000004
94#define KGSL_FLAGS_STARTED 0x00000008
95#define KGSL_FLAGS_ACTIVE 0x00000010
96#define KGSL_FLAGS_RESERVED0 0x00000020
97#define KGSL_FLAGS_RESERVED1 0x00000040
98#define KGSL_FLAGS_RESERVED2 0x00000080
99#define KGSL_FLAGS_SOFT_RESET 0x00000100
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700100#define KGSL_FLAGS_PER_CONTEXT_TIMESTAMPS 0x00000200
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700101
Lucille Sylvesterdce84cd2011-10-12 14:15:37 -0600102/* Clock flags to show which clocks should be controled by a given platform */
103#define KGSL_CLK_SRC 0x00000001
104#define KGSL_CLK_CORE 0x00000002
105#define KGSL_CLK_IFACE 0x00000004
106#define KGSL_CLK_MEM 0x00000008
107#define KGSL_CLK_MEM_IFACE 0x00000010
108#define KGSL_CLK_AXI 0x00000020
109
Vijay Krishnamoorthy52895312012-08-27 14:07:32 -0700110/* Server Side Sync Timeout in milliseconds */
111#define KGSL_SYNCOBJ_SERVER_TIMEOUT 2000
112
Shubhraprakash Das2dfe5dd2012-02-10 13:49:53 -0700113/*
114 * Reset status values for context
115 */
116enum kgsl_ctx_reset_stat {
117 KGSL_CTX_STAT_NO_ERROR = 0x00000000,
118 KGSL_CTX_STAT_GUILTY_CONTEXT_RESET_EXT = 0x00000001,
119 KGSL_CTX_STAT_INNOCENT_CONTEXT_RESET_EXT = 0x00000002,
120 KGSL_CTX_STAT_UNKNOWN_CONTEXT_RESET_EXT = 0x00000003
121};
122
Suman Tatiraju0123d182011-09-30 14:59:06 -0700123#define KGSL_CONVERT_TO_MBPS(val) \
124 (val*1000*1000U)
125
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700126/* device id */
127enum kgsl_deviceid {
128 KGSL_DEVICE_3D0 = 0x00000000,
129 KGSL_DEVICE_2D0 = 0x00000001,
130 KGSL_DEVICE_2D1 = 0x00000002,
131 KGSL_DEVICE_MAX = 0x00000003
132};
133
134enum kgsl_user_mem_type {
135 KGSL_USER_MEM_TYPE_PMEM = 0x00000000,
136 KGSL_USER_MEM_TYPE_ASHMEM = 0x00000001,
Jordan Crouse8eab35a2011-10-12 16:57:48 -0600137 KGSL_USER_MEM_TYPE_ADDR = 0x00000002,
138 KGSL_USER_MEM_TYPE_ION = 0x00000003,
Lynus Vaz31b5290e2012-01-18 19:20:24 +0530139 KGSL_USER_MEM_TYPE_MAX = 0x00000004,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700140};
141
142struct kgsl_devinfo {
143
144 unsigned int device_id;
145 /* chip revision id
146 * coreid:8 majorrev:8 minorrev:8 patch:8
147 */
148 unsigned int chip_id;
149 unsigned int mmu_enabled;
150 unsigned int gmem_gpubaseaddr;
151 /*
152 * This field contains the adreno revision
153 * number 200, 205, 220, etc...
154 */
155 unsigned int gpu_id;
156 unsigned int gmem_sizebytes;
157};
158
159/* this structure defines the region of memory that can be mmap()ed from this
160 driver. The timestamp fields are volatile because they are written by the
161 GPU
162*/
163struct kgsl_devmemstore {
164 volatile unsigned int soptimestamp;
165 unsigned int sbz;
166 volatile unsigned int eoptimestamp;
167 unsigned int sbz2;
168 volatile unsigned int ts_cmp_enable;
169 unsigned int sbz3;
170 volatile unsigned int ref_wait_ts;
171 unsigned int sbz4;
172 unsigned int current_context;
173 unsigned int sbz5;
174};
175
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700176#define KGSL_MEMSTORE_OFFSET(ctxt_id, field) \
177 ((ctxt_id)*sizeof(struct kgsl_devmemstore) + \
178 offsetof(struct kgsl_devmemstore, field))
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700179
180/* timestamp id*/
181enum kgsl_timestamp_type {
182 KGSL_TIMESTAMP_CONSUMED = 0x00000001, /* start-of-pipeline timestamp */
183 KGSL_TIMESTAMP_RETIRED = 0x00000002, /* end-of-pipeline timestamp*/
Jordan Crousec659f382012-04-16 11:10:41 -0600184 KGSL_TIMESTAMP_QUEUED = 0x00000003,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700185};
186
187/* property types - used with kgsl_device_getproperty */
188enum kgsl_property_type {
189 KGSL_PROP_DEVICE_INFO = 0x00000001,
190 KGSL_PROP_DEVICE_SHADOW = 0x00000002,
191 KGSL_PROP_DEVICE_POWER = 0x00000003,
192 KGSL_PROP_SHMEM = 0x00000004,
193 KGSL_PROP_SHMEM_APERTURES = 0x00000005,
194 KGSL_PROP_MMU_ENABLE = 0x00000006,
195 KGSL_PROP_INTERRUPT_WAITS = 0x00000007,
196 KGSL_PROP_VERSION = 0x00000008,
Jordan Crousef7370f82012-04-18 09:31:07 -0600197 KGSL_PROP_GPU_RESET_STAT = 0x00000009,
198 KGSL_PROP_PWRCTRL = 0x0000000E,
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700199};
200
201struct kgsl_shadowprop {
202 unsigned int gpuaddr;
203 unsigned int size;
204 unsigned int flags; /* contains KGSL_FLAGS_ values */
205};
206
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700207struct kgsl_version {
208 unsigned int drv_major;
209 unsigned int drv_minor;
210 unsigned int dev_major;
211 unsigned int dev_minor;
212};
213
Jordan Crouse35b8fe92012-10-03 09:38:42 -0600214/* Performance counter groups */
215
216#define KGSL_PERFCOUNTER_GROUP_CP 0x0
217#define KGSL_PERFCOUNTER_GROUP_RBBM 0x1
218#define KGSL_PERFCOUNTER_GROUP_PC 0x2
219#define KGSL_PERFCOUNTER_GROUP_VFD 0x3
220#define KGSL_PERFCOUNTER_GROUP_HLSQ 0x4
221#define KGSL_PERFCOUNTER_GROUP_VPC 0x5
222#define KGSL_PERFCOUNTER_GROUP_TSE 0x6
223#define KGSL_PERFCOUNTER_GROUP_RAS 0x7
224#define KGSL_PERFCOUNTER_GROUP_UCHE 0x8
225#define KGSL_PERFCOUNTER_GROUP_TP 0x9
226#define KGSL_PERFCOUNTER_GROUP_SP 0xA
227#define KGSL_PERFCOUNTER_GROUP_RB 0xB
228#define KGSL_PERFCOUNTER_GROUP_PWR 0xC
229#define KGSL_PERFCOUNTER_GROUP_VBIF 0xD
230#define KGSL_PERFCOUNTER_GROUP_VBIF_PWR 0xE
231
232#define KGSL_PERFCOUNTER_NOT_USED 0xFFFFFFFF
Carter Cooper88484882013-06-11 11:32:07 -0600233#define KGSL_PERFCOUNTER_BROKEN 0xFFFFFFFE
Jordan Crouse35b8fe92012-10-03 09:38:42 -0600234
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700235/* structure holds list of ibs */
236struct kgsl_ibdesc {
237 unsigned int gpuaddr;
238 void *hostptr;
239 unsigned int sizedwords;
240 unsigned int ctrl;
241};
242
243/* ioctls */
244#define KGSL_IOC_TYPE 0x09
245
246/* get misc info about the GPU
247 type should be a value from enum kgsl_property_type
248 value points to a structure that varies based on type
249 sizebytes is sizeof() that structure
250 for KGSL_PROP_DEVICE_INFO, use struct kgsl_devinfo
251 this structure contaings hardware versioning info.
252 for KGSL_PROP_DEVICE_SHADOW, use struct kgsl_shadowprop
253 this is used to find mmap() offset and sizes for mapping
254 struct kgsl_memstore into userspace.
255*/
256struct kgsl_device_getproperty {
257 unsigned int type;
258 void *value;
259 unsigned int sizebytes;
260};
261
262#define IOCTL_KGSL_DEVICE_GETPROPERTY \
263 _IOWR(KGSL_IOC_TYPE, 0x2, struct kgsl_device_getproperty)
264
Harsh Vardhan Dwivedib6cebfe2012-03-15 18:20:59 -0600265/* IOCTL_KGSL_DEVICE_READ (0x3) - removed 03/2012
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700266 */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700267
268/* block until the GPU has executed past a given timestamp
269 * timeout is in milliseconds.
270 */
271struct kgsl_device_waittimestamp {
272 unsigned int timestamp;
273 unsigned int timeout;
274};
275
276#define IOCTL_KGSL_DEVICE_WAITTIMESTAMP \
277 _IOW(KGSL_IOC_TYPE, 0x6, struct kgsl_device_waittimestamp)
278
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700279struct kgsl_device_waittimestamp_ctxtid {
280 unsigned int context_id;
281 unsigned int timestamp;
282 unsigned int timeout;
283};
284
285#define IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID \
286 _IOW(KGSL_IOC_TYPE, 0x7, struct kgsl_device_waittimestamp_ctxtid)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700287
288/* issue indirect commands to the GPU.
289 * drawctxt_id must have been created with IOCTL_KGSL_DRAWCTXT_CREATE
290 * ibaddr and sizedwords must specify a subset of a buffer created
291 * with IOCTL_KGSL_SHAREDMEM_FROM_PMEM
292 * flags may be a mask of KGSL_CONTEXT_ values
293 * timestamp is a returned counter value which can be passed to
294 * other ioctls to determine when the commands have been executed by
295 * the GPU.
296 */
297struct kgsl_ringbuffer_issueibcmds {
298 unsigned int drawctxt_id;
299 unsigned int ibdesc_addr;
300 unsigned int numibs;
301 unsigned int timestamp; /*output param */
302 unsigned int flags;
303};
304
305#define IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS \
306 _IOWR(KGSL_IOC_TYPE, 0x10, struct kgsl_ringbuffer_issueibcmds)
307
308/* read the most recently executed timestamp value
309 * type should be a value from enum kgsl_timestamp_type
310 */
311struct kgsl_cmdstream_readtimestamp {
312 unsigned int type;
313 unsigned int timestamp; /*output param */
314};
315
Jason Varbedian80ba33d2011-07-11 17:29:05 -0700316#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_OLD \
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700317 _IOR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp)
318
Jason Varbedian80ba33d2011-07-11 17:29:05 -0700319#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP \
320 _IOWR(KGSL_IOC_TYPE, 0x11, struct kgsl_cmdstream_readtimestamp)
321
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700322/* free memory when the GPU reaches a given timestamp.
323 * gpuaddr specify a memory region created by a
324 * IOCTL_KGSL_SHAREDMEM_FROM_PMEM call
325 * type should be a value from enum kgsl_timestamp_type
326 */
327struct kgsl_cmdstream_freememontimestamp {
328 unsigned int gpuaddr;
329 unsigned int type;
330 unsigned int timestamp;
331};
332
333#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP \
334 _IOW(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp)
335
336/* Previous versions of this header had incorrectly defined
337 IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP as a read-only ioctl instead
338 of a write only ioctl. To ensure binary compatability, the following
339 #define will be used to intercept the incorrect ioctl
340*/
341
342#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_OLD \
343 _IOR(KGSL_IOC_TYPE, 0x12, struct kgsl_cmdstream_freememontimestamp)
344
345/* create a draw context, which is used to preserve GPU state.
346 * The flags field may contain a mask KGSL_CONTEXT_* values
347 */
348struct kgsl_drawctxt_create {
349 unsigned int flags;
350 unsigned int drawctxt_id; /*output param */
351};
352
353#define IOCTL_KGSL_DRAWCTXT_CREATE \
354 _IOWR(KGSL_IOC_TYPE, 0x13, struct kgsl_drawctxt_create)
355
356/* destroy a draw context */
357struct kgsl_drawctxt_destroy {
358 unsigned int drawctxt_id;
359};
360
361#define IOCTL_KGSL_DRAWCTXT_DESTROY \
362 _IOW(KGSL_IOC_TYPE, 0x14, struct kgsl_drawctxt_destroy)
363
364/* add a block of pmem, fb, ashmem or user allocated address
365 * into the GPU address space */
366struct kgsl_map_user_mem {
367 int fd;
368 unsigned int gpuaddr; /*output param */
369 unsigned int len;
370 unsigned int offset;
371 unsigned int hostptr; /*input param */
372 enum kgsl_user_mem_type memtype;
Jeremy Gebben955f8522012-09-24 13:05:39 -0600373 unsigned int flags;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700374};
375
376#define IOCTL_KGSL_MAP_USER_MEM \
377 _IOWR(KGSL_IOC_TYPE, 0x15, struct kgsl_map_user_mem)
378
Carter Cooper7e7f02e2012-02-15 09:36:31 -0700379struct kgsl_cmdstream_readtimestamp_ctxtid {
380 unsigned int context_id;
381 unsigned int type;
382 unsigned int timestamp; /*output param */
383};
384
385#define IOCTL_KGSL_CMDSTREAM_READTIMESTAMP_CTXTID \
386 _IOWR(KGSL_IOC_TYPE, 0x16, struct kgsl_cmdstream_readtimestamp_ctxtid)
387
388struct kgsl_cmdstream_freememontimestamp_ctxtid {
389 unsigned int context_id;
390 unsigned int gpuaddr;
391 unsigned int type;
392 unsigned int timestamp;
393};
394
395#define IOCTL_KGSL_CMDSTREAM_FREEMEMONTIMESTAMP_CTXTID \
396 _IOW(KGSL_IOC_TYPE, 0x17, \
397 struct kgsl_cmdstream_freememontimestamp_ctxtid)
398
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700399/* add a block of pmem or fb into the GPU address space */
400struct kgsl_sharedmem_from_pmem {
401 int pmem_fd;
402 unsigned int gpuaddr; /*output param */
403 unsigned int len;
404 unsigned int offset;
405};
406
407#define IOCTL_KGSL_SHAREDMEM_FROM_PMEM \
408 _IOWR(KGSL_IOC_TYPE, 0x20, struct kgsl_sharedmem_from_pmem)
409
410/* remove memory from the GPU's address space */
411struct kgsl_sharedmem_free {
412 unsigned int gpuaddr;
413};
414
415#define IOCTL_KGSL_SHAREDMEM_FREE \
416 _IOW(KGSL_IOC_TYPE, 0x21, struct kgsl_sharedmem_free)
417
Sushmita Susheelendra41f8fa32011-05-11 17:15:58 -0600418struct kgsl_cff_user_event {
419 unsigned char cff_opcode;
420 unsigned int op1;
421 unsigned int op2;
422 unsigned int op3;
423 unsigned int op4;
424 unsigned int op5;
425 unsigned int __pad[2];
426};
427
428#define IOCTL_KGSL_CFF_USER_EVENT \
429 _IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_cff_user_event)
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700430
431struct kgsl_gmem_desc {
432 unsigned int x;
433 unsigned int y;
434 unsigned int width;
435 unsigned int height;
436 unsigned int pitch;
437};
438
439struct kgsl_buffer_desc {
440 void *hostptr;
441 unsigned int gpuaddr;
442 int size;
443 unsigned int format;
444 unsigned int pitch;
445 unsigned int enabled;
446};
447
448struct kgsl_bind_gmem_shadow {
449 unsigned int drawctxt_id;
450 struct kgsl_gmem_desc gmem_desc;
451 unsigned int shadow_x;
452 unsigned int shadow_y;
453 struct kgsl_buffer_desc shadow_buffer;
454 unsigned int buffer_id;
455};
456
457#define IOCTL_KGSL_DRAWCTXT_BIND_GMEM_SHADOW \
458 _IOW(KGSL_IOC_TYPE, 0x22, struct kgsl_bind_gmem_shadow)
459
460/* add a block of memory into the GPU address space */
Jordan Crousec6005102012-09-11 16:38:14 -0600461
462/*
463 * IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC deprecated 09/2012
464 * use IOCTL_KGSL_GPUMEM_ALLOC instead
465 */
466
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700467struct kgsl_sharedmem_from_vmalloc {
468 unsigned int gpuaddr; /*output param */
469 unsigned int hostptr;
470 unsigned int flags;
471};
472
473#define IOCTL_KGSL_SHAREDMEM_FROM_VMALLOC \
474 _IOWR(KGSL_IOC_TYPE, 0x23, struct kgsl_sharedmem_from_vmalloc)
475
Jordan Crousec3b866d2012-11-08 09:05:52 -0700476/*
477 * This is being deprecated in favor of IOCTL_KGSL_GPUMEM_CACHE_SYNC which
478 * supports both directions (flush and invalidate). This code will still
479 * work, but by definition it will do a flush of the cache which might not be
480 * what you want to have happen on a buffer following a GPU operation. It is
481 * safer to go with IOCTL_KGSL_GPUMEM_CACHE_SYNC
482 */
483
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700484#define IOCTL_KGSL_SHAREDMEM_FLUSH_CACHE \
485 _IOW(KGSL_IOC_TYPE, 0x24, struct kgsl_sharedmem_free)
486
487struct kgsl_drawctxt_set_bin_base_offset {
488 unsigned int drawctxt_id;
489 unsigned int offset;
490};
491
492#define IOCTL_KGSL_DRAWCTXT_SET_BIN_BASE_OFFSET \
493 _IOW(KGSL_IOC_TYPE, 0x25, struct kgsl_drawctxt_set_bin_base_offset)
494
495enum kgsl_cmdwindow_type {
496 KGSL_CMDWINDOW_MIN = 0x00000000,
497 KGSL_CMDWINDOW_2D = 0x00000000,
498 KGSL_CMDWINDOW_3D = 0x00000001, /* legacy */
499 KGSL_CMDWINDOW_MMU = 0x00000002,
500 KGSL_CMDWINDOW_ARBITER = 0x000000FF,
501 KGSL_CMDWINDOW_MAX = 0x000000FF,
502};
503
504/* write to the command window */
505struct kgsl_cmdwindow_write {
506 enum kgsl_cmdwindow_type target;
507 unsigned int addr;
508 unsigned int data;
509};
510
511#define IOCTL_KGSL_CMDWINDOW_WRITE \
512 _IOW(KGSL_IOC_TYPE, 0x2e, struct kgsl_cmdwindow_write)
513
514struct kgsl_gpumem_alloc {
515 unsigned long gpuaddr;
516 size_t size;
517 unsigned int flags;
518};
519
520#define IOCTL_KGSL_GPUMEM_ALLOC \
521 _IOWR(KGSL_IOC_TYPE, 0x2f, struct kgsl_gpumem_alloc)
522
Jeremy Gebbena7423e42011-04-18 15:11:21 -0600523struct kgsl_cff_syncmem {
524 unsigned int gpuaddr;
525 unsigned int len;
526 unsigned int __pad[2]; /* For future binary compatibility */
527};
528
529#define IOCTL_KGSL_CFF_SYNCMEM \
530 _IOW(KGSL_IOC_TYPE, 0x30, struct kgsl_cff_syncmem)
531
Jordan Croused4bc9d22011-11-17 13:39:21 -0700532/*
533 * A timestamp event allows the user space to register an action following an
Jeff Boody97ae63d2012-08-09 13:54:50 -0600534 * expired timestamp. Note IOCTL_KGSL_TIMESTAMP_EVENT has been redefined to
535 * _IOWR to support fences which need to return a fd for the priv parameter.
Jordan Croused4bc9d22011-11-17 13:39:21 -0700536 */
537
538struct kgsl_timestamp_event {
539 int type; /* Type of event (see list below) */
540 unsigned int timestamp; /* Timestamp to trigger event on */
541 unsigned int context_id; /* Context for the timestamp */
542 void *priv; /* Pointer to the event specific blob */
543 size_t len; /* Size of the event specific blob */
544};
545
Jeff Boody97ae63d2012-08-09 13:54:50 -0600546#define IOCTL_KGSL_TIMESTAMP_EVENT_OLD \
Jordan Croused4bc9d22011-11-17 13:39:21 -0700547 _IOW(KGSL_IOC_TYPE, 0x31, struct kgsl_timestamp_event)
548
549/* A genlock timestamp event releases an existing lock on timestamp expire */
550
551#define KGSL_TIMESTAMP_EVENT_GENLOCK 1
552
553struct kgsl_timestamp_event_genlock {
554 int handle; /* Handle of the genlock lock to release */
555};
556
Jeff Boody97ae63d2012-08-09 13:54:50 -0600557/* A fence timestamp event releases an existing lock on timestamp expire */
558
559#define KGSL_TIMESTAMP_EVENT_FENCE 2
560
561struct kgsl_timestamp_event_fence {
562 int fence_fd; /* Fence to signal */
563};
564
Jordan Crouseed7dd7f2012-03-29 13:16:02 -0600565/*
566 * Set a property within the kernel. Uses the same structure as
567 * IOCTL_KGSL_GETPROPERTY
568 */
569
570#define IOCTL_KGSL_SETPROPERTY \
571 _IOW(KGSL_IOC_TYPE, 0x32, struct kgsl_device_getproperty)
572
Jeff Boody97ae63d2012-08-09 13:54:50 -0600573#define IOCTL_KGSL_TIMESTAMP_EVENT \
574 _IOWR(KGSL_IOC_TYPE, 0x33, struct kgsl_timestamp_event)
575
Jeremy Gebben058cea02012-10-30 15:18:06 -0600576/**
577 * struct kgsl_gpumem_alloc_id - argument to IOCTL_KGSL_GPUMEM_ALLOC_ID
578 * @id: returned id value for this allocation.
579 * @flags: mask of KGSL_MEM* values requested and actual flags on return.
580 * @size: requested size of the allocation and actual size on return.
581 * @mmapsize: returned size to pass to mmap() which may be larger than 'size'
582 * @gpuaddr: returned GPU address for the allocation
583 *
584 * Allocate memory for access by the GPU. The flags and size fields are echoed
585 * back by the kernel, so that the caller can know if the request was
586 * adjusted.
587 *
588 * Supported flags:
589 * KGSL_MEMFLAGS_GPUREADONLY: the GPU will be unable to write to the buffer
590 * KGSL_MEMTYPE*: usage hint for debugging aid
591 * KGSL_MEMALIGN*: alignment hint, may be ignored or adjusted by the kernel.
Jeremy Gebben0d6f1482012-10-30 15:40:58 -0600592 * KGSL_MEMFLAGS_USE_CPU_MAP: If set on call and return, the returned GPU
593 * address will be 0. Calling mmap() will set the GPU address.
Jeremy Gebben058cea02012-10-30 15:18:06 -0600594 */
595struct kgsl_gpumem_alloc_id {
596 unsigned int id;
597 unsigned int flags;
598 unsigned int size;
599 unsigned int mmapsize;
600 unsigned long gpuaddr;
601/* private: reserved for future use*/
602 unsigned int __pad[2];
603};
604
605#define IOCTL_KGSL_GPUMEM_ALLOC_ID \
606 _IOWR(KGSL_IOC_TYPE, 0x34, struct kgsl_gpumem_alloc_id)
607
608/**
609 * struct kgsl_gpumem_free_id - argument to IOCTL_KGSL_GPUMEM_FREE_ID
610 * @id: GPU allocation id to free
611 *
612 * Free an allocation by id, in case a GPU address has not been assigned or
613 * is unknown. Freeing an allocation by id with this ioctl or by GPU address
614 * with IOCTL_KGSL_SHAREDMEM_FREE are equivalent.
615 */
616struct kgsl_gpumem_free_id {
617 unsigned int id;
618/* private: reserved for future use*/
619 unsigned int __pad;
620};
621
622#define IOCTL_KGSL_GPUMEM_FREE_ID \
623 _IOWR(KGSL_IOC_TYPE, 0x35, struct kgsl_gpumem_free_id)
624
625/**
626 * struct kgsl_gpumem_get_info - argument to IOCTL_KGSL_GPUMEM_GET_INFO
627 * @gpuaddr: GPU address to query. Also set on return.
628 * @id: GPU allocation id to query. Also set on return.
629 * @flags: returned mask of KGSL_MEM* values.
630 * @size: returned size of the allocation.
631 * @mmapsize: returned size to pass mmap(), which may be larger than 'size'
632 * @useraddr: returned address of the userspace mapping for this buffer
633 *
634 * This ioctl allows querying of all user visible attributes of an existing
635 * allocation, by either the GPU address or the id returned by a previous
636 * call to IOCTL_KGSL_GPUMEM_ALLOC_ID. Legacy allocation ioctls may not
637 * return all attributes so this ioctl can be used to look them up if needed.
638 *
639 */
640struct kgsl_gpumem_get_info {
641 unsigned long gpuaddr;
642 unsigned int id;
643 unsigned int flags;
644 unsigned int size;
645 unsigned int mmapsize;
646 unsigned long useraddr;
647/* private: reserved for future use*/
648 unsigned int __pad[4];
649};
650
651#define IOCTL_KGSL_GPUMEM_GET_INFO\
652 _IOWR(KGSL_IOC_TYPE, 0x36, struct kgsl_gpumem_get_info)
653
Jordan Crousec3b866d2012-11-08 09:05:52 -0700654/**
655 * struct kgsl_gpumem_sync_cache - argument to IOCTL_KGSL_GPUMEM_SYNC_CACHE
656 * @gpuaddr: GPU address of the buffer to sync.
657 * @id: id of the buffer to sync. Either gpuaddr or id is sufficient.
658 * @op: a mask of KGSL_GPUMEM_CACHE_* values
659 *
660 * Sync the L2 cache for memory headed to and from the GPU - this replaces
661 * KGSL_SHAREDMEM_FLUSH_CACHE since it can handle cache management for both
662 * directions
663 *
664 */
665struct kgsl_gpumem_sync_cache {
666 unsigned int gpuaddr;
667 unsigned int id;
668 unsigned int op;
669/* private: reserved for future use*/
670 unsigned int __pad[2]; /* For future binary compatibility */
671};
672
673#define KGSL_GPUMEM_CACHE_CLEAN (1 << 0)
674#define KGSL_GPUMEM_CACHE_TO_GPU KGSL_GPUMEM_CACHE_CLEAN
675
676#define KGSL_GPUMEM_CACHE_INV (1 << 1)
677#define KGSL_GPUMEM_CACHE_FROM_GPU KGSL_GPUMEM_CACHE_INV
678
679#define KGSL_GPUMEM_CACHE_FLUSH \
680 (KGSL_GPUMEM_CACHE_CLEAN | KGSL_GPUMEM_CACHE_INV)
681
682#define IOCTL_KGSL_GPUMEM_SYNC_CACHE \
683 _IOW(KGSL_IOC_TYPE, 0x37, struct kgsl_gpumem_sync_cache)
684
Jordan Crouse35b8fe92012-10-03 09:38:42 -0600685/**
686 * struct kgsl_perfcounter_get - argument to IOCTL_KGSL_PERFCOUNTER_GET
687 * @groupid: Performance counter group ID
688 * @countable: Countable to select within the group
689 * @offset: Return offset of the reserved counter
690 *
691 * Get an available performance counter from a specified groupid. The offset
692 * of the performance counter will be returned after successfully assigning
693 * the countable to the counter for the specified group. An error will be
694 * returned and an offset of 0 if the groupid is invalid or there are no
695 * more counters left. After successfully getting a perfcounter, the user
696 * must call kgsl_perfcounter_put(groupid, contable) when finished with
697 * the perfcounter to clear up perfcounter resources.
698 *
699 */
700struct kgsl_perfcounter_get {
701 unsigned int groupid;
702 unsigned int countable;
703 unsigned int offset;
704/* private: reserved for future use */
705 unsigned int __pad[2]; /* For future binary compatibility */
706};
707
708#define IOCTL_KGSL_PERFCOUNTER_GET \
709 _IOWR(KGSL_IOC_TYPE, 0x38, struct kgsl_perfcounter_get)
710
711/**
712 * struct kgsl_perfcounter_put - argument to IOCTL_KGSL_PERFCOUNTER_PUT
713 * @groupid: Performance counter group ID
714 * @countable: Countable to release within the group
715 *
716 * Put an allocated performance counter to allow others to have access to the
717 * resource that was previously taken. This is only to be called after
718 * successfully getting a performance counter from kgsl_perfcounter_get().
719 *
720 */
721struct kgsl_perfcounter_put {
722 unsigned int groupid;
723 unsigned int countable;
724/* private: reserved for future use */
725 unsigned int __pad[2]; /* For future binary compatibility */
726};
727
728#define IOCTL_KGSL_PERFCOUNTER_PUT \
729 _IOW(KGSL_IOC_TYPE, 0x39, struct kgsl_perfcounter_put)
730
731/**
732 * struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY
733 * @groupid: Performance counter group ID
734 * @countable: Return active countables array
735 * @size: Size of active countables array
736 * @max_counters: Return total number counters for the group ID
737 *
738 * Query the available performance counters given a groupid. The array
739 * *countables is used to return the current active countables in counters.
740 * The size of the array is passed in so the kernel will only write at most
741 * size or counter->size for the group id. The total number of available
742 * counters for the group ID is returned in max_counters.
743 * If the array or size passed in are invalid, then only the maximum number
744 * of counters will be returned, no data will be written to *countables.
745 * If the groupid is invalid an error code will be returned.
746 *
747 */
748struct kgsl_perfcounter_query {
749 unsigned int groupid;
750 /* Array to return the current countable for up to size counters */
751 unsigned int *countables;
752 unsigned int count;
753 unsigned int max_counters;
754/* private: reserved for future use */
755 unsigned int __pad[2]; /* For future binary compatibility */
756};
757
758#define IOCTL_KGSL_PERFCOUNTER_QUERY \
759 _IOWR(KGSL_IOC_TYPE, 0x3A, struct kgsl_perfcounter_query)
760
761/**
762 * struct kgsl_perfcounter_query - argument to IOCTL_KGSL_PERFCOUNTER_QUERY
763 * @groupid: Performance counter group IDs
764 * @countable: Performance counter countable IDs
765 * @value: Return performance counter reads
766 * @size: Size of all arrays (groupid/countable pair and return value)
767 *
768 * Read in the current value of a performance counter given by the groupid
769 * and countable.
770 *
771 */
772
773struct kgsl_perfcounter_read_group {
774 unsigned int groupid;
775 unsigned int countable;
Shubhraprakash Dase0345ca892013-04-30 16:20:32 -0700776 unsigned long long value;
Jordan Crouse35b8fe92012-10-03 09:38:42 -0600777};
778
779struct kgsl_perfcounter_read {
780 struct kgsl_perfcounter_read_group *reads;
781 unsigned int count;
782/* private: reserved for future use */
783 unsigned int __pad[2]; /* For future binary compatibility */
784};
785
786#define IOCTL_KGSL_PERFCOUNTER_READ \
787 _IOWR(KGSL_IOC_TYPE, 0x3B, struct kgsl_perfcounter_read)
Jeremy Gebbene4f2f972013-04-09 15:14:33 -0600788/*
789 * struct kgsl_gpumem_sync_cache_bulk - argument to
790 * IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK
791 * @id_list: list of GPU buffer ids of the buffers to sync
792 * @count: number of GPU buffer ids in id_list
793 * @op: a mask of KGSL_GPUMEM_CACHE_* values
794 *
795 * Sync the cache for memory headed to and from the GPU. Certain
796 * optimizations can be made on the cache operation based on the total
797 * size of the working set of memory to be managed.
798 */
799struct kgsl_gpumem_sync_cache_bulk {
800 unsigned int *id_list;
801 unsigned int count;
802 unsigned int op;
803/* private: reserved for future use */
804 unsigned int __pad[2]; /* For future binary compatibility */
805};
806
807#define IOCTL_KGSL_GPUMEM_SYNC_CACHE_BULK \
808 _IOWR(KGSL_IOC_TYPE, 0x3C, struct kgsl_gpumem_sync_cache_bulk)
Jordan Crouse35b8fe92012-10-03 09:38:42 -0600809
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700810#ifdef __KERNEL__
811#ifdef CONFIG_MSM_KGSL_DRM
812int kgsl_gem_obj_addr(int drm_fd, int handle, unsigned long *start,
813 unsigned long *len);
814#else
815#define kgsl_gem_obj_addr(...) 0
816#endif
817#endif
818#endif /* _MSM_KGSL_H */