nouveau_drm.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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 DRM_NOUVEAU_EVENT_NVIF 0x80000000
  27. #include "drm.h"
  28. #if defined(__cplusplus)
  29. extern "C" {
  30. #endif
  31. #define NOUVEAU_GEM_DOMAIN_CPU (1 << 0)
  32. #define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1)
  33. #define NOUVEAU_GEM_DOMAIN_GART (1 << 2)
  34. #define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3)
  35. #define NOUVEAU_GEM_DOMAIN_COHERENT (1 << 4)
  36. #define NOUVEAU_GEM_TILE_COMP 0x00030000 /* nv50-only */
  37. #define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00
  38. #define NOUVEAU_GEM_TILE_16BPP 0x00000001
  39. #define NOUVEAU_GEM_TILE_32BPP 0x00000002
  40. #define NOUVEAU_GEM_TILE_ZETA 0x00000004
  41. #define NOUVEAU_GEM_TILE_NONCONTIG 0x00000008
  42. struct drm_nouveau_gem_info {
  43. __u32 handle;
  44. __u32 domain;
  45. __u64 size;
  46. __u64 offset;
  47. __u64 map_handle;
  48. __u32 tile_mode;
  49. __u32 tile_flags;
  50. };
  51. struct drm_nouveau_gem_new {
  52. struct drm_nouveau_gem_info info;
  53. __u32 channel_hint;
  54. __u32 align;
  55. };
  56. #define NOUVEAU_GEM_MAX_BUFFERS 1024
  57. struct drm_nouveau_gem_pushbuf_bo_presumed {
  58. __u32 valid;
  59. __u32 domain;
  60. __u64 offset;
  61. };
  62. struct drm_nouveau_gem_pushbuf_bo {
  63. __u64 user_priv;
  64. __u32 handle;
  65. __u32 read_domains;
  66. __u32 write_domains;
  67. __u32 valid_domains;
  68. struct drm_nouveau_gem_pushbuf_bo_presumed presumed;
  69. };
  70. #define NOUVEAU_GEM_RELOC_LOW (1 << 0)
  71. #define NOUVEAU_GEM_RELOC_HIGH (1 << 1)
  72. #define NOUVEAU_GEM_RELOC_OR (1 << 2)
  73. #define NOUVEAU_GEM_MAX_RELOCS 1024
  74. struct drm_nouveau_gem_pushbuf_reloc {
  75. __u32 reloc_bo_index;
  76. __u32 reloc_bo_offset;
  77. __u32 bo_index;
  78. __u32 flags;
  79. __u32 data;
  80. __u32 vor;
  81. __u32 tor;
  82. };
  83. #define NOUVEAU_GEM_MAX_PUSH 512
  84. struct drm_nouveau_gem_pushbuf_push {
  85. __u32 bo_index;
  86. __u32 pad;
  87. __u64 offset;
  88. __u64 length;
  89. };
  90. struct drm_nouveau_gem_pushbuf {
  91. __u32 channel;
  92. __u32 nr_buffers;
  93. __u64 buffers;
  94. __u32 nr_relocs;
  95. __u32 nr_push;
  96. __u64 relocs;
  97. __u64 push;
  98. __u32 suffix0;
  99. __u32 suffix1;
  100. #define NOUVEAU_GEM_PUSHBUF_SYNC (1ULL << 0)
  101. __u64 vram_available;
  102. __u64 gart_available;
  103. };
  104. #define NOUVEAU_GEM_CPU_PREP_NOWAIT 0x00000001
  105. #define NOUVEAU_GEM_CPU_PREP_WRITE 0x00000004
  106. struct drm_nouveau_gem_cpu_prep {
  107. __u32 handle;
  108. __u32 flags;
  109. };
  110. struct drm_nouveau_gem_cpu_fini {
  111. __u32 handle;
  112. };
  113. #define DRM_NOUVEAU_GETPARAM 0x00 /* deprecated */
  114. #define DRM_NOUVEAU_SETPARAM 0x01 /* deprecated */
  115. #define DRM_NOUVEAU_CHANNEL_ALLOC 0x02 /* deprecated */
  116. #define DRM_NOUVEAU_CHANNEL_FREE 0x03 /* deprecated */
  117. #define DRM_NOUVEAU_GROBJ_ALLOC 0x04 /* deprecated */
  118. #define DRM_NOUVEAU_NOTIFIEROBJ_ALLOC 0x05 /* deprecated */
  119. #define DRM_NOUVEAU_GPUOBJ_FREE 0x06 /* deprecated */
  120. #define DRM_NOUVEAU_NVIF 0x07
  121. #define DRM_NOUVEAU_SVM_INIT 0x08
  122. #define DRM_NOUVEAU_SVM_BIND 0x09
  123. #define DRM_NOUVEAU_GEM_NEW 0x40
  124. #define DRM_NOUVEAU_GEM_PUSHBUF 0x41
  125. #define DRM_NOUVEAU_GEM_CPU_PREP 0x42
  126. #define DRM_NOUVEAU_GEM_CPU_FINI 0x43
  127. #define DRM_NOUVEAU_GEM_INFO 0x44
  128. struct drm_nouveau_svm_init {
  129. __u64 unmanaged_addr;
  130. __u64 unmanaged_size;
  131. };
  132. struct drm_nouveau_svm_bind {
  133. __u64 header;
  134. __u64 va_start;
  135. __u64 va_end;
  136. __u64 npages;
  137. __u64 stride;
  138. __u64 result;
  139. __u64 reserved0;
  140. __u64 reserved1;
  141. };
  142. #define NOUVEAU_SVM_BIND_COMMAND_SHIFT 0
  143. #define NOUVEAU_SVM_BIND_COMMAND_BITS 8
  144. #define NOUVEAU_SVM_BIND_COMMAND_MASK ((1 << 8) - 1)
  145. #define NOUVEAU_SVM_BIND_PRIORITY_SHIFT 8
  146. #define NOUVEAU_SVM_BIND_PRIORITY_BITS 8
  147. #define NOUVEAU_SVM_BIND_PRIORITY_MASK ((1 << 8) - 1)
  148. #define NOUVEAU_SVM_BIND_TARGET_SHIFT 16
  149. #define NOUVEAU_SVM_BIND_TARGET_BITS 32
  150. #define NOUVEAU_SVM_BIND_TARGET_MASK 0xffffffff
  151. /*
  152. * Below is use to validate ioctl argument, userspace can also use it to make
  153. * sure that no bit are set beyond known fields for a given kernel version.
  154. */
  155. #define NOUVEAU_SVM_BIND_VALID_BITS 48
  156. #define NOUVEAU_SVM_BIND_VALID_MASK ((1ULL << NOUVEAU_SVM_BIND_VALID_BITS) - 1)
  157. /*
  158. * NOUVEAU_BIND_COMMAND__MIGRATE: synchronous migrate to target memory.
  159. * result: number of page successfuly migrate to the target memory.
  160. */
  161. #define NOUVEAU_SVM_BIND_COMMAND__MIGRATE 0
  162. /*
  163. * NOUVEAU_SVM_BIND_HEADER_TARGET__GPU_VRAM: target the GPU VRAM memory.
  164. */
  165. #define NOUVEAU_SVM_BIND_TARGET__GPU_VRAM (1UL << 31)
  166. #define DRM_IOCTL_NOUVEAU_SVM_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_SVM_INIT, struct drm_nouveau_svm_init)
  167. #define DRM_IOCTL_NOUVEAU_SVM_BIND DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_SVM_BIND, struct drm_nouveau_svm_bind)
  168. #define DRM_IOCTL_NOUVEAU_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_NEW, struct drm_nouveau_gem_new)
  169. #define DRM_IOCTL_NOUVEAU_GEM_PUSHBUF DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_PUSHBUF, struct drm_nouveau_gem_pushbuf)
  170. #define DRM_IOCTL_NOUVEAU_GEM_CPU_PREP DRM_IOW (DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_PREP, struct drm_nouveau_gem_cpu_prep)
  171. #define DRM_IOCTL_NOUVEAU_GEM_CPU_FINI DRM_IOW (DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_FINI, struct drm_nouveau_gem_cpu_fini)
  172. #define DRM_IOCTL_NOUVEAU_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_INFO, struct drm_nouveau_gem_info)
  173. #if defined(__cplusplus)
  174. }
  175. #endif
  176. #endif /* __NOUVEAU_DRM_H__ */