1 /*
2  * Copyright 2020 Advanced Micro Devices, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20  * OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * Authors: AMD
23  *
24  */
25 
26 #include "../display_mode_lib.h"
27 #include "../display_mode_vba.h"
28 #include "../dml_inline_defs.h"
29 #include "display_rq_dlg_calc_30.h"
30 #include "display_mode_vba_30.h"
31 
32 static bool is_dual_plane(enum source_format_class source_format)
33 {
34 	bool ret_val = 0;
35 
36 	if ((source_format == dm_420_12) || (source_format == dm_420_8) || (source_format == dm_420_10) || (source_format == dm_rgbe_alpha))
37 		ret_val = 1;
38 
39 	return ret_val;
40 }
41 
42 static double get_refcyc_per_delivery(struct display_mode_lib *mode_lib,
43 	double refclk_freq_in_mhz,
44 	double pclk_freq_in_mhz,
45 	unsigned int odm_combine,
46 	unsigned int recout_width,
47 	unsigned int hactive,
48 	double vratio,
49 	double hscale_pixel_rate,
50 	unsigned int delivery_width,
51 	unsigned int req_per_swath_ub)
52 {
53 	double refcyc_per_delivery = 0.0;
54 
55 	if (vratio <= 1.0) {
56 		if (odm_combine)
57 			refcyc_per_delivery = (double)refclk_freq_in_mhz * (double)((unsigned int)odm_combine*2)
58 			* dml_min((double)recout_width, (double)hactive / ((unsigned int)odm_combine*2))
59 			/ pclk_freq_in_mhz / (double)req_per_swath_ub;
60 		else
61 			refcyc_per_delivery = (double)refclk_freq_in_mhz * (double)recout_width
62 			/ pclk_freq_in_mhz / (double)req_per_swath_ub;
63 	} else {
64 		refcyc_per_delivery = (double)refclk_freq_in_mhz * (double)delivery_width
65 			/ (double)hscale_pixel_rate / (double)req_per_swath_ub;
66 	}
67 
68 	dml_print("DML_DLG: %s: refclk_freq_in_mhz = %3.2f\n", __func__, refclk_freq_in_mhz);
69 	dml_print("DML_DLG: %s: pclk_freq_in_mhz   = %3.2f\n", __func__, pclk_freq_in_mhz);
70 	dml_print("DML_DLG: %s: recout_width       = %d\n", __func__, recout_width);
71 	dml_print("DML_DLG: %s: vratio             = %3.2f\n", __func__, vratio);
72 	dml_print("DML_DLG: %s: req_per_swath_ub   = %d\n", __func__, req_per_swath_ub);
73 	dml_print("DML_DLG: %s: refcyc_per_delivery= %3.2f\n", __func__, refcyc_per_delivery);
74 
75 	return refcyc_per_delivery;
76 
77 }
78 
79 static unsigned int get_blk_size_bytes(const enum source_macro_tile_size tile_size)
80 {
81 	if (tile_size == dm_256k_tile)
82 		return (256 * 1024);
83 	else if (tile_size == dm_64k_tile)
84 		return (64 * 1024);
85 	else
86 		return (4 * 1024);
87 }
88 
89 static void extract_rq_sizing_regs(struct display_mode_lib *mode_lib,
90 	display_data_rq_regs_st *rq_regs,
91 	const display_data_rq_sizing_params_st *rq_sizing)
92 {
93 	dml_print("DML_DLG: %s: rq_sizing param\n", __func__);
94 	print__data_rq_sizing_params_st(mode_lib, rq_sizing);
95 
96 	rq_regs->chunk_size = dml_log2(rq_sizing->chunk_bytes) - 10;
97 
98 	if (rq_sizing->min_chunk_bytes == 0)
99 		rq_regs->min_chunk_size = 0;
100 	else
101 		rq_regs->min_chunk_size = dml_log2(rq_sizing->min_chunk_bytes) - 8 + 1;
102 
103 	rq_regs->meta_chunk_size = dml_log2(rq_sizing->meta_chunk_bytes) - 10;
104 	if (rq_sizing->min_meta_chunk_bytes == 0)
105 		rq_regs->min_meta_chunk_size = 0;
106 	else
107 		rq_regs->min_meta_chunk_size = dml_log2(rq_sizing->min_meta_chunk_bytes) - 6 + 1;
108 
109 	rq_regs->dpte_group_size = dml_log2(rq_sizing->dpte_group_bytes) - 6;
110 	rq_regs->mpte_group_size = dml_log2(rq_sizing->mpte_group_bytes) - 6;
111 }
112 
113 static void extract_rq_regs(struct display_mode_lib *mode_lib,
114 	display_rq_regs_st *rq_regs,
115 	const display_rq_params_st *rq_param)
116 {
117 	unsigned int detile_buf_size_in_bytes = mode_lib->ip.det_buffer_size_kbytes * 1024;
118 	unsigned int detile_buf_plane1_addr = 0;
119 
120 	extract_rq_sizing_regs(mode_lib, &(rq_regs->rq_regs_l), &rq_param->sizing.rq_l);
121 
122 	rq_regs->rq_regs_l.pte_row_height_linear = dml_floor(dml_log2(rq_param->dlg.rq_l.dpte_row_height),
123 		1) - 3;
124 
125 	if (rq_param->yuv420) {
126 		extract_rq_sizing_regs(mode_lib, &(rq_regs->rq_regs_c), &rq_param->sizing.rq_c);
127 		rq_regs->rq_regs_c.pte_row_height_linear = dml_floor(dml_log2(rq_param->dlg.rq_c.dpte_row_height),
128 			1) - 3;
129 	}
130 
131 	rq_regs->rq_regs_l.swath_height = dml_log2(rq_param->dlg.rq_l.swath_height);
132 	rq_regs->rq_regs_c.swath_height = dml_log2(rq_param->dlg.rq_c.swath_height);
133 
134 	// FIXME: take the max between luma, chroma chunk size?
135 	// okay for now, as we are setting chunk_bytes to 8kb anyways
136 	if (rq_param->sizing.rq_l.chunk_bytes >= 32 * 1024 || (rq_param->yuv420 && rq_param->sizing.rq_c.chunk_bytes >= 32 * 1024)) { //32kb
137 		rq_regs->drq_expansion_mode = 0;
138 	} else {
139 		rq_regs->drq_expansion_mode = 2;
140 	}
141 	rq_regs->prq_expansion_mode = 1;
142 	rq_regs->mrq_expansion_mode = 1;
143 	rq_regs->crq_expansion_mode = 1;
144 
145 	if (rq_param->yuv420) {
146 	if ((double)rq_param->misc.rq_l.stored_swath_bytes
147 			/ (double)rq_param->misc.rq_c.stored_swath_bytes <= 1.5) {
148 			detile_buf_plane1_addr = (detile_buf_size_in_bytes / 2.0 / 64.0); // half to chroma
149 		} else {
150 			detile_buf_plane1_addr = dml_round_to_multiple((unsigned int)((2.0 * detile_buf_size_in_bytes) / 3.0),
151 				256,
152 				0) / 64.0; // 2/3 to chroma
153 		}
154 	}
155 	rq_regs->plane1_base_address = detile_buf_plane1_addr;
156 }
157 
158 static void handle_det_buf_split(struct display_mode_lib *mode_lib,
159 	display_rq_params_st *rq_param,
160 	const display_pipe_source_params_st *pipe_src_param)
161 {
162 	unsigned int total_swath_bytes = 0;
163 	unsigned int swath_bytes_l = 0;
164 	unsigned int swath_bytes_c = 0;
165 	unsigned int full_swath_bytes_packed_l = 0;
166 	unsigned int full_swath_bytes_packed_c = 0;
167 	bool req128_l = false;
168 	bool req128_c = false;
169 	bool surf_linear = (pipe_src_param->sw_mode == dm_sw_linear);
170 	bool surf_vert = (pipe_src_param->source_scan == dm_vert);
171 	unsigned int log2_swath_height_l = 0;
172 	unsigned int log2_swath_height_c = 0;
173 	unsigned int detile_buf_size_in_bytes = mode_lib->ip.det_buffer_size_kbytes * 1024;
174 
175 	full_swath_bytes_packed_l = rq_param->misc.rq_l.full_swath_bytes;
176 	full_swath_bytes_packed_c = rq_param->misc.rq_c.full_swath_bytes;
177 
178 	if (rq_param->yuv420_10bpc) {
179 		full_swath_bytes_packed_l = dml_round_to_multiple(rq_param->misc.rq_l.full_swath_bytes * 2.0 / 3.0,
180 			256,
181 			1) + 256;
182 		full_swath_bytes_packed_c = dml_round_to_multiple(rq_param->misc.rq_c.full_swath_bytes * 2.0 / 3.0,
183 			256,
184 			1) + 256;
185 	}
186 
187 	if (rq_param->yuv420)
188 		total_swath_bytes = 2 * full_swath_bytes_packed_l + 2 * full_swath_bytes_packed_c;
189 	else
190 		total_swath_bytes = 2 * full_swath_bytes_packed_l;
191 
192 	if (total_swath_bytes <= detile_buf_size_in_bytes) { //full 256b request
193 		req128_l = false;
194 		req128_c = false;
195 		swath_bytes_l = full_swath_bytes_packed_l;
196 		swath_bytes_c = full_swath_bytes_packed_c;
197 	} else if (!rq_param->yuv420) {
198 		req128_l = true;
199 		req128_c = false;
200 		swath_bytes_c = full_swath_bytes_packed_c;
201 		swath_bytes_l = full_swath_bytes_packed_l / 2;
202 	} else if ((double)full_swath_bytes_packed_l / (double)full_swath_bytes_packed_c < 1.5) {
203 		req128_l = false;
204 		req128_c = true;
205 		swath_bytes_l = full_swath_bytes_packed_l;
206 		swath_bytes_c = full_swath_bytes_packed_c / 2;
207 
208 		total_swath_bytes = 2 * swath_bytes_l + 2 * swath_bytes_c;
209 
210 		if (total_swath_bytes > detile_buf_size_in_bytes) {
211 			req128_l = true;
212 			swath_bytes_l = full_swath_bytes_packed_l / 2;
213 		}
214 	} else {
215 		req128_l = true;
216 		req128_c = false;
217 		swath_bytes_l = full_swath_bytes_packed_l/2;
218 		swath_bytes_c = full_swath_bytes_packed_c;
219 
220 		total_swath_bytes = 2 * swath_bytes_l + 2 * swath_bytes_c;
221 
222 		if (total_swath_bytes > detile_buf_size_in_bytes) {
223 			req128_c = true;
224 			swath_bytes_c = full_swath_bytes_packed_c/2;
225 		}
226 	}
227 
228 	if (rq_param->yuv420)
229 		total_swath_bytes = 2 * swath_bytes_l + 2 * swath_bytes_c;
230 	else
231 		total_swath_bytes = 2 * swath_bytes_l;
232 
233 	rq_param->misc.rq_l.stored_swath_bytes = swath_bytes_l;
234 	rq_param->misc.rq_c.stored_swath_bytes = swath_bytes_c;
235 
236 	if (surf_linear) {
237 		log2_swath_height_l = 0;
238 		log2_swath_height_c = 0;
239 	} else {
240 		unsigned int swath_height_l;
241 		unsigned int swath_height_c;
242 
243 		if (!surf_vert) {
244 			swath_height_l = rq_param->misc.rq_l.blk256_height;
245 			swath_height_c = rq_param->misc.rq_c.blk256_height;
246 		} else {
247 			swath_height_l = rq_param->misc.rq_l.blk256_width;
248 			swath_height_c = rq_param->misc.rq_c.blk256_width;
249 		}
250 
251 		if (swath_height_l > 0)
252 			log2_swath_height_l = dml_log2(swath_height_l);
253 
254 		if (req128_l && log2_swath_height_l > 0)
255 			log2_swath_height_l -= 1;
256 
257 		if (swath_height_c > 0)
258 			log2_swath_height_c = dml_log2(swath_height_c);
259 
260 		if (req128_c && log2_swath_height_c > 0)
261 			log2_swath_height_c -= 1;
262 	}
263 
264 	rq_param->dlg.rq_l.swath_height = 1 << log2_swath_height_l;
265 	rq_param->dlg.rq_c.swath_height = 1 << log2_swath_height_c;
266 
267 	dml_print("DML_DLG: %s: req128_l = %0d\n", __func__, req128_l);
268 	dml_print("DML_DLG: %s: req128_c = %0d\n", __func__, req128_c);
269 	dml_print("DML_DLG: %s: full_swath_bytes_packed_l = %0d\n",
270 		__func__,
271 		full_swath_bytes_packed_l);
272 	dml_print("DML_DLG: %s: full_swath_bytes_packed_c = %0d\n",
273 		__func__,
274 		full_swath_bytes_packed_c);
275 }
276 
277 static void get_meta_and_pte_attr(struct display_mode_lib *mode_lib,
278 	display_data_rq_dlg_params_st *rq_dlg_param,
279 	display_data_rq_misc_params_st *rq_misc_param,
280 	display_data_rq_sizing_params_st *rq_sizing_param,
281 	unsigned int vp_width,
282 	unsigned int vp_height,
283 	unsigned int data_pitch,
284 	unsigned int meta_pitch,
285 	unsigned int source_format,
286 	unsigned int tiling,
287 	unsigned int macro_tile_size,
288 	unsigned int source_scan,
289 	unsigned int hostvm_enable,
290 	unsigned int is_chroma,
291 	unsigned int surface_height)
292 {
293 	bool surf_linear = (tiling == dm_sw_linear);
294 	bool surf_vert = (source_scan == dm_vert);
295 
296 	unsigned int bytes_per_element = 0;
297 	unsigned int bytes_per_element_y = 0;
298 	unsigned int bytes_per_element_c = 0;
299 
300 	unsigned int blk256_width = 0;
301 	unsigned int blk256_height = 0;
302 
303 	unsigned int blk256_width_y = 0;
304 	unsigned int blk256_height_y = 0;
305 	unsigned int blk256_width_c = 0;
306 	unsigned int blk256_height_c = 0;
307 	unsigned int log2_bytes_per_element = 0;
308 	unsigned int log2_blk256_width = 0;
309 	unsigned int log2_blk256_height = 0;
310 	unsigned int blk_bytes = 0;
311 	unsigned int log2_blk_bytes = 0;
312 	unsigned int log2_blk_height = 0;
313 	unsigned int log2_blk_width = 0;
314 	unsigned int log2_meta_req_bytes = 0;
315 	unsigned int log2_meta_req_height = 0;
316 	unsigned int log2_meta_req_width = 0;
317 	unsigned int meta_req_width = 0;
318 	unsigned int meta_req_height = 0;
319 	unsigned int log2_meta_row_height = 0;
320 	unsigned int meta_row_width_ub = 0;
321 	unsigned int log2_meta_chunk_bytes = 0;
322 	unsigned int log2_meta_chunk_height = 0;
323 
324 	//full sized meta chunk width in unit of data elements
325 	unsigned int log2_meta_chunk_width = 0;
326 	unsigned int log2_min_meta_chunk_bytes = 0;
327 	unsigned int min_meta_chunk_width = 0;
328 	unsigned int meta_chunk_width = 0;
329 	unsigned int meta_chunk_per_row_int = 0;
330 	unsigned int meta_row_remainder = 0;
331 	unsigned int meta_chunk_threshold = 0;
332 	unsigned int meta_blk_bytes = 0;
333 	unsigned int meta_blk_height = 0;
334 	unsigned int meta_blk_width = 0;
335 	unsigned int meta_surface_bytes = 0;
336 	unsigned int vmpg_bytes = 0;
337 	unsigned int meta_pte_req_per_frame_ub = 0;
338 	unsigned int meta_pte_bytes_per_frame_ub = 0;
339 	const unsigned int log2_vmpg_bytes = dml_log2(mode_lib->soc.gpuvm_min_page_size_bytes);
340 	const bool dual_plane_en = is_dual_plane((enum source_format_class)(source_format));
341 	const unsigned int dpte_buf_in_pte_reqs = dual_plane_en ?
342 		(is_chroma ? mode_lib->ip.dpte_buffer_size_in_pte_reqs_chroma : mode_lib->ip.dpte_buffer_size_in_pte_reqs_luma)
343 		: (mode_lib->ip.dpte_buffer_size_in_pte_reqs_luma + mode_lib->ip.dpte_buffer_size_in_pte_reqs_chroma);
344 
345 	unsigned int log2_vmpg_height = 0;
346 	unsigned int log2_vmpg_width = 0;
347 	unsigned int log2_dpte_req_height_ptes = 0;
348 	unsigned int log2_dpte_req_height = 0;
349 	unsigned int log2_dpte_req_width = 0;
350 	unsigned int log2_dpte_row_height_linear = 0;
351 	unsigned int log2_dpte_row_height = 0;
352 	unsigned int log2_dpte_group_width = 0;
353 	unsigned int dpte_row_width_ub = 0;
354 	unsigned int dpte_req_height = 0;
355 	unsigned int dpte_req_width = 0;
356 	unsigned int dpte_group_width = 0;
357 	unsigned int log2_dpte_group_bytes = 0;
358 	unsigned int log2_dpte_group_length = 0;
359 	double byte_per_pixel_det_y = 0;
360 	double byte_per_pixel_det_c = 0;
361 
362 	dml30_CalculateBytePerPixelAnd256BBlockSizes((enum source_format_class)(source_format),
363 		(enum dm_swizzle_mode)(tiling),
364 		&bytes_per_element_y,
365 		&bytes_per_element_c,
366 		&byte_per_pixel_det_y,
367 		&byte_per_pixel_det_c,
368 		&blk256_height_y,
369 		&blk256_height_c,
370 		&blk256_width_y,
371 		&blk256_width_c);
372 
373 	if (!is_chroma) {
374 		blk256_width = blk256_width_y;
375 		blk256_height = blk256_height_y;
376 		bytes_per_element = bytes_per_element_y;
377 	} else {
378 		blk256_width = blk256_width_c;
379 		blk256_height = blk256_height_c;
380 		bytes_per_element = bytes_per_element_c;
381 	}
382 
383 	log2_bytes_per_element = dml_log2(bytes_per_element);
384 
385 	dml_print("DML_DLG: %s: surf_linear        = %d\n", __func__, surf_linear);
386 	dml_print("DML_DLG: %s: surf_vert          = %d\n", __func__, surf_vert);
387 	dml_print("DML_DLG: %s: blk256_width       = %d\n", __func__, blk256_width);
388 	dml_print("DML_DLG: %s: blk256_height      = %d\n", __func__, blk256_height);
389 
390 	log2_blk256_width = dml_log2((double)blk256_width);
391 	log2_blk256_height = dml_log2((double)blk256_height);
392 	blk_bytes = surf_linear ?
393 		256 : get_blk_size_bytes((enum source_macro_tile_size) macro_tile_size);
394 	log2_blk_bytes = dml_log2((double)blk_bytes);
395 	log2_blk_height = 0;
396 	log2_blk_width = 0;
397 
398 	// remember log rule
399 	// "+" in log is multiply
400 	// "-" in log is divide
401 	// "/2" is like square root
402 	// blk is vertical biased
403 	if (tiling != dm_sw_linear)
404 		log2_blk_height = log2_blk256_height
405 		+ dml_ceil((double)(log2_blk_bytes - 8) / 2.0, 1);
406 	else
407 		log2_blk_height = 0;  // blk height of 1
408 
409 	log2_blk_width = log2_blk_bytes - log2_bytes_per_element - log2_blk_height;
410 
411 	if (!surf_vert) {
412 		int unsigned temp = 0;
413 
414 		temp = dml_round_to_multiple(vp_width - 1, blk256_width, 1) + blk256_width;
415 		if (data_pitch < blk256_width) {
416 			dml_print("WARNING: DML_DLG: %s: swath_size calculation ignoring data_pitch=%u < blk256_width=%u\n", __func__, data_pitch, blk256_width);
417 		} else {
418 			if (temp > data_pitch) {
419 				if (data_pitch >= vp_width)
420 					temp = data_pitch;
421 				else
422 					dml_print("WARNING: DML_DLG: %s: swath_size calculation ignoring data_pitch=%u < vp_width=%u\n", __func__, data_pitch, vp_width);
423 			}
424 		}
425 		rq_dlg_param->swath_width_ub = temp;
426 		rq_dlg_param->req_per_swath_ub = temp >> log2_blk256_width;
427 	} else {
428 		int unsigned temp = 0;
429 
430 		temp = dml_round_to_multiple(vp_height - 1, blk256_height, 1) + blk256_height;
431 		if (surface_height < blk256_height) {
432 			dml_print("WARNING: DML_DLG: %s swath_size calculation ignored surface_height=%u < blk256_height=%u\n", __func__, surface_height, blk256_height);
433 		} else {
434 			if (temp > surface_height) {
435 				if (surface_height >= vp_height)
436 					temp = surface_height;
437 				else
438 					dml_print("WARNING: DML_DLG: %s swath_size calculation ignored surface_height=%u < vp_height=%u\n", __func__, surface_height, vp_height);
439 			}
440 		}
441 		rq_dlg_param->swath_width_ub = temp;
442 		rq_dlg_param->req_per_swath_ub = temp >> log2_blk256_height;
443 	}
444 
445 	if (!surf_vert)
446 		rq_misc_param->full_swath_bytes = rq_dlg_param->swath_width_ub * blk256_height
447 		* bytes_per_element;
448 	else
449 		rq_misc_param->full_swath_bytes = rq_dlg_param->swath_width_ub * blk256_width
450 		* bytes_per_element;
451 
452 	rq_misc_param->blk256_height = blk256_height;
453 	rq_misc_param->blk256_width = blk256_width;
454 
455 	// -------
456 	// meta
457 	// -------
458 	log2_meta_req_bytes = 6; // meta request is 64b and is 8x8byte meta element
459 
460 				 // each 64b meta request for dcn is 8x8 meta elements and
461 				 // a meta element covers one 256b block of the data surface.
462 	log2_meta_req_height = log2_blk256_height + 3; // meta req is 8x8 byte, each byte represent 1 blk256
463 	log2_meta_req_width = log2_meta_req_bytes + 8 - log2_bytes_per_element
464 		- log2_meta_req_height;
465 	meta_req_width = 1 << log2_meta_req_width;
466 	meta_req_height = 1 << log2_meta_req_height;
467 	log2_meta_row_height = 0;
468 	meta_row_width_ub = 0;
469 
470 	// the dimensions of a meta row are meta_row_width x meta_row_height in elements.
471 	// calculate upper bound of the meta_row_width
472 	if (!surf_vert) {
473 		log2_meta_row_height = log2_meta_req_height;
474 		meta_row_width_ub = dml_round_to_multiple(vp_width - 1, meta_req_width, 1)
475 			+ meta_req_width;
476 		rq_dlg_param->meta_req_per_row_ub = meta_row_width_ub / meta_req_width;
477 	} else {
478 		log2_meta_row_height = log2_meta_req_width;
479 		meta_row_width_ub = dml_round_to_multiple(vp_height - 1, meta_req_height, 1)
480 			+ meta_req_height;
481 		rq_dlg_param->meta_req_per_row_ub = meta_row_width_ub / meta_req_height;
482 	}
483 	rq_dlg_param->meta_bytes_per_row_ub = rq_dlg_param->meta_req_per_row_ub * 64;
484 
485 	rq_dlg_param->meta_row_height = 1 << log2_meta_row_height;
486 
487 	log2_meta_chunk_bytes = dml_log2(rq_sizing_param->meta_chunk_bytes);
488 	log2_meta_chunk_height = log2_meta_row_height;
489 
490 	//full sized meta chunk width in unit of data elements
491 	log2_meta_chunk_width = log2_meta_chunk_bytes + 8 - log2_bytes_per_element
492 		- log2_meta_chunk_height;
493 	log2_min_meta_chunk_bytes = dml_log2(rq_sizing_param->min_meta_chunk_bytes);
494 	min_meta_chunk_width = 1
495 		<< (log2_min_meta_chunk_bytes + 8 - log2_bytes_per_element
496 			- log2_meta_chunk_height);
497 	meta_chunk_width = 1 << log2_meta_chunk_width;
498 	meta_chunk_per_row_int = (unsigned int)(meta_row_width_ub / meta_chunk_width);
499 	meta_row_remainder = meta_row_width_ub % meta_chunk_width;
500 	meta_chunk_threshold = 0;
501 	meta_blk_bytes = 4096;
502 	meta_blk_height = blk256_height * 64;
503 	meta_blk_width = meta_blk_bytes * 256 / bytes_per_element / meta_blk_height;
504 	meta_surface_bytes = meta_pitch
505 		* (dml_round_to_multiple(vp_height - 1, meta_blk_height, 1) + meta_blk_height)
506 		* bytes_per_element / 256;
507 	vmpg_bytes = mode_lib->soc.gpuvm_min_page_size_bytes;
508 	meta_pte_req_per_frame_ub = (dml_round_to_multiple(meta_surface_bytes - vmpg_bytes,
509 		8 * vmpg_bytes,
510 		1) + 8 * vmpg_bytes) / (8 * vmpg_bytes);
511 	meta_pte_bytes_per_frame_ub = meta_pte_req_per_frame_ub * 64; //64B mpte request
512 	rq_dlg_param->meta_pte_bytes_per_frame_ub = meta_pte_bytes_per_frame_ub;
513 
514 	dml_print("DML_DLG: %s: meta_blk_height             = %d\n", __func__, meta_blk_height);
515 	dml_print("DML_DLG: %s: meta_blk_width              = %d\n", __func__, meta_blk_width);
516 	dml_print("DML_DLG: %s: meta_surface_bytes          = %d\n", __func__, meta_surface_bytes);
517 	dml_print("DML_DLG: %s: meta_pte_req_per_frame_ub   = %d\n",
518 		__func__,
519 		meta_pte_req_per_frame_ub);
520 	dml_print("DML_DLG: %s: meta_pte_bytes_per_frame_ub = %d\n",
521 		__func__,
522 		meta_pte_bytes_per_frame_ub);
523 
524 	if (!surf_vert)
525 		meta_chunk_threshold = 2 * min_meta_chunk_width - meta_req_width;
526 	else
527 		meta_chunk_threshold = 2 * min_meta_chunk_width - meta_req_height;
528 
529 	if (meta_row_remainder <= meta_chunk_threshold)
530 		rq_dlg_param->meta_chunks_per_row_ub = meta_chunk_per_row_int + 1;
531 	else
532 		rq_dlg_param->meta_chunks_per_row_ub = meta_chunk_per_row_int + 2;
533 
534 	// ------
535 	// dpte
536 	// ------
537 	if (surf_linear) {
538 		log2_vmpg_height = 0;   // one line high
539 	} else {
540 		log2_vmpg_height = (log2_vmpg_bytes - 8) / 2 + log2_blk256_height;
541 	}
542 	log2_vmpg_width = log2_vmpg_bytes - log2_bytes_per_element - log2_vmpg_height;
543 
544 	// only 3 possible shapes for dpte request in dimensions of ptes: 8x1, 4x2, 2x4.
545 	if (surf_linear) { //one 64B PTE request returns 8 PTEs
546 		log2_dpte_req_height_ptes = 0;
547 		log2_dpte_req_width = log2_vmpg_width + 3;
548 		log2_dpte_req_height = 0;
549 	} else if (log2_blk_bytes == 12) { //4KB tile means 4kB page size
550 					 //one 64B req gives 8x1 PTEs for 4KB tile
551 		log2_dpte_req_height_ptes = 0;
552 		log2_dpte_req_width = log2_blk_width + 3;
553 		log2_dpte_req_height = log2_blk_height + 0;
554 	} else if ((log2_blk_bytes >= 16) && (log2_vmpg_bytes == 12)) { // tile block >= 64KB
555 									  //two 64B reqs of 2x4 PTEs give 16 PTEs to cover 64KB
556 		log2_dpte_req_height_ptes = 4;
557 		log2_dpte_req_width = log2_blk256_width + 4; // log2_64KB_width
558 		log2_dpte_req_height = log2_blk256_height + 4; // log2_64KB_height
559 	} else { //64KB page size and must 64KB tile block
560 		   //one 64B req gives 8x1 PTEs for 64KB tile
561 		log2_dpte_req_height_ptes = 0;
562 		log2_dpte_req_width = log2_blk_width + 3;
563 		log2_dpte_req_height = log2_blk_height + 0;
564 	}
565 
566 	// The dpte request dimensions in data elements is dpte_req_width x dpte_req_height
567 	// log2_vmpg_width is how much 1 pte represent, now calculating how much a 64b pte req represent
568 	// That depends on the pte shape (i.e. 8x1, 4x2, 2x4)
569 	//log2_dpte_req_height	= log2_vmpg_height + log2_dpte_req_height_ptes;
570 	//log2_dpte_req_width	 = log2_vmpg_width + log2_dpte_req_width_ptes;
571 	dpte_req_height = 1 << log2_dpte_req_height;
572 	dpte_req_width = 1 << log2_dpte_req_width;
573 
574 	// calculate pitch dpte row buffer can hold
575 	// round the result down to a power of two.
576 	if (surf_linear) {
577 		unsigned int dpte_row_height = 0;
578 
579 		log2_dpte_row_height_linear = dml_floor(dml_log2(dpte_buf_in_pte_reqs * dpte_req_width / data_pitch), 1);
580 
581 		dml_print("DML_DLG: %s: is_chroma                   = %d\n", __func__, is_chroma);
582 		dml_print("DML_DLG: %s: dpte_buf_in_pte_reqs        = %d\n", __func__, dpte_buf_in_pte_reqs);
583 		dml_print("DML_DLG: %s: log2_dpte_row_height_linear = %d\n", __func__, log2_dpte_row_height_linear);
584 
585 		ASSERT(log2_dpte_row_height_linear >= 3);
586 
587 		if (log2_dpte_row_height_linear > 7)
588 			log2_dpte_row_height_linear = 7;
589 
590 		log2_dpte_row_height = log2_dpte_row_height_linear;
591 		// For linear, the dpte row is pitch dependent and the pte requests wrap at the pitch boundary.
592 		// the dpte_row_width_ub is the upper bound of data_pitch*dpte_row_height in elements with this unique buffering.
593 		dpte_row_height = 1 << log2_dpte_row_height;
594 		dpte_row_width_ub = dml_round_to_multiple(data_pitch * dpte_row_height - 1,
595 			dpte_req_width,
596 			1) + dpte_req_width;
597 		rq_dlg_param->dpte_req_per_row_ub = dpte_row_width_ub / dpte_req_width;
598 	} else {
599 		// the upper bound of the dpte_row_width without dependency on viewport position follows.
600 		// for tiled mode, row height is the same as req height and row store up to vp size upper bound
601 		if (!surf_vert) {
602 			log2_dpte_row_height = log2_dpte_req_height;
603 			dpte_row_width_ub = dml_round_to_multiple(vp_width - 1, dpte_req_width, 1)
604 				+ dpte_req_width;
605 			rq_dlg_param->dpte_req_per_row_ub = dpte_row_width_ub / dpte_req_width;
606 		} else {
607 			log2_dpte_row_height =
608 				(log2_blk_width < log2_dpte_req_width) ?
609 				log2_blk_width : log2_dpte_req_width;
610 			dpte_row_width_ub = dml_round_to_multiple(vp_height - 1, dpte_req_height, 1)
611 				+ dpte_req_height;
612 			rq_dlg_param->dpte_req_per_row_ub = dpte_row_width_ub / dpte_req_height;
613 		}
614 	}
615 	if (log2_blk_bytes >= 16 && log2_vmpg_bytes == 12) // tile block >= 64KB
616 		rq_dlg_param->dpte_bytes_per_row_ub = rq_dlg_param->dpte_req_per_row_ub * 128; //2*64B dpte request
617 	else
618 		rq_dlg_param->dpte_bytes_per_row_ub = rq_dlg_param->dpte_req_per_row_ub * 64; //64B dpte request
619 
620 	rq_dlg_param->dpte_row_height = 1 << log2_dpte_row_height;
621 
622 	// the dpte_group_bytes is reduced for the specific case of vertical
623 	// access of a tile surface that has dpte request of 8x1 ptes.
624 	if (hostvm_enable)
625 		rq_sizing_param->dpte_group_bytes = 512;
626 	else {
627 		if (!surf_linear & (log2_dpte_req_height_ptes == 0) & surf_vert) //reduced, in this case, will have page fault within a group
628 			rq_sizing_param->dpte_group_bytes = 512;
629 		else
630 			rq_sizing_param->dpte_group_bytes = 2048;
631 	}
632 
633 	//since pte request size is 64byte, the number of data pte requests per full sized group is as follows.
634 	log2_dpte_group_bytes = dml_log2(rq_sizing_param->dpte_group_bytes);
635 	log2_dpte_group_length = log2_dpte_group_bytes - 6; //length in 64b requests
636 
637 								// full sized data pte group width in elements
638 	if (!surf_vert)
639 		log2_dpte_group_width = log2_dpte_group_length + log2_dpte_req_width;
640 	else
641 		log2_dpte_group_width = log2_dpte_group_length + log2_dpte_req_height;
642 
643 	//But if the tile block >=64KB and the page size is 4KB, then each dPTE request is 2*64B
644 	if ((log2_blk_bytes >= 16) && (log2_vmpg_bytes == 12)) // tile block >= 64KB
645 		log2_dpte_group_width = log2_dpte_group_width - 1;
646 
647 	dpte_group_width = 1 << log2_dpte_group_width;
648 
649 	// since dpte groups are only aligned to dpte_req_width and not dpte_group_width,
650 	// the upper bound for the dpte groups per row is as follows.
651 	rq_dlg_param->dpte_groups_per_row_ub = dml_ceil((double)dpte_row_width_ub / dpte_group_width,
652 		1);
653 }
654 
655 static void get_surf_rq_param(struct display_mode_lib *mode_lib,
656 	display_data_rq_sizing_params_st *rq_sizing_param,
657 	display_data_rq_dlg_params_st *rq_dlg_param,
658 	display_data_rq_misc_params_st *rq_misc_param,
659 	const display_pipe_params_st *pipe_param,
660 	bool is_chroma,
661 	bool is_alpha)
662 {
663 	bool mode_422 = 0;
664 	unsigned int vp_width = 0;
665 	unsigned int vp_height = 0;
666 	unsigned int data_pitch = 0;
667 	unsigned int meta_pitch = 0;
668 	unsigned int surface_height = 0;
669 	unsigned int ppe = mode_422 ? 2 : 1;
670 
671 	// FIXME check if ppe apply for both luma and chroma in 422 case
672 	if (is_chroma | is_alpha) {
673 		vp_width = pipe_param->src.viewport_width_c / ppe;
674 		vp_height = pipe_param->src.viewport_height_c;
675 		data_pitch = pipe_param->src.data_pitch_c;
676 		meta_pitch = pipe_param->src.meta_pitch_c;
677 		surface_height = pipe_param->src.surface_height_y / 2.0;
678 	} else {
679 		vp_width = pipe_param->src.viewport_width / ppe;
680 		vp_height = pipe_param->src.viewport_height;
681 		data_pitch = pipe_param->src.data_pitch;
682 		meta_pitch = pipe_param->src.meta_pitch;
683 		surface_height = pipe_param->src.surface_height_y;
684 	}
685 
686 	if (pipe_param->dest.odm_combine) {
687 		unsigned int access_dir = 0;
688 		unsigned int full_src_vp_width = 0;
689 		unsigned int hactive_odm = 0;
690 		unsigned int src_hactive_odm = 0;
691 		access_dir = (pipe_param->src.source_scan == dm_vert); // vp access direction: horizontal or vertical accessed
692 		hactive_odm  = pipe_param->dest.hactive / ((unsigned int) pipe_param->dest.odm_combine*2);
693 		if (is_chroma) {
694 			full_src_vp_width = pipe_param->scale_ratio_depth.hscl_ratio_c * pipe_param->dest.full_recout_width;
695 			src_hactive_odm  = pipe_param->scale_ratio_depth.hscl_ratio_c * hactive_odm;
696 		} else {
697 			full_src_vp_width = pipe_param->scale_ratio_depth.hscl_ratio * pipe_param->dest.full_recout_width;
698 			src_hactive_odm  = pipe_param->scale_ratio_depth.hscl_ratio * hactive_odm;
699 		}
700 
701 		if (access_dir == 0) {
702 			vp_width = dml_min(full_src_vp_width, src_hactive_odm);
703 			dml_print("DML_DLG: %s: vp_width = %d\n", __func__, vp_width);
704 		} else {
705 			vp_height = dml_min(full_src_vp_width, src_hactive_odm);
706 			dml_print("DML_DLG: %s: vp_height = %d\n", __func__, vp_height);
707 		}
708 		dml_print("DML_DLG: %s: full_src_vp_width = %d\n", __func__, full_src_vp_width);
709 		dml_print("DML_DLG: %s: hactive_odm = %d\n", __func__, hactive_odm);
710 		dml_print("DML_DLG: %s: src_hactive_odm = %d\n", __func__, src_hactive_odm);
711 	}
712 
713 	rq_sizing_param->chunk_bytes = 8192;
714 
715 	if (is_alpha) {
716 		rq_sizing_param->chunk_bytes = 4096;
717 	}
718 
719 	if (rq_sizing_param->chunk_bytes == 64 * 1024)
720 		rq_sizing_param->min_chunk_bytes = 0;
721 	else
722 		rq_sizing_param->min_chunk_bytes = 1024;
723 
724 	rq_sizing_param->meta_chunk_bytes = 2048;
725 	rq_sizing_param->min_meta_chunk_bytes = 256;
726 
727 	if (pipe_param->src.hostvm)
728 		rq_sizing_param->mpte_group_bytes = 512;
729 	else
730 		rq_sizing_param->mpte_group_bytes = 2048;
731 
732 	get_meta_and_pte_attr(mode_lib,
733 		rq_dlg_param,
734 		rq_misc_param,
735 		rq_sizing_param,
736 		vp_width,
737 		vp_height,
738 		data_pitch,
739 		meta_pitch,
740 		pipe_param->src.source_format,
741 		pipe_param->src.sw_mode,
742 		pipe_param->src.macro_tile_size,
743 		pipe_param->src.source_scan,
744 		pipe_param->src.hostvm,
745 		is_chroma,
746 		surface_height);
747 }
748 
749 static void dml_rq_dlg_get_rq_params(struct display_mode_lib *mode_lib,
750 	display_rq_params_st *rq_param,
751 	const display_pipe_params_st *pipe_param)
752 {
753 	// get param for luma surface
754 	rq_param->yuv420 = pipe_param->src.source_format == dm_420_8
755 	|| pipe_param->src.source_format == dm_420_10
756 	|| pipe_param->src.source_format == dm_rgbe_alpha
757 	|| pipe_param->src.source_format == dm_420_12;
758 
759 	rq_param->yuv420_10bpc = pipe_param->src.source_format == dm_420_10;
760 
761 	rq_param->rgbe_alpha = (pipe_param->src.source_format == dm_rgbe_alpha)?1:0;
762 
763 	get_surf_rq_param(mode_lib,
764 		&(rq_param->sizing.rq_l),
765 		&(rq_param->dlg.rq_l),
766 		&(rq_param->misc.rq_l),
767 		pipe_param,
768 		0,
769 		0);
770 
771 	if (is_dual_plane((enum source_format_class)(pipe_param->src.source_format))) {
772 		// get param for chroma surface
773 		get_surf_rq_param(mode_lib,
774 			&(rq_param->sizing.rq_c),
775 			&(rq_param->dlg.rq_c),
776 			&(rq_param->misc.rq_c),
777 			pipe_param,
778 			1,
779 			rq_param->rgbe_alpha);
780 	}
781 
782 	// calculate how to split the det buffer space between luma and chroma
783 	handle_det_buf_split(mode_lib, rq_param, &pipe_param->src);
784 	print__rq_params_st(mode_lib, rq_param);
785 }
786 
787 void dml30_rq_dlg_get_rq_reg(struct display_mode_lib *mode_lib,
788 	display_rq_regs_st *rq_regs,
789 	const display_pipe_params_st *pipe_param)
790 {
791 	display_rq_params_st rq_param = { 0 };
792 
793 	memset(rq_regs, 0, sizeof(*rq_regs));
794 	dml_rq_dlg_get_rq_params(mode_lib, &rq_param, pipe_param);
795 	extract_rq_regs(mode_lib, rq_regs, &rq_param);
796 
797 	print__rq_regs_st(mode_lib, rq_regs);
798 }
799 
800 static void calculate_ttu_cursor(struct display_mode_lib *mode_lib,
801 	double *refcyc_per_req_delivery_pre_cur,
802 	double *refcyc_per_req_delivery_cur,
803 	double refclk_freq_in_mhz,
804 	double ref_freq_to_pix_freq,
805 	double hscale_pixel_rate_l,
806 	double hscl_ratio,
807 	double vratio_pre_l,
808 	double vratio_l,
809 	unsigned int cur_width,
810 	enum cursor_bpp cur_bpp)
811 {
812 	unsigned int cur_src_width = cur_width;
813 	unsigned int cur_req_size = 0;
814 	unsigned int cur_req_width = 0;
815 	double cur_width_ub = 0.0;
816 	double cur_req_per_width = 0.0;
817 	double hactive_cur = 0.0;
818 
819 	ASSERT(cur_src_width <= 256);
820 
821 	*refcyc_per_req_delivery_pre_cur = 0.0;
822 	*refcyc_per_req_delivery_cur = 0.0;
823 	if (cur_src_width > 0) {
824 		unsigned int cur_bit_per_pixel = 0;
825 
826 		if (cur_bpp == dm_cur_2bit) {
827 			cur_req_size = 64; // byte
828 			cur_bit_per_pixel = 2;
829 		} else { // 32bit
830 			cur_bit_per_pixel = 32;
831 			if (cur_src_width >= 1 && cur_src_width <= 16)
832 				cur_req_size = 64;
833 			else if (cur_src_width >= 17 && cur_src_width <= 31)
834 				cur_req_size = 128;
835 			else
836 				cur_req_size = 256;
837 		}
838 
839 		cur_req_width = (double)cur_req_size / ((double)cur_bit_per_pixel / 8.0);
840 		cur_width_ub = dml_ceil((double)cur_src_width / (double)cur_req_width, 1)
841 			* (double)cur_req_width;
842 		cur_req_per_width = cur_width_ub / (double)cur_req_width;
843 		hactive_cur = (double)cur_src_width / hscl_ratio; // FIXME: oswin to think about what to do for cursor
844 
845 		if (vratio_pre_l <= 1.0) {
846 			*refcyc_per_req_delivery_pre_cur = hactive_cur * ref_freq_to_pix_freq
847 				/ (double)cur_req_per_width;
848 		} else {
849 			*refcyc_per_req_delivery_pre_cur = (double)refclk_freq_in_mhz
850 				* (double)cur_src_width / hscale_pixel_rate_l
851 				/ (double)cur_req_per_width;
852 		}
853 
854 		ASSERT(*refcyc_per_req_delivery_pre_cur < dml_pow(2, 13));
855 
856 		if (vratio_l <= 1.0) {
857 			*refcyc_per_req_delivery_cur = hactive_cur * ref_freq_to_pix_freq
858 				/ (double)cur_req_per_width;
859 		} else {
860 			*refcyc_per_req_delivery_cur = (double)refclk_freq_in_mhz
861 				* (double)cur_src_width / hscale_pixel_rate_l
862 				/ (double)cur_req_per_width;
863 		}
864 
865 		dml_print("DML_DLG: %s: cur_req_width                     = %d\n",
866 			__func__,
867 			cur_req_width);
868 		dml_print("DML_DLG: %s: cur_width_ub                      = %3.2f\n",
869 			__func__,
870 			cur_width_ub);
871 		dml_print("DML_DLG: %s: cur_req_per_width                 = %3.2f\n",
872 			__func__,
873 			cur_req_per_width);
874 		dml_print("DML_DLG: %s: hactive_cur                       = %3.2f\n",
875 			__func__,
876 			hactive_cur);
877 		dml_print("DML_DLG: %s: refcyc_per_req_delivery_pre_cur   = %3.2f\n",
878 			__func__,
879 			*refcyc_per_req_delivery_pre_cur);
880 		dml_print("DML_DLG: %s: refcyc_per_req_delivery_cur       = %3.2f\n",
881 			__func__,
882 			*refcyc_per_req_delivery_cur);
883 
884 		ASSERT(*refcyc_per_req_delivery_cur < dml_pow(2, 13));
885 	}
886 }
887 
888 // Note: currently taken in as is.
889 // Nice to decouple code from hw register implement and extract code that are repeated for luma and chroma.
890 static void dml_rq_dlg_get_dlg_params(struct display_mode_lib *mode_lib,
891 	const display_e2e_pipe_params_st *e2e_pipe_param,
892 	const unsigned int num_pipes,
893 	const unsigned int pipe_idx,
894 	display_dlg_regs_st *disp_dlg_regs,
895 	display_ttu_regs_st *disp_ttu_regs,
896 	const display_rq_dlg_params_st rq_dlg_param,
897 	const display_dlg_sys_params_st dlg_sys_param,
898 	const bool cstate_en,
899 	const bool pstate_en,
900 	const bool vm_en,
901 	const bool ignore_viewport_pos,
902 	const bool immediate_flip_support)
903 {
904 	const display_pipe_source_params_st *src = &e2e_pipe_param[pipe_idx].pipe.src;
905 	const display_pipe_dest_params_st *dst = &e2e_pipe_param[pipe_idx].pipe.dest;
906 	const display_output_params_st *dout = &e2e_pipe_param[pipe_idx].dout;
907 	const display_clocks_and_cfg_st *clks = &e2e_pipe_param[pipe_idx].clks_cfg;
908 	const scaler_ratio_depth_st *scl = &e2e_pipe_param[pipe_idx].pipe.scale_ratio_depth;
909 	const scaler_taps_st *taps = &e2e_pipe_param[pipe_idx].pipe.scale_taps;
910 
911 	// -------------------------
912 	// Section 1.15.2.1: OTG dependent Params
913 	// -------------------------
914 	// Timing
915 	unsigned int htotal = dst->htotal;
916 	//	unsigned int hblank_start = dst.hblank_start; // TODO: Remove
917 	unsigned int hblank_end = dst->hblank_end;
918 	unsigned int vblank_start = dst->vblank_start;
919 	unsigned int vblank_end = dst->vblank_end;
920 	unsigned int min_vblank = mode_lib->ip.min_vblank_lines;
921 
922 	double dppclk_freq_in_mhz = clks->dppclk_mhz;
923 	double dispclk_freq_in_mhz = clks->dispclk_mhz;
924 	double refclk_freq_in_mhz = clks->refclk_mhz;
925 	double pclk_freq_in_mhz = dst->pixel_rate_mhz;
926 	bool interlaced = dst->interlaced;
927 
928 	double ref_freq_to_pix_freq = refclk_freq_in_mhz / pclk_freq_in_mhz;
929 
930 	double min_dcfclk_mhz = 0;
931 	double t_calc_us = 0;
932 	double min_ttu_vblank = 0;
933 
934 	double min_dst_y_ttu_vblank = 0;
935 	unsigned int dlg_vblank_start = 0;
936 	bool dual_plane = false;
937 	bool mode_422 = false;
938 	unsigned int access_dir = 0;
939 	unsigned int vp_height_l = 0;
940 	unsigned int vp_width_l = 0;
941 	unsigned int vp_height_c = 0;
942 	unsigned int vp_width_c = 0;
943 
944 	// Scaling
945 	unsigned int htaps_l = 0;
946 	unsigned int htaps_c = 0;
947 	double hratio_l = 0;
948 	double hratio_c = 0;
949 	double vratio_l = 0;
950 	double vratio_c = 0;
951 	bool scl_enable = false;
952 
953 	double line_time_in_us = 0;
954 	//	double vinit_l;
955 	//	double vinit_c;
956 	//	double vinit_bot_l;
957 	//	double vinit_bot_c;
958 
959 	//	unsigned int swath_height_l;
960 	unsigned int swath_width_ub_l = 0;
961 	//	unsigned int dpte_bytes_per_row_ub_l;
962 	unsigned int dpte_groups_per_row_ub_l = 0;
963 	//	unsigned int meta_pte_bytes_per_frame_ub_l;
964 	//	unsigned int meta_bytes_per_row_ub_l;
965 
966 	//	unsigned int swath_height_c;
967 	unsigned int swath_width_ub_c = 0;
968 	//   unsigned int dpte_bytes_per_row_ub_c;
969 	unsigned int dpte_groups_per_row_ub_c = 0;
970 
971 	unsigned int meta_chunks_per_row_ub_l = 0;
972 	unsigned int meta_chunks_per_row_ub_c = 0;
973 	unsigned int vupdate_offset = 0;
974 	unsigned int vupdate_width = 0;
975 	unsigned int vready_offset = 0;
976 
977 	unsigned int dppclk_delay_subtotal = 0;
978 	unsigned int dispclk_delay_subtotal = 0;
979 	unsigned int pixel_rate_delay_subtotal = 0;
980 
981 	unsigned int vstartup_start = 0;
982 	unsigned int dst_x_after_scaler = 0;
983 	unsigned int dst_y_after_scaler = 0;
984 	double line_wait = 0;
985 	double dst_y_prefetch = 0;
986 	double dst_y_per_vm_vblank = 0;
987 	double dst_y_per_row_vblank = 0;
988 	double dst_y_per_vm_flip = 0;
989 	double dst_y_per_row_flip = 0;
990 	double max_dst_y_per_vm_vblank = 0;
991 	double max_dst_y_per_row_vblank = 0;
992 	double lsw = 0;
993 	double vratio_pre_l = 0;
994 	double vratio_pre_c = 0;
995 	unsigned int req_per_swath_ub_l = 0;
996 	unsigned int req_per_swath_ub_c = 0;
997 	unsigned int meta_row_height_l = 0;
998 	unsigned int meta_row_height_c = 0;
999 	unsigned int swath_width_pixels_ub_l = 0;
1000 	unsigned int swath_width_pixels_ub_c = 0;
1001 	unsigned int scaler_rec_in_width_l = 0;
1002 	unsigned int scaler_rec_in_width_c = 0;
1003 	unsigned int dpte_row_height_l = 0;
1004 	unsigned int dpte_row_height_c = 0;
1005 	double hscale_pixel_rate_l = 0;
1006 	double hscale_pixel_rate_c = 0;
1007 	double min_hratio_fact_l = 0;
1008 	double min_hratio_fact_c = 0;
1009 	double refcyc_per_line_delivery_pre_l = 0;
1010 	double refcyc_per_line_delivery_pre_c = 0;
1011 	double refcyc_per_line_delivery_l = 0;
1012 	double refcyc_per_line_delivery_c = 0;
1013 
1014 	double refcyc_per_req_delivery_pre_l = 0;
1015 	double refcyc_per_req_delivery_pre_c = 0;
1016 	double refcyc_per_req_delivery_l = 0;
1017 	double refcyc_per_req_delivery_c = 0;
1018 
1019 	unsigned int full_recout_width = 0;
1020 	double refcyc_per_req_delivery_pre_cur0 = 0;
1021 	double refcyc_per_req_delivery_cur0 = 0;
1022 	double refcyc_per_req_delivery_pre_cur1 = 0;
1023 	double refcyc_per_req_delivery_cur1 = 0;
1024 
1025 	unsigned int pipe_index_in_combine[DC__NUM_PIPES__MAX] = { 0 };
1026 
1027 	memset(disp_dlg_regs, 0, sizeof(*disp_dlg_regs));
1028 	memset(disp_ttu_regs, 0, sizeof(*disp_ttu_regs));
1029 
1030 	dml_print("DML_DLG: %s:  cstate_en = %d\n", __func__, cstate_en);
1031 	dml_print("DML_DLG: %s:  pstate_en = %d\n", __func__, pstate_en);
1032 	dml_print("DML_DLG: %s:  vm_en     = %d\n", __func__, vm_en);
1033 	dml_print("DML_DLG: %s:  ignore_viewport_pos  = %d\n", __func__, ignore_viewport_pos);
1034 	dml_print("DML_DLG: %s:  immediate_flip_support  = %d\n", __func__, immediate_flip_support);
1035 
1036 	dml_print("DML_DLG: %s: dppclk_freq_in_mhz     = %3.2f\n", __func__, dppclk_freq_in_mhz);
1037 	dml_print("DML_DLG: %s: dispclk_freq_in_mhz    = %3.2f\n", __func__, dispclk_freq_in_mhz);
1038 	dml_print("DML_DLG: %s: refclk_freq_in_mhz     = %3.2f\n", __func__, refclk_freq_in_mhz);
1039 	dml_print("DML_DLG: %s: pclk_freq_in_mhz       = %3.2f\n", __func__, pclk_freq_in_mhz);
1040 	dml_print("DML_DLG: %s: interlaced             = %d\n", __func__, interlaced);
1041 	ASSERT(ref_freq_to_pix_freq < 4.0);
1042 
1043 	disp_dlg_regs->ref_freq_to_pix_freq =
1044 		(unsigned int)(ref_freq_to_pix_freq * dml_pow(2, 19));
1045 	disp_dlg_regs->refcyc_per_htotal = (unsigned int)(ref_freq_to_pix_freq * (double)htotal
1046 		* dml_pow(2, 8));
1047 	disp_dlg_regs->dlg_vblank_end = interlaced ? (vblank_end / 2) : vblank_end; // 15 bits
1048 
1049 	min_dcfclk_mhz = dlg_sys_param.deepsleep_dcfclk_mhz;
1050 	t_calc_us = get_tcalc(mode_lib, e2e_pipe_param, num_pipes);
1051 	min_ttu_vblank = get_min_ttu_vblank(mode_lib, e2e_pipe_param, num_pipes, pipe_idx);
1052 
1053 	min_dst_y_ttu_vblank = min_ttu_vblank * pclk_freq_in_mhz / (double)htotal;
1054 	dlg_vblank_start = interlaced ? (vblank_start / 2) : vblank_start;
1055 
1056 	disp_dlg_regs->min_dst_y_next_start = (unsigned int)(((double)dlg_vblank_start
1057 		) * dml_pow(2, 2));
1058 	ASSERT(disp_dlg_regs->min_dst_y_next_start < (unsigned int)dml_pow(2, 18));
1059 
1060 	dml_print("DML_DLG: %s: min_dcfclk_mhz                         = %3.2f\n",
1061 		__func__,
1062 		min_dcfclk_mhz);
1063 	dml_print("DML_DLG: %s: min_ttu_vblank                         = %3.2f\n",
1064 		__func__,
1065 		min_ttu_vblank);
1066 	dml_print("DML_DLG: %s: min_dst_y_ttu_vblank                   = %3.2f\n",
1067 		__func__,
1068 		min_dst_y_ttu_vblank);
1069 	dml_print("DML_DLG: %s: t_calc_us                              = %3.2f\n",
1070 		__func__,
1071 		t_calc_us);
1072 	dml_print("DML_DLG: %s: disp_dlg_regs->min_dst_y_next_start    = 0x%0x\n",
1073 		__func__,
1074 		disp_dlg_regs->min_dst_y_next_start);
1075 	dml_print("DML_DLG: %s: ref_freq_to_pix_freq                   = %3.2f\n",
1076 		__func__,
1077 		ref_freq_to_pix_freq);
1078 
1079 	// -------------------------
1080 	// Section 1.15.2.2: Prefetch, Active and TTU
1081 	// -------------------------
1082 	// Prefetch Calc
1083 	// Source
1084 	//			 dcc_en			  = src.dcc;
1085 	dual_plane = is_dual_plane((enum source_format_class)(src->source_format));
1086 	mode_422 = false; // TODO
1087 	access_dir = (src->source_scan == dm_vert); // vp access direction: horizontal or vertical accessed
1088 	vp_height_l = src->viewport_height;
1089 	vp_width_l = src->viewport_width;
1090 	vp_height_c = src->viewport_height_c;
1091 	vp_width_c = src->viewport_width_c;
1092 
1093 	// Scaling
1094 	htaps_l = taps->htaps;
1095 	htaps_c = taps->htaps_c;
1096 	hratio_l = scl->hscl_ratio;
1097 	hratio_c = scl->hscl_ratio_c;
1098 	vratio_l = scl->vscl_ratio;
1099 	vratio_c = scl->vscl_ratio_c;
1100 	scl_enable = scl->scl_enable;
1101 
1102 	line_time_in_us = (htotal / pclk_freq_in_mhz);
1103 	swath_width_ub_l = rq_dlg_param.rq_l.swath_width_ub;
1104 	dpte_groups_per_row_ub_l = rq_dlg_param.rq_l.dpte_groups_per_row_ub;
1105 	swath_width_ub_c = rq_dlg_param.rq_c.swath_width_ub;
1106 	dpte_groups_per_row_ub_c = rq_dlg_param.rq_c.dpte_groups_per_row_ub;
1107 
1108 	meta_chunks_per_row_ub_l = rq_dlg_param.rq_l.meta_chunks_per_row_ub;
1109 	meta_chunks_per_row_ub_c = rq_dlg_param.rq_c.meta_chunks_per_row_ub;
1110 	vupdate_offset = dst->vupdate_offset;
1111 	vupdate_width = dst->vupdate_width;
1112 	vready_offset = dst->vready_offset;
1113 
1114 	dppclk_delay_subtotal = mode_lib->ip.dppclk_delay_subtotal;
1115 	dispclk_delay_subtotal = mode_lib->ip.dispclk_delay_subtotal;
1116 
1117 	if (scl_enable)
1118 		dppclk_delay_subtotal += mode_lib->ip.dppclk_delay_scl;
1119 	else
1120 		dppclk_delay_subtotal += mode_lib->ip.dppclk_delay_scl_lb_only;
1121 
1122 	dppclk_delay_subtotal += mode_lib->ip.dppclk_delay_cnvc_formatter
1123 		+ src->num_cursors * mode_lib->ip.dppclk_delay_cnvc_cursor;
1124 
1125 	if (dout->dsc_enable) {
1126 		double dsc_delay = get_dsc_delay(mode_lib, e2e_pipe_param, num_pipes, pipe_idx);
1127 
1128 		dispclk_delay_subtotal += dsc_delay;
1129 	}
1130 
1131 	pixel_rate_delay_subtotal = dppclk_delay_subtotal * pclk_freq_in_mhz / dppclk_freq_in_mhz
1132 		+ dispclk_delay_subtotal * pclk_freq_in_mhz / dispclk_freq_in_mhz;
1133 
1134 	vstartup_start = dst->vstartup_start;
1135 	if (interlaced) {
1136 		if (vstartup_start / 2.0
1137 			- (double)(vready_offset + vupdate_width + vupdate_offset) / htotal
1138 			<= vblank_end / 2.0)
1139 			disp_dlg_regs->vready_after_vcount0 = 1;
1140 		else
1141 			disp_dlg_regs->vready_after_vcount0 = 0;
1142 	} else {
1143 		if (vstartup_start
1144 			- (double)(vready_offset + vupdate_width + vupdate_offset) / htotal
1145 			<= vblank_end)
1146 			disp_dlg_regs->vready_after_vcount0 = 1;
1147 		else
1148 			disp_dlg_regs->vready_after_vcount0 = 0;
1149 	}
1150 
1151 	// TODO: Where is this coming from?
1152 	if (interlaced)
1153 		vstartup_start = vstartup_start / 2;
1154 
1155 	// TODO: What if this min_vblank doesn't match the value in the dml_config_settings.cpp?
1156 	if (vstartup_start >= min_vblank) {
1157 		dml_print("WARNING: DML_DLG: %s: vblank_start=%d vblank_end=%d\n",
1158 			__func__,
1159 			vblank_start,
1160 			vblank_end);
1161 		dml_print("WARNING: DML_DLG: %s: vstartup_start=%d should be less than min_vblank=%d\n",
1162 			__func__,
1163 			vstartup_start,
1164 			min_vblank);
1165 		min_vblank = vstartup_start + 1;
1166 		dml_print("WARNING: DML_DLG: %s: vstartup_start=%d should be less than min_vblank=%d\n",
1167 			__func__,
1168 			vstartup_start,
1169 			min_vblank);
1170 	}
1171 
1172 	dst_x_after_scaler = get_dst_x_after_scaler(mode_lib, e2e_pipe_param, num_pipes, pipe_idx);
1173 	dst_y_after_scaler = get_dst_y_after_scaler(mode_lib, e2e_pipe_param, num_pipes, pipe_idx);
1174 
1175 	// do some adjustment on the dst_after scaler to account for odm combine mode
1176 	dml_print("DML_DLG: %s: input dst_x_after_scaler                     = %d\n",
1177 		__func__,
1178 		dst_x_after_scaler);
1179 	dml_print("DML_DLG: %s: input dst_y_after_scaler                     = %d\n",
1180 		__func__,
1181 		dst_y_after_scaler);
1182 
1183 	// need to figure out which side of odm combine we're in
1184 	if (dst->odm_combine) {
1185 		// figure out which pipes go together
1186 		bool visited[DC__NUM_PIPES__MAX] = { false };
1187 		unsigned int i, j, k;
1188 
1189 		for (k = 0; k < num_pipes; ++k) {
1190 			visited[k] = false;
1191 			pipe_index_in_combine[k] = 0;
1192 		}
1193 
1194 		for (i = 0; i < num_pipes; i++) {
1195 			if (e2e_pipe_param[i].pipe.src.is_hsplit && !visited[i]) {
1196 
1197 				unsigned int grp = e2e_pipe_param[i].pipe.src.hsplit_grp;
1198 				unsigned int grp_idx = 0;
1199 
1200 				for (j = i; j < num_pipes; j++) {
1201 					if (e2e_pipe_param[j].pipe.src.hsplit_grp == grp
1202 							&& e2e_pipe_param[j].pipe.src.is_hsplit && !visited[j]) {
1203 						pipe_index_in_combine[j] = grp_idx;
1204 						dml_print("DML_DLG: %s: pipe[%d] is in grp %d idx %d\n", __func__, j, grp, grp_idx);
1205 						grp_idx++;
1206 						visited[j] = true;
1207 					}
1208 				}
1209 			}
1210 		}
1211 
1212 	}
1213 
1214 	if (dst->odm_combine == dm_odm_combine_mode_disabled) {
1215 		disp_dlg_regs->refcyc_h_blank_end = (unsigned int)((double) hblank_end * ref_freq_to_pix_freq);
1216 	} else {
1217 		unsigned int   odm_combine_factor = (dst->odm_combine == dm_odm_combine_mode_2to1 ? 2 : 4); // TODO: We should really check that 4to1 is supported before setting it to 4
1218 		unsigned int   odm_pipe_index = pipe_index_in_combine[pipe_idx];
1219 		disp_dlg_regs->refcyc_h_blank_end = (unsigned int)(((double) hblank_end + odm_pipe_index * (double) dst->hactive / odm_combine_factor) * ref_freq_to_pix_freq);
1220 	}
1221 	ASSERT(disp_dlg_regs->refcyc_h_blank_end < (unsigned int)dml_pow(2, 13));
1222 
1223 	dml_print("DML_DLG: %s: htotal                                     = %d\n", __func__, htotal);
1224 	dml_print("DML_DLG: %s: pixel_rate_delay_subtotal                  = %d\n",
1225 		__func__,
1226 		pixel_rate_delay_subtotal);
1227 	dml_print("DML_DLG: %s: dst_x_after_scaler[%d]                     = %d\n",
1228 		__func__,
1229 		pipe_idx,
1230 		dst_x_after_scaler);
1231 	dml_print("DML_DLG: %s: dst_y_after_scaler[%d]                     = %d\n",
1232 		__func__,
1233 		pipe_idx,
1234 		dst_y_after_scaler);
1235 
1236 	// Lwait
1237 		// TODO: Should this be urgent_latency_pixel_mixed_with_vm_data_us?
1238 	line_wait = mode_lib->soc.urgent_latency_pixel_data_only_us;
1239 	if (cstate_en)
1240 		line_wait = dml_max(mode_lib->soc.sr_enter_plus_exit_time_us, line_wait);
1241 	if (pstate_en)
1242 		line_wait = dml_max(mode_lib->soc.dram_clock_change_latency_us
1243 			+ mode_lib->soc.urgent_latency_pixel_data_only_us, // TODO: Should this be urgent_latency_pixel_mixed_with_vm_data_us?
1244 			line_wait);
1245 	line_wait = line_wait / line_time_in_us;
1246 
1247 	dst_y_prefetch = get_dst_y_prefetch(mode_lib, e2e_pipe_param, num_pipes, pipe_idx);
1248 	dml_print("DML_DLG: %s: dst_y_prefetch (after rnd) = %3.2f\n", __func__, dst_y_prefetch);
1249 
1250 	dst_y_per_vm_vblank = get_dst_y_per_vm_vblank(mode_lib,
1251 		e2e_pipe_param,
1252 		num_pipes,
1253 		pipe_idx);
1254 	dst_y_per_row_vblank = get_dst_y_per_row_vblank(mode_lib,
1255 		e2e_pipe_param,
1256 		num_pipes,
1257 		pipe_idx);
1258 	dst_y_per_vm_flip = get_dst_y_per_vm_flip(mode_lib, e2e_pipe_param, num_pipes, pipe_idx);
1259 	dst_y_per_row_flip = get_dst_y_per_row_flip(mode_lib, e2e_pipe_param, num_pipes, pipe_idx);
1260 
1261 	max_dst_y_per_vm_vblank = 32.0;	 //U5.2
1262 	max_dst_y_per_row_vblank = 16.0;	//U4.2
1263 
1264 	// magic!
1265 	if (htotal <= 75) {
1266 		min_vblank = 300;
1267 		max_dst_y_per_vm_vblank = 100.0;
1268 		max_dst_y_per_row_vblank = 100.0;
1269 	}
1270 
1271 	dml_print("DML_DLG: %s: dst_y_per_vm_flip    = %3.2f\n", __func__, dst_y_per_vm_flip);
1272 	dml_print("DML_DLG: %s: dst_y_per_row_flip   = %3.2f\n", __func__, dst_y_per_row_flip);
1273 	dml_print("DML_DLG: %s: dst_y_per_vm_vblank  = %3.2f\n", __func__, dst_y_per_vm_vblank);
1274 	dml_print("DML_DLG: %s: dst_y_per_row_vblank = %3.2f\n", __func__, dst_y_per_row_vblank);
1275 
1276 	ASSERT(dst_y_per_vm_vblank < max_dst_y_per_vm_vblank);
1277 	ASSERT(dst_y_per_row_vblank < max_dst_y_per_row_vblank);
1278 
1279 	ASSERT(dst_y_prefetch > (dst_y_per_vm_vblank + dst_y_per_row_vblank));
1280 	lsw = dst_y_prefetch - (dst_y_per_vm_vblank + dst_y_per_row_vblank);
1281 
1282 	dml_print("DML_DLG: %s: lsw = %3.2f\n", __func__, lsw);
1283 
1284 	vratio_pre_l = get_vratio_prefetch_l(mode_lib, e2e_pipe_param, num_pipes, pipe_idx);
1285 	vratio_pre_c = get_vratio_prefetch_c(mode_lib, e2e_pipe_param, num_pipes, pipe_idx);
1286 
1287 	dml_print("DML_DLG: %s: vratio_pre_l=%3.2f\n", __func__, vratio_pre_l);
1288 	dml_print("DML_DLG: %s: vratio_pre_c=%3.2f\n", __func__, vratio_pre_c);
1289 
1290 	// Active
1291 	req_per_swath_ub_l = rq_dlg_param.rq_l.req_per_swath_ub;
1292 	req_per_swath_ub_c = rq_dlg_param.rq_c.req_per_swath_ub;
1293 	meta_row_height_l = rq_dlg_param.rq_l.meta_row_height;
1294 	meta_row_height_c = rq_dlg_param.rq_c.meta_row_height;
1295 	swath_width_pixels_ub_l = 0;
1296 	swath_width_pixels_ub_c = 0;
1297 	scaler_rec_in_width_l = 0;
1298 	scaler_rec_in_width_c = 0;
1299 	dpte_row_height_l = rq_dlg_param.rq_l.dpte_row_height;
1300 	dpte_row_height_c = rq_dlg_param.rq_c.dpte_row_height;
1301 
1302 	if (mode_422) {
1303 		swath_width_pixels_ub_l = swath_width_ub_l * 2;  // *2 for 2 pixel per element
1304 		swath_width_pixels_ub_c = swath_width_ub_c * 2;
1305 	} else {
1306 		swath_width_pixels_ub_l = swath_width_ub_l * 1;
1307 		swath_width_pixels_ub_c = swath_width_ub_c * 1;
1308 	}
1309 
1310 	hscale_pixel_rate_l = 0.;
1311 	hscale_pixel_rate_c = 0.;
1312 	min_hratio_fact_l = 1.0;
1313 	min_hratio_fact_c = 1.0;
1314 
1315 	if (hratio_l <= 1)
1316 		min_hratio_fact_l = 2.0;
1317 	else if (htaps_l <= 6) {
1318 		if ((hratio_l * 2.0) > 4.0)
1319 			min_hratio_fact_l = 4.0;
1320 		else
1321 			min_hratio_fact_l = hratio_l * 2.0;
1322 	} else {
1323 		if (hratio_l > 4.0)
1324 			min_hratio_fact_l = 4.0;
1325 		else
1326 			min_hratio_fact_l = hratio_l;
1327 	}
1328 
1329 	hscale_pixel_rate_l = min_hratio_fact_l * dppclk_freq_in_mhz;
1330 
1331 	if (hratio_c <= 1)
1332 		min_hratio_fact_c = 2.0;
1333 	else if (htaps_c <= 6) {
1334 		if ((hratio_c * 2.0) > 4.0)
1335 			min_hratio_fact_c = 4.0;
1336 		else
1337 			min_hratio_fact_c = hratio_c * 2.0;
1338 	} else {
1339 		if (hratio_c > 4.0)
1340 			min_hratio_fact_c = 4.0;
1341 		else
1342 			min_hratio_fact_c = hratio_c;
1343 	}
1344 
1345 	hscale_pixel_rate_c = min_hratio_fact_c * dppclk_freq_in_mhz;
1346 
1347 	refcyc_per_line_delivery_pre_l = 0.;
1348 	refcyc_per_line_delivery_pre_c = 0.;
1349 	refcyc_per_line_delivery_l = 0.;
1350 	refcyc_per_line_delivery_c = 0.;
1351 
1352 	refcyc_per_req_delivery_pre_l = 0.;
1353 	refcyc_per_req_delivery_pre_c = 0.;
1354 	refcyc_per_req_delivery_l = 0.;
1355 	refcyc_per_req_delivery_c = 0.;
1356 
1357 	full_recout_width = 0;
1358 	// In ODM
1359 	if (src->is_hsplit) {
1360 		// This "hack"  is only allowed (and valid) for MPC combine. In ODM
1361 		// combine, you MUST specify the full_recout_width...according to Oswin
1362 		if (dst->full_recout_width == 0 && !dst->odm_combine) {
1363 			dml_print("DML_DLG: %s: Warning: full_recout_width not set in hsplit mode\n",
1364 				__func__);
1365 			full_recout_width = dst->recout_width * 2; // assume half split for dcn1
1366 		} else
1367 			full_recout_width = dst->full_recout_width;
1368 	} else
1369 		full_recout_width = dst->recout_width;
1370 
1371 	// As of DCN2, mpc_combine and odm_combine are mutually exclusive
1372 	refcyc_per_line_delivery_pre_l = get_refcyc_per_delivery(mode_lib,
1373 		refclk_freq_in_mhz,
1374 		pclk_freq_in_mhz,
1375 		dst->odm_combine,
1376 		full_recout_width,
1377 		dst->hactive,
1378 		vratio_pre_l,
1379 		hscale_pixel_rate_l,
1380 		swath_width_pixels_ub_l,
1381 		1); // per line
1382 
1383 	refcyc_per_line_delivery_l = get_refcyc_per_delivery(mode_lib,
1384 		refclk_freq_in_mhz,
1385 		pclk_freq_in_mhz,
1386 		dst->odm_combine,
1387 		full_recout_width,
1388 		dst->hactive,
1389 		vratio_l,
1390 		hscale_pixel_rate_l,
1391 		swath_width_pixels_ub_l,
1392 		1); // per line
1393 
1394 	dml_print("DML_DLG: %s: full_recout_width              = %d\n",
1395 		__func__,
1396 		full_recout_width);
1397 	dml_print("DML_DLG: %s: hscale_pixel_rate_l            = %3.2f\n",
1398 		__func__,
1399 		hscale_pixel_rate_l);
1400 	dml_print("DML_DLG: %s: refcyc_per_line_delivery_pre_l = %3.2f\n",
1401 		__func__,
1402 		refcyc_per_line_delivery_pre_l);
1403 	dml_print("DML_DLG: %s: refcyc_per_line_delivery_l     = %3.2f\n",
1404 		__func__,
1405 		refcyc_per_line_delivery_l);
1406 
1407 	if (dual_plane) {
1408 		refcyc_per_line_delivery_pre_c = get_refcyc_per_delivery(mode_lib,
1409 			refclk_freq_in_mhz,
1410 			pclk_freq_in_mhz,
1411 			dst->odm_combine,
1412 			full_recout_width,
1413 			dst->hactive,
1414 			vratio_pre_c,
1415 			hscale_pixel_rate_c,
1416 			swath_width_pixels_ub_c,
1417 			1); // per line
1418 
1419 		refcyc_per_line_delivery_c = get_refcyc_per_delivery(mode_lib,
1420 			refclk_freq_in_mhz,
1421 			pclk_freq_in_mhz,
1422 			dst->odm_combine,
1423 			full_recout_width,
1424 			dst->hactive,
1425 			vratio_c,
1426 			hscale_pixel_rate_c,
1427 			swath_width_pixels_ub_c,
1428 			1);  // per line
1429 
1430 		dml_print("DML_DLG: %s: refcyc_per_line_delivery_pre_c = %3.2f\n",
1431 			__func__,
1432 			refcyc_per_line_delivery_pre_c);
1433 		dml_print("DML_DLG: %s: refcyc_per_line_delivery_c     = %3.2f\n",
1434 			__func__,
1435 			refcyc_per_line_delivery_c);
1436 	}
1437 
1438 	// smehta: this is a hack added until we get the real dml, sorry, need to make progress
1439 	if (src->dynamic_metadata_enable && src->gpuvm) {
1440 		unsigned int levels = mode_lib->ip.gpuvm_max_page_table_levels;
1441 		double ref_cycles;
1442 
1443 		if (src->hostvm)
1444 			levels = levels * (mode_lib->ip.hostvm_max_page_table_levels+1);
1445 
1446 		ref_cycles = (levels * mode_lib->soc.urgent_latency_vm_data_only_us) * refclk_freq_in_mhz;
1447 		dml_print("BENyamin:    dst_y_prefetch                  = %f %d %f %f \n",
1448 			ref_cycles, levels, mode_lib->soc.urgent_latency_vm_data_only_us, refclk_freq_in_mhz);
1449 		disp_dlg_regs->refcyc_per_vm_dmdata = (unsigned int) ref_cycles;
1450 	}
1451 	dml_print("BENyamin:    dmdta_en vm                     = %d %d \n",
1452 		src->dynamic_metadata_enable, src->vm);
1453 	// TTU - Luma / Chroma
1454 	if (access_dir) {  // vertical access
1455 		scaler_rec_in_width_l = vp_height_l;
1456 		scaler_rec_in_width_c = vp_height_c;
1457 	} else {
1458 		scaler_rec_in_width_l = vp_width_l;
1459 		scaler_rec_in_width_c = vp_width_c;
1460 	}
1461 
1462 	refcyc_per_req_delivery_pre_l = get_refcyc_per_delivery(mode_lib,
1463 		refclk_freq_in_mhz,
1464 		pclk_freq_in_mhz,
1465 		dst->odm_combine,
1466 		full_recout_width,
1467 		dst->hactive,
1468 		vratio_pre_l,
1469 		hscale_pixel_rate_l,
1470 		scaler_rec_in_width_l,
1471 		req_per_swath_ub_l);  // per req
1472 	refcyc_per_req_delivery_l = get_refcyc_per_delivery(mode_lib,
1473 		refclk_freq_in_mhz,
1474 		pclk_freq_in_mhz,
1475 		dst->odm_combine,
1476 		full_recout_width,
1477 		dst->hactive,
1478 		vratio_l,
1479 		hscale_pixel_rate_l,
1480 		scaler_rec_in_width_l,
1481 		req_per_swath_ub_l);  // per req
1482 
1483 	dml_print("DML_DLG: %s: refcyc_per_req_delivery_pre_l = %3.2f\n",
1484 		__func__,
1485 		refcyc_per_req_delivery_pre_l);
1486 	dml_print("DML_DLG: %s: refcyc_per_req_delivery_l     = %3.2f\n",
1487 		__func__,
1488 		refcyc_per_req_delivery_l);
1489 
1490 	ASSERT(refcyc_per_req_delivery_pre_l < dml_pow(2, 13));
1491 	ASSERT(refcyc_per_req_delivery_l < dml_pow(2, 13));
1492 
1493 	if (dual_plane) {
1494 		refcyc_per_req_delivery_pre_c = get_refcyc_per_delivery(mode_lib,
1495 			refclk_freq_in_mhz,
1496 			pclk_freq_in_mhz,
1497 			dst->odm_combine,
1498 			full_recout_width,
1499 			dst->hactive,
1500 			vratio_pre_c,
1501 			hscale_pixel_rate_c,
1502 			scaler_rec_in_width_c,
1503 			req_per_swath_ub_c);  // per req
1504 		refcyc_per_req_delivery_c = get_refcyc_per_delivery(mode_lib,
1505 			refclk_freq_in_mhz,
1506 			pclk_freq_in_mhz,
1507 			dst->odm_combine,
1508 			full_recout_width,
1509 			dst->hactive,
1510 			vratio_c,
1511 			hscale_pixel_rate_c,
1512 			scaler_rec_in_width_c,
1513 			req_per_swath_ub_c);  // per req
1514 
1515 		dml_print("DML_DLG: %s: refcyc_per_req_delivery_pre_c = %3.2f\n",
1516 			__func__,
1517 			refcyc_per_req_delivery_pre_c);
1518 		dml_print("DML_DLG: %s: refcyc_per_req_delivery_c     = %3.2f\n",
1519 			__func__,
1520 			refcyc_per_req_delivery_c);
1521 
1522 		ASSERT(refcyc_per_req_delivery_pre_c < dml_pow(2, 13));
1523 		ASSERT(refcyc_per_req_delivery_c < dml_pow(2, 13));
1524 	}
1525 
1526 	// TTU - Cursor
1527 	refcyc_per_req_delivery_pre_cur0 = 0.0;
1528 	refcyc_per_req_delivery_cur0 = 0.0;
1529 	if (src->num_cursors > 0) {
1530 		calculate_ttu_cursor(mode_lib,
1531 			&refcyc_per_req_delivery_pre_cur0,
1532 			&refcyc_per_req_delivery_cur0,
1533 			refclk_freq_in_mhz,
1534 			ref_freq_to_pix_freq,
1535 			hscale_pixel_rate_l,
1536 			scl->hscl_ratio,
1537 			vratio_pre_l,
1538 			vratio_l,
1539 			src->cur0_src_width,
1540 			(enum cursor_bpp)(src->cur0_bpp));
1541 	}
1542 
1543 	refcyc_per_req_delivery_pre_cur1 = 0.0;
1544 	refcyc_per_req_delivery_cur1 = 0.0;
1545 	if (src->num_cursors > 1) {
1546 		calculate_ttu_cursor(mode_lib,
1547 			&refcyc_per_req_delivery_pre_cur1,
1548 			&refcyc_per_req_delivery_cur1,
1549 			refclk_freq_in_mhz,
1550 			ref_freq_to_pix_freq,
1551 			hscale_pixel_rate_l,
1552 			scl->hscl_ratio,
1553 			vratio_pre_l,
1554 			vratio_l,
1555 			src->cur1_src_width,
1556 			(enum cursor_bpp)(src->cur1_bpp));
1557 	}
1558 
1559 	// TTU - Misc
1560 	// all hard-coded
1561 
1562 	// Assignment to register structures
1563 	disp_dlg_regs->dst_y_after_scaler = dst_y_after_scaler; // in terms of line
1564 	ASSERT(disp_dlg_regs->dst_y_after_scaler < (unsigned int)8);
1565 	disp_dlg_regs->refcyc_x_after_scaler = dst_x_after_scaler * ref_freq_to_pix_freq; // in terms of refclk
1566 	ASSERT(disp_dlg_regs->refcyc_x_after_scaler < (unsigned int)dml_pow(2, 13));
1567 	disp_dlg_regs->dst_y_prefetch = (unsigned int)(dst_y_prefetch * dml_pow(2, 2));
1568 	disp_dlg_regs->dst_y_per_vm_vblank = (unsigned int)(dst_y_per_vm_vblank * dml_pow(2, 2));
1569 	disp_dlg_regs->dst_y_per_row_vblank = (unsigned int)(dst_y_per_row_vblank * dml_pow(2, 2));
1570 	disp_dlg_regs->dst_y_per_vm_flip = (unsigned int)(dst_y_per_vm_flip * dml_pow(2, 2));
1571 	disp_dlg_regs->dst_y_per_row_flip = (unsigned int)(dst_y_per_row_flip * dml_pow(2, 2));
1572 
1573 	disp_dlg_regs->vratio_prefetch = (unsigned int)(vratio_pre_l * dml_pow(2, 19));
1574 	disp_dlg_regs->vratio_prefetch_c = (unsigned int)(vratio_pre_c * dml_pow(2, 19));
1575 
1576 	dml_print("DML_DLG: %s: disp_dlg_regs->dst_y_per_vm_vblank  = 0x%x\n", __func__, disp_dlg_regs->dst_y_per_vm_vblank);
1577 	dml_print("DML_DLG: %s: disp_dlg_regs->dst_y_per_row_vblank = 0x%x\n", __func__, disp_dlg_regs->dst_y_per_row_vblank);
1578 	dml_print("DML_DLG: %s: disp_dlg_regs->dst_y_per_vm_flip    = 0x%x\n", __func__, disp_dlg_regs->dst_y_per_vm_flip);
1579 	dml_print("DML_DLG: %s: disp_dlg_regs->dst_y_per_row_flip   = 0x%x\n", __func__, disp_dlg_regs->dst_y_per_row_flip);
1580 	disp_dlg_regs->refcyc_per_pte_group_vblank_l =
1581 		(unsigned int)(dst_y_per_row_vblank * (double)htotal
1582 			* ref_freq_to_pix_freq / (double)dpte_groups_per_row_ub_l);
1583 	ASSERT(disp_dlg_regs->refcyc_per_pte_group_vblank_l < (unsigned int)dml_pow(2, 13));
1584 
1585 	if (dual_plane) {
1586 		disp_dlg_regs->refcyc_per_pte_group_vblank_c = (unsigned int)(dst_y_per_row_vblank
1587 			* (double)htotal * ref_freq_to_pix_freq
1588 			/ (double)dpte_groups_per_row_ub_c);
1589 		ASSERT(disp_dlg_regs->refcyc_per_pte_group_vblank_c
1590 			< (unsigned int)dml_pow(2, 13));
1591 	}
1592 
1593 	disp_dlg_regs->refcyc_per_meta_chunk_vblank_l =
1594 		(unsigned int)(dst_y_per_row_vblank * (double)htotal
1595 			* ref_freq_to_pix_freq / (double)meta_chunks_per_row_ub_l);
1596 	ASSERT(disp_dlg_regs->refcyc_per_meta_chunk_vblank_l < (unsigned int)dml_pow(2, 13));
1597 
1598 	disp_dlg_regs->refcyc_per_meta_chunk_vblank_c =
1599 		disp_dlg_regs->refcyc_per_meta_chunk_vblank_l; // dcc for 4:2:0 is not supported in dcn1.0.  assigned to be the same as _l for now
1600 
1601 	disp_dlg_regs->refcyc_per_pte_group_flip_l = (unsigned int)(dst_y_per_row_flip * htotal
1602 		* ref_freq_to_pix_freq) / dpte_groups_per_row_ub_l;
1603 	disp_dlg_regs->refcyc_per_meta_chunk_flip_l = (unsigned int)(dst_y_per_row_flip * htotal
1604 		* ref_freq_to_pix_freq) / meta_chunks_per_row_ub_l;
1605 
1606 	if (dual_plane) {
1607 		disp_dlg_regs->refcyc_per_pte_group_flip_c = (unsigned int)(dst_y_per_row_flip
1608 			* htotal * ref_freq_to_pix_freq) / dpte_groups_per_row_ub_c;
1609 		disp_dlg_regs->refcyc_per_meta_chunk_flip_c = (unsigned int)(dst_y_per_row_flip
1610 			* htotal * ref_freq_to_pix_freq) / meta_chunks_per_row_ub_c;
1611 	}
1612 
1613 	disp_dlg_regs->refcyc_per_vm_group_vblank   = get_refcyc_per_vm_group_vblank(mode_lib, e2e_pipe_param, num_pipes, pipe_idx) * refclk_freq_in_mhz;
1614 	disp_dlg_regs->refcyc_per_vm_group_flip	 = get_refcyc_per_vm_group_flip(mode_lib, e2e_pipe_param, num_pipes, pipe_idx) * refclk_freq_in_mhz;
1615 	disp_dlg_regs->refcyc_per_vm_req_vblank	 = get_refcyc_per_vm_req_vblank(mode_lib, e2e_pipe_param, num_pipes, pipe_idx) * refclk_freq_in_mhz * dml_pow(2, 10);
1616 	disp_dlg_regs->refcyc_per_vm_req_flip	   = get_refcyc_per_vm_req_flip(mode_lib, e2e_pipe_param, num_pipes, pipe_idx) * refclk_freq_in_mhz * dml_pow(2, 10);
1617 
1618 	// Clamp to max for now
1619 	if (disp_dlg_regs->refcyc_per_vm_group_vblank >= (unsigned int)dml_pow(2, 23))
1620 		disp_dlg_regs->refcyc_per_vm_group_vblank = dml_pow(2, 23) - 1;
1621 
1622 	if (disp_dlg_regs->refcyc_per_vm_group_flip >= (unsigned int)dml_pow(2, 23))
1623 		disp_dlg_regs->refcyc_per_vm_group_flip = dml_pow(2, 23) - 1;
1624 
1625 	if (disp_dlg_regs->refcyc_per_vm_req_vblank >= (unsigned int)dml_pow(2, 23))
1626 		disp_dlg_regs->refcyc_per_vm_req_vblank = dml_pow(2, 23) - 1;
1627 
1628 	if (disp_dlg_regs->refcyc_per_vm_req_flip >= (unsigned int)dml_pow(2, 23))
1629 		disp_dlg_regs->refcyc_per_vm_req_flip = dml_pow(2, 23) - 1;
1630 
1631 	disp_dlg_regs->dst_y_per_pte_row_nom_l = (unsigned int)((double)dpte_row_height_l
1632 		/ (double)vratio_l * dml_pow(2, 2));
1633 	ASSERT(disp_dlg_regs->dst_y_per_pte_row_nom_l < (unsigned int)dml_pow(2, 17));
1634 
1635 	if (dual_plane) {
1636 		disp_dlg_regs->dst_y_per_pte_row_nom_c = (unsigned int)((double)dpte_row_height_c
1637 			/ (double)vratio_c * dml_pow(2, 2));
1638 		if (disp_dlg_regs->dst_y_per_pte_row_nom_c >= (unsigned int)dml_pow(2, 17)) {
1639 			dml_print("DML_DLG: %s: Warning dst_y_per_pte_row_nom_c %u larger than supported by register format U15.2 %u\n",
1640 				__func__,
1641 				disp_dlg_regs->dst_y_per_pte_row_nom_c,
1642 				(unsigned int)dml_pow(2, 17) - 1);
1643 		}
1644 	}
1645 
1646 	disp_dlg_regs->dst_y_per_meta_row_nom_l = (unsigned int)((double)meta_row_height_l
1647 		/ (double)vratio_l * dml_pow(2, 2));
1648 	ASSERT(disp_dlg_regs->dst_y_per_meta_row_nom_l < (unsigned int)dml_pow(2, 17));
1649 
1650 	disp_dlg_regs->dst_y_per_meta_row_nom_c = disp_dlg_regs->dst_y_per_meta_row_nom_l; // TODO: dcc for 4:2:0 is not supported in dcn1.0.  assigned to be the same as _l for now
1651 
1652 	dml_print("DML: Trow: %fus\n", line_time_in_us * (double)dpte_row_height_l / (double)vratio_l);
1653 
1654 	disp_dlg_regs->refcyc_per_pte_group_nom_l = (unsigned int)((double)dpte_row_height_l
1655 		/ (double)vratio_l * (double)htotal * ref_freq_to_pix_freq
1656 		/ (double)dpte_groups_per_row_ub_l);
1657 	if (disp_dlg_regs->refcyc_per_pte_group_nom_l >= (unsigned int)dml_pow(2, 23))
1658 		disp_dlg_regs->refcyc_per_pte_group_nom_l = dml_pow(2, 23) - 1;
1659 	disp_dlg_regs->refcyc_per_meta_chunk_nom_l = (unsigned int)((double)meta_row_height_l
1660 		/ (double)vratio_l * (double)htotal * ref_freq_to_pix_freq
1661 		/ (double)meta_chunks_per_row_ub_l);
1662 	if (disp_dlg_regs->refcyc_per_meta_chunk_nom_l >= (unsigned int)dml_pow(2, 23))
1663 		disp_dlg_regs->refcyc_per_meta_chunk_nom_l = dml_pow(2, 23) - 1;
1664 
1665 	if (dual_plane) {
1666 		disp_dlg_regs->refcyc_per_pte_group_nom_c =
1667 			(unsigned int)((double)dpte_row_height_c / (double)vratio_c
1668 				* (double)htotal * ref_freq_to_pix_freq
1669 				/ (double)dpte_groups_per_row_ub_c);
1670 		if (disp_dlg_regs->refcyc_per_pte_group_nom_c >= (unsigned int)dml_pow(2, 23))
1671 			disp_dlg_regs->refcyc_per_pte_group_nom_c = dml_pow(2, 23) - 1;
1672 
1673 		// TODO: Is this the right calculation? Does htotal need to be halved?
1674 		disp_dlg_regs->refcyc_per_meta_chunk_nom_c =
1675 			(unsigned int)((double)meta_row_height_c / (double)vratio_c
1676 				* (double)htotal * ref_freq_to_pix_freq
1677 				/ (double)meta_chunks_per_row_ub_c);
1678 		if (disp_dlg_regs->refcyc_per_meta_chunk_nom_c >= (unsigned int)dml_pow(2, 23))
1679 			disp_dlg_regs->refcyc_per_meta_chunk_nom_c = dml_pow(2, 23) - 1;
1680 	}
1681 
1682 	disp_dlg_regs->refcyc_per_line_delivery_pre_l = (unsigned int)dml_floor(refcyc_per_line_delivery_pre_l,
1683 		1);
1684 	disp_dlg_regs->refcyc_per_line_delivery_l = (unsigned int)dml_floor(refcyc_per_line_delivery_l,
1685 		1);
1686 	ASSERT(disp_dlg_regs->refcyc_per_line_delivery_pre_l < (unsigned int)dml_pow(2, 13));
1687 	ASSERT(disp_dlg_regs->refcyc_per_line_delivery_l < (unsigned int)dml_pow(2, 13));
1688 
1689 	disp_dlg_regs->refcyc_per_line_delivery_pre_c = (unsigned int)dml_floor(refcyc_per_line_delivery_pre_c,
1690 		1);
1691 	disp_dlg_regs->refcyc_per_line_delivery_c = (unsigned int)dml_floor(refcyc_per_line_delivery_c,
1692 		1);
1693 	ASSERT(disp_dlg_regs->refcyc_per_line_delivery_pre_c < (unsigned int)dml_pow(2, 13));
1694 	ASSERT(disp_dlg_regs->refcyc_per_line_delivery_c < (unsigned int)dml_pow(2, 13));
1695 
1696 	disp_dlg_regs->chunk_hdl_adjust_cur0 = 3;
1697 	disp_dlg_regs->dst_y_offset_cur0 = 0;
1698 	disp_dlg_regs->chunk_hdl_adjust_cur1 = 3;
1699 	disp_dlg_regs->dst_y_offset_cur1 = 0;
1700 
1701 	disp_dlg_regs->dst_y_delta_drq_limit = 0x7fff; // off
1702 
1703 	disp_ttu_regs->refcyc_per_req_delivery_pre_l = (unsigned int)(refcyc_per_req_delivery_pre_l
1704 		* dml_pow(2, 10));
1705 	disp_ttu_regs->refcyc_per_req_delivery_l = (unsigned int)(refcyc_per_req_delivery_l
1706 		* dml_pow(2, 10));
1707 	disp_ttu_regs->refcyc_per_req_delivery_pre_c = (unsigned int)(refcyc_per_req_delivery_pre_c
1708 		* dml_pow(2, 10));
1709 	disp_ttu_regs->refcyc_per_req_delivery_c = (unsigned int)(refcyc_per_req_delivery_c
1710 		* dml_pow(2, 10));
1711 	disp_ttu_regs->refcyc_per_req_delivery_pre_cur0 =
1712 		(unsigned int)(refcyc_per_req_delivery_pre_cur0 * dml_pow(2, 10));
1713 	disp_ttu_regs->refcyc_per_req_delivery_cur0 = (unsigned int)(refcyc_per_req_delivery_cur0
1714 		* dml_pow(2, 10));
1715 	disp_ttu_regs->refcyc_per_req_delivery_pre_cur1 =
1716 		(unsigned int)(refcyc_per_req_delivery_pre_cur1 * dml_pow(2, 10));
1717 	disp_ttu_regs->refcyc_per_req_delivery_cur1 = (unsigned int)(refcyc_per_req_delivery_cur1
1718 		* dml_pow(2, 10));
1719 	disp_ttu_regs->qos_level_low_wm = 0;
1720 	ASSERT(disp_ttu_regs->qos_level_low_wm < dml_pow(2, 14));
1721 	disp_ttu_regs->qos_level_high_wm = (unsigned int)(4.0 * (double)htotal
1722 		* ref_freq_to_pix_freq);
1723 	ASSERT(disp_ttu_regs->qos_level_high_wm < dml_pow(2, 14));
1724 
1725 	disp_ttu_regs->qos_level_flip = 14;
1726 	disp_ttu_regs->qos_level_fixed_l = 8;
1727 	disp_ttu_regs->qos_level_fixed_c = 8;
1728 	disp_ttu_regs->qos_level_fixed_cur0 = 8;
1729 	disp_ttu_regs->qos_ramp_disable_l = 0;
1730 	disp_ttu_regs->qos_ramp_disable_c = 0;
1731 	disp_ttu_regs->qos_ramp_disable_cur0 = 0;
1732 
1733 	disp_ttu_regs->min_ttu_vblank = min_ttu_vblank * refclk_freq_in_mhz;
1734 	ASSERT(disp_ttu_regs->min_ttu_vblank < dml_pow(2, 24));
1735 
1736 	print__ttu_regs_st(mode_lib, disp_ttu_regs);
1737 	print__dlg_regs_st(mode_lib, disp_dlg_regs);
1738 }
1739 
1740 void dml30_rq_dlg_get_dlg_reg(struct display_mode_lib *mode_lib,
1741 	display_dlg_regs_st *dlg_regs,
1742 	display_ttu_regs_st *ttu_regs,
1743 	const display_e2e_pipe_params_st *e2e_pipe_param,
1744 	const unsigned int num_pipes,
1745 	const unsigned int pipe_idx,
1746 	const bool cstate_en,
1747 	const bool pstate_en,
1748 	const bool vm_en,
1749 	const bool ignore_viewport_pos,
1750 	const bool immediate_flip_support)
1751 {
1752 	display_rq_params_st rq_param = { 0 };
1753 	display_dlg_sys_params_st dlg_sys_param = { 0 };
1754 
1755 	// Get watermark and Tex.
1756 	dlg_sys_param.t_urg_wm_us = get_wm_urgent(mode_lib, e2e_pipe_param, num_pipes);
1757 	dlg_sys_param.deepsleep_dcfclk_mhz = get_clk_dcf_deepsleep(mode_lib,
1758 		e2e_pipe_param,
1759 		num_pipes);
1760 	dlg_sys_param.t_extra_us = get_urgent_extra_latency(mode_lib, e2e_pipe_param, num_pipes);
1761 	dlg_sys_param.mem_trip_us = get_wm_memory_trip(mode_lib, e2e_pipe_param, num_pipes);
1762 	dlg_sys_param.t_mclk_wm_us = get_wm_dram_clock_change(mode_lib, e2e_pipe_param, num_pipes);
1763 	dlg_sys_param.t_sr_wm_us = get_wm_stutter_enter_exit(mode_lib, e2e_pipe_param, num_pipes);
1764 	dlg_sys_param.total_flip_bw = get_total_immediate_flip_bw(mode_lib,
1765 		e2e_pipe_param,
1766 		num_pipes);
1767 	dlg_sys_param.total_flip_bytes = get_total_immediate_flip_bytes(mode_lib,
1768 		e2e_pipe_param,
1769 		num_pipes);
1770 
1771 	print__dlg_sys_params_st(mode_lib, &dlg_sys_param);
1772 
1773 	// system parameter calculation done
1774 
1775 	dml_print("DML_DLG: Calculation for pipe[%d] start\n\n", pipe_idx);
1776 	dml_rq_dlg_get_rq_params(mode_lib, &rq_param, &e2e_pipe_param[pipe_idx].pipe);
1777 	dml_rq_dlg_get_dlg_params(mode_lib,
1778 		e2e_pipe_param,
1779 		num_pipes,
1780 		pipe_idx,
1781 		dlg_regs,
1782 		ttu_regs,
1783 		rq_param.dlg,
1784 		dlg_sys_param,
1785 		cstate_en,
1786 		pstate_en,
1787 		vm_en,
1788 		ignore_viewport_pos,
1789 		immediate_flip_support);
1790 	dml_print("DML_DLG: Calculation for pipe[%d] end\n", pipe_idx);
1791 }
1792 
1793