Ben Skeggs | 292da61 | 2011-12-09 16:11:06 +1000 | [diff] [blame] | 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 | |
| 12 | struct nouveau_list { |
| 13 | struct nouveau_list *prev; |
| 14 | struct nouveau_list *next; |
| 15 | }; |
| 16 | |
| 17 | struct nouveau_object { |
| 18 | struct nouveau_object *parent; |
| 19 | uint64_t handle; |
| 20 | uint32_t oclass; |
| 21 | uint32_t length; |
| 22 | void *data; |
| 23 | }; |
| 24 | |
| 25 | struct nouveau_fifo { |
| 26 | struct nouveau_object *object; |
| 27 | uint32_t channel; |
| 28 | uint32_t pushbuf; |
| 29 | uint64_t unused1[3]; |
| 30 | }; |
| 31 | |
| 32 | struct nv04_fifo { |
| 33 | struct nouveau_fifo base; |
| 34 | uint32_t vram; |
| 35 | uint32_t gart; |
| 36 | uint32_t notify; |
| 37 | }; |
| 38 | |
| 39 | struct nvc0_fifo { |
| 40 | struct nouveau_fifo base; |
Christoph Bumiller | 754655c | 2012-04-19 20:03:39 +0200 | [diff] [blame^] | 41 | uint32_t notify; |
Ben Skeggs | 292da61 | 2011-12-09 16:11:06 +1000 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | struct nv04_notify { |
| 45 | struct nouveau_object *object; |
| 46 | uint32_t offset; |
| 47 | uint32_t length; |
| 48 | }; |
| 49 | |
| 50 | int nouveau_object_new(struct nouveau_object *parent, uint64_t handle, |
| 51 | uint32_t oclass, void *data, uint32_t length, |
| 52 | struct nouveau_object **); |
| 53 | void nouveau_object_del(struct nouveau_object **); |
| 54 | void *nouveau_object_find(struct nouveau_object *, uint32_t parent_class); |
| 55 | |
| 56 | struct nouveau_device { |
| 57 | struct nouveau_object object; |
| 58 | int fd; |
| 59 | uint32_t lib_version; |
| 60 | uint32_t drm_version; |
| 61 | uint32_t chipset; |
| 62 | uint64_t vram_size; |
| 63 | uint64_t gart_size; |
| 64 | uint64_t vram_limit; |
| 65 | uint64_t gart_limit; |
| 66 | }; |
| 67 | |
| 68 | int nouveau_device_wrap(int fd, int close, struct nouveau_device **); |
| 69 | int nouveau_device_open(const char *busid, struct nouveau_device **); |
| 70 | void nouveau_device_del(struct nouveau_device **); |
| 71 | int nouveau_getparam(struct nouveau_device *, uint64_t param, uint64_t *value); |
| 72 | int nouveau_setparam(struct nouveau_device *, uint64_t param, uint64_t value); |
| 73 | |
| 74 | struct nouveau_client { |
| 75 | struct nouveau_device *device; |
| 76 | int id; |
| 77 | }; |
| 78 | |
| 79 | int nouveau_client_new(struct nouveau_device *, struct nouveau_client **); |
| 80 | void nouveau_client_del(struct nouveau_client **); |
| 81 | |
| 82 | union nouveau_bo_config { |
| 83 | struct { |
| 84 | #define NV04_BO_16BPP 0x00000001 |
| 85 | #define NV04_BO_32BPP 0x00000002 |
| 86 | #define NV04_BO_ZETA 0x00000004 |
| 87 | uint32_t surf_flags; |
| 88 | uint32_t surf_pitch; |
| 89 | } nv04; |
| 90 | struct { |
| 91 | uint32_t memtype; |
| 92 | uint32_t tile_mode; |
| 93 | } nv50; |
| 94 | struct { |
| 95 | uint32_t memtype; |
| 96 | uint32_t tile_mode; |
| 97 | } nvc0; |
| 98 | uint32_t data[8]; |
| 99 | }; |
| 100 | |
| 101 | #define NOUVEAU_BO_VRAM 0x00000001 |
| 102 | #define NOUVEAU_BO_GART 0x00000002 |
| 103 | #define NOUVEAU_BO_APER (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART) |
| 104 | #define NOUVEAU_BO_RD 0x00000100 |
| 105 | #define NOUVEAU_BO_WR 0x00000200 |
| 106 | #define NOUVEAU_BO_RDWR (NOUVEAU_BO_RD | NOUVEAU_BO_WR) |
| 107 | #define NOUVEAU_BO_NOBLOCK 0x00000400 |
| 108 | #define NOUVEAU_BO_LOW 0x00001000 |
| 109 | #define NOUVEAU_BO_HIGH 0x00002000 |
| 110 | #define NOUVEAU_BO_OR 0x00004000 |
| 111 | #define NOUVEAU_BO_MAP 0x80000000 |
| 112 | #define NOUVEAU_BO_CONTIG 0x40000000 |
| 113 | #define NOUVEAU_BO_NOSNOOP 0x20000000 |
| 114 | |
| 115 | struct nouveau_bo { |
| 116 | struct nouveau_device *device; |
| 117 | uint32_t handle; |
| 118 | uint64_t size; |
| 119 | uint32_t flags; |
| 120 | uint64_t offset; |
| 121 | void *map; |
| 122 | union nouveau_bo_config config; |
| 123 | }; |
| 124 | |
| 125 | int nouveau_bo_new(struct nouveau_device *, uint32_t flags, uint32_t align, |
| 126 | uint64_t size, union nouveau_bo_config *, |
| 127 | struct nouveau_bo **); |
| 128 | int nouveau_bo_wrap(struct nouveau_device *, uint32_t handle, |
| 129 | struct nouveau_bo **); |
| 130 | int nouveau_bo_name_ref(struct nouveau_device *dev, uint32_t name, |
| 131 | struct nouveau_bo **); |
| 132 | int nouveau_bo_name_get(struct nouveau_bo *, uint32_t *name); |
| 133 | void nouveau_bo_ref(struct nouveau_bo *, struct nouveau_bo **); |
| 134 | int nouveau_bo_map(struct nouveau_bo *, uint32_t access, |
| 135 | struct nouveau_client *); |
| 136 | int nouveau_bo_wait(struct nouveau_bo *, uint32_t access, |
| 137 | struct nouveau_client *); |
| 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 | |
| 151 | struct nouveau_bufctx { |
| 152 | struct nouveau_client *client; |
| 153 | struct nouveau_list head; |
| 154 | struct nouveau_list pending; |
| 155 | struct nouveau_list current; |
| 156 | int relocs; |
| 157 | }; |
| 158 | |
| 159 | int nouveau_bufctx_new(struct nouveau_client *, int bins, |
| 160 | struct nouveau_bufctx **); |
| 161 | void nouveau_bufctx_del(struct nouveau_bufctx **); |
| 162 | struct nouveau_bufref * |
| 163 | nouveau_bufctx_refn(struct nouveau_bufctx *, int bin, |
| 164 | struct nouveau_bo *, uint32_t flags); |
| 165 | struct nouveau_bufref * |
| 166 | nouveau_bufctx_mthd(struct nouveau_bufctx *, int bin, uint32_t packet, |
| 167 | struct nouveau_bo *, uint64_t data, uint32_t flags, |
| 168 | uint32_t vor, uint32_t tor); |
| 169 | void nouveau_bufctx_reset(struct nouveau_bufctx *, int bin); |
| 170 | |
| 171 | struct nouveau_pushbuf_krec; |
| 172 | struct nouveau_pushbuf { |
| 173 | struct nouveau_client *client; |
| 174 | struct nouveau_object *channel; |
| 175 | struct nouveau_bufctx *bufctx; |
| 176 | void (*kick_notify)(struct nouveau_pushbuf *); |
| 177 | void *user_priv; |
| 178 | uint32_t rsvd_kick; |
| 179 | uint32_t flags; |
| 180 | uint32_t *cur; |
| 181 | uint32_t *end; |
| 182 | }; |
| 183 | |
| 184 | struct nouveau_pushbuf_refn { |
| 185 | struct nouveau_bo *bo; |
| 186 | uint32_t flags; |
| 187 | }; |
| 188 | |
| 189 | int nouveau_pushbuf_new(struct nouveau_client *, struct nouveau_object *channel, |
| 190 | int nr, uint32_t size, bool immediate, |
| 191 | struct nouveau_pushbuf **); |
| 192 | void nouveau_pushbuf_del(struct nouveau_pushbuf **); |
| 193 | int nouveau_pushbuf_space(struct nouveau_pushbuf *, uint32_t dwords, |
| 194 | uint32_t relocs, uint32_t pushes); |
| 195 | void nouveau_pushbuf_data(struct nouveau_pushbuf *, struct nouveau_bo *, |
| 196 | uint64_t offset, uint64_t length); |
| 197 | int nouveau_pushbuf_refn(struct nouveau_pushbuf *, |
| 198 | struct nouveau_pushbuf_refn *, int nr); |
| 199 | /* Emits a reloc into the push buffer at the current position, you *must* |
| 200 | * have previously added the referenced buffer to a buffer context, and |
| 201 | * validated it against the current push buffer. |
| 202 | */ |
| 203 | void nouveau_pushbuf_reloc(struct nouveau_pushbuf *, struct nouveau_bo *, |
| 204 | uint32_t data, uint32_t flags, |
| 205 | uint32_t vor, uint32_t tor); |
| 206 | int nouveau_pushbuf_validate(struct nouveau_pushbuf *); |
| 207 | uint32_t nouveau_pushbuf_refd(struct nouveau_pushbuf *, struct nouveau_bo *); |
| 208 | int nouveau_pushbuf_kick(struct nouveau_pushbuf *, struct nouveau_object *channel); |
| 209 | struct nouveau_bufctx * |
| 210 | nouveau_pushbuf_bufctx(struct nouveau_pushbuf *, struct nouveau_bufctx *); |
| 211 | |
| 212 | #endif |