1
0

nouveau_drm.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. /*
  2. * Copyright 2005 Stephane Marchesin.
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the "Software"),
  7. * to deal in the Software without restriction, including without limitation
  8. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. * and/or sell copies of the Software, and to permit persons to whom the
  10. * Software is furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice (including the next
  13. * paragraph) shall be included in all copies or substantial portions of the
  14. * 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. * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS 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. #ifndef __NOUVEAU_DRM_H__
  25. #define __NOUVEAU_DRM_H__
  26. #define NOUVEAU_DRM_HEADER_PATCHLEVEL 16
  27. #include "drm.h"
  28. #if defined(__cplusplus)
  29. extern "C" {
  30. #endif
  31. struct drm_nouveau_channel_alloc {
  32. uint32_t fb_ctxdma_handle;
  33. uint32_t tt_ctxdma_handle;
  34. int channel;
  35. uint32_t pushbuf_domains;
  36. /* Notifier memory */
  37. uint32_t notifier_handle;
  38. /* DRM-enforced subchannel assignments */
  39. struct {
  40. uint32_t handle;
  41. uint32_t grclass;
  42. } subchan[8];
  43. uint32_t nr_subchan;
  44. };
  45. struct drm_nouveau_channel_free {
  46. int channel;
  47. };
  48. struct drm_nouveau_grobj_alloc {
  49. int channel;
  50. uint32_t handle;
  51. int class;
  52. };
  53. struct drm_nouveau_notifierobj_alloc {
  54. uint32_t channel;
  55. uint32_t handle;
  56. uint32_t size;
  57. uint32_t offset;
  58. };
  59. struct drm_nouveau_gpuobj_free {
  60. int channel;
  61. uint32_t handle;
  62. };
  63. #define NOUVEAU_GETPARAM_PCI_VENDOR 3
  64. #define NOUVEAU_GETPARAM_PCI_DEVICE 4
  65. #define NOUVEAU_GETPARAM_BUS_TYPE 5
  66. #define NOUVEAU_GETPARAM_FB_SIZE 8
  67. #define NOUVEAU_GETPARAM_AGP_SIZE 9
  68. #define NOUVEAU_GETPARAM_CHIPSET_ID 11
  69. #define NOUVEAU_GETPARAM_VM_VRAM_BASE 12
  70. #define NOUVEAU_GETPARAM_GRAPH_UNITS 13
  71. #define NOUVEAU_GETPARAM_PTIMER_TIME 14
  72. #define NOUVEAU_GETPARAM_HAS_BO_USAGE 15
  73. #define NOUVEAU_GETPARAM_HAS_PAGEFLIP 16
  74. struct drm_nouveau_getparam {
  75. uint64_t param;
  76. uint64_t value;
  77. };
  78. struct drm_nouveau_setparam {
  79. uint64_t param;
  80. uint64_t value;
  81. };
  82. #define NOUVEAU_GEM_DOMAIN_CPU (1 << 0)
  83. #define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1)
  84. #define NOUVEAU_GEM_DOMAIN_GART (1 << 2)
  85. #define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3)
  86. #define NOUVEAU_GEM_DOMAIN_COHERENT (1 << 4)
  87. #define NOUVEAU_GEM_TILE_COMP 0x00030000 /* nv50-only */
  88. #define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00
  89. #define NOUVEAU_GEM_TILE_16BPP 0x00000001
  90. #define NOUVEAU_GEM_TILE_32BPP 0x00000002
  91. #define NOUVEAU_GEM_TILE_ZETA 0x00000004
  92. #define NOUVEAU_GEM_TILE_NONCONTIG 0x00000008
  93. struct drm_nouveau_gem_info {
  94. __u32 handle;
  95. __u32 domain;
  96. __u64 size;
  97. __u64 offset;
  98. __u64 map_handle;
  99. __u32 tile_mode;
  100. __u32 tile_flags;
  101. };
  102. struct drm_nouveau_gem_new {
  103. struct drm_nouveau_gem_info info;
  104. __u32 channel_hint;
  105. __u32 align;
  106. };
  107. #define NOUVEAU_GEM_MAX_BUFFERS 1024
  108. struct drm_nouveau_gem_pushbuf_bo_presumed {
  109. __u32 valid;
  110. __u32 domain;
  111. __u64 offset;
  112. };
  113. struct drm_nouveau_gem_pushbuf_bo {
  114. __u64 user_priv;
  115. __u32 handle;
  116. __u32 read_domains;
  117. __u32 write_domains;
  118. __u32 valid_domains;
  119. struct drm_nouveau_gem_pushbuf_bo_presumed presumed;
  120. };
  121. #define NOUVEAU_GEM_RELOC_LOW (1 << 0)
  122. #define NOUVEAU_GEM_RELOC_HIGH (1 << 1)
  123. #define NOUVEAU_GEM_RELOC_OR (1 << 2)
  124. #define NOUVEAU_GEM_MAX_RELOCS 1024
  125. struct drm_nouveau_gem_pushbuf_reloc {
  126. __u32 reloc_bo_index;
  127. __u32 reloc_bo_offset;
  128. __u32 bo_index;
  129. __u32 flags;
  130. __u32 data;
  131. __u32 vor;
  132. __u32 tor;
  133. };
  134. #define NOUVEAU_GEM_MAX_PUSH 512
  135. struct drm_nouveau_gem_pushbuf_push {
  136. __u32 bo_index;
  137. __u32 pad;
  138. __u64 offset;
  139. __u64 length;
  140. };
  141. struct drm_nouveau_gem_pushbuf {
  142. __u32 channel;
  143. __u32 nr_buffers;
  144. __u64 buffers;
  145. __u32 nr_relocs;
  146. __u32 nr_push;
  147. __u64 relocs;
  148. __u64 push;
  149. __u32 suffix0;
  150. __u32 suffix1;
  151. #define NOUVEAU_GEM_PUSHBUF_SYNC (1ULL << 0)
  152. __u64 vram_available;
  153. __u64 gart_available;
  154. };
  155. #define NOUVEAU_GEM_CPU_PREP_NOWAIT 0x00000001
  156. #define NOUVEAU_GEM_CPU_PREP_WRITE 0x00000004
  157. struct drm_nouveau_gem_cpu_prep {
  158. __u32 handle;
  159. __u32 flags;
  160. };
  161. struct drm_nouveau_gem_cpu_fini {
  162. __u32 handle;
  163. };
  164. #define DRM_NOUVEAU_GETPARAM 0x00 /* deprecated */
  165. #define DRM_NOUVEAU_SETPARAM 0x01 /* deprecated */
  166. #define DRM_NOUVEAU_CHANNEL_ALLOC 0x02 /* deprecated */
  167. #define DRM_NOUVEAU_CHANNEL_FREE 0x03 /* deprecated */
  168. #define DRM_NOUVEAU_GROBJ_ALLOC 0x04 /* deprecated */
  169. #define DRM_NOUVEAU_NOTIFIEROBJ_ALLOC 0x05 /* deprecated */
  170. #define DRM_NOUVEAU_GPUOBJ_FREE 0x06 /* deprecated */
  171. #define DRM_NOUVEAU_NVIF 0x07
  172. #define DRM_NOUVEAU_SVM_INIT 0x08
  173. #define DRM_NOUVEAU_SVM_BIND 0x09
  174. #define DRM_NOUVEAU_GEM_NEW 0x40
  175. #define DRM_NOUVEAU_GEM_PUSHBUF 0x41
  176. #define DRM_NOUVEAU_GEM_CPU_PREP 0x42
  177. #define DRM_NOUVEAU_GEM_CPU_FINI 0x43
  178. #define DRM_NOUVEAU_GEM_INFO 0x44
  179. struct drm_nouveau_svm_init {
  180. __u64 unmanaged_addr;
  181. __u64 unmanaged_size;
  182. };
  183. struct drm_nouveau_svm_bind {
  184. __u64 header;
  185. __u64 va_start;
  186. __u64 va_end;
  187. __u64 npages;
  188. __u64 stride;
  189. __u64 result;
  190. __u64 reserved0;
  191. __u64 reserved1;
  192. };
  193. #define NOUVEAU_SVM_BIND_COMMAND_SHIFT 0
  194. #define NOUVEAU_SVM_BIND_COMMAND_BITS 8
  195. #define NOUVEAU_SVM_BIND_COMMAND_MASK ((1 << 8) - 1)
  196. #define NOUVEAU_SVM_BIND_PRIORITY_SHIFT 8
  197. #define NOUVEAU_SVM_BIND_PRIORITY_BITS 8
  198. #define NOUVEAU_SVM_BIND_PRIORITY_MASK ((1 << 8) - 1)
  199. #define NOUVEAU_SVM_BIND_TARGET_SHIFT 16
  200. #define NOUVEAU_SVM_BIND_TARGET_BITS 32
  201. #define NOUVEAU_SVM_BIND_TARGET_MASK 0xffffffff
  202. /*
  203. * Below is use to validate ioctl argument, userspace can also use it to make
  204. * sure that no bit are set beyond known fields for a given kernel version.
  205. */
  206. #define NOUVEAU_SVM_BIND_VALID_BITS 48
  207. #define NOUVEAU_SVM_BIND_VALID_MASK ((1ULL << NOUVEAU_SVM_BIND_VALID_BITS) - 1)
  208. /*
  209. * NOUVEAU_BIND_COMMAND__MIGRATE: synchronous migrate to target memory.
  210. * result: number of page successfuly migrate to the target memory.
  211. */
  212. #define NOUVEAU_SVM_BIND_COMMAND__MIGRATE 0
  213. /*
  214. * NOUVEAU_SVM_BIND_HEADER_TARGET__GPU_VRAM: target the GPU VRAM memory.
  215. */
  216. #define NOUVEAU_SVM_BIND_TARGET__GPU_VRAM (1UL << 31)
  217. #if defined(__cplusplus)
  218. }
  219. #endif
  220. #endif /* __NOUVEAU_DRM_H__ */