2 * Copyright 2012-14 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
31 #include "grph_object_defs.h"
33 enum dc_link_fec_state {
34 dc_link_fec_not_ready,
38 struct dc_link_status {
40 struct dpcd_caps *dpcd_caps;
43 /* DP MST stream allocation (payload bandwidth number) */
44 struct link_mst_stream_allocation {
46 const struct stream_encoder *stream_enc;
47 /* associate DRM payload table with DC stream encoder */
49 /* number of slots required for the DP stream in transport packet */
53 /* DP MST stream allocation table */
54 struct link_mst_stream_allocation_table {
55 /* number of DP video streams */
57 /* array of stream allocations */
58 struct link_mst_stream_allocation stream_allocations[MAX_CONTROLLER_NUM];
62 uint64_t edp_poweroff;
67 struct time_stamp time_stamp;
70 * A link contains one or more sinks and their connected status.
71 * The currently active signal type (HDMI, DP-SST, DP-MST) is also reported.
74 struct dc_sink *remote_sinks[MAX_SINKS_PER_LINK];
75 unsigned int sink_count;
76 struct dc_sink *local_sink;
77 unsigned int link_index;
78 enum dc_connection_type type;
79 enum signal_type connector_signal;
80 enum dc_irq_source irq_source_hpd;
81 enum dc_irq_source irq_source_hpd_rx;/* aka DP Short Pulse */
82 bool is_hpd_filter_disabled;
84 bool link_state_valid;
85 bool aux_access_disabled;
86 bool sync_lt_in_progress;
87 bool is_lttpr_mode_transparent;
89 /* caps is the same as reported_link_cap. link_traing use
90 * reported_link_cap. Will clean up. TODO
92 struct dc_link_settings reported_link_cap;
93 struct dc_link_settings verified_link_cap;
94 struct dc_link_settings cur_link_settings;
95 struct dc_lane_settings cur_lane_setting;
96 struct dc_link_settings preferred_link_setting;
97 struct dc_link_training_overrides preferred_training_settings;
98 struct dp_audio_test_data audio_test_data;
104 uint8_t link_enc_hw_inst;
106 bool test_pattern_enabled;
107 union compliance_test_state compliance_test_state;
111 struct ddc_service *ddc;
115 /* Private to DC core */
119 struct dc_context *ctx;
121 struct link_encoder *link_enc;
122 struct graphics_object_id link_id;
123 union ddi_channel_mapping ddi_channel_mapping;
124 struct connector_device_tag_info device_tag;
125 struct dpcd_caps dpcd_caps;
126 uint32_t dongle_max_pix_clk;
127 unsigned short chip_caps;
128 unsigned int dpcd_sink_count;
129 enum edp_revision edp_revision;
130 bool psr_feature_enabled;
131 bool psr_allow_active;
132 union dpcd_sink_ext_caps dpcd_sink_ext_caps;
134 /* MST record stream using this link */
136 bool dp_keep_receiver_powered;
138 bool dp_skip_reset_segment;
140 struct link_mst_stream_allocation_table mst_stream_alloc_table;
142 struct dc_link_status link_status;
144 struct link_trace link_trace;
145 struct gpio *hpd_gpio;
146 enum dc_link_fec_state fec_state;
149 const struct dc_link_status *dc_link_get_status(const struct dc_link *dc_link);
152 * dc_get_link_at_index() - Return an enumerated dc_link.
154 * dc_link order is constant and determined at
155 * boot time. They cannot be created or destroyed.
156 * Use dc_get_caps() to get number of links.
158 static inline struct dc_link *dc_get_link_at_index(struct dc *dc, uint32_t link_index)
160 return dc->links[link_index];
163 static inline struct dc_link *get_edp_link(const struct dc *dc)
167 // report any eDP links, even unconnected DDI's
168 for (i = 0; i < dc->link_count; i++) {
169 if (dc->links[i]->connector_signal == SIGNAL_TYPE_EDP)
175 /* Set backlight level of an embedded panel (eDP, LVDS).
176 * backlight_pwm_u16_16 is unsigned 32 bit with 16 bit integer
177 * and 16 bit fractional, where 1.0 is max backlight value.
179 bool dc_link_set_backlight_level(const struct dc_link *dc_link,
180 uint32_t backlight_pwm_u16_16,
181 uint32_t frame_ramp);
183 /* Set/get nits-based backlight level of an embedded panel (eDP, LVDS). */
184 bool dc_link_set_backlight_level_nits(struct dc_link *link,
186 uint32_t backlight_millinits,
187 uint32_t transition_time_in_ms);
189 bool dc_link_get_backlight_level_nits(struct dc_link *link,
190 uint32_t *backlight_millinits,
191 uint32_t *backlight_millinits_peak);
193 bool dc_link_backlight_enable_aux(struct dc_link *link, bool enable);
195 bool dc_link_read_default_bl_aux(struct dc_link *link, uint32_t *backlight_millinits);
196 bool dc_link_set_default_brightness_aux(struct dc_link *link);
198 int dc_link_get_backlight_level(const struct dc_link *dc_link);
200 bool dc_link_set_abm_disable(const struct dc_link *dc_link);
202 bool dc_link_set_psr_allow_active(struct dc_link *dc_link, bool enable, bool wait);
204 bool dc_link_get_psr_state(const struct dc_link *dc_link, uint32_t *psr_state);
206 bool dc_link_setup_psr(struct dc_link *dc_link,
207 const struct dc_stream_state *stream, struct psr_config *psr_config,
208 struct psr_context *psr_context);
210 /* Request DC to detect if there is a Panel connected.
211 * boot - If this call is during initial boot.
212 * Return false for any type of detection failure or MST detection
213 * true otherwise. True meaning further action is required (status update
214 * and OS notification).
216 enum dc_detect_reason {
222 bool dc_link_detect(struct dc_link *dc_link, enum dc_detect_reason reason);
223 bool dc_link_get_hpd_state(struct dc_link *dc_link);
224 enum dc_status dc_link_allocate_mst_payload(struct pipe_ctx *pipe_ctx);
225 enum dc_status dc_link_reallocate_mst_payload(struct dc_link *link);
227 /* Notify DC about DP RX Interrupt (aka Short Pulse Interrupt).
229 * true - Downstream port status changed. DM should call DC to do the
231 * false - no change in Downstream port status. No further action required
233 bool dc_link_handle_hpd_rx_irq(struct dc_link *dc_link,
234 union hpd_irq_data *hpd_irq_dpcd_data, bool *out_link_loss);
236 struct dc_sink_init_data;
238 struct dc_sink *dc_link_add_remote_sink(
239 struct dc_link *dc_link,
242 struct dc_sink_init_data *init_data);
244 void dc_link_remove_remote_sink(
245 struct dc_link *link,
246 struct dc_sink *sink);
248 /* Used by diagnostics for virtual link at the moment */
250 void dc_link_dp_set_drive_settings(
251 struct dc_link *link,
252 struct link_training_settings *lt_settings);
254 bool dc_link_dp_perform_link_training_skip_aux(
255 struct dc_link *link,
256 const struct dc_link_settings *link_setting);
258 enum link_training_result dc_link_dp_perform_link_training(
259 struct dc_link *link,
260 const struct dc_link_settings *link_setting,
261 bool skip_video_pattern);
263 bool dc_link_dp_sync_lt_begin(struct dc_link *link);
265 enum link_training_result dc_link_dp_sync_lt_attempt(
266 struct dc_link *link,
267 struct dc_link_settings *link_setting,
268 struct dc_link_training_overrides *lt_settings);
270 bool dc_link_dp_sync_lt_end(struct dc_link *link, bool link_down);
272 void dc_link_dp_enable_hpd(const struct dc_link *link);
274 void dc_link_dp_disable_hpd(const struct dc_link *link);
276 bool dc_link_dp_set_test_pattern(
277 struct dc_link *link,
278 enum dp_test_pattern test_pattern,
279 enum dp_test_pattern_color_space test_pattern_color_space,
280 const struct link_training_settings *p_link_settings,
281 const unsigned char *p_custom_pattern,
282 unsigned int cust_pattern_size);
284 void dc_link_enable_hpd_filter(struct dc_link *link, bool enable);
286 bool dc_link_is_dp_sink_present(struct dc_link *link);
288 bool dc_link_detect_sink(struct dc_link *link, enum dc_connection_type *type);
290 * DPCD access interfaces
293 void dc_link_set_drive_settings(struct dc *dc,
294 struct link_training_settings *lt_settings,
295 const struct dc_link *link);
296 void dc_link_perform_link_training(struct dc *dc,
297 struct dc_link_settings *link_setting,
298 bool skip_video_pattern);
299 void dc_link_set_preferred_link_settings(struct dc *dc,
300 struct dc_link_settings *link_setting,
301 struct dc_link *link);
302 void dc_link_set_preferred_training_settings(struct dc *dc,
303 struct dc_link_settings *link_setting,
304 struct dc_link_training_overrides *lt_overrides,
305 struct dc_link *link,
306 bool skip_immediate_retrain);
307 void dc_link_enable_hpd(const struct dc_link *link);
308 void dc_link_disable_hpd(const struct dc_link *link);
309 void dc_link_set_test_pattern(struct dc_link *link,
310 enum dp_test_pattern test_pattern,
311 enum dp_test_pattern_color_space test_pattern_color_space,
312 const struct link_training_settings *p_link_settings,
313 const unsigned char *p_custom_pattern,
314 unsigned int cust_pattern_size);
315 uint32_t dc_link_bandwidth_kbps(
316 const struct dc_link *link,
317 const struct dc_link_settings *link_setting);
319 const struct dc_link_settings *dc_link_get_link_cap(
320 const struct dc_link *link);
322 void dc_link_overwrite_extended_receiver_cap(
323 struct dc_link *link);
328 struct i2c_command *cmd);
330 bool dc_submit_i2c_oem(
332 struct i2c_command *cmd);
334 uint32_t dc_bandwidth_in_kbps_from_timing(
335 const struct dc_crtc_timing *timing);
337 bool dc_link_is_fec_supported(const struct dc_link *link);
339 #endif /* DC_LINK_H_ */