1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_EVENT_H__
3 #define __NVKM_EVENT_H__
4 #include <core/os.h>
5 struct nvkm_notify;
6 struct nvkm_object;
7 
8 struct nvkm_event {
9 	const struct nvkm_event_func *func;
10 
11 	int types_nr;
12 	int index_nr;
13 
14 	spinlock_t refs_lock;
15 	spinlock_t list_lock;
16 	struct list_head list;
17 	int *refs;
18 };
19 
20 struct nvkm_event_func {
21 	int  (*ctor)(struct nvkm_object *, void *data, u32 size,
22 		     struct nvkm_notify *);
23 	void (*send)(void *data, u32 size, struct nvkm_notify *);
24 	void (*init)(struct nvkm_event *, int type, int index);
25 	void (*fini)(struct nvkm_event *, int type, int index);
26 };
27 
28 int  nvkm_event_init(const struct nvkm_event_func *func, int types_nr,
29 		     int index_nr, struct nvkm_event *);
30 void nvkm_event_fini(struct nvkm_event *);
31 void nvkm_event_get(struct nvkm_event *, u32 types, int index);
32 void nvkm_event_put(struct nvkm_event *, u32 types, int index);
33 void nvkm_event_send(struct nvkm_event *, u32 types, int index,
34 		     void *data, u32 size);
35 #endif
36