1 #ifndef __NOUVEAU_ENGINE_H__
2 #define __NOUVEAU_ENGINE_H__
3
4 #include <core/object.h>
5 #include <core/subdev.h>
6
7 #define NV_ENGINE_(eng,var) (NV_ENGINE_CLASS | ((var) << 8) | (eng))
8 #define NV_ENGINE(name,var) NV_ENGINE_(NVDEV_ENGINE_##name, (var))
9
10 struct nouveau_engine {
11 struct nouveau_subdev base;
12 struct nouveau_oclass *cclass;
13 struct nouveau_oclass *sclass;
14
15 struct list_head contexts;
16 spinlock_t lock;
17
18 void (*tile_prog)(struct nouveau_engine *, int region);
19 int (*tlb_flush)(struct nouveau_engine *);
20 };
21
22 static inline struct nouveau_engine *
nv_engine(void * obj)23 nv_engine(void *obj)
24 {
25 #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
26 if (unlikely(!nv_iclass(obj, NV_ENGINE_CLASS)))
27 nv_assert("BAD CAST -> NvEngine, %08x", nv_hclass(obj));
28 #endif
29 return obj;
30 }
31
32 static inline int
nv_engidx(struct nouveau_object * object)33 nv_engidx(struct nouveau_object *object)
34 {
35 return nv_subidx(object);
36 }
37
38 #define nouveau_engine_create(p,e,c,d,i,f,r) \
39 nouveau_engine_create_((p), (e), (c), (d), (i), (f), \
40 sizeof(**r),(void **)r)
41
42 #define nouveau_engine_destroy(p) \
43 nouveau_subdev_destroy(&(p)->base)
44 #define nouveau_engine_init(p) \
45 nouveau_subdev_init(&(p)->base)
46 #define nouveau_engine_fini(p,s) \
47 nouveau_subdev_fini(&(p)->base, (s))
48
49 int nouveau_engine_create_(struct nouveau_object *, struct nouveau_object *,
50 struct nouveau_oclass *, bool, const char *,
51 const char *, int, void **);
52
53 #define _nouveau_engine_dtor _nouveau_subdev_dtor
54 #define _nouveau_engine_init _nouveau_subdev_init
55 #define _nouveau_engine_fini _nouveau_subdev_fini
56
57 #endif
58