2 * Copyright 2022 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.
25 #include "link_hwss_dio.h"
26 #include "core_types.h"
27 #include "link_enc_cfg.h"
32 * Display Input Output (DIO), is the display input and output unit in DCN. It
33 * includes output encoders to support different display output, like
34 * DisplayPort, HDMI, DVI interface, and others. It also includes the control
35 * and status channels for these interfaces.
39 void set_dio_throttled_vcp_size(struct pipe_ctx *pipe_ctx,
40 struct fixed31_32 throttled_vcp_size)
42 struct stream_encoder *stream_encoder = pipe_ctx->stream_res.stream_enc;
44 stream_encoder->funcs->set_throttled_vcp_size(
49 void setup_dio_stream_encoder(struct pipe_ctx *pipe_ctx)
51 struct link_encoder *link_enc = link_enc_cfg_get_link_enc(pipe_ctx->stream->link);
52 struct stream_encoder *stream_enc = pipe_ctx->stream_res.stream_enc;
54 link_enc->funcs->connect_dig_be_to_fe(link_enc,
55 pipe_ctx->stream_res.stream_enc->id, true);
56 if (dc_is_dp_signal(pipe_ctx->stream->signal))
57 pipe_ctx->stream->ctx->dc->link_srv->dp_trace_source_sequence(pipe_ctx->stream->link,
58 DPCD_SOURCE_SEQ_AFTER_CONNECT_DIG_FE_BE);
59 if (stream_enc->funcs->enable_stream)
60 stream_enc->funcs->enable_stream(stream_enc,
61 pipe_ctx->stream->signal, true);
62 if (stream_enc->funcs->map_stream_to_link)
63 stream_enc->funcs->map_stream_to_link(stream_enc,
64 stream_enc->stream_enc_inst, link_enc->transmitter - TRANSMITTER_UNIPHY_A);
65 if (stream_enc->funcs->set_input_mode)
66 stream_enc->funcs->set_input_mode(stream_enc,
67 pipe_ctx->stream_res.pix_clk_params.dio_se_pix_per_cycle);
68 if (stream_enc->funcs->enable_fifo)
69 stream_enc->funcs->enable_fifo(stream_enc);
72 void reset_dio_stream_encoder(struct pipe_ctx *pipe_ctx)
74 struct link_encoder *link_enc = link_enc_cfg_get_link_enc(pipe_ctx->stream->link);
75 struct stream_encoder *stream_enc = pipe_ctx->stream_res.stream_enc;
80 if (stream_enc->funcs->disable_fifo)
81 stream_enc->funcs->disable_fifo(stream_enc);
82 if (stream_enc->funcs->set_input_mode)
83 stream_enc->funcs->set_input_mode(stream_enc, 0);
84 if (stream_enc->funcs->enable_stream)
85 stream_enc->funcs->enable_stream(stream_enc,
86 pipe_ctx->stream->signal, false);
87 link_enc->funcs->connect_dig_be_to_fe(
89 pipe_ctx->stream_res.stream_enc->id,
91 if (dc_is_dp_signal(pipe_ctx->stream->signal))
92 pipe_ctx->stream->ctx->dc->link_srv->dp_trace_source_sequence(
93 pipe_ctx->stream->link,
94 DPCD_SOURCE_SEQ_AFTER_DISCONNECT_DIG_FE_BE);
98 void setup_dio_stream_attribute(struct pipe_ctx *pipe_ctx)
100 struct stream_encoder *stream_encoder = pipe_ctx->stream_res.stream_enc;
101 struct dc_stream_state *stream = pipe_ctx->stream;
102 struct dc_link *link = stream->link;
104 if (!dc_is_virtual_signal(stream->signal))
105 stream_encoder->funcs->setup_stereo_sync(
107 pipe_ctx->stream_res.tg->inst,
108 stream->timing.timing_3d_format != TIMING_3D_FORMAT_NONE);
110 if (dc_is_dp_signal(stream->signal))
111 stream_encoder->funcs->dp_set_stream_attribute(
114 stream->output_color_space,
115 stream->use_vsc_sdp_for_colorimetry,
116 link->dpcd_caps.dprx_feature.bits.SST_SPLIT_SDP_CAP);
117 else if (dc_is_hdmi_tmds_signal(stream->signal))
118 stream_encoder->funcs->hdmi_set_stream_attribute(
122 pipe_ctx->stream_res.audio != NULL);
123 else if (dc_is_dvi_signal(stream->signal))
124 stream_encoder->funcs->dvi_set_stream_attribute(
127 (stream->signal == SIGNAL_TYPE_DVI_DUAL_LINK) ?
129 else if (dc_is_lvds_signal(stream->signal))
130 stream_encoder->funcs->lvds_set_stream_attribute(
134 if (dc_is_dp_signal(stream->signal))
135 link->dc->link_srv->dp_trace_source_sequence(link,
136 DPCD_SOURCE_SEQ_AFTER_DP_STREAM_ATTR);
139 void enable_dio_dp_link_output(struct dc_link *link,
140 const struct link_resource *link_res,
141 enum signal_type signal,
142 enum clock_source_id clock_source,
143 const struct dc_link_settings *link_settings)
145 struct link_encoder *link_enc = link_enc_cfg_get_link_enc(link);
147 if (dc_is_dp_sst_signal(signal))
148 link_enc->funcs->enable_dp_output(
153 link_enc->funcs->enable_dp_mst_output(
157 link->dc->link_srv->dp_trace_source_sequence(link,
158 DPCD_SOURCE_SEQ_AFTER_ENABLE_LINK_PHY);
161 void disable_dio_link_output(struct dc_link *link,
162 const struct link_resource *link_res,
163 enum signal_type signal)
165 struct link_encoder *link_enc = link_enc_cfg_get_link_enc(link);
167 link_enc->funcs->disable_output(link_enc, signal);
168 link->dc->link_srv->dp_trace_source_sequence(link,
169 DPCD_SOURCE_SEQ_AFTER_DISABLE_LINK_PHY);
172 void set_dio_dp_link_test_pattern(struct dc_link *link,
173 const struct link_resource *link_res,
174 struct encoder_set_dp_phy_pattern_param *tp_params)
176 struct link_encoder *link_enc = link_enc_cfg_get_link_enc(link);
178 link_enc->funcs->dp_set_phy_pattern(link_enc, tp_params);
179 link->dc->link_srv->dp_trace_source_sequence(link, DPCD_SOURCE_SEQ_AFTER_SET_SOURCE_PATTERN);
182 void set_dio_dp_lane_settings(struct dc_link *link,
183 const struct link_resource *link_res,
184 const struct dc_link_settings *link_settings,
185 const struct dc_lane_settings lane_settings[LANE_COUNT_DP_MAX])
187 struct link_encoder *link_enc = link_enc_cfg_get_link_enc(link);
189 link_enc->funcs->dp_set_lane_settings(link_enc, link_settings, lane_settings);
192 void update_dio_stream_allocation_table(struct dc_link *link,
193 const struct link_resource *link_res,
194 const struct link_mst_stream_allocation_table *table)
196 struct link_encoder *link_enc = link_enc_cfg_get_link_enc(link);
199 link_enc->funcs->update_mst_stream_allocation_table(link_enc, table);
202 void setup_dio_audio_output(struct pipe_ctx *pipe_ctx,
203 struct audio_output *audio_output, uint32_t audio_inst)
205 if (dc_is_dp_signal(pipe_ctx->stream->signal))
206 pipe_ctx->stream_res.stream_enc->funcs->dp_audio_setup(
207 pipe_ctx->stream_res.stream_enc,
209 &pipe_ctx->stream->audio_info);
211 pipe_ctx->stream_res.stream_enc->funcs->hdmi_audio_setup(
212 pipe_ctx->stream_res.stream_enc,
214 &pipe_ctx->stream->audio_info,
215 &audio_output->crtc_info);
218 void enable_dio_audio_packet(struct pipe_ctx *pipe_ctx)
220 if (dc_is_dp_signal(pipe_ctx->stream->signal))
221 pipe_ctx->stream_res.stream_enc->funcs->dp_audio_enable(
222 pipe_ctx->stream_res.stream_enc);
224 pipe_ctx->stream_res.stream_enc->funcs->audio_mute_control(
225 pipe_ctx->stream_res.stream_enc, false);
227 if (dc_is_dp_signal(pipe_ctx->stream->signal))
228 pipe_ctx->stream->ctx->dc->link_srv->dp_trace_source_sequence(
229 pipe_ctx->stream->link,
230 DPCD_SOURCE_SEQ_AFTER_ENABLE_AUDIO_STREAM);
233 void disable_dio_audio_packet(struct pipe_ctx *pipe_ctx)
235 pipe_ctx->stream_res.stream_enc->funcs->audio_mute_control(
236 pipe_ctx->stream_res.stream_enc, true);
238 if (pipe_ctx->stream_res.audio) {
239 if (dc_is_dp_signal(pipe_ctx->stream->signal))
240 pipe_ctx->stream_res.stream_enc->funcs->dp_audio_disable(
241 pipe_ctx->stream_res.stream_enc);
243 pipe_ctx->stream_res.stream_enc->funcs->hdmi_audio_disable(
244 pipe_ctx->stream_res.stream_enc);
247 if (dc_is_dp_signal(pipe_ctx->stream->signal))
248 pipe_ctx->stream->ctx->dc->link_srv->dp_trace_source_sequence(
249 pipe_ctx->stream->link,
250 DPCD_SOURCE_SEQ_AFTER_DISABLE_AUDIO_STREAM);
253 static const struct link_hwss dio_link_hwss = {
254 .setup_stream_encoder = setup_dio_stream_encoder,
255 .reset_stream_encoder = reset_dio_stream_encoder,
256 .setup_stream_attribute = setup_dio_stream_attribute,
257 .disable_link_output = disable_dio_link_output,
258 .setup_audio_output = setup_dio_audio_output,
259 .enable_audio_packet = enable_dio_audio_packet,
260 .disable_audio_packet = disable_dio_audio_packet,
262 .set_throttled_vcp_size = set_dio_throttled_vcp_size,
263 .enable_dp_link_output = enable_dio_dp_link_output,
264 .set_dp_link_test_pattern = set_dio_dp_link_test_pattern,
265 .set_dp_lane_settings = set_dio_dp_lane_settings,
266 .update_stream_allocation_table = update_dio_stream_allocation_table,
271 * can_use_dio_link_hwss - Check if the link_hwss is accessible
273 * @link: Reference a link struct containing one or more sinks and the
275 * @link_res: Mappable hardware resource used to enable a link.
278 * Return true if the link encoder is accessible from link.
280 bool can_use_dio_link_hwss(const struct dc_link *link,
281 const struct link_resource *link_res)
283 return link->link_enc != NULL;
287 * get_dio_link_hwss - Return link_hwss reference
289 * This function behaves like a get function to return the link_hwss populated
290 * in the link_hwss_dio.c file.
293 * Return the reference to the filled struct of link_hwss.
295 const struct link_hwss *get_dio_link_hwss(void)
297 return &dio_link_hwss;