1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#ifndef DC_LINK_H_
27#define DC_LINK_H_
28
29#include "dc.h"
30#include "dc_types.h"
31#include "grph_object_defs.h"
32
33enum dc_link_fec_state {
34 dc_link_fec_not_ready,
35 dc_link_fec_ready,
36 dc_link_fec_enabled
37};
38struct dc_link_status {
39 bool link_active;
40 struct dpcd_caps *dpcd_caps;
41};
42
43
44struct link_mst_stream_allocation {
45
46 const struct stream_encoder *stream_enc;
47
48 uint8_t vcp_id;
49
50 uint8_t slot_count;
51};
52
53
54struct link_mst_stream_allocation_table {
55
56 int stream_count;
57
58 struct link_mst_stream_allocation stream_allocations[MAX_CONTROLLER_NUM];
59};
60
61struct time_stamp {
62 uint64_t edp_poweroff;
63 uint64_t edp_poweron;
64};
65
66struct link_trace {
67 struct time_stamp time_stamp;
68};
69
70
71struct psr_settings {
72 bool psr_feature_enabled;
73 bool psr_allow_active;
74 enum dc_psr_version psr_version;
75
76
77
78
79
80
81 bool psr_frame_capture_indication_req;
82 unsigned int psr_sdp_transmit_line_num_deadline;
83};
84
85
86
87
88
89struct dc_link {
90 struct dc_sink *remote_sinks[MAX_SINKS_PER_LINK];
91 unsigned int sink_count;
92 struct dc_sink *local_sink;
93 unsigned int link_index;
94 enum dc_connection_type type;
95 enum signal_type connector_signal;
96 enum dc_irq_source irq_source_hpd;
97 enum dc_irq_source irq_source_hpd_rx;
98 bool is_hpd_filter_disabled;
99 bool dp_ss_off;
100 bool link_state_valid;
101 bool aux_access_disabled;
102 bool sync_lt_in_progress;
103 bool lttpr_non_transparent_mode;
104 bool is_internal_display;
105
106 bool edp_sink_present;
107
108
109
110
111 struct dc_link_settings reported_link_cap;
112 struct dc_link_settings verified_link_cap;
113 struct dc_link_settings cur_link_settings;
114 struct dc_lane_settings cur_lane_setting;
115 struct dc_link_settings preferred_link_setting;
116 struct dc_link_training_overrides preferred_training_settings;
117 struct dp_audio_test_data audio_test_data;
118
119 uint8_t ddc_hw_inst;
120
121 uint8_t hpd_src;
122
123 uint8_t link_enc_hw_inst;
124
125 bool test_pattern_enabled;
126 union compliance_test_state compliance_test_state;
127
128 void *priv;
129
130 struct ddc_service *ddc;
131
132 bool aux_mode;
133
134
135
136 const struct dc *dc;
137
138 struct dc_context *ctx;
139
140 struct panel_cntl *panel_cntl;
141 struct link_encoder *link_enc;
142 struct graphics_object_id link_id;
143 union ddi_channel_mapping ddi_channel_mapping;
144 struct connector_device_tag_info device_tag;
145 struct dpcd_caps dpcd_caps;
146 uint32_t dongle_max_pix_clk;
147 unsigned short chip_caps;
148 unsigned int dpcd_sink_count;
149#if defined(CONFIG_DRM_AMD_DC_HDCP)
150 struct hdcp_caps hdcp_caps;
151#endif
152 enum edp_revision edp_revision;
153 union dpcd_sink_ext_caps dpcd_sink_ext_caps;
154
155 struct psr_settings psr_settings;
156
157
158 struct link_flags {
159 bool dp_keep_receiver_powered;
160 bool dp_skip_DID2;
161 bool dp_skip_reset_segment;
162 } wa_flags;
163 struct link_mst_stream_allocation_table mst_stream_alloc_table;
164
165 struct dc_link_status link_status;
166
167 struct link_trace link_trace;
168 struct gpio *hpd_gpio;
169 enum dc_link_fec_state fec_state;
170};
171
172const struct dc_link_status *dc_link_get_status(const struct dc_link *dc_link);
173
174
175
176
177
178
179
180
181static inline struct dc_link *dc_get_link_at_index(struct dc *dc, uint32_t link_index)
182{
183 return dc->links[link_index];
184}
185
186static inline struct dc_link *get_edp_link(const struct dc *dc)
187{
188 int i;
189
190
191 for (i = 0; i < dc->link_count; i++) {
192 if (dc->links[i]->connector_signal == SIGNAL_TYPE_EDP)
193 return dc->links[i];
194 }
195 return NULL;
196}
197
198
199
200
201
202bool dc_link_set_backlight_level(const struct dc_link *dc_link,
203 uint32_t backlight_pwm_u16_16,
204 uint32_t frame_ramp);
205
206
207bool dc_link_set_backlight_level_nits(struct dc_link *link,
208 bool isHDR,
209 uint32_t backlight_millinits,
210 uint32_t transition_time_in_ms);
211
212bool dc_link_get_backlight_level_nits(struct dc_link *link,
213 uint32_t *backlight_millinits,
214 uint32_t *backlight_millinits_peak);
215
216bool dc_link_backlight_enable_aux(struct dc_link *link, bool enable);
217
218bool dc_link_read_default_bl_aux(struct dc_link *link, uint32_t *backlight_millinits);
219bool dc_link_set_default_brightness_aux(struct dc_link *link);
220
221int dc_link_get_backlight_level(const struct dc_link *dc_link);
222
223int dc_link_get_target_backlight_pwm(const struct dc_link *link);
224
225bool dc_link_set_psr_allow_active(struct dc_link *dc_link, bool enable,
226 bool wait, bool force_static);
227
228bool dc_link_get_psr_state(const struct dc_link *dc_link, enum dc_psr_state *state);
229
230bool dc_link_setup_psr(struct dc_link *dc_link,
231 const struct dc_stream_state *stream, struct psr_config *psr_config,
232 struct psr_context *psr_context);
233
234void dc_link_get_psr_residency(const struct dc_link *link, uint32_t *residency);
235
236
237
238
239
240
241
242enum dc_detect_reason {
243 DETECT_REASON_BOOT,
244 DETECT_REASON_HPD,
245 DETECT_REASON_HPDRX,
246 DETECT_REASON_FALLBACK,
247 DETECT_REASON_RETRAIN
248};
249
250bool dc_link_detect(struct dc_link *dc_link, enum dc_detect_reason reason);
251bool dc_link_get_hpd_state(struct dc_link *dc_link);
252enum dc_status dc_link_allocate_mst_payload(struct pipe_ctx *pipe_ctx);
253enum dc_status dc_link_reallocate_mst_payload(struct dc_link *link);
254
255
256
257
258
259
260
261bool dc_link_handle_hpd_rx_irq(struct dc_link *dc_link,
262 union hpd_irq_data *hpd_irq_dpcd_data, bool *out_link_loss);
263
264
265
266
267
268
269bool dc_link_wait_for_t12(struct dc_link *link);
270
271enum dc_status read_hpd_rx_irq_data(
272 struct dc_link *link,
273 union hpd_irq_data *irq_data);
274
275struct dc_sink_init_data;
276
277struct dc_sink *dc_link_add_remote_sink(
278 struct dc_link *dc_link,
279 const uint8_t *edid,
280 int len,
281 struct dc_sink_init_data *init_data);
282
283void dc_link_remove_remote_sink(
284 struct dc_link *link,
285 struct dc_sink *sink);
286
287
288
289void dc_link_dp_set_drive_settings(
290 struct dc_link *link,
291 struct link_training_settings *lt_settings);
292
293bool dc_link_dp_perform_link_training_skip_aux(
294 struct dc_link *link,
295 const struct dc_link_settings *link_setting);
296
297enum link_training_result dc_link_dp_perform_link_training(
298 struct dc_link *link,
299 const struct dc_link_settings *link_setting,
300 bool skip_video_pattern);
301
302bool dc_link_dp_sync_lt_begin(struct dc_link *link);
303
304enum link_training_result dc_link_dp_sync_lt_attempt(
305 struct dc_link *link,
306 struct dc_link_settings *link_setting,
307 struct dc_link_training_overrides *lt_settings);
308
309bool dc_link_dp_sync_lt_end(struct dc_link *link, bool link_down);
310
311void dc_link_dp_enable_hpd(const struct dc_link *link);
312
313void dc_link_dp_disable_hpd(const struct dc_link *link);
314
315bool dc_link_dp_set_test_pattern(
316 struct dc_link *link,
317 enum dp_test_pattern test_pattern,
318 enum dp_test_pattern_color_space test_pattern_color_space,
319 const struct link_training_settings *p_link_settings,
320 const unsigned char *p_custom_pattern,
321 unsigned int cust_pattern_size);
322
323bool dc_link_dp_get_max_link_enc_cap(const struct dc_link *link, struct dc_link_settings *max_link_enc_cap);
324
325void dc_link_enable_hpd_filter(struct dc_link *link, bool enable);
326
327bool dc_link_is_dp_sink_present(struct dc_link *link);
328
329bool dc_link_detect_sink(struct dc_link *link, enum dc_connection_type *type);
330
331
332
333
334#ifdef CONFIG_DRM_AMD_DC_HDCP
335bool dc_link_is_hdcp14(struct dc_link *link, enum signal_type signal);
336bool dc_link_is_hdcp22(struct dc_link *link, enum signal_type signal);
337#endif
338void dc_link_set_drive_settings(struct dc *dc,
339 struct link_training_settings *lt_settings,
340 const struct dc_link *link);
341void dc_link_perform_link_training(struct dc *dc,
342 struct dc_link_settings *link_setting,
343 bool skip_video_pattern);
344void dc_link_set_preferred_link_settings(struct dc *dc,
345 struct dc_link_settings *link_setting,
346 struct dc_link *link);
347void dc_link_set_preferred_training_settings(struct dc *dc,
348 struct dc_link_settings *link_setting,
349 struct dc_link_training_overrides *lt_overrides,
350 struct dc_link *link,
351 bool skip_immediate_retrain);
352void dc_link_enable_hpd(const struct dc_link *link);
353void dc_link_disable_hpd(const struct dc_link *link);
354void dc_link_set_test_pattern(struct dc_link *link,
355 enum dp_test_pattern test_pattern,
356 enum dp_test_pattern_color_space test_pattern_color_space,
357 const struct link_training_settings *p_link_settings,
358 const unsigned char *p_custom_pattern,
359 unsigned int cust_pattern_size);
360uint32_t dc_link_bandwidth_kbps(
361 const struct dc_link *link,
362 const struct dc_link_settings *link_setting);
363
364const struct dc_link_settings *dc_link_get_link_cap(
365 const struct dc_link *link);
366
367void dc_link_overwrite_extended_receiver_cap(
368 struct dc_link *link);
369
370bool dc_submit_i2c(
371 struct dc *dc,
372 uint32_t link_index,
373 struct i2c_command *cmd);
374
375bool dc_submit_i2c_oem(
376 struct dc *dc,
377 struct i2c_command *cmd);
378
379uint32_t dc_bandwidth_in_kbps_from_timing(
380 const struct dc_crtc_timing *timing);
381
382bool dc_link_is_fec_supported(const struct dc_link *link);
383bool dc_link_should_enable_fec(const struct dc_link *link);
384
385#endif
386