1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVIF_OUTP_H__
3 #define __NVIF_OUTP_H__
4 #include <nvif/object.h>
5 #include <nvif/if0012.h>
6 #include <drm/display/drm_dp.h>
7 struct nvif_disp;
8 
9 struct nvif_outp {
10 	struct nvif_object object;
11 	u32 id;
12 
13 	struct {
14 		enum {
15 			NVIF_OUTP_DAC,
16 			NVIF_OUTP_SOR,
17 			NVIF_OUTP_PIOR,
18 		} type;
19 
20 		enum {
21 			NVIF_OUTP_RGB_CRT,
22 			NVIF_OUTP_TMDS,
23 			NVIF_OUTP_LVDS,
24 			NVIF_OUTP_DP,
25 		} proto;
26 
27 		u8 heads;
28 #define NVIF_OUTP_DDC_INVALID 0xff
29 		u8 ddc;
30 		u8 conn;
31 
32 		union {
33 			struct {
34 				u32 freq_max;
35 			} rgb_crt;
36 			struct {
37 				bool dual;
38 			} tmds;
39 			struct {
40 				bool acpi_edid;
41 			} lvds;
42 			struct {
43 				u8   aux;
44 				bool mst;
45 				bool increased_wm;
46 				u8   link_nr;
47 				u32  link_bw;
48 			} dp;
49 		};
50 	} info;
51 
52 	struct {
53 		int id;
54 		int link;
55 	} or;
56 };
57 
58 int nvif_outp_ctor(struct nvif_disp *, const char *name, int id, struct nvif_outp *);
59 void nvif_outp_dtor(struct nvif_outp *);
60 
61 enum nvif_outp_detect_status {
62 	NOT_PRESENT,
63 	PRESENT,
64 	UNKNOWN,
65 };
66 
67 enum nvif_outp_detect_status nvif_outp_detect(struct nvif_outp *);
68 int nvif_outp_edid_get(struct nvif_outp *, u8 **pedid);
69 
70 int nvif_outp_load_detect(struct nvif_outp *, u32 loadval);
71 int nvif_outp_acquire_dac(struct nvif_outp *);
72 int nvif_outp_acquire_sor(struct nvif_outp *, bool hda);
73 int nvif_outp_acquire_pior(struct nvif_outp *);
74 int nvif_outp_inherit_rgb_crt(struct nvif_outp *outp, u8 *proto_out);
75 int nvif_outp_inherit_lvds(struct nvif_outp *outp, u8 *proto_out);
76 int nvif_outp_inherit_tmds(struct nvif_outp *outp, u8 *proto_out);
77 int nvif_outp_inherit_dp(struct nvif_outp *outp, u8 *proto_out);
78 
79 void nvif_outp_release(struct nvif_outp *);
80 
81 static inline bool
nvif_outp_acquired(struct nvif_outp * outp)82 nvif_outp_acquired(struct nvif_outp *outp)
83 {
84 	return outp->or.id >= 0;
85 }
86 
87 int nvif_outp_bl_get(struct nvif_outp *);
88 int nvif_outp_bl_set(struct nvif_outp *, int level);
89 
90 int nvif_outp_lvds(struct nvif_outp *, bool dual, bool bpc8);
91 
92 int nvif_outp_hdmi(struct nvif_outp *, int head, bool enable, u8 max_ac_packet, u8 rekey, u32 khz,
93 		   bool scdc, bool scdc_scrambling, bool scdc_low_rates);
94 
95 int nvif_outp_infoframe(struct nvif_outp *, u8 type, struct nvif_outp_infoframe_v0 *, u32 size);
96 int nvif_outp_hda_eld(struct nvif_outp *, int head, void *data, u32 size);
97 
98 int nvif_outp_dp_aux_pwr(struct nvif_outp *, bool enable);
99 int nvif_outp_dp_aux_xfer(struct nvif_outp *, u8 type, u8 *size, u32 addr, u8 *data);
100 
101 struct nvif_outp_dp_rate {
102 	int dpcd; /* -1 for non-indexed rates */
103 	u32 rate;
104 };
105 
106 int nvif_outp_dp_rates(struct nvif_outp *, struct nvif_outp_dp_rate *rate, int rate_nr);
107 int nvif_outp_dp_train(struct nvif_outp *, u8 dpcd[DP_RECEIVER_CAP_SIZE],
108 		       u8 lttprs, u8 link_nr, u32 link_bw, bool mst, bool post_lt_adj,
109 		       bool retrain);
110 int nvif_outp_dp_drive(struct nvif_outp *, u8 link_nr, u8 pe[4], u8 vs[4]);
111 int nvif_outp_dp_sst(struct nvif_outp *, int head, u32 watermark, u32 hblanksym, u32 vblanksym);
112 int nvif_outp_dp_mst_id_get(struct nvif_outp *, u32 *id);
113 int nvif_outp_dp_mst_id_put(struct nvif_outp *, u32 id);
114 int nvif_outp_dp_mst_vcpi(struct nvif_outp *, int head,
115 			  u8 start_slot, u8 num_slots, u16 pbn, u16 aligned_pbn);
116 #endif
117