xref: /openbmc/linux/drivers/gpu/drm/amd/display/dc/inc/link.h (revision a90fa0ad)
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_H__
27 #define __DC_LINK_H__
28 
29 /* FILE POLICY AND INTENDED USAGE:
30  *
31  * This header declares link functions exposed to dc. All functions must have
32  * "link_" as prefix. For example link_run_my_function. This header is strictly
33  * private in dc and should never be included in other header files. dc
34  * components should include this header in their .c files in order to access
35  * functions in link folder. This file should never include any header files in
36  * link folder. If there is a need to expose a function declared in one of
37  * header files in side link folder, you need to move the function declaration
38  * into this file and prefix it with "link_".
39  */
40 #include "core_types.h"
41 #include "dc_link.h"
42 
43 struct gpio *link_get_hpd_gpio(struct dc_bios *dcb,
44 		struct graphics_object_id link_id,
45 		struct gpio_service *gpio_service);
46 
47 struct ddc_service_init_data {
48 	struct graphics_object_id id;
49 	struct dc_context *ctx;
50 	struct dc_link *link;
51 	bool is_dpia_link;
52 };
53 
54 struct ddc_service *link_create_ddc_service(
55 		struct ddc_service_init_data *ddc_init_data);
56 
57 void link_destroy_ddc_service(struct ddc_service **ddc);
58 
59 bool link_is_in_aux_transaction_mode(struct ddc_service *ddc);
60 
61 bool link_query_ddc_data(
62 		struct ddc_service *ddc,
63 		uint32_t address,
64 		uint8_t *write_buf,
65 		uint32_t write_size,
66 		uint8_t *read_buf,
67 		uint32_t read_size);
68 
69 
70 /* Attempt to submit an aux payload, retrying on timeouts, defers, and busy
71  * states as outlined in the DP spec.  Returns true if the request was
72  * successful.
73  *
74  * NOTE: The function requires explicit mutex on DM side in order to prevent
75  * potential race condition. DC components should call the dpcd read/write
76  * function in dm_helpers in order to access dpcd safely
77  */
78 bool link_aux_transfer_with_retries_no_mutex(struct ddc_service *ddc,
79 		struct aux_payload *payload);
80 
81 uint32_t link_get_aux_defer_delay(struct ddc_service *ddc);
82 
83 bool link_is_dp_128b_132b_signal(struct pipe_ctx *pipe_ctx);
84 
85 enum dp_link_encoding link_dp_get_encoding_format(
86 		const struct dc_link_settings *link_settings);
87 
88 bool link_decide_link_settings(
89 	struct dc_stream_state *stream,
90 	struct dc_link_settings *link_setting);
91 
92 void link_dp_trace_set_edp_power_timestamp(struct dc_link *link,
93 		bool power_up);
94 uint64_t link_dp_trace_get_edp_poweron_timestamp(struct dc_link *link);
95 uint64_t link_dp_trace_get_edp_poweroff_timestamp(struct dc_link *link);
96 
97 bool link_is_edp_ilr_optimization_required(struct dc_link *link,
98 		struct dc_crtc_timing *crtc_timing);
99 
100 bool link_backlight_enable_aux(struct dc_link *link, bool enable);
101 void link_edp_add_delay_for_T9(struct dc_link *link);
102 bool link_edp_receiver_ready_T9(struct dc_link *link);
103 bool link_edp_receiver_ready_T7(struct dc_link *link);
104 bool link_power_alpm_dpcd_enable(struct dc_link *link, bool enable);
105 bool link_set_sink_vtotal_in_psr_active(const struct dc_link *link,
106 		uint16_t psr_vtotal_idle, uint16_t psr_vtotal_su);
107 void link_get_psr_residency(const struct dc_link *link, uint32_t *residency);
108 
109 #endif /* __DC_LINK_HPD_H__ */
110