v3d_drm.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * Copyright © 2014-2018 Broadcom
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. * IN THE SOFTWARE.
  22. */
  23. #ifndef _V3D_DRM_H_
  24. #define _V3D_DRM_H_
  25. #include "drm.h"
  26. #if defined(__cplusplus)
  27. extern "C" {
  28. #endif
  29. #define DRM_V3D_SUBMIT_CL 0x00
  30. #define DRM_V3D_WAIT_BO 0x01
  31. #define DRM_V3D_CREATE_BO 0x02
  32. #define DRM_V3D_MMAP_BO 0x03
  33. #define DRM_V3D_GET_PARAM 0x04
  34. #define DRM_V3D_GET_BO_OFFSET 0x05
  35. #define DRM_IOCTL_V3D_SUBMIT_CL DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_SUBMIT_CL, struct drm_v3d_submit_cl)
  36. #define DRM_IOCTL_V3D_WAIT_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_WAIT_BO, struct drm_v3d_wait_bo)
  37. #define DRM_IOCTL_V3D_CREATE_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_CREATE_BO, struct drm_v3d_create_bo)
  38. #define DRM_IOCTL_V3D_MMAP_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_MMAP_BO, struct drm_v3d_mmap_bo)
  39. #define DRM_IOCTL_V3D_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_GET_PARAM, struct drm_v3d_get_param)
  40. #define DRM_IOCTL_V3D_GET_BO_OFFSET DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_GET_BO_OFFSET, struct drm_v3d_get_bo_offset)
  41. /**
  42. * struct drm_v3d_submit_cl - ioctl argument for submitting commands to the 3D
  43. * engine.
  44. *
  45. * This asks the kernel to have the GPU execute an optional binner
  46. * command list, and a render command list.
  47. */
  48. struct drm_v3d_submit_cl {
  49. /* Pointer to the binner command list.
  50. *
  51. * This is the first set of commands executed, which runs the
  52. * coordinate shader to determine where primitives land on the screen,
  53. * then writes out the state updates and draw calls necessary per tile
  54. * to the tile allocation BO.
  55. */
  56. __u32 bcl_start;
  57. /** End address of the BCL (first byte after the BCL) */
  58. __u32 bcl_end;
  59. /* Offset of the render command list.
  60. *
  61. * This is the second set of commands executed, which will either
  62. * execute the tiles that have been set up by the BCL, or a fixed set
  63. * of tiles (in the case of RCL-only blits).
  64. */
  65. __u32 rcl_start;
  66. /** End address of the RCL (first byte after the RCL) */
  67. __u32 rcl_end;
  68. /** An optional sync object to wait on before starting the BCL. */
  69. __u32 in_sync_bcl;
  70. /** An optional sync object to wait on before starting the RCL. */
  71. __u32 in_sync_rcl;
  72. /** An optional sync object to place the completion fence in. */
  73. __u32 out_sync;
  74. /* Offset of the tile alloc memory
  75. *
  76. * This is optional on V3D 3.3 (where the CL can set the value) but
  77. * required on V3D 4.1.
  78. */
  79. __u32 qma;
  80. /** Size of the tile alloc memory. */
  81. __u32 qms;
  82. /** Offset of the tile state data array. */
  83. __u32 qts;
  84. /* Pointer to a u32 array of the BOs that are referenced by the job.
  85. */
  86. __u64 bo_handles;
  87. /* Number of BO handles passed in (size is that times 4). */
  88. __u32 bo_handle_count;
  89. /* Pad, must be zero-filled. */
  90. __u32 pad;
  91. };
  92. /**
  93. * struct drm_v3d_wait_bo - ioctl argument for waiting for
  94. * completion of the last DRM_V3D_SUBMIT_CL on a BO.
  95. *
  96. * This is useful for cases where multiple processes might be
  97. * rendering to a BO and you want to wait for all rendering to be
  98. * completed.
  99. */
  100. struct drm_v3d_wait_bo {
  101. __u32 handle;
  102. __u32 pad;
  103. __u64 timeout_ns;
  104. };
  105. /**
  106. * struct drm_v3d_create_bo - ioctl argument for creating V3D BOs.
  107. *
  108. * There are currently no values for the flags argument, but it may be
  109. * used in a future extension.
  110. */
  111. struct drm_v3d_create_bo {
  112. __u32 size;
  113. __u32 flags;
  114. /** Returned GEM handle for the BO. */
  115. __u32 handle;
  116. /**
  117. * Returned offset for the BO in the V3D address space. This offset
  118. * is private to the DRM fd and is valid for the lifetime of the GEM
  119. * handle.
  120. *
  121. * This offset value will always be nonzero, since various HW
  122. * units treat 0 specially.
  123. */
  124. __u32 offset;
  125. };
  126. /**
  127. * struct drm_v3d_mmap_bo - ioctl argument for mapping V3D BOs.
  128. *
  129. * This doesn't actually perform an mmap. Instead, it returns the
  130. * offset you need to use in an mmap on the DRM device node. This
  131. * means that tools like valgrind end up knowing about the mapped
  132. * memory.
  133. *
  134. * There are currently no values for the flags argument, but it may be
  135. * used in a future extension.
  136. */
  137. struct drm_v3d_mmap_bo {
  138. /** Handle for the object being mapped. */
  139. __u32 handle;
  140. __u32 flags;
  141. /** offset into the drm node to use for subsequent mmap call. */
  142. __u64 offset;
  143. };
  144. enum drm_v3d_param {
  145. DRM_V3D_PARAM_V3D_UIFCFG,
  146. DRM_V3D_PARAM_V3D_HUB_IDENT1,
  147. DRM_V3D_PARAM_V3D_HUB_IDENT2,
  148. DRM_V3D_PARAM_V3D_HUB_IDENT3,
  149. DRM_V3D_PARAM_V3D_CORE0_IDENT0,
  150. DRM_V3D_PARAM_V3D_CORE0_IDENT1,
  151. DRM_V3D_PARAM_V3D_CORE0_IDENT2,
  152. };
  153. struct drm_v3d_get_param {
  154. __u32 param;
  155. __u32 pad;
  156. __u64 value;
  157. };
  158. /**
  159. * Returns the offset for the BO in the V3D address space for this DRM fd.
  160. * This is the same value returned by drm_v3d_create_bo, if that was called
  161. * from this DRM fd.
  162. */
  163. struct drm_v3d_get_bo_offset {
  164. __u32 handle;
  165. __u32 offset;
  166. };
  167. #if defined(__cplusplus)
  168. }
  169. #endif
  170. #endif /* _V3D_DRM_H_ */