xref: /linux/drivers/gpu/drm/amd/display/dc/inc/hw/stream_encoder.h (revision 06ed6aa56ffac9241e03a24649e8d048f8f1b10c)
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 
34 struct dc_bios;
35 struct dc_context;
36 struct dc_crtc_timing;
37 
38 enum 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 
47 enum 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 
55 struct 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 
68 enum dynamic_metadata_mode {
69 	dmdata_dp,
70 	dmdata_hdmi,
71 	dmdata_dolby_vision
72 };
73 
74 struct 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 
88 struct encoder_unblank_param {
89 	struct dc_link_settings link_settings;
90 	struct dc_crtc_timing timing;
91 	int opp_cnt;
92 };
93 
94 struct 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 
101 struct 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 };
108 
109 struct enc_state {
110 	uint32_t dsc_mode;  // DISABLED  0; 1 or 2 indicate enabled state.
111 	uint32_t dsc_slice_width;
112 	uint32_t sec_gsp_pps_line_num;
113 	uint32_t vbid6_line_reference;
114 	uint32_t vbid6_line_num;
115 	uint32_t sec_gsp_pps_enable;
116 	uint32_t sec_stream_enable;
117 };
118 
119 struct stream_encoder_funcs {
120 	void (*dp_set_stream_attribute)(
121 		struct stream_encoder *enc,
122 		struct dc_crtc_timing *crtc_timing,
123 		enum dc_color_space output_color_space,
124 		bool use_vsc_sdp_for_colorimetry,
125 		uint32_t enable_sdp_splitting);
126 
127 	void (*hdmi_set_stream_attribute)(
128 		struct stream_encoder *enc,
129 		struct dc_crtc_timing *crtc_timing,
130 		int actual_pix_clk_khz,
131 		bool enable_audio);
132 
133 	void (*dvi_set_stream_attribute)(
134 		struct stream_encoder *enc,
135 		struct dc_crtc_timing *crtc_timing,
136 		bool is_dual_link);
137 
138 	void (*lvds_set_stream_attribute)(
139 		struct stream_encoder *enc,
140 		struct dc_crtc_timing *crtc_timing);
141 
142 	void (*set_mst_bandwidth)(
143 		struct stream_encoder *enc,
144 		struct fixed31_32 avg_time_slots_per_mtp);
145 
146 	void (*update_hdmi_info_packets)(
147 		struct stream_encoder *enc,
148 		const struct encoder_info_frame *info_frame);
149 
150 	void (*stop_hdmi_info_packets)(
151 		struct stream_encoder *enc);
152 
153 	void (*update_dp_info_packets)(
154 		struct stream_encoder *enc,
155 		const struct encoder_info_frame *info_frame);
156 
157 	void (*send_immediate_sdp_message)(
158 				struct stream_encoder *enc,
159 				const uint8_t *custom_sdp_message,
160 				unsigned int sdp_message_size);
161 
162 	void (*stop_dp_info_packets)(
163 		struct stream_encoder *enc);
164 
165 	void (*dp_blank)(
166 		struct stream_encoder *enc);
167 
168 	void (*dp_unblank)(
169 		struct stream_encoder *enc,
170 		const struct encoder_unblank_param *param);
171 
172 	void (*audio_mute_control)(
173 		struct stream_encoder *enc, bool mute);
174 
175 	void (*dp_audio_setup)(
176 		struct stream_encoder *enc,
177 		unsigned int az_inst,
178 		struct audio_info *info);
179 
180 	void (*dp_audio_enable) (
181 			struct stream_encoder *enc);
182 
183 	void (*dp_audio_disable) (
184 			struct stream_encoder *enc);
185 
186 	void (*hdmi_audio_setup)(
187 		struct stream_encoder *enc,
188 		unsigned int az_inst,
189 		struct audio_info *info,
190 		struct audio_crtc_info *audio_crtc_info);
191 
192 	void (*hdmi_audio_disable) (
193 			struct stream_encoder *enc);
194 
195 	void (*setup_stereo_sync) (
196 			struct stream_encoder *enc,
197 			int tg_inst,
198 			bool enable);
199 
200 	void (*set_avmute)(
201 		struct stream_encoder *enc, bool enable);
202 
203 	void (*dig_connect_to_otg)(
204 		struct stream_encoder *enc,
205 		int tg_inst);
206 
207 	void (*hdmi_reset_stream_attribute)(
208 		struct stream_encoder *enc);
209 
210 	unsigned int (*dig_source_otg)(
211 		struct stream_encoder *enc);
212 
213 	bool (*dp_get_pixel_format)(
214 		struct stream_encoder *enc,
215 		enum dc_pixel_encoding *encoding,
216 		enum dc_color_depth *depth);
217 
218 	void (*enc_read_state)(struct stream_encoder *enc, struct enc_state *s);
219 
220 	void (*dp_set_dsc_config)(
221 			struct stream_encoder *enc,
222 			enum optc_dsc_mode dsc_mode,
223 			uint32_t dsc_bytes_per_pixel,
224 			uint32_t dsc_slice_width);
225 
226 	void (*dp_set_dsc_pps_info_packet)(struct stream_encoder *enc,
227 				bool enable,
228 				uint8_t *dsc_packed_pps);
229 
230 	void (*set_dynamic_metadata)(struct stream_encoder *enc,
231 			bool enable,
232 			uint32_t hubp_requestor_id,
233 			enum dynamic_metadata_mode dmdata_mode);
234 
235 	void (*dp_set_odm_combine)(
236 		struct stream_encoder *enc,
237 		bool odm_combine);
238 };
239 
240 #endif /* STREAM_ENCODER_H_ */
241