2 * Copyright 2017 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.
28 #ifndef STREAM_ENCODER_H_
29 #define STREAM_ENCODER_H_
31 #include "audio_types.h"
32 #include "hw_shared.h"
37 struct dc_crtc_timing;
39 enum 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
48 enum 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
56 struct audio_clock_info {
57 /* pixel clock frequency*/
58 uint32_t pixel_clock_in_10khz;
61 /* CTS - 32KHz audio*/
69 enum dynamic_metadata_mode {
75 struct enc_sdp_line_num {
76 /* Adaptive Sync SDP */
77 bool adaptive_sync_line_num_valid;
78 uint32_t adaptive_sync_line_num;
81 struct encoder_info_frame {
82 /* auxiliary video information */
83 struct dc_info_packet avi;
84 struct dc_info_packet gamut;
85 struct dc_info_packet vendor;
86 struct dc_info_packet hfvsif;
87 struct dc_info_packet vtem;
88 /* source product description */
89 struct dc_info_packet spd;
90 /* video stream configuration */
91 struct dc_info_packet vsc;
92 /* HDR Static MetaData */
93 struct dc_info_packet hdrsmd;
94 /* Adaptive Sync SDP*/
95 struct dc_info_packet adaptive_sync;
96 struct enc_sdp_line_num sdp_line_num;
99 struct encoder_unblank_param {
100 struct dc_link_settings link_settings;
101 struct dc_crtc_timing timing;
105 struct encoder_set_dp_phy_pattern_param {
106 enum dp_test_pattern dp_phy_pattern;
107 const uint8_t *custom_pattern;
108 uint32_t custom_pattern_size;
109 enum dp_panel_mode dp_panel_mode;
112 struct stream_encoder {
113 const struct stream_encoder_funcs *funcs;
114 struct dc_context *ctx;
117 uint32_t stream_enc_inst;
123 uint32_t dsc_mode; // DISABLED 0; 1 or 2 indicate enabled state.
124 uint32_t dsc_slice_width;
125 uint32_t sec_gsp_pps_line_num;
126 uint32_t vbid6_line_reference;
127 uint32_t vbid6_line_num;
128 uint32_t sec_gsp_pps_enable;
129 uint32_t sec_stream_enable;
132 struct stream_encoder_funcs {
133 void (*dp_set_stream_attribute)(
134 struct stream_encoder *enc,
135 struct dc_crtc_timing *crtc_timing,
136 enum dc_color_space output_color_space,
137 bool use_vsc_sdp_for_colorimetry,
138 uint32_t enable_sdp_splitting);
140 void (*hdmi_set_stream_attribute)(
141 struct stream_encoder *enc,
142 struct dc_crtc_timing *crtc_timing,
143 int actual_pix_clk_khz,
146 void (*dvi_set_stream_attribute)(
147 struct stream_encoder *enc,
148 struct dc_crtc_timing *crtc_timing,
151 void (*lvds_set_stream_attribute)(
152 struct stream_encoder *enc,
153 struct dc_crtc_timing *crtc_timing);
155 void (*set_throttled_vcp_size)(
156 struct stream_encoder *enc,
157 struct fixed31_32 avg_time_slots_per_mtp);
159 void (*update_hdmi_info_packets)(
160 struct stream_encoder *enc,
161 const struct encoder_info_frame *info_frame);
163 void (*stop_hdmi_info_packets)(
164 struct stream_encoder *enc);
166 void (*update_dp_info_packets_sdp_line_num)(
167 struct stream_encoder *enc,
168 struct encoder_info_frame *info_frame);
170 void (*update_dp_info_packets)(
171 struct stream_encoder *enc,
172 const struct encoder_info_frame *info_frame);
174 void (*send_immediate_sdp_message)(
175 struct stream_encoder *enc,
176 const uint8_t *custom_sdp_message,
177 unsigned int sdp_message_size);
179 void (*stop_dp_info_packets)(
180 struct stream_encoder *enc);
183 struct stream_encoder *enc
187 struct dc_link *link,
188 struct stream_encoder *enc);
191 struct dc_link *link,
192 struct stream_encoder *enc,
193 const struct encoder_unblank_param *param);
195 void (*audio_mute_control)(
196 struct stream_encoder *enc, bool mute);
198 void (*dp_audio_setup)(
199 struct stream_encoder *enc,
200 unsigned int az_inst,
201 struct audio_info *info);
203 void (*dp_audio_enable) (
204 struct stream_encoder *enc);
206 void (*dp_audio_disable) (
207 struct stream_encoder *enc);
209 void (*hdmi_audio_setup)(
210 struct stream_encoder *enc,
211 unsigned int az_inst,
212 struct audio_info *info,
213 struct audio_crtc_info *audio_crtc_info);
215 void (*hdmi_audio_disable) (
216 struct stream_encoder *enc);
218 void (*setup_stereo_sync) (
219 struct stream_encoder *enc,
224 struct stream_encoder *enc, bool enable);
226 void (*dig_connect_to_otg)(
227 struct stream_encoder *enc,
230 void (*hdmi_reset_stream_attribute)(
231 struct stream_encoder *enc);
233 unsigned int (*dig_source_otg)(
234 struct stream_encoder *enc);
236 bool (*dp_get_pixel_format)(
237 struct stream_encoder *enc,
238 enum dc_pixel_encoding *encoding,
239 enum dc_color_depth *depth);
241 void (*enc_read_state)(struct stream_encoder *enc, struct enc_state *s);
243 void (*dp_set_dsc_config)(
244 struct stream_encoder *enc,
245 enum optc_dsc_mode dsc_mode,
246 uint32_t dsc_bytes_per_pixel,
247 uint32_t dsc_slice_width);
249 void (*dp_set_dsc_pps_info_packet)(struct stream_encoder *enc,
251 uint8_t *dsc_packed_pps,
252 bool immediate_update);
254 void (*set_dynamic_metadata)(struct stream_encoder *enc,
256 uint32_t hubp_requestor_id,
257 enum dynamic_metadata_mode dmdata_mode);
260 * @dp_set_odm_combine: Sets up DP stream encoder for ODM.
262 void (*dp_set_odm_combine)(
263 struct stream_encoder *enc,
266 uint32_t (*get_fifo_cal_average_level)(
267 struct stream_encoder *enc);
269 void (*set_input_mode)(
270 struct stream_encoder *enc, unsigned int pix_per_container);
271 void (*enable_fifo)(struct stream_encoder *enc);
272 void (*disable_fifo)(struct stream_encoder *enc);
275 struct hpo_dp_stream_encoder_state {
276 uint32_t stream_enc_enabled;
277 uint32_t vid_stream_enabled;
279 uint32_t pixel_encoding;
280 uint32_t component_depth;
281 uint32_t compressed_format;
282 uint32_t sdp_enabled;
283 uint32_t mapped_to_link_enc;
286 struct hpo_dp_stream_encoder {
287 const struct hpo_dp_stream_encoder_funcs *funcs;
288 struct dc_context *ctx;
296 struct hpo_dp_stream_encoder_funcs {
297 void (*enable_stream)(
298 struct hpo_dp_stream_encoder *enc);
301 struct hpo_dp_stream_encoder *enc,
302 uint32_t stream_source);
305 struct hpo_dp_stream_encoder *enc);
308 struct hpo_dp_stream_encoder *enc);
310 void (*set_stream_attribute)(
311 struct hpo_dp_stream_encoder *enc,
312 struct dc_crtc_timing *crtc_timing,
313 enum dc_color_space output_color_space,
314 bool use_vsc_sdp_for_colorimetry,
315 bool compressed_format,
316 bool double_buffer_en);
318 void (*update_dp_info_packets_sdp_line_num)(
319 struct hpo_dp_stream_encoder *enc,
320 struct encoder_info_frame *info_frame);
322 void (*update_dp_info_packets)(
323 struct hpo_dp_stream_encoder *enc,
324 const struct encoder_info_frame *info_frame);
326 void (*stop_dp_info_packets)(
327 struct hpo_dp_stream_encoder *enc);
329 void (*dp_set_dsc_pps_info_packet)(
330 struct hpo_dp_stream_encoder *enc,
332 uint8_t *dsc_packed_pps,
333 bool immediate_update);
335 void (*map_stream_to_link)(
336 struct hpo_dp_stream_encoder *enc,
337 uint32_t stream_enc_inst,
338 uint32_t link_enc_inst);
340 void (*dp_audio_setup)(
341 struct hpo_dp_stream_encoder *enc,
342 unsigned int az_inst,
343 struct audio_info *info);
345 void (*dp_audio_enable)(
346 struct hpo_dp_stream_encoder *enc);
348 void (*dp_audio_disable)(
349 struct hpo_dp_stream_encoder *enc);
352 struct hpo_dp_stream_encoder *enc,
353 struct hpo_dp_stream_encoder_state *state);
355 void (*set_hblank_min_symbol_width)(
356 struct hpo_dp_stream_encoder *enc,
360 #endif /* STREAM_ENCODER_H_ */