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 
38 enum dc_status dp_retrieve_lttpr_cap(struct dc_link *link);
39 
40 /* Convert PHY repeater count read from DPCD uint8_t. */
41 uint8_t dp_parse_lttpr_repeater_count(uint8_t lttpr_repeater_count);
42 
43 bool dp_is_lttpr_present(struct dc_link *link);
44 
45 bool is_dp_active_dongle(const struct dc_link *link);
46 
47 bool is_dp_branch_device(const struct dc_link *link);
48 
49 void dpcd_write_cable_id_to_dprx(struct dc_link *link);
50 
51 /* Initialize output parameter lt_settings. */
52 void dp_decide_training_settings(
53 	struct dc_link *link,
54 	const struct dc_link_settings *link_setting,
55 	struct link_training_settings *lt_settings);
56 
57 
58 bool decide_edp_link_settings_with_dsc(struct dc_link *link,
59 		struct dc_link_settings *link_setting,
60 		uint32_t req_bw,
61 		enum dc_link_rate max_link_rate);
62 
63 void dpcd_set_source_specific_data(struct dc_link *link);
64 
65 /*query dpcd for version and mst cap addresses*/
66 bool read_is_mst_supported(struct dc_link *link);
67 
68 bool decide_fallback_link_setting(
69 		struct dc_link *link,
70 		struct dc_link_settings *max,
71 		struct dc_link_settings *cur,
72 		enum link_training_result training_result);
73 
74 bool dp_verify_link_cap_with_retries(
75 	struct dc_link *link,
76 	struct dc_link_settings *known_limit_link_setting,
77 	int attempts);
78 
79 #endif /* __DC_LINK_DP_CAPABILITY_H__ */
80