1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_DISP_OUTP_H__
3 #define __NVKM_DISP_OUTP_H__
4 #include "priv.h"
5 
6 #include <drm/display/drm_dp.h>
7 #include <subdev/bios.h>
8 #include <subdev/bios/dcb.h>
9 #include <subdev/bios/dp.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 	union {
30 		struct {
31 			bool dual;
32 			bool bpc8;
33 		} lvds;
34 
35 		struct {
36 			struct nvbios_dpout info;
37 			u8 version;
38 
39 			struct nvkm_i2c_aux *aux;
40 
41 			bool enabled;
42 			bool aux_pwr;
43 			bool aux_pwr_pu;
44 			u8 lttpr[6];
45 			u8 lttprs;
46 			u8 dpcd[DP_RECEIVER_CAP_SIZE];
47 
48 			struct {
49 				int dpcd; /* -1, or index into SUPPORTED_LINK_RATES table */
50 				u32 rate;
51 			} rate[8];
52 			int rates;
53 			int links;
54 
55 			struct mutex mutex;
56 			struct {
57 				atomic_t done;
58 				u8 nr;
59 				u8 bw;
60 				bool mst;
61 			} lt;
62 		} dp;
63 	};
64 
65 	struct nvkm_object object;
66 	struct {
67 		struct nvkm_head *head;
68 	} asy;
69 };
70 
71 int nvkm_outp_new_(const struct nvkm_outp_func *, struct nvkm_disp *, int index,
72 		   struct dcb_output *, struct nvkm_outp **);
73 int nvkm_outp_new(struct nvkm_disp *, int index, struct dcb_output *, struct nvkm_outp **);
74 void nvkm_outp_del(struct nvkm_outp **);
75 void nvkm_outp_init(struct nvkm_outp *);
76 void nvkm_outp_fini(struct nvkm_outp *);
77 int nvkm_outp_acquire(struct nvkm_outp *, u8 user, bool hda);
78 void nvkm_outp_release(struct nvkm_outp *, u8 user);
79 void nvkm_outp_route(struct nvkm_disp *);
80 
81 struct nvkm_outp_func {
82 	void *(*dtor)(struct nvkm_outp *);
83 	void (*init)(struct nvkm_outp *);
84 	void (*fini)(struct nvkm_outp *);
85 	int (*acquire)(struct nvkm_outp *);
86 	void (*release)(struct nvkm_outp *);
87 	void (*disable)(struct nvkm_outp *, struct nvkm_ior *);
88 };
89 
90 #define OUTP_MSG(o,l,f,a...) do {                                              \
91 	struct nvkm_outp *_outp = (o);                                         \
92 	nvkm_##l(&_outp->disp->engine.subdev, "outp %02x:%04x:%04x: "f"\n",    \
93 		 _outp->index, _outp->info.hasht, _outp->info.hashm, ##a);     \
94 } while(0)
95 #define OUTP_ERR(o,f,a...) OUTP_MSG((o), error, f, ##a)
96 #define OUTP_DBG(o,f,a...) OUTP_MSG((o), debug, f, ##a)
97 #define OUTP_TRACE(o,f,a...) OUTP_MSG((o), trace, f, ##a)
98 #endif
99