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