14562236bSHarry Wentland /*
24562236bSHarry Wentland  * Copyright 2015 Advanced Micro Devices, Inc.
34562236bSHarry Wentland  *
44562236bSHarry Wentland  * Permission is hereby granted, free of charge, to any person obtaining a
54562236bSHarry Wentland  * copy of this software and associated documentation files (the "Software"),
64562236bSHarry Wentland  * to deal in the Software without restriction, including without limitation
74562236bSHarry Wentland  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
84562236bSHarry Wentland  * and/or sell copies of the Software, and to permit persons to whom the
94562236bSHarry Wentland  * Software is furnished to do so, subject to the following conditions:
104562236bSHarry Wentland  *
114562236bSHarry Wentland  * The above copyright notice and this permission notice shall be included in
124562236bSHarry Wentland  * all copies or substantial portions of the Software.
134562236bSHarry Wentland  *
144562236bSHarry Wentland  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
154562236bSHarry Wentland  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
164562236bSHarry Wentland  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
174562236bSHarry Wentland  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
184562236bSHarry Wentland  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
194562236bSHarry Wentland  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
204562236bSHarry Wentland  * OTHER DEALINGS IN THE SOFTWARE.
214562236bSHarry Wentland  *
224562236bSHarry Wentland  * Authors: AMD
234562236bSHarry Wentland  *
244562236bSHarry Wentland  */
254562236bSHarry Wentland 
264562236bSHarry Wentland #ifndef _CORE_TYPES_H_
274562236bSHarry Wentland #define _CORE_TYPES_H_
284562236bSHarry Wentland 
294562236bSHarry Wentland #include "dc.h"
305e141de4SHarry Wentland #include "dce_calcs.h"
31ff5ef992SAlex Deucher #include "dcn_calcs.h"
324562236bSHarry Wentland #include "ddc_service_types.h"
334562236bSHarry Wentland #include "dc_bios_types.h"
34ff5ef992SAlex Deucher #include "mem_input.h"
358feabd03SYue Hin Lau #include "hubp.h"
36ff5ef992SAlex Deucher #include "mpc.h"
37345429a6SHarry Wentland #include "dwb.h"
38345429a6SHarry Wentland #include "mcif_wb.h"
39d4caa72eSAnthony Koo #include "panel_cntl.h"
404562236bSHarry Wentland 
414562236bSHarry Wentland #define MAX_CLOCK_SOURCES 7
424562236bSHarry Wentland 
433be5262eSHarry Wentland void enable_surface_flip_reporting(struct dc_plane_state *plane_state,
444562236bSHarry Wentland 		uint32_t controller_id);
454562236bSHarry Wentland 
464562236bSHarry Wentland #include "grph_object_id.h"
474562236bSHarry Wentland #include "link_encoder.h"
484562236bSHarry Wentland #include "stream_encoder.h"
494562236bSHarry Wentland #include "clock_source.h"
504562236bSHarry Wentland #include "audio.h"
51a185048cSTony Cheng #include "dm_pp_smu.h"
52d462fcf5SBhawanpreet Lakha #ifdef CONFIG_DRM_AMD_DC_HDCP
53d462fcf5SBhawanpreet Lakha #include "dm_cp_psp.h"
54d462fcf5SBhawanpreet Lakha #endif
55fd249266SWenjing Liu #include "link_hwss.h"
564562236bSHarry Wentland 
574562236bSHarry Wentland /************ link *****************/
584562236bSHarry Wentland struct link_init_data {
59fb3466a4SBhawanpreet Lakha 	const struct dc *dc;
604562236bSHarry Wentland 	struct dc_context *ctx; /* TODO: remove 'dal' when DC is complete. */
614562236bSHarry Wentland 	uint32_t connector_index; /* this will be mapped to the HPD pins */
624562236bSHarry Wentland 	uint32_t link_index; /* this is mapped to DAL display_index
634562236bSHarry Wentland 				TODO: remove it when DC is complete. */
649fa0fb77SMeenakshikumar Somasundaram 	bool is_dpia_link;
654562236bSHarry Wentland };
664562236bSHarry Wentland 
67d0778ebfSHarry Wentland struct dc_link *link_create(const struct link_init_data *init_params);
68d0778ebfSHarry Wentland void link_destroy(struct dc_link **link);
694562236bSHarry Wentland 
704562236bSHarry Wentland enum dc_status dc_link_validate_mode_timing(
710971c40eSHarry Wentland 		const struct dc_stream_state *stream,
72d0778ebfSHarry Wentland 		struct dc_link *link,
734562236bSHarry Wentland 		const struct dc_crtc_timing *timing);
744562236bSHarry Wentland 
75d0778ebfSHarry Wentland void core_link_resume(struct dc_link *link);
764562236bSHarry Wentland 
77ab8db3e1SAndrey Grodzovsky void core_link_enable_stream(
78ab8db3e1SAndrey Grodzovsky 		struct dc_state *state,
79ab8db3e1SAndrey Grodzovsky 		struct pipe_ctx *pipe_ctx);
804562236bSHarry Wentland 
8157430404SSu Sung Chung void core_link_disable_stream(struct pipe_ctx *pipe_ctx);
824562236bSHarry Wentland 
8315e17335SCharlene Liu void core_link_set_avmute(struct pipe_ctx *pipe_ctx, bool enable);
844562236bSHarry Wentland /********** DAL Core*********************/
854562236bSHarry Wentland #include "transform.h"
86d94585a0SYue Hin Lau #include "dpp.h"
874562236bSHarry Wentland 
884562236bSHarry Wentland struct resource_pool;
89608ac7bbSJerry Zuo struct dc_state;
904562236bSHarry Wentland struct resource_context;
91aa919167SBhawanpreet Lakha struct clk_bw_params;
924562236bSHarry Wentland 
934562236bSHarry Wentland struct resource_funcs {
944562236bSHarry Wentland 	void (*destroy)(struct resource_pool **pool);
9566b198ffSDmytro Laktyushkin 	void (*link_init)(struct dc_link *link);
96d4caa72eSAnthony Koo 	struct panel_cntl*(*panel_cntl_create)(
97d4caa72eSAnthony Koo 		const struct panel_cntl_init_data *panel_cntl_init_data);
984562236bSHarry Wentland 	struct link_encoder *(*link_enc_create)(
994562236bSHarry Wentland 			const struct encoder_init_data *init);
100e1f4328fSJimmy Kizito 	/* Create a minimal link encoder object with no dc_link object
101e1f4328fSJimmy Kizito 	 * associated with it. */
102e1f4328fSJimmy Kizito 	struct link_encoder *(*link_enc_create_minimal)(struct dc_context *ctx, enum engine_id eng_id);
103e1f4328fSJimmy Kizito 
10445209ef7SDmytro Laktyushkin 	bool (*validate_bandwidth)(
105fb3466a4SBhawanpreet Lakha 					struct dc *dc,
106afcd526bSJoshua Aberback 					struct dc_state *context,
107afcd526bSJoshua Aberback 					bool fast_validate);
1088e02c26aSJoshua Aberback 	void (*calculate_wm_and_dlg)(
109b3ff538cSDmytro Laktyushkin 				struct dc *dc, struct dc_state *context,
110b3ff538cSDmytro Laktyushkin 				display_e2e_pipe_params_st *pipes,
111b3ff538cSDmytro Laktyushkin 				int pipe_cnt,
112b3ff538cSDmytro Laktyushkin 				int vlevel);
113443dfba0SDmytro Laktyushkin 	void (*update_soc_for_wm_a)(
114443dfba0SDmytro Laktyushkin 				struct dc *dc, struct dc_state *context);
115ed07237cSIlya Bakoulin 	int (*populate_dml_pipes)(
116ed07237cSIlya Bakoulin 		struct dc *dc,
1172f488884SAlvin Lee 		struct dc_state *context,
118fa896813SIsabel Zhang 		display_e2e_pipe_params_st *pipes,
119fa896813SIsabel Zhang 		bool fast_validate);
120ed07237cSIlya Bakoulin 
121f42ef862SJimmy Kizito 	/*
122f42ef862SJimmy Kizito 	 * Algorithm for assigning available link encoders to links.
123f42ef862SJimmy Kizito 	 *
124f42ef862SJimmy Kizito 	 * Update link_enc_assignments table and link_enc_avail list accordingly in
125f42ef862SJimmy Kizito 	 * struct resource_context.
126f42ef862SJimmy Kizito 	 */
127f42ef862SJimmy Kizito 	void (*link_encs_assign)(
128f42ef862SJimmy Kizito 			struct dc *dc,
129f42ef862SJimmy Kizito 			struct dc_state *state,
130f42ef862SJimmy Kizito 			struct dc_stream_state *streams[],
131f42ef862SJimmy Kizito 			uint8_t stream_count);
132f42ef862SJimmy Kizito 	/*
133f42ef862SJimmy Kizito 	 * Unassign a link encoder from a stream.
134f42ef862SJimmy Kizito 	 *
135f42ef862SJimmy Kizito 	 * Update link_enc_assignments table and link_enc_avail list accordingly in
136f42ef862SJimmy Kizito 	 * struct resource_context.
137f42ef862SJimmy Kizito 	 */
138f42ef862SJimmy Kizito 	void (*link_enc_unassign)(
139f42ef862SJimmy Kizito 			struct dc_state *state,
140f42ef862SJimmy Kizito 			struct dc_stream_state *stream);
141f42ef862SJimmy Kizito 
1421dc90497SAndrey Grodzovsky 	enum dc_status (*validate_global)(
1431dc90497SAndrey Grodzovsky 		struct dc *dc,
144608ac7bbSJerry Zuo 		struct dc_state *context);
1451dc90497SAndrey Grodzovsky 
1464562236bSHarry Wentland 	struct pipe_ctx *(*acquire_idle_pipe_for_layer)(
147608ac7bbSJerry Zuo 			struct dc_state *context,
148a2b8659dSTony Cheng 			const struct resource_pool *pool,
1490971c40eSHarry Wentland 			struct dc_stream_state *stream);
1501dc90497SAndrey Grodzovsky 
1518e7095b9SDmytro Laktyushkin 	enum dc_status (*validate_plane)(const struct dc_plane_state *plane_state, struct dc_caps *caps);
1521dc90497SAndrey Grodzovsky 
1531dc90497SAndrey Grodzovsky 	enum dc_status (*add_stream_to_ctx)(
1541dc90497SAndrey Grodzovsky 			struct dc *dc,
155608ac7bbSJerry Zuo 			struct dc_state *new_ctx,
1561dc90497SAndrey Grodzovsky 			struct dc_stream_state *dc_stream);
157e56ae556SNikola Cornij 
158e56ae556SNikola Cornij 	enum dc_status (*remove_stream_from_ctx)(
159e56ae556SNikola Cornij 				struct dc *dc,
160e56ae556SNikola Cornij 				struct dc_state *new_ctx,
161e56ae556SNikola Cornij 				struct dc_stream_state *stream);
1628d8c82b6SJoseph Gravenor 	enum dc_status (*patch_unknown_plane_state)(
16374eac5f3SSu Sung Chung 			struct dc_plane_state *plane_state);
16474eac5f3SSu Sung Chung 
16578cc70b1SWesley Chalmers 	struct stream_encoder *(*find_first_free_match_stream_enc_for_link)(
16678cc70b1SWesley Chalmers 			struct resource_context *res_ctx,
16778cc70b1SWesley Chalmers 			const struct resource_pool *pool,
16878cc70b1SWesley Chalmers 			struct dc_stream_state *stream);
169345429a6SHarry Wentland 	void (*populate_dml_writeback_from_context)(
170345429a6SHarry Wentland 			struct dc *dc,
171345429a6SHarry Wentland 			struct resource_context *res_ctx,
172345429a6SHarry Wentland 			display_e2e_pipe_params_st *pipes);
17378cc70b1SWesley Chalmers 
174345429a6SHarry Wentland 	void (*set_mcif_arb_params)(
175345429a6SHarry Wentland 			struct dc *dc,
176345429a6SHarry Wentland 			struct dc_state *context,
177345429a6SHarry Wentland 			display_e2e_pipe_params_st *pipes,
178345429a6SHarry Wentland 			int pipe_cnt);
1791b2c7b2cSBhawanpreet Lakha 	void (*update_bw_bounding_box)(
1801b2c7b2cSBhawanpreet Lakha 			struct dc *dc,
1811b2c7b2cSBhawanpreet Lakha 			struct clk_bw_params *bw_params);
1825dba4991SBhawanpreet Lakha 	bool (*acquire_post_bldn_3dlut)(
1835dba4991SBhawanpreet Lakha 			struct resource_context *res_ctx,
1845dba4991SBhawanpreet Lakha 			const struct resource_pool *pool,
1855dba4991SBhawanpreet Lakha 			int mpcc_id,
1865dba4991SBhawanpreet Lakha 			struct dc_3dlut **lut,
1875dba4991SBhawanpreet Lakha 			struct dc_transfer_func **shaper);
1885dba4991SBhawanpreet Lakha 
1895dba4991SBhawanpreet Lakha 	bool (*release_post_bldn_3dlut)(
1905dba4991SBhawanpreet Lakha 			struct resource_context *res_ctx,
1915dba4991SBhawanpreet Lakha 			const struct resource_pool *pool,
1925dba4991SBhawanpreet Lakha 			struct dc_3dlut **lut,
1935dba4991SBhawanpreet Lakha 			struct dc_transfer_func **shaper);
19459b8ca24SAlex Hung 
195b4f71c8cSAurabindo Pillai 	enum dc_status (*add_dsc_to_stream_resource)(
196b4f71c8cSAurabindo Pillai 			struct dc *dc, struct dc_state *state,
197b4f71c8cSAurabindo Pillai 			struct dc_stream_state *stream);
198d3dfceb5SAurabindo Pillai 
199d3dfceb5SAurabindo Pillai 	void (*add_phantom_pipes)(
200d3dfceb5SAurabindo Pillai             struct dc *dc,
201d3dfceb5SAurabindo Pillai             struct dc_state *context,
202d3dfceb5SAurabindo Pillai             display_e2e_pipe_params_st *pipes,
203d3dfceb5SAurabindo Pillai 			unsigned int pipe_cnt,
204d3dfceb5SAurabindo Pillai             unsigned int index);
205*85f4bc0cSAlvin Lee 
206*85f4bc0cSAlvin Lee 	bool (*remove_phantom_pipes)(struct dc *dc, struct dc_state *context);
2074562236bSHarry Wentland };
2084562236bSHarry Wentland 
2094562236bSHarry Wentland struct audio_support{
2104562236bSHarry Wentland 	bool dp_audio;
2114562236bSHarry Wentland 	bool hdmi_audio_on_dongle;
2124562236bSHarry Wentland 	bool hdmi_audio_native;
2134562236bSHarry Wentland };
2144562236bSHarry Wentland 
215f0e3db90SHarry Wentland #define NO_UNDERLAY_PIPE -1
216f0e3db90SHarry Wentland 
2174562236bSHarry Wentland struct resource_pool {
2184562236bSHarry Wentland 	struct mem_input *mis[MAX_PIPES];
2198feabd03SYue Hin Lau 	struct hubp *hubps[MAX_PIPES];
2204562236bSHarry Wentland 	struct input_pixel_processor *ipps[MAX_PIPES];
2214562236bSHarry Wentland 	struct transform *transforms[MAX_PIPES];
222d94585a0SYue Hin Lau 	struct dpp *dpps[MAX_PIPES];
2234562236bSHarry Wentland 	struct output_pixel_processor *opps[MAX_PIPES];
2244562236bSHarry Wentland 	struct timing_generator *timing_generators[MAX_PIPES];
2254562236bSHarry Wentland 	struct stream_encoder *stream_enc[MAX_PIPES * 2];
226c9ef081dSYue Hin Lau 	struct hubbub *hubbub;
227cc408d72SDmytro Laktyushkin 	struct mpc *mpc;
2280f1a6ad7SJun Lei 	struct pp_smu_funcs *pp_smu;
2291877ccf6SDavid Francis 	struct dce_aux *engines[MAX_PIPES];
230c85e6e54SDavid Francis 	struct dce_i2c_hw *hw_i2cs[MAX_PIPES];
231c85e6e54SDavid Francis 	struct dce_i2c_sw *sw_i2cs[MAX_PIPES];
232c85e6e54SDavid Francis 	bool i2c_hw_buffer_in_use;
2334562236bSHarry Wentland 
234345429a6SHarry Wentland 	struct dwbc *dwbc[MAX_DWB_PIPES];
235345429a6SHarry Wentland 	struct mcif_wb *mcif_wb[MAX_DWB_PIPES];
236345429a6SHarry Wentland 	struct {
237345429a6SHarry Wentland 		unsigned int gsl_0:1;
238345429a6SHarry Wentland 		unsigned int gsl_1:1;
239345429a6SHarry Wentland 		unsigned int gsl_2:1;
240345429a6SHarry Wentland 	} gsl_groups;
241345429a6SHarry Wentland 
24297bda032SHarry Wentland 	struct display_stream_compressor *dscs[MAX_PIPES];
243345429a6SHarry Wentland 
2444562236bSHarry Wentland 	unsigned int pipe_count;
2454562236bSHarry Wentland 	unsigned int underlay_pipe_index;
2464562236bSHarry Wentland 	unsigned int stream_enc_count;
247929c3aaaSEric Bernstein 
248e1f4328fSJimmy Kizito 	/* An array for accessing the link encoder objects that have been created.
249e1f4328fSJimmy Kizito 	 * Index in array corresponds to engine ID - viz. 0: ENGINE_ID_DIGA
250e1f4328fSJimmy Kizito 	 */
251e1f4328fSJimmy Kizito 	struct link_encoder *link_encoders[MAX_DIG_LINK_ENCODERS];
252e1f4328fSJimmy Kizito 	/* Number of DIG link encoder objects created - i.e. number of valid
253e1f4328fSJimmy Kizito 	 * entries in link_encoders array.
254e1f4328fSJimmy Kizito 	 */
255e1f4328fSJimmy Kizito 	unsigned int dig_link_enc_count;
256eabf2019SJimmy Kizito 	/* Number of USB4 DPIA (DisplayPort Input Adapter) link objects created.*/
257eabf2019SJimmy Kizito 	unsigned int usb4_dpia_count;
258e1f4328fSJimmy Kizito 
25983228ebbSFangzhi Zuo 	unsigned int hpo_dp_stream_enc_count;
26083228ebbSFangzhi Zuo 	struct hpo_dp_stream_encoder *hpo_dp_stream_enc[MAX_HPO_DP2_ENCODERS];
2613bc8d921SFangzhi Zuo 	unsigned int hpo_dp_link_enc_count;
2623bc8d921SFangzhi Zuo 	struct hpo_dp_link_encoder *hpo_dp_link_enc[MAX_HPO_DP2_LINK_ENCODERS];
2635dba4991SBhawanpreet Lakha 	struct dc_3dlut *mpc_lut[MAX_PIPES];
2645dba4991SBhawanpreet Lakha 	struct dc_transfer_func *mpc_shaper[MAX_PIPES];
26559b8ca24SAlex Hung 
26633d7598dSJun Lei 	struct {
26733d7598dSJun Lei 		unsigned int xtalin_clock_inKhz;
26833d7598dSJun Lei 		unsigned int dccg_ref_clock_inKhz;
26933d7598dSJun Lei 		unsigned int dchub_ref_clock_inKhz;
27033d7598dSJun Lei 	} ref_clocks;
2713be1406aSYongqiang Sun 	unsigned int timing_generator_count;
272345429a6SHarry Wentland 	unsigned int mpcc_count;
2734562236bSHarry Wentland 
274345429a6SHarry Wentland 	unsigned int writeback_pipe_count;
2754562236bSHarry Wentland 	/*
2764562236bSHarry Wentland 	 * reserved clock source for DP
2774562236bSHarry Wentland 	 */
2784562236bSHarry Wentland 	struct clock_source *dp_clock_source;
2794562236bSHarry Wentland 
2804562236bSHarry Wentland 	struct clock_source *clock_sources[MAX_CLOCK_SOURCES];
2814562236bSHarry Wentland 	unsigned int clk_src_count;
2824562236bSHarry Wentland 
2837352193aSTai Man 	struct audio *audios[MAX_AUDIOS];
2844562236bSHarry Wentland 	unsigned int audio_count;
2854562236bSHarry Wentland 	struct audio_support audio_support;
2864562236bSHarry Wentland 
287ea2e8d92SDmytro Laktyushkin 	struct dccg *dccg;
2884562236bSHarry Wentland 	struct irq_service *irqs;
2894562236bSHarry Wentland 
2905e7773a2SAnthony Koo 	struct abm *abm;
2915e7773a2SAnthony Koo 	struct dmcu *dmcu;
2924c1a1335SWyatt Wood 	struct dmub_psr *psr;
2935e7773a2SAnthony Koo 
294d99f1387SBhawanpreet Lakha 	struct abm *multiple_abms[MAX_PIPES];
295d99f1387SBhawanpreet Lakha 
2964562236bSHarry Wentland 	const struct resource_funcs *funcs;
2974562236bSHarry Wentland 	const struct resource_caps *res_cap;
298d9a07577SJun Lei 
299d9a07577SJun Lei 	struct ddc_service *oem_device;
3004562236bSHarry Wentland };
3014562236bSHarry Wentland 
302f553e681SDmytro Laktyushkin struct dcn_fe_bandwidth {
30369338c1fSDmytro Laktyushkin 	int dppclk_khz;
304799c5b9cSWesley Chalmers 
305f553e681SDmytro Laktyushkin };
306f553e681SDmytro Laktyushkin 
30779b06f0cSHarry Wentland struct stream_resource {
308a6a6cb34SHarry Wentland 	struct output_pixel_processor *opp;
30997bda032SHarry Wentland 	struct display_stream_compressor *dsc;
3106b670fa9SHarry Wentland 	struct timing_generator *tg;
3118e9c4c8cSHarry Wentland 	struct stream_encoder *stream_enc;
31283228ebbSFangzhi Zuo 	struct hpo_dp_stream_encoder *hpo_dp_stream_enc;
313afaacef4SHarry Wentland 	struct audio *audio;
31410688217SHarry Wentland 
31510688217SHarry Wentland 	struct pixel_clk_params pix_clk_params;
31696c50c0dSHarry Wentland 	struct encoder_info_frame encoder_info_frame;
3179aef1a31SSivapiriyanKumarasamy 
3189aef1a31SSivapiriyanKumarasamy 	struct abm *abm;
319345429a6SHarry Wentland 	/* There are only (num_pipes+1)/2 groups. 0 means unassigned,
320345429a6SHarry Wentland 	 * otherwise it's using group number 'gsl_group-1'
321345429a6SHarry Wentland 	 */
322345429a6SHarry Wentland 	uint8_t gsl_group;
32379b06f0cSHarry Wentland };
32479b06f0cSHarry Wentland 
32579b06f0cSHarry Wentland struct plane_resource {
3266702a9acSHarry Wentland 	struct scaler_data scl_data;
3278feabd03SYue Hin Lau 	struct hubp *hubp;
32886a66c4eSHarry Wentland 	struct mem_input *mi;
32986a66c4eSHarry Wentland 	struct input_pixel_processor *ipp;
33086a66c4eSHarry Wentland 	struct transform *xfm;
331d94585a0SYue Hin Lau 	struct dpp *dpp;
332e07f541fSYongqiang Sun 	uint8_t mpcc_inst;
333f553e681SDmytro Laktyushkin 
334f553e681SDmytro Laktyushkin 	struct dcn_fe_bandwidth bw;
33579b06f0cSHarry Wentland };
33679b06f0cSHarry Wentland 
3374c3adc0bSWenjing Liu #define LINK_RES_HPO_DP_REC_MAP__MASK 0xFFFF
3384c3adc0bSWenjing Liu #define LINK_RES_HPO_DP_REC_MAP__SHIFT 0
3394c3adc0bSWenjing Liu 
340ef30f441SWenjing Liu /* all mappable hardware resources used to enable a link */
341ef30f441SWenjing Liu struct link_resource {
342f3fac948SWenjing Liu 	struct hpo_dp_link_encoder *hpo_dp_link_enc;
343ef30f441SWenjing Liu };
344ef30f441SWenjing Liu 
34524c18794SDmytro Laktyushkin union pipe_update_flags {
34624c18794SDmytro Laktyushkin 	struct {
34724c18794SDmytro Laktyushkin 		uint32_t enable : 1;
34824c18794SDmytro Laktyushkin 		uint32_t disable : 1;
34924c18794SDmytro Laktyushkin 		uint32_t odm : 1;
35024c18794SDmytro Laktyushkin 		uint32_t global_sync : 1;
35124c18794SDmytro Laktyushkin 		uint32_t opp_changed : 1;
35224c18794SDmytro Laktyushkin 		uint32_t tg_changed : 1;
35324c18794SDmytro Laktyushkin 		uint32_t mpcc : 1;
35424c18794SDmytro Laktyushkin 		uint32_t dppclk : 1;
35524c18794SDmytro Laktyushkin 		uint32_t hubp_interdependent : 1;
35624c18794SDmytro Laktyushkin 		uint32_t hubp_rq_dlg_ttu : 1;
35724c18794SDmytro Laktyushkin 		uint32_t gamut_remap : 1;
35824c18794SDmytro Laktyushkin 		uint32_t scaler : 1;
35924c18794SDmytro Laktyushkin 		uint32_t viewport : 1;
360498563cfSJinZe.Xu 		uint32_t plane_changed : 1;
361ba5a5371SNicholas Kazlauskas 		uint32_t det_size : 1;
36224c18794SDmytro Laktyushkin 	} bits;
36324c18794SDmytro Laktyushkin 	uint32_t raw;
36424c18794SDmytro Laktyushkin };
36524c18794SDmytro Laktyushkin 
3664562236bSHarry Wentland struct pipe_ctx {
3673be5262eSHarry Wentland 	struct dc_plane_state *plane_state;
3680971c40eSHarry Wentland 	struct dc_stream_state *stream;
3694562236bSHarry Wentland 
37079b06f0cSHarry Wentland 	struct plane_resource plane_res;
37179b06f0cSHarry Wentland 	struct stream_resource stream_res;
372ef30f441SWenjing Liu 	struct link_resource link_res;
37379b06f0cSHarry Wentland 
3744562236bSHarry Wentland 	struct clock_source *clock_source;
3754562236bSHarry Wentland 
3764562236bSHarry Wentland 	struct pll_settings pll_settings;
3774562236bSHarry Wentland 
3784562236bSHarry Wentland 	uint8_t pipe_idx;
379a896f870SMeenakshikumar Somasundaram 	uint8_t pipe_idx_syncd;
3804562236bSHarry Wentland 
3814562236bSHarry Wentland 	struct pipe_ctx *top_pipe;
3824562236bSHarry Wentland 	struct pipe_ctx *bottom_pipe;
383b1f6d01cSDmytro Laktyushkin 	struct pipe_ctx *next_odm_pipe;
384b1f6d01cSDmytro Laktyushkin 	struct pipe_ctx *prev_odm_pipe;
385f0558542SDmytro Laktyushkin 
386ff5ef992SAlex Deucher 	struct _vcs_dpi_display_dlg_regs_st dlg_regs;
387ff5ef992SAlex Deucher 	struct _vcs_dpi_display_ttu_regs_st ttu_regs;
388ff5ef992SAlex Deucher 	struct _vcs_dpi_display_rq_regs_st rq_regs;
389ff5ef992SAlex Deucher 	struct _vcs_dpi_display_pipe_dest_params_st pipe_dlg_param;
3901f2fcc81SHarry Wentland 	struct _vcs_dpi_display_rq_params_st dml_rq_param;
3911f2fcc81SHarry Wentland 	struct _vcs_dpi_display_dlg_sys_params_st dml_dlg_sys_param;
3921f2fcc81SHarry Wentland 	struct _vcs_dpi_display_e2e_pipe_params_st dml_input;
393ba5a5371SNicholas Kazlauskas 	int det_buffer_size_kb;
394ba5a5371SNicholas Kazlauskas 	bool unbounded_req;
39559b8ca24SAlex Hung 
39624c18794SDmytro Laktyushkin 	union pipe_update_flags update_flags;
397345429a6SHarry Wentland 	struct dwbc *dwbc;
398345429a6SHarry Wentland 	struct mcif_wb *mcif_wb;
399d209124dSBhawanpreet Lakha 	bool vtp_locked;
4004562236bSHarry Wentland };
4014562236bSHarry Wentland 
4020d4b4253SJimmy Kizito /* Data used for dynamic link encoder assignment.
4030d4b4253SJimmy Kizito  * Tracks current and future assignments; available link encoders;
4040d4b4253SJimmy Kizito  * and mode of operation (whether to use current or future assignments).
4050d4b4253SJimmy Kizito  */
4060d4b4253SJimmy Kizito struct link_enc_cfg_context {
4070d4b4253SJimmy Kizito 	enum link_enc_cfg_mode mode;
4080d4b4253SJimmy Kizito 	struct link_enc_assignment link_enc_assignments[MAX_PIPES];
4090d4b4253SJimmy Kizito 	enum engine_id link_enc_avail[MAX_DIG_LINK_ENCODERS];
4100d4b4253SJimmy Kizito 	struct link_enc_assignment transient_assignments[MAX_PIPES];
4110d4b4253SJimmy Kizito };
4120d4b4253SJimmy Kizito 
4134562236bSHarry Wentland struct resource_context {
4144562236bSHarry Wentland 	struct pipe_ctx pipe_ctx[MAX_PIPES];
4154562236bSHarry Wentland 	bool is_stream_enc_acquired[MAX_PIPES * 2];
4164562236bSHarry Wentland 	bool is_audio_acquired[MAX_PIPES];
4174562236bSHarry Wentland 	uint8_t clock_source_ref_count[MAX_CLOCK_SOURCES];
4184562236bSHarry Wentland 	uint8_t dp_clock_source_ref_count;
419345429a6SHarry Wentland 	bool is_dsc_acquired[MAX_PIPES];
4200d4b4253SJimmy Kizito 	struct link_enc_cfg_context link_enc_cfg_ctx;
42183228ebbSFangzhi Zuo 	bool is_hpo_dp_stream_enc_acquired[MAX_HPO_DP2_ENCODERS];
4226dd8931bSWenjing Liu 	unsigned int hpo_dp_link_enc_to_link_idx[MAX_HPO_DP2_LINK_ENCODERS];
4236dd8931bSWenjing Liu 	int hpo_dp_link_enc_ref_cnts[MAX_HPO_DP2_LINK_ENCODERS];
4245dba4991SBhawanpreet Lakha 	bool is_mpc_3dlut_acquired[MAX_PIPES];
4254562236bSHarry Wentland };
4264562236bSHarry Wentland 
4279037d802SDmytro Laktyushkin struct dce_bw_output {
4289037d802SDmytro Laktyushkin 	bool cpuc_state_change_enable;
4299037d802SDmytro Laktyushkin 	bool cpup_state_change_enable;
4309037d802SDmytro Laktyushkin 	bool stutter_mode_enable;
4319037d802SDmytro Laktyushkin 	bool nbp_state_change_enable;
4329037d802SDmytro Laktyushkin 	bool all_displays_in_sync;
4339037d802SDmytro Laktyushkin 	struct dce_watermarks urgent_wm_ns[MAX_PIPES];
4349037d802SDmytro Laktyushkin 	struct dce_watermarks stutter_exit_wm_ns[MAX_PIPES];
435b361521fSMikita Lipski 	struct dce_watermarks stutter_entry_wm_ns[MAX_PIPES];
4369037d802SDmytro Laktyushkin 	struct dce_watermarks nbp_state_change_wm_ns[MAX_PIPES];
4379037d802SDmytro Laktyushkin 	int sclk_khz;
4389037d802SDmytro Laktyushkin 	int sclk_deep_sleep_khz;
4399037d802SDmytro Laktyushkin 	int yclk_khz;
4409037d802SDmytro Laktyushkin 	int dispclk_khz;
4419037d802SDmytro Laktyushkin 	int blackout_recovery_time_us;
4429037d802SDmytro Laktyushkin };
4439037d802SDmytro Laktyushkin 
444345429a6SHarry Wentland struct dcn_bw_writeback {
445345429a6SHarry Wentland 	struct mcif_arb_params mcif_wb_arb[MAX_DWB_PIPES];
446345429a6SHarry Wentland };
447345429a6SHarry Wentland 
4489037d802SDmytro Laktyushkin struct dcn_bw_output {
449d578839cSDmytro Laktyushkin 	struct dc_clocks clk;
4509037d802SDmytro Laktyushkin 	struct dcn_watermark_set watermarks;
451345429a6SHarry Wentland 	struct dcn_bw_writeback bw_writeback;
452ba5a5371SNicholas Kazlauskas 	int compbuf_size_kb;
4539037d802SDmytro Laktyushkin };
4549037d802SDmytro Laktyushkin 
455813d20dcSAidan Wood union bw_output {
4569037d802SDmytro Laktyushkin 	struct dcn_bw_output dcn;
4579037d802SDmytro Laktyushkin 	struct dce_bw_output dce;
4589037d802SDmytro Laktyushkin };
4599037d802SDmytro Laktyushkin 
460813d20dcSAidan Wood struct bw_context {
461813d20dcSAidan Wood 	union bw_output bw;
462813d20dcSAidan Wood 	struct display_mode_lib dml;
463813d20dcSAidan Wood };
4642119aa17SDavid Francis /**
4652119aa17SDavid Francis  * struct dc_state - The full description of a state requested by a user
4662119aa17SDavid Francis  *
4672119aa17SDavid Francis  * @streams: Stream properties
4682119aa17SDavid Francis  * @stream_status: The planes on a given stream
4692119aa17SDavid Francis  * @res_ctx: Persistent state of resources
470813d20dcSAidan Wood  * @bw_ctx: The output from bandwidth and watermark calculations and the DML
4712119aa17SDavid Francis  * @pp_display_cfg: PowerPlay clocks and settings
4722119aa17SDavid Francis  * @dcn_bw_vars: non-stack memory to support bandwidth calculations
4732119aa17SDavid Francis  *
4742119aa17SDavid Francis  */
475608ac7bbSJerry Zuo struct dc_state {
4760971c40eSHarry Wentland 	struct dc_stream_state *streams[MAX_PIPES];
477ab2541b6SAric Cyr 	struct dc_stream_status stream_status[MAX_PIPES];
478ab2541b6SAric Cyr 	uint8_t stream_count;
4790825d965SEric Yang 	uint8_t stream_mask;
4804562236bSHarry Wentland 
4814562236bSHarry Wentland 	struct resource_context res_ctx;
4824562236bSHarry Wentland 
483813d20dcSAidan Wood 	struct bw_context bw_ctx;
4849037d802SDmytro Laktyushkin 
4855ea81b91SDmytro Laktyushkin 	/* Note: these are big structures, do *not* put on stack! */
4864562236bSHarry Wentland 	struct dm_pp_display_configuration pp_display_cfg;
487ff5ef992SAlex Deucher 	struct dcn_bw_internal_vars dcn_bw_vars;
4888a76708eSAndrey Grodzovsky 
4890de34efcSDmytro Laktyushkin 	struct clk_mgr *clk_mgr;
490ab8db3e1SAndrey Grodzovsky 
4918ee5702aSDave Airlie 	struct kref refcount;
4926b85151fSMartin Leung 
4936b85151fSMartin Leung 	struct {
4946b85151fSMartin Leung 		unsigned int stutter_period_us;
4956b85151fSMartin Leung 	} perf_params;
4964562236bSHarry Wentland };
4974562236bSHarry Wentland 
498e4b0eac3SJasdeep Dhillon struct dc_bounding_box_max_clk {
499e4b0eac3SJasdeep Dhillon 	int max_dcfclk_mhz;
500e4b0eac3SJasdeep Dhillon 	int max_dispclk_mhz;
501e4b0eac3SJasdeep Dhillon 	int max_dppclk_mhz;
502e4b0eac3SJasdeep Dhillon 	int max_phyclk_mhz;
503e4b0eac3SJasdeep Dhillon };
504e4b0eac3SJasdeep Dhillon 
5054562236bSHarry Wentland #endif /* _CORE_TYPES_H_ */
506