OSDN Git Service

nouveau: remove nouveau_object_find()
[android-x86/external-libdrm.git] / nouveau / nouveau.h
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_drm {
26         struct nouveau_object client;
27         int fd;
28         uint32_t version;
29         bool nvif;
30 };
31
32 static inline struct nouveau_drm *
33 nouveau_drm(struct nouveau_object *obj)
34 {
35         while (obj && obj->parent)
36                 obj = obj->parent;
37         return (struct nouveau_drm *)obj;
38 }
39
40 int nouveau_drm_new(int fd, struct nouveau_drm **);
41 void nouveau_drm_del(struct nouveau_drm **);
42
43 struct nouveau_fifo {
44         struct nouveau_object *object;
45         uint32_t channel;
46         uint32_t pushbuf;
47         uint64_t unused1[3];
48 };
49
50 struct nv04_fifo {
51         struct nouveau_fifo base;
52         uint32_t vram;
53         uint32_t gart;
54         uint32_t notify;
55 };
56
57 struct nvc0_fifo {
58         struct nouveau_fifo base;
59         uint32_t notify;
60 };
61
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
69
70 struct nve0_fifo {
71         struct {
72                 struct nouveau_fifo base;
73                 uint32_t notify;
74         };
75         uint32_t engine;
76 };
77
78 struct nv04_notify {
79         struct nouveau_object *object;
80         uint32_t offset;
81         uint32_t length;
82 };
83
84 /* Supported class information, provided by the kernel */
85 struct nouveau_sclass {
86         int32_t oclass;
87         int minver;
88         int maxver;
89 };
90
91 /* Client-provided array describing class versions that are desired.
92  *
93  * These are used to match against the kernel's list of supported classes.
94  */
95 struct nouveau_mclass {
96         int32_t oclass; /* 0 == EOL */
97         int version;
98         void *data;
99 };
100
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 *);
112
113 struct nouveau_device {
114         struct nouveau_object object;
115         int fd;
116         uint32_t lib_version;
117         uint32_t drm_version;
118         uint32_t chipset;
119         uint64_t vram_size;
120         uint64_t gart_size;
121         uint64_t vram_limit;
122         uint64_t gart_limit;
123 };
124
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);
130
131 struct nouveau_client {
132         struct nouveau_device *device;
133         int id;
134 };
135
136 int  nouveau_client_new(struct nouveau_device *, struct nouveau_client **);
137 void nouveau_client_del(struct nouveau_client **);
138
139 union nouveau_bo_config {
140         struct {
141 #define NV04_BO_16BPP 0x00000001
142 #define NV04_BO_32BPP 0x00000002
143 #define NV04_BO_ZETA  0x00000004
144                 uint32_t surf_flags;
145                 uint32_t surf_pitch;
146         } nv04;
147         struct {
148                 uint32_t memtype;
149                 uint32_t tile_mode;
150         } nv50;
151         struct {
152                 uint32_t memtype;
153                 uint32_t tile_mode;
154         } nvc0;
155         uint32_t data[8];
156 };
157
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
172
173 struct nouveau_bo {
174         struct nouveau_device *device;
175         uint32_t handle;
176         uint64_t size;
177         uint32_t flags;
178         uint64_t offset;
179         void *map;
180         union nouveau_bo_config config;
181 };
182
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);
199
200 struct nouveau_bufref {
201         struct nouveau_list thead;
202         struct nouveau_bo *bo;
203         uint32_t packet;
204         uint32_t flags;
205         uint32_t data;
206         uint32_t vor;
207         uint32_t tor;
208         uint32_t priv_data;
209         void *priv;
210 };
211
212 struct nouveau_bufctx {
213         struct nouveau_client *client;
214         struct nouveau_list head;
215         struct nouveau_list pending;
216         struct nouveau_list current;
217         int relocs;
218 };
219
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);
231
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 *);
238         void *user_priv;
239         uint32_t rsvd_kick;
240         uint32_t flags;
241         uint32_t *cur;
242         uint32_t *end;
243 };
244
245 struct nouveau_pushbuf_refn {
246         struct nouveau_bo *bo;
247         uint32_t flags;
248 };
249
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.
263  */
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 *);
272
273 #endif