xref: /linux/drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_DISP_IOR_H__
3 #define __NVKM_DISP_IOR_H__
4 #include "priv.h"
5 struct nvkm_i2c_aux;
6 
7 struct nvkm_ior {
8 	const struct nvkm_ior_func *func;
9 	struct nvkm_disp *disp;
10 	enum nvkm_ior_type {
11 		DAC,
12 		SOR,
13 		PIOR,
14 	} type;
15 	int id;
16 	bool hda;
17 	char name[8];
18 
19 	struct list_head head;
20 	bool identity;
21 
22 	struct nvkm_ior_state {
23 		struct nvkm_outp *outp;
24 		unsigned rgdiv;
25 		unsigned proto_evo:4;
26 		enum nvkm_ior_proto {
27 			CRT,
28 			TV,
29 			TMDS,
30 			LVDS,
31 			DP,
32 			UNKNOWN
33 		} proto:3;
34 		unsigned link:2;
35 		unsigned head:8;
36 	} arm, asy;
37 
38 	/* Armed DP state. */
39 	struct {
40 		bool mst;
41 		bool ef;
42 		u8 nr;
43 		u8 bw;
44 	} dp;
45 
46 	/* Armed TMDS state. */
47 	struct {
48 		bool high_speed;
49 	} tmds;
50 };
51 
52 struct nvkm_ior_func {
53 	struct {
54 		int (*get)(struct nvkm_outp *, int *link);
55 		void (*set)(struct nvkm_outp *, struct nvkm_ior *);
56 	} route;
57 
58 	void (*state)(struct nvkm_ior *, struct nvkm_ior_state *);
59 	void (*power)(struct nvkm_ior *, bool normal, bool pu,
60 		      bool data, bool vsync, bool hsync);
61 	int (*sense)(struct nvkm_ior *, u32 loadval);
62 	void (*clock)(struct nvkm_ior *);
63 	void (*war_2)(struct nvkm_ior *);
64 	void (*war_3)(struct nvkm_ior *);
65 
66 	const struct nvkm_ior_func_bl {
67 		int (*get)(struct nvkm_ior *);
68 		int (*set)(struct nvkm_ior *, int lvl);
69 	} *bl;
70 
71 	const struct nvkm_ior_func_hdmi {
72 		void (*ctrl)(struct nvkm_ior *, int head, bool enable, u8 max_ac_packet, u8 rekey);
73 		void (*scdc)(struct nvkm_ior *, u32 khz, bool support, bool scrambling,
74 			     bool scrambling_low_rates);
75 		void (*infoframe_avi)(struct nvkm_ior *, int head, void *data, u32 size);
76 		void (*infoframe_vsi)(struct nvkm_ior *, int head, void *data, u32 size);
77 		void (*audio)(struct nvkm_ior *, int head, bool enable);
78 	} *hdmi;
79 
80 	const struct nvkm_ior_func_dp {
81 		u8 lanes[4];
82 		int (*links)(struct nvkm_ior *, struct nvkm_i2c_aux *);
83 		void (*power)(struct nvkm_ior *, int nr);
84 		void (*pattern)(struct nvkm_ior *, int pattern);
85 		void (*drive)(struct nvkm_ior *, int ln, int pc,
86 			      int dc, int pe, int tx_pu);
87 		int (*sst)(struct nvkm_ior *, int head, bool ef,
88 			   u32 watermark, u32 hblanksym, u32 vblanksym);
89 		void (*vcpi)(struct nvkm_ior *, int head, u8 slot,
90 			     u8 slot_nr, u16 pbn, u16 aligned);
91 		void (*audio)(struct nvkm_ior *, int head, bool enable);
92 		void (*audio_sym)(struct nvkm_ior *, int head, u16 h, u32 v);
93 		void (*activesym)(struct nvkm_ior *, int head,
94 				  u8 TU, u8 VTUa, u8 VTUf, u8 VTUi);
95 		void (*watermark)(struct nvkm_ior *, int head, u8 watermark);
96 	} *dp;
97 
98 	const struct nvkm_ior_func_hda {
99 		void (*hpd)(struct nvkm_ior *, int head, bool present);
100 		void (*eld)(struct nvkm_ior *, int head, u8 *data, u8 size);
101 		void (*device_entry)(struct nvkm_ior *, int head);
102 	} *hda;
103 };
104 
105 int nvkm_ior_new_(const struct nvkm_ior_func *func, struct nvkm_disp *,
106 		  enum nvkm_ior_type type, int id, bool hda);
107 void nvkm_ior_del(struct nvkm_ior **);
108 struct nvkm_ior *nvkm_ior_find(struct nvkm_disp *, enum nvkm_ior_type, int id);
109 
110 static inline u32
111 nv50_ior_base(struct nvkm_ior *ior)
112 {
113 	return ior->id * 0x800;
114 }
115 
116 int nv50_dac_cnt(struct nvkm_disp *, unsigned long *);
117 int nv50_dac_new(struct nvkm_disp *, int);
118 void nv50_dac_power(struct nvkm_ior *, bool, bool, bool, bool, bool);
119 int nv50_dac_sense(struct nvkm_ior *, u32);
120 
121 int gf119_dac_cnt(struct nvkm_disp *, unsigned long *);
122 int gf119_dac_new(struct nvkm_disp *, int);
123 
124 static inline u32
125 nv50_sor_link(struct nvkm_ior *ior)
126 {
127 	return nv50_ior_base(ior) + ((ior->asy.link == 2) * 0x80);
128 }
129 
130 int nv50_sor_cnt(struct nvkm_disp *, unsigned long *);
131 void nv50_sor_state(struct nvkm_ior *, struct nvkm_ior_state *);
132 void nv50_sor_power(struct nvkm_ior *, bool, bool, bool, bool, bool);
133 void nv50_sor_clock(struct nvkm_ior *);
134 extern const struct nvkm_ior_func_bl nv50_sor_bl;
135 
136 int g84_sor_new(struct nvkm_disp *, int);
137 extern const struct nvkm_ior_func_hdmi g84_sor_hdmi;
138 
139 int g94_sor_cnt(struct nvkm_disp *, unsigned long *);
140 
141 void g94_sor_state(struct nvkm_ior *, struct nvkm_ior_state *);
142 extern const struct nvkm_ior_func_dp g94_sor_dp;
143 int g94_sor_dp_links(struct nvkm_ior *, struct nvkm_i2c_aux *);
144 void g94_sor_dp_power(struct nvkm_ior *, int);
145 void g94_sor_dp_pattern(struct nvkm_ior *, int);
146 void g94_sor_dp_drive(struct nvkm_ior *, int, int, int, int, int);
147 void g94_sor_dp_audio_sym(struct nvkm_ior *, int, u16, u32);
148 void g94_sor_dp_activesym(struct nvkm_ior *, int, u8, u8, u8, u8);
149 void g94_sor_dp_watermark(struct nvkm_ior *, int, u8);
150 
151 extern const struct nvkm_ior_func_bl gt215_sor_bl;
152 extern const struct nvkm_ior_func_hdmi gt215_sor_hdmi;
153 void gt215_sor_dp_audio(struct nvkm_ior *, int, bool);
154 extern const struct nvkm_ior_func_hda gt215_sor_hda;
155 
156 int gf119_sor_cnt(struct nvkm_disp *, unsigned long *);
157 void gf119_sor_state(struct nvkm_ior *, struct nvkm_ior_state *);
158 void gf119_sor_clock(struct nvkm_ior *);
159 extern const struct nvkm_ior_func_dp gf119_sor_dp;
160 int gf119_sor_dp_links(struct nvkm_ior *, struct nvkm_i2c_aux *);
161 void gf119_sor_dp_drive(struct nvkm_ior *, int, int, int, int, int);
162 void gf119_sor_dp_vcpi(struct nvkm_ior *, int, u8, u8, u16, u16);
163 void gf119_sor_dp_audio(struct nvkm_ior *, int, bool);
164 void gf119_sor_dp_audio_sym(struct nvkm_ior *, int, u16, u32);
165 void gf119_sor_dp_watermark(struct nvkm_ior *, int, u8);
166 extern const struct nvkm_ior_func_hda gf119_sor_hda;
167 void gf119_sor_hda_hpd(struct nvkm_ior *, int, bool);
168 void gf119_sor_hda_eld(struct nvkm_ior *, int, u8 *, u8);
169 
170 int gk104_sor_new(struct nvkm_disp *, int);
171 extern const struct nvkm_ior_func_hdmi gk104_sor_hdmi;
172 void gk104_sor_hdmi_ctrl(struct nvkm_ior *, int, bool, u8, u8);
173 void gk104_sor_hdmi_infoframe_avi(struct nvkm_ior *, int, void *, u32);
174 void gk104_sor_hdmi_infoframe_vsi(struct nvkm_ior *, int, void *, u32);
175 
176 void gm107_sor_dp_pattern(struct nvkm_ior *, int);
177 
178 void gm200_sor_route_set(struct nvkm_outp *, struct nvkm_ior *);
179 int gm200_sor_route_get(struct nvkm_outp *, int *);
180 extern const struct nvkm_ior_func_hdmi gm200_sor_hdmi;
181 void gm200_sor_hdmi_scdc(struct nvkm_ior *, u32, bool, bool, bool);
182 extern const struct nvkm_ior_func_dp gm200_sor_dp;
183 void gm200_sor_dp_drive(struct nvkm_ior *, int, int, int, int, int);
184 
185 int gp100_sor_new(struct nvkm_disp *, int);
186 
187 int gv100_sor_cnt(struct nvkm_disp *, unsigned long *);
188 void gv100_sor_state(struct nvkm_ior *, struct nvkm_ior_state *);
189 extern const struct nvkm_ior_func_hdmi gv100_sor_hdmi;
190 void gv100_sor_hdmi_infoframe_avi(struct nvkm_ior *, int, void *, u32);
191 void gv100_sor_hdmi_infoframe_vsi(struct nvkm_ior *, int, void *, u32);
192 void gv100_sor_dp_audio(struct nvkm_ior *, int, bool);
193 void gv100_sor_dp_audio_sym(struct nvkm_ior *, int, u16, u32);
194 void gv100_sor_dp_watermark(struct nvkm_ior *, int, u8);
195 extern const struct nvkm_ior_func_hda gv100_sor_hda;
196 
197 void tu102_sor_dp_vcpi(struct nvkm_ior *, int, u8, u8, u16, u16);
198 
199 int nv50_pior_cnt(struct nvkm_disp *, unsigned long *);
200 int nv50_pior_new(struct nvkm_disp *, int);
201 void nv50_pior_depth(struct nvkm_ior *, struct nvkm_ior_state *, u32 ctrl);
202 
203 #define IOR_MSG(i,l,f,a...) do {                                               \
204 	struct nvkm_ior *_ior = (i);                                           \
205 	nvkm_##l(&_ior->disp->engine.subdev, "%s: "f"\n", _ior->name, ##a);    \
206 } while(0)
207 #define IOR_WARN(i,f,a...) IOR_MSG((i), warn, f, ##a)
208 #define IOR_DBG(i,f,a...) IOR_MSG((i), debug, f, ##a)
209 #endif
210