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