summaryrefslogtreecommitdiff
path: root/include/drm/tegra_drm.h
blob: f61dc5ae034654962bedf38d6558bcda39bbc49a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
/*
 * Copyright (c) 2012-2013, NVIDIA CORPORATION.  All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef _TEGRA_DRM_H_
#define _TEGRA_DRM_H_

#include "drm.h"

#if defined(__cplusplus)
extern "C" {
#endif

#define DRM_TEGRA_GEM_CONTIGUOUS	(1 << 0)
#define DRM_TEGRA_GEM_FLAGS		(DRM_TEGRA_GEM_CONTIGUOUS)

/**
 * struct drm_tegra_gem_create - parameters for the GEM object creation IOCTL
 */
struct drm_tegra_gem_create {
	/**
	 * @size:
	 *
	 * The size, in bytes, of the buffer object to be created.
	 */
	__u64 size;

	/**
	 * @flags:
	 *
	 * A bitmask of flags that influence the creation of GEM objects:
	 *
	 * DRM_TEGRA_GEM_CONTIGUOUS - The buffer is to be backed by physically
	 *	contiguous memory.
	 */
	__u32 flags;

	/**
	 * @handle:
	 *
	 * Return location for the handle of the created GEM object.
	 */
	__u32 handle;
};

/**
 * struct drm_tegra_gem_mmap - parameters for the GEM mmap IOCTL
 */
struct drm_tegra_gem_mmap {
	/**
	 * @handle:
	 *
	 * Handle of the GEM object to obtain an mmap offset for.
	 */
	__u32 handle;

	/**
	 * @pad:
	 *
	 * Structure padding that may be used in the future. Must be 0.
	 */
	__u32 pad;

	/**
	 * @offset:
	 *
	 * Return location for the mmap offset for the given GEM object.
	 */
	__u64 offset;
};

#define DRM_TEGRA_CHANNEL_FLAGS (0)

struct drm_tegra_open_channel {
	/**
	 * @client:
	 *
	 * The client ID for this channel.
	 */
	__u32 client;

	/**
	 * @flags:
	 *
	 * A bitmask of flags that influence the channel creation. Currently
	 * no flags are defined, so this must be 0.
	 */
	__u32 flags;

	/**
	 * @syncpts:
	 *
	 * Return location for the number of syncpoints used by this channel.
	 */
	__u32 syncpts;

	/**
	 * @version:
	 *
	 * Return location for the implementation version of this channel.
	 */
	__u32 version;

	/**
	 * @context:
	 *
	 * Return location for the application context of this channel. This
	 * context needs to be passed to the DRM_TEGRA_CHANNEL_CLOSE or the
	 * DRM_TEGRA_SUBMIT IOCTLs.
	 */
	__u64 context;

	/**
	 * @reserved:
	 *
	 * This field is reserved for future use. Must be 0.
	 */
	__u64 reserved;
};

struct drm_tegra_close_channel {
	/**
	 * @context:
	 *
	 * The application context of this channel. This is obtained from the
	 * DRM_TEGRA_OPEN_CHANNEL IOCTL.
	 */
	__u64 context;
};

#define DRM_TEGRA_BUFFER_FLAGS	(0)

struct drm_tegra_buffer {
	/**
	 * @handle:
	 *
	 * Handle of the buffer.
	 */
	__u32 handle;

	/**
	 * @flags:
	 *
	 * A bitmask of flags specifying the usage of the buffer. Currently no
	 * flags are defined, so this must be 0.
	 */
	__u32 flags;
};

#define DRM_TEGRA_FENCE_WAIT	(1 << 0)
#define DRM_TEGRA_FENCE_EMIT	(1 << 1)
#define DRM_TEGRA_FENCE_FD	(1 << 2)
#define DRM_TEGRA_FENCE_FLAGS	(DRM_TEGRA_FENCE_WAIT | \
				 DRM_TEGRA_FENCE_EMIT | \
				 DRM_TEGRA_FENCE_FD)

struct drm_tegra_fence {
	/**
	 * @handle:
	 *
	 * Handle (syncobj) or file descriptor (sync FD) of the fence. It is
	 * interpreted based on the DRM_TEGRA_FENCE_FD flag (see below).
	 */
	__u32 handle;

	/**
	 * @flags:
	 *
	 * A bitmask of flags that specify this fence.
	 *
	 * DRM_TEGRA_FENCE_WAIT - Wait for this fence before the new command
	 *	buffer is submitted.
	 * DRM_TEGRA_FENCE_EMIT - Emit this fence when the command buffer is
	 *	done being processed.
	 * DRM_TEGRA_FENCE_FD - This fence is a sync FD. If not specified, a
	 *	syncobj will be used.
	 */
	__u32 flags;

	/**
	 * @offset:
	 *
	 * Offset in the command stream for this fence. This is used to patch
	 * the command stream with the resolved syncpoint ID.
	 */
	__u32 offset;

	/**
	 * @index:
	 *
	 * Syncpoint to use for this fence. This is an index into the list of
	 * syncpoints of the channel. It will be resolved to a real syncpoint
	 * ID upon job submission.
	 */
	__u32 index;

	/**
	 * @value:
	 *
	 * Number of times to increment the syncpoint.
	 */
	__u32 value;

	/**
	 * @reserved:
	 *
	 * This field is reserved for future use. Must be 0.
	 */
	__u32 reserved[3];
};

#define DRM_TEGRA_CMDBUF_FLAGS	(0)

/**
 * struct drm_tegra_cmdbuf - structure describing a command buffer
 */
struct drm_tegra_cmdbuf {
	/**
	 * @index:
	 *
	 * Index into the job's buffer handle list, pointing to the handle of
	 * the GEM object that contains this command buffer.
	 */
	__u32 index;

	/**
	 * @offset:
	 *
	 * Offset, in bytes, into the GEM object at which the command buffer
	 * starts. Needs to be a multiple of 4.
	 */
	__u32 offset;

	/**
	 * @words:
	 *
	 * Number of 32-bit words in this command buffer.
	 */
	__u32 words;

	/**
	 * @flags:
	 *
	 * A bitmask of flags that influence the processing of this command
	 * buffer. Currently no flags are defined, so this must be 0.
	 */
	__u32 flags;

	/**
	 * @pad:
	 *
	 * Structure padding that may be used in the future. Must be 0.
	 */
	__u32 pad;

	/**
	 * @num_fences:
	 *
	 * The number of fences attached to this command buffer.
	 */
	__u32 num_fences;

	/**
	 * @fences:
	 *
	 * Pointer to an array of @num_fences &struct drm_tegra_fence objects.
	 */
	__u64 fences;
};

#define DRM_TEGRA_RELOC_FLAGS	(0)

/**
 * struct drm_tegra_reloc - GEM object relocation structure
 */
struct drm_tegra_reloc {
	struct {
		/**
		 * @cmdbuf.index:
		 *
		 * Index into the job's buffer handle list pointing to the
		 * handle of the GEM object containing the command buffer for
		 * which to perform this GEM object relocation.
		 */
		__u32 index;

		/**
		 * @cmdbuf.offset:
		 *
		 * Offset into the command buffer at which to insert the the
		 * relocated address.
		 */
		__u32 offset;
	} cmdbuf;

	struct {
		/**
		 * @target.index:
		 *
		 * Index into the job's buffer handle list pointing to the
		 * handle of the GEM object to be relocated.
		 */
		__u32 index;

		/**
		 * @target.offset:
		 *
		 * Offset into the target GEM object at which the relocated
		 * data starts.
		 */
		__u32 offset;
	} target;

	/**
	 * @shift:
	 *
	 * The number of bits by which to shift relocated addresses.
	 */
	__u32 shift;

	/**
	 * @flags:
	 *
	 * A bitmask of flags that determine how the GEM object should be
	 * relocated.
	 */
	__u32 flags;

	/**
	 * @reserved:
	 *
	 * This field is reserved for future use. Must be 0.
	 */
	__u64 reserved;
};

#define DRM_TEGRA_SUBMIT_FLAGS	(0)

/**
 * struct drm_tegra_submit - job submission structure
 */
struct drm_tegra_submit {
	/**
	 * @context:
	 *
	 * The application context identifying the channel to use for the
	 * execution of this job.
	 */
	__u64 context;

	/**
	 * @num_buffers:
	 *
	 * The number of GEM objects used during the execution of this job.
	 */
	__u32 num_buffers;

	/**
	 * @num_cmdbufs:
	 *
	 * The number of command buffers to execute as part of this job.
	 */
	__u32 num_cmdbufs;

	/**
	 * @num_relocs:
	 *
	 * The number of relocations to perform before executing this job.
	 */
	__u32 num_relocs;

	/**
	 * @timeout:
	 *
	 * The maximum amount of time, in milliseconds, to allow for the
	 * execution of this job.
	 */
	__u32 timeout;

	/**
	 * @buffers:
	 *
	 * A pointer to @num_buffers &struct drm_tegra_buffer structures that
	 * specify the GEM objects used during the execution of this job.
	 */
	__u64 buffers;

	/**
	 * @cmdbufs:
	 *
	 * A pointer to @num_cmdbufs &struct drm_tegra_cmdbuf structures that
	 * define the command buffers to execute as part of this job.
	 */
	__u64 cmdbufs;

	/**
	 * @relocs:
	 *
	 * A pointer to @num_relocs &struct drm_tegra_reloc structures that
	 * specify the relocations that need to be performed before executing
	 * this job.
	 */
	__u64 relocs;

	/**
	 * @flags:
	 *
	 * A bitmask of flags that specify how to execute this job. Currently
	 * no flags are defined, so this must be 0.
	 */
	__u32 flags;

	/**
	 * @pad:
	 *
	 * Structure padding that may be used in the future. Must be 0.
	 */
	__u32 pad;

	/**
	 * @reserved:
	 *
	 * This field is reserved for future use. Must be 0.
	 */
	__u64 reserved[9]; /* future expansion */
};

#define DRM_TEGRA_GEM_CREATE		0x00
#define DRM_TEGRA_GEM_MMAP		0x01
#define DRM_TEGRA_OPEN_CHANNEL		0x02
#define DRM_TEGRA_CLOSE_CHANNEL		0x03
#define DRM_TEGRA_SUBMIT		0x04

#define DRM_IOCTL_TEGRA_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_CREATE, struct drm_tegra_gem_create)
#define DRM_IOCTL_TEGRA_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_MMAP, struct drm_tegra_gem_mmap)
#define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
#define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_close_channel)
#define DRM_IOCTL_TEGRA_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SUBMIT, struct drm_tegra_submit)

#if defined(__cplusplus)
}
#endif

#endif