| .. | .. |
|---|
| 26 | 26 | #ifndef DC_LINK_H_ |
|---|
| 27 | 27 | #define DC_LINK_H_ |
|---|
| 28 | 28 | |
|---|
| 29 | +#include "dc.h" |
|---|
| 29 | 30 | #include "dc_types.h" |
|---|
| 30 | 31 | #include "grph_object_defs.h" |
|---|
| 31 | 32 | |
|---|
| 33 | +enum dc_link_fec_state { |
|---|
| 34 | + dc_link_fec_not_ready, |
|---|
| 35 | + dc_link_fec_ready, |
|---|
| 36 | + dc_link_fec_enabled |
|---|
| 37 | +}; |
|---|
| 32 | 38 | struct dc_link_status { |
|---|
| 39 | + bool link_active; |
|---|
| 33 | 40 | struct dpcd_caps *dpcd_caps; |
|---|
| 34 | 41 | }; |
|---|
| 35 | 42 | |
|---|
| .. | .. |
|---|
| 59 | 66 | struct link_trace { |
|---|
| 60 | 67 | struct time_stamp time_stamp; |
|---|
| 61 | 68 | }; |
|---|
| 69 | + |
|---|
| 70 | +/* PSR feature flags */ |
|---|
| 71 | +struct psr_settings { |
|---|
| 72 | + bool psr_feature_enabled; // PSR is supported by sink |
|---|
| 73 | + bool psr_allow_active; // PSR is currently active |
|---|
| 74 | + enum dc_psr_version psr_version; // Internal PSR version, determined based on DPCD |
|---|
| 75 | + |
|---|
| 76 | + /* These parameters are calculated in Driver, |
|---|
| 77 | + * based on display timing and Sink capabilities. |
|---|
| 78 | + * If VBLANK region is too small and Sink takes a long time |
|---|
| 79 | + * to set up RFB, it may take an extra frame to enter PSR state. |
|---|
| 80 | + */ |
|---|
| 81 | + bool psr_frame_capture_indication_req; |
|---|
| 82 | + unsigned int psr_sdp_transmit_line_num_deadline; |
|---|
| 83 | +}; |
|---|
| 84 | + |
|---|
| 62 | 85 | /* |
|---|
| 63 | 86 | * A link contains one or more sinks and their connected status. |
|---|
| 64 | 87 | * The currently active signal type (HDMI, DP-SST, DP-MST) is also reported. |
|---|
| .. | .. |
|---|
| 74 | 97 | enum dc_irq_source irq_source_hpd_rx;/* aka DP Short Pulse */ |
|---|
| 75 | 98 | bool is_hpd_filter_disabled; |
|---|
| 76 | 99 | bool dp_ss_off; |
|---|
| 100 | + bool link_state_valid; |
|---|
| 101 | + bool aux_access_disabled; |
|---|
| 102 | + bool sync_lt_in_progress; |
|---|
| 103 | + bool lttpr_non_transparent_mode; |
|---|
| 77 | 104 | |
|---|
| 78 | 105 | /* caps is the same as reported_link_cap. link_traing use |
|---|
| 79 | 106 | * reported_link_cap. Will clean up. TODO |
|---|
| .. | .. |
|---|
| 83 | 110 | struct dc_link_settings cur_link_settings; |
|---|
| 84 | 111 | struct dc_lane_settings cur_lane_setting; |
|---|
| 85 | 112 | struct dc_link_settings preferred_link_setting; |
|---|
| 113 | + struct dc_link_training_overrides preferred_training_settings; |
|---|
| 114 | + struct dp_audio_test_data audio_test_data; |
|---|
| 86 | 115 | |
|---|
| 87 | 116 | uint8_t ddc_hw_inst; |
|---|
| 88 | 117 | |
|---|
| .. | .. |
|---|
| 105 | 134 | |
|---|
| 106 | 135 | struct dc_context *ctx; |
|---|
| 107 | 136 | |
|---|
| 137 | + struct panel_cntl *panel_cntl; |
|---|
| 108 | 138 | struct link_encoder *link_enc; |
|---|
| 109 | 139 | struct graphics_object_id link_id; |
|---|
| 110 | 140 | union ddi_channel_mapping ddi_channel_mapping; |
|---|
| 111 | 141 | struct connector_device_tag_info device_tag; |
|---|
| 112 | 142 | struct dpcd_caps dpcd_caps; |
|---|
| 143 | + uint32_t dongle_max_pix_clk; |
|---|
| 113 | 144 | unsigned short chip_caps; |
|---|
| 114 | 145 | unsigned int dpcd_sink_count; |
|---|
| 146 | +#if defined(CONFIG_DRM_AMD_DC_HDCP) |
|---|
| 147 | + struct hdcp_caps hdcp_caps; |
|---|
| 148 | +#endif |
|---|
| 115 | 149 | enum edp_revision edp_revision; |
|---|
| 116 | | - bool psr_enabled; |
|---|
| 150 | + union dpcd_sink_ext_caps dpcd_sink_ext_caps; |
|---|
| 151 | + |
|---|
| 152 | + struct psr_settings psr_settings; |
|---|
| 117 | 153 | |
|---|
| 118 | 154 | /* MST record stream using this link */ |
|---|
| 119 | 155 | struct link_flags { |
|---|
| 120 | 156 | bool dp_keep_receiver_powered; |
|---|
| 157 | + bool dp_skip_DID2; |
|---|
| 158 | + bool dp_skip_reset_segment; |
|---|
| 121 | 159 | } wa_flags; |
|---|
| 122 | 160 | struct link_mst_stream_allocation_table mst_stream_alloc_table; |
|---|
| 123 | 161 | |
|---|
| 124 | 162 | struct dc_link_status link_status; |
|---|
| 125 | 163 | |
|---|
| 126 | 164 | struct link_trace link_trace; |
|---|
| 165 | + struct gpio *hpd_gpio; |
|---|
| 166 | + enum dc_link_fec_state fec_state; |
|---|
| 127 | 167 | }; |
|---|
| 128 | 168 | |
|---|
| 129 | 169 | const struct dc_link_status *dc_link_get_status(const struct dc_link *dc_link); |
|---|
| 130 | 170 | |
|---|
| 131 | | -/* |
|---|
| 132 | | - * Return an enumerated dc_link. dc_link order is constant and determined at |
|---|
| 171 | +/** |
|---|
| 172 | + * dc_get_link_at_index() - Return an enumerated dc_link. |
|---|
| 173 | + * |
|---|
| 174 | + * dc_link order is constant and determined at |
|---|
| 133 | 175 | * boot time. They cannot be created or destroyed. |
|---|
| 134 | 176 | * Use dc_get_caps() to get number of links. |
|---|
| 135 | 177 | */ |
|---|
| .. | .. |
|---|
| 138 | 180 | return dc->links[link_index]; |
|---|
| 139 | 181 | } |
|---|
| 140 | 182 | |
|---|
| 141 | | -/* Set backlight level of an embedded panel (eDP, LVDS). */ |
|---|
| 142 | | -bool dc_link_set_backlight_level(const struct dc_link *dc_link, uint32_t level, |
|---|
| 143 | | - uint32_t frame_ramp, const struct dc_stream_state *stream); |
|---|
| 183 | +static inline struct dc_link *get_edp_link(const struct dc *dc) |
|---|
| 184 | +{ |
|---|
| 185 | + int i; |
|---|
| 186 | + |
|---|
| 187 | + // report any eDP links, even unconnected DDI's |
|---|
| 188 | + for (i = 0; i < dc->link_count; i++) { |
|---|
| 189 | + if (dc->links[i]->connector_signal == SIGNAL_TYPE_EDP) |
|---|
| 190 | + return dc->links[i]; |
|---|
| 191 | + } |
|---|
| 192 | + return NULL; |
|---|
| 193 | +} |
|---|
| 194 | + |
|---|
| 195 | +/* Set backlight level of an embedded panel (eDP, LVDS). |
|---|
| 196 | + * backlight_pwm_u16_16 is unsigned 32 bit with 16 bit integer |
|---|
| 197 | + * and 16 bit fractional, where 1.0 is max backlight value. |
|---|
| 198 | + */ |
|---|
| 199 | +bool dc_link_set_backlight_level(const struct dc_link *dc_link, |
|---|
| 200 | + uint32_t backlight_pwm_u16_16, |
|---|
| 201 | + uint32_t frame_ramp); |
|---|
| 202 | + |
|---|
| 203 | +/* Set/get nits-based backlight level of an embedded panel (eDP, LVDS). */ |
|---|
| 204 | +bool dc_link_set_backlight_level_nits(struct dc_link *link, |
|---|
| 205 | + bool isHDR, |
|---|
| 206 | + uint32_t backlight_millinits, |
|---|
| 207 | + uint32_t transition_time_in_ms); |
|---|
| 208 | + |
|---|
| 209 | +bool dc_link_get_backlight_level_nits(struct dc_link *link, |
|---|
| 210 | + uint32_t *backlight_millinits, |
|---|
| 211 | + uint32_t *backlight_millinits_peak); |
|---|
| 212 | + |
|---|
| 213 | +bool dc_link_backlight_enable_aux(struct dc_link *link, bool enable); |
|---|
| 214 | + |
|---|
| 215 | +bool dc_link_read_default_bl_aux(struct dc_link *link, uint32_t *backlight_millinits); |
|---|
| 216 | +bool dc_link_set_default_brightness_aux(struct dc_link *link); |
|---|
| 144 | 217 | |
|---|
| 145 | 218 | int dc_link_get_backlight_level(const struct dc_link *dc_link); |
|---|
| 146 | 219 | |
|---|
| 147 | | -bool dc_link_set_abm_disable(const struct dc_link *dc_link); |
|---|
| 220 | +int dc_link_get_target_backlight_pwm(const struct dc_link *link); |
|---|
| 148 | 221 | |
|---|
| 149 | | -bool dc_link_set_psr_enable(const struct dc_link *dc_link, bool enable, bool wait); |
|---|
| 222 | +bool dc_link_set_psr_allow_active(struct dc_link *dc_link, bool enable, bool wait); |
|---|
| 150 | 223 | |
|---|
| 151 | 224 | bool dc_link_get_psr_state(const struct dc_link *dc_link, uint32_t *psr_state); |
|---|
| 152 | 225 | |
|---|
| .. | .. |
|---|
| 164 | 237 | DETECT_REASON_BOOT, |
|---|
| 165 | 238 | DETECT_REASON_HPD, |
|---|
| 166 | 239 | DETECT_REASON_HPDRX, |
|---|
| 240 | + DETECT_REASON_FALLBACK, |
|---|
| 241 | + DETECT_REASON_RETRAIN |
|---|
| 167 | 242 | }; |
|---|
| 168 | 243 | |
|---|
| 169 | 244 | bool dc_link_detect(struct dc_link *dc_link, enum dc_detect_reason reason); |
|---|
| 245 | +bool dc_link_get_hpd_state(struct dc_link *dc_link); |
|---|
| 246 | +enum dc_status dc_link_allocate_mst_payload(struct pipe_ctx *pipe_ctx); |
|---|
| 247 | +enum dc_status dc_link_reallocate_mst_payload(struct dc_link *link); |
|---|
| 170 | 248 | |
|---|
| 171 | 249 | /* Notify DC about DP RX Interrupt (aka Short Pulse Interrupt). |
|---|
| 172 | 250 | * Return: |
|---|
| .. | .. |
|---|
| 195 | 273 | struct dc_link *link, |
|---|
| 196 | 274 | struct link_training_settings *lt_settings); |
|---|
| 197 | 275 | |
|---|
| 276 | +bool dc_link_dp_perform_link_training_skip_aux( |
|---|
| 277 | + struct dc_link *link, |
|---|
| 278 | + const struct dc_link_settings *link_setting); |
|---|
| 279 | + |
|---|
| 198 | 280 | enum link_training_result dc_link_dp_perform_link_training( |
|---|
| 199 | 281 | struct dc_link *link, |
|---|
| 200 | 282 | const struct dc_link_settings *link_setting, |
|---|
| 201 | 283 | bool skip_video_pattern); |
|---|
| 284 | + |
|---|
| 285 | +bool dc_link_dp_sync_lt_begin(struct dc_link *link); |
|---|
| 286 | + |
|---|
| 287 | +enum link_training_result dc_link_dp_sync_lt_attempt( |
|---|
| 288 | + struct dc_link *link, |
|---|
| 289 | + struct dc_link_settings *link_setting, |
|---|
| 290 | + struct dc_link_training_overrides *lt_settings); |
|---|
| 291 | + |
|---|
| 292 | +bool dc_link_dp_sync_lt_end(struct dc_link *link, bool link_down); |
|---|
| 202 | 293 | |
|---|
| 203 | 294 | void dc_link_dp_enable_hpd(const struct dc_link *link); |
|---|
| 204 | 295 | |
|---|
| .. | .. |
|---|
| 207 | 298 | bool dc_link_dp_set_test_pattern( |
|---|
| 208 | 299 | struct dc_link *link, |
|---|
| 209 | 300 | enum dp_test_pattern test_pattern, |
|---|
| 301 | + enum dp_test_pattern_color_space test_pattern_color_space, |
|---|
| 210 | 302 | const struct link_training_settings *p_link_settings, |
|---|
| 211 | 303 | const unsigned char *p_custom_pattern, |
|---|
| 212 | 304 | unsigned int cust_pattern_size); |
|---|
| .. | .. |
|---|
| 220 | 312 | * DPCD access interfaces |
|---|
| 221 | 313 | */ |
|---|
| 222 | 314 | |
|---|
| 315 | +#ifdef CONFIG_DRM_AMD_DC_HDCP |
|---|
| 316 | +bool dc_link_is_hdcp14(struct dc_link *link, enum signal_type signal); |
|---|
| 317 | +bool dc_link_is_hdcp22(struct dc_link *link, enum signal_type signal); |
|---|
| 318 | +#endif |
|---|
| 223 | 319 | void dc_link_set_drive_settings(struct dc *dc, |
|---|
| 224 | 320 | struct link_training_settings *lt_settings, |
|---|
| 225 | 321 | const struct dc_link *link); |
|---|
| .. | .. |
|---|
| 229 | 325 | void dc_link_set_preferred_link_settings(struct dc *dc, |
|---|
| 230 | 326 | struct dc_link_settings *link_setting, |
|---|
| 231 | 327 | struct dc_link *link); |
|---|
| 328 | +void dc_link_set_preferred_training_settings(struct dc *dc, |
|---|
| 329 | + struct dc_link_settings *link_setting, |
|---|
| 330 | + struct dc_link_training_overrides *lt_overrides, |
|---|
| 331 | + struct dc_link *link, |
|---|
| 332 | + bool skip_immediate_retrain); |
|---|
| 232 | 333 | void dc_link_enable_hpd(const struct dc_link *link); |
|---|
| 233 | 334 | void dc_link_disable_hpd(const struct dc_link *link); |
|---|
| 234 | 335 | void dc_link_set_test_pattern(struct dc_link *link, |
|---|
| 235 | 336 | enum dp_test_pattern test_pattern, |
|---|
| 337 | + enum dp_test_pattern_color_space test_pattern_color_space, |
|---|
| 236 | 338 | const struct link_training_settings *p_link_settings, |
|---|
| 237 | 339 | const unsigned char *p_custom_pattern, |
|---|
| 238 | 340 | unsigned int cust_pattern_size); |
|---|
| 341 | +uint32_t dc_link_bandwidth_kbps( |
|---|
| 342 | + const struct dc_link *link, |
|---|
| 343 | + const struct dc_link_settings *link_setting); |
|---|
| 344 | + |
|---|
| 345 | +const struct dc_link_settings *dc_link_get_link_cap( |
|---|
| 346 | + const struct dc_link *link); |
|---|
| 347 | + |
|---|
| 348 | +void dc_link_overwrite_extended_receiver_cap( |
|---|
| 349 | + struct dc_link *link); |
|---|
| 239 | 350 | |
|---|
| 240 | 351 | bool dc_submit_i2c( |
|---|
| 241 | 352 | struct dc *dc, |
|---|
| 242 | 353 | uint32_t link_index, |
|---|
| 243 | 354 | struct i2c_command *cmd); |
|---|
| 244 | 355 | |
|---|
| 356 | +bool dc_submit_i2c_oem( |
|---|
| 357 | + struct dc *dc, |
|---|
| 358 | + struct i2c_command *cmd); |
|---|
| 359 | + |
|---|
| 360 | +uint32_t dc_bandwidth_in_kbps_from_timing( |
|---|
| 361 | + const struct dc_crtc_timing *timing); |
|---|
| 362 | + |
|---|
| 363 | +bool dc_link_is_fec_supported(const struct dc_link *link); |
|---|
| 364 | + |
|---|
| 245 | 365 | #endif /* DC_LINK_H_ */ |
|---|