e876634da10a18a377c3565046f7ddd75295d8ca
[sfrench/cifs-2.6.git] / drivers / gpu / drm / nouveau / include / nvkm / core / client.h
1 #ifndef __NVKM_CLIENT_H__
2 #define __NVKM_CLIENT_H__
3 #define nvkm_client(p) container_of((p), struct nvkm_client, object)
4 #include <core/object.h>
5
6 struct nvkm_client {
7         struct nvkm_object object;
8         char name[32];
9         u64 device;
10         u32 debug;
11
12         struct nvkm_client_notify *notify[32];
13         struct rb_root objroot;
14
15         bool super;
16         void *data;
17         int (*ntfy)(const void *, u32, const void *, u32);
18
19         struct nvkm_vm *vm;
20 };
21
22 int  nvkm_client_new(const char *name, u64 device, const char *cfg,
23                      const char *dbg,
24                      int (*)(const void *, u32, const void *, u32),
25                      struct nvkm_client **);
26 struct nvkm_client *nvkm_client_search(struct nvkm_client *, u64 handle);
27
28 int nvkm_client_notify_new(struct nvkm_object *, struct nvkm_event *,
29                            void *data, u32 size);
30 int nvkm_client_notify_del(struct nvkm_client *, int index);
31 int nvkm_client_notify_get(struct nvkm_client *, int index);
32 int nvkm_client_notify_put(struct nvkm_client *, int index);
33
34 /* logging for client-facing objects */
35 #define nvif_printk(o,l,p,f,a...) do {                                         \
36         const struct nvkm_object *_object = (o);                               \
37         const struct nvkm_client *_client = _object->client;                   \
38         if (_client->debug >= NV_DBG_##l)                                      \
39                 printk(KERN_##p "nouveau: %s:%08x:%08x: "f, _client->name,     \
40                        _object->handle, _object->oclass, ##a);                 \
41 } while(0)
42 #define nvif_fatal(o,f,a...) nvif_printk((o), FATAL, CRIT, f, ##a)
43 #define nvif_error(o,f,a...) nvif_printk((o), ERROR,  ERR, f, ##a)
44 #define nvif_debug(o,f,a...) nvif_printk((o), DEBUG, INFO, f, ##a)
45 #define nvif_trace(o,f,a...) nvif_printk((o), TRACE, INFO, f, ##a)
46 #define nvif_info(o,f,a...)  nvif_printk((o),  INFO, INFO, f, ##a)
47 #define nvif_ioctl(o,f,a...) nvif_trace((o), "ioctl: "f, ##a)
48 #endif