| 1 |
#ifndef NOUVEAU_H |
| 2 |
#define NOUVEAU_H |
| 3 |
|
| 4 |
#include <stdbool.h> |
| 5 |
#include <stdint.h> |
| 6 |
|
| 7 |
#include "util/list.h" |
| 8 |
|
| 9 |
#include "drm-uapi/nouveau_drm.h" |
| 10 |
#include "nv_device_info.h" |
| 11 |
|
| 12 |
#define NOUVEAU_FIFO_CHANNEL_CLASS 0x80000001 |
| 13 |
#define NOUVEAU_NOTIFIER_CLASS 0x80000002 |
| 14 |
|
| 15 |
#define NOUVEAU_BO_VRAM 0x00000001 |
| 16 |
#define NOUVEAU_BO_GART 0x00000002 |
| 17 |
#define NOUVEAU_BO_APER (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART) |
| 18 |
#define NOUVEAU_BO_RD 0x00000100 |
| 19 |
#define NOUVEAU_BO_WR 0x00000200 |
| 20 |
#define NOUVEAU_BO_RDWR (NOUVEAU_BO_RD | NOUVEAU_BO_WR) |
| 21 |
#define NOUVEAU_BO_NOBLOCK 0x00000400 |
| 22 |
#define NOUVEAU_BO_LOW 0x00001000 |
| 23 |
#define NOUVEAU_BO_OR 0x00004000 |
| 24 |
#define NOUVEAU_BO_COHERENT 0x10000000 |
| 25 |
#define NOUVEAU_BO_NOSNOOP 0x20000000 |
| 26 |
#define NOUVEAU_BO_CONTIG 0x40000000 |
| 27 |
#define NOUVEAU_BO_MAP 0x80000000 |
| 28 |
|
| 29 |
struct nouveau_mclass { |
| 30 |
int32_t oclass; |
| 31 |
int version; |
| 32 |
}; |
| 33 |
|
| 34 |
struct nouveau_object { |
| 35 |
struct nouveau_object *parent; |
| 36 |
uint64_t handle; |
| 37 |
uint32_t oclass; |
| 38 |
void *data; |
| 39 |
}; |
| 40 |
|
| 41 |
struct nouveau_drm { |
| 42 |
struct nouveau_object client; |
| 43 |
int fd; |
| 44 |
uint32_t version; |
| 45 |
}; |
| 46 |
|
| 47 |
struct nouveau_device { |
| 48 |
struct nouveau_object object; |
| 49 |
uint32_t chipset; |
| 50 |
uint64_t vram_size; |
| 51 |
uint64_t gart_size; |
| 52 |
uint64_t vram_limit; |
| 53 |
uint64_t gart_limit; |
| 54 |
|
| 55 |
/* only pci info, class ids and and device type are set */ |
| 56 |
struct nv_device_info info; |
| 57 |
}; |
| 58 |
|
| 59 |
struct nouveau_client { |
| 60 |
struct nouveau_device *device; |
| 61 |
}; |
| 62 |
|
| 63 |
union nouveau_bo_config { |
| 64 |
struct { |
| 65 |
uint32_t memtype; |
| 66 |
uint32_t tile_mode; |
| 67 |
} nv50; |
| 68 |
struct { |
| 69 |
uint32_t memtype; |
| 70 |
uint32_t tile_mode; |
| 71 |
} nvc0; |
| 72 |
}; |
| 73 |
|
| 74 |
struct nouveau_bo { |
| 75 |
struct nouveau_device *device; |
| 76 |
uint32_t handle; |
| 77 |
uint64_t size; |
| 78 |
uint32_t flags; |
| 79 |
uint64_t offset; |
| 80 |
void *map; |
| 81 |
union nouveau_bo_config config; |
| 82 |
}; |
| 83 |
|
| 84 |
struct nouveau_bufref { |
| 85 |
struct list_head thead; |
| 86 |
struct nouveau_bo *bo; |
| 87 |
uint32_t packet; |
| 88 |
uint32_t flags; |
| 89 |
uint32_t data; |
| 90 |
uint32_t vor; |
| 91 |
uint32_t tor; |
| 92 |
uint32_t priv_data; |
| 93 |
void *priv; |
| 94 |
}; |
| 95 |
|
| 96 |
struct nouveau_bufctx { |
| 97 |
struct nouveau_client *client; |
| 98 |
struct list_head head; |
| 99 |
struct list_head pending; |
| 100 |
struct list_head current; |
| 101 |
int relocs; |
| 102 |
}; |
| 103 |
|
| 104 |
struct nouveau_pushbuf { |
| 105 |
struct nouveau_client *client; |
| 106 |
struct nouveau_object *channel; |
| 107 |
struct nouveau_bufctx *bufctx; |
| 108 |
void (*kick_notify)(struct nouveau_pushbuf *); |
| 109 |
void *user_priv; |
| 110 |
uint32_t rsvd_kick; |
| 111 |
uint32_t flags; |
| 112 |
uint32_t *cur; |
| 113 |
uint32_t *end; |
| 114 |
}; |
| 115 |
|
| 116 |
struct nouveau_pushbuf_refn { |
| 117 |
struct nouveau_bo *bo; |
| 118 |
uint32_t flags; |
| 119 |
}; |
| 120 |
|
| 121 |
struct nouveau_fifo { |
| 122 |
uint32_t pushbuf; |
| 123 |
uint32_t notify; |
| 124 |
}; |
| 125 |
|
| 126 |
struct nv04_fifo { |
| 127 |
struct nouveau_fifo base; |
| 128 |
uint32_t vram; |
| 129 |
uint32_t gart; |
| 130 |
}; |
| 131 |
|
| 132 |
struct nv04_notify { |
| 133 |
uint32_t offset; |
| 134 |
uint32_t length; |
| 135 |
}; |
| 136 |
|
| 137 |
struct nvc0_fifo { |
| 138 |
struct nouveau_fifo base; |
| 139 |
}; |
| 140 |
|
| 141 |
struct nve0_fifo { |
| 142 |
struct nouveau_fifo base; |
| 143 |
uint32_t engine; |
| 144 |
}; |
| 145 |
|
| 146 |
int nouveau_drm_new(int fd, struct nouveau_drm **); |
| 147 |
void nouveau_drm_del(struct nouveau_drm **); |
| 148 |
|
| 149 |
static inline struct nouveau_drm * |
| 150 |
nouveau_drm(struct nouveau_object *obj) |
| 151 |
{ |
| 152 |
while (obj && obj->parent) |
| 153 |
obj = obj->parent; |
| 154 |
return (struct nouveau_drm *)obj; |
| 155 |
} |
| 156 |
|
| 157 |
struct nv_device_info_v0; |
| 158 |
|
| 159 |
int nouveau_device_new(struct nouveau_object *parent, struct nouveau_device **); |
| 160 |
void nouveau_device_del(struct nouveau_device **); |
| 161 |
int nouveau_device_info(struct nouveau_device *, struct nv_device_info_v0 *); |
| 162 |
void nouveau_device_set_classes_for_debug(struct nouveau_device *dev, |
| 163 |
uint32_t cls_eng3d, |
| 164 |
uint32_t cls_compute, |
| 165 |
uint32_t cls_m2mf, |
| 166 |
uint32_t cls_copy); |
| 167 |
int nouveau_getparam(struct nouveau_device *, uint64_t param, uint64_t *value); |
| 168 |
|
| 169 |
int nouveau_client_new(struct nouveau_device *, struct nouveau_client **); |
| 170 |
void nouveau_client_del(struct nouveau_client **); |
| 171 |
|
| 172 |
int nouveau_object_new(struct nouveau_object *parent, uint64_t handle, uint32_t oclass, void *data, |
| 173 |
uint32_t length, struct nouveau_object **); |
| 174 |
void nouveau_object_del(struct nouveau_object **); |
| 175 |
int nouveau_object_mclass(struct nouveau_object *, const struct nouveau_mclass *); |
| 176 |
|
| 177 |
int nouveau_bo_new(struct nouveau_device *, uint32_t flags, uint32_t align, uint64_t size, |
| 178 |
union nouveau_bo_config *, struct nouveau_bo **); |
| 179 |
int nouveau_bo_map(struct nouveau_bo *, uint32_t access, struct nouveau_client *); |
| 180 |
int nouveau_bo_name_get(struct nouveau_bo *, uint32_t *name); |
| 181 |
int nouveau_bo_name_ref(struct nouveau_device *, uint32_t name, struct nouveau_bo **); |
| 182 |
int nouveau_bo_prime_handle_ref(struct nouveau_device *, int prime_fd, struct nouveau_bo **); |
| 183 |
void nouveau_bo_ref(struct nouveau_bo *, struct nouveau_bo **); |
| 184 |
int nouveau_bo_set_prime(struct nouveau_bo *, int *prime_fd); |
| 185 |
int nouveau_bo_wait(struct nouveau_bo *, uint32_t access, struct nouveau_client *); |
| 186 |
int nouveau_bo_wrap(struct nouveau_device *, uint32_t handle, struct nouveau_bo **); |
| 187 |
|
| 188 |
int nouveau_bufctx_new(struct nouveau_client *, int bins, struct nouveau_bufctx **); |
| 189 |
void nouveau_bufctx_del(struct nouveau_bufctx **); |
| 190 |
struct nouveau_bufref * |
| 191 |
nouveau_bufctx_refn(struct nouveau_bufctx *, int bin, struct nouveau_bo *, uint32_t flags); |
| 192 |
struct nouveau_bufref * |
| 193 |
nouveau_bufctx_mthd(struct nouveau_bufctx *, int bin, uint32_t packet, struct nouveau_bo *, |
| 194 |
uint64_t data, uint32_t flags, uint32_t vor, uint32_t tor); |
| 195 |
void nouveau_bufctx_reset(struct nouveau_bufctx *, int bin); |
| 196 |
|
| 197 |
int nouveau_pushbuf_new(struct nouveau_client *, struct nouveau_object *chan, int nr, uint32_t size, |
| 198 |
struct nouveau_pushbuf **); |
| 199 |
void nouveau_pushbuf_del(struct nouveau_pushbuf **); |
| 200 |
struct nouveau_bufctx * |
| 201 |
nouveau_pushbuf_bufctx(struct nouveau_pushbuf *, struct nouveau_bufctx *); |
| 202 |
void nouveau_pushbuf_data(struct nouveau_pushbuf *, struct nouveau_bo *, uint64_t offset, |
| 203 |
uint64_t length); |
| 204 |
int nouveau_pushbuf_kick(struct nouveau_pushbuf *); |
| 205 |
int nouveau_pushbuf_refn(struct nouveau_pushbuf *, struct nouveau_pushbuf_refn *, int nr); |
| 206 |
void nouveau_pushbuf_reloc(struct nouveau_pushbuf *, struct nouveau_bo *, uint32_t data, |
| 207 |
uint32_t flags, uint32_t vor, uint32_t tor); |
| 208 |
int nouveau_pushbuf_space(struct nouveau_pushbuf *, uint32_t dwords, uint32_t relocs, |
| 209 |
uint32_t pushes); |
| 210 |
int nouveau_pushbuf_validate(struct nouveau_pushbuf *); |
| 211 |
|
| 212 |
#endif |