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