1 /*
2  * Copyright 2022 Advanced Micro Devices, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * Authors: AMD
23  *
24  */
25 
26 #ifndef __DC_LINK_DP_CAPABILITY_H__
27 #define __DC_LINK_DP_CAPABILITY_H__
28 
29 #include "link.h"
30 
31 bool detect_dp_sink_caps(struct dc_link *link);
32 
33 void detect_edp_sink_caps(struct dc_link *link);
34 
35 struct dc_link_settings dp_get_max_link_cap(struct dc_link *link);
36 
37 bool dp_get_max_link_enc_cap(const struct dc_link *link,
38 		struct dc_link_settings *max_link_enc_cap);
39 
40 const struct dc_link_settings *dp_get_verified_link_cap(
41 		const struct dc_link *link);
42 
43 enum dp_link_encoding link_dp_get_encoding_format(
44 		const struct dc_link_settings *link_settings);
45 
46 enum dc_status dp_retrieve_lttpr_cap(struct dc_link *link);
47 
48 /* Convert PHY repeater count read from DPCD uint8_t. */
49 uint8_t dp_parse_lttpr_repeater_count(uint8_t lttpr_repeater_count);
50 
51 /* Calculate embedded LTTPR address offset for vendor-specific behaviour */
52 uint32_t dp_get_closest_lttpr_offset(uint8_t lttpr_count);
53 
54 bool dp_is_sink_present(struct dc_link *link);
55 
56 bool dp_is_lttpr_present(struct dc_link *link);
57 
58 bool dp_is_fec_supported(const struct dc_link *link);
59 
60 bool is_dp_active_dongle(const struct dc_link *link);
61 
62 bool is_dp_branch_device(const struct dc_link *link);
63 
64 void dpcd_write_cable_id_to_dprx(struct dc_link *link);
65 
66 bool dp_should_enable_fec(const struct dc_link *link);
67 
68 bool dp_is_128b_132b_signal(struct pipe_ctx *pipe_ctx);
69 
70 /* Initialize output parameter lt_settings. */
71 void dp_decide_training_settings(
72 	struct dc_link *link,
73 	const struct link_resource *link_res,
74 	const struct dc_link_settings *link_setting,
75 	struct link_training_settings *lt_settings);
76 
77 bool link_decide_link_settings(
78 	struct dc_stream_state *stream,
79 	struct dc_link_settings *link_setting);
80 
81 bool edp_decide_link_settings(struct dc_link *link,
82 		struct dc_link_settings *link_setting, uint32_t req_bw);
83 
84 bool decide_edp_link_settings_with_dsc(struct dc_link *link,
85 		struct dc_link_settings *link_setting,
86 		uint32_t req_bw,
87 		enum dc_link_rate max_link_rate);
88 
89 enum dp_link_encoding mst_decide_link_encoding_format(const struct dc_link *link);
90 
91 void dpcd_set_source_specific_data(struct dc_link *link);
92 
93 /*query dpcd for version and mst cap addresses*/
94 bool read_is_mst_supported(struct dc_link *link);
95 
96 bool decide_fallback_link_setting(
97 		struct dc_link *link,
98 		struct dc_link_settings *max,
99 		struct dc_link_settings *cur,
100 		enum link_training_result training_result);
101 
102 bool dp_verify_link_cap_with_retries(
103 	struct dc_link *link,
104 	struct dc_link_settings *known_limit_link_setting,
105 	int attempts);
106 
107 uint32_t link_bw_kbps_from_raw_frl_link_rate_data(uint8_t bw);
108 
109 bool dp_overwrite_extended_receiver_cap(struct dc_link *link);
110 
111 #endif /* __DC_LINK_DP_CAPABILITY_H__ */
112