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
13 struct nouveau_list *prev;
14 struct nouveau_list *next;
17 struct nouveau_object {
18 struct nouveau_object *parent;
26 struct nouveau_object client;
32 static inline struct nouveau_drm *
33 nouveau_drm(struct nouveau_object *obj)
35 while (obj && obj->parent)
37 return (struct nouveau_drm *)obj;
40 int nouveau_drm_new(int fd, struct nouveau_drm **);
41 void nouveau_drm_del(struct nouveau_drm **);
44 struct nouveau_object *object;
51 struct nouveau_fifo base;
58 struct nouveau_fifo base;
62 #define NVE0_FIFO_ENGINE_GR 0x00000001
63 #define NVE0_FIFO_ENGINE_VP 0x00000002
64 #define NVE0_FIFO_ENGINE_PPP 0x00000004
65 #define NVE0_FIFO_ENGINE_BSP 0x00000008
66 #define NVE0_FIFO_ENGINE_CE0 0x00000010
67 #define NVE0_FIFO_ENGINE_CE1 0x00000020
68 #define NVE0_FIFO_ENGINE_ENC 0x00000040
72 struct nouveau_fifo base;
79 struct nouveau_object *object;
84 /* Supported class information, provided by the kernel */
85 struct nouveau_sclass {
91 /* Client-provided array describing class versions that are desired.
93 * These are used to match against the kernel's list of supported classes.
95 struct nouveau_mclass {
96 int32_t oclass; /* 0 == EOL */
101 int nouveau_object_new(struct nouveau_object *parent, uint64_t handle,
102 uint32_t oclass, void *data, uint32_t length,
103 struct nouveau_object **);
104 void nouveau_object_del(struct nouveau_object **);
105 int nouveau_object_mthd(struct nouveau_object *, uint32_t mthd,
106 void *data, uint32_t size);
107 int nouveau_object_sclass_get(struct nouveau_object *,
108 struct nouveau_sclass **);
109 void nouveau_object_sclass_put(struct nouveau_sclass **);
110 int nouveau_object_mclass(struct nouveau_object *,
111 const struct nouveau_mclass *);
113 struct nouveau_device {
114 struct nouveau_object object;
116 uint32_t lib_version;
117 uint32_t drm_version;
125 int nouveau_device_wrap(int fd, int close, struct nouveau_device **);
126 int nouveau_device_open(const char *busid, struct nouveau_device **);
127 void nouveau_device_del(struct nouveau_device **);
128 int nouveau_getparam(struct nouveau_device *, uint64_t param, uint64_t *value);
129 int nouveau_setparam(struct nouveau_device *, uint64_t param, uint64_t value);
131 struct nouveau_client {
132 struct nouveau_device *device;
136 int nouveau_client_new(struct nouveau_device *, struct nouveau_client **);
137 void nouveau_client_del(struct nouveau_client **);
139 union nouveau_bo_config {
141 #define NV04_BO_16BPP 0x00000001
142 #define NV04_BO_32BPP 0x00000002
143 #define NV04_BO_ZETA 0x00000004
158 #define NOUVEAU_BO_VRAM 0x00000001
159 #define NOUVEAU_BO_GART 0x00000002
160 #define NOUVEAU_BO_APER (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART)
161 #define NOUVEAU_BO_RD 0x00000100
162 #define NOUVEAU_BO_WR 0x00000200
163 #define NOUVEAU_BO_RDWR (NOUVEAU_BO_RD | NOUVEAU_BO_WR)
164 #define NOUVEAU_BO_NOBLOCK 0x00000400
165 #define NOUVEAU_BO_LOW 0x00001000
166 #define NOUVEAU_BO_HIGH 0x00002000
167 #define NOUVEAU_BO_OR 0x00004000
168 #define NOUVEAU_BO_MAP 0x80000000
169 #define NOUVEAU_BO_CONTIG 0x40000000
170 #define NOUVEAU_BO_NOSNOOP 0x20000000
171 #define NOUVEAU_BO_COHERENT 0x10000000
174 struct nouveau_device *device;
180 union nouveau_bo_config config;
183 int nouveau_bo_new(struct nouveau_device *, uint32_t flags, uint32_t align,
184 uint64_t size, union nouveau_bo_config *,
185 struct nouveau_bo **);
186 int nouveau_bo_wrap(struct nouveau_device *, uint32_t handle,
187 struct nouveau_bo **);
188 int nouveau_bo_name_ref(struct nouveau_device *dev, uint32_t name,
189 struct nouveau_bo **);
190 int nouveau_bo_name_get(struct nouveau_bo *, uint32_t *name);
191 void nouveau_bo_ref(struct nouveau_bo *, struct nouveau_bo **);
192 int nouveau_bo_map(struct nouveau_bo *, uint32_t access,
193 struct nouveau_client *);
194 int nouveau_bo_wait(struct nouveau_bo *, uint32_t access,
195 struct nouveau_client *);
196 int nouveau_bo_prime_handle_ref(struct nouveau_device *dev, int prime_fd,
197 struct nouveau_bo **);
198 int nouveau_bo_set_prime(struct nouveau_bo *bo, int *prime_fd);
200 struct nouveau_bufref {
201 struct nouveau_list thead;
202 struct nouveau_bo *bo;
212 struct nouveau_bufctx {
213 struct nouveau_client *client;
214 struct nouveau_list head;
215 struct nouveau_list pending;
216 struct nouveau_list current;
220 int nouveau_bufctx_new(struct nouveau_client *, int bins,
221 struct nouveau_bufctx **);
222 void nouveau_bufctx_del(struct nouveau_bufctx **);
223 struct nouveau_bufref *
224 nouveau_bufctx_refn(struct nouveau_bufctx *, int bin,
225 struct nouveau_bo *, uint32_t flags);
226 struct nouveau_bufref *
227 nouveau_bufctx_mthd(struct nouveau_bufctx *, int bin, uint32_t packet,
228 struct nouveau_bo *, uint64_t data, uint32_t flags,
229 uint32_t vor, uint32_t tor);
230 void nouveau_bufctx_reset(struct nouveau_bufctx *, int bin);
232 struct nouveau_pushbuf_krec;
233 struct nouveau_pushbuf {
234 struct nouveau_client *client;
235 struct nouveau_object *channel;
236 struct nouveau_bufctx *bufctx;
237 void (*kick_notify)(struct nouveau_pushbuf *);
245 struct nouveau_pushbuf_refn {
246 struct nouveau_bo *bo;
250 int nouveau_pushbuf_new(struct nouveau_client *, struct nouveau_object *channel,
251 int nr, uint32_t size, bool immediate,
252 struct nouveau_pushbuf **);
253 void nouveau_pushbuf_del(struct nouveau_pushbuf **);
254 int nouveau_pushbuf_space(struct nouveau_pushbuf *, uint32_t dwords,
255 uint32_t relocs, uint32_t pushes);
256 void nouveau_pushbuf_data(struct nouveau_pushbuf *, struct nouveau_bo *,
257 uint64_t offset, uint64_t length);
258 int nouveau_pushbuf_refn(struct nouveau_pushbuf *,
259 struct nouveau_pushbuf_refn *, int nr);
260 /* Emits a reloc into the push buffer at the current position, you *must*
261 * have previously added the referenced buffer to a buffer context, and
262 * validated it against the current push buffer.
264 void nouveau_pushbuf_reloc(struct nouveau_pushbuf *, struct nouveau_bo *,
265 uint32_t data, uint32_t flags,
266 uint32_t vor, uint32_t tor);
267 int nouveau_pushbuf_validate(struct nouveau_pushbuf *);
268 uint32_t nouveau_pushbuf_refd(struct nouveau_pushbuf *, struct nouveau_bo *);
269 int nouveau_pushbuf_kick(struct nouveau_pushbuf *, struct nouveau_object *channel);
270 struct nouveau_bufctx *
271 nouveau_pushbuf_bufctx(struct nouveau_pushbuf *, struct nouveau_bufctx *);