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  * link_encoder.h
25*b843c749SSergey Zigachev  *
26*b843c749SSergey Zigachev  *  Created on: Oct 6, 2015
27*b843c749SSergey Zigachev  *      Author: yonsun
28*b843c749SSergey Zigachev  */
29*b843c749SSergey Zigachev 
30*b843c749SSergey Zigachev #ifndef LINK_ENCODER_H_
31*b843c749SSergey Zigachev #define LINK_ENCODER_H_
32*b843c749SSergey Zigachev 
33*b843c749SSergey Zigachev #include "grph_object_defs.h"
34*b843c749SSergey Zigachev #include "signal_types.h"
35*b843c749SSergey Zigachev #include "dc_types.h"
36*b843c749SSergey Zigachev 
37*b843c749SSergey Zigachev struct dc_context;
38*b843c749SSergey Zigachev struct encoder_set_dp_phy_pattern_param;
39*b843c749SSergey Zigachev struct link_mst_stream_allocation_table;
40*b843c749SSergey Zigachev struct dc_link_settings;
41*b843c749SSergey Zigachev struct link_training_settings;
42*b843c749SSergey Zigachev struct pipe_ctx;
43*b843c749SSergey Zigachev 
44*b843c749SSergey Zigachev struct encoder_init_data {
45*b843c749SSergey Zigachev 	enum channel_id channel;
46*b843c749SSergey Zigachev 	struct graphics_object_id connector;
47*b843c749SSergey Zigachev 	enum hpd_source_id hpd_source;
48*b843c749SSergey Zigachev 	/* TODO: in DAL2, here was pointer to EventManagerInterface */
49*b843c749SSergey Zigachev 	struct graphics_object_id encoder;
50*b843c749SSergey Zigachev 	struct dc_context *ctx;
51*b843c749SSergey Zigachev 	enum transmitter transmitter;
52*b843c749SSergey Zigachev };
53*b843c749SSergey Zigachev 
54*b843c749SSergey Zigachev struct encoder_feature_support {
55*b843c749SSergey Zigachev 	union {
56*b843c749SSergey Zigachev 		struct {
57*b843c749SSergey Zigachev 			uint32_t IS_HBR2_CAPABLE:1;
58*b843c749SSergey Zigachev 			uint32_t IS_HBR3_CAPABLE:1;
59*b843c749SSergey Zigachev 			uint32_t IS_TPS3_CAPABLE:1;
60*b843c749SSergey Zigachev 			uint32_t IS_TPS4_CAPABLE:1;
61*b843c749SSergey Zigachev 			uint32_t IS_YCBCR_CAPABLE:1;
62*b843c749SSergey Zigachev 			uint32_t HDMI_6GB_EN:1;
63*b843c749SSergey Zigachev 		} bits;
64*b843c749SSergey Zigachev 		uint32_t raw;
65*b843c749SSergey Zigachev 	} flags;
66*b843c749SSergey Zigachev 
67*b843c749SSergey Zigachev 	enum dc_color_depth max_hdmi_deep_color;
68*b843c749SSergey Zigachev 	unsigned int max_hdmi_pixel_clock;
69*b843c749SSergey Zigachev 	bool ycbcr420_supported;
70*b843c749SSergey Zigachev };
71*b843c749SSergey Zigachev 
72*b843c749SSergey Zigachev union dpcd_psr_configuration {
73*b843c749SSergey Zigachev 	struct {
74*b843c749SSergey Zigachev 		unsigned char ENABLE                    : 1;
75*b843c749SSergey Zigachev 		unsigned char TRANSMITTER_ACTIVE_IN_PSR : 1;
76*b843c749SSergey Zigachev 		unsigned char CRC_VERIFICATION          : 1;
77*b843c749SSergey Zigachev 		unsigned char FRAME_CAPTURE_INDICATION  : 1;
78*b843c749SSergey Zigachev 		/* For eDP 1.4, PSR v2*/
79*b843c749SSergey Zigachev 		unsigned char LINE_CAPTURE_INDICATION   : 1;
80*b843c749SSergey Zigachev 		/* For eDP 1.4, PSR v2*/
81*b843c749SSergey Zigachev 		unsigned char IRQ_HPD_WITH_CRC_ERROR    : 1;
82*b843c749SSergey Zigachev 		unsigned char RESERVED                  : 2;
83*b843c749SSergey Zigachev 	} bits;
84*b843c749SSergey Zigachev 	unsigned char raw;
85*b843c749SSergey Zigachev };
86*b843c749SSergey Zigachev 
87*b843c749SSergey Zigachev union psr_error_status {
88*b843c749SSergey Zigachev 	struct {
89*b843c749SSergey Zigachev 		unsigned char LINK_CRC_ERROR        :1;
90*b843c749SSergey Zigachev 		unsigned char RFB_STORAGE_ERROR     :1;
91*b843c749SSergey Zigachev 		unsigned char RESERVED              :6;
92*b843c749SSergey Zigachev 	} bits;
93*b843c749SSergey Zigachev 	unsigned char raw;
94*b843c749SSergey Zigachev };
95*b843c749SSergey Zigachev 
96*b843c749SSergey Zigachev union psr_sink_psr_status {
97*b843c749SSergey Zigachev 	struct {
98*b843c749SSergey Zigachev 	unsigned char SINK_SELF_REFRESH_STATUS  :3;
99*b843c749SSergey Zigachev 	unsigned char RESERVED                  :5;
100*b843c749SSergey Zigachev 	} bits;
101*b843c749SSergey Zigachev 	unsigned char raw;
102*b843c749SSergey Zigachev };
103*b843c749SSergey Zigachev 
104*b843c749SSergey Zigachev struct link_encoder {
105*b843c749SSergey Zigachev 	const struct link_encoder_funcs *funcs;
106*b843c749SSergey Zigachev 	int32_t aux_channel_offset;
107*b843c749SSergey Zigachev 	struct dc_context *ctx;
108*b843c749SSergey Zigachev 	struct graphics_object_id id;
109*b843c749SSergey Zigachev 	struct graphics_object_id connector;
110*b843c749SSergey Zigachev 	uint32_t output_signals;
111*b843c749SSergey Zigachev 	enum engine_id preferred_engine;
112*b843c749SSergey Zigachev 	struct encoder_feature_support features;
113*b843c749SSergey Zigachev 	enum transmitter transmitter;
114*b843c749SSergey Zigachev 	enum hpd_source_id hpd_source;
115*b843c749SSergey Zigachev };
116*b843c749SSergey Zigachev 
117*b843c749SSergey Zigachev struct link_encoder_funcs {
118*b843c749SSergey Zigachev 	bool (*validate_output_with_stream)(
119*b843c749SSergey Zigachev 		struct link_encoder *enc, const struct dc_stream_state *stream);
120*b843c749SSergey Zigachev 	void (*hw_init)(struct link_encoder *enc);
121*b843c749SSergey Zigachev 	void (*setup)(struct link_encoder *enc,
122*b843c749SSergey Zigachev 		enum signal_type signal);
123*b843c749SSergey Zigachev 	void (*enable_tmds_output)(struct link_encoder *enc,
124*b843c749SSergey Zigachev 		enum clock_source_id clock_source,
125*b843c749SSergey Zigachev 		enum dc_color_depth color_depth,
126*b843c749SSergey Zigachev 		enum signal_type signal,
127*b843c749SSergey Zigachev 		uint32_t pixel_clock);
128*b843c749SSergey Zigachev 	void (*enable_dp_output)(struct link_encoder *enc,
129*b843c749SSergey Zigachev 		const struct dc_link_settings *link_settings,
130*b843c749SSergey Zigachev 		enum clock_source_id clock_source);
131*b843c749SSergey Zigachev 	void (*enable_dp_mst_output)(struct link_encoder *enc,
132*b843c749SSergey Zigachev 		const struct dc_link_settings *link_settings,
133*b843c749SSergey Zigachev 		enum clock_source_id clock_source);
134*b843c749SSergey Zigachev 	void (*disable_output)(struct link_encoder *link_enc,
135*b843c749SSergey Zigachev 		enum signal_type signal);
136*b843c749SSergey Zigachev 	void (*dp_set_lane_settings)(struct link_encoder *enc,
137*b843c749SSergey Zigachev 		const struct link_training_settings *link_settings);
138*b843c749SSergey Zigachev 	void (*dp_set_phy_pattern)(struct link_encoder *enc,
139*b843c749SSergey Zigachev 		const struct encoder_set_dp_phy_pattern_param *para);
140*b843c749SSergey Zigachev 	void (*update_mst_stream_allocation_table)(
141*b843c749SSergey Zigachev 		struct link_encoder *enc,
142*b843c749SSergey Zigachev 		const struct link_mst_stream_allocation_table *table);
143*b843c749SSergey Zigachev 	void (*psr_program_dp_dphy_fast_training)(struct link_encoder *enc,
144*b843c749SSergey Zigachev 			bool exit_link_training_required);
145*b843c749SSergey Zigachev 	void (*psr_program_secondary_packet)(struct link_encoder *enc,
146*b843c749SSergey Zigachev 				unsigned int sdp_transmit_line_num_deadline);
147*b843c749SSergey Zigachev 	void (*connect_dig_be_to_fe)(struct link_encoder *enc,
148*b843c749SSergey Zigachev 		enum engine_id engine,
149*b843c749SSergey Zigachev 		bool connect);
150*b843c749SSergey Zigachev 	void (*enable_hpd)(struct link_encoder *enc);
151*b843c749SSergey Zigachev 	void (*disable_hpd)(struct link_encoder *enc);
152*b843c749SSergey Zigachev 	bool (*is_dig_enabled)(struct link_encoder *enc);
153*b843c749SSergey Zigachev 	void (*destroy)(struct link_encoder **enc);
154*b843c749SSergey Zigachev };
155*b843c749SSergey Zigachev 
156*b843c749SSergey Zigachev #endif /* LINK_ENCODER_H_ */
157