tegra_drm.h 21 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060
  1. /* SPDX-License-Identifier: MIT */
  2. /* Copyright (c) 2012-2020 NVIDIA Corporation */
  3. #ifndef _TEGRA_DRM_H_
  4. #define _TEGRA_DRM_H_
  5. #include "drm.h"
  6. #if defined(__cplusplus)
  7. extern "C" {
  8. #endif
  9. /* Tegra DRM legacy UAPI. Only enabled with STAGING */
  10. #define DRM_TEGRA_GEM_CREATE_TILED (1 << 0)
  11. #define DRM_TEGRA_GEM_CREATE_BOTTOM_UP (1 << 1)
  12. /**
  13. * struct drm_tegra_gem_create - parameters for the GEM object creation IOCTL
  14. */
  15. struct drm_tegra_gem_create {
  16. /**
  17. * @size:
  18. *
  19. * The size, in bytes, of the buffer object to be created.
  20. */
  21. __u64 size;
  22. /**
  23. * @flags:
  24. *
  25. * A bitmask of flags that influence the creation of GEM objects:
  26. *
  27. * DRM_TEGRA_GEM_CREATE_TILED
  28. * Use the 16x16 tiling format for this buffer.
  29. *
  30. * DRM_TEGRA_GEM_CREATE_BOTTOM_UP
  31. * The buffer has a bottom-up layout.
  32. */
  33. __u32 flags;
  34. /**
  35. * @handle:
  36. *
  37. * The handle of the created GEM object. Set by the kernel upon
  38. * successful completion of the IOCTL.
  39. */
  40. __u32 handle;
  41. };
  42. /**
  43. * struct drm_tegra_gem_mmap - parameters for the GEM mmap IOCTL
  44. */
  45. struct drm_tegra_gem_mmap {
  46. /**
  47. * @handle:
  48. *
  49. * Handle of the GEM object to obtain an mmap offset for.
  50. */
  51. __u32 handle;
  52. /**
  53. * @pad:
  54. *
  55. * Structure padding that may be used in the future. Must be 0.
  56. */
  57. __u32 pad;
  58. /**
  59. * @offset:
  60. *
  61. * The mmap offset for the given GEM object. Set by the kernel upon
  62. * successful completion of the IOCTL.
  63. */
  64. __u64 offset;
  65. };
  66. /**
  67. * struct drm_tegra_syncpt_read - parameters for the read syncpoint IOCTL
  68. */
  69. struct drm_tegra_syncpt_read {
  70. /**
  71. * @id:
  72. *
  73. * ID of the syncpoint to read the current value from.
  74. */
  75. __u32 id;
  76. /**
  77. * @value:
  78. *
  79. * The current syncpoint value. Set by the kernel upon successful
  80. * completion of the IOCTL.
  81. */
  82. __u32 value;
  83. };
  84. /**
  85. * struct drm_tegra_syncpt_incr - parameters for the increment syncpoint IOCTL
  86. */
  87. struct drm_tegra_syncpt_incr {
  88. /**
  89. * @id:
  90. *
  91. * ID of the syncpoint to increment.
  92. */
  93. __u32 id;
  94. /**
  95. * @pad:
  96. *
  97. * Structure padding that may be used in the future. Must be 0.
  98. */
  99. __u32 pad;
  100. };
  101. /**
  102. * struct drm_tegra_syncpt_wait - parameters for the wait syncpoint IOCTL
  103. */
  104. struct drm_tegra_syncpt_wait {
  105. /**
  106. * @id:
  107. *
  108. * ID of the syncpoint to wait on.
  109. */
  110. __u32 id;
  111. /**
  112. * @thresh:
  113. *
  114. * Threshold value for which to wait.
  115. */
  116. __u32 thresh;
  117. /**
  118. * @timeout:
  119. *
  120. * Timeout, in milliseconds, to wait.
  121. */
  122. __u32 timeout;
  123. /**
  124. * @value:
  125. *
  126. * The new syncpoint value after the wait. Set by the kernel upon
  127. * successful completion of the IOCTL.
  128. */
  129. __u32 value;
  130. };
  131. #define DRM_TEGRA_NO_TIMEOUT (0xffffffff)
  132. /**
  133. * struct drm_tegra_open_channel - parameters for the open channel IOCTL
  134. */
  135. struct drm_tegra_open_channel {
  136. /**
  137. * @client:
  138. *
  139. * The client ID for this channel.
  140. */
  141. __u32 client;
  142. /**
  143. * @pad:
  144. *
  145. * Structure padding that may be used in the future. Must be 0.
  146. */
  147. __u32 pad;
  148. /**
  149. * @context:
  150. *
  151. * The application context of this channel. Set by the kernel upon
  152. * successful completion of the IOCTL. This context needs to be passed
  153. * to the DRM_TEGRA_CHANNEL_CLOSE or the DRM_TEGRA_SUBMIT IOCTLs.
  154. */
  155. __u64 context;
  156. };
  157. /**
  158. * struct drm_tegra_close_channel - parameters for the close channel IOCTL
  159. */
  160. struct drm_tegra_close_channel {
  161. /**
  162. * @context:
  163. *
  164. * The application context of this channel. This is obtained from the
  165. * DRM_TEGRA_OPEN_CHANNEL IOCTL.
  166. */
  167. __u64 context;
  168. };
  169. /**
  170. * struct drm_tegra_get_syncpt - parameters for the get syncpoint IOCTL
  171. */
  172. struct drm_tegra_get_syncpt {
  173. /**
  174. * @context:
  175. *
  176. * The application context identifying the channel for which to obtain
  177. * the syncpoint ID.
  178. */
  179. __u64 context;
  180. /**
  181. * @index:
  182. *
  183. * Index of the client syncpoint for which to obtain the ID.
  184. */
  185. __u32 index;
  186. /**
  187. * @id:
  188. *
  189. * The ID of the given syncpoint. Set by the kernel upon successful
  190. * completion of the IOCTL.
  191. */
  192. __u32 id;
  193. };
  194. /**
  195. * struct drm_tegra_get_syncpt_base - parameters for the get wait base IOCTL
  196. */
  197. struct drm_tegra_get_syncpt_base {
  198. /**
  199. * @context:
  200. *
  201. * The application context identifying for which channel to obtain the
  202. * wait base.
  203. */
  204. __u64 context;
  205. /**
  206. * @syncpt:
  207. *
  208. * ID of the syncpoint for which to obtain the wait base.
  209. */
  210. __u32 syncpt;
  211. /**
  212. * @id:
  213. *
  214. * The ID of the wait base corresponding to the client syncpoint. Set
  215. * by the kernel upon successful completion of the IOCTL.
  216. */
  217. __u32 id;
  218. };
  219. /**
  220. * struct drm_tegra_syncpt - syncpoint increment operation
  221. */
  222. struct drm_tegra_syncpt {
  223. /**
  224. * @id:
  225. *
  226. * ID of the syncpoint to operate on.
  227. */
  228. __u32 id;
  229. /**
  230. * @incrs:
  231. *
  232. * Number of increments to perform for the syncpoint.
  233. */
  234. __u32 incrs;
  235. };
  236. /**
  237. * struct drm_tegra_cmdbuf - structure describing a command buffer
  238. */
  239. struct drm_tegra_cmdbuf {
  240. /**
  241. * @handle:
  242. *
  243. * Handle to a GEM object containing the command buffer.
  244. */
  245. __u32 handle;
  246. /**
  247. * @offset:
  248. *
  249. * Offset, in bytes, into the GEM object identified by @handle at
  250. * which the command buffer starts.
  251. */
  252. __u32 offset;
  253. /**
  254. * @words:
  255. *
  256. * Number of 32-bit words in this command buffer.
  257. */
  258. __u32 words;
  259. /**
  260. * @pad:
  261. *
  262. * Structure padding that may be used in the future. Must be 0.
  263. */
  264. __u32 pad;
  265. };
  266. /**
  267. * struct drm_tegra_reloc - GEM object relocation structure
  268. */
  269. struct drm_tegra_reloc {
  270. struct {
  271. /**
  272. * @cmdbuf.handle:
  273. *
  274. * Handle to the GEM object containing the command buffer for
  275. * which to perform this GEM object relocation.
  276. */
  277. __u32 handle;
  278. /**
  279. * @cmdbuf.offset:
  280. *
  281. * Offset, in bytes, into the command buffer at which to
  282. * insert the relocated address.
  283. */
  284. __u32 offset;
  285. } cmdbuf;
  286. struct {
  287. /**
  288. * @target.handle:
  289. *
  290. * Handle to the GEM object to be relocated.
  291. */
  292. __u32 handle;
  293. /**
  294. * @target.offset:
  295. *
  296. * Offset, in bytes, into the target GEM object at which the
  297. * relocated data starts.
  298. */
  299. __u32 offset;
  300. } target;
  301. /**
  302. * @shift:
  303. *
  304. * The number of bits by which to shift relocated addresses.
  305. */
  306. __u32 shift;
  307. /**
  308. * @pad:
  309. *
  310. * Structure padding that may be used in the future. Must be 0.
  311. */
  312. __u32 pad;
  313. };
  314. /**
  315. * struct drm_tegra_waitchk - wait check structure
  316. */
  317. struct drm_tegra_waitchk {
  318. /**
  319. * @handle:
  320. *
  321. * Handle to the GEM object containing a command stream on which to
  322. * perform the wait check.
  323. */
  324. __u32 handle;
  325. /**
  326. * @offset:
  327. *
  328. * Offset, in bytes, of the location in the command stream to perform
  329. * the wait check on.
  330. */
  331. __u32 offset;
  332. /**
  333. * @syncpt:
  334. *
  335. * ID of the syncpoint to wait check.
  336. */
  337. __u32 syncpt;
  338. /**
  339. * @thresh:
  340. *
  341. * Threshold value for which to check.
  342. */
  343. __u32 thresh;
  344. };
  345. /**
  346. * struct drm_tegra_submit - job submission structure
  347. */
  348. struct drm_tegra_submit {
  349. /**
  350. * @context:
  351. *
  352. * The application context identifying the channel to use for the
  353. * execution of this job.
  354. */
  355. __u64 context;
  356. /**
  357. * @num_syncpts:
  358. *
  359. * The number of syncpoints operated on by this job. This defines the
  360. * length of the array pointed to by @syncpts.
  361. */
  362. __u32 num_syncpts;
  363. /**
  364. * @num_cmdbufs:
  365. *
  366. * The number of command buffers to execute as part of this job. This
  367. * defines the length of the array pointed to by @cmdbufs.
  368. */
  369. __u32 num_cmdbufs;
  370. /**
  371. * @num_relocs:
  372. *
  373. * The number of relocations to perform before executing this job.
  374. * This defines the length of the array pointed to by @relocs.
  375. */
  376. __u32 num_relocs;
  377. /**
  378. * @num_waitchks:
  379. *
  380. * The number of wait checks to perform as part of this job. This
  381. * defines the length of the array pointed to by @waitchks.
  382. */
  383. __u32 num_waitchks;
  384. /**
  385. * @waitchk_mask:
  386. *
  387. * Bitmask of valid wait checks.
  388. */
  389. __u32 waitchk_mask;
  390. /**
  391. * @timeout:
  392. *
  393. * Timeout, in milliseconds, before this job is cancelled.
  394. */
  395. __u32 timeout;
  396. /**
  397. * @syncpts:
  398. *
  399. * A pointer to an array of &struct drm_tegra_syncpt structures that
  400. * specify the syncpoint operations performed as part of this job.
  401. * The number of elements in the array must be equal to the value
  402. * given by @num_syncpts.
  403. */
  404. __u64 syncpts;
  405. /**
  406. * @cmdbufs:
  407. *
  408. * A pointer to an array of &struct drm_tegra_cmdbuf structures that
  409. * define the command buffers to execute as part of this job. The
  410. * number of elements in the array must be equal to the value given
  411. * by @num_syncpts.
  412. */
  413. __u64 cmdbufs;
  414. /**
  415. * @relocs:
  416. *
  417. * A pointer to an array of &struct drm_tegra_reloc structures that
  418. * specify the relocations that need to be performed before executing
  419. * this job. The number of elements in the array must be equal to the
  420. * value given by @num_relocs.
  421. */
  422. __u64 relocs;
  423. /**
  424. * @waitchks:
  425. *
  426. * A pointer to an array of &struct drm_tegra_waitchk structures that
  427. * specify the wait checks to be performed while executing this job.
  428. * The number of elements in the array must be equal to the value
  429. * given by @num_waitchks.
  430. */
  431. __u64 waitchks;
  432. /**
  433. * @fence:
  434. *
  435. * The threshold of the syncpoint associated with this job after it
  436. * has been completed. Set by the kernel upon successful completion of
  437. * the IOCTL. This can be used with the DRM_TEGRA_SYNCPT_WAIT IOCTL to
  438. * wait for this job to be finished.
  439. */
  440. __u32 fence;
  441. /**
  442. * @reserved:
  443. *
  444. * This field is reserved for future use. Must be 0.
  445. */
  446. __u32 reserved[5];
  447. };
  448. #define DRM_TEGRA_GEM_TILING_MODE_PITCH 0
  449. #define DRM_TEGRA_GEM_TILING_MODE_TILED 1
  450. #define DRM_TEGRA_GEM_TILING_MODE_BLOCK 2
  451. /**
  452. * struct drm_tegra_gem_set_tiling - parameters for the set tiling IOCTL
  453. */
  454. struct drm_tegra_gem_set_tiling {
  455. /**
  456. * @handle:
  457. *
  458. * Handle to the GEM object for which to set the tiling parameters.
  459. */
  460. __u32 handle;
  461. /**
  462. * @mode:
  463. *
  464. * The tiling mode to set. Must be one of:
  465. *
  466. * DRM_TEGRA_GEM_TILING_MODE_PITCH
  467. * pitch linear format
  468. *
  469. * DRM_TEGRA_GEM_TILING_MODE_TILED
  470. * 16x16 tiling format
  471. *
  472. * DRM_TEGRA_GEM_TILING_MODE_BLOCK
  473. * 16Bx2 tiling format
  474. */
  475. __u32 mode;
  476. /**
  477. * @value:
  478. *
  479. * The value to set for the tiling mode parameter.
  480. */
  481. __u32 value;
  482. /**
  483. * @pad:
  484. *
  485. * Structure padding that may be used in the future. Must be 0.
  486. */
  487. __u32 pad;
  488. };
  489. /**
  490. * struct drm_tegra_gem_get_tiling - parameters for the get tiling IOCTL
  491. */
  492. struct drm_tegra_gem_get_tiling {
  493. /**
  494. * @handle:
  495. *
  496. * Handle to the GEM object for which to query the tiling parameters.
  497. */
  498. __u32 handle;
  499. /**
  500. * @mode:
  501. *
  502. * The tiling mode currently associated with the GEM object. Set by
  503. * the kernel upon successful completion of the IOCTL.
  504. */
  505. __u32 mode;
  506. /**
  507. * @value:
  508. *
  509. * The tiling mode parameter currently associated with the GEM object.
  510. * Set by the kernel upon successful completion of the IOCTL.
  511. */
  512. __u32 value;
  513. /**
  514. * @pad:
  515. *
  516. * Structure padding that may be used in the future. Must be 0.
  517. */
  518. __u32 pad;
  519. };
  520. #define DRM_TEGRA_GEM_BOTTOM_UP (1 << 0)
  521. #define DRM_TEGRA_GEM_FLAGS (DRM_TEGRA_GEM_BOTTOM_UP)
  522. /**
  523. * struct drm_tegra_gem_set_flags - parameters for the set flags IOCTL
  524. */
  525. struct drm_tegra_gem_set_flags {
  526. /**
  527. * @handle:
  528. *
  529. * Handle to the GEM object for which to set the flags.
  530. */
  531. __u32 handle;
  532. /**
  533. * @flags:
  534. *
  535. * The flags to set for the GEM object.
  536. */
  537. __u32 flags;
  538. };
  539. /**
  540. * struct drm_tegra_gem_get_flags - parameters for the get flags IOCTL
  541. */
  542. struct drm_tegra_gem_get_flags {
  543. /**
  544. * @handle:
  545. *
  546. * Handle to the GEM object for which to query the flags.
  547. */
  548. __u32 handle;
  549. /**
  550. * @flags:
  551. *
  552. * The flags currently associated with the GEM object. Set by the
  553. * kernel upon successful completion of the IOCTL.
  554. */
  555. __u32 flags;
  556. };
  557. #define DRM_TEGRA_GEM_CREATE 0x00
  558. #define DRM_TEGRA_GEM_MMAP 0x01
  559. #define DRM_TEGRA_SYNCPT_READ 0x02
  560. #define DRM_TEGRA_SYNCPT_INCR 0x03
  561. #define DRM_TEGRA_SYNCPT_WAIT 0x04
  562. #define DRM_TEGRA_OPEN_CHANNEL 0x05
  563. #define DRM_TEGRA_CLOSE_CHANNEL 0x06
  564. #define DRM_TEGRA_GET_SYNCPT 0x07
  565. #define DRM_TEGRA_SUBMIT 0x08
  566. #define DRM_TEGRA_GET_SYNCPT_BASE 0x09
  567. #define DRM_TEGRA_GEM_SET_TILING 0x0a
  568. #define DRM_TEGRA_GEM_GET_TILING 0x0b
  569. #define DRM_TEGRA_GEM_SET_FLAGS 0x0c
  570. #define DRM_TEGRA_GEM_GET_FLAGS 0x0d
  571. #define DRM_IOCTL_TEGRA_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_CREATE, struct drm_tegra_gem_create)
  572. #define DRM_IOCTL_TEGRA_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_MMAP, struct drm_tegra_gem_mmap)
  573. #define DRM_IOCTL_TEGRA_SYNCPT_READ DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SYNCPT_READ, struct drm_tegra_syncpt_read)
  574. #define DRM_IOCTL_TEGRA_SYNCPT_INCR DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SYNCPT_INCR, struct drm_tegra_syncpt_incr)
  575. #define DRM_IOCTL_TEGRA_SYNCPT_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SYNCPT_WAIT, struct drm_tegra_syncpt_wait)
  576. #define DRM_IOCTL_TEGRA_OPEN_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_OPEN_CHANNEL, struct drm_tegra_open_channel)
  577. #define DRM_IOCTL_TEGRA_CLOSE_CHANNEL DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_CLOSE_CHANNEL, struct drm_tegra_close_channel)
  578. #define DRM_IOCTL_TEGRA_GET_SYNCPT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GET_SYNCPT, struct drm_tegra_get_syncpt)
  579. #define DRM_IOCTL_TEGRA_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_SUBMIT, struct drm_tegra_submit)
  580. #define DRM_IOCTL_TEGRA_GET_SYNCPT_BASE DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GET_SYNCPT_BASE, struct drm_tegra_get_syncpt_base)
  581. #define DRM_IOCTL_TEGRA_GEM_SET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_SET_TILING, struct drm_tegra_gem_set_tiling)
  582. #define DRM_IOCTL_TEGRA_GEM_GET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_GET_TILING, struct drm_tegra_gem_get_tiling)
  583. #define DRM_IOCTL_TEGRA_GEM_SET_FLAGS DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_SET_FLAGS, struct drm_tegra_gem_set_flags)
  584. #define DRM_IOCTL_TEGRA_GEM_GET_FLAGS DRM_IOWR(DRM_COMMAND_BASE + DRM_TEGRA_GEM_GET_FLAGS, struct drm_tegra_gem_get_flags)
  585. /* New Tegra DRM UAPI */
  586. /*
  587. * Reported by the driver in the `capabilities` field.
  588. *
  589. * DRM_TEGRA_CHANNEL_CAP_CACHE_COHERENT: If set, the engine is cache coherent
  590. * with regard to the system memory.
  591. */
  592. #define DRM_TEGRA_CHANNEL_CAP_CACHE_COHERENT (1 << 0)
  593. struct drm_tegra_channel_open {
  594. /**
  595. * @host1x_class: [in]
  596. *
  597. * Host1x class of the engine that will be programmed using this
  598. * channel.
  599. */
  600. __u32 host1x_class;
  601. /**
  602. * @flags: [in]
  603. *
  604. * Flags.
  605. */
  606. __u32 flags;
  607. /**
  608. * @context: [out]
  609. *
  610. * Opaque identifier corresponding to the opened channel.
  611. */
  612. __u32 context;
  613. /**
  614. * @version: [out]
  615. *
  616. * Version of the engine hardware. This can be used by userspace
  617. * to determine how the engine needs to be programmed.
  618. */
  619. __u32 version;
  620. /**
  621. * @capabilities: [out]
  622. *
  623. * Flags describing the hardware capabilities.
  624. */
  625. __u32 capabilities;
  626. __u32 padding;
  627. };
  628. struct drm_tegra_channel_close {
  629. /**
  630. * @context: [in]
  631. *
  632. * Identifier of the channel to close.
  633. */
  634. __u32 context;
  635. __u32 padding;
  636. };
  637. /*
  638. * Mapping flags that can be used to influence how the mapping is created.
  639. *
  640. * DRM_TEGRA_CHANNEL_MAP_READ: create mapping that allows HW read access
  641. * DRM_TEGRA_CHANNEL_MAP_WRITE: create mapping that allows HW write access
  642. */
  643. #define DRM_TEGRA_CHANNEL_MAP_READ (1 << 0)
  644. #define DRM_TEGRA_CHANNEL_MAP_WRITE (1 << 1)
  645. #define DRM_TEGRA_CHANNEL_MAP_READ_WRITE (DRM_TEGRA_CHANNEL_MAP_READ | \
  646. DRM_TEGRA_CHANNEL_MAP_WRITE)
  647. struct drm_tegra_channel_map {
  648. /**
  649. * @context: [in]
  650. *
  651. * Identifier of the channel to which make memory available for.
  652. */
  653. __u32 context;
  654. /**
  655. * @handle: [in]
  656. *
  657. * GEM handle of the memory to map.
  658. */
  659. __u32 handle;
  660. /**
  661. * @flags: [in]
  662. *
  663. * Flags.
  664. */
  665. __u32 flags;
  666. /**
  667. * @mapping: [out]
  668. *
  669. * Identifier corresponding to the mapping, to be used for
  670. * relocations or unmapping later.
  671. */
  672. __u32 mapping;
  673. };
  674. struct drm_tegra_channel_unmap {
  675. /**
  676. * @context: [in]
  677. *
  678. * Channel identifier of the channel to unmap memory from.
  679. */
  680. __u32 context;
  681. /**
  682. * @mapping: [in]
  683. *
  684. * Mapping identifier of the memory mapping to unmap.
  685. */
  686. __u32 mapping;
  687. };
  688. /* Submission */
  689. /**
  690. * Specify that bit 39 of the patched-in address should be set to switch
  691. * swizzling between Tegra and non-Tegra sector layout on systems that store
  692. * surfaces in system memory in non-Tegra sector layout.
  693. */
  694. #define DRM_TEGRA_SUBMIT_RELOC_SECTOR_LAYOUT (1 << 0)
  695. struct drm_tegra_submit_buf {
  696. /**
  697. * @mapping: [in]
  698. *
  699. * Identifier of the mapping to use in the submission.
  700. */
  701. __u32 mapping;
  702. /**
  703. * @flags: [in]
  704. *
  705. * Flags.
  706. */
  707. __u32 flags;
  708. /**
  709. * Information for relocation patching.
  710. */
  711. struct {
  712. /**
  713. * @target_offset: [in]
  714. *
  715. * Offset from the start of the mapping of the data whose
  716. * address is to be patched into the gather.
  717. */
  718. __u64 target_offset;
  719. /**
  720. * @gather_offset_words: [in]
  721. *
  722. * Offset in words from the start of the gather data to
  723. * where the address should be patched into.
  724. */
  725. __u32 gather_offset_words;
  726. /**
  727. * @shift: [in]
  728. *
  729. * Number of bits the address should be shifted right before
  730. * patching in.
  731. */
  732. __u32 shift;
  733. } reloc;
  734. };
  735. /**
  736. * Execute `words` words of Host1x opcodes specified in the `gather_data_ptr`
  737. * buffer. Each GATHER_UPTR command uses successive words from the buffer.
  738. */
  739. #define DRM_TEGRA_SUBMIT_CMD_GATHER_UPTR 0
  740. /**
  741. * Wait for a syncpoint to reach a value before continuing with further
  742. * commands.
  743. */
  744. #define DRM_TEGRA_SUBMIT_CMD_WAIT_SYNCPT 1
  745. /**
  746. * Wait for a syncpoint to reach a value before continuing with further
  747. * commands. The threshold is calculated relative to the start of the job.
  748. */
  749. #define DRM_TEGRA_SUBMIT_CMD_WAIT_SYNCPT_RELATIVE 2
  750. struct drm_tegra_submit_cmd_gather_uptr {
  751. __u32 words;
  752. __u32 reserved[3];
  753. };
  754. struct drm_tegra_submit_cmd_wait_syncpt {
  755. __u32 id;
  756. __u32 value;
  757. __u32 reserved[2];
  758. };
  759. struct drm_tegra_submit_cmd {
  760. /**
  761. * @type: [in]
  762. *
  763. * Command type to execute. One of the DRM_TEGRA_SUBMIT_CMD*
  764. * defines.
  765. */
  766. __u32 type;
  767. /**
  768. * @flags: [in]
  769. *
  770. * Flags.
  771. */
  772. __u32 flags;
  773. union {
  774. struct drm_tegra_submit_cmd_gather_uptr gather_uptr;
  775. struct drm_tegra_submit_cmd_wait_syncpt wait_syncpt;
  776. __u32 reserved[4];
  777. };
  778. };
  779. struct drm_tegra_submit_syncpt {
  780. /**
  781. * @id: [in]
  782. *
  783. * ID of the syncpoint that the job will increment.
  784. */
  785. __u32 id;
  786. /**
  787. * @flags: [in]
  788. *
  789. * Flags.
  790. */
  791. __u32 flags;
  792. /**
  793. * @increments: [in]
  794. *
  795. * Number of times the job will increment this syncpoint.
  796. */
  797. __u32 increments;
  798. /**
  799. * @value: [out]
  800. *
  801. * Value the syncpoint will have once the job has completed all
  802. * its specified syncpoint increments.
  803. *
  804. * Note that the kernel may increment the syncpoint before or after
  805. * the job. These increments are not reflected in this field.
  806. *
  807. * If the job hangs or times out, not all of the increments may
  808. * get executed.
  809. */
  810. __u32 value;
  811. };
  812. struct drm_tegra_channel_submit {
  813. /**
  814. * @context: [in]
  815. *
  816. * Identifier of the channel to submit this job to.
  817. */
  818. __u32 context;
  819. /**
  820. * @num_bufs: [in]
  821. *
  822. * Number of elements in the `bufs_ptr` array.
  823. */
  824. __u32 num_bufs;
  825. /**
  826. * @num_cmds: [in]
  827. *
  828. * Number of elements in the `cmds_ptr` array.
  829. */
  830. __u32 num_cmds;
  831. /**
  832. * @gather_data_words: [in]
  833. *
  834. * Number of 32-bit words in the `gather_data_ptr` array.
  835. */
  836. __u32 gather_data_words;
  837. /**
  838. * @bufs_ptr: [in]
  839. *
  840. * Pointer to an array of drm_tegra_submit_buf structures.
  841. */
  842. __u64 bufs_ptr;
  843. /**
  844. * @cmds_ptr: [in]
  845. *
  846. * Pointer to an array of drm_tegra_submit_cmd structures.
  847. */
  848. __u64 cmds_ptr;
  849. /**
  850. * @gather_data_ptr: [in]
  851. *
  852. * Pointer to an array of Host1x opcodes to be used by GATHER_UPTR
  853. * commands.
  854. */
  855. __u64 gather_data_ptr;
  856. /**
  857. * @syncobj_in: [in]
  858. *
  859. * Handle for DRM syncobj that will be waited before submission.
  860. * Ignored if zero.
  861. */
  862. __u32 syncobj_in;
  863. /**
  864. * @syncobj_out: [in]
  865. *
  866. * Handle for DRM syncobj that will have its fence replaced with
  867. * the job's completion fence. Ignored if zero.
  868. */
  869. __u32 syncobj_out;
  870. /**
  871. * @syncpt_incr: [in,out]
  872. *
  873. * Information about the syncpoint the job will increment.
  874. */
  875. struct drm_tegra_submit_syncpt syncpt;
  876. };
  877. struct drm_tegra_syncpoint_allocate {
  878. /**
  879. * @id: [out]
  880. *
  881. * ID of allocated syncpoint.
  882. */
  883. __u32 id;
  884. __u32 padding;
  885. };
  886. struct drm_tegra_syncpoint_free {
  887. /**
  888. * @id: [in]
  889. *
  890. * ID of syncpoint to free.
  891. */
  892. __u32 id;
  893. __u32 padding;
  894. };
  895. struct drm_tegra_syncpoint_wait {
  896. /**
  897. * @timeout: [in]
  898. *
  899. * Absolute timestamp at which the wait will time out.
  900. */
  901. __s64 timeout_ns;
  902. /**
  903. * @id: [in]
  904. *
  905. * ID of syncpoint to wait on.
  906. */
  907. __u32 id;
  908. /**
  909. * @threshold: [in]
  910. *
  911. * Threshold to wait for.
  912. */
  913. __u32 threshold;
  914. /**
  915. * @value: [out]
  916. *
  917. * Value of the syncpoint upon wait completion.
  918. */
  919. __u32 value;
  920. __u32 padding;
  921. };
  922. #define DRM_IOCTL_TEGRA_CHANNEL_OPEN DRM_IOWR(DRM_COMMAND_BASE + 0x10, struct drm_tegra_channel_open)
  923. #define DRM_IOCTL_TEGRA_CHANNEL_CLOSE DRM_IOWR(DRM_COMMAND_BASE + 0x11, struct drm_tegra_channel_close)
  924. #define DRM_IOCTL_TEGRA_CHANNEL_MAP DRM_IOWR(DRM_COMMAND_BASE + 0x12, struct drm_tegra_channel_map)
  925. #define DRM_IOCTL_TEGRA_CHANNEL_UNMAP DRM_IOWR(DRM_COMMAND_BASE + 0x13, struct drm_tegra_channel_unmap)
  926. #define DRM_IOCTL_TEGRA_CHANNEL_SUBMIT DRM_IOWR(DRM_COMMAND_BASE + 0x14, struct drm_tegra_channel_submit)
  927. #define DRM_IOCTL_TEGRA_SYNCPOINT_ALLOCATE DRM_IOWR(DRM_COMMAND_BASE + 0x20, struct drm_tegra_syncpoint_allocate)
  928. #define DRM_IOCTL_TEGRA_SYNCPOINT_FREE DRM_IOWR(DRM_COMMAND_BASE + 0x21, struct drm_tegra_syncpoint_free)
  929. #define DRM_IOCTL_TEGRA_SYNCPOINT_WAIT DRM_IOWR(DRM_COMMAND_BASE + 0x22, struct drm_tegra_syncpoint_wait)
  930. #if defined(__cplusplus)
  931. }
  932. #endif
  933. #endif