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 extern const struct nvkm_subdev_func nvkm_engine;
10 
11 struct nvkm_engine {
12 	const struct nvkm_engine_func *func;
13 	struct nvkm_subdev subdev;
14 	spinlock_t lock;
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 	int (*reset)(struct nvkm_engine *);
25 	void (*intr)(struct nvkm_engine *);
26 	void (*tile)(struct nvkm_engine *, int region, struct nvkm_fb_tile *);
27 	bool (*chsw_load)(struct nvkm_engine *);
28 
29 	struct {
30 		int (*sclass)(struct nvkm_oclass *, int index,
31 			      const struct nvkm_device_oclass **);
32 	} base;
33 
34 	struct {
35 		int (*cclass)(struct nvkm_fifo_chan *,
36 			      const struct nvkm_oclass *,
37 			      struct nvkm_object **);
38 		int (*sclass)(struct nvkm_oclass *, int index);
39 	} fifo;
40 
41 	const struct nvkm_object_func *cclass;
42 	struct nvkm_sclass sclass[];
43 };
44 
45 int nvkm_engine_ctor(const struct nvkm_engine_func *, struct nvkm_device *,
46 		     enum nvkm_subdev_type, int inst, bool enable, struct nvkm_engine *);
47 int nvkm_engine_new_(const struct nvkm_engine_func *, struct nvkm_device *,
48 		     enum nvkm_subdev_type, int, bool enable, struct nvkm_engine **);
49 
50 struct nvkm_engine *nvkm_engine_ref(struct nvkm_engine *);
51 void nvkm_engine_unref(struct nvkm_engine **);
52 int nvkm_engine_reset(struct nvkm_engine *);
53 void nvkm_engine_tile(struct nvkm_engine *, int region);
54 bool nvkm_engine_chsw_load(struct nvkm_engine *);
55 #endif
56