]> Git Repo - J-linux.git/blob - drivers/gpu/drm/amd/display/dc/link/hwss/link_hwss_dio.c
Merge tag 'vfs-6.13-rc7.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
[J-linux.git] / drivers / gpu / drm / amd / display / dc / link / hwss / link_hwss_dio.c
1 /*
2  * Copyright 2022 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 #include "link_hwss_dio.h"
26 #include "core_types.h"
27 #include "link_enc_cfg.h"
28
29 /**
30  * DOC: overview
31  *
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.
36  */
37
38
39 void set_dio_throttled_vcp_size(struct pipe_ctx *pipe_ctx,
40                 struct fixed31_32 throttled_vcp_size)
41 {
42         struct stream_encoder *stream_encoder = pipe_ctx->stream_res.stream_enc;
43
44         stream_encoder->funcs->set_throttled_vcp_size(
45                                 stream_encoder,
46                                 throttled_vcp_size);
47 }
48
49 void setup_dio_stream_encoder(struct pipe_ctx *pipe_ctx)
50 {
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;
53
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);
70 }
71
72 void reset_dio_stream_encoder(struct pipe_ctx *pipe_ctx)
73 {
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;
76
77         if (!stream_enc)
78                 return;
79
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(
88                         link_enc,
89                         pipe_ctx->stream_res.stream_enc->id,
90                         false);
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);
95
96 }
97
98 void setup_dio_stream_attribute(struct pipe_ctx *pipe_ctx)
99 {
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;
103
104         if (!dc_is_virtual_signal(stream->signal))
105                 stream_encoder->funcs->setup_stereo_sync(
106                                 stream_encoder,
107                                 pipe_ctx->stream_res.tg->inst,
108                                 stream->timing.timing_3d_format != TIMING_3D_FORMAT_NONE);
109
110         if (dc_is_dp_signal(stream->signal))
111                 stream_encoder->funcs->dp_set_stream_attribute(
112                                 stream_encoder,
113                                 &stream->timing,
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(
119                                 stream_encoder,
120                                 &stream->timing,
121                                 stream->phy_pix_clk,
122                                 pipe_ctx->stream_res.audio != NULL);
123         else if (dc_is_dvi_signal(stream->signal))
124                 stream_encoder->funcs->dvi_set_stream_attribute(
125                                 stream_encoder,
126                                 &stream->timing,
127                                 (stream->signal == SIGNAL_TYPE_DVI_DUAL_LINK) ?
128                                                 true : false);
129         else if (dc_is_lvds_signal(stream->signal))
130                 stream_encoder->funcs->lvds_set_stream_attribute(
131                                 stream_encoder,
132                                 &stream->timing);
133
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);
137 }
138
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)
144 {
145         struct link_encoder *link_enc = link_enc_cfg_get_link_enc(link);
146
147         if (dc_is_dp_sst_signal(signal))
148                 link_enc->funcs->enable_dp_output(
149                                 link_enc,
150                                 link_settings,
151                                 clock_source);
152         else
153                 link_enc->funcs->enable_dp_mst_output(
154                                 link_enc,
155                                 link_settings,
156                                 clock_source);
157         link->dc->link_srv->dp_trace_source_sequence(link,
158                         DPCD_SOURCE_SEQ_AFTER_ENABLE_LINK_PHY);
159 }
160
161 void disable_dio_link_output(struct dc_link *link,
162                 const struct link_resource *link_res,
163                 enum signal_type signal)
164 {
165         struct link_encoder *link_enc = link_enc_cfg_get_link_enc(link);
166
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);
170 }
171
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)
175 {
176         struct link_encoder *link_enc = link_enc_cfg_get_link_enc(link);
177
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);
180 }
181
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])
186 {
187         struct link_encoder *link_enc = link_enc_cfg_get_link_enc(link);
188
189         link_enc->funcs->dp_set_lane_settings(link_enc, link_settings, lane_settings);
190 }
191
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)
195 {
196         struct link_encoder *link_enc = link_enc_cfg_get_link_enc(link);
197
198         ASSERT(link_enc);
199         link_enc->funcs->update_mst_stream_allocation_table(link_enc, table);
200 }
201
202 void setup_dio_audio_output(struct pipe_ctx *pipe_ctx,
203                 struct audio_output *audio_output, uint32_t audio_inst)
204 {
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,
208                                 audio_inst,
209                                 &pipe_ctx->stream->audio_info);
210         else
211                 pipe_ctx->stream_res.stream_enc->funcs->hdmi_audio_setup(
212                                 pipe_ctx->stream_res.stream_enc,
213                                 audio_inst,
214                                 &pipe_ctx->stream->audio_info,
215                                 &audio_output->crtc_info);
216 }
217
218 void enable_dio_audio_packet(struct pipe_ctx *pipe_ctx)
219 {
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);
223
224         pipe_ctx->stream_res.stream_enc->funcs->audio_mute_control(
225                         pipe_ctx->stream_res.stream_enc, false);
226
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);
231 }
232
233 void disable_dio_audio_packet(struct pipe_ctx *pipe_ctx)
234 {
235         pipe_ctx->stream_res.stream_enc->funcs->audio_mute_control(
236                         pipe_ctx->stream_res.stream_enc, true);
237
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);
242                 else
243                         pipe_ctx->stream_res.stream_enc->funcs->hdmi_audio_disable(
244                                         pipe_ctx->stream_res.stream_enc);
245         }
246
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);
251 }
252
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,
261         .ext = {
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,
267         },
268 };
269
270 /**
271  * can_use_dio_link_hwss - Check if the link_hwss is accessible
272  *
273  * @link: Reference a link struct containing one or more sinks and the
274  *        connective status.
275  * @link_res: Mappable hardware resource used to enable a link.
276  *
277  * Returns:
278  * Return true if the link encoder is accessible from link.
279  */
280 bool can_use_dio_link_hwss(const struct dc_link *link,
281                 const struct link_resource *link_res)
282 {
283         return link->link_enc != NULL;
284 }
285
286 /**
287  * get_dio_link_hwss - Return link_hwss reference
288  *
289  * This function behaves like a get function to return the link_hwss populated
290  * in the link_hwss_dio.c file.
291  *
292  * Returns:
293  * Return the reference to the filled struct of link_hwss.
294  */
295 const struct link_hwss *get_dio_link_hwss(void)
296 {
297         return &dio_link_hwss;
298 }
This page took 0.046281 seconds and 4 git commands to generate.