aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/core/include/core/parent.h
blob: 12da418ec70a2c29ef968aea14f692eb87197ee9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef __NOUVEAU_PARENT_H__
#define __NOUVEAU_PARENT_H__

#include <core/device.h>
#include <core/object.h>

struct nouveau_sclass {
	struct nouveau_sclass *sclass;
	struct nouveau_engine *engine;
	struct nouveau_oclass *oclass;
};

struct nouveau_parent {
	struct nouveau_object base;

	struct nouveau_sclass *sclass;
	u64 engine;

	int  (*context_attach)(struct nouveau_object *,
			       struct nouveau_object *);
	int  (*context_detach)(struct nouveau_object *, bool suspend,
			       struct nouveau_object *);

	int  (*object_attach)(struct nouveau_object *parent,
			      struct nouveau_object *object, u32 name);
	void (*object_detach)(struct nouveau_object *parent, int cookie);
};

static inline struct nouveau_parent *
nv_parent(void *obj)
{
#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
	if (unlikely(!(nv_iclass(obj, NV_PARENT_CLASS))))
		nv_assert("BAD CAST -> NvParent, %08x", nv_hclass(obj));
#endif
	return obj;
}

#define nouveau_parent_create(p,e,c,v,s,m,d)                                   \
	nouveau_parent_create_((p), (e), (c), (v), (s), (m),                   \
			       sizeof(**d), (void **)d)
#define nouveau_parent_init(p)                                                 \
	nouveau_object_init(&(p)->base)
#define nouveau_parent_fini(p,s)                                               \
	nouveau_object_fini(&(p)->base, (s))

int  nouveau_parent_create_(struct nouveau_object *, struct nouveau_object *,
			    struct nouveau_oclass *, u32 pclass,
			    struct nouveau_oclass *, u64 engcls,
			    int size, void **);
void nouveau_parent_destroy(struct nouveau_parent *);

void _nouveau_parent_dtor(struct nouveau_object *);
#define _nouveau_parent_init nouveau_object_init
#define _nouveau_parent_fini nouveau_object_fini

int nouveau_parent_sclass(struct nouveau_object *, u16 handle,
			  struct nouveau_object **pengine,
			  struct nouveau_oclass **poclass);
int nouveau_parent_lclass(struct nouveau_object *, u32 *, int);

#endif