17ed4e635SHarry Wentland /*
27ed4e635SHarry Wentland * Copyright 2017 Advanced Micro Devices, Inc.
37ed4e635SHarry Wentland  *
47ed4e635SHarry Wentland  * Permission is hereby granted, free of charge, to any person obtaining a
57ed4e635SHarry Wentland  * copy of this software and associated documentation files (the "Software"),
67ed4e635SHarry Wentland  * to deal in the Software without restriction, including without limitation
77ed4e635SHarry Wentland  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
87ed4e635SHarry Wentland  * and/or sell copies of the Software, and to permit persons to whom the
97ed4e635SHarry Wentland  * Software is furnished to do so, subject to the following conditions:
107ed4e635SHarry Wentland  *
117ed4e635SHarry Wentland  * The above copyright notice and this permission notice shall be included in
127ed4e635SHarry Wentland  * all copies or substantial portions of the Software.
137ed4e635SHarry Wentland  *
147ed4e635SHarry Wentland  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
157ed4e635SHarry Wentland  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
167ed4e635SHarry Wentland  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
177ed4e635SHarry Wentland  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
187ed4e635SHarry Wentland  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
197ed4e635SHarry Wentland  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
207ed4e635SHarry Wentland  * OTHER DEALINGS IN THE SOFTWARE.
217ed4e635SHarry Wentland  *
227ed4e635SHarry Wentland  * Authors: AMD
237ed4e635SHarry Wentland  *
247ed4e635SHarry Wentland  */
257ed4e635SHarry Wentland 
267ed4e635SHarry Wentland #ifndef __DC_RESOURCE_DCN20_H__
277ed4e635SHarry Wentland #define __DC_RESOURCE_DCN20_H__
287ed4e635SHarry Wentland 
297ed4e635SHarry Wentland #include "core_types.h"
30cf689e86SMelissa Wen #include "dml/dcn20/dcn20_fpu.h"
317ed4e635SHarry Wentland 
327ed4e635SHarry Wentland #define TO_DCN20_RES_POOL(pool)\
337ed4e635SHarry Wentland 	container_of(pool, struct dcn20_resource_pool, base)
347ed4e635SHarry Wentland 
357ed4e635SHarry Wentland struct dc;
367ed4e635SHarry Wentland struct resource_pool;
377ed4e635SHarry Wentland struct _vcs_dpi_display_pipe_params_st;
387ed4e635SHarry Wentland 
39cf689e86SMelissa Wen extern struct _vcs_dpi_ip_params_st dcn2_0_ip;
40cf689e86SMelissa Wen extern struct _vcs_dpi_ip_params_st dcn2_0_nv14_ip;
41cf689e86SMelissa Wen extern struct _vcs_dpi_soc_bounding_box_st dcn2_0_soc;
42cf689e86SMelissa Wen extern struct _vcs_dpi_soc_bounding_box_st dcn2_0_nv14_soc;
43cf689e86SMelissa Wen extern struct _vcs_dpi_soc_bounding_box_st dcn2_0_nv12_soc;
44cf689e86SMelissa Wen 
457ed4e635SHarry Wentland struct dcn20_resource_pool {
467ed4e635SHarry Wentland 	struct resource_pool base;
477ed4e635SHarry Wentland };
487ed4e635SHarry Wentland struct resource_pool *dcn20_create_resource_pool(
497ed4e635SHarry Wentland 		const struct dc_init_data *init_data,
507ed4e635SHarry Wentland 		struct dc *dc);
517ed4e635SHarry Wentland 
527ed4e635SHarry Wentland struct link_encoder *dcn20_link_encoder_create(
53e216431bSAurabindo Pillai 	struct dc_context *ctx,
547ed4e635SHarry Wentland 	const struct encoder_init_data *enc_init_data);
557ed4e635SHarry Wentland 
567ed4e635SHarry Wentland unsigned int dcn20_calc_max_scaled_time(
577ed4e635SHarry Wentland 		unsigned int time_per_pixel,
587ed4e635SHarry Wentland 		enum mmhubbub_wbif_mode mode,
597ed4e635SHarry Wentland 		unsigned int urgent_watermark);
60cf689e86SMelissa Wen 
61*198f0e89SWenjing Liu struct pipe_ctx *dcn20_acquire_free_pipe_for_layer(
62460ea898SWenjing Liu 		const struct dc_state *cur_ctx,
63460ea898SWenjing Liu 		struct dc_state *new_ctx,
647ed4e635SHarry Wentland 		const struct resource_pool *pool,
65460ea898SWenjing Liu 		const struct pipe_ctx *opp_head_pipe);
667ed4e635SHarry Wentland 
677ed4e635SHarry Wentland struct stream_encoder *dcn20_stream_encoder_create(
687ed4e635SHarry Wentland 	enum engine_id eng_id,
697ed4e635SHarry Wentland 	struct dc_context *ctx);
707ed4e635SHarry Wentland 
717ed4e635SHarry Wentland struct dce_hwseq *dcn20_hwseq_create(
727ed4e635SHarry Wentland 	struct dc_context *ctx);
737ed4e635SHarry Wentland 
747ed4e635SHarry Wentland bool dcn20_get_dcc_compression_cap(const struct dc *dc,
757ed4e635SHarry Wentland 		const struct dc_dcc_surface_param *input,
767ed4e635SHarry Wentland 		struct dc_surface_dcc_cap *output);
777ed4e635SHarry Wentland 
787ed4e635SHarry Wentland void dcn20_dpp_destroy(struct dpp **dpp);
797ed4e635SHarry Wentland 
807ed4e635SHarry Wentland struct dpp *dcn20_dpp_create(
817ed4e635SHarry Wentland 	struct dc_context *ctx,
827ed4e635SHarry Wentland 	uint32_t inst);
837ed4e635SHarry Wentland 
847ed4e635SHarry Wentland struct input_pixel_processor *dcn20_ipp_create(
857ed4e635SHarry Wentland 	struct dc_context *ctx, uint32_t inst);
867ed4e635SHarry Wentland 
877ed4e635SHarry Wentland struct output_pixel_processor *dcn20_opp_create(
887ed4e635SHarry Wentland 	struct dc_context *ctx, uint32_t inst);
897ed4e635SHarry Wentland 
907ed4e635SHarry Wentland struct dce_aux *dcn20_aux_engine_create(
917ed4e635SHarry Wentland 	struct dc_context *ctx, uint32_t inst);
927ed4e635SHarry Wentland 
937ed4e635SHarry Wentland struct dce_i2c_hw *dcn20_i2c_hw_create(
947ed4e635SHarry Wentland 	struct dc_context *ctx,
957ed4e635SHarry Wentland 	uint32_t inst);
967ed4e635SHarry Wentland 
977ed4e635SHarry Wentland void dcn20_clock_source_destroy(struct clock_source **clk_src);
987ed4e635SHarry Wentland 
997ed4e635SHarry Wentland struct display_stream_compressor *dcn20_dsc_create(
1007ed4e635SHarry Wentland 	struct dc_context *ctx, uint32_t inst);
1017ed4e635SHarry Wentland void dcn20_dsc_destroy(struct display_stream_compressor **dsc);
1027ed4e635SHarry Wentland 
1037ed4e635SHarry Wentland struct hubp *dcn20_hubp_create(
1047ed4e635SHarry Wentland 	struct dc_context *ctx,
1057ed4e635SHarry Wentland 	uint32_t inst);
1067ed4e635SHarry Wentland struct timing_generator *dcn20_timing_generator_create(
1077ed4e635SHarry Wentland 		struct dc_context *ctx,
1087ed4e635SHarry Wentland 		uint32_t instance);
1097ed4e635SHarry Wentland struct mpc *dcn20_mpc_create(struct dc_context *ctx);
1107ed4e635SHarry Wentland struct hubbub *dcn20_hubbub_create(struct dc_context *ctx);
1117ed4e635SHarry Wentland 
1127ed4e635SHarry Wentland bool dcn20_dwbc_create(struct dc_context *ctx, struct resource_pool *pool);
1137ed4e635SHarry Wentland bool dcn20_mmhubbub_create(struct dc_context *ctx, struct resource_pool *pool);
1147ed4e635SHarry Wentland 
1157ed4e635SHarry Wentland void dcn20_set_mcif_arb_params(
1167ed4e635SHarry Wentland 		struct dc *dc,
1177ed4e635SHarry Wentland 		struct dc_state *context,
1187ed4e635SHarry Wentland 		display_e2e_pipe_params_st *pipes,
1197ed4e635SHarry Wentland 		int pipe_cnt);
120cb0b554aSAlex Deucher bool dcn20_validate_bandwidth(struct dc *dc, struct dc_state *context, bool fast_validate);
121ea817dd5SDmytro Laktyushkin void dcn20_merge_pipes_for_validate(
122ea817dd5SDmytro Laktyushkin 		struct dc *dc,
123ea817dd5SDmytro Laktyushkin 		struct dc_state *context);
124b6bfba6cSDmytro Laktyushkin int dcn20_validate_apply_pipe_split_flags(
125b6bfba6cSDmytro Laktyushkin 		struct dc *dc,
126b6bfba6cSDmytro Laktyushkin 		struct dc_state *context,
127b6bfba6cSDmytro Laktyushkin 		int vlevel,
12865d68369SIsabel Zhang 		int *split,
1297287a675SDmytro Laktyushkin 		bool *merge);
1307287a675SDmytro Laktyushkin void dcn20_release_dsc(struct resource_context *res_ctx,
1317287a675SDmytro Laktyushkin 			const struct resource_pool *pool,
1327287a675SDmytro Laktyushkin 			struct display_stream_compressor **dsc);
133b6bfba6cSDmytro Laktyushkin bool dcn20_validate_dsc(struct dc *dc, struct dc_state *new_ctx);
13465d68369SIsabel Zhang void dcn20_split_stream_for_mpc(
135b6bfba6cSDmytro Laktyushkin 		struct resource_context *res_ctx,
136b6bfba6cSDmytro Laktyushkin 		const struct resource_pool *pool,
137b6bfba6cSDmytro Laktyushkin 		struct pipe_ctx *primary_pipe,
138b6bfba6cSDmytro Laktyushkin 		struct pipe_ctx *secondary_pipe);
139b6bfba6cSDmytro Laktyushkin bool dcn20_split_stream_for_odm(
14014e49bb3SNikola Cornij 		const struct dc *dc,
141b6bfba6cSDmytro Laktyushkin 		struct resource_context *res_ctx,
142b6bfba6cSDmytro Laktyushkin 		struct pipe_ctx *prev_odm_pipe,
143b6bfba6cSDmytro Laktyushkin 		struct pipe_ctx *next_odm_pipe);
144570bc18cSDmytro Laktyushkin void dcn20_acquire_dsc(const struct dc *dc,
145570bc18cSDmytro Laktyushkin 			struct resource_context *res_ctx,
146570bc18cSDmytro Laktyushkin 			struct display_stream_compressor **dsc,
147570bc18cSDmytro Laktyushkin 			int pipe_idx);
148b6bfba6cSDmytro Laktyushkin struct pipe_ctx *dcn20_find_secondary_pipe(struct dc *dc,
149b6bfba6cSDmytro Laktyushkin 		struct resource_context *res_ctx,
150b6bfba6cSDmytro Laktyushkin 		const struct resource_pool *pool,
151b6bfba6cSDmytro Laktyushkin 		const struct pipe_ctx *primary_pipe);
1526de20237SEric Yang bool dcn20_fast_validate_bw(
1536de20237SEric Yang 		struct dc *dc,
1546de20237SEric Yang 		struct dc_state *context,
1556de20237SEric Yang 		display_e2e_pipe_params_st *pipes,
1565e335addSEric Yang 		int *pipe_cnt_out,
1576de20237SEric Yang 		int *pipe_split_from,
158fa896813SIsabel Zhang 		int *vlevel_out,
159fa896813SIsabel Zhang 		bool fast_validate);
1607ed4e635SHarry Wentland 
1617ed4e635SHarry Wentland enum dc_status dcn20_build_mapped_resource(const struct dc *dc, struct dc_state *context, struct dc_stream_state *stream);
1627ed4e635SHarry Wentland enum dc_status dcn20_add_stream_to_ctx(struct dc *dc, struct dc_state *new_ctx, struct dc_stream_state *dc_stream);
1638c20a1edSDavid Francis enum dc_status dcn20_add_dsc_to_stream_resource(struct dc *dc, struct dc_state *dc_ctx, struct dc_stream_state *dc_stream);
1647ed4e635SHarry Wentland enum dc_status dcn20_remove_stream_from_ctx(struct dc *dc, struct dc_state *new_ctx, struct dc_stream_state *dc_stream);
1658d8c82b6SJoseph Gravenor enum dc_status dcn20_patch_unknown_plane_state(struct dc_plane_state *plane_state);
1667ed4e635SHarry Wentland 
1677ed4e635SHarry Wentland #endif /* __DC_RESOURCE_DCN20_H__ */
1687ed4e635SHarry Wentland 
169