1*b843c749SSergey Zigachev /*
2*b843c749SSergey Zigachev  * Copyright 2017 Advanced Micro Devices, Inc.
3*b843c749SSergey Zigachev  *
4*b843c749SSergey Zigachev  * Permission is hereby granted, free of charge, to any person obtaining a
5*b843c749SSergey Zigachev  * copy of this software and associated documentation files (the "Software"),
6*b843c749SSergey Zigachev  * to deal in the Software without restriction, including without limitation
7*b843c749SSergey Zigachev  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*b843c749SSergey Zigachev  * and/or sell copies of the Software, and to permit persons to whom the
9*b843c749SSergey Zigachev  * Software is furnished to do so, subject to the following conditions:
10*b843c749SSergey Zigachev  *
11*b843c749SSergey Zigachev  * The above copyright notice and this permission notice shall be included in
12*b843c749SSergey Zigachev  * all copies or substantial portions of the Software.
13*b843c749SSergey Zigachev  *
14*b843c749SSergey Zigachev  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15*b843c749SSergey Zigachev  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16*b843c749SSergey Zigachev  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17*b843c749SSergey Zigachev  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18*b843c749SSergey Zigachev  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19*b843c749SSergey Zigachev  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20*b843c749SSergey Zigachev  * OTHER DEALINGS IN THE SOFTWARE.
21*b843c749SSergey Zigachev  *
22*b843c749SSergey Zigachev  */
23*b843c749SSergey Zigachev /*
24*b843c749SSergey Zigachev  * stream_encoder.h
25*b843c749SSergey Zigachev  *
26*b843c749SSergey Zigachev  */
27*b843c749SSergey Zigachev 
28*b843c749SSergey Zigachev #ifndef STREAM_ENCODER_H_
29*b843c749SSergey Zigachev #define STREAM_ENCODER_H_
30*b843c749SSergey Zigachev 
31*b843c749SSergey Zigachev #include "audio_types.h"
32*b843c749SSergey Zigachev #include "hw_shared.h"
33*b843c749SSergey Zigachev 
34*b843c749SSergey Zigachev struct dc_bios;
35*b843c749SSergey Zigachev struct dc_context;
36*b843c749SSergey Zigachev struct dc_crtc_timing;
37*b843c749SSergey Zigachev 
38*b843c749SSergey Zigachev enum dp_pixel_encoding_type {
39*b843c749SSergey Zigachev 	DP_PIXEL_ENCODING_TYPE_RGB444		= 0x00000000,
40*b843c749SSergey Zigachev 	DP_PIXEL_ENCODING_TYPE_YCBCR422		= 0x00000001,
41*b843c749SSergey Zigachev 	DP_PIXEL_ENCODING_TYPE_YCBCR444		= 0x00000002,
42*b843c749SSergey Zigachev 	DP_PIXEL_ENCODING_TYPE_RGB_WIDE_GAMUT	= 0x00000003,
43*b843c749SSergey Zigachev 	DP_PIXEL_ENCODING_TYPE_Y_ONLY		= 0x00000004,
44*b843c749SSergey Zigachev 	DP_PIXEL_ENCODING_TYPE_YCBCR420		= 0x00000005
45*b843c749SSergey Zigachev };
46*b843c749SSergey Zigachev 
47*b843c749SSergey Zigachev enum dp_component_depth {
48*b843c749SSergey Zigachev 	DP_COMPONENT_PIXEL_DEPTH_6BPC		= 0x00000000,
49*b843c749SSergey Zigachev 	DP_COMPONENT_PIXEL_DEPTH_8BPC		= 0x00000001,
50*b843c749SSergey Zigachev 	DP_COMPONENT_PIXEL_DEPTH_10BPC		= 0x00000002,
51*b843c749SSergey Zigachev 	DP_COMPONENT_PIXEL_DEPTH_12BPC		= 0x00000003,
52*b843c749SSergey Zigachev 	DP_COMPONENT_PIXEL_DEPTH_16BPC		= 0x00000004
53*b843c749SSergey Zigachev };
54*b843c749SSergey Zigachev 
55*b843c749SSergey Zigachev struct encoder_info_frame {
56*b843c749SSergey Zigachev 	/* auxiliary video information */
57*b843c749SSergey Zigachev 	struct dc_info_packet avi;
58*b843c749SSergey Zigachev 	struct dc_info_packet gamut;
59*b843c749SSergey Zigachev 	struct dc_info_packet vendor;
60*b843c749SSergey Zigachev 	/* source product description */
61*b843c749SSergey Zigachev 	struct dc_info_packet spd;
62*b843c749SSergey Zigachev 	/* video stream configuration */
63*b843c749SSergey Zigachev 	struct dc_info_packet vsc;
64*b843c749SSergey Zigachev 	/* HDR Static MetaData */
65*b843c749SSergey Zigachev 	struct dc_info_packet hdrsmd;
66*b843c749SSergey Zigachev };
67*b843c749SSergey Zigachev 
68*b843c749SSergey Zigachev struct encoder_unblank_param {
69*b843c749SSergey Zigachev 	struct dc_link_settings link_settings;
70*b843c749SSergey Zigachev 	unsigned int pixel_clk_khz;
71*b843c749SSergey Zigachev };
72*b843c749SSergey Zigachev 
73*b843c749SSergey Zigachev struct encoder_set_dp_phy_pattern_param {
74*b843c749SSergey Zigachev 	enum dp_test_pattern dp_phy_pattern;
75*b843c749SSergey Zigachev 	const uint8_t *custom_pattern;
76*b843c749SSergey Zigachev 	uint32_t custom_pattern_size;
77*b843c749SSergey Zigachev 	enum dp_panel_mode dp_panel_mode;
78*b843c749SSergey Zigachev };
79*b843c749SSergey Zigachev 
80*b843c749SSergey Zigachev struct stream_encoder {
81*b843c749SSergey Zigachev 	const struct stream_encoder_funcs *funcs;
82*b843c749SSergey Zigachev 	struct dc_context *ctx;
83*b843c749SSergey Zigachev 	struct dc_bios *bp;
84*b843c749SSergey Zigachev 	enum engine_id id;
85*b843c749SSergey Zigachev };
86*b843c749SSergey Zigachev 
87*b843c749SSergey Zigachev struct stream_encoder_funcs {
88*b843c749SSergey Zigachev 	void (*dp_set_stream_attribute)(
89*b843c749SSergey Zigachev 		struct stream_encoder *enc,
90*b843c749SSergey Zigachev 		struct dc_crtc_timing *crtc_timing,
91*b843c749SSergey Zigachev 		enum dc_color_space output_color_space);
92*b843c749SSergey Zigachev 
93*b843c749SSergey Zigachev 	void (*hdmi_set_stream_attribute)(
94*b843c749SSergey Zigachev 		struct stream_encoder *enc,
95*b843c749SSergey Zigachev 		struct dc_crtc_timing *crtc_timing,
96*b843c749SSergey Zigachev 		int actual_pix_clk_khz,
97*b843c749SSergey Zigachev 		bool enable_audio);
98*b843c749SSergey Zigachev 
99*b843c749SSergey Zigachev 	void (*dvi_set_stream_attribute)(
100*b843c749SSergey Zigachev 		struct stream_encoder *enc,
101*b843c749SSergey Zigachev 		struct dc_crtc_timing *crtc_timing,
102*b843c749SSergey Zigachev 		bool is_dual_link);
103*b843c749SSergey Zigachev 
104*b843c749SSergey Zigachev 	void (*set_mst_bandwidth)(
105*b843c749SSergey Zigachev 		struct stream_encoder *enc,
106*b843c749SSergey Zigachev 		struct fixed31_32 avg_time_slots_per_mtp);
107*b843c749SSergey Zigachev 
108*b843c749SSergey Zigachev 	void (*update_hdmi_info_packets)(
109*b843c749SSergey Zigachev 		struct stream_encoder *enc,
110*b843c749SSergey Zigachev 		const struct encoder_info_frame *info_frame);
111*b843c749SSergey Zigachev 
112*b843c749SSergey Zigachev 	void (*stop_hdmi_info_packets)(
113*b843c749SSergey Zigachev 		struct stream_encoder *enc);
114*b843c749SSergey Zigachev 
115*b843c749SSergey Zigachev 	void (*update_dp_info_packets)(
116*b843c749SSergey Zigachev 		struct stream_encoder *enc,
117*b843c749SSergey Zigachev 		const struct encoder_info_frame *info_frame);
118*b843c749SSergey Zigachev 
119*b843c749SSergey Zigachev 	void (*stop_dp_info_packets)(
120*b843c749SSergey Zigachev 		struct stream_encoder *enc);
121*b843c749SSergey Zigachev 
122*b843c749SSergey Zigachev 	void (*dp_blank)(
123*b843c749SSergey Zigachev 		struct stream_encoder *enc);
124*b843c749SSergey Zigachev 
125*b843c749SSergey Zigachev 	void (*dp_unblank)(
126*b843c749SSergey Zigachev 		struct stream_encoder *enc,
127*b843c749SSergey Zigachev 		const struct encoder_unblank_param *param);
128*b843c749SSergey Zigachev 
129*b843c749SSergey Zigachev 	void (*audio_mute_control)(
130*b843c749SSergey Zigachev 		struct stream_encoder *enc, bool mute);
131*b843c749SSergey Zigachev 
132*b843c749SSergey Zigachev 	void (*dp_audio_setup)(
133*b843c749SSergey Zigachev 		struct stream_encoder *enc,
134*b843c749SSergey Zigachev 		unsigned int az_inst,
135*b843c749SSergey Zigachev 		struct audio_info *info);
136*b843c749SSergey Zigachev 
137*b843c749SSergey Zigachev 	void (*dp_audio_enable) (
138*b843c749SSergey Zigachev 			struct stream_encoder *enc);
139*b843c749SSergey Zigachev 
140*b843c749SSergey Zigachev 	void (*dp_audio_disable) (
141*b843c749SSergey Zigachev 			struct stream_encoder *enc);
142*b843c749SSergey Zigachev 
143*b843c749SSergey Zigachev 	void (*hdmi_audio_setup)(
144*b843c749SSergey Zigachev 		struct stream_encoder *enc,
145*b843c749SSergey Zigachev 		unsigned int az_inst,
146*b843c749SSergey Zigachev 		struct audio_info *info,
147*b843c749SSergey Zigachev 		struct audio_crtc_info *audio_crtc_info);
148*b843c749SSergey Zigachev 
149*b843c749SSergey Zigachev 	void (*hdmi_audio_disable) (
150*b843c749SSergey Zigachev 			struct stream_encoder *enc);
151*b843c749SSergey Zigachev 
152*b843c749SSergey Zigachev 	void (*setup_stereo_sync) (
153*b843c749SSergey Zigachev 			struct stream_encoder *enc,
154*b843c749SSergey Zigachev 			int tg_inst,
155*b843c749SSergey Zigachev 			bool enable);
156*b843c749SSergey Zigachev 
157*b843c749SSergey Zigachev 	void (*set_avmute)(
158*b843c749SSergey Zigachev 		struct stream_encoder *enc, bool enable);
159*b843c749SSergey Zigachev 
160*b843c749SSergey Zigachev };
161*b843c749SSergey Zigachev 
162*b843c749SSergey Zigachev #endif /* STREAM_ENCODER_H_ */
163