1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_DISP_OUTP_H__
3 #define __NVKM_DISP_OUTP_H__
4 #include <engine/disp.h>
5 
6 #include <subdev/bios.h>
7 #include <subdev/bios/dcb.h>
8 
9 struct nvkm_outp {
10 	const struct nvkm_outp_func *func;
11 	struct nvkm_disp *disp;
12 	int index;
13 	struct dcb_output info;
14 
15 	struct nvkm_i2c_bus *i2c;
16 
17 	struct list_head head;
18 	struct nvkm_conn *conn;
19 	bool identity;
20 
21 	/* Assembly state. */
22 #define NVKM_OUTP_PRIV 1
23 #define NVKM_OUTP_USER 2
24 	u8 acquired:2;
25 	struct nvkm_ior *ior;
26 };
27 
28 int nvkm_outp_ctor(const struct nvkm_outp_func *, struct nvkm_disp *,
29 		   int index, struct dcb_output *, struct nvkm_outp *);
30 int nvkm_outp_new(struct nvkm_disp *, int index, struct dcb_output *,
31 		  struct nvkm_outp **);
32 void nvkm_outp_del(struct nvkm_outp **);
33 void nvkm_outp_init(struct nvkm_outp *);
34 void nvkm_outp_fini(struct nvkm_outp *);
35 int nvkm_outp_acquire(struct nvkm_outp *, u8 user, bool hda);
36 void nvkm_outp_release(struct nvkm_outp *, u8 user);
37 void nvkm_outp_route(struct nvkm_disp *);
38 
39 struct nvkm_outp_func {
40 	void *(*dtor)(struct nvkm_outp *);
41 	void (*init)(struct nvkm_outp *);
42 	void (*fini)(struct nvkm_outp *);
43 	int (*acquire)(struct nvkm_outp *);
44 	void (*release)(struct nvkm_outp *);
45 	void (*disable)(struct nvkm_outp *, struct nvkm_ior *);
46 };
47 
48 #define OUTP_MSG(o,l,f,a...) do {                                              \
49 	struct nvkm_outp *_outp = (o);                                         \
50 	nvkm_##l(&_outp->disp->engine.subdev, "outp %02x:%04x:%04x: "f"\n",    \
51 		 _outp->index, _outp->info.hasht, _outp->info.hashm, ##a);     \
52 } while(0)
53 #define OUTP_ERR(o,f,a...) OUTP_MSG((o), error, f, ##a)
54 #define OUTP_DBG(o,f,a...) OUTP_MSG((o), debug, f, ##a)
55 #define OUTP_TRACE(o,f,a...) OUTP_MSG((o), trace, f, ##a)
56 #endif
57