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