1 /*
2  * Copyright 2022 Advanced Micro Devices, Inc. All rights reserved.
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 "dc.h"
27 #include "../display_mode_lib.h"
28 #include "display_mode_vba_32.h"
29 #include "../dml_inline_defs.h"
30 #include "display_mode_vba_util_32.h"
31 
32 void dml32_recalculate(struct display_mode_lib *mode_lib);
33 static void DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation(
34 		struct display_mode_lib *mode_lib);
35 void dml32_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_lib);
36 
dml32_recalculate(struct display_mode_lib * mode_lib)37 void dml32_recalculate(struct display_mode_lib *mode_lib)
38 {
39 	ModeSupportAndSystemConfiguration(mode_lib);
40 
41 	dml32_CalculateMaxDETAndMinCompressedBufferSize(mode_lib->vba.ConfigReturnBufferSizeInKByte,
42 			mode_lib->vba.ROBBufferSizeInKByte,
43 			DC__NUM_DPP,
44 			false, //mode_lib->vba.override_setting.nomDETInKByteOverrideEnable,
45 			0, //mode_lib->vba.override_setting.nomDETInKByteOverrideValue,
46 
47 			/* Output */
48 			&mode_lib->vba.MaxTotalDETInKByte, &mode_lib->vba.nomDETInKByte,
49 			&mode_lib->vba.MinCompressedBufferSizeInKByte);
50 
51 	PixelClockAdjustmentForProgressiveToInterlaceUnit(mode_lib);
52 #ifdef __DML_VBA_DEBUG__
53 	dml_print("DML::%s: Calling DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation\n", __func__);
54 #endif
55 	DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation(mode_lib);
56 }
57 
DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation(struct display_mode_lib * mode_lib)58 static void DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation(
59 		struct display_mode_lib *mode_lib)
60 {
61 	struct vba_vars_st *v = &mode_lib->vba;
62 	unsigned int j, k;
63 	bool ImmediateFlipRequirementFinal;
64 	int iteration;
65 	double MaxTotalRDBandwidth;
66 	unsigned int NextPrefetchMode;
67 	double MaxTotalRDBandwidthNoUrgentBurst = 0.0;
68 	bool DestinationLineTimesForPrefetchLessThan2 = false;
69 	bool VRatioPrefetchMoreThanMax = false;
70 	double TWait;
71 	double TotalWRBandwidth = 0;
72 	double WRBandwidth = 0;
73 
74 #ifdef __DML_VBA_DEBUG__
75 	dml_print("DML::%s: --- START ---\n", __func__);
76 	dml_print("DML::%s: mode_lib->vba.PrefetchMode = %d\n", __func__, mode_lib->vba.PrefetchMode);
77 	dml_print("DML::%s: mode_lib->vba.ImmediateFlipSupport = %d\n", __func__, mode_lib->vba.ImmediateFlipSupport);
78 	dml_print("DML::%s: mode_lib->vba.VoltageLevel = %d\n", __func__, mode_lib->vba.VoltageLevel);
79 #endif
80 
81 	v->WritebackDISPCLK = 0.0;
82 	v->GlobalDPPCLK = 0.0;
83 
84 	// DISPCLK and DPPCLK Calculation
85 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
86 		if (mode_lib->vba.WritebackEnable[k]) {
87 			v->WritebackDISPCLK = dml_max(v->WritebackDISPCLK,
88 					dml32_CalculateWriteBackDISPCLK(
89 							mode_lib->vba.WritebackPixelFormat[k],
90 							mode_lib->vba.PixelClock[k], mode_lib->vba.WritebackHRatio[k],
91 							mode_lib->vba.WritebackVRatio[k],
92 							mode_lib->vba.WritebackHTaps[k],
93 							mode_lib->vba.WritebackVTaps[k],
94 							mode_lib->vba.WritebackSourceWidth[k],
95 							mode_lib->vba.WritebackDestinationWidth[k],
96 							mode_lib->vba.HTotal[k], mode_lib->vba.WritebackLineBufferSize,
97 							mode_lib->vba.DISPCLKDPPCLKVCOSpeed));
98 		}
99 	}
100 
101 	v->DISPCLK_calculated = v->WritebackDISPCLK;
102 
103 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
104 		if (mode_lib->vba.BlendingAndTiming[k] == k) {
105 			v->DISPCLK_calculated = dml_max(v->DISPCLK_calculated,
106 					dml32_CalculateRequiredDispclk(
107 							mode_lib->vba.ODMCombineEnabled[k],
108 							mode_lib->vba.PixelClock[k],
109 							mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading,
110 							mode_lib->vba.DISPCLKRampingMargin,
111 							mode_lib->vba.DISPCLKDPPCLKVCOSpeed,
112 							mode_lib->vba.MaxDppclk[v->soc.num_states - 1]));
113 		}
114 	}
115 
116 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
117 		dml32_CalculateSinglePipeDPPCLKAndSCLThroughput(mode_lib->vba.HRatio[k],
118 				mode_lib->vba.HRatioChroma[k],
119 				mode_lib->vba.VRatio[k],
120 				mode_lib->vba.VRatioChroma[k],
121 				mode_lib->vba.MaxDCHUBToPSCLThroughput,
122 				mode_lib->vba.MaxPSCLToLBThroughput,
123 				mode_lib->vba.PixelClock[k],
124 				mode_lib->vba.SourcePixelFormat[k],
125 				mode_lib->vba.htaps[k],
126 				mode_lib->vba.HTAPsChroma[k],
127 				mode_lib->vba.vtaps[k],
128 				mode_lib->vba.VTAPsChroma[k],
129 
130 				/* Output */
131 				&v->PSCL_THROUGHPUT_LUMA[k], &v->PSCL_THROUGHPUT_CHROMA[k],
132 				&v->DPPCLKUsingSingleDPP[k]);
133 	}
134 
135 	dml32_CalculateDPPCLK(mode_lib->vba.NumberOfActiveSurfaces, mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading,
136 			mode_lib->vba.DISPCLKDPPCLKVCOSpeed, v->DPPCLKUsingSingleDPP, mode_lib->vba.DPPPerPlane,
137 			/* Output */
138 			&v->GlobalDPPCLK, v->DPPCLK);
139 
140 	for (k = 0; k < v->NumberOfActiveSurfaces; ++k) {
141 		v->DPPCLK_calculated[k] = v->DPPCLK[k];
142 	}
143 
144 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
145 		dml32_CalculateBytePerPixelAndBlockSizes(
146 				mode_lib->vba.SourcePixelFormat[k],
147 				mode_lib->vba.SurfaceTiling[k],
148 
149 				/* Output */
150 				&v->BytePerPixelY[k],
151 				&v->BytePerPixelC[k],
152 				&v->BytePerPixelDETY[k],
153 				&v->BytePerPixelDETC[k],
154 				&v->BlockHeight256BytesY[k],
155 				&v->BlockHeight256BytesC[k],
156 				&v->BlockWidth256BytesY[k],
157 				&v->BlockWidth256BytesC[k],
158 				&v->BlockHeightY[k],
159 				&v->BlockHeightC[k],
160 				&v->BlockWidthY[k],
161 				&v->BlockWidthC[k]);
162 	}
163 
164 #ifdef __DML_VBA_DEBUG__
165 	dml_print("DML::%s: %d\n", __func__, __LINE__);
166 #endif
167 	dml32_CalculateSwathWidth(
168 			false,  // ForceSingleDPP
169 			mode_lib->vba.NumberOfActiveSurfaces,
170 			mode_lib->vba.SourcePixelFormat,
171 			mode_lib->vba.SourceRotation,
172 			mode_lib->vba.ViewportStationary,
173 			mode_lib->vba.ViewportWidth,
174 			mode_lib->vba.ViewportHeight,
175 			mode_lib->vba.ViewportXStartY,
176 			mode_lib->vba.ViewportYStartY,
177 			mode_lib->vba.ViewportXStartC,
178 			mode_lib->vba.ViewportYStartC,
179 			mode_lib->vba.SurfaceWidthY,
180 			mode_lib->vba.SurfaceWidthC,
181 			mode_lib->vba.SurfaceHeightY,
182 			mode_lib->vba.SurfaceHeightC,
183 			mode_lib->vba.ODMCombineEnabled,
184 			v->BytePerPixelY,
185 			v->BytePerPixelC,
186 			v->BlockHeight256BytesY,
187 			v->BlockHeight256BytesC,
188 			v->BlockWidth256BytesY,
189 			v->BlockWidth256BytesC,
190 			mode_lib->vba.BlendingAndTiming,
191 			mode_lib->vba.HActive,
192 			mode_lib->vba.HRatio,
193 			mode_lib->vba.DPPPerPlane,
194 
195 			/* Output */
196 			v->SwathWidthSingleDPPY, v->SwathWidthSingleDPPC, v->SwathWidthY, v->SwathWidthC,
197 			v->dummy_vars
198 				.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation
199 				.dummy_integer_array[0], // Integer             MaximumSwathHeightY[]
200 			v->dummy_vars
201 				.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation
202 				.dummy_integer_array[1], // Integer             MaximumSwathHeightC[]
203 			v->swath_width_luma_ub, v->swath_width_chroma_ub);
204 
205 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
206 		v->ReadBandwidthSurfaceLuma[k] = v->SwathWidthSingleDPPY[k] * v->BytePerPixelY[k]
207 				/ (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]) * mode_lib->vba.VRatio[k];
208 		v->ReadBandwidthSurfaceChroma[k] = v->SwathWidthSingleDPPC[k] * v->BytePerPixelC[k]
209 				/ (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k])
210 				* mode_lib->vba.VRatioChroma[k];
211 #ifdef __DML_VBA_DEBUG__
212 		dml_print("DML::%s: ReadBandwidthSurfaceLuma[%i] = %fBps\n",
213 				__func__, k, v->ReadBandwidthSurfaceLuma[k]);
214 		dml_print("DML::%s: ReadBandwidthSurfaceChroma[%i] = %fBps\n",
215 				__func__, k, v->ReadBandwidthSurfaceChroma[k]);
216 #endif
217 	}
218 
219 	{
220 		// VBA_DELTA
221 		// Calculate DET size, swath height
222 		dml32_CalculateSwathAndDETConfiguration(
223 				mode_lib->vba.DETSizeOverride,
224 				mode_lib->vba.UsesMALLForPStateChange,
225 				mode_lib->vba.ConfigReturnBufferSizeInKByte,
226 				mode_lib->vba.MaxTotalDETInKByte,
227 				mode_lib->vba.MinCompressedBufferSizeInKByte,
228 				false, /* ForceSingleDPP */
229 				mode_lib->vba.NumberOfActiveSurfaces,
230 				mode_lib->vba.nomDETInKByte,
231 				mode_lib->vba.UseUnboundedRequesting,
232 				mode_lib->vba.DisableUnboundRequestIfCompBufReservedSpaceNeedAdjustment,
233 				mode_lib->vba.ip.pixel_chunk_size_kbytes,
234 				mode_lib->vba.ip.rob_buffer_size_kbytes,
235 				mode_lib->vba.CompressedBufferSegmentSizeInkByteFinal,
236 				v->dummy_vars
237 					.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation
238 					.dummy_output_encoder_array, /* output_encoder_class Output[] */
239 				v->ReadBandwidthSurfaceLuma,
240 				v->ReadBandwidthSurfaceChroma,
241 				v->dummy_vars
242 					.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation
243 					.dummy_single_array[0], /* Single MaximumSwathWidthLuma[] */
244 				v->dummy_vars
245 					.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation
246 					.dummy_single_array[1], /* Single MaximumSwathWidthChroma[] */
247 				mode_lib->vba.SourceRotation,
248 				mode_lib->vba.ViewportStationary,
249 				mode_lib->vba.SourcePixelFormat,
250 				mode_lib->vba.SurfaceTiling,
251 				mode_lib->vba.ViewportWidth,
252 				mode_lib->vba.ViewportHeight,
253 				mode_lib->vba.ViewportXStartY,
254 				mode_lib->vba.ViewportYStartY,
255 				mode_lib->vba.ViewportXStartC,
256 				mode_lib->vba.ViewportYStartC,
257 				mode_lib->vba.SurfaceWidthY,
258 				mode_lib->vba.SurfaceWidthC,
259 				mode_lib->vba.SurfaceHeightY,
260 				mode_lib->vba.SurfaceHeightC,
261 				v->BlockHeight256BytesY,
262 				v->BlockHeight256BytesC,
263 				v->BlockWidth256BytesY,
264 				v->BlockWidth256BytesC,
265 				mode_lib->vba.ODMCombineEnabled,
266 				mode_lib->vba.BlendingAndTiming,
267 				v->BytePerPixelY,
268 				v->BytePerPixelC,
269 				v->BytePerPixelDETY,
270 				v->BytePerPixelDETC,
271 				mode_lib->vba.HActive,
272 				mode_lib->vba.HRatio,
273 				mode_lib->vba.HRatioChroma,
274 				mode_lib->vba.DPPPerPlane,
275 
276 				/* Output */
277 				v->dummy_vars
278 					.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation
279 					.dummy_long_array[0], /* Long swath_width_luma_ub[] */
280 				v->dummy_vars
281 					.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation
282 					.dummy_long_array[1], /* Long swath_width_chroma_ub[] */
283 				v->dummy_vars
284 					.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation
285 					.dummy_double_array[0], /* Long SwathWidth[] */
286 				v->dummy_vars
287 					.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation
288 					.dummy_double_array[1], /* Long SwathWidthChroma[] */
289 				mode_lib->vba.SwathHeightY,
290 				mode_lib->vba.SwathHeightC,
291 				mode_lib->vba.DETBufferSizeInKByte,
292 				mode_lib->vba.DETBufferSizeY,
293 				mode_lib->vba.DETBufferSizeC,
294 				&v->UnboundedRequestEnabled,
295 				&v->CompressedBufferSizeInkByte,
296 				&v->CompBufReservedSpaceKBytes,
297 				&v->dummy_vars
298 					.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation
299 					.dummy_boolean,       /* bool *CompBufReservedSpaceNeedAjustment */
300 				v->dummy_vars
301 					.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation
302 					.dummy_boolean_array, /* bool ViewportSizeSupportPerSurface[] */
303 				&v->dummy_vars
304 					 .DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation
305 					 .dummy_boolean); /* bool *ViewportSizeSupport */
306 	}
307 
308 	v->CompBufReservedSpaceZs     = v->CompBufReservedSpaceKBytes * 1024.0 / 256.0;
309 	v->CompBufReservedSpace64B    = v->CompBufReservedSpaceKBytes * 1024.0 / 64.0;
310 
311 	// DCFCLK Deep Sleep
312 	dml32_CalculateDCFCLKDeepSleep(
313 			mode_lib->vba.NumberOfActiveSurfaces,
314 			v->BytePerPixelY,
315 			v->BytePerPixelC,
316 			mode_lib->vba.VRatio,
317 			mode_lib->vba.VRatioChroma,
318 			v->SwathWidthY,
319 			v->SwathWidthC,
320 			mode_lib->vba.DPPPerPlane,
321 			mode_lib->vba.HRatio,
322 			mode_lib->vba.HRatioChroma,
323 			mode_lib->vba.PixelClock,
324 			v->PSCL_THROUGHPUT_LUMA,
325 			v->PSCL_THROUGHPUT_CHROMA,
326 			mode_lib->vba.DPPCLK,
327 			v->ReadBandwidthSurfaceLuma,
328 			v->ReadBandwidthSurfaceChroma,
329 			mode_lib->vba.ReturnBusWidth,
330 
331 			/* Output */
332 			&v->DCFCLKDeepSleep);
333 
334 	// DSCCLK
335 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
336 		if ((mode_lib->vba.BlendingAndTiming[k] != k) || !mode_lib->vba.DSCEnabled[k]) {
337 			v->DSCCLK_calculated[k] = 0.0;
338 		} else {
339 			if (mode_lib->vba.OutputFormat[k] == dm_420)
340 				mode_lib->vba.DSCFormatFactor = 2;
341 			else if (mode_lib->vba.OutputFormat[k] == dm_444)
342 				mode_lib->vba.DSCFormatFactor = 1;
343 			else if (mode_lib->vba.OutputFormat[k] == dm_n422)
344 				mode_lib->vba.DSCFormatFactor = 2;
345 			else
346 				mode_lib->vba.DSCFormatFactor = 1;
347 			if (mode_lib->vba.ODMCombineEnabled[k] == dm_odm_combine_mode_4to1)
348 				v->DSCCLK_calculated[k] = mode_lib->vba.PixelClockBackEnd[k] / 12
349 						/ mode_lib->vba.DSCFormatFactor
350 						/ (1 - mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100);
351 			else if (mode_lib->vba.ODMCombineEnabled[k] == dm_odm_combine_mode_2to1)
352 				v->DSCCLK_calculated[k] = mode_lib->vba.PixelClockBackEnd[k] / 6
353 						/ mode_lib->vba.DSCFormatFactor
354 						/ (1 - mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100);
355 			else
356 				v->DSCCLK_calculated[k] = mode_lib->vba.PixelClockBackEnd[k] / 3
357 						/ mode_lib->vba.DSCFormatFactor
358 						/ (1 - mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100);
359 		}
360 	}
361 
362 	// DSC Delay
363 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
364 		v->DSCDelay[k] = dml32_DSCDelayRequirement(mode_lib->vba.DSCEnabled[k],
365 				mode_lib->vba.ODMCombineEnabled[k], mode_lib->vba.DSCInputBitPerComponent[k],
366 				mode_lib->vba.OutputBppPerState[mode_lib->vba.VoltageLevel][k],
367 				mode_lib->vba.HActive[k], mode_lib->vba.HTotal[k],
368 				mode_lib->vba.NumberOfDSCSlices[k], mode_lib->vba.OutputFormat[k],
369 				mode_lib->vba.Output[k], mode_lib->vba.PixelClock[k],
370 				mode_lib->vba.PixelClockBackEnd[k], mode_lib->vba.ip.dsc_delay_factor_wa);
371 	}
372 
373 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k)
374 		for (j = 0; j < mode_lib->vba.NumberOfActiveSurfaces; ++j) // NumberOfSurfaces
375 			if (j != k && mode_lib->vba.BlendingAndTiming[k] == j && mode_lib->vba.DSCEnabled[j])
376 				v->DSCDelay[k] = v->DSCDelay[j];
377 
378 	//Immediate Flip
379 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
380 		v->ImmediateFlipSupportedSurface[k] = mode_lib->vba.ImmediateFlipSupport
381 				&& (mode_lib->vba.ImmediateFlipRequirement[k] != dm_immediate_flip_not_required);
382 	}
383 
384 	// Prefetch
385 	dml32_CalculateSurfaceSizeInMall(
386 				mode_lib->vba.NumberOfActiveSurfaces,
387 				mode_lib->vba.MALLAllocatedForDCNFinal,
388 				mode_lib->vba.UseMALLForStaticScreen,
389 				mode_lib->vba.UsesMALLForPStateChange,
390 				mode_lib->vba.DCCEnable,
391 				mode_lib->vba.ViewportStationary,
392 				mode_lib->vba.ViewportXStartY,
393 				mode_lib->vba.ViewportYStartY,
394 				mode_lib->vba.ViewportXStartC,
395 				mode_lib->vba.ViewportYStartC,
396 				mode_lib->vba.ViewportWidth,
397 				mode_lib->vba.ViewportHeight,
398 				v->BytePerPixelY,
399 				mode_lib->vba.ViewportWidthChroma,
400 				mode_lib->vba.ViewportHeightChroma,
401 				v->BytePerPixelC,
402 				mode_lib->vba.SurfaceWidthY,
403 				mode_lib->vba.SurfaceWidthC,
404 				mode_lib->vba.SurfaceHeightY,
405 				mode_lib->vba.SurfaceHeightC,
406 				v->BlockWidth256BytesY,
407 				v->BlockWidth256BytesC,
408 				v->BlockHeight256BytesY,
409 				v->BlockHeight256BytesC,
410 				v->BlockWidthY,
411 				v->BlockWidthC,
412 				v->BlockHeightY,
413 				v->BlockHeightC,
414 				mode_lib->vba.DCCMetaPitchY,
415 				mode_lib->vba.DCCMetaPitchC,
416 
417 				/* Output */
418 				v->SurfaceSizeInMALL,
419 				&v->dummy_vars.
420 				DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation
421 				.dummy_boolean2); /* Boolean *ExceededMALLSize */
422 
423 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
424 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].PixelClock = mode_lib->vba.PixelClock[k];
425 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].DPPPerSurface = mode_lib->vba.DPPPerPlane[k];
426 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].SourceRotation = mode_lib->vba.SourceRotation[k];
427 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].ViewportHeight = mode_lib->vba.ViewportHeight[k];
428 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].ViewportHeightChroma = mode_lib->vba.ViewportHeightChroma[k];
429 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].BlockWidth256BytesY = v->BlockWidth256BytesY[k];
430 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].BlockHeight256BytesY = v->BlockHeight256BytesY[k];
431 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].BlockWidth256BytesC = v->BlockWidth256BytesC[k];
432 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].BlockHeight256BytesC = v->BlockHeight256BytesC[k];
433 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].BlockWidthY = v->BlockWidthY[k];
434 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].BlockHeightY = v->BlockHeightY[k];
435 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].BlockWidthC = v->BlockWidthC[k];
436 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].BlockHeightC = v->BlockHeightC[k];
437 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].InterlaceEnable = mode_lib->vba.Interlace[k];
438 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].HTotal = mode_lib->vba.HTotal[k];
439 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].DCCEnable = mode_lib->vba.DCCEnable[k];
440 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].SourcePixelFormat = mode_lib->vba.SourcePixelFormat[k];
441 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].SurfaceTiling = mode_lib->vba.SurfaceTiling[k];
442 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].BytePerPixelY = v->BytePerPixelY[k];
443 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].BytePerPixelC = v->BytePerPixelC[k];
444 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].ProgressiveToInterlaceUnitInOPP = mode_lib->vba.ProgressiveToInterlaceUnitInOPP;
445 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].VRatio = mode_lib->vba.VRatio[k];
446 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].VRatioChroma = mode_lib->vba.VRatioChroma[k];
447 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].VTaps = mode_lib->vba.vtaps[k];
448 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].VTapsChroma = mode_lib->vba.VTAPsChroma[k];
449 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].PitchY = mode_lib->vba.PitchY[k];
450 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].DCCMetaPitchY = mode_lib->vba.DCCMetaPitchY[k];
451 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].PitchC = mode_lib->vba.PitchC[k];
452 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].DCCMetaPitchC = mode_lib->vba.DCCMetaPitchC[k];
453 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].ViewportStationary = mode_lib->vba.ViewportStationary[k];
454 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].ViewportXStart = mode_lib->vba.ViewportXStartY[k];
455 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].ViewportYStart = mode_lib->vba.ViewportYStartY[k];
456 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].ViewportXStartC = mode_lib->vba.ViewportXStartC[k];
457 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].ViewportYStartC = mode_lib->vba.ViewportYStartC[k];
458 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].FORCE_ONE_ROW_FOR_FRAME = mode_lib->vba.ForceOneRowForFrame[k];
459 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].SwathHeightY = mode_lib->vba.SwathHeightY[k];
460 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters[k].SwathHeightC = mode_lib->vba.SwathHeightC[k];
461 	}
462 
463 	{
464 
465 		dml32_CalculateVMRowAndSwath(
466 				mode_lib->vba.NumberOfActiveSurfaces,
467 				v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.SurfaceParameters,
468 				v->SurfaceSizeInMALL,
469 				mode_lib->vba.PTEBufferSizeInRequestsLuma,
470 				mode_lib->vba.PTEBufferSizeInRequestsChroma,
471 				mode_lib->vba.DCCMetaBufferSizeBytes,
472 				mode_lib->vba.UseMALLForStaticScreen,
473 				mode_lib->vba.UsesMALLForPStateChange,
474 				mode_lib->vba.MALLAllocatedForDCNFinal,
475 				v->SwathWidthY,
476 				v->SwathWidthC,
477 				mode_lib->vba.GPUVMEnable,
478 				mode_lib->vba.HostVMEnable,
479 				mode_lib->vba.HostVMMaxNonCachedPageTableLevels,
480 				mode_lib->vba.GPUVMMaxPageTableLevels,
481 				mode_lib->vba.GPUVMMinPageSizeKBytes,
482 				mode_lib->vba.HostVMMinPageSize,
483 
484 				/* Output */
485 				v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_boolean_array2[0],  // Boolean PTEBufferSizeNotExceeded[]
486 				v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_boolean_array2[1],  // Boolean DCCMetaBufferSizeNotExceeded[]
487 				v->dpte_row_width_luma_ub,
488 				v->dpte_row_width_chroma_ub,
489 				v->dpte_row_height,
490 				v->dpte_row_height_chroma,
491 				v->dpte_row_height_linear,
492 				v->dpte_row_height_linear_chroma,
493 				v->meta_req_width,
494 				v->meta_req_width_chroma,
495 				v->meta_req_height,
496 				v->meta_req_height_chroma,
497 				v->meta_row_width,
498 				v->meta_row_width_chroma,
499 				v->meta_row_height,
500 				v->meta_row_height_chroma,
501 				v->vm_group_bytes,
502 				v->dpte_group_bytes,
503 				v->PixelPTEReqWidthY,
504 				v->PixelPTEReqHeightY,
505 				v->PTERequestSizeY,
506 				v->PixelPTEReqWidthC,
507 				v->PixelPTEReqHeightC,
508 				v->PTERequestSizeC,
509 				v->dpde0_bytes_per_frame_ub_l,
510 				v->meta_pte_bytes_per_frame_ub_l,
511 				v->dpde0_bytes_per_frame_ub_c,
512 				v->meta_pte_bytes_per_frame_ub_c,
513 				v->PrefetchSourceLinesY,
514 				v->PrefetchSourceLinesC,
515 				v->VInitPreFillY, v->VInitPreFillC,
516 				v->MaxNumSwathY,
517 				v->MaxNumSwathC,
518 				v->meta_row_bw,
519 				v->dpte_row_bw,
520 				v->PixelPTEBytesPerRow,
521 				v->PDEAndMetaPTEBytesFrame,
522 				v->MetaRowByte,
523 				v->Use_One_Row_For_Frame,
524 				v->Use_One_Row_For_Frame_Flip,
525 				v->UsesMALLForStaticScreen,
526 				v->PTE_BUFFER_MODE,
527 				v->BIGK_FRAGMENT_SIZE);
528 	}
529 
530 
531 	v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.ReorderBytes = mode_lib->vba.NumberOfChannels
532 			* dml_max3(mode_lib->vba.UrgentOutOfOrderReturnPerChannelPixelDataOnly,
533 					mode_lib->vba.UrgentOutOfOrderReturnPerChannelPixelMixedWithVMData,
534 					mode_lib->vba.UrgentOutOfOrderReturnPerChannelVMDataOnly);
535 
536 	v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.VMDataOnlyReturnBW = dml32_get_return_bw_mbps_vm_only(
537 			&mode_lib->vba.soc,
538 			mode_lib->vba.VoltageLevel,
539 			mode_lib->vba.DCFCLK,
540 			mode_lib->vba.FabricClock,
541 			mode_lib->vba.DRAMSpeed);
542 
543 #ifdef __DML_VBA_DEBUG__
544 	dml_print("DML::%s: mode_lib->vba.ReturnBusWidth = %f\n", __func__, mode_lib->vba.ReturnBusWidth);
545 	dml_print("DML::%s: mode_lib->vba.DCFCLK = %f\n", __func__, mode_lib->vba.DCFCLK);
546 	dml_print("DML::%s: mode_lib->vba.FabricClock = %f\n", __func__, mode_lib->vba.FabricClock);
547 	dml_print("DML::%s: mode_lib->vba.FabricDatapathToDCNDataReturn = %f\n", __func__,
548 			mode_lib->vba.FabricDatapathToDCNDataReturn);
549 	dml_print("DML::%s: mode_lib->vba.PercentOfIdealSDPPortBWReceivedAfterUrgLatency = %f\n",
550 			__func__, mode_lib->vba.PercentOfIdealSDPPortBWReceivedAfterUrgLatency);
551 	dml_print("DML::%s: mode_lib->vba.DRAMSpeed = %f\n", __func__, mode_lib->vba.DRAMSpeed);
552 	dml_print("DML::%s: mode_lib->vba.NumberOfChannels = %f\n", __func__, mode_lib->vba.NumberOfChannels);
553 	dml_print("DML::%s: mode_lib->vba.DRAMChannelWidth = %f\n", __func__, mode_lib->vba.DRAMChannelWidth);
554 	dml_print("DML::%s: mode_lib->vba.PercentOfIdealDRAMBWReceivedAfterUrgLatencyVMDataOnly = %f\n",
555 			__func__, mode_lib->vba.PercentOfIdealDRAMBWReceivedAfterUrgLatencyVMDataOnly);
556 	dml_print("DML::%s: VMDataOnlyReturnBW = %f\n", __func__, VMDataOnlyReturnBW);
557 	dml_print("DML::%s: ReturnBW = %f\n", __func__, mode_lib->vba.ReturnBW);
558 #endif
559 
560 	v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.HostVMInefficiencyFactor = 1.0;
561 
562 	if (mode_lib->vba.GPUVMEnable && mode_lib->vba.HostVMEnable)
563 		v->dummy_vars
564 			.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation
565 			.HostVMInefficiencyFactor =
566 			mode_lib->vba.ReturnBW / v->dummy_vars
567 				.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation
568 				.VMDataOnlyReturnBW;
569 
570 	mode_lib->vba.TotalDCCActiveDPP = 0;
571 	mode_lib->vba.TotalActiveDPP = 0;
572 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
573 		mode_lib->vba.TotalActiveDPP = mode_lib->vba.TotalActiveDPP + mode_lib->vba.DPPPerPlane[k];
574 		if (mode_lib->vba.DCCEnable[k])
575 			mode_lib->vba.TotalDCCActiveDPP = mode_lib->vba.TotalDCCActiveDPP
576 					+ mode_lib->vba.DPPPerPlane[k];
577 	}
578 
579 	v->UrgentExtraLatency = dml32_CalculateExtraLatency(
580 			mode_lib->vba.RoundTripPingLatencyCycles,
581 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.ReorderBytes,
582 			mode_lib->vba.DCFCLK,
583 			mode_lib->vba.TotalActiveDPP,
584 			mode_lib->vba.PixelChunkSizeInKByte,
585 			mode_lib->vba.TotalDCCActiveDPP,
586 			mode_lib->vba.MetaChunkSize,
587 			mode_lib->vba.ReturnBW,
588 			mode_lib->vba.GPUVMEnable,
589 			mode_lib->vba.HostVMEnable,
590 			mode_lib->vba.NumberOfActiveSurfaces,
591 			mode_lib->vba.DPPPerPlane,
592 			v->dpte_group_bytes,
593 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.HostVMInefficiencyFactor,
594 			mode_lib->vba.HostVMMinPageSize,
595 			mode_lib->vba.HostVMMaxNonCachedPageTableLevels);
596 
597 	mode_lib->vba.TCalc = 24.0 / v->DCFCLKDeepSleep;
598 
599 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
600 		if (mode_lib->vba.BlendingAndTiming[k] == k) {
601 			if (mode_lib->vba.WritebackEnable[k] == true) {
602 				v->WritebackDelay[mode_lib->vba.VoltageLevel][k] = mode_lib->vba.WritebackLatency
603 						+ dml32_CalculateWriteBackDelay(
604 								mode_lib->vba.WritebackPixelFormat[k],
605 								mode_lib->vba.WritebackHRatio[k],
606 								mode_lib->vba.WritebackVRatio[k],
607 								mode_lib->vba.WritebackVTaps[k],
608 								mode_lib->vba.WritebackDestinationWidth[k],
609 								mode_lib->vba.WritebackDestinationHeight[k],
610 								mode_lib->vba.WritebackSourceHeight[k],
611 								mode_lib->vba.HTotal[k]) / mode_lib->vba.DISPCLK;
612 			} else
613 				v->WritebackDelay[mode_lib->vba.VoltageLevel][k] = 0;
614 			for (j = 0; j < mode_lib->vba.NumberOfActiveSurfaces; ++j) {
615 				if (mode_lib->vba.BlendingAndTiming[j] == k &&
616 					mode_lib->vba.WritebackEnable[j] == true) {
617 					v->WritebackDelay[mode_lib->vba.VoltageLevel][k] =
618 						dml_max(v->WritebackDelay[mode_lib->vba.VoltageLevel][k],
619 						mode_lib->vba.WritebackLatency +
620 						dml32_CalculateWriteBackDelay(
621 								mode_lib->vba.WritebackPixelFormat[j],
622 								mode_lib->vba.WritebackHRatio[j],
623 								mode_lib->vba.WritebackVRatio[j],
624 								mode_lib->vba.WritebackVTaps[j],
625 								mode_lib->vba.WritebackDestinationWidth[j],
626 								mode_lib->vba.WritebackDestinationHeight[j],
627 								mode_lib->vba.WritebackSourceHeight[j],
628 								mode_lib->vba.HTotal[k]) / mode_lib->vba.DISPCLK);
629 				}
630 			}
631 		}
632 	}
633 
634 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k)
635 		for (j = 0; j < mode_lib->vba.NumberOfActiveSurfaces; ++j)
636 			if (mode_lib->vba.BlendingAndTiming[k] == j)
637 				v->WritebackDelay[mode_lib->vba.VoltageLevel][k] =
638 						v->WritebackDelay[mode_lib->vba.VoltageLevel][j];
639 
640 	v->UrgentLatency = dml32_CalculateUrgentLatency(mode_lib->vba.UrgentLatencyPixelDataOnly,
641 			mode_lib->vba.UrgentLatencyPixelMixedWithVMData,
642 			mode_lib->vba.UrgentLatencyVMDataOnly,
643 			mode_lib->vba.DoUrgentLatencyAdjustment,
644 			mode_lib->vba.UrgentLatencyAdjustmentFabricClockComponent,
645 			mode_lib->vba.UrgentLatencyAdjustmentFabricClockReference,
646 			mode_lib->vba.FabricClock);
647 
648 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
649 		dml32_CalculateUrgentBurstFactor(mode_lib->vba.UsesMALLForPStateChange[k],
650 				v->swath_width_luma_ub[k],
651 				v->swath_width_chroma_ub[k],
652 				mode_lib->vba.SwathHeightY[k],
653 				mode_lib->vba.SwathHeightC[k],
654 				mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k],
655 				v->UrgentLatency,
656 				mode_lib->vba.CursorBufferSize,
657 				mode_lib->vba.CursorWidth[k][0],
658 				mode_lib->vba.CursorBPP[k][0],
659 				mode_lib->vba.VRatio[k],
660 				mode_lib->vba.VRatioChroma[k],
661 				v->BytePerPixelDETY[k],
662 				v->BytePerPixelDETC[k],
663 				mode_lib->vba.DETBufferSizeY[k],
664 				mode_lib->vba.DETBufferSizeC[k],
665 
666 				/* output */
667 				&v->UrgBurstFactorCursor[k],
668 				&v->UrgBurstFactorLuma[k],
669 				&v->UrgBurstFactorChroma[k],
670 				&v->NoUrgentLatencyHiding[k]);
671 
672 		v->cursor_bw[k] = mode_lib->vba.NumberOfCursors[k] * mode_lib->vba.CursorWidth[k][0] * mode_lib->vba.CursorBPP[k][0] / 8 / (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]) * mode_lib->vba.VRatio[k];
673 	}
674 
675 	v->NotEnoughDETSwathFillLatencyHiding = dml32_CalculateDETSwathFillLatencyHiding(
676 						mode_lib->vba.NumberOfActiveSurfaces,
677 						mode_lib->vba.ReturnBW,
678 						v->UrgentLatency,
679 						mode_lib->vba.SwathHeightY,
680 						mode_lib->vba.SwathHeightC,
681 						v->swath_width_luma_ub,
682 						v->swath_width_chroma_ub,
683 						v->BytePerPixelDETY,
684 						v->BytePerPixelDETC,
685 						mode_lib->vba.DETBufferSizeY,
686 						mode_lib->vba.DETBufferSizeC,
687 						mode_lib->vba.DPPPerPlane,
688 						mode_lib->vba.HTotal,
689 						mode_lib->vba.PixelClock,
690 						mode_lib->vba.VRatio,
691 						mode_lib->vba.VRatioChroma,
692 						mode_lib->vba.UsesMALLForPStateChange,
693 						mode_lib->vba.UseUnboundedRequesting);
694 
695 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
696 		v->MaxVStartupLines[k] = ((mode_lib->vba.Interlace[k] &&
697 				!mode_lib->vba.ProgressiveToInterlaceUnitInOPP) ?
698 				dml_floor((mode_lib->vba.VTotal[k] - mode_lib->vba.VActive[k]) / 2.0, 1.0) :
699 				mode_lib->vba.VTotal[k] - mode_lib->vba.VActive[k]) - dml_max(1.0,
700 				dml_ceil((double) v->WritebackDelay[mode_lib->vba.VoltageLevel][k]
701 				/ (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]), 1));
702 
703 		// Clamp to max OTG vstartup register limit
704 		if (v->MaxVStartupLines[k] > 1023)
705 			v->MaxVStartupLines[k] = 1023;
706 
707 #ifdef __DML_VBA_DEBUG__
708 		dml_print("DML::%s: k=%d MaxVStartupLines = %d\n", __func__, k, v->MaxVStartupLines[k]);
709 		dml_print("DML::%s: k=%d VoltageLevel = %d\n", __func__, k, mode_lib->vba.VoltageLevel);
710 		dml_print("DML::%s: k=%d WritebackDelay = %f\n", __func__,
711 				k, v->WritebackDelay[mode_lib->vba.VoltageLevel][k]);
712 #endif
713 	}
714 
715 	v->MaximumMaxVStartupLines = 0;
716 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k)
717 		v->MaximumMaxVStartupLines = dml_max(v->MaximumMaxVStartupLines, v->MaxVStartupLines[k]);
718 
719 	ImmediateFlipRequirementFinal = false;
720 
721 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
722 		ImmediateFlipRequirementFinal = ImmediateFlipRequirementFinal
723 				|| (mode_lib->vba.ImmediateFlipRequirement[k] == dm_immediate_flip_required);
724 	}
725 #ifdef __DML_VBA_DEBUG__
726 	dml_print("DML::%s: ImmediateFlipRequirementFinal = %d\n", __func__, ImmediateFlipRequirementFinal);
727 #endif
728 	// ModeProgramming will not repeat the schedule calculation using different prefetch mode,
729 	//it is just calcualated once with given prefetch mode
730 	dml32_CalculateMinAndMaxPrefetchMode(
731 			mode_lib->vba.AllowForPStateChangeOrStutterInVBlankFinal,
732 			&mode_lib->vba.MinPrefetchMode,
733 			&mode_lib->vba.MaxPrefetchMode);
734 
735 	v->VStartupLines = __DML_VBA_MIN_VSTARTUP__;
736 
737 	iteration = 0;
738 	MaxTotalRDBandwidth = 0;
739 	NextPrefetchMode = mode_lib->vba.PrefetchModePerState[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb];
740 
741 	do {
742 		MaxTotalRDBandwidth = 0;
743 		DestinationLineTimesForPrefetchLessThan2 = false;
744 		VRatioPrefetchMoreThanMax = false;
745 #ifdef __DML_VBA_DEBUG__
746 		dml_print("DML::%s: Start loop: VStartup = %d\n", __func__, mode_lib->vba.VStartupLines);
747 #endif
748 		for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
749 			/* NOTE PerfetchMode variable is invalid in DAL as per the input received.
750 			 * Hence the direction is to use PrefetchModePerState.
751 			 */
752 			TWait = dml32_CalculateTWait(
753 				mode_lib->vba.PrefetchModePerState[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb],
754 				mode_lib->vba.UsesMALLForPStateChange[k],
755 				mode_lib->vba.SynchronizeDRRDisplaysForUCLKPStateChangeFinal,
756 				mode_lib->vba.DRRDisplay[k],
757 				mode_lib->vba.DRAMClockChangeLatency,
758 				mode_lib->vba.FCLKChangeLatency, v->UrgentLatency,
759 				mode_lib->vba.SREnterPlusExitTime);
760 
761 			memset(&v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe, 0, sizeof(DmlPipe));
762 
763 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.Dppclk = mode_lib->vba.DPPCLK[k];
764 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.Dispclk = mode_lib->vba.DISPCLK;
765 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.PixelClock = mode_lib->vba.PixelClock[k];
766 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.DCFClkDeepSleep = v->DCFCLKDeepSleep;
767 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.DPPPerSurface = mode_lib->vba.DPPPerPlane[k];
768 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.ScalerEnabled = mode_lib->vba.ScalerEnabled[k];
769 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.SourceRotation = mode_lib->vba.SourceRotation[k];
770 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.BlockWidth256BytesY = v->BlockWidth256BytesY[k];
771 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.BlockHeight256BytesY = v->BlockHeight256BytesY[k];
772 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.BlockWidth256BytesC = v->BlockWidth256BytesC[k];
773 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.BlockHeight256BytesC = v->BlockHeight256BytesC[k];
774 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.InterlaceEnable = mode_lib->vba.Interlace[k];
775 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.NumberOfCursors = mode_lib->vba.NumberOfCursors[k];
776 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.VBlank = mode_lib->vba.VTotal[k] - mode_lib->vba.VActive[k];
777 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.HTotal = mode_lib->vba.HTotal[k];
778 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.HActive = mode_lib->vba.HActive[k];
779 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.DCCEnable = mode_lib->vba.DCCEnable[k];
780 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.ODMMode = mode_lib->vba.ODMCombineEnabled[k];
781 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.SourcePixelFormat = mode_lib->vba.SourcePixelFormat[k];
782 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.BytePerPixelY = v->BytePerPixelY[k];
783 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.BytePerPixelC = v->BytePerPixelC[k];
784 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe.ProgressiveToInterlaceUnitInOPP = mode_lib->vba.ProgressiveToInterlaceUnitInOPP;
785 			v->ErrorResult[k] = dml32_CalculatePrefetchSchedule(
786 					v,
787 					k,
788 					v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.HostVMInefficiencyFactor,
789 					&v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.myPipe,
790 					v->DSCDelay[k],
791 					(unsigned int) (v->SwathWidthY[k] / v->HRatio[k]),
792 					dml_min(v->VStartupLines, v->MaxVStartupLines[k]),
793 					v->MaxVStartupLines[k],
794 					v->UrgentLatency,
795 					v->UrgentExtraLatency,
796 					v->TCalc,
797 					v->PDEAndMetaPTEBytesFrame[k],
798 					v->MetaRowByte[k],
799 					v->PixelPTEBytesPerRow[k],
800 					v->PrefetchSourceLinesY[k],
801 					v->SwathWidthY[k],
802 					v->VInitPreFillY[k],
803 					v->MaxNumSwathY[k],
804 					v->PrefetchSourceLinesC[k],
805 					v->SwathWidthC[k],
806 					v->VInitPreFillC[k],
807 					v->MaxNumSwathC[k],
808 					v->swath_width_luma_ub[k],
809 					v->swath_width_chroma_ub[k],
810 					v->SwathHeightY[k],
811 					v->SwathHeightC[k],
812 					TWait,
813 					(v->DRAMSpeedPerState[mode_lib->vba.VoltageLevel] <= MEM_STROBE_FREQ_MHZ ||
814 						v->DCFCLKPerState[mode_lib->vba.VoltageLevel] <= DCFCLK_FREQ_EXTRA_PREFETCH_REQ_MHZ) ?
815 							mode_lib->vba.ip.min_prefetch_in_strobe_us : 0,
816 					mode_lib->vba.PrefetchModePerState[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb] > 0 || mode_lib->vba.DRAMClockChangeRequirementFinal == false,
817 
818 					/* Output */
819 					&v->DSTXAfterScaler[k],
820 					&v->DSTYAfterScaler[k],
821 					&v->DestinationLinesForPrefetch[k],
822 					&v->PrefetchBandwidth[k],
823 					&v->DestinationLinesToRequestVMInVBlank[k],
824 					&v->DestinationLinesToRequestRowInVBlank[k],
825 					&v->VRatioPrefetchY[k],
826 					&v->VRatioPrefetchC[k],
827 					&v->RequiredPrefetchPixDataBWLuma[k],
828 					&v->RequiredPrefetchPixDataBWChroma[k],
829 					&v->NotEnoughTimeForDynamicMetadata[k],
830 					&v->Tno_bw[k], &v->prefetch_vmrow_bw[k],
831 					&v->Tdmdl_vm[k],
832 					&v->Tdmdl[k],
833 					&v->TSetup[k],
834 					&v->VUpdateOffsetPix[k],
835 					&v->VUpdateWidthPix[k],
836 					&v->VReadyOffsetPix[k]);
837 
838 #ifdef __DML_VBA_DEBUG__
839 			dml_print("DML::%s: k=%0d Prefetch calculation errResult=%0d\n",
840 					__func__, k, mode_lib->vba.ErrorResult[k]);
841 #endif
842 			v->VStartup[k] = dml_min(v->VStartupLines, v->MaxVStartupLines[k]);
843 		}
844 
845 		for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
846 			dml32_CalculateUrgentBurstFactor(mode_lib->vba.UsesMALLForPStateChange[k],
847 					v->swath_width_luma_ub[k],
848 					v->swath_width_chroma_ub[k],
849 					mode_lib->vba.SwathHeightY[k],
850 					mode_lib->vba.SwathHeightC[k],
851 					mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k],
852 					v->UrgentLatency,
853 					mode_lib->vba.CursorBufferSize,
854 					mode_lib->vba.CursorWidth[k][0],
855 					mode_lib->vba.CursorBPP[k][0],
856 					v->VRatioPrefetchY[k],
857 					v->VRatioPrefetchC[k],
858 					v->BytePerPixelDETY[k],
859 					v->BytePerPixelDETC[k],
860 					mode_lib->vba.DETBufferSizeY[k],
861 					mode_lib->vba.DETBufferSizeC[k],
862 					/* Output */
863 					&v->UrgBurstFactorCursorPre[k],
864 					&v->UrgBurstFactorLumaPre[k],
865 					&v->UrgBurstFactorChromaPre[k],
866 					&v->NoUrgentLatencyHidingPre[k]);
867 
868 			v->cursor_bw_pre[k] = mode_lib->vba.NumberOfCursors[k] * mode_lib->vba.CursorWidth[k][0] * mode_lib->vba.CursorBPP[k][0] /
869 					8.0 / (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]) * v->VRatioPrefetchY[k];
870 
871 #ifdef __DML_VBA_DEBUG__
872 			dml_print("DML::%s: k=%0d DPPPerSurface=%d\n", __func__, k, mode_lib->vba.DPPPerPlane[k]);
873 			dml_print("DML::%s: k=%0d UrgBurstFactorLuma=%f\n", __func__, k, v->UrgBurstFactorLuma[k]);
874 			dml_print("DML::%s: k=%0d UrgBurstFactorChroma=%f\n", __func__, k, v->UrgBurstFactorChroma[k]);
875 			dml_print("DML::%s: k=%0d UrgBurstFactorLumaPre=%f\n", __func__, k,
876 					v->UrgBurstFactorLumaPre[k]);
877 			dml_print("DML::%s: k=%0d UrgBurstFactorChromaPre=%f\n", __func__, k,
878 					v->UrgBurstFactorChromaPre[k]);
879 
880 			dml_print("DML::%s: k=%0d VRatioPrefetchY=%f\n", __func__, k, v->VRatioPrefetchY[k]);
881 			dml_print("DML::%s: k=%0d VRatioY=%f\n", __func__, k, mode_lib->vba.VRatio[k]);
882 
883 			dml_print("DML::%s: k=%0d prefetch_vmrow_bw=%f\n", __func__, k, v->prefetch_vmrow_bw[k]);
884 			dml_print("DML::%s: k=%0d ReadBandwidthSurfaceLuma=%f\n", __func__, k,
885 					v->ReadBandwidthSurfaceLuma[k]);
886 			dml_print("DML::%s: k=%0d ReadBandwidthSurfaceChroma=%f\n", __func__, k,
887 					v->ReadBandwidthSurfaceChroma[k]);
888 			dml_print("DML::%s: k=%0d cursor_bw=%f\n", __func__, k, v->cursor_bw[k]);
889 			dml_print("DML::%s: k=%0d meta_row_bw=%f\n", __func__, k, v->meta_row_bw[k]);
890 			dml_print("DML::%s: k=%0d dpte_row_bw=%f\n", __func__, k, v->dpte_row_bw[k]);
891 			dml_print("DML::%s: k=%0d RequiredPrefetchPixDataBWLuma=%f\n", __func__, k,
892 					v->RequiredPrefetchPixDataBWLuma[k]);
893 			dml_print("DML::%s: k=%0d RequiredPrefetchPixDataBWChroma=%f\n", __func__, k,
894 					v->RequiredPrefetchPixDataBWChroma[k]);
895 			dml_print("DML::%s: k=%0d cursor_bw_pre=%f\n", __func__, k, v->cursor_bw_pre[k]);
896 			dml_print("DML::%s: k=%0d MaxTotalRDBandwidthNoUrgentBurst=%f\n", __func__, k,
897 					MaxTotalRDBandwidthNoUrgentBurst);
898 #endif
899 			if (v->DestinationLinesForPrefetch[k] < 2)
900 				DestinationLineTimesForPrefetchLessThan2 = true;
901 
902 			if (v->VRatioPrefetchY[k] > v->MaxVRatioPre
903 					|| v->VRatioPrefetchC[k] > v->MaxVRatioPre)
904 				VRatioPrefetchMoreThanMax = true;
905 
906 			//bool DestinationLinesToRequestVMInVBlankEqualOrMoreThan32 = false;
907 			//bool DestinationLinesToRequestRowInVBlankEqualOrMoreThan16 = false;
908 			//if (v->DestinationLinesToRequestVMInVBlank[k] >= 32) {
909 			//    DestinationLinesToRequestVMInVBlankEqualOrMoreThan32 = true;
910 			//}
911 
912 			//if (v->DestinationLinesToRequestRowInVBlank[k] >= 16) {
913 			//    DestinationLinesToRequestRowInVBlankEqualOrMoreThan16 = true;
914 			//}
915 		}
916 
917 		v->FractionOfUrgentBandwidth = MaxTotalRDBandwidthNoUrgentBurst / mode_lib->vba.ReturnBW;
918 
919 #ifdef __DML_VBA_DEBUG__
920 		dml_print("DML::%s: MaxTotalRDBandwidthNoUrgentBurst=%f\n",
921 				__func__, MaxTotalRDBandwidthNoUrgentBurst);
922 		dml_print("DML::%s: ReturnBW=%f\n", __func__, mode_lib->vba.ReturnBW);
923 		dml_print("DML::%s: FractionOfUrgentBandwidth=%f\n",
924 				__func__, mode_lib->vba.FractionOfUrgentBandwidth);
925 #endif
926 
927 		{
928 			dml32_CalculatePrefetchBandwithSupport(
929 					mode_lib->vba.NumberOfActiveSurfaces,
930 					mode_lib->vba.ReturnBW,
931 					v->NoUrgentLatencyHidingPre,
932 					v->ReadBandwidthSurfaceLuma,
933 					v->ReadBandwidthSurfaceChroma,
934 					v->RequiredPrefetchPixDataBWLuma,
935 					v->RequiredPrefetchPixDataBWChroma,
936 					v->cursor_bw,
937 					v->meta_row_bw,
938 					v->dpte_row_bw,
939 					v->cursor_bw_pre,
940 					v->prefetch_vmrow_bw,
941 					mode_lib->vba.DPPPerPlane,
942 					v->UrgBurstFactorLuma,
943 					v->UrgBurstFactorChroma,
944 					v->UrgBurstFactorCursor,
945 					v->UrgBurstFactorLumaPre,
946 					v->UrgBurstFactorChromaPre,
947 					v->UrgBurstFactorCursorPre,
948 					v->PrefetchBandwidth,
949 					v->VRatio,
950 					v->MaxVRatioPre,
951 
952 					/* output */
953 					&MaxTotalRDBandwidth,
954 					&v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_single[0],
955 					&v->PrefetchModeSupported);
956 		}
957 
958 		for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k)
959 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector[k] = 1.0;
960 
961 		{
962 			dml32_CalculatePrefetchBandwithSupport(mode_lib->vba.NumberOfActiveSurfaces,
963 					mode_lib->vba.ReturnBW,
964 					v->NoUrgentLatencyHidingPre,
965 					v->ReadBandwidthSurfaceLuma,
966 					v->ReadBandwidthSurfaceChroma,
967 					v->RequiredPrefetchPixDataBWLuma,
968 					v->RequiredPrefetchPixDataBWChroma,
969 					v->cursor_bw,
970 					v->meta_row_bw,
971 					v->dpte_row_bw,
972 					v->cursor_bw_pre,
973 					v->prefetch_vmrow_bw,
974 					mode_lib->vba.DPPPerPlane,
975 					v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector,
976 					v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector,
977 					v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector,
978 					v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector,
979 					v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector,
980 					v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector,
981 					v->PrefetchBandwidth,
982 					v->VRatio,
983 					v->MaxVRatioPre,
984 
985 					/* output */
986 					&v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_single[0],
987 					&v->FractionOfUrgentBandwidth,
988 					&v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_boolean);
989 		}
990 
991 		if (VRatioPrefetchMoreThanMax != false || DestinationLineTimesForPrefetchLessThan2 != false) {
992 			v->PrefetchModeSupported = false;
993 		}
994 
995 		for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
996 			if (v->ErrorResult[k] == true || v->NotEnoughTimeForDynamicMetadata[k]) {
997 				v->PrefetchModeSupported = false;
998 			}
999 		}
1000 
1001 		if (v->PrefetchModeSupported == true && mode_lib->vba.ImmediateFlipSupport == true) {
1002 			mode_lib->vba.BandwidthAvailableForImmediateFlip = dml32_CalculateBandwidthAvailableForImmediateFlip(
1003 					mode_lib->vba.NumberOfActiveSurfaces,
1004 					mode_lib->vba.ReturnBW,
1005 					v->ReadBandwidthSurfaceLuma,
1006 					v->ReadBandwidthSurfaceChroma,
1007 					v->RequiredPrefetchPixDataBWLuma,
1008 					v->RequiredPrefetchPixDataBWChroma,
1009 					v->cursor_bw,
1010 					v->cursor_bw_pre,
1011 					mode_lib->vba.DPPPerPlane,
1012 					v->UrgBurstFactorLuma,
1013 					v->UrgBurstFactorChroma,
1014 					v->UrgBurstFactorCursor,
1015 					v->UrgBurstFactorLumaPre,
1016 					v->UrgBurstFactorChromaPre,
1017 					v->UrgBurstFactorCursorPre);
1018 
1019 			mode_lib->vba.TotImmediateFlipBytes = 0;
1020 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
1021 				if (mode_lib->vba.ImmediateFlipRequirement[k] != dm_immediate_flip_not_required) {
1022 					mode_lib->vba.TotImmediateFlipBytes = mode_lib->vba.TotImmediateFlipBytes
1023 							+ mode_lib->vba.DPPPerPlane[k]
1024 									* (v->PDEAndMetaPTEBytesFrame[k]
1025 											+ v->MetaRowByte[k]);
1026 					if (v->use_one_row_for_frame_flip[k][0][0]) {
1027 						mode_lib->vba.TotImmediateFlipBytes =
1028 								mode_lib->vba.TotImmediateFlipBytes
1029 										+ 2 * v->PixelPTEBytesPerRow[k];
1030 					} else {
1031 						mode_lib->vba.TotImmediateFlipBytes =
1032 								mode_lib->vba.TotImmediateFlipBytes
1033 										+ v->PixelPTEBytesPerRow[k];
1034 					}
1035 				}
1036 			}
1037 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
1038 				dml32_CalculateFlipSchedule(v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.HostVMInefficiencyFactor,
1039 						v->UrgentExtraLatency,
1040 						v->UrgentLatency,
1041 						mode_lib->vba.GPUVMMaxPageTableLevels,
1042 						mode_lib->vba.HostVMEnable,
1043 						mode_lib->vba.HostVMMaxNonCachedPageTableLevels,
1044 						mode_lib->vba.GPUVMEnable,
1045 						mode_lib->vba.HostVMMinPageSize,
1046 						v->PDEAndMetaPTEBytesFrame[k],
1047 						v->MetaRowByte[k],
1048 						v->PixelPTEBytesPerRow[k],
1049 						mode_lib->vba.BandwidthAvailableForImmediateFlip,
1050 						mode_lib->vba.TotImmediateFlipBytes,
1051 						mode_lib->vba.SourcePixelFormat[k],
1052 						mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k],
1053 						mode_lib->vba.VRatio[k],
1054 						mode_lib->vba.VRatioChroma[k],
1055 						v->Tno_bw[k],
1056 						mode_lib->vba.DCCEnable[k],
1057 						v->dpte_row_height[k],
1058 						v->meta_row_height[k],
1059 						v->dpte_row_height_chroma[k],
1060 						v->meta_row_height_chroma[k],
1061 						v->Use_One_Row_For_Frame_Flip[k],
1062 
1063 						/* Output */
1064 						&v->DestinationLinesToRequestVMInImmediateFlip[k],
1065 						&v->DestinationLinesToRequestRowInImmediateFlip[k],
1066 						&v->final_flip_bw[k],
1067 						&v->ImmediateFlipSupportedForPipe[k]);
1068 			}
1069 
1070 			{
1071 				dml32_CalculateImmediateFlipBandwithSupport(mode_lib->vba.NumberOfActiveSurfaces,
1072 						mode_lib->vba.ReturnBW,
1073 						mode_lib->vba.ImmediateFlipRequirement,
1074 						v->final_flip_bw,
1075 						v->ReadBandwidthSurfaceLuma,
1076 						v->ReadBandwidthSurfaceChroma,
1077 						v->RequiredPrefetchPixDataBWLuma,
1078 						v->RequiredPrefetchPixDataBWChroma,
1079 						v->cursor_bw,
1080 						v->meta_row_bw,
1081 						v->dpte_row_bw,
1082 						v->cursor_bw_pre,
1083 						v->prefetch_vmrow_bw,
1084 						mode_lib->vba.DPPPerPlane,
1085 						v->UrgBurstFactorLuma,
1086 						v->UrgBurstFactorChroma,
1087 						v->UrgBurstFactorCursor,
1088 						v->UrgBurstFactorLumaPre,
1089 						v->UrgBurstFactorChromaPre,
1090 						v->UrgBurstFactorCursorPre,
1091 
1092 						/* output */
1093 						&v->total_dcn_read_bw_with_flip,    // Single  *TotalBandwidth
1094 						&v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_single[0],                        // Single  *FractionOfUrgentBandwidth
1095 						&v->ImmediateFlipSupported);        // Boolean *ImmediateFlipBandwidthSupport
1096 
1097 				dml32_CalculateImmediateFlipBandwithSupport(mode_lib->vba.NumberOfActiveSurfaces,
1098 						mode_lib->vba.ReturnBW,
1099 						mode_lib->vba.ImmediateFlipRequirement,
1100 						v->final_flip_bw,
1101 						v->ReadBandwidthSurfaceLuma,
1102 						v->ReadBandwidthSurfaceChroma,
1103 						v->RequiredPrefetchPixDataBWLuma,
1104 						v->RequiredPrefetchPixDataBWChroma,
1105 						v->cursor_bw,
1106 						v->meta_row_bw,
1107 						v->dpte_row_bw,
1108 						v->cursor_bw_pre,
1109 						v->prefetch_vmrow_bw,
1110 						mode_lib->vba.DPPPerPlane,
1111 						v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector,
1112 						v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector,
1113 						v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector,
1114 						v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector,
1115 						v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector,
1116 						v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_unit_vector,
1117 
1118 						/* output */
1119 						&v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_single[1],                                // Single  *TotalBandwidth
1120 						&v->FractionOfUrgentBandwidthImmediateFlip, // Single  *FractionOfUrgentBandwidth
1121 						&v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_boolean);                              // Boolean *ImmediateFlipBandwidthSupport
1122 			}
1123 
1124 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
1125 				if (mode_lib->vba.ImmediateFlipRequirement[k] != dm_immediate_flip_not_required && v->ImmediateFlipSupportedForPipe[k] == false) {
1126 					v->ImmediateFlipSupported = false;
1127 #ifdef __DML_VBA_DEBUG__
1128 					dml_print("DML::%s: Pipe %0d not supporting iflip\n", __func__, k);
1129 #endif
1130 				}
1131 			}
1132 		} else {
1133 			v->ImmediateFlipSupported = false;
1134 		}
1135 
1136 		/* consider flip support is okay if the flip bw is ok or (when user does't require a iflip and there is no host vm) */
1137 		v->PrefetchAndImmediateFlipSupported = (v->PrefetchModeSupported == true &&
1138 				((!mode_lib->vba.ImmediateFlipSupport && !mode_lib->vba.HostVMEnable && !ImmediateFlipRequirementFinal) ||
1139 						v->ImmediateFlipSupported)) ? true : false;
1140 
1141 #ifdef __DML_VBA_DEBUG__
1142 		dml_print("DML::%s: PrefetchModeSupported = %d\n", __func__, locals->PrefetchModeSupported);
1143 		for (uint k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k)
1144 			dml_print("DML::%s: ImmediateFlipRequirement[%d] = %d\n", __func__, k,  mode_lib->vba.ImmediateFlipRequirement[k] == dm_immediate_flip_required);
1145 		dml_print("DML::%s: ImmediateFlipSupported = %d\n", __func__, locals->ImmediateFlipSupported);
1146 		dml_print("DML::%s: ImmediateFlipSupport = %d\n", __func__, mode_lib->vba.ImmediateFlipSupport);
1147 		dml_print("DML::%s: HostVMEnable = %d\n", __func__, mode_lib->vba.HostVMEnable);
1148 		dml_print("DML::%s: PrefetchAndImmediateFlipSupported = %d\n", __func__, locals->PrefetchAndImmediateFlipSupported);
1149 		dml_print("DML::%s: Done loop: Vstartup=%d, Max Vstartup=%d\n", __func__, locals->VStartupLines, locals->MaximumMaxVStartupLines);
1150 #endif
1151 
1152 		v->VStartupLines = v->VStartupLines + 1;
1153 
1154 		if (v->VStartupLines > v->MaximumMaxVStartupLines) {
1155 #ifdef __DML_VBA_DEBUG__
1156 			dml_print("DML::%s: Vstartup exceeds max vstartup, exiting loop\n", __func__);
1157 #endif
1158 			break; // VBA_DELTA: Implementation divergence! Gabe is *still* iterating across prefetch modes which we don't care to do
1159 		}
1160 		iteration++;
1161 		if (iteration > 2500) {
1162 #ifdef __DML_VBA_DEBUG__
1163 			dml_print("DML::%s: too many errors, exit now\n", __func__);
1164 			assert(0);
1165 #endif
1166 		}
1167 	} while (!(v->PrefetchAndImmediateFlipSupported || NextPrefetchMode > mode_lib->vba.MaxPrefetchMode));
1168 
1169 
1170 	if (v->VStartupLines <= v->MaximumMaxVStartupLines) {
1171 #ifdef __DML_VBA_DEBUG__
1172 		dml_print("DML::%s: Good, Prefetch and flip scheduling found solution at VStartupLines=%d\n", __func__, locals->VStartupLines-1);
1173 #endif
1174 	}
1175 
1176 
1177 	//Watermarks and NB P-State/DRAM Clock Change Support
1178 	{
1179 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.mmSOCParameters.UrgentLatency = v->UrgentLatency;
1180 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.mmSOCParameters.ExtraLatency = v->UrgentExtraLatency;
1181 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.mmSOCParameters.WritebackLatency = mode_lib->vba.WritebackLatency;
1182 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.mmSOCParameters.DRAMClockChangeLatency = mode_lib->vba.DRAMClockChangeLatency;
1183 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.mmSOCParameters.FCLKChangeLatency = mode_lib->vba.FCLKChangeLatency;
1184 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.mmSOCParameters.SRExitTime = mode_lib->vba.SRExitTime;
1185 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.mmSOCParameters.SREnterPlusExitTime = mode_lib->vba.SREnterPlusExitTime;
1186 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.mmSOCParameters.SRExitZ8Time = mode_lib->vba.SRExitZ8Time;
1187 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.mmSOCParameters.SREnterPlusExitZ8Time = mode_lib->vba.SREnterPlusExitZ8Time;
1188 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.mmSOCParameters.USRRetrainingLatency = mode_lib->vba.USRRetrainingLatency;
1189 		v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.mmSOCParameters.SMNLatency = mode_lib->vba.SMNLatency;
1190 
1191 		dml32_CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport(
1192 			v,
1193 			v->PrefetchModePerState[v->VoltageLevel][v->maxMpcComb],
1194 			v->DCFCLK,
1195 			v->ReturnBW,
1196 			v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.mmSOCParameters,
1197 			v->SOCCLK,
1198 			v->DCFCLKDeepSleep,
1199 			v->DETBufferSizeY,
1200 			v->DETBufferSizeC,
1201 			v->SwathHeightY,
1202 			v->SwathHeightC,
1203 			v->SwathWidthY,
1204 			v->SwathWidthC,
1205 			v->DPPPerPlane,
1206 			v->BytePerPixelDETY,
1207 			v->BytePerPixelDETC,
1208 			v->DSTXAfterScaler,
1209 			v->DSTYAfterScaler,
1210 			v->UnboundedRequestEnabled,
1211 			v->CompressedBufferSizeInkByte,
1212 
1213 			/* Output */
1214 			&v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_dramchange_support,
1215 			v->MaxActiveDRAMClockChangeLatencySupported,
1216 			v->SubViewportLinesNeededInMALL,
1217 			&v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_fclkchange_support,
1218 			&v->MinActiveFCLKChangeLatencySupported,
1219 			&v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_USRRetrainingSupport,
1220 			mode_lib->vba.ActiveDRAMClockChangeLatencyMargin);
1221 
1222 		/* DCN32 has a new struct Watermarks (typedef) which is used to store
1223 		 * calculated WM values. Copy over values from struct to vba varaibles
1224 		 * to ensure that the DCN32 getters return the correct value.
1225 		 */
1226 		v->UrgentWatermark = v->Watermark.UrgentWatermark;
1227 		v->WritebackUrgentWatermark = v->Watermark.WritebackUrgentWatermark;
1228 		v->DRAMClockChangeWatermark = v->Watermark.DRAMClockChangeWatermark;
1229 		v->WritebackDRAMClockChangeWatermark = v->Watermark.WritebackDRAMClockChangeWatermark;
1230 		v->StutterExitWatermark = v->Watermark.StutterExitWatermark;
1231 		v->StutterEnterPlusExitWatermark = v->Watermark.StutterEnterPlusExitWatermark;
1232 		v->Z8StutterExitWatermark = v->Watermark.Z8StutterExitWatermark;
1233 		v->Z8StutterEnterPlusExitWatermark = v->Watermark.Z8StutterEnterPlusExitWatermark;
1234 
1235 		for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
1236 			if (mode_lib->vba.WritebackEnable[k] == true) {
1237 				v->WritebackAllowDRAMClockChangeEndPosition[k] = dml_max(0,
1238 						v->VStartup[k] * mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]
1239 								- v->Watermark.WritebackDRAMClockChangeWatermark);
1240 				v->WritebackAllowFCLKChangeEndPosition[k] = dml_max(0,
1241 						v->VStartup[k] * mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]
1242 								- v->Watermark.WritebackFCLKChangeWatermark);
1243 			} else {
1244 				v->WritebackAllowDRAMClockChangeEndPosition[k] = 0;
1245 				v->WritebackAllowFCLKChangeEndPosition[k] = 0;
1246 			}
1247 		}
1248 	}
1249 
1250 	//Display Pipeline Delivery Time in Prefetch, Groups
1251 	dml32_CalculatePixelDeliveryTimes(
1252 			mode_lib->vba.NumberOfActiveSurfaces,
1253 			mode_lib->vba.VRatio,
1254 			mode_lib->vba.VRatioChroma,
1255 			v->VRatioPrefetchY,
1256 			v->VRatioPrefetchC,
1257 			v->swath_width_luma_ub,
1258 			v->swath_width_chroma_ub,
1259 			mode_lib->vba.DPPPerPlane,
1260 			mode_lib->vba.HRatio,
1261 			mode_lib->vba.HRatioChroma,
1262 			mode_lib->vba.PixelClock,
1263 			v->PSCL_THROUGHPUT_LUMA,
1264 			v->PSCL_THROUGHPUT_CHROMA,
1265 			mode_lib->vba.DPPCLK,
1266 			v->BytePerPixelC,
1267 			mode_lib->vba.SourceRotation,
1268 			mode_lib->vba.NumberOfCursors,
1269 			mode_lib->vba.CursorWidth,
1270 			mode_lib->vba.CursorBPP,
1271 			v->BlockWidth256BytesY,
1272 			v->BlockHeight256BytesY,
1273 			v->BlockWidth256BytesC,
1274 			v->BlockHeight256BytesC,
1275 
1276 			/* Output */
1277 			v->DisplayPipeLineDeliveryTimeLuma,
1278 			v->DisplayPipeLineDeliveryTimeChroma,
1279 			v->DisplayPipeLineDeliveryTimeLumaPrefetch,
1280 			v->DisplayPipeLineDeliveryTimeChromaPrefetch,
1281 			v->DisplayPipeRequestDeliveryTimeLuma,
1282 			v->DisplayPipeRequestDeliveryTimeChroma,
1283 			v->DisplayPipeRequestDeliveryTimeLumaPrefetch,
1284 			v->DisplayPipeRequestDeliveryTimeChromaPrefetch,
1285 			v->CursorRequestDeliveryTime,
1286 			v->CursorRequestDeliveryTimePrefetch);
1287 
1288 	dml32_CalculateMetaAndPTETimes(v->Use_One_Row_For_Frame,
1289 			mode_lib->vba.NumberOfActiveSurfaces,
1290 			mode_lib->vba.GPUVMEnable,
1291 			mode_lib->vba.MetaChunkSize,
1292 			mode_lib->vba.MinMetaChunkSizeBytes,
1293 			mode_lib->vba.HTotal,
1294 			mode_lib->vba.VRatio,
1295 			mode_lib->vba.VRatioChroma,
1296 			v->DestinationLinesToRequestRowInVBlank,
1297 			v->DestinationLinesToRequestRowInImmediateFlip,
1298 			mode_lib->vba.DCCEnable,
1299 			mode_lib->vba.PixelClock,
1300 			v->BytePerPixelY,
1301 			v->BytePerPixelC,
1302 			mode_lib->vba.SourceRotation,
1303 			v->dpte_row_height,
1304 			v->dpte_row_height_chroma,
1305 			v->meta_row_width,
1306 			v->meta_row_width_chroma,
1307 			v->meta_row_height,
1308 			v->meta_row_height_chroma,
1309 			v->meta_req_width,
1310 			v->meta_req_width_chroma,
1311 			v->meta_req_height,
1312 			v->meta_req_height_chroma,
1313 			v->dpte_group_bytes,
1314 			v->PTERequestSizeY,
1315 			v->PTERequestSizeC,
1316 			v->PixelPTEReqWidthY,
1317 			v->PixelPTEReqHeightY,
1318 			v->PixelPTEReqWidthC,
1319 			v->PixelPTEReqHeightC,
1320 			v->dpte_row_width_luma_ub,
1321 			v->dpte_row_width_chroma_ub,
1322 
1323 			/* Output */
1324 			v->DST_Y_PER_PTE_ROW_NOM_L,
1325 			v->DST_Y_PER_PTE_ROW_NOM_C,
1326 			v->DST_Y_PER_META_ROW_NOM_L,
1327 			v->DST_Y_PER_META_ROW_NOM_C,
1328 			v->TimePerMetaChunkNominal,
1329 			v->TimePerChromaMetaChunkNominal,
1330 			v->TimePerMetaChunkVBlank,
1331 			v->TimePerChromaMetaChunkVBlank,
1332 			v->TimePerMetaChunkFlip,
1333 			v->TimePerChromaMetaChunkFlip,
1334 			v->time_per_pte_group_nom_luma,
1335 			v->time_per_pte_group_vblank_luma,
1336 			v->time_per_pte_group_flip_luma,
1337 			v->time_per_pte_group_nom_chroma,
1338 			v->time_per_pte_group_vblank_chroma,
1339 			v->time_per_pte_group_flip_chroma);
1340 
1341 	dml32_CalculateVMGroupAndRequestTimes(
1342 			mode_lib->vba.NumberOfActiveSurfaces,
1343 			mode_lib->vba.GPUVMEnable,
1344 			mode_lib->vba.GPUVMMaxPageTableLevels,
1345 			mode_lib->vba.HTotal,
1346 			v->BytePerPixelC,
1347 			v->DestinationLinesToRequestVMInVBlank,
1348 			v->DestinationLinesToRequestVMInImmediateFlip,
1349 			mode_lib->vba.DCCEnable,
1350 			mode_lib->vba.PixelClock,
1351 			v->dpte_row_width_luma_ub,
1352 			v->dpte_row_width_chroma_ub,
1353 			v->vm_group_bytes,
1354 			v->dpde0_bytes_per_frame_ub_l,
1355 			v->dpde0_bytes_per_frame_ub_c,
1356 			v->meta_pte_bytes_per_frame_ub_l,
1357 			v->meta_pte_bytes_per_frame_ub_c,
1358 
1359 			/* Output */
1360 			v->TimePerVMGroupVBlank,
1361 			v->TimePerVMGroupFlip,
1362 			v->TimePerVMRequestVBlank,
1363 			v->TimePerVMRequestFlip);
1364 
1365 	// Min TTUVBlank
1366 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
1367 		if (mode_lib->vba.PrefetchModePerState[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb] == 0) {
1368 			v->MinTTUVBlank[k] = dml_max4(v->Watermark.DRAMClockChangeWatermark,
1369 					v->Watermark.FCLKChangeWatermark, v->Watermark.StutterEnterPlusExitWatermark,
1370 					v->Watermark.UrgentWatermark);
1371 		} else if (mode_lib->vba.PrefetchModePerState[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb]
1372 				== 1) {
1373 			v->MinTTUVBlank[k] = dml_max3(v->Watermark.FCLKChangeWatermark,
1374 					v->Watermark.StutterEnterPlusExitWatermark, v->Watermark.UrgentWatermark);
1375 		} else if (mode_lib->vba.PrefetchModePerState[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb]
1376 				== 2) {
1377 			v->MinTTUVBlank[k] = dml_max(v->Watermark.StutterEnterPlusExitWatermark,
1378 					v->Watermark.UrgentWatermark);
1379 		} else {
1380 			v->MinTTUVBlank[k] = v->Watermark.UrgentWatermark;
1381 		}
1382 		if (!mode_lib->vba.DynamicMetadataEnable[k])
1383 			v->MinTTUVBlank[k] = mode_lib->vba.TCalc + v->MinTTUVBlank[k];
1384 	}
1385 
1386 	// DCC Configuration
1387 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
1388 #ifdef __DML_VBA_DEBUG__
1389 		dml_print("DML::%s: Calculate DCC configuration for surface k=%d\n", __func__, k);
1390 #endif
1391 		dml32_CalculateDCCConfiguration(
1392 				mode_lib->vba.DCCEnable[k],
1393 				mode_lib->vba.DCCProgrammingAssumesScanDirectionUnknownFinal,
1394 				mode_lib->vba.SourcePixelFormat[k], mode_lib->vba.SurfaceWidthY[k],
1395 				mode_lib->vba.SurfaceWidthC[k],
1396 				mode_lib->vba.SurfaceHeightY[k],
1397 				mode_lib->vba.SurfaceHeightC[k],
1398 				mode_lib->vba.nomDETInKByte,
1399 				v->BlockHeight256BytesY[k],
1400 				v->BlockHeight256BytesC[k],
1401 				mode_lib->vba.SurfaceTiling[k],
1402 				v->BytePerPixelY[k],
1403 				v->BytePerPixelC[k],
1404 				v->BytePerPixelDETY[k],
1405 				v->BytePerPixelDETC[k],
1406 				(enum dm_rotation_angle) mode_lib->vba.SourceScan[k],
1407 				/* Output */
1408 				&v->DCCYMaxUncompressedBlock[k],
1409 				&v->DCCCMaxUncompressedBlock[k],
1410 				&v->DCCYMaxCompressedBlock[k],
1411 				&v->DCCCMaxCompressedBlock[k],
1412 				&v->DCCYIndependentBlock[k],
1413 				&v->DCCCIndependentBlock[k]);
1414 	}
1415 
1416 	// VStartup Adjustment
1417 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
1418 		bool isInterlaceTiming;
1419 		double Tvstartup_margin = (v->MaxVStartupLines[k] - v->VStartup[k]) * mode_lib->vba.HTotal[k]
1420 				/ mode_lib->vba.PixelClock[k];
1421 #ifdef __DML_VBA_DEBUG__
1422 		dml_print("DML::%s: k=%d, MinTTUVBlank = %f (before vstartup margin)\n", __func__, k,
1423 				v->MinTTUVBlank[k]);
1424 #endif
1425 
1426 		v->MinTTUVBlank[k] = v->MinTTUVBlank[k] + Tvstartup_margin;
1427 
1428 #ifdef __DML_VBA_DEBUG__
1429 		dml_print("DML::%s: k=%d, Tvstartup_margin = %f\n", __func__, k, Tvstartup_margin);
1430 		dml_print("DML::%s: k=%d, MaxVStartupLines = %d\n", __func__, k, v->MaxVStartupLines[k]);
1431 		dml_print("DML::%s: k=%d, VStartup = %d\n", __func__, k, v->VStartup[k]);
1432 		dml_print("DML::%s: k=%d, MinTTUVBlank = %f\n", __func__, k, v->MinTTUVBlank[k]);
1433 #endif
1434 
1435 		v->Tdmdl[k] = v->Tdmdl[k] + Tvstartup_margin;
1436 		if (mode_lib->vba.DynamicMetadataEnable[k] && mode_lib->vba.DynamicMetadataVMEnabled)
1437 			v->Tdmdl_vm[k] = v->Tdmdl_vm[k] + Tvstartup_margin;
1438 
1439 		isInterlaceTiming = (mode_lib->vba.Interlace[k] &&
1440 				!mode_lib->vba.ProgressiveToInterlaceUnitInOPP);
1441 
1442 		v->MIN_DST_Y_NEXT_START[k] = ((isInterlaceTiming ? dml_floor((mode_lib->vba.VTotal[k] -
1443 						mode_lib->vba.VFrontPorch[k]) / 2.0, 1.0) :
1444 						mode_lib->vba.VTotal[k]) - mode_lib->vba.VFrontPorch[k])
1445 						+ dml_max(1.0,
1446 						dml_ceil(v->WritebackDelay[mode_lib->vba.VoltageLevel][k]
1447 						/ (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]), 1.0))
1448 						+ dml_floor(4.0 * v->TSetup[k] / (mode_lib->vba.HTotal[k]
1449 						/ mode_lib->vba.PixelClock[k]), 1.0) / 4.0;
1450 
1451 		v->VStartup[k] = (isInterlaceTiming ? (2 * v->MaxVStartupLines[k]) : v->MaxVStartupLines[k]);
1452 
1453 		if (((v->VUpdateOffsetPix[k] + v->VUpdateWidthPix[k] + v->VReadyOffsetPix[k])
1454 			/ mode_lib->vba.HTotal[k]) <= (isInterlaceTiming ? dml_floor((mode_lib->vba.VTotal[k]
1455 			- mode_lib->vba.VActive[k] - mode_lib->vba.VFrontPorch[k] - v->VStartup[k]) / 2.0, 1.0) :
1456 			(int) (mode_lib->vba.VTotal[k] - mode_lib->vba.VActive[k]
1457 		       - mode_lib->vba.VFrontPorch[k] - v->VStartup[k]))) {
1458 			v->VREADY_AT_OR_AFTER_VSYNC[k] = true;
1459 		} else {
1460 			v->VREADY_AT_OR_AFTER_VSYNC[k] = false;
1461 		}
1462 #ifdef __DML_VBA_DEBUG__
1463 		dml_print("DML::%s: k=%d, VStartup = %d (max)\n", __func__, k, v->VStartup[k]);
1464 		dml_print("DML::%s: k=%d, VUpdateOffsetPix = %d\n", __func__, k, v->VUpdateOffsetPix[k]);
1465 		dml_print("DML::%s: k=%d, VUpdateWidthPix = %d\n", __func__, k, v->VUpdateWidthPix[k]);
1466 		dml_print("DML::%s: k=%d, VReadyOffsetPix = %d\n", __func__, k, v->VReadyOffsetPix[k]);
1467 		dml_print("DML::%s: k=%d, HTotal = %d\n", __func__, k, mode_lib->vba.HTotal[k]);
1468 		dml_print("DML::%s: k=%d, VTotal = %d\n", __func__, k, mode_lib->vba.VTotal[k]);
1469 		dml_print("DML::%s: k=%d, VActive = %d\n", __func__, k, mode_lib->vba.VActive[k]);
1470 		dml_print("DML::%s: k=%d, VFrontPorch = %d\n", __func__, k, mode_lib->vba.VFrontPorch[k]);
1471 		dml_print("DML::%s: k=%d, VStartup = %d\n", __func__, k, v->VStartup[k]);
1472 		dml_print("DML::%s: k=%d, TSetup = %f\n", __func__, k, v->TSetup[k]);
1473 		dml_print("DML::%s: k=%d, MIN_DST_Y_NEXT_START = %f\n", __func__, k, v->MIN_DST_Y_NEXT_START[k]);
1474 		dml_print("DML::%s: k=%d, VREADY_AT_OR_AFTER_VSYNC = %d\n", __func__, k,
1475 				v->VREADY_AT_OR_AFTER_VSYNC[k]);
1476 #endif
1477 	}
1478 
1479 	{
1480 		//Maximum Bandwidth Used
1481 		for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
1482 			if (mode_lib->vba.WritebackEnable[k] == true
1483 					&& mode_lib->vba.WritebackPixelFormat[k] == dm_444_32) {
1484 				WRBandwidth = mode_lib->vba.WritebackDestinationWidth[k]
1485 						* mode_lib->vba.WritebackDestinationHeight[k]
1486 						/ (mode_lib->vba.HTotal[k] * mode_lib->vba.WritebackSourceHeight[k]
1487 								/ mode_lib->vba.PixelClock[k]) * 4;
1488 			} else if (mode_lib->vba.WritebackEnable[k] == true) {
1489 				WRBandwidth = mode_lib->vba.WritebackDestinationWidth[k]
1490 						* mode_lib->vba.WritebackDestinationHeight[k]
1491 						/ (mode_lib->vba.HTotal[k] * mode_lib->vba.WritebackSourceHeight[k]
1492 								/ mode_lib->vba.PixelClock[k]) * 8;
1493 			}
1494 			TotalWRBandwidth = TotalWRBandwidth + WRBandwidth;
1495 		}
1496 
1497 		v->TotalDataReadBandwidth = 0;
1498 		for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
1499 			v->TotalDataReadBandwidth = v->TotalDataReadBandwidth + v->ReadBandwidthSurfaceLuma[k]
1500 					+ v->ReadBandwidthSurfaceChroma[k];
1501 #ifdef __DML_VBA_DEBUG__
1502 			dml_print("DML::%s: k=%d, TotalDataReadBandwidth = %f\n",
1503 					__func__, k, v->TotalDataReadBandwidth);
1504 			dml_print("DML::%s: k=%d, ReadBandwidthSurfaceLuma = %f\n",
1505 					__func__, k, v->ReadBandwidthSurfaceLuma[k]);
1506 			dml_print("DML::%s: k=%d, ReadBandwidthSurfaceChroma = %f\n",
1507 					__func__, k, v->ReadBandwidthSurfaceChroma[k]);
1508 #endif
1509 		}
1510 	}
1511 
1512 	// Stutter Efficiency
1513 	dml32_CalculateStutterEfficiency(v->CompressedBufferSizeInkByte,
1514 			mode_lib->vba.UsesMALLForPStateChange,
1515 			v->UnboundedRequestEnabled,
1516 			mode_lib->vba.MetaFIFOSizeInKEntries,
1517 			mode_lib->vba.ZeroSizeBufferEntries,
1518 			mode_lib->vba.PixelChunkSizeInKByte,
1519 			mode_lib->vba.NumberOfActiveSurfaces,
1520 			mode_lib->vba.ROBBufferSizeInKByte,
1521 			v->TotalDataReadBandwidth,
1522 			mode_lib->vba.DCFCLK,
1523 			mode_lib->vba.ReturnBW,
1524 			v->CompbufReservedSpace64B,
1525 			v->CompbufReservedSpaceZs,
1526 			mode_lib->vba.SRExitTime,
1527 			mode_lib->vba.SRExitZ8Time,
1528 			mode_lib->vba.SynchronizeTimingsFinal,
1529 			mode_lib->vba.BlendingAndTiming,
1530 			v->Watermark.StutterEnterPlusExitWatermark,
1531 			v->Watermark.Z8StutterEnterPlusExitWatermark,
1532 			mode_lib->vba.ProgressiveToInterlaceUnitInOPP,
1533 			mode_lib->vba.Interlace,
1534 			v->MinTTUVBlank, mode_lib->vba.DPPPerPlane,
1535 			mode_lib->vba.DETBufferSizeY,
1536 			v->BytePerPixelY,
1537 			v->BytePerPixelDETY,
1538 			v->SwathWidthY,
1539 			mode_lib->vba.SwathHeightY,
1540 			mode_lib->vba.SwathHeightC,
1541 			mode_lib->vba.DCCRateLuma,
1542 			mode_lib->vba.DCCRateChroma,
1543 			mode_lib->vba.DCCFractionOfZeroSizeRequestsLuma,
1544 			mode_lib->vba.DCCFractionOfZeroSizeRequestsChroma,
1545 			mode_lib->vba.HTotal, mode_lib->vba.VTotal,
1546 			mode_lib->vba.PixelClock,
1547 			mode_lib->vba.VRatio,
1548 			mode_lib->vba.SourceRotation,
1549 			v->BlockHeight256BytesY,
1550 			v->BlockWidth256BytesY,
1551 			v->BlockHeight256BytesC,
1552 			v->BlockWidth256BytesC,
1553 			v->DCCYMaxUncompressedBlock,
1554 			v->DCCCMaxUncompressedBlock,
1555 			mode_lib->vba.VActive,
1556 			mode_lib->vba.DCCEnable,
1557 			mode_lib->vba.WritebackEnable,
1558 			v->ReadBandwidthSurfaceLuma,
1559 			v->ReadBandwidthSurfaceChroma,
1560 			v->meta_row_bw,
1561 			v->dpte_row_bw,
1562 			/* Output */
1563 			&v->StutterEfficiencyNotIncludingVBlank,
1564 			&v->StutterEfficiency,
1565 			&v->NumberOfStutterBurstsPerFrame,
1566 			&v->Z8StutterEfficiencyNotIncludingVBlank,
1567 			&v->Z8StutterEfficiency,
1568 			&v->Z8NumberOfStutterBurstsPerFrame,
1569 			&v->StutterPeriod,
1570 			&v->DCHUBBUB_ARB_CSTATE_MAX_CAP_MODE);
1571 
1572 #ifdef __DML_VBA_ALLOW_DELTA__
1573 	{
1574 		unsigned int dummy_integer[1];
1575 
1576 		// Calculate z8 stutter eff assuming 0 reserved space
1577 		dml32_CalculateStutterEfficiency(v->CompressedBufferSizeInkByte,
1578 				mode_lib->vba.UsesMALLForPStateChange,
1579 				v->UnboundedRequestEnabled,
1580 				mode_lib->vba.MetaFIFOSizeInKEntries,
1581 				mode_lib->vba.ZeroSizeBufferEntries,
1582 				mode_lib->vba.PixelChunkSizeInKByte,
1583 				mode_lib->vba.NumberOfActiveSurfaces,
1584 				mode_lib->vba.ROBBufferSizeInKByte,
1585 				v->TotalDataReadBandwidth,
1586 				mode_lib->vba.DCFCLK,
1587 				mode_lib->vba.ReturnBW,
1588 				0, //CompbufReservedSpace64B,
1589 				0, //CompbufReservedSpaceZs,
1590 				mode_lib->vba.SRExitTime,
1591 				mode_lib->vba.SRExitZ8Time,
1592 				mode_lib->vba.SynchronizeTimingsFinal,
1593 				mode_lib->vba.BlendingAndTiming,
1594 				v->Watermark.StutterEnterPlusExitWatermark,
1595 				v->Watermark.Z8StutterEnterPlusExitWatermark,
1596 				mode_lib->vba.ProgressiveToInterlaceUnitInOPP,
1597 				mode_lib->vba.Interlace,
1598 				v->MinTTUVBlank,
1599 				mode_lib->vba.DPPPerPlane,
1600 				mode_lib->vba.DETBufferSizeY,
1601 				v->BytePerPixelY, v->BytePerPixelDETY,
1602 				v->SwathWidthY, mode_lib->vba.SwathHeightY,
1603 				mode_lib->vba.SwathHeightC,
1604 				mode_lib->vba.DCCRateLuma,
1605 				mode_lib->vba.DCCRateChroma,
1606 				mode_lib->vba.DCCFractionOfZeroSizeRequestsLuma,
1607 				mode_lib->vba.DCCFractionOfZeroSizeRequestsChroma,
1608 				mode_lib->vba.HTotal,
1609 				mode_lib->vba.VTotal,
1610 				mode_lib->vba.PixelClock,
1611 				mode_lib->vba.VRatio,
1612 				mode_lib->vba.SourceRotation,
1613 				v->BlockHeight256BytesY,
1614 				v->BlockWidth256BytesY,
1615 				v->BlockHeight256BytesC,
1616 				v->BlockWidth256BytesC,
1617 				v->DCCYMaxUncompressedBlock,
1618 				v->DCCCMaxUncompressedBlock,
1619 				mode_lib->vba.VActive,
1620 				mode_lib->vba.DCCEnable,
1621 				mode_lib->vba.WritebackEnable,
1622 				v->ReadBandwidthSurfaceLuma,
1623 				v->ReadBandwidthSurfaceChroma,
1624 				v->meta_row_bw, v->dpte_row_bw,
1625 
1626 				/* Output */
1627 				&v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_single[0],
1628 				&v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_single[1],
1629 				&dummy_integer[0],
1630 				&v->Z8StutterEfficiencyNotIncludingVBlankBestCase,
1631 				&v->Z8StutterEfficiencyBestCase,
1632 				&v->Z8NumberOfStutterBurstsPerFrameBestCase,
1633 				&v->StutterPeriodBestCase,
1634 				&v->dummy_vars.DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation.dummy_boolean);
1635 	}
1636 #else
1637 	v->Z8StutterEfficiencyNotIncludingVBlankBestCase = v->Z8StutterEfficiencyNotIncludingVBlank;
1638 	v->Z8StutterEfficiencyBestCase = v->Z8StutterEfficiency;
1639 	v->Z8NumberOfStutterBurstsPerFrameBestCase = v->Z8NumberOfStutterBurstsPerFrame;
1640 	v->StutterPeriodBestCase = v->StutterPeriod;
1641 #endif
1642 
1643 #ifdef __DML_VBA_DEBUG__
1644 	dml_print("DML::%s: --- END ---\n", __func__);
1645 #endif
1646 }
1647 
mode_support_configuration(struct vba_vars_st * v,struct display_mode_lib * mode_lib)1648 static void mode_support_configuration(struct vba_vars_st *v,
1649 				  struct display_mode_lib *mode_lib)
1650 {
1651 	int i, j, start_state;
1652 
1653 	if (mode_lib->validate_max_state)
1654 		start_state = v->soc.num_states - 1;
1655 	else
1656 		start_state = 0;
1657 
1658 	for (i = v->soc.num_states - 1; i >= start_state; i--) {
1659 		for (j = 0; j < 2; j++) {
1660 			if (mode_lib->vba.ScaleRatioAndTapsSupport == true
1661 				&& mode_lib->vba.SourceFormatPixelAndScanSupport == true
1662 				&& mode_lib->vba.ViewportSizeSupport[i][j] == true
1663 				&& !mode_lib->vba.LinkRateDoesNotMatchDPVersion
1664 				&& !mode_lib->vba.LinkRateForMultistreamNotIndicated
1665 				&& !mode_lib->vba.BPPForMultistreamNotIndicated
1666 				&& !mode_lib->vba.MultistreamWithHDMIOreDP
1667 				&& !mode_lib->vba.ExceededMultistreamSlots[i]
1668 				&& !mode_lib->vba.MSOOrODMSplitWithNonDPLink
1669 				&& !mode_lib->vba.NotEnoughLanesForMSO
1670 				&& mode_lib->vba.LinkCapacitySupport[i] == true && !mode_lib->vba.P2IWith420
1671 				//&& !mode_lib->vba.DSCOnlyIfNecessaryWithBPP
1672 				&& !mode_lib->vba.DSC422NativeNotSupported
1673 				&& !mode_lib->vba.MPCCombineMethodIncompatible
1674 				&& mode_lib->vba.ODMCombine2To1SupportCheckOK[i] == true
1675 				&& mode_lib->vba.ODMCombine4To1SupportCheckOK[i] == true
1676 				&& mode_lib->vba.NotEnoughDSCUnits[i] == false
1677 				&& !mode_lib->vba.NotEnoughDSCSlices[i]
1678 				&& !mode_lib->vba.ImmediateFlipOrHostVMAndPStateWithMALLFullFrameOrPhantomPipe
1679 				&& !mode_lib->vba.InvalidCombinationOfMALLUseForPStateAndStaticScreen
1680 				&& mode_lib->vba.DSCCLKRequiredMoreThanSupported[i] == false
1681 				&& mode_lib->vba.PixelsPerLinePerDSCUnitSupport[i]
1682 				&& mode_lib->vba.DTBCLKRequiredMoreThanSupported[i] == false
1683 				&& !mode_lib->vba.InvalidCombinationOfMALLUseForPState
1684 				&& !mode_lib->vba.ImmediateFlipRequiredButTheRequirementForEachSurfaceIsNotSpecified
1685 				&& mode_lib->vba.ROBSupport[i][j] == true
1686 				&& mode_lib->vba.DISPCLK_DPPCLK_Support[i][j] == true
1687 				&& mode_lib->vba.TotalAvailablePipesSupport[i][j] == true
1688 				&& mode_lib->vba.NumberOfOTGSupport == true
1689 				&& mode_lib->vba.NumberOfHDMIFRLSupport == true
1690 				&& mode_lib->vba.EnoughWritebackUnits == true
1691 				&& mode_lib->vba.WritebackLatencySupport == true
1692 				&& mode_lib->vba.WritebackScaleRatioAndTapsSupport == true
1693 				&& mode_lib->vba.CursorSupport == true && mode_lib->vba.PitchSupport == true
1694 				&& mode_lib->vba.ViewportExceedsSurface == false
1695 				&& mode_lib->vba.PrefetchSupported[i][j] == true
1696 				&& mode_lib->vba.VActiveBandwithSupport[i][j] == true
1697 				&& mode_lib->vba.DynamicMetadataSupported[i][j] == true
1698 				&& mode_lib->vba.TotalVerticalActiveBandwidthSupport[i][j] == true
1699 				&& mode_lib->vba.VRatioInPrefetchSupported[i][j] == true
1700 				&& mode_lib->vba.PTEBufferSizeNotExceeded[i][j] == true
1701 				&& mode_lib->vba.DCCMetaBufferSizeNotExceeded[i][j] == true
1702 				&& mode_lib->vba.NonsupportedDSCInputBPC == false
1703 				&& !mode_lib->vba.ExceededMALLSize
1704 				&& (mode_lib->vba.NotEnoughDETSwathFillLatencyHidingPerState[i][j] == false
1705 				|| i == v->soc.num_states - 1)
1706 				&& ((mode_lib->vba.HostVMEnable == false
1707 				&& !mode_lib->vba.ImmediateFlipRequiredFinal)
1708 				|| mode_lib->vba.ImmediateFlipSupportedForState[i][j])
1709 				&& (!mode_lib->vba.DRAMClockChangeRequirementFinal
1710 				|| i == v->soc.num_states - 1
1711 				|| mode_lib->vba.DRAMClockChangeSupport[i][j] != dm_dram_clock_change_unsupported)
1712 				&& (!mode_lib->vba.FCLKChangeRequirementFinal || i == v->soc.num_states - 1
1713 				|| mode_lib->vba.FCLKChangeSupport[i][j] != dm_fclock_change_unsupported)
1714 				&& (!mode_lib->vba.USRRetrainingRequiredFinal
1715 				|| mode_lib->vba.USRRetrainingSupport[i][j])) {
1716 				mode_lib->vba.ModeSupport[i][j] = true;
1717 			} else {
1718 				mode_lib->vba.ModeSupport[i][j] = false;
1719 			}
1720 		}
1721 	}
1722 }
1723 
dml32_ModeSupportAndSystemConfigurationFull(struct display_mode_lib * mode_lib)1724 void dml32_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_lib)
1725 {
1726 	struct vba_vars_st *v = &mode_lib->vba;
1727 	int i, j, start_state;
1728 	unsigned int k, m;
1729 	unsigned int MaximumMPCCombine;
1730 	unsigned int NumberOfNonCombinedSurfaceOfMaximumBandwidth;
1731 	unsigned int TotalSlots;
1732 	bool CompBufReservedSpaceNeedAdjustment;
1733 	bool CompBufReservedSpaceNeedAdjustmentSingleDPP;
1734 
1735 #ifdef __DML_VBA_DEBUG__
1736 	dml_print("DML::%s: called\n", __func__);
1737 #endif
1738 
1739 	/*MODE SUPPORT, VOLTAGE STATE AND SOC CONFIGURATION*/
1740 	if (mode_lib->validate_max_state)
1741 		start_state = v->soc.num_states - 1;
1742 	else
1743 		start_state = 0;
1744 
1745 	/*Scale Ratio, taps Support Check*/
1746 
1747 	mode_lib->vba.ScaleRatioAndTapsSupport = true;
1748 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
1749 		if (mode_lib->vba.ScalerEnabled[k] == false
1750 				&& ((mode_lib->vba.SourcePixelFormat[k] != dm_444_64
1751 						&& mode_lib->vba.SourcePixelFormat[k] != dm_444_32
1752 						&& mode_lib->vba.SourcePixelFormat[k] != dm_444_16
1753 						&& mode_lib->vba.SourcePixelFormat[k] != dm_mono_16
1754 						&& mode_lib->vba.SourcePixelFormat[k] != dm_mono_8
1755 						&& mode_lib->vba.SourcePixelFormat[k] != dm_rgbe
1756 						&& mode_lib->vba.SourcePixelFormat[k] != dm_rgbe_alpha)
1757 						|| mode_lib->vba.HRatio[k] != 1.0 || mode_lib->vba.htaps[k] != 1.0
1758 						|| mode_lib->vba.VRatio[k] != 1.0 || mode_lib->vba.vtaps[k] != 1.0)) {
1759 			mode_lib->vba.ScaleRatioAndTapsSupport = false;
1760 		} else if (mode_lib->vba.vtaps[k] < 1.0 || mode_lib->vba.vtaps[k] > 8.0 || mode_lib->vba.htaps[k] < 1.0
1761 				|| mode_lib->vba.htaps[k] > 8.0
1762 				|| (mode_lib->vba.htaps[k] > 1.0 && (mode_lib->vba.htaps[k] % 2) == 1)
1763 				|| mode_lib->vba.HRatio[k] > mode_lib->vba.MaxHSCLRatio
1764 				|| mode_lib->vba.VRatio[k] > mode_lib->vba.MaxVSCLRatio
1765 				|| mode_lib->vba.HRatio[k] > mode_lib->vba.htaps[k]
1766 				|| mode_lib->vba.VRatio[k] > mode_lib->vba.vtaps[k]
1767 				|| (mode_lib->vba.SourcePixelFormat[k] != dm_444_64
1768 						&& mode_lib->vba.SourcePixelFormat[k] != dm_444_32
1769 						&& mode_lib->vba.SourcePixelFormat[k] != dm_444_16
1770 						&& mode_lib->vba.SourcePixelFormat[k] != dm_mono_16
1771 						&& mode_lib->vba.SourcePixelFormat[k] != dm_mono_8
1772 						&& mode_lib->vba.SourcePixelFormat[k] != dm_rgbe
1773 						&& (mode_lib->vba.VTAPsChroma[k] < 1
1774 								|| mode_lib->vba.VTAPsChroma[k] > 8
1775 								|| mode_lib->vba.HTAPsChroma[k] < 1
1776 								|| mode_lib->vba.HTAPsChroma[k] > 8
1777 								|| (mode_lib->vba.HTAPsChroma[k] > 1
1778 										&& mode_lib->vba.HTAPsChroma[k] % 2
1779 												== 1)
1780 								|| mode_lib->vba.HRatioChroma[k]
1781 										> mode_lib->vba.MaxHSCLRatio
1782 								|| mode_lib->vba.VRatioChroma[k]
1783 										> mode_lib->vba.MaxVSCLRatio
1784 								|| mode_lib->vba.HRatioChroma[k]
1785 										> mode_lib->vba.HTAPsChroma[k]
1786 								|| mode_lib->vba.VRatioChroma[k]
1787 										> mode_lib->vba.VTAPsChroma[k]))) {
1788 			mode_lib->vba.ScaleRatioAndTapsSupport = false;
1789 		}
1790 	}
1791 
1792 	/*Source Format, Pixel Format and Scan Support Check*/
1793 	mode_lib->vba.SourceFormatPixelAndScanSupport = true;
1794 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
1795 		if (mode_lib->vba.SurfaceTiling[k] == dm_sw_linear
1796 			&& (!(!IsVertical((enum dm_rotation_angle) mode_lib->vba.SourceScan[k]))
1797 				|| mode_lib->vba.DCCEnable[k] == true)) {
1798 			mode_lib->vba.SourceFormatPixelAndScanSupport = false;
1799 		}
1800 	}
1801 
1802 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
1803 		dml32_CalculateBytePerPixelAndBlockSizes(
1804 				mode_lib->vba.SourcePixelFormat[k],
1805 				mode_lib->vba.SurfaceTiling[k],
1806 
1807 				/* Output */
1808 				&mode_lib->vba.BytePerPixelY[k],
1809 				&mode_lib->vba.BytePerPixelC[k],
1810 				&mode_lib->vba.BytePerPixelInDETY[k],
1811 				&mode_lib->vba.BytePerPixelInDETC[k],
1812 				&mode_lib->vba.Read256BlockHeightY[k],
1813 				&mode_lib->vba.Read256BlockHeightC[k],
1814 				&mode_lib->vba.Read256BlockWidthY[k],
1815 				&mode_lib->vba.Read256BlockWidthC[k],
1816 				&mode_lib->vba.MacroTileHeightY[k],
1817 				&mode_lib->vba.MacroTileHeightC[k],
1818 				&mode_lib->vba.MacroTileWidthY[k],
1819 				&mode_lib->vba.MacroTileWidthC[k]);
1820 	}
1821 
1822 	/*Bandwidth Support Check*/
1823 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
1824 		if (!IsVertical(mode_lib->vba.SourceRotation[k])) {
1825 			v->SwathWidthYSingleDPP[k] = mode_lib->vba.ViewportWidth[k];
1826 			v->SwathWidthCSingleDPP[k] = mode_lib->vba.ViewportWidthChroma[k];
1827 		} else {
1828 			v->SwathWidthYSingleDPP[k] = mode_lib->vba.ViewportHeight[k];
1829 			v->SwathWidthCSingleDPP[k] = mode_lib->vba.ViewportHeightChroma[k];
1830 		}
1831 	}
1832 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
1833 		v->ReadBandwidthLuma[k] = v->SwathWidthYSingleDPP[k] * dml_ceil(v->BytePerPixelInDETY[k], 1.0)
1834 				/ (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]) * mode_lib->vba.VRatio[k];
1835 		v->ReadBandwidthChroma[k] = v->SwathWidthYSingleDPP[k] / 2 * dml_ceil(v->BytePerPixelInDETC[k], 2.0)
1836 				/ (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]) * mode_lib->vba.VRatio[k]
1837 				/ 2.0;
1838 	}
1839 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
1840 		if (mode_lib->vba.WritebackEnable[k] == true && mode_lib->vba.WritebackPixelFormat[k] == dm_444_64) {
1841 			v->WriteBandwidth[k] = mode_lib->vba.WritebackDestinationWidth[k]
1842 					* mode_lib->vba.WritebackDestinationHeight[k]
1843 					/ (mode_lib->vba.WritebackSourceHeight[k] * mode_lib->vba.HTotal[k]
1844 							/ mode_lib->vba.PixelClock[k]) * 8.0;
1845 		} else if (mode_lib->vba.WritebackEnable[k] == true) {
1846 			v->WriteBandwidth[k] = mode_lib->vba.WritebackDestinationWidth[k]
1847 					* mode_lib->vba.WritebackDestinationHeight[k]
1848 					/ (mode_lib->vba.WritebackSourceHeight[k] * mode_lib->vba.HTotal[k]
1849 							/ mode_lib->vba.PixelClock[k]) * 4.0;
1850 		} else {
1851 			v->WriteBandwidth[k] = 0.0;
1852 		}
1853 	}
1854 
1855 	/*Writeback Latency support check*/
1856 
1857 	mode_lib->vba.WritebackLatencySupport = true;
1858 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
1859 		if (mode_lib->vba.WritebackEnable[k] == true
1860 				&& (v->WriteBandwidth[k]
1861 						> mode_lib->vba.WritebackInterfaceBufferSize * 1024
1862 								/ mode_lib->vba.WritebackLatency)) {
1863 			mode_lib->vba.WritebackLatencySupport = false;
1864 		}
1865 	}
1866 
1867 	/*Writeback Mode Support Check*/
1868 	mode_lib->vba.EnoughWritebackUnits = true;
1869 	mode_lib->vba.TotalNumberOfActiveWriteback = 0;
1870 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
1871 		if (mode_lib->vba.WritebackEnable[k] == true)
1872 			mode_lib->vba.TotalNumberOfActiveWriteback = mode_lib->vba.TotalNumberOfActiveWriteback + 1;
1873 	}
1874 
1875 	if (mode_lib->vba.TotalNumberOfActiveWriteback > mode_lib->vba.MaxNumWriteback)
1876 		mode_lib->vba.EnoughWritebackUnits = false;
1877 
1878 	/*Writeback Scale Ratio and Taps Support Check*/
1879 	mode_lib->vba.WritebackScaleRatioAndTapsSupport = true;
1880 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
1881 		if (mode_lib->vba.WritebackEnable[k] == true) {
1882 			if (mode_lib->vba.WritebackHRatio[k] > mode_lib->vba.WritebackMaxHSCLRatio
1883 					|| mode_lib->vba.WritebackVRatio[k] > mode_lib->vba.WritebackMaxVSCLRatio
1884 					|| mode_lib->vba.WritebackHRatio[k] < mode_lib->vba.WritebackMinHSCLRatio
1885 					|| mode_lib->vba.WritebackVRatio[k] < mode_lib->vba.WritebackMinVSCLRatio
1886 					|| mode_lib->vba.WritebackHTaps[k] > mode_lib->vba.WritebackMaxHSCLTaps
1887 					|| mode_lib->vba.WritebackVTaps[k] > mode_lib->vba.WritebackMaxVSCLTaps
1888 					|| mode_lib->vba.WritebackHRatio[k] > mode_lib->vba.WritebackHTaps[k]
1889 					|| mode_lib->vba.WritebackVRatio[k] > mode_lib->vba.WritebackVTaps[k]
1890 					|| (mode_lib->vba.WritebackHTaps[k] > 2.0
1891 							&& ((mode_lib->vba.WritebackHTaps[k] % 2) == 1))) {
1892 				mode_lib->vba.WritebackScaleRatioAndTapsSupport = false;
1893 			}
1894 			if (2.0 * mode_lib->vba.WritebackDestinationWidth[k] * (mode_lib->vba.WritebackVTaps[k] - 1)
1895 					* 57 > mode_lib->vba.WritebackLineBufferSize) {
1896 				mode_lib->vba.WritebackScaleRatioAndTapsSupport = false;
1897 			}
1898 		}
1899 	}
1900 
1901 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
1902 		dml32_CalculateSinglePipeDPPCLKAndSCLThroughput(mode_lib->vba.HRatio[k], mode_lib->vba.HRatioChroma[k],
1903 				mode_lib->vba.VRatio[k], mode_lib->vba.VRatioChroma[k],
1904 				mode_lib->vba.MaxDCHUBToPSCLThroughput, mode_lib->vba.MaxPSCLToLBThroughput,
1905 				mode_lib->vba.PixelClock[k], mode_lib->vba.SourcePixelFormat[k],
1906 				mode_lib->vba.htaps[k], mode_lib->vba.HTAPsChroma[k], mode_lib->vba.vtaps[k],
1907 				mode_lib->vba.VTAPsChroma[k],
1908 				/* Output */
1909 				&mode_lib->vba.PSCL_FACTOR[k], &mode_lib->vba.PSCL_FACTOR_CHROMA[k],
1910 				&mode_lib->vba.MinDPPCLKUsingSingleDPP[k]);
1911 	}
1912 
1913 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
1914 
1915 		if (mode_lib->vba.SurfaceTiling[k] == dm_sw_linear) {
1916 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MaximumSwathWidthSupportLuma = 8192;
1917 		} else if (!IsVertical(mode_lib->vba.SourceRotation[k]) && v->BytePerPixelC[k] > 0
1918 				&& mode_lib->vba.SourcePixelFormat[k] != dm_rgbe_alpha) {
1919 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MaximumSwathWidthSupportLuma = 7680;
1920 		} else if (IsVertical(mode_lib->vba.SourceRotation[k]) && v->BytePerPixelC[k] > 0
1921 				&& mode_lib->vba.SourcePixelFormat[k] != dm_rgbe_alpha) {
1922 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MaximumSwathWidthSupportLuma = 4320;
1923 		} else if (mode_lib->vba.SourcePixelFormat[k] == dm_rgbe_alpha) {
1924 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MaximumSwathWidthSupportLuma = 3840;
1925 		} else if (IsVertical(mode_lib->vba.SourceRotation[k]) && v->BytePerPixelY[k] == 8 &&
1926 				mode_lib->vba.DCCEnable[k] == true) {
1927 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MaximumSwathWidthSupportLuma = 3072;
1928 		} else {
1929 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MaximumSwathWidthSupportLuma = 6144;
1930 		}
1931 
1932 		if (mode_lib->vba.SourcePixelFormat[k] == dm_420_8 || mode_lib->vba.SourcePixelFormat[k] == dm_420_10
1933 				|| mode_lib->vba.SourcePixelFormat[k] == dm_420_12) {
1934 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MaximumSwathWidthSupportChroma = v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MaximumSwathWidthSupportLuma / 2.0;
1935 		} else {
1936 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MaximumSwathWidthSupportChroma = v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MaximumSwathWidthSupportLuma;
1937 		}
1938 		v->MaximumSwathWidthInLineBufferLuma = mode_lib->vba.LineBufferSizeFinal
1939 				* dml_max(mode_lib->vba.HRatio[k], 1.0) / mode_lib->vba.LBBitPerPixel[k]
1940 				/ (mode_lib->vba.vtaps[k] + dml_max(dml_ceil(mode_lib->vba.VRatio[k], 1.0) - 2, 0.0));
1941 		if (v->BytePerPixelC[k] == 0.0) {
1942 			v->MaximumSwathWidthInLineBufferChroma = 0;
1943 		} else {
1944 			v->MaximumSwathWidthInLineBufferChroma = mode_lib->vba.LineBufferSizeFinal
1945 					* dml_max(mode_lib->vba.HRatioChroma[k], 1.0) / mode_lib->vba.LBBitPerPixel[k]
1946 					/ (mode_lib->vba.VTAPsChroma[k]
1947 							+ dml_max(dml_ceil(mode_lib->vba.VRatioChroma[k], 1.0) - 2,
1948 									0.0));
1949 		}
1950 		v->MaximumSwathWidthLuma[k] = dml_min(v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MaximumSwathWidthSupportLuma,
1951 				v->MaximumSwathWidthInLineBufferLuma);
1952 		v->MaximumSwathWidthChroma[k] = dml_min(v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MaximumSwathWidthSupportChroma,
1953 				v->MaximumSwathWidthInLineBufferChroma);
1954 	}
1955 
1956 	dml32_CalculateSwathAndDETConfiguration(
1957 			mode_lib->vba.DETSizeOverride,
1958 			mode_lib->vba.UsesMALLForPStateChange,
1959 			mode_lib->vba.ConfigReturnBufferSizeInKByte,
1960 			mode_lib->vba.MaxTotalDETInKByte,
1961 			mode_lib->vba.MinCompressedBufferSizeInKByte,
1962 			1, /* ForceSingleDPP */
1963 			mode_lib->vba.NumberOfActiveSurfaces,
1964 			mode_lib->vba.nomDETInKByte,
1965 			mode_lib->vba.UseUnboundedRequesting,
1966 			mode_lib->vba.DisableUnboundRequestIfCompBufReservedSpaceNeedAdjustment,
1967 			mode_lib->vba.ip.pixel_chunk_size_kbytes,
1968 			mode_lib->vba.ip.rob_buffer_size_kbytes,
1969 			mode_lib->vba.CompressedBufferSegmentSizeInkByteFinal,
1970 			mode_lib->vba.Output,
1971 			mode_lib->vba.ReadBandwidthLuma,
1972 			mode_lib->vba.ReadBandwidthChroma,
1973 			mode_lib->vba.MaximumSwathWidthLuma,
1974 			mode_lib->vba.MaximumSwathWidthChroma,
1975 			mode_lib->vba.SourceRotation,
1976 			mode_lib->vba.ViewportStationary,
1977 			mode_lib->vba.SourcePixelFormat,
1978 			mode_lib->vba.SurfaceTiling,
1979 			mode_lib->vba.ViewportWidth,
1980 			mode_lib->vba.ViewportHeight,
1981 			mode_lib->vba.ViewportXStartY,
1982 			mode_lib->vba.ViewportYStartY,
1983 			mode_lib->vba.ViewportXStartC,
1984 			mode_lib->vba.ViewportYStartC,
1985 			mode_lib->vba.SurfaceWidthY,
1986 			mode_lib->vba.SurfaceWidthC,
1987 			mode_lib->vba.SurfaceHeightY,
1988 			mode_lib->vba.SurfaceHeightC,
1989 			mode_lib->vba.Read256BlockHeightY,
1990 			mode_lib->vba.Read256BlockHeightC,
1991 			mode_lib->vba.Read256BlockWidthY,
1992 			mode_lib->vba.Read256BlockWidthC,
1993 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_odm_mode,
1994 			mode_lib->vba.BlendingAndTiming,
1995 			mode_lib->vba.BytePerPixelY,
1996 			mode_lib->vba.BytePerPixelC,
1997 			mode_lib->vba.BytePerPixelInDETY,
1998 			mode_lib->vba.BytePerPixelInDETC,
1999 			mode_lib->vba.HActive,
2000 			mode_lib->vba.HRatio,
2001 			mode_lib->vba.HRatioChroma,
2002 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[0], /*  Integer DPPPerSurface[] */
2003 
2004 			/* Output */
2005 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[1], /* Long            swath_width_luma_ub[] */
2006 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[2], /* Long            swath_width_chroma_ub[]  */
2007 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_double_array[0], /* Long            SwathWidth[]  */
2008 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_double_array[1], /* Long            SwathWidthChroma[]  */
2009 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[3], /* Integer         SwathHeightY[]  */
2010 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[4], /* Integer         SwathHeightC[]  */
2011 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[5], /* Long            DETBufferSizeInKByte[]  */
2012 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[6], /* Long            DETBufferSizeY[]  */
2013 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[7], /* Long            DETBufferSizeC[]  */
2014 			&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_boolean_array[0][0], /* bool           *UnboundedRequestEnabled  */
2015 			&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[0][0], /* Long           *CompressedBufferSizeInkByte  */
2016 			&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[1][0], /* Long           *CompBufReservedSpaceKBytes */
2017 			&CompBufReservedSpaceNeedAdjustmentSingleDPP,
2018 			mode_lib->vba.SingleDPPViewportSizeSupportPerSurface,/* bool ViewportSizeSupportPerSurface[] */
2019 			&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_boolean_array[1][0]); /* bool           *ViewportSizeSupport */
2020 
2021 	v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MPCCombineMethodAsNeededForPStateChangeAndVoltage = false;
2022 	v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MPCCombineMethodAsPossible = false;
2023 
2024 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2025 		if (mode_lib->vba.MPCCombineUse[k] == dm_mpc_reduce_voltage_and_clocks)
2026 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MPCCombineMethodAsNeededForPStateChangeAndVoltage = true;
2027 		if (mode_lib->vba.MPCCombineUse[k] == dm_mpc_always_when_possible)
2028 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MPCCombineMethodAsPossible = true;
2029 	}
2030 	mode_lib->vba.MPCCombineMethodIncompatible = v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MPCCombineMethodAsNeededForPStateChangeAndVoltage
2031 			&& v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MPCCombineMethodAsPossible;
2032 
2033 	for (i = start_state; i < v->soc.num_states; i++) {
2034 		for (j = 0; j < 2; j++) {
2035 			mode_lib->vba.TotalNumberOfActiveDPP[i][j] = 0;
2036 			mode_lib->vba.TotalAvailablePipesSupport[i][j] = true;
2037 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.ODMModeNoDSC = dm_odm_combine_mode_disabled;
2038 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.ODMModeDSC = dm_odm_combine_mode_disabled;
2039 
2040 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2041 				dml32_CalculateODMMode(
2042 						mode_lib->vba.MaximumPixelsPerLinePerDSCUnit,
2043 						mode_lib->vba.HActive[k],
2044 						mode_lib->vba.OutputFormat[k],
2045 						mode_lib->vba.Output[k],
2046 						mode_lib->vba.ODMUse[k],
2047 						mode_lib->vba.MaxDispclk[i],
2048 						mode_lib->vba.MaxDispclk[v->soc.num_states - 1],
2049 						false,
2050 						mode_lib->vba.TotalNumberOfActiveDPP[i][j],
2051 						mode_lib->vba.MaxNumDPP,
2052 						mode_lib->vba.PixelClock[k],
2053 						mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading,
2054 						mode_lib->vba.DISPCLKRampingMargin,
2055 						mode_lib->vba.DISPCLKDPPCLKVCOSpeed,
2056 						mode_lib->vba.NumberOfDSCSlices[k],
2057 
2058 						/* Output */
2059 						&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalAvailablePipesSupportNoDSC,
2060 						&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.NumberOfDPPNoDSC,
2061 						&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.ODMModeNoDSC,
2062 						&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.RequiredDISPCLKPerSurfaceNoDSC);
2063 
2064 				dml32_CalculateODMMode(
2065 						mode_lib->vba.MaximumPixelsPerLinePerDSCUnit,
2066 						mode_lib->vba.HActive[k],
2067 						mode_lib->vba.OutputFormat[k],
2068 						mode_lib->vba.Output[k],
2069 						mode_lib->vba.ODMUse[k],
2070 						mode_lib->vba.MaxDispclk[i],
2071 						mode_lib->vba.MaxDispclk[v->soc.num_states - 1],
2072 						true,
2073 						mode_lib->vba.TotalNumberOfActiveDPP[i][j],
2074 						mode_lib->vba.MaxNumDPP,
2075 						mode_lib->vba.PixelClock[k],
2076 						mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading,
2077 						mode_lib->vba.DISPCLKRampingMargin,
2078 						mode_lib->vba.DISPCLKDPPCLKVCOSpeed,
2079 						mode_lib->vba.NumberOfDSCSlices[k],
2080 
2081 						/* Output */
2082 						&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalAvailablePipesSupportDSC,
2083 						&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.NumberOfDPPDSC,
2084 						&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.ODMModeDSC,
2085 						&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.RequiredDISPCLKPerSurfaceDSC);
2086 
2087 				dml32_CalculateOutputLink(
2088 						mode_lib->vba.PHYCLKPerState[i],
2089 						mode_lib->vba.PHYCLKD18PerState[i],
2090 						mode_lib->vba.PHYCLKD32PerState[i],
2091 						mode_lib->vba.Downspreading,
2092 						(mode_lib->vba.BlendingAndTiming[k] == k),
2093 						mode_lib->vba.Output[k],
2094 						mode_lib->vba.OutputFormat[k],
2095 						mode_lib->vba.HTotal[k],
2096 						mode_lib->vba.HActive[k],
2097 						mode_lib->vba.PixelClockBackEnd[k],
2098 						mode_lib->vba.ForcedOutputLinkBPP[k],
2099 						mode_lib->vba.DSCInputBitPerComponent[k],
2100 						mode_lib->vba.NumberOfDSCSlices[k],
2101 						mode_lib->vba.AudioSampleRate[k],
2102 						mode_lib->vba.AudioSampleLayout[k],
2103 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.ODMModeNoDSC,
2104 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.ODMModeDSC,
2105 						mode_lib->vba.DSCEnable[k],
2106 						mode_lib->vba.OutputLinkDPLanes[k],
2107 						mode_lib->vba.OutputLinkDPRate[k],
2108 
2109 						/* Output */
2110 						&mode_lib->vba.RequiresDSC[i][k],
2111 						&mode_lib->vba.RequiresFEC[i][k],
2112 						&mode_lib->vba.OutputBppPerState[i][k],
2113 						&mode_lib->vba.OutputTypePerState[i][k],
2114 						&mode_lib->vba.OutputRatePerState[i][k],
2115 						&mode_lib->vba.RequiredSlots[i][k]);
2116 
2117 				if (mode_lib->vba.RequiresDSC[i][k] == false) {
2118 					mode_lib->vba.ODMCombineEnablePerState[i][k] = v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.ODMModeNoDSC;
2119 					mode_lib->vba.RequiredDISPCLKPerSurface[i][j][k] =
2120 							v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.RequiredDISPCLKPerSurfaceNoDSC;
2121 					if (!v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalAvailablePipesSupportNoDSC)
2122 						mode_lib->vba.TotalAvailablePipesSupport[i][j] = false;
2123 					mode_lib->vba.TotalNumberOfActiveDPP[i][j] =
2124 							mode_lib->vba.TotalNumberOfActiveDPP[i][j] + v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.NumberOfDPPNoDSC;
2125 				} else {
2126 					mode_lib->vba.ODMCombineEnablePerState[i][k] = v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.ODMModeDSC;
2127 					mode_lib->vba.RequiredDISPCLKPerSurface[i][j][k] =
2128 							v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.RequiredDISPCLKPerSurfaceDSC;
2129 					if (!v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalAvailablePipesSupportDSC)
2130 						mode_lib->vba.TotalAvailablePipesSupport[i][j] = false;
2131 					mode_lib->vba.TotalNumberOfActiveDPP[i][j] =
2132 							mode_lib->vba.TotalNumberOfActiveDPP[i][j] + v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.NumberOfDPPDSC;
2133 				}
2134 			}
2135 
2136 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2137 				if (mode_lib->vba.ODMCombineEnablePerState[i][k] == dm_odm_combine_mode_4to1) {
2138 					mode_lib->vba.MPCCombine[i][j][k] = false;
2139 					mode_lib->vba.NoOfDPP[i][j][k] = 4;
2140 				} else if (mode_lib->vba.ODMCombineEnablePerState[i][k] == dm_odm_combine_mode_2to1) {
2141 					mode_lib->vba.MPCCombine[i][j][k] = false;
2142 					mode_lib->vba.NoOfDPP[i][j][k] = 2;
2143 				} else if (mode_lib->vba.MPCCombineUse[k] == dm_mpc_never) {
2144 					mode_lib->vba.MPCCombine[i][j][k] = false;
2145 					mode_lib->vba.NoOfDPP[i][j][k] = 1;
2146 				} else if (dml32_RoundToDFSGranularity(
2147 						mode_lib->vba.MinDPPCLKUsingSingleDPP[k]
2148 								* (1 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading
2149 												/ 100), 1,
2150 						mode_lib->vba.DISPCLKDPPCLKVCOSpeed) <= mode_lib->vba.MaxDppclk[i] &&
2151 				mode_lib->vba.SingleDPPViewportSizeSupportPerSurface[k] == true) {
2152 					mode_lib->vba.MPCCombine[i][j][k] = false;
2153 					mode_lib->vba.NoOfDPP[i][j][k] = 1;
2154 				} else if (mode_lib->vba.TotalNumberOfActiveDPP[i][j] < mode_lib->vba.MaxNumDPP) {
2155 					mode_lib->vba.MPCCombine[i][j][k] = true;
2156 					mode_lib->vba.NoOfDPP[i][j][k] = 2;
2157 					mode_lib->vba.TotalNumberOfActiveDPP[i][j] =
2158 							mode_lib->vba.TotalNumberOfActiveDPP[i][j] + 1;
2159 				} else {
2160 					mode_lib->vba.MPCCombine[i][j][k] = false;
2161 					mode_lib->vba.NoOfDPP[i][j][k] = 1;
2162 					mode_lib->vba.TotalAvailablePipesSupport[i][j] = false;
2163 				}
2164 			}
2165 
2166 			mode_lib->vba.TotalNumberOfSingleDPPSurfaces[i][j] = 0;
2167 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.NoChroma = true;
2168 
2169 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2170 				if (mode_lib->vba.NoOfDPP[i][j][k] == 1)
2171 					mode_lib->vba.TotalNumberOfSingleDPPSurfaces[i][j] =
2172 							mode_lib->vba.TotalNumberOfSingleDPPSurfaces[i][j] + 1;
2173 				if (mode_lib->vba.SourcePixelFormat[k] == dm_420_8
2174 						|| mode_lib->vba.SourcePixelFormat[k] == dm_420_10
2175 						|| mode_lib->vba.SourcePixelFormat[k] == dm_420_12
2176 						|| mode_lib->vba.SourcePixelFormat[k] == dm_rgbe_alpha) {
2177 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.NoChroma = false;
2178 				}
2179 			}
2180 
2181 			// if TotalNumberOfActiveDPP is > 1, then there should be no unbounded req mode (hw limitation), the comp buf reserved adjustment is not needed regardless
2182 			// if TotalNumberOfActiveDPP is == 1, then will use the SingleDPP version of unbounded_req for the decision
2183 			CompBufReservedSpaceNeedAdjustment = (mode_lib->vba.TotalNumberOfActiveDPP[i][j] > 1) ? 0 : CompBufReservedSpaceNeedAdjustmentSingleDPP;
2184 
2185 
2186 
2187 			if (j == 1 && !dml32_UnboundedRequest(mode_lib->vba.UseUnboundedRequesting,
2188 					mode_lib->vba.TotalNumberOfActiveDPP[i][j], v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.NoChroma,
2189 					mode_lib->vba.Output[0],
2190 					mode_lib->vba.SurfaceTiling[0],
2191 					CompBufReservedSpaceNeedAdjustment,
2192 					mode_lib->vba.DisableUnboundRequestIfCompBufReservedSpaceNeedAdjustment)) {
2193 				while (!(mode_lib->vba.TotalNumberOfActiveDPP[i][j] >= mode_lib->vba.MaxNumDPP
2194 						|| mode_lib->vba.TotalNumberOfSingleDPPSurfaces[i][j] == 0)) {
2195 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.BWOfNonCombinedSurfaceOfMaximumBandwidth = 0;
2196 					NumberOfNonCombinedSurfaceOfMaximumBandwidth = 0;
2197 
2198 					for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2199 						if (mode_lib->vba.MPCCombineUse[k]
2200 							!= dm_mpc_never &&
2201 							mode_lib->vba.MPCCombineUse[k] != dm_mpc_reduce_voltage &&
2202 							mode_lib->vba.ReadBandwidthLuma[k] +
2203 							mode_lib->vba.ReadBandwidthChroma[k] >
2204 							v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.BWOfNonCombinedSurfaceOfMaximumBandwidth &&
2205 							(mode_lib->vba.ODMCombineEnablePerState[i][k] !=
2206 							dm_odm_combine_mode_2to1 &&
2207 							mode_lib->vba.ODMCombineEnablePerState[i][k] !=
2208 							dm_odm_combine_mode_4to1) &&
2209 								mode_lib->vba.MPCCombine[i][j][k] == false) {
2210 							v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.BWOfNonCombinedSurfaceOfMaximumBandwidth =
2211 								mode_lib->vba.ReadBandwidthLuma[k]
2212 								+ mode_lib->vba.ReadBandwidthChroma[k];
2213 							NumberOfNonCombinedSurfaceOfMaximumBandwidth = k;
2214 						}
2215 					}
2216 					mode_lib->vba.MPCCombine[i][j][NumberOfNonCombinedSurfaceOfMaximumBandwidth] =
2217 							true;
2218 					mode_lib->vba.NoOfDPP[i][j][NumberOfNonCombinedSurfaceOfMaximumBandwidth] = 2;
2219 					mode_lib->vba.TotalNumberOfActiveDPP[i][j] =
2220 							mode_lib->vba.TotalNumberOfActiveDPP[i][j] + 1;
2221 					mode_lib->vba.TotalNumberOfSingleDPPSurfaces[i][j] =
2222 							mode_lib->vba.TotalNumberOfSingleDPPSurfaces[i][j] - 1;
2223 				}
2224 			}
2225 
2226 			//DISPCLK/DPPCLK
2227 			mode_lib->vba.WritebackRequiredDISPCLK = 0;
2228 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2229 				if (mode_lib->vba.WritebackEnable[k]) {
2230 					mode_lib->vba.WritebackRequiredDISPCLK = dml_max(
2231 							mode_lib->vba.WritebackRequiredDISPCLK,
2232 							dml32_CalculateWriteBackDISPCLK(
2233 									mode_lib->vba.WritebackPixelFormat[k],
2234 									mode_lib->vba.PixelClock[k],
2235 									mode_lib->vba.WritebackHRatio[k],
2236 									mode_lib->vba.WritebackVRatio[k],
2237 									mode_lib->vba.WritebackHTaps[k],
2238 									mode_lib->vba.WritebackVTaps[k],
2239 									mode_lib->vba.WritebackSourceWidth[k],
2240 									mode_lib->vba.WritebackDestinationWidth[k],
2241 									mode_lib->vba.HTotal[k],
2242 									mode_lib->vba.WritebackLineBufferSize,
2243 									mode_lib->vba.DISPCLKDPPCLKVCOSpeed));
2244 				}
2245 			}
2246 
2247 			mode_lib->vba.RequiredDISPCLK[i][j] = mode_lib->vba.WritebackRequiredDISPCLK;
2248 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2249 				mode_lib->vba.RequiredDISPCLK[i][j] = dml_max(mode_lib->vba.RequiredDISPCLK[i][j],
2250 						mode_lib->vba.RequiredDISPCLKPerSurface[i][j][k]);
2251 			}
2252 
2253 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k)
2254 				mode_lib->vba.NoOfDPPThisState[k] = mode_lib->vba.NoOfDPP[i][j][k];
2255 
2256 			dml32_CalculateDPPCLK(mode_lib->vba.NumberOfActiveSurfaces,
2257 					mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading,
2258 					mode_lib->vba.DISPCLKDPPCLKVCOSpeed, mode_lib->vba.MinDPPCLKUsingSingleDPP,
2259 					mode_lib->vba.NoOfDPPThisState,
2260 					/* Output */
2261 					&mode_lib->vba.GlobalDPPCLK, mode_lib->vba.RequiredDPPCLKThisState);
2262 
2263 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k)
2264 				mode_lib->vba.RequiredDPPCLK[i][j][k] = mode_lib->vba.RequiredDPPCLKThisState[k];
2265 
2266 			mode_lib->vba.DISPCLK_DPPCLK_Support[i][j] = !((mode_lib->vba.RequiredDISPCLK[i][j]
2267 					> mode_lib->vba.MaxDispclk[i])
2268 					|| (mode_lib->vba.GlobalDPPCLK > mode_lib->vba.MaxDppclk[i]));
2269 
2270 			if (mode_lib->vba.TotalNumberOfActiveDPP[i][j] > mode_lib->vba.MaxNumDPP)
2271 				mode_lib->vba.TotalAvailablePipesSupport[i][j] = false;
2272 		} // j
2273 	} // i (VOLTAGE_STATE)
2274 
2275 	/* Total Available OTG, HDMIFRL, DP Support Check */
2276 	v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalNumberOfActiveOTG = 0;
2277 	v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalNumberOfActiveHDMIFRL = 0;
2278 	v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalNumberOfActiveDP2p0 = 0;
2279 	v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalNumberOfActiveDP2p0Outputs = 0;
2280 
2281 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2282 		if (mode_lib->vba.BlendingAndTiming[k] == k) {
2283 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalNumberOfActiveOTG = v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalNumberOfActiveOTG + 1;
2284 			if (mode_lib->vba.Output[k] == dm_dp2p0) {
2285 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalNumberOfActiveDP2p0 = v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalNumberOfActiveDP2p0 + 1;
2286 				if (mode_lib->vba.OutputMultistreamId[k]
2287 						== k || mode_lib->vba.OutputMultistreamEn[k] == false) {
2288 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalNumberOfActiveDP2p0Outputs = v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalNumberOfActiveDP2p0Outputs + 1;
2289 				}
2290 			}
2291 		}
2292 	}
2293 
2294 	mode_lib->vba.NumberOfOTGSupport = (v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalNumberOfActiveOTG <= mode_lib->vba.MaxNumOTG);
2295 	mode_lib->vba.NumberOfHDMIFRLSupport = (v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalNumberOfActiveHDMIFRL <= mode_lib->vba.MaxNumHDMIFRLOutputs);
2296 	mode_lib->vba.NumberOfDP2p0Support = (v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalNumberOfActiveDP2p0 <= mode_lib->vba.MaxNumDP2p0Streams
2297 			&& v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalNumberOfActiveDP2p0Outputs <= mode_lib->vba.MaxNumDP2p0Outputs);
2298 
2299 	/* Display IO and DSC Support Check */
2300 	mode_lib->vba.NonsupportedDSCInputBPC = false;
2301 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
2302 		if (!(mode_lib->vba.DSCInputBitPerComponent[k] == 12.0
2303 				|| mode_lib->vba.DSCInputBitPerComponent[k] == 10.0
2304 				|| mode_lib->vba.DSCInputBitPerComponent[k] == 8.0)
2305 				|| mode_lib->vba.DSCInputBitPerComponent[k] > mode_lib->vba.MaximumDSCBitsPerComponent) {
2306 			mode_lib->vba.NonsupportedDSCInputBPC = true;
2307 		}
2308 	}
2309 
2310 	for (i = start_state; i < v->soc.num_states; ++i) {
2311 		mode_lib->vba.ExceededMultistreamSlots[i] = false;
2312 		for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2313 			if (mode_lib->vba.OutputMultistreamEn[k] == true && mode_lib->vba.OutputMultistreamId[k] == k) {
2314 				TotalSlots = mode_lib->vba.RequiredSlots[i][k];
2315 				for (j = 0; j < mode_lib->vba.NumberOfActiveSurfaces; ++j) {
2316 					if (mode_lib->vba.OutputMultistreamId[j] == k)
2317 						TotalSlots = TotalSlots + mode_lib->vba.RequiredSlots[i][j];
2318 				}
2319 				if (mode_lib->vba.Output[k] == dm_dp && TotalSlots > 63)
2320 					mode_lib->vba.ExceededMultistreamSlots[i] = true;
2321 				if (mode_lib->vba.Output[k] == dm_dp2p0 && TotalSlots > 64)
2322 					mode_lib->vba.ExceededMultistreamSlots[i] = true;
2323 			}
2324 		}
2325 		mode_lib->vba.LinkCapacitySupport[i] = true;
2326 		for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2327 			if (mode_lib->vba.BlendingAndTiming[k] == k
2328 				&& (mode_lib->vba.Output[k] == dm_dp || mode_lib->vba.Output[k] == dm_dp2p0
2329 					|| mode_lib->vba.Output[k] == dm_edp
2330 					|| mode_lib->vba.Output[k] == dm_hdmi)
2331 				&& mode_lib->vba.OutputBppPerState[i][k] == 0 &&
2332 				(mode_lib->vba.UsesMALLForPStateChange[k] != dm_use_mall_pstate_change_phantom_pipe)) {
2333 				/* Phantom pipes don't consider DSC in DML, so it could fail link check.
2334 				 * However, we don't care about the link for phantom pipes.
2335 				 */
2336 				mode_lib->vba.LinkCapacitySupport[i] = false;
2337 			}
2338 		}
2339 	}
2340 
2341 	mode_lib->vba.P2IWith420 = false;
2342 	mode_lib->vba.DSCOnlyIfNecessaryWithBPP = false;
2343 	mode_lib->vba.DSC422NativeNotSupported = false;
2344 	mode_lib->vba.LinkRateDoesNotMatchDPVersion = false;
2345 	mode_lib->vba.LinkRateForMultistreamNotIndicated = false;
2346 	mode_lib->vba.BPPForMultistreamNotIndicated = false;
2347 	mode_lib->vba.MultistreamWithHDMIOreDP = false;
2348 	mode_lib->vba.MSOOrODMSplitWithNonDPLink = false;
2349 	mode_lib->vba.NotEnoughLanesForMSO = false;
2350 
2351 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2352 		if (mode_lib->vba.BlendingAndTiming[k] == k
2353 				&& (mode_lib->vba.Output[k] == dm_dp || mode_lib->vba.Output[k] == dm_dp2p0
2354 						|| mode_lib->vba.Output[k] == dm_edp
2355 						|| mode_lib->vba.Output[k] == dm_hdmi)) {
2356 			if (mode_lib->vba.OutputFormat[k]
2357 					== dm_420 && mode_lib->vba.Interlace[k] == 1 &&
2358 					mode_lib->vba.ProgressiveToInterlaceUnitInOPP == true)
2359 				mode_lib->vba.P2IWith420 = true;
2360 
2361 			if (mode_lib->vba.DSCEnable[k] && mode_lib->vba.ForcedOutputLinkBPP[k] != 0)
2362 				mode_lib->vba.DSCOnlyIfNecessaryWithBPP = true;
2363 			if (mode_lib->vba.DSCEnable[k] && mode_lib->vba.OutputFormat[k] == dm_n422
2364 					&& !mode_lib->vba.DSC422NativeSupport)
2365 				mode_lib->vba.DSC422NativeNotSupported = true;
2366 
2367 			if (((mode_lib->vba.OutputLinkDPRate[k] == dm_dp_rate_hbr
2368 					|| mode_lib->vba.OutputLinkDPRate[k] == dm_dp_rate_hbr2
2369 					|| mode_lib->vba.OutputLinkDPRate[k] == dm_dp_rate_hbr3)
2370 					&& mode_lib->vba.Output[k] != dm_dp && mode_lib->vba.Output[k] != dm_edp)
2371 					|| ((mode_lib->vba.OutputLinkDPRate[k] == dm_dp_rate_uhbr10
2372 							|| mode_lib->vba.OutputLinkDPRate[k] == dm_dp_rate_uhbr13p5
2373 							|| mode_lib->vba.OutputLinkDPRate[k] == dm_dp_rate_uhbr20)
2374 							&& mode_lib->vba.Output[k] != dm_dp2p0))
2375 				mode_lib->vba.LinkRateDoesNotMatchDPVersion = true;
2376 
2377 			if (mode_lib->vba.OutputMultistreamEn[k] == true) {
2378 				if (mode_lib->vba.OutputMultistreamId[k] == k
2379 					&& mode_lib->vba.OutputLinkDPRate[k] == dm_dp_rate_na)
2380 					mode_lib->vba.LinkRateForMultistreamNotIndicated = true;
2381 				if (mode_lib->vba.OutputMultistreamId[k] == k && mode_lib->vba.ForcedOutputLinkBPP[k] == 0)
2382 					mode_lib->vba.BPPForMultistreamNotIndicated = true;
2383 				for (j = 0; j < mode_lib->vba.NumberOfActiveSurfaces; ++j) {
2384 					if (mode_lib->vba.OutputMultistreamId[k] == j
2385 						&& mode_lib->vba.ForcedOutputLinkBPP[k] == 0)
2386 						mode_lib->vba.BPPForMultistreamNotIndicated = true;
2387 				}
2388 			}
2389 
2390 			if ((mode_lib->vba.Output[k] == dm_edp || mode_lib->vba.Output[k] == dm_hdmi)) {
2391 				if (mode_lib->vba.OutputMultistreamEn[k] == true && mode_lib->vba.OutputMultistreamId[k] == k)
2392 					mode_lib->vba.MultistreamWithHDMIOreDP = true;
2393 				for (j = 0; j < mode_lib->vba.NumberOfActiveSurfaces; ++j) {
2394 					if (mode_lib->vba.OutputMultistreamEn[k] == true && mode_lib->vba.OutputMultistreamId[k] == j)
2395 						mode_lib->vba.MultistreamWithHDMIOreDP = true;
2396 				}
2397 			}
2398 
2399 			if (mode_lib->vba.Output[k] != dm_dp
2400 					&& (mode_lib->vba.ODMUse[k] == dm_odm_split_policy_1to2
2401 							|| mode_lib->vba.ODMUse[k] == dm_odm_mso_policy_1to2
2402 							|| mode_lib->vba.ODMUse[k] == dm_odm_mso_policy_1to4))
2403 				mode_lib->vba.MSOOrODMSplitWithNonDPLink = true;
2404 
2405 			if ((mode_lib->vba.ODMUse[k] == dm_odm_mso_policy_1to2
2406 					&& mode_lib->vba.OutputLinkDPLanes[k] < 2)
2407 					|| (mode_lib->vba.ODMUse[k] == dm_odm_mso_policy_1to4
2408 							&& mode_lib->vba.OutputLinkDPLanes[k] < 4))
2409 				mode_lib->vba.NotEnoughLanesForMSO = true;
2410 		}
2411 	}
2412 
2413 	for (i = start_state; i < v->soc.num_states; ++i) {
2414 		mode_lib->vba.DTBCLKRequiredMoreThanSupported[i] = false;
2415 		for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2416 			if (mode_lib->vba.BlendingAndTiming[k] == k
2417 					&& dml32_RequiredDTBCLK(mode_lib->vba.RequiresDSC[i][k],
2418 							mode_lib->vba.PixelClockBackEnd[k],
2419 							mode_lib->vba.OutputFormat[k],
2420 							mode_lib->vba.OutputBppPerState[i][k],
2421 							mode_lib->vba.NumberOfDSCSlices[k], mode_lib->vba.HTotal[k],
2422 							mode_lib->vba.HActive[k], mode_lib->vba.AudioSampleRate[k],
2423 							mode_lib->vba.AudioSampleLayout[k])
2424 							> mode_lib->vba.DTBCLKPerState[i]) {
2425 				mode_lib->vba.DTBCLKRequiredMoreThanSupported[i] = true;
2426 			}
2427 		}
2428 	}
2429 
2430 	for (i = start_state; i < v->soc.num_states; ++i) {
2431 		mode_lib->vba.ODMCombine2To1SupportCheckOK[i] = true;
2432 		mode_lib->vba.ODMCombine4To1SupportCheckOK[i] = true;
2433 		for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2434 			if (mode_lib->vba.BlendingAndTiming[k] == k
2435 					&& mode_lib->vba.ODMCombineEnablePerState[i][k] == dm_odm_combine_mode_2to1
2436 					&& mode_lib->vba.Output[k] == dm_hdmi) {
2437 				mode_lib->vba.ODMCombine2To1SupportCheckOK[i] = false;
2438 			}
2439 			if (mode_lib->vba.BlendingAndTiming[k] == k
2440 					&& mode_lib->vba.ODMCombineEnablePerState[i][k] == dm_odm_combine_mode_4to1
2441 					&& (mode_lib->vba.Output[k] == dm_dp || mode_lib->vba.Output[k] == dm_edp
2442 							|| mode_lib->vba.Output[k] == dm_hdmi)) {
2443 				mode_lib->vba.ODMCombine4To1SupportCheckOK[i] = false;
2444 			}
2445 		}
2446 	}
2447 
2448 	for (i = start_state; i < v->soc.num_states; i++) {
2449 		mode_lib->vba.DSCCLKRequiredMoreThanSupported[i] = false;
2450 		for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
2451 			if (mode_lib->vba.BlendingAndTiming[k] == k) {
2452 				if (mode_lib->vba.Output[k] == dm_dp || mode_lib->vba.Output[k] == dm_dp2p0
2453 						|| mode_lib->vba.Output[k] == dm_edp) {
2454 					if (mode_lib->vba.OutputFormat[k] == dm_420) {
2455 						mode_lib->vba.DSCFormatFactor = 2;
2456 					} else if (mode_lib->vba.OutputFormat[k] == dm_444) {
2457 						mode_lib->vba.DSCFormatFactor = 1;
2458 					} else if (mode_lib->vba.OutputFormat[k] == dm_n422) {
2459 						mode_lib->vba.DSCFormatFactor = 2;
2460 					} else {
2461 						mode_lib->vba.DSCFormatFactor = 1;
2462 					}
2463 					if (mode_lib->vba.RequiresDSC[i][k] == true) {
2464 						if (mode_lib->vba.ODMCombineEnablePerState[i][k]
2465 								== dm_odm_combine_mode_4to1) {
2466 							if (mode_lib->vba.PixelClockBackEnd[k] / 12.0 / mode_lib->vba.DSCFormatFactor > (1.0 - mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0) * mode_lib->vba.MaxDSCCLK[i])
2467 								mode_lib->vba.DSCCLKRequiredMoreThanSupported[i] = true;
2468 						} else if (mode_lib->vba.ODMCombineEnablePerState[i][k]
2469 								== dm_odm_combine_mode_2to1) {
2470 							if (mode_lib->vba.PixelClockBackEnd[k] / 6.0 / mode_lib->vba.DSCFormatFactor > (1.0 - mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0) * mode_lib->vba.MaxDSCCLK[i])
2471 								mode_lib->vba.DSCCLKRequiredMoreThanSupported[i] = true;
2472 						} else {
2473 							if (mode_lib->vba.PixelClockBackEnd[k] / 3.0 / mode_lib->vba.DSCFormatFactor > (1.0 - mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0) * mode_lib->vba.MaxDSCCLK[i])
2474 								mode_lib->vba.DSCCLKRequiredMoreThanSupported[i] = true;
2475 						}
2476 					}
2477 				}
2478 			}
2479 		}
2480 	}
2481 
2482 	/* Check DSC Unit and Slices Support */
2483 	v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalDSCUnitsRequired = 0;
2484 
2485 	for (i = start_state; i < v->soc.num_states; ++i) {
2486 		mode_lib->vba.NotEnoughDSCUnits[i] = false;
2487 		mode_lib->vba.NotEnoughDSCSlices[i] = false;
2488 		v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalDSCUnitsRequired = 0;
2489 		mode_lib->vba.PixelsPerLinePerDSCUnitSupport[i] = true;
2490 		for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2491 			if (mode_lib->vba.RequiresDSC[i][k] == true) {
2492 				if (mode_lib->vba.ODMCombineEnablePerState[i][k] == dm_odm_combine_mode_4to1) {
2493 					if (mode_lib->vba.HActive[k]
2494 							> 4 * mode_lib->vba.MaximumPixelsPerLinePerDSCUnit)
2495 						mode_lib->vba.PixelsPerLinePerDSCUnitSupport[i] = false;
2496 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalDSCUnitsRequired = v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalDSCUnitsRequired + 4;
2497 					if (mode_lib->vba.NumberOfDSCSlices[k] > 16)
2498 						mode_lib->vba.NotEnoughDSCSlices[i] = true;
2499 				} else if (mode_lib->vba.ODMCombineEnablePerState[i][k] == dm_odm_combine_mode_2to1) {
2500 					if (mode_lib->vba.HActive[k]
2501 							> 2 * mode_lib->vba.MaximumPixelsPerLinePerDSCUnit)
2502 						mode_lib->vba.PixelsPerLinePerDSCUnitSupport[i] = false;
2503 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalDSCUnitsRequired = v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalDSCUnitsRequired + 2;
2504 					if (mode_lib->vba.NumberOfDSCSlices[k] > 8)
2505 						mode_lib->vba.NotEnoughDSCSlices[i] = true;
2506 				} else {
2507 					if (mode_lib->vba.HActive[k] > mode_lib->vba.MaximumPixelsPerLinePerDSCUnit)
2508 						mode_lib->vba.PixelsPerLinePerDSCUnitSupport[i] = false;
2509 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalDSCUnitsRequired = v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalDSCUnitsRequired + 1;
2510 					if (mode_lib->vba.NumberOfDSCSlices[k] > 4)
2511 						mode_lib->vba.NotEnoughDSCSlices[i] = true;
2512 				}
2513 			}
2514 		}
2515 		if (v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.TotalDSCUnitsRequired > mode_lib->vba.NumberOfDSC)
2516 			mode_lib->vba.NotEnoughDSCUnits[i] = true;
2517 	}
2518 
2519 	/*DSC Delay per state*/
2520 	for (i = start_state; i < v->soc.num_states; ++i) {
2521 		for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2522 			mode_lib->vba.DSCDelayPerState[i][k] = dml32_DSCDelayRequirement(
2523 					mode_lib->vba.RequiresDSC[i][k], mode_lib->vba.ODMCombineEnablePerState[i][k],
2524 					mode_lib->vba.DSCInputBitPerComponent[k],
2525 					mode_lib->vba.OutputBppPerState[i][k], mode_lib->vba.HActive[k],
2526 					mode_lib->vba.HTotal[k], mode_lib->vba.NumberOfDSCSlices[k],
2527 					mode_lib->vba.OutputFormat[k], mode_lib->vba.Output[k],
2528 					mode_lib->vba.PixelClock[k], mode_lib->vba.PixelClockBackEnd[k],
2529 					mode_lib->vba.ip.dsc_delay_factor_wa);
2530 		}
2531 
2532 		for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
2533 			for (m = 0; m <= mode_lib->vba.NumberOfActiveSurfaces - 1; m++) {
2534 				for (j = 0; j <= mode_lib->vba.NumberOfActiveSurfaces - 1; j++) {
2535 					if (mode_lib->vba.BlendingAndTiming[k] == m &&
2536 							mode_lib->vba.RequiresDSC[i][m] == true) {
2537 						mode_lib->vba.DSCDelayPerState[i][k] =
2538 							mode_lib->vba.DSCDelayPerState[i][m];
2539 					}
2540 				}
2541 			}
2542 		}
2543 	}
2544 
2545 	//Calculate Swath, DET Configuration, DCFCLKDeepSleep
2546 	//
2547 	for (i = start_state; i < (int) v->soc.num_states; ++i) {
2548 		for (j = 0; j <= 1; ++j) {
2549 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2550 				mode_lib->vba.RequiredDPPCLKThisState[k] = mode_lib->vba.RequiredDPPCLK[i][j][k];
2551 				mode_lib->vba.NoOfDPPThisState[k] = mode_lib->vba.NoOfDPP[i][j][k];
2552 				mode_lib->vba.ODMCombineEnableThisState[k] =
2553 						mode_lib->vba.ODMCombineEnablePerState[i][k];
2554 			}
2555 
2556 			dml32_CalculateSwathAndDETConfiguration(
2557 					mode_lib->vba.DETSizeOverride,
2558 					mode_lib->vba.UsesMALLForPStateChange,
2559 					mode_lib->vba.ConfigReturnBufferSizeInKByte,
2560 					mode_lib->vba.MaxTotalDETInKByte,
2561 					mode_lib->vba.MinCompressedBufferSizeInKByte,
2562 					false, /* ForceSingleDPP */
2563 					mode_lib->vba.NumberOfActiveSurfaces,
2564 					mode_lib->vba.nomDETInKByte,
2565 					mode_lib->vba.UseUnboundedRequesting,
2566 					mode_lib->vba.DisableUnboundRequestIfCompBufReservedSpaceNeedAdjustment,
2567 					mode_lib->vba.ip.pixel_chunk_size_kbytes,
2568 					mode_lib->vba.ip.rob_buffer_size_kbytes,
2569 					mode_lib->vba.CompressedBufferSegmentSizeInkByteFinal,
2570 					mode_lib->vba.Output,
2571 					mode_lib->vba.ReadBandwidthLuma,
2572 					mode_lib->vba.ReadBandwidthChroma,
2573 					mode_lib->vba.MaximumSwathWidthLuma,
2574 					mode_lib->vba.MaximumSwathWidthChroma,
2575 					mode_lib->vba.SourceRotation,
2576 					mode_lib->vba.ViewportStationary,
2577 					mode_lib->vba.SourcePixelFormat,
2578 					mode_lib->vba.SurfaceTiling,
2579 					mode_lib->vba.ViewportWidth,
2580 					mode_lib->vba.ViewportHeight,
2581 					mode_lib->vba.ViewportXStartY,
2582 					mode_lib->vba.ViewportYStartY,
2583 					mode_lib->vba.ViewportXStartC,
2584 					mode_lib->vba.ViewportYStartC,
2585 					mode_lib->vba.SurfaceWidthY,
2586 					mode_lib->vba.SurfaceWidthC,
2587 					mode_lib->vba.SurfaceHeightY,
2588 					mode_lib->vba.SurfaceHeightC,
2589 					mode_lib->vba.Read256BlockHeightY,
2590 					mode_lib->vba.Read256BlockHeightC,
2591 					mode_lib->vba.Read256BlockWidthY,
2592 					mode_lib->vba.Read256BlockWidthC,
2593 					mode_lib->vba.ODMCombineEnableThisState,
2594 					mode_lib->vba.BlendingAndTiming,
2595 					mode_lib->vba.BytePerPixelY,
2596 					mode_lib->vba.BytePerPixelC,
2597 					mode_lib->vba.BytePerPixelInDETY,
2598 					mode_lib->vba.BytePerPixelInDETC,
2599 					mode_lib->vba.HActive,
2600 					mode_lib->vba.HRatio,
2601 					mode_lib->vba.HRatioChroma,
2602 					mode_lib->vba.NoOfDPPThisState,
2603 					/* Output */
2604 					mode_lib->vba.swath_width_luma_ub_this_state,
2605 					mode_lib->vba.swath_width_chroma_ub_this_state,
2606 					mode_lib->vba.SwathWidthYThisState,
2607 					mode_lib->vba.SwathWidthCThisState,
2608 					mode_lib->vba.SwathHeightYThisState,
2609 					mode_lib->vba.SwathHeightCThisState,
2610 					mode_lib->vba.DETBufferSizeInKByteThisState,
2611 					mode_lib->vba.DETBufferSizeYThisState,
2612 					mode_lib->vba.DETBufferSizeCThisState,
2613 					&mode_lib->vba.UnboundedRequestEnabledThisState,
2614 					&mode_lib->vba.CompressedBufferSizeInkByteThisState,
2615 					&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer[0], /* Long CompBufReservedSpaceKBytes */
2616 					&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_boolean[0], /* bool CompBufReservedSpaceNeedAdjustment */
2617 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_boolean_array[0],
2618 					&mode_lib->vba.ViewportSizeSupport[i][j]);
2619 
2620 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2621 				mode_lib->vba.swath_width_luma_ub_all_states[i][j][k] =
2622 						mode_lib->vba.swath_width_luma_ub_this_state[k];
2623 				mode_lib->vba.swath_width_chroma_ub_all_states[i][j][k] =
2624 						mode_lib->vba.swath_width_chroma_ub_this_state[k];
2625 				mode_lib->vba.SwathWidthYAllStates[i][j][k] = mode_lib->vba.SwathWidthYThisState[k];
2626 				mode_lib->vba.SwathWidthCAllStates[i][j][k] = mode_lib->vba.SwathWidthCThisState[k];
2627 				mode_lib->vba.SwathHeightYAllStates[i][j][k] = mode_lib->vba.SwathHeightYThisState[k];
2628 				mode_lib->vba.SwathHeightCAllStates[i][j][k] = mode_lib->vba.SwathHeightCThisState[k];
2629 				mode_lib->vba.UnboundedRequestEnabledAllStates[i][j] =
2630 						mode_lib->vba.UnboundedRequestEnabledThisState;
2631 				mode_lib->vba.CompressedBufferSizeInkByteAllStates[i][j] =
2632 						mode_lib->vba.CompressedBufferSizeInkByteThisState;
2633 				mode_lib->vba.DETBufferSizeInKByteAllStates[i][j][k] =
2634 						mode_lib->vba.DETBufferSizeInKByteThisState[k];
2635 				mode_lib->vba.DETBufferSizeYAllStates[i][j][k] =
2636 						mode_lib->vba.DETBufferSizeYThisState[k];
2637 				mode_lib->vba.DETBufferSizeCAllStates[i][j][k] =
2638 						mode_lib->vba.DETBufferSizeCThisState[k];
2639 			}
2640 		}
2641 	}
2642 
2643 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2644 		mode_lib->vba.cursor_bw[k] = mode_lib->vba.NumberOfCursors[k] * mode_lib->vba.CursorWidth[k][0]
2645 				* mode_lib->vba.CursorBPP[k][0] / 8.0
2646 				/ (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]) * mode_lib->vba.VRatio[k];
2647 	}
2648 
2649 	dml32_CalculateSurfaceSizeInMall(
2650 			mode_lib->vba.NumberOfActiveSurfaces,
2651 			mode_lib->vba.MALLAllocatedForDCNFinal,
2652 			mode_lib->vba.UseMALLForStaticScreen,
2653 			mode_lib->vba.UsesMALLForPStateChange,
2654 			mode_lib->vba.DCCEnable,
2655 			mode_lib->vba.ViewportStationary,
2656 			mode_lib->vba.ViewportXStartY,
2657 			mode_lib->vba.ViewportYStartY,
2658 			mode_lib->vba.ViewportXStartC,
2659 			mode_lib->vba.ViewportYStartC,
2660 			mode_lib->vba.ViewportWidth,
2661 			mode_lib->vba.ViewportHeight,
2662 			mode_lib->vba.BytePerPixelY,
2663 			mode_lib->vba.ViewportWidthChroma,
2664 			mode_lib->vba.ViewportHeightChroma,
2665 			mode_lib->vba.BytePerPixelC,
2666 			mode_lib->vba.SurfaceWidthY,
2667 			mode_lib->vba.SurfaceWidthC,
2668 			mode_lib->vba.SurfaceHeightY,
2669 			mode_lib->vba.SurfaceHeightC,
2670 			mode_lib->vba.Read256BlockWidthY,
2671 			mode_lib->vba.Read256BlockWidthC,
2672 			mode_lib->vba.Read256BlockHeightY,
2673 			mode_lib->vba.Read256BlockHeightC,
2674 			mode_lib->vba.MacroTileWidthY,
2675 			mode_lib->vba.MacroTileWidthC,
2676 			mode_lib->vba.MacroTileHeightY,
2677 			mode_lib->vba.MacroTileHeightC,
2678 			mode_lib->vba.DCCMetaPitchY,
2679 			mode_lib->vba.DCCMetaPitchC,
2680 
2681 			/* Output */
2682 			mode_lib->vba.SurfaceSizeInMALL,
2683 			&mode_lib->vba.ExceededMALLSize);
2684 
2685 	for (i = start_state; i < v->soc.num_states; i++) {
2686 		for (j = 0; j < 2; j++) {
2687 			for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
2688 				mode_lib->vba.swath_width_luma_ub_this_state[k] =
2689 						mode_lib->vba.swath_width_luma_ub_all_states[i][j][k];
2690 				mode_lib->vba.swath_width_chroma_ub_this_state[k] =
2691 						mode_lib->vba.swath_width_chroma_ub_all_states[i][j][k];
2692 				mode_lib->vba.SwathWidthYThisState[k] = mode_lib->vba.SwathWidthYAllStates[i][j][k];
2693 				mode_lib->vba.SwathWidthCThisState[k] = mode_lib->vba.SwathWidthCAllStates[i][j][k];
2694 				mode_lib->vba.SwathHeightYThisState[k] = mode_lib->vba.SwathHeightYAllStates[i][j][k];
2695 				mode_lib->vba.SwathHeightCThisState[k] = mode_lib->vba.SwathHeightCAllStates[i][j][k];
2696 				mode_lib->vba.DETBufferSizeInKByteThisState[k] =
2697 						mode_lib->vba.DETBufferSizeInKByteAllStates[i][j][k];
2698 				mode_lib->vba.DETBufferSizeYThisState[k] =
2699 						mode_lib->vba.DETBufferSizeYAllStates[i][j][k];
2700 				mode_lib->vba.DETBufferSizeCThisState[k] =
2701 						mode_lib->vba.DETBufferSizeCAllStates[i][j][k];
2702 				mode_lib->vba.RequiredDPPCLKThisState[k] = mode_lib->vba.RequiredDPPCLK[i][j][k];
2703 				mode_lib->vba.NoOfDPPThisState[k] = mode_lib->vba.NoOfDPP[i][j][k];
2704 			}
2705 
2706 			mode_lib->vba.TotalNumberOfDCCActiveDPP[i][j] = 0;
2707 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2708 				if (mode_lib->vba.DCCEnable[k] == true) {
2709 					mode_lib->vba.TotalNumberOfDCCActiveDPP[i][j] =
2710 							mode_lib->vba.TotalNumberOfDCCActiveDPP[i][j]
2711 									+ mode_lib->vba.NoOfDPP[i][j][k];
2712 				}
2713 			}
2714 
2715 
2716 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2717 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].PixelClock = mode_lib->vba.PixelClock[k];
2718 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].DPPPerSurface = mode_lib->vba.NoOfDPP[i][j][k];
2719 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].SourceRotation = mode_lib->vba.SourceRotation[k];
2720 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].ViewportHeight = mode_lib->vba.ViewportHeight[k];
2721 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].ViewportHeightChroma = mode_lib->vba.ViewportHeightChroma[k];
2722 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].BlockWidth256BytesY = mode_lib->vba.Read256BlockWidthY[k];
2723 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].BlockHeight256BytesY = mode_lib->vba.Read256BlockHeightY[k];
2724 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].BlockWidth256BytesC = mode_lib->vba.Read256BlockWidthC[k];
2725 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].BlockHeight256BytesC = mode_lib->vba.Read256BlockHeightC[k];
2726 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].BlockWidthY = mode_lib->vba.MacroTileWidthY[k];
2727 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].BlockHeightY = mode_lib->vba.MacroTileHeightY[k];
2728 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].BlockWidthC = mode_lib->vba.MacroTileWidthC[k];
2729 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].BlockHeightC = mode_lib->vba.MacroTileHeightC[k];
2730 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].InterlaceEnable = mode_lib->vba.Interlace[k];
2731 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].HTotal = mode_lib->vba.HTotal[k];
2732 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].DCCEnable = mode_lib->vba.DCCEnable[k];
2733 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].SourcePixelFormat = mode_lib->vba.SourcePixelFormat[k];
2734 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].SurfaceTiling = mode_lib->vba.SurfaceTiling[k];
2735 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].BytePerPixelY = mode_lib->vba.BytePerPixelY[k];
2736 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].BytePerPixelC = mode_lib->vba.BytePerPixelC[k];
2737 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].ProgressiveToInterlaceUnitInOPP =
2738 				mode_lib->vba.ProgressiveToInterlaceUnitInOPP;
2739 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].VRatio = mode_lib->vba.VRatio[k];
2740 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].VRatioChroma = mode_lib->vba.VRatioChroma[k];
2741 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].VTaps = mode_lib->vba.vtaps[k];
2742 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].VTapsChroma = mode_lib->vba.VTAPsChroma[k];
2743 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].PitchY = mode_lib->vba.PitchY[k];
2744 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].DCCMetaPitchY = mode_lib->vba.DCCMetaPitchY[k];
2745 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].PitchC = mode_lib->vba.PitchC[k];
2746 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].DCCMetaPitchC = mode_lib->vba.DCCMetaPitchC[k];
2747 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].ViewportStationary = mode_lib->vba.ViewportStationary[k];
2748 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].ViewportXStart = mode_lib->vba.ViewportXStartY[k];
2749 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].ViewportYStart = mode_lib->vba.ViewportYStartY[k];
2750 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].ViewportXStartC = mode_lib->vba.ViewportXStartC[k];
2751 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].ViewportYStartC = mode_lib->vba.ViewportYStartC[k];
2752 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].FORCE_ONE_ROW_FOR_FRAME = mode_lib->vba.ForceOneRowForFrame[k];
2753 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].SwathHeightY = mode_lib->vba.SwathHeightYThisState[k];
2754 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters[k].SwathHeightC = mode_lib->vba.SwathHeightCThisState[k];
2755 			}
2756 
2757 			{
2758 				dml32_CalculateVMRowAndSwath(
2759 						mode_lib->vba.NumberOfActiveSurfaces,
2760 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SurfParameters,
2761 						mode_lib->vba.SurfaceSizeInMALL,
2762 						mode_lib->vba.PTEBufferSizeInRequestsLuma,
2763 						mode_lib->vba.PTEBufferSizeInRequestsChroma,
2764 						mode_lib->vba.DCCMetaBufferSizeBytes,
2765 						mode_lib->vba.UseMALLForStaticScreen,
2766 						mode_lib->vba.UsesMALLForPStateChange,
2767 						mode_lib->vba.MALLAllocatedForDCNFinal,
2768 						mode_lib->vba.SwathWidthYThisState,
2769 						mode_lib->vba.SwathWidthCThisState,
2770 						mode_lib->vba.GPUVMEnable,
2771 						mode_lib->vba.HostVMEnable,
2772 						mode_lib->vba.HostVMMaxNonCachedPageTableLevels,
2773 						mode_lib->vba.GPUVMMaxPageTableLevels,
2774 						mode_lib->vba.GPUVMMinPageSizeKBytes,
2775 						mode_lib->vba.HostVMMinPageSize,
2776 
2777 						/* Output */
2778 						mode_lib->vba.PTEBufferSizeNotExceededPerState,
2779 						mode_lib->vba.DCCMetaBufferSizeNotExceededPerState,
2780 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[0],
2781 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[1],
2782 						mode_lib->vba.dpte_row_height,
2783 						mode_lib->vba.dpte_row_height_chroma,
2784 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[2],
2785 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[3],
2786 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[4],
2787 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[5],
2788 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[6],
2789 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[7],
2790 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[8],
2791 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[9],
2792 						mode_lib->vba.meta_row_height,
2793 						mode_lib->vba.meta_row_height_chroma,
2794 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[10],
2795 						mode_lib->vba.dpte_group_bytes,
2796 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[11],
2797 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[12],
2798 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[13],
2799 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[14],
2800 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[15],
2801 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[16],
2802 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[17],
2803 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[18],
2804 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[19],
2805 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[20],
2806 						mode_lib->vba.PrefetchLinesYThisState,
2807 						mode_lib->vba.PrefetchLinesCThisState,
2808 						mode_lib->vba.PrefillY,
2809 						mode_lib->vba.PrefillC,
2810 						mode_lib->vba.MaxNumSwY,
2811 						mode_lib->vba.MaxNumSwC,
2812 						mode_lib->vba.meta_row_bandwidth_this_state,
2813 						mode_lib->vba.dpte_row_bandwidth_this_state,
2814 						mode_lib->vba.DPTEBytesPerRowThisState,
2815 						mode_lib->vba.PDEAndMetaPTEBytesPerFrameThisState,
2816 						mode_lib->vba.MetaRowBytesThisState,
2817 						mode_lib->vba.use_one_row_for_frame_this_state,
2818 						mode_lib->vba.use_one_row_for_frame_flip_this_state,
2819 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_boolean_array[0], // Boolean UsesMALLForStaticScreen[]
2820 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_boolean_array[1], // Boolean PTE_BUFFER_MODE[]
2821 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer_array[21]); // Long BIGK_FRAGMENT_SIZE[]
2822 			}
2823 
2824 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2825 				mode_lib->vba.PrefetchLinesY[i][j][k] = mode_lib->vba.PrefetchLinesYThisState[k];
2826 				mode_lib->vba.PrefetchLinesC[i][j][k] = mode_lib->vba.PrefetchLinesCThisState[k];
2827 				mode_lib->vba.meta_row_bandwidth[i][j][k] =
2828 						mode_lib->vba.meta_row_bandwidth_this_state[k];
2829 				mode_lib->vba.dpte_row_bandwidth[i][j][k] =
2830 						mode_lib->vba.dpte_row_bandwidth_this_state[k];
2831 				mode_lib->vba.DPTEBytesPerRow[i][j][k] = mode_lib->vba.DPTEBytesPerRowThisState[k];
2832 				mode_lib->vba.PDEAndMetaPTEBytesPerFrame[i][j][k] =
2833 						mode_lib->vba.PDEAndMetaPTEBytesPerFrameThisState[k];
2834 				mode_lib->vba.MetaRowBytes[i][j][k] = mode_lib->vba.MetaRowBytesThisState[k];
2835 				mode_lib->vba.use_one_row_for_frame[i][j][k] =
2836 						mode_lib->vba.use_one_row_for_frame_this_state[k];
2837 				mode_lib->vba.use_one_row_for_frame_flip[i][j][k] =
2838 						mode_lib->vba.use_one_row_for_frame_flip_this_state[k];
2839 			}
2840 
2841 			mode_lib->vba.PTEBufferSizeNotExceeded[i][j] = true;
2842 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2843 				if (mode_lib->vba.PTEBufferSizeNotExceededPerState[k] == false)
2844 					mode_lib->vba.PTEBufferSizeNotExceeded[i][j] = false;
2845 			}
2846 
2847 			mode_lib->vba.DCCMetaBufferSizeNotExceeded[i][j] = true;
2848 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2849 				if (mode_lib->vba.DCCMetaBufferSizeNotExceededPerState[k] == false)
2850 					mode_lib->vba.DCCMetaBufferSizeNotExceeded[i][j] = false;
2851 			}
2852 
2853 			mode_lib->vba.UrgLatency[i] = dml32_CalculateUrgentLatency(
2854 					mode_lib->vba.UrgentLatencyPixelDataOnly,
2855 					mode_lib->vba.UrgentLatencyPixelMixedWithVMData,
2856 					mode_lib->vba.UrgentLatencyVMDataOnly, mode_lib->vba.DoUrgentLatencyAdjustment,
2857 					mode_lib->vba.UrgentLatencyAdjustmentFabricClockComponent,
2858 					mode_lib->vba.UrgentLatencyAdjustmentFabricClockReference,
2859 					mode_lib->vba.FabricClockPerState[i]);
2860 
2861 			//bool   NotUrgentLatencyHiding[DC__NUM_DPP__MAX];
2862 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2863 				dml32_CalculateUrgentBurstFactor(
2864 						mode_lib->vba.UsesMALLForPStateChange[k],
2865 						mode_lib->vba.swath_width_luma_ub_this_state[k],
2866 						mode_lib->vba.swath_width_chroma_ub_this_state[k],
2867 						mode_lib->vba.SwathHeightYThisState[k],
2868 						mode_lib->vba.SwathHeightCThisState[k],
2869 						(double) mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k],
2870 						mode_lib->vba.UrgLatency[i],
2871 						mode_lib->vba.CursorBufferSize,
2872 						mode_lib->vba.CursorWidth[k][0],
2873 						mode_lib->vba.CursorBPP[k][0],
2874 						mode_lib->vba.VRatio[k],
2875 						mode_lib->vba.VRatioChroma[k],
2876 						mode_lib->vba.BytePerPixelInDETY[k],
2877 						mode_lib->vba.BytePerPixelInDETC[k],
2878 						mode_lib->vba.DETBufferSizeYThisState[k],
2879 						mode_lib->vba.DETBufferSizeCThisState[k],
2880 						/* Output */
2881 						&mode_lib->vba.UrgentBurstFactorCursor[k],
2882 						&mode_lib->vba.UrgentBurstFactorLuma[k],
2883 						&mode_lib->vba.UrgentBurstFactorChroma[k],
2884 						&mode_lib->vba.NoUrgentLatencyHiding[k]);
2885 			}
2886 
2887 			dml32_CalculateDCFCLKDeepSleep(
2888 					mode_lib->vba.NumberOfActiveSurfaces,
2889 					mode_lib->vba.BytePerPixelY,
2890 					mode_lib->vba.BytePerPixelC,
2891 					mode_lib->vba.VRatio,
2892 					mode_lib->vba.VRatioChroma,
2893 					mode_lib->vba.SwathWidthYThisState,
2894 					mode_lib->vba.SwathWidthCThisState,
2895 					mode_lib->vba.NoOfDPPThisState,
2896 					mode_lib->vba.HRatio,
2897 					mode_lib->vba.HRatioChroma,
2898 					mode_lib->vba.PixelClock,
2899 					mode_lib->vba.PSCL_FACTOR,
2900 					mode_lib->vba.PSCL_FACTOR_CHROMA,
2901 					mode_lib->vba.RequiredDPPCLKThisState,
2902 					mode_lib->vba.ReadBandwidthLuma,
2903 					mode_lib->vba.ReadBandwidthChroma,
2904 					mode_lib->vba.ReturnBusWidth,
2905 
2906 					/* Output */
2907 					&mode_lib->vba.ProjectedDCFCLKDeepSleep[i][j]);
2908 		}
2909 	}
2910 
2911 	//Calculate Return BW
2912 	for (i = start_state; i < (int) v->soc.num_states; ++i) {
2913 		for (j = 0; j <= 1; ++j) {
2914 			for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
2915 				if (mode_lib->vba.BlendingAndTiming[k] == k) {
2916 					if (mode_lib->vba.WritebackEnable[k] == true) {
2917 						mode_lib->vba.WritebackDelayTime[k] =
2918 							mode_lib->vba.WritebackLatency
2919 						+ dml32_CalculateWriteBackDelay(
2920 							mode_lib->vba.WritebackPixelFormat[k],
2921 							mode_lib->vba.WritebackHRatio[k],
2922 							mode_lib->vba.WritebackVRatio[k],
2923 							mode_lib->vba.WritebackVTaps[k],
2924 							mode_lib->vba.WritebackDestinationWidth[k],
2925 							mode_lib->vba.WritebackDestinationHeight[k],
2926 							mode_lib->vba.WritebackSourceHeight[k],
2927 							mode_lib->vba.HTotal[k])
2928 							/ mode_lib->vba.RequiredDISPCLK[i][j];
2929 					} else {
2930 						mode_lib->vba.WritebackDelayTime[k] = 0.0;
2931 					}
2932 					for (m = 0; m <= mode_lib->vba.NumberOfActiveSurfaces - 1; m++) {
2933 						if (mode_lib->vba.BlendingAndTiming[m]
2934 								== k && mode_lib->vba.WritebackEnable[m] == true) {
2935 							mode_lib->vba.WritebackDelayTime[k] =
2936 								dml_max(mode_lib->vba.WritebackDelayTime[k],
2937 									mode_lib->vba.WritebackLatency
2938 								+ dml32_CalculateWriteBackDelay(
2939 									mode_lib->vba.WritebackPixelFormat[m],
2940 									mode_lib->vba.WritebackHRatio[m],
2941 									mode_lib->vba.WritebackVRatio[m],
2942 									mode_lib->vba.WritebackVTaps[m],
2943 									mode_lib->vba.WritebackDestinationWidth[m],
2944 									mode_lib->vba.WritebackDestinationHeight[m],
2945 									mode_lib->vba.WritebackSourceHeight[m],
2946 									mode_lib->vba.HTotal[m]) /
2947 									mode_lib->vba.RequiredDISPCLK[i][j]);
2948 						}
2949 					}
2950 				}
2951 			}
2952 			for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
2953 				for (m = 0; m <= mode_lib->vba.NumberOfActiveSurfaces - 1; m++) {
2954 					if (mode_lib->vba.BlendingAndTiming[k] == m) {
2955 						mode_lib->vba.WritebackDelayTime[k] =
2956 								mode_lib->vba.WritebackDelayTime[m];
2957 					}
2958 				}
2959 			}
2960 			mode_lib->vba.MaxMaxVStartup[i][j] = 0;
2961 			for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
2962 				mode_lib->vba.MaximumVStartup[i][j][k] = ((mode_lib->vba.Interlace[k] &&
2963 								!mode_lib->vba.ProgressiveToInterlaceUnitInOPP) ?
2964 								dml_floor((mode_lib->vba.VTotal[k] -
2965 									mode_lib->vba.VActive[k]) / 2.0, 1.0) :
2966 								mode_lib->vba.VTotal[k] - mode_lib->vba.VActive[k])
2967 								- dml_max(1.0, dml_ceil(1.0 *
2968 									mode_lib->vba.WritebackDelayTime[k] /
2969 									(mode_lib->vba.HTotal[k] /
2970 									mode_lib->vba.PixelClock[k]), 1.0));
2971 
2972 				// Clamp to max OTG vstartup register limit
2973 				if (mode_lib->vba.MaximumVStartup[i][j][k] > 1023)
2974 					mode_lib->vba.MaximumVStartup[i][j][k] = 1023;
2975 
2976 				mode_lib->vba.MaxMaxVStartup[i][j] = dml_max(mode_lib->vba.MaxMaxVStartup[i][j],
2977 						mode_lib->vba.MaximumVStartup[i][j][k]);
2978 			}
2979 		}
2980 	}
2981 
2982 	v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.ReorderingBytes = mode_lib->vba.NumberOfChannels
2983 			* dml_max3(mode_lib->vba.UrgentOutOfOrderReturnPerChannelPixelDataOnly,
2984 					mode_lib->vba.UrgentOutOfOrderReturnPerChannelPixelMixedWithVMData,
2985 					mode_lib->vba.UrgentOutOfOrderReturnPerChannelVMDataOnly);
2986 
2987 	dml32_CalculateMinAndMaxPrefetchMode(mode_lib->vba.AllowForPStateChangeOrStutterInVBlankFinal,
2988 			&mode_lib->vba.MinPrefetchMode,
2989 			&mode_lib->vba.MaxPrefetchMode);
2990 
2991 	for (i = start_state; i < (int) v->soc.num_states; ++i) {
2992 		for (j = 0; j <= 1; ++j)
2993 			mode_lib->vba.DCFCLKState[i][j] = mode_lib->vba.DCFCLKPerState[i];
2994 	}
2995 
2996 	/* Immediate Flip and MALL parameters */
2997 	mode_lib->vba.ImmediateFlipRequiredFinal = false;
2998 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
2999 		mode_lib->vba.ImmediateFlipRequiredFinal = mode_lib->vba.ImmediateFlipRequiredFinal
3000 				|| (mode_lib->vba.ImmediateFlipRequirement[k] == dm_immediate_flip_required);
3001 	}
3002 
3003 	mode_lib->vba.ImmediateFlipRequiredButTheRequirementForEachSurfaceIsNotSpecified = false;
3004 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
3005 		mode_lib->vba.ImmediateFlipRequiredButTheRequirementForEachSurfaceIsNotSpecified =
3006 				mode_lib->vba.ImmediateFlipRequiredButTheRequirementForEachSurfaceIsNotSpecified
3007 						|| ((mode_lib->vba.ImmediateFlipRequirement[k]
3008 								!= dm_immediate_flip_required)
3009 								&& (mode_lib->vba.ImmediateFlipRequirement[k]
3010 										!= dm_immediate_flip_not_required));
3011 	}
3012 	mode_lib->vba.ImmediateFlipRequiredButTheRequirementForEachSurfaceIsNotSpecified =
3013 			mode_lib->vba.ImmediateFlipRequiredButTheRequirementForEachSurfaceIsNotSpecified
3014 					&& mode_lib->vba.ImmediateFlipRequiredFinal;
3015 
3016 	mode_lib->vba.ImmediateFlipOrHostVMAndPStateWithMALLFullFrameOrPhantomPipe = false;
3017 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
3018 		mode_lib->vba.ImmediateFlipOrHostVMAndPStateWithMALLFullFrameOrPhantomPipe =
3019 			mode_lib->vba.ImmediateFlipOrHostVMAndPStateWithMALLFullFrameOrPhantomPipe ||
3020 			((mode_lib->vba.HostVMEnable == true || mode_lib->vba.ImmediateFlipRequirement[k] !=
3021 					dm_immediate_flip_not_required) &&
3022 			(mode_lib->vba.UsesMALLForPStateChange[k] == dm_use_mall_pstate_change_full_frame ||
3023 			mode_lib->vba.UsesMALLForPStateChange[k] == dm_use_mall_pstate_change_phantom_pipe));
3024 	}
3025 
3026 	mode_lib->vba.InvalidCombinationOfMALLUseForPStateAndStaticScreen = false;
3027 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
3028 		mode_lib->vba.InvalidCombinationOfMALLUseForPStateAndStaticScreen =
3029 			mode_lib->vba.InvalidCombinationOfMALLUseForPStateAndStaticScreen
3030 			|| ((mode_lib->vba.UseMALLForStaticScreen[k] == dm_use_mall_static_screen_enable
3031 			|| mode_lib->vba.UseMALLForStaticScreen[k] == dm_use_mall_static_screen_optimize)
3032 			&& (mode_lib->vba.UsesMALLForPStateChange[k] == dm_use_mall_pstate_change_phantom_pipe))
3033 			|| ((mode_lib->vba.UseMALLForStaticScreen[k] == dm_use_mall_static_screen_disable
3034 			|| mode_lib->vba.UseMALLForStaticScreen[k] == dm_use_mall_static_screen_optimize)
3035 			&& (mode_lib->vba.UsesMALLForPStateChange[k] == dm_use_mall_pstate_change_full_frame));
3036 	}
3037 
3038 	v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.FullFrameMALLPStateMethod = false;
3039 	v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SubViewportMALLPStateMethod = false;
3040 	v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.PhantomPipeMALLPStateMethod = false;
3041 
3042 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
3043 		if (mode_lib->vba.UsesMALLForPStateChange[k] == dm_use_mall_pstate_change_full_frame)
3044 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.FullFrameMALLPStateMethod = true;
3045 		if (mode_lib->vba.UsesMALLForPStateChange[k] == dm_use_mall_pstate_change_sub_viewport)
3046 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SubViewportMALLPStateMethod = true;
3047 		if (mode_lib->vba.UsesMALLForPStateChange[k] == dm_use_mall_pstate_change_phantom_pipe)
3048 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.PhantomPipeMALLPStateMethod = true;
3049 	}
3050 	mode_lib->vba.InvalidCombinationOfMALLUseForPState = (v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SubViewportMALLPStateMethod
3051 			!= v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.PhantomPipeMALLPStateMethod) || (v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.SubViewportMALLPStateMethod && v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.FullFrameMALLPStateMethod);
3052 
3053 	if (mode_lib->vba.UseMinimumRequiredDCFCLK == true) {
3054 		dml32_UseMinimumDCFCLK(
3055 				mode_lib->vba.UsesMALLForPStateChange,
3056 				mode_lib->vba.DRRDisplay,
3057 				mode_lib->vba.SynchronizeDRRDisplaysForUCLKPStateChangeFinal,
3058 				mode_lib->vba.MaxInterDCNTileRepeaters,
3059 				mode_lib->vba.MaxPrefetchMode,
3060 				mode_lib->vba.DRAMClockChangeLatency,
3061 				mode_lib->vba.FCLKChangeLatency,
3062 				mode_lib->vba.SREnterPlusExitTime,
3063 				mode_lib->vba.ReturnBusWidth,
3064 				mode_lib->vba.RoundTripPingLatencyCycles,
3065 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.ReorderingBytes,
3066 				mode_lib->vba.PixelChunkSizeInKByte,
3067 				mode_lib->vba.MetaChunkSize,
3068 				mode_lib->vba.GPUVMEnable,
3069 				mode_lib->vba.GPUVMMaxPageTableLevels,
3070 				mode_lib->vba.HostVMEnable,
3071 				mode_lib->vba.NumberOfActiveSurfaces,
3072 				mode_lib->vba.HostVMMinPageSize,
3073 				mode_lib->vba.HostVMMaxNonCachedPageTableLevels,
3074 				mode_lib->vba.DynamicMetadataVMEnabled,
3075 				mode_lib->vba.ImmediateFlipRequiredFinal,
3076 				mode_lib->vba.ProgressiveToInterlaceUnitInOPP,
3077 				mode_lib->vba.MaxAveragePercentOfIdealSDPPortBWDisplayCanUseInNormalSystemOperation,
3078 				mode_lib->vba.PercentOfIdealFabricAndSDPPortBWReceivedAfterUrgLatency,
3079 				mode_lib->vba.VTotal,
3080 				mode_lib->vba.VActive,
3081 				mode_lib->vba.DynamicMetadataTransmittedBytes,
3082 				mode_lib->vba.DynamicMetadataLinesBeforeActiveRequired,
3083 				mode_lib->vba.Interlace,
3084 				mode_lib->vba.RequiredDPPCLK,
3085 				mode_lib->vba.RequiredDISPCLK,
3086 				mode_lib->vba.UrgLatency,
3087 				mode_lib->vba.NoOfDPP,
3088 				mode_lib->vba.ProjectedDCFCLKDeepSleep,
3089 				mode_lib->vba.MaximumVStartup,
3090 				mode_lib->vba.TotalNumberOfActiveDPP,
3091 				mode_lib->vba.TotalNumberOfDCCActiveDPP,
3092 				mode_lib->vba.dpte_group_bytes,
3093 				mode_lib->vba.PrefetchLinesY,
3094 				mode_lib->vba.PrefetchLinesC,
3095 				mode_lib->vba.swath_width_luma_ub_all_states,
3096 				mode_lib->vba.swath_width_chroma_ub_all_states,
3097 				mode_lib->vba.BytePerPixelY,
3098 				mode_lib->vba.BytePerPixelC,
3099 				mode_lib->vba.HTotal,
3100 				mode_lib->vba.PixelClock,
3101 				mode_lib->vba.PDEAndMetaPTEBytesPerFrame,
3102 				mode_lib->vba.DPTEBytesPerRow,
3103 				mode_lib->vba.MetaRowBytes,
3104 				mode_lib->vba.DynamicMetadataEnable,
3105 				mode_lib->vba.ReadBandwidthLuma,
3106 				mode_lib->vba.ReadBandwidthChroma,
3107 				mode_lib->vba.DCFCLKPerState,
3108 
3109 				/* Output */
3110 				mode_lib->vba.DCFCLKState);
3111 	} // UseMinimumRequiredDCFCLK == true
3112 
3113 	for (i = start_state; i < (int) v->soc.num_states; ++i) {
3114 		for (j = 0; j <= 1; ++j) {
3115 			mode_lib->vba.ReturnBWPerState[i][j] = dml32_get_return_bw_mbps(&mode_lib->vba.soc, i,
3116 					mode_lib->vba.HostVMEnable, mode_lib->vba.DCFCLKState[i][j],
3117 					mode_lib->vba.FabricClockPerState[i], mode_lib->vba.DRAMSpeedPerState[i]);
3118 		}
3119 	}
3120 
3121 	//Re-ordering Buffer Support Check
3122 	for (i = start_state; i < (int) v->soc.num_states; ++i) {
3123 		for (j = 0; j <= 1; ++j) {
3124 			if ((mode_lib->vba.ROBBufferSizeInKByte - mode_lib->vba.PixelChunkSizeInKByte) * 1024
3125 					/ mode_lib->vba.ReturnBWPerState[i][j]
3126 					> (mode_lib->vba.RoundTripPingLatencyCycles + 32)
3127 							/ mode_lib->vba.DCFCLKState[i][j]
3128 							+ v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.ReorderingBytes / mode_lib->vba.ReturnBWPerState[i][j]) {
3129 				mode_lib->vba.ROBSupport[i][j] = true;
3130 			} else {
3131 				mode_lib->vba.ROBSupport[i][j] = false;
3132 			}
3133 		}
3134 	}
3135 
3136 	//Vertical Active BW support check
3137 	v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MaxTotalVActiveRDBandwidth = 0;
3138 
3139 	for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
3140 		v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MaxTotalVActiveRDBandwidth += mode_lib->vba.ReadBandwidthLuma[k]
3141 				+ mode_lib->vba.ReadBandwidthChroma[k];
3142 	}
3143 
3144 	for (i = start_state; i < (int) v->soc.num_states; ++i) {
3145 		for (j = 0; j <= 1; ++j) {
3146 			mode_lib->vba.MaxTotalVerticalActiveAvailableBandwidth[i][j] =
3147 				dml_min3(mode_lib->vba.ReturnBusWidth * mode_lib->vba.DCFCLKState[i][j]
3148 					* mode_lib->vba.MaxAveragePercentOfIdealSDPPortBWDisplayCanUseInNormalSystemOperation / 100,
3149 					mode_lib->vba.FabricClockPerState[i]
3150 					* mode_lib->vba.FabricDatapathToDCNDataReturn
3151 					* mode_lib->vba.MaxAveragePercentOfIdealFabricBWDisplayCanUseInNormalSystemOperation / 100,
3152 					mode_lib->vba.DRAMSpeedPerState[i]
3153 					* mode_lib->vba.NumberOfChannels
3154 					* mode_lib->vba.DRAMChannelWidth
3155 					* (i < 2 ? mode_lib->vba.MaxAveragePercentOfIdealDRAMBWDisplayCanUseInNormalSystemOperationSTROBE : mode_lib->vba.MaxAveragePercentOfIdealDRAMBWDisplayCanUseInNormalSystemOperation) / 100);
3156 
3157 			if (v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.MaxTotalVActiveRDBandwidth
3158 					<= mode_lib->vba.MaxTotalVerticalActiveAvailableBandwidth[i][j]) {
3159 				mode_lib->vba.TotalVerticalActiveBandwidthSupport[i][j] = true;
3160 			} else {
3161 				mode_lib->vba.TotalVerticalActiveBandwidthSupport[i][j] = false;
3162 			}
3163 		}
3164 	}
3165 
3166 	/* Prefetch Check */
3167 
3168 	for (i = start_state; i < (int) v->soc.num_states; ++i) {
3169 		for (j = 0; j <= 1; ++j) {
3170 
3171 			mode_lib->vba.TimeCalc = 24 / mode_lib->vba.ProjectedDCFCLKDeepSleep[i][j];
3172 
3173 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
3174 				mode_lib->vba.NoOfDPPThisState[k] = mode_lib->vba.NoOfDPP[i][j][k];
3175 				mode_lib->vba.swath_width_luma_ub_this_state[k] =
3176 						mode_lib->vba.swath_width_luma_ub_all_states[i][j][k];
3177 				mode_lib->vba.swath_width_chroma_ub_this_state[k] =
3178 						mode_lib->vba.swath_width_chroma_ub_all_states[i][j][k];
3179 				mode_lib->vba.SwathWidthYThisState[k] = mode_lib->vba.SwathWidthYAllStates[i][j][k];
3180 				mode_lib->vba.SwathWidthCThisState[k] = mode_lib->vba.SwathWidthCAllStates[i][j][k];
3181 				mode_lib->vba.SwathHeightYThisState[k] = mode_lib->vba.SwathHeightYAllStates[i][j][k];
3182 				mode_lib->vba.SwathHeightCThisState[k] = mode_lib->vba.SwathHeightCAllStates[i][j][k];
3183 				mode_lib->vba.UnboundedRequestEnabledThisState =
3184 						mode_lib->vba.UnboundedRequestEnabledAllStates[i][j];
3185 				mode_lib->vba.CompressedBufferSizeInkByteThisState =
3186 						mode_lib->vba.CompressedBufferSizeInkByteAllStates[i][j];
3187 				mode_lib->vba.DETBufferSizeInKByteThisState[k] =
3188 						mode_lib->vba.DETBufferSizeInKByteAllStates[i][j][k];
3189 				mode_lib->vba.DETBufferSizeYThisState[k] =
3190 						mode_lib->vba.DETBufferSizeYAllStates[i][j][k];
3191 				mode_lib->vba.DETBufferSizeCThisState[k] =
3192 						mode_lib->vba.DETBufferSizeCAllStates[i][j][k];
3193 			}
3194 
3195 			mode_lib->vba.VActiveBandwithSupport[i][j] = dml32_CalculateVActiveBandwithSupport(
3196 					mode_lib->vba.NumberOfActiveSurfaces,
3197 					mode_lib->vba.ReturnBWPerState[i][j],
3198 					mode_lib->vba.NoUrgentLatencyHiding,
3199 					mode_lib->vba.ReadBandwidthLuma,
3200 					mode_lib->vba.ReadBandwidthChroma,
3201 					mode_lib->vba.cursor_bw,
3202 					mode_lib->vba.meta_row_bandwidth_this_state,
3203 					mode_lib->vba.dpte_row_bandwidth_this_state,
3204 					mode_lib->vba.NoOfDPPThisState,
3205 					mode_lib->vba.UrgentBurstFactorLuma,
3206 					mode_lib->vba.UrgentBurstFactorChroma,
3207 					mode_lib->vba.UrgentBurstFactorCursor);
3208 
3209 			mode_lib->vba.NotEnoughDETSwathFillLatencyHidingPerState[i][j] = dml32_CalculateDETSwathFillLatencyHiding(
3210 					mode_lib->vba.NumberOfActiveSurfaces,
3211 					mode_lib->vba.ReturnBWPerState[i][j],
3212 					mode_lib->vba.UrgLatency[i],
3213 					mode_lib->vba.SwathHeightYThisState,
3214 					mode_lib->vba.SwathHeightCThisState,
3215 					mode_lib->vba.swath_width_luma_ub_this_state,
3216 					mode_lib->vba.swath_width_chroma_ub_this_state,
3217 					mode_lib->vba.BytePerPixelInDETY,
3218 					mode_lib->vba.BytePerPixelInDETC,
3219 					mode_lib->vba.DETBufferSizeYThisState,
3220 					mode_lib->vba.DETBufferSizeCThisState,
3221 					mode_lib->vba.NoOfDPPThisState,
3222 					mode_lib->vba.HTotal,
3223 					mode_lib->vba.PixelClock,
3224 					mode_lib->vba.VRatio,
3225 					mode_lib->vba.VRatioChroma,
3226 					mode_lib->vba.UsesMALLForPStateChange,
3227 					mode_lib->vba.UseUnboundedRequesting);
3228 
3229 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.VMDataOnlyReturnBWPerState = dml32_get_return_bw_mbps_vm_only(&mode_lib->vba.soc, i,
3230 					mode_lib->vba.DCFCLKState[i][j], mode_lib->vba.FabricClockPerState[i],
3231 					mode_lib->vba.DRAMSpeedPerState[i]);
3232 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.HostVMInefficiencyFactor = 1;
3233 
3234 			if (mode_lib->vba.GPUVMEnable && mode_lib->vba.HostVMEnable)
3235 				v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.HostVMInefficiencyFactor = mode_lib->vba.ReturnBWPerState[i][j]
3236 						/ v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.VMDataOnlyReturnBWPerState;
3237 
3238 			mode_lib->vba.ExtraLatency = dml32_CalculateExtraLatency(
3239 					mode_lib->vba.RoundTripPingLatencyCycles, v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.ReorderingBytes,
3240 					mode_lib->vba.DCFCLKState[i][j], mode_lib->vba.TotalNumberOfActiveDPP[i][j],
3241 					mode_lib->vba.PixelChunkSizeInKByte,
3242 					mode_lib->vba.TotalNumberOfDCCActiveDPP[i][j], mode_lib->vba.MetaChunkSize,
3243 					mode_lib->vba.ReturnBWPerState[i][j], mode_lib->vba.GPUVMEnable,
3244 					mode_lib->vba.HostVMEnable, mode_lib->vba.NumberOfActiveSurfaces,
3245 					mode_lib->vba.NoOfDPPThisState, mode_lib->vba.dpte_group_bytes,
3246 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.HostVMInefficiencyFactor, mode_lib->vba.HostVMMinPageSize,
3247 					mode_lib->vba.HostVMMaxNonCachedPageTableLevels);
3248 
3249 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.NextPrefetchModeState = mode_lib->vba.MinPrefetchMode;
3250 
3251 			mode_lib->vba.NextMaxVStartup = mode_lib->vba.MaxMaxVStartup[i][j];
3252 
3253 			do {
3254 				mode_lib->vba.PrefetchModePerState[i][j] = v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.NextPrefetchModeState;
3255 				mode_lib->vba.MaxVStartup = mode_lib->vba.NextMaxVStartup;
3256 
3257 				for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
3258 					mode_lib->vba.TWait = dml32_CalculateTWait(
3259 							mode_lib->vba.PrefetchModePerState[i][j],
3260 							mode_lib->vba.UsesMALLForPStateChange[k],
3261 							mode_lib->vba.SynchronizeDRRDisplaysForUCLKPStateChangeFinal,
3262 							mode_lib->vba.DRRDisplay[k],
3263 							mode_lib->vba.DRAMClockChangeLatency,
3264 							mode_lib->vba.FCLKChangeLatency, mode_lib->vba.UrgLatency[i],
3265 							mode_lib->vba.SREnterPlusExitTime);
3266 
3267 					memset(&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull, 0, sizeof(DmlPipe));
3268 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.Dppclk = mode_lib->vba.RequiredDPPCLK[i][j][k];
3269 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.Dispclk = mode_lib->vba.RequiredDISPCLK[i][j];
3270 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.PixelClock = mode_lib->vba.PixelClock[k];
3271 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.DCFClkDeepSleep = mode_lib->vba.ProjectedDCFCLKDeepSleep[i][j];
3272 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.DPPPerSurface = mode_lib->vba.NoOfDPP[i][j][k];
3273 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.ScalerEnabled = mode_lib->vba.ScalerEnabled[k];
3274 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.SourceRotation = mode_lib->vba.SourceRotation[k];
3275 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.BlockWidth256BytesY = mode_lib->vba.Read256BlockWidthY[k];
3276 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.BlockHeight256BytesY = mode_lib->vba.Read256BlockHeightY[k];
3277 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.BlockWidth256BytesC = mode_lib->vba.Read256BlockWidthC[k];
3278 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.BlockHeight256BytesC = mode_lib->vba.Read256BlockHeightC[k];
3279 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.InterlaceEnable = mode_lib->vba.Interlace[k];
3280 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.NumberOfCursors = mode_lib->vba.NumberOfCursors[k];
3281 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.VBlank = mode_lib->vba.VTotal[k] - mode_lib->vba.VActive[k];
3282 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.HTotal = mode_lib->vba.HTotal[k];
3283 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.HActive = mode_lib->vba.HActive[k];
3284 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.DCCEnable = mode_lib->vba.DCCEnable[k];
3285 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.ODMMode = mode_lib->vba.ODMCombineEnablePerState[i][k];
3286 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.SourcePixelFormat = mode_lib->vba.SourcePixelFormat[k];
3287 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.BytePerPixelY = mode_lib->vba.BytePerPixelY[k];
3288 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.BytePerPixelC = mode_lib->vba.BytePerPixelC[k];
3289 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe.ProgressiveToInterlaceUnitInOPP =
3290 							mode_lib->vba.ProgressiveToInterlaceUnitInOPP;
3291 
3292 					mode_lib->vba.NoTimeForPrefetch[i][j][k] =
3293 						dml32_CalculatePrefetchSchedule(
3294 							v,
3295 							k,
3296 							v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.HostVMInefficiencyFactor,
3297 							&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.myPipe,
3298 							v->DSCDelayPerState[i][k],
3299 							v->SwathWidthYThisState[k] / v->HRatio[k],
3300 							dml_min(v->MaxVStartup, v->MaximumVStartup[i][j][k]),
3301 							v->MaximumVStartup[i][j][k],
3302 							v->UrgLatency[i],
3303 							v->ExtraLatency,
3304 							v->TimeCalc,
3305 							v->PDEAndMetaPTEBytesPerFrame[i][j][k],
3306 							v->MetaRowBytes[i][j][k],
3307 							v->DPTEBytesPerRow[i][j][k],
3308 							v->PrefetchLinesY[i][j][k],
3309 							v->SwathWidthYThisState[k],
3310 							v->PrefillY[k],
3311 							v->MaxNumSwY[k],
3312 							v->PrefetchLinesC[i][j][k],
3313 							v->SwathWidthCThisState[k],
3314 							v->PrefillC[k],
3315 							v->MaxNumSwC[k],
3316 							v->swath_width_luma_ub_this_state[k],
3317 							v->swath_width_chroma_ub_this_state[k],
3318 							v->SwathHeightYThisState[k],
3319 							v->SwathHeightCThisState[k], v->TWait,
3320 							(v->DRAMSpeedPerState[i] <= MEM_STROBE_FREQ_MHZ || v->DCFCLKState[i][j] <= DCFCLK_FREQ_EXTRA_PREFETCH_REQ_MHZ) ?
3321 									mode_lib->vba.ip.min_prefetch_in_strobe_us : 0,
3322 							mode_lib->vba.PrefetchModePerState[i][j] > 0 || mode_lib->vba.DRAMClockChangeRequirementFinal == false,
3323 
3324 							/* Output */
3325 							&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.DSTXAfterScaler[k],
3326 							&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.DSTYAfterScaler[k],
3327 							&v->LineTimesForPrefetch[k],
3328 							&v->PrefetchBW[k],
3329 							&v->LinesForMetaPTE[k],
3330 							&v->LinesForMetaAndDPTERow[k],
3331 							&v->VRatioPreY[i][j][k],
3332 							&v->VRatioPreC[i][j][k],
3333 							&v->RequiredPrefetchPixelDataBWLuma[0][0][k],
3334 							&v->RequiredPrefetchPixelDataBWChroma[0][0][k],
3335 							&v->NoTimeForDynamicMetadata[i][j][k],
3336 							&v->Tno_bw[k],
3337 							&v->prefetch_vmrow_bw[k],
3338 							&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_single[0],         // double *Tdmdl_vm
3339 							&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_single[1],         // double *Tdmdl
3340 							&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_single[2],         // double *TSetup
3341 							&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer[0],         							    // unsigned int   *VUpdateOffsetPix
3342 							&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_single[3],         // unsigned int   *VUpdateWidthPix
3343 							&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_single[4]);        // unsigned int   *VReadyOffsetPix
3344 				}
3345 
3346 				for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
3347 					dml32_CalculateUrgentBurstFactor(
3348 							mode_lib->vba.UsesMALLForPStateChange[k],
3349 							mode_lib->vba.swath_width_luma_ub_this_state[k],
3350 							mode_lib->vba.swath_width_chroma_ub_this_state[k],
3351 							mode_lib->vba.SwathHeightYThisState[k],
3352 							mode_lib->vba.SwathHeightCThisState[k],
3353 							mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k],
3354 							mode_lib->vba.UrgLatency[i], mode_lib->vba.CursorBufferSize,
3355 							mode_lib->vba.CursorWidth[k][0], mode_lib->vba.CursorBPP[k][0],
3356 							mode_lib->vba.VRatioPreY[i][j][k],
3357 							mode_lib->vba.VRatioPreC[i][j][k],
3358 							mode_lib->vba.BytePerPixelInDETY[k],
3359 							mode_lib->vba.BytePerPixelInDETC[k],
3360 							mode_lib->vba.DETBufferSizeYThisState[k],
3361 							mode_lib->vba.DETBufferSizeCThisState[k],
3362 							/* Output */
3363 							&mode_lib->vba.UrgentBurstFactorCursorPre[k],
3364 							&mode_lib->vba.UrgentBurstFactorLumaPre[k],
3365 							&mode_lib->vba.UrgentBurstFactorChromaPre[k],
3366 							&mode_lib->vba.NotUrgentLatencyHidingPre[k]);
3367 
3368 					v->cursor_bw_pre[k] = mode_lib->vba.NumberOfCursors[k] * mode_lib->vba.CursorWidth[k][0] * mode_lib->vba.CursorBPP[k][0] /
3369 							8.0 / (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]) * v->VRatioPreY[i][j][k];
3370 				}
3371 
3372 				{
3373 					dml32_CalculatePrefetchBandwithSupport(
3374 							mode_lib->vba.NumberOfActiveSurfaces,
3375 							mode_lib->vba.ReturnBWPerState[i][j],
3376 							mode_lib->vba.NotUrgentLatencyHidingPre,
3377 							mode_lib->vba.ReadBandwidthLuma,
3378 							mode_lib->vba.ReadBandwidthChroma,
3379 							mode_lib->vba.RequiredPrefetchPixelDataBWLuma[0][0],
3380 							mode_lib->vba.RequiredPrefetchPixelDataBWChroma[0][0],
3381 							mode_lib->vba.cursor_bw,
3382 							mode_lib->vba.meta_row_bandwidth_this_state,
3383 							mode_lib->vba.dpte_row_bandwidth_this_state,
3384 							mode_lib->vba.cursor_bw_pre,
3385 							mode_lib->vba.prefetch_vmrow_bw,
3386 							mode_lib->vba.NoOfDPPThisState,
3387 							mode_lib->vba.UrgentBurstFactorLuma,
3388 							mode_lib->vba.UrgentBurstFactorChroma,
3389 							mode_lib->vba.UrgentBurstFactorCursor,
3390 							mode_lib->vba.UrgentBurstFactorLumaPre,
3391 							mode_lib->vba.UrgentBurstFactorChromaPre,
3392 							mode_lib->vba.UrgentBurstFactorCursorPre,
3393 							v->PrefetchBW,
3394 							v->VRatio,
3395 							v->MaxVRatioPre,
3396 
3397 							/* output */
3398 							&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_single[0],   // Single  *PrefetchBandwidth
3399 							&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_single[1],   // Single  *FractionOfUrgentBandwidth
3400 							&mode_lib->vba.PrefetchSupported[i][j]);
3401 				}
3402 
3403 				for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
3404 					if (mode_lib->vba.LineTimesForPrefetch[k]
3405 							< 2.0 || mode_lib->vba.LinesForMetaPTE[k] >= 32.0
3406 							|| mode_lib->vba.LinesForMetaAndDPTERow[k] >= 16.0
3407 							|| mode_lib->vba.NoTimeForPrefetch[i][j][k] == true) {
3408 						mode_lib->vba.PrefetchSupported[i][j] = false;
3409 					}
3410 				}
3411 
3412 				mode_lib->vba.DynamicMetadataSupported[i][j] = true;
3413 				for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
3414 					if (mode_lib->vba.NoTimeForDynamicMetadata[i][j][k] == true)
3415 						mode_lib->vba.DynamicMetadataSupported[i][j] = false;
3416 				}
3417 
3418 				mode_lib->vba.VRatioInPrefetchSupported[i][j] = true;
3419 				for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
3420 					if (mode_lib->vba.VRatioPreY[i][j][k] > mode_lib->vba.MaxVRatioPre
3421 							|| mode_lib->vba.VRatioPreC[i][j][k] > mode_lib->vba.MaxVRatioPre
3422 							|| mode_lib->vba.NoTimeForPrefetch[i][j][k] == true) {
3423 						mode_lib->vba.VRatioInPrefetchSupported[i][j] = false;
3424 					}
3425 				}
3426 				mode_lib->vba.AnyLinesForVMOrRowTooLarge = false;
3427 				for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
3428 					if (mode_lib->vba.LinesForMetaAndDPTERow[k] >= 16
3429 							|| mode_lib->vba.LinesForMetaPTE[k] >= 32) {
3430 						mode_lib->vba.AnyLinesForVMOrRowTooLarge = true;
3431 					}
3432 				}
3433 
3434 				if (mode_lib->vba.PrefetchSupported[i][j] == true
3435 						&& mode_lib->vba.VRatioInPrefetchSupported[i][j] == true) {
3436 					mode_lib->vba.BandwidthAvailableForImmediateFlip =
3437 							dml32_CalculateBandwidthAvailableForImmediateFlip(
3438 							mode_lib->vba.NumberOfActiveSurfaces,
3439 							mode_lib->vba.ReturnBWPerState[i][j],
3440 							mode_lib->vba.ReadBandwidthLuma,
3441 							mode_lib->vba.ReadBandwidthChroma,
3442 							mode_lib->vba.RequiredPrefetchPixelDataBWLuma[0][0],
3443 							mode_lib->vba.RequiredPrefetchPixelDataBWChroma[0][0],
3444 							mode_lib->vba.cursor_bw,
3445 							mode_lib->vba.cursor_bw_pre,
3446 							mode_lib->vba.NoOfDPPThisState,
3447 							mode_lib->vba.UrgentBurstFactorLuma,
3448 							mode_lib->vba.UrgentBurstFactorChroma,
3449 							mode_lib->vba.UrgentBurstFactorCursor,
3450 							mode_lib->vba.UrgentBurstFactorLumaPre,
3451 							mode_lib->vba.UrgentBurstFactorChromaPre,
3452 							mode_lib->vba.UrgentBurstFactorCursorPre);
3453 
3454 					mode_lib->vba.TotImmediateFlipBytes = 0.0;
3455 					for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
3456 						if (!(mode_lib->vba.ImmediateFlipRequirement[k] ==
3457 								dm_immediate_flip_not_required)) {
3458 							mode_lib->vba.TotImmediateFlipBytes =
3459 									mode_lib->vba.TotImmediateFlipBytes
3460 								+ mode_lib->vba.NoOfDPP[i][j][k]
3461 								* mode_lib->vba.PDEAndMetaPTEBytesPerFrame[i][j][k]
3462 								+ mode_lib->vba.MetaRowBytes[i][j][k];
3463 							if (mode_lib->vba.use_one_row_for_frame_flip[i][j][k]) {
3464 								mode_lib->vba.TotImmediateFlipBytes =
3465 									mode_lib->vba.TotImmediateFlipBytes + 2
3466 								* mode_lib->vba.DPTEBytesPerRow[i][j][k];
3467 							} else {
3468 								mode_lib->vba.TotImmediateFlipBytes =
3469 									mode_lib->vba.TotImmediateFlipBytes
3470 								+ mode_lib->vba.DPTEBytesPerRow[i][j][k];
3471 							}
3472 						}
3473 					}
3474 
3475 					for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
3476 						dml32_CalculateFlipSchedule(v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.HostVMInefficiencyFactor,
3477 							mode_lib->vba.ExtraLatency,
3478 							mode_lib->vba.UrgLatency[i],
3479 							mode_lib->vba.GPUVMMaxPageTableLevels,
3480 							mode_lib->vba.HostVMEnable,
3481 							mode_lib->vba.HostVMMaxNonCachedPageTableLevels,
3482 							mode_lib->vba.GPUVMEnable,
3483 							mode_lib->vba.HostVMMinPageSize,
3484 							mode_lib->vba.PDEAndMetaPTEBytesPerFrame[i][j][k],
3485 							mode_lib->vba.MetaRowBytes[i][j][k],
3486 							mode_lib->vba.DPTEBytesPerRow[i][j][k],
3487 							mode_lib->vba.BandwidthAvailableForImmediateFlip,
3488 							mode_lib->vba.TotImmediateFlipBytes,
3489 							mode_lib->vba.SourcePixelFormat[k],
3490 							(mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]),
3491 							mode_lib->vba.VRatio[k],
3492 							mode_lib->vba.VRatioChroma[k],
3493 							mode_lib->vba.Tno_bw[k],
3494 								mode_lib->vba.DCCEnable[k],
3495 							mode_lib->vba.dpte_row_height[k],
3496 							mode_lib->vba.meta_row_height[k],
3497 							mode_lib->vba.dpte_row_height_chroma[k],
3498 							mode_lib->vba.meta_row_height_chroma[k],
3499 							mode_lib->vba.use_one_row_for_frame_flip[i][j][k], // 24
3500 
3501 							/* Output */
3502 							&mode_lib->vba.DestinationLinesToRequestVMInImmediateFlip[k],
3503 							&mode_lib->vba.DestinationLinesToRequestRowInImmediateFlip[k],
3504 							&mode_lib->vba.final_flip_bw[k],
3505 							&mode_lib->vba.ImmediateFlipSupportedForPipe[k]);
3506 					}
3507 
3508 					{
3509 						dml32_CalculateImmediateFlipBandwithSupport(mode_lib->vba.NumberOfActiveSurfaces,
3510 								mode_lib->vba.ReturnBWPerState[i][j],
3511 								mode_lib->vba.ImmediateFlipRequirement,
3512 								mode_lib->vba.final_flip_bw,
3513 								mode_lib->vba.ReadBandwidthLuma,
3514 								mode_lib->vba.ReadBandwidthChroma,
3515 								mode_lib->vba.RequiredPrefetchPixelDataBWLuma[0][0],
3516 								mode_lib->vba.RequiredPrefetchPixelDataBWChroma[0][0],
3517 								mode_lib->vba.cursor_bw,
3518 								mode_lib->vba.meta_row_bandwidth_this_state,
3519 								mode_lib->vba.dpte_row_bandwidth_this_state,
3520 								mode_lib->vba.cursor_bw_pre,
3521 								mode_lib->vba.prefetch_vmrow_bw,
3522 								mode_lib->vba.DPPPerPlane,
3523 								mode_lib->vba.UrgentBurstFactorLuma,
3524 								mode_lib->vba.UrgentBurstFactorChroma,
3525 								mode_lib->vba.UrgentBurstFactorCursor,
3526 								mode_lib->vba.UrgentBurstFactorLumaPre,
3527 								mode_lib->vba.UrgentBurstFactorChromaPre,
3528 								mode_lib->vba.UrgentBurstFactorCursorPre,
3529 
3530 								/* output */
3531 								&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_single[0], //  Single  *TotalBandwidth
3532 								&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_single[1], //  Single  *FractionOfUrgentBandwidth
3533 								&mode_lib->vba.ImmediateFlipSupportedForState[i][j]); // Boolean *ImmediateFlipBandwidthSupport
3534 					}
3535 
3536 					for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
3537 						if (!(mode_lib->vba.ImmediateFlipRequirement[k]
3538 								== dm_immediate_flip_not_required)
3539 								&& (mode_lib->vba.ImmediateFlipSupportedForPipe[k]
3540 										== false))
3541 							mode_lib->vba.ImmediateFlipSupportedForState[i][j] = false;
3542 					}
3543 				} else { // if prefetch not support, assume iflip not supported
3544 					mode_lib->vba.ImmediateFlipSupportedForState[i][j] = false;
3545 				}
3546 
3547 				if (mode_lib->vba.MaxVStartup <= __DML_VBA_MIN_VSTARTUP__
3548 						|| mode_lib->vba.AnyLinesForVMOrRowTooLarge == false) {
3549 					mode_lib->vba.NextMaxVStartup = mode_lib->vba.MaxMaxVStartup[i][j];
3550 					v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.NextPrefetchModeState = v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.NextPrefetchModeState + 1;
3551 				} else {
3552 					mode_lib->vba.NextMaxVStartup = mode_lib->vba.NextMaxVStartup - 1;
3553 				}
3554 			} while (!((mode_lib->vba.PrefetchSupported[i][j] == true
3555 					&& mode_lib->vba.DynamicMetadataSupported[i][j] == true
3556 					&& mode_lib->vba.VRatioInPrefetchSupported[i][j] == true &&
3557 					// consider flip support is okay if when there is no hostvm and the
3558 					// user does't require a iflip OR the flip bw is ok
3559 					// If there is hostvm, DCN needs to support iflip for invalidation
3560 					((mode_lib->vba.HostVMEnable == false
3561 							&& !mode_lib->vba.ImmediateFlipRequiredFinal)
3562 							|| mode_lib->vba.ImmediateFlipSupportedForState[i][j] == true))
3563 					|| (mode_lib->vba.NextMaxVStartup == mode_lib->vba.MaxMaxVStartup[i][j]
3564 							&& v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.NextPrefetchModeState > mode_lib->vba.MaxPrefetchMode)));
3565 
3566 			for (k = 0; k < mode_lib->vba.NumberOfActiveSurfaces; ++k) {
3567 				mode_lib->vba.use_one_row_for_frame_this_state[k] =
3568 						mode_lib->vba.use_one_row_for_frame[i][j][k];
3569 			}
3570 
3571 
3572 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.mSOCParameters.UrgentLatency = mode_lib->vba.UrgLatency[i];
3573 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.mSOCParameters.ExtraLatency = mode_lib->vba.ExtraLatency;
3574 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.mSOCParameters.WritebackLatency = mode_lib->vba.WritebackLatency;
3575 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.mSOCParameters.DRAMClockChangeLatency = mode_lib->vba.DRAMClockChangeLatency;
3576 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.mSOCParameters.FCLKChangeLatency = mode_lib->vba.FCLKChangeLatency;
3577 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.mSOCParameters.SRExitTime = mode_lib->vba.SRExitTime;
3578 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.mSOCParameters.SREnterPlusExitTime = mode_lib->vba.SREnterPlusExitTime;
3579 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.mSOCParameters.SRExitZ8Time = mode_lib->vba.SRExitZ8Time;
3580 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.mSOCParameters.SREnterPlusExitZ8Time = mode_lib->vba.SREnterPlusExitZ8Time;
3581 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.mSOCParameters.USRRetrainingLatency = mode_lib->vba.USRRetrainingLatency;
3582 			v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.mSOCParameters.SMNLatency = mode_lib->vba.SMNLatency;
3583 
3584 			{
3585 				dml32_CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport(
3586 						v,
3587 						v->PrefetchModePerState[i][j],
3588 						v->DCFCLKState[i][j],
3589 						v->ReturnBWPerState[i][j],
3590 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.mSOCParameters,
3591 						v->SOCCLKPerState[i],
3592 						v->ProjectedDCFCLKDeepSleep[i][j],
3593 						v->DETBufferSizeYThisState,
3594 						v->DETBufferSizeCThisState,
3595 						v->SwathHeightYThisState,
3596 						v->SwathHeightCThisState,
3597 						v->SwathWidthYThisState, // 24
3598 						v->SwathWidthCThisState,
3599 						v->NoOfDPPThisState,
3600 						v->BytePerPixelInDETY,
3601 						v->BytePerPixelInDETC,
3602 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.DSTXAfterScaler,
3603 						v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.DSTYAfterScaler,
3604 						v->UnboundedRequestEnabledThisState,
3605 						v->CompressedBufferSizeInkByteThisState,
3606 
3607 						/* Output */
3608 						&v->DRAMClockChangeSupport[i][j],
3609 						&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_single2[0], // double *MaxActiveDRAMClockChangeLatencySupported
3610 						&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_integer[0], // Long SubViewportLinesNeededInMALL[]
3611 						&v->FCLKChangeSupport[i][j],
3612 						&v->dummy_vars.dml32_ModeSupportAndSystemConfigurationFull.dummy_single2[1], // double *MinActiveFCLKChangeLatencySupported
3613 						&mode_lib->vba.USRRetrainingSupport[i][j],
3614 						mode_lib->vba.ActiveDRAMClockChangeLatencyMarginPerState[i][j]);
3615 			}
3616 		}
3617 	} // End of Prefetch Check
3618 
3619 	/*Cursor Support Check*/
3620 	mode_lib->vba.CursorSupport = true;
3621 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
3622 		if (mode_lib->vba.CursorWidth[k][0] > 0.0) {
3623 			if (mode_lib->vba.CursorBPP[k][0] == 64 && mode_lib->vba.Cursor64BppSupport == false)
3624 				mode_lib->vba.CursorSupport = false;
3625 		}
3626 	}
3627 
3628 	/*Valid Pitch Check*/
3629 	mode_lib->vba.PitchSupport = true;
3630 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
3631 		mode_lib->vba.AlignedYPitch[k] = dml_ceil(
3632 				dml_max(mode_lib->vba.PitchY[k], mode_lib->vba.SurfaceWidthY[k]),
3633 				mode_lib->vba.MacroTileWidthY[k]);
3634 		if (mode_lib->vba.DCCEnable[k] == true) {
3635 			mode_lib->vba.AlignedDCCMetaPitchY[k] = dml_ceil(
3636 					dml_max(mode_lib->vba.DCCMetaPitchY[k], mode_lib->vba.SurfaceWidthY[k]),
3637 					64.0 * mode_lib->vba.Read256BlockWidthY[k]);
3638 		} else {
3639 			mode_lib->vba.AlignedDCCMetaPitchY[k] = mode_lib->vba.DCCMetaPitchY[k];
3640 		}
3641 		if (mode_lib->vba.SourcePixelFormat[k] != dm_444_64 && mode_lib->vba.SourcePixelFormat[k] != dm_444_32
3642 				&& mode_lib->vba.SourcePixelFormat[k] != dm_444_16
3643 				&& mode_lib->vba.SourcePixelFormat[k] != dm_mono_16
3644 				&& mode_lib->vba.SourcePixelFormat[k] != dm_rgbe
3645 				&& mode_lib->vba.SourcePixelFormat[k] != dm_mono_8) {
3646 			mode_lib->vba.AlignedCPitch[k] = dml_ceil(
3647 					dml_max(mode_lib->vba.PitchC[k], mode_lib->vba.SurfaceWidthC[k]),
3648 					mode_lib->vba.MacroTileWidthC[k]);
3649 			if (mode_lib->vba.DCCEnable[k] == true) {
3650 				mode_lib->vba.AlignedDCCMetaPitchC[k] = dml_ceil(
3651 						dml_max(mode_lib->vba.DCCMetaPitchC[k],
3652 								mode_lib->vba.SurfaceWidthC[k]),
3653 						64.0 * mode_lib->vba.Read256BlockWidthC[k]);
3654 			} else {
3655 				mode_lib->vba.AlignedDCCMetaPitchC[k] = mode_lib->vba.DCCMetaPitchC[k];
3656 			}
3657 		} else {
3658 			mode_lib->vba.AlignedCPitch[k] = mode_lib->vba.PitchC[k];
3659 			mode_lib->vba.AlignedDCCMetaPitchC[k] = mode_lib->vba.DCCMetaPitchC[k];
3660 		}
3661 		if (mode_lib->vba.AlignedYPitch[k] > mode_lib->vba.PitchY[k]
3662 				|| mode_lib->vba.AlignedCPitch[k] > mode_lib->vba.PitchC[k]
3663 				|| mode_lib->vba.AlignedDCCMetaPitchY[k] > mode_lib->vba.DCCMetaPitchY[k]
3664 				|| mode_lib->vba.AlignedDCCMetaPitchC[k] > mode_lib->vba.DCCMetaPitchC[k]) {
3665 			mode_lib->vba.PitchSupport = false;
3666 		}
3667 	}
3668 
3669 	mode_lib->vba.ViewportExceedsSurface = false;
3670 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
3671 		if (mode_lib->vba.ViewportWidth[k] > mode_lib->vba.SurfaceWidthY[k]
3672 				|| mode_lib->vba.ViewportHeight[k] > mode_lib->vba.SurfaceHeightY[k]) {
3673 			mode_lib->vba.ViewportExceedsSurface = true;
3674 			if (mode_lib->vba.SourcePixelFormat[k] != dm_444_64
3675 					&& mode_lib->vba.SourcePixelFormat[k] != dm_444_32
3676 					&& mode_lib->vba.SourcePixelFormat[k] != dm_444_16
3677 					&& mode_lib->vba.SourcePixelFormat[k] != dm_444_8
3678 					&& mode_lib->vba.SourcePixelFormat[k] != dm_rgbe) {
3679 				if (mode_lib->vba.ViewportWidthChroma[k] > mode_lib->vba.SurfaceWidthC[k]
3680 						|| mode_lib->vba.ViewportHeightChroma[k]
3681 								> mode_lib->vba.SurfaceHeightC[k]) {
3682 					mode_lib->vba.ViewportExceedsSurface = true;
3683 				}
3684 			}
3685 		}
3686 	}
3687 
3688 	/*Mode Support, Voltage State and SOC Configuration*/
3689 	mode_support_configuration(v, mode_lib);
3690 
3691 	MaximumMPCCombine = 0;
3692 
3693 	for (i = v->soc.num_states; i >= start_state; i--) {
3694 		if (i == v->soc.num_states || mode_lib->vba.ModeSupport[i][0] == true ||
3695 				mode_lib->vba.ModeSupport[i][1] == true) {
3696 			mode_lib->vba.VoltageLevel = i;
3697 			mode_lib->vba.ModeIsSupported = mode_lib->vba.ModeSupport[i][0] == true
3698 					|| mode_lib->vba.ModeSupport[i][1] == true;
3699 
3700 			if (mode_lib->vba.ModeSupport[i][0] == true)
3701 				MaximumMPCCombine = 0;
3702 			else
3703 				MaximumMPCCombine = 1;
3704 		}
3705 	}
3706 
3707 	mode_lib->vba.ImmediateFlipSupport =
3708 			mode_lib->vba.ImmediateFlipSupportedForState[mode_lib->vba.VoltageLevel][MaximumMPCCombine];
3709 	mode_lib->vba.UnboundedRequestEnabled =
3710 			mode_lib->vba.UnboundedRequestEnabledAllStates[mode_lib->vba.VoltageLevel][MaximumMPCCombine];
3711 	mode_lib->vba.CompressedBufferSizeInkByte =
3712 			mode_lib->vba.CompressedBufferSizeInkByteAllStates[mode_lib->vba.VoltageLevel][MaximumMPCCombine]; // Not used, informational
3713 
3714 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
3715 		mode_lib->vba.MPCCombineEnable[k] =
3716 				mode_lib->vba.MPCCombine[mode_lib->vba.VoltageLevel][MaximumMPCCombine][k];
3717 		mode_lib->vba.DPPPerPlane[k] = mode_lib->vba.NoOfDPP[mode_lib->vba.VoltageLevel][MaximumMPCCombine][k];
3718 		mode_lib->vba.SwathHeightY[k] =
3719 				mode_lib->vba.SwathHeightYAllStates[mode_lib->vba.VoltageLevel][MaximumMPCCombine][k];
3720 		mode_lib->vba.SwathHeightC[k] =
3721 				mode_lib->vba.SwathHeightCAllStates[mode_lib->vba.VoltageLevel][MaximumMPCCombine][k];
3722 		mode_lib->vba.DETBufferSizeInKByte[k] =
3723 			mode_lib->vba.DETBufferSizeInKByteAllStates[mode_lib->vba.VoltageLevel][MaximumMPCCombine][k];
3724 		mode_lib->vba.DETBufferSizeY[k] =
3725 				mode_lib->vba.DETBufferSizeYAllStates[mode_lib->vba.VoltageLevel][MaximumMPCCombine][k];
3726 		mode_lib->vba.DETBufferSizeC[k] =
3727 				mode_lib->vba.DETBufferSizeCAllStates[mode_lib->vba.VoltageLevel][MaximumMPCCombine][k];
3728 		mode_lib->vba.OutputType[k] = mode_lib->vba.OutputTypePerState[mode_lib->vba.VoltageLevel][k];
3729 		mode_lib->vba.OutputRate[k] = mode_lib->vba.OutputRatePerState[mode_lib->vba.VoltageLevel][k];
3730 	}
3731 
3732 	mode_lib->vba.DCFCLK = mode_lib->vba.DCFCLKState[mode_lib->vba.VoltageLevel][MaximumMPCCombine];
3733 	mode_lib->vba.DRAMSpeed = mode_lib->vba.DRAMSpeedPerState[mode_lib->vba.VoltageLevel];
3734 	mode_lib->vba.FabricClock = mode_lib->vba.FabricClockPerState[mode_lib->vba.VoltageLevel];
3735 	mode_lib->vba.SOCCLK = mode_lib->vba.SOCCLKPerState[mode_lib->vba.VoltageLevel];
3736 	mode_lib->vba.ReturnBW = mode_lib->vba.ReturnBWPerState[mode_lib->vba.VoltageLevel][MaximumMPCCombine];
3737 	mode_lib->vba.DISPCLK = mode_lib->vba.RequiredDISPCLK[mode_lib->vba.VoltageLevel][MaximumMPCCombine];
3738 	mode_lib->vba.maxMpcComb = MaximumMPCCombine;
3739 
3740 	for (k = 0; k <= mode_lib->vba.NumberOfActiveSurfaces - 1; k++) {
3741 		if (mode_lib->vba.BlendingAndTiming[k] == k) {
3742 			mode_lib->vba.ODMCombineEnabled[k] =
3743 					mode_lib->vba.ODMCombineEnablePerState[mode_lib->vba.VoltageLevel][k];
3744 		} else {
3745 			mode_lib->vba.ODMCombineEnabled[k] = dm_odm_combine_mode_disabled;
3746 		}
3747 
3748 		mode_lib->vba.DSCEnabled[k] = mode_lib->vba.RequiresDSC[mode_lib->vba.VoltageLevel][k];
3749 		mode_lib->vba.FECEnable[k] = mode_lib->vba.RequiresFEC[mode_lib->vba.VoltageLevel][k];
3750 		mode_lib->vba.OutputBpp[k] = mode_lib->vba.OutputBppPerState[mode_lib->vba.VoltageLevel][k];
3751 	}
3752 
3753 	mode_lib->vba.UrgentWatermark = mode_lib->vba.Watermark.UrgentWatermark;
3754 	mode_lib->vba.StutterEnterPlusExitWatermark = mode_lib->vba.Watermark.StutterEnterPlusExitWatermark;
3755 	mode_lib->vba.StutterExitWatermark = mode_lib->vba.Watermark.StutterExitWatermark;
3756 	mode_lib->vba.WritebackDRAMClockChangeWatermark = mode_lib->vba.Watermark.WritebackDRAMClockChangeWatermark;
3757 	mode_lib->vba.DRAMClockChangeWatermark = mode_lib->vba.Watermark.DRAMClockChangeWatermark;
3758 	mode_lib->vba.UrgentLatency = mode_lib->vba.UrgLatency[mode_lib->vba.VoltageLevel];
3759 	mode_lib->vba.DCFCLKDeepSleep = mode_lib->vba.ProjectedDCFCLKDeepSleep[mode_lib->vba.VoltageLevel][MaximumMPCCombine];
3760 
3761 	/* VBA has Error type to Error Msg output here, but not necessary for DML-C */
3762 } // ModeSupportAndSystemConfigurationFull
3763