xref: /linux/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_translation_helper.c (revision 92c4c9fdc838d3b41a996bb700ea64b9e78fc7ea)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright 2023 Advanced Micro Devices, Inc.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21  * OTHER DEALINGS IN THE SOFTWARE.
22  *
23  * Authors: AMD
24  *
25  */
26 
27 #include "display_mode_core.h"
28 #include "dml2_internal_types.h"
29 #include "dml2_translation_helper.h"
30 
31 #define NUM_DCFCLK_STAS 5
32 #define NUM_DCFCLK_STAS_NEW 8
33 
dml2_init_ip_params(struct dml2_context * dml2,const struct dc * in_dc,struct ip_params_st * out)34 void dml2_init_ip_params(struct dml2_context *dml2, const struct dc *in_dc, struct ip_params_st *out)
35 {
36 	(void)in_dc;
37 	switch (dml2->v20.dml_core_ctx.project) {
38 	case dml_project_dcn32:
39 	case dml_project_dcn321:
40 	default:
41 		// Hardcoded values for DCN32x
42 		out->vblank_nom_default_us = 600;
43 		out->rob_buffer_size_kbytes = 128;
44 		out->config_return_buffer_size_in_kbytes = 1280;
45 		out->config_return_buffer_segment_size_in_kbytes = 64;
46 		out->compressed_buffer_segment_size_in_kbytes = 64;
47 		out->meta_fifo_size_in_kentries = 22;
48 		out->zero_size_buffer_entries = 512;
49 		out->dpte_buffer_size_in_pte_reqs_luma = 68;
50 		out->dpte_buffer_size_in_pte_reqs_chroma = 36;
51 		out->dcc_meta_buffer_size_bytes = 6272;
52 		out->gpuvm_max_page_table_levels = 4;
53 		out->hostvm_max_page_table_levels = 0;
54 		out->pixel_chunk_size_kbytes = 8;
55 		//out->alpha_pixel_chunk_size_kbytes;
56 		out->min_pixel_chunk_size_bytes = 1024;
57 		out->meta_chunk_size_kbytes = 2;
58 		out->min_meta_chunk_size_bytes = 256;
59 		out->writeback_chunk_size_kbytes = 8;
60 		out->line_buffer_size_bits = 1171920;
61 		out->max_line_buffer_lines = 32;
62 		out->writeback_interface_buffer_size_kbytes = 90;
63 		//Number of pipes after DCN Pipe harvesting
64 		out->max_num_dpp = dml2->config.dcn_pipe_count;
65 		out->max_num_otg = dml2->config.dcn_pipe_count;
66 		out->max_num_wb = 1;
67 		out->max_dchub_pscl_bw_pix_per_clk = 4;
68 		out->max_pscl_lb_bw_pix_per_clk = 2;
69 		out->max_lb_vscl_bw_pix_per_clk = 4;
70 		out->max_vscl_hscl_bw_pix_per_clk = 4;
71 		out->max_hscl_ratio = 6;
72 		out->max_vscl_ratio = 6;
73 		out->max_hscl_taps = 8;
74 		out->max_vscl_taps = 8;
75 		out->dispclk_ramp_margin_percent = 1;
76 		out->dppclk_delay_subtotal = 47;
77 		out->dppclk_delay_scl = 50;
78 		out->dppclk_delay_scl_lb_only = 16;
79 		out->dppclk_delay_cnvc_formatter = 28;
80 		out->dppclk_delay_cnvc_cursor = 6;
81 		out->cursor_buffer_size = 16;
82 		out->cursor_chunk_size = 2;
83 		out->dispclk_delay_subtotal = 125;
84 		out->max_inter_dcn_tile_repeaters = 8;
85 		out->writeback_max_hscl_ratio = 1;
86 		out->writeback_max_vscl_ratio = 1;
87 		out->writeback_min_hscl_ratio = 1;
88 		out->writeback_min_vscl_ratio = 1;
89 		out->writeback_max_hscl_taps = 1;
90 		out->writeback_max_vscl_taps = 1;
91 		out->writeback_line_buffer_buffer_size = 0;
92 		out->num_dsc = 4;
93 		out->maximum_dsc_bits_per_component = 12;
94 		out->maximum_pixels_per_line_per_dsc_unit = 6016;
95 		out->dsc422_native_support = true;
96 		out->dcc_supported = true;
97 		out->ptoi_supported = false;
98 
99 		out->gpuvm_enable = false;
100 		out->hostvm_enable = false;
101 		out->cursor_64bpp_support = false;
102 		out->dynamic_metadata_vm_enabled = false;
103 
104 		out->max_num_hdmi_frl_outputs = 1;
105 		out->max_num_dp2p0_outputs = 2;
106 		out->max_num_dp2p0_streams = 4;
107 		break;
108 
109 	case dml_project_dcn35:
110 	case dml_project_dcn351:
111 	case dml_project_dcn36:
112 		out->rob_buffer_size_kbytes = 64;
113 		out->config_return_buffer_size_in_kbytes = 1792;
114 		out->compressed_buffer_segment_size_in_kbytes = 64;
115 		out->meta_fifo_size_in_kentries = 32;
116 		out->zero_size_buffer_entries = 512;
117 		out->pixel_chunk_size_kbytes = 8;
118 		out->alpha_pixel_chunk_size_kbytes = 4;
119 		out->min_pixel_chunk_size_bytes = 1024;
120 		out->meta_chunk_size_kbytes = 2;
121 		out->min_meta_chunk_size_bytes = 256;
122 		out->writeback_chunk_size_kbytes = 8;
123 		out->dpte_buffer_size_in_pte_reqs_luma = 68;
124 		out->dpte_buffer_size_in_pte_reqs_chroma = 36;
125 		out->dcc_meta_buffer_size_bytes = 6272;
126 		out->gpuvm_enable = 1;
127 		out->hostvm_enable = 1;
128 		out->gpuvm_max_page_table_levels = 1;
129 		out->hostvm_max_page_table_levels = 2;
130 		out->num_dsc = 4;
131 		out->maximum_dsc_bits_per_component = 12;
132 		out->maximum_pixels_per_line_per_dsc_unit = 6016;
133 		out->dsc422_native_support = 1;
134 		out->line_buffer_size_bits = 986880;
135 		out->dcc_supported = 1;
136 		out->max_line_buffer_lines = 32;
137 		out->writeback_interface_buffer_size_kbytes = 90;
138 		out->max_num_dpp = 4;
139 		out->max_num_otg = 4;
140 		out->max_num_hdmi_frl_outputs = 1;
141 		out->max_num_dp2p0_outputs = 2;
142 		out->max_num_dp2p0_streams = 4;
143 		out->max_num_wb = 1;
144 
145 		out->max_dchub_pscl_bw_pix_per_clk = 4;
146 		out->max_pscl_lb_bw_pix_per_clk = 2;
147 		out->max_lb_vscl_bw_pix_per_clk = 4;
148 		out->max_vscl_hscl_bw_pix_per_clk = 4;
149 		out->max_hscl_ratio = 6;
150 		out->max_vscl_ratio = 6;
151 		out->max_hscl_taps = 8;
152 		out->max_vscl_taps = 8;
153 		out->dispclk_ramp_margin_percent = 1.11;
154 
155 		out->dppclk_delay_subtotal = 47;
156 		out->dppclk_delay_scl = 50;
157 		out->dppclk_delay_scl_lb_only = 16;
158 		out->dppclk_delay_cnvc_formatter = 28;
159 		out->dppclk_delay_cnvc_cursor = 6;
160 		out->dispclk_delay_subtotal = 125;
161 
162 		out->dynamic_metadata_vm_enabled = false;
163 		out->max_inter_dcn_tile_repeaters = 8;
164 		out->cursor_buffer_size = 16; // kBytes
165 		out->cursor_chunk_size = 2; // kBytes
166 
167 		out->writeback_line_buffer_buffer_size = 0;
168 		out->writeback_max_hscl_ratio = 1;
169 		out->writeback_max_vscl_ratio = 1;
170 		out->writeback_min_hscl_ratio = 1;
171 		out->writeback_min_vscl_ratio = 1;
172 		out->writeback_max_hscl_taps  = 1;
173 		out->writeback_max_vscl_taps  = 1;
174 		out->ptoi_supported	= 0;
175 
176 		out->vblank_nom_default_us = 668; /*not in dml, but in programming guide, hard coded in dml2_translate_ip_params*/
177 		out->config_return_buffer_segment_size_in_kbytes = 64; /*required, but not exist,, hard coded in dml2_translate_ip_params*/
178 		break;
179 
180 	case dml_project_dcn401:
181 		// Hardcoded values for DCN4m
182 		out->vblank_nom_default_us = 668;	//600;
183 		out->rob_buffer_size_kbytes = 192;	//128;
184 		out->config_return_buffer_size_in_kbytes = 1344;	//1280;
185 		out->config_return_buffer_segment_size_in_kbytes = 64;
186 		out->compressed_buffer_segment_size_in_kbytes = 64;
187 		out->meta_fifo_size_in_kentries = 22;
188 		out->dpte_buffer_size_in_pte_reqs_luma = 68;
189 		out->dpte_buffer_size_in_pte_reqs_chroma = 36;
190 		out->gpuvm_max_page_table_levels = 4;
191 		out->pixel_chunk_size_kbytes = 8;
192 		out->alpha_pixel_chunk_size_kbytes = 4;
193 		out->min_pixel_chunk_size_bytes = 1024;
194 		out->writeback_chunk_size_kbytes = 8;
195 		out->line_buffer_size_bits = 1171920;
196 		out->max_line_buffer_lines = 32;
197 		out->writeback_interface_buffer_size_kbytes = 90;
198 		//Number of pipes after DCN Pipe harvesting
199 		out->max_num_dpp = dml2->config.dcn_pipe_count;
200 		out->max_num_otg = dml2->config.dcn_pipe_count;
201 		out->max_num_wb = 1;
202 		out->max_dchub_pscl_bw_pix_per_clk = 4;
203 		out->max_pscl_lb_bw_pix_per_clk = 2;
204 		out->max_lb_vscl_bw_pix_per_clk = 4;
205 		out->max_vscl_hscl_bw_pix_per_clk = 4;
206 		out->max_hscl_ratio = 6;
207 		out->max_vscl_ratio = 6;
208 		out->max_hscl_taps = 8;
209 		out->max_vscl_taps = 8;
210 		out->dispclk_ramp_margin_percent = 1;
211 		out->dppclk_delay_subtotal = 47;
212 		out->dppclk_delay_scl = 50;
213 		out->dppclk_delay_scl_lb_only = 16;
214 		out->dppclk_delay_cnvc_formatter = 28;
215 		out->dppclk_delay_cnvc_cursor = 6;
216 		out->dispclk_delay_subtotal = 125;
217 		out->cursor_buffer_size = 24;	//16
218 		out->cursor_chunk_size = 2;
219 		out->max_inter_dcn_tile_repeaters = 8;
220 		out->writeback_max_hscl_ratio = 1;
221 		out->writeback_max_vscl_ratio = 1;
222 		out->writeback_min_hscl_ratio = 1;
223 		out->writeback_min_vscl_ratio = 1;
224 		out->writeback_max_hscl_taps = 1;
225 		out->writeback_max_vscl_taps = 1;
226 		out->writeback_line_buffer_buffer_size = 0;
227 		out->num_dsc = 4;
228 		out->maximum_dsc_bits_per_component = 12;
229 		out->maximum_pixels_per_line_per_dsc_unit = 5760;
230 		out->dsc422_native_support = true;
231 		out->dcc_supported = true;
232 		out->ptoi_supported = false;
233 
234 		out->gpuvm_enable = false;
235 		out->hostvm_enable = false;
236 		out->cursor_64bpp_support = true;	//false;
237 		out->dynamic_metadata_vm_enabled = false;
238 
239 		out->max_num_hdmi_frl_outputs = 1;
240 		out->max_num_dp2p0_outputs = 4;		//2;
241 		out->max_num_dp2p0_streams = 4;
242 		break;
243 	}
244 }
245 
dml2_init_socbb_params(struct dml2_context * dml2,const struct dc * in_dc,struct soc_bounding_box_st * out)246 void dml2_init_socbb_params(struct dml2_context *dml2, const struct dc *in_dc, struct soc_bounding_box_st *out)
247 {
248 	(void)in_dc;
249 	out->dprefclk_mhz = dml2->config.bbox_overrides.dprefclk_mhz;
250 	out->xtalclk_mhz = dml2->config.bbox_overrides.xtalclk_mhz;
251 	out->pcierefclk_mhz = 100;
252 	out->refclk_mhz = dml2->config.bbox_overrides.dchub_refclk_mhz;
253 
254 	out->max_outstanding_reqs = 512;
255 	out->pct_ideal_sdp_bw_after_urgent = 100;
256 	out->pct_ideal_fabric_bw_after_urgent = 67;
257 	out->pct_ideal_dram_bw_after_urgent_pixel_only = 20;
258 	out->pct_ideal_dram_bw_after_urgent_pixel_and_vm = 60;
259 	out->pct_ideal_dram_bw_after_urgent_vm_only = 30;
260 	out->pct_ideal_dram_bw_after_urgent_strobe = 67;
261 	out->max_avg_sdp_bw_use_normal_percent = 80;
262 	out->max_avg_fabric_bw_use_normal_percent = 60;
263 	out->max_avg_dram_bw_use_normal_percent = 15;
264 	out->max_avg_dram_bw_use_normal_strobe_percent = 50;
265 
266 	out->urgent_out_of_order_return_per_channel_pixel_only_bytes = 4096;
267 	out->urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 4096;
268 	out->urgent_out_of_order_return_per_channel_vm_only_bytes = 4096;
269 	out->return_bus_width_bytes = 64;
270 	out->dram_channel_width_bytes = 2;
271 	out->fabric_datapath_to_dcn_data_return_bytes = 64;
272 	out->hostvm_min_page_size_kbytes = 0;
273 	out->gpuvm_min_page_size_kbytes = 256;
274 	out->phy_downspread_percent = 0.38;
275 	out->dcn_downspread_percent = 0.5;
276 	out->dispclk_dppclk_vco_speed_mhz = dml2->config.bbox_overrides.disp_pll_vco_speed_mhz;
277 	out->mall_allocated_for_dcn_mbytes = dml2->config.mall_cfg.max_cab_allocation_bytes / 1048576; // 64 or 32 MB;
278 
279 	out->do_urgent_latency_adjustment = true;
280 
281 	switch (dml2->v20.dml_core_ctx.project) {
282 
283 	case dml_project_dcn32:
284 	default:
285 		out->num_chans = 24;
286 		out->round_trip_ping_latency_dcfclk_cycles = 263;
287 		out->smn_latency_us = 2;
288 		break;
289 
290 	case dml_project_dcn321:
291 		out->num_chans = 8;
292 		out->round_trip_ping_latency_dcfclk_cycles = 207;
293 		out->smn_latency_us = 0;
294 		break;
295 
296 	case dml_project_dcn35:
297 	case dml_project_dcn351:
298 	case dml_project_dcn36:
299 		out->num_chans = 4;
300 		out->round_trip_ping_latency_dcfclk_cycles = 106;
301 		out->smn_latency_us = 2;
302 		out->dispclk_dppclk_vco_speed_mhz = 3600;
303 		out->pct_ideal_dram_bw_after_urgent_pixel_only = 65.0;
304 		break;
305 
306 
307 	case dml_project_dcn401:
308 		out->pct_ideal_fabric_bw_after_urgent = 76;			//67;
309 		out->max_avg_sdp_bw_use_normal_percent = 75;		//80;
310 		out->max_avg_fabric_bw_use_normal_percent = 57;		//60;
311 
312 		out->urgent_out_of_order_return_per_channel_pixel_only_bytes = 0;	//4096;
313 		out->urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 0;	//4096;
314 		out->urgent_out_of_order_return_per_channel_vm_only_bytes = 0;		//4096;
315 
316 		out->num_chans = 16;
317 		out->round_trip_ping_latency_dcfclk_cycles = 1000;	//263;
318 		out->smn_latency_us = 0;							//2 us
319 		out->mall_allocated_for_dcn_mbytes = dml2->config.mall_cfg.max_cab_allocation_bytes / 1048576; // 64;
320 		break;
321 	}
322 	/* ---Overrides if available--- */
323 	if (dml2->config.bbox_overrides.dram_num_chan)
324 		out->num_chans = dml2->config.bbox_overrides.dram_num_chan;
325 
326 	if (dml2->config.bbox_overrides.dram_chanel_width_bytes)
327 		out->dram_channel_width_bytes = dml2->config.bbox_overrides.dram_chanel_width_bytes;
328 }
329 
dml2_init_soc_states(struct dml2_context * dml2,const struct dc * in_dc,const struct soc_bounding_box_st * in_bbox,struct soc_states_st * out)330 void dml2_init_soc_states(struct dml2_context *dml2, const struct dc *in_dc,
331 	const struct soc_bounding_box_st *in_bbox, struct soc_states_st *out)
332 {
333 	(void)in_dc;
334 	struct dml2_policy_build_synthetic_soc_states_scratch *s = &dml2->v20.scratch.create_scratch.build_synthetic_socbb_scratch;
335 	struct dml2_policy_build_synthetic_soc_states_params *p = &dml2->v20.scratch.build_synthetic_socbb_params;
336 	int dcfclk_stas_mhz[NUM_DCFCLK_STAS] = {0};
337 	int dcfclk_stas_mhz_new[NUM_DCFCLK_STAS_NEW] = {0};
338 	unsigned int dml_project = dml2->v20.dml_core_ctx.project;
339 
340 	unsigned int i = 0;
341 	unsigned int transactions_per_mem_clock = 16; // project specific, depends on used Memory type
342 
343 	if (dml_project == dml_project_dcn351) {
344 		p->dcfclk_stas_mhz = dcfclk_stas_mhz_new;
345 		p->num_dcfclk_stas = NUM_DCFCLK_STAS_NEW;
346 	} else {
347 		p->dcfclk_stas_mhz = dcfclk_stas_mhz;
348 		p->num_dcfclk_stas = NUM_DCFCLK_STAS;
349 	}
350 
351 	p->in_bbox = in_bbox;
352 	p->out_states = out;
353 	p->in_states = &dml2->v20.scratch.create_scratch.in_states;
354 
355 
356 	/* Initial hardcoded values */
357 	switch (dml2->v20.dml_core_ctx.project) {
358 
359 	case dml_project_dcn32:
360 	default:
361 		p->in_states->num_states = 2;
362 		transactions_per_mem_clock = 16;
363 		p->in_states->state_array[0].socclk_mhz = 620.0;
364 		p->in_states->state_array[0].dscclk_mhz = 716.667;
365 		p->in_states->state_array[0].phyclk_mhz = 810;
366 		p->in_states->state_array[0].phyclk_d18_mhz = 667;
367 		p->in_states->state_array[0].phyclk_d32_mhz = 625;
368 		p->in_states->state_array[0].dtbclk_mhz = 1564.0;
369 		p->in_states->state_array[0].fabricclk_mhz = 450.0;
370 		p->in_states->state_array[0].dcfclk_mhz = 300.0;
371 		p->in_states->state_array[0].dispclk_mhz = 2150.0;
372 		p->in_states->state_array[0].dppclk_mhz = 2150.0;
373 		p->in_states->state_array[0].dram_speed_mts = 100 * transactions_per_mem_clock;
374 
375 		p->in_states->state_array[0].urgent_latency_pixel_data_only_us = 4;
376 		p->in_states->state_array[0].urgent_latency_pixel_mixed_with_vm_data_us = 0;
377 		p->in_states->state_array[0].urgent_latency_vm_data_only_us = 0;
378 		p->in_states->state_array[0].writeback_latency_us = 12;
379 		p->in_states->state_array[0].urgent_latency_adjustment_fabric_clock_component_us = 1;
380 		p->in_states->state_array[0].urgent_latency_adjustment_fabric_clock_reference_mhz = 3000;
381 		p->in_states->state_array[0].sr_exit_z8_time_us = 0;
382 		p->in_states->state_array[0].sr_enter_plus_exit_z8_time_us = 0;
383 		p->in_states->state_array[0].dram_clock_change_latency_us = 400;
384 		p->in_states->state_array[0].use_ideal_dram_bw_strobe = true;
385 		p->in_states->state_array[0].sr_exit_time_us = 42.97;
386 		p->in_states->state_array[0].sr_enter_plus_exit_time_us = 49.94;
387 		p->in_states->state_array[0].fclk_change_latency_us = 20;
388 		p->in_states->state_array[0].usr_retraining_latency_us = 2;
389 
390 		p->in_states->state_array[1].socclk_mhz = 1200.0;
391 		p->in_states->state_array[1].fabricclk_mhz = 2500.0;
392 		p->in_states->state_array[1].dcfclk_mhz = 1564.0;
393 		p->in_states->state_array[1].dram_speed_mts = 1125 * transactions_per_mem_clock;
394 		break;
395 
396 	case dml_project_dcn321:
397 		p->in_states->num_states = 2;
398 		transactions_per_mem_clock = 16;
399 		p->in_states->state_array[0].socclk_mhz = 582.0;
400 		p->in_states->state_array[0].dscclk_mhz = 573.333;
401 		p->in_states->state_array[0].phyclk_mhz = 810;
402 		p->in_states->state_array[0].phyclk_d18_mhz = 667;
403 		p->in_states->state_array[0].phyclk_d32_mhz = 313;
404 		p->in_states->state_array[0].dtbclk_mhz = 1564.0;
405 		p->in_states->state_array[0].fabricclk_mhz = 450.0;
406 		p->in_states->state_array[0].dcfclk_mhz = 300.0;
407 		p->in_states->state_array[0].dispclk_mhz = 1720.0;
408 		p->in_states->state_array[0].dppclk_mhz = 1720.0;
409 		p->in_states->state_array[0].dram_speed_mts = 100 * transactions_per_mem_clock;
410 
411 		p->in_states->state_array[0].urgent_latency_pixel_data_only_us = 4;
412 		p->in_states->state_array[0].urgent_latency_pixel_mixed_with_vm_data_us = 0;
413 		p->in_states->state_array[0].urgent_latency_vm_data_only_us = 0;
414 		p->in_states->state_array[0].writeback_latency_us = 12;
415 		p->in_states->state_array[0].urgent_latency_adjustment_fabric_clock_component_us = 1;
416 		p->in_states->state_array[0].urgent_latency_adjustment_fabric_clock_reference_mhz = 3000;
417 		p->in_states->state_array[0].sr_exit_z8_time_us = 0;
418 		p->in_states->state_array[0].sr_enter_plus_exit_z8_time_us = 0;
419 		p->in_states->state_array[0].dram_clock_change_latency_us = 400;
420 		p->in_states->state_array[0].use_ideal_dram_bw_strobe = true;
421 		p->in_states->state_array[0].sr_exit_time_us = 19.95;
422 		p->in_states->state_array[0].sr_enter_plus_exit_time_us = 24.36;
423 		p->in_states->state_array[0].fclk_change_latency_us = 7;
424 		p->in_states->state_array[0].usr_retraining_latency_us = 0;
425 
426 		p->in_states->state_array[1].socclk_mhz = 1200.0;
427 		p->in_states->state_array[1].fabricclk_mhz = 2250.0;
428 		p->in_states->state_array[1].dcfclk_mhz = 1434.0;
429 		p->in_states->state_array[1].dram_speed_mts = 1000 * transactions_per_mem_clock;
430 		break;
431 
432 
433 	case dml_project_dcn401:
434 		p->in_states->num_states = 2;
435 		transactions_per_mem_clock = 16;
436 		p->in_states->state_array[0].socclk_mhz = 300;		//620.0;
437 		p->in_states->state_array[0].dscclk_mhz = 666.667;	//716.667;
438 		p->in_states->state_array[0].phyclk_mhz = 810;
439 		p->in_states->state_array[0].phyclk_d18_mhz = 667;
440 		p->in_states->state_array[0].phyclk_d32_mhz = 625;
441 		p->in_states->state_array[0].dtbclk_mhz = 2000;		//1564.0;
442 		p->in_states->state_array[0].fabricclk_mhz = 300;	//450.0;
443 		p->in_states->state_array[0].dcfclk_mhz = 200;		//300.0;
444 		p->in_states->state_array[0].dispclk_mhz = 2000;	//2150.0;
445 		p->in_states->state_array[0].dppclk_mhz = 2000;		//2150.0;
446 		p->in_states->state_array[0].dram_speed_mts = 97 * transactions_per_mem_clock; //100 *
447 
448 		p->in_states->state_array[0].urgent_latency_pixel_data_only_us = 4;
449 		p->in_states->state_array[0].urgent_latency_pixel_mixed_with_vm_data_us = 0;
450 		p->in_states->state_array[0].urgent_latency_vm_data_only_us = 0;
451 		p->in_states->state_array[0].writeback_latency_us = 12;
452 		p->in_states->state_array[0].urgent_latency_adjustment_fabric_clock_component_us = 1;
453 		p->in_states->state_array[0].urgent_latency_adjustment_fabric_clock_reference_mhz = 1000;	//3000;
454 		p->in_states->state_array[0].sr_exit_z8_time_us = 0;
455 		p->in_states->state_array[0].sr_enter_plus_exit_z8_time_us = 0;
456 		p->in_states->state_array[0].dram_clock_change_latency_us = 400;
457 		p->in_states->state_array[0].use_ideal_dram_bw_strobe = true;
458 		p->in_states->state_array[0].sr_exit_time_us = 15.70;	//42.97;
459 		p->in_states->state_array[0].sr_enter_plus_exit_time_us = 20.20;	//49.94;
460 		p->in_states->state_array[0].fclk_change_latency_us = 0;	//20;
461 		p->in_states->state_array[0].usr_retraining_latency_us = 0;	//2;
462 
463 		p->in_states->state_array[1].socclk_mhz = 1600;		//1200.0;
464 		p->in_states->state_array[1].fabricclk_mhz = 2500;	//2500.0;
465 		p->in_states->state_array[1].dcfclk_mhz = 1800;		//1564.0;
466 		p->in_states->state_array[1].dram_speed_mts = 1125 * transactions_per_mem_clock;
467 		break;
468 	}
469 
470 	/* Override from passed values, if available */
471 	for (i = 0; i < p->in_states->num_states; i++) {
472 		if (dml2->config.bbox_overrides.sr_exit_latency_us) {
473 			p->in_states->state_array[i].sr_exit_time_us =
474 				dml2->config.bbox_overrides.sr_exit_latency_us;
475 		}
476 
477 		if (dml2->config.bbox_overrides.sr_enter_plus_exit_latency_us) {
478 			p->in_states->state_array[i].sr_enter_plus_exit_time_us =
479 				dml2->config.bbox_overrides.sr_enter_plus_exit_latency_us;
480 		}
481 
482 		if (dml2->config.bbox_overrides.sr_exit_z8_time_us) {
483 			p->in_states->state_array[i].sr_exit_z8_time_us =
484 				dml2->config.bbox_overrides.sr_exit_z8_time_us;
485 		}
486 
487 		if (dml2->config.bbox_overrides.sr_enter_plus_exit_z8_time_us) {
488 			p->in_states->state_array[i].sr_enter_plus_exit_z8_time_us =
489 				dml2->config.bbox_overrides.sr_enter_plus_exit_z8_time_us;
490 		}
491 
492 		if (dml2->config.bbox_overrides.urgent_latency_us) {
493 			p->in_states->state_array[i].urgent_latency_pixel_data_only_us =
494 				dml2->config.bbox_overrides.urgent_latency_us;
495 		}
496 
497 		if (dml2->config.bbox_overrides.dram_clock_change_latency_us) {
498 			p->in_states->state_array[i].dram_clock_change_latency_us =
499 				dml2->config.bbox_overrides.dram_clock_change_latency_us;
500 		}
501 
502 		if (dml2->config.bbox_overrides.fclk_change_latency_us) {
503 			p->in_states->state_array[i].fclk_change_latency_us =
504 				dml2->config.bbox_overrides.fclk_change_latency_us;
505 		}
506 	}
507 
508 	/* DCFCLK stas values are project specific */
509 	if ((dml2->v20.dml_core_ctx.project == dml_project_dcn32) ||
510 		(dml2->v20.dml_core_ctx.project == dml_project_dcn321)) {
511 		p->dcfclk_stas_mhz[0] = p->in_states->state_array[0].dcfclk_mhz;
512 		p->dcfclk_stas_mhz[1] = 615;
513 		p->dcfclk_stas_mhz[2] = 906;
514 		p->dcfclk_stas_mhz[3] = 1324;
515 		p->dcfclk_stas_mhz[4] = p->in_states->state_array[1].dcfclk_mhz;
516 	} else if (dml2->v20.dml_core_ctx.project != dml_project_dcn35 &&
517 			dml2->v20.dml_core_ctx.project != dml_project_dcn36 &&
518 			dml2->v20.dml_core_ctx.project != dml_project_dcn351) {
519 		p->dcfclk_stas_mhz[0] = 300;
520 		p->dcfclk_stas_mhz[1] = 615;
521 		p->dcfclk_stas_mhz[2] = 906;
522 		p->dcfclk_stas_mhz[3] = 1324;
523 		p->dcfclk_stas_mhz[4] = 1500;
524 	}
525 	/* Copy clocks tables entries, if available */
526 	if (dml2->config.bbox_overrides.clks_table.num_states) {
527 		p->in_states->num_states = dml2->config.bbox_overrides.clks_table.num_states;
528 		for (i = 0; i < dml2->config.bbox_overrides.clks_table.num_entries_per_clk.num_dcfclk_levels; i++) {
529 			p->in_states->state_array[i].dcfclk_mhz = dml2->config.bbox_overrides.clks_table.clk_entries[i].dcfclk_mhz;
530 		}
531 
532 		p->dcfclk_stas_mhz[0] = dml2->config.bbox_overrides.clks_table.clk_entries[0].dcfclk_mhz;
533 		if (i > 1)
534 			p->dcfclk_stas_mhz[4] = dml2->config.bbox_overrides.clks_table.clk_entries[i-1].dcfclk_mhz;
535 
536 		for (i = 0; i < dml2->config.bbox_overrides.clks_table.num_entries_per_clk.num_fclk_levels; i++) {
537 			p->in_states->state_array[i].fabricclk_mhz =
538 				dml2->config.bbox_overrides.clks_table.clk_entries[i].fclk_mhz;
539 		}
540 
541 		for (i = 0; i < dml2->config.bbox_overrides.clks_table.num_entries_per_clk.num_memclk_levels; i++) {
542 			p->in_states->state_array[i].dram_speed_mts =
543 				dml2->config.bbox_overrides.clks_table.clk_entries[i].memclk_mhz * transactions_per_mem_clock;
544 		}
545 
546 		for (i = 0; i < dml2->config.bbox_overrides.clks_table.num_entries_per_clk.num_socclk_levels; i++) {
547 			p->in_states->state_array[i].socclk_mhz =
548 				dml2->config.bbox_overrides.clks_table.clk_entries[i].socclk_mhz;
549 		}
550 
551 		for (i = 0; i < dml2->config.bbox_overrides.clks_table.num_entries_per_clk.num_dtbclk_levels; i++) {
552 			if (dml2->config.bbox_overrides.clks_table.clk_entries[i].dtbclk_mhz > 0)
553 				p->in_states->state_array[i].dtbclk_mhz =
554 					dml2->config.bbox_overrides.clks_table.clk_entries[i].dtbclk_mhz;
555 		}
556 
557 		for (i = 0; i < dml2->config.bbox_overrides.clks_table.num_entries_per_clk.num_dispclk_levels; i++) {
558 			p->in_states->state_array[i].dispclk_mhz =
559 				dml2->config.bbox_overrides.clks_table.clk_entries[i].dispclk_mhz;
560 			p->in_states->state_array[i].dppclk_mhz =
561 				dml2->config.bbox_overrides.clks_table.clk_entries[i].dppclk_mhz;
562 		}
563 	}
564 
565 	if (dml2->v20.dml_core_ctx.project == dml_project_dcn35 ||
566 	    dml2->v20.dml_core_ctx.project == dml_project_dcn36 ||
567 	    dml2->v20.dml_core_ctx.project == dml_project_dcn351) {
568 		int max_dcfclk_mhz = 0, max_dispclk_mhz = 0, max_dppclk_mhz = 0, max_phyclk_mhz = 0,
569 			max_dtbclk_mhz = 0, max_fclk_mhz = 0, max_uclk_mhz = 0, max_socclk_mhz = 0;
570 
571 		for (i = 0; i < p->in_states->num_states; i++) {
572 			if (p->in_states->state_array[i].dcfclk_mhz > max_dcfclk_mhz)
573 				max_dcfclk_mhz = (int)p->in_states->state_array[i].dcfclk_mhz;
574 			if (p->in_states->state_array[i].fabricclk_mhz > max_fclk_mhz)
575 				max_fclk_mhz = (int)p->in_states->state_array[i].fabricclk_mhz;
576 			if (p->in_states->state_array[i].socclk_mhz > max_socclk_mhz)
577 				max_socclk_mhz = (int)p->in_states->state_array[i].socclk_mhz;
578 			if (p->in_states->state_array[i].dram_speed_mts > max_uclk_mhz)
579 				max_uclk_mhz = (int)p->in_states->state_array[i].dram_speed_mts;
580 			if (p->in_states->state_array[i].dispclk_mhz > max_dispclk_mhz)
581 				max_dispclk_mhz = (int)p->in_states->state_array[i].dispclk_mhz;
582 			if (p->in_states->state_array[i].dppclk_mhz > max_dppclk_mhz)
583 				max_dppclk_mhz = (int)p->in_states->state_array[i].dppclk_mhz;
584 			if (p->in_states->state_array[i].phyclk_mhz > max_phyclk_mhz)
585 				max_phyclk_mhz = (int)p->in_states->state_array[i].phyclk_mhz;
586 			if (p->in_states->state_array[i].dtbclk_mhz > max_dtbclk_mhz)
587 				max_dtbclk_mhz = (int)p->in_states->state_array[i].dtbclk_mhz;
588 		}
589 
590 		for (i = 0; i < p->in_states->num_states; i++) {
591 			/* Independent states - including base (unlisted) parameters from state 0. */
592 			p->out_states->state_array[i] = p->in_states->state_array[0];
593 
594 			p->out_states->state_array[i].dispclk_mhz = max_dispclk_mhz;
595 			p->out_states->state_array[i].dppclk_mhz = max_dppclk_mhz;
596 			p->out_states->state_array[i].dtbclk_mhz = max_dtbclk_mhz;
597 			p->out_states->state_array[i].phyclk_mhz = max_phyclk_mhz;
598 
599 			p->out_states->state_array[i].dscclk_mhz = max_dispclk_mhz / 3.0;
600 			p->out_states->state_array[i].phyclk_mhz = max_phyclk_mhz;
601 			p->out_states->state_array[i].dtbclk_mhz = max_dtbclk_mhz;
602 
603 			/* Dependent states. */
604 			p->out_states->state_array[i].dram_speed_mts = p->in_states->state_array[i].dram_speed_mts;
605 			p->out_states->state_array[i].fabricclk_mhz = p->in_states->state_array[i].fabricclk_mhz;
606 			p->out_states->state_array[i].socclk_mhz = p->in_states->state_array[i].socclk_mhz;
607 			p->out_states->state_array[i].dcfclk_mhz = p->in_states->state_array[i].dcfclk_mhz;
608 		}
609 
610 		p->out_states->num_states = p->in_states->num_states;
611 	} else {
612 		dml2_policy_build_synthetic_soc_states(s, p);
613 	}
614 }
615 
dml2_translate_ip_params(const struct dc * in,struct ip_params_st * out)616 void dml2_translate_ip_params(const struct dc *in, struct ip_params_st *out)
617 {
618 	const struct _vcs_dpi_ip_params_st *in_ip_params = &in->dml.ip;
619 	/* Copy over the IP params tp dml2_ctx */
620 	out->compressed_buffer_segment_size_in_kbytes = in_ip_params->compressed_buffer_segment_size_in_kbytes;
621 	out->config_return_buffer_size_in_kbytes = in_ip_params->config_return_buffer_size_in_kbytes;
622 	out->cursor_buffer_size = in_ip_params->cursor_buffer_size;
623 	out->cursor_chunk_size = in_ip_params->cursor_chunk_size;
624 	out->dcc_meta_buffer_size_bytes = in_ip_params->dcc_meta_buffer_size_bytes;
625 	out->dcc_supported = in_ip_params->dcc_supported;
626 	out->dispclk_delay_subtotal = in_ip_params->dispclk_delay_subtotal;
627 	out->dispclk_ramp_margin_percent = in_ip_params->dispclk_ramp_margin_percent;
628 	out->dppclk_delay_cnvc_cursor = in_ip_params->dppclk_delay_cnvc_cursor;
629 	out->dppclk_delay_cnvc_formatter = in_ip_params->dppclk_delay_cnvc_formatter;
630 	out->dppclk_delay_scl = in_ip_params->dppclk_delay_scl;
631 	out->dppclk_delay_scl_lb_only = in_ip_params->dppclk_delay_scl_lb_only;
632 	out->dppclk_delay_subtotal = in_ip_params->dppclk_delay_subtotal;
633 	out->dpte_buffer_size_in_pte_reqs_chroma = in_ip_params->dpte_buffer_size_in_pte_reqs_chroma;
634 	out->dpte_buffer_size_in_pte_reqs_luma = in_ip_params->dpte_buffer_size_in_pte_reqs_luma;
635 	out->dsc422_native_support = in_ip_params->dsc422_native_support;
636 	out->dynamic_metadata_vm_enabled = in_ip_params->dynamic_metadata_vm_enabled;
637 	out->gpuvm_enable = in_ip_params->gpuvm_enable;
638 	out->gpuvm_max_page_table_levels = in_ip_params->gpuvm_max_page_table_levels;
639 	out->hostvm_enable = in_ip_params->hostvm_enable;
640 	out->hostvm_max_page_table_levels = in_ip_params->hostvm_max_page_table_levels;
641 	out->line_buffer_size_bits = in_ip_params->line_buffer_size_bits;
642 	out->maximum_dsc_bits_per_component = in_ip_params->maximum_dsc_bits_per_component;
643 	out->maximum_pixels_per_line_per_dsc_unit = in_ip_params->maximum_pixels_per_line_per_dsc_unit;
644 	out->max_dchub_pscl_bw_pix_per_clk = in_ip_params->max_dchub_pscl_bw_pix_per_clk;
645 	out->max_hscl_ratio = in_ip_params->max_hscl_ratio;
646 	out->max_hscl_taps = in_ip_params->max_hscl_taps;
647 	out->max_inter_dcn_tile_repeaters = in_ip_params->max_inter_dcn_tile_repeaters;
648 	out->max_lb_vscl_bw_pix_per_clk = in_ip_params->max_lb_vscl_bw_pix_per_clk;
649 	out->max_line_buffer_lines = in_ip_params->max_line_buffer_lines;
650 	out->max_num_dp2p0_outputs = in_ip_params->max_num_dp2p0_outputs;
651 	out->max_num_dp2p0_streams = in_ip_params->max_num_dp2p0_streams;
652 	out->max_num_dpp = in_ip_params->max_num_dpp;
653 	out->max_num_hdmi_frl_outputs = in_ip_params->max_num_hdmi_frl_outputs;
654 	out->max_num_otg = in_ip_params->max_num_otg;
655 	out->max_num_wb = in_ip_params->max_num_wb;
656 	out->max_pscl_lb_bw_pix_per_clk = in_ip_params->max_pscl_lb_bw_pix_per_clk;
657 	out->max_vscl_hscl_bw_pix_per_clk = in_ip_params->max_vscl_hscl_bw_pix_per_clk;
658 	out->max_vscl_ratio = in_ip_params->max_vscl_ratio;
659 	out->max_vscl_taps = in_ip_params->max_vscl_taps;
660 	out->meta_chunk_size_kbytes = in_ip_params->meta_chunk_size_kbytes;
661 	out->meta_fifo_size_in_kentries = in_ip_params->meta_fifo_size_in_kentries;
662 	out->min_meta_chunk_size_bytes = in_ip_params->min_meta_chunk_size_bytes;
663 	out->min_pixel_chunk_size_bytes = in_ip_params->min_pixel_chunk_size_bytes;
664 	out->num_dsc = in_ip_params->num_dsc;
665 	out->pixel_chunk_size_kbytes = in_ip_params->pixel_chunk_size_kbytes;
666 	out->ptoi_supported = in_ip_params->ptoi_supported;
667 	out->rob_buffer_size_kbytes = in_ip_params->rob_buffer_size_kbytes;
668 	out->writeback_chunk_size_kbytes = in_ip_params->writeback_chunk_size_kbytes;
669 	out->writeback_interface_buffer_size_kbytes = in_ip_params->writeback_interface_buffer_size_kbytes;
670 	out->writeback_line_buffer_buffer_size = in_ip_params->writeback_line_buffer_buffer_size;
671 	out->writeback_max_hscl_ratio = in_ip_params->writeback_max_hscl_ratio;
672 	out->writeback_max_hscl_taps = in_ip_params->writeback_max_hscl_taps;
673 	out->writeback_max_vscl_ratio = in_ip_params->writeback_max_vscl_ratio;
674 	out->writeback_max_vscl_taps = in_ip_params->writeback_max_vscl_taps;
675 	out->writeback_min_hscl_ratio = in_ip_params->writeback_min_hscl_ratio;
676 	out->writeback_min_vscl_ratio = in_ip_params->writeback_min_vscl_ratio;
677 	out->zero_size_buffer_entries = in_ip_params->zero_size_buffer_entries;
678 
679 	/* As per hardcoded reference / discussions */
680 	out->config_return_buffer_segment_size_in_kbytes = 64;
681 	//out->vblank_nom_default_us = 600;
682 	out->vblank_nom_default_us = in_ip_params->VBlankNomDefaultUS;
683 }
684 
dml2_translate_socbb_params(const struct dc * in,struct soc_bounding_box_st * out)685 void dml2_translate_socbb_params(const struct dc *in, struct soc_bounding_box_st *out)
686 {
687 	const struct _vcs_dpi_soc_bounding_box_st *in_soc_params = &in->dml.soc;
688 	/* Copy over the SOCBB params to dml2_ctx */
689 	out->dispclk_dppclk_vco_speed_mhz = in_soc_params->dispclk_dppclk_vco_speed_mhz;
690 	out->do_urgent_latency_adjustment = in_soc_params->do_urgent_latency_adjustment;
691 	out->dram_channel_width_bytes = (dml_uint_t)in_soc_params->dram_channel_width_bytes;
692 	out->fabric_datapath_to_dcn_data_return_bytes = (dml_uint_t)in_soc_params->fabric_datapath_to_dcn_data_return_bytes;
693 	out->gpuvm_min_page_size_kbytes = in_soc_params->gpuvm_min_page_size_bytes / 1024;
694 	out->hostvm_min_page_size_kbytes = in_soc_params->hostvm_min_page_size_bytes / 1024;
695 	out->mall_allocated_for_dcn_mbytes = (dml_uint_t)in_soc_params->mall_allocated_for_dcn_mbytes;
696 	out->max_avg_dram_bw_use_normal_percent = in_soc_params->max_avg_dram_bw_use_normal_percent;
697 	out->max_avg_fabric_bw_use_normal_percent = in_soc_params->max_avg_fabric_bw_use_normal_percent;
698 	out->max_avg_dram_bw_use_normal_strobe_percent = in_soc_params->max_avg_dram_bw_use_normal_strobe_percent;
699 	out->max_avg_sdp_bw_use_normal_percent = in_soc_params->max_avg_sdp_bw_use_normal_percent;
700 	out->max_outstanding_reqs = in_soc_params->max_request_size_bytes;
701 	out->num_chans = in_soc_params->num_chans;
702 	out->pct_ideal_dram_bw_after_urgent_strobe = in_soc_params->pct_ideal_dram_bw_after_urgent_strobe;
703 	out->pct_ideal_dram_bw_after_urgent_vm_only = in_soc_params->pct_ideal_dram_sdp_bw_after_urgent_vm_only;
704 	out->pct_ideal_fabric_bw_after_urgent = in_soc_params->pct_ideal_fabric_bw_after_urgent;
705 	out->pct_ideal_sdp_bw_after_urgent = in_soc_params->pct_ideal_sdp_bw_after_urgent;
706 	out->phy_downspread_percent = in_soc_params->downspread_percent;
707 	out->refclk_mhz = 50; // As per hardcoded reference.
708 	out->return_bus_width_bytes = in_soc_params->return_bus_width_bytes;
709 	out->round_trip_ping_latency_dcfclk_cycles = in_soc_params->round_trip_ping_latency_dcfclk_cycles;
710 	out->smn_latency_us = in_soc_params->smn_latency_us;
711 	out->urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = in_soc_params->urgent_out_of_order_return_per_channel_pixel_and_vm_bytes;
712 	out->urgent_out_of_order_return_per_channel_pixel_only_bytes = in_soc_params->urgent_out_of_order_return_per_channel_pixel_only_bytes;
713 	out->urgent_out_of_order_return_per_channel_vm_only_bytes = in_soc_params->urgent_out_of_order_return_per_channel_vm_only_bytes;
714 	out->pct_ideal_dram_bw_after_urgent_pixel_and_vm = in_soc_params->pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm;
715 	out->pct_ideal_dram_bw_after_urgent_pixel_only = in_soc_params->pct_ideal_dram_sdp_bw_after_urgent_pixel_only;
716 	out->dcn_downspread_percent = in_soc_params->dcn_downspread_percent;
717 }
718 
dml2_translate_soc_states(const struct dc * dc,struct soc_states_st * out,int num_states)719 void dml2_translate_soc_states(const struct dc *dc, struct soc_states_st *out, int num_states)
720 {
721 	unsigned int i = 0;
722 	out->num_states = num_states;
723 
724 	for (i = 0; i < out->num_states; i++) {
725 		out->state_array[i].dcfclk_mhz = dc->dml.soc.clock_limits[i].dcfclk_mhz;
726 		out->state_array[i].dispclk_mhz = dc->dml.soc.clock_limits[i].dispclk_mhz;
727 		out->state_array[i].dppclk_mhz = dc->dml.soc.clock_limits[i].dppclk_mhz;
728 		out->state_array[i].dram_speed_mts = dc->dml.soc.clock_limits[i].dram_speed_mts;
729 		out->state_array[i].dtbclk_mhz = dc->dml.soc.clock_limits[i].dtbclk_mhz;
730 		out->state_array[i].socclk_mhz = dc->dml.soc.clock_limits[i].socclk_mhz;
731 		out->state_array[i].fabricclk_mhz = dc->dml.soc.clock_limits[i].fabricclk_mhz;
732 		out->state_array[i].dscclk_mhz = dc->dml.soc.clock_limits[i].dscclk_mhz;
733 		out->state_array[i].phyclk_d18_mhz = dc->dml.soc.clock_limits[i].phyclk_d18_mhz;
734 		out->state_array[i].phyclk_d32_mhz = dc->dml.soc.clock_limits[i].phyclk_d32_mhz;
735 		out->state_array[i].phyclk_mhz = dc->dml.soc.clock_limits[i].phyclk_mhz;
736 		out->state_array[i].sr_enter_plus_exit_time_us = dc->dml.soc.sr_enter_plus_exit_time_us;
737 		out->state_array[i].sr_exit_time_us = dc->dml.soc.sr_exit_time_us;
738 		out->state_array[i].fclk_change_latency_us = dc->dml.soc.fclk_change_latency_us;
739 		out->state_array[i].dram_clock_change_latency_us = dc->dml.soc.dram_clock_change_latency_us;
740 		out->state_array[i].usr_retraining_latency_us = dc->dml.soc.usr_retraining_latency_us;
741 		out->state_array[i].writeback_latency_us = dc->dml.soc.writeback_latency_us;
742 		/* Driver initialized values for these are different than the spreadsheet. Use the
743 		 * spreadsheet ones for now. We need to decided which ones to use.
744 		 */
745 		out->state_array[i].sr_exit_z8_time_us = dc->dml.soc.sr_exit_z8_time_us;
746 		out->state_array[i].sr_enter_plus_exit_z8_time_us = dc->dml.soc.sr_enter_plus_exit_z8_time_us;
747 		//out->state_array[i].sr_exit_z8_time_us = 5.20;
748 		//out->state_array[i].sr_enter_plus_exit_z8_time_us = 9.60;
749 		out->state_array[i].use_ideal_dram_bw_strobe = true;
750 		out->state_array[i].urgent_latency_pixel_data_only_us = dc->dml.soc.urgent_latency_pixel_data_only_us;
751 		out->state_array[i].urgent_latency_pixel_mixed_with_vm_data_us = dc->dml.soc.urgent_latency_pixel_mixed_with_vm_data_us;
752 		out->state_array[i].urgent_latency_vm_data_only_us = dc->dml.soc.urgent_latency_vm_data_only_us;
753 		out->state_array[i].urgent_latency_adjustment_fabric_clock_component_us = dc->dml.soc.urgent_latency_adjustment_fabric_clock_component_us;
754 		out->state_array[i].urgent_latency_adjustment_fabric_clock_reference_mhz = dc->dml.soc.urgent_latency_adjustment_fabric_clock_reference_mhz;
755 	}
756 }
757 
populate_dml_timing_cfg_from_stream_state(struct dml_timing_cfg_st * out,unsigned int location,const struct dc_stream_state * in)758 static void populate_dml_timing_cfg_from_stream_state(struct dml_timing_cfg_st *out, unsigned int location, const struct dc_stream_state *in)
759 {
760 	dml_uint_t hblank_start, vblank_start;
761 
762 	out->HActive[location] = in->timing.h_addressable + in->timing.h_border_left + in->timing.h_border_right;
763 	out->VActive[location] = in->timing.v_addressable + in->timing.v_border_bottom + in->timing.v_border_top;
764 	out->RefreshRate[location] = ((in->timing.pix_clk_100hz * 100) / in->timing.h_total) / in->timing.v_total;
765 	out->VFrontPorch[location] = in->timing.v_front_porch;
766 	out->PixelClock[location] = in->timing.pix_clk_100hz / 10000.00;
767 	if (in->timing.timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING)
768 		out->PixelClock[location] *= 2;
769 	out->HTotal[location] = in->timing.h_total;
770 	out->VTotal[location] = in->timing.v_total;
771 	out->Interlace[location] = (in->timing.flags.INTERLACE != 0);
772 	hblank_start = in->timing.h_total - in->timing.h_front_porch;
773 	out->HBlankEnd[location] = hblank_start
774 					- in->timing.h_addressable
775 					- in->timing.h_border_left
776 					- in->timing.h_border_right;
777 	vblank_start = in->timing.v_total - in->timing.v_front_porch;
778 	out->VBlankEnd[location] = vblank_start
779 					- in->timing.v_addressable
780 					- in->timing.v_border_top
781 					- in->timing.v_border_bottom;
782 	out->DRRDisplay[location] = false;
783 }
784 
populate_dml_output_cfg_from_stream_state(struct dml_output_cfg_st * out,unsigned int location,const struct dc_stream_state * in,const struct pipe_ctx * pipe,struct dml2_context * dml2)785 static void populate_dml_output_cfg_from_stream_state(struct dml_output_cfg_st *out, unsigned int location,
786 				const struct dc_stream_state *in, const struct pipe_ctx *pipe, struct dml2_context *dml2)
787 {
788 	(void)pipe;
789 	unsigned int output_bpc;
790 
791 	out->DSCEnable[location] = (enum dml_dsc_enable)in->timing.flags.DSC;
792 	out->OutputLinkDPLanes[location] = 4; // As per code in dcn20_resource.c
793 	out->DSCInputBitPerComponent[location] = 12; // As per code in dcn20_resource.c
794 	out->DSCSlices[location] = in->timing.dsc_cfg.num_slices_h;
795 
796 	switch (in->signal) {
797 	case SIGNAL_TYPE_DISPLAY_PORT_MST:
798 	case SIGNAL_TYPE_DISPLAY_PORT:
799 		out->OutputEncoder[location] = dml_dp;
800 		if (location < MAX_HPO_DP2_ENCODERS && dml2->v20.scratch.hpo_stream_to_link_encoder_mapping[location] != -1)
801 			out->OutputEncoder[dml2->v20.scratch.hpo_stream_to_link_encoder_mapping[location]] = dml_dp2p0;
802 		break;
803 	case SIGNAL_TYPE_EDP:
804 		out->OutputEncoder[location] = dml_edp;
805 		break;
806 	case SIGNAL_TYPE_HDMI_TYPE_A:
807 	case SIGNAL_TYPE_DVI_SINGLE_LINK:
808 	case SIGNAL_TYPE_DVI_DUAL_LINK:
809 		out->OutputEncoder[location] = dml_hdmi;
810 		break;
811 	default:
812 		out->OutputEncoder[location] = dml_dp;
813 	}
814 
815 	switch (in->timing.display_color_depth) {
816 	case COLOR_DEPTH_666:
817 		output_bpc = 6;
818 		break;
819 	case COLOR_DEPTH_888:
820 		output_bpc = 8;
821 		break;
822 	case COLOR_DEPTH_101010:
823 		output_bpc = 10;
824 		break;
825 	case COLOR_DEPTH_121212:
826 		output_bpc = 12;
827 		break;
828 	case COLOR_DEPTH_141414:
829 		output_bpc = 14;
830 		break;
831 	case COLOR_DEPTH_161616:
832 		output_bpc = 16;
833 		break;
834 	case COLOR_DEPTH_999:
835 		output_bpc = 9;
836 		break;
837 	case COLOR_DEPTH_111111:
838 		output_bpc = 11;
839 		break;
840 	default:
841 		output_bpc = 8;
842 		break;
843 	}
844 
845 	switch (in->timing.pixel_encoding) {
846 	case PIXEL_ENCODING_RGB:
847 	case PIXEL_ENCODING_YCBCR444:
848 		out->OutputFormat[location] = dml_444;
849 		out->OutputBpp[location] = (dml_float_t)output_bpc * 3;
850 		break;
851 	case PIXEL_ENCODING_YCBCR420:
852 		out->OutputFormat[location] = dml_420;
853 		out->OutputBpp[location] = (output_bpc * 3.0) / 2;
854 		break;
855 	case PIXEL_ENCODING_YCBCR422:
856 		if (in->timing.flags.DSC && !in->timing.dsc_cfg.ycbcr422_simple)
857 			out->OutputFormat[location] = dml_n422;
858 		else
859 			out->OutputFormat[location] = dml_s422;
860 		out->OutputBpp[location] = (dml_float_t)output_bpc * 2;
861 		break;
862 	default:
863 		out->OutputFormat[location] = dml_444;
864 		out->OutputBpp[location] = (dml_float_t)output_bpc * 3;
865 		break;
866 	}
867 
868 	if (in->timing.flags.DSC) {
869 		out->OutputBpp[location] = in->timing.dsc_cfg.bits_per_pixel / 16.0;
870 	}
871 
872 	// This has been false throughout DCN32x development. If needed we can change this later on.
873 	out->OutputMultistreamEn[location] = false;
874 
875 	switch (in->signal) {
876 	case SIGNAL_TYPE_NONE:
877 	case SIGNAL_TYPE_DVI_SINGLE_LINK:
878 	case SIGNAL_TYPE_DVI_DUAL_LINK:
879 	case SIGNAL_TYPE_HDMI_TYPE_A:
880 	case SIGNAL_TYPE_LVDS:
881 	case SIGNAL_TYPE_RGB:
882 	case SIGNAL_TYPE_DISPLAY_PORT:
883 	case SIGNAL_TYPE_DISPLAY_PORT_MST:
884 	case SIGNAL_TYPE_EDP:
885 	case SIGNAL_TYPE_VIRTUAL:
886 	default:
887 		out->OutputLinkDPRate[location] = dml_dp_rate_na;
888 		break;
889 	}
890 
891 	out->PixelClockBackEnd[location] = in->timing.pix_clk_100hz / 10000.00;
892 
893 	out->AudioSampleLayout[location] = in->audio_info.modes->sample_size;
894 	out->AudioSampleRate[location] = in->audio_info.modes->max_bit_rate;
895 
896 	out->OutputDisabled[location] = true;
897 }
898 
populate_dummy_dml_surface_cfg(struct dml_surface_cfg_st * out,unsigned int location,const struct dc_stream_state * in)899 static void populate_dummy_dml_surface_cfg(struct dml_surface_cfg_st *out, unsigned int location, const struct dc_stream_state *in)
900 {
901 	out->SurfaceWidthY[location] = in->timing.h_addressable;
902 	out->SurfaceHeightY[location] = in->timing.v_addressable;
903 	out->SurfaceWidthC[location] = in->timing.h_addressable;
904 	out->SurfaceHeightC[location] = in->timing.v_addressable;
905 	out->PitchY[location] = ((out->SurfaceWidthY[location] + 127) / 128) * 128;
906 	out->PitchC[location] = 1;
907 	out->DCCEnable[location] = false;
908 	out->DCCMetaPitchY[location] = 0;
909 	out->DCCMetaPitchC[location] = 0;
910 	out->DCCRateLuma[location] = 1.0;
911 	out->DCCRateChroma[location] = 1.0;
912 	out->DCCFractionOfZeroSizeRequestsLuma[location] = 0;
913 	out->DCCFractionOfZeroSizeRequestsChroma[location] = 0;
914 	out->SurfaceTiling[location] = dml_sw_64kb_r_x;
915 	out->SourcePixelFormat[location] = dml_444_32;
916 }
917 
populate_dml_surface_cfg_from_plane_state(enum dml_project_id dml2_project,struct dml_surface_cfg_st * out,unsigned int location,const struct dc_plane_state * in)918 static void populate_dml_surface_cfg_from_plane_state(enum dml_project_id dml2_project, struct dml_surface_cfg_st *out, unsigned int location, const struct dc_plane_state *in)
919 {
920 	out->PitchY[location] = in->plane_size.surface_pitch;
921 	out->SurfaceHeightY[location] = in->plane_size.surface_size.height;
922 	out->SurfaceWidthY[location] = in->plane_size.surface_size.width;
923 	out->SurfaceHeightC[location] = in->plane_size.chroma_size.height;
924 	out->SurfaceWidthC[location] = in->plane_size.chroma_size.width;
925 	out->PitchC[location] = in->plane_size.chroma_pitch;
926 	out->DCCEnable[location] = in->dcc.enable;
927 	out->DCCMetaPitchY[location] = in->dcc.meta_pitch;
928 	out->DCCMetaPitchC[location] = in->dcc.meta_pitch_c;
929 	out->DCCRateLuma[location] = 1.0;
930 	out->DCCRateChroma[location] = 1.0;
931 	out->DCCFractionOfZeroSizeRequestsLuma[location] = in->dcc.independent_64b_blks;
932 	out->DCCFractionOfZeroSizeRequestsChroma[location] = in->dcc.independent_64b_blks_c;
933 
934 	switch (dml2_project) {
935 	default:
936 		out->SurfaceTiling[location] = (enum dml_swizzle_mode)in->tiling_info.gfx9.swizzle;
937 		break;
938 	case dml_project_dcn401:
939 		// Temporary use gfx11 swizzle in dml, until proper dml for DCN4x is integrated/implemented
940 		switch (in->tiling_info.gfx_addr3.swizzle) {
941 		case DC_ADDR3_SW_4KB_2D:
942 		case DC_ADDR3_SW_64KB_2D:
943 		case DC_ADDR3_SW_256KB_2D:
944 		default:
945 			out->SurfaceTiling[location] = dml_sw_64kb_r_x;
946 			break;
947 		case DC_ADDR3_SW_LINEAR:
948 			out->SurfaceTiling[location] = dml_sw_linear;
949 			break;
950 		}
951 	}
952 
953 	switch (in->format) {
954 	case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
955 	case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb:
956 		out->SourcePixelFormat[location] = dml_420_8;
957 		break;
958 	case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
959 	case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
960 		out->SourcePixelFormat[location] = dml_420_10;
961 		break;
962 	case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
963 	case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616:
964 	case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F:
965 	case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
966 		out->SourcePixelFormat[location] = dml_444_64;
967 		break;
968 	case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555:
969 	case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
970 		out->SourcePixelFormat[location] = dml_444_16;
971 		break;
972 	case SURFACE_PIXEL_FORMAT_GRPH_PALETA_256_COLORS:
973 		out->SourcePixelFormat[location] = dml_444_8;
974 		break;
975 	case SURFACE_PIXEL_FORMAT_GRPH_RGBE_ALPHA:
976 		out->SourcePixelFormat[location] = dml_rgbe_alpha;
977 		break;
978 	default:
979 		out->SourcePixelFormat[location] = dml_444_32;
980 		break;
981 	}
982 }
983 
get_scaler_data_for_plane(const struct dc_plane_state * in,struct dc_state * context)984 static struct scaler_data *get_scaler_data_for_plane(
985 		const struct dc_plane_state *in,
986 		struct dc_state *context)
987 {
988 	int i;
989 	struct pipe_ctx *temp_pipe = &context->res_ctx.temp_pipe;
990 
991 	memset(temp_pipe, 0, sizeof(struct pipe_ctx));
992 
993 	for (i = 0; i < MAX_PIPES; i++)	{
994 		const struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
995 
996 		if (pipe->plane_state == in && !pipe->prev_odm_pipe) {
997 			temp_pipe->stream = pipe->stream;
998 			temp_pipe->plane_state = pipe->plane_state;
999 			temp_pipe->plane_res.scl_data.taps = pipe->plane_res.scl_data.taps;
1000 			temp_pipe->stream_res = pipe->stream_res;
1001 			resource_build_scaling_params(temp_pipe);
1002 			break;
1003 		}
1004 	}
1005 
1006 	ASSERT(i < MAX_PIPES);
1007 	return &temp_pipe->plane_res.scl_data;
1008 }
1009 
populate_dummy_dml_plane_cfg(struct dml_plane_cfg_st * out,unsigned int location,const struct dc_stream_state * in,const struct soc_bounding_box_st * soc)1010 static void populate_dummy_dml_plane_cfg(struct dml_plane_cfg_st *out, unsigned int location,
1011 					 const struct dc_stream_state *in,
1012 					 const struct soc_bounding_box_st *soc)
1013 {
1014 	dml_uint_t width, height;
1015 
1016 	if (in->timing.h_addressable > 3840)
1017 		width = 3840;
1018 	else
1019 		width = in->timing.h_addressable;	// 4K max
1020 
1021 	if (in->timing.v_addressable > 2160)
1022 		height = 2160;
1023 	else
1024 		height = in->timing.v_addressable;	// 4K max
1025 
1026 	out->CursorBPP[location] = dml_cur_32bit;
1027 	out->CursorWidth[location] = 256;
1028 
1029 	out->GPUVMMinPageSizeKBytes[location] = soc->gpuvm_min_page_size_kbytes;
1030 
1031 	out->ViewportWidth[location] = width;
1032 	out->ViewportHeight[location] = height;
1033 	out->ViewportStationary[location] = false;
1034 	out->ViewportWidthChroma[location] = 0;
1035 	out->ViewportHeightChroma[location] = 0;
1036 	out->ViewportXStart[location] = 0;
1037 	out->ViewportXStartC[location] = 0;
1038 	out->ViewportYStart[location] = 0;
1039 	out->ViewportYStartC[location] = 0;
1040 
1041 	out->ScalerEnabled[location] = false;
1042 	out->HRatio[location] = 1.0;
1043 	out->VRatio[location] = 1.0;
1044 	out->HRatioChroma[location] = 0;
1045 	out->VRatioChroma[location] = 0;
1046 	out->HTaps[location] = 1;
1047 	out->VTaps[location] = 1;
1048 	out->HTapsChroma[location] = 0;
1049 	out->VTapsChroma[location] = 0;
1050 	out->SourceScan[location] = dml_rotation_0;
1051 	out->ScalerRecoutWidth[location] = width;
1052 
1053 	out->LBBitPerPixel[location] = 57;
1054 
1055 	out->DynamicMetadataEnable[location] = false;
1056 
1057 	out->NumberOfCursors[location] = 1;
1058 	out->UseMALLForStaticScreen[location] = dml_use_mall_static_screen_disable;
1059 	out->UseMALLForPStateChange[location] = dml_use_mall_pstate_change_disable;
1060 
1061 	out->DETSizeOverride[location] = 256;
1062 
1063 	out->ScalerEnabled[location] = false;
1064 }
1065 
populate_dml_plane_cfg_from_plane_state(struct dml_plane_cfg_st * out,unsigned int location,const struct dc_plane_state * in,struct dc_state * context,const struct soc_bounding_box_st * soc)1066 static void populate_dml_plane_cfg_from_plane_state(struct dml_plane_cfg_st *out, unsigned int location,
1067 						    const struct dc_plane_state *in, struct dc_state *context,
1068 						    const struct soc_bounding_box_st *soc)
1069 {
1070 	struct scaler_data *scaler_data = get_scaler_data_for_plane(in, context);
1071 
1072 	out->CursorBPP[location] = dml_cur_32bit;
1073 	out->CursorWidth[location] = 256;
1074 
1075 	out->GPUVMMinPageSizeKBytes[location] = soc->gpuvm_min_page_size_kbytes;
1076 
1077 	out->ViewportWidth[location] = scaler_data->viewport.width;
1078 	out->ViewportHeight[location] = scaler_data->viewport.height;
1079 	out->ViewportWidthChroma[location] = scaler_data->viewport_c.width;
1080 	out->ViewportHeightChroma[location] = scaler_data->viewport_c.height;
1081 	out->ViewportXStart[location] = scaler_data->viewport.x;
1082 	out->ViewportYStart[location] = scaler_data->viewport.y;
1083 	out->ViewportXStartC[location] = scaler_data->viewport_c.x;
1084 	out->ViewportYStartC[location] = scaler_data->viewport_c.y;
1085 	out->ViewportStationary[location] = false;
1086 
1087 	out->ScalerEnabled[location] = scaler_data->ratios.horz.value != dc_fixpt_one.value ||
1088 				scaler_data->ratios.horz_c.value != dc_fixpt_one.value ||
1089 				scaler_data->ratios.vert.value != dc_fixpt_one.value ||
1090 				scaler_data->ratios.vert_c.value != dc_fixpt_one.value;
1091 
1092 	/* Current driver code base uses LBBitPerPixel as 57. There is a discrepancy
1093 	 * from the HW/DML teams about this value. Initialize LBBitPerPixel with the
1094 	 * value current used in Navi3x .
1095 	 */
1096 
1097 	out->LBBitPerPixel[location] = 57;
1098 
1099 	if (out->ScalerEnabled[location] == false) {
1100 		out->HRatio[location] = 1;
1101 		out->HRatioChroma[location] = 1;
1102 		out->VRatio[location] = 1;
1103 		out->VRatioChroma[location] = 1;
1104 	} else {
1105 		/* Follow the original dml_wrapper.c code direction to fix scaling issues */
1106 		out->HRatio[location] = (dml_float_t)scaler_data->ratios.horz.value / (1ULL << 32);
1107 		out->HRatioChroma[location] = (dml_float_t)scaler_data->ratios.horz_c.value / (1ULL << 32);
1108 		out->VRatio[location] = (dml_float_t)scaler_data->ratios.vert.value / (1ULL << 32);
1109 		out->VRatioChroma[location] = (dml_float_t)scaler_data->ratios.vert_c.value / (1ULL << 32);
1110 	}
1111 
1112 	if (!scaler_data->taps.h_taps) {
1113 		out->HTaps[location] = 1;
1114 		out->HTapsChroma[location] = 1;
1115 	} else {
1116 		out->HTaps[location] = scaler_data->taps.h_taps;
1117 		out->HTapsChroma[location] = scaler_data->taps.h_taps_c;
1118 	}
1119 	if (!scaler_data->taps.v_taps) {
1120 		out->VTaps[location] = 1;
1121 		out->VTapsChroma[location] = 1;
1122 	} else {
1123 		out->VTaps[location] = scaler_data->taps.v_taps;
1124 		out->VTapsChroma[location] = scaler_data->taps.v_taps_c;
1125 	}
1126 
1127 	out->SourceScan[location] = (enum dml_rotation_angle)in->rotation;
1128 	out->ScalerRecoutWidth[location] = in->dst_rect.width;
1129 
1130 	out->DynamicMetadataEnable[location] = false;
1131 	out->DynamicMetadataLinesBeforeActiveRequired[location] = 0;
1132 	out->DynamicMetadataTransmittedBytes[location] = 0;
1133 
1134 	out->NumberOfCursors[location] = 1;
1135 }
1136 
map_stream_to_dml_display_cfg(const struct dml2_context * dml2,const struct dc_stream_state * stream,const struct dml_display_cfg_st * dml_dispcfg)1137 static unsigned int map_stream_to_dml_display_cfg(const struct dml2_context *dml2,
1138 		const struct dc_stream_state *stream, const struct dml_display_cfg_st *dml_dispcfg)
1139 {
1140 	(void)dml_dispcfg;
1141 	int i = 0;
1142 	int location = -1;
1143 
1144 	for (i = 0; i < __DML2_WRAPPER_MAX_STREAMS_PLANES__; i++) {
1145 		if (dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_stream_id_valid[i] && dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_stream_id[i] == stream->stream_id) {
1146 			location = i;
1147 			break;
1148 		}
1149 	}
1150 
1151 	return location;
1152 }
1153 
get_plane_id(struct dml2_context * dml2,const struct dc_state * context,const struct dc_plane_state * plane,unsigned int stream_id,unsigned int plane_index,unsigned int * plane_id)1154 static bool get_plane_id(struct dml2_context *dml2, const struct dc_state *context, const struct dc_plane_state *plane,
1155 		unsigned int stream_id, unsigned int plane_index, unsigned int *plane_id)
1156 {
1157 	int i, j;
1158 	bool is_plane_duplicate = dml2->v20.scratch.plane_duplicate_exists;
1159 
1160 	if (!plane_id)
1161 		return false;
1162 
1163 	for (i = 0; i < context->stream_count; i++) {
1164 		if (context->streams[i]->stream_id == stream_id) {
1165 			for (j = 0; j < context->stream_status[i].plane_count; j++) {
1166 				if (context->stream_status[i].plane_states[j] == plane &&
1167 					(!is_plane_duplicate || (j == plane_index))) {
1168 					*plane_id = (i << 16) | j;
1169 					return true;
1170 				}
1171 			}
1172 		}
1173 	}
1174 
1175 	return false;
1176 }
1177 
map_plane_to_dml_display_cfg(const struct dml2_context * dml2,const struct dc_plane_state * plane,const struct dc_state * context,const struct dml_display_cfg_st * dml_dispcfg,unsigned int stream_id,int plane_index)1178 static unsigned int map_plane_to_dml_display_cfg(const struct dml2_context *dml2, const struct dc_plane_state *plane,
1179 		const struct dc_state *context, const struct dml_display_cfg_st *dml_dispcfg, unsigned int stream_id, int plane_index)
1180 {
1181 	(void)dml_dispcfg;
1182 	unsigned int plane_id;
1183 	unsigned int i = 0;
1184 	unsigned int location = UINT_MAX;
1185 
1186 	if (!get_plane_id(context->bw_ctx.dml2, context, plane, stream_id, plane_index, &plane_id)) {
1187 		ASSERT(false);
1188 		return UINT_MAX;
1189 	}
1190 
1191 	for (i = 0; i < __DML2_WRAPPER_MAX_STREAMS_PLANES__; i++) {
1192 		if (dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_plane_id_valid[i] && dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_plane_id[i] == plane_id) {
1193 			location = i;
1194 			break;
1195 		}
1196 	}
1197 
1198 	return location;
1199 }
1200 
dml2_populate_pipe_to_plane_index_mapping(struct dml2_context * dml2,struct dc_state * state)1201 static void dml2_populate_pipe_to_plane_index_mapping(struct dml2_context *dml2, struct dc_state *state)
1202 {
1203 	unsigned int i;
1204 	unsigned int pipe_index = 0;
1205 	unsigned int plane_index = 0;
1206 	struct dml2_dml_to_dc_pipe_mapping *dml_to_dc_pipe_mapping = &dml2->v20.scratch.dml_to_dc_pipe_mapping;
1207 
1208 	for (i = 0; i < __DML2_WRAPPER_MAX_STREAMS_PLANES__; i++) {
1209 		dml_to_dc_pipe_mapping->dml_pipe_idx_to_plane_index_valid[i] = false;
1210 		dml_to_dc_pipe_mapping->dml_pipe_idx_to_plane_index[i] = 0;
1211 	}
1212 
1213 	for (i = 0; i < __DML2_WRAPPER_MAX_STREAMS_PLANES__; i++) {
1214 		struct pipe_ctx *pipe = &state->res_ctx.pipe_ctx[i];
1215 
1216 		if (!pipe || !pipe->stream || !pipe->plane_state)
1217 			continue;
1218 
1219 		while (pipe) {
1220 			pipe_index = pipe->pipe_idx;
1221 
1222 			if (pipe->stream && dml_to_dc_pipe_mapping->dml_pipe_idx_to_plane_index_valid[pipe_index] == false) {
1223 				dml_to_dc_pipe_mapping->dml_pipe_idx_to_plane_index[pipe_index] = plane_index;
1224 				plane_index++;
1225 				dml_to_dc_pipe_mapping->dml_pipe_idx_to_plane_index_valid[pipe_index] = true;
1226 			}
1227 
1228 			pipe = pipe->bottom_pipe;
1229 		}
1230 
1231 		plane_index = 0;
1232 	}
1233 }
1234 
populate_dml_writeback_cfg_from_stream_state(struct dml_writeback_cfg_st * out,unsigned int location,const struct dc_stream_state * in)1235 static void populate_dml_writeback_cfg_from_stream_state(struct dml_writeback_cfg_st *out,
1236 		unsigned int location, const struct dc_stream_state *in)
1237 {
1238 	if (in->num_wb_info > 0) {
1239 		for (int i = 0; i < __DML_NUM_DMB__; i++) {
1240 			const struct dc_writeback_info *wb_info = &in->writeback_info[i];
1241 			/*current dml support 1 dwb per stream, limitation*/
1242 			if (wb_info->wb_enabled) {
1243 				out->WritebackEnable[location] = wb_info->wb_enabled;
1244 				out->ActiveWritebacksPerSurface[location] = wb_info->dwb_params.cnv_params.src_width;
1245 				out->WritebackDestinationWidth[location] = wb_info->dwb_params.dest_width;
1246 				out->WritebackDestinationHeight[location] = wb_info->dwb_params.dest_height;
1247 
1248 				out->WritebackSourceWidth[location] = wb_info->dwb_params.cnv_params.crop_en ?
1249 					wb_info->dwb_params.cnv_params.crop_width :
1250 					wb_info->dwb_params.cnv_params.src_width;
1251 
1252 				out->WritebackSourceHeight[location] = wb_info->dwb_params.cnv_params.crop_en ?
1253 					wb_info->dwb_params.cnv_params.crop_height :
1254 					wb_info->dwb_params.cnv_params.src_height;
1255 				/*current design does not have chroma scaling, need to follow up*/
1256 				out->WritebackHTaps[location] = wb_info->dwb_params.scaler_taps.h_taps > 0 ?
1257 					wb_info->dwb_params.scaler_taps.h_taps : 1;
1258 				out->WritebackVTaps[location] = wb_info->dwb_params.scaler_taps.v_taps > 0 ?
1259 					wb_info->dwb_params.scaler_taps.v_taps : 1;
1260 
1261 				out->WritebackHRatio[location] = wb_info->dwb_params.cnv_params.crop_en ?
1262 					(double)wb_info->dwb_params.cnv_params.crop_width /
1263 						(double)wb_info->dwb_params.dest_width :
1264 					(double)wb_info->dwb_params.cnv_params.src_width /
1265 						(double)wb_info->dwb_params.dest_width;
1266 				out->WritebackVRatio[location] = wb_info->dwb_params.cnv_params.crop_en ?
1267 					(double)wb_info->dwb_params.cnv_params.crop_height /
1268 						(double)wb_info->dwb_params.dest_height :
1269 					(double)wb_info->dwb_params.cnv_params.src_height /
1270 						(double)wb_info->dwb_params.dest_height;
1271 			}
1272 		}
1273 	}
1274 }
1275 
dml2_map_hpo_stream_encoder_to_hpo_link_encoder_index(struct dml2_context * dml2,struct dc_state * context)1276 static void dml2_map_hpo_stream_encoder_to_hpo_link_encoder_index(struct dml2_context *dml2, struct dc_state *context)
1277 {
1278 	int i;
1279 	struct pipe_ctx *current_pipe_context;
1280 
1281 	/* Scratch gets reset to zero in dml, but link encoder instance can be zero, so reset to -1 */
1282 	for (i = 0; i < MAX_HPO_DP2_ENCODERS; i++) {
1283 		dml2->v20.scratch.hpo_stream_to_link_encoder_mapping[i] = -1;
1284 	}
1285 
1286 	/* If an HPO stream encoder is allocated to a pipe, get the instance of it's allocated HPO Link encoder */
1287 	for (i = 0; i < MAX_PIPES; i++) {
1288 		current_pipe_context = &context->res_ctx.pipe_ctx[i];
1289 		if (current_pipe_context->stream &&
1290 			current_pipe_context->stream_res.hpo_dp_stream_enc &&
1291 			current_pipe_context->link_res.hpo_dp_link_enc &&
1292 			dc_is_dp_signal(current_pipe_context->stream->signal)) {
1293 				dml2->v20.scratch.hpo_stream_to_link_encoder_mapping[current_pipe_context->stream_res.hpo_dp_stream_enc->inst] =
1294 					current_pipe_context->link_res.hpo_dp_link_enc->inst;
1295 			}
1296 	}
1297 }
1298 
map_dc_state_into_dml_display_cfg(struct dml2_context * dml2,struct dc_state * context,struct dml_display_cfg_st * dml_dispcfg)1299 void map_dc_state_into_dml_display_cfg(struct dml2_context *dml2, struct dc_state *context, struct dml_display_cfg_st *dml_dispcfg)
1300 {
1301 	int i = 0, j = 0, k = 0;
1302 	int disp_cfg_stream_location, disp_cfg_plane_location;
1303 	enum mall_stream_type stream_mall_type;
1304 	struct pipe_ctx *current_pipe_context;
1305 
1306 	for (i = 0; i < __DML2_WRAPPER_MAX_STREAMS_PLANES__; i++) {
1307 		dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_stream_id_valid[i] = false;
1308 		dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_plane_id_valid[i] = false;
1309 		dml2->v20.scratch.dml_to_dc_pipe_mapping.dml_pipe_idx_to_stream_id_valid[i] = false;
1310 		dml2->v20.scratch.dml_to_dc_pipe_mapping.dml_pipe_idx_to_plane_id_valid[i] = false;
1311 	}
1312 
1313 	//Generally these are set by referencing our latest BB/IP params in dcn32_resource.c file
1314 	dml_dispcfg->plane.GPUVMEnable = dml2->v20.dml_core_ctx.ip.gpuvm_enable;
1315 	dml_dispcfg->plane.GPUVMMaxPageTableLevels = dml2->v20.dml_core_ctx.ip.gpuvm_max_page_table_levels;
1316 	dml_dispcfg->plane.HostVMEnable = dml2->v20.dml_core_ctx.ip.hostvm_enable;
1317 	dml_dispcfg->plane.HostVMMaxPageTableLevels = dml2->v20.dml_core_ctx.ip.hostvm_max_page_table_levels;
1318 	if (dml2->v20.dml_core_ctx.ip.hostvm_enable)
1319 		dml2->v20.dml_core_ctx.policy.AllowForPStateChangeOrStutterInVBlankFinal = dml_prefetch_support_uclk_fclk_and_stutter;
1320 
1321 	dml2_populate_pipe_to_plane_index_mapping(dml2, context);
1322 	dml2_map_hpo_stream_encoder_to_hpo_link_encoder_index(dml2, context);
1323 
1324 	for (i = 0; i < context->stream_count; i++) {
1325 		current_pipe_context = NULL;
1326 		for (k = 0; k < MAX_PIPES; k++) {
1327 			/* find one pipe allocated to this stream for the purpose of getting
1328 			info about the link later */
1329 			if (context->streams[i] == context->res_ctx.pipe_ctx[k].stream) {
1330 				current_pipe_context = &context->res_ctx.pipe_ctx[k];
1331 				break;
1332 			}
1333 		}
1334 		disp_cfg_stream_location = map_stream_to_dml_display_cfg(dml2, context->streams[i], dml_dispcfg);
1335 		stream_mall_type = dc_state_get_stream_subvp_type(context, context->streams[i]);
1336 
1337 		if (disp_cfg_stream_location < 0)
1338 			disp_cfg_stream_location = dml_dispcfg->num_timings++;
1339 
1340 		ASSERT(disp_cfg_stream_location >= 0 && disp_cfg_stream_location < __DML2_WRAPPER_MAX_STREAMS_PLANES__);
1341 
1342 		populate_dml_timing_cfg_from_stream_state(&dml_dispcfg->timing, disp_cfg_stream_location, context->streams[i]);
1343 		populate_dml_output_cfg_from_stream_state(&dml_dispcfg->output, disp_cfg_stream_location, context->streams[i], current_pipe_context, dml2);
1344 		/*Call site for populate_dml_writeback_cfg_from_stream_state*/
1345 		populate_dml_writeback_cfg_from_stream_state(&dml_dispcfg->writeback,
1346 			disp_cfg_stream_location, context->streams[i]);
1347 
1348 		switch (context->streams[i]->debug.force_odm_combine_segments) {
1349 		case 2:
1350 			dml2->v20.dml_core_ctx.policy.ODMUse[disp_cfg_stream_location] = dml_odm_use_policy_combine_2to1;
1351 			break;
1352 		case 4:
1353 			dml2->v20.dml_core_ctx.policy.ODMUse[disp_cfg_stream_location] = dml_odm_use_policy_combine_4to1;
1354 			break;
1355 		default:
1356 			break;
1357 		}
1358 
1359 		dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_stream_id[disp_cfg_stream_location] = context->streams[i]->stream_id;
1360 		dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_stream_id_valid[disp_cfg_stream_location] = true;
1361 
1362 		if (context->stream_status[i].plane_count == 0) {
1363 			disp_cfg_plane_location = dml_dispcfg->num_surfaces++;
1364 
1365 			populate_dummy_dml_surface_cfg(&dml_dispcfg->surface, disp_cfg_plane_location, context->streams[i]);
1366 			populate_dummy_dml_plane_cfg(&dml_dispcfg->plane, disp_cfg_plane_location,
1367 						     context->streams[i], &dml2->v20.dml_core_ctx.soc);
1368 
1369 			dml_dispcfg->plane.BlendingAndTiming[disp_cfg_plane_location] = disp_cfg_stream_location;
1370 
1371 			dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_plane_id_valid[disp_cfg_plane_location] = true;
1372 		} else {
1373 			for (j = 0; j < context->stream_status[i].plane_count; j++) {
1374 				disp_cfg_plane_location = map_plane_to_dml_display_cfg(dml2,
1375 					context->stream_status[i].plane_states[j], context, dml_dispcfg, context->streams[i]->stream_id, j);
1376 
1377 				if (disp_cfg_plane_location < 0)
1378 					disp_cfg_plane_location = dml_dispcfg->num_surfaces++;
1379 
1380 				ASSERT(disp_cfg_plane_location >= 0 && disp_cfg_plane_location < __DML2_WRAPPER_MAX_STREAMS_PLANES__);
1381 
1382 				populate_dml_surface_cfg_from_plane_state(dml2->v20.dml_core_ctx.project, &dml_dispcfg->surface, disp_cfg_plane_location, context->stream_status[i].plane_states[j]);
1383 				populate_dml_plane_cfg_from_plane_state(
1384 					&dml_dispcfg->plane, disp_cfg_plane_location,
1385 					context->stream_status[i].plane_states[j], context,
1386 					&dml2->v20.dml_core_ctx.soc);
1387 
1388 				if (stream_mall_type == SUBVP_MAIN) {
1389 					dml_dispcfg->plane.UseMALLForPStateChange[disp_cfg_plane_location] = dml_use_mall_pstate_change_sub_viewport;
1390 					dml_dispcfg->plane.UseMALLForStaticScreen[disp_cfg_plane_location] = dml_use_mall_static_screen_optimize;
1391 				} else if (stream_mall_type == SUBVP_PHANTOM) {
1392 					dml_dispcfg->plane.UseMALLForPStateChange[disp_cfg_plane_location] = dml_use_mall_pstate_change_phantom_pipe;
1393 					dml_dispcfg->plane.UseMALLForStaticScreen[disp_cfg_plane_location] = dml_use_mall_static_screen_disable;
1394 					dml2->v20.dml_core_ctx.policy.ImmediateFlipRequirement[disp_cfg_plane_location] = dml_immediate_flip_not_required;
1395 				} else {
1396 					dml_dispcfg->plane.UseMALLForPStateChange[disp_cfg_plane_location] = dml_use_mall_pstate_change_disable;
1397 					dml_dispcfg->plane.UseMALLForStaticScreen[disp_cfg_plane_location] = dml_use_mall_static_screen_optimize;
1398 				}
1399 
1400 				dml_dispcfg->plane.BlendingAndTiming[disp_cfg_plane_location] = disp_cfg_stream_location;
1401 
1402 				if (get_plane_id(dml2, context, context->stream_status[i].plane_states[j], context->streams[i]->stream_id, j,
1403 					&dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_plane_id[disp_cfg_plane_location]))
1404 					dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_plane_id_valid[disp_cfg_plane_location] = true;
1405 
1406 				if (j >= 1) {
1407 					populate_dml_timing_cfg_from_stream_state(&dml_dispcfg->timing, disp_cfg_plane_location, context->streams[i]);
1408 					populate_dml_output_cfg_from_stream_state(&dml_dispcfg->output, disp_cfg_plane_location, context->streams[i], current_pipe_context, dml2);
1409 					switch (context->streams[i]->debug.force_odm_combine_segments) {
1410 					case 2:
1411 						dml2->v20.dml_core_ctx.policy.ODMUse[disp_cfg_plane_location] = dml_odm_use_policy_combine_2to1;
1412 						break;
1413 					case 4:
1414 						dml2->v20.dml_core_ctx.policy.ODMUse[disp_cfg_plane_location] = dml_odm_use_policy_combine_4to1;
1415 						break;
1416 					default:
1417 						break;
1418 					}
1419 
1420 					if (stream_mall_type == SUBVP_MAIN)
1421 						dml_dispcfg->plane.UseMALLForPStateChange[disp_cfg_plane_location] = dml_use_mall_pstate_change_sub_viewport;
1422 					else if (stream_mall_type == SUBVP_PHANTOM)
1423 						dml_dispcfg->plane.UseMALLForPStateChange[disp_cfg_plane_location] = dml_use_mall_pstate_change_phantom_pipe;
1424 
1425 					dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_stream_id[disp_cfg_plane_location] = context->streams[i]->stream_id;
1426 					dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_stream_id_valid[disp_cfg_plane_location] = true;
1427 
1428 					dml_dispcfg->num_timings++;
1429 				}
1430 			}
1431 		}
1432 	}
1433 }
1434 
dml2_update_pipe_ctx_dchub_regs(struct _vcs_dpi_dml_display_rq_regs_st * rq_regs,struct _vcs_dpi_dml_display_dlg_regs_st * disp_dlg_regs,struct _vcs_dpi_dml_display_ttu_regs_st * disp_ttu_regs,struct pipe_ctx * out)1435 void dml2_update_pipe_ctx_dchub_regs(struct _vcs_dpi_dml_display_rq_regs_st *rq_regs,
1436 	struct _vcs_dpi_dml_display_dlg_regs_st *disp_dlg_regs,
1437 	struct _vcs_dpi_dml_display_ttu_regs_st *disp_ttu_regs,
1438 	struct pipe_ctx *out)
1439 {
1440 	memset(&out->rq_regs, 0, sizeof(out->rq_regs));
1441 	out->rq_regs.rq_regs_l.chunk_size = rq_regs->rq_regs_l.chunk_size;
1442 	out->rq_regs.rq_regs_l.min_chunk_size = rq_regs->rq_regs_l.min_chunk_size;
1443 	out->rq_regs.rq_regs_l.meta_chunk_size = rq_regs->rq_regs_l.meta_chunk_size;
1444 	out->rq_regs.rq_regs_l.min_meta_chunk_size = rq_regs->rq_regs_l.min_meta_chunk_size;
1445 	out->rq_regs.rq_regs_l.dpte_group_size = rq_regs->rq_regs_l.dpte_group_size;
1446 	out->rq_regs.rq_regs_l.mpte_group_size = rq_regs->rq_regs_l.mpte_group_size;
1447 	out->rq_regs.rq_regs_l.swath_height = rq_regs->rq_regs_l.swath_height;
1448 	out->rq_regs.rq_regs_l.pte_row_height_linear = rq_regs->rq_regs_l.pte_row_height_linear;
1449 
1450 	out->rq_regs.rq_regs_c.chunk_size = rq_regs->rq_regs_c.chunk_size;
1451 	out->rq_regs.rq_regs_c.min_chunk_size = rq_regs->rq_regs_c.min_chunk_size;
1452 	out->rq_regs.rq_regs_c.meta_chunk_size = rq_regs->rq_regs_c.meta_chunk_size;
1453 	out->rq_regs.rq_regs_c.min_meta_chunk_size = rq_regs->rq_regs_c.min_meta_chunk_size;
1454 	out->rq_regs.rq_regs_c.dpte_group_size = rq_regs->rq_regs_c.dpte_group_size;
1455 	out->rq_regs.rq_regs_c.mpte_group_size = rq_regs->rq_regs_c.mpte_group_size;
1456 	out->rq_regs.rq_regs_c.swath_height = rq_regs->rq_regs_c.swath_height;
1457 	out->rq_regs.rq_regs_c.pte_row_height_linear = rq_regs->rq_regs_c.pte_row_height_linear;
1458 
1459 	out->rq_regs.drq_expansion_mode = rq_regs->drq_expansion_mode;
1460 	out->rq_regs.prq_expansion_mode = rq_regs->prq_expansion_mode;
1461 	out->rq_regs.mrq_expansion_mode = rq_regs->mrq_expansion_mode;
1462 	out->rq_regs.crq_expansion_mode = rq_regs->crq_expansion_mode;
1463 	out->rq_regs.plane1_base_address = rq_regs->plane1_base_address;
1464 
1465 	memset(&out->dlg_regs, 0, sizeof(out->dlg_regs));
1466 	out->dlg_regs.refcyc_h_blank_end = disp_dlg_regs->refcyc_h_blank_end;
1467 	out->dlg_regs.dlg_vblank_end = disp_dlg_regs->dlg_vblank_end;
1468 	out->dlg_regs.min_dst_y_next_start = disp_dlg_regs->min_dst_y_next_start;
1469 	out->dlg_regs.refcyc_per_htotal = disp_dlg_regs->refcyc_per_htotal;
1470 	out->dlg_regs.refcyc_x_after_scaler = disp_dlg_regs->refcyc_x_after_scaler;
1471 	out->dlg_regs.dst_y_after_scaler = disp_dlg_regs->dst_y_after_scaler;
1472 	out->dlg_regs.dst_y_prefetch = disp_dlg_regs->dst_y_prefetch;
1473 	out->dlg_regs.dst_y_per_vm_vblank = disp_dlg_regs->dst_y_per_vm_vblank;
1474 	out->dlg_regs.dst_y_per_row_vblank = disp_dlg_regs->dst_y_per_row_vblank;
1475 	out->dlg_regs.dst_y_per_vm_flip = disp_dlg_regs->dst_y_per_vm_flip;
1476 	out->dlg_regs.dst_y_per_row_flip = disp_dlg_regs->dst_y_per_row_flip;
1477 	out->dlg_regs.ref_freq_to_pix_freq = disp_dlg_regs->ref_freq_to_pix_freq;
1478 	out->dlg_regs.vratio_prefetch = disp_dlg_regs->vratio_prefetch;
1479 	out->dlg_regs.vratio_prefetch_c = disp_dlg_regs->vratio_prefetch_c;
1480 	out->dlg_regs.refcyc_per_pte_group_vblank_l = disp_dlg_regs->refcyc_per_pte_group_vblank_l;
1481 	out->dlg_regs.refcyc_per_pte_group_vblank_c = disp_dlg_regs->refcyc_per_pte_group_vblank_c;
1482 	out->dlg_regs.refcyc_per_meta_chunk_vblank_l = disp_dlg_regs->refcyc_per_meta_chunk_vblank_l;
1483 	out->dlg_regs.refcyc_per_meta_chunk_vblank_c = disp_dlg_regs->refcyc_per_meta_chunk_vblank_c;
1484 	out->dlg_regs.refcyc_per_pte_group_flip_l = disp_dlg_regs->refcyc_per_pte_group_flip_l;
1485 	out->dlg_regs.refcyc_per_pte_group_flip_c = disp_dlg_regs->refcyc_per_pte_group_flip_c;
1486 	out->dlg_regs.refcyc_per_meta_chunk_flip_l = disp_dlg_regs->refcyc_per_meta_chunk_flip_l;
1487 	out->dlg_regs.refcyc_per_meta_chunk_flip_c = disp_dlg_regs->refcyc_per_meta_chunk_flip_c;
1488 	out->dlg_regs.dst_y_per_pte_row_nom_l = disp_dlg_regs->dst_y_per_pte_row_nom_l;
1489 	out->dlg_regs.dst_y_per_pte_row_nom_c = disp_dlg_regs->dst_y_per_pte_row_nom_c;
1490 	out->dlg_regs.refcyc_per_pte_group_nom_l = disp_dlg_regs->refcyc_per_pte_group_nom_l;
1491 	out->dlg_regs.refcyc_per_pte_group_nom_c = disp_dlg_regs->refcyc_per_pte_group_nom_c;
1492 	out->dlg_regs.dst_y_per_meta_row_nom_l = disp_dlg_regs->dst_y_per_meta_row_nom_l;
1493 	out->dlg_regs.dst_y_per_meta_row_nom_c = disp_dlg_regs->dst_y_per_meta_row_nom_c;
1494 	out->dlg_regs.refcyc_per_meta_chunk_nom_l = disp_dlg_regs->refcyc_per_meta_chunk_nom_l;
1495 	out->dlg_regs.refcyc_per_meta_chunk_nom_c = disp_dlg_regs->refcyc_per_meta_chunk_nom_c;
1496 	out->dlg_regs.refcyc_per_line_delivery_pre_l = disp_dlg_regs->refcyc_per_line_delivery_pre_l;
1497 	out->dlg_regs.refcyc_per_line_delivery_pre_c = disp_dlg_regs->refcyc_per_line_delivery_pre_c;
1498 	out->dlg_regs.refcyc_per_line_delivery_l = disp_dlg_regs->refcyc_per_line_delivery_l;
1499 	out->dlg_regs.refcyc_per_line_delivery_c = disp_dlg_regs->refcyc_per_line_delivery_c;
1500 	out->dlg_regs.refcyc_per_vm_group_vblank = disp_dlg_regs->refcyc_per_vm_group_vblank;
1501 	out->dlg_regs.refcyc_per_vm_group_flip = disp_dlg_regs->refcyc_per_vm_group_flip;
1502 	out->dlg_regs.refcyc_per_vm_req_vblank = disp_dlg_regs->refcyc_per_vm_req_vblank;
1503 	out->dlg_regs.refcyc_per_vm_req_flip = disp_dlg_regs->refcyc_per_vm_req_flip;
1504 	out->dlg_regs.dst_y_offset_cur0 = disp_dlg_regs->dst_y_offset_cur0;
1505 	out->dlg_regs.chunk_hdl_adjust_cur0 = disp_dlg_regs->chunk_hdl_adjust_cur0;
1506 	out->dlg_regs.dst_y_offset_cur1 = disp_dlg_regs->dst_y_offset_cur1;
1507 	out->dlg_regs.chunk_hdl_adjust_cur1 = disp_dlg_regs->chunk_hdl_adjust_cur1;
1508 	out->dlg_regs.vready_after_vcount0 = disp_dlg_regs->vready_after_vcount0;
1509 	out->dlg_regs.dst_y_delta_drq_limit = disp_dlg_regs->dst_y_delta_drq_limit;
1510 	out->dlg_regs.refcyc_per_vm_dmdata = disp_dlg_regs->refcyc_per_vm_dmdata;
1511 	out->dlg_regs.dmdata_dl_delta = disp_dlg_regs->dmdata_dl_delta;
1512 
1513 	memset(&out->ttu_regs, 0, sizeof(out->ttu_regs));
1514 	out->ttu_regs.qos_level_low_wm = disp_ttu_regs->qos_level_low_wm;
1515 	out->ttu_regs.qos_level_high_wm = disp_ttu_regs->qos_level_high_wm;
1516 	out->ttu_regs.min_ttu_vblank = disp_ttu_regs->min_ttu_vblank;
1517 	out->ttu_regs.qos_level_flip = disp_ttu_regs->qos_level_flip;
1518 	out->ttu_regs.refcyc_per_req_delivery_l = disp_ttu_regs->refcyc_per_req_delivery_l;
1519 	out->ttu_regs.refcyc_per_req_delivery_c = disp_ttu_regs->refcyc_per_req_delivery_c;
1520 	out->ttu_regs.refcyc_per_req_delivery_cur0 = disp_ttu_regs->refcyc_per_req_delivery_cur0;
1521 	out->ttu_regs.refcyc_per_req_delivery_cur1 = disp_ttu_regs->refcyc_per_req_delivery_cur1;
1522 	out->ttu_regs.refcyc_per_req_delivery_pre_l = disp_ttu_regs->refcyc_per_req_delivery_pre_l;
1523 	out->ttu_regs.refcyc_per_req_delivery_pre_c = disp_ttu_regs->refcyc_per_req_delivery_pre_c;
1524 	out->ttu_regs.refcyc_per_req_delivery_pre_cur0 = disp_ttu_regs->refcyc_per_req_delivery_pre_cur0;
1525 	out->ttu_regs.refcyc_per_req_delivery_pre_cur1 = disp_ttu_regs->refcyc_per_req_delivery_pre_cur1;
1526 	out->ttu_regs.qos_level_fixed_l = disp_ttu_regs->qos_level_fixed_l;
1527 	out->ttu_regs.qos_level_fixed_c = disp_ttu_regs->qos_level_fixed_c;
1528 	out->ttu_regs.qos_level_fixed_cur0 = disp_ttu_regs->qos_level_fixed_cur0;
1529 	out->ttu_regs.qos_level_fixed_cur1 = disp_ttu_regs->qos_level_fixed_cur1;
1530 	out->ttu_regs.qos_ramp_disable_l = disp_ttu_regs->qos_ramp_disable_l;
1531 	out->ttu_regs.qos_ramp_disable_c = disp_ttu_regs->qos_ramp_disable_c;
1532 	out->ttu_regs.qos_ramp_disable_cur0 = disp_ttu_regs->qos_ramp_disable_cur0;
1533 	out->ttu_regs.qos_ramp_disable_cur1 = disp_ttu_regs->qos_ramp_disable_cur1;
1534 }
1535