1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_ENGINE_H__
3 #define __NVKM_ENGINE_H__
4 #define nvkm_engine(p) container_of((p), struct nvkm_engine, subdev)
5 #include <core/subdev.h>
6 struct nvkm_fifo_chan;
7 struct nvkm_fb_tile;
8 
9 struct nvkm_engine {
10 	const struct nvkm_engine_func *func;
11 	struct nvkm_subdev subdev;
12 	spinlock_t lock;
13 
14 	int usecount;
15 };
16 
17 struct nvkm_engine_func {
18 	void *(*dtor)(struct nvkm_engine *);
19 	void (*preinit)(struct nvkm_engine *);
20 	int (*oneinit)(struct nvkm_engine *);
21 	int (*info)(struct nvkm_engine *, u64 mthd, u64 *data);
22 	int (*init)(struct nvkm_engine *);
23 	int (*fini)(struct nvkm_engine *, bool suspend);
24 	void (*intr)(struct nvkm_engine *);
25 	void (*tile)(struct nvkm_engine *, int region, struct nvkm_fb_tile *);
26 	bool (*chsw_load)(struct nvkm_engine *);
27 
28 	struct {
29 		int (*sclass)(struct nvkm_oclass *, int index,
30 			      const struct nvkm_device_oclass **);
31 	} base;
32 
33 	struct {
34 		int (*cclass)(struct nvkm_fifo_chan *,
35 			      const struct nvkm_oclass *,
36 			      struct nvkm_object **);
37 		int (*sclass)(struct nvkm_oclass *, int index);
38 	} fifo;
39 
40 	const struct nvkm_object_func *cclass;
41 	struct nvkm_sclass sclass[];
42 };
43 
44 int nvkm_engine_ctor(const struct nvkm_engine_func *, struct nvkm_device *,
45 		     int index, bool enable, struct nvkm_engine *);
46 int nvkm_engine_new_(const struct nvkm_engine_func *, struct nvkm_device *,
47 		     int index, bool enable, struct nvkm_engine **);
48 struct nvkm_engine *nvkm_engine_ref(struct nvkm_engine *);
49 void nvkm_engine_unref(struct nvkm_engine **);
50 void nvkm_engine_tile(struct nvkm_engine *, int region);
51 bool nvkm_engine_chsw_load(struct nvkm_engine *);
52 #endif
53