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