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  * Authors: AMD
23  *
24  */
25 
26 #ifndef __DC_RESOURCE_DCN20_H__
27 #define __DC_RESOURCE_DCN20_H__
28 
29 #include "core_types.h"
30 
31 #define TO_DCN20_RES_POOL(pool)\
32 	container_of(pool, struct dcn20_resource_pool, base)
33 
34 struct dc;
35 struct resource_pool;
36 struct _vcs_dpi_display_pipe_params_st;
37 
38 struct dcn20_resource_pool {
39 	struct resource_pool base;
40 };
41 struct resource_pool *dcn20_create_resource_pool(
42 		const struct dc_init_data *init_data,
43 		struct dc *dc);
44 
45 struct link_encoder *dcn20_link_encoder_create(
46 	const struct encoder_init_data *enc_init_data);
47 
48 unsigned int dcn20_calc_max_scaled_time(
49 		unsigned int time_per_pixel,
50 		enum mmhubbub_wbif_mode mode,
51 		unsigned int urgent_watermark);
52 int dcn20_populate_dml_pipes_from_context(
53 		struct dc *dc,
54 		struct dc_state *context,
55 		display_e2e_pipe_params_st *pipes,
56 		bool fast_validate);
57 struct pipe_ctx *dcn20_acquire_idle_pipe_for_layer(
58 		struct dc_state *state,
59 		const struct resource_pool *pool,
60 		struct dc_stream_state *stream);
61 
62 struct stream_encoder *dcn20_stream_encoder_create(
63 	enum engine_id eng_id,
64 	struct dc_context *ctx);
65 
66 struct dce_hwseq *dcn20_hwseq_create(
67 	struct dc_context *ctx);
68 
69 bool dcn20_get_dcc_compression_cap(const struct dc *dc,
70 		const struct dc_dcc_surface_param *input,
71 		struct dc_surface_dcc_cap *output);
72 
73 void dcn20_dpp_destroy(struct dpp **dpp);
74 
75 struct dpp *dcn20_dpp_create(
76 	struct dc_context *ctx,
77 	uint32_t inst);
78 
79 struct input_pixel_processor *dcn20_ipp_create(
80 	struct dc_context *ctx, uint32_t inst);
81 
82 
83 struct output_pixel_processor *dcn20_opp_create(
84 	struct dc_context *ctx, uint32_t inst);
85 
86 struct dce_aux *dcn20_aux_engine_create(
87 	struct dc_context *ctx, uint32_t inst);
88 
89 struct dce_i2c_hw *dcn20_i2c_hw_create(
90 	struct dc_context *ctx,
91 	uint32_t inst);
92 
93 void dcn20_clock_source_destroy(struct clock_source **clk_src);
94 
95 struct display_stream_compressor *dcn20_dsc_create(
96 	struct dc_context *ctx, uint32_t inst);
97 void dcn20_dsc_destroy(struct display_stream_compressor **dsc);
98 
99 void dcn20_cap_soc_clocks(
100 		struct _vcs_dpi_soc_bounding_box_st *bb,
101 		struct pp_smu_nv_clock_table max_clocks);
102 void dcn20_update_bounding_box(struct dc *dc, struct _vcs_dpi_soc_bounding_box_st *bb,
103 		struct pp_smu_nv_clock_table *max_clocks, unsigned int *uclk_states, unsigned int num_states);
104 struct hubp *dcn20_hubp_create(
105 	struct dc_context *ctx,
106 	uint32_t inst);
107 struct timing_generator *dcn20_timing_generator_create(
108 		struct dc_context *ctx,
109 		uint32_t instance);
110 struct mpc *dcn20_mpc_create(struct dc_context *ctx);
111 struct hubbub *dcn20_hubbub_create(struct dc_context *ctx);
112 
113 bool dcn20_dwbc_create(struct dc_context *ctx, struct resource_pool *pool);
114 bool dcn20_mmhubbub_create(struct dc_context *ctx, struct resource_pool *pool);
115 
116 void dcn20_set_mcif_arb_params(
117 		struct dc *dc,
118 		struct dc_state *context,
119 		display_e2e_pipe_params_st *pipes,
120 		int pipe_cnt);
121 bool dcn20_validate_bandwidth(struct dc *dc, struct dc_state *context, bool fast_validate);
122 void dcn20_merge_pipes_for_validate(
123 		struct dc *dc,
124 		struct dc_state *context);
125 int dcn20_validate_apply_pipe_split_flags(
126 		struct dc *dc,
127 		struct dc_state *context,
128 		int vlevel,
129 		int *split,
130 		bool *merge);
131 void dcn20_release_dsc(struct resource_context *res_ctx,
132 			const struct resource_pool *pool,
133 			struct display_stream_compressor **dsc);
134 bool dcn20_validate_dsc(struct dc *dc, struct dc_state *new_ctx);
135 void dcn20_split_stream_for_mpc(
136 		struct resource_context *res_ctx,
137 		const struct resource_pool *pool,
138 		struct pipe_ctx *primary_pipe,
139 		struct pipe_ctx *secondary_pipe);
140 bool dcn20_split_stream_for_odm(
141 		const struct dc *dc,
142 		struct resource_context *res_ctx,
143 		struct pipe_ctx *prev_odm_pipe,
144 		struct pipe_ctx *next_odm_pipe);
145 void dcn20_acquire_dsc(const struct dc *dc,
146 			struct resource_context *res_ctx,
147 			struct display_stream_compressor **dsc,
148 			int pipe_idx);
149 struct pipe_ctx *dcn20_find_secondary_pipe(struct dc *dc,
150 		struct resource_context *res_ctx,
151 		const struct resource_pool *pool,
152 		const struct pipe_ctx *primary_pipe);
153 bool dcn20_fast_validate_bw(
154 		struct dc *dc,
155 		struct dc_state *context,
156 		display_e2e_pipe_params_st *pipes,
157 		int *pipe_cnt_out,
158 		int *pipe_split_from,
159 		int *vlevel_out,
160 		bool fast_validate);
161 void dcn20_calculate_dlg_params(
162 		struct dc *dc, struct dc_state *context,
163 		display_e2e_pipe_params_st *pipes,
164 		int pipe_cnt,
165 		int vlevel);
166 
167 enum dc_status dcn20_build_mapped_resource(const struct dc *dc, struct dc_state *context, struct dc_stream_state *stream);
168 enum dc_status dcn20_add_stream_to_ctx(struct dc *dc, struct dc_state *new_ctx, struct dc_stream_state *dc_stream);
169 enum dc_status dcn20_add_dsc_to_stream_resource(struct dc *dc, struct dc_state *dc_ctx, struct dc_stream_state *dc_stream);
170 enum dc_status dcn20_remove_stream_from_ctx(struct dc *dc, struct dc_state *new_ctx, struct dc_stream_state *dc_stream);
171 enum dc_status dcn20_patch_unknown_plane_state(struct dc_plane_state *plane_state);
172 
173 void dcn20_patch_bounding_box(
174 		struct dc *dc,
175 		struct _vcs_dpi_soc_bounding_box_st *bb);
176 void dcn20_cap_soc_clocks(
177 		struct _vcs_dpi_soc_bounding_box_st *bb,
178 		struct pp_smu_nv_clock_table max_clocks);
179 
180 #endif /* __DC_RESOURCE_DCN20_H__ */
181 
182