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