drm/nouveau/core: prepare for new-style objects
[deliverable/linux.git] / drivers / gpu / drm / nouveau / include / nvkm / core / client.h
1 #ifndef __NVKM_CLIENT_H__
2 #define __NVKM_CLIENT_H__
3 #include <core/namedb.h>
4
5 struct nvkm_client {
6 struct nvkm_namedb namedb;
7 struct nvkm_handle *root;
8 u64 device;
9 char name[32];
10 u32 debug;
11 struct nvkm_vm *vm;
12 bool super;
13 void *data;
14
15 int (*ntfy)(const void *, u32, const void *, u32);
16 struct nvkm_client_notify *notify[16];
17
18 struct rb_root objroot;
19 };
20
21 bool nvkm_client_insert(struct nvkm_client *, struct nvkm_handle *);
22 void nvkm_client_remove(struct nvkm_client *, struct nvkm_handle *);
23 struct nvkm_handle *nvkm_client_search(struct nvkm_client *, u64 handle);
24
25 static inline struct nvkm_client *
26 nvkm_client(struct nvkm_object *object)
27 {
28 while (object && object->parent)
29 object = object->parent;
30 if (object && nv_iclass(object, NV_CLIENT_CLASS))
31 return container_of(object, struct nvkm_client, namedb.parent.object);
32 return NULL;
33 }
34
35 int nvkm_client_new(const char *name, u64 device, const char *cfg,
36 const char *dbg, struct nvkm_client **);
37 void nvkm_client_del(struct nvkm_client **);
38 int nvkm_client_init(struct nvkm_client *);
39 int nvkm_client_fini(struct nvkm_client *, bool suspend);
40 const char *nvkm_client_name(void *obj);
41
42 int nvkm_client_notify_new(struct nvkm_object *, struct nvkm_event *,
43 void *data, u32 size);
44 int nvkm_client_notify_del(struct nvkm_client *, int index);
45 int nvkm_client_notify_get(struct nvkm_client *, int index);
46 int nvkm_client_notify_put(struct nvkm_client *, int index);
47
48 /* logging for client-facing objects */
49 #define nvif_printk(o,l,p,f,a...) do { \
50 struct nvkm_object *_object = (o); \
51 struct nvkm_client *_client = nvkm_client(_object); \
52 if (_client->debug >= NV_DBG_##l) \
53 printk(KERN_##p "nouveau: %s: "f, _client->name, ##a); \
54 } while(0)
55 #define nvif_error(o,f,a...) nvif_printk((o), ERROR, ERR, f, ##a)
56 #define nvif_debug(o,f,a...) nvif_printk((o), DEBUG, INFO, f, ##a)
57 #define nvif_trace(o,f,a...) nvif_printk((o), TRACE, INFO, f, ##a)
58 #define nvif_ioctl(o,f,a...) nvif_trace((o), "ioctl: "f, ##a)
59 #endif
This page took 0.03342 seconds and 6 git commands to generate.