tegra_drm.h revision 1.1.1.1 1 /* $NetBSD: tegra_drm.h,v 1.1.1.1 2021/12/18 20:15:58 riastradh Exp $ */
2
3 /*
4 * Copyright (c) 2012-2013, NVIDIA CORPORATION. All rights reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 #ifndef _UAPI_TEGRA_DRM_H_
26 #define _UAPI_TEGRA_DRM_H_
27
28 #include "drm.h"
29
30 #if defined(__cplusplus)
31 extern "C" {
32 #endif
33
34 #define DRM_TEGRA_GEM_CREATE_TILED (1 << 0)
35 #define DRM_TEGRA_GEM_CREATE_BOTTOM_UP (1 << 1)
36
37 /**
38 * struct drm_tegra_gem_create - parameters for the GEM object creation IOCTL
39 */
40 struct drm_tegra_gem_create {
41 /**
42 * @size:
43 *
44 * The size, in bytes, of the buffer object to be created.
45 */
46 __u64 size;
47
48 /**
49 * @flags:
50 *
51 * A bitmask of flags that influence the creation of GEM objects:
52 *
53 * DRM_TEGRA_GEM_CREATE_TILED
54 * Use the 16x16 tiling format for this buffer.
55 *
56 * DRM_TEGRA_GEM_CREATE_BOTTOM_UP
57 * The buffer has a bottom-up layout.
58 */
59 __u32 flags;
60
61 /**
62 * @handle:
63 *
64 * The handle of the created GEM object. Set by the kernel upon
65 * successful completion of the IOCTL.
66 */
67 __u32 handle;
68 };
69
70 /**
71 * struct drm_tegra_gem_mmap - parameters for the GEM mmap IOCTL
72 */
73 struct drm_tegra_gem_mmap {
74 /**
75 * @handle:
76 *
77 * Handle of the GEM object to obtain an mmap offset for.
78 */
79 __u32 handle;
80
81 /**
82 * @pad:
83 *
84 * Structure padding that may be used in the future. Must be 0.
85 */
86 __u32 pad;
87
88 /**
89 * @offset:
90 *
91 * The mmap offset for the given GEM object. Set by the kernel upon
92 * successful completion of the IOCTL.
93 */
94 __u64 offset;
95 };
96
97 /**
98 * struct drm_tegra_syncpt_read - parameters for the read syncpoint IOCTL
99 */
100 struct drm_tegra_syncpt_read {
101 /**
102 * @id:
103 *
104 * ID of the syncpoint to read the current value from.
105 */
106 __u32 id;
107
108 /**
109 * @value:
110 *
111 * The current syncpoint value. Set by the kernel upon successful
112 * completion of the IOCTL.
113 */
114 __u32 value;
115 };
116
117 /**
118 * struct drm_tegra_syncpt_incr - parameters for the increment syncpoint IOCTL
119 */
120 struct drm_tegra_syncpt_incr {
121 /**
122 * @id:
123 *
124 * ID of the syncpoint to increment.
125 */
126 __u32 id;
127
128 /**
129 * @pad:
130 *
131 * Structure padding that may be used in the future. Must be 0.
132 */
133 __u32 pad;
134 };
135
136 /**
137 * struct drm_tegra_syncpt_wait - parameters for the wait syncpoint IOCTL
138 */
139 struct drm_tegra_syncpt_wait {
140 /**
141 * @id:
142 *
143 * ID of the syncpoint to wait on.
144 */
145 __u32 id;
146
147 /**
148 * @thresh:
149 *
150 * Threshold value for which to wait.
151 */
152 __u32 thresh;
153
154 /**
155 * @timeout:
156 *
157 * Timeout, in milliseconds, to wait.
158 */
159 __u32 timeout;
160
161 /**
162 * @value:
163 *
164 * The new syncpoint value after the wait. Set by the kernel upon
165 * successful completion of the IOCTL.
166 */
167 __u32 value;
168 };
169
170 #define DRM_TEGRA_NO_TIMEOUT (0xffffffff)
171
172 /**
173 * struct drm_tegra_open_channel - parameters for the open channel IOCTL
174 */
175 struct drm_tegra_open_channel {
176 /**
177 * @client:
178 *
179 * The client ID for this channel.
180 */
181 __u32 client;
182
183 /**
184 * @pad:
185 *
186 * Structure padding that may be used in the future. Must be 0.
187 */
188 __u32 pad;
189
190 /**
191 * @context:
192 *
193 * The application context of this channel. Set by the kernel upon
194 * successful completion of the IOCTL. This context needs to be passed
195 * to the DRM_TEGRA_CHANNEL_CLOSE or the DRM_TEGRA_SUBMIT IOCTLs.
196 */
197 __u64 context;
198 };
199
200 /**
201 * struct drm_tegra_close_channel - parameters for the close channel IOCTL
202 */
203 struct drm_tegra_close_channel {
204 /**
205 * @context:
206 *
207 * The application context of this channel. This is obtained from the
208 * DRM_TEGRA_OPEN_CHANNEL IOCTL.
209 */
210 __u64 context;
211 };
212
213 /**
214 * struct drm_tegra_get_syncpt - parameters for the get syncpoint IOCTL
215 */
216 struct drm_tegra_get_syncpt {
217 /**
218 * @context:
219 *
220 * The application context identifying the channel for which to obtain
221 * the syncpoint ID.
222 */
223 __u64 context;
224
225 /**
226 * @index:
227 *
228 * Index of the client syncpoint for which to obtain the ID.
229 */
230 __u32 index;
231
232 /**
233 * @id:
234 *
235 * The ID of the given syncpoint. Set by the kernel upon successful
236 * completion of the IOCTL.
237 */
238 __u32 id;
239 };
240
241 /**
242 * struct drm_tegra_get_syncpt_base - parameters for the get wait base IOCTL
243 */
244 struct drm_tegra_get_syncpt_base {
245 /**
246 * @context:
247 *
248 * The application context identifying for which channel to obtain the
249 * wait base.
250 */
251 __u64 context;
252
253 /**
254 * @syncpt:
255 *
256 * ID of the syncpoint for which to obtain the wait base.
257 */
258 __u32 syncpt;
259
260 /**
261 * @id:
262 *
263 * The ID of the wait base corresponding to the client syncpoint. Set
264 * by the kernel upon successful completion of the IOCTL.
265 */
266 __u32 id;
267 };
268
269 /**
270 * struct drm_tegra_syncpt - syncpoint increment operation
271 */
272 struct drm_tegra_syncpt {
273 /**
274 * @id:
275 *
276 * ID of the syncpoint to operate on.
277 */
278 __u32 id;
279
280 /**
281 * @incrs:
282 *
283 * Number of increments to perform for the syncpoint.
284 */
285 __u32 incrs;
286 };
287
288 /**
289 * struct drm_tegra_cmdbuf - structure describing a command buffer
290 */
291 struct drm_tegra_cmdbuf {
292 /**
293 * @handle:
294 *
295 * Handle to a GEM object containing the command buffer.
296 */
297 __u32 handle;
298
299 /**
300 * @offset:
301 *
302 * Offset, in bytes, into the GEM object identified by @handle at
303 * which the command buffer starts.
304 */
305 __u32 offset;
306
307 /**
308 * @words:
309 *
310 * Number of 32-bit words in this command buffer.
311 */
312 __u32 words;
313
314 /**
315 * @pad:
316 *
317 * Structure padding that may be used in the future. Must be 0.
318 */
319 __u32 pad;
320 };
321
322 /**
323 * struct drm_tegra_reloc - GEM object relocation structure
324 */
325 struct drm_tegra_reloc {
326 struct {
327 /**
328 * @cmdbuf.handle:
329 *
330 * Handle to the GEM object containing the command buffer for
331 * which to perform this GEM object relocation.
332 */
333 __u32 handle;
334
335 /**
336 * @cmdbuf.offset:
337 *
338 * Offset, in bytes, into the command buffer at which to
339 * insert the relocated address.
340 */
341 __u32 offset;
342 } cmdbuf;
343 struct {
344 /**
345 * @target.handle:
346 *
347 * Handle to the GEM object to be relocated.
348 */
349 __u32 handle;
350
351 /**
352 * @target.offset:
353 *
354 * Offset, in bytes, into the target GEM object at which the
355 * relocated data starts.
356 */
357 __u32 offset;
358 } target;
359
360 /**
361 * @shift:
362 *
363 * The number of bits by which to shift relocated addresses.
364 */
365 __u32 shift;
366
367 /**
368 * @pad:
369 *
370 * Structure padding that may be used in the future. Must be 0.
371 */
372 __u32 pad;
373 };
374
375 /**
376 * struct drm_tegra_waitchk - wait check structure
377 */
378 struct drm_tegra_waitchk {
379 /**
380 * @handle:
381 *
382 * Handle to the GEM object containing a command stream on which to
383 * perform the wait check.
384 */
385 __u32 handle;
386
387 /**
388 * @offset:
389 *
390 * Offset, in bytes, of the location in the command stream to perform
391 * the wait check on.
392 */
393 __u32 offset;
394
395 /**
396 * @syncpt:
397 *
398 * ID of the syncpoint to wait check.
399 */
400 __u32 syncpt;
401
402 /**
403 * @thresh:
404 *
405 * Threshold value for which to check.
406 */
407 __u32 thresh;
408 };
409
410 /**
411 * struct drm_tegra_submit - job submission structure
412 */
413 struct drm_tegra_submit {
414 /**
415 * @context:
416 *
417 * The application context identifying the channel to use for the
418 * execution of this job.
419 */
420 __u64 context;
421
422 /**
423 * @num_syncpts:
424 *
425 * The number of syncpoints operated on by this job. This defines the
426 * length of the array pointed to by @syncpts.
427 */
428 __u32 num_syncpts;
429
430 /**
431 * @num_cmdbufs:
432 *
433 * The number of command buffers to execute as part of this job. This
434 * defines the length of the array pointed to by @cmdbufs.
435 */
436 __u32 num_cmdbufs;
437
438 /**
439 * @num_relocs:
440 *
441 * The number of relocations to perform before executing this job.
442 * This defines the length of the array pointed to by @relocs.
443 */
444 __u32 num_relocs;
445
446 /**
447 * @num_waitchks:
448 *
449 * The number of wait checks to perform as part of this job. This
450 * defines the length of the array pointed to by @waitchks.
451 */
452 __u32 num_waitchks;
453
454 /**
455 * @waitchk_mask:
456 *
457 * Bitmask of valid wait checks.
458 */
459 __u32 waitchk_mask;
460
461 /**
462 * @timeout:
463 *
464 * Timeout, in milliseconds, before this job is cancelled.
465 */
466 __u32 timeout;
467
468 /**
469 * @syncpts:
470 *
471 * A pointer to an array of &struct drm_tegra_syncpt structures that
472 * specify the syncpoint operations performed as part of this job.
473 * The number of elements in the array must be equal to the value
474 * given by @num_syncpts.
475 */
476 __u64 syncpts;
477
478 /**
479 * @cmdbufs:
480 *
481 * A pointer to an array of &struct drm_tegra_cmdbuf structures that
482 * define the command buffers to execute as part of this job. The
483 * number of elements in the array must be equal to the value given
484 * by @num_syncpts.
485 */
486 __u64 cmdbufs;
487
488 /**
489 * @relocs:
490 *
491 * A pointer to an array of &struct drm_tegra_reloc structures that
492 * specify the relocations that need to be performed before executing
493 * this job. The number of elements in the array must be equal to the
494 * value given by @num_relocs.
495 */
496 __u64 relocs;
497
498 /**
499 * @waitchks:
500 *
501 * A pointer to an array of &struct drm_tegra_waitchk structures that
502 * specify the wait checks to be performed while executing this job.
503 * The number of elements in the array must be equal to the value
504 * given by @num_waitchks.
505 */
506 __u64 waitchks;
507
508 /**
509 * @fence:
510 *
511 * The threshold of the syncpoint associated with this job after it
512 * has been completed. Set by the kernel upon successful completion of
513 * the IOCTL. This can be used with the DRM_TEGRA_SYNCPT_WAIT IOCTL to
514 * wait for this job to be finished.
515 */
516 __u32 fence;
517
518 /**
519 * @reserved:
520 *
521 * This field is reserved for future use. Must be 0.
522 */
523 __u32 reserved[5];
524 };
525
526 #define DRM_TEGRA_GEM_TILING_MODE_PITCH 0
527 #define DRM_TEGRA_GEM_TILING_MODE_TILED 1
528 #define DRM_TEGRA_GEM_TILING_MODE_BLOCK 2
529
530 /**
531 * struct drm_tegra_gem_set_tiling - parameters for the set tiling IOCTL
532 */
533 struct drm_tegra_gem_set_tiling {
534 /**
535 * @handle:
536 *
537 * Handle to the GEM object for which to set the tiling parameters.
538 */
539 __u32 handle;
540
541 /**
542 * @mode:
543 *
544 * The tiling mode to set. Must be one of:
545 *
546 * DRM_TEGRA_GEM_TILING_MODE_PITCH
547 * pitch linear format
548 *
549 * DRM_TEGRA_GEM_TILING_MODE_TILED
550 * 16x16 tiling format
551 *
552 * DRM_TEGRA_GEM_TILING_MODE_BLOCK
553 * 16Bx2 tiling format
554 */
555 __u32 mode;
556
557 /**
558 * @value:
559 *
560 * The value to set for the tiling mode parameter.
561 */
562 __u32 value;
563
564 /**
565 * @pad:
566 *
567 * Structure padding that may be used in the future. Must be 0.
568 */
569 __u32 pad;
570 };
571
572 /**
573 * struct drm_tegra_gem_get_tiling - parameters for the get tiling IOCTL
574 */
575 struct drm_tegra_gem_get_tiling {
576 /**
577 * @handle:
578 *
579 * Handle to the GEM object for which to query the tiling parameters.
580 */
581 __u32 handle;
582
583 /**
584 * @mode:
585 *
586 * The tiling mode currently associated with the GEM object. Set by
587 * the kernel upon successful completion of the IOCTL.
588 */
589 __u32 mode;
590
591 /**
592 * @value:
593 *
594 * The tiling mode parameter currently associated with the GEM object.
595 * Set by the kernel upon successful completion of the IOCTL.
596 */
597 __u32 value;
598
599 /**
600 * @pad:
601 *
602 * Structure padding that may be used in the future. Must be 0.
603 */
604 __u32 pad;
605 };
606
607 #define DRM_TEGRA_GEM_BOTTOM_UP (1 << 0)
608 #define DRM_TEGRA_GEM_FLAGS (DRM_TEGRA_GEM_BOTTOM_UP)
609
610 /**
611 * struct drm_tegra_gem_set_flags - parameters for the set flags IOCTL
612 */
613 struct drm_tegra_gem_set_flags {
614 /**
615 * @handle:
616 *
617 * Handle to the GEM object for which to set the flags.
618 */
619 __u32 handle;
620
621 /**
622 * @flags:
623 *
624 * The flags to set for the GEM object.
625 */
626 __u32 flags;
627 };
628
629 /**
630 * struct drm_tegra_gem_get_flags - parameters for the get flags IOCTL
631 */
632 struct drm_tegra_gem_get_flags {
633 /**
634 * @handle:
635 *
636 * Handle to the GEM object for which to query the flags.
637 */
638 __u32 handle;
639
640 /**
641 * @flags:
642 *
643 * The flags currently associated with the GEM object. Set by the
644 * kernel upon successful completion of the IOCTL.
645 */
646 __u32 flags;
647 };
648
649 #define DRM_TEGRA_GEM_CREATE 0x00
650 #define DRM_TEGRA_GEM_MMAP 0x01
651 #define DRM_TEGRA_SYNCPT_READ 0x02
652 #define DRM_TEGRA_SYNCPT_INCR 0x03
653 #define DRM_TEGRA_SYNCPT_WAIT 0x04
654 #define DRM_TEGRA_OPEN_CHANNEL 0x05
655 #define DRM_TEGRA_CLOSE_CHANNEL 0x06
656 #define DRM_TEGRA_GET_SYNCPT 0x07
657 #define DRM_TEGRA_SUBMIT 0x08
658 #define DRM_TEGRA_GET_SYNCPT_BASE 0x09
659 #define DRM_TEGRA_GEM_SET_TILING 0x0a
660 #define DRM_TEGRA_GEM_GET_TILING 0x0b
661 #define DRM_TEGRA_GEM_SET_FLAGS 0x0c
662 #define DRM_TEGRA_GEM_GET_FLAGS 0x0d
663
664 #define DRM_IOCTL_TEGRA_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_CREATE, struct drm_tegra_gem_create)
665 #define DRM_IOCTL_TEGRA_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_MMAP, struct drm_tegra_gem_mmap)
666 #define DRM_IOCTL_TEGRA_SYNCPT_READ DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SYNCPT_READ, struct drm_tegra_syncpt_read)
667 #define DRM_IOCTL_TEGRA_SYNCPT_INCR DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SYNCPT_INCR, struct drm_tegra_syncpt_incr)
668 #define DRM_IOCTL_TEGRA_SYNCPT_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SYNCPT_WAIT, struct drm_tegra_syncpt_wait)
669 #define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
670 #define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_close_channel)
671 #define DRM_IOCTL_TEGRA_GET_SYNCPT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GET_SYNCPT, struct drm_tegra_get_syncpt)
672 #define DRM_IOCTL_TEGRA_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SUBMIT, struct drm_tegra_submit)
673 #define DRM_IOCTL_TEGRA_GET_SYNCPT_BASE DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GET_SYNCPT_BASE, struct drm_tegra_get_syncpt_base)
674 #define DRM_IOCTL_TEGRA_GEM_SET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_SET_TILING, struct drm_tegra_gem_set_tiling)
675 #define DRM_IOCTL_TEGRA_GEM_GET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_GET_TILING, struct drm_tegra_gem_get_tiling)
676 #define DRM_IOCTL_TEGRA_GEM_SET_FLAGS DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_SET_FLAGS, struct drm_tegra_gem_set_flags)
677 #define DRM_IOCTL_TEGRA_GEM_GET_FLAGS DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_GET_FLAGS, struct drm_tegra_gem_get_flags)
678
679 #if defined(__cplusplus)
680 }
681 #endif
682
683 #endif
684