Loading...
1/*
2 * Copyright 2017 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 */
23/*
24 * stream_encoder.h
25 *
26 */
27
28#ifndef STREAM_ENCODER_H_
29#define STREAM_ENCODER_H_
30
31#include "audio_types.h"
32#include "hw_shared.h"
33#include "dc_link.h"
34
35struct dc_bios;
36struct dc_context;
37struct dc_crtc_timing;
38
39enum dp_pixel_encoding_type {
40 DP_PIXEL_ENCODING_TYPE_RGB444 = 0x00000000,
41 DP_PIXEL_ENCODING_TYPE_YCBCR422 = 0x00000001,
42 DP_PIXEL_ENCODING_TYPE_YCBCR444 = 0x00000002,
43 DP_PIXEL_ENCODING_TYPE_RGB_WIDE_GAMUT = 0x00000003,
44 DP_PIXEL_ENCODING_TYPE_Y_ONLY = 0x00000004,
45 DP_PIXEL_ENCODING_TYPE_YCBCR420 = 0x00000005
46};
47
48enum dp_component_depth {
49 DP_COMPONENT_PIXEL_DEPTH_6BPC = 0x00000000,
50 DP_COMPONENT_PIXEL_DEPTH_8BPC = 0x00000001,
51 DP_COMPONENT_PIXEL_DEPTH_10BPC = 0x00000002,
52 DP_COMPONENT_PIXEL_DEPTH_12BPC = 0x00000003,
53 DP_COMPONENT_PIXEL_DEPTH_16BPC = 0x00000004
54};
55
56struct audio_clock_info {
57 /* pixel clock frequency*/
58 uint32_t pixel_clock_in_10khz;
59 /* N - 32KHz audio */
60 uint32_t n_32khz;
61 /* CTS - 32KHz audio*/
62 uint32_t cts_32khz;
63 uint32_t n_44khz;
64 uint32_t cts_44khz;
65 uint32_t n_48khz;
66 uint32_t cts_48khz;
67};
68
69enum dynamic_metadata_mode {
70 dmdata_dp,
71 dmdata_hdmi,
72 dmdata_dolby_vision
73};
74
75struct encoder_info_frame {
76 /* auxiliary video information */
77 struct dc_info_packet avi;
78 struct dc_info_packet gamut;
79 struct dc_info_packet vendor;
80 struct dc_info_packet hfvsif;
81 struct dc_info_packet vtem;
82 /* source product description */
83 struct dc_info_packet spd;
84 /* video stream configuration */
85 struct dc_info_packet vsc;
86 /* HDR Static MetaData */
87 struct dc_info_packet hdrsmd;
88};
89
90struct encoder_unblank_param {
91 struct dc_link_settings link_settings;
92 struct dc_crtc_timing timing;
93 int opp_cnt;
94};
95
96struct encoder_set_dp_phy_pattern_param {
97 enum dp_test_pattern dp_phy_pattern;
98 const uint8_t *custom_pattern;
99 uint32_t custom_pattern_size;
100 enum dp_panel_mode dp_panel_mode;
101};
102
103struct stream_encoder {
104 const struct stream_encoder_funcs *funcs;
105 struct dc_context *ctx;
106 struct dc_bios *bp;
107 enum engine_id id;
108 uint32_t stream_enc_inst;
109 struct vpg *vpg;
110 struct afmt *afmt;
111};
112
113struct enc_state {
114 uint32_t dsc_mode; // DISABLED 0; 1 or 2 indicate enabled state.
115 uint32_t dsc_slice_width;
116 uint32_t sec_gsp_pps_line_num;
117 uint32_t vbid6_line_reference;
118 uint32_t vbid6_line_num;
119 uint32_t sec_gsp_pps_enable;
120 uint32_t sec_stream_enable;
121};
122
123struct stream_encoder_funcs {
124 void (*dp_set_stream_attribute)(
125 struct stream_encoder *enc,
126 struct dc_crtc_timing *crtc_timing,
127 enum dc_color_space output_color_space,
128 bool use_vsc_sdp_for_colorimetry,
129 uint32_t enable_sdp_splitting);
130
131 void (*hdmi_set_stream_attribute)(
132 struct stream_encoder *enc,
133 struct dc_crtc_timing *crtc_timing,
134 int actual_pix_clk_khz,
135 bool enable_audio);
136
137 void (*dvi_set_stream_attribute)(
138 struct stream_encoder *enc,
139 struct dc_crtc_timing *crtc_timing,
140 bool is_dual_link);
141
142 void (*lvds_set_stream_attribute)(
143 struct stream_encoder *enc,
144 struct dc_crtc_timing *crtc_timing);
145
146 void (*set_throttled_vcp_size)(
147 struct stream_encoder *enc,
148 struct fixed31_32 avg_time_slots_per_mtp);
149
150 void (*update_hdmi_info_packets)(
151 struct stream_encoder *enc,
152 const struct encoder_info_frame *info_frame);
153
154 void (*stop_hdmi_info_packets)(
155 struct stream_encoder *enc);
156
157 void (*update_dp_info_packets)(
158 struct stream_encoder *enc,
159 const struct encoder_info_frame *info_frame);
160
161 void (*send_immediate_sdp_message)(
162 struct stream_encoder *enc,
163 const uint8_t *custom_sdp_message,
164 unsigned int sdp_message_size);
165
166 void (*stop_dp_info_packets)(
167 struct stream_encoder *enc);
168
169 void (*reset_fifo)(
170 struct stream_encoder *enc
171 );
172
173 void (*dp_blank)(
174 struct dc_link *link,
175 struct stream_encoder *enc);
176
177 void (*dp_unblank)(
178 struct dc_link *link,
179 struct stream_encoder *enc,
180 const struct encoder_unblank_param *param);
181
182 void (*audio_mute_control)(
183 struct stream_encoder *enc, bool mute);
184
185 void (*dp_audio_setup)(
186 struct stream_encoder *enc,
187 unsigned int az_inst,
188 struct audio_info *info);
189
190 void (*dp_audio_enable) (
191 struct stream_encoder *enc);
192
193 void (*dp_audio_disable) (
194 struct stream_encoder *enc);
195
196 void (*hdmi_audio_setup)(
197 struct stream_encoder *enc,
198 unsigned int az_inst,
199 struct audio_info *info,
200 struct audio_crtc_info *audio_crtc_info);
201
202 void (*hdmi_audio_disable) (
203 struct stream_encoder *enc);
204
205 void (*setup_stereo_sync) (
206 struct stream_encoder *enc,
207 int tg_inst,
208 bool enable);
209
210 void (*set_avmute)(
211 struct stream_encoder *enc, bool enable);
212
213 void (*dig_connect_to_otg)(
214 struct stream_encoder *enc,
215 int tg_inst);
216
217 void (*hdmi_reset_stream_attribute)(
218 struct stream_encoder *enc);
219
220 unsigned int (*dig_source_otg)(
221 struct stream_encoder *enc);
222
223 bool (*dp_get_pixel_format)(
224 struct stream_encoder *enc,
225 enum dc_pixel_encoding *encoding,
226 enum dc_color_depth *depth);
227
228 void (*enc_read_state)(struct stream_encoder *enc, struct enc_state *s);
229
230 void (*dp_set_dsc_config)(
231 struct stream_encoder *enc,
232 enum optc_dsc_mode dsc_mode,
233 uint32_t dsc_bytes_per_pixel,
234 uint32_t dsc_slice_width);
235
236 void (*dp_set_dsc_pps_info_packet)(struct stream_encoder *enc,
237 bool enable,
238 uint8_t *dsc_packed_pps,
239 bool immediate_update);
240
241 void (*set_dynamic_metadata)(struct stream_encoder *enc,
242 bool enable,
243 uint32_t hubp_requestor_id,
244 enum dynamic_metadata_mode dmdata_mode);
245
246 /**
247 * @dp_set_odm_combine: Sets up DP stream encoder for ODM.
248 */
249 void (*dp_set_odm_combine)(
250 struct stream_encoder *enc,
251 bool odm_combine);
252
253 uint32_t (*get_fifo_cal_average_level)(
254 struct stream_encoder *enc);
255
256 void (*set_input_mode)(
257 struct stream_encoder *enc, unsigned int pix_per_container);
258 void (*enable_fifo)(struct stream_encoder *enc);
259 void (*disable_fifo)(struct stream_encoder *enc);
260};
261
262struct hpo_dp_stream_encoder_state {
263 uint32_t stream_enc_enabled;
264 uint32_t vid_stream_enabled;
265 uint32_t otg_inst;
266 uint32_t pixel_encoding;
267 uint32_t component_depth;
268 uint32_t compressed_format;
269 uint32_t sdp_enabled;
270 uint32_t mapped_to_link_enc;
271};
272
273struct hpo_dp_stream_encoder {
274 const struct hpo_dp_stream_encoder_funcs *funcs;
275 struct dc_context *ctx;
276 struct dc_bios *bp;
277 uint32_t inst;
278 enum engine_id id;
279 struct vpg *vpg;
280 struct apg *apg;
281};
282
283struct hpo_dp_stream_encoder_funcs {
284 void (*enable_stream)(
285 struct hpo_dp_stream_encoder *enc);
286
287 void (*dp_unblank)(
288 struct hpo_dp_stream_encoder *enc,
289 uint32_t stream_source);
290
291 void (*dp_blank)(
292 struct hpo_dp_stream_encoder *enc);
293
294 void (*disable)(
295 struct hpo_dp_stream_encoder *enc);
296
297 void (*set_stream_attribute)(
298 struct hpo_dp_stream_encoder *enc,
299 struct dc_crtc_timing *crtc_timing,
300 enum dc_color_space output_color_space,
301 bool use_vsc_sdp_for_colorimetry,
302 bool compressed_format,
303 bool double_buffer_en);
304
305 void (*update_dp_info_packets)(
306 struct hpo_dp_stream_encoder *enc,
307 const struct encoder_info_frame *info_frame);
308
309 void (*stop_dp_info_packets)(
310 struct hpo_dp_stream_encoder *enc);
311
312 void (*dp_set_dsc_pps_info_packet)(
313 struct hpo_dp_stream_encoder *enc,
314 bool enable,
315 uint8_t *dsc_packed_pps,
316 bool immediate_update);
317
318 void (*map_stream_to_link)(
319 struct hpo_dp_stream_encoder *enc,
320 uint32_t stream_enc_inst,
321 uint32_t link_enc_inst);
322
323 void (*dp_audio_setup)(
324 struct hpo_dp_stream_encoder *enc,
325 unsigned int az_inst,
326 struct audio_info *info);
327
328 void (*dp_audio_enable)(
329 struct hpo_dp_stream_encoder *enc);
330
331 void (*dp_audio_disable)(
332 struct hpo_dp_stream_encoder *enc);
333
334 void (*read_state)(
335 struct hpo_dp_stream_encoder *enc,
336 struct hpo_dp_stream_encoder_state *state);
337
338 void (*set_hblank_min_symbol_width)(
339 struct hpo_dp_stream_encoder *enc,
340 uint16_t width);
341};
342
343#endif /* STREAM_ENCODER_H_ */
1/*
2 * Copyright 2017 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 */
23/*
24 * stream_encoder.h
25 *
26 */
27
28#ifndef STREAM_ENCODER_H_
29#define STREAM_ENCODER_H_
30
31#include "audio_types.h"
32#include "hw_shared.h"
33
34struct dc_bios;
35struct dc_context;
36struct dc_crtc_timing;
37
38enum dp_pixel_encoding_type {
39 DP_PIXEL_ENCODING_TYPE_RGB444 = 0x00000000,
40 DP_PIXEL_ENCODING_TYPE_YCBCR422 = 0x00000001,
41 DP_PIXEL_ENCODING_TYPE_YCBCR444 = 0x00000002,
42 DP_PIXEL_ENCODING_TYPE_RGB_WIDE_GAMUT = 0x00000003,
43 DP_PIXEL_ENCODING_TYPE_Y_ONLY = 0x00000004,
44 DP_PIXEL_ENCODING_TYPE_YCBCR420 = 0x00000005
45};
46
47enum dp_component_depth {
48 DP_COMPONENT_PIXEL_DEPTH_6BPC = 0x00000000,
49 DP_COMPONENT_PIXEL_DEPTH_8BPC = 0x00000001,
50 DP_COMPONENT_PIXEL_DEPTH_10BPC = 0x00000002,
51 DP_COMPONENT_PIXEL_DEPTH_12BPC = 0x00000003,
52 DP_COMPONENT_PIXEL_DEPTH_16BPC = 0x00000004
53};
54
55struct audio_clock_info {
56 /* pixel clock frequency*/
57 uint32_t pixel_clock_in_10khz;
58 /* N - 32KHz audio */
59 uint32_t n_32khz;
60 /* CTS - 32KHz audio*/
61 uint32_t cts_32khz;
62 uint32_t n_44khz;
63 uint32_t cts_44khz;
64 uint32_t n_48khz;
65 uint32_t cts_48khz;
66};
67
68enum dynamic_metadata_mode {
69 dmdata_dp,
70 dmdata_hdmi,
71 dmdata_dolby_vision
72};
73
74struct encoder_info_frame {
75 /* auxiliary video information */
76 struct dc_info_packet avi;
77 struct dc_info_packet gamut;
78 struct dc_info_packet vendor;
79 struct dc_info_packet hfvsif;
80 /* source product description */
81 struct dc_info_packet spd;
82 /* video stream configuration */
83 struct dc_info_packet vsc;
84 /* HDR Static MetaData */
85 struct dc_info_packet hdrsmd;
86};
87
88struct encoder_unblank_param {
89 struct dc_link_settings link_settings;
90 struct dc_crtc_timing timing;
91 int opp_cnt;
92};
93
94struct encoder_set_dp_phy_pattern_param {
95 enum dp_test_pattern dp_phy_pattern;
96 const uint8_t *custom_pattern;
97 uint32_t custom_pattern_size;
98 enum dp_panel_mode dp_panel_mode;
99};
100
101struct stream_encoder {
102 const struct stream_encoder_funcs *funcs;
103 struct dc_context *ctx;
104 struct dc_bios *bp;
105 enum engine_id id;
106 uint32_t stream_enc_inst;
107#if defined(CONFIG_DRM_AMD_DC_DCN3_0)
108 struct vpg *vpg;
109 struct afmt *afmt;
110#endif
111};
112
113struct enc_state {
114 uint32_t dsc_mode; // DISABLED 0; 1 or 2 indicate enabled state.
115 uint32_t dsc_slice_width;
116 uint32_t sec_gsp_pps_line_num;
117 uint32_t vbid6_line_reference;
118 uint32_t vbid6_line_num;
119 uint32_t sec_gsp_pps_enable;
120 uint32_t sec_stream_enable;
121};
122
123struct stream_encoder_funcs {
124 void (*dp_set_stream_attribute)(
125 struct stream_encoder *enc,
126 struct dc_crtc_timing *crtc_timing,
127 enum dc_color_space output_color_space,
128 bool use_vsc_sdp_for_colorimetry,
129 uint32_t enable_sdp_splitting);
130
131 void (*hdmi_set_stream_attribute)(
132 struct stream_encoder *enc,
133 struct dc_crtc_timing *crtc_timing,
134 int actual_pix_clk_khz,
135 bool enable_audio);
136
137 void (*dvi_set_stream_attribute)(
138 struct stream_encoder *enc,
139 struct dc_crtc_timing *crtc_timing,
140 bool is_dual_link);
141
142 void (*lvds_set_stream_attribute)(
143 struct stream_encoder *enc,
144 struct dc_crtc_timing *crtc_timing);
145
146 void (*set_mst_bandwidth)(
147 struct stream_encoder *enc,
148 struct fixed31_32 avg_time_slots_per_mtp);
149
150 void (*update_hdmi_info_packets)(
151 struct stream_encoder *enc,
152 const struct encoder_info_frame *info_frame);
153
154 void (*stop_hdmi_info_packets)(
155 struct stream_encoder *enc);
156
157 void (*update_dp_info_packets)(
158 struct stream_encoder *enc,
159 const struct encoder_info_frame *info_frame);
160
161 void (*send_immediate_sdp_message)(
162 struct stream_encoder *enc,
163 const uint8_t *custom_sdp_message,
164 unsigned int sdp_message_size);
165
166 void (*stop_dp_info_packets)(
167 struct stream_encoder *enc);
168
169 void (*dp_blank)(
170 struct stream_encoder *enc);
171
172 void (*dp_unblank)(
173 struct stream_encoder *enc,
174 const struct encoder_unblank_param *param);
175
176 void (*audio_mute_control)(
177 struct stream_encoder *enc, bool mute);
178
179 void (*dp_audio_setup)(
180 struct stream_encoder *enc,
181 unsigned int az_inst,
182 struct audio_info *info);
183
184 void (*dp_audio_enable) (
185 struct stream_encoder *enc);
186
187 void (*dp_audio_disable) (
188 struct stream_encoder *enc);
189
190 void (*hdmi_audio_setup)(
191 struct stream_encoder *enc,
192 unsigned int az_inst,
193 struct audio_info *info,
194 struct audio_crtc_info *audio_crtc_info);
195
196 void (*hdmi_audio_disable) (
197 struct stream_encoder *enc);
198
199 void (*setup_stereo_sync) (
200 struct stream_encoder *enc,
201 int tg_inst,
202 bool enable);
203
204 void (*set_avmute)(
205 struct stream_encoder *enc, bool enable);
206
207 void (*dig_connect_to_otg)(
208 struct stream_encoder *enc,
209 int tg_inst);
210
211 void (*hdmi_reset_stream_attribute)(
212 struct stream_encoder *enc);
213
214 unsigned int (*dig_source_otg)(
215 struct stream_encoder *enc);
216
217 bool (*dp_get_pixel_format)(
218 struct stream_encoder *enc,
219 enum dc_pixel_encoding *encoding,
220 enum dc_color_depth *depth);
221
222 void (*enc_read_state)(struct stream_encoder *enc, struct enc_state *s);
223
224 void (*dp_set_dsc_config)(
225 struct stream_encoder *enc,
226 enum optc_dsc_mode dsc_mode,
227 uint32_t dsc_bytes_per_pixel,
228 uint32_t dsc_slice_width);
229
230 void (*dp_set_dsc_pps_info_packet)(struct stream_encoder *enc,
231 bool enable,
232 uint8_t *dsc_packed_pps);
233
234 void (*set_dynamic_metadata)(struct stream_encoder *enc,
235 bool enable,
236 uint32_t hubp_requestor_id,
237 enum dynamic_metadata_mode dmdata_mode);
238
239 void (*dp_set_odm_combine)(
240 struct stream_encoder *enc,
241 bool odm_combine);
242};
243
244#endif /* STREAM_ENCODER_H_ */