nouveau_drm.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. __u64 vram_available;
  101. __u64 gart_available;
  102. };
  103. #define NOUVEAU_GEM_CPU_PREP_NOWAIT 0x00000001
  104. #define NOUVEAU_GEM_CPU_PREP_WRITE 0x00000004
  105. struct drm_nouveau_gem_cpu_prep {
  106. __u32 handle;
  107. __u32 flags;
  108. };
  109. struct drm_nouveau_gem_cpu_fini {
  110. __u32 handle;
  111. };
  112. #define DRM_NOUVEAU_GETPARAM 0x00 /* deprecated */
  113. #define DRM_NOUVEAU_SETPARAM 0x01 /* deprecated */
  114. #define DRM_NOUVEAU_CHANNEL_ALLOC 0x02 /* deprecated */
  115. #define DRM_NOUVEAU_CHANNEL_FREE 0x03 /* deprecated */
  116. #define DRM_NOUVEAU_GROBJ_ALLOC 0x04 /* deprecated */
  117. #define DRM_NOUVEAU_NOTIFIEROBJ_ALLOC 0x05 /* deprecated */
  118. #define DRM_NOUVEAU_GPUOBJ_FREE 0x06 /* deprecated */
  119. #define DRM_NOUVEAU_NVIF 0x07
  120. #define DRM_NOUVEAU_SVM_INIT 0x08
  121. #define DRM_NOUVEAU_SVM_BIND 0x09
  122. #define DRM_NOUVEAU_GEM_NEW 0x40
  123. #define DRM_NOUVEAU_GEM_PUSHBUF 0x41
  124. #define DRM_NOUVEAU_GEM_CPU_PREP 0x42
  125. #define DRM_NOUVEAU_GEM_CPU_FINI 0x43
  126. #define DRM_NOUVEAU_GEM_INFO 0x44
  127. struct drm_nouveau_svm_init {
  128. __u64 unmanaged_addr;
  129. __u64 unmanaged_size;
  130. };
  131. struct drm_nouveau_svm_bind {
  132. __u64 header;
  133. __u64 va_start;
  134. __u64 va_end;
  135. __u64 npages;
  136. __u64 stride;
  137. __u64 result;
  138. __u64 reserved0;
  139. __u64 reserved1;
  140. };
  141. #define NOUVEAU_SVM_BIND_COMMAND_SHIFT 0
  142. #define NOUVEAU_SVM_BIND_COMMAND_BITS 8
  143. #define NOUVEAU_SVM_BIND_COMMAND_MASK ((1 << 8) - 1)
  144. #define NOUVEAU_SVM_BIND_PRIORITY_SHIFT 8
  145. #define NOUVEAU_SVM_BIND_PRIORITY_BITS 8
  146. #define NOUVEAU_SVM_BIND_PRIORITY_MASK ((1 << 8) - 1)
  147. #define NOUVEAU_SVM_BIND_TARGET_SHIFT 16
  148. #define NOUVEAU_SVM_BIND_TARGET_BITS 32
  149. #define NOUVEAU_SVM_BIND_TARGET_MASK 0xffffffff
  150. /*
  151. * Below is use to validate ioctl argument, userspace can also use it to make
  152. * sure that no bit are set beyond known fields for a given kernel version.
  153. */
  154. #define NOUVEAU_SVM_BIND_VALID_BITS 48
  155. #define NOUVEAU_SVM_BIND_VALID_MASK ((1ULL << NOUVEAU_SVM_BIND_VALID_BITS) - 1)
  156. /*
  157. * NOUVEAU_BIND_COMMAND__MIGRATE: synchronous migrate to target memory.
  158. * result: number of page successfuly migrate to the target memory.
  159. */
  160. #define NOUVEAU_SVM_BIND_COMMAND__MIGRATE 0
  161. /*
  162. * NOUVEAU_SVM_BIND_HEADER_TARGET__GPU_VRAM: target the GPU VRAM memory.
  163. */
  164. #define NOUVEAU_SVM_BIND_TARGET__GPU_VRAM (1UL << 31)
  165. #define DRM_IOCTL_NOUVEAU_SVM_INIT DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_SVM_INIT, struct drm_nouveau_svm_init)
  166. #define DRM_IOCTL_NOUVEAU_SVM_BIND DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_SVM_BIND, struct drm_nouveau_svm_bind)
  167. #define DRM_IOCTL_NOUVEAU_GEM_NEW DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_NEW, struct drm_nouveau_gem_new)
  168. #define DRM_IOCTL_NOUVEAU_GEM_PUSHBUF DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_PUSHBUF, struct drm_nouveau_gem_pushbuf)
  169. #define DRM_IOCTL_NOUVEAU_GEM_CPU_PREP DRM_IOW (DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_PREP, struct drm_nouveau_gem_cpu_prep)
  170. #define DRM_IOCTL_NOUVEAU_GEM_CPU_FINI DRM_IOW (DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_CPU_FINI, struct drm_nouveau_gem_cpu_fini)
  171. #define DRM_IOCTL_NOUVEAU_GEM_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_NOUVEAU_GEM_INFO, struct drm_nouveau_gem_info)
  172. #if defined(__cplusplus)
  173. }
  174. #endif
  175. #endif /* __NOUVEAU_DRM_H__ */