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 link_init_data { 44 const struct dc *dc; 45 struct dc_context *ctx; /* TODO: remove 'dal' when DC is complete. */ 46 uint32_t connector_index; /* this will be mapped to the HPD pins */ 47 uint32_t link_index; /* this is mapped to DAL display_index 48 TODO: remove it when DC is complete. */ 49 bool is_dpia_link; 50 }; 51 52 struct dc_link *link_create(const struct link_init_data *init_params); 53 void link_destroy(struct dc_link **link); 54 55 // TODO - convert any function declarations below to function pointers 56 struct gpio *link_get_hpd_gpio(struct dc_bios *dcb, 57 struct graphics_object_id link_id, 58 struct gpio_service *gpio_service); 59 60 struct ddc_service_init_data { 61 struct graphics_object_id id; 62 struct dc_context *ctx; 63 struct dc_link *link; 64 bool is_dpia_link; 65 }; 66 67 struct ddc_service *link_create_ddc_service( 68 struct ddc_service_init_data *ddc_init_data); 69 70 void link_destroy_ddc_service(struct ddc_service **ddc); 71 72 bool link_is_in_aux_transaction_mode(struct ddc_service *ddc); 73 74 bool link_query_ddc_data( 75 struct ddc_service *ddc, 76 uint32_t address, 77 uint8_t *write_buf, 78 uint32_t write_size, 79 uint8_t *read_buf, 80 uint32_t read_size); 81 82 83 /* Attempt to submit an aux payload, retrying on timeouts, defers, and busy 84 * states as outlined in the DP spec. Returns true if the request was 85 * successful. 86 * 87 * NOTE: The function requires explicit mutex on DM side in order to prevent 88 * potential race condition. DC components should call the dpcd read/write 89 * function in dm_helpers in order to access dpcd safely 90 */ 91 bool link_aux_transfer_with_retries_no_mutex(struct ddc_service *ddc, 92 struct aux_payload *payload); 93 94 uint32_t link_get_aux_defer_delay(struct ddc_service *ddc); 95 96 bool link_is_dp_128b_132b_signal(struct pipe_ctx *pipe_ctx); 97 98 enum dp_link_encoding link_dp_get_encoding_format( 99 const struct dc_link_settings *link_settings); 100 101 bool link_decide_link_settings( 102 struct dc_stream_state *stream, 103 struct dc_link_settings *link_setting); 104 105 void link_dp_trace_set_edp_power_timestamp(struct dc_link *link, 106 bool power_up); 107 uint64_t link_dp_trace_get_edp_poweron_timestamp(struct dc_link *link); 108 uint64_t link_dp_trace_get_edp_poweroff_timestamp(struct dc_link *link); 109 110 bool link_is_edp_ilr_optimization_required(struct dc_link *link, 111 struct dc_crtc_timing *crtc_timing); 112 113 bool link_backlight_enable_aux(struct dc_link *link, bool enable); 114 void link_edp_add_delay_for_T9(struct dc_link *link); 115 bool link_edp_receiver_ready_T9(struct dc_link *link); 116 bool link_edp_receiver_ready_T7(struct dc_link *link); 117 bool link_power_alpm_dpcd_enable(struct dc_link *link, bool enable); 118 bool link_set_sink_vtotal_in_psr_active(const struct dc_link *link, 119 uint16_t psr_vtotal_idle, uint16_t psr_vtotal_su); 120 void link_get_psr_residency(const struct dc_link *link, uint32_t *residency); 121 enum dc_status link_increase_mst_payload(struct pipe_ctx *pipe_ctx, uint32_t req_pbn); 122 enum dc_status link_reduce_mst_payload(struct pipe_ctx *pipe_ctx, uint32_t req_pbn); 123 void link_blank_all_dp_displays(struct dc *dc); 124 void link_blank_all_edp_displays(struct dc *dc); 125 void link_blank_dp_stream(struct dc_link *link, bool hw_init); 126 void link_resume(struct dc_link *link); 127 void link_set_dpms_on( 128 struct dc_state *state, 129 struct pipe_ctx *pipe_ctx); 130 void link_set_dpms_off(struct pipe_ctx *pipe_ctx); 131 void link_dp_source_sequence_trace(struct dc_link *link, uint8_t dp_test_mode); 132 void link_set_dsc_on_stream(struct pipe_ctx *pipe_ctx, bool enable); 133 bool link_set_dsc_enable(struct pipe_ctx *pipe_ctx, bool enable); 134 bool link_update_dsc_config(struct pipe_ctx *pipe_ctx); 135 enum dc_status link_validate_mode_timing( 136 const struct dc_stream_state *stream, 137 struct dc_link *link, 138 const struct dc_crtc_timing *timing); 139 bool link_detect(struct dc_link *link, enum dc_detect_reason reason); 140 bool link_detect_connection_type(struct dc_link *link, 141 enum dc_connection_type *type); 142 const struct dc_link_status *link_get_status(const struct dc_link *link); 143 #ifdef CONFIG_DRM_AMD_DC_HDCP 144 /* return true if the connected receiver supports the hdcp version */ 145 bool link_is_hdcp14(struct dc_link *link, enum signal_type signal); 146 bool link_is_hdcp22(struct dc_link *link, enum signal_type signal); 147 #endif 148 void link_clear_dprx_states(struct dc_link *link); 149 bool link_reset_cur_dp_mst_topology(struct dc_link *link); 150 uint32_t dp_link_bandwidth_kbps( 151 const struct dc_link *link, 152 const struct dc_link_settings *link_settings); 153 uint32_t link_timing_bandwidth_kbps(const struct dc_crtc_timing *timing); 154 void link_get_cur_res_map(const struct dc *dc, uint32_t *map); 155 void link_restore_res_map(const struct dc *dc, uint32_t *map); 156 157 #endif /* __DC_LINK_HPD_H__ */ 158