drm/nouveau/core: prepare for new-style objects
[deliverable/linux.git] / drivers / gpu / drm / nouveau / include / nvkm / core / client.h
CommitLineData
5025407b
BS
1#ifndef __NVKM_CLIENT_H__
2#define __NVKM_CLIENT_H__
9274f4a9
BS
3#include <core/namedb.h>
4
5025407b
BS
5struct nvkm_client {
6 struct nvkm_namedb namedb;
7 struct nvkm_handle *root;
4e7e62d6 8 u64 device;
a2896ced 9 char name[32];
9274f4a9 10 u32 debug;
5025407b 11 struct nvkm_vm *vm;
8ec2a6ec
BS
12 bool super;
13 void *data;
14
15 int (*ntfy)(const void *, u32, const void *, u32);
7caa63c0 16 struct nvkm_client_notify *notify[16];
bf81df9b
BS
17
18 struct rb_root objroot;
9274f4a9
BS
19};
20
bf81df9b
BS
21bool nvkm_client_insert(struct nvkm_client *, struct nvkm_handle *);
22void nvkm_client_remove(struct nvkm_client *, struct nvkm_handle *);
23struct nvkm_handle *nvkm_client_search(struct nvkm_client *, u64 handle);
24
5025407b 25static inline struct nvkm_client *
524bdbf2 26nvkm_client(struct nvkm_object *object)
9274f4a9 27{
524bdbf2
BS
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);
7974dd1b 32 return NULL;
9274f4a9
BS
33}
34
76ecea5b
BS
35int nvkm_client_new(const char *name, u64 device, const char *cfg,
36 const char *dbg, struct nvkm_client **);
37void nvkm_client_del(struct nvkm_client **);
5025407b
BS
38int nvkm_client_init(struct nvkm_client *);
39int nvkm_client_fini(struct nvkm_client *, bool suspend);
40const char *nvkm_client_name(void *obj);
9274f4a9 41
5025407b 42int nvkm_client_notify_new(struct nvkm_object *, struct nvkm_event *,
8ec2a6ec 43 void *data, u32 size);
5025407b
BS
44int nvkm_client_notify_del(struct nvkm_client *, int index);
45int nvkm_client_notify_get(struct nvkm_client *, int index);
46int nvkm_client_notify_put(struct nvkm_client *, int index);
6594363b
BS
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)
9274f4a9 59#endif
This page took 0.213904 seconds and 5 git commands to generate.