1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright © 2019 Intel Corporation 4 */ 5 6 #ifndef __INTEL_DP_H__ 7 #define __INTEL_DP_H__ 8 9 #include <linux/types.h> 10 11 enum intel_output_format; 12 enum pipe; 13 enum port; 14 struct drm_connector_state; 15 struct drm_encoder; 16 struct drm_i915_private; 17 struct drm_modeset_acquire_ctx; 18 struct drm_dp_vsc_sdp; 19 struct intel_atomic_state; 20 struct intel_connector; 21 struct intel_crtc_state; 22 struct intel_digital_port; 23 struct intel_dp; 24 struct intel_encoder; 25 26 struct link_config_limits { 27 int min_rate, max_rate; 28 int min_lane_count, max_lane_count; 29 struct { 30 /* Uncompressed DSC input or link output bpp in 1 bpp units */ 31 int min_bpp, max_bpp; 32 } pipe; 33 struct { 34 /* Compressed or uncompressed link output bpp in 1/16 bpp units */ 35 int min_bpp_x16, max_bpp_x16; 36 } link; 37 }; 38 39 void intel_edp_fixup_vbt_bpp(struct intel_encoder *encoder, int pipe_bpp); 40 bool intel_dp_limited_color_range(const struct intel_crtc_state *crtc_state, 41 const struct drm_connector_state *conn_state); 42 int intel_dp_min_bpp(enum intel_output_format output_format); 43 void intel_dp_init_modeset_retry_work(struct intel_connector *connector); 44 void 45 intel_dp_queue_modeset_retry_for_link(struct intel_atomic_state *state, 46 struct intel_encoder *encoder, 47 const struct intel_crtc_state *crtc_state); 48 bool intel_dp_init_connector(struct intel_digital_port *dig_port, 49 struct intel_connector *intel_connector); 50 void intel_dp_connector_sync_state(struct intel_connector *connector, 51 const struct intel_crtc_state *crtc_state); 52 void intel_dp_set_link_params(struct intel_dp *intel_dp, 53 int link_rate, int lane_count); 54 int intel_dp_get_active_pipes(struct intel_dp *intel_dp, 55 struct drm_modeset_acquire_ctx *ctx, 56 u8 *pipe_mask); 57 void intel_dp_flush_connector_commits(struct intel_connector *connector); 58 void intel_dp_link_check(struct intel_encoder *encoder); 59 void intel_dp_check_link_state(struct intel_dp *intel_dp); 60 void intel_dp_set_power(struct intel_dp *intel_dp, u8 mode); 61 void intel_dp_configure_protocol_converter(struct intel_dp *intel_dp, 62 const struct intel_crtc_state *crtc_state); 63 void intel_dp_sink_enable_decompression(struct intel_atomic_state *state, 64 struct intel_connector *connector, 65 const struct intel_crtc_state *new_crtc_state); 66 void intel_dp_sink_disable_decompression(struct intel_atomic_state *state, 67 struct intel_connector *connector, 68 const struct intel_crtc_state *old_crtc_state); 69 void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder); 70 void intel_dp_encoder_shutdown(struct intel_encoder *intel_encoder); 71 void intel_dp_encoder_flush_work(struct drm_encoder *encoder); 72 int intel_dp_compute_config(struct intel_encoder *encoder, 73 struct intel_crtc_state *pipe_config, 74 struct drm_connector_state *conn_state); 75 int intel_dp_dsc_compute_config(struct intel_dp *intel_dp, 76 struct intel_crtc_state *pipe_config, 77 struct drm_connector_state *conn_state, 78 struct link_config_limits *limits, 79 int timeslots, 80 bool recompute_pipe_bpp); 81 void intel_dp_audio_compute_config(struct intel_encoder *encoder, 82 struct intel_crtc_state *pipe_config, 83 struct drm_connector_state *conn_state); 84 bool intel_dp_has_hdmi_sink(struct intel_dp *intel_dp); 85 bool intel_dp_is_edp(struct intel_dp *intel_dp); 86 bool intel_dp_is_uhbr(const struct intel_crtc_state *crtc_state); 87 bool intel_dp_has_dsc(const struct intel_connector *connector); 88 int intel_dp_link_symbol_size(int rate); 89 int intel_dp_link_symbol_clock(int rate); 90 bool intel_dp_is_port_edp(struct drm_i915_private *dev_priv, enum port port); 91 enum irqreturn intel_dp_hpd_pulse(struct intel_digital_port *dig_port, 92 bool long_hpd); 93 void intel_edp_backlight_on(const struct intel_crtc_state *crtc_state, 94 const struct drm_connector_state *conn_state); 95 void intel_edp_backlight_off(const struct drm_connector_state *conn_state); 96 void intel_edp_fixup_vbt_bpp(struct intel_encoder *encoder, int pipe_bpp); 97 void intel_dp_mst_suspend(struct drm_i915_private *dev_priv); 98 void intel_dp_mst_resume(struct drm_i915_private *dev_priv); 99 int intel_dp_max_source_lane_count(struct intel_digital_port *dig_port); 100 int intel_dp_max_link_rate(struct intel_dp *intel_dp); 101 int intel_dp_max_lane_count(struct intel_dp *intel_dp); 102 int intel_dp_config_required_rate(const struct intel_crtc_state *crtc_state); 103 int intel_dp_rate_select(struct intel_dp *intel_dp, int rate); 104 int intel_dp_max_common_rate(struct intel_dp *intel_dp); 105 int intel_dp_max_common_lane_count(struct intel_dp *intel_dp); 106 int intel_dp_common_rate(struct intel_dp *intel_dp, int index); 107 int intel_dp_rate_index(const int *rates, int len, int rate); 108 int intel_dp_link_config_index(struct intel_dp *intel_dp, int link_rate, int lane_count); 109 void intel_dp_link_config_get(struct intel_dp *intel_dp, int idx, int *link_rate, int *lane_count); 110 void intel_dp_update_sink_caps(struct intel_dp *intel_dp); 111 void intel_dp_reset_link_params(struct intel_dp *intel_dp); 112 113 void intel_dp_compute_rate(struct intel_dp *intel_dp, int port_clock, 114 u8 *link_bw, u8 *rate_select); 115 bool intel_dp_source_supports_tps3(struct drm_i915_private *i915); 116 bool intel_dp_source_supports_tps4(struct drm_i915_private *i915); 117 118 int intel_dp_link_required(int pixel_clock, int bpp); 119 int intel_dp_effective_data_rate(int pixel_clock, int bpp_x16, 120 int bw_overhead); 121 int intel_dp_max_link_data_rate(struct intel_dp *intel_dp, 122 int max_dprx_rate, int max_dprx_lanes); 123 bool intel_dp_joiner_needs_dsc(struct drm_i915_private *i915, 124 int num_joined_pipes); 125 bool intel_dp_has_joiner(struct intel_dp *intel_dp); 126 bool intel_dp_needs_vsc_sdp(const struct intel_crtc_state *crtc_state, 127 const struct drm_connector_state *conn_state); 128 void intel_dp_set_infoframes(struct intel_encoder *encoder, bool enable, 129 const struct intel_crtc_state *crtc_state, 130 const struct drm_connector_state *conn_state); 131 void intel_read_dp_sdp(struct intel_encoder *encoder, 132 struct intel_crtc_state *crtc_state, 133 unsigned int type); 134 void intel_digital_port_lock(struct intel_encoder *encoder); 135 void intel_digital_port_unlock(struct intel_encoder *encoder); 136 bool intel_digital_port_connected(struct intel_encoder *encoder); 137 bool intel_digital_port_connected_locked(struct intel_encoder *encoder); 138 int intel_dp_dsc_compute_max_bpp(const struct intel_connector *connector, 139 u8 dsc_max_bpc); 140 u16 intel_dp_dsc_get_max_compressed_bpp(struct drm_i915_private *i915, 141 u32 link_clock, u32 lane_count, 142 u32 mode_clock, u32 mode_hdisplay, 143 int num_joined_pipes, 144 enum intel_output_format output_format, 145 u32 pipe_bpp, 146 u32 timeslots); 147 int intel_dp_dsc_sink_min_compressed_bpp(struct intel_crtc_state *pipe_config); 148 int intel_dp_dsc_sink_max_compressed_bpp(const struct intel_connector *connector, 149 struct intel_crtc_state *pipe_config, 150 int bpc); 151 u8 intel_dp_dsc_get_slice_count(const struct intel_connector *connector, 152 int mode_clock, int mode_hdisplay, 153 int num_joined_pipes); 154 int intel_dp_num_joined_pipes(struct intel_dp *intel_dp, 155 struct intel_connector *connector, 156 int hdisplay, int clock); 157 158 static inline unsigned int intel_dp_unused_lane_mask(int lane_count) 159 { 160 return ~((1 << lane_count) - 1) & 0xf; 161 } 162 163 bool intel_dp_supports_fec(struct intel_dp *intel_dp, 164 const struct intel_connector *connector, 165 const struct intel_crtc_state *pipe_config); 166 u32 intel_dp_mode_to_fec_clock(u32 mode_clock); 167 int intel_dp_bw_fec_overhead(bool fec_enabled); 168 169 bool intel_dp_supports_fec(struct intel_dp *intel_dp, 170 const struct intel_connector *connector, 171 const struct intel_crtc_state *pipe_config); 172 173 bool intel_dp_supports_dsc(const struct intel_connector *connector, 174 const struct intel_crtc_state *crtc_state); 175 176 u32 intel_dp_dsc_nearest_valid_bpp(struct drm_i915_private *i915, u32 bpp, u32 pipe_bpp); 177 178 void intel_ddi_update_pipe(struct intel_atomic_state *state, 179 struct intel_encoder *encoder, 180 const struct intel_crtc_state *crtc_state, 181 const struct drm_connector_state *conn_state); 182 183 bool intel_dp_initial_fastset_check(struct intel_encoder *encoder, 184 struct intel_crtc_state *crtc_state); 185 void intel_dp_sync_state(struct intel_encoder *encoder, 186 const struct intel_crtc_state *crtc_state); 187 188 void intel_dp_check_frl_training(struct intel_dp *intel_dp); 189 void intel_dp_pcon_dsc_configure(struct intel_dp *intel_dp, 190 const struct intel_crtc_state *crtc_state); 191 192 void intel_dp_invalidate_source_oui(struct intel_dp *intel_dp); 193 void intel_dp_wait_source_oui(struct intel_dp *intel_dp); 194 int intel_dp_output_bpp(enum intel_output_format output_format, int bpp); 195 196 bool 197 intel_dp_compute_config_link_bpp_limits(struct intel_dp *intel_dp, 198 const struct intel_crtc_state *crtc_state, 199 bool dsc, 200 struct link_config_limits *limits); 201 202 void intel_dp_get_dsc_sink_cap(u8 dpcd_rev, struct intel_connector *connector); 203 bool intel_dp_has_gamut_metadata_dip(struct intel_encoder *encoder); 204 205 bool intel_dp_link_params_valid(struct intel_dp *intel_dp, int link_rate, 206 u8 lane_count); 207 bool intel_dp_has_connector(struct intel_dp *intel_dp, 208 const struct drm_connector_state *conn_state); 209 210 #endif /* __INTEL_DP_H__ */ 211