Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.1-rc5 553 lines 18 kB view raw
1/* 2 * Copyright 2012-14 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#include "dc.h" 30#include "dc_types.h" 31#include "grph_object_defs.h" 32 33struct link_resource; 34 35enum dc_link_fec_state { 36 dc_link_fec_not_ready, 37 dc_link_fec_ready, 38 dc_link_fec_enabled 39}; 40 41struct dc_link_status { 42 bool link_active; 43 struct dpcd_caps *dpcd_caps; 44}; 45 46struct dprx_states { 47 bool cable_id_written; 48}; 49 50/* DP MST stream allocation (payload bandwidth number) */ 51struct link_mst_stream_allocation { 52 /* DIG front */ 53 const struct stream_encoder *stream_enc; 54 /* HPO DP Stream Encoder */ 55 const struct hpo_dp_stream_encoder *hpo_dp_stream_enc; 56 /* associate DRM payload table with DC stream encoder */ 57 uint8_t vcp_id; 58 /* number of slots required for the DP stream in transport packet */ 59 uint8_t slot_count; 60}; 61 62/* DP MST stream allocation table */ 63struct link_mst_stream_allocation_table { 64 /* number of DP video streams */ 65 int stream_count; 66 /* array of stream allocations */ 67 struct link_mst_stream_allocation stream_allocations[MAX_CONTROLLER_NUM]; 68}; 69 70struct edp_trace_power_timestamps { 71 uint64_t poweroff; 72 uint64_t poweron; 73}; 74 75struct dp_trace_lt_counts { 76 unsigned int total; 77 unsigned int fail; 78}; 79 80struct dp_trace_lt { 81 struct dp_trace_lt_counts counts; 82 struct dp_trace_timestamps { 83 unsigned long long start; 84 unsigned long long end; 85 } timestamps; 86 enum link_training_result result; 87 bool is_logged; 88}; 89 90struct dp_trace { 91 struct dp_trace_lt detect_lt_trace; 92 struct dp_trace_lt commit_lt_trace; 93 unsigned int link_loss_count; 94 bool is_initialized; 95 struct edp_trace_power_timestamps edp_trace_power_timestamps; 96}; 97 98/* PSR feature flags */ 99struct psr_settings { 100 bool psr_feature_enabled; // PSR is supported by sink 101 bool psr_allow_active; // PSR is currently active 102 enum dc_psr_version psr_version; // Internal PSR version, determined based on DPCD 103 bool psr_vtotal_control_support; // Vtotal control is supported by sink 104 105 /* These parameters are calculated in Driver, 106 * based on display timing and Sink capabilities. 107 * If VBLANK region is too small and Sink takes a long time 108 * to set up RFB, it may take an extra frame to enter PSR state. 109 */ 110 bool psr_frame_capture_indication_req; 111 unsigned int psr_sdp_transmit_line_num_deadline; 112 uint8_t force_ffu_mode; 113 unsigned int psr_power_opt; 114}; 115 116/* To split out "global" and "per-panel" config settings. 117 * Add a struct dc_panel_config under dc_link 118 */ 119struct dc_panel_config { 120 // extra panel power sequence parameters 121 struct pps { 122 unsigned int extra_t3_ms; 123 unsigned int extra_t7_ms; 124 unsigned int extra_delay_backlight_off; 125 unsigned int extra_post_t7_ms; 126 unsigned int extra_pre_t11_ms; 127 unsigned int extra_t12_ms; 128 unsigned int extra_post_OUI_ms; 129 } pps; 130 // ABM 131 struct varib { 132 unsigned int varibright_feature_enable; 133 unsigned int def_varibright_level; 134 unsigned int abm_config_setting; 135 } varib; 136 // edp DSC 137 struct dsc { 138 bool disable_dsc_edp; 139 unsigned int force_dsc_edp_policy; 140 } dsc; 141 /* eDP ILR */ 142 struct ilr { 143 bool optimize_edp_link_rate; /* eDP ILR */ 144 } ilr; 145}; 146/* 147 * A link contains one or more sinks and their connected status. 148 * The currently active signal type (HDMI, DP-SST, DP-MST) is also reported. 149 */ 150struct dc_link { 151 struct dc_sink *remote_sinks[MAX_SINKS_PER_LINK]; 152 unsigned int sink_count; 153 struct dc_sink *local_sink; 154 unsigned int link_index; 155 enum dc_connection_type type; 156 enum signal_type connector_signal; 157 enum dc_irq_source irq_source_hpd; 158 enum dc_irq_source irq_source_hpd_rx;/* aka DP Short Pulse */ 159 bool is_hpd_filter_disabled; 160 bool dp_ss_off; 161 bool link_state_valid; 162 bool aux_access_disabled; 163 bool sync_lt_in_progress; 164 bool is_internal_display; 165 166 /* TODO: Rename. Flag an endpoint as having a programmable mapping to a 167 * DIG encoder. */ 168 bool is_dig_mapping_flexible; 169 bool hpd_status; /* HPD status of link without physical HPD pin. */ 170 bool is_hpd_pending; /* Indicates a new received hpd */ 171 172 bool edp_sink_present; 173 174 struct dp_trace dp_trace; 175 176 /* caps is the same as reported_link_cap. link_traing use 177 * reported_link_cap. Will clean up. TODO 178 */ 179 struct dc_link_settings reported_link_cap; 180 struct dc_link_settings verified_link_cap; 181 struct dc_link_settings cur_link_settings; 182 struct dc_lane_settings cur_lane_setting[LANE_COUNT_DP_MAX]; 183 struct dc_link_settings preferred_link_setting; 184 /* preferred_training_settings are override values that 185 * come from DM. DM is responsible for the memory 186 * management of the override pointers. 187 */ 188 struct dc_link_training_overrides preferred_training_settings; 189 struct dp_audio_test_data audio_test_data; 190 191 uint8_t ddc_hw_inst; 192 193 uint8_t hpd_src; 194 195 uint8_t link_enc_hw_inst; 196 /* DIG link encoder ID. Used as index in link encoder resource pool. 197 * For links with fixed mapping to DIG, this is not changed after dc_link 198 * object creation. 199 */ 200 enum engine_id eng_id; 201 202 bool test_pattern_enabled; 203 union compliance_test_state compliance_test_state; 204 205 void *priv; 206 207 struct ddc_service *ddc; 208 209 bool aux_mode; 210 211 /* Private to DC core */ 212 213 const struct dc *dc; 214 215 struct dc_context *ctx; 216 217 struct panel_cntl *panel_cntl; 218 struct link_encoder *link_enc; 219 struct graphics_object_id link_id; 220 /* Endpoint type distinguishes display endpoints which do not have entries 221 * in the BIOS connector table from those that do. Helps when tracking link 222 * encoder to display endpoint assignments. 223 */ 224 enum display_endpoint_type ep_type; 225 union ddi_channel_mapping ddi_channel_mapping; 226 struct connector_device_tag_info device_tag; 227 struct dpcd_caps dpcd_caps; 228 uint32_t dongle_max_pix_clk; 229 unsigned short chip_caps; 230 unsigned int dpcd_sink_count; 231#if defined(CONFIG_DRM_AMD_DC_HDCP) 232 struct hdcp_caps hdcp_caps; 233#endif 234 enum edp_revision edp_revision; 235 union dpcd_sink_ext_caps dpcd_sink_ext_caps; 236 237 struct psr_settings psr_settings; 238 239 /* Drive settings read from integrated info table */ 240 struct dc_lane_settings bios_forced_drive_settings; 241 242 /* Vendor specific LTTPR workaround variables */ 243 uint8_t vendor_specific_lttpr_link_rate_wa; 244 bool apply_vendor_specific_lttpr_link_rate_wa; 245 246 /* MST record stream using this link */ 247 struct link_flags { 248 bool dp_keep_receiver_powered; 249 bool dp_skip_DID2; 250 bool dp_skip_reset_segment; 251 bool dp_mot_reset_segment; 252 /* Some USB4 docks do not handle turning off MST DSC once it has been enabled. */ 253 bool dpia_mst_dsc_always_on; 254 /* Forced DPIA into TBT3 compatibility mode. */ 255 bool dpia_forced_tbt3_mode; 256 bool dongle_mode_timing_override; 257 } wa_flags; 258 struct link_mst_stream_allocation_table mst_stream_alloc_table; 259 260 struct dc_link_status link_status; 261 struct dprx_states dprx_states; 262 263 struct gpio *hpd_gpio; 264 enum dc_link_fec_state fec_state; 265 struct dc_panel_config panel_config; 266 struct phy_state phy_state; 267}; 268 269const struct dc_link_status *dc_link_get_status(const struct dc_link *dc_link); 270 271/** 272 * dc_get_link_at_index() - Return an enumerated dc_link. 273 * 274 * dc_link order is constant and determined at 275 * boot time. They cannot be created or destroyed. 276 * Use dc_get_caps() to get number of links. 277 */ 278static inline struct dc_link *dc_get_link_at_index(struct dc *dc, uint32_t link_index) 279{ 280 return dc->links[link_index]; 281} 282 283static inline void get_edp_links(const struct dc *dc, 284 struct dc_link **edp_links, 285 int *edp_num) 286{ 287 int i; 288 289 *edp_num = 0; 290 for (i = 0; i < dc->link_count; i++) { 291 // report any eDP links, even unconnected DDI's 292 if (!dc->links[i]) 293 continue; 294 if (dc->links[i]->connector_signal == SIGNAL_TYPE_EDP) { 295 edp_links[*edp_num] = dc->links[i]; 296 if (++(*edp_num) == MAX_NUM_EDP) 297 return; 298 } 299 } 300} 301 302static inline bool dc_get_edp_link_panel_inst(const struct dc *dc, 303 const struct dc_link *link, 304 unsigned int *inst_out) 305{ 306 struct dc_link *edp_links[MAX_NUM_EDP]; 307 int edp_num; 308 309 if (link->connector_signal != SIGNAL_TYPE_EDP) 310 return false; 311 get_edp_links(dc, edp_links, &edp_num); 312 if ((edp_num > 1) && (link->link_index > edp_links[0]->link_index)) 313 *inst_out = 1; 314 else 315 *inst_out = 0; 316 return true; 317} 318 319/* Set backlight level of an embedded panel (eDP, LVDS). 320 * backlight_pwm_u16_16 is unsigned 32 bit with 16 bit integer 321 * and 16 bit fractional, where 1.0 is max backlight value. 322 */ 323bool dc_link_set_backlight_level(const struct dc_link *dc_link, 324 uint32_t backlight_pwm_u16_16, 325 uint32_t frame_ramp); 326 327/* Set/get nits-based backlight level of an embedded panel (eDP, LVDS). */ 328bool dc_link_set_backlight_level_nits(struct dc_link *link, 329 bool isHDR, 330 uint32_t backlight_millinits, 331 uint32_t transition_time_in_ms); 332 333bool dc_link_get_backlight_level_nits(struct dc_link *link, 334 uint32_t *backlight_millinits, 335 uint32_t *backlight_millinits_peak); 336 337bool dc_link_backlight_enable_aux(struct dc_link *link, bool enable); 338 339bool dc_link_read_default_bl_aux(struct dc_link *link, uint32_t *backlight_millinits); 340bool dc_link_set_default_brightness_aux(struct dc_link *link); 341 342int dc_link_get_backlight_level(const struct dc_link *dc_link); 343 344int dc_link_get_target_backlight_pwm(const struct dc_link *link); 345 346bool dc_link_set_psr_allow_active(struct dc_link *dc_link, const bool *enable, 347 bool wait, bool force_static, const unsigned int *power_opts); 348 349bool dc_link_get_psr_state(const struct dc_link *dc_link, enum dc_psr_state *state); 350 351bool dc_link_setup_psr(struct dc_link *dc_link, 352 const struct dc_stream_state *stream, struct psr_config *psr_config, 353 struct psr_context *psr_context); 354 355bool dc_power_alpm_dpcd_enable(struct dc_link *link, bool enable); 356 357void dc_link_get_psr_residency(const struct dc_link *link, uint32_t *residency); 358 359void dc_link_blank_all_dp_displays(struct dc *dc); 360void dc_link_blank_all_edp_displays(struct dc *dc); 361 362void dc_link_blank_dp_stream(struct dc_link *link, bool hw_init); 363bool dc_link_set_sink_vtotal_in_psr_active(const struct dc_link *link, 364 uint16_t psr_vtotal_idle, uint16_t psr_vtotal_su); 365 366/* Request DC to detect if there is a Panel connected. 367 * boot - If this call is during initial boot. 368 * Return false for any type of detection failure or MST detection 369 * true otherwise. True meaning further action is required (status update 370 * and OS notification). 371 */ 372enum dc_detect_reason { 373 DETECT_REASON_BOOT, 374 DETECT_REASON_RESUMEFROMS3S4, 375 DETECT_REASON_HPD, 376 DETECT_REASON_HPDRX, 377 DETECT_REASON_FALLBACK, 378 DETECT_REASON_RETRAIN, 379 DETECT_REASON_TDR, 380}; 381 382bool dc_link_detect(struct dc_link *dc_link, enum dc_detect_reason reason); 383bool dc_link_get_hpd_state(struct dc_link *dc_link); 384enum dc_status dc_link_allocate_mst_payload(struct pipe_ctx *pipe_ctx); 385enum dc_status dc_link_reduce_mst_payload(struct pipe_ctx *pipe_ctx, uint32_t req_pbn); 386enum dc_status dc_link_increase_mst_payload(struct pipe_ctx *pipe_ctx, uint32_t req_pbn); 387 388/* Notify DC about DP RX Interrupt (aka Short Pulse Interrupt). 389 * Return: 390 * true - Downstream port status changed. DM should call DC to do the 391 * detection. 392 * false - no change in Downstream port status. No further action required 393 * from DM. */ 394bool dc_link_handle_hpd_rx_irq(struct dc_link *dc_link, 395 union hpd_irq_data *hpd_irq_dpcd_data, bool *out_link_loss, 396 bool defer_handling, bool *has_left_work); 397 398/* 399 * On eDP links this function call will stall until T12 has elapsed. 400 * If the panel is not in power off state, this function will return 401 * immediately. 402 */ 403bool dc_link_wait_for_t12(struct dc_link *link); 404 405void dc_link_dp_handle_automated_test(struct dc_link *link); 406void dc_link_dp_handle_link_loss(struct dc_link *link); 407bool dc_link_dp_allow_hpd_rx_irq(const struct dc_link *link); 408 409struct dc_sink_init_data; 410 411struct dc_sink *dc_link_add_remote_sink( 412 struct dc_link *dc_link, 413 const uint8_t *edid, 414 int len, 415 struct dc_sink_init_data *init_data); 416 417void dc_link_remove_remote_sink( 418 struct dc_link *link, 419 struct dc_sink *sink); 420 421/* Used by diagnostics for virtual link at the moment */ 422 423void dc_link_dp_set_drive_settings( 424 struct dc_link *link, 425 const struct link_resource *link_res, 426 struct link_training_settings *lt_settings); 427 428bool dc_link_dp_perform_link_training_skip_aux( 429 struct dc_link *link, 430 const struct link_resource *link_res, 431 const struct dc_link_settings *link_setting); 432 433enum link_training_result dc_link_dp_perform_link_training( 434 struct dc_link *link, 435 const struct link_resource *link_res, 436 const struct dc_link_settings *link_settings, 437 bool skip_video_pattern); 438 439bool dc_link_dp_sync_lt_begin(struct dc_link *link); 440 441enum link_training_result dc_link_dp_sync_lt_attempt( 442 struct dc_link *link, 443 const struct link_resource *link_res, 444 struct dc_link_settings *link_setting, 445 struct dc_link_training_overrides *lt_settings); 446 447bool dc_link_dp_sync_lt_end(struct dc_link *link, bool link_down); 448 449void dc_link_dp_enable_hpd(const struct dc_link *link); 450 451void dc_link_dp_disable_hpd(const struct dc_link *link); 452 453bool dc_link_dp_set_test_pattern( 454 struct dc_link *link, 455 enum dp_test_pattern test_pattern, 456 enum dp_test_pattern_color_space test_pattern_color_space, 457 const struct link_training_settings *p_link_settings, 458 const unsigned char *p_custom_pattern, 459 unsigned int cust_pattern_size); 460 461bool dc_link_dp_get_max_link_enc_cap(const struct dc_link *link, struct dc_link_settings *max_link_enc_cap); 462 463void dc_link_enable_hpd_filter(struct dc_link *link, bool enable); 464 465bool dc_link_is_dp_sink_present(struct dc_link *link); 466 467bool dc_link_detect_sink(struct dc_link *link, enum dc_connection_type *type); 468/* 469 * DPCD access interfaces 470 */ 471 472#ifdef CONFIG_DRM_AMD_DC_HDCP 473bool dc_link_is_hdcp14(struct dc_link *link, enum signal_type signal); 474bool dc_link_is_hdcp22(struct dc_link *link, enum signal_type signal); 475#endif 476void dc_link_set_drive_settings(struct dc *dc, 477 struct link_training_settings *lt_settings, 478 const struct dc_link *link); 479void dc_link_set_preferred_link_settings(struct dc *dc, 480 struct dc_link_settings *link_setting, 481 struct dc_link *link); 482void dc_link_set_preferred_training_settings(struct dc *dc, 483 struct dc_link_settings *link_setting, 484 struct dc_link_training_overrides *lt_overrides, 485 struct dc_link *link, 486 bool skip_immediate_retrain); 487void dc_link_enable_hpd(const struct dc_link *link); 488void dc_link_disable_hpd(const struct dc_link *link); 489void dc_link_set_test_pattern(struct dc_link *link, 490 enum dp_test_pattern test_pattern, 491 enum dp_test_pattern_color_space test_pattern_color_space, 492 const struct link_training_settings *p_link_settings, 493 const unsigned char *p_custom_pattern, 494 unsigned int cust_pattern_size); 495uint32_t dc_link_bandwidth_kbps( 496 const struct dc_link *link, 497 const struct dc_link_settings *link_setting); 498 499const struct dc_link_settings *dc_link_get_link_cap( 500 const struct dc_link *link); 501 502void dc_link_overwrite_extended_receiver_cap( 503 struct dc_link *link); 504 505bool dc_is_oem_i2c_device_present( 506 struct dc *dc, 507 size_t slave_address 508); 509 510bool dc_submit_i2c( 511 struct dc *dc, 512 uint32_t link_index, 513 struct i2c_command *cmd); 514 515bool dc_submit_i2c_oem( 516 struct dc *dc, 517 struct i2c_command *cmd); 518 519uint32_t dc_bandwidth_in_kbps_from_timing( 520 const struct dc_crtc_timing *timing); 521 522bool dc_link_is_fec_supported(const struct dc_link *link); 523bool dc_link_should_enable_fec(const struct dc_link *link); 524 525uint32_t dc_link_bw_kbps_from_raw_frl_link_rate_data(uint8_t bw); 526enum dp_link_encoding dc_link_dp_mst_decide_link_encoding_format(const struct dc_link *link); 527 528void dc_link_get_cur_link_res(const struct dc_link *link, 529 struct link_resource *link_res); 530/* take a snapshot of current link resource allocation state */ 531void dc_get_cur_link_res_map(const struct dc *dc, uint32_t *map); 532/* restore link resource allocation state from a snapshot */ 533void dc_restore_link_res_map(const struct dc *dc, uint32_t *map); 534void dc_link_clear_dprx_states(struct dc_link *link); 535struct gpio *get_hpd_gpio(struct dc_bios *dcb, 536 struct graphics_object_id link_id, 537 struct gpio_service *gpio_service); 538void dp_trace_reset(struct dc_link *link); 539bool dc_dp_trace_is_initialized(struct dc_link *link); 540unsigned long long dc_dp_trace_get_lt_end_timestamp(struct dc_link *link, 541 bool in_detection); 542void dc_dp_trace_set_is_logged_flag(struct dc_link *link, 543 bool in_detection, 544 bool is_logged); 545bool dc_dp_trace_is_logged(struct dc_link *link, 546 bool in_detection); 547struct dp_trace_lt_counts *dc_dp_trace_get_lt_counts(struct dc_link *link, 548 bool in_detection); 549unsigned int dc_dp_trace_get_link_loss_count(struct dc_link *link); 550 551/* Destruct the mst topology of the link and reset the allocated payload table */ 552bool reset_cur_dp_mst_topology(struct dc_link *link); 553#endif /* DC_LINK_H_ */