nouveau.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. #ifndef __NOUVEAU_H__
  2. #define __NOUVEAU_H__
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. /* Supported class information, provided by the kernel */
  6. struct nouveau_sclass {
  7. int32_t oclass;
  8. int minver;
  9. int maxver;
  10. };
  11. /* Client-provided array describing class versions that are desired.
  12. *
  13. * These are used to match against the kernel's list of supported classes.
  14. */
  15. struct nouveau_mclass {
  16. int32_t oclass;
  17. int version;
  18. void *data;
  19. };
  20. struct nouveau_object {
  21. struct nouveau_object *parent;
  22. uint64_t handle;
  23. uint32_t oclass;
  24. uint32_t length; /* deprecated */
  25. void *data; /* deprecated */
  26. };
  27. int nouveau_object_new(struct nouveau_object *parent, uint64_t handle,
  28. uint32_t oclass, void *data, uint32_t length,
  29. struct nouveau_object **);
  30. void nouveau_object_del(struct nouveau_object **);
  31. int nouveau_object_mthd(struct nouveau_object *, uint32_t mthd,
  32. void *data, uint32_t size);
  33. int nouveau_object_sclass_get(struct nouveau_object *,
  34. struct nouveau_sclass **);
  35. void nouveau_object_sclass_put(struct nouveau_sclass **);
  36. int nouveau_object_mclass(struct nouveau_object *,
  37. const struct nouveau_mclass *);
  38. struct nouveau_drm {
  39. struct nouveau_object client;
  40. int fd;
  41. uint32_t version;
  42. bool nvif;
  43. };
  44. static inline struct nouveau_drm *
  45. nouveau_drm(struct nouveau_object *obj)
  46. {
  47. while (obj && obj->parent)
  48. obj = obj->parent;
  49. return (struct nouveau_drm *)obj;
  50. }
  51. int nouveau_drm_new(int fd, struct nouveau_drm **);
  52. void nouveau_drm_del(struct nouveau_drm **);
  53. struct nouveau_device {
  54. struct nouveau_object object;
  55. int fd; /* deprecated */
  56. uint32_t lib_version; /* deprecated */
  57. uint32_t drm_version; /* deprecated */
  58. uint32_t chipset;
  59. uint64_t vram_size;
  60. uint64_t gart_size;
  61. uint64_t vram_limit;
  62. uint64_t gart_limit;
  63. };
  64. int nouveau_device_new(struct nouveau_object *parent, int32_t oclass,
  65. void *data, uint32_t size, struct nouveau_device **);
  66. void nouveau_device_del(struct nouveau_device **);
  67. int nouveau_getparam(struct nouveau_device *, uint64_t param, uint64_t *value);
  68. int nouveau_setparam(struct nouveau_device *, uint64_t param, uint64_t value);
  69. /* deprecated */
  70. int nouveau_device_wrap(int fd, int close, struct nouveau_device **);
  71. int nouveau_device_open(const char *busid, struct nouveau_device **);
  72. struct nouveau_client {
  73. struct nouveau_device *device;
  74. int id;
  75. };
  76. int nouveau_client_new(struct nouveau_device *, struct nouveau_client **);
  77. void nouveau_client_del(struct nouveau_client **);
  78. union nouveau_bo_config {
  79. struct {
  80. #define NV04_BO_16BPP 0x00000001
  81. #define NV04_BO_32BPP 0x00000002
  82. #define NV04_BO_ZETA 0x00000004
  83. uint32_t surf_flags;
  84. uint32_t surf_pitch;
  85. } nv04;
  86. struct {
  87. uint32_t memtype;
  88. uint32_t tile_mode;
  89. } nv50;
  90. struct {
  91. uint32_t memtype;
  92. uint32_t tile_mode;
  93. } nvc0;
  94. uint32_t data[8];
  95. };
  96. #define NOUVEAU_BO_VRAM 0x00000001
  97. #define NOUVEAU_BO_GART 0x00000002
  98. #define NOUVEAU_BO_APER (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART)
  99. #define NOUVEAU_BO_RD 0x00000100
  100. #define NOUVEAU_BO_WR 0x00000200
  101. #define NOUVEAU_BO_RDWR (NOUVEAU_BO_RD | NOUVEAU_BO_WR)
  102. #define NOUVEAU_BO_NOBLOCK 0x00000400
  103. #define NOUVEAU_BO_LOW 0x00001000
  104. #define NOUVEAU_BO_HIGH 0x00002000
  105. #define NOUVEAU_BO_OR 0x00004000
  106. #define NOUVEAU_BO_MAP 0x80000000
  107. #define NOUVEAU_BO_CONTIG 0x40000000
  108. #define NOUVEAU_BO_NOSNOOP 0x20000000
  109. #define NOUVEAU_BO_COHERENT 0x10000000
  110. struct nouveau_bo {
  111. struct nouveau_device *device;
  112. uint32_t handle;
  113. uint64_t size;
  114. uint32_t flags;
  115. uint64_t offset;
  116. void *map;
  117. union nouveau_bo_config config;
  118. };
  119. int nouveau_bo_new(struct nouveau_device *, uint32_t flags, uint32_t align,
  120. uint64_t size, union nouveau_bo_config *,
  121. struct nouveau_bo **);
  122. int nouveau_bo_wrap(struct nouveau_device *, uint32_t handle,
  123. struct nouveau_bo **);
  124. int nouveau_bo_name_ref(struct nouveau_device *v, uint32_t name,
  125. struct nouveau_bo **);
  126. int nouveau_bo_name_get(struct nouveau_bo *, uint32_t *name);
  127. void nouveau_bo_ref(struct nouveau_bo *, struct nouveau_bo **);
  128. int nouveau_bo_map(struct nouveau_bo *, uint32_t access,
  129. struct nouveau_client *);
  130. int nouveau_bo_wait(struct nouveau_bo *, uint32_t access,
  131. struct nouveau_client *);
  132. int nouveau_bo_prime_handle_ref(struct nouveau_device *, int prime_fd,
  133. struct nouveau_bo **);
  134. int nouveau_bo_set_prime(struct nouveau_bo *, int *prime_fd);
  135. struct nouveau_list {
  136. struct nouveau_list *prev;
  137. struct nouveau_list *next;
  138. };
  139. struct nouveau_bufref {
  140. struct nouveau_list thead;
  141. struct nouveau_bo *bo;
  142. uint32_t packet;
  143. uint32_t flags;
  144. uint32_t data;
  145. uint32_t vor;
  146. uint32_t tor;
  147. uint32_t priv_data;
  148. void *priv;
  149. };
  150. struct nouveau_bufctx {
  151. struct nouveau_client *client;
  152. struct nouveau_list head;
  153. struct nouveau_list pending;
  154. struct nouveau_list current;
  155. int relocs;
  156. };
  157. int nouveau_bufctx_new(struct nouveau_client *, int bins,
  158. struct nouveau_bufctx **);
  159. void nouveau_bufctx_del(struct nouveau_bufctx **);
  160. struct nouveau_bufref *
  161. nouveau_bufctx_refn(struct nouveau_bufctx *, int bin,
  162. struct nouveau_bo *, uint32_t flags);
  163. struct nouveau_bufref *
  164. nouveau_bufctx_mthd(struct nouveau_bufctx *, int bin, uint32_t packet,
  165. struct nouveau_bo *, uint64_t data, uint32_t flags,
  166. uint32_t vor, uint32_t tor);
  167. void nouveau_bufctx_reset(struct nouveau_bufctx *, int bin);
  168. struct nouveau_pushbuf_krec;
  169. struct nouveau_pushbuf {
  170. struct nouveau_client *client;
  171. struct nouveau_object *channel;
  172. struct nouveau_bufctx *bufctx;
  173. void (*kick_notify)(struct nouveau_pushbuf *);
  174. void *user_priv;
  175. uint32_t rsvd_kick;
  176. uint32_t flags;
  177. uint32_t *cur;
  178. uint32_t *end;
  179. };
  180. struct nouveau_pushbuf_refn {
  181. struct nouveau_bo *bo;
  182. uint32_t flags;
  183. };
  184. int nouveau_pushbuf_new(struct nouveau_client *, struct nouveau_object *chan,
  185. int nr, uint32_t size, bool immediate,
  186. struct nouveau_pushbuf **);
  187. void nouveau_pushbuf_del(struct nouveau_pushbuf **);
  188. int nouveau_pushbuf_space(struct nouveau_pushbuf *, uint32_t dwords,
  189. uint32_t relocs, uint32_t pushes);
  190. void nouveau_pushbuf_data(struct nouveau_pushbuf *, struct nouveau_bo *,
  191. uint64_t offset, uint64_t length);
  192. int nouveau_pushbuf_refn(struct nouveau_pushbuf *,
  193. struct nouveau_pushbuf_refn *, int nr);
  194. /* Emits a reloc into the push buffer at the current position, you *must*
  195. * have previously added the referenced buffer to a buffer context, and
  196. * validated it against the current push buffer.
  197. */
  198. void nouveau_pushbuf_reloc(struct nouveau_pushbuf *, struct nouveau_bo *,
  199. uint32_t data, uint32_t flags,
  200. uint32_t vor, uint32_t tor);
  201. int nouveau_pushbuf_validate(struct nouveau_pushbuf *);
  202. uint32_t nouveau_pushbuf_refd(struct nouveau_pushbuf *, struct nouveau_bo *);
  203. int nouveau_pushbuf_kick(struct nouveau_pushbuf *, struct nouveau_object *chan);
  204. struct nouveau_bufctx *
  205. nouveau_pushbuf_bufctx(struct nouveau_pushbuf *, struct nouveau_bufctx *);
  206. #define NOUVEAU_DEVICE_CLASS 0x80000000
  207. #define NOUVEAU_FIFO_CHANNEL_CLASS 0x80000001
  208. #define NOUVEAU_NOTIFIER_CLASS 0x80000002
  209. struct nouveau_fifo {
  210. struct nouveau_object *object;
  211. uint32_t channel;
  212. uint32_t pushbuf;
  213. uint64_t unused1[3];
  214. };
  215. struct nv04_fifo {
  216. struct nouveau_fifo base;
  217. uint32_t vram;
  218. uint32_t gart;
  219. uint32_t notify;
  220. };
  221. struct nvc0_fifo {
  222. struct nouveau_fifo base;
  223. uint32_t notify;
  224. };
  225. #define NVE0_FIFO_ENGINE_GR 0x00000001
  226. #define NVE0_FIFO_ENGINE_VP 0x00000002
  227. #define NVE0_FIFO_ENGINE_PPP 0x00000004
  228. #define NVE0_FIFO_ENGINE_BSP 0x00000008
  229. #define NVE0_FIFO_ENGINE_CE0 0x00000010
  230. #define NVE0_FIFO_ENGINE_CE1 0x00000020
  231. #define NVE0_FIFO_ENGINE_ENC 0x00000040
  232. struct nve0_fifo {
  233. struct {
  234. struct nouveau_fifo base;
  235. uint32_t notify;
  236. };
  237. uint32_t engine;
  238. };
  239. struct nv04_notify {
  240. struct nouveau_object *object;
  241. uint32_t offset;
  242. uint32_t length;
  243. };
  244. #endif