1 /* SPDX-License-Identifier: MIT */
2 /*
3 * Copyright 2023 Advanced Micro Devices, Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22 *
23 * Authors: AMD
24 *
25 */
26
27 #include "display_mode_core.h"
28 #include "display_mode_util.h"
29 #include "display_mode_lib_defines.h"
30
31 #include "dml_assert.h"
32
33 #define DML2_MAX_FMT_420_BUFFER_WIDTH 4096
34 #define TB_BORROWED_MAX 400
35
36 // ---------------------------
37 // Declaration Begins
38 // ---------------------------
39 static void CalculateBytePerPixelAndBlockSizes(
40 enum dml_source_format_class SourcePixelFormat,
41 enum dml_swizzle_mode SurfaceTiling,
42 // Output
43 dml_uint_t *BytePerPixelY,
44 dml_uint_t *BytePerPixelC,
45 dml_float_t *BytePerPixelDETY,
46 dml_float_t *BytePerPixelDETC,
47 dml_uint_t *BlockHeight256BytesY,
48 dml_uint_t *BlockHeight256BytesC,
49 dml_uint_t *BlockWidth256BytesY,
50 dml_uint_t *BlockWidth256BytesC,
51 dml_uint_t *MacroTileHeightY,
52 dml_uint_t *MacroTileHeightC,
53 dml_uint_t *MacroTileWidthY,
54 dml_uint_t *MacroTileWidthC);
55
56 static dml_float_t CalculateWriteBackDISPCLK(
57 enum dml_source_format_class WritebackPixelFormat,
58 dml_float_t PixelClock,
59 dml_float_t WritebackHRatio,
60 dml_float_t WritebackVRatio,
61 dml_uint_t WritebackHTaps,
62 dml_uint_t WritebackVTaps,
63 dml_uint_t WritebackSourceWidth,
64 dml_uint_t WritebackDestinationWidth,
65 dml_uint_t HTotal,
66 dml_uint_t WritebackLineBufferSize,
67 dml_float_t DISPCLKDPPCLKVCOSpeed);
68
69 static void CalculateVMRowAndSwath(
70 struct display_mode_lib_scratch_st *s,
71 struct CalculateVMRowAndSwath_params_st *p);
72
73 static void CalculateOutputLink(
74 dml_float_t PHYCLKPerState,
75 dml_float_t PHYCLKD18PerState,
76 dml_float_t PHYCLKD32PerState,
77 dml_float_t Downspreading,
78 dml_bool_t IsMainSurfaceUsingTheIndicatedTiming,
79 enum dml_output_encoder_class Output,
80 enum dml_output_format_class OutputFormat,
81 dml_uint_t HTotal,
82 dml_uint_t HActive,
83 dml_float_t PixelClockBackEnd,
84 dml_float_t ForcedOutputLinkBPP,
85 dml_uint_t DSCInputBitPerComponent,
86 dml_uint_t NumberOfDSCSlices,
87 dml_float_t AudioSampleRate,
88 dml_uint_t AudioSampleLayout,
89 enum dml_odm_mode ODMModeNoDSC,
90 enum dml_odm_mode ODMModeDSC,
91 enum dml_dsc_enable DSCEnable,
92 dml_uint_t OutputLinkDPLanes,
93 enum dml_output_link_dp_rate OutputLinkDPRate,
94
95 // Output
96 dml_bool_t *RequiresDSC,
97 dml_bool_t *RequiresFEC,
98 dml_float_t *OutBpp,
99 enum dml_output_type_and_rate__type *OutputType,
100 enum dml_output_type_and_rate__rate *OutputRate,
101 dml_uint_t *RequiredSlots);
102
103 static void CalculateODMMode(
104 dml_uint_t MaximumPixelsPerLinePerDSCUnit,
105 dml_uint_t HActive,
106 enum dml_output_encoder_class Output,
107 enum dml_output_format_class OutputFormat,
108 enum dml_odm_use_policy ODMUse,
109 dml_float_t StateDispclk,
110 dml_float_t MaxDispclk,
111 dml_bool_t DSCEnable,
112 dml_uint_t TotalNumberOfActiveDPP,
113 dml_uint_t MaxNumDPP,
114 dml_float_t PixelClock,
115 dml_float_t DISPCLKDPPCLKDSCCLKDownSpreading,
116 dml_float_t DISPCLKRampingMargin,
117 dml_float_t DISPCLKDPPCLKVCOSpeed,
118 dml_uint_t NumberOfDSCSlices,
119
120 // Output
121 dml_bool_t *TotalAvailablePipesSupport,
122 dml_uint_t *NumberOfDPP,
123 enum dml_odm_mode *ODMMode,
124 dml_float_t *RequiredDISPCLKPerSurface);
125
126 static dml_float_t CalculateRequiredDispclk(
127 enum dml_odm_mode ODMMode,
128 dml_float_t PixelClock,
129 dml_float_t DISPCLKDPPCLKDSCCLKDownSpreading,
130 dml_float_t DISPCLKRampingMargin,
131 dml_float_t DISPCLKDPPCLKVCOSpeed,
132 dml_float_t MaxDispclkSingle);
133
134 static void CalculateSinglePipeDPPCLKAndSCLThroughput(
135 dml_float_t HRatio,
136 dml_float_t HRatioChroma,
137 dml_float_t VRatio,
138 dml_float_t VRatioChroma,
139 dml_float_t MaxDCHUBToPSCLThroughput,
140 dml_float_t MaxPSCLToLBThroughput,
141 dml_float_t PixelClock,
142 enum dml_source_format_class SourcePixelFormat,
143 dml_uint_t HTaps,
144 dml_uint_t HTapsChroma,
145 dml_uint_t VTaps,
146 dml_uint_t VTapsChroma,
147
148 // Output
149 dml_float_t *PSCL_THROUGHPUT,
150 dml_float_t *PSCL_THROUGHPUT_CHROMA,
151 dml_float_t *DPPCLKUsingSingleDPP);
152
153 static void CalculateDPPCLK(
154 dml_uint_t NumberOfActiveSurfaces,
155 dml_float_t DISPCLKDPPCLKDSCCLKDownSpreading,
156 dml_float_t DISPCLKDPPCLKVCOSpeed,
157 dml_float_t DPPCLKUsingSingleDPP[],
158 dml_uint_t DPPPerSurface[],
159
160 // Output
161 dml_float_t *GlobalDPPCLK,
162 dml_float_t Dppclk[]);
163
164 static void CalculateMALLUseForStaticScreen(
165 dml_uint_t NumberOfActiveSurfaces,
166 dml_uint_t MALLAllocatedForDCNFinal,
167 enum dml_use_mall_for_static_screen_mode *UseMALLForStaticScreen,
168 dml_uint_t SurfaceSizeInMALL[],
169 dml_bool_t one_row_per_frame_fits_in_buffer[],
170
171 // Output
172 dml_bool_t UsesMALLForStaticScreen[]);
173
174 static dml_uint_t dscceComputeDelay(
175 dml_uint_t bpc,
176 dml_float_t BPP,
177 dml_uint_t sliceWidth,
178 dml_uint_t numSlices,
179 enum dml_output_format_class pixelFormat,
180 enum dml_output_encoder_class Output);
181
182 static dml_uint_t dscComputeDelay(enum dml_output_format_class pixelFormat,
183 enum dml_output_encoder_class Output);
184
185 static dml_bool_t CalculatePrefetchSchedule(struct display_mode_lib_scratch_st *scratch,
186 struct CalculatePrefetchSchedule_params_st *p);
187
188 static dml_float_t RoundToDFSGranularity(dml_float_t Clock, dml_bool_t round_up, dml_float_t VCOSpeed);
189
190 static void CalculateDCCConfiguration(
191 dml_bool_t DCCEnabled,
192 dml_bool_t DCCProgrammingAssumesScanDirectionUnknown,
193 enum dml_source_format_class SourcePixelFormat,
194 dml_uint_t SurfaceWidthLuma,
195 dml_uint_t SurfaceWidthChroma,
196 dml_uint_t SurfaceHeightLuma,
197 dml_uint_t SurfaceHeightChroma,
198 dml_uint_t nomDETInKByte,
199 dml_uint_t RequestHeight256ByteLuma,
200 dml_uint_t RequestHeight256ByteChroma,
201 enum dml_swizzle_mode TilingFormat,
202 dml_uint_t BytePerPixelY,
203 dml_uint_t BytePerPixelC,
204 dml_float_t BytePerPixelDETY,
205 dml_float_t BytePerPixelDETC,
206 enum dml_rotation_angle SourceScan,
207 // Output
208 dml_uint_t *MaxUncompressedBlockLuma,
209 dml_uint_t *MaxUncompressedBlockChroma,
210 dml_uint_t *MaxCompressedBlockLuma,
211 dml_uint_t *MaxCompressedBlockChroma,
212 dml_uint_t *IndependentBlockLuma,
213 dml_uint_t *IndependentBlockChroma);
214
215 static dml_uint_t CalculatePrefetchSourceLines(
216 dml_float_t VRatio,
217 dml_uint_t VTaps,
218 dml_bool_t Interlace,
219 dml_bool_t ProgressiveToInterlaceUnitInOPP,
220 dml_uint_t SwathHeight,
221 enum dml_rotation_angle SourceScan,
222 dml_bool_t ViewportStationary,
223 dml_uint_t SwathWidth,
224 dml_uint_t ViewportHeight,
225 dml_uint_t ViewportXStart,
226 dml_uint_t ViewportYStart,
227
228 // Output
229 dml_uint_t *VInitPreFill,
230 dml_uint_t *MaxNumSwath);
231
232 static dml_uint_t CalculateVMAndRowBytes(
233 dml_bool_t ViewportStationary,
234 dml_bool_t DCCEnable,
235 dml_uint_t NumberOfDPPs,
236 dml_uint_t BlockHeight256Bytes,
237 dml_uint_t BlockWidth256Bytes,
238 enum dml_source_format_class SourcePixelFormat,
239 dml_uint_t SurfaceTiling,
240 dml_uint_t BytePerPixel,
241 enum dml_rotation_angle SourceScan,
242 dml_uint_t SwathWidth,
243 dml_uint_t ViewportHeight,
244 dml_uint_t ViewportXStart,
245 dml_uint_t ViewportYStart,
246 dml_bool_t GPUVMEnable,
247 dml_uint_t GPUVMMaxPageTableLevels,
248 dml_uint_t GPUVMMinPageSizeKBytes,
249 dml_uint_t PTEBufferSizeInRequests,
250 dml_uint_t Pitch,
251 dml_uint_t DCCMetaPitch,
252 dml_uint_t MacroTileWidth,
253 dml_uint_t MacroTileHeight,
254
255 // Output
256 dml_uint_t *MetaRowByte,
257 dml_uint_t *PixelPTEBytesPerRow,
258 dml_uint_t *PixelPTEBytesPerRowStorage, // for PTE buffer size check
259 dml_uint_t *dpte_row_width_ub,
260 dml_uint_t *dpte_row_height,
261 dml_uint_t *dpte_row_height_linear,
262 dml_uint_t *PixelPTEBytesPerRow_one_row_per_frame,
263 dml_uint_t *dpte_row_width_ub_one_row_per_frame,
264 dml_uint_t *dpte_row_height_one_row_per_frame,
265 dml_uint_t *MetaRequestWidth,
266 dml_uint_t *MetaRequestHeight,
267 dml_uint_t *meta_row_width,
268 dml_uint_t *meta_row_height,
269 dml_uint_t *PixelPTEReqWidth,
270 dml_uint_t *PixelPTEReqHeight,
271 dml_uint_t *PTERequestSize,
272 dml_uint_t *DPDE0BytesFrame,
273 dml_uint_t *MetaPTEBytesFrame);
274
275 static dml_float_t CalculateTWait(
276 dml_uint_t PrefetchMode,
277 enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange,
278 dml_bool_t SynchronizeDRRDisplaysForUCLKPStateChangeFinal,
279 dml_bool_t DRRDisplay,
280 dml_float_t DRAMClockChangeLatency,
281 dml_float_t FCLKChangeLatency,
282 dml_float_t UrgentLatency,
283 dml_float_t SREnterPlusExitTime);
284
285 static void CalculatePrefetchMode(
286 enum dml_prefetch_modes AllowForPStateChangeOrStutterInVBlank,
287 dml_uint_t *MinPrefetchMode,
288 dml_uint_t *MaxPrefetchMode);
289
290 static void CalculateRowBandwidth(
291 dml_bool_t GPUVMEnable,
292 enum dml_source_format_class SourcePixelFormat,
293 dml_float_t VRatio,
294 dml_float_t VRatioChroma,
295 dml_bool_t DCCEnable,
296 dml_float_t LineTime,
297 dml_uint_t MetaRowByteLuma,
298 dml_uint_t MetaRowByteChroma,
299 dml_uint_t meta_row_height_luma,
300 dml_uint_t meta_row_height_chroma,
301 dml_uint_t PixelPTEBytesPerRowLuma,
302 dml_uint_t PixelPTEBytesPerRowChroma,
303 dml_uint_t dpte_row_height_luma,
304 dml_uint_t dpte_row_height_chroma,
305 // Output
306 dml_float_t *meta_row_bw,
307 dml_float_t *dpte_row_bw);
308
309 static void CalculateFlipSchedule(
310 dml_float_t HostVMInefficiencyFactor,
311 dml_float_t UrgentExtraLatency,
312 dml_float_t UrgentLatency,
313 dml_uint_t GPUVMMaxPageTableLevels,
314 dml_bool_t HostVMEnable,
315 dml_uint_t HostVMMaxNonCachedPageTableLevels,
316 dml_bool_t GPUVMEnable,
317 dml_uint_t HostVMMinPageSize,
318 dml_float_t PDEAndMetaPTEBytesPerFrame,
319 dml_float_t MetaRowBytes,
320 dml_float_t DPTEBytesPerRow,
321 dml_float_t BandwidthAvailableForImmediateFlip,
322 dml_uint_t TotImmediateFlipBytes,
323 enum dml_source_format_class SourcePixelFormat,
324 dml_float_t LineTime,
325 dml_float_t VRatio,
326 dml_float_t VRatioChroma,
327 dml_float_t Tno_bw,
328 dml_bool_t DCCEnable,
329 dml_uint_t dpte_row_height,
330 dml_uint_t meta_row_height,
331 dml_uint_t dpte_row_height_chroma,
332 dml_uint_t meta_row_height_chroma,
333 dml_bool_t use_one_row_for_frame_flip,
334
335 // Output
336 dml_float_t *DestinationLinesToRequestVMInImmediateFlip,
337 dml_float_t *DestinationLinesToRequestRowInImmediateFlip,
338 dml_float_t *final_flip_bw,
339 dml_bool_t *ImmediateFlipSupportedForPipe);
340
341 static dml_float_t CalculateWriteBackDelay(
342 enum dml_source_format_class WritebackPixelFormat,
343 dml_float_t WritebackHRatio,
344 dml_float_t WritebackVRatio,
345 dml_uint_t WritebackVTaps,
346 dml_uint_t WritebackDestinationWidth,
347 dml_uint_t WritebackDestinationHeight,
348 dml_uint_t WritebackSourceHeight,
349 dml_uint_t HTotal);
350
351 static void CalculateVUpdateAndDynamicMetadataParameters(
352 dml_uint_t MaxInterDCNTileRepeaters,
353 dml_float_t Dppclk,
354 dml_float_t DISPCLK,
355 dml_float_t DCFClkDeepSleep,
356 dml_float_t PixelClock,
357 dml_uint_t HTotal,
358 dml_uint_t VBlank,
359 dml_uint_t DynamicMetadataTransmittedBytes,
360 dml_uint_t DynamicMetadataLinesBeforeActiveRequired,
361 dml_uint_t InterlaceEnable,
362 dml_bool_t ProgressiveToInterlaceUnitInOPP,
363 dml_float_t *TSetup,
364 dml_float_t *Tdmbf,
365 dml_float_t *Tdmec,
366 dml_float_t *Tdmsks,
367 dml_uint_t *VUpdateOffsetPix,
368 dml_uint_t *VUpdateWidthPix,
369 dml_uint_t *VReadyOffsetPix);
370
371 static void PixelClockAdjustmentForProgressiveToInterlaceUnit(struct dml_display_cfg_st *display_cfg, dml_bool_t ptoi_supported);
372
373 static dml_float_t TruncToValidBPP(
374 dml_float_t LinkBitRate,
375 dml_uint_t Lanes,
376 dml_uint_t HTotal,
377 dml_uint_t HActive,
378 dml_float_t PixelClock,
379 dml_float_t DesiredBPP,
380 dml_bool_t DSCEnable,
381 enum dml_output_encoder_class Output,
382 enum dml_output_format_class Format,
383 dml_uint_t DSCInputBitPerComponent,
384 dml_uint_t DSCSlices,
385 dml_uint_t AudioRate,
386 dml_uint_t AudioLayout,
387 enum dml_odm_mode ODMModeNoDSC,
388 enum dml_odm_mode ODMModeDSC,
389 // Output
390 dml_uint_t *RequiredSlotsSingle);
391
392 static void CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport(
393 struct display_mode_lib_scratch_st *s,
394 struct CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_params_st *p);
395
396 static void CalculateDCFCLKDeepSleep(
397 dml_uint_t NumberOfActiveSurfaces,
398 dml_uint_t BytePerPixelY[],
399 dml_uint_t BytePerPixelC[],
400 dml_float_t VRatio[],
401 dml_float_t VRatioChroma[],
402 dml_uint_t SwathWidthY[],
403 dml_uint_t SwathWidthC[],
404 dml_uint_t DPPPerSurface[],
405 dml_float_t HRatio[],
406 dml_float_t HRatioChroma[],
407 dml_float_t PixelClock[],
408 dml_float_t PSCL_THROUGHPUT[],
409 dml_float_t PSCL_THROUGHPUT_CHROMA[],
410 dml_float_t Dppclk[],
411 dml_float_t ReadBandwidthLuma[],
412 dml_float_t ReadBandwidthChroma[],
413 dml_uint_t ReturnBusWidth,
414
415 // Output
416 dml_float_t *DCFCLKDeepSleep);
417
418 static void CalculateUrgentBurstFactor(
419 enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange,
420 dml_uint_t swath_width_luma_ub,
421 dml_uint_t swath_width_chroma_ub,
422 dml_uint_t SwathHeightY,
423 dml_uint_t SwathHeightC,
424 dml_float_t LineTime,
425 dml_float_t UrgentLatency,
426 dml_float_t CursorBufferSize,
427 dml_uint_t CursorWidth,
428 dml_uint_t CursorBPP,
429 dml_float_t VRatio,
430 dml_float_t VRatioC,
431 dml_float_t BytePerPixelInDETY,
432 dml_float_t BytePerPixelInDETC,
433 dml_uint_t DETBufferSizeY,
434 dml_uint_t DETBufferSizeC,
435 // Output
436 dml_float_t *UrgentBurstFactorCursor,
437 dml_float_t *UrgentBurstFactorLuma,
438 dml_float_t *UrgentBurstFactorChroma,
439 dml_bool_t *NotEnoughUrgentLatencyHiding);
440
441 static dml_float_t RequiredDTBCLK(
442 dml_bool_t DSCEnable,
443 dml_float_t PixelClock,
444 enum dml_output_format_class OutputFormat,
445 dml_float_t OutputBpp,
446 dml_uint_t DSCSlices,
447 dml_uint_t HTotal,
448 dml_uint_t HActive,
449 dml_uint_t AudioRate,
450 dml_uint_t AudioLayoutSingle);
451
452 static void UseMinimumDCFCLK(
453 struct display_mode_lib_scratch_st *scratch,
454 struct UseMinimumDCFCLK_params_st *p);
455
456 static void CalculatePixelDeliveryTimes(
457 dml_uint_t NumberOfActiveSurfaces,
458 dml_float_t VRatio[],
459 dml_float_t VRatioChroma[],
460 dml_float_t VRatioPrefetchY[],
461 dml_float_t VRatioPrefetchC[],
462 dml_uint_t swath_width_luma_ub[],
463 dml_uint_t swath_width_chroma_ub[],
464 dml_uint_t DPPPerSurface[],
465 dml_float_t HRatio[],
466 dml_float_t HRatioChroma[],
467 dml_float_t PixelClock[],
468 dml_float_t PSCL_THROUGHPUT[],
469 dml_float_t PSCL_THROUGHPUT_CHROMA[],
470 dml_float_t Dppclk[],
471 dml_uint_t BytePerPixelC[],
472 enum dml_rotation_angle SourceScan[],
473 dml_uint_t NumberOfCursors[],
474 dml_uint_t CursorWidth[],
475 dml_uint_t CursorBPP[],
476 dml_uint_t BlockWidth256BytesY[],
477 dml_uint_t BlockHeight256BytesY[],
478 dml_uint_t BlockWidth256BytesC[],
479 dml_uint_t BlockHeight256BytesC[],
480
481 // Output
482 dml_float_t DisplayPipeLineDeliveryTimeLuma[],
483 dml_float_t DisplayPipeLineDeliveryTimeChroma[],
484 dml_float_t DisplayPipeLineDeliveryTimeLumaPrefetch[],
485 dml_float_t DisplayPipeLineDeliveryTimeChromaPrefetch[],
486 dml_float_t DisplayPipeRequestDeliveryTimeLuma[],
487 dml_float_t DisplayPipeRequestDeliveryTimeChroma[],
488 dml_float_t DisplayPipeRequestDeliveryTimeLumaPrefetch[],
489 dml_float_t DisplayPipeRequestDeliveryTimeChromaPrefetch[],
490 dml_float_t CursorRequestDeliveryTime[],
491 dml_float_t CursorRequestDeliveryTimePrefetch[]);
492
493 static void CalculateMetaAndPTETimes(
494 dml_bool_t use_one_row_for_frame[],
495 dml_uint_t NumberOfActiveSurfaces,
496 dml_bool_t GPUVMEnable,
497 dml_uint_t MetaChunkSize,
498 dml_uint_t MinMetaChunkSizeBytes,
499 dml_uint_t HTotal[],
500 dml_float_t VRatio[],
501 dml_float_t VRatioChroma[],
502 dml_float_t DestinationLinesToRequestRowInVBlank[],
503 dml_float_t DestinationLinesToRequestRowInImmediateFlip[],
504 dml_bool_t DCCEnable[],
505 dml_float_t PixelClock[],
506 dml_uint_t BytePerPixelY[],
507 dml_uint_t BytePerPixelC[],
508 enum dml_rotation_angle SourceScan[],
509 dml_uint_t dpte_row_height[],
510 dml_uint_t dpte_row_height_chroma[],
511 dml_uint_t meta_row_width[],
512 dml_uint_t meta_row_width_chroma[],
513 dml_uint_t meta_row_height[],
514 dml_uint_t meta_row_height_chroma[],
515 dml_uint_t meta_req_width[],
516 dml_uint_t meta_req_width_chroma[],
517 dml_uint_t meta_req_height[],
518 dml_uint_t meta_req_height_chroma[],
519 dml_uint_t dpte_group_bytes[],
520 dml_uint_t PTERequestSizeY[],
521 dml_uint_t PTERequestSizeC[],
522 dml_uint_t PixelPTEReqWidthY[],
523 dml_uint_t PixelPTEReqHeightY[],
524 dml_uint_t PixelPTEReqWidthC[],
525 dml_uint_t PixelPTEReqHeightC[],
526 dml_uint_t dpte_row_width_luma_ub[],
527 dml_uint_t dpte_row_width_chroma_ub[],
528
529 // Output
530 dml_float_t DST_Y_PER_PTE_ROW_NOM_L[],
531 dml_float_t DST_Y_PER_PTE_ROW_NOM_C[],
532 dml_float_t DST_Y_PER_META_ROW_NOM_L[],
533 dml_float_t DST_Y_PER_META_ROW_NOM_C[],
534 dml_float_t TimePerMetaChunkNominal[],
535 dml_float_t TimePerChromaMetaChunkNominal[],
536 dml_float_t TimePerMetaChunkVBlank[],
537 dml_float_t TimePerChromaMetaChunkVBlank[],
538 dml_float_t TimePerMetaChunkFlip[],
539 dml_float_t TimePerChromaMetaChunkFlip[],
540 dml_float_t time_per_pte_group_nom_luma[],
541 dml_float_t time_per_pte_group_vblank_luma[],
542 dml_float_t time_per_pte_group_flip_luma[],
543 dml_float_t time_per_pte_group_nom_chroma[],
544 dml_float_t time_per_pte_group_vblank_chroma[],
545 dml_float_t time_per_pte_group_flip_chroma[]);
546
547 static void CalculateVMGroupAndRequestTimes(
548 dml_uint_t NumberOfActiveSurfaces,
549 dml_bool_t GPUVMEnable,
550 dml_uint_t GPUVMMaxPageTableLevels,
551 dml_uint_t HTotal[],
552 dml_uint_t BytePerPixelC[],
553 dml_float_t DestinationLinesToRequestVMInVBlank[],
554 dml_float_t DestinationLinesToRequestVMInImmediateFlip[],
555 dml_bool_t DCCEnable[],
556 dml_float_t PixelClock[],
557 dml_uint_t dpte_row_width_luma_ub[],
558 dml_uint_t dpte_row_width_chroma_ub[],
559 dml_uint_t vm_group_bytes[],
560 dml_uint_t dpde0_bytes_per_frame_ub_l[],
561 dml_uint_t dpde0_bytes_per_frame_ub_c[],
562 dml_uint_t meta_pte_bytes_per_frame_ub_l[],
563 dml_uint_t meta_pte_bytes_per_frame_ub_c[],
564
565 // Output
566 dml_float_t TimePerVMGroupVBlank[],
567 dml_float_t TimePerVMGroupFlip[],
568 dml_float_t TimePerVMRequestVBlank[],
569 dml_float_t TimePerVMRequestFlip[]);
570
571 static void CalculateStutterEfficiency(
572 struct display_mode_lib_scratch_st *scratch,
573 struct CalculateStutterEfficiency_params_st *p);
574
575 static void CalculateSwathAndDETConfiguration(
576 struct display_mode_lib_scratch_st *scratch,
577 struct CalculateSwathAndDETConfiguration_params_st *p);
578
579 static void CalculateSwathWidth(
580 dml_bool_t ForceSingleDPP,
581 dml_uint_t NumberOfActiveSurfaces,
582 enum dml_source_format_class SourcePixelFormat[],
583 enum dml_rotation_angle SourceScan[],
584 dml_bool_t ViewportStationary[],
585 dml_uint_t ViewportWidth[],
586 dml_uint_t ViewportHeight[],
587 dml_uint_t ViewportXStart[],
588 dml_uint_t ViewportYStart[],
589 dml_uint_t ViewportXStartC[],
590 dml_uint_t ViewportYStartC[],
591 dml_uint_t SurfaceWidthY[],
592 dml_uint_t SurfaceWidthC[],
593 dml_uint_t SurfaceHeightY[],
594 dml_uint_t SurfaceHeightC[],
595 enum dml_odm_mode ODMMode[],
596 dml_uint_t BytePerPixY[],
597 dml_uint_t BytePerPixC[],
598 dml_uint_t Read256BytesBlockHeightY[],
599 dml_uint_t Read256BytesBlockHeightC[],
600 dml_uint_t Read256BytesBlockWidthY[],
601 dml_uint_t Read256BytesBlockWidthC[],
602 dml_uint_t BlendingAndTiming[],
603 dml_uint_t HActive[],
604 dml_float_t HRatio[],
605 dml_uint_t DPPPerSurface[],
606
607 // Output
608 dml_uint_t SwathWidthSingleDPPY[],
609 dml_uint_t SwathWidthSingleDPPC[],
610 dml_uint_t SwathWidthY[],
611 dml_uint_t SwathWidthC[],
612 dml_uint_t MaximumSwathHeightY[],
613 dml_uint_t MaximumSwathHeightC[],
614 dml_uint_t swath_width_luma_ub[],
615 dml_uint_t swath_width_chroma_ub[]);
616
617 static dml_float_t CalculateExtraLatency(
618 dml_uint_t RoundTripPingLatencyCycles,
619 dml_uint_t ReorderingBytes,
620 dml_float_t DCFCLK,
621 dml_uint_t TotalNumberOfActiveDPP,
622 dml_uint_t PixelChunkSizeInKByte,
623 dml_uint_t TotalNumberOfDCCActiveDPP,
624 dml_uint_t MetaChunkSize,
625 dml_float_t ReturnBW,
626 dml_bool_t GPUVMEnable,
627 dml_bool_t HostVMEnable,
628 dml_uint_t NumberOfActiveSurfaces,
629 dml_uint_t NumberOfDPP[],
630 dml_uint_t dpte_group_bytes[],
631 dml_float_t HostVMInefficiencyFactor,
632 dml_uint_t HostVMMinPageSize,
633 dml_uint_t HostVMMaxNonCachedPageTableLevels);
634
635 static dml_uint_t CalculateExtraLatencyBytes(
636 dml_uint_t ReorderingBytes,
637 dml_uint_t TotalNumberOfActiveDPP,
638 dml_uint_t PixelChunkSizeInKByte,
639 dml_uint_t TotalNumberOfDCCActiveDPP,
640 dml_uint_t MetaChunkSize,
641 dml_bool_t GPUVMEnable,
642 dml_bool_t HostVMEnable,
643 dml_uint_t NumberOfActiveSurfaces,
644 dml_uint_t NumberOfDPP[],
645 dml_uint_t dpte_group_bytes[],
646 dml_float_t HostVMInefficiencyFactor,
647 dml_uint_t HostVMMinPageSize,
648 dml_uint_t HostVMMaxNonCachedPageTableLevels);
649
650 static dml_float_t CalculateUrgentLatency(
651 dml_float_t UrgentLatencyPixelDataOnly,
652 dml_float_t UrgentLatencyPixelMixedWithVMData,
653 dml_float_t UrgentLatencyVMDataOnly,
654 dml_bool_t DoUrgentLatencyAdjustment,
655 dml_float_t UrgentLatencyAdjustmentFabricClockComponent,
656 dml_float_t UrgentLatencyAdjustmentFabricClockReference,
657 dml_float_t FabricClockSingle);
658
659 static dml_bool_t UnboundedRequest(
660 enum dml_unbounded_requesting_policy UseUnboundedRequestingFinal,
661 dml_uint_t TotalNumberOfActiveDPP,
662 dml_bool_t NoChromaOrLinear,
663 enum dml_output_encoder_class Output);
664
665 static void CalculateSurfaceSizeInMall(
666 dml_uint_t NumberOfActiveSurfaces,
667 dml_uint_t MALLAllocatedForDCN,
668 enum dml_use_mall_for_static_screen_mode UseMALLForStaticScreen[],
669 dml_bool_t DCCEnable[],
670 dml_bool_t ViewportStationary[],
671 dml_uint_t ViewportXStartY[],
672 dml_uint_t ViewportYStartY[],
673 dml_uint_t ViewportXStartC[],
674 dml_uint_t ViewportYStartC[],
675 dml_uint_t ViewportWidthY[],
676 dml_uint_t ViewportHeightY[],
677 dml_uint_t BytesPerPixelY[],
678 dml_uint_t ViewportWidthC[],
679 dml_uint_t ViewportHeightC[],
680 dml_uint_t BytesPerPixelC[],
681 dml_uint_t SurfaceWidthY[],
682 dml_uint_t SurfaceWidthC[],
683 dml_uint_t SurfaceHeightY[],
684 dml_uint_t SurfaceHeightC[],
685 dml_uint_t Read256BytesBlockWidthY[],
686 dml_uint_t Read256BytesBlockWidthC[],
687 dml_uint_t Read256BytesBlockHeightY[],
688 dml_uint_t Read256BytesBlockHeightC[],
689 dml_uint_t ReadBlockWidthY[],
690 dml_uint_t ReadBlockWidthC[],
691 dml_uint_t ReadBlockHeightY[],
692 dml_uint_t ReadBlockHeightC[],
693
694 // Output
695 dml_uint_t SurfaceSizeInMALL[],
696 dml_bool_t *ExceededMALLSize);
697
698 static void CalculateDETBufferSize(
699 dml_uint_t DETSizeOverride[],
700 enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange[],
701 dml_bool_t ForceSingleDPP,
702 dml_uint_t NumberOfActiveSurfaces,
703 dml_bool_t UnboundedRequestEnabled,
704 dml_uint_t nomDETInKByte,
705 dml_uint_t MaxTotalDETInKByte,
706 dml_uint_t ConfigReturnBufferSizeInKByte,
707 dml_uint_t MinCompressedBufferSizeInKByte,
708 dml_uint_t ConfigReturnBufferSegmentSizeInkByte,
709 dml_uint_t CompressedBufferSegmentSizeInkByteFinal,
710 enum dml_source_format_class SourcePixelFormat[],
711 dml_float_t ReadBandwidthLuma[],
712 dml_float_t ReadBandwidthChroma[],
713 dml_uint_t RotesY[],
714 dml_uint_t RoundedUpMaxSwathSizeBytesC[],
715 dml_uint_t DPPPerSurface[],
716 // Output
717 dml_uint_t DETBufferSizeInKByte[],
718 dml_uint_t *CompressedBufferSizeInkByte);
719
720 static void CalculateMaxDETAndMinCompressedBufferSize(
721 dml_uint_t ConfigReturnBufferSizeInKByte,
722 dml_uint_t ConfigReturnBufferSegmentSizeInKByte,
723 dml_uint_t ROBBufferSizeInKByte,
724 dml_uint_t MaxNumDPP,
725 dml_bool_t nomDETInKByteOverrideEnable,
726 dml_uint_t nomDETInKByteOverrideValue,
727
728 // Output
729 dml_uint_t *MaxTotalDETInKByte,
730 dml_uint_t *nomDETInKByte,
731 dml_uint_t *MinCompressedBufferSizeInKByte);
732
733 static dml_uint_t DSCDelayRequirement(
734 dml_bool_t DSCEnabled,
735 enum dml_odm_mode ODMMode,
736 dml_uint_t DSCInputBitPerComponent,
737 dml_float_t OutputBpp,
738 dml_uint_t HActive,
739 dml_uint_t HTotal,
740 dml_uint_t NumberOfDSCSlices,
741 enum dml_output_format_class OutputFormat,
742 enum dml_output_encoder_class Output,
743 dml_float_t PixelClock,
744 dml_float_t PixelClockBackEnd);
745
746 static dml_bool_t CalculateVActiveBandwithSupport(
747 dml_uint_t NumberOfActiveSurfaces,
748 dml_float_t ReturnBW,
749 dml_bool_t NotUrgentLatencyHiding[],
750 dml_float_t ReadBandwidthLuma[],
751 dml_float_t ReadBandwidthChroma[],
752 dml_float_t cursor_bw[],
753 dml_float_t meta_row_bandwidth[],
754 dml_float_t dpte_row_bandwidth[],
755 dml_uint_t NumberOfDPP[],
756 dml_float_t UrgentBurstFactorLuma[],
757 dml_float_t UrgentBurstFactorChroma[],
758 dml_float_t UrgentBurstFactorCursor[]);
759
760 static void CalculatePrefetchBandwithSupport(
761 dml_uint_t NumberOfActiveSurfaces,
762 dml_float_t ReturnBW,
763 enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange[],
764 dml_bool_t NotUrgentLatencyHiding[],
765 dml_float_t ReadBandwidthLuma[],
766 dml_float_t ReadBandwidthChroma[],
767 dml_float_t PrefetchBandwidthLuma[],
768 dml_float_t PrefetchBandwidthChroma[],
769 dml_float_t cursor_bw[],
770 dml_float_t meta_row_bandwidth[],
771 dml_float_t dpte_row_bandwidth[],
772 dml_float_t cursor_bw_pre[],
773 dml_float_t prefetch_vmrow_bw[],
774 dml_uint_t NumberOfDPP[],
775 dml_float_t UrgentBurstFactorLuma[],
776 dml_float_t UrgentBurstFactorChroma[],
777 dml_float_t UrgentBurstFactorCursor[],
778 dml_float_t UrgentBurstFactorLumaPre[],
779 dml_float_t UrgentBurstFactorChromaPre[],
780 dml_float_t UrgentBurstFactorCursorPre[],
781
782 // Output
783 dml_float_t *PrefetchBandwidth,
784 dml_float_t *PrefetchBandwidthNotIncludingMALLPrefetch,
785 dml_float_t *FractionOfUrgentBandwidth,
786 dml_bool_t *PrefetchBandwidthSupport);
787
788 static dml_float_t CalculateBandwidthAvailableForImmediateFlip(
789 dml_uint_t NumberOfActiveSurfaces,
790 dml_float_t ReturnBW,
791 dml_float_t ReadBandwidthLuma[],
792 dml_float_t ReadBandwidthChroma[],
793 dml_float_t PrefetchBandwidthLuma[],
794 dml_float_t PrefetchBandwidthChroma[],
795 dml_float_t cursor_bw[],
796 dml_float_t cursor_bw_pre[],
797 dml_uint_t NumberOfDPP[],
798 dml_float_t UrgentBurstFactorLuma[],
799 dml_float_t UrgentBurstFactorChroma[],
800 dml_float_t UrgentBurstFactorCursor[],
801 dml_float_t UrgentBurstFactorLumaPre[],
802 dml_float_t UrgentBurstFactorChromaPre[],
803 dml_float_t UrgentBurstFactorCursorPre[]);
804
805 static void CalculateImmediateFlipBandwithSupport(
806 dml_uint_t NumberOfActiveSurfaces,
807 dml_float_t ReturnBW,
808 enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange[],
809 enum dml_immediate_flip_requirement ImmediateFlipRequirement[],
810 dml_float_t final_flip_bw[],
811 dml_float_t ReadBandwidthLuma[],
812 dml_float_t ReadBandwidthChroma[],
813 dml_float_t PrefetchBandwidthLuma[],
814 dml_float_t PrefetchBandwidthChroma[],
815 dml_float_t cursor_bw[],
816 dml_float_t meta_row_bandwidth[],
817 dml_float_t dpte_row_bandwidth[],
818 dml_float_t cursor_bw_pre[],
819 dml_float_t prefetch_vmrow_bw[],
820 dml_uint_t NumberOfDPP[],
821 dml_float_t UrgentBurstFactorLuma[],
822 dml_float_t UrgentBurstFactorChroma[],
823 dml_float_t UrgentBurstFactorCursor[],
824 dml_float_t UrgentBurstFactorLumaPre[],
825 dml_float_t UrgentBurstFactorChromaPre[],
826 dml_float_t UrgentBurstFactorCursorPre[],
827
828 // Output
829 dml_float_t *TotalBandwidth,
830 dml_float_t *TotalBandwidthNotIncludingMALLPrefetch,
831 dml_float_t *FractionOfUrgentBandwidth,
832 dml_bool_t *ImmediateFlipBandwidthSupport);
833
834 // ---------------------------
835 // Declaration Ends
836 // ---------------------------
837
dscceComputeDelay(dml_uint_t bpc,dml_float_t BPP,dml_uint_t sliceWidth,dml_uint_t numSlices,enum dml_output_format_class pixelFormat,enum dml_output_encoder_class Output)838 static dml_uint_t dscceComputeDelay(
839 dml_uint_t bpc,
840 dml_float_t BPP,
841 dml_uint_t sliceWidth,
842 dml_uint_t numSlices,
843 enum dml_output_format_class pixelFormat,
844 enum dml_output_encoder_class Output)
845 {
846 // valid bpc = source bits per component in the set of {8, 10, 12}
847 // valid bpp = increments of 1/16 of a bit
848 // min = 6/7/8 in N420/N422/444, respectively
849 // max = such that compression is 1:1
850 //valid sliceWidth = number of pixels per slice line, must be less than or equal to 5184/numSlices (or 4096/numSlices in 420 mode)
851 //valid numSlices = number of slices in the horiziontal direction per DSC engine in the set of {1, 2, 3, 4}
852 //valid pixelFormat = pixel/color format in the set of {:N444_RGB, :S422, :N422, :N420}
853
854 // fixed value
855 dml_uint_t rcModelSize = 8192;
856
857 // N422/N420 operate at 2 pixels per clock
858 dml_uint_t pixelsPerClock, lstall, D, initalXmitDelay, w, s, ix, wx, p, l0, a, ax, L,
859 Delay, pixels;
860
861 if (pixelFormat == dml_420)
862 pixelsPerClock = 2;
863 // #all other modes operate at 1 pixel per clock
864 else if (pixelFormat == dml_444)
865 pixelsPerClock = 1;
866 else if (pixelFormat == dml_n422)
867 pixelsPerClock = 2;
868 else
869 pixelsPerClock = 1;
870
871 //initial transmit delay as per PPS
872 initalXmitDelay = (dml_uint_t)(dml_round(rcModelSize / 2.0 / BPP / pixelsPerClock, 1));
873
874 //compute ssm delay
875 if (bpc == 8)
876 D = 81;
877 else if (bpc == 10)
878 D = 89;
879 else
880 D = 113;
881
882 //divide by pixel per cycle to compute slice width as seen by DSC
883 w = sliceWidth / pixelsPerClock;
884
885 //422 mode has an additional cycle of delay
886 if (pixelFormat == dml_420 || pixelFormat == dml_444 || pixelFormat == dml_n422)
887 s = 0;
888 else
889 s = 1;
890
891 //main calculation for the dscce
892 ix = initalXmitDelay + 45;
893 wx = (w + 2) / 3;
894 p = 3 * wx - w;
895 l0 = ix / w;
896 a = ix + p * l0;
897 ax = (a + 2) / 3 + D + 6 + 1;
898 L = (ax + wx - 1) / wx;
899 if ((ix % w) == 0 && p != 0)
900 lstall = 1;
901 else
902 lstall = 0;
903 Delay = L * wx * (numSlices - 1) + ax + s + lstall + 22;
904
905 //dsc processes 3 pixel containers per cycle and a container can contain 1 or 2 pixels
906 pixels = Delay * 3 * pixelsPerClock;
907
908 #ifdef __DML_VBA_DEBUG__
909 dml_print("DML::%s: bpc: %u\n", __func__, bpc);
910 dml_print("DML::%s: BPP: %f\n", __func__, BPP);
911 dml_print("DML::%s: sliceWidth: %u\n", __func__, sliceWidth);
912 dml_print("DML::%s: numSlices: %u\n", __func__, numSlices);
913 dml_print("DML::%s: pixelFormat: %u\n", __func__, pixelFormat);
914 dml_print("DML::%s: Output: %u\n", __func__, Output);
915 dml_print("DML::%s: pixels: %u\n", __func__, pixels);
916 #endif
917 return pixels;
918 }
919
dscComputeDelay(enum dml_output_format_class pixelFormat,enum dml_output_encoder_class Output)920 static dml_uint_t dscComputeDelay(enum dml_output_format_class pixelFormat, enum dml_output_encoder_class Output)
921 {
922 dml_uint_t Delay = 0;
923
924 if (pixelFormat == dml_420) {
925 // sfr
926 Delay = Delay + 2;
927 // dsccif
928 Delay = Delay + 0;
929 // dscc - input deserializer
930 Delay = Delay + 3;
931 // dscc gets pixels every other cycle
932 Delay = Delay + 2;
933 // dscc - input cdc fifo
934 Delay = Delay + 12;
935 // dscc gets pixels every other cycle
936 Delay = Delay + 13;
937 // dscc - cdc uncertainty
938 Delay = Delay + 2;
939 // dscc - output cdc fifo
940 Delay = Delay + 7;
941 // dscc gets pixels every other cycle
942 Delay = Delay + 3;
943 // dscc - cdc uncertainty
944 Delay = Delay + 2;
945 // dscc - output serializer
946 Delay = Delay + 1;
947 // sft
948 Delay = Delay + 1;
949 } else if (pixelFormat == dml_n422) {
950 // sfr
951 Delay = Delay + 2;
952 // dsccif
953 Delay = Delay + 1;
954 // dscc - input deserializer
955 Delay = Delay + 5;
956 // dscc - input cdc fifo
957 Delay = Delay + 25;
958 // dscc - cdc uncertainty
959 Delay = Delay + 2;
960 // dscc - output cdc fifo
961 Delay = Delay + 10;
962 // dscc - cdc uncertainty
963 Delay = Delay + 2;
964 // dscc - output serializer
965 Delay = Delay + 1;
966 // sft
967 Delay = Delay + 1;
968 } else {
969 // sfr
970 Delay = Delay + 2;
971 // dsccif
972 Delay = Delay + 0;
973 // dscc - input deserializer
974 Delay = Delay + 3;
975 // dscc - input cdc fifo
976 Delay = Delay + 12;
977 // dscc - cdc uncertainty
978 Delay = Delay + 2;
979 // dscc - output cdc fifo
980 Delay = Delay + 7;
981 // dscc - output serializer
982 Delay = Delay + 1;
983 // dscc - cdc uncertainty
984 Delay = Delay + 2;
985 // sft
986 Delay = Delay + 1;
987 }
988 #ifdef __DML_VBA_DEBUG__
989 dml_print("DML::%s: pixelFormat = %u\n", __func__, pixelFormat);
990 dml_print("DML::%s: Delay = %u\n", __func__, Delay);
991 #endif
992
993 return Delay;
994 }
995
CalculatePrefetchSchedule(struct display_mode_lib_scratch_st * scratch,struct CalculatePrefetchSchedule_params_st * p)996 static dml_bool_t CalculatePrefetchSchedule(struct display_mode_lib_scratch_st *scratch,
997 struct CalculatePrefetchSchedule_params_st *p)
998 {
999 struct CalculatePrefetchSchedule_locals_st *s = &scratch->CalculatePrefetchSchedule_locals;
1000
1001 s->MyError = false;
1002 s->DPPCycles = 0;
1003 s->DISPCLKCycles = 0;
1004 s->DSTTotalPixelsAfterScaler = 0.0;
1005 s->LineTime = 0.0;
1006 s->dst_y_prefetch_equ = 0.0;
1007 s->prefetch_bw_oto = 0.0;
1008 s->Tvm_oto = 0.0;
1009 s->Tr0_oto = 0.0;
1010 s->Tvm_oto_lines = 0.0;
1011 s->Tr0_oto_lines = 0.0;
1012 s->dst_y_prefetch_oto = 0.0;
1013 s->TimeForFetchingMetaPTE = 0.0;
1014 s->TimeForFetchingRowInVBlank = 0.0;
1015 s->LinesToRequestPrefetchPixelData = 0.0;
1016 s->HostVMDynamicLevelsTrips = 0;
1017 s->trip_to_mem = 0.0;
1018 s->Tvm_trips = 0.0;
1019 s->Tr0_trips = 0.0;
1020 s->Tvm_trips_rounded = 0.0;
1021 s->Tr0_trips_rounded = 0.0;
1022 s->max_Tsw = 0.0;
1023 s->Lsw_oto = 0.0;
1024 s->Tpre_rounded = 0.0;
1025 s->prefetch_bw_equ = 0.0;
1026 s->Tvm_equ = 0.0;
1027 s->Tr0_equ = 0.0;
1028 s->Tdmbf = 0.0;
1029 s->Tdmec = 0.0;
1030 s->Tdmsks = 0.0;
1031 s->prefetch_sw_bytes = 0.0;
1032 s->prefetch_bw_pr = 0.0;
1033 s->bytes_pp = 0.0;
1034 s->dep_bytes = 0.0;
1035 s->min_Lsw_oto = 0.0;
1036 s->Tsw_est1 = 0.0;
1037 s->Tsw_est3 = 0.0;
1038
1039 if (p->GPUVMEnable == true && p->HostVMEnable == true) {
1040 s->HostVMDynamicLevelsTrips = p->HostVMMaxNonCachedPageTableLevels;
1041 } else {
1042 s->HostVMDynamicLevelsTrips = 0;
1043 }
1044 #ifdef __DML_VBA_DEBUG__
1045 dml_print("DML::%s: GPUVMEnable = %u\n", __func__, p->GPUVMEnable);
1046 dml_print("DML::%s: GPUVMPageTableLevels = %u\n", __func__, p->GPUVMPageTableLevels);
1047 dml_print("DML::%s: DCCEnable = %u\n", __func__, p->myPipe->DCCEnable);
1048 dml_print("DML::%s: VStartup = %u\n", __func__, p->VStartup);
1049 dml_print("DML::%s: MaxVStartup = %u\n", __func__, p->MaxVStartup);
1050 dml_print("DML::%s: HostVMEnable = %u\n", __func__, p->HostVMEnable);
1051 dml_print("DML::%s: HostVMInefficiencyFactor= %f\n", __func__, p->HostVMInefficiencyFactor);
1052 dml_print("DML::%s: myPipe->Dppclk = %f\n", __func__, p->myPipe->Dppclk);
1053 #endif
1054 CalculateVUpdateAndDynamicMetadataParameters(
1055 p->MaxInterDCNTileRepeaters,
1056 p->myPipe->Dppclk,
1057 p->myPipe->Dispclk,
1058 p->myPipe->DCFClkDeepSleep,
1059 p->myPipe->PixelClock,
1060 p->myPipe->HTotal,
1061 p->myPipe->VBlank,
1062 p->DynamicMetadataTransmittedBytes,
1063 p->DynamicMetadataLinesBeforeActiveRequired,
1064 p->myPipe->InterlaceEnable,
1065 p->myPipe->ProgressiveToInterlaceUnitInOPP,
1066 p->TSetup,
1067
1068 // Output
1069 &s->Tdmbf,
1070 &s->Tdmec,
1071 &s->Tdmsks,
1072 p->VUpdateOffsetPix,
1073 p->VUpdateWidthPix,
1074 p->VReadyOffsetPix);
1075
1076 s->LineTime = p->myPipe->HTotal / p->myPipe->PixelClock;
1077 s->trip_to_mem = p->UrgentLatency;
1078 s->Tvm_trips = p->UrgentExtraLatency + s->trip_to_mem * (p->GPUVMPageTableLevels * (s->HostVMDynamicLevelsTrips + 1) - 1);
1079
1080 if (p->DynamicMetadataVMEnabled == true) {
1081 *p->Tdmdl = p->TWait + s->Tvm_trips + s->trip_to_mem;
1082 } else {
1083 *p->Tdmdl = p->TWait + p->UrgentExtraLatency;
1084 }
1085
1086 #ifdef __DML_VBA_ALLOW_DELTA__
1087 if (DynamicMetadataEnable == false) {
1088 *Tdmdl = 0.0;
1089 }
1090 #endif
1091
1092 if (p->DynamicMetadataEnable == true) {
1093 if (p->VStartup * s->LineTime < *p->TSetup + *p->Tdmdl + s->Tdmbf + s->Tdmec + s->Tdmsks) {
1094 *p->NotEnoughTimeForDynamicMetadata = true;
1095 dml_print("DML::%s: Not Enough Time for Dynamic Meta!\n", __func__);
1096 dml_print("DML::%s: Tdmbf: %fus - time for dmd transfer from dchub to dio output buffer\n", __func__, s->Tdmbf);
1097 dml_print("DML::%s: Tdmec: %fus - time dio takes to transfer dmd\n", __func__, s->Tdmec);
1098 dml_print("DML::%s: Tdmsks: %fus - time before active dmd must complete transmission at dio\n", __func__, s->Tdmsks);
1099 dml_print("DML::%s: Tdmdl: %fus - time for fabric to become ready and fetch dmd \n", __func__, *p->Tdmdl);
1100 } else {
1101 *p->NotEnoughTimeForDynamicMetadata = false;
1102 }
1103 } else {
1104 *p->NotEnoughTimeForDynamicMetadata = false;
1105 }
1106
1107 *p->Tdmdl_vm = (p->DynamicMetadataEnable == true && p->DynamicMetadataVMEnabled == true && p->GPUVMEnable == true ? p->TWait + s->Tvm_trips : 0);
1108
1109 if (p->myPipe->ScalerEnabled)
1110 s->DPPCycles = (dml_uint_t)(p->DPPCLKDelaySubtotalPlusCNVCFormater + p->DPPCLKDelaySCL);
1111 else
1112 s->DPPCycles = (dml_uint_t)(p->DPPCLKDelaySubtotalPlusCNVCFormater + p->DPPCLKDelaySCLLBOnly);
1113
1114 s->DPPCycles = (dml_uint_t)(s->DPPCycles + p->myPipe->NumberOfCursors * p->DPPCLKDelayCNVCCursor);
1115
1116 s->DISPCLKCycles = (dml_uint_t)p->DISPCLKDelaySubtotal;
1117
1118 if (p->myPipe->Dppclk == 0.0 || p->myPipe->Dispclk == 0.0)
1119 return true;
1120
1121 *p->DSTXAfterScaler = (dml_uint_t) dml_round(s->DPPCycles * p->myPipe->PixelClock / p->myPipe->Dppclk + s->DISPCLKCycles * p->myPipe->PixelClock / p->myPipe->Dispclk + p->DSCDelay, 1.0);
1122 *p->DSTXAfterScaler = (dml_uint_t) dml_round(*p->DSTXAfterScaler + (p->myPipe->ODMMode != dml_odm_mode_bypass ? 18 : 0) + (p->myPipe->DPPPerSurface - 1) * p->DPP_RECOUT_WIDTH +
1123 ((p->myPipe->ODMMode == dml_odm_mode_split_1to2 || p->myPipe->ODMMode == dml_odm_mode_mso_1to2) ? (dml_float_t)p->myPipe->HActive / 2.0 : 0) +
1124 ((p->myPipe->ODMMode == dml_odm_mode_mso_1to4) ? (dml_float_t)p->myPipe->HActive * 3.0 / 4.0 : 0), 1.0);
1125
1126 #ifdef __DML_VBA_DEBUG__
1127 dml_print("DML::%s: DPPCycles = %u\n", __func__, s->DPPCycles);
1128 dml_print("DML::%s: PixelClock = %f\n", __func__, p->myPipe->PixelClock);
1129 dml_print("DML::%s: Dppclk = %f\n", __func__, p->myPipe->Dppclk);
1130 dml_print("DML::%s: DISPCLKCycles = %u\n", __func__, s->DISPCLKCycles);
1131 dml_print("DML::%s: DISPCLK = %f\n", __func__, p->myPipe->Dispclk);
1132 dml_print("DML::%s: DSCDelay = %u\n", __func__, p->DSCDelay);
1133 dml_print("DML::%s: ODMMode = %u\n", __func__, p->myPipe->ODMMode);
1134 dml_print("DML::%s: DPP_RECOUT_WIDTH = %u\n", __func__, p->DPP_RECOUT_WIDTH);
1135 dml_print("DML::%s: DSTXAfterScaler = %u\n", __func__, *p->DSTXAfterScaler);
1136 #endif
1137
1138 if (p->OutputFormat == dml_420 || (p->myPipe->InterlaceEnable && p->myPipe->ProgressiveToInterlaceUnitInOPP))
1139 *p->DSTYAfterScaler = 1;
1140 else
1141 *p->DSTYAfterScaler = 0;
1142
1143 s->DSTTotalPixelsAfterScaler = *p->DSTYAfterScaler * p->myPipe->HTotal + *p->DSTXAfterScaler;
1144 *p->DSTYAfterScaler = (dml_uint_t)(dml_floor(s->DSTTotalPixelsAfterScaler / p->myPipe->HTotal, 1));
1145 *p->DSTXAfterScaler = (dml_uint_t)(s->DSTTotalPixelsAfterScaler - ((dml_float_t) (*p->DSTYAfterScaler * p->myPipe->HTotal)));
1146 #ifdef __DML_VBA_DEBUG__
1147 dml_print("DML::%s: DSTXAfterScaler = %u (final)\n", __func__, *p->DSTXAfterScaler);
1148 dml_print("DML::%s: DSTYAfterScaler = %u (final)\n", __func__, *p->DSTYAfterScaler);
1149 #endif
1150
1151 s->MyError = false;
1152
1153 s->Tr0_trips = s->trip_to_mem * (s->HostVMDynamicLevelsTrips + 1);
1154
1155 if (p->GPUVMEnable == true) {
1156 s->Tvm_trips_rounded = dml_ceil(4.0 * s->Tvm_trips / s->LineTime, 1.0) / 4.0 * s->LineTime;
1157 s->Tr0_trips_rounded = dml_ceil(4.0 * s->Tr0_trips / s->LineTime, 1.0) / 4.0 * s->LineTime;
1158 if (p->GPUVMPageTableLevels >= 3) {
1159 *p->Tno_bw = p->UrgentExtraLatency + s->trip_to_mem * (dml_float_t) ((p->GPUVMPageTableLevels - 2) * (s->HostVMDynamicLevelsTrips + 1) - 1);
1160 } else if (p->GPUVMPageTableLevels == 1 && p->myPipe->DCCEnable != true) {
1161 s->Tr0_trips_rounded = dml_ceil(4.0 * p->UrgentExtraLatency / s->LineTime, 1.0) / 4.0 * s->LineTime;
1162 *p->Tno_bw = p->UrgentExtraLatency;
1163 } else {
1164 *p->Tno_bw = 0;
1165 }
1166 } else if (p->myPipe->DCCEnable == true) {
1167 s->Tvm_trips_rounded = s->LineTime / 4.0;
1168 s->Tr0_trips_rounded = dml_ceil(4.0 * s->Tr0_trips / s->LineTime, 1.0) / 4.0 * s->LineTime;
1169 *p->Tno_bw = 0;
1170 } else {
1171 s->Tvm_trips_rounded = s->LineTime / 4.0;
1172 s->Tr0_trips_rounded = s->LineTime / 2.0;
1173 *p->Tno_bw = 0;
1174 }
1175 s->Tvm_trips_rounded = dml_max(s->Tvm_trips_rounded, s->LineTime / 4.0);
1176 s->Tr0_trips_rounded = dml_max(s->Tr0_trips_rounded, s->LineTime / 4.0);
1177
1178 if (p->myPipe->SourcePixelFormat == dml_420_8 || p->myPipe->SourcePixelFormat == dml_420_10 || p->myPipe->SourcePixelFormat == dml_420_12) {
1179 s->bytes_pp = p->myPipe->BytePerPixelY + p->myPipe->BytePerPixelC / 4;
1180 } else {
1181 s->bytes_pp = p->myPipe->BytePerPixelY + p->myPipe->BytePerPixelC;
1182 }
1183
1184 s->prefetch_bw_pr = s->bytes_pp * p->myPipe->PixelClock / (dml_float_t)p->myPipe->DPPPerSurface;
1185 if (p->myPipe->VRatio < 1.0)
1186 s->prefetch_bw_pr = p->myPipe->VRatio * s->prefetch_bw_pr;
1187
1188 s->max_Tsw = (dml_max(p->PrefetchSourceLinesY, p->PrefetchSourceLinesC) * s->LineTime);
1189
1190 s->prefetch_sw_bytes = p->PrefetchSourceLinesY * p->swath_width_luma_ub * p->myPipe->BytePerPixelY + p->PrefetchSourceLinesC * p->swath_width_chroma_ub * p->myPipe->BytePerPixelC;
1191 s->prefetch_bw_oto = dml_max(s->prefetch_bw_pr, s->prefetch_sw_bytes / s->max_Tsw);
1192
1193 s->min_Lsw_oto = dml_max(p->PrefetchSourceLinesY, p->PrefetchSourceLinesC) / __DML_MAX_VRATIO_PRE_OTO__;
1194 s->min_Lsw_oto = dml_max(s->min_Lsw_oto, 1.0);
1195 s->Lsw_oto = dml_ceil(4.0 * dml_max(s->prefetch_sw_bytes / s->prefetch_bw_oto / s->LineTime, s->min_Lsw_oto), 1.0) / 4.0;
1196
1197 if (p->GPUVMEnable == true) {
1198 s->Tvm_oto = dml_max3(
1199 s->Tvm_trips,
1200 *p->Tno_bw + p->PDEAndMetaPTEBytesFrame * p->HostVMInefficiencyFactor / s->prefetch_bw_oto,
1201 s->LineTime / 4.0);
1202 } else
1203 s->Tvm_oto = s->LineTime / 4.0;
1204
1205 if ((p->GPUVMEnable == true || p->myPipe->DCCEnable == true)) {
1206 s->Tr0_oto = dml_max4(
1207 s->Tr0_trips,
1208 (p->MetaRowByte + p->PixelPTEBytesPerRow * p->HostVMInefficiencyFactor) / s->prefetch_bw_oto,
1209 (s->LineTime - s->Tvm_oto)/2.0,
1210 s->LineTime / 4.0);
1211 #ifdef __DML_VBA_DEBUG__
1212 dml_print("DML::%s: Tr0_oto max0 = %f\n", __func__, (p->MetaRowByte + p->PixelPTEBytesPerRow * p->HostVMInefficiencyFactor) / s->prefetch_bw_oto);
1213 dml_print("DML::%s: Tr0_oto max1 = %f\n", __func__, s->Tr0_trips);
1214 dml_print("DML::%s: Tr0_oto max2 = %f\n", __func__, s->LineTime - s->Tvm_oto);
1215 dml_print("DML::%s: Tr0_oto max3 = %f\n", __func__, s->LineTime / 4);
1216 #endif
1217 } else
1218 s->Tr0_oto = (s->LineTime - s->Tvm_oto) / 2.0;
1219
1220 s->Tvm_oto_lines = dml_ceil(4.0 * s->Tvm_oto / s->LineTime, 1) / 4.0;
1221 s->Tr0_oto_lines = dml_ceil(4.0 * s->Tr0_oto / s->LineTime, 1) / 4.0;
1222 s->dst_y_prefetch_oto = s->Tvm_oto_lines + 2 * s->Tr0_oto_lines + s->Lsw_oto;
1223
1224 s->dst_y_prefetch_equ = p->VStartup - (*p->TSetup + dml_max(p->TWait + p->TCalc, *p->Tdmdl)) / s->LineTime - (*p->DSTYAfterScaler + (dml_float_t) *p->DSTXAfterScaler / (dml_float_t)p->myPipe->HTotal);
1225
1226 #ifdef __DML_VBA_DEBUG__
1227 dml_print("DML::%s: HTotal = %u\n", __func__, p->myPipe->HTotal);
1228 dml_print("DML::%s: min_Lsw_oto = %f\n", __func__, s->min_Lsw_oto);
1229 dml_print("DML::%s: *Tno_bw = %f\n", __func__, *p->Tno_bw);
1230 dml_print("DML::%s: UrgentExtraLatency = %f\n", __func__, p->UrgentExtraLatency);
1231 dml_print("DML::%s: trip_to_mem = %f\n", __func__, s->trip_to_mem);
1232 dml_print("DML::%s: BytePerPixelY = %u\n", __func__, p->myPipe->BytePerPixelY);
1233 dml_print("DML::%s: PrefetchSourceLinesY = %f\n", __func__, p->PrefetchSourceLinesY);
1234 dml_print("DML::%s: swath_width_luma_ub = %u\n", __func__, p->swath_width_luma_ub);
1235 dml_print("DML::%s: BytePerPixelC = %u\n", __func__, p->myPipe->BytePerPixelC);
1236 dml_print("DML::%s: PrefetchSourceLinesC = %f\n", __func__, p->PrefetchSourceLinesC);
1237 dml_print("DML::%s: swath_width_chroma_ub = %u\n", __func__, p->swath_width_chroma_ub);
1238 dml_print("DML::%s: prefetch_sw_bytes = %f\n", __func__, s->prefetch_sw_bytes);
1239 dml_print("DML::%s: bytes_pp = %f\n", __func__, s->bytes_pp);
1240 dml_print("DML::%s: PDEAndMetaPTEBytesFrame = %u\n", __func__, p->PDEAndMetaPTEBytesFrame);
1241 dml_print("DML::%s: MetaRowByte = %u\n", __func__, p->MetaRowByte);
1242 dml_print("DML::%s: PixelPTEBytesPerRow = %u\n", __func__, p->PixelPTEBytesPerRow);
1243 dml_print("DML::%s: HostVMInefficiencyFactor = %f\n", __func__, p->HostVMInefficiencyFactor);
1244 dml_print("DML::%s: Tvm_trips = %f\n", __func__, s->Tvm_trips);
1245 dml_print("DML::%s: Tr0_trips = %f\n", __func__, s->Tr0_trips);
1246 dml_print("DML::%s: prefetch_bw_oto = %f\n", __func__, s->prefetch_bw_oto);
1247 dml_print("DML::%s: Tr0_oto = %f\n", __func__, s->Tr0_oto);
1248 dml_print("DML::%s: Tvm_oto = %f\n", __func__, s->Tvm_oto);
1249 dml_print("DML::%s: Tvm_oto_lines = %f\n", __func__, s->Tvm_oto_lines);
1250 dml_print("DML::%s: Tr0_oto_lines = %f\n", __func__, s->Tr0_oto_lines);
1251 dml_print("DML::%s: Lsw_oto = %f\n", __func__, s->Lsw_oto);
1252 dml_print("DML::%s: dst_y_prefetch_oto = %f\n", __func__, s->dst_y_prefetch_oto);
1253 dml_print("DML::%s: dst_y_prefetch_equ = %f\n", __func__, s->dst_y_prefetch_equ);
1254 #endif
1255
1256 s->dst_y_prefetch_equ = dml_floor(4.0 * (s->dst_y_prefetch_equ + 0.125), 1) / 4.0;
1257 s->Tpre_rounded = s->dst_y_prefetch_equ * s->LineTime;
1258
1259 dml_print("DML::%s: dst_y_prefetch_equ: %f (after round)\n", __func__, s->dst_y_prefetch_equ);
1260
1261 dml_print("DML::%s: LineTime: %f\n", __func__, s->LineTime);
1262 dml_print("DML::%s: VStartup: %u\n", __func__, p->VStartup);
1263 dml_print("DML::%s: Tvstartup: %fus - time between vstartup and first pixel of active\n", __func__, p->VStartup * s->LineTime);
1264 dml_print("DML::%s: TSetup: %fus - time from vstartup to vready\n", __func__, *p->TSetup);
1265 dml_print("DML::%s: TCalc: %fus - time for calculations in dchub starting at vready\n", __func__, p->TCalc);
1266 dml_print("DML::%s: TWait: %fus - time for fabric to become ready max(pstate exit,cstate enter/exit, urgent latency) after TCalc\n", __func__, p->TWait);
1267 dml_print("DML::%s: Tdmbf: %fus - time for dmd transfer from dchub to dio output buffer\n", __func__, s->Tdmbf);
1268 dml_print("DML::%s: Tdmec: %fus - time dio takes to transfer dmd\n", __func__, s->Tdmec);
1269 dml_print("DML::%s: Tdmsks: %fus - time before active dmd must complete transmission at dio\n", __func__, s->Tdmsks);
1270 dml_print("DML::%s: Tdmdl_vm: %fus - time for vm stages of dmd \n", __func__, *p->Tdmdl_vm);
1271 dml_print("DML::%s: Tdmdl: %fus - time for fabric to become ready and fetch dmd \n", __func__, *p->Tdmdl);
1272 dml_print("DML::%s: DSTXAfterScaler: %u pixels - number of pixel clocks pipeline and buffer delay after scaler \n", __func__, *p->DSTXAfterScaler);
1273 dml_print("DML::%s: DSTYAfterScaler: %u lines - number of lines of pipeline and buffer delay after scaler \n", __func__, *p->DSTYAfterScaler);
1274
1275 s->dep_bytes = dml_max(p->PDEAndMetaPTEBytesFrame * p->HostVMInefficiencyFactor, p->MetaRowByte + p->PixelPTEBytesPerRow * p->HostVMInefficiencyFactor);
1276
1277 if (s->prefetch_sw_bytes < s->dep_bytes) {
1278 s->prefetch_sw_bytes = 2 * s->dep_bytes;
1279 }
1280
1281 *p->DestinationLinesToRequestVMInVBlank = 0;
1282 *p->DestinationLinesToRequestRowInVBlank = 0;
1283 *p->VRatioPrefetchY = 0;
1284 *p->VRatioPrefetchC = 0;
1285 *p->RequiredPrefetchPixDataBWLuma = 0;
1286 if (s->dst_y_prefetch_equ > 1) {
1287
1288 if (s->Tpre_rounded - *p->Tno_bw > 0) {
1289 s->PrefetchBandwidth1 = (p->PDEAndMetaPTEBytesFrame * p->HostVMInefficiencyFactor + 2 * p->MetaRowByte
1290 + 2 * p->PixelPTEBytesPerRow * p->HostVMInefficiencyFactor
1291 + s->prefetch_sw_bytes)
1292 / (s->Tpre_rounded - *p->Tno_bw);
1293 s->Tsw_est1 = s->prefetch_sw_bytes / s->PrefetchBandwidth1;
1294 } else
1295 s->PrefetchBandwidth1 = 0;
1296
1297 if (p->VStartup == p->MaxVStartup && (s->Tsw_est1 / s->LineTime < s->min_Lsw_oto) && s->Tpre_rounded - s->min_Lsw_oto * s->LineTime - 0.75 * s->LineTime - *p->Tno_bw > 0) {
1298 s->PrefetchBandwidth1 = (p->PDEAndMetaPTEBytesFrame * p->HostVMInefficiencyFactor + 2 * p->MetaRowByte + 2 * p->PixelPTEBytesPerRow * p->HostVMInefficiencyFactor) /
1299 (s->Tpre_rounded - s->min_Lsw_oto * s->LineTime - 0.75 * s->LineTime - *p->Tno_bw);
1300 }
1301
1302 if (s->Tpre_rounded - *p->Tno_bw - 2 * s->Tr0_trips_rounded > 0)
1303 s->PrefetchBandwidth2 = (p->PDEAndMetaPTEBytesFrame * p->HostVMInefficiencyFactor + s->prefetch_sw_bytes) /
1304 (s->Tpre_rounded - *p->Tno_bw - 2 * s->Tr0_trips_rounded);
1305 else
1306 s->PrefetchBandwidth2 = 0;
1307
1308 if (s->Tpre_rounded - s->Tvm_trips_rounded > 0) {
1309 s->PrefetchBandwidth3 = (2 * p->MetaRowByte + 2 * p->PixelPTEBytesPerRow * p->HostVMInefficiencyFactor + s->prefetch_sw_bytes) /
1310 (s->Tpre_rounded - s->Tvm_trips_rounded);
1311 s->Tsw_est3 = s->prefetch_sw_bytes / s->PrefetchBandwidth3;
1312 }
1313 else
1314 s->PrefetchBandwidth3 = 0;
1315
1316
1317 if (p->VStartup == p->MaxVStartup && (s->Tsw_est3 / s->LineTime < s->min_Lsw_oto) && s->Tpre_rounded - s->min_Lsw_oto * s->LineTime - 0.5 * s->LineTime - s->Tvm_trips_rounded > 0) {
1318 s->PrefetchBandwidth3 = (2 * p->MetaRowByte + 2 * p->PixelPTEBytesPerRow * p->HostVMInefficiencyFactor) / (s->Tpre_rounded - s->min_Lsw_oto * s->LineTime - 0.5 * s->LineTime - s->Tvm_trips_rounded);
1319 }
1320
1321 if (s->Tpre_rounded - s->Tvm_trips_rounded - 2 * s->Tr0_trips_rounded > 0)
1322 s->PrefetchBandwidth4 = s->prefetch_sw_bytes / (s->Tpre_rounded - s->Tvm_trips_rounded - 2 * s->Tr0_trips_rounded);
1323 else
1324 s->PrefetchBandwidth4 = 0;
1325
1326 #ifdef __DML_VBA_DEBUG__
1327 dml_print("DML::%s: Tpre_rounded: %f\n", __func__, s->Tpre_rounded);
1328 dml_print("DML::%s: Tno_bw: %f\n", __func__, *p->Tno_bw);
1329 dml_print("DML::%s: Tvm_trips_rounded: %f\n", __func__, s->Tvm_trips_rounded);
1330 dml_print("DML::%s: Tsw_est1: %f\n", __func__, s->Tsw_est1);
1331 dml_print("DML::%s: Tsw_est3: %f\n", __func__, s->Tsw_est3);
1332 dml_print("DML::%s: PrefetchBandwidth1: %f\n", __func__, s->PrefetchBandwidth1);
1333 dml_print("DML::%s: PrefetchBandwidth2: %f\n", __func__, s->PrefetchBandwidth2);
1334 dml_print("DML::%s: PrefetchBandwidth3: %f\n", __func__, s->PrefetchBandwidth3);
1335 dml_print("DML::%s: PrefetchBandwidth4: %f\n", __func__, s->PrefetchBandwidth4);
1336 #endif
1337 {
1338 dml_bool_t Case1OK;
1339 dml_bool_t Case2OK;
1340 dml_bool_t Case3OK;
1341
1342 if (s->PrefetchBandwidth1 > 0) {
1343 if (*p->Tno_bw + p->PDEAndMetaPTEBytesFrame * p->HostVMInefficiencyFactor / s->PrefetchBandwidth1 >= s->Tvm_trips_rounded && (p->MetaRowByte + p->PixelPTEBytesPerRow * p->HostVMInefficiencyFactor) / s->PrefetchBandwidth1 >= s->Tr0_trips_rounded) {
1344 Case1OK = true;
1345 } else {
1346 Case1OK = false;
1347 }
1348 } else {
1349 Case1OK = false;
1350 }
1351
1352 if (s->PrefetchBandwidth2 > 0) {
1353 if (*p->Tno_bw + p->PDEAndMetaPTEBytesFrame * p->HostVMInefficiencyFactor / s->PrefetchBandwidth2 >= s->Tvm_trips_rounded && (p->MetaRowByte + p->PixelPTEBytesPerRow * p->HostVMInefficiencyFactor) / s->PrefetchBandwidth2 < s->Tr0_trips_rounded) {
1354 Case2OK = true;
1355 } else {
1356 Case2OK = false;
1357 }
1358 } else {
1359 Case2OK = false;
1360 }
1361
1362 if (s->PrefetchBandwidth3 > 0) {
1363 if (*p->Tno_bw + p->PDEAndMetaPTEBytesFrame * p->HostVMInefficiencyFactor / s->PrefetchBandwidth3 < s->Tvm_trips_rounded && (p->MetaRowByte + p->PixelPTEBytesPerRow * p->HostVMInefficiencyFactor) / s->PrefetchBandwidth3 >= s->Tr0_trips_rounded) {
1364 Case3OK = true;
1365 } else {
1366 Case3OK = false;
1367 }
1368 } else {
1369 Case3OK = false;
1370 }
1371
1372 if (Case1OK) {
1373 s->prefetch_bw_equ = s->PrefetchBandwidth1;
1374 } else if (Case2OK) {
1375 s->prefetch_bw_equ = s->PrefetchBandwidth2;
1376 } else if (Case3OK) {
1377 s->prefetch_bw_equ = s->PrefetchBandwidth3;
1378 } else {
1379 s->prefetch_bw_equ = s->PrefetchBandwidth4;
1380 }
1381
1382 #ifdef __DML_VBA_DEBUG__
1383 dml_print("DML::%s: Case1OK: %u\n", __func__, Case1OK);
1384 dml_print("DML::%s: Case2OK: %u\n", __func__, Case2OK);
1385 dml_print("DML::%s: Case3OK: %u\n", __func__, Case3OK);
1386 dml_print("DML::%s: prefetch_bw_equ: %f\n", __func__, s->prefetch_bw_equ);
1387 #endif
1388
1389 if (s->prefetch_bw_equ > 0) {
1390 if (p->GPUVMEnable == true) {
1391 s->Tvm_equ = dml_max3(*p->Tno_bw + p->PDEAndMetaPTEBytesFrame * p->HostVMInefficiencyFactor / s->prefetch_bw_equ, s->Tvm_trips, s->LineTime / 4);
1392 } else {
1393 s->Tvm_equ = s->LineTime / 4;
1394 }
1395
1396 if ((p->GPUVMEnable == true || p->myPipe->DCCEnable == true)) {
1397 s->Tr0_equ = dml_max4((p->MetaRowByte + p->PixelPTEBytesPerRow * p->HostVMInefficiencyFactor) / s->prefetch_bw_equ, s->Tr0_trips, (s->LineTime - s->Tvm_equ) / 2, s->LineTime / 4);
1398 } else {
1399 s->Tr0_equ = (s->LineTime - s->Tvm_equ) / 2;
1400 }
1401 } else {
1402 s->Tvm_equ = 0;
1403 s->Tr0_equ = 0;
1404 dml_print("DML::%s: prefetch_bw_equ equals 0!\n", __func__);
1405 }
1406 }
1407
1408
1409 if (s->dst_y_prefetch_oto < s->dst_y_prefetch_equ) {
1410 *p->DestinationLinesForPrefetch = s->dst_y_prefetch_oto;
1411 s->TimeForFetchingMetaPTE = s->Tvm_oto;
1412 s->TimeForFetchingRowInVBlank = s->Tr0_oto;
1413
1414 *p->DestinationLinesToRequestVMInVBlank = dml_ceil(4.0 * s->TimeForFetchingMetaPTE / s->LineTime, 1.0) / 4.0;
1415 *p->DestinationLinesToRequestRowInVBlank = dml_ceil(4.0 * s->TimeForFetchingRowInVBlank / s->LineTime, 1.0) / 4.0;
1416 } else {
1417 *p->DestinationLinesForPrefetch = s->dst_y_prefetch_equ;
1418 s->TimeForFetchingMetaPTE = s->Tvm_equ;
1419 s->TimeForFetchingRowInVBlank = s->Tr0_equ;
1420
1421 if (p->VStartup == p->MaxVStartup && p->EnhancedPrefetchScheduleAccelerationFinal != 0) {
1422 *p->DestinationLinesToRequestVMInVBlank = dml_floor(4.0 * s->TimeForFetchingMetaPTE / s->LineTime, 1.0) / 4.0;
1423 *p->DestinationLinesToRequestRowInVBlank = dml_floor(4.0 * s->TimeForFetchingRowInVBlank / s->LineTime, 1.0) / 4.0;
1424 } else {
1425 *p->DestinationLinesToRequestVMInVBlank = dml_ceil(4.0 * s->TimeForFetchingMetaPTE / s->LineTime, 1.0) / 4.0;
1426 *p->DestinationLinesToRequestRowInVBlank = dml_ceil(4.0 * s->TimeForFetchingRowInVBlank / s->LineTime, 1.0) / 4.0;
1427 }
1428 }
1429
1430 s->LinesToRequestPrefetchPixelData = *p->DestinationLinesForPrefetch - *p->DestinationLinesToRequestVMInVBlank - 2 * *p->DestinationLinesToRequestRowInVBlank;
1431
1432 #ifdef __DML_VBA_DEBUG__
1433 dml_print("DML::%s: DestinationLinesForPrefetch = %f\n", __func__, *p->DestinationLinesForPrefetch);
1434 dml_print("DML::%s: DestinationLinesToRequestVMInVBlank = %f\n", __func__, *p->DestinationLinesToRequestVMInVBlank);
1435 dml_print("DML::%s: TimeForFetchingRowInVBlank = %f\n", __func__, s->TimeForFetchingRowInVBlank);
1436 dml_print("DML::%s: LineTime = %f\n", __func__, s->LineTime);
1437 dml_print("DML::%s: DestinationLinesToRequestRowInVBlank = %f\n", __func__, *p->DestinationLinesToRequestRowInVBlank);
1438 dml_print("DML::%s: PrefetchSourceLinesY = %f\n", __func__, p->PrefetchSourceLinesY);
1439 dml_print("DML::%s: LinesToRequestPrefetchPixelData = %f\n", __func__, s->LinesToRequestPrefetchPixelData);
1440 #endif
1441
1442 if (s->LinesToRequestPrefetchPixelData >= 1 && s->prefetch_bw_equ > 0) {
1443 *p->VRatioPrefetchY = (dml_float_t)p->PrefetchSourceLinesY / s->LinesToRequestPrefetchPixelData;
1444 *p->VRatioPrefetchY = dml_max(*p->VRatioPrefetchY, 1.0);
1445 #ifdef __DML_VBA_DEBUG__
1446 dml_print("DML::%s: VRatioPrefetchY = %f\n", __func__, *p->VRatioPrefetchY);
1447 dml_print("DML::%s: SwathHeightY = %u\n", __func__, p->SwathHeightY);
1448 dml_print("DML::%s: VInitPreFillY = %u\n", __func__, p->VInitPreFillY);
1449 #endif
1450 if ((p->SwathHeightY > 4) && (p->VInitPreFillY > 3)) {
1451 if (s->LinesToRequestPrefetchPixelData > (p->VInitPreFillY - 3.0) / 2.0) {
1452 *p->VRatioPrefetchY = dml_max(*p->VRatioPrefetchY,
1453 (dml_float_t)p->MaxNumSwathY * p->SwathHeightY / (s->LinesToRequestPrefetchPixelData - (p->VInitPreFillY - 3.0) / 2.0));
1454 } else {
1455 s->MyError = true;
1456 dml_print("DML::%s: MyErr set. LinesToRequestPrefetchPixelData=%f VinitPreFillY=%u\n", __func__, s->LinesToRequestPrefetchPixelData, p->VInitPreFillY);
1457 *p->VRatioPrefetchY = 0;
1458 }
1459 #ifdef __DML_VBA_DEBUG__
1460 dml_print("DML::%s: VRatioPrefetchY = %f\n", __func__, *p->VRatioPrefetchY);
1461 dml_print("DML::%s: PrefetchSourceLinesY = %f\n", __func__, p->PrefetchSourceLinesY);
1462 dml_print("DML::%s: MaxNumSwathY = %u\n", __func__, p->MaxNumSwathY);
1463 #endif
1464 }
1465
1466 *p->VRatioPrefetchC = (dml_float_t)p->PrefetchSourceLinesC / s->LinesToRequestPrefetchPixelData;
1467 *p->VRatioPrefetchC = dml_max(*p->VRatioPrefetchC, 1.0);
1468
1469 #ifdef __DML_VBA_DEBUG__
1470 dml_print("DML::%s: VRatioPrefetchC = %f\n", __func__, *p->VRatioPrefetchC);
1471 dml_print("DML::%s: SwathHeightC = %u\n", __func__, p->SwathHeightC);
1472 dml_print("DML::%s: VInitPreFillC = %u\n", __func__, p->VInitPreFillC);
1473 #endif
1474 if ((p->SwathHeightC > 4) && (p->VInitPreFillC > 3)) {
1475 if (s->LinesToRequestPrefetchPixelData > (p->VInitPreFillC - 3.0) / 2.0) {
1476 *p->VRatioPrefetchC = dml_max(*p->VRatioPrefetchC, (dml_float_t)p->MaxNumSwathC * p->SwathHeightC / (s->LinesToRequestPrefetchPixelData - (p->VInitPreFillC - 3.0) / 2.0));
1477 } else {
1478 s->MyError = true;
1479 dml_print("DML::%s: MyErr set. LinesToRequestPrefetchPixelData=%f VInitPreFillC=%u\n", __func__, s->LinesToRequestPrefetchPixelData, p->VInitPreFillC);
1480 *p->VRatioPrefetchC = 0;
1481 }
1482 #ifdef __DML_VBA_DEBUG__
1483 dml_print("DML::%s: VRatioPrefetchC = %f\n", __func__, *p->VRatioPrefetchC);
1484 dml_print("DML::%s: PrefetchSourceLinesC = %f\n", __func__, p->PrefetchSourceLinesC);
1485 dml_print("DML::%s: MaxNumSwathC = %u\n", __func__, p->MaxNumSwathC);
1486 #endif
1487 }
1488
1489 *p->RequiredPrefetchPixDataBWLuma = (dml_float_t)p->PrefetchSourceLinesY / s->LinesToRequestPrefetchPixelData
1490 * p->myPipe->BytePerPixelY
1491 * p->swath_width_luma_ub / s->LineTime;
1492
1493 #ifdef __DML_VBA_DEBUG__
1494 dml_print("DML::%s: BytePerPixelY = %u\n", __func__, p->myPipe->BytePerPixelY);
1495 dml_print("DML::%s: swath_width_luma_ub = %u\n", __func__, p->swath_width_luma_ub);
1496 dml_print("DML::%s: LineTime = %f\n", __func__, s->LineTime);
1497 dml_print("DML::%s: RequiredPrefetchPixDataBWLuma = %f\n", __func__, *p->RequiredPrefetchPixDataBWLuma);
1498 #endif
1499 *p->RequiredPrefetchPixDataBWChroma = (dml_float_t)p->PrefetchSourceLinesC / s->LinesToRequestPrefetchPixelData
1500 *p->myPipe->BytePerPixelC
1501 *p->swath_width_chroma_ub / s->LineTime;
1502 } else {
1503 s->MyError = true;
1504 dml_print("DML:%s: MyErr set. LinesToRequestPrefetchPixelData: %f, should be > 0\n", __func__, s->LinesToRequestPrefetchPixelData);
1505 *p->VRatioPrefetchY = 0;
1506 *p->VRatioPrefetchC = 0;
1507 *p->RequiredPrefetchPixDataBWLuma = 0;
1508 *p->RequiredPrefetchPixDataBWChroma = 0;
1509 }
1510
1511 dml_print("DML: Tpre: %fus - sum of time to request meta pte, 2 x data pte + meta data, swaths\n", (dml_float_t)s->LinesToRequestPrefetchPixelData * s->LineTime + 2.0 * s->TimeForFetchingRowInVBlank + s->TimeForFetchingMetaPTE);
1512 dml_print("DML: Tvm: %fus - time to fetch page tables for meta surface\n", s->TimeForFetchingMetaPTE);
1513 dml_print("DML: Tr0: %fus - time to fetch first row of data pagetables and first row of meta data (done in parallel)\n", s->TimeForFetchingRowInVBlank);
1514 dml_print("DML: Tsw: %fus = time to fetch enough pixel data and cursor data to feed the scalers init position and detile\n", (dml_float_t)s->LinesToRequestPrefetchPixelData * s->LineTime);
1515 dml_print("DML: To: %fus - time for propagation from scaler to optc\n", (*p->DSTYAfterScaler + ((dml_float_t) (*p->DSTXAfterScaler) / (dml_float_t)p->myPipe->HTotal)) * s->LineTime);
1516 dml_print("DML: Tvstartup - TSetup - Tcalc - Twait - Tpre - To > 0\n");
1517 dml_print("DML: Tslack(pre): %fus - time left over in schedule\n", p->VStartup * s->LineTime - s->TimeForFetchingMetaPTE - 2 * s->TimeForFetchingRowInVBlank - (*p->DSTYAfterScaler + ((dml_float_t) (*p->DSTXAfterScaler) / (dml_float_t)p->myPipe->HTotal)) * s->LineTime - p->TWait - p->TCalc - *p->TSetup);
1518 dml_print("DML: row_bytes = dpte_row_bytes (per_pipe) = PixelPTEBytesPerRow = : %u\n", p->PixelPTEBytesPerRow);
1519
1520 } else {
1521 s->MyError = true;
1522 dml_print("DML::%s: MyErr set, dst_y_prefetch_equ = %f (should be > 1)\n", __func__, s->dst_y_prefetch_equ);
1523 s->TimeForFetchingMetaPTE = 0;
1524 s->TimeForFetchingRowInVBlank = 0;
1525 *p->DestinationLinesToRequestVMInVBlank = 0;
1526 *p->DestinationLinesToRequestRowInVBlank = 0;
1527 s->LinesToRequestPrefetchPixelData = 0;
1528 *p->VRatioPrefetchY = 0;
1529 *p->VRatioPrefetchC = 0;
1530 *p->RequiredPrefetchPixDataBWLuma = 0;
1531 *p->RequiredPrefetchPixDataBWChroma = 0;
1532 }
1533
1534 {
1535 dml_float_t prefetch_vm_bw;
1536 dml_float_t prefetch_row_bw;
1537
1538 if (p->PDEAndMetaPTEBytesFrame == 0) {
1539 prefetch_vm_bw = 0;
1540 } else if (*p->DestinationLinesToRequestVMInVBlank > 0) {
1541 #ifdef __DML_VBA_DEBUG__
1542 dml_print("DML::%s: PDEAndMetaPTEBytesFrame = %u\n", __func__, p->PDEAndMetaPTEBytesFrame);
1543 dml_print("DML::%s: HostVMInefficiencyFactor = %f\n", __func__, p->HostVMInefficiencyFactor);
1544 dml_print("DML::%s: DestinationLinesToRequestVMInVBlank = %f\n", __func__, *p->DestinationLinesToRequestVMInVBlank);
1545 dml_print("DML::%s: LineTime = %f\n", __func__, s->LineTime);
1546 #endif
1547 prefetch_vm_bw = p->PDEAndMetaPTEBytesFrame * p->HostVMInefficiencyFactor / (*p->DestinationLinesToRequestVMInVBlank * s->LineTime);
1548 #ifdef __DML_VBA_DEBUG__
1549 dml_print("DML::%s: prefetch_vm_bw = %f\n", __func__, prefetch_vm_bw);
1550 #endif
1551 } else {
1552 prefetch_vm_bw = 0;
1553 s->MyError = true;
1554 dml_print("DML::%s: MyErr set. DestinationLinesToRequestVMInVBlank=%f (should be > 0)\n", __func__, *p->DestinationLinesToRequestVMInVBlank);
1555 }
1556
1557 if (p->MetaRowByte + p->PixelPTEBytesPerRow == 0) {
1558 prefetch_row_bw = 0;
1559 } else if (*p->DestinationLinesToRequestRowInVBlank > 0) {
1560 prefetch_row_bw = (p->MetaRowByte + p->PixelPTEBytesPerRow * p->HostVMInefficiencyFactor) / (*p->DestinationLinesToRequestRowInVBlank * s->LineTime);
1561
1562 #ifdef __DML_VBA_DEBUG__
1563 dml_print("DML::%s: MetaRowByte = %u\n", __func__, p->MetaRowByte);
1564 dml_print("DML::%s: PixelPTEBytesPerRow = %u\n", __func__, p->PixelPTEBytesPerRow);
1565 dml_print("DML::%s: DestinationLinesToRequestRowInVBlank = %f\n", __func__, *p->DestinationLinesToRequestRowInVBlank);
1566 dml_print("DML::%s: prefetch_row_bw = %f\n", __func__, prefetch_row_bw);
1567 #endif
1568 } else {
1569 prefetch_row_bw = 0;
1570 s->MyError = true;
1571 dml_print("DML::%s: MyErr set. DestinationLinesToRequestRowInVBlank=%f (should be > 0)\n", __func__, *p->DestinationLinesToRequestRowInVBlank);
1572 }
1573
1574 *p->prefetch_vmrow_bw = dml_max(prefetch_vm_bw, prefetch_row_bw);
1575 }
1576
1577 if (s->MyError) {
1578 s->TimeForFetchingMetaPTE = 0;
1579 s->TimeForFetchingRowInVBlank = 0;
1580 *p->DestinationLinesToRequestVMInVBlank = 0;
1581 *p->DestinationLinesToRequestRowInVBlank = 0;
1582 *p->DestinationLinesForPrefetch = 0;
1583 s->LinesToRequestPrefetchPixelData = 0;
1584 *p->VRatioPrefetchY = 0;
1585 *p->VRatioPrefetchC = 0;
1586 *p->RequiredPrefetchPixDataBWLuma = 0;
1587 *p->RequiredPrefetchPixDataBWChroma = 0;
1588 }
1589
1590 return s->MyError;
1591 } // CalculatePrefetchSchedule
1592
CalculateBytePerPixelAndBlockSizes(enum dml_source_format_class SourcePixelFormat,enum dml_swizzle_mode SurfaceTiling,dml_uint_t * BytePerPixelY,dml_uint_t * BytePerPixelC,dml_float_t * BytePerPixelDETY,dml_float_t * BytePerPixelDETC,dml_uint_t * BlockHeight256BytesY,dml_uint_t * BlockHeight256BytesC,dml_uint_t * BlockWidth256BytesY,dml_uint_t * BlockWidth256BytesC,dml_uint_t * MacroTileHeightY,dml_uint_t * MacroTileHeightC,dml_uint_t * MacroTileWidthY,dml_uint_t * MacroTileWidthC)1593 static void CalculateBytePerPixelAndBlockSizes(
1594 enum dml_source_format_class SourcePixelFormat,
1595 enum dml_swizzle_mode SurfaceTiling,
1596
1597 // Output
1598 dml_uint_t *BytePerPixelY,
1599 dml_uint_t *BytePerPixelC,
1600 dml_float_t *BytePerPixelDETY,
1601 dml_float_t *BytePerPixelDETC,
1602 dml_uint_t *BlockHeight256BytesY,
1603 dml_uint_t *BlockHeight256BytesC,
1604 dml_uint_t *BlockWidth256BytesY,
1605 dml_uint_t *BlockWidth256BytesC,
1606 dml_uint_t *MacroTileHeightY,
1607 dml_uint_t *MacroTileHeightC,
1608 dml_uint_t *MacroTileWidthY,
1609 dml_uint_t *MacroTileWidthC)
1610 {
1611 if (SourcePixelFormat == dml_444_64) {
1612 *BytePerPixelDETY = 8;
1613 *BytePerPixelDETC = 0;
1614 *BytePerPixelY = 8;
1615 *BytePerPixelC = 0;
1616 } else if (SourcePixelFormat == dml_444_32 || SourcePixelFormat == dml_rgbe) {
1617 *BytePerPixelDETY = 4;
1618 *BytePerPixelDETC = 0;
1619 *BytePerPixelY = 4;
1620 *BytePerPixelC = 0;
1621 } else if (SourcePixelFormat == dml_444_16 || SourcePixelFormat == dml_mono_16) {
1622 *BytePerPixelDETY = 2;
1623 *BytePerPixelDETC = 0;
1624 *BytePerPixelY = 2;
1625 *BytePerPixelC = 0;
1626 } else if (SourcePixelFormat == dml_444_8 || SourcePixelFormat == dml_mono_8) {
1627 *BytePerPixelDETY = 1;
1628 *BytePerPixelDETC = 0;
1629 *BytePerPixelY = 1;
1630 *BytePerPixelC = 0;
1631 } else if (SourcePixelFormat == dml_rgbe_alpha) {
1632 *BytePerPixelDETY = 4;
1633 *BytePerPixelDETC = 1;
1634 *BytePerPixelY = 4;
1635 *BytePerPixelC = 1;
1636 } else if (SourcePixelFormat == dml_420_8) {
1637 *BytePerPixelDETY = 1;
1638 *BytePerPixelDETC = 2;
1639 *BytePerPixelY = 1;
1640 *BytePerPixelC = 2;
1641 } else if (SourcePixelFormat == dml_420_12) {
1642 *BytePerPixelDETY = 2;
1643 *BytePerPixelDETC = 4;
1644 *BytePerPixelY = 2;
1645 *BytePerPixelC = 4;
1646 } else {
1647 *BytePerPixelDETY = (dml_float_t) (4.0 / 3);
1648 *BytePerPixelDETC = (dml_float_t) (8.0 / 3);
1649 *BytePerPixelY = 2;
1650 *BytePerPixelC = 4;
1651 }
1652 #ifdef __DML_VBA_DEBUG__
1653 dml_print("DML::%s: SourcePixelFormat = %u\n", __func__, SourcePixelFormat);
1654 dml_print("DML::%s: BytePerPixelDETY = %f\n", __func__, *BytePerPixelDETY);
1655 dml_print("DML::%s: BytePerPixelDETC = %f\n", __func__, *BytePerPixelDETC);
1656 dml_print("DML::%s: BytePerPixelY = %u\n", __func__, *BytePerPixelY);
1657 dml_print("DML::%s: BytePerPixelC = %u\n", __func__, *BytePerPixelC);
1658 #endif
1659 if ((SourcePixelFormat == dml_444_64 || SourcePixelFormat == dml_444_32
1660 || SourcePixelFormat == dml_444_16
1661 || SourcePixelFormat == dml_444_8
1662 || SourcePixelFormat == dml_mono_16
1663 || SourcePixelFormat == dml_mono_8
1664 || SourcePixelFormat == dml_rgbe)) {
1665 if (SurfaceTiling == dml_sw_linear) {
1666 *BlockHeight256BytesY = 1;
1667 } else if (SourcePixelFormat == dml_444_64) {
1668 *BlockHeight256BytesY = 4;
1669 } else if (SourcePixelFormat == dml_444_8) {
1670 *BlockHeight256BytesY = 16;
1671 } else {
1672 *BlockHeight256BytesY = 8;
1673 }
1674 *BlockWidth256BytesY = 256U / *BytePerPixelY / *BlockHeight256BytesY;
1675 *BlockHeight256BytesC = 0;
1676 *BlockWidth256BytesC = 0;
1677 } else {
1678 if (SurfaceTiling == dml_sw_linear) {
1679 *BlockHeight256BytesY = 1;
1680 *BlockHeight256BytesC = 1;
1681 } else if (SourcePixelFormat == dml_rgbe_alpha) {
1682 *BlockHeight256BytesY = 8;
1683 *BlockHeight256BytesC = 16;
1684 } else if (SourcePixelFormat == dml_420_8) {
1685 *BlockHeight256BytesY = 16;
1686 *BlockHeight256BytesC = 8;
1687 } else {
1688 *BlockHeight256BytesY = 8;
1689 *BlockHeight256BytesC = 8;
1690 }
1691 *BlockWidth256BytesY = 256U / *BytePerPixelY / *BlockHeight256BytesY;
1692 *BlockWidth256BytesC = 256U / *BytePerPixelC / *BlockHeight256BytesC;
1693 }
1694 #ifdef __DML_VBA_DEBUG__
1695 dml_print("DML::%s: BlockWidth256BytesY = %u\n", __func__, *BlockWidth256BytesY);
1696 dml_print("DML::%s: BlockHeight256BytesY = %u\n", __func__, *BlockHeight256BytesY);
1697 dml_print("DML::%s: BlockWidth256BytesC = %u\n", __func__, *BlockWidth256BytesC);
1698 dml_print("DML::%s: BlockHeight256BytesC = %u\n", __func__, *BlockHeight256BytesC);
1699 #endif
1700
1701 if (SurfaceTiling == dml_sw_linear) {
1702 *MacroTileHeightY = *BlockHeight256BytesY;
1703 *MacroTileWidthY = 256 / *BytePerPixelY / *MacroTileHeightY;
1704 *MacroTileHeightC = *BlockHeight256BytesC;
1705 if (*MacroTileHeightC == 0) {
1706 *MacroTileWidthC = 0;
1707 } else {
1708 *MacroTileWidthC = 256 / *BytePerPixelC / *MacroTileHeightC;
1709 }
1710 } else if (SurfaceTiling == dml_sw_64kb_d || SurfaceTiling == dml_sw_64kb_d_t || SurfaceTiling == dml_sw_64kb_d_x || SurfaceTiling == dml_sw_64kb_r_x) {
1711 *MacroTileHeightY = 16 * *BlockHeight256BytesY;
1712 *MacroTileWidthY = 65536 / *BytePerPixelY / *MacroTileHeightY;
1713 *MacroTileHeightC = 16 * *BlockHeight256BytesC;
1714 if (*MacroTileHeightC == 0) {
1715 *MacroTileWidthC = 0;
1716 } else {
1717 *MacroTileWidthC = 65536 / *BytePerPixelC / *MacroTileHeightC;
1718 }
1719 } else {
1720 *MacroTileHeightY = 32 * *BlockHeight256BytesY;
1721 *MacroTileWidthY = 65536 * 4 / *BytePerPixelY / *MacroTileHeightY;
1722 *MacroTileHeightC = 32 * *BlockHeight256BytesC;
1723 if (*MacroTileHeightC == 0) {
1724 *MacroTileWidthC = 0;
1725 } else {
1726 *MacroTileWidthC = 65536 * 4 / *BytePerPixelC / *MacroTileHeightC;
1727 }
1728 }
1729
1730 #ifdef __DML_VBA_DEBUG__
1731 dml_print("DML::%s: MacroTileWidthY = %u\n", __func__, *MacroTileWidthY);
1732 dml_print("DML::%s: MacroTileHeightY = %u\n", __func__, *MacroTileHeightY);
1733 dml_print("DML::%s: MacroTileWidthC = %u\n", __func__, *MacroTileWidthC);
1734 dml_print("DML::%s: MacroTileHeightC = %u\n", __func__, *MacroTileHeightC);
1735 #endif
1736 } // CalculateBytePerPixelAndBlockSizes
1737
CalculateTWait(dml_uint_t PrefetchMode,enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange,dml_bool_t SynchronizeDRRDisplaysForUCLKPStateChangeFinal,dml_bool_t DRRDisplay,dml_float_t DRAMClockChangeLatency,dml_float_t FCLKChangeLatency,dml_float_t UrgentLatency,dml_float_t SREnterPlusExitTime)1738 static dml_float_t CalculateTWait(
1739 dml_uint_t PrefetchMode,
1740 enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange,
1741 dml_bool_t SynchronizeDRRDisplaysForUCLKPStateChangeFinal,
1742 dml_bool_t DRRDisplay,
1743 dml_float_t DRAMClockChangeLatency,
1744 dml_float_t FCLKChangeLatency,
1745 dml_float_t UrgentLatency,
1746 dml_float_t SREnterPlusExitTime)
1747 {
1748 dml_float_t TWait = 0.0;
1749
1750 if (PrefetchMode == 0 &&
1751 !(UseMALLForPStateChange == dml_use_mall_pstate_change_full_frame) && !(UseMALLForPStateChange == dml_use_mall_pstate_change_sub_viewport) &&
1752 !(UseMALLForPStateChange == dml_use_mall_pstate_change_phantom_pipe) && !(SynchronizeDRRDisplaysForUCLKPStateChangeFinal && DRRDisplay)) {
1753 TWait = dml_max3(DRAMClockChangeLatency + UrgentLatency, SREnterPlusExitTime, UrgentLatency);
1754 } else if (PrefetchMode <= 1 && !(UseMALLForPStateChange == dml_use_mall_pstate_change_phantom_pipe)) {
1755 TWait = dml_max3(FCLKChangeLatency + UrgentLatency, SREnterPlusExitTime, UrgentLatency);
1756 } else if (PrefetchMode <= 2 && !(UseMALLForPStateChange == dml_use_mall_pstate_change_phantom_pipe)) {
1757 TWait = dml_max(SREnterPlusExitTime, UrgentLatency);
1758 } else {
1759 TWait = UrgentLatency;
1760 }
1761
1762 #ifdef __DML_VBA_DEBUG__
1763 dml_print("DML::%s: PrefetchMode = %u\n", __func__, PrefetchMode);
1764 dml_print("DML::%s: TWait = %f\n", __func__, TWait);
1765 #endif
1766 return TWait;
1767 } // CalculateTWait
1768
1769
1770 /// @brief Calculate the "starting point" for prefetch calculation
1771 /// if AllowForPStateChangeOrStutterInVBlank is set as a particular requirement, then the mode evalulation
1772 /// will only be done at the given mode. If no specific requirement (i.e. *_if_possible), then will just go from
1773 /// try all the prefetch mode in decreasing order of "difficulty" (start from 0 which means all power saving
1774 /// features).
CalculatePrefetchMode(enum dml_prefetch_modes AllowForPStateChangeOrStutterInVBlank,dml_uint_t * MinPrefetchMode,dml_uint_t * MaxPrefetchMode)1775 static void CalculatePrefetchMode(
1776 enum dml_prefetch_modes AllowForPStateChangeOrStutterInVBlank,
1777 dml_uint_t *MinPrefetchMode,
1778 dml_uint_t *MaxPrefetchMode)
1779 {
1780 if (AllowForPStateChangeOrStutterInVBlank == dml_prefetch_support_uclk_fclk_and_stutter_if_possible) {
1781 *MinPrefetchMode = 0; // consider all pwr saving features
1782 *MaxPrefetchMode = 3; // consider just urgent latency
1783 } else {
1784 if (AllowForPStateChangeOrStutterInVBlank == dml_prefetch_support_none) {
1785 *MinPrefetchMode = 3;
1786 } else if (AllowForPStateChangeOrStutterInVBlank == dml_prefetch_support_stutter) {
1787 *MinPrefetchMode = 2;
1788 } else if (AllowForPStateChangeOrStutterInVBlank == dml_prefetch_support_fclk_and_stutter) {
1789 *MinPrefetchMode = 1;
1790 } else if (AllowForPStateChangeOrStutterInVBlank == dml_prefetch_support_uclk_fclk_and_stutter) {
1791 *MinPrefetchMode = 0;
1792 } else {
1793 dml_print("ERROR: Invalid AllowForPStateChangeOrStutterInVBlank setting! val=%u\n", AllowForPStateChangeOrStutterInVBlank);
1794 ASSERT(0);
1795 }
1796 *MaxPrefetchMode = *MinPrefetchMode;
1797 }
1798 } // CalculatePrefetchMode
1799
CalculateWriteBackDISPCLK(enum dml_source_format_class WritebackPixelFormat,dml_float_t PixelClock,dml_float_t WritebackHRatio,dml_float_t WritebackVRatio,dml_uint_t WritebackHTaps,dml_uint_t WritebackVTaps,dml_uint_t WritebackSourceWidth,dml_uint_t WritebackDestinationWidth,dml_uint_t HTotal,dml_uint_t WritebackLineBufferSize,dml_float_t DISPCLKDPPCLKVCOSpeed)1800 static dml_float_t CalculateWriteBackDISPCLK(
1801 enum dml_source_format_class WritebackPixelFormat,
1802 dml_float_t PixelClock,
1803 dml_float_t WritebackHRatio,
1804 dml_float_t WritebackVRatio,
1805 dml_uint_t WritebackHTaps,
1806 dml_uint_t WritebackVTaps,
1807 dml_uint_t WritebackSourceWidth,
1808 dml_uint_t WritebackDestinationWidth,
1809 dml_uint_t HTotal,
1810 dml_uint_t WritebackLineBufferSize,
1811 dml_float_t DISPCLKDPPCLKVCOSpeed)
1812 {
1813 dml_float_t DISPCLK_H, DISPCLK_V, DISPCLK_HB;
1814
1815 DISPCLK_H = PixelClock * dml_ceil(WritebackHTaps / 8.0, 1) / WritebackHRatio;
1816 DISPCLK_V = PixelClock * (WritebackVTaps * dml_ceil(WritebackDestinationWidth / 6.0, 1) + 8.0) / (dml_float_t) HTotal;
1817 DISPCLK_HB = PixelClock * WritebackVTaps * (WritebackDestinationWidth * WritebackVTaps - WritebackLineBufferSize / 57.0) / 6.0 / (dml_float_t) WritebackSourceWidth;
1818 return RoundToDFSGranularity(dml_max3(DISPCLK_H, DISPCLK_V, DISPCLK_HB), 1, DISPCLKDPPCLKVCOSpeed);
1819 }
1820
CalculateWriteBackDelay(enum dml_source_format_class WritebackPixelFormat,dml_float_t WritebackHRatio,dml_float_t WritebackVRatio,dml_uint_t WritebackVTaps,dml_uint_t WritebackDestinationWidth,dml_uint_t WritebackDestinationHeight,dml_uint_t WritebackSourceHeight,dml_uint_t HTotal)1821 static dml_float_t CalculateWriteBackDelay(
1822 enum dml_source_format_class WritebackPixelFormat,
1823 dml_float_t WritebackHRatio,
1824 dml_float_t WritebackVRatio,
1825 dml_uint_t WritebackVTaps,
1826 dml_uint_t WritebackDestinationWidth,
1827 dml_uint_t WritebackDestinationHeight,
1828 dml_uint_t WritebackSourceHeight,
1829 dml_uint_t HTotal)
1830 {
1831 dml_float_t CalculateWriteBackDelay;
1832 dml_float_t Line_length;
1833 dml_float_t Output_lines_last_notclamped;
1834 dml_float_t WritebackVInit;
1835
1836 WritebackVInit = (WritebackVRatio + WritebackVTaps + 1) / 2;
1837 Line_length = dml_max((dml_float_t) WritebackDestinationWidth, dml_ceil((dml_float_t)WritebackDestinationWidth / 6.0, 1.0) * WritebackVTaps);
1838 Output_lines_last_notclamped = WritebackDestinationHeight - 1 - dml_ceil(((dml_float_t)WritebackSourceHeight - (dml_float_t) WritebackVInit) / (dml_float_t)WritebackVRatio, 1.0);
1839 if (Output_lines_last_notclamped < 0) {
1840 CalculateWriteBackDelay = 0;
1841 } else {
1842 CalculateWriteBackDelay = Output_lines_last_notclamped * Line_length + (HTotal - WritebackDestinationWidth) + 80;
1843 }
1844 return CalculateWriteBackDelay;
1845 }
1846
CalculateVUpdateAndDynamicMetadataParameters(dml_uint_t MaxInterDCNTileRepeaters,dml_float_t Dppclk,dml_float_t Dispclk,dml_float_t DCFClkDeepSleep,dml_float_t PixelClock,dml_uint_t HTotal,dml_uint_t VBlank,dml_uint_t DynamicMetadataTransmittedBytes,dml_uint_t DynamicMetadataLinesBeforeActiveRequired,dml_uint_t InterlaceEnable,dml_bool_t ProgressiveToInterlaceUnitInOPP,dml_float_t * TSetup,dml_float_t * Tdmbf,dml_float_t * Tdmec,dml_float_t * Tdmsks,dml_uint_t * VUpdateOffsetPix,dml_uint_t * VUpdateWidthPix,dml_uint_t * VReadyOffsetPix)1847 static void CalculateVUpdateAndDynamicMetadataParameters(
1848 dml_uint_t MaxInterDCNTileRepeaters,
1849 dml_float_t Dppclk,
1850 dml_float_t Dispclk,
1851 dml_float_t DCFClkDeepSleep,
1852 dml_float_t PixelClock,
1853 dml_uint_t HTotal,
1854 dml_uint_t VBlank,
1855 dml_uint_t DynamicMetadataTransmittedBytes,
1856 dml_uint_t DynamicMetadataLinesBeforeActiveRequired,
1857 dml_uint_t InterlaceEnable,
1858 dml_bool_t ProgressiveToInterlaceUnitInOPP,
1859
1860 // Output
1861 dml_float_t *TSetup,
1862 dml_float_t *Tdmbf,
1863 dml_float_t *Tdmec,
1864 dml_float_t *Tdmsks,
1865 dml_uint_t *VUpdateOffsetPix,
1866 dml_uint_t *VUpdateWidthPix,
1867 dml_uint_t *VReadyOffsetPix)
1868 {
1869 dml_float_t TotalRepeaterDelayTime;
1870 TotalRepeaterDelayTime = MaxInterDCNTileRepeaters * (2 / Dppclk + 3 / Dispclk);
1871 *VUpdateWidthPix = (dml_uint_t)(dml_ceil((14.0 / DCFClkDeepSleep + 12.0 / Dppclk + TotalRepeaterDelayTime) * PixelClock, 1.0));
1872 *VReadyOffsetPix = (dml_uint_t)(dml_ceil(dml_max(150.0 / Dppclk, TotalRepeaterDelayTime + 20.0 / DCFClkDeepSleep + 10.0 / Dppclk) * PixelClock, 1.0));
1873 *VUpdateOffsetPix = (dml_uint_t)(dml_ceil(HTotal / 4.0, 1.0));
1874 *TSetup = (*VUpdateOffsetPix + *VUpdateWidthPix + *VReadyOffsetPix) / PixelClock;
1875 *Tdmbf = DynamicMetadataTransmittedBytes / 4.0 / Dispclk;
1876 *Tdmec = HTotal / PixelClock;
1877
1878 if (DynamicMetadataLinesBeforeActiveRequired == 0) {
1879 *Tdmsks = VBlank * HTotal / PixelClock / 2.0;
1880 } else {
1881 *Tdmsks = DynamicMetadataLinesBeforeActiveRequired * HTotal / PixelClock;
1882 }
1883 if (InterlaceEnable == 1 && ProgressiveToInterlaceUnitInOPP == false) {
1884 *Tdmsks = *Tdmsks / 2;
1885 }
1886 #ifdef __DML_VBA_DEBUG__
1887 dml_print("DML::%s: DynamicMetadataLinesBeforeActiveRequired = %u\n", __func__, DynamicMetadataLinesBeforeActiveRequired);
1888 dml_print("DML::%s: VBlank = %u\n", __func__, VBlank);
1889 dml_print("DML::%s: HTotal = %u\n", __func__, HTotal);
1890 dml_print("DML::%s: PixelClock = %f\n", __func__, PixelClock);
1891 dml_print("DML::%s: Dppclk = %f\n", __func__, Dppclk);
1892 dml_print("DML::%s: DCFClkDeepSleep = %f\n", __func__, DCFClkDeepSleep);
1893 dml_print("DML::%s: MaxInterDCNTileRepeaters = %u\n", __func__, MaxInterDCNTileRepeaters);
1894 dml_print("DML::%s: TotalRepeaterDelayTime = %f\n", __func__, TotalRepeaterDelayTime);
1895
1896 dml_print("DML::%s: VUpdateWidthPix = %u\n", __func__, *VUpdateWidthPix);
1897 dml_print("DML::%s: VReadyOffsetPix = %u\n", __func__, *VReadyOffsetPix);
1898 dml_print("DML::%s: VUpdateOffsetPix = %u\n", __func__, *VUpdateOffsetPix);
1899
1900 dml_print("DML::%s: Tdmsks = %f\n", __func__, *Tdmsks);
1901 #endif
1902 }
1903
CalculateRowBandwidth(dml_bool_t GPUVMEnable,enum dml_source_format_class SourcePixelFormat,dml_float_t VRatio,dml_float_t VRatioChroma,dml_bool_t DCCEnable,dml_float_t LineTime,dml_uint_t MetaRowByteLuma,dml_uint_t MetaRowByteChroma,dml_uint_t meta_row_height_luma,dml_uint_t meta_row_height_chroma,dml_uint_t PixelPTEBytesPerRowLuma,dml_uint_t PixelPTEBytesPerRowChroma,dml_uint_t dpte_row_height_luma,dml_uint_t dpte_row_height_chroma,dml_float_t * meta_row_bw,dml_float_t * dpte_row_bw)1904 static void CalculateRowBandwidth(
1905 dml_bool_t GPUVMEnable,
1906 enum dml_source_format_class SourcePixelFormat,
1907 dml_float_t VRatio,
1908 dml_float_t VRatioChroma,
1909 dml_bool_t DCCEnable,
1910 dml_float_t LineTime,
1911 dml_uint_t MetaRowByteLuma,
1912 dml_uint_t MetaRowByteChroma,
1913 dml_uint_t meta_row_height_luma,
1914 dml_uint_t meta_row_height_chroma,
1915 dml_uint_t PixelPTEBytesPerRowLuma,
1916 dml_uint_t PixelPTEBytesPerRowChroma,
1917 dml_uint_t dpte_row_height_luma,
1918 dml_uint_t dpte_row_height_chroma,
1919 // Output
1920 dml_float_t *meta_row_bw,
1921 dml_float_t *dpte_row_bw)
1922 {
1923 if (DCCEnable != true) {
1924 *meta_row_bw = 0;
1925 } else if (SourcePixelFormat == dml_420_8 || SourcePixelFormat == dml_420_10 || SourcePixelFormat == dml_420_12 || SourcePixelFormat == dml_rgbe_alpha) {
1926 *meta_row_bw = VRatio * MetaRowByteLuma / (meta_row_height_luma * LineTime)
1927 + VRatioChroma * MetaRowByteChroma
1928 / (meta_row_height_chroma * LineTime);
1929 } else {
1930 *meta_row_bw = VRatio * MetaRowByteLuma / (meta_row_height_luma * LineTime);
1931 }
1932
1933 if (GPUVMEnable != true) {
1934 *dpte_row_bw = 0;
1935 } else if (SourcePixelFormat == dml_420_8 || SourcePixelFormat == dml_420_10 || SourcePixelFormat == dml_420_12 || SourcePixelFormat == dml_rgbe_alpha) {
1936 *dpte_row_bw = VRatio * PixelPTEBytesPerRowLuma / (dpte_row_height_luma * LineTime)
1937 + VRatioChroma * PixelPTEBytesPerRowChroma
1938 / (dpte_row_height_chroma * LineTime);
1939 } else {
1940 *dpte_row_bw = VRatio * PixelPTEBytesPerRowLuma / (dpte_row_height_luma * LineTime);
1941 }
1942 }
1943
1944 /// @brief Determine immediate flip schedule given bw remaining after considering the prefetch schedule
1945 /// @param BandwidthAvailableForImmediateFlip Bandwidth available for iflip for all planes
CalculateFlipSchedule(dml_float_t HostVMInefficiencyFactor,dml_float_t UrgentExtraLatency,dml_float_t UrgentLatency,dml_uint_t GPUVMMaxPageTableLevels,dml_bool_t HostVMEnable,dml_uint_t HostVMMaxNonCachedPageTableLevels,dml_bool_t GPUVMEnable,dml_uint_t HostVMMinPageSize,dml_float_t PDEAndMetaPTEBytesPerFrame,dml_float_t MetaRowBytes,dml_float_t DPTEBytesPerRow,dml_float_t BandwidthAvailableForImmediateFlip,dml_uint_t TotImmediateFlipBytes,enum dml_source_format_class SourcePixelFormat,dml_float_t LineTime,dml_float_t VRatio,dml_float_t VRatioChroma,dml_float_t Tno_bw,dml_bool_t DCCEnable,dml_uint_t dpte_row_height,dml_uint_t meta_row_height,dml_uint_t dpte_row_height_chroma,dml_uint_t meta_row_height_chroma,dml_bool_t use_one_row_for_frame_flip,dml_float_t * DestinationLinesToRequestVMInImmediateFlip,dml_float_t * DestinationLinesToRequestRowInImmediateFlip,dml_float_t * final_flip_bw,dml_bool_t * ImmediateFlipSupportedForPipe)1946 static void CalculateFlipSchedule(
1947 dml_float_t HostVMInefficiencyFactor,
1948 dml_float_t UrgentExtraLatency,
1949 dml_float_t UrgentLatency,
1950 dml_uint_t GPUVMMaxPageTableLevels,
1951 dml_bool_t HostVMEnable,
1952 dml_uint_t HostVMMaxNonCachedPageTableLevels,
1953 dml_bool_t GPUVMEnable,
1954 dml_uint_t HostVMMinPageSize,
1955 dml_float_t PDEAndMetaPTEBytesPerFrame,
1956 dml_float_t MetaRowBytes,
1957 dml_float_t DPTEBytesPerRow,
1958 dml_float_t BandwidthAvailableForImmediateFlip,
1959 dml_uint_t TotImmediateFlipBytes,
1960 enum dml_source_format_class SourcePixelFormat,
1961 dml_float_t LineTime,
1962 dml_float_t VRatio,
1963 dml_float_t VRatioChroma,
1964 dml_float_t Tno_bw,
1965 dml_bool_t DCCEnable,
1966 dml_uint_t dpte_row_height,
1967 dml_uint_t meta_row_height,
1968 dml_uint_t dpte_row_height_chroma,
1969 dml_uint_t meta_row_height_chroma,
1970 dml_bool_t use_one_row_for_frame_flip,
1971
1972 // Output
1973 dml_float_t *DestinationLinesToRequestVMInImmediateFlip,
1974 dml_float_t *DestinationLinesToRequestRowInImmediateFlip,
1975 dml_float_t *final_flip_bw,
1976 dml_bool_t *ImmediateFlipSupportedForPipe)
1977 {
1978 dml_float_t min_row_time = 0.0;
1979 dml_uint_t HostVMDynamicLevelsTrips = 0;
1980 dml_float_t TimeForFetchingMetaPTEImmediateFlip = 0;
1981 dml_float_t TimeForFetchingRowInVBlankImmediateFlip = 0;
1982 dml_float_t ImmediateFlipBW = 0; // @brief The immediate flip bandwidth for this pipe
1983
1984 if (GPUVMEnable == true && HostVMEnable == true) {
1985 HostVMDynamicLevelsTrips = HostVMMaxNonCachedPageTableLevels;
1986 } else {
1987 HostVMDynamicLevelsTrips = 0;
1988 }
1989
1990 #ifdef __DML_VBA_DEBUG__
1991 dml_print("DML::%s: TotImmediateFlipBytes = %u\n", __func__, TotImmediateFlipBytes);
1992 dml_print("DML::%s: HostVMInefficiencyFactor = %f\n", __func__, HostVMInefficiencyFactor);
1993 dml_print("DML::%s: UrgentLatency = %f\n", __func__, UrgentLatency);
1994 dml_print("DML::%s: BandwidthAvailableForImmediateFlip = %f\n", __func__, BandwidthAvailableForImmediateFlip);
1995 #endif
1996
1997 if (TotImmediateFlipBytes > 0) {
1998 if (use_one_row_for_frame_flip) {
1999 ImmediateFlipBW = (PDEAndMetaPTEBytesPerFrame + MetaRowBytes + 2.0 * DPTEBytesPerRow) * BandwidthAvailableForImmediateFlip / (dml_float_t) TotImmediateFlipBytes;
2000 } else {
2001 ImmediateFlipBW = (PDEAndMetaPTEBytesPerFrame + MetaRowBytes + DPTEBytesPerRow) * BandwidthAvailableForImmediateFlip / (dml_float_t) TotImmediateFlipBytes;
2002 }
2003 if (GPUVMEnable == true) {
2004 TimeForFetchingMetaPTEImmediateFlip = dml_max3(Tno_bw + PDEAndMetaPTEBytesPerFrame * HostVMInefficiencyFactor / ImmediateFlipBW,
2005 UrgentExtraLatency + UrgentLatency * (GPUVMMaxPageTableLevels * (HostVMDynamicLevelsTrips + 1) - 1),
2006 LineTime / 4.0);
2007 } else {
2008 TimeForFetchingMetaPTEImmediateFlip = 0;
2009 }
2010 if ((GPUVMEnable == true || DCCEnable == true)) {
2011 TimeForFetchingRowInVBlankImmediateFlip = dml_max3((MetaRowBytes + DPTEBytesPerRow * HostVMInefficiencyFactor) / ImmediateFlipBW, UrgentLatency * (HostVMDynamicLevelsTrips + 1), LineTime / 4.0);
2012 } else {
2013 TimeForFetchingRowInVBlankImmediateFlip = 0;
2014 }
2015
2016 *DestinationLinesToRequestVMInImmediateFlip = dml_ceil(4.0 * (TimeForFetchingMetaPTEImmediateFlip / LineTime), 1.0) / 4.0;
2017 *DestinationLinesToRequestRowInImmediateFlip = dml_ceil(4.0 * (TimeForFetchingRowInVBlankImmediateFlip / LineTime), 1.0) / 4.0;
2018
2019 if (GPUVMEnable == true) {
2020 *final_flip_bw = dml_max(PDEAndMetaPTEBytesPerFrame * HostVMInefficiencyFactor / (*DestinationLinesToRequestVMInImmediateFlip * LineTime),
2021 (MetaRowBytes + DPTEBytesPerRow * HostVMInefficiencyFactor) / (*DestinationLinesToRequestRowInImmediateFlip * LineTime));
2022 } else if ((GPUVMEnable == true || DCCEnable == true)) {
2023 *final_flip_bw = (MetaRowBytes + DPTEBytesPerRow * HostVMInefficiencyFactor) / (*DestinationLinesToRequestRowInImmediateFlip * LineTime);
2024 } else {
2025 *final_flip_bw = 0;
2026 }
2027 } else {
2028 TimeForFetchingMetaPTEImmediateFlip = 0;
2029 TimeForFetchingRowInVBlankImmediateFlip = 0;
2030 *DestinationLinesToRequestVMInImmediateFlip = 0;
2031 *DestinationLinesToRequestRowInImmediateFlip = 0;
2032 *final_flip_bw = 0;
2033 }
2034
2035 if (SourcePixelFormat == dml_420_8 || SourcePixelFormat == dml_420_10 || SourcePixelFormat == dml_rgbe_alpha) {
2036 if (GPUVMEnable == true && DCCEnable != true) {
2037 min_row_time = dml_min(dpte_row_height * LineTime / VRatio, dpte_row_height_chroma * LineTime / VRatioChroma);
2038 } else if (GPUVMEnable != true && DCCEnable == true) {
2039 min_row_time = dml_min(meta_row_height * LineTime / VRatio, meta_row_height_chroma * LineTime / VRatioChroma);
2040 } else {
2041 min_row_time = dml_min4(dpte_row_height * LineTime / VRatio, meta_row_height * LineTime / VRatio, dpte_row_height_chroma * LineTime / VRatioChroma, meta_row_height_chroma * LineTime / VRatioChroma);
2042 }
2043 } else {
2044 if (GPUVMEnable == true && DCCEnable != true) {
2045 min_row_time = dpte_row_height * LineTime / VRatio;
2046 } else if (GPUVMEnable != true && DCCEnable == true) {
2047 min_row_time = meta_row_height * LineTime / VRatio;
2048 } else {
2049 min_row_time = dml_min(dpte_row_height * LineTime / VRatio, meta_row_height * LineTime / VRatio);
2050 }
2051 }
2052
2053 if (*DestinationLinesToRequestVMInImmediateFlip >= 32 || *DestinationLinesToRequestRowInImmediateFlip >= 16 || TimeForFetchingMetaPTEImmediateFlip + 2 * TimeForFetchingRowInVBlankImmediateFlip > min_row_time) {
2054 *ImmediateFlipSupportedForPipe = false;
2055 } else {
2056 *ImmediateFlipSupportedForPipe = true;
2057 }
2058
2059 #ifdef __DML_VBA_DEBUG__
2060 dml_print("DML::%s: GPUVMEnable = %u\n", __func__, GPUVMEnable);
2061 dml_print("DML::%s: DCCEnable = %u\n", __func__, DCCEnable);
2062
2063 dml_print("DML::%s: MetaRowBytes = %f\n", __func__, MetaRowBytes);
2064 dml_print("DML::%s: DPTEBytesPerRow = %f\n", __func__, DPTEBytesPerRow);
2065 dml_print("DML::%s: BandwidthAvailableForImmediateFlip = %f\n", __func__, BandwidthAvailableForImmediateFlip);
2066 dml_print("DML::%s: TotImmediateFlipBytes = %u\n", __func__, TotImmediateFlipBytes);
2067 dml_print("DML::%s: ImmediateFlipBW = %f\n", __func__, ImmediateFlipBW);
2068 dml_print("DML::%s: PDEAndMetaPTEBytesPerFrame = %f\n", __func__, PDEAndMetaPTEBytesPerFrame);
2069 dml_print("DML::%s: HostVMInefficiencyFactor = %f\n", __func__, HostVMInefficiencyFactor);
2070 dml_print("DML::%s: LineTime = %f\n", __func__, LineTime);
2071 dml_print("DML::%s: final_flip_bw = %f\n", __func__, *final_flip_bw);
2072
2073 dml_print("DML::%s: DestinationLinesToRequestVMInImmediateFlip = %f\n", __func__, *DestinationLinesToRequestVMInImmediateFlip);
2074 dml_print("DML::%s: DestinationLinesToRequestRowInImmediateFlip = %f\n", __func__, *DestinationLinesToRequestRowInImmediateFlip);
2075 dml_print("DML::%s: TimeForFetchingMetaPTEImmediateFlip = %f\n", __func__, TimeForFetchingMetaPTEImmediateFlip);
2076 dml_print("DML::%s: TimeForFetchingRowInVBlankImmediateFlip = %f\n", __func__, TimeForFetchingRowInVBlankImmediateFlip);
2077 dml_print("DML::%s: min_row_time = %f\n", __func__, min_row_time);
2078 dml_print("DML::%s: ImmediateFlipSupportedForPipe = %u\n", __func__, *ImmediateFlipSupportedForPipe);
2079 #endif
2080 } // CalculateFlipSchedule
2081
RoundToDFSGranularity(dml_float_t Clock,dml_bool_t round_up,dml_float_t VCOSpeed)2082 static dml_float_t RoundToDFSGranularity(dml_float_t Clock, dml_bool_t round_up, dml_float_t VCOSpeed)
2083 {
2084 if (Clock <= 0.0)
2085 return 0.0;
2086 else {
2087 if (round_up)
2088 return VCOSpeed * 4.0 / dml_floor(VCOSpeed * 4.0 / Clock, 1.0);
2089 else
2090 return VCOSpeed * 4.0 / dml_ceil(VCOSpeed * 4.0 / Clock, 1.0);
2091 }
2092 }
2093
CalculateDCCConfiguration(dml_bool_t DCCEnabled,dml_bool_t DCCProgrammingAssumesScanDirectionUnknown,enum dml_source_format_class SourcePixelFormat,dml_uint_t SurfaceWidthLuma,dml_uint_t SurfaceWidthChroma,dml_uint_t SurfaceHeightLuma,dml_uint_t SurfaceHeightChroma,dml_uint_t nomDETInKByte,dml_uint_t RequestHeight256ByteLuma,dml_uint_t RequestHeight256ByteChroma,enum dml_swizzle_mode TilingFormat,dml_uint_t BytePerPixelY,dml_uint_t BytePerPixelC,dml_float_t BytePerPixelDETY,dml_float_t BytePerPixelDETC,enum dml_rotation_angle SourceScan,dml_uint_t * MaxUncompressedBlockLuma,dml_uint_t * MaxUncompressedBlockChroma,dml_uint_t * MaxCompressedBlockLuma,dml_uint_t * MaxCompressedBlockChroma,dml_uint_t * IndependentBlockLuma,dml_uint_t * IndependentBlockChroma)2094 static void CalculateDCCConfiguration(
2095 dml_bool_t DCCEnabled,
2096 dml_bool_t DCCProgrammingAssumesScanDirectionUnknown,
2097 enum dml_source_format_class SourcePixelFormat,
2098 dml_uint_t SurfaceWidthLuma,
2099 dml_uint_t SurfaceWidthChroma,
2100 dml_uint_t SurfaceHeightLuma,
2101 dml_uint_t SurfaceHeightChroma,
2102 dml_uint_t nomDETInKByte,
2103 dml_uint_t RequestHeight256ByteLuma,
2104 dml_uint_t RequestHeight256ByteChroma,
2105 enum dml_swizzle_mode TilingFormat,
2106 dml_uint_t BytePerPixelY,
2107 dml_uint_t BytePerPixelC,
2108 dml_float_t BytePerPixelDETY,
2109 dml_float_t BytePerPixelDETC,
2110 enum dml_rotation_angle SourceScan,
2111 // Output
2112 dml_uint_t *MaxUncompressedBlockLuma,
2113 dml_uint_t *MaxUncompressedBlockChroma,
2114 dml_uint_t *MaxCompressedBlockLuma,
2115 dml_uint_t *MaxCompressedBlockChroma,
2116 dml_uint_t *IndependentBlockLuma,
2117 dml_uint_t *IndependentBlockChroma)
2118 {
2119 dml_uint_t DETBufferSizeForDCC = nomDETInKByte * 1024;
2120
2121 dml_uint_t yuv420;
2122 dml_uint_t horz_div_l;
2123 dml_uint_t horz_div_c;
2124 dml_uint_t vert_div_l;
2125 dml_uint_t vert_div_c;
2126
2127 dml_uint_t swath_buf_size;
2128 dml_float_t detile_buf_vp_horz_limit;
2129 dml_float_t detile_buf_vp_vert_limit;
2130
2131 dml_uint_t MAS_vp_horz_limit;
2132 dml_uint_t MAS_vp_vert_limit;
2133 dml_uint_t max_vp_horz_width;
2134 dml_uint_t max_vp_vert_height;
2135 dml_uint_t eff_surf_width_l;
2136 dml_uint_t eff_surf_width_c;
2137 dml_uint_t eff_surf_height_l;
2138 dml_uint_t eff_surf_height_c;
2139
2140 dml_uint_t full_swath_bytes_horz_wc_l;
2141 dml_uint_t full_swath_bytes_horz_wc_c;
2142 dml_uint_t full_swath_bytes_vert_wc_l;
2143 dml_uint_t full_swath_bytes_vert_wc_c;
2144
2145 dml_uint_t req128_horz_wc_l;
2146 dml_uint_t req128_horz_wc_c;
2147 dml_uint_t req128_vert_wc_l;
2148 dml_uint_t req128_vert_wc_c;
2149
2150 dml_uint_t segment_order_horz_contiguous_luma;
2151 dml_uint_t segment_order_horz_contiguous_chroma;
2152 dml_uint_t segment_order_vert_contiguous_luma;
2153 dml_uint_t segment_order_vert_contiguous_chroma;
2154
2155 typedef enum{
2156 REQ_256Bytes,
2157 REQ_128BytesNonContiguous,
2158 REQ_128BytesContiguous,
2159 REQ_NA
2160 } RequestType;
2161
2162 RequestType RequestLuma;
2163 RequestType RequestChroma;
2164
2165 yuv420 = ((SourcePixelFormat == dml_420_8 || SourcePixelFormat == dml_420_10 || SourcePixelFormat == dml_420_12) ? 1 : 0);
2166 horz_div_l = 1;
2167 horz_div_c = 1;
2168 vert_div_l = 1;
2169 vert_div_c = 1;
2170
2171 if (BytePerPixelY == 1)
2172 vert_div_l = 0;
2173 if (BytePerPixelC == 1)
2174 vert_div_c = 0;
2175
2176 if (BytePerPixelC == 0) {
2177 swath_buf_size = DETBufferSizeForDCC / 2 - 2 * 256;
2178 detile_buf_vp_horz_limit = (dml_float_t) swath_buf_size / ((dml_float_t) RequestHeight256ByteLuma * BytePerPixelY / (1 + horz_div_l));
2179 detile_buf_vp_vert_limit = (dml_float_t) swath_buf_size / (256.0 / RequestHeight256ByteLuma / (1 + vert_div_l));
2180 } else {
2181 swath_buf_size = DETBufferSizeForDCC / 2 - 2 * 2 * 256;
2182 detile_buf_vp_horz_limit = (dml_float_t) swath_buf_size / ((dml_float_t) RequestHeight256ByteLuma * BytePerPixelY / (1 + horz_div_l) + (dml_float_t) RequestHeight256ByteChroma * BytePerPixelC / (1 + horz_div_c) / (1 + yuv420));
2183 detile_buf_vp_vert_limit = (dml_float_t) swath_buf_size / (256.0 / RequestHeight256ByteLuma / (1 + vert_div_l) + 256.0 / RequestHeight256ByteChroma / (1 + vert_div_c) / (1 + yuv420));
2184 }
2185
2186 if (SourcePixelFormat == dml_420_10) {
2187 detile_buf_vp_horz_limit = 1.5 * detile_buf_vp_horz_limit;
2188 detile_buf_vp_vert_limit = 1.5 * detile_buf_vp_vert_limit;
2189 }
2190
2191 detile_buf_vp_horz_limit = dml_floor(detile_buf_vp_horz_limit - 1, 16);
2192 detile_buf_vp_vert_limit = dml_floor(detile_buf_vp_vert_limit - 1, 16);
2193
2194 MAS_vp_horz_limit = SourcePixelFormat == dml_rgbe_alpha ? 3840 : 6144;
2195 MAS_vp_vert_limit = SourcePixelFormat == dml_rgbe_alpha ? 3840 : (BytePerPixelY == 8 ? 3072 : 6144);
2196 max_vp_horz_width = (dml_uint_t)(dml_min((dml_float_t) MAS_vp_horz_limit, detile_buf_vp_horz_limit));
2197 max_vp_vert_height = (dml_uint_t)(dml_min((dml_float_t) MAS_vp_vert_limit, detile_buf_vp_vert_limit));
2198 eff_surf_width_l = (SurfaceWidthLuma > max_vp_horz_width ? max_vp_horz_width : SurfaceWidthLuma);
2199 eff_surf_width_c = eff_surf_width_l / (1 + yuv420);
2200 eff_surf_height_l = (SurfaceHeightLuma > max_vp_vert_height ? max_vp_vert_height : SurfaceHeightLuma);
2201 eff_surf_height_c = eff_surf_height_l / (1 + yuv420);
2202
2203 full_swath_bytes_horz_wc_l = eff_surf_width_l * RequestHeight256ByteLuma * BytePerPixelY;
2204 full_swath_bytes_vert_wc_l = eff_surf_height_l * 256 / RequestHeight256ByteLuma;
2205 if (BytePerPixelC > 0) {
2206 full_swath_bytes_horz_wc_c = eff_surf_width_c * RequestHeight256ByteChroma * BytePerPixelC;
2207 full_swath_bytes_vert_wc_c = eff_surf_height_c * 256 / RequestHeight256ByteChroma;
2208 } else {
2209 full_swath_bytes_horz_wc_c = 0;
2210 full_swath_bytes_vert_wc_c = 0;
2211 }
2212
2213 if (SourcePixelFormat == dml_420_10) {
2214 full_swath_bytes_horz_wc_l = (dml_uint_t)(dml_ceil((dml_float_t) full_swath_bytes_horz_wc_l * 2.0 / 3.0, 256.0));
2215 full_swath_bytes_horz_wc_c = (dml_uint_t)(dml_ceil((dml_float_t) full_swath_bytes_horz_wc_c * 2.0 / 3.0, 256.0));
2216 full_swath_bytes_vert_wc_l = (dml_uint_t)(dml_ceil((dml_float_t) full_swath_bytes_vert_wc_l * 2.0 / 3.0, 256.0));
2217 full_swath_bytes_vert_wc_c = (dml_uint_t)(dml_ceil((dml_float_t) full_swath_bytes_vert_wc_c * 2.0 / 3.0, 256.0));
2218 }
2219
2220 if (2 * full_swath_bytes_horz_wc_l + 2 * full_swath_bytes_horz_wc_c <= DETBufferSizeForDCC) {
2221 req128_horz_wc_l = 0;
2222 req128_horz_wc_c = 0;
2223 } else if (full_swath_bytes_horz_wc_l < 1.5 * full_swath_bytes_horz_wc_c && 2 * full_swath_bytes_horz_wc_l + full_swath_bytes_horz_wc_c <= DETBufferSizeForDCC) {
2224 req128_horz_wc_l = 0;
2225 req128_horz_wc_c = 1;
2226 } else if (full_swath_bytes_horz_wc_l >= 1.5 * full_swath_bytes_horz_wc_c && full_swath_bytes_horz_wc_l + 2 * full_swath_bytes_horz_wc_c <= DETBufferSizeForDCC) {
2227 req128_horz_wc_l = 1;
2228 req128_horz_wc_c = 0;
2229 } else {
2230 req128_horz_wc_l = 1;
2231 req128_horz_wc_c = 1;
2232 }
2233
2234 if (2 * full_swath_bytes_vert_wc_l + 2 * full_swath_bytes_vert_wc_c <= DETBufferSizeForDCC) {
2235 req128_vert_wc_l = 0;
2236 req128_vert_wc_c = 0;
2237 } else if (full_swath_bytes_vert_wc_l < 1.5 * full_swath_bytes_vert_wc_c && 2 * full_swath_bytes_vert_wc_l + full_swath_bytes_vert_wc_c <= DETBufferSizeForDCC) {
2238 req128_vert_wc_l = 0;
2239 req128_vert_wc_c = 1;
2240 } else if (full_swath_bytes_vert_wc_l >= 1.5 * full_swath_bytes_vert_wc_c && full_swath_bytes_vert_wc_l + 2 * full_swath_bytes_vert_wc_c <= DETBufferSizeForDCC) {
2241 req128_vert_wc_l = 1;
2242 req128_vert_wc_c = 0;
2243 } else {
2244 req128_vert_wc_l = 1;
2245 req128_vert_wc_c = 1;
2246 }
2247
2248 if (BytePerPixelY == 2) {
2249 segment_order_horz_contiguous_luma = 0;
2250 segment_order_vert_contiguous_luma = 1;
2251 } else {
2252 segment_order_horz_contiguous_luma = 1;
2253 segment_order_vert_contiguous_luma = 0;
2254 }
2255
2256 if (BytePerPixelC == 2) {
2257 segment_order_horz_contiguous_chroma = 0;
2258 segment_order_vert_contiguous_chroma = 1;
2259 } else {
2260 segment_order_horz_contiguous_chroma = 1;
2261 segment_order_vert_contiguous_chroma = 0;
2262 }
2263 #ifdef __DML_VBA_DEBUG__
2264 dml_print("DML::%s: DCCEnabled = %u\n", __func__, DCCEnabled);
2265 dml_print("DML::%s: nomDETInKByte = %u\n", __func__, nomDETInKByte);
2266 dml_print("DML::%s: DETBufferSizeForDCC = %u\n", __func__, DETBufferSizeForDCC);
2267 dml_print("DML::%s: req128_horz_wc_l = %u\n", __func__, req128_horz_wc_l);
2268 dml_print("DML::%s: req128_horz_wc_c = %u\n", __func__, req128_horz_wc_c);
2269 dml_print("DML::%s: full_swath_bytes_horz_wc_l = %u\n", __func__, full_swath_bytes_horz_wc_l);
2270 dml_print("DML::%s: full_swath_bytes_vert_wc_c = %u\n", __func__, full_swath_bytes_vert_wc_c);
2271 dml_print("DML::%s: segment_order_horz_contiguous_luma = %u\n", __func__, segment_order_horz_contiguous_luma);
2272 dml_print("DML::%s: segment_order_horz_contiguous_chroma = %u\n", __func__, segment_order_horz_contiguous_chroma);
2273 #endif
2274
2275 if (DCCProgrammingAssumesScanDirectionUnknown == true) {
2276 if (req128_horz_wc_l == 0 && req128_vert_wc_l == 0) {
2277 RequestLuma = REQ_256Bytes;
2278 } else if ((req128_horz_wc_l == 1 && segment_order_horz_contiguous_luma == 0) || (req128_vert_wc_l == 1 && segment_order_vert_contiguous_luma == 0)) {
2279 RequestLuma = REQ_128BytesNonContiguous;
2280 } else {
2281 RequestLuma = REQ_128BytesContiguous;
2282 }
2283 if (req128_horz_wc_c == 0 && req128_vert_wc_c == 0) {
2284 RequestChroma = REQ_256Bytes;
2285 } else if ((req128_horz_wc_c == 1 && segment_order_horz_contiguous_chroma == 0) || (req128_vert_wc_c == 1 && segment_order_vert_contiguous_chroma == 0)) {
2286 RequestChroma = REQ_128BytesNonContiguous;
2287 } else {
2288 RequestChroma = REQ_128BytesContiguous;
2289 }
2290 } else if (!dml_is_vertical_rotation(SourceScan)) {
2291 if (req128_horz_wc_l == 0) {
2292 RequestLuma = REQ_256Bytes;
2293 } else if (segment_order_horz_contiguous_luma == 0) {
2294 RequestLuma = REQ_128BytesNonContiguous;
2295 } else {
2296 RequestLuma = REQ_128BytesContiguous;
2297 }
2298 if (req128_horz_wc_c == 0) {
2299 RequestChroma = REQ_256Bytes;
2300 } else if (segment_order_horz_contiguous_chroma == 0) {
2301 RequestChroma = REQ_128BytesNonContiguous;
2302 } else {
2303 RequestChroma = REQ_128BytesContiguous;
2304 }
2305 } else {
2306 if (req128_vert_wc_l == 0) {
2307 RequestLuma = REQ_256Bytes;
2308 } else if (segment_order_vert_contiguous_luma == 0) {
2309 RequestLuma = REQ_128BytesNonContiguous;
2310 } else {
2311 RequestLuma = REQ_128BytesContiguous;
2312 }
2313 if (req128_vert_wc_c == 0) {
2314 RequestChroma = REQ_256Bytes;
2315 } else if (segment_order_vert_contiguous_chroma == 0) {
2316 RequestChroma = REQ_128BytesNonContiguous;
2317 } else {
2318 RequestChroma = REQ_128BytesContiguous;
2319 }
2320 }
2321
2322 if (RequestLuma == REQ_256Bytes) {
2323 *MaxUncompressedBlockLuma = 256;
2324 *MaxCompressedBlockLuma = 256;
2325 *IndependentBlockLuma = 0;
2326 } else if (RequestLuma == REQ_128BytesContiguous) {
2327 *MaxUncompressedBlockLuma = 256;
2328 *MaxCompressedBlockLuma = 128;
2329 *IndependentBlockLuma = 128;
2330 } else {
2331 *MaxUncompressedBlockLuma = 256;
2332 *MaxCompressedBlockLuma = 64;
2333 *IndependentBlockLuma = 64;
2334 }
2335
2336 if (RequestChroma == REQ_256Bytes) {
2337 *MaxUncompressedBlockChroma = 256;
2338 *MaxCompressedBlockChroma = 256;
2339 *IndependentBlockChroma = 0;
2340 } else if (RequestChroma == REQ_128BytesContiguous) {
2341 *MaxUncompressedBlockChroma = 256;
2342 *MaxCompressedBlockChroma = 128;
2343 *IndependentBlockChroma = 128;
2344 } else {
2345 *MaxUncompressedBlockChroma = 256;
2346 *MaxCompressedBlockChroma = 64;
2347 *IndependentBlockChroma = 64;
2348 }
2349
2350 if (DCCEnabled != true || BytePerPixelC == 0) {
2351 *MaxUncompressedBlockChroma = 0;
2352 *MaxCompressedBlockChroma = 0;
2353 *IndependentBlockChroma = 0;
2354 }
2355
2356 if (DCCEnabled != true) {
2357 *MaxUncompressedBlockLuma = 0;
2358 *MaxCompressedBlockLuma = 0;
2359 *IndependentBlockLuma = 0;
2360 }
2361
2362 #ifdef __DML_VBA_DEBUG__
2363 dml_print("DML::%s: MaxUncompressedBlockLuma = %u\n", __func__, *MaxUncompressedBlockLuma);
2364 dml_print("DML::%s: MaxCompressedBlockLuma = %u\n", __func__, *MaxCompressedBlockLuma);
2365 dml_print("DML::%s: IndependentBlockLuma = %u\n", __func__, *IndependentBlockLuma);
2366 dml_print("DML::%s: MaxUncompressedBlockChroma = %u\n", __func__, *MaxUncompressedBlockChroma);
2367 dml_print("DML::%s: MaxCompressedBlockChroma = %u\n", __func__, *MaxCompressedBlockChroma);
2368 dml_print("DML::%s: IndependentBlockChroma = %u\n", __func__, *IndependentBlockChroma);
2369 #endif
2370
2371 } // CalculateDCCConfiguration
2372
CalculatePrefetchSourceLines(dml_float_t VRatio,dml_uint_t VTaps,dml_bool_t Interlace,dml_bool_t ProgressiveToInterlaceUnitInOPP,dml_uint_t SwathHeight,enum dml_rotation_angle SourceScan,dml_bool_t ViewportStationary,dml_uint_t SwathWidth,dml_uint_t ViewportHeight,dml_uint_t ViewportXStart,dml_uint_t ViewportYStart,dml_uint_t * VInitPreFill,dml_uint_t * MaxNumSwath)2373 static dml_uint_t CalculatePrefetchSourceLines(
2374 dml_float_t VRatio,
2375 dml_uint_t VTaps,
2376 dml_bool_t Interlace,
2377 dml_bool_t ProgressiveToInterlaceUnitInOPP,
2378 dml_uint_t SwathHeight,
2379 enum dml_rotation_angle SourceScan,
2380 dml_bool_t ViewportStationary,
2381 dml_uint_t SwathWidth,
2382 dml_uint_t ViewportHeight,
2383 dml_uint_t ViewportXStart,
2384 dml_uint_t ViewportYStart,
2385
2386 // Output
2387 dml_uint_t *VInitPreFill,
2388 dml_uint_t *MaxNumSwath)
2389 {
2390
2391 dml_uint_t vp_start_rot = 0;
2392 dml_uint_t sw0_tmp = 0;
2393 dml_uint_t MaxPartialSwath = 0;
2394 dml_float_t numLines = 0;
2395
2396 #ifdef __DML_VBA_DEBUG__
2397 dml_print("DML::%s: VRatio = %f\n", __func__, VRatio);
2398 dml_print("DML::%s: VTaps = %u\n", __func__, VTaps);
2399 dml_print("DML::%s: ViewportXStart = %u\n", __func__, ViewportXStart);
2400 dml_print("DML::%s: ViewportYStart = %u\n", __func__, ViewportYStart);
2401 dml_print("DML::%s: ViewportStationary = %u\n", __func__, ViewportStationary);
2402 dml_print("DML::%s: SwathHeight = %u\n", __func__, SwathHeight);
2403 #endif
2404 if (ProgressiveToInterlaceUnitInOPP)
2405 *VInitPreFill = (dml_uint_t)(dml_floor((VRatio + (dml_float_t) VTaps + 1) / 2.0, 1));
2406 else
2407 *VInitPreFill = (dml_uint_t)(dml_floor((VRatio + (dml_float_t) VTaps + 1 + Interlace * 0.5 * VRatio) / 2.0, 1));
2408
2409 if (ViewportStationary) {
2410 if (SourceScan == dml_rotation_180 || SourceScan == dml_rotation_180m) {
2411 vp_start_rot = SwathHeight - (((dml_uint_t) (ViewportYStart + ViewportHeight - 1) % SwathHeight) + 1);
2412 } else if (SourceScan == dml_rotation_270 || SourceScan == dml_rotation_90m) {
2413 vp_start_rot = ViewportXStart;
2414 } else if (SourceScan == dml_rotation_90 || SourceScan == dml_rotation_270m) {
2415 vp_start_rot = SwathHeight - (((dml_uint_t)(ViewportYStart + SwathWidth - 1) % SwathHeight) + 1);
2416 } else {
2417 vp_start_rot = ViewportYStart;
2418 }
2419 sw0_tmp = SwathHeight - (vp_start_rot % SwathHeight);
2420 if (sw0_tmp < *VInitPreFill) {
2421 *MaxNumSwath = (dml_uint_t)(dml_ceil((*VInitPreFill - sw0_tmp) / (dml_float_t) SwathHeight, 1) + 1);
2422 } else {
2423 *MaxNumSwath = 1;
2424 }
2425 MaxPartialSwath = (dml_uint_t)(dml_max(1, (dml_uint_t) (vp_start_rot + *VInitPreFill - 1) % SwathHeight));
2426 } else {
2427 *MaxNumSwath = (dml_uint_t)(dml_ceil((*VInitPreFill - 1.0) / (dml_float_t) SwathHeight, 1) + 1);
2428 if (*VInitPreFill > 1) {
2429 MaxPartialSwath = (dml_uint_t)(dml_max(1, (dml_uint_t) (*VInitPreFill - 2) % SwathHeight));
2430 } else {
2431 MaxPartialSwath = (dml_uint_t)(dml_max(1, (dml_uint_t) (*VInitPreFill + SwathHeight - 2) % SwathHeight));
2432 }
2433 }
2434 numLines = *MaxNumSwath * SwathHeight + MaxPartialSwath;
2435
2436 #ifdef __DML_VBA_DEBUG__
2437 dml_print("DML::%s: vp_start_rot = %u\n", __func__, vp_start_rot);
2438 dml_print("DML::%s: VInitPreFill = %u\n", __func__, *VInitPreFill);
2439 dml_print("DML::%s: MaxPartialSwath = %u\n", __func__, MaxPartialSwath);
2440 dml_print("DML::%s: MaxNumSwath = %u\n", __func__, *MaxNumSwath);
2441 dml_print("DML::%s: Prefetch source lines = %3.2f\n", __func__, numLines);
2442 #endif
2443 return (dml_uint_t)(numLines);
2444
2445 } // CalculatePrefetchSourceLines
2446
CalculateVMAndRowBytes(dml_bool_t ViewportStationary,dml_bool_t DCCEnable,dml_uint_t NumberOfDPPs,dml_uint_t BlockHeight256Bytes,dml_uint_t BlockWidth256Bytes,enum dml_source_format_class SourcePixelFormat,dml_uint_t SurfaceTiling,dml_uint_t BytePerPixel,enum dml_rotation_angle SourceScan,dml_uint_t SwathWidth,dml_uint_t ViewportHeight,dml_uint_t ViewportXStart,dml_uint_t ViewportYStart,dml_bool_t GPUVMEnable,dml_uint_t GPUVMMaxPageTableLevels,dml_uint_t GPUVMMinPageSizeKBytes,dml_uint_t PTEBufferSizeInRequests,dml_uint_t Pitch,dml_uint_t DCCMetaPitch,dml_uint_t MacroTileWidth,dml_uint_t MacroTileHeight,dml_uint_t * MetaRowByte,dml_uint_t * PixelPTEBytesPerRow,dml_uint_t * PixelPTEBytesPerRowStorage,dml_uint_t * dpte_row_width_ub,dml_uint_t * dpte_row_height,dml_uint_t * dpte_row_height_linear,dml_uint_t * PixelPTEBytesPerRow_one_row_per_frame,dml_uint_t * dpte_row_width_ub_one_row_per_frame,dml_uint_t * dpte_row_height_one_row_per_frame,dml_uint_t * MetaRequestWidth,dml_uint_t * MetaRequestHeight,dml_uint_t * meta_row_width,dml_uint_t * meta_row_height,dml_uint_t * PixelPTEReqWidth,dml_uint_t * PixelPTEReqHeight,dml_uint_t * PTERequestSize,dml_uint_t * DPDE0BytesFrame,dml_uint_t * MetaPTEBytesFrame)2447 static dml_uint_t CalculateVMAndRowBytes(
2448 dml_bool_t ViewportStationary,
2449 dml_bool_t DCCEnable,
2450 dml_uint_t NumberOfDPPs,
2451 dml_uint_t BlockHeight256Bytes,
2452 dml_uint_t BlockWidth256Bytes,
2453 enum dml_source_format_class SourcePixelFormat,
2454 dml_uint_t SurfaceTiling,
2455 dml_uint_t BytePerPixel,
2456 enum dml_rotation_angle SourceScan,
2457 dml_uint_t SwathWidth,
2458 dml_uint_t ViewportHeight,
2459 dml_uint_t ViewportXStart,
2460 dml_uint_t ViewportYStart,
2461 dml_bool_t GPUVMEnable,
2462 dml_uint_t GPUVMMaxPageTableLevels,
2463 dml_uint_t GPUVMMinPageSizeKBytes,
2464 dml_uint_t PTEBufferSizeInRequests,
2465 dml_uint_t Pitch,
2466 dml_uint_t DCCMetaPitch,
2467 dml_uint_t MacroTileWidth,
2468 dml_uint_t MacroTileHeight,
2469
2470 // Output
2471 dml_uint_t *MetaRowByte,
2472 dml_uint_t *PixelPTEBytesPerRow, // for bandwidth calculation
2473 dml_uint_t *PixelPTEBytesPerRowStorage, // for PTE buffer size check
2474 dml_uint_t *dpte_row_width_ub,
2475 dml_uint_t *dpte_row_height,
2476 dml_uint_t *dpte_row_height_linear,
2477 dml_uint_t *PixelPTEBytesPerRow_one_row_per_frame,
2478 dml_uint_t *dpte_row_width_ub_one_row_per_frame,
2479 dml_uint_t *dpte_row_height_one_row_per_frame,
2480 dml_uint_t *MetaRequestWidth,
2481 dml_uint_t *MetaRequestHeight,
2482 dml_uint_t *meta_row_width,
2483 dml_uint_t *meta_row_height,
2484 dml_uint_t *PixelPTEReqWidth,
2485 dml_uint_t *PixelPTEReqHeight,
2486 dml_uint_t *PTERequestSize,
2487 dml_uint_t *DPDE0BytesFrame,
2488 dml_uint_t *MetaPTEBytesFrame)
2489 {
2490 dml_uint_t MPDEBytesFrame;
2491 dml_uint_t DCCMetaSurfaceBytes;
2492 dml_uint_t ExtraDPDEBytesFrame;
2493 dml_uint_t PDEAndMetaPTEBytesFrame;
2494 dml_uint_t MacroTileSizeBytes;
2495 dml_uint_t vp_height_meta_ub;
2496 dml_uint_t vp_height_dpte_ub;
2497
2498 dml_uint_t PixelPTEReqWidth_linear = 0; // VBA_DELTA. VBA doesn't calculate this
2499
2500 *MetaRequestHeight = 8 * BlockHeight256Bytes;
2501 *MetaRequestWidth = 8 * BlockWidth256Bytes;
2502 if (SurfaceTiling == dml_sw_linear) {
2503 *meta_row_height = 32;
2504 *meta_row_width = (dml_uint_t)(dml_floor(ViewportXStart + SwathWidth + *MetaRequestWidth - 1, *MetaRequestWidth) - dml_floor(ViewportXStart, *MetaRequestWidth));
2505 } else if (!dml_is_vertical_rotation(SourceScan)) {
2506 *meta_row_height = *MetaRequestHeight;
2507 if (ViewportStationary && NumberOfDPPs == 1) {
2508 *meta_row_width = (dml_uint_t)(dml_floor(ViewportXStart + SwathWidth + *MetaRequestWidth - 1, *MetaRequestWidth) - dml_floor(ViewportXStart, *MetaRequestWidth));
2509 } else {
2510 *meta_row_width = (dml_uint_t)(dml_ceil(SwathWidth - 1, *MetaRequestWidth) + *MetaRequestWidth);
2511 }
2512 *MetaRowByte = (dml_uint_t)(*meta_row_width * *MetaRequestHeight * BytePerPixel / 256.0);
2513 } else {
2514 *meta_row_height = *MetaRequestWidth;
2515 if (ViewportStationary && NumberOfDPPs == 1) {
2516 *meta_row_width = (dml_uint_t)(dml_floor(ViewportYStart + ViewportHeight + *MetaRequestHeight - 1, *MetaRequestHeight) - dml_floor(ViewportYStart, *MetaRequestHeight));
2517 } else {
2518 *meta_row_width = (dml_uint_t)(dml_ceil(SwathWidth - 1, *MetaRequestHeight) + *MetaRequestHeight);
2519 }
2520 *MetaRowByte = (dml_uint_t)(*meta_row_width * *MetaRequestWidth * BytePerPixel / 256.0);
2521 }
2522
2523 if (ViewportStationary && (NumberOfDPPs == 1 || !dml_is_vertical_rotation(SourceScan))) {
2524 vp_height_meta_ub = (dml_uint_t)(dml_floor(ViewportYStart + ViewportHeight + 64 * BlockHeight256Bytes - 1, 64 * BlockHeight256Bytes) - dml_floor(ViewportYStart, 64 * BlockHeight256Bytes));
2525 } else if (!dml_is_vertical_rotation(SourceScan)) {
2526 vp_height_meta_ub = (dml_uint_t)(dml_ceil(ViewportHeight - 1, 64 * BlockHeight256Bytes) + 64 * BlockHeight256Bytes);
2527 } else {
2528 vp_height_meta_ub = (dml_uint_t)(dml_ceil(SwathWidth - 1, 64 * BlockHeight256Bytes) + 64 * BlockHeight256Bytes);
2529 }
2530
2531 DCCMetaSurfaceBytes = (dml_uint_t)(DCCMetaPitch * vp_height_meta_ub * BytePerPixel / 256.0);
2532
2533 if (GPUVMEnable == true) {
2534 *MetaPTEBytesFrame = (dml_uint_t)((dml_ceil((dml_float_t) (DCCMetaSurfaceBytes - 4.0 * 1024.0) / (8 * 4.0 * 1024), 1) + 1) * 64);
2535 MPDEBytesFrame = 128 * (GPUVMMaxPageTableLevels - 1);
2536 } else {
2537 *MetaPTEBytesFrame = 0;
2538 MPDEBytesFrame = 0;
2539 }
2540
2541 if (DCCEnable != true) {
2542 *MetaPTEBytesFrame = 0;
2543 MPDEBytesFrame = 0;
2544 *MetaRowByte = 0;
2545 }
2546
2547 MacroTileSizeBytes = MacroTileWidth * BytePerPixel * MacroTileHeight;
2548
2549 if (ViewportStationary && (NumberOfDPPs == 1 || !dml_is_vertical_rotation(SourceScan))) {
2550 vp_height_dpte_ub = (dml_uint_t)(dml_floor(ViewportYStart + ViewportHeight + MacroTileHeight - 1, MacroTileHeight) - dml_floor(ViewportYStart, MacroTileHeight));
2551 } else if (!dml_is_vertical_rotation(SourceScan)) {
2552 vp_height_dpte_ub = (dml_uint_t)(dml_ceil(ViewportHeight - 1, MacroTileHeight) + MacroTileHeight);
2553 } else {
2554 vp_height_dpte_ub = (dml_uint_t)(dml_ceil(SwathWidth - 1, MacroTileHeight) + MacroTileHeight);
2555 }
2556
2557 if (GPUVMEnable == true && GPUVMMaxPageTableLevels > 1) {
2558 *DPDE0BytesFrame = (dml_uint_t)(64 * (dml_ceil((dml_float_t) (Pitch * vp_height_dpte_ub * BytePerPixel - MacroTileSizeBytes) / (dml_float_t) (8 * 2097152), 1) + 1));
2559 ExtraDPDEBytesFrame = 128 * (GPUVMMaxPageTableLevels - 2);
2560 } else {
2561 *DPDE0BytesFrame = 0;
2562 ExtraDPDEBytesFrame = 0;
2563 }
2564
2565 PDEAndMetaPTEBytesFrame = *MetaPTEBytesFrame + MPDEBytesFrame + *DPDE0BytesFrame + ExtraDPDEBytesFrame;
2566
2567 #ifdef __DML_VBA_DEBUG__
2568 dml_print("DML::%s: DCCEnable = %u\n", __func__, DCCEnable);
2569 dml_print("DML::%s: GPUVMEnable = %u\n", __func__, GPUVMEnable);
2570 dml_print("DML::%s: SwModeLinear = %u\n", __func__, SurfaceTiling == dml_sw_linear);
2571 dml_print("DML::%s: BytePerPixel = %u\n", __func__, BytePerPixel);
2572 dml_print("DML::%s: GPUVMMaxPageTableLevels = %u\n", __func__, GPUVMMaxPageTableLevels);
2573 dml_print("DML::%s: BlockHeight256Bytes = %u\n", __func__, BlockHeight256Bytes);
2574 dml_print("DML::%s: BlockWidth256Bytes = %u\n", __func__, BlockWidth256Bytes);
2575 dml_print("DML::%s: MacroTileHeight = %u\n", __func__, MacroTileHeight);
2576 dml_print("DML::%s: MacroTileWidth = %u\n", __func__, MacroTileWidth);
2577 dml_print("DML::%s: MetaPTEBytesFrame = %u\n", __func__, *MetaPTEBytesFrame);
2578 dml_print("DML::%s: MPDEBytesFrame = %u\n", __func__, MPDEBytesFrame);
2579 dml_print("DML::%s: DPDE0BytesFrame = %u\n", __func__, *DPDE0BytesFrame);
2580 dml_print("DML::%s: ExtraDPDEBytesFrame= %u\n", __func__, ExtraDPDEBytesFrame);
2581 dml_print("DML::%s: PDEAndMetaPTEBytesFrame = %u\n", __func__, PDEAndMetaPTEBytesFrame);
2582 dml_print("DML::%s: ViewportHeight = %u\n", __func__, ViewportHeight);
2583 dml_print("DML::%s: SwathWidth = %u\n", __func__, SwathWidth);
2584 dml_print("DML::%s: vp_height_dpte_ub = %u\n", __func__, vp_height_dpte_ub);
2585 #endif
2586
2587 if (SurfaceTiling == dml_sw_linear) {
2588 *PixelPTEReqHeight = 1;
2589 *PixelPTEReqWidth = GPUVMMinPageSizeKBytes * 1024 * 8 / BytePerPixel;
2590 PixelPTEReqWidth_linear = GPUVMMinPageSizeKBytes * 1024 * 8 / BytePerPixel;
2591 *PTERequestSize = 64;
2592 } else if (GPUVMMinPageSizeKBytes == 4) {
2593 *PixelPTEReqHeight = 16 * BlockHeight256Bytes;
2594 *PixelPTEReqWidth = 16 * BlockWidth256Bytes;
2595 *PTERequestSize = 128;
2596 } else {
2597 *PixelPTEReqHeight = MacroTileHeight;
2598 *PixelPTEReqWidth = 8 * 1024 * GPUVMMinPageSizeKBytes / (MacroTileHeight * BytePerPixel);
2599 *PTERequestSize = 64;
2600 }
2601 #ifdef __DML_VBA_DEBUG__
2602 dml_print("DML::%s: GPUVMMinPageSizeKBytes = %u\n", __func__, GPUVMMinPageSizeKBytes);
2603 dml_print("DML::%s: PDEAndMetaPTEBytesFrame = %u (after HostVM factor)\n", __func__, PDEAndMetaPTEBytesFrame);
2604 dml_print("DML::%s: PixelPTEReqHeight = %u\n", __func__, *PixelPTEReqHeight);
2605 dml_print("DML::%s: PixelPTEReqWidth = %u\n", __func__, *PixelPTEReqWidth);
2606 dml_print("DML::%s: PixelPTEReqWidth_linear = %u\n", __func__, PixelPTEReqWidth_linear);
2607 dml_print("DML::%s: PTERequestSize = %u\n", __func__, *PTERequestSize);
2608 dml_print("DML::%s: Pitch = %u\n", __func__, Pitch);
2609 #endif
2610
2611 *dpte_row_height_one_row_per_frame = vp_height_dpte_ub;
2612 *dpte_row_width_ub_one_row_per_frame = (dml_uint_t)((dml_ceil(((dml_float_t)Pitch * (dml_float_t) *dpte_row_height_one_row_per_frame / (dml_float_t) *PixelPTEReqHeight - 1) / (dml_float_t) *PixelPTEReqWidth, 1) + 1) * (dml_float_t) *PixelPTEReqWidth);
2613 *PixelPTEBytesPerRow_one_row_per_frame = (dml_uint_t)((dml_float_t) *dpte_row_width_ub_one_row_per_frame / (dml_float_t) *PixelPTEReqWidth * *PTERequestSize);
2614
2615 if (SurfaceTiling == dml_sw_linear) {
2616 *dpte_row_height = (dml_uint_t)(dml_min(128, 1 << (dml_uint_t) dml_floor(dml_log2(PTEBufferSizeInRequests * *PixelPTEReqWidth / Pitch), 1)));
2617 dml_print("DML::%s: dpte_row_height term 1 = %u\n", __func__, PTEBufferSizeInRequests * *PixelPTEReqWidth / Pitch);
2618 dml_print("DML::%s: dpte_row_height term 2 = %f\n", __func__, dml_log2(PTEBufferSizeInRequests * *PixelPTEReqWidth / Pitch));
2619 dml_print("DML::%s: dpte_row_height term 3 = %f\n", __func__, dml_floor(dml_log2(PTEBufferSizeInRequests * *PixelPTEReqWidth / Pitch), 1));
2620 dml_print("DML::%s: dpte_row_height term 4 = %u\n", __func__, 1 << (dml_uint_t) dml_floor(dml_log2(PTEBufferSizeInRequests * *PixelPTEReqWidth / Pitch), 1));
2621 dml_print("DML::%s: dpte_row_height = %u\n", __func__, *dpte_row_height);
2622
2623 *dpte_row_width_ub = (dml_uint_t)(dml_ceil(((dml_float_t) Pitch * (dml_float_t) *dpte_row_height - 1), (dml_float_t) *PixelPTEReqWidth) + *PixelPTEReqWidth);
2624 *PixelPTEBytesPerRow = (dml_uint_t)((dml_float_t) *dpte_row_width_ub / (dml_float_t) *PixelPTEReqWidth * *PTERequestSize);
2625
2626 // VBA_DELTA, VBA doesn't have programming value for pte row height linear.
2627 *dpte_row_height_linear = 1 << (dml_uint_t) dml_floor(dml_log2(PTEBufferSizeInRequests * PixelPTEReqWidth_linear / Pitch), 1);
2628 if (*dpte_row_height_linear > 128)
2629 *dpte_row_height_linear = 128;
2630
2631 #ifdef __DML_VBA_DEBUG__
2632 dml_print("DML::%s: dpte_row_width_ub = %u (linear)\n", __func__, *dpte_row_width_ub);
2633 #endif
2634
2635 } else if (!dml_is_vertical_rotation(SourceScan)) {
2636 *dpte_row_height = *PixelPTEReqHeight;
2637
2638 if (GPUVMMinPageSizeKBytes > 64) {
2639 *dpte_row_width_ub = (dml_uint_t)((dml_ceil(((dml_float_t) Pitch * (dml_float_t) *dpte_row_height / (dml_float_t) *PixelPTEReqHeight - 1) / (dml_float_t) *PixelPTEReqWidth, 1) + 1) * *PixelPTEReqWidth);
2640 } else if (ViewportStationary && (NumberOfDPPs == 1)) {
2641 *dpte_row_width_ub = (dml_uint_t)(dml_floor(ViewportXStart + SwathWidth + *PixelPTEReqWidth - 1, *PixelPTEReqWidth) - dml_floor(ViewportXStart, *PixelPTEReqWidth));
2642 } else {
2643 *dpte_row_width_ub = (dml_uint_t)((dml_ceil((dml_float_t) (SwathWidth - 1) / (dml_float_t)*PixelPTEReqWidth, 1) + 1.0) * *PixelPTEReqWidth);
2644 }
2645 #ifdef __DML_VBA_DEBUG__
2646 dml_print("DML::%s: dpte_row_width_ub = %u (tiled horz)\n", __func__, *dpte_row_width_ub);
2647 #endif
2648
2649 ASSERT(*PixelPTEReqWidth);
2650 if (*PixelPTEReqWidth != 0)
2651 *PixelPTEBytesPerRow = *dpte_row_width_ub / *PixelPTEReqWidth * *PTERequestSize;
2652 } else {
2653 *dpte_row_height = (dml_uint_t)(dml_min(*PixelPTEReqWidth, MacroTileWidth));
2654
2655 if (ViewportStationary && (NumberOfDPPs == 1)) {
2656 *dpte_row_width_ub = (dml_uint_t)(dml_floor(ViewportYStart + ViewportHeight + *PixelPTEReqHeight - 1, *PixelPTEReqHeight) - dml_floor(ViewportYStart, *PixelPTEReqHeight));
2657 } else {
2658 *dpte_row_width_ub = (dml_uint_t)((dml_ceil((dml_float_t) (SwathWidth - 1) / (dml_float_t) *PixelPTEReqHeight, 1) + 1) * *PixelPTEReqHeight);
2659 }
2660
2661 *PixelPTEBytesPerRow = (dml_uint_t)((dml_float_t) *dpte_row_width_ub / (dml_float_t) *PixelPTEReqHeight * *PTERequestSize);
2662 #ifdef __DML_VBA_DEBUG__
2663 dml_print("DML::%s: dpte_row_width_ub = %u (tiled vert)\n", __func__, *dpte_row_width_ub);
2664 #endif
2665 }
2666
2667 if (GPUVMEnable != true)
2668 *PixelPTEBytesPerRow = 0;
2669
2670 *PixelPTEBytesPerRowStorage = *PixelPTEBytesPerRow;
2671
2672 #ifdef __DML_VBA_DEBUG__
2673 dml_print("DML::%s: GPUVMMinPageSizeKBytes = %u\n", __func__, GPUVMMinPageSizeKBytes);
2674 dml_print("DML::%s: GPUVMEnable = %u\n", __func__, GPUVMEnable);
2675 dml_print("DML::%s: dpte_row_height = %u\n", __func__, *dpte_row_height);
2676 dml_print("DML::%s: dpte_row_height_linear = %u\n", __func__, *dpte_row_height_linear);
2677 dml_print("DML::%s: dpte_row_width_ub = %u\n", __func__, *dpte_row_width_ub);
2678 dml_print("DML::%s: PixelPTEBytesPerRow = %u\n", __func__, *PixelPTEBytesPerRow);
2679 dml_print("DML::%s: PixelPTEBytesPerRowStorage = %u\n", __func__, *PixelPTEBytesPerRowStorage);
2680 dml_print("DML::%s: PTEBufferSizeInRequests = %u\n", __func__, PTEBufferSizeInRequests);
2681 dml_print("DML::%s: dpte_row_height_one_row_per_frame = %u\n", __func__, *dpte_row_height_one_row_per_frame);
2682 dml_print("DML::%s: dpte_row_width_ub_one_row_per_frame = %u\n", __func__, *dpte_row_width_ub_one_row_per_frame);
2683 dml_print("DML::%s: PixelPTEBytesPerRow_one_row_per_frame = %u\n", __func__, *PixelPTEBytesPerRow_one_row_per_frame);
2684 #endif
2685
2686 dml_print("DML: vm_bytes = meta_pte_bytes_per_frame (per_pipe) = MetaPTEBytesFrame = : %i\n", *MetaPTEBytesFrame);
2687
2688 return PDEAndMetaPTEBytesFrame;
2689 } // CalculateVMAndRowBytes
2690
PixelClockAdjustmentForProgressiveToInterlaceUnit(struct dml_display_cfg_st * display_cfg,dml_bool_t ptoi_supported)2691 static void PixelClockAdjustmentForProgressiveToInterlaceUnit(struct dml_display_cfg_st *display_cfg, dml_bool_t ptoi_supported)
2692 {
2693 dml_uint_t num_active_planes = dml_get_num_active_planes(display_cfg);
2694
2695 //Progressive To Interlace Unit Effect
2696 for (dml_uint_t k = 0; k < num_active_planes; ++k) {
2697 display_cfg->output.PixelClockBackEnd[k] = display_cfg->timing.PixelClock[k];
2698 if (display_cfg->timing.Interlace[k] == 1 && ptoi_supported == true) {
2699 display_cfg->timing.PixelClock[k] = 2 * display_cfg->timing.PixelClock[k];
2700 }
2701 }
2702 }
2703
TruncToValidBPP(dml_float_t LinkBitRate,dml_uint_t Lanes,dml_uint_t HTotal,dml_uint_t HActive,dml_float_t PixelClock,dml_float_t DesiredBPP,dml_bool_t DSCEnable,enum dml_output_encoder_class Output,enum dml_output_format_class Format,dml_uint_t DSCInputBitPerComponent,dml_uint_t DSCSlices,dml_uint_t AudioRate,dml_uint_t AudioLayout,enum dml_odm_mode ODMModeNoDSC,enum dml_odm_mode ODMModeDSC,dml_uint_t * RequiredSlots)2704 static dml_float_t TruncToValidBPP(
2705 dml_float_t LinkBitRate,
2706 dml_uint_t Lanes,
2707 dml_uint_t HTotal,
2708 dml_uint_t HActive,
2709 dml_float_t PixelClock,
2710 dml_float_t DesiredBPP,
2711 dml_bool_t DSCEnable,
2712 enum dml_output_encoder_class Output,
2713 enum dml_output_format_class Format,
2714 dml_uint_t DSCInputBitPerComponent,
2715 dml_uint_t DSCSlices,
2716 dml_uint_t AudioRate,
2717 dml_uint_t AudioLayout,
2718 enum dml_odm_mode ODMModeNoDSC,
2719 enum dml_odm_mode ODMModeDSC,
2720
2721 // Output
2722 dml_uint_t *RequiredSlots)
2723 {
2724 dml_float_t MaxLinkBPP;
2725 dml_uint_t MinDSCBPP;
2726 dml_float_t MaxDSCBPP;
2727 dml_uint_t NonDSCBPP0;
2728 dml_uint_t NonDSCBPP1;
2729 dml_uint_t NonDSCBPP2;
2730
2731 if (Format == dml_420) {
2732 NonDSCBPP0 = 12;
2733 NonDSCBPP1 = 15;
2734 NonDSCBPP2 = 18;
2735 MinDSCBPP = 6;
2736 MaxDSCBPP = 1.5 * DSCInputBitPerComponent - 1.0 / 16;
2737 } else if (Format == dml_444) {
2738 NonDSCBPP0 = 24;
2739 NonDSCBPP1 = 30;
2740 NonDSCBPP2 = 36;
2741 MinDSCBPP = 8;
2742 MaxDSCBPP = 3 * DSCInputBitPerComponent - 1.0 / 16;
2743 } else {
2744 if (Output == dml_hdmi) {
2745 NonDSCBPP0 = 24;
2746 NonDSCBPP1 = 24;
2747 NonDSCBPP2 = 24;
2748 } else {
2749 NonDSCBPP0 = 16;
2750 NonDSCBPP1 = 20;
2751 NonDSCBPP2 = 24;
2752 }
2753 if (Format == dml_n422) {
2754 MinDSCBPP = 7;
2755 MaxDSCBPP = 2 * DSCInputBitPerComponent - 1.0 / 16.0;
2756 } else {
2757 MinDSCBPP = 8;
2758 MaxDSCBPP = 3 * DSCInputBitPerComponent - 1.0 / 16.0;
2759 }
2760 }
2761
2762 if (Output == dml_dp2p0) {
2763 MaxLinkBPP = LinkBitRate * Lanes / PixelClock * 128.0 / 132.0 * 383.0 / 384.0 * 65536.0 / 65540.0;
2764 } else if (DSCEnable && Output == dml_dp) {
2765 MaxLinkBPP = LinkBitRate / 10.0 * 8.0 * Lanes / PixelClock * (1 - 2.4 / 100);
2766 } else {
2767 MaxLinkBPP = LinkBitRate / 10.0 * 8.0 * Lanes / PixelClock;
2768 }
2769
2770 if (DSCEnable) {
2771 if (ODMModeDSC == dml_odm_mode_combine_4to1) {
2772 MaxLinkBPP = dml_min(MaxLinkBPP, 16);
2773 } else if (ODMModeDSC == dml_odm_mode_combine_2to1) {
2774 MaxLinkBPP = dml_min(MaxLinkBPP, 32);
2775 } else if (ODMModeDSC == dml_odm_mode_split_1to2) {
2776 MaxLinkBPP = 2 * MaxLinkBPP;
2777 }
2778 } else {
2779 if (ODMModeNoDSC == dml_odm_mode_combine_4to1) {
2780 MaxLinkBPP = dml_min(MaxLinkBPP, 16);
2781 } else if (ODMModeNoDSC == dml_odm_mode_combine_2to1) {
2782 MaxLinkBPP = dml_min(MaxLinkBPP, 32);
2783 } else if (ODMModeNoDSC == dml_odm_mode_split_1to2) {
2784 MaxLinkBPP = 2 * MaxLinkBPP;
2785 }
2786 }
2787
2788 *RequiredSlots = (dml_uint_t)(dml_ceil(DesiredBPP / MaxLinkBPP * 64, 1));
2789
2790 if (DesiredBPP == 0) {
2791 if (DSCEnable) {
2792 if (MaxLinkBPP < MinDSCBPP) {
2793 return __DML_DPP_INVALID__;
2794 } else if (MaxLinkBPP >= MaxDSCBPP) {
2795 return MaxDSCBPP;
2796 } else {
2797 return dml_floor(16.0 * MaxLinkBPP, 1.0) / 16.0;
2798 }
2799 } else {
2800 if (MaxLinkBPP >= NonDSCBPP2) {
2801 return NonDSCBPP2;
2802 } else if (MaxLinkBPP >= NonDSCBPP1) {
2803 return NonDSCBPP1;
2804 } else if (MaxLinkBPP >= NonDSCBPP0) {
2805 return NonDSCBPP0;
2806 } else {
2807 return __DML_DPP_INVALID__;
2808 }
2809 }
2810 } else {
2811 if (!((DSCEnable == false && (DesiredBPP == NonDSCBPP2 || DesiredBPP == NonDSCBPP1 || DesiredBPP == NonDSCBPP0)) ||
2812 (DSCEnable && DesiredBPP >= MinDSCBPP && DesiredBPP <= MaxDSCBPP))) {
2813 return __DML_DPP_INVALID__;
2814 } else {
2815 return DesiredBPP;
2816 }
2817 }
2818 } // TruncToValidBPP
2819
CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport(struct display_mode_lib_scratch_st * scratch,struct CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_params_st * p)2820 static void CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport(
2821 struct display_mode_lib_scratch_st *scratch,
2822 struct CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_params_st *p)
2823 {
2824 struct CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_locals_st *s = &scratch->CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_locals;
2825
2826 s->TotalActiveWriteback = 0;
2827 p->Watermark->UrgentWatermark = p->mmSOCParameters.UrgentLatency + p->mmSOCParameters.ExtraLatency;
2828 p->Watermark->USRRetrainingWatermark = p->mmSOCParameters.UrgentLatency + p->mmSOCParameters.ExtraLatency + p->mmSOCParameters.USRRetrainingLatency + p->mmSOCParameters.SMNLatency;
2829 p->Watermark->DRAMClockChangeWatermark = p->mmSOCParameters.DRAMClockChangeLatency + p->Watermark->UrgentWatermark;
2830 p->Watermark->FCLKChangeWatermark = p->mmSOCParameters.FCLKChangeLatency + p->Watermark->UrgentWatermark;
2831 p->Watermark->StutterExitWatermark = p->mmSOCParameters.SRExitTime + p->mmSOCParameters.ExtraLatency + 10 / p->DCFClkDeepSleep;
2832 p->Watermark->StutterEnterPlusExitWatermark = p->mmSOCParameters.SREnterPlusExitTime + p->mmSOCParameters.ExtraLatency + 10 / p->DCFClkDeepSleep;
2833 p->Watermark->Z8StutterExitWatermark = p->mmSOCParameters.SRExitZ8Time + p->mmSOCParameters.ExtraLatency + 10 / p->DCFClkDeepSleep;
2834 p->Watermark->Z8StutterEnterPlusExitWatermark = p->mmSOCParameters.SREnterPlusExitZ8Time + p->mmSOCParameters.ExtraLatency + 10 / p->DCFClkDeepSleep;
2835
2836 #ifdef __DML_VBA_DEBUG__
2837 dml_print("DML::%s: UrgentLatency = %f\n", __func__, p->mmSOCParameters.UrgentLatency);
2838 dml_print("DML::%s: ExtraLatency = %f\n", __func__, p->mmSOCParameters.ExtraLatency);
2839 dml_print("DML::%s: DRAMClockChangeLatency = %f\n", __func__, p->mmSOCParameters.DRAMClockChangeLatency);
2840 dml_print("DML::%s: UrgentWatermark = %f\n", __func__, p->Watermark->UrgentWatermark);
2841 dml_print("DML::%s: USRRetrainingWatermark = %f\n", __func__, p->Watermark->USRRetrainingWatermark);
2842 dml_print("DML::%s: DRAMClockChangeWatermark = %f\n", __func__, p->Watermark->DRAMClockChangeWatermark);
2843 dml_print("DML::%s: FCLKChangeWatermark = %f\n", __func__, p->Watermark->FCLKChangeWatermark);
2844 dml_print("DML::%s: StutterExitWatermark = %f\n", __func__, p->Watermark->StutterExitWatermark);
2845 dml_print("DML::%s: StutterEnterPlusExitWatermark = %f\n", __func__, p->Watermark->StutterEnterPlusExitWatermark);
2846 dml_print("DML::%s: Z8StutterExitWatermark = %f\n", __func__, p->Watermark->Z8StutterExitWatermark);
2847 dml_print("DML::%s: Z8StutterEnterPlusExitWatermark = %f\n", __func__, p->Watermark->Z8StutterEnterPlusExitWatermark);
2848 #endif
2849
2850 s->TotalActiveWriteback = 0;
2851 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
2852 if (p->WritebackEnable[k] == true) {
2853 s->TotalActiveWriteback = s->TotalActiveWriteback + 1;
2854 }
2855 }
2856
2857 if (s->TotalActiveWriteback <= 1) {
2858 p->Watermark->WritebackUrgentWatermark = p->mmSOCParameters.WritebackLatency;
2859 } else {
2860 p->Watermark->WritebackUrgentWatermark = p->mmSOCParameters.WritebackLatency + p->WritebackChunkSize * 1024.0 / 32.0 / p->SOCCLK;
2861 }
2862 if (p->USRRetrainingRequiredFinal)
2863 p->Watermark->WritebackUrgentWatermark = p->Watermark->WritebackUrgentWatermark + p->mmSOCParameters.USRRetrainingLatency;
2864
2865 if (s->TotalActiveWriteback <= 1) {
2866 p->Watermark->WritebackDRAMClockChangeWatermark = p->mmSOCParameters.DRAMClockChangeLatency + p->mmSOCParameters.WritebackLatency;
2867 p->Watermark->WritebackFCLKChangeWatermark = p->mmSOCParameters.FCLKChangeLatency + p->mmSOCParameters.WritebackLatency;
2868 } else {
2869 p->Watermark->WritebackDRAMClockChangeWatermark = p->mmSOCParameters.DRAMClockChangeLatency + p->mmSOCParameters.WritebackLatency + p->WritebackChunkSize * 1024.0 / 32.0 / p->SOCCLK;
2870 p->Watermark->WritebackFCLKChangeWatermark = p->mmSOCParameters.FCLKChangeLatency + p->mmSOCParameters.WritebackLatency + p->WritebackChunkSize * 1024 / 32 / p->SOCCLK;
2871 }
2872
2873 if (p->USRRetrainingRequiredFinal)
2874 p->Watermark->WritebackDRAMClockChangeWatermark = p->Watermark->WritebackDRAMClockChangeWatermark + p->mmSOCParameters.USRRetrainingLatency;
2875
2876 if (p->USRRetrainingRequiredFinal)
2877 p->Watermark->WritebackFCLKChangeWatermark = p->Watermark->WritebackFCLKChangeWatermark + p->mmSOCParameters.USRRetrainingLatency;
2878
2879 #ifdef __DML_VBA_DEBUG__
2880 dml_print("DML::%s: WritebackDRAMClockChangeWatermark = %f\n", __func__, p->Watermark->WritebackDRAMClockChangeWatermark);
2881 dml_print("DML::%s: WritebackFCLKChangeWatermark = %f\n", __func__, p->Watermark->WritebackFCLKChangeWatermark);
2882 dml_print("DML::%s: WritebackUrgentWatermark = %f\n", __func__, p->Watermark->WritebackUrgentWatermark);
2883 dml_print("DML::%s: USRRetrainingRequiredFinal = %u\n", __func__, p->USRRetrainingRequiredFinal);
2884 dml_print("DML::%s: USRRetrainingLatency = %f\n", __func__, p->mmSOCParameters.USRRetrainingLatency);
2885 #endif
2886
2887 s->TotalPixelBW = 0.0;
2888 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
2889 s->TotalPixelBW = s->TotalPixelBW + p->DPPPerSurface[k]
2890 * (p->SwathWidthY[k] * p->BytePerPixelDETY[k] * p->VRatio[k] + p->SwathWidthC[k] * p->BytePerPixelDETC[k] * p->VRatioChroma[k]) / (p->HTotal[k] / p->PixelClock[k]);
2891 }
2892
2893 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
2894
2895 s->LBLatencyHidingSourceLinesY[k] = (dml_uint_t)(dml_min((dml_float_t)p->MaxLineBufferLines, dml_floor((dml_float_t)p->LineBufferSize / (dml_float_t)p->LBBitPerPixel[k] / ((dml_float_t)p->SwathWidthY[k] / dml_max(p->HRatio[k], 1.0)), 1)) - (p->VTaps[k] - 1));
2896 s->LBLatencyHidingSourceLinesC[k] = (dml_uint_t)(dml_min((dml_float_t)p->MaxLineBufferLines, dml_floor((dml_float_t)p->LineBufferSize / (dml_float_t)p->LBBitPerPixel[k] / ((dml_float_t)p->SwathWidthC[k] / dml_max(p->HRatioChroma[k], 1.0)), 1)) - (p->VTapsChroma[k] - 1));
2897
2898
2899 #ifdef __DML_VBA_DEBUG__
2900 dml_print("DML::%s: k=%u, MaxLineBufferLines = %u\n", __func__, k, p->MaxLineBufferLines);
2901 dml_print("DML::%s: k=%u, LineBufferSize = %u\n", __func__, k, p->LineBufferSize);
2902 dml_print("DML::%s: k=%u, LBBitPerPixel = %u\n", __func__, k, p->LBBitPerPixel[k]);
2903 dml_print("DML::%s: k=%u, HRatio = %f\n", __func__, k, p->HRatio[k]);
2904 dml_print("DML::%s: k=%u, VTaps = %u\n", __func__, k, p->VTaps[k]);
2905 #endif
2906
2907 s->EffectiveLBLatencyHidingY = s->LBLatencyHidingSourceLinesY[k] / p->VRatio[k] * (p->HTotal[k] / p->PixelClock[k]);
2908 s->EffectiveLBLatencyHidingC = s->LBLatencyHidingSourceLinesC[k] / p->VRatioChroma[k] * (p->HTotal[k] / p->PixelClock[k]);
2909
2910 s->EffectiveDETBufferSizeY = p->DETBufferSizeY[k];
2911 if (p->UnboundedRequestEnabled) {
2912 s->EffectiveDETBufferSizeY = s->EffectiveDETBufferSizeY + p->CompressedBufferSizeInkByte * 1024 * (p->SwathWidthY[k] * p->BytePerPixelDETY[k] * p->VRatio[k]) / (p->HTotal[k] / p->PixelClock[k]) / s->TotalPixelBW;
2913 }
2914
2915 s->LinesInDETY[k] = (dml_float_t)s->EffectiveDETBufferSizeY / p->BytePerPixelDETY[k] / p->SwathWidthY[k];
2916 s->LinesInDETYRoundedDownToSwath[k] = (dml_uint_t)(dml_floor(s->LinesInDETY[k], p->SwathHeightY[k]));
2917 s->FullDETBufferingTimeY = s->LinesInDETYRoundedDownToSwath[k] * (p->HTotal[k] / p->PixelClock[k]) / p->VRatio[k];
2918
2919 s->ActiveClockChangeLatencyHidingY = s->EffectiveLBLatencyHidingY + s->FullDETBufferingTimeY - ((dml_float_t)p->DSTXAfterScaler[k] / (dml_float_t)p->HTotal[k] + (dml_float_t)p->DSTYAfterScaler[k]) * (dml_float_t)p->HTotal[k] / p->PixelClock[k];
2920
2921 if (p->NumberOfActiveSurfaces > 1) {
2922 s->ActiveClockChangeLatencyHidingY = s->ActiveClockChangeLatencyHidingY - (1.0 - 1.0 / (dml_float_t)p->NumberOfActiveSurfaces) * (dml_float_t)p->SwathHeightY[k] * (dml_float_t)p->HTotal[k] / p->PixelClock[k] / p->VRatio[k];
2923 }
2924
2925 if (p->BytePerPixelDETC[k] > 0) {
2926 s->LinesInDETC[k] = p->DETBufferSizeC[k] / p->BytePerPixelDETC[k] / p->SwathWidthC[k];
2927 s->LinesInDETCRoundedDownToSwath[k] = (dml_uint_t)(dml_floor(s->LinesInDETC[k], p->SwathHeightC[k]));
2928 s->FullDETBufferingTimeC = s->LinesInDETCRoundedDownToSwath[k] * (p->HTotal[k] / p->PixelClock[k]) / p->VRatioChroma[k];
2929 s->ActiveClockChangeLatencyHidingC = s->EffectiveLBLatencyHidingC + s->FullDETBufferingTimeC - ((dml_float_t)p->DSTXAfterScaler[k] / (dml_float_t)p->HTotal[k] + (dml_float_t)p->DSTYAfterScaler[k]) * (dml_float_t)p->HTotal[k] / p->PixelClock[k];
2930 if (p->NumberOfActiveSurfaces > 1) {
2931 s->ActiveClockChangeLatencyHidingC = s->ActiveClockChangeLatencyHidingC - (1.0 - 1.0 / (dml_float_t)p->NumberOfActiveSurfaces) * (dml_float_t)p->SwathHeightC[k] * (dml_float_t)p->HTotal[k] / p->PixelClock[k] / p->VRatioChroma[k];
2932 }
2933 s->ActiveClockChangeLatencyHiding = dml_min(s->ActiveClockChangeLatencyHidingY, s->ActiveClockChangeLatencyHidingC);
2934 } else {
2935 s->ActiveClockChangeLatencyHiding = s->ActiveClockChangeLatencyHidingY;
2936 }
2937
2938 s->ActiveDRAMClockChangeLatencyMargin[k] = s->ActiveClockChangeLatencyHiding - p->Watermark->UrgentWatermark - p->Watermark->DRAMClockChangeWatermark;
2939 s->ActiveFCLKChangeLatencyMargin[k] = s->ActiveClockChangeLatencyHiding - p->Watermark->UrgentWatermark - p->Watermark->FCLKChangeWatermark;
2940 s->USRRetrainingLatencyMargin[k] = s->ActiveClockChangeLatencyHiding - p->Watermark->USRRetrainingWatermark;
2941
2942 if (p->WritebackEnable[k]) {
2943 s->WritebackLatencyHiding = (dml_float_t)p->WritebackInterfaceBufferSize * 1024.0 / ((dml_float_t)p->WritebackDestinationWidth[k] * (dml_float_t)p->WritebackDestinationHeight[k] / ((dml_float_t)p->WritebackSourceHeight[k] * (dml_float_t)p->HTotal[k] / p->PixelClock[k]) * 4.0);
2944 if (p->WritebackPixelFormat[k] == dml_444_64) {
2945 s->WritebackLatencyHiding = s->WritebackLatencyHiding / 2;
2946 }
2947 s->WritebackDRAMClockChangeLatencyMargin = s->WritebackLatencyHiding - p->Watermark->WritebackDRAMClockChangeWatermark;
2948
2949 s->WritebackFCLKChangeLatencyMargin = s->WritebackLatencyHiding - p->Watermark->WritebackFCLKChangeWatermark;
2950
2951 s->ActiveDRAMClockChangeLatencyMargin[k] = dml_min(s->ActiveDRAMClockChangeLatencyMargin[k], s->WritebackFCLKChangeLatencyMargin);
2952 s->ActiveFCLKChangeLatencyMargin[k] = dml_min(s->ActiveFCLKChangeLatencyMargin[k], s->WritebackDRAMClockChangeLatencyMargin);
2953 }
2954 p->MaxActiveDRAMClockChangeLatencySupported[k] = (p->UseMALLForPStateChange[k] == dml_use_mall_pstate_change_phantom_pipe) ? 0 : (s->ActiveDRAMClockChangeLatencyMargin[k] + p->mmSOCParameters.DRAMClockChangeLatency);
2955 p->ActiveDRAMClockChangeLatencyMargin[k] = s->ActiveDRAMClockChangeLatencyMargin[k];
2956 }
2957
2958 *p->USRRetrainingSupport = true;
2959 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
2960 if ((p->UseMALLForPStateChange[k] != dml_use_mall_pstate_change_phantom_pipe) && (s->USRRetrainingLatencyMargin[k] < 0)) {
2961 *p->USRRetrainingSupport = false;
2962 }
2963 }
2964
2965 s->FoundCriticalSurface = false;
2966 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
2967 if ((p->UseMALLForPStateChange[k] != dml_use_mall_pstate_change_phantom_pipe) && ((!s->FoundCriticalSurface)
2968 || ((s->ActiveFCLKChangeLatencyMargin[k] + p->mmSOCParameters.FCLKChangeLatency) < *p->MaxActiveFCLKChangeLatencySupported))) {
2969 s->FoundCriticalSurface = true;
2970 *p->MaxActiveFCLKChangeLatencySupported = s->ActiveFCLKChangeLatencyMargin[k] + p->mmSOCParameters.FCLKChangeLatency;
2971 }
2972 }
2973
2974 for (dml_uint_t i = 0; i < p->NumberOfActiveSurfaces; ++i) {
2975 for (dml_uint_t j = 0; j < p->NumberOfActiveSurfaces; ++j) {
2976 if (i == j ||
2977 (p->BlendingAndTiming[i] == i && p->BlendingAndTiming[j] == i) ||
2978 (p->BlendingAndTiming[j] == j && p->BlendingAndTiming[i] == j) ||
2979 (p->BlendingAndTiming[i] == p->BlendingAndTiming[j] && p->BlendingAndTiming[i] != i) ||
2980 (p->SynchronizeTimingsFinal && p->PixelClock[i] == p->PixelClock[j] && p->HTotal[i] == p->HTotal[j] && p->VTotal[i] == p->VTotal[j] && p->VActive[i] == p->VActive[j]) ||
2981 (p->SynchronizeDRRDisplaysForUCLKPStateChangeFinal && (p->DRRDisplay[i] || p->DRRDisplay[j]))) {
2982 s->SynchronizedSurfaces[i][j] = true;
2983 } else {
2984 s->SynchronizedSurfaces[i][j] = false;
2985 }
2986 }
2987 }
2988
2989 s->FCLKChangeSupportNumber = 0;
2990 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
2991 if ((p->UseMALLForPStateChange[k] != dml_use_mall_pstate_change_phantom_pipe) && (s->ActiveFCLKChangeLatencyMargin[k] < 0)) {
2992 if (!(p->PrefetchMode[k] <= 1)) {
2993 s->FCLKChangeSupportNumber = 3;
2994 } else if (s->FCLKChangeSupportNumber == 0) {
2995 s->FCLKChangeSupportNumber = ((p->SynchronizeDRRDisplaysForUCLKPStateChangeFinal && p->DRRDisplay[k]) ? 2 : 1);
2996 s->LastSurfaceWithoutMargin = k;
2997 } else if (((s->FCLKChangeSupportNumber == 1) && (p->DRRDisplay[k] || (!s->SynchronizedSurfaces[s->LastSurfaceWithoutMargin][k]))) || (s->FCLKChangeSupportNumber == 2))
2998 s->FCLKChangeSupportNumber = 3;
2999 }
3000 }
3001
3002 if (s->FCLKChangeSupportNumber == 0) {
3003 *p->FCLKChangeSupport = dml_fclock_change_vactive;
3004 } else if ((s->FCLKChangeSupportNumber == 1) || (s->FCLKChangeSupportNumber == 2)) {
3005 *p->FCLKChangeSupport = dml_fclock_change_vblank;
3006 } else {
3007 *p->FCLKChangeSupport = dml_fclock_change_unsupported;
3008 }
3009
3010 s->DRAMClockChangeMethod = 0;
3011 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
3012 if (p->UseMALLForPStateChange[k] == dml_use_mall_pstate_change_full_frame)
3013 s->DRAMClockChangeMethod = 1;
3014 else if (p->UseMALLForPStateChange[k] == dml_use_mall_pstate_change_sub_viewport)
3015 s->DRAMClockChangeMethod = 2;
3016 }
3017
3018 s->DRAMClockChangeSupportNumber = 0;
3019 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
3020 if (((s->DRAMClockChangeMethod == 0) && (s->ActiveDRAMClockChangeLatencyMargin[k] < 0)) ||
3021 ((s->DRAMClockChangeMethod == 1) && (p->UseMALLForPStateChange[k] != dml_use_mall_pstate_change_full_frame)) ||
3022 ((s->DRAMClockChangeMethod == 2) && (p->UseMALLForPStateChange[k] != dml_use_mall_pstate_change_sub_viewport) && (p->UseMALLForPStateChange[k] != dml_use_mall_pstate_change_phantom_pipe))) {
3023 if (p->PrefetchMode[k] != 0) { // Don't need to support DRAM clock change, PrefetchMode 0 means needs DRAM clock change support
3024 s->DRAMClockChangeSupportNumber = 3;
3025 } else if (s->DRAMClockChangeSupportNumber == 0) {
3026 s->DRAMClockChangeSupportNumber = (p->SynchronizeDRRDisplaysForUCLKPStateChangeFinal && p->DRRDisplay[k]) ? 2 : 1;
3027 s->LastSurfaceWithoutMargin = k;
3028 } else if (((s->DRAMClockChangeSupportNumber == 1) && (p->DRRDisplay[k] || !s->SynchronizedSurfaces[s->LastSurfaceWithoutMargin][k])) || (s->DRAMClockChangeSupportNumber == 2)) {
3029 s->DRAMClockChangeSupportNumber = 3;
3030 }
3031 }
3032 }
3033
3034 if (s->DRAMClockChangeMethod == 0) { // No MALL usage
3035 if (s->DRAMClockChangeSupportNumber == 0) {
3036 *p->DRAMClockChangeSupport = dml_dram_clock_change_vactive;
3037 } else if (s->DRAMClockChangeSupportNumber == 1) {
3038 *p->DRAMClockChangeSupport = dml_dram_clock_change_vblank;
3039 } else if (s->DRAMClockChangeSupportNumber == 2) {
3040 *p->DRAMClockChangeSupport = dml_dram_clock_change_vblank_drr;
3041 } else {
3042 *p->DRAMClockChangeSupport = dml_dram_clock_change_unsupported;
3043 }
3044 } else if (s->DRAMClockChangeMethod == 1) { // Any pipe using MALL full frame
3045 if (s->DRAMClockChangeSupportNumber == 0) {
3046 *p->DRAMClockChangeSupport = dml_dram_clock_change_vactive_w_mall_full_frame;
3047 } else if (s->DRAMClockChangeSupportNumber == 1) {
3048 *p->DRAMClockChangeSupport = dml_dram_clock_change_vblank_w_mall_full_frame;
3049 } else if (s->DRAMClockChangeSupportNumber == 2) {
3050 *p->DRAMClockChangeSupport = dml_dram_clock_change_vblank_drr_w_mall_full_frame;
3051 } else {
3052 *p->DRAMClockChangeSupport = dml_dram_clock_change_unsupported;
3053 }
3054 } else { // Any pipe using MALL subviewport
3055 if (s->DRAMClockChangeSupportNumber == 0) {
3056 *p->DRAMClockChangeSupport = dml_dram_clock_change_vactive_w_mall_sub_vp;
3057 } else if (s->DRAMClockChangeSupportNumber == 1) {
3058 *p->DRAMClockChangeSupport = dml_dram_clock_change_vblank_w_mall_sub_vp;
3059 } else if (s->DRAMClockChangeSupportNumber == 2) {
3060 *p->DRAMClockChangeSupport = dml_dram_clock_change_vblank_drr_w_mall_sub_vp;
3061 } else {
3062 *p->DRAMClockChangeSupport = dml_dram_clock_change_unsupported;
3063 }
3064 }
3065
3066 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
3067 s->dst_y_pstate = (dml_uint_t)(dml_ceil((p->mmSOCParameters.DRAMClockChangeLatency + p->mmSOCParameters.UrgentLatency) / (p->HTotal[k] / p->PixelClock[k]), 1));
3068 s->src_y_pstate_l = (dml_uint_t)(dml_ceil(s->dst_y_pstate * p->VRatio[k], p->SwathHeightY[k]));
3069 s->src_y_ahead_l = (dml_uint_t)(dml_floor(p->DETBufferSizeY[k] / p->BytePerPixelDETY[k] / p->SwathWidthY[k], p->SwathHeightY[k]) + s->LBLatencyHidingSourceLinesY[k]);
3070 s->sub_vp_lines_l = s->src_y_pstate_l + s->src_y_ahead_l + p->meta_row_height[k];
3071
3072 #ifdef __DML_VBA_DEBUG__
3073 dml_print("DML::%s: k=%u, DETBufferSizeY = %u\n", __func__, k, p->DETBufferSizeY[k]);
3074 dml_print("DML::%s: k=%u, BytePerPixelDETY = %f\n", __func__, k, p->BytePerPixelDETY[k]);
3075 dml_print("DML::%s: k=%u, SwathWidthY = %u\n", __func__, k, p->SwathWidthY[k]);
3076 dml_print("DML::%s: k=%u, SwathHeightY = %u\n", __func__, k, p->SwathHeightY[k]);
3077 dml_print("DML::%s: k=%u, LBLatencyHidingSourceLinesY = %u\n", __func__, k, s->LBLatencyHidingSourceLinesY[k]);
3078 dml_print("DML::%s: k=%u, dst_y_pstate = %u\n", __func__, k, s->dst_y_pstate);
3079 dml_print("DML::%s: k=%u, src_y_pstate_l = %u\n", __func__, k, s->src_y_pstate_l);
3080 dml_print("DML::%s: k=%u, src_y_ahead_l = %u\n", __func__, k, s->src_y_ahead_l);
3081 dml_print("DML::%s: k=%u, meta_row_height = %u\n", __func__, k, p->meta_row_height[k]);
3082 dml_print("DML::%s: k=%u, sub_vp_lines_l = %u\n", __func__, k, s->sub_vp_lines_l);
3083 #endif
3084 p->SubViewportLinesNeededInMALL[k] = s->sub_vp_lines_l;
3085
3086 if (p->BytePerPixelDETC[k] > 0) {
3087 s->src_y_pstate_c = (dml_uint_t)(dml_ceil(s->dst_y_pstate * p->VRatioChroma[k], p->SwathHeightC[k]));
3088 s->src_y_ahead_c = (dml_uint_t)(dml_floor(p->DETBufferSizeC[k] / p->BytePerPixelDETC[k] / p->SwathWidthC[k], p->SwathHeightC[k]) + s->LBLatencyHidingSourceLinesC[k]);
3089 s->sub_vp_lines_c = s->src_y_pstate_c + s->src_y_ahead_c + p->meta_row_height_chroma[k];
3090 p->SubViewportLinesNeededInMALL[k] = (dml_uint_t)(dml_max(s->sub_vp_lines_l, s->sub_vp_lines_c));
3091
3092 #ifdef __DML_VBA_DEBUG__
3093 dml_print("DML::%s: k=%u, src_y_pstate_c = %u\n", __func__, k, s->src_y_pstate_c);
3094 dml_print("DML::%s: k=%u, src_y_ahead_c = %u\n", __func__, k, s->src_y_ahead_c);
3095 dml_print("DML::%s: k=%u, meta_row_height_chroma = %u\n", __func__, k, p->meta_row_height_chroma[k]);
3096 dml_print("DML::%s: k=%u, sub_vp_lines_c = %u\n", __func__, k, s->sub_vp_lines_c);
3097 #endif
3098 }
3099 }
3100
3101 #ifdef __DML_VBA_DEBUG__
3102 dml_print("DML::%s: DRAMClockChangeSupport = %u\n", __func__, *p->DRAMClockChangeSupport);
3103 dml_print("DML::%s: FCLKChangeSupport = %u\n", __func__, *p->FCLKChangeSupport);
3104 dml_print("DML::%s: MaxActiveFCLKChangeLatencySupported = %f\n", __func__, *p->MaxActiveFCLKChangeLatencySupported);
3105 dml_print("DML::%s: USRRetrainingSupport = %u\n", __func__, *p->USRRetrainingSupport);
3106 #endif
3107 } // CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport
3108
CalculateDCFCLKDeepSleep(dml_uint_t NumberOfActiveSurfaces,dml_uint_t BytePerPixelY[],dml_uint_t BytePerPixelC[],dml_float_t VRatio[],dml_float_t VRatioChroma[],dml_uint_t SwathWidthY[],dml_uint_t SwathWidthC[],dml_uint_t DPPPerSurface[],dml_float_t HRatio[],dml_float_t HRatioChroma[],dml_float_t PixelClock[],dml_float_t PSCL_THROUGHPUT[],dml_float_t PSCL_THROUGHPUT_CHROMA[],dml_float_t Dppclk[],dml_float_t ReadBandwidthLuma[],dml_float_t ReadBandwidthChroma[],dml_uint_t ReturnBusWidth,dml_float_t * DCFClkDeepSleep)3109 static void CalculateDCFCLKDeepSleep(
3110 dml_uint_t NumberOfActiveSurfaces,
3111 dml_uint_t BytePerPixelY[],
3112 dml_uint_t BytePerPixelC[],
3113 dml_float_t VRatio[],
3114 dml_float_t VRatioChroma[],
3115 dml_uint_t SwathWidthY[],
3116 dml_uint_t SwathWidthC[],
3117 dml_uint_t DPPPerSurface[],
3118 dml_float_t HRatio[],
3119 dml_float_t HRatioChroma[],
3120 dml_float_t PixelClock[],
3121 dml_float_t PSCL_THROUGHPUT[],
3122 dml_float_t PSCL_THROUGHPUT_CHROMA[],
3123 dml_float_t Dppclk[],
3124 dml_float_t ReadBandwidthLuma[],
3125 dml_float_t ReadBandwidthChroma[],
3126 dml_uint_t ReturnBusWidth,
3127
3128 // Output
3129 dml_float_t *DCFClkDeepSleep)
3130 {
3131 dml_float_t DisplayPipeLineDeliveryTimeLuma;
3132 dml_float_t DisplayPipeLineDeliveryTimeChroma;
3133 dml_float_t DCFClkDeepSleepPerSurface[__DML_NUM_PLANES__];
3134 dml_float_t ReadBandwidth = 0.0;
3135
3136 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
3137
3138 if (VRatio[k] <= 1) {
3139 DisplayPipeLineDeliveryTimeLuma = SwathWidthY[k] * DPPPerSurface[k] / HRatio[k] / PixelClock[k];
3140 } else {
3141 DisplayPipeLineDeliveryTimeLuma = SwathWidthY[k] / PSCL_THROUGHPUT[k] / Dppclk[k];
3142 }
3143 if (BytePerPixelC[k] == 0) {
3144 DisplayPipeLineDeliveryTimeChroma = 0;
3145 } else {
3146 if (VRatioChroma[k] <= 1) {
3147 DisplayPipeLineDeliveryTimeChroma = SwathWidthC[k] * DPPPerSurface[k] / HRatioChroma[k] / PixelClock[k];
3148 } else {
3149 DisplayPipeLineDeliveryTimeChroma = SwathWidthC[k] / PSCL_THROUGHPUT_CHROMA[k] / Dppclk[k];
3150 }
3151 }
3152
3153 if (BytePerPixelC[k] > 0) {
3154 DCFClkDeepSleepPerSurface[k] = dml_max(__DML_MIN_DCFCLK_FACTOR__ * SwathWidthY[k] * BytePerPixelY[k] / 32.0 / DisplayPipeLineDeliveryTimeLuma,
3155 __DML_MIN_DCFCLK_FACTOR__ * SwathWidthC[k] * BytePerPixelC[k] / 32.0 / DisplayPipeLineDeliveryTimeChroma);
3156 } else {
3157 DCFClkDeepSleepPerSurface[k] = __DML_MIN_DCFCLK_FACTOR__ * SwathWidthY[k] * BytePerPixelY[k] / 64.0 / DisplayPipeLineDeliveryTimeLuma;
3158 }
3159 DCFClkDeepSleepPerSurface[k] = dml_max(DCFClkDeepSleepPerSurface[k], PixelClock[k] / 16);
3160
3161 #ifdef __DML_VBA_DEBUG__
3162 dml_print("DML::%s: k=%u, PixelClock = %f\n", __func__, k, PixelClock[k]);
3163 dml_print("DML::%s: k=%u, DCFClkDeepSleepPerSurface = %f\n", __func__, k, DCFClkDeepSleepPerSurface[k]);
3164 #endif
3165 }
3166
3167 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
3168 ReadBandwidth = ReadBandwidth + ReadBandwidthLuma[k] + ReadBandwidthChroma[k];
3169 }
3170
3171 *DCFClkDeepSleep = dml_max(8.0, __DML_MIN_DCFCLK_FACTOR__ * ReadBandwidth / (dml_float_t) ReturnBusWidth);
3172
3173 #ifdef __DML_VBA_DEBUG__
3174 dml_print("DML::%s: __DML_MIN_DCFCLK_FACTOR__ = %f\n", __func__, __DML_MIN_DCFCLK_FACTOR__);
3175 dml_print("DML::%s: ReadBandwidth = %f\n", __func__, ReadBandwidth);
3176 dml_print("DML::%s: ReturnBusWidth = %u\n", __func__, ReturnBusWidth);
3177 dml_print("DML::%s: DCFClkDeepSleep = %f\n", __func__, *DCFClkDeepSleep);
3178 #endif
3179
3180 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
3181 *DCFClkDeepSleep = dml_max(*DCFClkDeepSleep, DCFClkDeepSleepPerSurface[k]);
3182 }
3183 dml_print("DML::%s: DCFClkDeepSleep = %f (final)\n", __func__, *DCFClkDeepSleep);
3184 } // CalculateDCFCLKDeepSleep
3185
CalculateUrgentBurstFactor(enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange,dml_uint_t swath_width_luma_ub,dml_uint_t swath_width_chroma_ub,dml_uint_t SwathHeightY,dml_uint_t SwathHeightC,dml_float_t LineTime,dml_float_t UrgentLatency,dml_float_t CursorBufferSize,dml_uint_t CursorWidth,dml_uint_t CursorBPP,dml_float_t VRatio,dml_float_t VRatioC,dml_float_t BytePerPixelInDETY,dml_float_t BytePerPixelInDETC,dml_uint_t DETBufferSizeY,dml_uint_t DETBufferSizeC,dml_float_t * UrgentBurstFactorCursor,dml_float_t * UrgentBurstFactorLuma,dml_float_t * UrgentBurstFactorChroma,dml_bool_t * NotEnoughUrgentLatencyHiding)3186 static void CalculateUrgentBurstFactor(
3187 enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange,
3188 dml_uint_t swath_width_luma_ub,
3189 dml_uint_t swath_width_chroma_ub,
3190 dml_uint_t SwathHeightY,
3191 dml_uint_t SwathHeightC,
3192 dml_float_t LineTime,
3193 dml_float_t UrgentLatency,
3194 dml_float_t CursorBufferSize,
3195 dml_uint_t CursorWidth,
3196 dml_uint_t CursorBPP,
3197 dml_float_t VRatio,
3198 dml_float_t VRatioC,
3199 dml_float_t BytePerPixelInDETY,
3200 dml_float_t BytePerPixelInDETC,
3201 dml_uint_t DETBufferSizeY,
3202 dml_uint_t DETBufferSizeC,
3203 // Output
3204 dml_float_t *UrgentBurstFactorCursor,
3205 dml_float_t *UrgentBurstFactorLuma,
3206 dml_float_t *UrgentBurstFactorChroma,
3207 dml_bool_t *NotEnoughUrgentLatencyHiding)
3208 {
3209 dml_float_t LinesInDETLuma;
3210 dml_float_t LinesInDETChroma;
3211 dml_uint_t LinesInCursorBuffer;
3212 dml_float_t CursorBufferSizeInTime;
3213 dml_float_t DETBufferSizeInTimeLuma;
3214 dml_float_t DETBufferSizeInTimeChroma;
3215
3216 *NotEnoughUrgentLatencyHiding = 0;
3217
3218 if (CursorWidth > 0) {
3219 LinesInCursorBuffer = 1 << (dml_uint_t) dml_floor(dml_log2(CursorBufferSize * 1024.0 / (CursorWidth * CursorBPP / 8.0)), 1.0);
3220 if (VRatio > 0) {
3221 CursorBufferSizeInTime = LinesInCursorBuffer * LineTime / VRatio;
3222 if (CursorBufferSizeInTime - UrgentLatency <= 0) {
3223 *NotEnoughUrgentLatencyHiding = 1;
3224 *UrgentBurstFactorCursor = 0;
3225 } else {
3226 *UrgentBurstFactorCursor = CursorBufferSizeInTime / (CursorBufferSizeInTime - UrgentLatency);
3227 }
3228 } else {
3229 *UrgentBurstFactorCursor = 1;
3230 }
3231 }
3232
3233 LinesInDETLuma = (UseMALLForPStateChange == dml_use_mall_pstate_change_phantom_pipe ? 1024*1024 : DETBufferSizeY) / BytePerPixelInDETY / swath_width_luma_ub;
3234
3235 if (VRatio > 0) {
3236 DETBufferSizeInTimeLuma = dml_floor(LinesInDETLuma, SwathHeightY) * LineTime / VRatio;
3237 if (DETBufferSizeInTimeLuma - UrgentLatency <= 0) {
3238 *NotEnoughUrgentLatencyHiding = 1;
3239 *UrgentBurstFactorLuma = 0;
3240 } else {
3241 *UrgentBurstFactorLuma = DETBufferSizeInTimeLuma / (DETBufferSizeInTimeLuma - UrgentLatency);
3242 }
3243 } else {
3244 *UrgentBurstFactorLuma = 1;
3245 }
3246
3247 if (BytePerPixelInDETC > 0) {
3248 LinesInDETChroma = (UseMALLForPStateChange == dml_use_mall_pstate_change_phantom_pipe ? 1024*1024 : DETBufferSizeC) / BytePerPixelInDETC / swath_width_chroma_ub;
3249
3250 if (VRatioC > 0) {
3251 DETBufferSizeInTimeChroma = dml_floor(LinesInDETChroma, SwathHeightC) * LineTime / VRatioC;
3252 if (DETBufferSizeInTimeChroma - UrgentLatency <= 0) {
3253 *NotEnoughUrgentLatencyHiding = 1;
3254 *UrgentBurstFactorChroma = 0;
3255 } else {
3256 *UrgentBurstFactorChroma = DETBufferSizeInTimeChroma / (DETBufferSizeInTimeChroma - UrgentLatency);
3257 }
3258 } else {
3259 *UrgentBurstFactorChroma = 1;
3260 }
3261 }
3262 } // CalculateUrgentBurstFactor
3263
CalculatePixelDeliveryTimes(dml_uint_t NumberOfActiveSurfaces,dml_float_t VRatio[],dml_float_t VRatioChroma[],dml_float_t VRatioPrefetchY[],dml_float_t VRatioPrefetchC[],dml_uint_t swath_width_luma_ub[],dml_uint_t swath_width_chroma_ub[],dml_uint_t DPPPerSurface[],dml_float_t HRatio[],dml_float_t HRatioChroma[],dml_float_t PixelClock[],dml_float_t PSCL_THROUGHPUT[],dml_float_t PSCL_THROUGHPUT_CHROMA[],dml_float_t Dppclk[],dml_uint_t BytePerPixelC[],enum dml_rotation_angle SourceScan[],dml_uint_t NumberOfCursors[],dml_uint_t CursorWidth[],dml_uint_t CursorBPP[],dml_uint_t BlockWidth256BytesY[],dml_uint_t BlockHeight256BytesY[],dml_uint_t BlockWidth256BytesC[],dml_uint_t BlockHeight256BytesC[],dml_float_t DisplayPipeLineDeliveryTimeLuma[],dml_float_t DisplayPipeLineDeliveryTimeChroma[],dml_float_t DisplayPipeLineDeliveryTimeLumaPrefetch[],dml_float_t DisplayPipeLineDeliveryTimeChromaPrefetch[],dml_float_t DisplayPipeRequestDeliveryTimeLuma[],dml_float_t DisplayPipeRequestDeliveryTimeChroma[],dml_float_t DisplayPipeRequestDeliveryTimeLumaPrefetch[],dml_float_t DisplayPipeRequestDeliveryTimeChromaPrefetch[],dml_float_t CursorRequestDeliveryTime[],dml_float_t CursorRequestDeliveryTimePrefetch[])3264 static void CalculatePixelDeliveryTimes(
3265 dml_uint_t NumberOfActiveSurfaces,
3266 dml_float_t VRatio[],
3267 dml_float_t VRatioChroma[],
3268 dml_float_t VRatioPrefetchY[],
3269 dml_float_t VRatioPrefetchC[],
3270 dml_uint_t swath_width_luma_ub[],
3271 dml_uint_t swath_width_chroma_ub[],
3272 dml_uint_t DPPPerSurface[],
3273 dml_float_t HRatio[],
3274 dml_float_t HRatioChroma[],
3275 dml_float_t PixelClock[],
3276 dml_float_t PSCL_THROUGHPUT[],
3277 dml_float_t PSCL_THROUGHPUT_CHROMA[],
3278 dml_float_t Dppclk[],
3279 dml_uint_t BytePerPixelC[],
3280 enum dml_rotation_angle SourceScan[],
3281 dml_uint_t NumberOfCursors[],
3282 dml_uint_t CursorWidth[],
3283 dml_uint_t CursorBPP[],
3284 dml_uint_t BlockWidth256BytesY[],
3285 dml_uint_t BlockHeight256BytesY[],
3286 dml_uint_t BlockWidth256BytesC[],
3287 dml_uint_t BlockHeight256BytesC[],
3288
3289 // Output
3290 dml_float_t DisplayPipeLineDeliveryTimeLuma[],
3291 dml_float_t DisplayPipeLineDeliveryTimeChroma[],
3292 dml_float_t DisplayPipeLineDeliveryTimeLumaPrefetch[],
3293 dml_float_t DisplayPipeLineDeliveryTimeChromaPrefetch[],
3294 dml_float_t DisplayPipeRequestDeliveryTimeLuma[],
3295 dml_float_t DisplayPipeRequestDeliveryTimeChroma[],
3296 dml_float_t DisplayPipeRequestDeliveryTimeLumaPrefetch[],
3297 dml_float_t DisplayPipeRequestDeliveryTimeChromaPrefetch[],
3298 dml_float_t CursorRequestDeliveryTime[],
3299 dml_float_t CursorRequestDeliveryTimePrefetch[])
3300 {
3301 dml_float_t req_per_swath_ub;
3302
3303 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
3304
3305 #ifdef __DML_VBA_DEBUG__
3306 dml_print("DML::%s: k=%u : HRatio = %f\n", __func__, k, HRatio[k]);
3307 dml_print("DML::%s: k=%u : VRatio = %f\n", __func__, k, VRatio[k]);
3308 dml_print("DML::%s: k=%u : HRatioChroma = %f\n", __func__, k, HRatioChroma[k]);
3309 dml_print("DML::%s: k=%u : VRatioChroma = %f\n", __func__, k, VRatioChroma[k]);
3310 dml_print("DML::%s: k=%u : swath_width_luma_ub = %u\n", __func__, k, swath_width_luma_ub[k]);
3311 dml_print("DML::%s: k=%u : swath_width_chroma_ub = %u\n", __func__, k, swath_width_chroma_ub[k]);
3312 dml_print("DML::%s: k=%u : PSCL_THROUGHPUT = %f\n", __func__, k, PSCL_THROUGHPUT[k]);
3313 dml_print("DML::%s: k=%u : PSCL_THROUGHPUT_CHROMA = %f\n", __func__, k, PSCL_THROUGHPUT_CHROMA[k]);
3314 dml_print("DML::%s: k=%u : DPPPerSurface = %u\n", __func__, k, DPPPerSurface[k]);
3315 dml_print("DML::%s: k=%u : PixelClock = %f\n", __func__, k, PixelClock[k]);
3316 dml_print("DML::%s: k=%u : Dppclk = %f\n", __func__, k, Dppclk[k]);
3317 #endif
3318
3319 if (VRatio[k] <= 1) {
3320 DisplayPipeLineDeliveryTimeLuma[k] = swath_width_luma_ub[k] * DPPPerSurface[k] / HRatio[k] / PixelClock[k];
3321 } else {
3322 DisplayPipeLineDeliveryTimeLuma[k] = swath_width_luma_ub[k] / PSCL_THROUGHPUT[k] / Dppclk[k];
3323 }
3324
3325 if (BytePerPixelC[k] == 0) {
3326 DisplayPipeLineDeliveryTimeChroma[k] = 0;
3327 } else {
3328 if (VRatioChroma[k] <= 1) {
3329 DisplayPipeLineDeliveryTimeChroma[k] = swath_width_chroma_ub[k] * DPPPerSurface[k] / HRatioChroma[k] / PixelClock[k];
3330 } else {
3331 DisplayPipeLineDeliveryTimeChroma[k] = swath_width_chroma_ub[k] / PSCL_THROUGHPUT_CHROMA[k] / Dppclk[k];
3332 }
3333 }
3334
3335 if (VRatioPrefetchY[k] <= 1) {
3336 DisplayPipeLineDeliveryTimeLumaPrefetch[k] = swath_width_luma_ub[k] * DPPPerSurface[k] / HRatio[k] / PixelClock[k];
3337 } else {
3338 DisplayPipeLineDeliveryTimeLumaPrefetch[k] = swath_width_luma_ub[k] / PSCL_THROUGHPUT[k] / Dppclk[k];
3339 }
3340
3341 if (BytePerPixelC[k] == 0) {
3342 DisplayPipeLineDeliveryTimeChromaPrefetch[k] = 0;
3343 } else {
3344 if (VRatioPrefetchC[k] <= 1) {
3345 DisplayPipeLineDeliveryTimeChromaPrefetch[k] = swath_width_chroma_ub[k] * DPPPerSurface[k] / HRatioChroma[k] / PixelClock[k];
3346 } else {
3347 DisplayPipeLineDeliveryTimeChromaPrefetch[k] = swath_width_chroma_ub[k] / PSCL_THROUGHPUT_CHROMA[k] / Dppclk[k];
3348 }
3349 }
3350 #ifdef __DML_VBA_DEBUG__
3351 dml_print("DML::%s: k=%u : DisplayPipeLineDeliveryTimeLuma = %f\n", __func__, k, DisplayPipeLineDeliveryTimeLuma[k]);
3352 dml_print("DML::%s: k=%u : DisplayPipeLineDeliveryTimeLumaPrefetch = %f\n", __func__, k, DisplayPipeLineDeliveryTimeLumaPrefetch[k]);
3353 dml_print("DML::%s: k=%u : DisplayPipeLineDeliveryTimeChroma = %f\n", __func__, k, DisplayPipeLineDeliveryTimeChroma[k]);
3354 dml_print("DML::%s: k=%u : DisplayPipeLineDeliveryTimeChromaPrefetch = %f\n", __func__, k, DisplayPipeLineDeliveryTimeChromaPrefetch[k]);
3355 #endif
3356 }
3357
3358 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
3359 if (!dml_is_vertical_rotation(SourceScan[k])) {
3360 req_per_swath_ub = swath_width_luma_ub[k] / BlockWidth256BytesY[k];
3361 } else {
3362 req_per_swath_ub = swath_width_luma_ub[k] / BlockHeight256BytesY[k];
3363 }
3364 #ifdef __DML_VBA_DEBUG__
3365 dml_print("DML::%s: k=%u : req_per_swath_ub = %f (Luma)\n", __func__, k, req_per_swath_ub);
3366 #endif
3367
3368 DisplayPipeRequestDeliveryTimeLuma[k] = DisplayPipeLineDeliveryTimeLuma[k] / req_per_swath_ub;
3369 DisplayPipeRequestDeliveryTimeLumaPrefetch[k] = DisplayPipeLineDeliveryTimeLumaPrefetch[k] / req_per_swath_ub;
3370 if (BytePerPixelC[k] == 0) {
3371 DisplayPipeRequestDeliveryTimeChroma[k] = 0;
3372 DisplayPipeRequestDeliveryTimeChromaPrefetch[k] = 0;
3373 } else {
3374 if (!dml_is_vertical_rotation(SourceScan[k])) {
3375 req_per_swath_ub = swath_width_chroma_ub[k] / BlockWidth256BytesC[k];
3376 } else {
3377 req_per_swath_ub = swath_width_chroma_ub[k] / BlockHeight256BytesC[k];
3378 }
3379 #ifdef __DML_VBA_DEBUG__
3380 dml_print("DML::%s: k=%u : req_per_swath_ub = %f (Chroma)\n", __func__, k, req_per_swath_ub);
3381 #endif
3382 DisplayPipeRequestDeliveryTimeChroma[k] = DisplayPipeLineDeliveryTimeChroma[k] / req_per_swath_ub;
3383 DisplayPipeRequestDeliveryTimeChromaPrefetch[k] = DisplayPipeLineDeliveryTimeChromaPrefetch[k] / req_per_swath_ub;
3384 }
3385 #ifdef __DML_VBA_DEBUG__
3386 dml_print("DML::%s: k=%u : DisplayPipeRequestDeliveryTimeLuma = %f\n", __func__, k, DisplayPipeRequestDeliveryTimeLuma[k]);
3387 dml_print("DML::%s: k=%u : DisplayPipeRequestDeliveryTimeLumaPrefetch = %f\n", __func__, k, DisplayPipeRequestDeliveryTimeLumaPrefetch[k]);
3388 dml_print("DML::%s: k=%u : DisplayPipeRequestDeliveryTimeChroma = %f\n", __func__, k, DisplayPipeRequestDeliveryTimeChroma[k]);
3389 dml_print("DML::%s: k=%u : DisplayPipeRequestDeliveryTimeChromaPrefetch = %f\n", __func__, k, DisplayPipeRequestDeliveryTimeChromaPrefetch[k]);
3390 #endif
3391 }
3392
3393 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
3394 dml_uint_t cursor_req_per_width;
3395 cursor_req_per_width = (dml_uint_t)(dml_ceil((dml_float_t) CursorWidth[k] * (dml_float_t) CursorBPP[k] / 256.0 / 8.0, 1.0));
3396 if (NumberOfCursors[k] > 0) {
3397 if (VRatio[k] <= 1) {
3398 CursorRequestDeliveryTime[k] = (dml_float_t) CursorWidth[k] / HRatio[k] / PixelClock[k] / cursor_req_per_width;
3399 } else {
3400 CursorRequestDeliveryTime[k] = (dml_float_t) CursorWidth[k] / PSCL_THROUGHPUT[k] / Dppclk[k] / cursor_req_per_width;
3401 }
3402 if (VRatioPrefetchY[k] <= 1) {
3403 CursorRequestDeliveryTimePrefetch[k] = (dml_float_t) CursorWidth[k] / HRatio[k] / PixelClock[k] / cursor_req_per_width;
3404 } else {
3405 CursorRequestDeliveryTimePrefetch[k] = (dml_float_t) CursorWidth[k] / PSCL_THROUGHPUT[k] / Dppclk[k] / cursor_req_per_width;
3406 }
3407 } else {
3408 CursorRequestDeliveryTime[k] = 0;
3409 CursorRequestDeliveryTimePrefetch[k] = 0;
3410 }
3411 #ifdef __DML_VBA_DEBUG__
3412 dml_print("DML::%s: k=%u : NumberOfCursors = %u\n", __func__, k, NumberOfCursors[k]);
3413 dml_print("DML::%s: k=%u : CursorRequestDeliveryTime = %f\n", __func__, k, CursorRequestDeliveryTime[k]);
3414 dml_print("DML::%s: k=%u : CursorRequestDeliveryTimePrefetch = %f\n", __func__, k, CursorRequestDeliveryTimePrefetch[k]);
3415 #endif
3416 }
3417 } // CalculatePixelDeliveryTimes
3418
CalculateMetaAndPTETimes(dml_bool_t use_one_row_for_frame[],dml_uint_t NumberOfActiveSurfaces,dml_bool_t GPUVMEnable,dml_uint_t MetaChunkSize,dml_uint_t MinMetaChunkSizeBytes,dml_uint_t HTotal[],dml_float_t VRatio[],dml_float_t VRatioChroma[],dml_float_t DestinationLinesToRequestRowInVBlank[],dml_float_t DestinationLinesToRequestRowInImmediateFlip[],dml_bool_t DCCEnable[],dml_float_t PixelClock[],dml_uint_t BytePerPixelY[],dml_uint_t BytePerPixelC[],enum dml_rotation_angle SourceScan[],dml_uint_t dpte_row_height[],dml_uint_t dpte_row_height_chroma[],dml_uint_t meta_row_width[],dml_uint_t meta_row_width_chroma[],dml_uint_t meta_row_height[],dml_uint_t meta_row_height_chroma[],dml_uint_t meta_req_width[],dml_uint_t meta_req_width_chroma[],dml_uint_t meta_req_height[],dml_uint_t meta_req_height_chroma[],dml_uint_t dpte_group_bytes[],dml_uint_t PTERequestSizeY[],dml_uint_t PTERequestSizeC[],dml_uint_t PixelPTEReqWidthY[],dml_uint_t PixelPTEReqHeightY[],dml_uint_t PixelPTEReqWidthC[],dml_uint_t PixelPTEReqHeightC[],dml_uint_t dpte_row_width_luma_ub[],dml_uint_t dpte_row_width_chroma_ub[],dml_float_t DST_Y_PER_PTE_ROW_NOM_L[],dml_float_t DST_Y_PER_PTE_ROW_NOM_C[],dml_float_t DST_Y_PER_META_ROW_NOM_L[],dml_float_t DST_Y_PER_META_ROW_NOM_C[],dml_float_t TimePerMetaChunkNominal[],dml_float_t TimePerChromaMetaChunkNominal[],dml_float_t TimePerMetaChunkVBlank[],dml_float_t TimePerChromaMetaChunkVBlank[],dml_float_t TimePerMetaChunkFlip[],dml_float_t TimePerChromaMetaChunkFlip[],dml_float_t time_per_pte_group_nom_luma[],dml_float_t time_per_pte_group_vblank_luma[],dml_float_t time_per_pte_group_flip_luma[],dml_float_t time_per_pte_group_nom_chroma[],dml_float_t time_per_pte_group_vblank_chroma[],dml_float_t time_per_pte_group_flip_chroma[])3419 static void CalculateMetaAndPTETimes(
3420 dml_bool_t use_one_row_for_frame[],
3421 dml_uint_t NumberOfActiveSurfaces,
3422 dml_bool_t GPUVMEnable,
3423 dml_uint_t MetaChunkSize,
3424 dml_uint_t MinMetaChunkSizeBytes,
3425 dml_uint_t HTotal[],
3426 dml_float_t VRatio[],
3427 dml_float_t VRatioChroma[],
3428 dml_float_t DestinationLinesToRequestRowInVBlank[],
3429 dml_float_t DestinationLinesToRequestRowInImmediateFlip[],
3430 dml_bool_t DCCEnable[],
3431 dml_float_t PixelClock[],
3432 dml_uint_t BytePerPixelY[],
3433 dml_uint_t BytePerPixelC[],
3434 enum dml_rotation_angle SourceScan[],
3435 dml_uint_t dpte_row_height[],
3436 dml_uint_t dpte_row_height_chroma[],
3437 dml_uint_t meta_row_width[],
3438 dml_uint_t meta_row_width_chroma[],
3439 dml_uint_t meta_row_height[],
3440 dml_uint_t meta_row_height_chroma[],
3441 dml_uint_t meta_req_width[],
3442 dml_uint_t meta_req_width_chroma[],
3443 dml_uint_t meta_req_height[],
3444 dml_uint_t meta_req_height_chroma[],
3445 dml_uint_t dpte_group_bytes[],
3446 dml_uint_t PTERequestSizeY[],
3447 dml_uint_t PTERequestSizeC[],
3448 dml_uint_t PixelPTEReqWidthY[],
3449 dml_uint_t PixelPTEReqHeightY[],
3450 dml_uint_t PixelPTEReqWidthC[],
3451 dml_uint_t PixelPTEReqHeightC[],
3452 dml_uint_t dpte_row_width_luma_ub[],
3453 dml_uint_t dpte_row_width_chroma_ub[],
3454
3455 // Output
3456 dml_float_t DST_Y_PER_PTE_ROW_NOM_L[],
3457 dml_float_t DST_Y_PER_PTE_ROW_NOM_C[],
3458 dml_float_t DST_Y_PER_META_ROW_NOM_L[],
3459 dml_float_t DST_Y_PER_META_ROW_NOM_C[],
3460 dml_float_t TimePerMetaChunkNominal[],
3461 dml_float_t TimePerChromaMetaChunkNominal[],
3462 dml_float_t TimePerMetaChunkVBlank[],
3463 dml_float_t TimePerChromaMetaChunkVBlank[],
3464 dml_float_t TimePerMetaChunkFlip[],
3465 dml_float_t TimePerChromaMetaChunkFlip[],
3466 dml_float_t time_per_pte_group_nom_luma[],
3467 dml_float_t time_per_pte_group_vblank_luma[],
3468 dml_float_t time_per_pte_group_flip_luma[],
3469 dml_float_t time_per_pte_group_nom_chroma[],
3470 dml_float_t time_per_pte_group_vblank_chroma[],
3471 dml_float_t time_per_pte_group_flip_chroma[])
3472 {
3473 dml_uint_t meta_chunk_width;
3474 dml_uint_t min_meta_chunk_width;
3475 dml_uint_t meta_chunk_per_row_int;
3476 dml_uint_t meta_row_remainder;
3477 dml_uint_t meta_chunk_threshold;
3478 dml_uint_t meta_chunks_per_row_ub;
3479 dml_uint_t meta_chunk_width_chroma;
3480 dml_uint_t min_meta_chunk_width_chroma;
3481 dml_uint_t meta_chunk_per_row_int_chroma;
3482 dml_uint_t meta_row_remainder_chroma;
3483 dml_uint_t meta_chunk_threshold_chroma;
3484 dml_uint_t meta_chunks_per_row_ub_chroma;
3485 dml_uint_t dpte_group_width_luma;
3486 dml_uint_t dpte_groups_per_row_luma_ub;
3487 dml_uint_t dpte_group_width_chroma;
3488 dml_uint_t dpte_groups_per_row_chroma_ub;
3489
3490 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
3491 DST_Y_PER_PTE_ROW_NOM_L[k] = dpte_row_height[k] / VRatio[k];
3492 if (BytePerPixelC[k] == 0) {
3493 DST_Y_PER_PTE_ROW_NOM_C[k] = 0;
3494 } else {
3495 DST_Y_PER_PTE_ROW_NOM_C[k] = dpte_row_height_chroma[k] / VRatioChroma[k];
3496 }
3497 DST_Y_PER_META_ROW_NOM_L[k] = meta_row_height[k] / VRatio[k];
3498 if (BytePerPixelC[k] == 0) {
3499 DST_Y_PER_META_ROW_NOM_C[k] = 0;
3500 } else {
3501 DST_Y_PER_META_ROW_NOM_C[k] = meta_row_height_chroma[k] / VRatioChroma[k];
3502 }
3503 }
3504
3505 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
3506 if (DCCEnable[k] == true) {
3507 meta_chunk_width = MetaChunkSize * 1024 * 256 / BytePerPixelY[k] / meta_row_height[k];
3508 min_meta_chunk_width = MinMetaChunkSizeBytes * 256 / BytePerPixelY[k] / meta_row_height[k];
3509 meta_chunk_per_row_int = meta_row_width[k] / meta_chunk_width;
3510 meta_row_remainder = meta_row_width[k] % meta_chunk_width;
3511 if (!dml_is_vertical_rotation(SourceScan[k])) {
3512 meta_chunk_threshold = 2 * min_meta_chunk_width - meta_req_width[k];
3513 } else {
3514 meta_chunk_threshold = 2 * min_meta_chunk_width - meta_req_height[k];
3515 }
3516 if (meta_row_remainder <= meta_chunk_threshold) {
3517 meta_chunks_per_row_ub = meta_chunk_per_row_int + 1;
3518 } else {
3519 meta_chunks_per_row_ub = meta_chunk_per_row_int + 2;
3520 }
3521 TimePerMetaChunkNominal[k] = meta_row_height[k] / VRatio[k] * HTotal[k] / PixelClock[k] / meta_chunks_per_row_ub;
3522 TimePerMetaChunkVBlank[k] = DestinationLinesToRequestRowInVBlank[k] * HTotal[k] / PixelClock[k] / meta_chunks_per_row_ub;
3523 TimePerMetaChunkFlip[k] = DestinationLinesToRequestRowInImmediateFlip[k] * HTotal[k] / PixelClock[k] / meta_chunks_per_row_ub;
3524 if (BytePerPixelC[k] == 0) {
3525 TimePerChromaMetaChunkNominal[k] = 0;
3526 TimePerChromaMetaChunkVBlank[k] = 0;
3527 TimePerChromaMetaChunkFlip[k] = 0;
3528 } else {
3529 meta_chunk_width_chroma = MetaChunkSize * 1024 * 256 / BytePerPixelC[k] / meta_row_height_chroma[k];
3530 min_meta_chunk_width_chroma = MinMetaChunkSizeBytes * 256 / BytePerPixelC[k] / meta_row_height_chroma[k];
3531 meta_chunk_per_row_int_chroma = (dml_uint_t)((dml_float_t) meta_row_width_chroma[k] / meta_chunk_width_chroma);
3532 meta_row_remainder_chroma = meta_row_width_chroma[k] % meta_chunk_width_chroma;
3533 if (!dml_is_vertical_rotation(SourceScan[k])) {
3534 meta_chunk_threshold_chroma = 2 * min_meta_chunk_width_chroma - meta_req_width_chroma[k];
3535 } else {
3536 meta_chunk_threshold_chroma = 2 * min_meta_chunk_width_chroma - meta_req_height_chroma[k];
3537 }
3538 if (meta_row_remainder_chroma <= meta_chunk_threshold_chroma) {
3539 meta_chunks_per_row_ub_chroma = meta_chunk_per_row_int_chroma + 1;
3540 } else {
3541 meta_chunks_per_row_ub_chroma = meta_chunk_per_row_int_chroma + 2;
3542 }
3543 TimePerChromaMetaChunkNominal[k] = meta_row_height_chroma[k] / VRatioChroma[k] * HTotal[k] / PixelClock[k] / meta_chunks_per_row_ub_chroma;
3544 TimePerChromaMetaChunkVBlank[k] = DestinationLinesToRequestRowInVBlank[k] * HTotal[k] / PixelClock[k] / meta_chunks_per_row_ub_chroma;
3545 TimePerChromaMetaChunkFlip[k] = DestinationLinesToRequestRowInImmediateFlip[k] * HTotal[k] / PixelClock[k] / meta_chunks_per_row_ub_chroma;
3546 }
3547 } else {
3548 TimePerMetaChunkNominal[k] = 0;
3549 TimePerMetaChunkVBlank[k] = 0;
3550 TimePerMetaChunkFlip[k] = 0;
3551 TimePerChromaMetaChunkNominal[k] = 0;
3552 TimePerChromaMetaChunkVBlank[k] = 0;
3553 TimePerChromaMetaChunkFlip[k] = 0;
3554 }
3555 }
3556
3557 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
3558 if (GPUVMEnable == true) {
3559 if (!dml_is_vertical_rotation(SourceScan[k])) {
3560 dpte_group_width_luma = (dml_uint_t)((dml_float_t) dpte_group_bytes[k] / (dml_float_t) PTERequestSizeY[k] * PixelPTEReqWidthY[k]);
3561 } else {
3562 dpte_group_width_luma = (dml_uint_t)((dml_float_t) dpte_group_bytes[k] / (dml_float_t) PTERequestSizeY[k] * PixelPTEReqHeightY[k]);
3563 }
3564
3565 if (use_one_row_for_frame[k]) {
3566 dpte_groups_per_row_luma_ub = (dml_uint_t)(dml_ceil((dml_float_t) dpte_row_width_luma_ub[k] / (dml_float_t) dpte_group_width_luma / 2.0, 1.0));
3567 } else {
3568 dpte_groups_per_row_luma_ub = (dml_uint_t)(dml_ceil((dml_float_t) dpte_row_width_luma_ub[k] / (dml_float_t) dpte_group_width_luma, 1.0));
3569 }
3570
3571 dml_print("DML::%s: k=%u, use_one_row_for_frame = %u\n", __func__, k, use_one_row_for_frame[k]);
3572 dml_print("DML::%s: k=%u, dpte_group_bytes = %u\n", __func__, k, dpte_group_bytes[k]);
3573 dml_print("DML::%s: k=%u, PTERequestSizeY = %u\n", __func__, k, PTERequestSizeY[k]);
3574 dml_print("DML::%s: k=%u, PixelPTEReqWidthY = %u\n", __func__, k, PixelPTEReqWidthY[k]);
3575 dml_print("DML::%s: k=%u, PixelPTEReqHeightY = %u\n", __func__, k, PixelPTEReqHeightY[k]);
3576 dml_print("DML::%s: k=%u, dpte_row_width_luma_ub = %u\n", __func__, k, dpte_row_width_luma_ub[k]);
3577 dml_print("DML::%s: k=%u, dpte_group_width_luma = %u\n", __func__, k, dpte_group_width_luma);
3578 dml_print("DML::%s: k=%u, dpte_groups_per_row_luma_ub = %u\n", __func__, k, dpte_groups_per_row_luma_ub);
3579
3580 time_per_pte_group_nom_luma[k] = DST_Y_PER_PTE_ROW_NOM_L[k] * HTotal[k] / PixelClock[k] / dpte_groups_per_row_luma_ub;
3581 time_per_pte_group_vblank_luma[k] = DestinationLinesToRequestRowInVBlank[k] * HTotal[k] / PixelClock[k] / dpte_groups_per_row_luma_ub;
3582 time_per_pte_group_flip_luma[k] = DestinationLinesToRequestRowInImmediateFlip[k] * HTotal[k] / PixelClock[k] / dpte_groups_per_row_luma_ub;
3583 if (BytePerPixelC[k] == 0) {
3584 time_per_pte_group_nom_chroma[k] = 0;
3585 time_per_pte_group_vblank_chroma[k] = 0;
3586 time_per_pte_group_flip_chroma[k] = 0;
3587 } else {
3588 if (!dml_is_vertical_rotation(SourceScan[k])) {
3589 dpte_group_width_chroma = (dml_uint_t)((dml_float_t) dpte_group_bytes[k] / (dml_float_t) PTERequestSizeC[k] * PixelPTEReqWidthC[k]);
3590 } else {
3591 dpte_group_width_chroma = (dml_uint_t)((dml_float_t) dpte_group_bytes[k] / (dml_float_t) PTERequestSizeC[k] * PixelPTEReqHeightC[k]);
3592 }
3593
3594 if (use_one_row_for_frame[k]) {
3595 dpte_groups_per_row_chroma_ub = (dml_uint_t)(dml_ceil((dml_float_t) dpte_row_width_chroma_ub[k] / (dml_float_t) dpte_group_width_chroma / 2.0, 1.0));
3596 } else {
3597 dpte_groups_per_row_chroma_ub = (dml_uint_t)(dml_ceil((dml_float_t) dpte_row_width_chroma_ub[k] / (dml_float_t) dpte_group_width_chroma, 1.0));
3598 }
3599 dml_print("DML::%s: k=%u, dpte_row_width_chroma_ub = %u\n", __func__, k, dpte_row_width_chroma_ub[k]);
3600 dml_print("DML::%s: k=%u, dpte_group_width_chroma = %u\n", __func__, k, dpte_group_width_chroma);
3601 dml_print("DML::%s: k=%u, dpte_groups_per_row_chroma_ub = %u\n", __func__, k, dpte_groups_per_row_chroma_ub);
3602
3603 time_per_pte_group_nom_chroma[k] = DST_Y_PER_PTE_ROW_NOM_C[k] * HTotal[k] / PixelClock[k] / dpte_groups_per_row_chroma_ub;
3604 time_per_pte_group_vblank_chroma[k] = DestinationLinesToRequestRowInVBlank[k] * HTotal[k] / PixelClock[k] / dpte_groups_per_row_chroma_ub;
3605 time_per_pte_group_flip_chroma[k] = DestinationLinesToRequestRowInImmediateFlip[k] * HTotal[k] / PixelClock[k] / dpte_groups_per_row_chroma_ub;
3606 }
3607 } else {
3608 time_per_pte_group_nom_luma[k] = 0;
3609 time_per_pte_group_vblank_luma[k] = 0;
3610 time_per_pte_group_flip_luma[k] = 0;
3611 time_per_pte_group_nom_chroma[k] = 0;
3612 time_per_pte_group_vblank_chroma[k] = 0;
3613 time_per_pte_group_flip_chroma[k] = 0;
3614 }
3615 #ifdef __DML_VBA_DEBUG__
3616 dml_print("DML::%s: k=%u, DestinationLinesToRequestRowInVBlank = %f\n", __func__, k, DestinationLinesToRequestRowInVBlank[k]);
3617 dml_print("DML::%s: k=%u, DestinationLinesToRequestRowInImmediateFlip = %f\n", __func__, k, DestinationLinesToRequestRowInImmediateFlip[k]);
3618
3619 dml_print("DML::%s: k=%u, DST_Y_PER_PTE_ROW_NOM_L = %f\n", __func__, k, DST_Y_PER_PTE_ROW_NOM_L[k]);
3620 dml_print("DML::%s: k=%u, DST_Y_PER_PTE_ROW_NOM_C = %f\n", __func__, k, DST_Y_PER_PTE_ROW_NOM_C[k]);
3621 dml_print("DML::%s: k=%u, DST_Y_PER_META_ROW_NOM_L = %f\n", __func__, k, DST_Y_PER_META_ROW_NOM_L[k]);
3622 dml_print("DML::%s: k=%u, DST_Y_PER_META_ROW_NOM_C = %f\n", __func__, k, DST_Y_PER_META_ROW_NOM_C[k]);
3623 dml_print("DML::%s: k=%u, TimePerMetaChunkNominal = %f\n", __func__, k, TimePerMetaChunkNominal[k]);
3624 dml_print("DML::%s: k=%u, TimePerMetaChunkVBlank = %f\n", __func__, k, TimePerMetaChunkVBlank[k]);
3625 dml_print("DML::%s: k=%u, TimePerMetaChunkFlip = %f\n", __func__, k, TimePerMetaChunkFlip[k]);
3626 dml_print("DML::%s: k=%u, TimePerChromaMetaChunkNominal = %f\n", __func__, k, TimePerChromaMetaChunkNominal[k]);
3627 dml_print("DML::%s: k=%u, TimePerChromaMetaChunkVBlank = %f\n", __func__, k, TimePerChromaMetaChunkVBlank[k]);
3628 dml_print("DML::%s: k=%u, TimePerChromaMetaChunkFlip = %f\n", __func__, k, TimePerChromaMetaChunkFlip[k]);
3629 dml_print("DML::%s: k=%u, time_per_pte_group_nom_luma = %f\n", __func__, k, time_per_pte_group_nom_luma[k]);
3630 dml_print("DML::%s: k=%u, time_per_pte_group_vblank_luma = %f\n", __func__, k, time_per_pte_group_vblank_luma[k]);
3631 dml_print("DML::%s: k=%u, time_per_pte_group_flip_luma = %f\n", __func__, k, time_per_pte_group_flip_luma[k]);
3632 dml_print("DML::%s: k=%u, time_per_pte_group_nom_chroma = %f\n", __func__, k, time_per_pte_group_nom_chroma[k]);
3633 dml_print("DML::%s: k=%u, time_per_pte_group_vblank_chroma = %f\n", __func__, k, time_per_pte_group_vblank_chroma[k]);
3634 dml_print("DML::%s: k=%u, time_per_pte_group_flip_chroma = %f\n", __func__, k, time_per_pte_group_flip_chroma[k]);
3635 #endif
3636 }
3637 } // CalculateMetaAndPTETimes
3638
CalculateVMGroupAndRequestTimes(dml_uint_t NumberOfActiveSurfaces,dml_bool_t GPUVMEnable,dml_uint_t GPUVMMaxPageTableLevels,dml_uint_t HTotal[],dml_uint_t BytePerPixelC[],dml_float_t DestinationLinesToRequestVMInVBlank[],dml_float_t DestinationLinesToRequestVMInImmediateFlip[],dml_bool_t DCCEnable[],dml_float_t PixelClock[],dml_uint_t dpte_row_width_luma_ub[],dml_uint_t dpte_row_width_chroma_ub[],dml_uint_t vm_group_bytes[],dml_uint_t dpde0_bytes_per_frame_ub_l[],dml_uint_t dpde0_bytes_per_frame_ub_c[],dml_uint_t meta_pte_bytes_per_frame_ub_l[],dml_uint_t meta_pte_bytes_per_frame_ub_c[],dml_float_t TimePerVMGroupVBlank[],dml_float_t TimePerVMGroupFlip[],dml_float_t TimePerVMRequestVBlank[],dml_float_t TimePerVMRequestFlip[])3639 static void CalculateVMGroupAndRequestTimes(
3640 dml_uint_t NumberOfActiveSurfaces,
3641 dml_bool_t GPUVMEnable,
3642 dml_uint_t GPUVMMaxPageTableLevels,
3643 dml_uint_t HTotal[],
3644 dml_uint_t BytePerPixelC[],
3645 dml_float_t DestinationLinesToRequestVMInVBlank[],
3646 dml_float_t DestinationLinesToRequestVMInImmediateFlip[],
3647 dml_bool_t DCCEnable[],
3648 dml_float_t PixelClock[],
3649 dml_uint_t dpte_row_width_luma_ub[],
3650 dml_uint_t dpte_row_width_chroma_ub[],
3651 dml_uint_t vm_group_bytes[],
3652 dml_uint_t dpde0_bytes_per_frame_ub_l[],
3653 dml_uint_t dpde0_bytes_per_frame_ub_c[],
3654 dml_uint_t meta_pte_bytes_per_frame_ub_l[],
3655 dml_uint_t meta_pte_bytes_per_frame_ub_c[],
3656
3657 // Output
3658 dml_float_t TimePerVMGroupVBlank[],
3659 dml_float_t TimePerVMGroupFlip[],
3660 dml_float_t TimePerVMRequestVBlank[],
3661 dml_float_t TimePerVMRequestFlip[])
3662 {
3663 dml_uint_t num_group_per_lower_vm_stage;
3664 dml_uint_t num_req_per_lower_vm_stage;
3665
3666 #ifdef __DML_VBA_DEBUG__
3667 dml_print("DML::%s: NumberOfActiveSurfaces = %u\n", __func__, NumberOfActiveSurfaces);
3668 dml_print("DML::%s: GPUVMEnable = %u\n", __func__, GPUVMEnable);
3669 #endif
3670 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
3671
3672 #ifdef __DML_VBA_DEBUG__
3673 dml_print("DML::%s: k=%u, DCCEnable = %u\n", __func__, k, DCCEnable[k]);
3674 dml_print("DML::%s: k=%u, vm_group_bytes = %u\n", __func__, k, vm_group_bytes[k]);
3675 dml_print("DML::%s: k=%u, dpde0_bytes_per_frame_ub_l = %u\n", __func__, k, dpde0_bytes_per_frame_ub_l[k]);
3676 dml_print("DML::%s: k=%u, dpde0_bytes_per_frame_ub_c = %u\n", __func__, k, dpde0_bytes_per_frame_ub_c[k]);
3677 dml_print("DML::%s: k=%u, meta_pte_bytes_per_frame_ub_l = %u\n", __func__, k, meta_pte_bytes_per_frame_ub_l[k]);
3678 dml_print("DML::%s: k=%u, meta_pte_bytes_per_frame_ub_c = %u\n", __func__, k, meta_pte_bytes_per_frame_ub_c[k]);
3679 #endif
3680
3681 if (GPUVMEnable == true && (DCCEnable[k] == true || GPUVMMaxPageTableLevels > 1)) {
3682 if (DCCEnable[k] == false) {
3683 if (BytePerPixelC[k] > 0) {
3684 num_group_per_lower_vm_stage = (dml_uint_t) (dml_ceil((dml_float_t) dpde0_bytes_per_frame_ub_l[k] / (dml_float_t) vm_group_bytes[k], 1.0) +
3685 dml_ceil((dml_float_t) dpde0_bytes_per_frame_ub_c[k] / (dml_float_t) vm_group_bytes[k], 1.0));
3686 } else {
3687 num_group_per_lower_vm_stage = (dml_uint_t) (dml_ceil((dml_float_t) dpde0_bytes_per_frame_ub_l[k] / (dml_float_t) vm_group_bytes[k], 1.0));
3688 }
3689 } else {
3690 if (GPUVMMaxPageTableLevels == 1) {
3691 if (BytePerPixelC[k] > 0) {
3692 num_group_per_lower_vm_stage = (dml_uint_t)(dml_ceil((dml_float_t) (meta_pte_bytes_per_frame_ub_l[k]) / (dml_float_t) (vm_group_bytes[k]), 1.0) +
3693 dml_ceil((dml_float_t) (meta_pte_bytes_per_frame_ub_c[k]) / (dml_float_t) (vm_group_bytes[k]), 1.0));
3694 } else {
3695 num_group_per_lower_vm_stage = (dml_uint_t)(dml_ceil((dml_float_t) (meta_pte_bytes_per_frame_ub_l[k]) / (dml_float_t) (vm_group_bytes[k]), 1.0));
3696 }
3697 } else {
3698 if (BytePerPixelC[k] > 0) {
3699 num_group_per_lower_vm_stage = (dml_uint_t)(2.0 + dml_ceil((dml_float_t) (dpde0_bytes_per_frame_ub_l[k]) / (dml_float_t) (vm_group_bytes[k]), 1) +
3700 dml_ceil((dml_float_t) (dpde0_bytes_per_frame_ub_c[k]) / (dml_float_t) (vm_group_bytes[k]), 1) +
3701 dml_ceil((dml_float_t) (meta_pte_bytes_per_frame_ub_l[k]) / (dml_float_t) (vm_group_bytes[k]), 1) +
3702 dml_ceil((dml_float_t) (meta_pte_bytes_per_frame_ub_c[k]) / (dml_float_t) (vm_group_bytes[k]), 1));
3703 } else {
3704 num_group_per_lower_vm_stage = (dml_uint_t)(1.0 + dml_ceil((dml_float_t) (dpde0_bytes_per_frame_ub_l[k]) / (dml_float_t) (vm_group_bytes[k]), 1) +
3705 dml_ceil((dml_float_t) (meta_pte_bytes_per_frame_ub_l[k]) / (dml_float_t) (vm_group_bytes[k]), 1));
3706 }
3707 }
3708 }
3709
3710 if (DCCEnable[k] == false) {
3711 if (BytePerPixelC[k] > 0) {
3712 num_req_per_lower_vm_stage = dpde0_bytes_per_frame_ub_l[k] / 64 + dpde0_bytes_per_frame_ub_c[k] / 64;
3713 } else {
3714 num_req_per_lower_vm_stage = dpde0_bytes_per_frame_ub_l[k] / 64;
3715 }
3716 } else {
3717 if (GPUVMMaxPageTableLevels == 1) {
3718 if (BytePerPixelC[k] > 0) {
3719 num_req_per_lower_vm_stage = meta_pte_bytes_per_frame_ub_l[k] / 64 + meta_pte_bytes_per_frame_ub_c[k] / 64;
3720 } else {
3721 num_req_per_lower_vm_stage = meta_pte_bytes_per_frame_ub_l[k] / 64;
3722 }
3723 } else {
3724 if (BytePerPixelC[k] > 0) {
3725 num_req_per_lower_vm_stage = dpde0_bytes_per_frame_ub_l[k] / 64 + dpde0_bytes_per_frame_ub_c[k] / 64 + meta_pte_bytes_per_frame_ub_l[k] / 64 + meta_pte_bytes_per_frame_ub_c[k] / 64;
3726 } else {
3727 num_req_per_lower_vm_stage = dpde0_bytes_per_frame_ub_l[k] / 64 + meta_pte_bytes_per_frame_ub_l[k] / 64;
3728 }
3729 }
3730 }
3731
3732 TimePerVMGroupVBlank[k] = DestinationLinesToRequestVMInVBlank[k] * HTotal[k] / PixelClock[k] / num_group_per_lower_vm_stage;
3733 TimePerVMGroupFlip[k] = DestinationLinesToRequestVMInImmediateFlip[k] * HTotal[k] / PixelClock[k] / num_group_per_lower_vm_stage;
3734 TimePerVMRequestVBlank[k] = DestinationLinesToRequestVMInVBlank[k] * HTotal[k] / PixelClock[k] / num_req_per_lower_vm_stage;
3735 TimePerVMRequestFlip[k] = DestinationLinesToRequestVMInImmediateFlip[k] * HTotal[k] / PixelClock[k] / num_req_per_lower_vm_stage;
3736
3737 if (GPUVMMaxPageTableLevels > 2) {
3738 TimePerVMGroupVBlank[k] = TimePerVMGroupVBlank[k] / 2;
3739 TimePerVMGroupFlip[k] = TimePerVMGroupFlip[k] / 2;
3740 TimePerVMRequestVBlank[k] = TimePerVMRequestVBlank[k] / 2;
3741 TimePerVMRequestFlip[k] = TimePerVMRequestFlip[k] / 2;
3742 }
3743
3744 } else {
3745 TimePerVMGroupVBlank[k] = 0;
3746 TimePerVMGroupFlip[k] = 0;
3747 TimePerVMRequestVBlank[k] = 0;
3748 TimePerVMRequestFlip[k] = 0;
3749 }
3750
3751 #ifdef __DML_VBA_DEBUG__
3752 dml_print("DML::%s: k=%u, TimePerVMGroupVBlank = %f\n", __func__, k, TimePerVMGroupVBlank[k]);
3753 dml_print("DML::%s: k=%u, TimePerVMGroupFlip = %f\n", __func__, k, TimePerVMGroupFlip[k]);
3754 dml_print("DML::%s: k=%u, TimePerVMRequestVBlank = %f\n", __func__, k, TimePerVMRequestVBlank[k]);
3755 dml_print("DML::%s: k=%u, TimePerVMRequestFlip = %f\n", __func__, k, TimePerVMRequestFlip[k]);
3756 #endif
3757 }
3758 } // CalculateVMGroupAndRequestTimes
3759
CalculateStutterEfficiency(struct display_mode_lib_scratch_st * scratch,struct CalculateStutterEfficiency_params_st * p)3760 static void CalculateStutterEfficiency(struct display_mode_lib_scratch_st *scratch,
3761 struct CalculateStutterEfficiency_params_st *p)
3762 {
3763 dml_float_t DETBufferingTimeY = 0;
3764 dml_float_t SwathWidthYCriticalSurface = 0;
3765 dml_float_t SwathHeightYCriticalSurface = 0;
3766 dml_float_t VActiveTimeCriticalSurface = 0;
3767 dml_float_t FrameTimeCriticalSurface = 0;
3768 dml_uint_t BytePerPixelYCriticalSurface = 0;
3769 dml_float_t LinesToFinishSwathTransferStutterCriticalSurface = 0;
3770 dml_uint_t DETBufferSizeYCriticalSurface = 0;
3771 dml_float_t MinTTUVBlankCriticalSurface = 0;
3772 dml_uint_t BlockWidth256BytesYCriticalSurface = 0;
3773 dml_bool_t SinglePlaneCriticalSurface = 0;
3774 dml_bool_t SinglePipeCriticalSurface = 0;
3775 dml_float_t TotalCompressedReadBandwidth = 0;
3776 dml_float_t TotalRowReadBandwidth = 0;
3777 dml_float_t AverageDCCCompressionRate = 0;
3778 dml_float_t EffectiveCompressedBufferSize = 0;
3779 dml_float_t PartOfUncompressedPixelBurstThatFitsInROBAndCompressedBuffer = 0;
3780 dml_float_t StutterBurstTime = 0;
3781 dml_uint_t TotalActiveWriteback = 0;
3782 dml_float_t LinesInDETY = 0;
3783 dml_float_t LinesInDETYRoundedDownToSwath = 0;
3784 dml_float_t MaximumEffectiveCompressionLuma = 0;
3785 dml_float_t MaximumEffectiveCompressionChroma = 0;
3786 dml_float_t TotalZeroSizeRequestReadBandwidth = 0;
3787 dml_float_t TotalZeroSizeCompressedReadBandwidth = 0;
3788 dml_float_t AverageDCCZeroSizeFraction = 0;
3789 dml_float_t AverageZeroSizeCompressionRate = 0;
3790
3791 dml_bool_t FoundCriticalSurface = false;
3792
3793 dml_uint_t TotalNumberOfActiveOTG = 0;
3794 dml_float_t SinglePixelClock = 0;
3795 dml_uint_t SingleHTotal = 0;
3796 dml_uint_t SingleVTotal = 0;
3797 dml_bool_t SameTiming = true;
3798
3799 dml_float_t LastStutterPeriod = 0.0;
3800 dml_float_t LastZ8StutterPeriod = 0.0;
3801
3802 dml_uint_t SwathSizeCriticalSurface;
3803 dml_uint_t LastChunkOfSwathSize;
3804 dml_uint_t MissingPartOfLastSwathOfDETSize;
3805
3806 TotalZeroSizeRequestReadBandwidth = 0;
3807 TotalZeroSizeCompressedReadBandwidth = 0;
3808 TotalRowReadBandwidth = 0;
3809 TotalCompressedReadBandwidth = 0;
3810
3811 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
3812 if (p->UseMALLForPStateChange[k] != dml_use_mall_pstate_change_phantom_pipe) {
3813 if (p->DCCEnable[k] == true) {
3814 if ((dml_is_vertical_rotation(p->SourceScan[k]) && p->BlockWidth256BytesY[k] > p->SwathHeightY[k]) || (!dml_is_vertical_rotation(p->SourceScan[k]) && p->BlockHeight256BytesY[k] > p->SwathHeightY[k]) || p->DCCYMaxUncompressedBlock[k] < 256) {
3815 MaximumEffectiveCompressionLuma = 2;
3816 } else {
3817 MaximumEffectiveCompressionLuma = 4;
3818 }
3819 TotalCompressedReadBandwidth = TotalCompressedReadBandwidth + p->ReadBandwidthSurfaceLuma[k] / dml_min(p->NetDCCRateLuma[k], MaximumEffectiveCompressionLuma);
3820 #ifdef __DML_VBA_DEBUG__
3821 dml_print("DML::%s: k=%u, ReadBandwidthSurfaceLuma = %f\n", __func__, k, p->ReadBandwidthSurfaceLuma[k]);
3822 dml_print("DML::%s: k=%u, NetDCCRateLuma = %f\n", __func__, k, p->NetDCCRateLuma[k]);
3823 dml_print("DML::%s: k=%u, MaximumEffectiveCompressionLuma = %f\n", __func__, k, MaximumEffectiveCompressionLuma);
3824 #endif
3825 TotalZeroSizeRequestReadBandwidth = TotalZeroSizeRequestReadBandwidth + p->ReadBandwidthSurfaceLuma[k] * p->DCCFractionOfZeroSizeRequestsLuma[k];
3826 TotalZeroSizeCompressedReadBandwidth = TotalZeroSizeCompressedReadBandwidth + p->ReadBandwidthSurfaceLuma[k] * p->DCCFractionOfZeroSizeRequestsLuma[k] / MaximumEffectiveCompressionLuma;
3827
3828 if (p->ReadBandwidthSurfaceChroma[k] > 0) {
3829 if ((dml_is_vertical_rotation(p->SourceScan[k]) && p->BlockWidth256BytesC[k] > p->SwathHeightC[k]) || (!dml_is_vertical_rotation(p->SourceScan[k]) && p->BlockHeight256BytesC[k] > p->SwathHeightC[k]) || p->DCCCMaxUncompressedBlock[k] < 256) {
3830 MaximumEffectiveCompressionChroma = 2;
3831 } else {
3832 MaximumEffectiveCompressionChroma = 4;
3833 }
3834 TotalCompressedReadBandwidth = TotalCompressedReadBandwidth + p->ReadBandwidthSurfaceChroma[k] / dml_min(p->NetDCCRateChroma[k], MaximumEffectiveCompressionChroma);
3835 #ifdef __DML_VBA_DEBUG__
3836 dml_print("DML::%s: k=%u, ReadBandwidthSurfaceChroma = %f\n", __func__, k, p->ReadBandwidthSurfaceChroma[k]);
3837 dml_print("DML::%s: k=%u, NetDCCRateChroma = %f\n", __func__, k, p->NetDCCRateChroma[k]);
3838 dml_print("DML::%s: k=%u, MaximumEffectiveCompressionChroma = %f\n", __func__, k, MaximumEffectiveCompressionChroma);
3839 #endif
3840 TotalZeroSizeRequestReadBandwidth = TotalZeroSizeRequestReadBandwidth + p->ReadBandwidthSurfaceChroma[k] * p->DCCFractionOfZeroSizeRequestsChroma[k];
3841 TotalZeroSizeCompressedReadBandwidth = TotalZeroSizeCompressedReadBandwidth + p->ReadBandwidthSurfaceChroma[k] * p->DCCFractionOfZeroSizeRequestsChroma[k] / MaximumEffectiveCompressionChroma;
3842 }
3843 } else {
3844 TotalCompressedReadBandwidth = TotalCompressedReadBandwidth + p->ReadBandwidthSurfaceLuma[k] + p->ReadBandwidthSurfaceChroma[k];
3845 }
3846 TotalRowReadBandwidth = TotalRowReadBandwidth + p->DPPPerSurface[k] * (p->meta_row_bw[k] + p->dpte_row_bw[k]);
3847 }
3848 }
3849
3850 AverageDCCCompressionRate = p->TotalDataReadBandwidth / TotalCompressedReadBandwidth;
3851 AverageDCCZeroSizeFraction = TotalZeroSizeRequestReadBandwidth / p->TotalDataReadBandwidth;
3852
3853 #ifdef __DML_VBA_DEBUG__
3854 dml_print("DML::%s: UnboundedRequestEnabled = %u\n", __func__, p->UnboundedRequestEnabled);
3855 dml_print("DML::%s: TotalCompressedReadBandwidth = %f\n", __func__, TotalCompressedReadBandwidth);
3856 dml_print("DML::%s: TotalZeroSizeRequestReadBandwidth = %f\n", __func__, TotalZeroSizeRequestReadBandwidth);
3857 dml_print("DML::%s: TotalZeroSizeCompressedReadBandwidth = %f\n", __func__, TotalZeroSizeCompressedReadBandwidth);
3858 dml_print("DML::%s: MaximumEffectiveCompressionLuma = %f\n", __func__, MaximumEffectiveCompressionLuma);
3859 dml_print("DML::%s: MaximumEffectiveCompressionChroma = %f\n", __func__, MaximumEffectiveCompressionChroma);
3860 dml_print("DML::%s: AverageDCCCompressionRate = %f\n", __func__, AverageDCCCompressionRate);
3861 dml_print("DML::%s: AverageDCCZeroSizeFraction = %f\n", __func__, AverageDCCZeroSizeFraction);
3862 dml_print("DML::%s: CompbufReservedSpace64B = %u\n", __func__, p->CompbufReservedSpace64B);
3863 dml_print("DML::%s: CompbufReservedSpaceZs = %u\n", __func__, p->CompbufReservedSpaceZs);
3864 dml_print("DML::%s: CompressedBufferSizeInkByte = %u\n", __func__, p->CompressedBufferSizeInkByte);
3865 #endif
3866 if (AverageDCCZeroSizeFraction == 1) {
3867 AverageZeroSizeCompressionRate = TotalZeroSizeRequestReadBandwidth / TotalZeroSizeCompressedReadBandwidth;
3868 EffectiveCompressedBufferSize = (dml_float_t)p->MetaFIFOSizeInKEntries * 1024 * 64 * AverageZeroSizeCompressionRate + ((dml_float_t)p->ZeroSizeBufferEntries - p->CompbufReservedSpaceZs) * 64 * AverageZeroSizeCompressionRate;
3869 } else if (AverageDCCZeroSizeFraction > 0) {
3870 AverageZeroSizeCompressionRate = TotalZeroSizeRequestReadBandwidth / TotalZeroSizeCompressedReadBandwidth;
3871 EffectiveCompressedBufferSize = dml_min((dml_float_t)p->CompressedBufferSizeInkByte * 1024 * AverageDCCCompressionRate,
3872 (dml_float_t)p->MetaFIFOSizeInKEntries * 1024 * 64 / (AverageDCCZeroSizeFraction / AverageZeroSizeCompressionRate + 1 / AverageDCCCompressionRate)) +
3873 dml_min(((dml_float_t)p->ROBBufferSizeInKByte * 1024 - p->CompbufReservedSpace64B * 64) * AverageDCCCompressionRate,
3874 ((dml_float_t)p->ZeroSizeBufferEntries - p->CompbufReservedSpaceZs) * 64 / (AverageDCCZeroSizeFraction / AverageZeroSizeCompressionRate));
3875
3876 #ifdef __DML_VBA_DEBUG__
3877 dml_print("DML::%s: min 1 = %f\n", __func__, p->CompressedBufferSizeInkByte * 1024 * AverageDCCCompressionRate);
3878 dml_print("DML::%s: min 2 = %f\n", __func__, p->MetaFIFOSizeInKEntries * 1024 * 64 / (AverageDCCZeroSizeFraction / AverageZeroSizeCompressionRate + 1 / AverageDCCCompressionRate));
3879 dml_print("DML::%s: min 3 = %f\n", __func__, (p->ROBBufferSizeInKByte * 1024 - p->CompbufReservedSpace64B * 64) * AverageDCCCompressionRate);
3880 dml_print("DML::%s: min 4 = %f\n", __func__, (p->ZeroSizeBufferEntries - p->CompbufReservedSpaceZs) * 64 / (AverageDCCZeroSizeFraction / AverageZeroSizeCompressionRate));
3881 #endif
3882 } else {
3883 EffectiveCompressedBufferSize = dml_min((dml_float_t)p->CompressedBufferSizeInkByte * 1024 * AverageDCCCompressionRate,
3884 (dml_float_t)p->MetaFIFOSizeInKEntries * 1024 * 64 * AverageDCCCompressionRate) +
3885 ((dml_float_t)p->ROBBufferSizeInKByte * 1024 - p->CompbufReservedSpace64B * 64) * AverageDCCCompressionRate;
3886
3887 #ifdef __DML_VBA_DEBUG__
3888 dml_print("DML::%s: min 1 = %f\n", __func__, p->CompressedBufferSizeInkByte * 1024 * AverageDCCCompressionRate);
3889 dml_print("DML::%s: min 2 = %f\n", __func__, p->MetaFIFOSizeInKEntries * 1024 * 64 * AverageDCCCompressionRate);
3890 #endif
3891 }
3892
3893 #ifdef __DML_VBA_DEBUG__
3894 dml_print("DML::%s: MetaFIFOSizeInKEntries = %u\n", __func__, p->MetaFIFOSizeInKEntries);
3895 dml_print("DML::%s: AverageZeroSizeCompressionRate = %f\n", __func__, AverageZeroSizeCompressionRate);
3896 dml_print("DML::%s: EffectiveCompressedBufferSize = %f\n", __func__, EffectiveCompressedBufferSize);
3897 #endif
3898
3899 *p->StutterPeriod = 0;
3900
3901 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
3902 if (p->UseMALLForPStateChange[k] != dml_use_mall_pstate_change_phantom_pipe) {
3903 LinesInDETY = ((dml_float_t)p->DETBufferSizeY[k] + (p->UnboundedRequestEnabled == true ? EffectiveCompressedBufferSize : 0) * p->ReadBandwidthSurfaceLuma[k] / p->TotalDataReadBandwidth) / p->BytePerPixelDETY[k] / p->SwathWidthY[k];
3904 LinesInDETYRoundedDownToSwath = dml_floor(LinesInDETY, p->SwathHeightY[k]);
3905 DETBufferingTimeY = LinesInDETYRoundedDownToSwath * ((dml_float_t)p->HTotal[k] / p->PixelClock[k]) / p->VRatio[k];
3906 #ifdef __DML_VBA_DEBUG__
3907 dml_print("DML::%s: k=%u, DETBufferSizeY = %u\n", __func__, k, p->DETBufferSizeY[k]);
3908 dml_print("DML::%s: k=%u, BytePerPixelDETY = %f\n", __func__, k, p->BytePerPixelDETY[k]);
3909 dml_print("DML::%s: k=%u, SwathWidthY = %u\n", __func__, k, p->SwathWidthY[k]);
3910 dml_print("DML::%s: k=%u, ReadBandwidthSurfaceLuma = %f\n", __func__, k, p->ReadBandwidthSurfaceLuma[k]);
3911 dml_print("DML::%s: k=%u, TotalDataReadBandwidth = %f\n", __func__, k, p->TotalDataReadBandwidth);
3912 dml_print("DML::%s: k=%u, LinesInDETY = %f\n", __func__, k, LinesInDETY);
3913 dml_print("DML::%s: k=%u, LinesInDETYRoundedDownToSwath = %f\n", __func__, k, LinesInDETYRoundedDownToSwath);
3914 dml_print("DML::%s: k=%u, HTotal = %u\n", __func__, k, p->HTotal[k]);
3915 dml_print("DML::%s: k=%u, PixelClock = %f\n", __func__, k, p->PixelClock[k]);
3916 dml_print("DML::%s: k=%u, VRatio = %f\n", __func__, k, p->VRatio[k]);
3917 dml_print("DML::%s: k=%u, DETBufferingTimeY = %f\n", __func__, k, DETBufferingTimeY);
3918 dml_print("DML::%s: k=%u,PixelClock = %f\n", __func__, k, p->PixelClock[k]);
3919 #endif
3920
3921 if (!FoundCriticalSurface || DETBufferingTimeY < *p->StutterPeriod) {
3922 dml_bool_t isInterlaceTiming = p->Interlace[k] && !p->ProgressiveToInterlaceUnitInOPP;
3923
3924 FoundCriticalSurface = true;
3925 *p->StutterPeriod = DETBufferingTimeY;
3926 FrameTimeCriticalSurface = (isInterlaceTiming ? dml_floor((dml_float_t)p->VTotal[k]/2.0, 1.0) : p->VTotal[k]) * (dml_float_t)p->HTotal[k] / p->PixelClock[k];
3927 VActiveTimeCriticalSurface = (isInterlaceTiming ? dml_floor((dml_float_t)p->VActive[k]/2.0, 1.0) : p->VActive[k]) * (dml_float_t)p->HTotal[k] / p->PixelClock[k];
3928 BytePerPixelYCriticalSurface = p->BytePerPixelY[k];
3929 SwathWidthYCriticalSurface = p->SwathWidthY[k];
3930 SwathHeightYCriticalSurface = p->SwathHeightY[k];
3931 BlockWidth256BytesYCriticalSurface = p->BlockWidth256BytesY[k];
3932 LinesToFinishSwathTransferStutterCriticalSurface = p->SwathHeightY[k] - (LinesInDETY - LinesInDETYRoundedDownToSwath);
3933 DETBufferSizeYCriticalSurface = p->DETBufferSizeY[k];
3934 MinTTUVBlankCriticalSurface = p->MinTTUVBlank[k];
3935 SinglePlaneCriticalSurface = (p->ReadBandwidthSurfaceChroma[k] == 0);
3936 SinglePipeCriticalSurface = (p->DPPPerSurface[k] == 1);
3937
3938 #ifdef __DML_VBA_DEBUG__
3939 dml_print("DML::%s: k=%u, FoundCriticalSurface = %u\n", __func__, k, FoundCriticalSurface);
3940 dml_print("DML::%s: k=%u, StutterPeriod = %f\n", __func__, k, *p->StutterPeriod);
3941 dml_print("DML::%s: k=%u, MinTTUVBlankCriticalSurface = %f\n", __func__, k, MinTTUVBlankCriticalSurface);
3942 dml_print("DML::%s: k=%u, FrameTimeCriticalSurface = %f\n", __func__, k, FrameTimeCriticalSurface);
3943 dml_print("DML::%s: k=%u, VActiveTimeCriticalSurface = %f\n", __func__, k, VActiveTimeCriticalSurface);
3944 dml_print("DML::%s: k=%u, BytePerPixelYCriticalSurface = %u\n", __func__, k, BytePerPixelYCriticalSurface);
3945 dml_print("DML::%s: k=%u, SwathWidthYCriticalSurface = %f\n", __func__, k, SwathWidthYCriticalSurface);
3946 dml_print("DML::%s: k=%u, SwathHeightYCriticalSurface = %f\n", __func__, k, SwathHeightYCriticalSurface);
3947 dml_print("DML::%s: k=%u, BlockWidth256BytesYCriticalSurface = %u\n", __func__, k, BlockWidth256BytesYCriticalSurface);
3948 dml_print("DML::%s: k=%u, SinglePlaneCriticalSurface = %u\n", __func__, k, SinglePlaneCriticalSurface);
3949 dml_print("DML::%s: k=%u, SinglePipeCriticalSurface = %u\n", __func__, k, SinglePipeCriticalSurface);
3950 dml_print("DML::%s: k=%u, LinesToFinishSwathTransferStutterCriticalSurface = %f\n", __func__, k, LinesToFinishSwathTransferStutterCriticalSurface);
3951 #endif
3952 }
3953 }
3954 }
3955
3956 PartOfUncompressedPixelBurstThatFitsInROBAndCompressedBuffer = dml_min(*p->StutterPeriod * p->TotalDataReadBandwidth, EffectiveCompressedBufferSize);
3957 #ifdef __DML_VBA_DEBUG__
3958 dml_print("DML::%s: ROBBufferSizeInKByte = %u\n", __func__, p->ROBBufferSizeInKByte);
3959 dml_print("DML::%s: AverageDCCCompressionRate = %f\n", __func__, AverageDCCCompressionRate);
3960 dml_print("DML::%s: StutterPeriod * TotalDataReadBandwidth = %f\n", __func__, *p->StutterPeriod * p->TotalDataReadBandwidth);
3961 dml_print("DML::%s: ROBBufferSizeInKByte * 1024 * AverageDCCCompressionRate + EffectiveCompressedBufferSize = %f\n", __func__, p->ROBBufferSizeInKByte * 1024 * AverageDCCCompressionRate + EffectiveCompressedBufferSize);
3962 dml_print("DML::%s: EffectiveCompressedBufferSize = %f\n", __func__, EffectiveCompressedBufferSize);
3963 dml_print("DML::%s: PartOfUncompressedPixelBurstThatFitsInROBAndCompressedBuffer = %f\n", __func__, PartOfUncompressedPixelBurstThatFitsInROBAndCompressedBuffer);
3964 dml_print("DML::%s: ReturnBW = %f\n", __func__, p->ReturnBW);
3965 dml_print("DML::%s: TotalDataReadBandwidth = %f\n", __func__, p->TotalDataReadBandwidth);
3966 dml_print("DML::%s: TotalRowReadBandwidth = %f\n", __func__, TotalRowReadBandwidth);
3967 dml_print("DML::%s: DCFCLK = %f\n", __func__, p->DCFCLK);
3968 #endif
3969
3970 StutterBurstTime = PartOfUncompressedPixelBurstThatFitsInROBAndCompressedBuffer / AverageDCCCompressionRate / p->ReturnBW + (*p->StutterPeriod * p->TotalDataReadBandwidth - PartOfUncompressedPixelBurstThatFitsInROBAndCompressedBuffer) / (p->DCFCLK * 64) + *p->StutterPeriod * TotalRowReadBandwidth / p->ReturnBW;
3971 #ifdef __DML_VBA_DEBUG__
3972 dml_print("DML::%s: Part 1 = %f\n", __func__, PartOfUncompressedPixelBurstThatFitsInROBAndCompressedBuffer / AverageDCCCompressionRate / p->ReturnBW);
3973 dml_print("DML::%s: StutterPeriod * TotalDataReadBandwidth = %f\n", __func__, (*p->StutterPeriod * p->TotalDataReadBandwidth));
3974 dml_print("DML::%s: Part 2 = %f\n", __func__, (*p->StutterPeriod * p->TotalDataReadBandwidth - PartOfUncompressedPixelBurstThatFitsInROBAndCompressedBuffer) / (p->DCFCLK * 64));
3975 dml_print("DML::%s: Part 3 = %f\n", __func__, *p->StutterPeriod * TotalRowReadBandwidth / p->ReturnBW);
3976 dml_print("DML::%s: StutterBurstTime = %f\n", __func__, StutterBurstTime);
3977 #endif
3978 StutterBurstTime = dml_max(StutterBurstTime, LinesToFinishSwathTransferStutterCriticalSurface * BytePerPixelYCriticalSurface * SwathWidthYCriticalSurface / p->ReturnBW);
3979
3980 dml_print("DML::%s: Time to finish residue swath=%f\n", __func__, LinesToFinishSwathTransferStutterCriticalSurface * BytePerPixelYCriticalSurface * SwathWidthYCriticalSurface / p->ReturnBW);
3981
3982 TotalActiveWriteback = 0;
3983 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
3984 if (p->WritebackEnable[k]) {
3985 TotalActiveWriteback = TotalActiveWriteback + 1;
3986 }
3987 }
3988
3989 if (TotalActiveWriteback == 0) {
3990 #ifdef __DML_VBA_DEBUG__
3991 dml_print("DML::%s: SRExitTime = %f\n", __func__, p->SRExitTime);
3992 dml_print("DML::%s: SRExitZ8Time = %f\n", __func__, p->SRExitZ8Time);
3993 dml_print("DML::%s: StutterBurstTime = %f (final)\n", __func__, StutterBurstTime);
3994 dml_print("DML::%s: StutterPeriod = %f\n", __func__, *p->StutterPeriod);
3995 #endif
3996 *p->StutterEfficiencyNotIncludingVBlank = dml_max(0., 1 - (p->SRExitTime + StutterBurstTime) / *p->StutterPeriod) * 100;
3997 *p->Z8StutterEfficiencyNotIncludingVBlank = dml_max(0., 1 - (p->SRExitZ8Time + StutterBurstTime) / *p->StutterPeriod) * 100;
3998 *p->NumberOfStutterBurstsPerFrame = (*p->StutterEfficiencyNotIncludingVBlank > 0 ? (dml_uint_t)(dml_ceil(VActiveTimeCriticalSurface / *p->StutterPeriod, 1)) : 0);
3999 *p->Z8NumberOfStutterBurstsPerFrame = (*p->Z8StutterEfficiencyNotIncludingVBlank > 0 ? (dml_uint_t)(dml_ceil(VActiveTimeCriticalSurface / *p->StutterPeriod, 1)) : 0);
4000 } else {
4001 *p->StutterEfficiencyNotIncludingVBlank = 0.;
4002 *p->Z8StutterEfficiencyNotIncludingVBlank = 0.;
4003 *p->NumberOfStutterBurstsPerFrame = 0;
4004 *p->Z8NumberOfStutterBurstsPerFrame = 0;
4005 }
4006 #ifdef __DML_VBA_DEBUG__
4007 dml_print("DML::%s: VActiveTimeCriticalSurface = %f\n", __func__, VActiveTimeCriticalSurface);
4008 dml_print("DML::%s: StutterEfficiencyNotIncludingVBlank = %f\n", __func__, *p->StutterEfficiencyNotIncludingVBlank);
4009 dml_print("DML::%s: Z8StutterEfficiencyNotIncludingVBlank = %f\n", __func__, *p->Z8StutterEfficiencyNotIncludingVBlank);
4010 dml_print("DML::%s: NumberOfStutterBurstsPerFrame = %u\n", __func__, *p->NumberOfStutterBurstsPerFrame);
4011 dml_print("DML::%s: Z8NumberOfStutterBurstsPerFrame = %u\n", __func__, *p->Z8NumberOfStutterBurstsPerFrame);
4012 #endif
4013
4014 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
4015 if (p->UseMALLForPStateChange[k] != dml_use_mall_pstate_change_phantom_pipe) {
4016 if (p->BlendingAndTiming[k] == k) {
4017 if (TotalNumberOfActiveOTG == 0) {
4018 SinglePixelClock = p->PixelClock[k];
4019 SingleHTotal = p->HTotal[k];
4020 SingleVTotal = p->VTotal[k];
4021 } else if (SinglePixelClock != p->PixelClock[k] || SingleHTotal != p->HTotal[k] || SingleVTotal != p->VTotal[k]) {
4022 SameTiming = false;
4023 }
4024 TotalNumberOfActiveOTG = TotalNumberOfActiveOTG + 1;
4025 }
4026 }
4027 }
4028
4029 if (*p->StutterEfficiencyNotIncludingVBlank > 0) {
4030 LastStutterPeriod = VActiveTimeCriticalSurface - (*p->NumberOfStutterBurstsPerFrame - 1) * *p->StutterPeriod;
4031
4032 if ((p->SynchronizeTimingsFinal || TotalNumberOfActiveOTG == 1) && SameTiming &&
4033 LastStutterPeriod + MinTTUVBlankCriticalSurface > p->StutterEnterPlusExitWatermark) {
4034 *p->StutterEfficiency = (1 - (*p->NumberOfStutterBurstsPerFrame * p->SRExitTime + StutterBurstTime * VActiveTimeCriticalSurface / *p->StutterPeriod) / FrameTimeCriticalSurface) * 100;
4035 } else {
4036 *p->StutterEfficiency = *p->StutterEfficiencyNotIncludingVBlank;
4037 }
4038 } else {
4039 *p->StutterEfficiency = 0;
4040 }
4041
4042 if (*p->Z8StutterEfficiencyNotIncludingVBlank > 0) {
4043 LastZ8StutterPeriod = VActiveTimeCriticalSurface - (*p->NumberOfStutterBurstsPerFrame - 1) * *p->StutterPeriod;
4044 if ((p->SynchronizeTimingsFinal || TotalNumberOfActiveOTG == 1) && SameTiming && LastZ8StutterPeriod + MinTTUVBlankCriticalSurface > p->Z8StutterEnterPlusExitWatermark) {
4045 *p->Z8StutterEfficiency = (1 - (*p->NumberOfStutterBurstsPerFrame * p->SRExitZ8Time + StutterBurstTime * VActiveTimeCriticalSurface / *p->StutterPeriod) / FrameTimeCriticalSurface) * 100;
4046 } else {
4047 *p->Z8StutterEfficiency = *p->Z8StutterEfficiencyNotIncludingVBlank;
4048 }
4049 } else {
4050 *p->Z8StutterEfficiency = 0.;
4051 }
4052
4053 #ifdef __DML_VBA_DEBUG__
4054 dml_print("DML::%s: LastZ8StutterPeriod = %f\n", __func__, LastZ8StutterPeriod);
4055 dml_print("DML::%s: Z8StutterEnterPlusExitWatermark = %f\n", __func__, p->Z8StutterEnterPlusExitWatermark);
4056 dml_print("DML::%s: StutterBurstTime = %f\n", __func__, StutterBurstTime);
4057 dml_print("DML::%s: StutterPeriod = %f\n", __func__, *p->StutterPeriod);
4058 dml_print("DML::%s: StutterEfficiency = %f\n", __func__, *p->StutterEfficiency);
4059 dml_print("DML::%s: Z8StutterEfficiency = %f\n", __func__, *p->Z8StutterEfficiency);
4060 dml_print("DML::%s: StutterEfficiencyNotIncludingVBlank = %f\n", __func__, *p->StutterEfficiencyNotIncludingVBlank);
4061 dml_print("DML::%s: Z8NumberOfStutterBurstsPerFrame = %u\n", __func__, *p->Z8NumberOfStutterBurstsPerFrame);
4062 #endif
4063
4064 SwathSizeCriticalSurface = (dml_uint_t)(BytePerPixelYCriticalSurface * SwathHeightYCriticalSurface * dml_ceil(SwathWidthYCriticalSurface, BlockWidth256BytesYCriticalSurface));
4065 LastChunkOfSwathSize = SwathSizeCriticalSurface % (p->PixelChunkSizeInKByte * 1024);
4066 MissingPartOfLastSwathOfDETSize = (dml_uint_t)(dml_ceil(DETBufferSizeYCriticalSurface, SwathSizeCriticalSurface) - DETBufferSizeYCriticalSurface);
4067
4068 *p->DCHUBBUB_ARB_CSTATE_MAX_CAP_MODE = !(!p->UnboundedRequestEnabled && (p->NumberOfActiveSurfaces == 1) && SinglePlaneCriticalSurface && SinglePipeCriticalSurface && (LastChunkOfSwathSize > 0) &&
4069 (LastChunkOfSwathSize <= 4096) && (MissingPartOfLastSwathOfDETSize > 0) && (MissingPartOfLastSwathOfDETSize <= LastChunkOfSwathSize));
4070
4071 #ifdef __DML_VBA_DEBUG__
4072 dml_print("DML::%s: SwathSizeCriticalSurface = %u\n", __func__, SwathSizeCriticalSurface);
4073 dml_print("DML::%s: DETBufferSizeYCriticalSurface = %u\n", __func__, DETBufferSizeYCriticalSurface);
4074 dml_print("DML::%s: PixelChunkSizeInKByte = %u\n", __func__, p->PixelChunkSizeInKByte);
4075 dml_print("DML::%s: LastChunkOfSwathSize = %u\n", __func__, LastChunkOfSwathSize);
4076 dml_print("DML::%s: MissingPartOfLastSwathOfDETSize = %u\n", __func__, MissingPartOfLastSwathOfDETSize);
4077 dml_print("DML::%s: DCHUBBUB_ARB_CSTATE_MAX_CAP_MODE = %u\n", __func__, *p->DCHUBBUB_ARB_CSTATE_MAX_CAP_MODE);
4078 #endif
4079 } // CalculateStutterEfficiency
4080
4081 /// \CalculateSwathAndDETConfiguration
4082 /// @brief Calculates swath width and different return buffers sizing (DET, CDB, etc.)
CalculateSwathAndDETConfiguration(struct display_mode_lib_scratch_st * scratch,struct CalculateSwathAndDETConfiguration_params_st * p)4083 static void CalculateSwathAndDETConfiguration(struct display_mode_lib_scratch_st *scratch,
4084 struct CalculateSwathAndDETConfiguration_params_st *p)
4085 {
4086 dml_uint_t MaximumSwathHeightY[__DML_NUM_PLANES__];
4087 dml_uint_t MaximumSwathHeightC[__DML_NUM_PLANES__];
4088 dml_uint_t RoundedUpMaxSwathSizeBytesY[__DML_NUM_PLANES__];
4089 dml_uint_t RoundedUpMaxSwathSizeBytesC[__DML_NUM_PLANES__];
4090 dml_uint_t RoundedUpSwathSizeBytesY[__DML_NUM_PLANES__];
4091 dml_uint_t RoundedUpSwathSizeBytesC[__DML_NUM_PLANES__];
4092 dml_uint_t SwathWidthSingleDPP[__DML_NUM_PLANES__];
4093 dml_uint_t SwathWidthSingleDPPChroma[__DML_NUM_PLANES__];
4094
4095 dml_uint_t TotalActiveDPP = 0;
4096 dml_bool_t NoChromaOrLinearSurfaces = true;
4097 dml_uint_t SurfaceDoingUnboundedRequest = 0;
4098
4099 dml_uint_t DETBufferSizeInKByteForSwathCalculation;
4100
4101 const long TTUFIFODEPTH = 8;
4102 const long MAXIMUMCOMPRESSION = 4;
4103
4104 #ifdef __DML_VBA_DEBUG__
4105 dml_print("DML::%s: ForceSingleDPP = %u\n", __func__, p->ForceSingleDPP);
4106 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
4107 dml_print("DML::%s: DPPPerSurface[%u] = %u\n", __func__, k, p->DPPPerSurface[k]);
4108 }
4109 #endif
4110 CalculateSwathWidth(p->ForceSingleDPP,
4111 p->NumberOfActiveSurfaces,
4112 p->SourcePixelFormat,
4113 p->SourceScan,
4114 p->ViewportStationary,
4115 p->ViewportWidth,
4116 p->ViewportHeight,
4117 p->ViewportXStart,
4118 p->ViewportYStart,
4119 p->ViewportXStartC,
4120 p->ViewportYStartC,
4121 p->SurfaceWidthY,
4122 p->SurfaceWidthC,
4123 p->SurfaceHeightY,
4124 p->SurfaceHeightC,
4125 p->ODMMode,
4126 p->BytePerPixY,
4127 p->BytePerPixC,
4128 p->Read256BytesBlockHeightY,
4129 p->Read256BytesBlockHeightC,
4130 p->Read256BytesBlockWidthY,
4131 p->Read256BytesBlockWidthC,
4132 p->BlendingAndTiming,
4133 p->HActive,
4134 p->HRatio,
4135 p->DPPPerSurface,
4136
4137 // Output
4138 SwathWidthSingleDPP,
4139 SwathWidthSingleDPPChroma,
4140 p->SwathWidth,
4141 p->SwathWidthChroma,
4142 MaximumSwathHeightY,
4143 MaximumSwathHeightC,
4144 p->swath_width_luma_ub,
4145 p->swath_width_chroma_ub);
4146
4147 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
4148 RoundedUpMaxSwathSizeBytesY[k] = (dml_uint_t)(p->swath_width_luma_ub[k] * p->BytePerPixDETY[k] * MaximumSwathHeightY[k]);
4149 RoundedUpMaxSwathSizeBytesC[k] = (dml_uint_t)(p->swath_width_chroma_ub[k] * p->BytePerPixDETC[k] * MaximumSwathHeightC[k]);
4150 #ifdef __DML_VBA_DEBUG__
4151 dml_print("DML::%s: k=%u DPPPerSurface = %u\n", __func__, k, p->DPPPerSurface[k]);
4152 dml_print("DML::%s: k=%u swath_width_luma_ub = %u\n", __func__, k, p->swath_width_luma_ub[k]);
4153 dml_print("DML::%s: k=%u BytePerPixDETY = %f\n", __func__, k, p->BytePerPixDETY[k]);
4154 dml_print("DML::%s: k=%u MaximumSwathHeightY = %u\n", __func__, k, MaximumSwathHeightY[k]);
4155 dml_print("DML::%s: k=%u RoundedUpMaxSwathSizeBytesY = %u\n", __func__, k, RoundedUpMaxSwathSizeBytesY[k]);
4156 dml_print("DML::%s: k=%u swath_width_chroma_ub = %u\n", __func__, k, p->swath_width_chroma_ub[k]);
4157 dml_print("DML::%s: k=%u BytePerPixDETC = %f\n", __func__, k, p->BytePerPixDETC[k]);
4158 dml_print("DML::%s: k=%u MaximumSwathHeightC = %u\n", __func__, k, MaximumSwathHeightC[k]);
4159 dml_print("DML::%s: k=%u RoundedUpMaxSwathSizeBytesC = %u\n", __func__, k, RoundedUpMaxSwathSizeBytesC[k]);
4160 #endif
4161 if (p->SourcePixelFormat[k] == dml_420_10) {
4162 RoundedUpMaxSwathSizeBytesY[k] = (dml_uint_t)(dml_ceil((dml_float_t) RoundedUpMaxSwathSizeBytesY[k], 256));
4163 RoundedUpMaxSwathSizeBytesC[k] = (dml_uint_t)(dml_ceil((dml_float_t) RoundedUpMaxSwathSizeBytesC[k], 256));
4164 }
4165 }
4166
4167 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
4168 TotalActiveDPP = TotalActiveDPP + (p->ForceSingleDPP ? 1 : p->DPPPerSurface[k]);
4169 if (p->DPPPerSurface[k] > 0)
4170 SurfaceDoingUnboundedRequest = k;
4171 if (p->SourcePixelFormat[k] == dml_420_8 || p->SourcePixelFormat[k] == dml_420_10 ||
4172 p->SourcePixelFormat[k] == dml_420_12 || p->SourcePixelFormat[k] == dml_rgbe_alpha
4173 || p->SurfaceTiling[k] == dml_sw_linear) {
4174 NoChromaOrLinearSurfaces = false;
4175 }
4176 }
4177
4178 *p->UnboundedRequestEnabled = UnboundedRequest(p->UseUnboundedRequestingFinal, TotalActiveDPP,
4179 NoChromaOrLinearSurfaces, p->Output[0]);
4180
4181 CalculateDETBufferSize(p->DETSizeOverride,
4182 p->UseMALLForPStateChange,
4183 p->ForceSingleDPP,
4184 p->NumberOfActiveSurfaces,
4185 *p->UnboundedRequestEnabled,
4186 p->nomDETInKByte,
4187 p->MaxTotalDETInKByte,
4188 p->ConfigReturnBufferSizeInKByte,
4189 p->MinCompressedBufferSizeInKByte,
4190 p->ConfigReturnBufferSegmentSizeInkByte,
4191 p->CompressedBufferSegmentSizeInkByteFinal,
4192 p->SourcePixelFormat,
4193 p->ReadBandwidthLuma,
4194 p->ReadBandwidthChroma,
4195 RoundedUpMaxSwathSizeBytesY,
4196 RoundedUpMaxSwathSizeBytesC,
4197 p->DPPPerSurface,
4198
4199 // Output
4200 p->DETBufferSizeInKByte, // per hubp pipe
4201 p->CompressedBufferSizeInkByte);
4202
4203 #ifdef __DML_VBA_DEBUG__
4204 dml_print("DML::%s: TotalActiveDPP = %u\n", __func__, TotalActiveDPP);
4205 dml_print("DML::%s: nomDETInKByte = %u\n", __func__, p->nomDETInKByte);
4206 dml_print("DML::%s: ConfigReturnBufferSizeInKByte = %u\n", __func__, p->ConfigReturnBufferSizeInKByte);
4207 dml_print("DML::%s: UseUnboundedRequestingFinal = %u\n", __func__, p->UseUnboundedRequestingFinal);
4208 dml_print("DML::%s: UnboundedRequestEnabled = %u\n", __func__, *p->UnboundedRequestEnabled);
4209 dml_print("DML::%s: CompressedBufferSizeInkByte = %u\n", __func__, *p->CompressedBufferSizeInkByte);
4210 #endif
4211
4212 *p->ViewportSizeSupport = true;
4213 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
4214
4215 DETBufferSizeInKByteForSwathCalculation = (p->UseMALLForPStateChange[k] == dml_use_mall_pstate_change_phantom_pipe ? 1024 : p->DETBufferSizeInKByte[k]);
4216 #ifdef __DML_VBA_DEBUG__
4217 dml_print("DML::%s: k=%u DETBufferSizeInKByteForSwathCalculation = %u\n", __func__, k, DETBufferSizeInKByteForSwathCalculation);
4218 #endif
4219
4220 if (RoundedUpMaxSwathSizeBytesY[k] + RoundedUpMaxSwathSizeBytesC[k] <= DETBufferSizeInKByteForSwathCalculation * 1024 / 2) {
4221 p->SwathHeightY[k] = MaximumSwathHeightY[k];
4222 p->SwathHeightC[k] = MaximumSwathHeightC[k];
4223 RoundedUpSwathSizeBytesY[k] = RoundedUpMaxSwathSizeBytesY[k];
4224 RoundedUpSwathSizeBytesC[k] = RoundedUpMaxSwathSizeBytesC[k];
4225 } else if (RoundedUpMaxSwathSizeBytesY[k] >= 1.5 * RoundedUpMaxSwathSizeBytesC[k] && RoundedUpMaxSwathSizeBytesY[k] / 2 + RoundedUpMaxSwathSizeBytesC[k] <= DETBufferSizeInKByteForSwathCalculation * 1024 / 2) {
4226 p->SwathHeightY[k] = MaximumSwathHeightY[k] / 2;
4227 p->SwathHeightC[k] = MaximumSwathHeightC[k];
4228 RoundedUpSwathSizeBytesY[k] = RoundedUpMaxSwathSizeBytesY[k] / 2;
4229 RoundedUpSwathSizeBytesC[k] = RoundedUpMaxSwathSizeBytesC[k];
4230 } else if (RoundedUpMaxSwathSizeBytesY[k] < 1.5 * RoundedUpMaxSwathSizeBytesC[k] && RoundedUpMaxSwathSizeBytesY[k] + RoundedUpMaxSwathSizeBytesC[k] / 2 <= DETBufferSizeInKByteForSwathCalculation * 1024 / 2) {
4231 p->SwathHeightY[k] = MaximumSwathHeightY[k];
4232 p->SwathHeightC[k] = MaximumSwathHeightC[k] / 2;
4233 RoundedUpSwathSizeBytesY[k] = RoundedUpMaxSwathSizeBytesY[k];
4234 RoundedUpSwathSizeBytesC[k] = RoundedUpMaxSwathSizeBytesC[k] / 2;
4235 } else {
4236 p->SwathHeightY[k] = MaximumSwathHeightY[k] / 2;
4237 p->SwathHeightC[k] = MaximumSwathHeightC[k] / 2;
4238 RoundedUpSwathSizeBytesY[k] = RoundedUpMaxSwathSizeBytesY[k] / 2;
4239 RoundedUpSwathSizeBytesC[k] = RoundedUpMaxSwathSizeBytesC[k] / 2;
4240 }
4241
4242 if ((RoundedUpMaxSwathSizeBytesY[k] / 2 + RoundedUpMaxSwathSizeBytesC[k] / 2 > DETBufferSizeInKByteForSwathCalculation * 1024 / 2) ||
4243 p->SwathWidth[k] > p->MaximumSwathWidthLuma[k] || (p->SwathHeightC[k] > 0 && p->SwathWidthChroma[k] > p->MaximumSwathWidthChroma[k])) {
4244 *p->ViewportSizeSupport = false;
4245 p->ViewportSizeSupportPerSurface[k] = false;
4246 } else {
4247 p->ViewportSizeSupportPerSurface[k] = true;
4248 }
4249
4250 if (p->SwathHeightC[k] == 0) {
4251 #ifdef __DML_VBA_DEBUG__
4252 dml_print("DML::%s: k=%u All DET for plane0\n", __func__, k);
4253 #endif
4254 p->DETBufferSizeY[k] = p->DETBufferSizeInKByte[k] * 1024;
4255 p->DETBufferSizeC[k] = 0;
4256 } else if (RoundedUpSwathSizeBytesY[k] <= 1.5 * RoundedUpSwathSizeBytesC[k]) {
4257 #ifdef __DML_VBA_DEBUG__
4258 dml_print("DML::%s: k=%u Half DET for plane0, half for plane1\n", __func__, k);
4259 #endif
4260 p->DETBufferSizeY[k] = p->DETBufferSizeInKByte[k] * 1024 / 2;
4261 p->DETBufferSizeC[k] = p->DETBufferSizeInKByte[k] * 1024 / 2;
4262 } else {
4263 #ifdef __DML_VBA_DEBUG__
4264 dml_print("DML::%s: k=%u 2/3 DET for plane0, 1/3 for plane1\n", __func__, k);
4265 #endif
4266 p->DETBufferSizeY[k] = (dml_uint_t)(dml_floor(p->DETBufferSizeInKByte[k] * 1024 * 2 / 3, 1024));
4267 p->DETBufferSizeC[k] = p->DETBufferSizeInKByte[k] * 1024 - p->DETBufferSizeY[k];
4268 }
4269
4270 #ifdef __DML_VBA_DEBUG__
4271 dml_print("DML::%s: k=%u SwathHeightY = %u\n", __func__, k, p->SwathHeightY[k]);
4272 dml_print("DML::%s: k=%u SwathHeightC = %u\n", __func__, k, p->SwathHeightC[k]);
4273 dml_print("DML::%s: k=%u RoundedUpMaxSwathSizeBytesY = %u\n", __func__, k, RoundedUpMaxSwathSizeBytesY[k]);
4274 dml_print("DML::%s: k=%u RoundedUpMaxSwathSizeBytesC = %u\n", __func__, k, RoundedUpMaxSwathSizeBytesC[k]);
4275 dml_print("DML::%s: k=%u RoundedUpSwathSizeBytesY = %u\n", __func__, k, RoundedUpSwathSizeBytesY[k]);
4276 dml_print("DML::%s: k=%u RoundedUpSwathSizeBytesC = %u\n", __func__, k, RoundedUpSwathSizeBytesC[k]);
4277 dml_print("DML::%s: k=%u DETBufferSizeInKByte = %u\n", __func__, k, p->DETBufferSizeInKByte[k]);
4278 dml_print("DML::%s: k=%u DETBufferSizeY = %u\n", __func__, k, p->DETBufferSizeY[k]);
4279 dml_print("DML::%s: k=%u DETBufferSizeC = %u\n", __func__, k, p->DETBufferSizeC[k]);
4280 dml_print("DML::%s: k=%u ViewportSizeSupportPerSurface = %u\n", __func__, k, p->ViewportSizeSupportPerSurface[k]);
4281 #endif
4282
4283 }
4284
4285 *p->compbuf_reserved_space_64b = 2 * p->PixelChunkSizeInKByte * 1024 / 64;
4286 if (*p->UnboundedRequestEnabled) {
4287 *p->compbuf_reserved_space_64b = dml_max(*p->compbuf_reserved_space_64b,
4288 (dml_float_t)(p->ROBBufferSizeInKByte * 1024/64)
4289 - (dml_float_t)(RoundedUpSwathSizeBytesY[SurfaceDoingUnboundedRequest] * TTUFIFODEPTH / MAXIMUMCOMPRESSION/64));
4290 }
4291 *p->compbuf_reserved_space_zs = 2 * p->PixelChunkSizeInKByte * 1024 / 256;
4292 } // CalculateSwathAndDETConfiguration
4293
CalculateSwathWidth(dml_bool_t ForceSingleDPP,dml_uint_t NumberOfActiveSurfaces,enum dml_source_format_class SourcePixelFormat[],enum dml_rotation_angle SourceScan[],dml_bool_t ViewportStationary[],dml_uint_t ViewportWidth[],dml_uint_t ViewportHeight[],dml_uint_t ViewportXStart[],dml_uint_t ViewportYStart[],dml_uint_t ViewportXStartC[],dml_uint_t ViewportYStartC[],dml_uint_t SurfaceWidthY[],dml_uint_t SurfaceWidthC[],dml_uint_t SurfaceHeightY[],dml_uint_t SurfaceHeightC[],enum dml_odm_mode ODMMode[],dml_uint_t BytePerPixY[],dml_uint_t BytePerPixC[],dml_uint_t Read256BytesBlockHeightY[],dml_uint_t Read256BytesBlockHeightC[],dml_uint_t Read256BytesBlockWidthY[],dml_uint_t Read256BytesBlockWidthC[],dml_uint_t BlendingAndTiming[],dml_uint_t HActive[],dml_float_t HRatio[],dml_uint_t DPPPerSurface[],dml_uint_t SwathWidthSingleDPPY[],dml_uint_t SwathWidthSingleDPPC[],dml_uint_t SwathWidthY[],dml_uint_t SwathWidthC[],dml_uint_t MaximumSwathHeightY[],dml_uint_t MaximumSwathHeightC[],dml_uint_t swath_width_luma_ub[],dml_uint_t swath_width_chroma_ub[])4294 static void CalculateSwathWidth(
4295 dml_bool_t ForceSingleDPP,
4296 dml_uint_t NumberOfActiveSurfaces,
4297 enum dml_source_format_class SourcePixelFormat[],
4298 enum dml_rotation_angle SourceScan[],
4299 dml_bool_t ViewportStationary[],
4300 dml_uint_t ViewportWidth[],
4301 dml_uint_t ViewportHeight[],
4302 dml_uint_t ViewportXStart[],
4303 dml_uint_t ViewportYStart[],
4304 dml_uint_t ViewportXStartC[],
4305 dml_uint_t ViewportYStartC[],
4306 dml_uint_t SurfaceWidthY[],
4307 dml_uint_t SurfaceWidthC[],
4308 dml_uint_t SurfaceHeightY[],
4309 dml_uint_t SurfaceHeightC[],
4310 enum dml_odm_mode ODMMode[],
4311 dml_uint_t BytePerPixY[],
4312 dml_uint_t BytePerPixC[],
4313 dml_uint_t Read256BytesBlockHeightY[],
4314 dml_uint_t Read256BytesBlockHeightC[],
4315 dml_uint_t Read256BytesBlockWidthY[],
4316 dml_uint_t Read256BytesBlockWidthC[],
4317 dml_uint_t BlendingAndTiming[],
4318 dml_uint_t HActive[],
4319 dml_float_t HRatio[],
4320 dml_uint_t DPPPerSurface[],
4321
4322 // Output
4323 dml_uint_t SwathWidthSingleDPPY[],
4324 dml_uint_t SwathWidthSingleDPPC[],
4325 dml_uint_t SwathWidthY[], // per-pipe
4326 dml_uint_t SwathWidthC[], // per-pipe
4327 dml_uint_t MaximumSwathHeightY[],
4328 dml_uint_t MaximumSwathHeightC[],
4329 dml_uint_t swath_width_luma_ub[], // per-pipe
4330 dml_uint_t swath_width_chroma_ub[]) // per-pipe
4331 {
4332 enum dml_odm_mode MainSurfaceODMMode;
4333 dml_uint_t surface_width_ub_l;
4334 dml_uint_t surface_height_ub_l;
4335 dml_uint_t surface_width_ub_c = 0;
4336 dml_uint_t surface_height_ub_c = 0;
4337
4338 #ifdef __DML_VBA_DEBUG__
4339 dml_print("DML::%s: ForceSingleDPP = %u\n", __func__, ForceSingleDPP);
4340 dml_print("DML::%s: NumberOfActiveSurfaces = %u\n", __func__, NumberOfActiveSurfaces);
4341 #endif
4342
4343 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
4344 if (!dml_is_vertical_rotation(SourceScan[k])) {
4345 SwathWidthSingleDPPY[k] = ViewportWidth[k];
4346 } else {
4347 SwathWidthSingleDPPY[k] = ViewportHeight[k];
4348 }
4349
4350 #ifdef __DML_VBA_DEBUG__
4351 dml_print("DML::%s: k=%u ViewportWidth=%u\n", __func__, k, ViewportWidth[k]);
4352 dml_print("DML::%s: k=%u ViewportHeight=%u\n", __func__, k, ViewportHeight[k]);
4353 dml_print("DML::%s: k=%u DPPPerSurface=%u\n", __func__, k, DPPPerSurface[k]);
4354 #endif
4355
4356 MainSurfaceODMMode = ODMMode[k];
4357 for (dml_uint_t j = 0; j < NumberOfActiveSurfaces; ++j) {
4358 if (BlendingAndTiming[k] == j) {
4359 MainSurfaceODMMode = ODMMode[j];
4360 }
4361 }
4362
4363 if (ForceSingleDPP) {
4364 SwathWidthY[k] = SwathWidthSingleDPPY[k];
4365 } else {
4366 if (MainSurfaceODMMode == dml_odm_mode_combine_4to1) {
4367 SwathWidthY[k] = (dml_uint_t)(dml_min(SwathWidthSingleDPPY[k], dml_round(HActive[k] / 4.0 * HRatio[k], true)));
4368 } else if (MainSurfaceODMMode == dml_odm_mode_combine_2to1) {
4369 SwathWidthY[k] = (dml_uint_t)(dml_min(SwathWidthSingleDPPY[k], dml_round(HActive[k] / 2.0 * HRatio[k], true)));
4370 } else if (DPPPerSurface[k] == 2) {
4371 SwathWidthY[k] = SwathWidthSingleDPPY[k] / 2;
4372 } else {
4373 SwathWidthY[k] = SwathWidthSingleDPPY[k];
4374 }
4375 }
4376
4377 #ifdef __DML_VBA_DEBUG__
4378 dml_print("DML::%s: k=%u HActive=%u\n", __func__, k, HActive[k]);
4379 dml_print("DML::%s: k=%u HRatio=%f\n", __func__, k, HRatio[k]);
4380 dml_print("DML::%s: k=%u MainSurfaceODMMode=%u\n", __func__, k, MainSurfaceODMMode);
4381 dml_print("DML::%s: k=%u SwathWidthSingleDPPY=%u\n", __func__, k, SwathWidthSingleDPPY[k]);
4382 dml_print("DML::%s: k=%u SwathWidthY=%u\n", __func__, k, SwathWidthY[k]);
4383 #endif
4384
4385 if (SourcePixelFormat[k] == dml_420_8 || SourcePixelFormat[k] == dml_420_10 || SourcePixelFormat[k] == dml_420_12) {
4386 SwathWidthC[k] = SwathWidthY[k] / 2;
4387 SwathWidthSingleDPPC[k] = SwathWidthSingleDPPY[k] / 2;
4388 } else {
4389 SwathWidthC[k] = SwathWidthY[k];
4390 SwathWidthSingleDPPC[k] = SwathWidthSingleDPPY[k];
4391 }
4392
4393 if (ForceSingleDPP == true) {
4394 SwathWidthY[k] = SwathWidthSingleDPPY[k];
4395 SwathWidthC[k] = SwathWidthSingleDPPC[k];
4396 }
4397
4398 surface_width_ub_l = (dml_uint_t)dml_ceil(SurfaceWidthY[k], Read256BytesBlockWidthY[k]);
4399 surface_height_ub_l = (dml_uint_t)dml_ceil(SurfaceHeightY[k], Read256BytesBlockHeightY[k]);
4400
4401 if (!dml_is_vertical_rotation(SourceScan[k])) {
4402 MaximumSwathHeightY[k] = Read256BytesBlockHeightY[k];
4403 MaximumSwathHeightC[k] = Read256BytesBlockHeightC[k];
4404 if (ViewportStationary[k] && DPPPerSurface[k] == 1) {
4405 swath_width_luma_ub[k] = (dml_uint_t)(dml_min(surface_width_ub_l, dml_floor(ViewportXStart[k] + SwathWidthY[k] + Read256BytesBlockWidthY[k] - 1, Read256BytesBlockWidthY[k]) - dml_floor(ViewportXStart[k], Read256BytesBlockWidthY[k])));
4406 } else {
4407 swath_width_luma_ub[k] = (dml_uint_t)(dml_min(surface_width_ub_l, dml_ceil(SwathWidthY[k] - 1, Read256BytesBlockWidthY[k]) + Read256BytesBlockWidthY[k]));
4408 }
4409 if (BytePerPixC[k] > 0) {
4410 surface_width_ub_c = (dml_uint_t)dml_ceil(SurfaceWidthC[k], Read256BytesBlockWidthC[k]);
4411 if (ViewportStationary[k] && DPPPerSurface[k] == 1) {
4412 swath_width_chroma_ub[k] = (dml_uint_t)(dml_min(surface_width_ub_c, dml_floor(ViewportXStartC[k] + SwathWidthC[k] + Read256BytesBlockWidthC[k] - 1, Read256BytesBlockWidthC[k]) - dml_floor(ViewportXStartC[k], Read256BytesBlockWidthC[k])));
4413 } else {
4414 swath_width_chroma_ub[k] = (dml_uint_t)(dml_min(surface_width_ub_c, dml_ceil(SwathWidthC[k] - 1, Read256BytesBlockWidthC[k]) + Read256BytesBlockWidthC[k]));
4415 }
4416 } else {
4417 swath_width_chroma_ub[k] = 0;
4418 }
4419 } else {
4420 MaximumSwathHeightY[k] = Read256BytesBlockWidthY[k];
4421 MaximumSwathHeightC[k] = Read256BytesBlockWidthC[k];
4422
4423 if (ViewportStationary[k] && DPPPerSurface[k] == 1) {
4424 swath_width_luma_ub[k] = (dml_uint_t)(dml_min(surface_height_ub_l, dml_floor(ViewportYStart[k] + SwathWidthY[k] + Read256BytesBlockHeightY[k] - 1, Read256BytesBlockHeightY[k]) - dml_floor(ViewportYStart[k], Read256BytesBlockHeightY[k])));
4425 } else {
4426 swath_width_luma_ub[k] = (dml_uint_t)(dml_min(surface_height_ub_l, dml_ceil(SwathWidthY[k] - 1, Read256BytesBlockHeightY[k]) + Read256BytesBlockHeightY[k]));
4427 }
4428 if (BytePerPixC[k] > 0) {
4429 surface_height_ub_c = (dml_uint_t)dml_ceil(SurfaceHeightC[k], Read256BytesBlockHeightC[k]);
4430 if (ViewportStationary[k] && DPPPerSurface[k] == 1) {
4431 swath_width_chroma_ub[k] = (dml_uint_t)(dml_min(surface_height_ub_c, dml_floor(ViewportYStartC[k] + SwathWidthC[k] + Read256BytesBlockHeightC[k] - 1, Read256BytesBlockHeightC[k]) - dml_floor(ViewportYStartC[k], Read256BytesBlockHeightC[k])));
4432 } else {
4433 swath_width_chroma_ub[k] = (dml_uint_t)(dml_min(surface_height_ub_c, dml_ceil(SwathWidthC[k] - 1, Read256BytesBlockHeightC[k]) + Read256BytesBlockHeightC[k]));
4434 }
4435 } else {
4436 swath_width_chroma_ub[k] = 0;
4437 }
4438 }
4439
4440 #ifdef __DML_VBA_DEBUG__
4441 dml_print("DML::%s: k=%u surface_width_ub_l=%u\n", __func__, k, surface_width_ub_l);
4442 dml_print("DML::%s: k=%u surface_height_ub_l=%u\n", __func__, k, surface_height_ub_l);
4443 dml_print("DML::%s: k=%u surface_width_ub_c=%u\n", __func__, k, surface_width_ub_c);
4444 dml_print("DML::%s: k=%u surface_height_ub_c=%u\n", __func__, k, surface_height_ub_c);
4445 dml_print("DML::%s: k=%u Read256BytesBlockWidthY=%u\n", __func__, k, Read256BytesBlockWidthY[k]);
4446 dml_print("DML::%s: k=%u Read256BytesBlockHeightY=%u\n", __func__, k, Read256BytesBlockHeightY[k]);
4447 dml_print("DML::%s: k=%u Read256BytesBlockWidthC=%u\n", __func__, k, Read256BytesBlockWidthC[k]);
4448 dml_print("DML::%s: k=%u Read256BytesBlockHeightC=%u\n", __func__, k, Read256BytesBlockHeightC[k]);
4449 dml_print("DML::%s: k=%u ViewportStationary=%u\n", __func__, k, ViewportStationary[k]);
4450 dml_print("DML::%s: k=%u DPPPerSurface=%u\n", __func__, k, DPPPerSurface[k]);
4451 dml_print("DML::%s: k=%u swath_width_luma_ub=%u\n", __func__, k, swath_width_luma_ub[k]);
4452 dml_print("DML::%s: k=%u swath_width_chroma_ub=%u\n", __func__, k, swath_width_chroma_ub[k]);
4453 dml_print("DML::%s: k=%u MaximumSwathHeightY=%u\n", __func__, k, MaximumSwathHeightY[k]);
4454 dml_print("DML::%s: k=%u MaximumSwathHeightC=%u\n", __func__, k, MaximumSwathHeightC[k]);
4455 #endif
4456
4457 }
4458 } // CalculateSwathWidth
4459
CalculateExtraLatency(dml_uint_t RoundTripPingLatencyCycles,dml_uint_t ReorderingBytes,dml_float_t DCFCLK,dml_uint_t TotalNumberOfActiveDPP,dml_uint_t PixelChunkSizeInKByte,dml_uint_t TotalNumberOfDCCActiveDPP,dml_uint_t MetaChunkSize,dml_float_t ReturnBW,dml_bool_t GPUVMEnable,dml_bool_t HostVMEnable,dml_uint_t NumberOfActiveSurfaces,dml_uint_t NumberOfDPP[],dml_uint_t dpte_group_bytes[],dml_float_t HostVMInefficiencyFactor,dml_uint_t HostVMMinPageSize,dml_uint_t HostVMMaxNonCachedPageTableLevels)4460 static dml_float_t CalculateExtraLatency(
4461 dml_uint_t RoundTripPingLatencyCycles,
4462 dml_uint_t ReorderingBytes,
4463 dml_float_t DCFCLK,
4464 dml_uint_t TotalNumberOfActiveDPP,
4465 dml_uint_t PixelChunkSizeInKByte,
4466 dml_uint_t TotalNumberOfDCCActiveDPP,
4467 dml_uint_t MetaChunkSize,
4468 dml_float_t ReturnBW,
4469 dml_bool_t GPUVMEnable,
4470 dml_bool_t HostVMEnable,
4471 dml_uint_t NumberOfActiveSurfaces,
4472 dml_uint_t NumberOfDPP[],
4473 dml_uint_t dpte_group_bytes[],
4474 dml_float_t HostVMInefficiencyFactor,
4475 dml_uint_t HostVMMinPageSize,
4476 dml_uint_t HostVMMaxNonCachedPageTableLevels)
4477 {
4478 dml_float_t ExtraLatencyBytes;
4479 dml_float_t ExtraLatency;
4480
4481 ExtraLatencyBytes = CalculateExtraLatencyBytes(
4482 ReorderingBytes,
4483 TotalNumberOfActiveDPP,
4484 PixelChunkSizeInKByte,
4485 TotalNumberOfDCCActiveDPP,
4486 MetaChunkSize,
4487 GPUVMEnable,
4488 HostVMEnable,
4489 NumberOfActiveSurfaces,
4490 NumberOfDPP,
4491 dpte_group_bytes,
4492 HostVMInefficiencyFactor,
4493 HostVMMinPageSize,
4494 HostVMMaxNonCachedPageTableLevels);
4495
4496 ExtraLatency = (RoundTripPingLatencyCycles + __DML_ARB_TO_RET_DELAY__) / DCFCLK + ExtraLatencyBytes / ReturnBW;
4497
4498 #ifdef __DML_VBA_DEBUG__
4499 dml_print("DML::%s: RoundTripPingLatencyCycles=%u\n", __func__, RoundTripPingLatencyCycles);
4500 dml_print("DML::%s: DCFCLK=%f\n", __func__, DCFCLK);
4501 dml_print("DML::%s: ExtraLatencyBytes=%f\n", __func__, ExtraLatencyBytes);
4502 dml_print("DML::%s: ReturnBW=%f\n", __func__, ReturnBW);
4503 dml_print("DML::%s: ExtraLatency=%f\n", __func__, ExtraLatency);
4504 #endif
4505
4506 return ExtraLatency;
4507 } // CalculateExtraLatency
4508
CalculateHostVMDynamicLevels(dml_bool_t GPUVMEnable,dml_bool_t HostVMEnable,dml_uint_t HostVMMinPageSize,dml_uint_t HostVMMaxNonCachedPageTableLevels)4509 static dml_uint_t CalculateHostVMDynamicLevels(
4510 dml_bool_t GPUVMEnable,
4511 dml_bool_t HostVMEnable,
4512 dml_uint_t HostVMMinPageSize,
4513 dml_uint_t HostVMMaxNonCachedPageTableLevels)
4514 {
4515 dml_uint_t HostVMDynamicLevels = 0;
4516
4517 if (GPUVMEnable && HostVMEnable) {
4518 if (HostVMMinPageSize < 2048)
4519 HostVMDynamicLevels = HostVMMaxNonCachedPageTableLevels;
4520 else if (HostVMMinPageSize >= 2048 && HostVMMinPageSize < 1048576)
4521 HostVMDynamicLevels = (dml_uint_t) dml_max(0, (dml_float_t) HostVMMaxNonCachedPageTableLevels - 1);
4522 else
4523 HostVMDynamicLevels = (dml_uint_t) dml_max(0, (dml_float_t) HostVMMaxNonCachedPageTableLevels - 2);
4524 } else {
4525 HostVMDynamicLevels = 0;
4526 }
4527 return HostVMDynamicLevels;
4528 }
4529
CalculateExtraLatencyBytes(dml_uint_t ReorderingBytes,dml_uint_t TotalNumberOfActiveDPP,dml_uint_t PixelChunkSizeInKByte,dml_uint_t TotalNumberOfDCCActiveDPP,dml_uint_t MetaChunkSize,dml_bool_t GPUVMEnable,dml_bool_t HostVMEnable,dml_uint_t NumberOfActiveSurfaces,dml_uint_t NumberOfDPP[],dml_uint_t dpte_group_bytes[],dml_float_t HostVMInefficiencyFactor,dml_uint_t HostVMMinPageSize,dml_uint_t HostVMMaxNonCachedPageTableLevels)4530 static dml_uint_t CalculateExtraLatencyBytes(dml_uint_t ReorderingBytes,
4531 dml_uint_t TotalNumberOfActiveDPP,
4532 dml_uint_t PixelChunkSizeInKByte,
4533 dml_uint_t TotalNumberOfDCCActiveDPP,
4534 dml_uint_t MetaChunkSize,
4535 dml_bool_t GPUVMEnable,
4536 dml_bool_t HostVMEnable,
4537 dml_uint_t NumberOfActiveSurfaces,
4538 dml_uint_t NumberOfDPP[],
4539 dml_uint_t dpte_group_bytes[],
4540 dml_float_t HostVMInefficiencyFactor,
4541 dml_uint_t HostVMMinPageSize,
4542 dml_uint_t HostVMMaxNonCachedPageTableLevels)
4543 {
4544 dml_uint_t HostVMDynamicLevels = CalculateHostVMDynamicLevels(GPUVMEnable, HostVMEnable, HostVMMinPageSize, HostVMMaxNonCachedPageTableLevels);
4545 dml_float_t ret = ReorderingBytes + (TotalNumberOfActiveDPP * PixelChunkSizeInKByte + TotalNumberOfDCCActiveDPP * MetaChunkSize) * 1024.0;
4546
4547 if (GPUVMEnable == true) {
4548 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
4549 ret = ret + NumberOfDPP[k] * dpte_group_bytes[k] * (1 + 8 * HostVMDynamicLevels) * HostVMInefficiencyFactor;
4550 }
4551 }
4552 return (dml_uint_t)(ret);
4553 }
4554
CalculateUrgentLatency(dml_float_t UrgentLatencyPixelDataOnly,dml_float_t UrgentLatencyPixelMixedWithVMData,dml_float_t UrgentLatencyVMDataOnly,dml_bool_t DoUrgentLatencyAdjustment,dml_float_t UrgentLatencyAdjustmentFabricClockComponent,dml_float_t UrgentLatencyAdjustmentFabricClockReference,dml_float_t FabricClock)4555 static dml_float_t CalculateUrgentLatency(
4556 dml_float_t UrgentLatencyPixelDataOnly,
4557 dml_float_t UrgentLatencyPixelMixedWithVMData,
4558 dml_float_t UrgentLatencyVMDataOnly,
4559 dml_bool_t DoUrgentLatencyAdjustment,
4560 dml_float_t UrgentLatencyAdjustmentFabricClockComponent,
4561 dml_float_t UrgentLatencyAdjustmentFabricClockReference,
4562 dml_float_t FabricClock)
4563 {
4564 dml_float_t ret;
4565
4566 ret = dml_max3(UrgentLatencyPixelDataOnly, UrgentLatencyPixelMixedWithVMData, UrgentLatencyVMDataOnly);
4567 if (DoUrgentLatencyAdjustment == true) {
4568 ret = ret + UrgentLatencyAdjustmentFabricClockComponent * (UrgentLatencyAdjustmentFabricClockReference / FabricClock - 1);
4569 }
4570 return ret;
4571 }
4572
RequiredDTBCLK(dml_bool_t DSCEnable,dml_float_t PixelClock,enum dml_output_format_class OutputFormat,dml_float_t OutputBpp,dml_uint_t DSCSlices,dml_uint_t HTotal,dml_uint_t HActive,dml_uint_t AudioRate,dml_uint_t AudioLayout)4573 static dml_float_t RequiredDTBCLK(
4574 dml_bool_t DSCEnable,
4575 dml_float_t PixelClock,
4576 enum dml_output_format_class OutputFormat,
4577 dml_float_t OutputBpp,
4578 dml_uint_t DSCSlices,
4579 dml_uint_t HTotal,
4580 dml_uint_t HActive,
4581 dml_uint_t AudioRate,
4582 dml_uint_t AudioLayout)
4583 {
4584 if (DSCEnable != true) {
4585 return dml_max(PixelClock / 4.0 * OutputBpp / 24.0, 25.0);
4586 } else {
4587 dml_float_t PixelWordRate = PixelClock / (OutputFormat == dml_444 ? 1 : 2);
4588 dml_float_t HCActive = dml_ceil(DSCSlices * dml_ceil(OutputBpp * dml_ceil(HActive / DSCSlices, 1) / 8.0, 1) / 3.0, 1);
4589 dml_float_t HCBlank = 64 + 32 * dml_ceil(AudioRate * (AudioLayout == 1 ? 1 : 0.25) * HTotal / (PixelClock * 1000), 1);
4590 dml_float_t AverageTribyteRate = PixelWordRate * (HCActive + HCBlank) / HTotal;
4591 dml_float_t HActiveTribyteRate = PixelWordRate * HCActive / HActive;
4592 return dml_max4(PixelWordRate / 4.0, AverageTribyteRate / 4.0, HActiveTribyteRate / 4.0, 25.0) * 1.002;
4593 }
4594 }
4595
UseMinimumDCFCLK(struct display_mode_lib_scratch_st * scratch,struct UseMinimumDCFCLK_params_st * p)4596 static void UseMinimumDCFCLK(struct display_mode_lib_scratch_st *scratch, struct UseMinimumDCFCLK_params_st *p)
4597 {
4598 struct UseMinimumDCFCLK_locals_st *s = &scratch->UseMinimumDCFCLK_locals;
4599
4600 s->NormalEfficiency = p->PercentOfIdealSDPPortBWReceivedAfterUrgLatency / 100.0;
4601 for (dml_uint_t j = 0; j < 2; ++j) {
4602
4603
4604 s->TotalMaxPrefetchFlipDPTERowBandwidth[j] = 0;
4605 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
4606 s->TotalMaxPrefetchFlipDPTERowBandwidth[j] = s->TotalMaxPrefetchFlipDPTERowBandwidth[j] + p->NoOfDPP[j][k] * p->DPTEBytesPerRow[j][k] / (15.75 * p->HTotal[k] / p->PixelClock[k]);
4607 }
4608
4609 for (dml_uint_t k = 0; k <= p->NumberOfActiveSurfaces - 1; ++k) {
4610 s->NoOfDPPState[k] = p->NoOfDPP[j][k];
4611 }
4612
4613 s->DPTEBandwidth = s->TotalMaxPrefetchFlipDPTERowBandwidth[j];
4614
4615 s->DCFCLKRequiredForAverageBandwidth = dml_max(p->ProjectedDCFCLKDeepSleep[j], s->DPTEBandwidth / s->NormalEfficiency / p->ReturnBusWidth);
4616
4617 s->ExtraLatencyBytes = CalculateExtraLatencyBytes(p->ReorderingBytes, p->TotalNumberOfActiveDPP[j], p->PixelChunkSizeInKByte, p->TotalNumberOfDCCActiveDPP[j],
4618 p->MetaChunkSize, p->GPUVMEnable, p->HostVMEnable, p->NumberOfActiveSurfaces, s->NoOfDPPState, p->dpte_group_bytes,
4619 1, p->HostVMMinPageSize, p->HostVMMaxNonCachedPageTableLevels);
4620 s->ExtraLatencyCycles = p->RoundTripPingLatencyCycles + __DML_ARB_TO_RET_DELAY__ + s->ExtraLatencyBytes / s->NormalEfficiency / p->ReturnBusWidth;
4621 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
4622 dml_float_t DCFCLKCyclesRequiredInPrefetch;
4623 dml_float_t PrefetchTime;
4624
4625 s->PixelDCFCLKCyclesRequiredInPrefetch[k] = (p->PrefetchLinesY[j][k] * p->swath_width_luma_ub_all_states[j][k] * p->BytePerPixelY[k] + p->PrefetchLinesC[j][k] * p->swath_width_chroma_ub_all_states[j][k] * p->BytePerPixelC[k]) / s->NormalEfficiency / p->ReturnBusWidth;
4626 DCFCLKCyclesRequiredInPrefetch = 2 * s->ExtraLatencyCycles / s->NoOfDPPState[k] + p->PDEAndMetaPTEBytesPerFrame[j][k] / s->NormalEfficiency / s->NormalEfficiency / p->ReturnBusWidth * (p->GPUVMMaxPageTableLevels > 2 ? 1 : 0) + 2 * p->DPTEBytesPerRow[j][k] / s->NormalEfficiency / s->NormalEfficiency / p->ReturnBusWidth + 2 * p->MetaRowBytes[j][k] / s->NormalEfficiency / p->ReturnBusWidth + s->PixelDCFCLKCyclesRequiredInPrefetch[k];
4627 s->PrefetchPixelLinesTime[k] = dml_max(p->PrefetchLinesY[j][k], p->PrefetchLinesC[j][k]) * p->HTotal[k] / p->PixelClock[k];
4628 s->DynamicMetadataVMExtraLatency[k] = (p->GPUVMEnable == true && p->DynamicMetadataEnable[k] == true && p->DynamicMetadataVMEnabled == true) ? p->UrgLatency * p->GPUVMMaxPageTableLevels * (p->HostVMEnable == true ? p->HostVMMaxNonCachedPageTableLevels + 1 : 1) : 0;
4629
4630 s->MinimumTWait = CalculateTWait(p->MaxPrefetchMode,
4631 p->UseMALLForPStateChange[k],
4632 p->SynchronizeDRRDisplaysForUCLKPStateChangeFinal,
4633 p->DRRDisplay[k],
4634 p->DRAMClockChangeLatencyFinal,
4635 p->FCLKChangeLatency,
4636 p->UrgLatency,
4637 p->SREnterPlusExitTime);
4638
4639 PrefetchTime = (p->MaximumVStartup[j][k] - 1) * p->HTotal[k] / p->PixelClock[k] - s->MinimumTWait - p->UrgLatency * ((p->GPUVMMaxPageTableLevels <= 2 ? p->GPUVMMaxPageTableLevels : p->GPUVMMaxPageTableLevels - 2) * (p->HostVMEnable == true ? p->HostVMMaxNonCachedPageTableLevels + 1 : 1) - 1) - s->DynamicMetadataVMExtraLatency[k];
4640
4641 if (PrefetchTime > 0) {
4642 dml_float_t ExpectedVRatioPrefetch;
4643 ExpectedVRatioPrefetch = s->PrefetchPixelLinesTime[k] / (PrefetchTime * s->PixelDCFCLKCyclesRequiredInPrefetch[k] / DCFCLKCyclesRequiredInPrefetch);
4644 s->DCFCLKRequiredForPeakBandwidthPerSurface[k] = s->NoOfDPPState[k] * s->PixelDCFCLKCyclesRequiredInPrefetch[k] / s->PrefetchPixelLinesTime[k] * dml_max(1.0, ExpectedVRatioPrefetch) * dml_max(1.0, ExpectedVRatioPrefetch / 4);
4645 if (p->HostVMEnable == true || p->ImmediateFlipRequirement == true) {
4646 s->DCFCLKRequiredForPeakBandwidthPerSurface[k] = s->DCFCLKRequiredForPeakBandwidthPerSurface[k] + s->NoOfDPPState[k] * s->DPTEBandwidth / s->NormalEfficiency / s->NormalEfficiency / p->ReturnBusWidth;
4647 }
4648 } else {
4649 s->DCFCLKRequiredForPeakBandwidthPerSurface[k] = p->DCFCLKPerState;
4650 }
4651 if (p->DynamicMetadataEnable[k] == true) {
4652 dml_float_t TSetupPipe;
4653 dml_float_t TdmbfPipe;
4654 dml_float_t TdmsksPipe;
4655 dml_float_t TdmecPipe;
4656 dml_float_t AllowedTimeForUrgentExtraLatency;
4657
4658 CalculateVUpdateAndDynamicMetadataParameters(
4659 p->MaxInterDCNTileRepeaters,
4660 p->RequiredDPPCLKPerSurface[j][k],
4661 p->RequiredDISPCLK[j],
4662 p->ProjectedDCFCLKDeepSleep[j],
4663 p->PixelClock[k],
4664 p->HTotal[k],
4665 p->VTotal[k] - p->VActive[k],
4666 p->DynamicMetadataTransmittedBytes[k],
4667 p->DynamicMetadataLinesBeforeActiveRequired[k],
4668 p->Interlace[k],
4669 p->ProgressiveToInterlaceUnitInOPP,
4670
4671 // Output
4672 &TSetupPipe,
4673 &TdmbfPipe,
4674 &TdmecPipe,
4675 &TdmsksPipe,
4676 &s->dummy1,
4677 &s->dummy2,
4678 &s->dummy3);
4679
4680 AllowedTimeForUrgentExtraLatency = p->MaximumVStartup[j][k] * p->HTotal[k] / p->PixelClock[k] - s->MinimumTWait - TSetupPipe - TdmbfPipe - TdmecPipe - TdmsksPipe - s->DynamicMetadataVMExtraLatency[k];
4681 if (AllowedTimeForUrgentExtraLatency > 0) {
4682 s->DCFCLKRequiredForPeakBandwidthPerSurface[k] = dml_max(s->DCFCLKRequiredForPeakBandwidthPerSurface[k], s->ExtraLatencyCycles / AllowedTimeForUrgentExtraLatency);
4683 } else {
4684 s->DCFCLKRequiredForPeakBandwidthPerSurface[k] = p->DCFCLKPerState;
4685 }
4686 }
4687 }
4688 s->DCFCLKRequiredForPeakBandwidth = 0;
4689 for (dml_uint_t k = 0; k <= p->NumberOfActiveSurfaces - 1; ++k) {
4690 s->DCFCLKRequiredForPeakBandwidth = s->DCFCLKRequiredForPeakBandwidth + s->DCFCLKRequiredForPeakBandwidthPerSurface[k];
4691 }
4692 s->MinimumTvmPlus2Tr0 = p->UrgLatency * (p->GPUVMEnable == true ? (p->HostVMEnable == true ? (p->GPUVMMaxPageTableLevels + 2) * (p->HostVMMaxNonCachedPageTableLevels + 1) - 1 : p->GPUVMMaxPageTableLevels + 1) : 0);
4693 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
4694 dml_float_t MaximumTvmPlus2Tr0PlusTsw;
4695 MaximumTvmPlus2Tr0PlusTsw = (p->MaximumVStartup[j][k] - 2) * p->HTotal[k] / p->PixelClock[k] - s->MinimumTWait - s->DynamicMetadataVMExtraLatency[k];
4696 if (MaximumTvmPlus2Tr0PlusTsw <= s->MinimumTvmPlus2Tr0 + s->PrefetchPixelLinesTime[k] / 4) {
4697 s->DCFCLKRequiredForPeakBandwidth = p->DCFCLKPerState;
4698 } else {
4699 s->DCFCLKRequiredForPeakBandwidth = dml_max3(s->DCFCLKRequiredForPeakBandwidth,
4700 2 * s->ExtraLatencyCycles / (MaximumTvmPlus2Tr0PlusTsw - s->MinimumTvmPlus2Tr0 - s->PrefetchPixelLinesTime[k] / 4),
4701 (2 * s->ExtraLatencyCycles + s->PixelDCFCLKCyclesRequiredInPrefetch[k]) / (MaximumTvmPlus2Tr0PlusTsw - s->MinimumTvmPlus2Tr0));
4702 }
4703 }
4704 p->DCFCLKState[j] = dml_min(p->DCFCLKPerState, 1.05 * dml_max(s->DCFCLKRequiredForAverageBandwidth, s->DCFCLKRequiredForPeakBandwidth));
4705 }
4706 }
4707
4708
UnboundedRequest(enum dml_unbounded_requesting_policy UseUnboundedRequestingFinal,dml_uint_t TotalNumberOfActiveDPP,dml_bool_t NoChromaOrLinear,enum dml_output_encoder_class Output)4709 static dml_bool_t UnboundedRequest(enum dml_unbounded_requesting_policy UseUnboundedRequestingFinal,
4710 dml_uint_t TotalNumberOfActiveDPP,
4711 dml_bool_t NoChromaOrLinear,
4712 enum dml_output_encoder_class Output)
4713 {
4714 dml_bool_t ret_val = false;
4715
4716 ret_val = (UseUnboundedRequestingFinal != dml_unbounded_requesting_disable
4717 && TotalNumberOfActiveDPP == 1 && NoChromaOrLinear);
4718 if (UseUnboundedRequestingFinal == dml_unbounded_requesting_edp_only && Output != dml_edp) {
4719 ret_val = false;
4720 }
4721 return (ret_val);
4722 }
4723
CalculateSurfaceSizeInMall(dml_uint_t NumberOfActiveSurfaces,dml_uint_t MALLAllocatedForDCN,enum dml_use_mall_for_static_screen_mode UseMALLForStaticScreen[],dml_bool_t DCCEnable[],dml_bool_t ViewportStationary[],dml_uint_t ViewportXStartY[],dml_uint_t ViewportYStartY[],dml_uint_t ViewportXStartC[],dml_uint_t ViewportYStartC[],dml_uint_t ViewportWidthY[],dml_uint_t ViewportHeightY[],dml_uint_t BytesPerPixelY[],dml_uint_t ViewportWidthC[],dml_uint_t ViewportHeightC[],dml_uint_t BytesPerPixelC[],dml_uint_t SurfaceWidthY[],dml_uint_t SurfaceWidthC[],dml_uint_t SurfaceHeightY[],dml_uint_t SurfaceHeightC[],dml_uint_t Read256BytesBlockWidthY[],dml_uint_t Read256BytesBlockWidthC[],dml_uint_t Read256BytesBlockHeightY[],dml_uint_t Read256BytesBlockHeightC[],dml_uint_t ReadBlockWidthY[],dml_uint_t ReadBlockWidthC[],dml_uint_t ReadBlockHeightY[],dml_uint_t ReadBlockHeightC[],dml_uint_t SurfaceSizeInMALL[],dml_bool_t * ExceededMALLSize)4724 static void CalculateSurfaceSizeInMall(
4725 dml_uint_t NumberOfActiveSurfaces,
4726 dml_uint_t MALLAllocatedForDCN,
4727 enum dml_use_mall_for_static_screen_mode UseMALLForStaticScreen[],
4728 dml_bool_t DCCEnable[],
4729 dml_bool_t ViewportStationary[],
4730 dml_uint_t ViewportXStartY[],
4731 dml_uint_t ViewportYStartY[],
4732 dml_uint_t ViewportXStartC[],
4733 dml_uint_t ViewportYStartC[],
4734 dml_uint_t ViewportWidthY[],
4735 dml_uint_t ViewportHeightY[],
4736 dml_uint_t BytesPerPixelY[],
4737 dml_uint_t ViewportWidthC[],
4738 dml_uint_t ViewportHeightC[],
4739 dml_uint_t BytesPerPixelC[],
4740 dml_uint_t SurfaceWidthY[],
4741 dml_uint_t SurfaceWidthC[],
4742 dml_uint_t SurfaceHeightY[],
4743 dml_uint_t SurfaceHeightC[],
4744 dml_uint_t Read256BytesBlockWidthY[],
4745 dml_uint_t Read256BytesBlockWidthC[],
4746 dml_uint_t Read256BytesBlockHeightY[],
4747 dml_uint_t Read256BytesBlockHeightC[],
4748 dml_uint_t ReadBlockWidthY[],
4749 dml_uint_t ReadBlockWidthC[],
4750 dml_uint_t ReadBlockHeightY[],
4751 dml_uint_t ReadBlockHeightC[],
4752
4753 // Output
4754 dml_uint_t SurfaceSizeInMALL[],
4755 dml_bool_t *ExceededMALLSize)
4756 {
4757 dml_uint_t TotalSurfaceSizeInMALL = 0;
4758
4759 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
4760 if (ViewportStationary[k]) {
4761 SurfaceSizeInMALL[k] = (dml_uint_t)(dml_min(dml_ceil(SurfaceWidthY[k], ReadBlockWidthY[k]), dml_floor(ViewportXStartY[k] + ViewportWidthY[k] + ReadBlockWidthY[k] - 1, ReadBlockWidthY[k]) - dml_floor(ViewportXStartY[k], ReadBlockWidthY[k])) *
4762 dml_min(dml_ceil(SurfaceHeightY[k], ReadBlockHeightY[k]), dml_floor(ViewportYStartY[k] + ViewportHeightY[k] + ReadBlockHeightY[k] - 1, ReadBlockHeightY[k]) - dml_floor(ViewportYStartY[k], ReadBlockHeightY[k])) *
4763 BytesPerPixelY[k]);
4764
4765 if (ReadBlockWidthC[k] > 0) {
4766 SurfaceSizeInMALL[k] = (dml_uint_t)(SurfaceSizeInMALL[k] +
4767 dml_min(dml_ceil(SurfaceWidthC[k], ReadBlockWidthC[k]), dml_floor(ViewportXStartC[k] + ViewportWidthC[k] + ReadBlockWidthC[k] - 1, ReadBlockWidthC[k]) - dml_floor(ViewportXStartC[k], ReadBlockWidthC[k])) *
4768 dml_min(dml_ceil(SurfaceHeightC[k], ReadBlockHeightC[k]), dml_floor(ViewportYStartC[k] + ViewportHeightC[k] + ReadBlockHeightC[k] - 1, ReadBlockHeightC[k]) - dml_floor(ViewportYStartC[k], ReadBlockHeightC[k])) * BytesPerPixelC[k]);
4769 }
4770 if (DCCEnable[k] == true) {
4771 SurfaceSizeInMALL[k] = (dml_uint_t)(SurfaceSizeInMALL[k] +
4772 dml_min(dml_ceil(SurfaceWidthY[k], 8 * Read256BytesBlockWidthY[k]), dml_floor(ViewportXStartY[k] + ViewportWidthY[k] + 8 * Read256BytesBlockWidthY[k] - 1, 8 * Read256BytesBlockWidthY[k]) - dml_floor(ViewportXStartY[k], 8 * Read256BytesBlockWidthY[k])) *
4773 dml_min(dml_ceil(SurfaceHeightY[k], 8 * Read256BytesBlockHeightY[k]), dml_floor(ViewportYStartY[k] + ViewportHeightY[k] + 8 * Read256BytesBlockHeightY[k] - 1, 8 * Read256BytesBlockHeightY[k]) - dml_floor(ViewportYStartY[k], 8 * Read256BytesBlockHeightY[k])) * BytesPerPixelY[k] / 256);
4774 if (Read256BytesBlockWidthC[k] > 0) {
4775 SurfaceSizeInMALL[k] = (dml_uint_t)(SurfaceSizeInMALL[k] +
4776 dml_min(dml_ceil(SurfaceWidthC[k], 8 * Read256BytesBlockWidthC[k]), dml_floor(ViewportXStartC[k] + ViewportWidthC[k] + 8 * Read256BytesBlockWidthC[k] - 1, 8 * Read256BytesBlockWidthC[k]) - dml_floor(ViewportXStartC[k], 8 * Read256BytesBlockWidthC[k])) *
4777 dml_min(dml_ceil(SurfaceHeightC[k], 8 * Read256BytesBlockHeightC[k]), dml_floor(ViewportYStartC[k] + ViewportHeightC[k] + 8 * Read256BytesBlockHeightC[k] - 1, 8 * Read256BytesBlockHeightC[k]) - dml_floor(ViewportYStartC[k], 8 * Read256BytesBlockHeightC[k])) * BytesPerPixelC[k] / 256);
4778 }
4779 }
4780 } else {
4781 SurfaceSizeInMALL[k] = (dml_uint_t)(dml_ceil(dml_min(SurfaceWidthY[k], ViewportWidthY[k] + ReadBlockWidthY[k] - 1), ReadBlockWidthY[k]) * dml_ceil(dml_min(SurfaceHeightY[k], ViewportHeightY[k] + ReadBlockHeightY[k] - 1), ReadBlockHeightY[k]) * BytesPerPixelY[k]);
4782 if (ReadBlockWidthC[k] > 0) {
4783 SurfaceSizeInMALL[k] = (dml_uint_t)(SurfaceSizeInMALL[k] +
4784 dml_ceil(dml_min(SurfaceWidthC[k], ViewportWidthC[k] + ReadBlockWidthC[k] - 1), ReadBlockWidthC[k]) *
4785 dml_ceil(dml_min(SurfaceHeightC[k], ViewportHeightC[k] + ReadBlockHeightC[k] - 1), ReadBlockHeightC[k]) * BytesPerPixelC[k]);
4786 }
4787 if (DCCEnable[k] == true) {
4788 SurfaceSizeInMALL[k] = (dml_uint_t)(SurfaceSizeInMALL[k] +
4789 dml_ceil(dml_min(SurfaceWidthY[k], ViewportWidthY[k] + 8 * Read256BytesBlockWidthY[k] - 1), 8 * Read256BytesBlockWidthY[k]) *
4790 dml_ceil(dml_min(SurfaceHeightY[k], ViewportHeightY[k] + 8 * Read256BytesBlockHeightY[k] - 1), 8 * Read256BytesBlockHeightY[k]) * BytesPerPixelY[k] / 256);
4791
4792 if (Read256BytesBlockWidthC[k] > 0) {
4793 SurfaceSizeInMALL[k] = (dml_uint_t)(SurfaceSizeInMALL[k] +
4794 dml_ceil(dml_min(SurfaceWidthC[k], ViewportWidthC[k] + 8 * Read256BytesBlockWidthC[k] - 1), 8 * Read256BytesBlockWidthC[k]) *
4795 dml_ceil(dml_min(SurfaceHeightC[k], ViewportHeightC[k] + 8 * Read256BytesBlockHeightC[k] - 1), 8 * Read256BytesBlockHeightC[k]) * BytesPerPixelC[k] / 256);
4796 }
4797 }
4798 }
4799 }
4800
4801 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
4802 if (UseMALLForStaticScreen[k] == dml_use_mall_static_screen_enable)
4803 TotalSurfaceSizeInMALL = TotalSurfaceSizeInMALL + SurfaceSizeInMALL[k];
4804 }
4805 *ExceededMALLSize = (TotalSurfaceSizeInMALL > MALLAllocatedForDCN * 1024 * 1024);
4806 } // CalculateSurfaceSizeInMall
4807
CalculateDETBufferSize(dml_uint_t DETSizeOverride[],enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange[],dml_bool_t ForceSingleDPP,dml_uint_t NumberOfActiveSurfaces,dml_bool_t UnboundedRequestEnabled,dml_uint_t nomDETInKByte,dml_uint_t MaxTotalDETInKByte,dml_uint_t ConfigReturnBufferSizeInKByte,dml_uint_t MinCompressedBufferSizeInKByte,dml_uint_t ConfigReturnBufferSegmentSizeInkByte,dml_uint_t CompressedBufferSegmentSizeInkByteFinal,enum dml_source_format_class SourcePixelFormat[],dml_float_t ReadBandwidthLuma[],dml_float_t ReadBandwidthChroma[],dml_uint_t RoundedUpMaxSwathSizeBytesY[],dml_uint_t RoundedUpMaxSwathSizeBytesC[],dml_uint_t DPPPerSurface[],dml_uint_t DETBufferSizeInKByte[],dml_uint_t * CompressedBufferSizeInkByte)4808 static void CalculateDETBufferSize(
4809 dml_uint_t DETSizeOverride[],
4810 enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange[],
4811 dml_bool_t ForceSingleDPP,
4812 dml_uint_t NumberOfActiveSurfaces,
4813 dml_bool_t UnboundedRequestEnabled,
4814 dml_uint_t nomDETInKByte,
4815 dml_uint_t MaxTotalDETInKByte,
4816 dml_uint_t ConfigReturnBufferSizeInKByte,
4817 dml_uint_t MinCompressedBufferSizeInKByte,
4818 dml_uint_t ConfigReturnBufferSegmentSizeInkByte,
4819 dml_uint_t CompressedBufferSegmentSizeInkByteFinal,
4820 enum dml_source_format_class SourcePixelFormat[],
4821 dml_float_t ReadBandwidthLuma[],
4822 dml_float_t ReadBandwidthChroma[],
4823 dml_uint_t RoundedUpMaxSwathSizeBytesY[],
4824 dml_uint_t RoundedUpMaxSwathSizeBytesC[],
4825 dml_uint_t DPPPerSurface[],
4826 // Output
4827 dml_uint_t DETBufferSizeInKByte[],
4828 dml_uint_t *CompressedBufferSizeInkByte)
4829 {
4830 dml_uint_t DETBufferSizePoolInKByte;
4831 dml_uint_t NextDETBufferPieceInKByte;
4832 dml_bool_t DETPieceAssignedToThisSurfaceAlready[__DML_NUM_PLANES__];
4833 dml_bool_t NextPotentialSurfaceToAssignDETPieceFound;
4834 dml_uint_t NextSurfaceToAssignDETPiece;
4835 dml_float_t TotalBandwidth;
4836 dml_float_t BandwidthOfSurfacesNotAssignedDETPiece;
4837 dml_uint_t max_minDET;
4838 dml_uint_t minDET;
4839 dml_uint_t minDET_pipe;
4840
4841 #ifdef __DML_VBA_DEBUG__
4842 dml_print("DML::%s: ForceSingleDPP = %u\n", __func__, ForceSingleDPP);
4843 dml_print("DML::%s: nomDETInKByte = %u\n", __func__, nomDETInKByte);
4844 dml_print("DML::%s: NumberOfActiveSurfaces = %u\n", __func__, NumberOfActiveSurfaces);
4845 dml_print("DML::%s: UnboundedRequestEnabled = %u\n", __func__, UnboundedRequestEnabled);
4846 dml_print("DML::%s: MaxTotalDETInKByte = %u\n", __func__, MaxTotalDETInKByte);
4847 dml_print("DML::%s: ConfigReturnBufferSizeInKByte = %u\n", __func__, ConfigReturnBufferSizeInKByte);
4848 dml_print("DML::%s: MinCompressedBufferSizeInKByte = %u\n", __func__, MinCompressedBufferSizeInKByte);
4849 dml_print("DML::%s: CompressedBufferSegmentSizeInkByteFinal = %u\n", __func__, CompressedBufferSegmentSizeInkByteFinal);
4850 #endif
4851
4852 // Note: Will use default det size if that fits 2 swaths
4853 if (UnboundedRequestEnabled) {
4854 if (DETSizeOverride[0] > 0) {
4855 DETBufferSizeInKByte[0] = DETSizeOverride[0];
4856 } else {
4857 DETBufferSizeInKByte[0] = (dml_uint_t) dml_max(128.0, dml_ceil(2.0 * ((dml_float_t) RoundedUpMaxSwathSizeBytesY[0] + (dml_float_t) RoundedUpMaxSwathSizeBytesC[0]) / 1024.0, ConfigReturnBufferSegmentSizeInkByte));
4858 }
4859 *CompressedBufferSizeInkByte = ConfigReturnBufferSizeInKByte - DETBufferSizeInKByte[0];
4860 } else {
4861 DETBufferSizePoolInKByte = MaxTotalDETInKByte;
4862 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
4863 DETBufferSizeInKByte[k] = 0;
4864 if (SourcePixelFormat[k] == dml_420_8 || SourcePixelFormat[k] == dml_420_10 || SourcePixelFormat[k] == dml_420_12) {
4865 max_minDET = nomDETInKByte - ConfigReturnBufferSegmentSizeInkByte;
4866 } else {
4867 max_minDET = nomDETInKByte;
4868 }
4869 minDET = 128;
4870 minDET_pipe = 0;
4871
4872 // add DET resource until can hold 2 full swaths
4873 while (minDET <= max_minDET && minDET_pipe == 0) {
4874 if (2.0 * ((dml_float_t) RoundedUpMaxSwathSizeBytesY[k] + (dml_float_t) RoundedUpMaxSwathSizeBytesC[k]) / 1024.0 <= minDET)
4875 minDET_pipe = minDET;
4876 minDET = minDET + ConfigReturnBufferSegmentSizeInkByte;
4877 }
4878
4879 #ifdef __DML_VBA_DEBUG__
4880 dml_print("DML::%s: k=%u minDET = %u\n", __func__, k, minDET);
4881 dml_print("DML::%s: k=%u max_minDET = %u\n", __func__, k, max_minDET);
4882 dml_print("DML::%s: k=%u minDET_pipe = %u\n", __func__, k, minDET_pipe);
4883 dml_print("DML::%s: k=%u RoundedUpMaxSwathSizeBytesY = %u\n", __func__, k, RoundedUpMaxSwathSizeBytesY[k]);
4884 dml_print("DML::%s: k=%u RoundedUpMaxSwathSizeBytesC = %u\n", __func__, k, RoundedUpMaxSwathSizeBytesC[k]);
4885 #endif
4886
4887 if (minDET_pipe == 0) {
4888 minDET_pipe = (dml_uint_t)(dml_max(128, dml_ceil(((dml_float_t)RoundedUpMaxSwathSizeBytesY[k] + (dml_float_t)RoundedUpMaxSwathSizeBytesC[k]) / 1024.0, ConfigReturnBufferSegmentSizeInkByte)));
4889 #ifdef __DML_VBA_DEBUG__
4890 dml_print("DML::%s: k=%u minDET_pipe = %u (assume each plane take half DET)\n", __func__, k, minDET_pipe);
4891 #endif
4892 }
4893
4894 if (UseMALLForPStateChange[k] == dml_use_mall_pstate_change_phantom_pipe) {
4895 DETBufferSizeInKByte[k] = 0;
4896 } else if (DETSizeOverride[k] > 0) {
4897 DETBufferSizeInKByte[k] = DETSizeOverride[k];
4898 DETBufferSizePoolInKByte = DETBufferSizePoolInKByte - (ForceSingleDPP ? 1 : DPPPerSurface[k]) * DETSizeOverride[k];
4899 } else if ((ForceSingleDPP ? 1 : DPPPerSurface[k]) * minDET_pipe <= DETBufferSizePoolInKByte) {
4900 DETBufferSizeInKByte[k] = minDET_pipe;
4901 DETBufferSizePoolInKByte = DETBufferSizePoolInKByte - (ForceSingleDPP ? 1 : DPPPerSurface[k]) * minDET_pipe;
4902 }
4903
4904 #ifdef __DML_VBA_DEBUG__
4905 dml_print("DML::%s: k=%u DPPPerSurface = %u\n", __func__, k, DPPPerSurface[k]);
4906 dml_print("DML::%s: k=%u DETSizeOverride = %u\n", __func__, k, DETSizeOverride[k]);
4907 dml_print("DML::%s: k=%u DETBufferSizeInKByte = %u\n", __func__, k, DETBufferSizeInKByte[k]);
4908 dml_print("DML::%s: DETBufferSizePoolInKByte = %u\n", __func__, DETBufferSizePoolInKByte);
4909 #endif
4910 }
4911
4912 TotalBandwidth = 0;
4913 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
4914 if (UseMALLForPStateChange[k] != dml_use_mall_pstate_change_phantom_pipe)
4915 TotalBandwidth = TotalBandwidth + ReadBandwidthLuma[k] + ReadBandwidthChroma[k];
4916 }
4917 #ifdef __DML_VBA_DEBUG__
4918 dml_print("DML::%s: --- Before bandwidth adjustment ---\n", __func__);
4919 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
4920 dml_print("DML::%s: k=%u DETBufferSizeInKByte = %u\n", __func__, k, DETBufferSizeInKByte[k]);
4921 }
4922 dml_print("DML::%s: --- DET allocation with bandwidth ---\n", __func__);
4923 #endif
4924 dml_print("DML::%s: TotalBandwidth = %f\n", __func__, TotalBandwidth);
4925 BandwidthOfSurfacesNotAssignedDETPiece = TotalBandwidth;
4926 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
4927
4928 if (UseMALLForPStateChange[k] == dml_use_mall_pstate_change_phantom_pipe) {
4929 DETPieceAssignedToThisSurfaceAlready[k] = true;
4930 } else if (DETSizeOverride[k] > 0 || (((dml_float_t) (ForceSingleDPP ? 1 : DPPPerSurface[k]) * (dml_float_t) DETBufferSizeInKByte[k] / (dml_float_t) MaxTotalDETInKByte) >= ((ReadBandwidthLuma[k] + ReadBandwidthChroma[k]) / TotalBandwidth))) {
4931 DETPieceAssignedToThisSurfaceAlready[k] = true;
4932 BandwidthOfSurfacesNotAssignedDETPiece = BandwidthOfSurfacesNotAssignedDETPiece - ReadBandwidthLuma[k] - ReadBandwidthChroma[k];
4933 } else {
4934 DETPieceAssignedToThisSurfaceAlready[k] = false;
4935 }
4936 #ifdef __DML_VBA_DEBUG__
4937 dml_print("DML::%s: k=%u DETPieceAssignedToThisSurfaceAlready = %u\n", __func__, k, DETPieceAssignedToThisSurfaceAlready[k]);
4938 dml_print("DML::%s: k=%u BandwidthOfSurfacesNotAssignedDETPiece = %f\n", __func__, k, BandwidthOfSurfacesNotAssignedDETPiece);
4939 #endif
4940 }
4941
4942 for (dml_uint_t j = 0; j < NumberOfActiveSurfaces; ++j) {
4943 NextPotentialSurfaceToAssignDETPieceFound = false;
4944 NextSurfaceToAssignDETPiece = 0;
4945
4946 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
4947 #ifdef __DML_VBA_DEBUG__
4948 dml_print("DML::%s: j=%u k=%u, ReadBandwidthLuma[k] = %f\n", __func__, j, k, ReadBandwidthLuma[k]);
4949 dml_print("DML::%s: j=%u k=%u, ReadBandwidthChroma[k] = %f\n", __func__, j, k, ReadBandwidthChroma[k]);
4950 dml_print("DML::%s: j=%u k=%u, ReadBandwidthLuma[Next] = %f\n", __func__, j, k, ReadBandwidthLuma[NextSurfaceToAssignDETPiece]);
4951 dml_print("DML::%s: j=%u k=%u, ReadBandwidthChroma[Next] = %f\n", __func__, j, k, ReadBandwidthChroma[NextSurfaceToAssignDETPiece]);
4952 dml_print("DML::%s: j=%u k=%u, NextSurfaceToAssignDETPiece = %u\n", __func__, j, k, NextSurfaceToAssignDETPiece);
4953 #endif
4954 if (!DETPieceAssignedToThisSurfaceAlready[k] && (!NextPotentialSurfaceToAssignDETPieceFound ||
4955 ReadBandwidthLuma[k] + ReadBandwidthChroma[k] < ReadBandwidthLuma[NextSurfaceToAssignDETPiece] + ReadBandwidthChroma[NextSurfaceToAssignDETPiece])) {
4956 NextSurfaceToAssignDETPiece = k;
4957 NextPotentialSurfaceToAssignDETPieceFound = true;
4958 }
4959 #ifdef __DML_VBA_DEBUG__
4960 dml_print("DML::%s: j=%u k=%u, DETPieceAssignedToThisSurfaceAlready = %u\n", __func__, j, k, DETPieceAssignedToThisSurfaceAlready[k]);
4961 dml_print("DML::%s: j=%u k=%u, NextPotentialSurfaceToAssignDETPieceFound = %u\n", __func__, j, k, NextPotentialSurfaceToAssignDETPieceFound);
4962 #endif
4963 }
4964
4965 if (NextPotentialSurfaceToAssignDETPieceFound) {
4966 // Note: To show the banker's rounding behavior in VBA and also the fact that the DET buffer size varies due to precision issue
4967 //
4968 //dml_float_t tmp1 = ((dml_float_t) DETBufferSizePoolInKByte * (ReadBandwidthLuma[NextSurfaceToAssignDETPiece] + ReadBandwidthChroma[NextSurfaceToAssignDETPiece]) / BandwidthOfSurfacesNotAssignedDETPiece /
4969 // ((ForceSingleDPP ? 1 : DPPPerSurface[NextSurfaceToAssignDETPiece]) * 64.0));
4970 //dml_float_t tmp2 = dml_round((dml_float_t) DETBufferSizePoolInKByte * (ReadBandwidthLuma[NextSurfaceToAssignDETPiece] + ReadBandwidthChroma[NextSurfaceToAssignDETPiece]) / BandwidthOfSurfacesNotAssignedDETPiece /
4971 // ((ForceSingleDPP ? 1 : DPPPerSurface[NextSurfaceToAssignDETPiece]) * 64.0));
4972 //
4973 //dml_print("DML::%s: j=%u, tmp1 = %f\n", __func__, j, tmp1);
4974 //dml_print("DML::%s: j=%u, tmp2 = %f\n", __func__, j, tmp2);
4975
4976 NextDETBufferPieceInKByte = (dml_uint_t)(dml_min(
4977 dml_round((dml_float_t) DETBufferSizePoolInKByte * (ReadBandwidthLuma[NextSurfaceToAssignDETPiece] + ReadBandwidthChroma[NextSurfaceToAssignDETPiece]) / BandwidthOfSurfacesNotAssignedDETPiece /
4978 ((ForceSingleDPP ? 1 : DPPPerSurface[NextSurfaceToAssignDETPiece]) * ConfigReturnBufferSegmentSizeInkByte), true)
4979 * (ForceSingleDPP ? 1 : DPPPerSurface[NextSurfaceToAssignDETPiece]) * ConfigReturnBufferSegmentSizeInkByte,
4980 dml_floor((dml_float_t) DETBufferSizePoolInKByte, (ForceSingleDPP ? 1 : DPPPerSurface[NextSurfaceToAssignDETPiece]) * ConfigReturnBufferSegmentSizeInkByte)));
4981
4982 #ifdef __DML_VBA_DEBUG__
4983 dml_print("DML::%s: j=%u, DETBufferSizePoolInKByte = %u\n", __func__, j, DETBufferSizePoolInKByte);
4984 dml_print("DML::%s: j=%u, NextSurfaceToAssignDETPiece = %u\n", __func__, j, NextSurfaceToAssignDETPiece);
4985 dml_print("DML::%s: j=%u, ReadBandwidthLuma[%u] = %f\n", __func__, j, NextSurfaceToAssignDETPiece, ReadBandwidthLuma[NextSurfaceToAssignDETPiece]);
4986 dml_print("DML::%s: j=%u, ReadBandwidthChroma[%u] = %f\n", __func__, j, NextSurfaceToAssignDETPiece, ReadBandwidthChroma[NextSurfaceToAssignDETPiece]);
4987 dml_print("DML::%s: j=%u, BandwidthOfSurfacesNotAssignedDETPiece = %f\n", __func__, j, BandwidthOfSurfacesNotAssignedDETPiece);
4988 dml_print("DML::%s: j=%u, NextDETBufferPieceInKByte = %u\n", __func__, j, NextDETBufferPieceInKByte);
4989 dml_print("DML::%s: j=%u, DETBufferSizeInKByte[%u] increases from %u ", __func__, j, NextSurfaceToAssignDETPiece, DETBufferSizeInKByte[NextSurfaceToAssignDETPiece]);
4990 #endif
4991
4992 DETBufferSizeInKByte[NextSurfaceToAssignDETPiece] = DETBufferSizeInKByte[NextSurfaceToAssignDETPiece] + NextDETBufferPieceInKByte / (ForceSingleDPP ? 1 : DPPPerSurface[NextSurfaceToAssignDETPiece]);
4993 #ifdef __DML_VBA_DEBUG__
4994 dml_print("to %u\n", DETBufferSizeInKByte[NextSurfaceToAssignDETPiece]);
4995 #endif
4996
4997 DETBufferSizePoolInKByte = DETBufferSizePoolInKByte - NextDETBufferPieceInKByte;
4998 DETPieceAssignedToThisSurfaceAlready[NextSurfaceToAssignDETPiece] = true;
4999 BandwidthOfSurfacesNotAssignedDETPiece = BandwidthOfSurfacesNotAssignedDETPiece - (ReadBandwidthLuma[NextSurfaceToAssignDETPiece] + ReadBandwidthChroma[NextSurfaceToAssignDETPiece]);
5000 }
5001 }
5002 *CompressedBufferSizeInkByte = MinCompressedBufferSizeInKByte;
5003 }
5004 *CompressedBufferSizeInkByte = *CompressedBufferSizeInkByte * CompressedBufferSegmentSizeInkByteFinal / ConfigReturnBufferSegmentSizeInkByte;
5005
5006 #ifdef __DML_VBA_DEBUG__
5007 dml_print("DML::%s: --- After bandwidth adjustment ---\n", __func__);
5008 dml_print("DML::%s: CompressedBufferSizeInkByte = %u\n", __func__, *CompressedBufferSizeInkByte);
5009 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
5010 dml_print("DML::%s: k=%u DETBufferSizeInKByte = %u (TotalReadBandWidth=%f)\n", __func__, k, DETBufferSizeInKByte[k], ReadBandwidthLuma[k] + ReadBandwidthChroma[k]);
5011 }
5012 #endif
5013 } // CalculateDETBufferSize
5014
5015
5016 /// @brief Calculate the bound for return buffer sizing
CalculateMaxDETAndMinCompressedBufferSize(dml_uint_t ConfigReturnBufferSizeInKByte,dml_uint_t ConfigReturnBufferSegmentSizeInKByte,dml_uint_t ROBBufferSizeInKByte,dml_uint_t MaxNumDPP,dml_bool_t nomDETInKByteOverrideEnable,dml_uint_t nomDETInKByteOverrideValue,dml_uint_t * MaxTotalDETInKByte,dml_uint_t * nomDETInKByte,dml_uint_t * MinCompressedBufferSizeInKByte)5017 static void CalculateMaxDETAndMinCompressedBufferSize(
5018 dml_uint_t ConfigReturnBufferSizeInKByte,
5019 dml_uint_t ConfigReturnBufferSegmentSizeInKByte,
5020 dml_uint_t ROBBufferSizeInKByte,
5021 dml_uint_t MaxNumDPP,
5022 dml_bool_t nomDETInKByteOverrideEnable, // VBA_DELTA, allow DV to override default DET size
5023 dml_uint_t nomDETInKByteOverrideValue, // VBA_DELTA
5024
5025 // Output
5026 dml_uint_t *MaxTotalDETInKByte,
5027 dml_uint_t *nomDETInKByte,
5028 dml_uint_t *MinCompressedBufferSizeInKByte)
5029 {
5030 *MaxTotalDETInKByte = ConfigReturnBufferSizeInKByte - ConfigReturnBufferSegmentSizeInKByte;
5031 *nomDETInKByte = (dml_uint_t)(dml_floor((dml_float_t) *MaxTotalDETInKByte / (dml_float_t) MaxNumDPP, ConfigReturnBufferSegmentSizeInKByte));
5032 *MinCompressedBufferSizeInKByte = ConfigReturnBufferSizeInKByte - *MaxTotalDETInKByte;
5033
5034 #ifdef __DML_VBA_DEBUG__
5035 dml_print("DML::%s: ConfigReturnBufferSizeInKByte = %u\n", __func__, ConfigReturnBufferSizeInKByte);
5036 dml_print("DML::%s: ROBBufferSizeInKByte = %u\n", __func__, ROBBufferSizeInKByte);
5037 dml_print("DML::%s: MaxNumDPP = %u\n", __func__, MaxNumDPP);
5038 dml_print("DML::%s: MaxTotalDETInKByte = %u\n", __func__, *MaxTotalDETInKByte);
5039 dml_print("DML::%s: nomDETInKByte = %u\n", __func__, *nomDETInKByte);
5040 dml_print("DML::%s: MinCompressedBufferSizeInKByte = %u\n", __func__, *MinCompressedBufferSizeInKByte);
5041 #endif
5042
5043 if (nomDETInKByteOverrideEnable) {
5044 *nomDETInKByte = nomDETInKByteOverrideValue;
5045 dml_print("DML::%s: nomDETInKByte = %u (overrided)\n", __func__, *nomDETInKByte);
5046 }
5047 } // CalculateMaxDETAndMinCompressedBufferSize
5048
5049 /// @brief Calculate all the RQ request attributes, like row height and # swath
CalculateVMRowAndSwath(struct display_mode_lib_scratch_st * scratch,struct CalculateVMRowAndSwath_params_st * p)5050 static void CalculateVMRowAndSwath(struct display_mode_lib_scratch_st *scratch,
5051 struct CalculateVMRowAndSwath_params_st *p)
5052 {
5053 struct CalculateVMRowAndSwath_locals_st *s = &scratch->CalculateVMRowAndSwath_locals;
5054
5055 s->HostVMDynamicLevels = CalculateHostVMDynamicLevels(p->GPUVMEnable, p->HostVMEnable, p->HostVMMinPageSize, p->HostVMMaxNonCachedPageTableLevels);
5056
5057 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
5058 if (p->HostVMEnable == true) {
5059 p->vm_group_bytes[k] = 512;
5060 p->dpte_group_bytes[k] = 512;
5061 } else if (p->GPUVMEnable == true) {
5062 p->vm_group_bytes[k] = 2048;
5063 if (p->GPUVMMinPageSizeKBytes[k] >= 64 && dml_is_vertical_rotation(p->myPipe[k].SourceScan)) {
5064 p->dpte_group_bytes[k] = 512;
5065 } else {
5066 p->dpte_group_bytes[k] = 2048;
5067 }
5068 } else {
5069 p->vm_group_bytes[k] = 0;
5070 p->dpte_group_bytes[k] = 0;
5071 }
5072
5073 if (p->myPipe[k].SourcePixelFormat == dml_420_8 || p->myPipe[k].SourcePixelFormat == dml_420_10 ||
5074 p->myPipe[k].SourcePixelFormat == dml_420_12 || p->myPipe[k].SourcePixelFormat == dml_rgbe_alpha) {
5075 if ((p->myPipe[k].SourcePixelFormat == dml_420_10 || p->myPipe[k].SourcePixelFormat == dml_420_12) && !dml_is_vertical_rotation(p->myPipe[k].SourceScan)) {
5076 s->PTEBufferSizeInRequestsForLuma[k] = (p->PTEBufferSizeInRequestsLuma + p->PTEBufferSizeInRequestsChroma) / 2;
5077 s->PTEBufferSizeInRequestsForChroma[k] = s->PTEBufferSizeInRequestsForLuma[k];
5078 } else {
5079 s->PTEBufferSizeInRequestsForLuma[k] = p->PTEBufferSizeInRequestsLuma;
5080 s->PTEBufferSizeInRequestsForChroma[k] = p->PTEBufferSizeInRequestsChroma;
5081 }
5082
5083 s->PDEAndMetaPTEBytesFrameC = CalculateVMAndRowBytes(
5084 p->myPipe[k].ViewportStationary,
5085 p->myPipe[k].DCCEnable,
5086 p->myPipe[k].DPPPerSurface,
5087 p->myPipe[k].BlockHeight256BytesC,
5088 p->myPipe[k].BlockWidth256BytesC,
5089 p->myPipe[k].SourcePixelFormat,
5090 p->myPipe[k].SurfaceTiling,
5091 p->myPipe[k].BytePerPixelC,
5092 p->myPipe[k].SourceScan,
5093 p->SwathWidthC[k],
5094 p->myPipe[k].ViewportHeightChroma,
5095 p->myPipe[k].ViewportXStartC,
5096 p->myPipe[k].ViewportYStartC,
5097 p->GPUVMEnable,
5098 p->GPUVMMaxPageTableLevels,
5099 p->GPUVMMinPageSizeKBytes[k],
5100 s->PTEBufferSizeInRequestsForChroma[k],
5101 p->myPipe[k].PitchC,
5102 p->myPipe[k].DCCMetaPitchC,
5103 p->myPipe[k].BlockWidthC,
5104 p->myPipe[k].BlockHeightC,
5105
5106 // Output
5107 &s->MetaRowByteC[k],
5108 &s->PixelPTEBytesPerRowC[k],
5109 &s->PixelPTEBytesPerRowStorageC[k],
5110 &p->dpte_row_width_chroma_ub[k],
5111 &p->dpte_row_height_chroma[k],
5112 &p->dpte_row_height_linear_chroma[k],
5113 &s->PixelPTEBytesPerRowC_one_row_per_frame[k],
5114 &s->dpte_row_width_chroma_ub_one_row_per_frame[k],
5115 &s->dpte_row_height_chroma_one_row_per_frame[k],
5116 &p->meta_req_width_chroma[k],
5117 &p->meta_req_height_chroma[k],
5118 &p->meta_row_width_chroma[k],
5119 &p->meta_row_height_chroma[k],
5120 &p->PixelPTEReqWidthC[k],
5121 &p->PixelPTEReqHeightC[k],
5122 &p->PTERequestSizeC[k],
5123 &p->dpde0_bytes_per_frame_ub_c[k],
5124 &p->meta_pte_bytes_per_frame_ub_c[k]);
5125
5126 p->PrefetchSourceLinesC[k] = CalculatePrefetchSourceLines (
5127 p->myPipe[k].VRatioChroma,
5128 p->myPipe[k].VTapsChroma,
5129 p->myPipe[k].InterlaceEnable,
5130 p->myPipe[k].ProgressiveToInterlaceUnitInOPP,
5131 p->myPipe[k].SwathHeightC,
5132 p->myPipe[k].SourceScan,
5133 p->myPipe[k].ViewportStationary,
5134 p->SwathWidthC[k],
5135 p->myPipe[k].ViewportHeightChroma,
5136 p->myPipe[k].ViewportXStartC,
5137 p->myPipe[k].ViewportYStartC,
5138
5139 // Output
5140 &p->VInitPreFillC[k],
5141 &p->MaxNumSwathC[k]);
5142 } else {
5143 s->PTEBufferSizeInRequestsForLuma[k] = p->PTEBufferSizeInRequestsLuma + p->PTEBufferSizeInRequestsChroma;
5144 s->PTEBufferSizeInRequestsForChroma[k] = 0;
5145 s->PixelPTEBytesPerRowC[k] = 0;
5146 s->PixelPTEBytesPerRowStorageC[k] = 0;
5147 s->PDEAndMetaPTEBytesFrameC = 0;
5148 s->MetaRowByteC[k] = 0;
5149 p->MaxNumSwathC[k] = 0;
5150 p->PrefetchSourceLinesC[k] = 0;
5151 s->dpte_row_height_chroma_one_row_per_frame[k] = 0;
5152 s->dpte_row_width_chroma_ub_one_row_per_frame[k] = 0;
5153 s->PixelPTEBytesPerRowC_one_row_per_frame[k] = 0;
5154 }
5155
5156 s->PDEAndMetaPTEBytesFrameY = CalculateVMAndRowBytes(
5157 p->myPipe[k].ViewportStationary,
5158 p->myPipe[k].DCCEnable,
5159 p->myPipe[k].DPPPerSurface,
5160 p->myPipe[k].BlockHeight256BytesY,
5161 p->myPipe[k].BlockWidth256BytesY,
5162 p->myPipe[k].SourcePixelFormat,
5163 p->myPipe[k].SurfaceTiling,
5164 p->myPipe[k].BytePerPixelY,
5165 p->myPipe[k].SourceScan,
5166 p->SwathWidthY[k],
5167 p->myPipe[k].ViewportHeight,
5168 p->myPipe[k].ViewportXStart,
5169 p->myPipe[k].ViewportYStart,
5170 p->GPUVMEnable,
5171 p->GPUVMMaxPageTableLevels,
5172 p->GPUVMMinPageSizeKBytes[k],
5173 s->PTEBufferSizeInRequestsForLuma[k],
5174 p->myPipe[k].PitchY,
5175 p->myPipe[k].DCCMetaPitchY,
5176 p->myPipe[k].BlockWidthY,
5177 p->myPipe[k].BlockHeightY,
5178
5179 // Output
5180 &s->MetaRowByteY[k],
5181 &s->PixelPTEBytesPerRowY[k],
5182 &s->PixelPTEBytesPerRowStorageY[k],
5183 &p->dpte_row_width_luma_ub[k],
5184 &p->dpte_row_height_luma[k],
5185 &p->dpte_row_height_linear_luma[k],
5186 &s->PixelPTEBytesPerRowY_one_row_per_frame[k],
5187 &s->dpte_row_width_luma_ub_one_row_per_frame[k],
5188 &s->dpte_row_height_luma_one_row_per_frame[k],
5189 &p->meta_req_width[k],
5190 &p->meta_req_height[k],
5191 &p->meta_row_width[k],
5192 &p->meta_row_height[k],
5193 &p->PixelPTEReqWidthY[k],
5194 &p->PixelPTEReqHeightY[k],
5195 &p->PTERequestSizeY[k],
5196 &p->dpde0_bytes_per_frame_ub_l[k],
5197 &p->meta_pte_bytes_per_frame_ub_l[k]);
5198
5199 p->PrefetchSourceLinesY[k] = CalculatePrefetchSourceLines(
5200 p->myPipe[k].VRatio,
5201 p->myPipe[k].VTaps,
5202 p->myPipe[k].InterlaceEnable,
5203 p->myPipe[k].ProgressiveToInterlaceUnitInOPP,
5204 p->myPipe[k].SwathHeightY,
5205 p->myPipe[k].SourceScan,
5206 p->myPipe[k].ViewportStationary,
5207 p->SwathWidthY[k],
5208 p->myPipe[k].ViewportHeight,
5209 p->myPipe[k].ViewportXStart,
5210 p->myPipe[k].ViewportYStart,
5211
5212 // Output
5213 &p->VInitPreFillY[k],
5214 &p->MaxNumSwathY[k]);
5215
5216 p->PDEAndMetaPTEBytesFrame[k] = (s->PDEAndMetaPTEBytesFrameY + s->PDEAndMetaPTEBytesFrameC) * (1 + 8 * s->HostVMDynamicLevels);
5217 p->MetaRowByte[k] = s->MetaRowByteY[k] + s->MetaRowByteC[k];
5218
5219 if (s->PixelPTEBytesPerRowStorageY[k] <= 64 * s->PTEBufferSizeInRequestsForLuma[k] && s->PixelPTEBytesPerRowStorageC[k] <= 64 * s->PTEBufferSizeInRequestsForChroma[k]) {
5220 p->PTEBufferSizeNotExceeded[k] = true;
5221 } else {
5222 p->PTEBufferSizeNotExceeded[k] = false;
5223 #ifdef __DML_VBA_DEBUG__
5224 dml_print("DML::%s: k=%u, PixelPTEBytesPerRowY = %u\n", __func__, k, s->PixelPTEBytesPerRowY[k]);
5225 dml_print("DML::%s: k=%u, PixelPTEBytesPerRowC = %u\n", __func__, k, s->PixelPTEBytesPerRowC[k]);
5226 dml_print("DML::%s: k=%u, PixelPTEBytesPerRowStorageY = %u\n", __func__, k, s->PixelPTEBytesPerRowStorageY[k]);
5227 dml_print("DML::%s: k=%u, PixelPTEBytesPerRowStorageC = %u\n", __func__, k, s->PixelPTEBytesPerRowStorageC[k]);
5228 dml_print("DML::%s: k=%u, PTEBufferSizeInRequestsForLuma = %u\n", __func__, k, s->PTEBufferSizeInRequestsForLuma[k]);
5229 dml_print("DML::%s: k=%u, PTEBufferSizeInRequestsForChroma = %u\n", __func__, k, s->PTEBufferSizeInRequestsForChroma[k]);
5230 dml_print("DML::%s: k=%u, PTEBufferSizeNotExceeded = %u\n", __func__, k, p->PTEBufferSizeNotExceeded[k]);
5231 #endif
5232 }
5233 s->one_row_per_frame_fits_in_buffer[k] = (s->PixelPTEBytesPerRowY_one_row_per_frame[k] <= 64 * 2 * s->PTEBufferSizeInRequestsForLuma[k] &&
5234 s->PixelPTEBytesPerRowC_one_row_per_frame[k] <= 64 * 2 * s->PTEBufferSizeInRequestsForChroma[k]);
5235
5236 #ifdef __DML_VBA_DEBUG__
5237 dml_print("DML::%s: k=%u, PDEAndMetaPTEBytesFrame = %u\n", __func__, k, p->PDEAndMetaPTEBytesFrame[k]);
5238 dml_print("DML::%s: k=%u, PDEAndMetaPTEBytesFrameY = %u\n", __func__, k, s->PDEAndMetaPTEBytesFrameY);
5239 dml_print("DML::%s: k=%u, PDEAndMetaPTEBytesFrameC = %u\n", __func__, k, s->PDEAndMetaPTEBytesFrameC);
5240 dml_print("DML::%s: k=%u, HostVMDynamicLevels = %u\n", __func__, k, s->HostVMDynamicLevels);
5241 dml_print("DML::%s: k=%u, one_row_per_frame_fits_in_buffer = %u\n", __func__, k, s->one_row_per_frame_fits_in_buffer[k]);
5242 dml_print("DML::%s: k=%u, PixelPTEBytesPerRowY_one_row_per_frame = %u\n", __func__, k, s->PixelPTEBytesPerRowY_one_row_per_frame[k]);
5243 dml_print("DML::%s: k=%u, PixelPTEBytesPerRowC_one_row_per_frame = %u\n", __func__, k, s->PixelPTEBytesPerRowC_one_row_per_frame[k]);
5244 #endif
5245 }
5246
5247 CalculateMALLUseForStaticScreen(
5248 p->NumberOfActiveSurfaces,
5249 p->MALLAllocatedForDCN,
5250 p->UseMALLForStaticScreen, // mode
5251 p->SurfaceSizeInMALL,
5252 s->one_row_per_frame_fits_in_buffer,
5253 // Output
5254 p->UsesMALLForStaticScreen); // boolen
5255
5256 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
5257 if (p->PTEBufferModeOverrideEn[k] == 1) {
5258 p->PTE_BUFFER_MODE[k] = p->PTEBufferModeOverrideVal[k];
5259 }
5260 p->PTE_BUFFER_MODE[k] = p->myPipe[k].FORCE_ONE_ROW_FOR_FRAME || p->UsesMALLForStaticScreen[k] || (p->UseMALLForPStateChange[k] == dml_use_mall_pstate_change_sub_viewport) ||
5261 (p->UseMALLForPStateChange[k] == dml_use_mall_pstate_change_phantom_pipe) || (p->GPUVMMinPageSizeKBytes[k] > 64);
5262 p->BIGK_FRAGMENT_SIZE[k] = (dml_uint_t)(dml_log2(p->GPUVMMinPageSizeKBytes[k] * 1024) - 12);
5263 }
5264
5265 for (dml_uint_t k = 0; k < p->NumberOfActiveSurfaces; ++k) {
5266 #ifdef __DML_VBA_DEBUG__
5267 dml_print("DML::%s: k=%u, SurfaceSizeInMALL = %u\n", __func__, k, p->SurfaceSizeInMALL[k]);
5268 dml_print("DML::%s: k=%u, UsesMALLForStaticScreen = %u\n", __func__, k, p->UsesMALLForStaticScreen[k]);
5269 #endif
5270 p->use_one_row_for_frame[k] = p->myPipe[k].FORCE_ONE_ROW_FOR_FRAME || p->UsesMALLForStaticScreen[k] || (p->UseMALLForPStateChange[k] == dml_use_mall_pstate_change_sub_viewport) ||
5271 (p->UseMALLForPStateChange[k] == dml_use_mall_pstate_change_phantom_pipe) || (p->GPUVMMinPageSizeKBytes[k] > 64 && dml_is_vertical_rotation(p->myPipe[k].SourceScan));
5272
5273 p->use_one_row_for_frame_flip[k] = p->use_one_row_for_frame[k] && !(p->UseMALLForPStateChange[k] == dml_use_mall_pstate_change_full_frame);
5274
5275 if (p->use_one_row_for_frame[k]) {
5276 p->dpte_row_height_luma[k] = s->dpte_row_height_luma_one_row_per_frame[k];
5277 p->dpte_row_width_luma_ub[k] = s->dpte_row_width_luma_ub_one_row_per_frame[k];
5278 s->PixelPTEBytesPerRowY[k] = s->PixelPTEBytesPerRowY_one_row_per_frame[k];
5279 p->dpte_row_height_chroma[k] = s->dpte_row_height_chroma_one_row_per_frame[k];
5280 p->dpte_row_width_chroma_ub[k] = s->dpte_row_width_chroma_ub_one_row_per_frame[k];
5281 s->PixelPTEBytesPerRowC[k] = s->PixelPTEBytesPerRowC_one_row_per_frame[k];
5282 p->PTEBufferSizeNotExceeded[k] = s->one_row_per_frame_fits_in_buffer[k];
5283 }
5284
5285 if (p->MetaRowByte[k] <= p->DCCMetaBufferSizeBytes) {
5286 p->DCCMetaBufferSizeNotExceeded[k] = true;
5287 } else {
5288 p->DCCMetaBufferSizeNotExceeded[k] = false;
5289
5290 #ifdef __DML_VBA_DEBUG__
5291 dml_print("DML::%s: k=%u, MetaRowByte = %u\n", __func__, k, p->MetaRowByte[k]);
5292 dml_print("DML::%s: k=%u, DCCMetaBufferSizeBytes = %u\n", __func__, k, p->DCCMetaBufferSizeBytes);
5293 dml_print("DML::%s: k=%u, DCCMetaBufferSizeNotExceeded = %u\n", __func__, k, p->DCCMetaBufferSizeNotExceeded[k]);
5294 #endif
5295 }
5296 s->PixelPTEBytesPerRowY[k] = s->PixelPTEBytesPerRowY[k] * (1 + 8 * s->HostVMDynamicLevels);
5297 s->PixelPTEBytesPerRowC[k] = s->PixelPTEBytesPerRowC[k] * (1 + 8 * s->HostVMDynamicLevels);
5298 p->PixelPTEBytesPerRow[k] = s->PixelPTEBytesPerRowY[k] + s->PixelPTEBytesPerRowC[k];
5299 if (p->use_one_row_for_frame[k])
5300 p->PixelPTEBytesPerRow[k] = p->PixelPTEBytesPerRow[k] / 2;
5301
5302 CalculateRowBandwidth(
5303 p->GPUVMEnable,
5304 p->myPipe[k].SourcePixelFormat,
5305 p->myPipe[k].VRatio,
5306 p->myPipe[k].VRatioChroma,
5307 p->myPipe[k].DCCEnable,
5308 p->myPipe[k].HTotal / p->myPipe[k].PixelClock,
5309 s->MetaRowByteY[k],
5310 s->MetaRowByteC[k],
5311 p->meta_row_height[k],
5312 p->meta_row_height_chroma[k],
5313 s->PixelPTEBytesPerRowY[k],
5314 s->PixelPTEBytesPerRowC[k],
5315 p->dpte_row_height_luma[k],
5316 p->dpte_row_height_chroma[k],
5317
5318 // Output
5319 &p->meta_row_bw[k],
5320 &p->dpte_row_bw[k]);
5321 #ifdef __DML_VBA_DEBUG__
5322 dml_print("DML::%s: k=%u, use_one_row_for_frame = %u\n", __func__, k, p->use_one_row_for_frame[k]);
5323 dml_print("DML::%s: k=%u, use_one_row_for_frame_flip = %u\n", __func__, k, p->use_one_row_for_frame_flip[k]);
5324 dml_print("DML::%s: k=%u, UseMALLForPStateChange = %u\n", __func__, k, p->UseMALLForPStateChange[k]);
5325 dml_print("DML::%s: k=%u, dpte_row_height_luma = %u\n", __func__, k, p->dpte_row_height_luma[k]);
5326 dml_print("DML::%s: k=%u, dpte_row_width_luma_ub = %u\n", __func__, k, p->dpte_row_width_luma_ub[k]);
5327 dml_print("DML::%s: k=%u, PixelPTEBytesPerRowY = %u\n", __func__, k, s->PixelPTEBytesPerRowY[k]);
5328 dml_print("DML::%s: k=%u, dpte_row_height_chroma = %u\n", __func__, k, p->dpte_row_height_chroma[k]);
5329 dml_print("DML::%s: k=%u, dpte_row_width_chroma_ub = %u\n", __func__, k, p->dpte_row_width_chroma_ub[k]);
5330 dml_print("DML::%s: k=%u, PixelPTEBytesPerRowC = %u\n", __func__, k, s->PixelPTEBytesPerRowC[k]);
5331 dml_print("DML::%s: k=%u, PixelPTEBytesPerRow = %u\n", __func__, k, p->PixelPTEBytesPerRow[k]);
5332 dml_print("DML::%s: k=%u, PTEBufferSizeNotExceeded = %u\n", __func__, k, p->PTEBufferSizeNotExceeded[k]);
5333 dml_print("DML::%s: k=%u, PTE_BUFFER_MODE = %u\n", __func__, k, p->PTE_BUFFER_MODE[k]);
5334 dml_print("DML::%s: k=%u, BIGK_FRAGMENT_SIZE = %u\n", __func__, k, p->BIGK_FRAGMENT_SIZE[k]);
5335 #endif
5336 }
5337 }
5338
CalculateOutputLink(dml_float_t PHYCLKPerState,dml_float_t PHYCLKD18PerState,dml_float_t PHYCLKD32PerState,dml_float_t Downspreading,dml_bool_t IsMainSurfaceUsingTheIndicatedTiming,enum dml_output_encoder_class Output,enum dml_output_format_class OutputFormat,dml_uint_t HTotal,dml_uint_t HActive,dml_float_t PixelClockBackEnd,dml_float_t ForcedOutputLinkBPP,dml_uint_t DSCInputBitPerComponent,dml_uint_t NumberOfDSCSlices,dml_float_t AudioSampleRate,dml_uint_t AudioSampleLayout,enum dml_odm_mode ODMModeNoDSC,enum dml_odm_mode ODMModeDSC,enum dml_dsc_enable DSCEnable,dml_uint_t OutputLinkDPLanes,enum dml_output_link_dp_rate OutputLinkDPRate,dml_bool_t * RequiresDSC,dml_bool_t * RequiresFEC,dml_float_t * OutBpp,enum dml_output_type_and_rate__type * OutputType,enum dml_output_type_and_rate__rate * OutputRate,dml_uint_t * RequiredSlots)5339 static void CalculateOutputLink(
5340 dml_float_t PHYCLKPerState,
5341 dml_float_t PHYCLKD18PerState,
5342 dml_float_t PHYCLKD32PerState,
5343 dml_float_t Downspreading,
5344 dml_bool_t IsMainSurfaceUsingTheIndicatedTiming,
5345 enum dml_output_encoder_class Output,
5346 enum dml_output_format_class OutputFormat,
5347 dml_uint_t HTotal,
5348 dml_uint_t HActive,
5349 dml_float_t PixelClockBackEnd,
5350 dml_float_t ForcedOutputLinkBPP,
5351 dml_uint_t DSCInputBitPerComponent,
5352 dml_uint_t NumberOfDSCSlices,
5353 dml_float_t AudioSampleRate,
5354 dml_uint_t AudioSampleLayout,
5355 enum dml_odm_mode ODMModeNoDSC,
5356 enum dml_odm_mode ODMModeDSC,
5357 enum dml_dsc_enable DSCEnable,
5358 dml_uint_t OutputLinkDPLanes,
5359 enum dml_output_link_dp_rate OutputLinkDPRate,
5360
5361 // Output
5362 dml_bool_t *RequiresDSC,
5363 dml_bool_t *RequiresFEC,
5364 dml_float_t *OutBpp,
5365 enum dml_output_type_and_rate__type *OutputType,
5366 enum dml_output_type_and_rate__rate *OutputRate,
5367 dml_uint_t *RequiredSlots)
5368 {
5369 dml_bool_t LinkDSCEnable;
5370 dml_uint_t dummy;
5371 *RequiresDSC = false;
5372 *RequiresFEC = false;
5373 *OutBpp = 0;
5374
5375 *OutputType = dml_output_type_unknown;
5376 *OutputRate = dml_output_rate_unknown;
5377
5378 if (IsMainSurfaceUsingTheIndicatedTiming) {
5379 if (Output == dml_hdmi) {
5380 *RequiresDSC = false;
5381 *RequiresFEC = false;
5382 *OutBpp = TruncToValidBPP(dml_min(600, PHYCLKPerState) * 10, 3, HTotal, HActive, PixelClockBackEnd, ForcedOutputLinkBPP, false, Output,
5383 OutputFormat, DSCInputBitPerComponent, NumberOfDSCSlices, (dml_uint_t)AudioSampleRate, AudioSampleLayout, ODMModeNoDSC, ODMModeDSC, &dummy);
5384 //OutputTypeAndRate = "HDMI";
5385 *OutputType = dml_output_type_hdmi;
5386
5387 } else if (Output == dml_dp || Output == dml_dp2p0 || Output == dml_edp) {
5388 if (DSCEnable == dml_dsc_enable) {
5389 *RequiresDSC = true;
5390 LinkDSCEnable = true;
5391 if (Output == dml_dp || Output == dml_dp2p0) {
5392 *RequiresFEC = true;
5393 } else {
5394 *RequiresFEC = false;
5395 }
5396 } else {
5397 *RequiresDSC = false;
5398 LinkDSCEnable = false;
5399 if (Output == dml_dp2p0) {
5400 *RequiresFEC = true;
5401 } else {
5402 *RequiresFEC = false;
5403 }
5404 }
5405 if (Output == dml_dp2p0) {
5406 *OutBpp = 0;
5407 if ((OutputLinkDPRate == dml_dp_rate_na || OutputLinkDPRate == dml_dp_rate_uhbr10) && PHYCLKD32PerState >= 10000 / 32.0) {
5408 *OutBpp = TruncToValidBPP((1 - Downspreading / 100) * 10000, OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd, ForcedOutputLinkBPP, LinkDSCEnable, Output,
5409 OutputFormat, DSCInputBitPerComponent, NumberOfDSCSlices, (dml_uint_t)AudioSampleRate, AudioSampleLayout, ODMModeNoDSC, ODMModeDSC, RequiredSlots);
5410 if (*OutBpp == 0 && PHYCLKD32PerState < 13500 / 32.0 && DSCEnable == dml_dsc_enable_if_necessary && ForcedOutputLinkBPP == 0) {
5411 *RequiresDSC = true;
5412 LinkDSCEnable = true;
5413 *OutBpp = TruncToValidBPP((1 - Downspreading / 100) * 10000, OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd, ForcedOutputLinkBPP, LinkDSCEnable, Output,
5414 OutputFormat, DSCInputBitPerComponent, NumberOfDSCSlices, (dml_uint_t)AudioSampleRate, AudioSampleLayout, ODMModeNoDSC, ODMModeDSC, RequiredSlots);
5415 }
5416 //OutputTypeAndRate = Output & " UHBR10";
5417 *OutputType = dml_output_type_dp2p0;
5418 *OutputRate = dml_output_rate_dp_rate_uhbr10;
5419 }
5420 if ((OutputLinkDPRate == dml_dp_rate_na || OutputLinkDPRate == dml_dp_rate_uhbr13p5) && *OutBpp == 0 && PHYCLKD32PerState >= 13500 / 32.0) {
5421 *OutBpp = TruncToValidBPP((1 - Downspreading / 100) * 13500, OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd, ForcedOutputLinkBPP, LinkDSCEnable, Output,
5422 OutputFormat, DSCInputBitPerComponent, NumberOfDSCSlices, (dml_uint_t)AudioSampleRate, AudioSampleLayout, ODMModeNoDSC, ODMModeDSC, RequiredSlots);
5423
5424 if (*OutBpp == 0 && PHYCLKD32PerState < 20000 / 32 && DSCEnable == dml_dsc_enable_if_necessary && ForcedOutputLinkBPP == 0) {
5425 *RequiresDSC = true;
5426 LinkDSCEnable = true;
5427 *OutBpp = TruncToValidBPP((1 - Downspreading / 100) * 13500, OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd, ForcedOutputLinkBPP, LinkDSCEnable, Output,
5428 OutputFormat, DSCInputBitPerComponent, NumberOfDSCSlices, (dml_uint_t)AudioSampleRate, AudioSampleLayout, ODMModeNoDSC, ODMModeDSC, RequiredSlots);
5429 }
5430 //OutputTypeAndRate = Output & " UHBR13p5";
5431 *OutputType = dml_output_type_dp2p0;
5432 *OutputRate = dml_output_rate_dp_rate_uhbr13p5;
5433 }
5434 if ((OutputLinkDPRate == dml_dp_rate_na || OutputLinkDPRate == dml_dp_rate_uhbr20) && *OutBpp == 0 && PHYCLKD32PerState >= 20000 / 32) {
5435 *OutBpp = TruncToValidBPP((1 - Downspreading / 100) * 20000, OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd, ForcedOutputLinkBPP, LinkDSCEnable, Output,
5436 OutputFormat, DSCInputBitPerComponent, NumberOfDSCSlices, (dml_uint_t)AudioSampleRate, AudioSampleLayout, ODMModeNoDSC, ODMModeDSC, RequiredSlots);
5437 if (*OutBpp == 0 && DSCEnable == dml_dsc_enable_if_necessary && ForcedOutputLinkBPP == 0) {
5438 *RequiresDSC = true;
5439 LinkDSCEnable = true;
5440 *OutBpp = TruncToValidBPP((1 - Downspreading / 100) * 20000, OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd, ForcedOutputLinkBPP, LinkDSCEnable, Output,
5441 OutputFormat, DSCInputBitPerComponent, NumberOfDSCSlices, (dml_uint_t)AudioSampleRate, AudioSampleLayout, ODMModeNoDSC, ODMModeDSC, RequiredSlots);
5442 }
5443 //OutputTypeAndRate = Output & " UHBR20";
5444 *OutputType = dml_output_type_dp2p0;
5445 *OutputRate = dml_output_rate_dp_rate_uhbr20;
5446 }
5447 } else { // output is dp or edp
5448 *OutBpp = 0;
5449 if ((OutputLinkDPRate == dml_dp_rate_na || OutputLinkDPRate == dml_dp_rate_hbr) && PHYCLKPerState >= 270) {
5450 *OutBpp = TruncToValidBPP((1 - Downspreading / 100) * 2700, OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd, ForcedOutputLinkBPP, LinkDSCEnable, Output,
5451 OutputFormat, DSCInputBitPerComponent, NumberOfDSCSlices, (dml_uint_t)AudioSampleRate, AudioSampleLayout, ODMModeNoDSC, ODMModeDSC, RequiredSlots);
5452 if (*OutBpp == 0 && PHYCLKPerState < 540 && DSCEnable == dml_dsc_enable_if_necessary && ForcedOutputLinkBPP == 0) {
5453 *RequiresDSC = true;
5454 LinkDSCEnable = true;
5455 if (Output == dml_dp) {
5456 *RequiresFEC = true;
5457 }
5458 *OutBpp = TruncToValidBPP((1 - Downspreading / 100) * 2700, OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd, ForcedOutputLinkBPP, LinkDSCEnable, Output,
5459 OutputFormat, DSCInputBitPerComponent, NumberOfDSCSlices, (dml_uint_t)AudioSampleRate, AudioSampleLayout, ODMModeNoDSC, ODMModeDSC, RequiredSlots);
5460 }
5461 //OutputTypeAndRate = Output & " HBR";
5462 *OutputType = (Output == dml_dp) ? dml_output_type_dp : dml_output_type_edp;
5463 *OutputRate = dml_output_rate_dp_rate_hbr;
5464 }
5465 if ((OutputLinkDPRate == dml_dp_rate_na || OutputLinkDPRate == dml_dp_rate_hbr2) && *OutBpp == 0 && PHYCLKPerState >= 540) {
5466 *OutBpp = TruncToValidBPP((1 - Downspreading / 100) * 5400, OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd, ForcedOutputLinkBPP, LinkDSCEnable, Output,
5467 OutputFormat, DSCInputBitPerComponent, NumberOfDSCSlices, (dml_uint_t)AudioSampleRate, AudioSampleLayout, ODMModeNoDSC, ODMModeDSC, RequiredSlots);
5468
5469 if (*OutBpp == 0 && PHYCLKPerState < 810 && DSCEnable == dml_dsc_enable_if_necessary && ForcedOutputLinkBPP == 0) {
5470 *RequiresDSC = true;
5471 LinkDSCEnable = true;
5472 if (Output == dml_dp) {
5473 *RequiresFEC = true;
5474 }
5475 *OutBpp = TruncToValidBPP((1 - Downspreading / 100) * 5400, OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd, ForcedOutputLinkBPP, LinkDSCEnable, Output,
5476 OutputFormat, DSCInputBitPerComponent, NumberOfDSCSlices, (dml_uint_t)AudioSampleRate, AudioSampleLayout, ODMModeNoDSC, ODMModeDSC, RequiredSlots);
5477 }
5478 //OutputTypeAndRate = Output & " HBR2";
5479 *OutputType = (Output == dml_dp) ? dml_output_type_dp : dml_output_type_edp;
5480 *OutputRate = dml_output_rate_dp_rate_hbr2;
5481 }
5482 if ((OutputLinkDPRate == dml_dp_rate_na || OutputLinkDPRate == dml_dp_rate_hbr3) && *OutBpp == 0 && PHYCLKPerState >= 810) { // VBA_ERROR, vba code doesn't have hbr3 check
5483 *OutBpp = TruncToValidBPP((1 - Downspreading / 100) * 8100, OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd, ForcedOutputLinkBPP, LinkDSCEnable, Output,
5484 OutputFormat, DSCInputBitPerComponent, NumberOfDSCSlices, (dml_uint_t)AudioSampleRate, AudioSampleLayout, ODMModeNoDSC, ODMModeDSC, RequiredSlots);
5485
5486 if (*OutBpp == 0 && DSCEnable == dml_dsc_enable_if_necessary && ForcedOutputLinkBPP == 0) {
5487 *RequiresDSC = true;
5488 LinkDSCEnable = true;
5489 if (Output == dml_dp) {
5490 *RequiresFEC = true;
5491 }
5492 *OutBpp = TruncToValidBPP((1 - Downspreading / 100) * 8100, OutputLinkDPLanes, HTotal, HActive, PixelClockBackEnd, ForcedOutputLinkBPP, LinkDSCEnable, Output,
5493 OutputFormat, DSCInputBitPerComponent, NumberOfDSCSlices, (dml_uint_t)AudioSampleRate, AudioSampleLayout, ODMModeNoDSC, ODMModeDSC, RequiredSlots);
5494 }
5495 //OutputTypeAndRate = Output & " HBR3";
5496 *OutputType = (Output == dml_dp) ? dml_output_type_dp : dml_output_type_edp;
5497 *OutputRate = dml_output_rate_dp_rate_hbr3;
5498 }
5499 }
5500 }
5501 }
5502 }
5503
5504 /// @brief Determine the ODM mode and number of DPP used per plane based on dispclk, dsc usage, odm usage policy
CalculateODMMode(dml_uint_t MaximumPixelsPerLinePerDSCUnit,dml_uint_t HActive,enum dml_output_encoder_class Output,enum dml_output_format_class OutputFormat,enum dml_odm_use_policy ODMUse,dml_float_t StateDispclk,dml_float_t MaxDispclk,dml_bool_t DSCEnable,dml_uint_t TotalNumberOfActiveDPP,dml_uint_t MaxNumDPP,dml_float_t PixelClock,dml_float_t DISPCLKDPPCLKDSCCLKDownSpreading,dml_float_t DISPCLKRampingMargin,dml_float_t DISPCLKDPPCLKVCOSpeed,dml_uint_t NumberOfDSCSlices,dml_bool_t * TotalAvailablePipesSupport,dml_uint_t * NumberOfDPP,enum dml_odm_mode * ODMMode,dml_float_t * RequiredDISPCLKPerSurface)5505 static void CalculateODMMode(
5506 dml_uint_t MaximumPixelsPerLinePerDSCUnit,
5507 dml_uint_t HActive,
5508 enum dml_output_encoder_class Output,
5509 enum dml_output_format_class OutputFormat,
5510 enum dml_odm_use_policy ODMUse,
5511 dml_float_t StateDispclk,
5512 dml_float_t MaxDispclk,
5513 dml_bool_t DSCEnable,
5514 dml_uint_t TotalNumberOfActiveDPP,
5515 dml_uint_t MaxNumDPP,
5516 dml_float_t PixelClock,
5517 dml_float_t DISPCLKDPPCLKDSCCLKDownSpreading,
5518 dml_float_t DISPCLKRampingMargin,
5519 dml_float_t DISPCLKDPPCLKVCOSpeed,
5520 dml_uint_t NumberOfDSCSlices,
5521
5522 // Output
5523 dml_bool_t *TotalAvailablePipesSupport,
5524 dml_uint_t *NumberOfDPP,
5525 enum dml_odm_mode *ODMMode,
5526 dml_float_t *RequiredDISPCLKPerSurface)
5527 {
5528
5529 dml_float_t SurfaceRequiredDISPCLKWithoutODMCombine;
5530 dml_float_t SurfaceRequiredDISPCLKWithODMCombineTwoToOne;
5531 dml_float_t SurfaceRequiredDISPCLKWithODMCombineFourToOne;
5532
5533 SurfaceRequiredDISPCLKWithoutODMCombine = CalculateRequiredDispclk(dml_odm_mode_bypass, PixelClock, DISPCLKDPPCLKDSCCLKDownSpreading, DISPCLKRampingMargin, DISPCLKDPPCLKVCOSpeed, MaxDispclk);
5534 SurfaceRequiredDISPCLKWithODMCombineTwoToOne = CalculateRequiredDispclk(dml_odm_mode_combine_2to1, PixelClock, DISPCLKDPPCLKDSCCLKDownSpreading, DISPCLKRampingMargin, DISPCLKDPPCLKVCOSpeed, MaxDispclk);
5535 SurfaceRequiredDISPCLKWithODMCombineFourToOne = CalculateRequiredDispclk(dml_odm_mode_combine_4to1, PixelClock, DISPCLKDPPCLKDSCCLKDownSpreading, DISPCLKRampingMargin, DISPCLKDPPCLKVCOSpeed, MaxDispclk);
5536 *TotalAvailablePipesSupport = true;
5537
5538 if (OutputFormat == dml_420) {
5539 if (HActive > 4 * DML2_MAX_FMT_420_BUFFER_WIDTH)
5540 *TotalAvailablePipesSupport = false;
5541 else if (HActive > 2 * DML2_MAX_FMT_420_BUFFER_WIDTH)
5542 ODMUse = dml_odm_use_policy_combine_4to1;
5543 else if (HActive > DML2_MAX_FMT_420_BUFFER_WIDTH && ODMUse != dml_odm_use_policy_combine_4to1)
5544 ODMUse = dml_odm_use_policy_combine_2to1;
5545 if (Output == dml_hdmi && ODMUse == dml_odm_use_policy_combine_2to1)
5546 *TotalAvailablePipesSupport = false;
5547 if ((Output == dml_hdmi || Output == dml_dp || Output == dml_edp) && ODMUse == dml_odm_use_policy_combine_4to1)
5548 *TotalAvailablePipesSupport = false;
5549 }
5550
5551 if (ODMUse == dml_odm_use_policy_bypass || ODMUse == dml_odm_use_policy_combine_as_needed)
5552 *ODMMode = dml_odm_mode_bypass;
5553 else if (ODMUse == dml_odm_use_policy_combine_2to1)
5554 *ODMMode = dml_odm_mode_combine_2to1;
5555 else if (ODMUse == dml_odm_use_policy_combine_4to1)
5556 *ODMMode = dml_odm_mode_combine_4to1;
5557 else if (ODMUse == dml_odm_use_policy_split_1to2)
5558 *ODMMode = dml_odm_mode_split_1to2;
5559 else if (ODMUse == dml_odm_use_policy_mso_1to2)
5560 *ODMMode = dml_odm_mode_mso_1to2;
5561 else if (ODMUse == dml_odm_use_policy_mso_1to4)
5562 *ODMMode = dml_odm_mode_mso_1to4;
5563
5564 *RequiredDISPCLKPerSurface = SurfaceRequiredDISPCLKWithoutODMCombine;
5565 *NumberOfDPP = 0;
5566
5567 if (!(Output == dml_hdmi || Output == dml_dp || Output == dml_edp) && (ODMUse == dml_odm_use_policy_combine_4to1 || (ODMUse == dml_odm_use_policy_combine_as_needed &&
5568 (SurfaceRequiredDISPCLKWithODMCombineTwoToOne > StateDispclk || (DSCEnable && (HActive > 2 * MaximumPixelsPerLinePerDSCUnit)) || NumberOfDSCSlices > 8)))) {
5569 if (TotalNumberOfActiveDPP + 4 <= MaxNumDPP) {
5570 *ODMMode = dml_odm_mode_combine_4to1;
5571 *RequiredDISPCLKPerSurface = SurfaceRequiredDISPCLKWithODMCombineFourToOne;
5572 *NumberOfDPP = 4;
5573 } else {
5574 *TotalAvailablePipesSupport = false;
5575 }
5576 } else if (Output != dml_hdmi && (ODMUse == dml_odm_use_policy_combine_2to1 || (ODMUse == dml_odm_use_policy_combine_as_needed &&
5577 ((SurfaceRequiredDISPCLKWithoutODMCombine > StateDispclk && SurfaceRequiredDISPCLKWithODMCombineTwoToOne <= StateDispclk) ||
5578 (DSCEnable && (HActive > MaximumPixelsPerLinePerDSCUnit)) || (NumberOfDSCSlices <= 8 && NumberOfDSCSlices > 4))))) {
5579 if (TotalNumberOfActiveDPP + 2 <= MaxNumDPP) {
5580 *ODMMode = dml_odm_mode_combine_2to1;
5581 *RequiredDISPCLKPerSurface = SurfaceRequiredDISPCLKWithODMCombineTwoToOne;
5582 *NumberOfDPP = 2;
5583 } else {
5584 *TotalAvailablePipesSupport = false;
5585 }
5586 } else {
5587 if (TotalNumberOfActiveDPP + 1 <= MaxNumDPP) {
5588 *NumberOfDPP = 1;
5589 } else {
5590 *TotalAvailablePipesSupport = false;
5591 }
5592 }
5593 }
5594
5595 /// @brief Calculate the required DISPCLK given the odm mode and pixclk
CalculateRequiredDispclk(enum dml_odm_mode ODMMode,dml_float_t PixelClock,dml_float_t DISPCLKDPPCLKDSCCLKDownSpreading,dml_float_t DISPCLKRampingMargin,dml_float_t DISPCLKDPPCLKVCOSpeed,dml_float_t MaxDispclk)5596 static dml_float_t CalculateRequiredDispclk(
5597 enum dml_odm_mode ODMMode,
5598 dml_float_t PixelClock,
5599 dml_float_t DISPCLKDPPCLKDSCCLKDownSpreading,
5600 dml_float_t DISPCLKRampingMargin,
5601 dml_float_t DISPCLKDPPCLKVCOSpeed,
5602 dml_float_t MaxDispclk)
5603 {
5604 dml_float_t RequiredDispclk = 0.;
5605 dml_float_t PixelClockAfterODM;
5606
5607 dml_float_t DISPCLKWithRampingRoundedToDFSGranularity;
5608 dml_float_t DISPCLKWithoutRampingRoundedToDFSGranularity;
5609 dml_float_t MaxDispclkRoundedDownToDFSGranularity;
5610
5611 if (ODMMode == dml_odm_mode_combine_4to1) {
5612 PixelClockAfterODM = PixelClock / 4;
5613 } else if (ODMMode == dml_odm_mode_combine_2to1) {
5614 PixelClockAfterODM = PixelClock / 2;
5615 } else {
5616 PixelClockAfterODM = PixelClock;
5617 }
5618
5619 DISPCLKWithRampingRoundedToDFSGranularity = RoundToDFSGranularity(PixelClockAfterODM * (1.0 + DISPCLKDPPCLKDSCCLKDownSpreading / 100.0) * (1 + DISPCLKRampingMargin / 100.0), 1, DISPCLKDPPCLKVCOSpeed);
5620 DISPCLKWithoutRampingRoundedToDFSGranularity = RoundToDFSGranularity(PixelClockAfterODM * (1.0 + DISPCLKDPPCLKDSCCLKDownSpreading / 100.0), 1, DISPCLKDPPCLKVCOSpeed);
5621 MaxDispclkRoundedDownToDFSGranularity = RoundToDFSGranularity(MaxDispclk, 0, DISPCLKDPPCLKVCOSpeed);
5622
5623 if (DISPCLKWithoutRampingRoundedToDFSGranularity > MaxDispclkRoundedDownToDFSGranularity) {
5624 RequiredDispclk = DISPCLKWithoutRampingRoundedToDFSGranularity;
5625 } else if (DISPCLKWithRampingRoundedToDFSGranularity > MaxDispclkRoundedDownToDFSGranularity) {
5626 RequiredDispclk = MaxDispclkRoundedDownToDFSGranularity;
5627 } else {
5628 RequiredDispclk = DISPCLKWithRampingRoundedToDFSGranularity;
5629 }
5630
5631 return RequiredDispclk;
5632 }
5633
5634 /// @brief Determine DPPCLK if there only one DPP per plane, main factor is the pixel rate and DPP scaling parameter
CalculateSinglePipeDPPCLKAndSCLThroughput(dml_float_t HRatio,dml_float_t HRatioChroma,dml_float_t VRatio,dml_float_t VRatioChroma,dml_float_t MaxDCHUBToPSCLThroughput,dml_float_t MaxPSCLToLBThroughput,dml_float_t PixelClock,enum dml_source_format_class SourcePixelFormat,dml_uint_t HTaps,dml_uint_t HTapsChroma,dml_uint_t VTaps,dml_uint_t VTapsChroma,dml_float_t * PSCL_THROUGHPUT,dml_float_t * PSCL_THROUGHPUT_CHROMA,dml_float_t * DPPCLKUsingSingleDPP)5635 static void CalculateSinglePipeDPPCLKAndSCLThroughput(
5636 dml_float_t HRatio,
5637 dml_float_t HRatioChroma,
5638 dml_float_t VRatio,
5639 dml_float_t VRatioChroma,
5640 dml_float_t MaxDCHUBToPSCLThroughput,
5641 dml_float_t MaxPSCLToLBThroughput,
5642 dml_float_t PixelClock,
5643 enum dml_source_format_class SourcePixelFormat,
5644 dml_uint_t HTaps,
5645 dml_uint_t HTapsChroma,
5646 dml_uint_t VTaps,
5647 dml_uint_t VTapsChroma,
5648
5649 // Output
5650 dml_float_t *PSCL_THROUGHPUT,
5651 dml_float_t *PSCL_THROUGHPUT_CHROMA,
5652 dml_float_t *DPPCLKUsingSingleDPP)
5653 {
5654 dml_float_t DPPCLKUsingSingleDPPLuma;
5655 dml_float_t DPPCLKUsingSingleDPPChroma;
5656
5657 if (HRatio > 1) {
5658 *PSCL_THROUGHPUT = dml_min(MaxDCHUBToPSCLThroughput, MaxPSCLToLBThroughput * HRatio / dml_ceil((dml_float_t) HTaps / 6.0, 1.0));
5659 } else {
5660 *PSCL_THROUGHPUT = dml_min(MaxDCHUBToPSCLThroughput, MaxPSCLToLBThroughput);
5661 }
5662
5663 DPPCLKUsingSingleDPPLuma = PixelClock * dml_max3(VTaps / 6 * dml_min(1, HRatio), HRatio * VRatio / *PSCL_THROUGHPUT, 1);
5664
5665 if ((HTaps > 6 || VTaps > 6) && DPPCLKUsingSingleDPPLuma < 2 * PixelClock)
5666 DPPCLKUsingSingleDPPLuma = 2 * PixelClock;
5667
5668 if ((SourcePixelFormat != dml_420_8 && SourcePixelFormat != dml_420_10 && SourcePixelFormat != dml_420_12 && SourcePixelFormat != dml_rgbe_alpha)) {
5669 *PSCL_THROUGHPUT_CHROMA = 0;
5670 *DPPCLKUsingSingleDPP = DPPCLKUsingSingleDPPLuma;
5671 } else {
5672 if (HRatioChroma > 1) {
5673 *PSCL_THROUGHPUT_CHROMA = dml_min(MaxDCHUBToPSCLThroughput, MaxPSCLToLBThroughput * HRatioChroma / dml_ceil((dml_float_t) HTapsChroma / 6.0, 1.0));
5674 } else {
5675 *PSCL_THROUGHPUT_CHROMA = dml_min(MaxDCHUBToPSCLThroughput, MaxPSCLToLBThroughput);
5676 }
5677 DPPCLKUsingSingleDPPChroma = PixelClock * dml_max3(VTapsChroma / 6 * dml_min(1, HRatioChroma),
5678 HRatioChroma * VRatioChroma / *PSCL_THROUGHPUT_CHROMA, 1);
5679 if ((HTapsChroma > 6 || VTapsChroma > 6) && DPPCLKUsingSingleDPPChroma < 2 * PixelClock)
5680 DPPCLKUsingSingleDPPChroma = 2 * PixelClock;
5681 *DPPCLKUsingSingleDPP = dml_max(DPPCLKUsingSingleDPPLuma, DPPCLKUsingSingleDPPChroma);
5682 }
5683 }
5684
5685 /// @brief Calculate the actual dppclk freq
5686 /// @param DPPCLKUsingSingleDPP DppClk freq required if there is only 1 DPP per plane
5687 /// @param DPPPerSurface Number of DPP for each plane
CalculateDPPCLK(dml_uint_t NumberOfActiveSurfaces,dml_float_t DISPCLKDPPCLKDSCCLKDownSpreading,dml_float_t DISPCLKDPPCLKVCOSpeed,dml_float_t DPPCLKUsingSingleDPP[],dml_uint_t DPPPerSurface[],dml_float_t * GlobalDPPCLK,dml_float_t Dppclk[])5688 static void CalculateDPPCLK(
5689 dml_uint_t NumberOfActiveSurfaces,
5690 dml_float_t DISPCLKDPPCLKDSCCLKDownSpreading,
5691 dml_float_t DISPCLKDPPCLKVCOSpeed,
5692 dml_float_t DPPCLKUsingSingleDPP[],
5693 dml_uint_t DPPPerSurface[],
5694
5695 // Output
5696 dml_float_t *GlobalDPPCLK,
5697 dml_float_t Dppclk[])
5698 {
5699 *GlobalDPPCLK = 0;
5700 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
5701 Dppclk[k] = DPPCLKUsingSingleDPP[k] / DPPPerSurface[k] * (1 + DISPCLKDPPCLKDSCCLKDownSpreading / 100.0);
5702 *GlobalDPPCLK = dml_max(*GlobalDPPCLK, Dppclk[k]);
5703 }
5704 *GlobalDPPCLK = RoundToDFSGranularity(*GlobalDPPCLK, 1, DISPCLKDPPCLKVCOSpeed);
5705
5706 dml_print("DML::%s: GlobalDPPCLK = %f\n", __func__, *GlobalDPPCLK);
5707 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
5708 Dppclk[k] = *GlobalDPPCLK / 255.0 * dml_ceil(Dppclk[k] * 255.0 / *GlobalDPPCLK, 1.0);
5709 dml_print("DML::%s: Dppclk[%0d] = %f\n", __func__, k, Dppclk[k]);
5710 }
5711 }
5712
CalculateMALLUseForStaticScreen(dml_uint_t NumberOfActiveSurfaces,dml_uint_t MALLAllocatedForDCNFinal,enum dml_use_mall_for_static_screen_mode * UseMALLForStaticScreen,dml_uint_t SurfaceSizeInMALL[],dml_bool_t one_row_per_frame_fits_in_buffer[],dml_bool_t UsesMALLForStaticScreen[])5713 static void CalculateMALLUseForStaticScreen(
5714 dml_uint_t NumberOfActiveSurfaces,
5715 dml_uint_t MALLAllocatedForDCNFinal,
5716 enum dml_use_mall_for_static_screen_mode *UseMALLForStaticScreen,
5717 dml_uint_t SurfaceSizeInMALL[],
5718 dml_bool_t one_row_per_frame_fits_in_buffer[],
5719
5720 // Output
5721 dml_bool_t UsesMALLForStaticScreen[])
5722 {
5723
5724 dml_uint_t SurfaceToAddToMALL;
5725 dml_bool_t CanAddAnotherSurfaceToMALL;
5726 dml_uint_t TotalSurfaceSizeInMALL;
5727
5728 TotalSurfaceSizeInMALL = 0;
5729 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
5730 UsesMALLForStaticScreen[k] = (UseMALLForStaticScreen[k] == dml_use_mall_static_screen_enable);
5731 if (UsesMALLForStaticScreen[k])
5732 TotalSurfaceSizeInMALL = TotalSurfaceSizeInMALL + SurfaceSizeInMALL[k];
5733 #ifdef __DML_VBA_DEBUG__
5734 dml_print("DML::%s: k=%u, UsesMALLForStaticScreen = %u\n", __func__, k, UsesMALLForStaticScreen[k]);
5735 dml_print("DML::%s: k=%u, TotalSurfaceSizeInMALL = %u\n", __func__, k, TotalSurfaceSizeInMALL);
5736 #endif
5737 }
5738
5739 SurfaceToAddToMALL = 0;
5740 CanAddAnotherSurfaceToMALL = true;
5741 while (CanAddAnotherSurfaceToMALL) {
5742 CanAddAnotherSurfaceToMALL = false;
5743 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
5744 if (TotalSurfaceSizeInMALL + SurfaceSizeInMALL[k] <= MALLAllocatedForDCNFinal * 1024 * 1024 &&
5745 !UsesMALLForStaticScreen[k] && UseMALLForStaticScreen[k] != dml_use_mall_static_screen_disable && one_row_per_frame_fits_in_buffer[k] &&
5746 (!CanAddAnotherSurfaceToMALL || SurfaceSizeInMALL[k] < SurfaceSizeInMALL[SurfaceToAddToMALL])) {
5747 CanAddAnotherSurfaceToMALL = true;
5748 SurfaceToAddToMALL = k;
5749 dml_print("DML::%s: k=%u, UseMALLForStaticScreen = %u (dis, en, optimize)\n", __func__, k, UseMALLForStaticScreen[k]);
5750 }
5751 }
5752 if (CanAddAnotherSurfaceToMALL) {
5753 UsesMALLForStaticScreen[SurfaceToAddToMALL] = true;
5754 TotalSurfaceSizeInMALL = TotalSurfaceSizeInMALL + SurfaceSizeInMALL[SurfaceToAddToMALL];
5755
5756 #ifdef __DML_VBA_DEBUG__
5757 dml_print("DML::%s: SurfaceToAddToMALL = %u\n", __func__, SurfaceToAddToMALL);
5758 dml_print("DML::%s: TotalSurfaceSizeInMALL = %u\n", __func__, TotalSurfaceSizeInMALL);
5759 #endif
5760 }
5761 }
5762 }
5763
5764 // @brief Calculate return bw for VM only traffic
dml_get_return_bw_mbps_vm_only(const struct soc_bounding_box_st * soc,dml_bool_t use_ideal_dram_bw_strobe,dml_bool_t HostVMEnable,dml_float_t DCFCLK,dml_float_t FabricClock,dml_float_t DRAMSpeed)5765 dml_float_t dml_get_return_bw_mbps_vm_only(
5766 const struct soc_bounding_box_st *soc,
5767 dml_bool_t use_ideal_dram_bw_strobe,
5768 dml_bool_t HostVMEnable,
5769 dml_float_t DCFCLK,
5770 dml_float_t FabricClock,
5771 dml_float_t DRAMSpeed)
5772 {
5773 dml_float_t VMDataOnlyReturnBW =
5774 dml_min3(soc->return_bus_width_bytes * DCFCLK * soc->pct_ideal_sdp_bw_after_urgent / 100.0,
5775 FabricClock * soc->fabric_datapath_to_dcn_data_return_bytes * soc->pct_ideal_sdp_bw_after_urgent / 100.0,
5776 DRAMSpeed * soc->num_chans * soc->dram_channel_width_bytes *
5777 ((use_ideal_dram_bw_strobe && !HostVMEnable) ? soc->pct_ideal_dram_bw_after_urgent_strobe : soc->pct_ideal_dram_bw_after_urgent_vm_only) / 100.0);
5778 #ifdef __DML_VBA_DEBUG__
5779 dml_print("DML::%s: use_ideal_dram_bw_strobe = %u\n", __func__, use_ideal_dram_bw_strobe);
5780 dml_print("DML::%s: HostVMEnable = %u\n", __func__, HostVMEnable);
5781 dml_print("DML::%s: DCFCLK = %f\n", __func__, DCFCLK);
5782 dml_print("DML::%s: FabricClock = %f\n", __func__, FabricClock);
5783 dml_print("DML::%s: DRAMSpeed = %f\n", __func__, DRAMSpeed);
5784 dml_print("DML::%s: VMDataOnlyReturnBW = %f\n", __func__, VMDataOnlyReturnBW);
5785 #endif
5786 return VMDataOnlyReturnBW;
5787 }
5788
5789 // Function: dml_get_return_bw_mbps
5790 // Megabyte per second
dml_get_return_bw_mbps(const struct soc_bounding_box_st * soc,dml_bool_t use_ideal_dram_bw_strobe,dml_bool_t HostVMEnable,dml_float_t DCFCLK,dml_float_t FabricClock,dml_float_t DRAMSpeed)5791 dml_float_t dml_get_return_bw_mbps(
5792 const struct soc_bounding_box_st *soc,
5793 dml_bool_t use_ideal_dram_bw_strobe,
5794 dml_bool_t HostVMEnable,
5795 dml_float_t DCFCLK,
5796 dml_float_t FabricClock,
5797 dml_float_t DRAMSpeed)
5798 {
5799 dml_float_t ReturnBW = 0.;
5800 dml_float_t IdealSDPPortBandwidth = soc->return_bus_width_bytes * DCFCLK;
5801 dml_float_t IdealFabricBandwidth = FabricClock * soc->fabric_datapath_to_dcn_data_return_bytes;
5802 dml_float_t IdealDRAMBandwidth = DRAMSpeed * soc->num_chans * soc->dram_channel_width_bytes;
5803 dml_float_t PixelDataOnlyReturnBW = dml_min3(IdealSDPPortBandwidth * soc->pct_ideal_sdp_bw_after_urgent / 100,
5804 IdealFabricBandwidth * soc->pct_ideal_fabric_bw_after_urgent / 100,
5805 IdealDRAMBandwidth * ((use_ideal_dram_bw_strobe && !HostVMEnable) ? soc->pct_ideal_dram_bw_after_urgent_strobe :
5806 soc->pct_ideal_dram_bw_after_urgent_pixel_only) / 100);
5807 dml_float_t PixelMixedWithVMDataReturnBW = dml_min3(IdealSDPPortBandwidth * soc->pct_ideal_sdp_bw_after_urgent / 100,
5808 IdealFabricBandwidth * soc->pct_ideal_fabric_bw_after_urgent / 100,
5809 IdealDRAMBandwidth * ((use_ideal_dram_bw_strobe && !HostVMEnable) ? soc->pct_ideal_dram_bw_after_urgent_strobe :
5810 soc->pct_ideal_dram_bw_after_urgent_pixel_and_vm) / 100);
5811
5812 if (HostVMEnable != true) {
5813 ReturnBW = PixelDataOnlyReturnBW;
5814 } else {
5815 ReturnBW = PixelMixedWithVMDataReturnBW;
5816 }
5817
5818 #ifdef __DML_VBA_DEBUG__
5819 dml_print("DML::%s: use_ideal_dram_bw_strobe = %u\n", __func__, use_ideal_dram_bw_strobe);
5820 dml_print("DML::%s: HostVMEnable = %u\n", __func__, HostVMEnable);
5821 dml_print("DML::%s: DCFCLK = %f\n", __func__, DCFCLK);
5822 dml_print("DML::%s: FabricClock = %f\n", __func__, FabricClock);
5823 dml_print("DML::%s: DRAMSpeed = %f\n", __func__, DRAMSpeed);
5824 dml_print("DML::%s: IdealSDPPortBandwidth = %f\n", __func__, IdealSDPPortBandwidth);
5825 dml_print("DML::%s: IdealFabricBandwidth = %f\n", __func__, IdealFabricBandwidth);
5826 dml_print("DML::%s: IdealDRAMBandwidth = %f\n", __func__, IdealDRAMBandwidth);
5827 dml_print("DML::%s: PixelDataOnlyReturnBW = %f\n", __func__, PixelDataOnlyReturnBW);
5828 dml_print("DML::%s: PixelMixedWithVMDataReturnBW = %f\n", __func__, PixelMixedWithVMDataReturnBW);
5829 dml_print("DML::%s: ReturnBW = %f MBps\n", __func__, ReturnBW);
5830 #endif
5831 return ReturnBW;
5832 }
5833
5834 // Function: dml_get_return_dram_bw_mbps
5835 // Megabyte per second
dml_get_return_dram_bw_mbps(const struct soc_bounding_box_st * soc,dml_bool_t use_ideal_dram_bw_strobe,dml_bool_t HostVMEnable,dml_float_t DRAMSpeed)5836 static dml_float_t dml_get_return_dram_bw_mbps(
5837 const struct soc_bounding_box_st *soc,
5838 dml_bool_t use_ideal_dram_bw_strobe,
5839 dml_bool_t HostVMEnable,
5840 dml_float_t DRAMSpeed)
5841 {
5842 dml_float_t ReturnDRAMBW = 0.;
5843 dml_float_t IdealDRAMBandwidth = DRAMSpeed * soc->num_chans * soc->dram_channel_width_bytes;
5844 dml_float_t PixelDataOnlyReturnBW = IdealDRAMBandwidth * ((use_ideal_dram_bw_strobe && !HostVMEnable) ? soc->pct_ideal_dram_bw_after_urgent_strobe :
5845 soc->pct_ideal_dram_bw_after_urgent_pixel_only) / 100;
5846 dml_float_t PixelMixedWithVMDataReturnBW = IdealDRAMBandwidth * ((use_ideal_dram_bw_strobe && !HostVMEnable) ? soc->pct_ideal_dram_bw_after_urgent_strobe :
5847 soc->pct_ideal_dram_bw_after_urgent_pixel_and_vm) / 100;
5848
5849 if (HostVMEnable != true) {
5850 ReturnDRAMBW = PixelDataOnlyReturnBW;
5851 } else {
5852 ReturnDRAMBW = PixelMixedWithVMDataReturnBW;
5853 }
5854
5855 #ifdef __DML_VBA_DEBUG__
5856 dml_print("DML::%s: use_ideal_dram_bw_strobe = %u\n", __func__, use_ideal_dram_bw_strobe);
5857 dml_print("DML::%s: HostVMEnable = %u\n", __func__, HostVMEnable);
5858 dml_print("DML::%s: DRAMSpeed = %f\n", __func__, DRAMSpeed);
5859 dml_print("DML::%s: IdealDRAMBandwidth = %f\n", __func__, IdealDRAMBandwidth);
5860 dml_print("DML::%s: PixelDataOnlyReturnBW = %f\n", __func__, PixelDataOnlyReturnBW);
5861 dml_print("DML::%s: PixelMixedWithVMDataReturnBW = %f\n", __func__, PixelMixedWithVMDataReturnBW);
5862 dml_print("DML::%s: ReturnDRAMBW = %f MBps\n", __func__, ReturnDRAMBW);
5863 #endif
5864 return ReturnDRAMBW;
5865 }
5866
5867 /// @brief BACKEND
DSCDelayRequirement(dml_bool_t DSCEnabled,enum dml_odm_mode ODMMode,dml_uint_t DSCInputBitPerComponent,dml_float_t OutputBpp,dml_uint_t HActive,dml_uint_t HTotal,dml_uint_t NumberOfDSCSlices,enum dml_output_format_class OutputFormat,enum dml_output_encoder_class Output,dml_float_t PixelClock,dml_float_t PixelClockBackEnd)5868 static dml_uint_t DSCDelayRequirement(
5869 dml_bool_t DSCEnabled,
5870 enum dml_odm_mode ODMMode,
5871 dml_uint_t DSCInputBitPerComponent,
5872 dml_float_t OutputBpp,
5873 dml_uint_t HActive,
5874 dml_uint_t HTotal,
5875 dml_uint_t NumberOfDSCSlices,
5876 enum dml_output_format_class OutputFormat,
5877 enum dml_output_encoder_class Output,
5878 dml_float_t PixelClock,
5879 dml_float_t PixelClockBackEnd)
5880 {
5881 dml_uint_t DSCDelayRequirement_val = 0;
5882
5883 if (DSCEnabled == true && OutputBpp != 0) {
5884 if (ODMMode == dml_odm_mode_combine_4to1) {
5885 DSCDelayRequirement_val = dscceComputeDelay(DSCInputBitPerComponent, OutputBpp, (dml_uint_t)(dml_ceil((dml_float_t) HActive / (dml_float_t) NumberOfDSCSlices, 1.0)),
5886 (dml_uint_t) (NumberOfDSCSlices / 4.0), OutputFormat, Output) + dscComputeDelay(OutputFormat, Output);
5887 } else if (ODMMode == dml_odm_mode_combine_2to1) {
5888 DSCDelayRequirement_val = dscceComputeDelay(DSCInputBitPerComponent, OutputBpp, (dml_uint_t)(dml_ceil((dml_float_t) HActive / (dml_float_t) NumberOfDSCSlices, 1.0)),
5889 (dml_uint_t) (NumberOfDSCSlices / 2.0), OutputFormat, Output) + dscComputeDelay(OutputFormat, Output);
5890 } else {
5891 DSCDelayRequirement_val = dscceComputeDelay(DSCInputBitPerComponent, OutputBpp, (dml_uint_t)((dml_float_t) dml_ceil(HActive / (dml_float_t) NumberOfDSCSlices, 1.0)),
5892 NumberOfDSCSlices, OutputFormat, Output) + dscComputeDelay(OutputFormat, Output);
5893 }
5894 DSCDelayRequirement_val = (dml_uint_t)(DSCDelayRequirement_val + (HTotal - HActive) * dml_ceil((dml_float_t) DSCDelayRequirement_val / (dml_float_t) HActive, 1.0));
5895 DSCDelayRequirement_val = (dml_uint_t)(DSCDelayRequirement_val * PixelClock / PixelClockBackEnd);
5896
5897 } else {
5898 DSCDelayRequirement_val = 0;
5899 }
5900 #ifdef __DML_VBA_DEBUG__
5901 dml_print("DML::%s: DSCEnabled = %u\n", __func__, DSCEnabled);
5902 dml_print("DML::%s: ODMMode = %u\n", __func__, ODMMode);
5903 dml_print("DML::%s: OutputBpp = %f\n", __func__, OutputBpp);
5904 dml_print("DML::%s: HActive = %u\n", __func__, HActive);
5905 dml_print("DML::%s: HTotal = %u\n", __func__, HTotal);
5906 dml_print("DML::%s: PixelClock = %f\n", __func__, PixelClock);
5907 dml_print("DML::%s: PixelClockBackEnd = %f\n", __func__, PixelClockBackEnd);
5908 dml_print("DML::%s: OutputFormat = %u\n", __func__, OutputFormat);
5909 dml_print("DML::%s: DSCInputBitPerComponent = %u\n", __func__, DSCInputBitPerComponent);
5910 dml_print("DML::%s: NumberOfDSCSlices = %u\n", __func__, NumberOfDSCSlices);
5911 dml_print("DML::%s: DSCDelayRequirement_val = %u\n", __func__, DSCDelayRequirement_val);
5912 #endif
5913
5914 return DSCDelayRequirement_val;
5915 }
5916
CalculateVActiveBandwithSupport(dml_uint_t NumberOfActiveSurfaces,dml_float_t ReturnBW,dml_bool_t NotUrgentLatencyHiding[],dml_float_t ReadBandwidthLuma[],dml_float_t ReadBandwidthChroma[],dml_float_t cursor_bw[],dml_float_t meta_row_bandwidth[],dml_float_t dpte_row_bandwidth[],dml_uint_t NumberOfDPP[],dml_float_t UrgentBurstFactorLuma[],dml_float_t UrgentBurstFactorChroma[],dml_float_t UrgentBurstFactorCursor[])5917 static dml_bool_t CalculateVActiveBandwithSupport(dml_uint_t NumberOfActiveSurfaces,
5918 dml_float_t ReturnBW,
5919 dml_bool_t NotUrgentLatencyHiding[],
5920 dml_float_t ReadBandwidthLuma[],
5921 dml_float_t ReadBandwidthChroma[],
5922 dml_float_t cursor_bw[],
5923 dml_float_t meta_row_bandwidth[],
5924 dml_float_t dpte_row_bandwidth[],
5925 dml_uint_t NumberOfDPP[],
5926 dml_float_t UrgentBurstFactorLuma[],
5927 dml_float_t UrgentBurstFactorChroma[],
5928 dml_float_t UrgentBurstFactorCursor[])
5929 {
5930 dml_bool_t NotEnoughUrgentLatencyHiding = false;
5931 dml_bool_t CalculateVActiveBandwithSupport_val = false;
5932 dml_float_t VActiveBandwith = 0;
5933
5934 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
5935 if (NotUrgentLatencyHiding[k]) {
5936 NotEnoughUrgentLatencyHiding = true;
5937 }
5938 }
5939
5940 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
5941 VActiveBandwith = VActiveBandwith + ReadBandwidthLuma[k] * UrgentBurstFactorLuma[k] + ReadBandwidthChroma[k] * UrgentBurstFactorChroma[k] + cursor_bw[k] * UrgentBurstFactorCursor[k] + NumberOfDPP[k] * meta_row_bandwidth[k] + NumberOfDPP[k] * dpte_row_bandwidth[k];
5942 }
5943
5944 CalculateVActiveBandwithSupport_val = (VActiveBandwith <= ReturnBW) && !NotEnoughUrgentLatencyHiding;
5945
5946 #ifdef __DML_VBA_DEBUG__
5947 dml_print("DML::%s: NotEnoughUrgentLatencyHiding = %u\n", __func__, NotEnoughUrgentLatencyHiding);
5948 dml_print("DML::%s: VActiveBandwith = %f\n", __func__, VActiveBandwith);
5949 dml_print("DML::%s: ReturnBW = %f\n", __func__, ReturnBW);
5950 dml_print("DML::%s: CalculateVActiveBandwithSupport_val = %u\n", __func__, CalculateVActiveBandwithSupport_val);
5951 #endif
5952 return CalculateVActiveBandwithSupport_val;
5953 }
5954
CalculatePrefetchBandwithSupport(dml_uint_t NumberOfActiveSurfaces,dml_float_t ReturnBW,enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange[],dml_bool_t NotUrgentLatencyHiding[],dml_float_t ReadBandwidthLuma[],dml_float_t ReadBandwidthChroma[],dml_float_t PrefetchBandwidthLuma[],dml_float_t PrefetchBandwidthChroma[],dml_float_t cursor_bw[],dml_float_t meta_row_bandwidth[],dml_float_t dpte_row_bandwidth[],dml_float_t cursor_bw_pre[],dml_float_t prefetch_vmrow_bw[],dml_uint_t NumberOfDPP[],dml_float_t UrgentBurstFactorLuma[],dml_float_t UrgentBurstFactorChroma[],dml_float_t UrgentBurstFactorCursor[],dml_float_t UrgentBurstFactorLumaPre[],dml_float_t UrgentBurstFactorChromaPre[],dml_float_t UrgentBurstFactorCursorPre[],dml_float_t * PrefetchBandwidth,dml_float_t * PrefetchBandwidthNotIncludingMALLPrefetch,dml_float_t * FractionOfUrgentBandwidth,dml_bool_t * PrefetchBandwidthSupport)5955 static void CalculatePrefetchBandwithSupport(
5956 dml_uint_t NumberOfActiveSurfaces,
5957 dml_float_t ReturnBW,
5958 enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange[],
5959 dml_bool_t NotUrgentLatencyHiding[],
5960 dml_float_t ReadBandwidthLuma[],
5961 dml_float_t ReadBandwidthChroma[],
5962 dml_float_t PrefetchBandwidthLuma[],
5963 dml_float_t PrefetchBandwidthChroma[],
5964 dml_float_t cursor_bw[],
5965 dml_float_t meta_row_bandwidth[],
5966 dml_float_t dpte_row_bandwidth[],
5967 dml_float_t cursor_bw_pre[],
5968 dml_float_t prefetch_vmrow_bw[],
5969 dml_uint_t NumberOfDPP[],
5970 dml_float_t UrgentBurstFactorLuma[],
5971 dml_float_t UrgentBurstFactorChroma[],
5972 dml_float_t UrgentBurstFactorCursor[],
5973 dml_float_t UrgentBurstFactorLumaPre[],
5974 dml_float_t UrgentBurstFactorChromaPre[],
5975 dml_float_t UrgentBurstFactorCursorPre[],
5976
5977 // Output
5978 dml_float_t *PrefetchBandwidth,
5979 dml_float_t *PrefetchBandwidthNotIncludingMALLPrefetch,
5980 dml_float_t *FractionOfUrgentBandwidth,
5981 dml_bool_t *PrefetchBandwidthSupport)
5982 {
5983 dml_bool_t NotEnoughUrgentLatencyHiding = false;
5984 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
5985 if (NotUrgentLatencyHiding[k]) {
5986 NotEnoughUrgentLatencyHiding = true;
5987 }
5988 }
5989
5990 *PrefetchBandwidth = 0;
5991 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
5992 *PrefetchBandwidth = *PrefetchBandwidth + dml_max3(NumberOfDPP[k] * prefetch_vmrow_bw[k],
5993 ReadBandwidthLuma[k] * UrgentBurstFactorLuma[k] + ReadBandwidthChroma[k] * UrgentBurstFactorChroma[k] + cursor_bw[k] * UrgentBurstFactorCursor[k] + NumberOfDPP[k] * (meta_row_bandwidth[k] + dpte_row_bandwidth[k]),
5994 NumberOfDPP[k] * (PrefetchBandwidthLuma[k] * UrgentBurstFactorLumaPre[k] + PrefetchBandwidthChroma[k] * UrgentBurstFactorChromaPre[k]) + cursor_bw_pre[k] * UrgentBurstFactorCursorPre[k]);
5995 }
5996
5997 *PrefetchBandwidthNotIncludingMALLPrefetch = 0;
5998 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
5999 if (UseMALLForPStateChange[k] != dml_use_mall_pstate_change_phantom_pipe)
6000 *PrefetchBandwidthNotIncludingMALLPrefetch = *PrefetchBandwidthNotIncludingMALLPrefetch
6001 + dml_max3(NumberOfDPP[k] * prefetch_vmrow_bw[k],
6002 ReadBandwidthLuma[k] * UrgentBurstFactorLuma[k] + ReadBandwidthChroma[k] * UrgentBurstFactorChroma[k]
6003 + cursor_bw[k] * UrgentBurstFactorCursor[k]
6004 + NumberOfDPP[k] * (meta_row_bandwidth[k] + dpte_row_bandwidth[k]),
6005 NumberOfDPP[k] * (PrefetchBandwidthLuma[k] * UrgentBurstFactorLumaPre[k]
6006 + PrefetchBandwidthChroma[k] * UrgentBurstFactorChromaPre[k])
6007 + cursor_bw_pre[k] * UrgentBurstFactorCursorPre[k]);
6008 }
6009
6010 *PrefetchBandwidthSupport = (*PrefetchBandwidth <= ReturnBW) && !NotEnoughUrgentLatencyHiding;
6011 *FractionOfUrgentBandwidth = *PrefetchBandwidth / ReturnBW;
6012
6013 #ifdef __DML_VBA_DEBUG__
6014 dml_print("DML::%s: ReturnBW = %f\n", __func__, ReturnBW);
6015 dml_print("DML::%s: PrefetchBandwidth = %f\n", __func__, *PrefetchBandwidth);
6016 dml_print("DML::%s: FractionOfUrgentBandwidth = %f\n", __func__, *FractionOfUrgentBandwidth);
6017 dml_print("DML::%s: PrefetchBandwidthSupport = %u\n", __func__, *PrefetchBandwidthSupport);
6018 #endif
6019 }
6020
CalculateBandwidthAvailableForImmediateFlip(dml_uint_t NumberOfActiveSurfaces,dml_float_t ReturnBW,dml_float_t ReadBandwidthLuma[],dml_float_t ReadBandwidthChroma[],dml_float_t PrefetchBandwidthLuma[],dml_float_t PrefetchBandwidthChroma[],dml_float_t cursor_bw[],dml_float_t cursor_bw_pre[],dml_uint_t NumberOfDPP[],dml_float_t UrgentBurstFactorLuma[],dml_float_t UrgentBurstFactorChroma[],dml_float_t UrgentBurstFactorCursor[],dml_float_t UrgentBurstFactorLumaPre[],dml_float_t UrgentBurstFactorChromaPre[],dml_float_t UrgentBurstFactorCursorPre[])6021 static dml_float_t CalculateBandwidthAvailableForImmediateFlip(
6022 dml_uint_t NumberOfActiveSurfaces,
6023 dml_float_t ReturnBW,
6024 dml_float_t ReadBandwidthLuma[],
6025 dml_float_t ReadBandwidthChroma[],
6026 dml_float_t PrefetchBandwidthLuma[],
6027 dml_float_t PrefetchBandwidthChroma[],
6028 dml_float_t cursor_bw[],
6029 dml_float_t cursor_bw_pre[],
6030 dml_uint_t NumberOfDPP[],
6031 dml_float_t UrgentBurstFactorLuma[],
6032 dml_float_t UrgentBurstFactorChroma[],
6033 dml_float_t UrgentBurstFactorCursor[],
6034 dml_float_t UrgentBurstFactorLumaPre[],
6035 dml_float_t UrgentBurstFactorChromaPre[],
6036 dml_float_t UrgentBurstFactorCursorPre[])
6037 {
6038 dml_float_t ret_val = ReturnBW;
6039
6040 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
6041 ret_val = ret_val - dml_max(ReadBandwidthLuma[k] * UrgentBurstFactorLuma[k] + ReadBandwidthChroma[k] * UrgentBurstFactorChroma[k] + cursor_bw[k] * UrgentBurstFactorCursor[k],
6042 NumberOfDPP[k] * (PrefetchBandwidthLuma[k] * UrgentBurstFactorLumaPre[k] + PrefetchBandwidthChroma[k] * UrgentBurstFactorChromaPre[k]) +
6043 cursor_bw_pre[k] * UrgentBurstFactorCursorPre[k]);
6044 #ifdef __DML_VBA_DEBUG__
6045 dml_print("DML::%s: k=%u\n", __func__, k);
6046 dml_print("DML::%s: NumberOfDPP = %u\n", __func__, NumberOfDPP[k]);
6047 dml_print("DML::%s: ReadBandwidthLuma = %f\n", __func__, ReadBandwidthLuma[k]);
6048 dml_print("DML::%s: UrgentBurstFactorLuma = %f\n", __func__, UrgentBurstFactorLuma[k]);
6049 dml_print("DML::%s: ReadBandwidthChroma = %f\n", __func__, ReadBandwidthChroma[k]);
6050 dml_print("DML::%s: UrgentBurstFactorChroma = %f\n", __func__, UrgentBurstFactorChroma[k]);
6051 dml_print("DML::%s: cursor_bw = %f\n", __func__, cursor_bw[k]);
6052 dml_print("DML::%s: UrgentBurstFactorCursor = %f\n", __func__, UrgentBurstFactorCursor[k]);
6053
6054 dml_print("DML::%s: PrefetchBandwidthLuma = %f\n", __func__, PrefetchBandwidthLuma[k]);
6055 dml_print("DML::%s: UrgentBurstFactorLumaPre = %f\n", __func__, UrgentBurstFactorLumaPre[k]);
6056 dml_print("DML::%s: PrefetchBandwidthChroma = %f\n", __func__, PrefetchBandwidthChroma[k]);
6057 dml_print("DML::%s: UrgentBurstFactorChromaPre = %f\n", __func__, UrgentBurstFactorChromaPre[k]);
6058 dml_print("DML::%s: cursor_bw_pre = %f\n", __func__, cursor_bw_pre[k]);
6059 dml_print("DML::%s: UrgentBurstFactorCursorPre = %f\n", __func__, UrgentBurstFactorCursorPre[k]);
6060 dml_print("DML::%s: ret_val = %f\n", __func__, ret_val);
6061 #endif
6062 }
6063
6064 return ret_val;
6065 }
6066
CalculateImmediateFlipBandwithSupport(dml_uint_t NumberOfActiveSurfaces,dml_float_t ReturnBW,enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange[],enum dml_immediate_flip_requirement ImmediateFlipRequirement[],dml_float_t final_flip_bw[],dml_float_t ReadBandwidthLuma[],dml_float_t ReadBandwidthChroma[],dml_float_t PrefetchBandwidthLuma[],dml_float_t PrefetchBandwidthChroma[],dml_float_t cursor_bw[],dml_float_t meta_row_bandwidth[],dml_float_t dpte_row_bandwidth[],dml_float_t cursor_bw_pre[],dml_float_t prefetch_vmrow_bw[],dml_uint_t NumberOfDPP[],dml_float_t UrgentBurstFactorLuma[],dml_float_t UrgentBurstFactorChroma[],dml_float_t UrgentBurstFactorCursor[],dml_float_t UrgentBurstFactorLumaPre[],dml_float_t UrgentBurstFactorChromaPre[],dml_float_t UrgentBurstFactorCursorPre[],dml_float_t * TotalBandwidth,dml_float_t * TotalBandwidthNotIncludingMALLPrefetch,dml_float_t * FractionOfUrgentBandwidth,dml_bool_t * ImmediateFlipBandwidthSupport)6067 static void CalculateImmediateFlipBandwithSupport(
6068 dml_uint_t NumberOfActiveSurfaces,
6069 dml_float_t ReturnBW,
6070 enum dml_use_mall_for_pstate_change_mode UseMALLForPStateChange[],
6071 enum dml_immediate_flip_requirement ImmediateFlipRequirement[],
6072 dml_float_t final_flip_bw[],
6073 dml_float_t ReadBandwidthLuma[],
6074 dml_float_t ReadBandwidthChroma[],
6075 dml_float_t PrefetchBandwidthLuma[],
6076 dml_float_t PrefetchBandwidthChroma[],
6077 dml_float_t cursor_bw[],
6078 dml_float_t meta_row_bandwidth[],
6079 dml_float_t dpte_row_bandwidth[],
6080 dml_float_t cursor_bw_pre[],
6081 dml_float_t prefetch_vmrow_bw[],
6082 dml_uint_t NumberOfDPP[],
6083 dml_float_t UrgentBurstFactorLuma[],
6084 dml_float_t UrgentBurstFactorChroma[],
6085 dml_float_t UrgentBurstFactorCursor[],
6086 dml_float_t UrgentBurstFactorLumaPre[],
6087 dml_float_t UrgentBurstFactorChromaPre[],
6088 dml_float_t UrgentBurstFactorCursorPre[],
6089
6090 // Output
6091 dml_float_t *TotalBandwidth,
6092 dml_float_t *TotalBandwidthNotIncludingMALLPrefetch,
6093 dml_float_t *FractionOfUrgentBandwidth,
6094 dml_bool_t *ImmediateFlipBandwidthSupport)
6095 {
6096 *TotalBandwidth = 0;
6097 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
6098 if (ImmediateFlipRequirement[k] != dml_immediate_flip_not_required) {
6099
6100
6101
6102 *TotalBandwidth = *TotalBandwidth + dml_max3(NumberOfDPP[k] * prefetch_vmrow_bw[k],
6103 NumberOfDPP[k] * final_flip_bw[k] + ReadBandwidthLuma[k] * UrgentBurstFactorLuma[k] + ReadBandwidthChroma[k] * UrgentBurstFactorChroma[k] + cursor_bw[k] * UrgentBurstFactorCursor[k],
6104 NumberOfDPP[k] * (final_flip_bw[k] + PrefetchBandwidthLuma[k] * UrgentBurstFactorLumaPre[k] + PrefetchBandwidthChroma[k] * UrgentBurstFactorChromaPre[k]) + cursor_bw_pre[k] * UrgentBurstFactorCursorPre[k]);
6105 } else {
6106 *TotalBandwidth = *TotalBandwidth + dml_max3(NumberOfDPP[k] * prefetch_vmrow_bw[k],
6107 NumberOfDPP[k] * (meta_row_bandwidth[k] + dpte_row_bandwidth[k]) + ReadBandwidthLuma[k] * UrgentBurstFactorLuma[k] + ReadBandwidthChroma[k] * UrgentBurstFactorChroma[k] + cursor_bw[k] * UrgentBurstFactorCursor[k],
6108 NumberOfDPP[k] * (PrefetchBandwidthLuma[k] * UrgentBurstFactorLumaPre[k] + PrefetchBandwidthChroma[k] * UrgentBurstFactorChromaPre[k]) + cursor_bw_pre[k] * UrgentBurstFactorCursorPre[k]);
6109 }
6110 #ifdef __DML_VBA_DEBUG__
6111 dml_print("DML::%s: k = %u\n", __func__, k);
6112 dml_print("DML::%s: ImmediateFlipRequirement = %u\n", __func__, ImmediateFlipRequirement[k]);
6113 dml_print("DML::%s: TotalBandwidth = %f\n", __func__, *TotalBandwidth);
6114 dml_print("DML::%s: NumberOfDPP = %u\n", __func__, NumberOfDPP[k]);
6115 dml_print("DML::%s: prefetch_vmrow_bw = %f\n", __func__, prefetch_vmrow_bw[k]);
6116 dml_print("DML::%s: final_flip_bw = %f\n", __func__, final_flip_bw[k]);
6117 dml_print("DML::%s: ReadBandwidthLuma = %f\n", __func__, ReadBandwidthLuma[k]);
6118 dml_print("DML::%s: UrgentBurstFactorLuma = %f\n", __func__, UrgentBurstFactorLuma[k]);
6119 dml_print("DML::%s: ReadBandwidthChroma = %f\n", __func__, ReadBandwidthChroma[k]);
6120 dml_print("DML::%s: UrgentBurstFactorChroma = %f\n", __func__, UrgentBurstFactorChroma[k]);
6121 dml_print("DML::%s: cursor_bw = %f\n", __func__, cursor_bw[k]);
6122 dml_print("DML::%s: UrgentBurstFactorCursor = %f\n", __func__, UrgentBurstFactorCursor[k]);
6123 dml_print("DML::%s: PrefetchBandwidthLuma = %f\n", __func__, PrefetchBandwidthLuma[k]);
6124 dml_print("DML::%s: UrgentBurstFactorLumaPre = %f\n", __func__, UrgentBurstFactorLumaPre[k]);
6125 dml_print("DML::%s: PrefetchBandwidthChroma = %f\n", __func__, PrefetchBandwidthChroma[k]);
6126 dml_print("DML::%s: UrgentBurstFactorChromaPre = %f\n", __func__, UrgentBurstFactorChromaPre[k]);
6127 dml_print("DML::%s: cursor_bw_pre = %f\n", __func__, cursor_bw_pre[k]);
6128 dml_print("DML::%s: UrgentBurstFactorCursorPre = %f\n", __func__, UrgentBurstFactorCursorPre[k]);
6129 dml_print("DML::%s: meta_row_bandwidth = %f\n", __func__, meta_row_bandwidth[k]);
6130 dml_print("DML::%s: dpte_row_bandwidth = %f\n", __func__, dpte_row_bandwidth[k]);
6131 #endif
6132 }
6133
6134 *TotalBandwidthNotIncludingMALLPrefetch = 0;
6135 for (dml_uint_t k = 0; k < NumberOfActiveSurfaces; ++k) {
6136 if (UseMALLForPStateChange[k] != dml_use_mall_pstate_change_phantom_pipe) {
6137 if (ImmediateFlipRequirement[k] != dml_immediate_flip_not_required)
6138 *TotalBandwidthNotIncludingMALLPrefetch = *TotalBandwidthNotIncludingMALLPrefetch + dml_max3(NumberOfDPP[k] * prefetch_vmrow_bw[k],
6139 NumberOfDPP[k] * final_flip_bw[k] + ReadBandwidthLuma[k] * UrgentBurstFactorLuma[k] + ReadBandwidthChroma[k] * UrgentBurstFactorChroma[k] + cursor_bw[k] * UrgentBurstFactorCursor[k],
6140 NumberOfDPP[k] * (final_flip_bw[k] + PrefetchBandwidthLuma[k] * UrgentBurstFactorLumaPre[k] + PrefetchBandwidthChroma[k] * UrgentBurstFactorChromaPre[k])
6141 + cursor_bw_pre[k] * UrgentBurstFactorCursorPre[k]);
6142 else
6143 *TotalBandwidthNotIncludingMALLPrefetch = *TotalBandwidthNotIncludingMALLPrefetch + dml_max3(NumberOfDPP[k] * prefetch_vmrow_bw[k],
6144 NumberOfDPP[k] * (meta_row_bandwidth[k] + dpte_row_bandwidth[k])
6145 + ReadBandwidthLuma[k] * UrgentBurstFactorLuma[k] + ReadBandwidthChroma[k] * UrgentBurstFactorChroma[k] + cursor_bw[k] * UrgentBurstFactorCursor[k],
6146 NumberOfDPP[k] * (PrefetchBandwidthLuma[k] * UrgentBurstFactorLumaPre[k] + PrefetchBandwidthChroma[k] * UrgentBurstFactorChromaPre[k])
6147 + cursor_bw_pre[k] * UrgentBurstFactorCursorPre[k]);
6148 }
6149 }
6150
6151 *ImmediateFlipBandwidthSupport = (*TotalBandwidth <= ReturnBW);
6152 *FractionOfUrgentBandwidth = *TotalBandwidth / ReturnBW;
6153 #ifdef __DML_VBA_DEBUG__
6154 dml_print("DML::%s: ReturnBW = %f\n", __func__, ReturnBW);
6155 dml_print("DML::%s: TotalBandwidth = %f\n", __func__, *TotalBandwidth);
6156 dml_print("DML::%s: ImmediateFlipBandwidthSupport = %u\n", __func__, *ImmediateFlipBandwidthSupport);
6157 #endif
6158 }
6159
MicroSecToVertLines(dml_uint_t num_us,dml_uint_t h_total,dml_float_t pixel_clock)6160 static dml_uint_t MicroSecToVertLines(dml_uint_t num_us, dml_uint_t h_total, dml_float_t pixel_clock)
6161 {
6162 dml_uint_t lines_time_in_ns = 1000.0 * (h_total * 1000.0) / (pixel_clock * 1000.0);
6163
6164 return dml_ceil(1000.0 * num_us / lines_time_in_ns, 1.0);
6165 }
6166
6167 /// @brief Calculate the maximum vstartup for mode support and mode programming consideration
6168 /// Bounded by min of actual vblank and input vblank_nom, dont want vstartup/ready to start too early if actual vbllank is huge
CalculateMaxVStartup(dml_uint_t plane_idx,dml_bool_t ptoi_supported,dml_uint_t vblank_nom_default_us,struct dml_timing_cfg_st * timing,dml_float_t write_back_delay_us)6169 static dml_uint_t CalculateMaxVStartup(
6170 dml_uint_t plane_idx,
6171 dml_bool_t ptoi_supported,
6172 dml_uint_t vblank_nom_default_us,
6173 struct dml_timing_cfg_st *timing,
6174 dml_float_t write_back_delay_us)
6175 {
6176 dml_uint_t vblank_size = 0;
6177 dml_uint_t max_vstartup_lines = 0;
6178 const dml_uint_t max_allowed_vblank_nom = 1023;
6179
6180 dml_float_t line_time_us = (dml_float_t) timing->HTotal[plane_idx] / timing->PixelClock[plane_idx];
6181 dml_uint_t vblank_actual = timing->VTotal[plane_idx] - timing->VActive[plane_idx];
6182
6183 dml_uint_t vblank_nom_default_in_line = MicroSecToVertLines(vblank_nom_default_us, timing->HTotal[plane_idx],
6184 timing->PixelClock[plane_idx]);
6185 dml_uint_t vblank_nom_input = (dml_uint_t)dml_min(vblank_actual, vblank_nom_default_in_line);
6186
6187 // vblank_nom should not be smaller than (VSync (VTotal - VActive - VFrontPorch) + 2)
6188 // + 2 is because
6189 // 1 -> VStartup_start should be 1 line before VSync
6190 // 1 -> always reserve 1 line between start of VBlank to VStartup signal
6191 dml_uint_t vblank_nom_vsync_capped = dml_max(vblank_nom_input,
6192 timing->VTotal[plane_idx] - timing->VActive[plane_idx] - timing->VFrontPorch[plane_idx] + 2);
6193 dml_uint_t vblank_nom_max_allowed_capped = dml_min(vblank_nom_vsync_capped, max_allowed_vblank_nom);
6194 dml_uint_t vblank_avail = (vblank_nom_max_allowed_capped == 0) ?
6195 vblank_nom_default_in_line : vblank_nom_max_allowed_capped;
6196
6197 vblank_size = (dml_uint_t) dml_min(vblank_actual, vblank_avail);
6198
6199 if (timing->Interlace[plane_idx] && !ptoi_supported)
6200 max_vstartup_lines = (dml_uint_t) (dml_floor(vblank_size/2.0, 1.0));
6201 else
6202 max_vstartup_lines = vblank_size - (dml_uint_t) dml_max(1.0, dml_ceil(write_back_delay_us/line_time_us, 1.0));
6203 #ifdef __DML_VBA_DEBUG__
6204 dml_print("DML::%s: plane_idx = %u\n", __func__, plane_idx);
6205 dml_print("DML::%s: VBlankNom = %u\n", __func__, timing->VBlankNom[plane_idx]);
6206 dml_print("DML::%s: vblank_nom_default_us = %u\n", __func__, vblank_nom_default_us);
6207 dml_print("DML::%s: line_time_us = %f\n", __func__, line_time_us);
6208 dml_print("DML::%s: vblank_actual = %u\n", __func__, vblank_actual);
6209 dml_print("DML::%s: vblank_avail = %u\n", __func__, vblank_avail);
6210 dml_print("DML::%s: max_vstartup_lines = %u\n", __func__, max_vstartup_lines);
6211 #endif
6212 return max_vstartup_lines;
6213 }
6214
set_calculate_prefetch_schedule_params(struct display_mode_lib_st * mode_lib,struct CalculatePrefetchSchedule_params_st * CalculatePrefetchSchedule_params,dml_uint_t j,dml_uint_t k)6215 static void set_calculate_prefetch_schedule_params(struct display_mode_lib_st *mode_lib,
6216 struct CalculatePrefetchSchedule_params_st *CalculatePrefetchSchedule_params,
6217 dml_uint_t j,
6218 dml_uint_t k)
6219 {
6220 CalculatePrefetchSchedule_params->DSCDelay = mode_lib->ms.DSCDelayPerState[k];
6221 CalculatePrefetchSchedule_params->EnhancedPrefetchScheduleAccelerationFinal = mode_lib->ms.policy.EnhancedPrefetchScheduleAccelerationFinal;
6222 CalculatePrefetchSchedule_params->DPPCLKDelaySubtotalPlusCNVCFormater = mode_lib->ms.ip.dppclk_delay_subtotal + mode_lib->ms.ip.dppclk_delay_cnvc_formatter;
6223 CalculatePrefetchSchedule_params->DPPCLKDelaySCL = mode_lib->ms.ip.dppclk_delay_scl;
6224 CalculatePrefetchSchedule_params->DPPCLKDelaySCLLBOnly = mode_lib->ms.ip.dppclk_delay_scl_lb_only;
6225 CalculatePrefetchSchedule_params->DPPCLKDelayCNVCCursor = mode_lib->ms.ip.dppclk_delay_cnvc_cursor;
6226 CalculatePrefetchSchedule_params->DISPCLKDelaySubtotal = mode_lib->ms.ip.dispclk_delay_subtotal;
6227 CalculatePrefetchSchedule_params->DPP_RECOUT_WIDTH = (dml_uint_t)(mode_lib->ms.SwathWidthYThisState[k] / mode_lib->ms.cache_display_cfg.plane.HRatio[k]);
6228 CalculatePrefetchSchedule_params->OutputFormat = mode_lib->ms.cache_display_cfg.output.OutputFormat[k];
6229 CalculatePrefetchSchedule_params->MaxInterDCNTileRepeaters = mode_lib->ms.ip.max_inter_dcn_tile_repeaters;
6230 CalculatePrefetchSchedule_params->GPUVMPageTableLevels = mode_lib->ms.cache_display_cfg.plane.GPUVMMaxPageTableLevels;
6231 CalculatePrefetchSchedule_params->GPUVMEnable = mode_lib->ms.cache_display_cfg.plane.GPUVMEnable;
6232 CalculatePrefetchSchedule_params->HostVMEnable = mode_lib->ms.cache_display_cfg.plane.HostVMEnable;
6233 CalculatePrefetchSchedule_params->HostVMMaxNonCachedPageTableLevels = mode_lib->ms.cache_display_cfg.plane.HostVMMaxPageTableLevels;
6234 CalculatePrefetchSchedule_params->HostVMMinPageSize = mode_lib->ms.soc.hostvm_min_page_size_kbytes * 1024;
6235 CalculatePrefetchSchedule_params->DynamicMetadataEnable = mode_lib->ms.cache_display_cfg.plane.DynamicMetadataEnable[k];
6236 CalculatePrefetchSchedule_params->DynamicMetadataVMEnabled = mode_lib->ms.ip.dynamic_metadata_vm_enabled;
6237 CalculatePrefetchSchedule_params->DynamicMetadataLinesBeforeActiveRequired = mode_lib->ms.cache_display_cfg.plane.DynamicMetadataLinesBeforeActiveRequired[k];
6238 CalculatePrefetchSchedule_params->DynamicMetadataTransmittedBytes = mode_lib->ms.cache_display_cfg.plane.DynamicMetadataTransmittedBytes[k];
6239 CalculatePrefetchSchedule_params->UrgentLatency = mode_lib->ms.UrgLatency;
6240 CalculatePrefetchSchedule_params->UrgentExtraLatency = mode_lib->ms.ExtraLatency;
6241 CalculatePrefetchSchedule_params->TCalc = mode_lib->ms.TimeCalc;
6242 CalculatePrefetchSchedule_params->PDEAndMetaPTEBytesFrame = mode_lib->ms.PDEAndMetaPTEBytesPerFrame[j][k];
6243 CalculatePrefetchSchedule_params->MetaRowByte = mode_lib->ms.MetaRowBytes[j][k];
6244 CalculatePrefetchSchedule_params->PixelPTEBytesPerRow = mode_lib->ms.DPTEBytesPerRow[j][k];
6245 CalculatePrefetchSchedule_params->PrefetchSourceLinesY = mode_lib->ms.PrefetchLinesY[j][k];
6246 CalculatePrefetchSchedule_params->VInitPreFillY = mode_lib->ms.PrefillY[k];
6247 CalculatePrefetchSchedule_params->MaxNumSwathY = mode_lib->ms.MaxNumSwY[k];
6248 CalculatePrefetchSchedule_params->PrefetchSourceLinesC = mode_lib->ms.PrefetchLinesC[j][k];
6249 CalculatePrefetchSchedule_params->VInitPreFillC = mode_lib->ms.PrefillC[k];
6250 CalculatePrefetchSchedule_params->MaxNumSwathC = mode_lib->ms.MaxNumSwC[k];
6251 CalculatePrefetchSchedule_params->swath_width_luma_ub = mode_lib->ms.swath_width_luma_ub_this_state[k];
6252 CalculatePrefetchSchedule_params->swath_width_chroma_ub = mode_lib->ms.swath_width_chroma_ub_this_state[k];
6253 CalculatePrefetchSchedule_params->SwathHeightY = mode_lib->ms.SwathHeightYThisState[k];
6254 CalculatePrefetchSchedule_params->SwathHeightC = mode_lib->ms.SwathHeightCThisState[k];
6255 CalculatePrefetchSchedule_params->TWait = mode_lib->ms.TWait;
6256 CalculatePrefetchSchedule_params->DestinationLinesForPrefetch = &mode_lib->ms.LineTimesForPrefetch[k];
6257 CalculatePrefetchSchedule_params->DestinationLinesToRequestVMInVBlank = &mode_lib->ms.LinesForMetaPTE[k];
6258 CalculatePrefetchSchedule_params->DestinationLinesToRequestRowInVBlank = &mode_lib->ms.LinesForMetaAndDPTERow[k];
6259 CalculatePrefetchSchedule_params->VRatioPrefetchY = &mode_lib->ms.VRatioPreY[j][k];
6260 CalculatePrefetchSchedule_params->VRatioPrefetchC = &mode_lib->ms.VRatioPreC[j][k];
6261 CalculatePrefetchSchedule_params->RequiredPrefetchPixDataBWLuma = &mode_lib->ms.RequiredPrefetchPixelDataBWLuma[k];
6262 CalculatePrefetchSchedule_params->RequiredPrefetchPixDataBWChroma = &mode_lib->ms.RequiredPrefetchPixelDataBWChroma[k];
6263 CalculatePrefetchSchedule_params->NotEnoughTimeForDynamicMetadata = &mode_lib->ms.support.NoTimeForDynamicMetadata[j][k];
6264 CalculatePrefetchSchedule_params->Tno_bw = &mode_lib->ms.Tno_bw[k];
6265 }
6266
dml_prefetch_check(struct display_mode_lib_st * mode_lib)6267 static void dml_prefetch_check(struct display_mode_lib_st *mode_lib)
6268 {
6269 struct dml_core_mode_support_locals_st *s = &mode_lib->scratch.dml_core_mode_support_locals;
6270 struct CalculatePrefetchSchedule_params_st *CalculatePrefetchSchedule_params = &mode_lib->scratch.CalculatePrefetchSchedule_params;
6271 struct CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_params_st *CalculateWatermarks_params = &mode_lib->scratch.CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_params;
6272 struct DmlPipe *myPipe;
6273 dml_uint_t j, k;
6274
6275 for (j = 0; j < 2; ++j) {
6276 mode_lib->ms.TimeCalc = 24 / mode_lib->ms.ProjectedDCFCLKDeepSleep[j];
6277
6278 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
6279 mode_lib->ms.NoOfDPPThisState[k] = mode_lib->ms.NoOfDPP[j][k];
6280 mode_lib->ms.swath_width_luma_ub_this_state[k] = mode_lib->ms.swath_width_luma_ub_all_states[j][k];
6281 mode_lib->ms.swath_width_chroma_ub_this_state[k] = mode_lib->ms.swath_width_chroma_ub_all_states[j][k];
6282 mode_lib->ms.SwathWidthYThisState[k] = mode_lib->ms.SwathWidthYAllStates[j][k];
6283 mode_lib->ms.SwathWidthCThisState[k] = mode_lib->ms.SwathWidthCAllStates[j][k];
6284 mode_lib->ms.SwathHeightYThisState[k] = mode_lib->ms.SwathHeightYAllStates[j][k];
6285 mode_lib->ms.SwathHeightCThisState[k] = mode_lib->ms.SwathHeightCAllStates[j][k];
6286 mode_lib->ms.UnboundedRequestEnabledThisState = mode_lib->ms.UnboundedRequestEnabledAllStates[j];
6287 mode_lib->ms.CompressedBufferSizeInkByteThisState = mode_lib->ms.CompressedBufferSizeInkByteAllStates[j];
6288 mode_lib->ms.DETBufferSizeInKByteThisState[k] = mode_lib->ms.DETBufferSizeInKByteAllStates[j][k];
6289 mode_lib->ms.DETBufferSizeYThisState[k] = mode_lib->ms.DETBufferSizeYAllStates[j][k];
6290 mode_lib->ms.DETBufferSizeCThisState[k] = mode_lib->ms.DETBufferSizeCAllStates[j][k];
6291 }
6292
6293 mode_lib->ms.support.VActiveBandwithSupport[j] = CalculateVActiveBandwithSupport(
6294 mode_lib->ms.num_active_planes,
6295 mode_lib->ms.ReturnBWPerState[j],
6296 mode_lib->ms.NotUrgentLatencyHiding,
6297 mode_lib->ms.ReadBandwidthLuma,
6298 mode_lib->ms.ReadBandwidthChroma,
6299 mode_lib->ms.cursor_bw,
6300 mode_lib->ms.meta_row_bandwidth_this_state,
6301 mode_lib->ms.dpte_row_bandwidth_this_state,
6302 mode_lib->ms.NoOfDPPThisState,
6303 mode_lib->ms.UrgentBurstFactorLuma,
6304 mode_lib->ms.UrgentBurstFactorChroma,
6305 mode_lib->ms.UrgentBurstFactorCursor);
6306
6307 s->VMDataOnlyReturnBWPerState = dml_get_return_bw_mbps_vm_only(
6308 &mode_lib->ms.soc,
6309 mode_lib->ms.state.use_ideal_dram_bw_strobe,
6310 mode_lib->ms.cache_display_cfg.plane.HostVMEnable,
6311 mode_lib->ms.DCFCLKState[j],
6312 mode_lib->ms.state.fabricclk_mhz,
6313 mode_lib->ms.state.dram_speed_mts);
6314
6315 s->HostVMInefficiencyFactor = 1;
6316 if (mode_lib->ms.cache_display_cfg.plane.GPUVMEnable && mode_lib->ms.cache_display_cfg.plane.HostVMEnable)
6317 s->HostVMInefficiencyFactor = mode_lib->ms.ReturnBWPerState[j] / s->VMDataOnlyReturnBWPerState;
6318
6319 mode_lib->ms.ExtraLatency = CalculateExtraLatency(
6320 mode_lib->ms.soc.round_trip_ping_latency_dcfclk_cycles,
6321 s->ReorderingBytes,
6322 mode_lib->ms.DCFCLKState[j],
6323 mode_lib->ms.TotalNumberOfActiveDPP[j],
6324 mode_lib->ms.ip.pixel_chunk_size_kbytes,
6325 mode_lib->ms.TotalNumberOfDCCActiveDPP[j],
6326 mode_lib->ms.ip.meta_chunk_size_kbytes,
6327 mode_lib->ms.ReturnBWPerState[j],
6328 mode_lib->ms.cache_display_cfg.plane.GPUVMEnable,
6329 mode_lib->ms.cache_display_cfg.plane.HostVMEnable,
6330 mode_lib->ms.num_active_planes,
6331 mode_lib->ms.NoOfDPPThisState,
6332 mode_lib->ms.dpte_group_bytes,
6333 s->HostVMInefficiencyFactor,
6334 mode_lib->ms.soc.hostvm_min_page_size_kbytes * 1024,
6335 mode_lib->ms.cache_display_cfg.plane.HostVMMaxPageTableLevels);
6336
6337 s->NextMaxVStartup = s->MaxVStartupAllPlanes[j];
6338 s->MaxVStartup = 0;
6339 s->AllPrefetchModeTested = true;
6340 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6341 CalculatePrefetchMode(mode_lib->ms.policy.AllowForPStateChangeOrStutterInVBlank[k], &s->MinPrefetchMode[k], &s->MaxPrefetchMode[k]);
6342 s->NextPrefetchMode[k] = s->MinPrefetchMode[k];
6343 }
6344
6345 do {
6346 s->MaxVStartup = s->NextMaxVStartup;
6347 s->AllPrefetchModeTested = true;
6348
6349 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6350 mode_lib->ms.PrefetchMode[k] = s->NextPrefetchMode[k];
6351 mode_lib->ms.TWait = CalculateTWait(
6352 mode_lib->ms.PrefetchMode[k],
6353 mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[k],
6354 mode_lib->ms.policy.SynchronizeDRRDisplaysForUCLKPStateChangeFinal,
6355 mode_lib->ms.cache_display_cfg.timing.DRRDisplay[k],
6356 mode_lib->ms.state.dram_clock_change_latency_us,
6357 mode_lib->ms.state.fclk_change_latency_us,
6358 mode_lib->ms.UrgLatency,
6359 mode_lib->ms.state.sr_enter_plus_exit_time_us);
6360
6361 myPipe = &s->myPipe;
6362 myPipe->Dppclk = mode_lib->ms.RequiredDPPCLKPerSurface[j][k];
6363 myPipe->Dispclk = mode_lib->ms.RequiredDISPCLK[j];
6364 myPipe->PixelClock = mode_lib->ms.cache_display_cfg.timing.PixelClock[k];
6365 myPipe->DCFClkDeepSleep = mode_lib->ms.ProjectedDCFCLKDeepSleep[j];
6366 myPipe->DPPPerSurface = mode_lib->ms.NoOfDPP[j][k];
6367 myPipe->ScalerEnabled = mode_lib->ms.cache_display_cfg.plane.ScalerEnabled[k];
6368 myPipe->SourceScan = mode_lib->ms.cache_display_cfg.plane.SourceScan[k];
6369 myPipe->BlockWidth256BytesY = mode_lib->ms.Read256BlockWidthY[k];
6370 myPipe->BlockHeight256BytesY = mode_lib->ms.Read256BlockHeightY[k];
6371 myPipe->BlockWidth256BytesC = mode_lib->ms.Read256BlockWidthC[k];
6372 myPipe->BlockHeight256BytesC = mode_lib->ms.Read256BlockHeightC[k];
6373 myPipe->InterlaceEnable = mode_lib->ms.cache_display_cfg.timing.Interlace[k];
6374 myPipe->NumberOfCursors = mode_lib->ms.cache_display_cfg.plane.NumberOfCursors[k];
6375 myPipe->VBlank = mode_lib->ms.cache_display_cfg.timing.VTotal[k] - mode_lib->ms.cache_display_cfg.timing.VActive[k];
6376 myPipe->HTotal = mode_lib->ms.cache_display_cfg.timing.HTotal[k];
6377 myPipe->HActive = mode_lib->ms.cache_display_cfg.timing.HActive[k];
6378 myPipe->DCCEnable = mode_lib->ms.cache_display_cfg.surface.DCCEnable[k];
6379 myPipe->ODMMode = mode_lib->ms.ODMModePerState[k];
6380 myPipe->SourcePixelFormat = mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k];
6381 myPipe->BytePerPixelY = mode_lib->ms.BytePerPixelY[k];
6382 myPipe->BytePerPixelC = mode_lib->ms.BytePerPixelC[k];
6383 myPipe->ProgressiveToInterlaceUnitInOPP = mode_lib->ms.ip.ptoi_supported;
6384
6385 #ifdef __DML_VBA_DEBUG__
6386 dml_print("DML::%s: Calling CalculatePrefetchSchedule for j=%u, k=%u\n", __func__, j, k);
6387 dml_print("DML::%s: MaximumVStartup = %u\n", __func__, s->MaximumVStartup[j][k]);
6388 dml_print("DML::%s: MaxVStartup = %u\n", __func__, s->MaxVStartup);
6389 dml_print("DML::%s: NextPrefetchMode = %u\n", __func__, s->NextPrefetchMode[k]);
6390 dml_print("DML::%s: AllowForPStateChangeOrStutterInVBlank = %u\n", __func__, mode_lib->ms.policy.AllowForPStateChangeOrStutterInVBlank[k]);
6391 dml_print("DML::%s: PrefetchMode = %u\n", __func__, mode_lib->ms.PrefetchMode[k]);
6392 #endif
6393
6394 CalculatePrefetchSchedule_params->HostVMInefficiencyFactor = s->HostVMInefficiencyFactor;
6395 CalculatePrefetchSchedule_params->myPipe = myPipe;
6396 CalculatePrefetchSchedule_params->VStartup = (dml_uint_t)(dml_min(s->MaxVStartup, s->MaximumVStartup[j][k]));
6397 CalculatePrefetchSchedule_params->MaxVStartup = s->MaximumVStartup[j][k];
6398 CalculatePrefetchSchedule_params->DSTXAfterScaler = &s->DSTXAfterScaler[k];
6399 CalculatePrefetchSchedule_params->DSTYAfterScaler = &s->DSTYAfterScaler[k];
6400 CalculatePrefetchSchedule_params->prefetch_vmrow_bw = &mode_lib->ms.prefetch_vmrow_bw[k];
6401 CalculatePrefetchSchedule_params->Tdmdl_vm = &s->dummy_single[0];
6402 CalculatePrefetchSchedule_params->Tdmdl = &s->dummy_single[1];
6403 CalculatePrefetchSchedule_params->TSetup = &s->dummy_single[2];
6404 CalculatePrefetchSchedule_params->VUpdateOffsetPix = &s->dummy_integer[0];
6405 CalculatePrefetchSchedule_params->VUpdateWidthPix = &s->dummy_integer[1];
6406 CalculatePrefetchSchedule_params->VReadyOffsetPix = &s->dummy_integer[2];
6407
6408 set_calculate_prefetch_schedule_params(mode_lib, CalculatePrefetchSchedule_params, j, k);
6409
6410 mode_lib->ms.support.NoTimeForPrefetch[j][k] =
6411 CalculatePrefetchSchedule(&mode_lib->scratch,
6412 CalculatePrefetchSchedule_params);
6413 }
6414
6415 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6416 CalculateUrgentBurstFactor(
6417 mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[k],
6418 mode_lib->ms.swath_width_luma_ub_this_state[k],
6419 mode_lib->ms.swath_width_chroma_ub_this_state[k],
6420 mode_lib->ms.SwathHeightYThisState[k],
6421 mode_lib->ms.SwathHeightCThisState[k],
6422 mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k],
6423 mode_lib->ms.UrgLatency,
6424 mode_lib->ms.ip.cursor_buffer_size,
6425 mode_lib->ms.cache_display_cfg.plane.CursorWidth[k],
6426 mode_lib->ms.cache_display_cfg.plane.CursorBPP[k],
6427 mode_lib->ms.VRatioPreY[j][k],
6428 mode_lib->ms.VRatioPreC[j][k],
6429 mode_lib->ms.BytePerPixelInDETY[k],
6430 mode_lib->ms.BytePerPixelInDETC[k],
6431 mode_lib->ms.DETBufferSizeYThisState[k],
6432 mode_lib->ms.DETBufferSizeCThisState[k],
6433 /* Output */
6434 &mode_lib->ms.UrgentBurstFactorCursorPre[k],
6435 &mode_lib->ms.UrgentBurstFactorLumaPre[k],
6436 &mode_lib->ms.UrgentBurstFactorChroma[k],
6437 &mode_lib->ms.NotUrgentLatencyHidingPre[k]);
6438
6439 mode_lib->ms.cursor_bw_pre[k] = mode_lib->ms.cache_display_cfg.plane.NumberOfCursors[k] * mode_lib->ms.cache_display_cfg.plane.CursorWidth[k] *
6440 mode_lib->ms.cache_display_cfg.plane.CursorBPP[k] / 8.0 / (mode_lib->ms.cache_display_cfg.timing.HTotal[k] /
6441 mode_lib->ms.cache_display_cfg.timing.PixelClock[k]) * mode_lib->ms.VRatioPreY[j][k];
6442 }
6443
6444 {
6445 CalculatePrefetchBandwithSupport(
6446 mode_lib->ms.num_active_planes,
6447 mode_lib->ms.ReturnBWPerState[j],
6448 mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange,
6449 mode_lib->ms.NotUrgentLatencyHidingPre,
6450 mode_lib->ms.ReadBandwidthLuma,
6451 mode_lib->ms.ReadBandwidthChroma,
6452 mode_lib->ms.RequiredPrefetchPixelDataBWLuma,
6453 mode_lib->ms.RequiredPrefetchPixelDataBWChroma,
6454 mode_lib->ms.cursor_bw,
6455 mode_lib->ms.meta_row_bandwidth_this_state,
6456 mode_lib->ms.dpte_row_bandwidth_this_state,
6457 mode_lib->ms.cursor_bw_pre,
6458 mode_lib->ms.prefetch_vmrow_bw,
6459 mode_lib->ms.NoOfDPPThisState,
6460 mode_lib->ms.UrgentBurstFactorLuma,
6461 mode_lib->ms.UrgentBurstFactorChroma,
6462 mode_lib->ms.UrgentBurstFactorCursor,
6463 mode_lib->ms.UrgentBurstFactorLumaPre,
6464 mode_lib->ms.UrgentBurstFactorChromaPre,
6465 mode_lib->ms.UrgentBurstFactorCursorPre,
6466
6467 /* output */
6468 &s->dummy_single[0], // dml_float_t *PrefetchBandwidth
6469 &s->dummy_single[1], // dml_float_t *PrefetchBandwidthNotIncludingMALLPrefetch
6470 &mode_lib->mp.FractionOfUrgentBandwidth, // dml_float_t *FractionOfUrgentBandwidth
6471 &mode_lib->ms.support.PrefetchSupported[j]);
6472 }
6473
6474 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6475 if (mode_lib->ms.LineTimesForPrefetch[k] < 2.0
6476 || mode_lib->ms.LinesForMetaPTE[k] >= 32.0
6477 || mode_lib->ms.LinesForMetaAndDPTERow[k] >= 16.0
6478 || mode_lib->ms.support.NoTimeForPrefetch[j][k] == true) {
6479 mode_lib->ms.support.PrefetchSupported[j] = false;
6480 }
6481 }
6482
6483 mode_lib->ms.support.DynamicMetadataSupported[j] = true;
6484 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
6485 if (mode_lib->ms.support.NoTimeForDynamicMetadata[j][k] == true) {
6486 mode_lib->ms.support.DynamicMetadataSupported[j] = false;
6487 }
6488 }
6489
6490 mode_lib->ms.support.VRatioInPrefetchSupported[j] = true;
6491 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6492 if (mode_lib->ms.support.NoTimeForPrefetch[j][k] == true ||
6493 mode_lib->ms.VRatioPreY[j][k] > __DML_MAX_VRATIO_PRE_ENHANCE_PREFETCH_ACC__ ||
6494 mode_lib->ms.VRatioPreC[j][k] > __DML_MAX_VRATIO_PRE_ENHANCE_PREFETCH_ACC__ ||
6495 ((s->MaxVStartup < s->MaximumVStartup[j][k] || mode_lib->ms.policy.EnhancedPrefetchScheduleAccelerationFinal == 0) &&
6496 (mode_lib->ms.VRatioPreY[j][k] > __DML_MAX_VRATIO_PRE__ || mode_lib->ms.VRatioPreC[j][k] > __DML_MAX_VRATIO_PRE__))) {
6497 mode_lib->ms.support.VRatioInPrefetchSupported[j] = false;
6498 }
6499 }
6500
6501 s->AnyLinesForVMOrRowTooLarge = false;
6502 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
6503 if (mode_lib->ms.LinesForMetaAndDPTERow[k] >= 16 || mode_lib->ms.LinesForMetaPTE[k] >= 32) {
6504 s->AnyLinesForVMOrRowTooLarge = true;
6505 }
6506 }
6507
6508 if (mode_lib->ms.support.PrefetchSupported[j] == true && mode_lib->ms.support.VRatioInPrefetchSupported[j] == true) {
6509 mode_lib->ms.BandwidthAvailableForImmediateFlip = CalculateBandwidthAvailableForImmediateFlip(
6510 mode_lib->ms.num_active_planes,
6511 mode_lib->ms.ReturnBWPerState[j],
6512 mode_lib->ms.ReadBandwidthLuma,
6513 mode_lib->ms.ReadBandwidthChroma,
6514 mode_lib->ms.RequiredPrefetchPixelDataBWLuma,
6515 mode_lib->ms.RequiredPrefetchPixelDataBWChroma,
6516 mode_lib->ms.cursor_bw,
6517 mode_lib->ms.cursor_bw_pre,
6518 mode_lib->ms.NoOfDPPThisState,
6519 mode_lib->ms.UrgentBurstFactorLuma,
6520 mode_lib->ms.UrgentBurstFactorChroma,
6521 mode_lib->ms.UrgentBurstFactorCursor,
6522 mode_lib->ms.UrgentBurstFactorLumaPre,
6523 mode_lib->ms.UrgentBurstFactorChromaPre,
6524 mode_lib->ms.UrgentBurstFactorCursorPre);
6525
6526 mode_lib->ms.TotImmediateFlipBytes = 0;
6527 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6528 if (!(mode_lib->ms.policy.ImmediateFlipRequirement[k] == dml_immediate_flip_not_required)) {
6529 mode_lib->ms.TotImmediateFlipBytes = mode_lib->ms.TotImmediateFlipBytes + mode_lib->ms.NoOfDPP[j][k] * mode_lib->ms.PDEAndMetaPTEBytesPerFrame[j][k] + mode_lib->ms.MetaRowBytes[j][k];
6530 if (mode_lib->ms.use_one_row_for_frame_flip[j][k]) {
6531 mode_lib->ms.TotImmediateFlipBytes = mode_lib->ms.TotImmediateFlipBytes + mode_lib->ms.NoOfDPP[j][k] * (2 * mode_lib->ms.DPTEBytesPerRow[j][k]);
6532 } else {
6533 mode_lib->ms.TotImmediateFlipBytes = mode_lib->ms.TotImmediateFlipBytes + mode_lib->ms.NoOfDPP[j][k] * mode_lib->ms.DPTEBytesPerRow[j][k];
6534 }
6535 }
6536 }
6537
6538 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6539 CalculateFlipSchedule(
6540 s->HostVMInefficiencyFactor,
6541 mode_lib->ms.ExtraLatency,
6542 mode_lib->ms.UrgLatency,
6543 mode_lib->ms.cache_display_cfg.plane.GPUVMMaxPageTableLevels,
6544 mode_lib->ms.cache_display_cfg.plane.HostVMEnable,
6545 mode_lib->ms.cache_display_cfg.plane.HostVMMaxPageTableLevels,
6546 mode_lib->ms.cache_display_cfg.plane.GPUVMEnable,
6547 mode_lib->ms.soc.hostvm_min_page_size_kbytes * 1024,
6548 mode_lib->ms.PDEAndMetaPTEBytesPerFrame[j][k],
6549 mode_lib->ms.MetaRowBytes[j][k],
6550 mode_lib->ms.DPTEBytesPerRow[j][k],
6551 mode_lib->ms.BandwidthAvailableForImmediateFlip,
6552 mode_lib->ms.TotImmediateFlipBytes,
6553 mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k],
6554 (mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k]),
6555 mode_lib->ms.cache_display_cfg.plane.VRatio[k],
6556 mode_lib->ms.cache_display_cfg.plane.VRatioChroma[k],
6557 mode_lib->ms.Tno_bw[k],
6558 mode_lib->ms.cache_display_cfg.surface.DCCEnable[k],
6559 mode_lib->ms.dpte_row_height[k],
6560 mode_lib->ms.meta_row_height[k],
6561 mode_lib->ms.dpte_row_height_chroma[k],
6562 mode_lib->ms.meta_row_height_chroma[k],
6563 mode_lib->ms.use_one_row_for_frame_flip[j][k], // 24
6564
6565 /* Output */
6566 &mode_lib->ms.DestinationLinesToRequestVMInImmediateFlip[k],
6567 &mode_lib->ms.DestinationLinesToRequestRowInImmediateFlip[k],
6568 &mode_lib->ms.final_flip_bw[k],
6569 &mode_lib->ms.ImmediateFlipSupportedForPipe[k]);
6570 }
6571
6572 {
6573 CalculateImmediateFlipBandwithSupport(mode_lib->ms.num_active_planes,
6574 mode_lib->ms.ReturnBWPerState[j],
6575 mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange,
6576 mode_lib->ms.policy.ImmediateFlipRequirement,
6577 mode_lib->ms.final_flip_bw,
6578 mode_lib->ms.ReadBandwidthLuma,
6579 mode_lib->ms.ReadBandwidthChroma,
6580 mode_lib->ms.RequiredPrefetchPixelDataBWLuma,
6581 mode_lib->ms.RequiredPrefetchPixelDataBWChroma,
6582 mode_lib->ms.cursor_bw,
6583 mode_lib->ms.meta_row_bandwidth_this_state,
6584 mode_lib->ms.dpte_row_bandwidth_this_state,
6585 mode_lib->ms.cursor_bw_pre,
6586 mode_lib->ms.prefetch_vmrow_bw,
6587 mode_lib->ms.NoOfDPP[j], // VBA_ERROR DPPPerSurface is not assigned at this point, should use NoOfDpp here
6588 mode_lib->ms.UrgentBurstFactorLuma,
6589 mode_lib->ms.UrgentBurstFactorChroma,
6590 mode_lib->ms.UrgentBurstFactorCursor,
6591 mode_lib->ms.UrgentBurstFactorLumaPre,
6592 mode_lib->ms.UrgentBurstFactorChromaPre,
6593 mode_lib->ms.UrgentBurstFactorCursorPre,
6594
6595 /* output */
6596 &s->dummy_single[0], // dml_float_t *TotalBandwidth
6597 &s->dummy_single[1], // dml_float_t *TotalBandwidthNotIncludingMALLPrefetch
6598 &s->dummy_single[2], // dml_float_t *FractionOfUrgentBandwidth
6599 &mode_lib->ms.support.ImmediateFlipSupportedForState[j]); // dml_bool_t *ImmediateFlipBandwidthSupport
6600 }
6601
6602 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6603 if (!(mode_lib->ms.policy.ImmediateFlipRequirement[k] == dml_immediate_flip_not_required) && (mode_lib->ms.ImmediateFlipSupportedForPipe[k] == false))
6604 mode_lib->ms.support.ImmediateFlipSupportedForState[j] = false;
6605 }
6606
6607 } else { // if prefetch not support, assume iflip not supported
6608 mode_lib->ms.support.ImmediateFlipSupportedForState[j] = false;
6609 }
6610
6611 if (s->MaxVStartup <= __DML_VBA_MIN_VSTARTUP__ || s->AnyLinesForVMOrRowTooLarge == false) {
6612 s->NextMaxVStartup = s->MaxVStartupAllPlanes[j];
6613 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6614 s->NextPrefetchMode[k] = s->NextPrefetchMode[k] + 1;
6615
6616 if (s->NextPrefetchMode[k] <= s->MaxPrefetchMode[k])
6617 s->AllPrefetchModeTested = false;
6618 }
6619 } else {
6620 s->NextMaxVStartup = s->NextMaxVStartup - 1;
6621 }
6622 } while (!((mode_lib->ms.support.PrefetchSupported[j] == true && mode_lib->ms.support.DynamicMetadataSupported[j] == true &&
6623 mode_lib->ms.support.VRatioInPrefetchSupported[j] == true &&
6624 // consider flip support is okay if when there is no hostvm and the user does't require a iflip OR the flip bw is ok
6625 // If there is hostvm, DCN needs to support iflip for invalidation
6626 ((s->ImmediateFlipRequiredFinal) || mode_lib->ms.support.ImmediateFlipSupportedForState[j] == true)) ||
6627 (s->NextMaxVStartup == s->MaxVStartupAllPlanes[j] && s->AllPrefetchModeTested)));
6628
6629 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
6630 mode_lib->ms.use_one_row_for_frame_this_state[k] = mode_lib->ms.use_one_row_for_frame[j][k];
6631 }
6632
6633 s->mSOCParameters.UrgentLatency = mode_lib->ms.UrgLatency;
6634 s->mSOCParameters.ExtraLatency = mode_lib->ms.ExtraLatency;
6635 s->mSOCParameters.WritebackLatency = mode_lib->ms.state.writeback_latency_us;
6636 s->mSOCParameters.DRAMClockChangeLatency = mode_lib->ms.state.dram_clock_change_latency_us;
6637 s->mSOCParameters.FCLKChangeLatency = mode_lib->ms.state.fclk_change_latency_us;
6638 s->mSOCParameters.SRExitTime = mode_lib->ms.state.sr_exit_time_us;
6639 s->mSOCParameters.SREnterPlusExitTime = mode_lib->ms.state.sr_enter_plus_exit_time_us;
6640 s->mSOCParameters.SRExitZ8Time = mode_lib->ms.state.sr_exit_z8_time_us;
6641 s->mSOCParameters.SREnterPlusExitZ8Time = mode_lib->ms.state.sr_enter_plus_exit_z8_time_us;
6642 s->mSOCParameters.USRRetrainingLatency = mode_lib->ms.state.usr_retraining_latency_us;
6643 s->mSOCParameters.SMNLatency = mode_lib->ms.soc.smn_latency_us;
6644
6645 CalculateWatermarks_params->USRRetrainingRequiredFinal = mode_lib->ms.policy.USRRetrainingRequiredFinal;
6646 CalculateWatermarks_params->UseMALLForPStateChange = mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange;
6647 CalculateWatermarks_params->PrefetchMode = mode_lib->ms.PrefetchMode;
6648 CalculateWatermarks_params->NumberOfActiveSurfaces = mode_lib->ms.num_active_planes;
6649 CalculateWatermarks_params->MaxLineBufferLines = mode_lib->ms.ip.max_line_buffer_lines;
6650 CalculateWatermarks_params->LineBufferSize = mode_lib->ms.ip.line_buffer_size_bits;
6651 CalculateWatermarks_params->WritebackInterfaceBufferSize = mode_lib->ms.ip.writeback_interface_buffer_size_kbytes;
6652 CalculateWatermarks_params->DCFCLK = mode_lib->ms.DCFCLKState[j];
6653 CalculateWatermarks_params->ReturnBW = mode_lib->ms.ReturnBWPerState[j];
6654 CalculateWatermarks_params->SynchronizeTimingsFinal = mode_lib->ms.policy.SynchronizeTimingsFinal;
6655 CalculateWatermarks_params->SynchronizeDRRDisplaysForUCLKPStateChangeFinal = mode_lib->ms.policy.SynchronizeDRRDisplaysForUCLKPStateChangeFinal;
6656 CalculateWatermarks_params->DRRDisplay = mode_lib->ms.cache_display_cfg.timing.DRRDisplay;
6657 CalculateWatermarks_params->dpte_group_bytes = mode_lib->ms.dpte_group_bytes;
6658 CalculateWatermarks_params->meta_row_height = mode_lib->ms.meta_row_height;
6659 CalculateWatermarks_params->meta_row_height_chroma = mode_lib->ms.meta_row_height_chroma;
6660 CalculateWatermarks_params->mmSOCParameters = s->mSOCParameters;
6661 CalculateWatermarks_params->WritebackChunkSize = mode_lib->ms.ip.writeback_chunk_size_kbytes;
6662 CalculateWatermarks_params->SOCCLK = mode_lib->ms.state.socclk_mhz;
6663 CalculateWatermarks_params->DCFClkDeepSleep = mode_lib->ms.ProjectedDCFCLKDeepSleep[j];
6664 CalculateWatermarks_params->DETBufferSizeY = mode_lib->ms.DETBufferSizeYThisState;
6665 CalculateWatermarks_params->DETBufferSizeC = mode_lib->ms.DETBufferSizeCThisState;
6666 CalculateWatermarks_params->SwathHeightY = mode_lib->ms.SwathHeightYThisState;
6667 CalculateWatermarks_params->SwathHeightC = mode_lib->ms.SwathHeightCThisState;
6668 CalculateWatermarks_params->LBBitPerPixel = mode_lib->ms.cache_display_cfg.plane.LBBitPerPixel;
6669 CalculateWatermarks_params->SwathWidthY = mode_lib->ms.SwathWidthYThisState;
6670 CalculateWatermarks_params->SwathWidthC = mode_lib->ms.SwathWidthCThisState;
6671 CalculateWatermarks_params->HRatio = mode_lib->ms.cache_display_cfg.plane.HRatio;
6672 CalculateWatermarks_params->HRatioChroma = mode_lib->ms.cache_display_cfg.plane.HRatioChroma;
6673 CalculateWatermarks_params->VTaps = mode_lib->ms.cache_display_cfg.plane.VTaps;
6674 CalculateWatermarks_params->VTapsChroma = mode_lib->ms.cache_display_cfg.plane.VTapsChroma;
6675 CalculateWatermarks_params->VRatio = mode_lib->ms.cache_display_cfg.plane.VRatio;
6676 CalculateWatermarks_params->VRatioChroma = mode_lib->ms.cache_display_cfg.plane.VRatioChroma;
6677 CalculateWatermarks_params->HTotal = mode_lib->ms.cache_display_cfg.timing.HTotal;
6678 CalculateWatermarks_params->VTotal = mode_lib->ms.cache_display_cfg.timing.VTotal;
6679 CalculateWatermarks_params->VActive = mode_lib->ms.cache_display_cfg.timing.VActive;
6680 CalculateWatermarks_params->PixelClock = mode_lib->ms.cache_display_cfg.timing.PixelClock;
6681 CalculateWatermarks_params->BlendingAndTiming = mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming;
6682 CalculateWatermarks_params->DPPPerSurface = mode_lib->ms.NoOfDPPThisState;
6683 CalculateWatermarks_params->BytePerPixelDETY = mode_lib->ms.BytePerPixelInDETY;
6684 CalculateWatermarks_params->BytePerPixelDETC = mode_lib->ms.BytePerPixelInDETC;
6685 CalculateWatermarks_params->DSTXAfterScaler = s->DSTXAfterScaler;
6686 CalculateWatermarks_params->DSTYAfterScaler = s->DSTYAfterScaler;
6687 CalculateWatermarks_params->WritebackEnable = mode_lib->ms.cache_display_cfg.writeback.WritebackEnable;
6688 CalculateWatermarks_params->WritebackPixelFormat = mode_lib->ms.cache_display_cfg.writeback.WritebackPixelFormat;
6689 CalculateWatermarks_params->WritebackDestinationWidth = mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationWidth;
6690 CalculateWatermarks_params->WritebackDestinationHeight = mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationHeight;
6691 CalculateWatermarks_params->WritebackSourceHeight = mode_lib->ms.cache_display_cfg.writeback.WritebackSourceHeight;
6692 CalculateWatermarks_params->UnboundedRequestEnabled = mode_lib->ms.UnboundedRequestEnabledThisState;
6693 CalculateWatermarks_params->CompressedBufferSizeInkByte = mode_lib->ms.CompressedBufferSizeInkByteThisState;
6694
6695 // Output
6696 CalculateWatermarks_params->Watermark = &s->dummy_watermark; // Watermarks *Watermark
6697 CalculateWatermarks_params->DRAMClockChangeSupport = &mode_lib->ms.support.DRAMClockChangeSupport[j];
6698 CalculateWatermarks_params->MaxActiveDRAMClockChangeLatencySupported = &s->dummy_single_array[0]; // dml_float_t *MaxActiveDRAMClockChangeLatencySupported[]
6699 CalculateWatermarks_params->SubViewportLinesNeededInMALL = &mode_lib->ms.SubViewportLinesNeededInMALL[j]; // dml_uint_t SubViewportLinesNeededInMALL[]
6700 CalculateWatermarks_params->FCLKChangeSupport = &mode_lib->ms.support.FCLKChangeSupport[j];
6701 CalculateWatermarks_params->MaxActiveFCLKChangeLatencySupported = &s->dummy_single[0]; // dml_float_t *MaxActiveFCLKChangeLatencySupported
6702 CalculateWatermarks_params->USRRetrainingSupport = &mode_lib->ms.support.USRRetrainingSupport[j];
6703 CalculateWatermarks_params->ActiveDRAMClockChangeLatencyMargin = mode_lib->ms.support.ActiveDRAMClockChangeLatencyMargin;
6704
6705 CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport(&mode_lib->scratch,
6706 CalculateWatermarks_params);
6707
6708 } // for j
6709 }
6710
6711 /// @brief The Mode Support function.
dml_core_mode_support(struct display_mode_lib_st * mode_lib)6712 dml_bool_t dml_core_mode_support(struct display_mode_lib_st *mode_lib)
6713 {
6714 struct dml_core_mode_support_locals_st *s = &mode_lib->scratch.dml_core_mode_support_locals;
6715 struct UseMinimumDCFCLK_params_st *UseMinimumDCFCLK_params = &mode_lib->scratch.UseMinimumDCFCLK_params;
6716 struct CalculateSwathAndDETConfiguration_params_st *CalculateSwathAndDETConfiguration_params = &mode_lib->scratch.CalculateSwathAndDETConfiguration_params;
6717 struct CalculateVMRowAndSwath_params_st *CalculateVMRowAndSwath_params = &mode_lib->scratch.CalculateVMRowAndSwath_params;
6718
6719 dml_uint_t j, k, m;
6720
6721 mode_lib->ms.num_active_planes = dml_get_num_active_planes(&mode_lib->ms.cache_display_cfg);
6722 dml_print("DML::%s: num_active_planes = %u\n", __func__, mode_lib->ms.num_active_planes);
6723
6724 CalculateMaxDETAndMinCompressedBufferSize(
6725 mode_lib->ms.ip.config_return_buffer_size_in_kbytes,
6726 mode_lib->ms.ip.config_return_buffer_segment_size_in_kbytes,
6727 mode_lib->ms.ip.rob_buffer_size_kbytes,
6728 mode_lib->ms.ip.max_num_dpp,
6729 mode_lib->ms.policy.NomDETInKByteOverrideEnable, // VBA_DELTA
6730 mode_lib->ms.policy.NomDETInKByteOverrideValue, // VBA_DELTA
6731
6732 /* Output */
6733 &mode_lib->ms.MaxTotalDETInKByte,
6734 &mode_lib->ms.NomDETInKByte,
6735 &mode_lib->ms.MinCompressedBufferSizeInKByte);
6736
6737 PixelClockAdjustmentForProgressiveToInterlaceUnit(&mode_lib->ms.cache_display_cfg, mode_lib->ms.ip.ptoi_supported);
6738
6739
6740 /*MODE SUPPORT, VOLTAGE STATE AND SOC CONFIGURATION*/
6741
6742 /*Scale Ratio, taps Support Check*/
6743 mode_lib->ms.support.ScaleRatioAndTapsSupport = true;
6744 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6745 if (mode_lib->ms.cache_display_cfg.plane.ScalerEnabled[k] == false
6746 && ((mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_444_64
6747 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_444_32
6748 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_444_16
6749 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_mono_16
6750 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_mono_8
6751 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_rgbe
6752 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_rgbe_alpha)
6753 || mode_lib->ms.cache_display_cfg.plane.HRatio[k] != 1.0
6754 || mode_lib->ms.cache_display_cfg.plane.HTaps[k] != 1.0
6755 || mode_lib->ms.cache_display_cfg.plane.VRatio[k] != 1.0
6756 || mode_lib->ms.cache_display_cfg.plane.VTaps[k] != 1.0)) {
6757 mode_lib->ms.support.ScaleRatioAndTapsSupport = false;
6758 } else if (mode_lib->ms.cache_display_cfg.plane.VTaps[k] < 1.0 || mode_lib->ms.cache_display_cfg.plane.VTaps[k] > 8.0
6759 || mode_lib->ms.cache_display_cfg.plane.HTaps[k] < 1.0 || mode_lib->ms.cache_display_cfg.plane.HTaps[k] > 8.0
6760 || (mode_lib->ms.cache_display_cfg.plane.HTaps[k] > 1.0 && (mode_lib->ms.cache_display_cfg.plane.HTaps[k] % 2) == 1)
6761 || mode_lib->ms.cache_display_cfg.plane.HRatio[k] > mode_lib->ms.ip.max_hscl_ratio
6762 || mode_lib->ms.cache_display_cfg.plane.VRatio[k] > mode_lib->ms.ip.max_vscl_ratio
6763 || mode_lib->ms.cache_display_cfg.plane.HRatio[k] > mode_lib->ms.cache_display_cfg.plane.HTaps[k]
6764 || mode_lib->ms.cache_display_cfg.plane.VRatio[k] > mode_lib->ms.cache_display_cfg.plane.VTaps[k]
6765 || (mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_444_64
6766 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_444_32
6767 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_444_16
6768 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_mono_16
6769 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_mono_8
6770 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_rgbe
6771 && (mode_lib->ms.cache_display_cfg.plane.VTapsChroma[k] < 1 || mode_lib->ms.cache_display_cfg.plane.VTapsChroma[k] > 8 || mode_lib->ms.cache_display_cfg.plane.HTapsChroma[k] < 1 || mode_lib->ms.cache_display_cfg.plane.HTapsChroma[k] > 8 ||
6772 (mode_lib->ms.cache_display_cfg.plane.HTapsChroma[k] > 1 && mode_lib->ms.cache_display_cfg.plane.HTapsChroma[k] % 2 == 1) ||
6773 mode_lib->ms.cache_display_cfg.plane.HRatioChroma[k] > mode_lib->ms.ip.max_hscl_ratio ||
6774 mode_lib->ms.cache_display_cfg.plane.VRatioChroma[k] > mode_lib->ms.ip.max_vscl_ratio ||
6775 mode_lib->ms.cache_display_cfg.plane.HRatioChroma[k] > mode_lib->ms.cache_display_cfg.plane.HTapsChroma[k] ||
6776 mode_lib->ms.cache_display_cfg.plane.VRatioChroma[k] > mode_lib->ms.cache_display_cfg.plane.VTapsChroma[k]))) {
6777 mode_lib->ms.support.ScaleRatioAndTapsSupport = false;
6778 }
6779 }
6780
6781 /*Source Format, Pixel Format and Scan Support Check*/
6782 mode_lib->ms.support.SourceFormatPixelAndScanSupport = true;
6783 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6784 if (mode_lib->ms.cache_display_cfg.surface.SurfaceTiling[k] == dml_sw_linear && (!(!dml_is_vertical_rotation(mode_lib->ms.cache_display_cfg.plane.SourceScan[k])) || mode_lib->ms.cache_display_cfg.surface.DCCEnable[k] == true)) {
6785 mode_lib->ms.support.SourceFormatPixelAndScanSupport = false;
6786 }
6787 }
6788
6789 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6790 CalculateBytePerPixelAndBlockSizes(
6791 mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k],
6792 mode_lib->ms.cache_display_cfg.surface.SurfaceTiling[k],
6793
6794 /* Output */
6795 &mode_lib->ms.BytePerPixelY[k],
6796 &mode_lib->ms.BytePerPixelC[k],
6797 &mode_lib->ms.BytePerPixelInDETY[k],
6798 &mode_lib->ms.BytePerPixelInDETC[k],
6799 &mode_lib->ms.Read256BlockHeightY[k],
6800 &mode_lib->ms.Read256BlockHeightC[k],
6801 &mode_lib->ms.Read256BlockWidthY[k],
6802 &mode_lib->ms.Read256BlockWidthC[k],
6803 &mode_lib->ms.MacroTileHeightY[k],
6804 &mode_lib->ms.MacroTileHeightC[k],
6805 &mode_lib->ms.MacroTileWidthY[k],
6806 &mode_lib->ms.MacroTileWidthC[k]);
6807 }
6808
6809 /*Bandwidth Support Check*/
6810 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6811 if (!dml_is_vertical_rotation(mode_lib->ms.cache_display_cfg.plane.SourceScan[k])) {
6812 mode_lib->ms.SwathWidthYSingleDPP[k] = mode_lib->ms.cache_display_cfg.plane.ViewportWidth[k];
6813 mode_lib->ms.SwathWidthCSingleDPP[k] = mode_lib->ms.cache_display_cfg.plane.ViewportWidthChroma[k];
6814 } else {
6815 mode_lib->ms.SwathWidthYSingleDPP[k] = mode_lib->ms.cache_display_cfg.plane.ViewportHeight[k];
6816 mode_lib->ms.SwathWidthCSingleDPP[k] = mode_lib->ms.cache_display_cfg.plane.ViewportHeightChroma[k];
6817 }
6818 }
6819 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6820 mode_lib->ms.ReadBandwidthLuma[k] = mode_lib->ms.SwathWidthYSingleDPP[k] * dml_ceil(mode_lib->ms.BytePerPixelInDETY[k], 1.0) / (mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k]) * mode_lib->ms.cache_display_cfg.plane.VRatio[k];
6821 mode_lib->ms.ReadBandwidthChroma[k] = mode_lib->ms.SwathWidthYSingleDPP[k] / 2 * dml_ceil(mode_lib->ms.BytePerPixelInDETC[k], 2.0) / (mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k]) * mode_lib->ms.cache_display_cfg.plane.VRatio[k] / 2.0;
6822 }
6823 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6824 if (mode_lib->ms.cache_display_cfg.writeback.WritebackEnable[k] == true
6825 && mode_lib->ms.cache_display_cfg.writeback.WritebackPixelFormat[k] == dml_444_64) {
6826 mode_lib->ms.WriteBandwidth[k] = mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationWidth[k]
6827 * mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationHeight[k]
6828 / (mode_lib->ms.cache_display_cfg.writeback.WritebackSourceHeight[k]
6829 * mode_lib->ms.cache_display_cfg.timing.HTotal[k]
6830 / mode_lib->ms.cache_display_cfg.timing.PixelClock[k]) * 8.0;
6831 } else if (mode_lib->ms.cache_display_cfg.writeback.WritebackEnable[k] == true) {
6832 mode_lib->ms.WriteBandwidth[k] = mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationWidth[k]
6833 * mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationHeight[k]
6834 / (mode_lib->ms.cache_display_cfg.writeback.WritebackSourceHeight[k]
6835 * mode_lib->ms.cache_display_cfg.timing.HTotal[k]
6836 / mode_lib->ms.cache_display_cfg.timing.PixelClock[k]) * 4.0;
6837 } else {
6838 mode_lib->ms.WriteBandwidth[k] = 0.0;
6839 }
6840 }
6841
6842 /*Writeback Latency support check*/
6843 mode_lib->ms.support.WritebackLatencySupport = true;
6844 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6845 if (mode_lib->ms.cache_display_cfg.writeback.WritebackEnable[k] == true &&
6846 (mode_lib->ms.WriteBandwidth[k] > mode_lib->ms.ip.writeback_interface_buffer_size_kbytes * 1024 / mode_lib->ms.state.writeback_latency_us)) {
6847 mode_lib->ms.support.WritebackLatencySupport = false;
6848 }
6849 }
6850
6851 /*Writeback Mode Support Check*/
6852 s->TotalNumberOfActiveWriteback = 0;
6853 for (k = 0; k <= (dml_uint_t) mode_lib->ms.num_active_planes - 1; k++) {
6854 if (mode_lib->ms.cache_display_cfg.writeback.WritebackEnable[k] == true) {
6855 s->TotalNumberOfActiveWriteback = s->TotalNumberOfActiveWriteback + 1;
6856 }
6857 }
6858
6859 mode_lib->ms.support.EnoughWritebackUnits = 1;
6860 if (s->TotalNumberOfActiveWriteback > (dml_uint_t) mode_lib->ms.ip.max_num_wb) {
6861 mode_lib->ms.support.EnoughWritebackUnits = false;
6862 }
6863
6864 /*Writeback Scale Ratio and Taps Support Check*/
6865 mode_lib->ms.support.WritebackScaleRatioAndTapsSupport = true;
6866 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6867 if (mode_lib->ms.cache_display_cfg.writeback.WritebackEnable[k] == true) {
6868 if (mode_lib->ms.cache_display_cfg.writeback.WritebackHRatio[k] > mode_lib->ms.ip.writeback_max_hscl_ratio
6869 || mode_lib->ms.cache_display_cfg.writeback.WritebackVRatio[k] > mode_lib->ms.ip.writeback_max_vscl_ratio
6870 || mode_lib->ms.cache_display_cfg.writeback.WritebackHRatio[k] < mode_lib->ms.ip.writeback_min_hscl_ratio
6871 || mode_lib->ms.cache_display_cfg.writeback.WritebackVRatio[k] < mode_lib->ms.ip.writeback_min_vscl_ratio
6872 || mode_lib->ms.cache_display_cfg.writeback.WritebackHTaps[k] > (dml_uint_t) mode_lib->ms.ip.writeback_max_hscl_taps
6873 || mode_lib->ms.cache_display_cfg.writeback.WritebackVTaps[k] > (dml_uint_t) mode_lib->ms.ip.writeback_max_vscl_taps
6874 || mode_lib->ms.cache_display_cfg.writeback.WritebackHRatio[k] > (dml_uint_t) mode_lib->ms.cache_display_cfg.writeback.WritebackHTaps[k]
6875 || mode_lib->ms.cache_display_cfg.writeback.WritebackVRatio[k] > (dml_uint_t) mode_lib->ms.cache_display_cfg.writeback.WritebackVTaps[k]
6876 || (mode_lib->ms.cache_display_cfg.writeback.WritebackHTaps[k] > 2.0 && ((mode_lib->ms.cache_display_cfg.writeback.WritebackHTaps[k] % 2) == 1))) {
6877 mode_lib->ms.support.WritebackScaleRatioAndTapsSupport = false;
6878 }
6879 if (2.0 * mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationWidth[k] * (mode_lib->ms.cache_display_cfg.writeback.WritebackVTaps[k] - 1) * 57 > mode_lib->ms.ip.writeback_line_buffer_buffer_size) {
6880 mode_lib->ms.support.WritebackScaleRatioAndTapsSupport = false;
6881 }
6882 }
6883 }
6884
6885 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6886 CalculateSinglePipeDPPCLKAndSCLThroughput(
6887 mode_lib->ms.cache_display_cfg.plane.HRatio[k],
6888 mode_lib->ms.cache_display_cfg.plane.HRatioChroma[k],
6889 mode_lib->ms.cache_display_cfg.plane.VRatio[k],
6890 mode_lib->ms.cache_display_cfg.plane.VRatioChroma[k],
6891 mode_lib->ms.ip.max_dchub_pscl_bw_pix_per_clk,
6892 mode_lib->ms.ip.max_pscl_lb_bw_pix_per_clk,
6893 mode_lib->ms.cache_display_cfg.timing.PixelClock[k],
6894 mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k],
6895 mode_lib->ms.cache_display_cfg.plane.HTaps[k],
6896 mode_lib->ms.cache_display_cfg.plane.HTapsChroma[k],
6897 mode_lib->ms.cache_display_cfg.plane.VTaps[k],
6898 mode_lib->ms.cache_display_cfg.plane.VTapsChroma[k],
6899 /* Output */
6900 &mode_lib->ms.PSCL_FACTOR[k],
6901 &mode_lib->ms.PSCL_FACTOR_CHROMA[k],
6902 &mode_lib->ms.MinDPPCLKUsingSingleDPP[k]);
6903 }
6904
6905 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
6906 if (mode_lib->ms.cache_display_cfg.surface.SurfaceTiling[k] == dml_sw_linear) {
6907 s->MaximumSwathWidthSupportLuma = 8192;
6908 } else if (!dml_is_vertical_rotation(mode_lib->ms.cache_display_cfg.plane.SourceScan[k]) && mode_lib->ms.BytePerPixelC[k] > 0 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_rgbe_alpha) {
6909 s->MaximumSwathWidthSupportLuma = 7680;
6910 } else if (dml_is_vertical_rotation(mode_lib->ms.cache_display_cfg.plane.SourceScan[k]) && mode_lib->ms.BytePerPixelC[k] > 0 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_rgbe_alpha) {
6911 s->MaximumSwathWidthSupportLuma = 4320;
6912 } else if (mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] == dml_rgbe_alpha) {
6913 s->MaximumSwathWidthSupportLuma = 3840;
6914 } else if (dml_is_vertical_rotation(mode_lib->ms.cache_display_cfg.plane.SourceScan[k]) && mode_lib->ms.BytePerPixelY[k] == 8 && mode_lib->ms.cache_display_cfg.surface.DCCEnable[k] == true) {
6915 s->MaximumSwathWidthSupportLuma = 3072;
6916 } else {
6917 s->MaximumSwathWidthSupportLuma = 6144;
6918 }
6919
6920 if (mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] == dml_420_8 || mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] == dml_420_10 || mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] == dml_420_12) {
6921 s->MaximumSwathWidthSupportChroma = (dml_uint_t)(s->MaximumSwathWidthSupportLuma / 2.0);
6922 } else {
6923 s->MaximumSwathWidthSupportChroma = s->MaximumSwathWidthSupportLuma;
6924 }
6925 mode_lib->ms.MaximumSwathWidthInLineBufferLuma = mode_lib->ms.ip.line_buffer_size_bits * dml_max(mode_lib->ms.cache_display_cfg.plane.HRatio[k], 1.0) / mode_lib->ms.cache_display_cfg.plane.LBBitPerPixel[k] /
6926 (mode_lib->ms.cache_display_cfg.plane.VTaps[k] + dml_max(dml_ceil(mode_lib->ms.cache_display_cfg.plane.VRatio[k], 1.0) - 2, 0.0));
6927 if (mode_lib->ms.BytePerPixelC[k] == 0.0) {
6928 mode_lib->ms.MaximumSwathWidthInLineBufferChroma = 0;
6929 } else {
6930 mode_lib->ms.MaximumSwathWidthInLineBufferChroma =
6931 mode_lib->ms.ip.line_buffer_size_bits
6932 * dml_max(mode_lib->ms.cache_display_cfg.plane.HRatioChroma[k], 1.0)
6933 / mode_lib->ms.cache_display_cfg.plane.LBBitPerPixel[k]
6934 / (mode_lib->ms.cache_display_cfg.plane.VTapsChroma[k]
6935 + dml_max(dml_ceil(mode_lib->ms.cache_display_cfg.plane.VRatioChroma[k], 1.0) - 2, 0.0));
6936 }
6937 mode_lib->ms.MaximumSwathWidthLuma[k] = dml_min(s->MaximumSwathWidthSupportLuma, mode_lib->ms.MaximumSwathWidthInLineBufferLuma);
6938 mode_lib->ms.MaximumSwathWidthChroma[k] = dml_min(s->MaximumSwathWidthSupportChroma, mode_lib->ms.MaximumSwathWidthInLineBufferChroma);
6939 }
6940
6941 /*Number Of DSC Slices*/
6942 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
6943 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == k &&
6944 mode_lib->ms.cache_display_cfg.output.DSCEnable[k] != dml_dsc_disable) {
6945 mode_lib->ms.support.NumberOfDSCSlices[k] = mode_lib->ms.cache_display_cfg.output.DSCSlices[k];
6946
6947 if (mode_lib->ms.support.NumberOfDSCSlices[k] == 0) {
6948 if (mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k] > 4800) {
6949 mode_lib->ms.support.NumberOfDSCSlices[k] = (dml_uint_t)(dml_ceil(mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k] / 600, 4));
6950 } else if (mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k] > 2400) {
6951 mode_lib->ms.support.NumberOfDSCSlices[k] = 8;
6952 } else if (mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k] > 1200) {
6953 mode_lib->ms.support.NumberOfDSCSlices[k] = 4;
6954 } else if (mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k] > 340) {
6955 mode_lib->ms.support.NumberOfDSCSlices[k] = 2;
6956 } else {
6957 mode_lib->ms.support.NumberOfDSCSlices[k] = 1;
6958 }
6959 }
6960 } else {
6961 mode_lib->ms.support.NumberOfDSCSlices[k] = 1;
6962 }
6963 }
6964
6965 CalculateSwathAndDETConfiguration_params->DETSizeOverride = mode_lib->ms.cache_display_cfg.plane.DETSizeOverride;
6966 CalculateSwathAndDETConfiguration_params->UseMALLForPStateChange = mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange;
6967 CalculateSwathAndDETConfiguration_params->ConfigReturnBufferSizeInKByte = mode_lib->ms.ip.config_return_buffer_size_in_kbytes;
6968 CalculateSwathAndDETConfiguration_params->ROBBufferSizeInKByte = mode_lib->ms.ip.rob_buffer_size_kbytes;
6969 CalculateSwathAndDETConfiguration_params->MaxTotalDETInKByte = mode_lib->ms.MaxTotalDETInKByte;
6970 CalculateSwathAndDETConfiguration_params->MinCompressedBufferSizeInKByte = mode_lib->ms.MinCompressedBufferSizeInKByte;
6971 CalculateSwathAndDETConfiguration_params->PixelChunkSizeInKByte = mode_lib->ms.ip.pixel_chunk_size_kbytes;
6972 CalculateSwathAndDETConfiguration_params->ForceSingleDPP = 1;
6973 CalculateSwathAndDETConfiguration_params->NumberOfActiveSurfaces = mode_lib->ms.num_active_planes;
6974 CalculateSwathAndDETConfiguration_params->nomDETInKByte = mode_lib->ms.NomDETInKByte;
6975 CalculateSwathAndDETConfiguration_params->UseUnboundedRequestingFinal = mode_lib->ms.policy.UseUnboundedRequesting;
6976 CalculateSwathAndDETConfiguration_params->ConfigReturnBufferSegmentSizeInkByte = mode_lib->ms.ip.config_return_buffer_segment_size_in_kbytes;
6977 CalculateSwathAndDETConfiguration_params->CompressedBufferSegmentSizeInkByteFinal = mode_lib->ms.ip.compressed_buffer_segment_size_in_kbytes;
6978 CalculateSwathAndDETConfiguration_params->Output = mode_lib->ms.cache_display_cfg.output.OutputEncoder;
6979 CalculateSwathAndDETConfiguration_params->ReadBandwidthLuma = mode_lib->ms.ReadBandwidthLuma;
6980 CalculateSwathAndDETConfiguration_params->ReadBandwidthChroma = mode_lib->ms.ReadBandwidthChroma;
6981 CalculateSwathAndDETConfiguration_params->MaximumSwathWidthLuma = mode_lib->ms.MaximumSwathWidthLuma;
6982 CalculateSwathAndDETConfiguration_params->MaximumSwathWidthChroma = mode_lib->ms.MaximumSwathWidthChroma;
6983 CalculateSwathAndDETConfiguration_params->SourceScan = mode_lib->ms.cache_display_cfg.plane.SourceScan;
6984 CalculateSwathAndDETConfiguration_params->ViewportStationary = mode_lib->ms.cache_display_cfg.plane.ViewportStationary;
6985 CalculateSwathAndDETConfiguration_params->SourcePixelFormat = mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat;
6986 CalculateSwathAndDETConfiguration_params->SurfaceTiling = mode_lib->ms.cache_display_cfg.surface.SurfaceTiling;
6987 CalculateSwathAndDETConfiguration_params->ViewportWidth = mode_lib->ms.cache_display_cfg.plane.ViewportWidth;
6988 CalculateSwathAndDETConfiguration_params->ViewportHeight = mode_lib->ms.cache_display_cfg.plane.ViewportHeight;
6989 CalculateSwathAndDETConfiguration_params->ViewportXStart = mode_lib->ms.cache_display_cfg.plane.ViewportXStart;
6990 CalculateSwathAndDETConfiguration_params->ViewportYStart = mode_lib->ms.cache_display_cfg.plane.ViewportYStart;
6991 CalculateSwathAndDETConfiguration_params->ViewportXStartC = mode_lib->ms.cache_display_cfg.plane.ViewportXStartC;
6992 CalculateSwathAndDETConfiguration_params->ViewportYStartC = mode_lib->ms.cache_display_cfg.plane.ViewportYStartC;
6993 CalculateSwathAndDETConfiguration_params->SurfaceWidthY = mode_lib->ms.cache_display_cfg.surface.SurfaceWidthY;
6994 CalculateSwathAndDETConfiguration_params->SurfaceWidthC = mode_lib->ms.cache_display_cfg.surface.SurfaceWidthC;
6995 CalculateSwathAndDETConfiguration_params->SurfaceHeightY = mode_lib->ms.cache_display_cfg.surface.SurfaceHeightY;
6996 CalculateSwathAndDETConfiguration_params->SurfaceHeightC = mode_lib->ms.cache_display_cfg.surface.SurfaceHeightC;
6997 CalculateSwathAndDETConfiguration_params->Read256BytesBlockHeightY = mode_lib->ms.Read256BlockHeightY;
6998 CalculateSwathAndDETConfiguration_params->Read256BytesBlockHeightC = mode_lib->ms.Read256BlockHeightC;
6999 CalculateSwathAndDETConfiguration_params->Read256BytesBlockWidthY = mode_lib->ms.Read256BlockWidthY;
7000 CalculateSwathAndDETConfiguration_params->Read256BytesBlockWidthC = mode_lib->ms.Read256BlockWidthC;
7001 CalculateSwathAndDETConfiguration_params->ODMMode = s->dummy_odm_mode;
7002 CalculateSwathAndDETConfiguration_params->BlendingAndTiming = mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming;
7003 CalculateSwathAndDETConfiguration_params->BytePerPixY = mode_lib->ms.BytePerPixelY;
7004 CalculateSwathAndDETConfiguration_params->BytePerPixC = mode_lib->ms.BytePerPixelC;
7005 CalculateSwathAndDETConfiguration_params->BytePerPixDETY = mode_lib->ms.BytePerPixelInDETY;
7006 CalculateSwathAndDETConfiguration_params->BytePerPixDETC = mode_lib->ms.BytePerPixelInDETC;
7007 CalculateSwathAndDETConfiguration_params->HActive = mode_lib->ms.cache_display_cfg.timing.HActive;
7008 CalculateSwathAndDETConfiguration_params->HRatio = mode_lib->ms.cache_display_cfg.plane.HRatio;
7009 CalculateSwathAndDETConfiguration_params->HRatioChroma = mode_lib->ms.cache_display_cfg.plane.HRatioChroma;
7010 CalculateSwathAndDETConfiguration_params->DPPPerSurface = s->dummy_integer_array[0];
7011 CalculateSwathAndDETConfiguration_params->swath_width_luma_ub = s->dummy_integer_array[1];
7012 CalculateSwathAndDETConfiguration_params->swath_width_chroma_ub = s->dummy_integer_array[2];
7013 CalculateSwathAndDETConfiguration_params->SwathWidth = s->dummy_integer_array[3];
7014 CalculateSwathAndDETConfiguration_params->SwathWidthChroma = s->dummy_integer_array[4];
7015 CalculateSwathAndDETConfiguration_params->SwathHeightY = s->dummy_integer_array[5];
7016 CalculateSwathAndDETConfiguration_params->SwathHeightC = s->dummy_integer_array[6];
7017 CalculateSwathAndDETConfiguration_params->DETBufferSizeInKByte = s->dummy_integer_array[7];
7018 CalculateSwathAndDETConfiguration_params->DETBufferSizeY = mode_lib->ms.DETBufferSizeY;
7019 CalculateSwathAndDETConfiguration_params->DETBufferSizeC = mode_lib->ms.DETBufferSizeC;
7020 CalculateSwathAndDETConfiguration_params->UnboundedRequestEnabled = &s->dummy_boolean[0];
7021 CalculateSwathAndDETConfiguration_params->compbuf_reserved_space_64b = &s->dummy_integer[2];
7022 CalculateSwathAndDETConfiguration_params->compbuf_reserved_space_zs = &s->dummy_integer[1];
7023 CalculateSwathAndDETConfiguration_params->CompressedBufferSizeInkByte = &s->dummy_integer[0];
7024 CalculateSwathAndDETConfiguration_params->ViewportSizeSupportPerSurface = mode_lib->ms.SingleDPPViewportSizeSupportPerSurface;
7025 CalculateSwathAndDETConfiguration_params->ViewportSizeSupport = &s->dummy_boolean[1];
7026
7027 CalculateSwathAndDETConfiguration(&mode_lib->scratch,
7028 CalculateSwathAndDETConfiguration_params); /* dml_bool_t *ViewportSizeSupport */
7029
7030 s->MPCCombineMethodAsNeededForPStateChangeAndVoltage = false;
7031 s->MPCCombineMethodAsPossible = false;
7032 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7033 if (mode_lib->ms.policy.MPCCombineUse[k] == dml_mpc_as_needed_for_pstate_and_voltage)
7034 s->MPCCombineMethodAsNeededForPStateChangeAndVoltage = true;
7035 if (mode_lib->ms.policy.MPCCombineUse[k] == dml_mpc_as_possible)
7036 s->MPCCombineMethodAsPossible = true;
7037 }
7038 mode_lib->ms.support.MPCCombineMethodIncompatible = s->MPCCombineMethodAsNeededForPStateChangeAndVoltage && s->MPCCombineMethodAsPossible;
7039
7040 for (j = 0; j < 2; j++) {
7041 mode_lib->ms.TotalNumberOfActiveDPP[j] = 0;
7042 mode_lib->ms.support.TotalAvailablePipesSupport[j] = true;
7043
7044 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7045 CalculateODMMode(
7046 mode_lib->ms.ip.maximum_pixels_per_line_per_dsc_unit,
7047 mode_lib->ms.cache_display_cfg.timing.HActive[k],
7048 mode_lib->ms.cache_display_cfg.output.OutputEncoder[k],
7049 mode_lib->ms.cache_display_cfg.output.OutputFormat[k],
7050 mode_lib->ms.policy.ODMUse[k],
7051 mode_lib->ms.state.dispclk_mhz,
7052 mode_lib->ms.max_state.dispclk_mhz,
7053 false, // DSCEnable
7054 mode_lib->ms.TotalNumberOfActiveDPP[j],
7055 mode_lib->ms.ip.max_num_dpp,
7056 mode_lib->ms.cache_display_cfg.timing.PixelClock[k],
7057 mode_lib->ms.soc.dcn_downspread_percent,
7058 mode_lib->ms.ip.dispclk_ramp_margin_percent,
7059 mode_lib->ms.soc.dispclk_dppclk_vco_speed_mhz,
7060 mode_lib->ms.support.NumberOfDSCSlices[k],
7061
7062 /* Output */
7063 &s->TotalAvailablePipesSupportNoDSC,
7064 &s->NumberOfDPPNoDSC,
7065 &s->ODMModeNoDSC,
7066 &s->RequiredDISPCLKPerSurfaceNoDSC);
7067
7068 CalculateODMMode(
7069 mode_lib->ms.ip.maximum_pixels_per_line_per_dsc_unit,
7070 mode_lib->ms.cache_display_cfg.timing.HActive[k],
7071 mode_lib->ms.cache_display_cfg.output.OutputEncoder[k],
7072 mode_lib->ms.cache_display_cfg.output.OutputFormat[k],
7073 mode_lib->ms.policy.ODMUse[k],
7074 mode_lib->ms.state.dispclk_mhz,
7075 mode_lib->ms.max_state.dispclk_mhz,
7076 true, // DSCEnable
7077 mode_lib->ms.TotalNumberOfActiveDPP[j],
7078 mode_lib->ms.ip.max_num_dpp,
7079 mode_lib->ms.cache_display_cfg.timing.PixelClock[k],
7080 mode_lib->ms.soc.dcn_downspread_percent,
7081 mode_lib->ms.ip.dispclk_ramp_margin_percent,
7082 mode_lib->ms.soc.dispclk_dppclk_vco_speed_mhz,
7083 mode_lib->ms.support.NumberOfDSCSlices[k],
7084
7085 /* Output */
7086 &s->TotalAvailablePipesSupportDSC,
7087 &s->NumberOfDPPDSC,
7088 &s->ODMModeDSC,
7089 &s->RequiredDISPCLKPerSurfaceDSC);
7090
7091 CalculateOutputLink(
7092 mode_lib->ms.state.phyclk_mhz,
7093 mode_lib->ms.state.phyclk_d18_mhz,
7094 mode_lib->ms.state.phyclk_d32_mhz,
7095 mode_lib->ms.soc.phy_downspread_percent,
7096 (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == k),
7097 mode_lib->ms.cache_display_cfg.output.OutputEncoder[k],
7098 mode_lib->ms.cache_display_cfg.output.OutputFormat[k],
7099 mode_lib->ms.cache_display_cfg.timing.HTotal[k],
7100 mode_lib->ms.cache_display_cfg.timing.HActive[k],
7101 mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k],
7102 mode_lib->ms.cache_display_cfg.output.ForcedOutputLinkBPP[k],
7103 mode_lib->ms.cache_display_cfg.output.DSCInputBitPerComponent[k],
7104 mode_lib->ms.support.NumberOfDSCSlices[k],
7105 mode_lib->ms.cache_display_cfg.output.AudioSampleRate[k],
7106 mode_lib->ms.cache_display_cfg.output.AudioSampleLayout[k],
7107 s->ODMModeNoDSC,
7108 s->ODMModeDSC,
7109 mode_lib->ms.cache_display_cfg.output.DSCEnable[k],
7110 mode_lib->ms.cache_display_cfg.output.OutputLinkDPLanes[k],
7111 mode_lib->ms.cache_display_cfg.output.OutputLinkDPRate[k],
7112
7113 /* Output */
7114 &mode_lib->ms.RequiresDSC[k],
7115 &mode_lib->ms.RequiresFEC[k],
7116 &mode_lib->ms.OutputBppPerState[k],
7117 &mode_lib->ms.OutputTypePerState[k], // VBA_DELTA, VBA uses a string to represent type and rate, but DML uses enum, don't want to rely on strng
7118 &mode_lib->ms.OutputRatePerState[k],
7119 &mode_lib->ms.RequiredSlots[k]);
7120
7121 if (mode_lib->ms.RequiresDSC[k] == false) {
7122 mode_lib->ms.ODMModePerState[k] = s->ODMModeNoDSC;
7123 mode_lib->ms.RequiredDISPCLKPerSurface[j][k] = s->RequiredDISPCLKPerSurfaceNoDSC;
7124 if (!s->TotalAvailablePipesSupportNoDSC)
7125 mode_lib->ms.support.TotalAvailablePipesSupport[j] = false;
7126 mode_lib->ms.TotalNumberOfActiveDPP[j] = mode_lib->ms.TotalNumberOfActiveDPP[j] + s->NumberOfDPPNoDSC;
7127 } else {
7128 mode_lib->ms.ODMModePerState[k] = s->ODMModeDSC;
7129 mode_lib->ms.RequiredDISPCLKPerSurface[j][k] = s->RequiredDISPCLKPerSurfaceDSC;
7130 if (!s->TotalAvailablePipesSupportDSC)
7131 mode_lib->ms.support.TotalAvailablePipesSupport[j] = false;
7132 mode_lib->ms.TotalNumberOfActiveDPP[j] = mode_lib->ms.TotalNumberOfActiveDPP[j] + s->NumberOfDPPDSC;
7133 }
7134 }
7135
7136 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7137 if (mode_lib->ms.ODMModePerState[k] == dml_odm_mode_combine_4to1) {
7138 mode_lib->ms.MPCCombine[j][k] = false;
7139 mode_lib->ms.NoOfDPP[j][k] = 4;
7140 } else if (mode_lib->ms.ODMModePerState[k] == dml_odm_mode_combine_2to1) {
7141 mode_lib->ms.MPCCombine[j][k] = false;
7142 mode_lib->ms.NoOfDPP[j][k] = 2;
7143 } else if (mode_lib->ms.policy.MPCCombineUse[k] == dml_mpc_disabled) {
7144 mode_lib->ms.MPCCombine[j][k] = false;
7145 mode_lib->ms.NoOfDPP[j][k] = 1;
7146 } else if (RoundToDFSGranularity(mode_lib->ms.MinDPPCLKUsingSingleDPP[k] * (1 + mode_lib->ms.soc.dcn_downspread_percent / 100),
7147 1, mode_lib->ms.soc.dispclk_dppclk_vco_speed_mhz) <= mode_lib->ms.state.dppclk_mhz &&
7148 mode_lib->ms.SingleDPPViewportSizeSupportPerSurface[k] == true) {
7149 mode_lib->ms.MPCCombine[j][k] = false;
7150 mode_lib->ms.NoOfDPP[j][k] = 1;
7151 } else if (mode_lib->ms.TotalNumberOfActiveDPP[j] < (dml_uint_t) mode_lib->ms.ip.max_num_dpp) {
7152 mode_lib->ms.MPCCombine[j][k] = true;
7153 mode_lib->ms.NoOfDPP[j][k] = 2;
7154 mode_lib->ms.TotalNumberOfActiveDPP[j] = (dml_uint_t) mode_lib->ms.TotalNumberOfActiveDPP[j] + 1;
7155 } else {
7156 mode_lib->ms.MPCCombine[j][k] = false;
7157 mode_lib->ms.NoOfDPP[j][k] = 1;
7158 mode_lib->ms.support.TotalAvailablePipesSupport[j] = false;
7159 }
7160 }
7161
7162 mode_lib->ms.TotalNumberOfSingleDPPSurfaces[j] = 0;
7163 s->NoChromaOrLinear = true;
7164 for (k = 0; k < (dml_uint_t) mode_lib->ms.num_active_planes; ++k) {
7165 if (mode_lib->ms.NoOfDPP[j][k] == 1)
7166 mode_lib->ms.TotalNumberOfSingleDPPSurfaces[j] = mode_lib->ms.TotalNumberOfSingleDPPSurfaces[j] + 1;
7167 if (mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] == dml_420_8
7168 || mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] == dml_420_10
7169 || mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] == dml_420_12
7170 || mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] == dml_rgbe_alpha
7171 || mode_lib->ms.cache_display_cfg.surface.SurfaceTiling[k] == dml_sw_linear) {
7172 s->NoChromaOrLinear = false;
7173 }
7174 }
7175
7176 if (j == 1 && !UnboundedRequest(mode_lib->ms.policy.UseUnboundedRequesting,
7177 mode_lib->ms.TotalNumberOfActiveDPP[j], s->NoChromaOrLinear,
7178 mode_lib->ms.cache_display_cfg.output.OutputEncoder[0])) {
7179 while (!(mode_lib->ms.TotalNumberOfActiveDPP[j] >= (dml_uint_t) mode_lib->ms.ip.max_num_dpp || mode_lib->ms.TotalNumberOfSingleDPPSurfaces[j] == 0)) {
7180 s->BWOfNonCombinedSurfaceOfMaximumBandwidth = 0;
7181 s->NumberOfNonCombinedSurfaceOfMaximumBandwidth = 0;
7182 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7183 if (mode_lib->ms.policy.MPCCombineUse[k] != dml_mpc_disabled && mode_lib->ms.policy.MPCCombineUse[k] != dml_mpc_as_needed_for_voltage &&
7184 mode_lib->ms.ReadBandwidthLuma[k] + mode_lib->ms.ReadBandwidthChroma[k] > s->BWOfNonCombinedSurfaceOfMaximumBandwidth &&
7185 (mode_lib->ms.ODMModePerState[k] != dml_odm_mode_combine_2to1 && mode_lib->ms.ODMModePerState[k] != dml_odm_mode_combine_4to1) &&
7186 mode_lib->ms.MPCCombine[j][k] == false) {
7187 s->BWOfNonCombinedSurfaceOfMaximumBandwidth = mode_lib->ms.ReadBandwidthLuma[k] + mode_lib->ms.ReadBandwidthChroma[k];
7188 s->NumberOfNonCombinedSurfaceOfMaximumBandwidth = k;
7189 }
7190 }
7191 mode_lib->ms.MPCCombine[j][s->NumberOfNonCombinedSurfaceOfMaximumBandwidth] = true;
7192 mode_lib->ms.NoOfDPP[j][s->NumberOfNonCombinedSurfaceOfMaximumBandwidth] = 2;
7193 mode_lib->ms.TotalNumberOfActiveDPP[j] = mode_lib->ms.TotalNumberOfActiveDPP[j] + 1;
7194 mode_lib->ms.TotalNumberOfSingleDPPSurfaces[j] = mode_lib->ms.TotalNumberOfSingleDPPSurfaces[j] - 1;
7195 }
7196 }
7197
7198 //DISPCLK/DPPCLK
7199 mode_lib->ms.WritebackRequiredDISPCLK = 0;
7200 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7201 if (mode_lib->ms.cache_display_cfg.writeback.WritebackEnable[k]) {
7202 mode_lib->ms.WritebackRequiredDISPCLK = dml_max(mode_lib->ms.WritebackRequiredDISPCLK,
7203 CalculateWriteBackDISPCLK(mode_lib->ms.cache_display_cfg.writeback.WritebackPixelFormat[k],
7204 mode_lib->ms.cache_display_cfg.timing.PixelClock[k],
7205 mode_lib->ms.cache_display_cfg.writeback.WritebackHRatio[k],
7206 mode_lib->ms.cache_display_cfg.writeback.WritebackVRatio[k],
7207 mode_lib->ms.cache_display_cfg.writeback.WritebackHTaps[k],
7208 mode_lib->ms.cache_display_cfg.writeback.WritebackVTaps[k],
7209 mode_lib->ms.cache_display_cfg.writeback.WritebackSourceWidth[k],
7210 mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationWidth[k],
7211 mode_lib->ms.cache_display_cfg.timing.HTotal[k],
7212 mode_lib->ms.ip.writeback_line_buffer_buffer_size,
7213 mode_lib->ms.soc.dispclk_dppclk_vco_speed_mhz));
7214 }
7215 }
7216
7217 mode_lib->ms.RequiredDISPCLK[j] = mode_lib->ms.WritebackRequiredDISPCLK;
7218 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7219 mode_lib->ms.RequiredDISPCLK[j] = dml_max(mode_lib->ms.RequiredDISPCLK[j], mode_lib->ms.RequiredDISPCLKPerSurface[j][k]);
7220 }
7221
7222 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7223 mode_lib->ms.NoOfDPPThisState[k] = mode_lib->ms.NoOfDPP[j][k];
7224 }
7225
7226 CalculateDPPCLK(mode_lib->ms.num_active_planes,
7227 mode_lib->ms.soc.dcn_downspread_percent,
7228 mode_lib->ms.soc.dispclk_dppclk_vco_speed_mhz,
7229 mode_lib->ms.MinDPPCLKUsingSingleDPP,
7230 mode_lib->ms.NoOfDPPThisState,
7231 /* Output */
7232 &mode_lib->ms.GlobalDPPCLK,
7233 mode_lib->ms.RequiredDPPCLKThisState);
7234
7235 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7236 mode_lib->ms.RequiredDPPCLKPerSurface[j][k] = mode_lib->ms.RequiredDPPCLKThisState[k];
7237 }
7238
7239 mode_lib->ms.support.DISPCLK_DPPCLK_Support[j] = !((mode_lib->ms.RequiredDISPCLK[j] > mode_lib->ms.state.dispclk_mhz) || (mode_lib->ms.GlobalDPPCLK > mode_lib->ms.state.dppclk_mhz));
7240
7241 if (mode_lib->ms.TotalNumberOfActiveDPP[j] > (dml_uint_t) mode_lib->ms.ip.max_num_dpp) {
7242 mode_lib->ms.support.TotalAvailablePipesSupport[j] = false;
7243 }
7244 } // j
7245
7246 /* Total Available OTG, HDMIFRL, DP Support Check */
7247 s->TotalNumberOfActiveOTG = 0;
7248 s->TotalNumberOfActiveHDMIFRL = 0;
7249 s->TotalNumberOfActiveDP2p0 = 0;
7250 s->TotalNumberOfActiveDP2p0Outputs = 0;
7251
7252 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7253 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == k) {
7254 s->TotalNumberOfActiveOTG = s->TotalNumberOfActiveOTG + 1;
7255 if (mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_hdmifrl)
7256 s->TotalNumberOfActiveHDMIFRL = s->TotalNumberOfActiveHDMIFRL + 1;
7257 if (mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_dp2p0) {
7258 s->TotalNumberOfActiveDP2p0 = s->TotalNumberOfActiveDP2p0 + 1;
7259 if (mode_lib->ms.cache_display_cfg.output.OutputMultistreamId[k] == k || mode_lib->ms.cache_display_cfg.output.OutputMultistreamEn[k] == false) {
7260 s->TotalNumberOfActiveDP2p0Outputs = s->TotalNumberOfActiveDP2p0Outputs + 1;
7261 }
7262 }
7263 }
7264 }
7265
7266 mode_lib->ms.support.NumberOfOTGSupport = (s->TotalNumberOfActiveOTG <= (dml_uint_t) mode_lib->ms.ip.max_num_otg);
7267 mode_lib->ms.support.NumberOfHDMIFRLSupport = (s->TotalNumberOfActiveHDMIFRL <= (dml_uint_t) mode_lib->ms.ip.max_num_hdmi_frl_outputs);
7268 mode_lib->ms.support.NumberOfDP2p0Support = (s->TotalNumberOfActiveDP2p0 <= (dml_uint_t) mode_lib->ms.ip.max_num_dp2p0_streams && s->TotalNumberOfActiveDP2p0Outputs <= (dml_uint_t) mode_lib->ms.ip.max_num_dp2p0_outputs);
7269
7270 /* Display IO and DSC Support Check */
7271 mode_lib->ms.support.NonsupportedDSCInputBPC = false;
7272 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
7273 if (mode_lib->ms.cache_display_cfg.output.OutputDisabled[k] == false &&
7274 !(mode_lib->ms.cache_display_cfg.output.DSCInputBitPerComponent[k] == 12.0
7275 || mode_lib->ms.cache_display_cfg.output.DSCInputBitPerComponent[k] == 10.0
7276 || mode_lib->ms.cache_display_cfg.output.DSCInputBitPerComponent[k] == 8.0
7277 || mode_lib->ms.cache_display_cfg.output.DSCInputBitPerComponent[k] > (dml_uint_t) mode_lib->ms.ip.maximum_dsc_bits_per_component
7278 )) {
7279 mode_lib->ms.support.NonsupportedDSCInputBPC = true;
7280 }
7281 }
7282
7283 mode_lib->ms.support.ExceededMultistreamSlots = false;
7284 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7285 if (mode_lib->ms.cache_display_cfg.output.OutputMultistreamId[k] == k) {
7286 s->TotalSlots = mode_lib->ms.RequiredSlots[k];
7287 for (j = 0; j < mode_lib->ms.num_active_planes; ++j) {
7288 if (mode_lib->ms.cache_display_cfg.output.OutputMultistreamId[j] == k)
7289 s->TotalSlots = s->TotalSlots + mode_lib->ms.RequiredSlots[j];
7290 }
7291 if (mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_dp && s->TotalSlots > 63)
7292 mode_lib->ms.support.ExceededMultistreamSlots = true;
7293 if (mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_dp2p0 && s->TotalSlots > 64)
7294 mode_lib->ms.support.ExceededMultistreamSlots = true;
7295 }
7296 }
7297 mode_lib->ms.support.LinkCapacitySupport = true;
7298 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7299 if (mode_lib->ms.cache_display_cfg.output.OutputDisabled[k] == false &&
7300 mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == k && (mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_dp || mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_dp2p0 || mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_edp ||
7301 mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_hdmi || mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_hdmifrl) && mode_lib->ms.OutputBppPerState[k] == 0) {
7302 mode_lib->ms.support.LinkCapacitySupport = false;
7303 }
7304 }
7305
7306 mode_lib->ms.support.P2IWith420 = false;
7307 mode_lib->ms.support.DSCOnlyIfNecessaryWithBPP = false;
7308 mode_lib->ms.support.DSC422NativeNotSupported = false;
7309 mode_lib->ms.support.LinkRateDoesNotMatchDPVersion = false;
7310 mode_lib->ms.support.LinkRateForMultistreamNotIndicated = false;
7311 mode_lib->ms.support.BPPForMultistreamNotIndicated = false;
7312 mode_lib->ms.support.MultistreamWithHDMIOreDP = false;
7313 mode_lib->ms.support.MSOOrODMSplitWithNonDPLink = false;
7314 mode_lib->ms.support.NotEnoughLanesForMSO = false;
7315
7316 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7317 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == k && (mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_dp || mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_dp2p0 || mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_edp ||
7318 mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_hdmi || mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_hdmifrl)) {
7319 if (mode_lib->ms.cache_display_cfg.output.OutputFormat[k] == dml_420 && mode_lib->ms.cache_display_cfg.timing.Interlace[k] == 1 && mode_lib->ms.ip.ptoi_supported == true)
7320 mode_lib->ms.support.P2IWith420 = true;
7321
7322 if (mode_lib->ms.cache_display_cfg.output.DSCEnable[k] == dml_dsc_enable_if_necessary && mode_lib->ms.cache_display_cfg.output.ForcedOutputLinkBPP[k] != 0)
7323 mode_lib->ms.support.DSCOnlyIfNecessaryWithBPP = true;
7324 if ((mode_lib->ms.cache_display_cfg.output.DSCEnable[k] == dml_dsc_enable || mode_lib->ms.cache_display_cfg.output.DSCEnable[k] == dml_dsc_enable_if_necessary) && mode_lib->ms.cache_display_cfg.output.OutputFormat[k] == dml_n422 && !mode_lib->ms.ip.dsc422_native_support)
7325 mode_lib->ms.support.DSC422NativeNotSupported = true;
7326
7327 if (((mode_lib->ms.cache_display_cfg.output.OutputLinkDPRate[k] == dml_dp_rate_hbr || mode_lib->ms.cache_display_cfg.output.OutputLinkDPRate[k] == dml_dp_rate_hbr2 || mode_lib->ms.cache_display_cfg.output.OutputLinkDPRate[k] == dml_dp_rate_hbr3) &&
7328 mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] != dml_dp && mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] != dml_edp) ||
7329 ((mode_lib->ms.cache_display_cfg.output.OutputLinkDPRate[k] == dml_dp_rate_uhbr10 || mode_lib->ms.cache_display_cfg.output.OutputLinkDPRate[k] == dml_dp_rate_uhbr13p5 || mode_lib->ms.cache_display_cfg.output.OutputLinkDPRate[k] == dml_dp_rate_uhbr20) &&
7330 mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] != dml_dp2p0))
7331 mode_lib->ms.support.LinkRateDoesNotMatchDPVersion = true;
7332
7333 if (mode_lib->ms.cache_display_cfg.output.OutputMultistreamEn[k] == 1) {
7334 if (mode_lib->ms.cache_display_cfg.output.OutputMultistreamId[k] == k && mode_lib->ms.cache_display_cfg.output.OutputLinkDPRate[k] == dml_dp_rate_na)
7335 mode_lib->ms.support.LinkRateForMultistreamNotIndicated = true;
7336 if (mode_lib->ms.cache_display_cfg.output.OutputMultistreamId[k] == k && mode_lib->ms.cache_display_cfg.output.ForcedOutputLinkBPP[k] == 0)
7337 mode_lib->ms.support.BPPForMultistreamNotIndicated = true;
7338 for (j = 0; j < mode_lib->ms.num_active_planes; ++j) {
7339 if (mode_lib->ms.cache_display_cfg.output.OutputMultistreamId[k] == j && mode_lib->ms.cache_display_cfg.output.ForcedOutputLinkBPP[k] == 0)
7340 mode_lib->ms.support.BPPForMultistreamNotIndicated = true;
7341 }
7342 }
7343
7344 if ((mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_edp || mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_hdmi || mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_hdmifrl)) {
7345 if (mode_lib->ms.cache_display_cfg.output.OutputMultistreamEn[k] == 1 && mode_lib->ms.cache_display_cfg.output.OutputMultistreamId[k] == k)
7346 mode_lib->ms.support.MultistreamWithHDMIOreDP = true;
7347 for (j = 0; j < mode_lib->ms.num_active_planes; ++j) {
7348 if (mode_lib->ms.cache_display_cfg.output.OutputMultistreamEn[k] == 1 && mode_lib->ms.cache_display_cfg.output.OutputMultistreamId[k] == j)
7349 mode_lib->ms.support.MultistreamWithHDMIOreDP = true;
7350 }
7351 }
7352 if (mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] != dml_dp && (mode_lib->ms.policy.ODMUse[k] == dml_odm_use_policy_split_1to2 ||
7353 mode_lib->ms.policy.ODMUse[k] == dml_odm_use_policy_mso_1to2 || mode_lib->ms.policy.ODMUse[k] == dml_odm_use_policy_mso_1to4))
7354 mode_lib->ms.support.MSOOrODMSplitWithNonDPLink = true;
7355
7356 if ((mode_lib->ms.policy.ODMUse[k] == dml_odm_use_policy_mso_1to2 && mode_lib->ms.cache_display_cfg.output.OutputLinkDPLanes[k] < 2) ||
7357 (mode_lib->ms.policy.ODMUse[k] == dml_odm_use_policy_mso_1to4 && mode_lib->ms.cache_display_cfg.output.OutputLinkDPLanes[k] < 4))
7358 mode_lib->ms.support.NotEnoughLanesForMSO = true;
7359 }
7360 }
7361
7362 mode_lib->ms.support.DTBCLKRequiredMoreThanSupported = false;
7363 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7364 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == k &&
7365 mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_hdmifrl &&
7366 RequiredDTBCLK(
7367 mode_lib->ms.RequiresDSC[k],
7368 mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k],
7369 mode_lib->ms.cache_display_cfg.output.OutputFormat[k],
7370 mode_lib->ms.OutputBppPerState[k],
7371 mode_lib->ms.support.NumberOfDSCSlices[k],
7372 mode_lib->ms.cache_display_cfg.timing.HTotal[k],
7373 mode_lib->ms.cache_display_cfg.timing.HActive[k],
7374 mode_lib->ms.cache_display_cfg.output.AudioSampleRate[k],
7375 mode_lib->ms.cache_display_cfg.output.AudioSampleLayout[k]) > mode_lib->ms.state.dtbclk_mhz) {
7376 mode_lib->ms.support.DTBCLKRequiredMoreThanSupported = true;
7377 }
7378 }
7379
7380 mode_lib->ms.support.ODMCombineTwoToOneSupportCheckOK = true;
7381 mode_lib->ms.support.ODMCombineFourToOneSupportCheckOK = true;
7382 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7383 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == k && mode_lib->ms.ODMModePerState[k] == dml_odm_mode_combine_2to1 && mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_hdmi) {
7384 mode_lib->ms.support.ODMCombineTwoToOneSupportCheckOK = false;
7385 }
7386 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == k && mode_lib->ms.ODMModePerState[k] == dml_odm_mode_combine_4to1 && (mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_dp ||
7387 mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_edp || mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_hdmi)) {
7388 mode_lib->ms.support.ODMCombineFourToOneSupportCheckOK = false;
7389 }
7390 }
7391
7392 mode_lib->ms.support.DSCCLKRequiredMoreThanSupported = false;
7393 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
7394 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == k) {
7395 if (mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_dp ||
7396 mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_dp2p0 ||
7397 mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_edp ||
7398 mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_hdmifrl) {
7399 if (mode_lib->ms.cache_display_cfg.output.OutputFormat[k] == dml_420) {
7400 s->DSCFormatFactor = 2;
7401 } else if (mode_lib->ms.cache_display_cfg.output.OutputFormat[k] == dml_444) {
7402 s->DSCFormatFactor = 1;
7403 } else if (mode_lib->ms.cache_display_cfg.output.OutputFormat[k] == dml_n422 || mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_hdmifrl) {
7404 s->DSCFormatFactor = 2;
7405 } else {
7406 s->DSCFormatFactor = 1;
7407 }
7408 #ifdef __DML_VBA_DEBUG__
7409 dml_print("DML::%s: k=%u, RequiresDSC = %u\n", __func__, k, mode_lib->ms.RequiresDSC[k]);
7410 #endif
7411 if (mode_lib->ms.RequiresDSC[k] == true) {
7412 if (mode_lib->ms.ODMModePerState[k] == dml_odm_mode_combine_4to1) {
7413 if (mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k] / 12.0 / (dml_float_t)s->DSCFormatFactor > (1.0 - mode_lib->ms.soc.dcn_downspread_percent / 100.0) * mode_lib->ms.state.dscclk_mhz) {
7414 #ifdef __DML_VBA_DEBUG__
7415 dml_print("DML::%s: k=%u, PixelClockBackEnd = %f\n", __func__, k, mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k]);
7416 dml_print("DML::%s: k=%u, DSCCLKPerState = %f\n", __func__, k, mode_lib->ms.state.dscclk_mhz);
7417 dml_print("DML::%s: k=%u, DSCFormatFactor = %u\n", __func__, k, s->DSCFormatFactor);
7418 #endif
7419 mode_lib->ms.support.DSCCLKRequiredMoreThanSupported = true;
7420 }
7421 } else if (mode_lib->ms.ODMModePerState[k] == dml_odm_mode_combine_2to1) {
7422 if (mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k] / 6.0 / (dml_float_t)s->DSCFormatFactor > (1.0 - mode_lib->ms.soc.dcn_downspread_percent / 100.0) * mode_lib->ms.state.dscclk_mhz) {
7423 mode_lib->ms.support.DSCCLKRequiredMoreThanSupported = true;
7424 }
7425 } else {
7426 if (mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k] / 3.0 / (dml_float_t)s->DSCFormatFactor > (1.0 - mode_lib->ms.soc.dcn_downspread_percent / 100.0) * mode_lib->ms.state.dscclk_mhz) {
7427 mode_lib->ms.support.DSCCLKRequiredMoreThanSupported = true;
7428 }
7429 }
7430 }
7431 }
7432 }
7433 }
7434 #ifdef __DML_VBA_DEBUG__
7435 dml_print("DML::%s: DSCCLKRequiredMoreThanSupported = %u\n", __func__, mode_lib->ms.support.DSCCLKRequiredMoreThanSupported);
7436 #endif
7437
7438 /* Check DSC Unit and Slices Support */
7439 mode_lib->ms.support.NotEnoughDSCUnits = false;
7440 mode_lib->ms.support.NotEnoughDSCSlices = false;
7441 s->TotalDSCUnitsRequired = 0;
7442 mode_lib->ms.support.PixelsPerLinePerDSCUnitSupport = true;
7443 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7444 if (mode_lib->ms.RequiresDSC[k] == true) {
7445 if (mode_lib->ms.ODMModePerState[k] == dml_odm_mode_combine_4to1) {
7446 if (mode_lib->ms.cache_display_cfg.timing.HActive[k] > 4 * (dml_uint_t) mode_lib->ms.ip.maximum_pixels_per_line_per_dsc_unit)
7447 mode_lib->ms.support.PixelsPerLinePerDSCUnitSupport = false;
7448 s->TotalDSCUnitsRequired = s->TotalDSCUnitsRequired + 4;
7449 if (mode_lib->ms.support.NumberOfDSCSlices[k] > 16)
7450 mode_lib->ms.support.NotEnoughDSCSlices = true;
7451 } else if (mode_lib->ms.ODMModePerState[k] == dml_odm_mode_combine_2to1) {
7452 if (mode_lib->ms.cache_display_cfg.timing.HActive[k] > 2 * (dml_uint_t) mode_lib->ms.ip.maximum_pixels_per_line_per_dsc_unit)
7453 mode_lib->ms.support.PixelsPerLinePerDSCUnitSupport = false;
7454 s->TotalDSCUnitsRequired = s->TotalDSCUnitsRequired + 2;
7455 if (mode_lib->ms.support.NumberOfDSCSlices[k] > 8)
7456 mode_lib->ms.support.NotEnoughDSCSlices = true;
7457 } else {
7458 if (mode_lib->ms.cache_display_cfg.timing.HActive[k] > (dml_uint_t) mode_lib->ms.ip.maximum_pixels_per_line_per_dsc_unit)
7459 mode_lib->ms.support.PixelsPerLinePerDSCUnitSupport = false;
7460 s->TotalDSCUnitsRequired = s->TotalDSCUnitsRequired + 1;
7461 if (mode_lib->ms.support.NumberOfDSCSlices[k] > 4)
7462 mode_lib->ms.support.NotEnoughDSCSlices = true;
7463 }
7464 }
7465 }
7466 if (s->TotalDSCUnitsRequired > (dml_uint_t) mode_lib->ms.ip.num_dsc) {
7467 mode_lib->ms.support.NotEnoughDSCUnits = true;
7468 }
7469
7470 /*DSC Delay per state*/
7471 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7472 mode_lib->ms.DSCDelayPerState[k] = DSCDelayRequirement(mode_lib->ms.RequiresDSC[k],
7473 mode_lib->ms.ODMModePerState[k],
7474 mode_lib->ms.cache_display_cfg.output.DSCInputBitPerComponent[k],
7475 mode_lib->ms.OutputBppPerState[k],
7476 mode_lib->ms.cache_display_cfg.timing.HActive[k],
7477 mode_lib->ms.cache_display_cfg.timing.HTotal[k],
7478 mode_lib->ms.support.NumberOfDSCSlices[k],
7479 mode_lib->ms.cache_display_cfg.output.OutputFormat[k],
7480 mode_lib->ms.cache_display_cfg.output.OutputEncoder[k],
7481 mode_lib->ms.cache_display_cfg.timing.PixelClock[k],
7482 mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k]);
7483 }
7484
7485 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
7486 for (m = 0; m <= mode_lib->ms.num_active_planes - 1; m++) {
7487 for (j = 0; j <= mode_lib->ms.num_active_planes - 1; j++) {
7488 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == m && mode_lib->ms.RequiresDSC[m] == true) {
7489 mode_lib->ms.DSCDelayPerState[k] = mode_lib->ms.DSCDelayPerState[m];
7490 }
7491 }
7492 }
7493 }
7494
7495 //Calculate Swath, DET Configuration, DCFCLKDeepSleep
7496 //
7497 for (j = 0; j < 2; ++j) {
7498 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7499 mode_lib->ms.RequiredDPPCLKThisState[k] = mode_lib->ms.RequiredDPPCLKPerSurface[j][k];
7500 mode_lib->ms.NoOfDPPThisState[k] = mode_lib->ms.NoOfDPP[j][k];
7501 mode_lib->ms.ODMModeThisState[k] = mode_lib->ms.ODMModePerState[k];
7502 }
7503
7504 CalculateSwathAndDETConfiguration_params->DETSizeOverride = mode_lib->ms.cache_display_cfg.plane.DETSizeOverride;
7505 CalculateSwathAndDETConfiguration_params->UseMALLForPStateChange = mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange;
7506 CalculateSwathAndDETConfiguration_params->ConfigReturnBufferSizeInKByte = mode_lib->ms.ip.config_return_buffer_size_in_kbytes;
7507 CalculateSwathAndDETConfiguration_params->ROBBufferSizeInKByte = mode_lib->ms.ip.rob_buffer_size_kbytes;
7508 CalculateSwathAndDETConfiguration_params->MaxTotalDETInKByte = mode_lib->ms.MaxTotalDETInKByte;
7509 CalculateSwathAndDETConfiguration_params->MinCompressedBufferSizeInKByte = mode_lib->ms.MinCompressedBufferSizeInKByte;
7510 CalculateSwathAndDETConfiguration_params->PixelChunkSizeInKByte = mode_lib->ms.ip.pixel_chunk_size_kbytes;
7511 CalculateSwathAndDETConfiguration_params->ForceSingleDPP = false;
7512 CalculateSwathAndDETConfiguration_params->NumberOfActiveSurfaces = mode_lib->ms.num_active_planes;
7513 CalculateSwathAndDETConfiguration_params->nomDETInKByte = mode_lib->ms.NomDETInKByte;
7514 CalculateSwathAndDETConfiguration_params->UseUnboundedRequestingFinal = mode_lib->ms.policy.UseUnboundedRequesting;
7515 CalculateSwathAndDETConfiguration_params->ConfigReturnBufferSegmentSizeInkByte = mode_lib->ms.ip.config_return_buffer_segment_size_in_kbytes;
7516 CalculateSwathAndDETConfiguration_params->CompressedBufferSegmentSizeInkByteFinal = mode_lib->ms.ip.compressed_buffer_segment_size_in_kbytes;
7517 CalculateSwathAndDETConfiguration_params->Output = mode_lib->ms.cache_display_cfg.output.OutputEncoder;
7518 CalculateSwathAndDETConfiguration_params->ReadBandwidthLuma = mode_lib->ms.ReadBandwidthLuma;
7519 CalculateSwathAndDETConfiguration_params->ReadBandwidthChroma = mode_lib->ms.ReadBandwidthChroma;
7520 CalculateSwathAndDETConfiguration_params->MaximumSwathWidthLuma = mode_lib->ms.MaximumSwathWidthLuma;
7521 CalculateSwathAndDETConfiguration_params->MaximumSwathWidthChroma = mode_lib->ms.MaximumSwathWidthChroma;
7522 CalculateSwathAndDETConfiguration_params->SourceScan = mode_lib->ms.cache_display_cfg.plane.SourceScan;
7523 CalculateSwathAndDETConfiguration_params->ViewportStationary = mode_lib->ms.cache_display_cfg.plane.ViewportStationary;
7524 CalculateSwathAndDETConfiguration_params->SourcePixelFormat = mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat;
7525 CalculateSwathAndDETConfiguration_params->SurfaceTiling = mode_lib->ms.cache_display_cfg.surface.SurfaceTiling;
7526 CalculateSwathAndDETConfiguration_params->ViewportWidth = mode_lib->ms.cache_display_cfg.plane.ViewportWidth;
7527 CalculateSwathAndDETConfiguration_params->ViewportHeight = mode_lib->ms.cache_display_cfg.plane.ViewportHeight;
7528 CalculateSwathAndDETConfiguration_params->ViewportXStart = mode_lib->ms.cache_display_cfg.plane.ViewportXStart;
7529 CalculateSwathAndDETConfiguration_params->ViewportYStart = mode_lib->ms.cache_display_cfg.plane.ViewportYStart;
7530 CalculateSwathAndDETConfiguration_params->ViewportXStartC = mode_lib->ms.cache_display_cfg.plane.ViewportXStartC;
7531 CalculateSwathAndDETConfiguration_params->ViewportYStartC = mode_lib->ms.cache_display_cfg.plane.ViewportYStartC;
7532 CalculateSwathAndDETConfiguration_params->SurfaceWidthY = mode_lib->ms.cache_display_cfg.surface.SurfaceWidthY;
7533 CalculateSwathAndDETConfiguration_params->SurfaceWidthC = mode_lib->ms.cache_display_cfg.surface.SurfaceWidthC;
7534 CalculateSwathAndDETConfiguration_params->SurfaceHeightY = mode_lib->ms.cache_display_cfg.surface.SurfaceHeightY;
7535 CalculateSwathAndDETConfiguration_params->SurfaceHeightC = mode_lib->ms.cache_display_cfg.surface.SurfaceHeightC;
7536 CalculateSwathAndDETConfiguration_params->Read256BytesBlockHeightY = mode_lib->ms.Read256BlockHeightY;
7537 CalculateSwathAndDETConfiguration_params->Read256BytesBlockHeightC = mode_lib->ms.Read256BlockHeightC;
7538 CalculateSwathAndDETConfiguration_params->Read256BytesBlockWidthY = mode_lib->ms.Read256BlockWidthY;
7539 CalculateSwathAndDETConfiguration_params->Read256BytesBlockWidthC = mode_lib->ms.Read256BlockWidthC;
7540 CalculateSwathAndDETConfiguration_params->ODMMode = mode_lib->ms.ODMModeThisState;
7541 CalculateSwathAndDETConfiguration_params->BlendingAndTiming = mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming;
7542 CalculateSwathAndDETConfiguration_params->BytePerPixY = mode_lib->ms.BytePerPixelY;
7543 CalculateSwathAndDETConfiguration_params->BytePerPixC = mode_lib->ms.BytePerPixelC;
7544 CalculateSwathAndDETConfiguration_params->BytePerPixDETY = mode_lib->ms.BytePerPixelInDETY;
7545 CalculateSwathAndDETConfiguration_params->BytePerPixDETC = mode_lib->ms.BytePerPixelInDETC;
7546 CalculateSwathAndDETConfiguration_params->HActive = mode_lib->ms.cache_display_cfg.timing.HActive;
7547 CalculateSwathAndDETConfiguration_params->HRatio = mode_lib->ms.cache_display_cfg.plane.HRatio;
7548 CalculateSwathAndDETConfiguration_params->HRatioChroma = mode_lib->ms.cache_display_cfg.plane.HRatioChroma;
7549 CalculateSwathAndDETConfiguration_params->DPPPerSurface = mode_lib->ms.NoOfDPPThisState;
7550 CalculateSwathAndDETConfiguration_params->swath_width_luma_ub = mode_lib->ms.swath_width_luma_ub_this_state;
7551 CalculateSwathAndDETConfiguration_params->swath_width_chroma_ub = mode_lib->ms.swath_width_chroma_ub_this_state;
7552 CalculateSwathAndDETConfiguration_params->SwathWidth = mode_lib->ms.SwathWidthYThisState;
7553 CalculateSwathAndDETConfiguration_params->SwathWidthChroma = mode_lib->ms.SwathWidthCThisState;
7554 CalculateSwathAndDETConfiguration_params->SwathHeightY = mode_lib->ms.SwathHeightYThisState;
7555 CalculateSwathAndDETConfiguration_params->SwathHeightC = mode_lib->ms.SwathHeightCThisState;
7556 CalculateSwathAndDETConfiguration_params->DETBufferSizeInKByte = mode_lib->ms.DETBufferSizeInKByteThisState;
7557 CalculateSwathAndDETConfiguration_params->DETBufferSizeY = mode_lib->ms.DETBufferSizeYThisState;
7558 CalculateSwathAndDETConfiguration_params->DETBufferSizeC = mode_lib->ms.DETBufferSizeCThisState;
7559 CalculateSwathAndDETConfiguration_params->UnboundedRequestEnabled = &mode_lib->ms.UnboundedRequestEnabledThisState;
7560 CalculateSwathAndDETConfiguration_params->compbuf_reserved_space_64b = &s->dummy_integer[2];
7561 CalculateSwathAndDETConfiguration_params->compbuf_reserved_space_zs = &s->dummy_integer[1];
7562 CalculateSwathAndDETConfiguration_params->CompressedBufferSizeInkByte = &mode_lib->ms.CompressedBufferSizeInkByteThisState;
7563 CalculateSwathAndDETConfiguration_params->ViewportSizeSupportPerSurface = s->dummy_boolean_array[0];
7564 CalculateSwathAndDETConfiguration_params->ViewportSizeSupport = &mode_lib->ms.support.ViewportSizeSupport[j];
7565
7566 CalculateSwathAndDETConfiguration(&mode_lib->scratch,
7567 CalculateSwathAndDETConfiguration_params);
7568
7569 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7570 mode_lib->ms.swath_width_luma_ub_all_states[j][k] = mode_lib->ms.swath_width_luma_ub_this_state[k];
7571 mode_lib->ms.swath_width_chroma_ub_all_states[j][k] = mode_lib->ms.swath_width_chroma_ub_this_state[k];
7572 mode_lib->ms.SwathWidthYAllStates[j][k] = mode_lib->ms.SwathWidthYThisState[k];
7573 mode_lib->ms.SwathWidthCAllStates[j][k] = mode_lib->ms.SwathWidthCThisState[k];
7574 mode_lib->ms.SwathHeightYAllStates[j][k] = mode_lib->ms.SwathHeightYThisState[k];
7575 mode_lib->ms.SwathHeightCAllStates[j][k] = mode_lib->ms.SwathHeightCThisState[k];
7576 mode_lib->ms.UnboundedRequestEnabledAllStates[j] = mode_lib->ms.UnboundedRequestEnabledThisState;
7577 mode_lib->ms.CompressedBufferSizeInkByteAllStates[j] = mode_lib->ms.CompressedBufferSizeInkByteThisState;
7578 mode_lib->ms.DETBufferSizeInKByteAllStates[j][k] = mode_lib->ms.DETBufferSizeInKByteThisState[k];
7579 mode_lib->ms.DETBufferSizeYAllStates[j][k] = mode_lib->ms.DETBufferSizeYThisState[k];
7580 mode_lib->ms.DETBufferSizeCAllStates[j][k] = mode_lib->ms.DETBufferSizeCThisState[k];
7581 }
7582 }
7583
7584 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7585 mode_lib->ms.cursor_bw[k] = mode_lib->ms.cache_display_cfg.plane.NumberOfCursors[k] * mode_lib->ms.cache_display_cfg.plane.CursorWidth[k] * mode_lib->ms.cache_display_cfg.plane.CursorBPP[k] / 8.0 / (mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k]) * mode_lib->ms.cache_display_cfg.plane.VRatio[k];
7586 }
7587
7588 CalculateSurfaceSizeInMall(
7589 mode_lib->ms.num_active_planes,
7590 mode_lib->ms.soc.mall_allocated_for_dcn_mbytes,
7591 mode_lib->ms.cache_display_cfg.plane.UseMALLForStaticScreen,
7592 mode_lib->ms.cache_display_cfg.surface.DCCEnable,
7593 mode_lib->ms.cache_display_cfg.plane.ViewportStationary,
7594 mode_lib->ms.cache_display_cfg.plane.ViewportXStart,
7595 mode_lib->ms.cache_display_cfg.plane.ViewportYStart,
7596 mode_lib->ms.cache_display_cfg.plane.ViewportXStartC,
7597 mode_lib->ms.cache_display_cfg.plane.ViewportYStartC,
7598 mode_lib->ms.cache_display_cfg.plane.ViewportWidth,
7599 mode_lib->ms.cache_display_cfg.plane.ViewportHeight,
7600 mode_lib->ms.BytePerPixelY,
7601 mode_lib->ms.cache_display_cfg.plane.ViewportWidthChroma,
7602 mode_lib->ms.cache_display_cfg.plane.ViewportHeightChroma,
7603 mode_lib->ms.BytePerPixelC,
7604 mode_lib->ms.cache_display_cfg.surface.SurfaceWidthY,
7605 mode_lib->ms.cache_display_cfg.surface.SurfaceWidthC,
7606 mode_lib->ms.cache_display_cfg.surface.SurfaceHeightY,
7607 mode_lib->ms.cache_display_cfg.surface.SurfaceHeightC,
7608 mode_lib->ms.Read256BlockWidthY,
7609 mode_lib->ms.Read256BlockWidthC,
7610 mode_lib->ms.Read256BlockHeightY,
7611 mode_lib->ms.Read256BlockHeightC,
7612 mode_lib->ms.MacroTileWidthY,
7613 mode_lib->ms.MacroTileWidthC,
7614 mode_lib->ms.MacroTileHeightY,
7615 mode_lib->ms.MacroTileHeightC,
7616
7617 /* Output */
7618 mode_lib->ms.SurfaceSizeInMALL,
7619 &mode_lib->ms.support.ExceededMALLSize);
7620
7621 for (j = 0; j < 2; j++) {
7622 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
7623 mode_lib->ms.swath_width_luma_ub_this_state[k] = mode_lib->ms.swath_width_luma_ub_all_states[j][k];
7624 mode_lib->ms.swath_width_chroma_ub_this_state[k] = mode_lib->ms.swath_width_chroma_ub_all_states[j][k];
7625 mode_lib->ms.SwathWidthYThisState[k] = mode_lib->ms.SwathWidthYAllStates[j][k];
7626 mode_lib->ms.SwathWidthCThisState[k] = mode_lib->ms.SwathWidthCAllStates[j][k];
7627 mode_lib->ms.SwathHeightYThisState[k] = mode_lib->ms.SwathHeightYAllStates[j][k];
7628 mode_lib->ms.SwathHeightCThisState[k] = mode_lib->ms.SwathHeightCAllStates[j][k];
7629 mode_lib->ms.DETBufferSizeInKByteThisState[k] = mode_lib->ms.DETBufferSizeInKByteAllStates[j][k];
7630 mode_lib->ms.DETBufferSizeYThisState[k] = mode_lib->ms.DETBufferSizeYAllStates[j][k];
7631 mode_lib->ms.DETBufferSizeCThisState[k] = mode_lib->ms.DETBufferSizeCAllStates[j][k];
7632 mode_lib->ms.RequiredDPPCLKThisState[k] = mode_lib->ms.RequiredDPPCLKPerSurface[j][k];
7633 mode_lib->ms.NoOfDPPThisState[k] = mode_lib->ms.NoOfDPP[j][k];
7634 }
7635
7636 mode_lib->ms.TotalNumberOfDCCActiveDPP[j] = 0;
7637 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7638 if (mode_lib->ms.cache_display_cfg.surface.DCCEnable[k] == true) {
7639 mode_lib->ms.TotalNumberOfDCCActiveDPP[j] = mode_lib->ms.TotalNumberOfDCCActiveDPP[j] + mode_lib->ms.NoOfDPP[j][k];
7640 }
7641 }
7642
7643 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7644 s->SurfParameters[k].PixelClock = mode_lib->ms.cache_display_cfg.timing.PixelClock[k];
7645 s->SurfParameters[k].DPPPerSurface = mode_lib->ms.NoOfDPP[j][k];
7646 s->SurfParameters[k].SourceScan = mode_lib->ms.cache_display_cfg.plane.SourceScan[k];
7647 s->SurfParameters[k].ViewportHeight = mode_lib->ms.cache_display_cfg.plane.ViewportHeight[k];
7648 s->SurfParameters[k].ViewportHeightChroma = mode_lib->ms.cache_display_cfg.plane.ViewportHeightChroma[k];
7649 s->SurfParameters[k].BlockWidth256BytesY = mode_lib->ms.Read256BlockWidthY[k];
7650 s->SurfParameters[k].BlockHeight256BytesY = mode_lib->ms.Read256BlockHeightY[k];
7651 s->SurfParameters[k].BlockWidth256BytesC = mode_lib->ms.Read256BlockWidthC[k];
7652 s->SurfParameters[k].BlockHeight256BytesC = mode_lib->ms.Read256BlockHeightC[k];
7653 s->SurfParameters[k].BlockWidthY = mode_lib->ms.MacroTileWidthY[k];
7654 s->SurfParameters[k].BlockHeightY = mode_lib->ms.MacroTileHeightY[k];
7655 s->SurfParameters[k].BlockWidthC = mode_lib->ms.MacroTileWidthC[k];
7656 s->SurfParameters[k].BlockHeightC = mode_lib->ms.MacroTileHeightC[k];
7657 s->SurfParameters[k].InterlaceEnable = mode_lib->ms.cache_display_cfg.timing.Interlace[k];
7658 s->SurfParameters[k].HTotal = mode_lib->ms.cache_display_cfg.timing.HTotal[k];
7659 s->SurfParameters[k].DCCEnable = mode_lib->ms.cache_display_cfg.surface.DCCEnable[k];
7660 s->SurfParameters[k].SourcePixelFormat = mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k];
7661 s->SurfParameters[k].SurfaceTiling = mode_lib->ms.cache_display_cfg.surface.SurfaceTiling[k];
7662 s->SurfParameters[k].BytePerPixelY = mode_lib->ms.BytePerPixelY[k];
7663 s->SurfParameters[k].BytePerPixelC = mode_lib->ms.BytePerPixelC[k];
7664 s->SurfParameters[k].ProgressiveToInterlaceUnitInOPP = mode_lib->ms.ip.ptoi_supported;
7665 s->SurfParameters[k].VRatio = mode_lib->ms.cache_display_cfg.plane.VRatio[k];
7666 s->SurfParameters[k].VRatioChroma = mode_lib->ms.cache_display_cfg.plane.VRatioChroma[k];
7667 s->SurfParameters[k].VTaps = mode_lib->ms.cache_display_cfg.plane.VTaps[k];
7668 s->SurfParameters[k].VTapsChroma = mode_lib->ms.cache_display_cfg.plane.VTapsChroma[k];
7669 s->SurfParameters[k].PitchY = mode_lib->ms.cache_display_cfg.surface.PitchY[k];
7670 s->SurfParameters[k].DCCMetaPitchY = mode_lib->ms.cache_display_cfg.surface.DCCMetaPitchY[k];
7671 s->SurfParameters[k].PitchC = mode_lib->ms.cache_display_cfg.surface.PitchC[k];
7672 s->SurfParameters[k].DCCMetaPitchC = mode_lib->ms.cache_display_cfg.surface.DCCMetaPitchC[k];
7673 s->SurfParameters[k].ViewportStationary = mode_lib->ms.cache_display_cfg.plane.ViewportStationary[k];
7674 s->SurfParameters[k].ViewportXStart = mode_lib->ms.cache_display_cfg.plane.ViewportXStart[k];
7675 s->SurfParameters[k].ViewportYStart = mode_lib->ms.cache_display_cfg.plane.ViewportYStart[k];
7676 s->SurfParameters[k].ViewportXStartC = mode_lib->ms.cache_display_cfg.plane.ViewportXStartC[k];
7677 s->SurfParameters[k].ViewportYStartC = mode_lib->ms.cache_display_cfg.plane.ViewportYStartC[k];
7678 s->SurfParameters[k].FORCE_ONE_ROW_FOR_FRAME = mode_lib->ms.cache_display_cfg.plane.ForceOneRowForFrame[k];
7679 s->SurfParameters[k].SwathHeightY = mode_lib->ms.SwathHeightYThisState[k];
7680 s->SurfParameters[k].SwathHeightC = mode_lib->ms.SwathHeightCThisState[k];
7681 }
7682
7683 CalculateVMRowAndSwath_params->NumberOfActiveSurfaces = mode_lib->ms.num_active_planes;
7684 CalculateVMRowAndSwath_params->myPipe = s->SurfParameters;
7685 CalculateVMRowAndSwath_params->SurfaceSizeInMALL = mode_lib->ms.SurfaceSizeInMALL;
7686 CalculateVMRowAndSwath_params->PTEBufferSizeInRequestsLuma = mode_lib->ms.ip.dpte_buffer_size_in_pte_reqs_luma;
7687 CalculateVMRowAndSwath_params->PTEBufferSizeInRequestsChroma = mode_lib->ms.ip.dpte_buffer_size_in_pte_reqs_chroma;
7688 CalculateVMRowAndSwath_params->DCCMetaBufferSizeBytes = mode_lib->ms.ip.dcc_meta_buffer_size_bytes;
7689 CalculateVMRowAndSwath_params->UseMALLForStaticScreen = mode_lib->ms.cache_display_cfg.plane.UseMALLForStaticScreen;
7690 CalculateVMRowAndSwath_params->UseMALLForPStateChange = mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange;
7691 CalculateVMRowAndSwath_params->MALLAllocatedForDCN = mode_lib->ms.soc.mall_allocated_for_dcn_mbytes;
7692 CalculateVMRowAndSwath_params->SwathWidthY = mode_lib->ms.SwathWidthYThisState;
7693 CalculateVMRowAndSwath_params->SwathWidthC = mode_lib->ms.SwathWidthCThisState;
7694 CalculateVMRowAndSwath_params->GPUVMEnable = mode_lib->ms.cache_display_cfg.plane.GPUVMEnable;
7695 CalculateVMRowAndSwath_params->HostVMEnable = mode_lib->ms.cache_display_cfg.plane.HostVMEnable;
7696 CalculateVMRowAndSwath_params->HostVMMaxNonCachedPageTableLevels = mode_lib->ms.cache_display_cfg.plane.HostVMMaxPageTableLevels;
7697 CalculateVMRowAndSwath_params->GPUVMMaxPageTableLevels = mode_lib->ms.cache_display_cfg.plane.GPUVMMaxPageTableLevels;
7698 CalculateVMRowAndSwath_params->GPUVMMinPageSizeKBytes = mode_lib->ms.cache_display_cfg.plane.GPUVMMinPageSizeKBytes;
7699 CalculateVMRowAndSwath_params->HostVMMinPageSize = mode_lib->ms.soc.hostvm_min_page_size_kbytes * 1024;
7700 CalculateVMRowAndSwath_params->PTEBufferModeOverrideEn = mode_lib->ms.cache_display_cfg.plane.PTEBufferModeOverrideEn;
7701 CalculateVMRowAndSwath_params->PTEBufferModeOverrideVal = mode_lib->ms.cache_display_cfg.plane.PTEBufferMode;
7702 CalculateVMRowAndSwath_params->PTEBufferSizeNotExceeded = mode_lib->ms.PTEBufferSizeNotExceededPerState;
7703 CalculateVMRowAndSwath_params->DCCMetaBufferSizeNotExceeded = mode_lib->ms.DCCMetaBufferSizeNotExceededPerState;
7704 CalculateVMRowAndSwath_params->dpte_row_width_luma_ub = s->dummy_integer_array[0];
7705 CalculateVMRowAndSwath_params->dpte_row_width_chroma_ub = s->dummy_integer_array[1];
7706 CalculateVMRowAndSwath_params->dpte_row_height_luma = mode_lib->ms.dpte_row_height;
7707 CalculateVMRowAndSwath_params->dpte_row_height_chroma = mode_lib->ms.dpte_row_height_chroma;
7708 CalculateVMRowAndSwath_params->dpte_row_height_linear_luma = s->dummy_integer_array[2]; // VBA_DELTA
7709 CalculateVMRowAndSwath_params->dpte_row_height_linear_chroma = s->dummy_integer_array[3]; // VBA_DELTA
7710 CalculateVMRowAndSwath_params->meta_req_width = s->dummy_integer_array[4];
7711 CalculateVMRowAndSwath_params->meta_req_width_chroma = s->dummy_integer_array[5];
7712 CalculateVMRowAndSwath_params->meta_req_height = s->dummy_integer_array[6];
7713 CalculateVMRowAndSwath_params->meta_req_height_chroma = s->dummy_integer_array[7];
7714 CalculateVMRowAndSwath_params->meta_row_width = s->dummy_integer_array[8];
7715 CalculateVMRowAndSwath_params->meta_row_width_chroma = s->dummy_integer_array[9];
7716 CalculateVMRowAndSwath_params->meta_row_height = mode_lib->ms.meta_row_height;
7717 CalculateVMRowAndSwath_params->meta_row_height_chroma = mode_lib->ms.meta_row_height_chroma;
7718 CalculateVMRowAndSwath_params->vm_group_bytes = s->dummy_integer_array[10];
7719 CalculateVMRowAndSwath_params->dpte_group_bytes = mode_lib->ms.dpte_group_bytes;
7720 CalculateVMRowAndSwath_params->PixelPTEReqWidthY = s->dummy_integer_array[11];
7721 CalculateVMRowAndSwath_params->PixelPTEReqHeightY = s->dummy_integer_array[12];
7722 CalculateVMRowAndSwath_params->PTERequestSizeY = s->dummy_integer_array[13];
7723 CalculateVMRowAndSwath_params->PixelPTEReqWidthC = s->dummy_integer_array[14];
7724 CalculateVMRowAndSwath_params->PixelPTEReqHeightC = s->dummy_integer_array[15];
7725 CalculateVMRowAndSwath_params->PTERequestSizeC = s->dummy_integer_array[16];
7726 CalculateVMRowAndSwath_params->dpde0_bytes_per_frame_ub_l = s->dummy_integer_array[17];
7727 CalculateVMRowAndSwath_params->meta_pte_bytes_per_frame_ub_l = s->dummy_integer_array[18];
7728 CalculateVMRowAndSwath_params->dpde0_bytes_per_frame_ub_c = s->dummy_integer_array[19];
7729 CalculateVMRowAndSwath_params->meta_pte_bytes_per_frame_ub_c = s->dummy_integer_array[20];
7730 CalculateVMRowAndSwath_params->PrefetchSourceLinesY = mode_lib->ms.PrefetchLinesYThisState;
7731 CalculateVMRowAndSwath_params->PrefetchSourceLinesC = mode_lib->ms.PrefetchLinesCThisState;
7732 CalculateVMRowAndSwath_params->VInitPreFillY = mode_lib->ms.PrefillY;
7733 CalculateVMRowAndSwath_params->VInitPreFillC = mode_lib->ms.PrefillC;
7734 CalculateVMRowAndSwath_params->MaxNumSwathY = mode_lib->ms.MaxNumSwY;
7735 CalculateVMRowAndSwath_params->MaxNumSwathC = mode_lib->ms.MaxNumSwC;
7736 CalculateVMRowAndSwath_params->meta_row_bw = mode_lib->ms.meta_row_bandwidth_this_state;
7737 CalculateVMRowAndSwath_params->dpte_row_bw = mode_lib->ms.dpte_row_bandwidth_this_state;
7738 CalculateVMRowAndSwath_params->PixelPTEBytesPerRow = mode_lib->ms.DPTEBytesPerRowThisState;
7739 CalculateVMRowAndSwath_params->PDEAndMetaPTEBytesFrame = mode_lib->ms.PDEAndMetaPTEBytesPerFrameThisState;
7740 CalculateVMRowAndSwath_params->MetaRowByte = mode_lib->ms.MetaRowBytesThisState;
7741 CalculateVMRowAndSwath_params->use_one_row_for_frame = mode_lib->ms.use_one_row_for_frame_this_state;
7742 CalculateVMRowAndSwath_params->use_one_row_for_frame_flip = mode_lib->ms.use_one_row_for_frame_flip_this_state;
7743 CalculateVMRowAndSwath_params->UsesMALLForStaticScreen = s->dummy_boolean_array[0];
7744 CalculateVMRowAndSwath_params->PTE_BUFFER_MODE = s->dummy_boolean_array[1];
7745 CalculateVMRowAndSwath_params->BIGK_FRAGMENT_SIZE = s->dummy_integer_array[21];
7746
7747 CalculateVMRowAndSwath(&mode_lib->scratch,
7748 CalculateVMRowAndSwath_params);
7749
7750 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7751 mode_lib->ms.PrefetchLinesY[j][k] = mode_lib->ms.PrefetchLinesYThisState[k];
7752 mode_lib->ms.PrefetchLinesC[j][k] = mode_lib->ms.PrefetchLinesCThisState[k];
7753 mode_lib->ms.meta_row_bandwidth[j][k] = mode_lib->ms.meta_row_bandwidth_this_state[k];
7754 mode_lib->ms.dpte_row_bandwidth[j][k] = mode_lib->ms.dpte_row_bandwidth_this_state[k];
7755 mode_lib->ms.DPTEBytesPerRow[j][k] = mode_lib->ms.DPTEBytesPerRowThisState[k];
7756 mode_lib->ms.PDEAndMetaPTEBytesPerFrame[j][k] = mode_lib->ms.PDEAndMetaPTEBytesPerFrameThisState[k];
7757 mode_lib->ms.MetaRowBytes[j][k] = mode_lib->ms.MetaRowBytesThisState[k];
7758 mode_lib->ms.use_one_row_for_frame[j][k] = mode_lib->ms.use_one_row_for_frame_this_state[k];
7759 mode_lib->ms.use_one_row_for_frame_flip[j][k] = mode_lib->ms.use_one_row_for_frame_flip_this_state[k];
7760 }
7761
7762 mode_lib->ms.support.PTEBufferSizeNotExceeded[j] = true;
7763
7764 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7765 if (mode_lib->ms.PTEBufferSizeNotExceededPerState[k] == false)
7766 mode_lib->ms.support.PTEBufferSizeNotExceeded[j] = false;
7767 #ifdef __DML_VBA_DEBUG__
7768 dml_print("DML::%s: j=%u k=%u, PTEBufferSizeNotExceededPerState[%u] = %u\n", __func__, j, k, k, mode_lib->ms.PTEBufferSizeNotExceededPerState[k]);
7769 #endif
7770 }
7771 #ifdef __DML_VBA_DEBUG__
7772 dml_print("DML::%s: PTEBufferSizeNotExceeded[%u] = %u\n", __func__, j, mode_lib->ms.support.PTEBufferSizeNotExceeded[j]);
7773 #endif
7774
7775 mode_lib->ms.support.DCCMetaBufferSizeNotExceeded[j] = true;
7776 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7777 if (mode_lib->ms.DCCMetaBufferSizeNotExceededPerState[k] == false)
7778 mode_lib->ms.support.DCCMetaBufferSizeNotExceeded[j] = false;
7779 }
7780
7781 mode_lib->ms.UrgLatency = CalculateUrgentLatency(mode_lib->ms.state.urgent_latency_pixel_data_only_us,
7782 mode_lib->ms.state.urgent_latency_pixel_mixed_with_vm_data_us,
7783 mode_lib->ms.state.urgent_latency_vm_data_only_us,
7784 mode_lib->ms.soc.do_urgent_latency_adjustment,
7785 mode_lib->ms.state.urgent_latency_adjustment_fabric_clock_component_us,
7786 mode_lib->ms.state.urgent_latency_adjustment_fabric_clock_reference_mhz,
7787 mode_lib->ms.state.fabricclk_mhz);
7788
7789 /* Getter functions work at mp interface so copy the urgent latency to mp*/
7790 mode_lib->mp.UrgentLatency = mode_lib->ms.UrgLatency;
7791
7792 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7793 CalculateUrgentBurstFactor(
7794 mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[k],
7795 mode_lib->ms.swath_width_luma_ub_this_state[k],
7796 mode_lib->ms.swath_width_chroma_ub_this_state[k],
7797 mode_lib->ms.SwathHeightYThisState[k],
7798 mode_lib->ms.SwathHeightCThisState[k],
7799 (dml_float_t) mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k],
7800 mode_lib->ms.UrgLatency,
7801 mode_lib->ms.ip.cursor_buffer_size,
7802 mode_lib->ms.cache_display_cfg.plane.CursorWidth[k],
7803 mode_lib->ms.cache_display_cfg.plane.CursorBPP[k],
7804 mode_lib->ms.cache_display_cfg.plane.VRatio[k],
7805 mode_lib->ms.cache_display_cfg.plane.VRatioChroma[k],
7806 mode_lib->ms.BytePerPixelInDETY[k],
7807 mode_lib->ms.BytePerPixelInDETC[k],
7808 mode_lib->ms.DETBufferSizeYThisState[k],
7809 mode_lib->ms.DETBufferSizeCThisState[k],
7810 /* Output */
7811 &mode_lib->ms.UrgentBurstFactorCursor[k],
7812 &mode_lib->ms.UrgentBurstFactorLuma[k],
7813 &mode_lib->ms.UrgentBurstFactorChroma[k],
7814 &mode_lib->ms.NotUrgentLatencyHiding[k]);
7815 }
7816
7817 CalculateDCFCLKDeepSleep(
7818 mode_lib->ms.num_active_planes,
7819 mode_lib->ms.BytePerPixelY,
7820 mode_lib->ms.BytePerPixelC,
7821 mode_lib->ms.cache_display_cfg.plane.VRatio,
7822 mode_lib->ms.cache_display_cfg.plane.VRatioChroma,
7823 mode_lib->ms.SwathWidthYThisState,
7824 mode_lib->ms.SwathWidthCThisState,
7825 mode_lib->ms.NoOfDPPThisState,
7826 mode_lib->ms.cache_display_cfg.plane.HRatio,
7827 mode_lib->ms.cache_display_cfg.plane.HRatioChroma,
7828 mode_lib->ms.cache_display_cfg.timing.PixelClock,
7829 mode_lib->ms.PSCL_FACTOR,
7830 mode_lib->ms.PSCL_FACTOR_CHROMA,
7831 mode_lib->ms.RequiredDPPCLKThisState,
7832 mode_lib->ms.ReadBandwidthLuma,
7833 mode_lib->ms.ReadBandwidthChroma,
7834 mode_lib->ms.soc.return_bus_width_bytes,
7835
7836 /* Output */
7837 &mode_lib->ms.ProjectedDCFCLKDeepSleep[j]);
7838 }
7839
7840 //Calculate Return BW
7841 for (j = 0; j < 2; ++j) {
7842 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
7843 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == k) {
7844 if (mode_lib->ms.cache_display_cfg.writeback.WritebackEnable[k] == true) {
7845 mode_lib->ms.WritebackDelayTime[k] = mode_lib->ms.state.writeback_latency_us + CalculateWriteBackDelay(
7846 mode_lib->ms.cache_display_cfg.writeback.WritebackPixelFormat[k],
7847 mode_lib->ms.cache_display_cfg.writeback.WritebackHRatio[k],
7848 mode_lib->ms.cache_display_cfg.writeback.WritebackVRatio[k],
7849 mode_lib->ms.cache_display_cfg.writeback.WritebackVTaps[k],
7850 mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationWidth[k],
7851 mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationHeight[k],
7852 mode_lib->ms.cache_display_cfg.writeback.WritebackSourceHeight[k],
7853 mode_lib->ms.cache_display_cfg.timing.HTotal[k]) / mode_lib->ms.RequiredDISPCLK[j];
7854 } else {
7855 mode_lib->ms.WritebackDelayTime[k] = 0.0;
7856 }
7857 for (m = 0; m <= mode_lib->ms.num_active_planes - 1; m++) {
7858 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[m] == k && mode_lib->ms.cache_display_cfg.writeback.WritebackEnable[m] == true) {
7859 mode_lib->ms.WritebackDelayTime[k] = dml_max(mode_lib->ms.WritebackDelayTime[k],
7860 mode_lib->ms.state.writeback_latency_us + CalculateWriteBackDelay(
7861 mode_lib->ms.cache_display_cfg.writeback.WritebackPixelFormat[m],
7862 mode_lib->ms.cache_display_cfg.writeback.WritebackHRatio[m],
7863 mode_lib->ms.cache_display_cfg.writeback.WritebackVRatio[m],
7864 mode_lib->ms.cache_display_cfg.writeback.WritebackVTaps[m],
7865 mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationWidth[m],
7866 mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationHeight[m],
7867 mode_lib->ms.cache_display_cfg.writeback.WritebackSourceHeight[m],
7868 mode_lib->ms.cache_display_cfg.timing.HTotal[m]) / mode_lib->ms.RequiredDISPCLK[j]);
7869 }
7870 }
7871 }
7872 }
7873 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
7874 for (m = 0; m <= mode_lib->ms.num_active_planes - 1; m++) {
7875 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == m) {
7876 mode_lib->ms.WritebackDelayTime[k] = mode_lib->ms.WritebackDelayTime[m];
7877 }
7878 }
7879 }
7880 s->MaxVStartupAllPlanes[j] = 0; // max vstartup among all planes
7881
7882 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
7883 s->MaximumVStartup[j][k] = CalculateMaxVStartup(k,
7884 mode_lib->ms.ip.ptoi_supported,
7885 mode_lib->ms.ip.vblank_nom_default_us,
7886 &mode_lib->ms.cache_display_cfg.timing,
7887 mode_lib->ms.WritebackDelayTime[k]);
7888
7889 s->MaxVStartupAllPlanes[j] = (dml_uint_t)(dml_max(s->MaxVStartupAllPlanes[j], s->MaximumVStartup[j][k]));
7890 #ifdef __DML_VBA_DEBUG__
7891 dml_print("DML::%s: k=%u, MaxVStartupAllPlanes[%u] = %u\n", __func__, k, j, s->MaxVStartupAllPlanes[j]);
7892 dml_print("DML::%s: k=%u, MaximumVStartup[%u][%u] = %u\n", __func__, k, j, k, s->MaximumVStartup[j][k]);
7893 #endif
7894 }
7895 }
7896
7897 s->ReorderingBytes = (dml_uint_t)(mode_lib->ms.soc.num_chans * dml_max3(mode_lib->ms.soc.urgent_out_of_order_return_per_channel_pixel_only_bytes,
7898 mode_lib->ms.soc.urgent_out_of_order_return_per_channel_pixel_and_vm_bytes,
7899 mode_lib->ms.soc.urgent_out_of_order_return_per_channel_vm_only_bytes));
7900
7901 for (j = 0; j < 2; ++j) {
7902 mode_lib->ms.DCFCLKState[j] = mode_lib->ms.state.dcfclk_mhz;
7903 }
7904
7905 /* Immediate Flip and MALL parameters */
7906 s->ImmediateFlipRequiredFinal = false;
7907 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7908 s->ImmediateFlipRequiredFinal = s->ImmediateFlipRequiredFinal || (mode_lib->ms.policy.ImmediateFlipRequirement[k] == dml_immediate_flip_required);
7909 }
7910
7911 mode_lib->ms.support.ImmediateFlipRequiredButTheRequirementForEachSurfaceIsNotSpecified = false;
7912 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7913 mode_lib->ms.support.ImmediateFlipRequiredButTheRequirementForEachSurfaceIsNotSpecified = mode_lib->ms.support.ImmediateFlipRequiredButTheRequirementForEachSurfaceIsNotSpecified ||
7914 ((mode_lib->ms.policy.ImmediateFlipRequirement[k] != dml_immediate_flip_required) &&
7915 (mode_lib->ms.policy.ImmediateFlipRequirement[k] != dml_immediate_flip_not_required));
7916 }
7917 mode_lib->ms.support.ImmediateFlipRequiredButTheRequirementForEachSurfaceIsNotSpecified = mode_lib->ms.support.ImmediateFlipRequiredButTheRequirementForEachSurfaceIsNotSpecified && s->ImmediateFlipRequiredFinal;
7918
7919 mode_lib->ms.support.ImmediateFlipOrHostVMAndPStateWithMALLFullFrameOrPhantomPipe = false;
7920 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7921 mode_lib->ms.support.ImmediateFlipOrHostVMAndPStateWithMALLFullFrameOrPhantomPipe =
7922 mode_lib->ms.support.ImmediateFlipOrHostVMAndPStateWithMALLFullFrameOrPhantomPipe || ((mode_lib->ms.cache_display_cfg.plane.HostVMEnable == true || mode_lib->ms.policy.ImmediateFlipRequirement[k] != dml_immediate_flip_not_required) &&
7923 (mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[k] == dml_use_mall_pstate_change_full_frame || mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[k] == dml_use_mall_pstate_change_phantom_pipe));
7924 }
7925
7926 mode_lib->ms.support.InvalidCombinationOfMALLUseForPStateAndStaticScreen = false;
7927 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7928 mode_lib->ms.support.InvalidCombinationOfMALLUseForPStateAndStaticScreen = mode_lib->ms.support.InvalidCombinationOfMALLUseForPStateAndStaticScreen ||
7929 ((mode_lib->ms.cache_display_cfg.plane.UseMALLForStaticScreen[k] == dml_use_mall_static_screen_enable || mode_lib->ms.cache_display_cfg.plane.UseMALLForStaticScreen[k] == dml_use_mall_static_screen_optimize) && (mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[k] == dml_use_mall_pstate_change_phantom_pipe)) ||
7930 ((mode_lib->ms.cache_display_cfg.plane.UseMALLForStaticScreen[k] == dml_use_mall_static_screen_disable || mode_lib->ms.cache_display_cfg.plane.UseMALLForStaticScreen[k] == dml_use_mall_static_screen_optimize) && (mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[k] == dml_use_mall_pstate_change_full_frame));
7931 }
7932
7933 s->FullFrameMALLPStateMethod = false;
7934 s->SubViewportMALLPStateMethod = false;
7935 s->PhantomPipeMALLPStateMethod = false;
7936 s->SubViewportMALLRefreshGreaterThan120Hz = false;
7937 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
7938 if (mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[k] == dml_use_mall_pstate_change_full_frame)
7939 s->FullFrameMALLPStateMethod = true;
7940 if (mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[k] == dml_use_mall_pstate_change_sub_viewport) {
7941 s->SubViewportMALLPStateMethod = true;
7942 if (mode_lib->ms.cache_display_cfg.timing.RefreshRate[k] > 120)
7943 s->SubViewportMALLRefreshGreaterThan120Hz = true;
7944 }
7945 if (mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[k] == dml_use_mall_pstate_change_phantom_pipe)
7946 s->PhantomPipeMALLPStateMethod = true;
7947 }
7948 mode_lib->ms.support.InvalidCombinationOfMALLUseForPState = (s->SubViewportMALLPStateMethod != s->PhantomPipeMALLPStateMethod)
7949 || (s->SubViewportMALLPStateMethod && s->FullFrameMALLPStateMethod) || s->SubViewportMALLRefreshGreaterThan120Hz;
7950
7951 if (mode_lib->ms.policy.UseMinimumRequiredDCFCLK == true) {
7952 UseMinimumDCFCLK_params->UseMALLForPStateChange = mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange;
7953 UseMinimumDCFCLK_params->DRRDisplay = mode_lib->ms.cache_display_cfg.timing.DRRDisplay;
7954 UseMinimumDCFCLK_params->SynchronizeDRRDisplaysForUCLKPStateChangeFinal = mode_lib->ms.policy.SynchronizeDRRDisplaysForUCLKPStateChangeFinal;
7955 UseMinimumDCFCLK_params->MaxInterDCNTileRepeaters = mode_lib->ms.ip.max_inter_dcn_tile_repeaters;
7956 UseMinimumDCFCLK_params->MaxPrefetchMode = dml_prefetch_support_stutter;
7957 UseMinimumDCFCLK_params->DRAMClockChangeLatencyFinal = mode_lib->ms.state.dram_clock_change_latency_us;
7958 UseMinimumDCFCLK_params->FCLKChangeLatency = mode_lib->ms.state.fclk_change_latency_us;
7959 UseMinimumDCFCLK_params->SREnterPlusExitTime = mode_lib->ms.state.sr_enter_plus_exit_time_us;
7960 UseMinimumDCFCLK_params->ReturnBusWidth = mode_lib->ms.soc.return_bus_width_bytes;
7961 UseMinimumDCFCLK_params->RoundTripPingLatencyCycles = mode_lib->ms.soc.round_trip_ping_latency_dcfclk_cycles;
7962 UseMinimumDCFCLK_params->ReorderingBytes = s->ReorderingBytes;
7963 UseMinimumDCFCLK_params->PixelChunkSizeInKByte = mode_lib->ms.ip.pixel_chunk_size_kbytes;
7964 UseMinimumDCFCLK_params->MetaChunkSize = mode_lib->ms.ip.meta_chunk_size_kbytes;
7965 UseMinimumDCFCLK_params->GPUVMEnable = mode_lib->ms.cache_display_cfg.plane.GPUVMEnable;
7966 UseMinimumDCFCLK_params->GPUVMMaxPageTableLevels = mode_lib->ms.cache_display_cfg.plane.GPUVMMaxPageTableLevels;
7967 UseMinimumDCFCLK_params->HostVMEnable = mode_lib->ms.cache_display_cfg.plane.HostVMEnable;
7968 UseMinimumDCFCLK_params->NumberOfActiveSurfaces = mode_lib->ms.num_active_planes;
7969 UseMinimumDCFCLK_params->HostVMMinPageSize = mode_lib->ms.soc.hostvm_min_page_size_kbytes * 1024;
7970 UseMinimumDCFCLK_params->HostVMMaxNonCachedPageTableLevels = mode_lib->ms.cache_display_cfg.plane.HostVMMaxPageTableLevels;
7971 UseMinimumDCFCLK_params->DynamicMetadataVMEnabled = mode_lib->ms.ip.dynamic_metadata_vm_enabled;
7972 UseMinimumDCFCLK_params->ImmediateFlipRequirement = s->ImmediateFlipRequiredFinal;
7973 UseMinimumDCFCLK_params->ProgressiveToInterlaceUnitInOPP = mode_lib->ms.ip.ptoi_supported;
7974 UseMinimumDCFCLK_params->MaxAveragePercentOfIdealSDPPortBWDisplayCanUseInNormalSystemOperation = mode_lib->ms.soc.max_avg_sdp_bw_use_normal_percent;
7975 UseMinimumDCFCLK_params->PercentOfIdealSDPPortBWReceivedAfterUrgLatency = mode_lib->ms.soc.pct_ideal_sdp_bw_after_urgent;
7976 UseMinimumDCFCLK_params->VTotal = mode_lib->ms.cache_display_cfg.timing.VTotal;
7977 UseMinimumDCFCLK_params->VActive = mode_lib->ms.cache_display_cfg.timing.VActive;
7978 UseMinimumDCFCLK_params->DynamicMetadataTransmittedBytes = mode_lib->ms.cache_display_cfg.plane.DynamicMetadataTransmittedBytes;
7979 UseMinimumDCFCLK_params->DynamicMetadataLinesBeforeActiveRequired = mode_lib->ms.cache_display_cfg.plane.DynamicMetadataLinesBeforeActiveRequired;
7980 UseMinimumDCFCLK_params->Interlace = mode_lib->ms.cache_display_cfg.timing.Interlace;
7981 UseMinimumDCFCLK_params->RequiredDPPCLKPerSurface = mode_lib->ms.RequiredDPPCLKPerSurface;
7982 UseMinimumDCFCLK_params->RequiredDISPCLK = mode_lib->ms.RequiredDISPCLK;
7983 UseMinimumDCFCLK_params->UrgLatency = mode_lib->ms.UrgLatency;
7984 UseMinimumDCFCLK_params->NoOfDPP = mode_lib->ms.NoOfDPP;
7985 UseMinimumDCFCLK_params->ProjectedDCFCLKDeepSleep = mode_lib->ms.ProjectedDCFCLKDeepSleep;
7986 UseMinimumDCFCLK_params->MaximumVStartup = s->MaximumVStartup;
7987 UseMinimumDCFCLK_params->TotalNumberOfActiveDPP = mode_lib->ms.TotalNumberOfActiveDPP;
7988 UseMinimumDCFCLK_params->TotalNumberOfDCCActiveDPP = mode_lib->ms.TotalNumberOfDCCActiveDPP;
7989 UseMinimumDCFCLK_params->dpte_group_bytes = mode_lib->ms.dpte_group_bytes;
7990 UseMinimumDCFCLK_params->PrefetchLinesY = mode_lib->ms.PrefetchLinesY;
7991 UseMinimumDCFCLK_params->PrefetchLinesC = mode_lib->ms.PrefetchLinesC;
7992 UseMinimumDCFCLK_params->swath_width_luma_ub_all_states = mode_lib->ms.swath_width_luma_ub_all_states;
7993 UseMinimumDCFCLK_params->swath_width_chroma_ub_all_states = mode_lib->ms.swath_width_chroma_ub_all_states;
7994 UseMinimumDCFCLK_params->BytePerPixelY = mode_lib->ms.BytePerPixelY;
7995 UseMinimumDCFCLK_params->BytePerPixelC = mode_lib->ms.BytePerPixelC;
7996 UseMinimumDCFCLK_params->HTotal = mode_lib->ms.cache_display_cfg.timing.HTotal;
7997 UseMinimumDCFCLK_params->PixelClock = mode_lib->ms.cache_display_cfg.timing.PixelClock;
7998 UseMinimumDCFCLK_params->PDEAndMetaPTEBytesPerFrame = mode_lib->ms.PDEAndMetaPTEBytesPerFrame;
7999 UseMinimumDCFCLK_params->DPTEBytesPerRow = mode_lib->ms.DPTEBytesPerRow;
8000 UseMinimumDCFCLK_params->MetaRowBytes = mode_lib->ms.MetaRowBytes;
8001 UseMinimumDCFCLK_params->DynamicMetadataEnable = mode_lib->ms.cache_display_cfg.plane.DynamicMetadataEnable;
8002 UseMinimumDCFCLK_params->ReadBandwidthLuma = mode_lib->ms.ReadBandwidthLuma;
8003 UseMinimumDCFCLK_params->ReadBandwidthChroma = mode_lib->ms.ReadBandwidthChroma;
8004 UseMinimumDCFCLK_params->DCFCLKPerState = mode_lib->ms.state.dcfclk_mhz;
8005 UseMinimumDCFCLK_params->DCFCLKState = mode_lib->ms.DCFCLKState;
8006
8007 UseMinimumDCFCLK(&mode_lib->scratch,
8008 UseMinimumDCFCLK_params);
8009
8010 } // UseMinimumRequiredDCFCLK == true
8011
8012 for (j = 0; j < 2; ++j) {
8013 mode_lib->ms.ReturnBWPerState[j] = dml_get_return_bw_mbps(&mode_lib->ms.soc, mode_lib->ms.state.use_ideal_dram_bw_strobe,
8014 mode_lib->ms.cache_display_cfg.plane.HostVMEnable, mode_lib->ms.DCFCLKState[j], mode_lib->ms.state.fabricclk_mhz,
8015 mode_lib->ms.state.dram_speed_mts);
8016 mode_lib->ms.ReturnDRAMBWPerState[j] = dml_get_return_dram_bw_mbps(&mode_lib->ms.soc, mode_lib->ms.state.use_ideal_dram_bw_strobe,
8017 mode_lib->ms.cache_display_cfg.plane.HostVMEnable,
8018 mode_lib->ms.state.dram_speed_mts);
8019 }
8020
8021 //Re-ordering Buffer Support Check
8022 for (j = 0; j < 2; ++j) {
8023 if ((mode_lib->ms.ip.rob_buffer_size_kbytes - mode_lib->ms.ip.pixel_chunk_size_kbytes) * 1024 / mode_lib->ms.ReturnBWPerState[j] >
8024 (mode_lib->ms.soc.round_trip_ping_latency_dcfclk_cycles + 32) / mode_lib->ms.DCFCLKState[j] + s->ReorderingBytes / mode_lib->ms.ReturnBWPerState[j]) {
8025 mode_lib->ms.support.ROBSupport[j] = true;
8026 } else {
8027 mode_lib->ms.support.ROBSupport[j] = false;
8028 }
8029 dml_print("DML::%s: DEBUG ROBSupport[%u] = %u (%u)\n", __func__, j, mode_lib->ms.support.ROBSupport[j], __LINE__);
8030 }
8031
8032 //Vertical Active BW support check
8033 s->MaxTotalVActiveRDBandwidth = 0;
8034 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8035 s->MaxTotalVActiveRDBandwidth = s->MaxTotalVActiveRDBandwidth + mode_lib->ms.ReadBandwidthLuma[k] + mode_lib->ms.ReadBandwidthChroma[k];
8036 }
8037
8038 for (j = 0; j < 2; ++j) {
8039 mode_lib->ms.support.MaxTotalVerticalActiveAvailableBandwidth[j] = dml_min3(mode_lib->ms.soc.return_bus_width_bytes * mode_lib->ms.DCFCLKState[j] * mode_lib->ms.soc.max_avg_sdp_bw_use_normal_percent / 100.0,
8040 mode_lib->ms.state.fabricclk_mhz * mode_lib->ms.soc.fabric_datapath_to_dcn_data_return_bytes * mode_lib->ms.soc.max_avg_fabric_bw_use_normal_percent / 100.0,
8041 mode_lib->ms.state.dram_speed_mts * mode_lib->ms.soc.num_chans * mode_lib->ms.soc.dram_channel_width_bytes *
8042 ((mode_lib->ms.state.use_ideal_dram_bw_strobe && !mode_lib->ms.cache_display_cfg.plane.HostVMEnable) ?
8043 mode_lib->ms.soc.max_avg_dram_bw_use_normal_strobe_percent : mode_lib->ms.soc.max_avg_dram_bw_use_normal_percent) / 100.0);
8044
8045 if (s->MaxTotalVActiveRDBandwidth <= mode_lib->ms.support.MaxTotalVerticalActiveAvailableBandwidth[j]) {
8046 mode_lib->ms.support.TotalVerticalActiveBandwidthSupport[j] = true;
8047 } else {
8048 mode_lib->ms.support.TotalVerticalActiveBandwidthSupport[j] = false;
8049 }
8050 }
8051
8052 /* Prefetch Check */
8053 dml_prefetch_check(mode_lib);
8054
8055 // End of Prefetch Check
8056 dml_print("DML::%s: Done prefetch calculation\n", __func__);
8057
8058 /*Cursor Support Check*/
8059 mode_lib->ms.support.CursorSupport = true;
8060 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
8061 if (mode_lib->ms.cache_display_cfg.plane.CursorWidth[k] > 0.0) {
8062 if (mode_lib->ms.cache_display_cfg.plane.CursorBPP[k] == 64 && mode_lib->ms.ip.cursor_64bpp_support == false) {
8063 mode_lib->ms.support.CursorSupport = false;
8064 }
8065 }
8066 }
8067
8068 /*Valid Pitch Check*/
8069 mode_lib->ms.support.PitchSupport = true;
8070 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
8071 mode_lib->ms.support.AlignedYPitch[k] = dml_ceil(
8072 dml_max(mode_lib->ms.cache_display_cfg.surface.PitchY[k], mode_lib->ms.cache_display_cfg.surface.SurfaceWidthY[k]),
8073 mode_lib->ms.MacroTileWidthY[k]);
8074 if (mode_lib->ms.cache_display_cfg.surface.DCCEnable[k] == true) {
8075 mode_lib->ms.support.AlignedDCCMetaPitchY[k] = dml_ceil(dml_max(mode_lib->ms.cache_display_cfg.surface.DCCMetaPitchY[k], mode_lib->ms.cache_display_cfg.surface.SurfaceWidthY[k]), 64.0 * mode_lib->ms.Read256BlockWidthY[k]);
8076 } else {
8077 mode_lib->ms.support.AlignedDCCMetaPitchY[k] = mode_lib->ms.cache_display_cfg.surface.DCCMetaPitchY[k];
8078 }
8079 if (mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_444_64
8080 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_444_32
8081 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_444_16
8082 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_mono_16
8083 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_rgbe
8084 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_mono_8) {
8085 mode_lib->ms.support.AlignedCPitch[k] = dml_ceil(dml_max(mode_lib->ms.cache_display_cfg.surface.PitchC[k], mode_lib->ms.cache_display_cfg.surface.SurfaceWidthC[k]), mode_lib->ms.MacroTileWidthC[k]);
8086 if (mode_lib->ms.cache_display_cfg.surface.DCCEnable[k] == true) {
8087 mode_lib->ms.support.AlignedDCCMetaPitchC[k] = dml_ceil(dml_max(mode_lib->ms.cache_display_cfg.surface.DCCMetaPitchC[k], mode_lib->ms.cache_display_cfg.surface.SurfaceWidthC[k]), 64.0 * mode_lib->ms.Read256BlockWidthC[k]);
8088 } else {
8089 mode_lib->ms.support.AlignedDCCMetaPitchC[k] = mode_lib->ms.cache_display_cfg.surface.DCCMetaPitchC[k];
8090 }
8091 } else {
8092 mode_lib->ms.support.AlignedCPitch[k] = mode_lib->ms.cache_display_cfg.surface.PitchC[k];
8093 mode_lib->ms.support.AlignedDCCMetaPitchC[k] = mode_lib->ms.cache_display_cfg.surface.DCCMetaPitchC[k];
8094 }
8095 if (mode_lib->ms.support.AlignedYPitch[k] > mode_lib->ms.cache_display_cfg.surface.PitchY[k] || mode_lib->ms.support.AlignedCPitch[k] > mode_lib->ms.cache_display_cfg.surface.PitchC[k] ||
8096 mode_lib->ms.support.AlignedDCCMetaPitchY[k] > mode_lib->ms.cache_display_cfg.surface.DCCMetaPitchY[k] || mode_lib->ms.support.AlignedDCCMetaPitchC[k] > mode_lib->ms.cache_display_cfg.surface.DCCMetaPitchC[k]) {
8097 mode_lib->ms.support.PitchSupport = false;
8098 }
8099 }
8100
8101 mode_lib->ms.support.ViewportExceedsSurface = false;
8102 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
8103 if (mode_lib->ms.cache_display_cfg.plane.ViewportWidth[k] > mode_lib->ms.cache_display_cfg.surface.SurfaceWidthY[k] || mode_lib->ms.cache_display_cfg.plane.ViewportHeight[k] > mode_lib->ms.cache_display_cfg.surface.SurfaceHeightY[k]) {
8104 mode_lib->ms.support.ViewportExceedsSurface = true;
8105 if (mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_444_64 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_444_32 &&
8106 mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_444_16 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_444_8 && mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k] != dml_rgbe) {
8107 if (mode_lib->ms.cache_display_cfg.plane.ViewportWidthChroma[k] > mode_lib->ms.cache_display_cfg.surface.SurfaceWidthC[k] || mode_lib->ms.cache_display_cfg.plane.ViewportHeightChroma[k] > mode_lib->ms.cache_display_cfg.surface.SurfaceHeightC[k]) {
8108 mode_lib->ms.support.ViewportExceedsSurface = true;
8109 }
8110 }
8111 }
8112 }
8113
8114 /*Mode Support, Voltage State and SOC Configuration*/
8115 for (j = 0; j < 2; j++) { // j iterator is for the combine mode off or on
8116 dml_print("DML::%s: checking support for j=%u\n", __func__, j);
8117 dml_print("DML::%s: state_idx=%0d max_state_idx=%0d\n", __func__, mode_lib->ms.state_idx, mode_lib->ms.max_state_idx);
8118
8119 s->is_max_pwr_state = (mode_lib->ms.max_state_idx == mode_lib->ms.state_idx);
8120 s->is_max_dram_pwr_state = (mode_lib->ms.max_state.dram_speed_mts == mode_lib->ms.state.dram_speed_mts);
8121
8122 s->dram_clock_change_support = (!mode_lib->ms.policy.DRAMClockChangeRequirementFinal ||
8123 (s->is_max_dram_pwr_state && mode_lib->policy.AssumeModeSupportAtMaxPwrStateEvenDRAMClockChangeNotSupported) ||
8124 mode_lib->ms.support.DRAMClockChangeSupport[j] != dml_dram_clock_change_unsupported);
8125 s->f_clock_change_support = (!mode_lib->ms.policy.FCLKChangeRequirementFinal ||
8126 (s->is_max_pwr_state && mode_lib->policy.AssumeModeSupportAtMaxPwrStateEvenFClockChangeNotSupported) ||
8127 mode_lib->ms.support.FCLKChangeSupport[j] != dml_fclock_change_unsupported);
8128
8129 if (mode_lib->ms.support.ScaleRatioAndTapsSupport == true
8130 && mode_lib->ms.support.SourceFormatPixelAndScanSupport == true
8131 && mode_lib->ms.support.ViewportSizeSupport[j] == true
8132 && !mode_lib->ms.support.LinkRateDoesNotMatchDPVersion
8133 && !mode_lib->ms.support.LinkRateForMultistreamNotIndicated
8134 && !mode_lib->ms.support.BPPForMultistreamNotIndicated
8135 && !mode_lib->ms.support.MultistreamWithHDMIOreDP
8136 && !mode_lib->ms.support.ExceededMultistreamSlots
8137 && !mode_lib->ms.support.MSOOrODMSplitWithNonDPLink
8138 && !mode_lib->ms.support.NotEnoughLanesForMSO
8139 && mode_lib->ms.support.LinkCapacitySupport == true
8140 && !mode_lib->ms.support.P2IWith420
8141 && !mode_lib->ms.support.DSCOnlyIfNecessaryWithBPP
8142 && !mode_lib->ms.support.DSC422NativeNotSupported
8143 && !mode_lib->ms.support.MPCCombineMethodIncompatible
8144 && mode_lib->ms.support.ODMCombineTwoToOneSupportCheckOK == true
8145 && mode_lib->ms.support.ODMCombineFourToOneSupportCheckOK == true
8146 && mode_lib->ms.support.NotEnoughDSCUnits == false
8147 && !mode_lib->ms.support.NotEnoughDSCSlices
8148 && !mode_lib->ms.support.ImmediateFlipOrHostVMAndPStateWithMALLFullFrameOrPhantomPipe
8149 && !mode_lib->ms.support.InvalidCombinationOfMALLUseForPStateAndStaticScreen
8150 && mode_lib->ms.support.DSCCLKRequiredMoreThanSupported == false
8151 && mode_lib->ms.support.PixelsPerLinePerDSCUnitSupport
8152 && mode_lib->ms.support.DTBCLKRequiredMoreThanSupported == false
8153 && !mode_lib->ms.support.InvalidCombinationOfMALLUseForPState
8154 && !mode_lib->ms.support.ImmediateFlipRequiredButTheRequirementForEachSurfaceIsNotSpecified
8155 && mode_lib->ms.support.ROBSupport[j] == true
8156 && mode_lib->ms.support.DISPCLK_DPPCLK_Support[j] == true
8157 && mode_lib->ms.support.TotalAvailablePipesSupport[j] == true
8158 && mode_lib->ms.support.NumberOfOTGSupport == true
8159 && mode_lib->ms.support.NumberOfHDMIFRLSupport == true
8160 && mode_lib->ms.support.NumberOfDP2p0Support == true
8161 && mode_lib->ms.support.EnoughWritebackUnits == true
8162 && mode_lib->ms.support.WritebackLatencySupport == true
8163 && mode_lib->ms.support.WritebackScaleRatioAndTapsSupport == true
8164 && mode_lib->ms.support.CursorSupport == true
8165 && mode_lib->ms.support.PitchSupport == true
8166 && mode_lib->ms.support.ViewportExceedsSurface == false
8167 && mode_lib->ms.support.PrefetchSupported[j] == true
8168 && mode_lib->ms.support.VActiveBandwithSupport[j] == true
8169 && mode_lib->ms.support.DynamicMetadataSupported[j] == true
8170 && mode_lib->ms.support.TotalVerticalActiveBandwidthSupport[j] == true
8171 && mode_lib->ms.support.VRatioInPrefetchSupported[j] == true
8172 && mode_lib->ms.support.PTEBufferSizeNotExceeded[j] == true
8173 && mode_lib->ms.support.DCCMetaBufferSizeNotExceeded[j] == true
8174 && mode_lib->ms.support.NonsupportedDSCInputBPC == false
8175 && !mode_lib->ms.support.ExceededMALLSize
8176 && ((mode_lib->ms.cache_display_cfg.plane.HostVMEnable == false && !s->ImmediateFlipRequiredFinal) || mode_lib->ms.support.ImmediateFlipSupportedForState[j])
8177 && s->dram_clock_change_support == true
8178 && s->f_clock_change_support == true
8179 && (!mode_lib->ms.policy.USRRetrainingRequiredFinal || mode_lib->ms.support.USRRetrainingSupport[j])) {
8180 dml_print("DML::%s: mode is supported\n", __func__);
8181 mode_lib->ms.support.ModeSupport[j] = true;
8182 } else {
8183 dml_print("DML::%s: mode is NOT supported\n", __func__);
8184 mode_lib->ms.support.ModeSupport[j] = false;
8185 dml_print_mode_support(mode_lib, j);
8186 }
8187 }
8188
8189 mode_lib->ms.support.MaximumMPCCombine = 0;
8190 mode_lib->ms.support.ModeIsSupported = 0;
8191 if (mode_lib->ms.support.ModeSupport[0] == true || mode_lib->ms.support.ModeSupport[1] == true) { // if the mode is supported by either no combine or mpccombine
8192 mode_lib->ms.support.ModeIsSupported = mode_lib->ms.support.ModeSupport[0] == true || mode_lib->ms.support.ModeSupport[1] == true;
8193
8194 // Determine if MPC combine is necessary, depends on if using MPC combine will help dram clock change or fclk change, etc.
8195 if ((mode_lib->ms.support.ModeSupport[0] == false && mode_lib->ms.support.ModeSupport[1] == true) || s->MPCCombineMethodAsPossible ||
8196 (s->MPCCombineMethodAsNeededForPStateChangeAndVoltage && mode_lib->ms.policy.DRAMClockChangeRequirementFinal &&
8197 (((mode_lib->ms.support.DRAMClockChangeSupport[1] == dml_dram_clock_change_vactive || mode_lib->ms.support.DRAMClockChangeSupport[1] == dml_dram_clock_change_vactive_w_mall_full_frame || mode_lib->ms.support.DRAMClockChangeSupport[1] == dml_dram_clock_change_vactive_w_mall_sub_vp) &&
8198 !(mode_lib->ms.support.DRAMClockChangeSupport[0] == dml_dram_clock_change_vactive || mode_lib->ms.support.DRAMClockChangeSupport[0] == dml_dram_clock_change_vactive_w_mall_full_frame || mode_lib->ms.support.DRAMClockChangeSupport[0] == dml_dram_clock_change_vactive_w_mall_sub_vp)) ||
8199 ((mode_lib->ms.support.DRAMClockChangeSupport[1] == dml_dram_clock_change_vblank || mode_lib->ms.support.DRAMClockChangeSupport[1] == dml_dram_clock_change_vblank_drr
8200 || mode_lib->ms.support.DRAMClockChangeSupport[1] == dml_dram_clock_change_vblank_w_mall_full_frame || mode_lib->ms.support.DRAMClockChangeSupport[1] == dml_dram_clock_change_vblank_drr_w_mall_full_frame
8201 || mode_lib->ms.support.DRAMClockChangeSupport[1] == dml_dram_clock_change_vblank_w_mall_sub_vp || mode_lib->ms.support.DRAMClockChangeSupport[1] == dml_dram_clock_change_vblank_drr_w_mall_sub_vp
8202 ) &&
8203 mode_lib->ms.support.DRAMClockChangeSupport[0] == dml_dram_clock_change_unsupported)))
8204 || (s->MPCCombineMethodAsNeededForPStateChangeAndVoltage && mode_lib->ms.policy.FCLKChangeRequirementFinal &&
8205 ((mode_lib->ms.support.FCLKChangeSupport[1] == dml_fclock_change_vactive && mode_lib->ms.support.FCLKChangeSupport[0] != dml_fclock_change_vactive) ||
8206 (mode_lib->ms.support.FCLKChangeSupport[1] == dml_fclock_change_vblank && mode_lib->ms.support.FCLKChangeSupport[0] == dml_fclock_change_unsupported)))) {
8207 mode_lib->ms.support.MaximumMPCCombine = 1;
8208 } else {
8209 mode_lib->ms.support.MaximumMPCCombine = 0;
8210 }
8211 }
8212
8213 // Since now the mode_support work on 1 particular power state, so there is only 1 state idx (index 0).
8214 mode_lib->ms.support.ImmediateFlipSupport = mode_lib->ms.support.ImmediateFlipSupportedForState[mode_lib->ms.support.MaximumMPCCombine]; // Consider flip support if max combine support imm flip
8215 mode_lib->ms.support.UnboundedRequestEnabled = mode_lib->ms.UnboundedRequestEnabledAllStates[mode_lib->ms.support.MaximumMPCCombine]; // Not used, informational
8216 mode_lib->ms.support.CompressedBufferSizeInkByte = mode_lib->ms.CompressedBufferSizeInkByteAllStates[mode_lib->ms.support.MaximumMPCCombine]; // Not used, informational
8217
8218 dml_print("DML::%s: ModeIsSupported = %u\n", __func__, mode_lib->ms.support.ModeIsSupported);
8219 dml_print("DML::%s: MaximumMPCCombine = %u\n", __func__, mode_lib->ms.support.MaximumMPCCombine);
8220 dml_print("DML::%s: ImmediateFlipSupport = %u\n", __func__, mode_lib->ms.support.ImmediateFlipSupport);
8221 dml_print("DML::%s: UnboundedRequestEnabled = %u\n", __func__, mode_lib->ms.support.UnboundedRequestEnabled);
8222 dml_print("DML::%s: CompressedBufferSizeInkByte = %u\n", __func__, mode_lib->ms.support.CompressedBufferSizeInkByte);
8223
8224 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
8225 mode_lib->ms.support.MPCCombineEnable[k] = mode_lib->ms.MPCCombine[mode_lib->ms.support.MaximumMPCCombine][k];
8226 mode_lib->ms.support.DPPPerSurface[k] = mode_lib->ms.NoOfDPP[mode_lib->ms.support.MaximumMPCCombine][k];
8227 mode_lib->ms.SwathHeightY[k] = mode_lib->ms.SwathHeightYAllStates[mode_lib->ms.support.MaximumMPCCombine][k];
8228 mode_lib->ms.SwathHeightC[k] = mode_lib->ms.SwathHeightCAllStates[mode_lib->ms.support.MaximumMPCCombine][k];
8229 mode_lib->ms.DETBufferSizeInKByte[k] = mode_lib->ms.DETBufferSizeInKByteAllStates[mode_lib->ms.support.MaximumMPCCombine][k];
8230 mode_lib->ms.DETBufferSizeY[k] = mode_lib->ms.DETBufferSizeYAllStates[mode_lib->ms.support.MaximumMPCCombine][k];
8231 mode_lib->ms.DETBufferSizeC[k] = mode_lib->ms.DETBufferSizeCAllStates[mode_lib->ms.support.MaximumMPCCombine][k];
8232 }
8233
8234 mode_lib->ms.DRAMSpeed = mode_lib->ms.state.dram_speed_mts;
8235 mode_lib->ms.FabricClock = mode_lib->ms.state.fabricclk_mhz;
8236 mode_lib->ms.SOCCLK = mode_lib->ms.state.socclk_mhz;
8237 mode_lib->ms.DCFCLK = mode_lib->ms.DCFCLKState[mode_lib->ms.support.MaximumMPCCombine];
8238 mode_lib->ms.ReturnBW = mode_lib->ms.ReturnBWPerState[mode_lib->ms.support.MaximumMPCCombine];
8239 mode_lib->ms.ReturnDRAMBW = mode_lib->ms.ReturnDRAMBWPerState[mode_lib->ms.support.MaximumMPCCombine];
8240
8241 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
8242 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == k) {
8243 mode_lib->ms.support.ODMMode[k] = mode_lib->ms.ODMModePerState[k];
8244 } else {
8245 mode_lib->ms.support.ODMMode[k] = dml_odm_mode_bypass;
8246 }
8247
8248 mode_lib->ms.support.DSCEnabled[k] = mode_lib->ms.RequiresDSC[k];
8249 mode_lib->ms.support.FECEnabled[k] = mode_lib->ms.RequiresFEC[k];
8250 mode_lib->ms.support.OutputBpp[k] = mode_lib->ms.OutputBppPerState[k];
8251 mode_lib->ms.support.OutputType[k] = mode_lib->ms.OutputTypePerState[k];
8252 mode_lib->ms.support.OutputRate[k] = mode_lib->ms.OutputRatePerState[k];
8253 mode_lib->ms.support.SubViewportLinesNeededInMALL[k] = mode_lib->ms.SubViewportLinesNeededInMALL[k];
8254 }
8255
8256 return mode_lib->ms.support.ModeIsSupported;
8257 } // dml_core_mode_support
8258
8259 /// @brief This function calculates some parameters thats are needed ahead of the mode programming function all
dml_core_mode_support_partial(struct display_mode_lib_st * mode_lib)8260 void dml_core_mode_support_partial(struct display_mode_lib_st *mode_lib)
8261 {
8262 CalculateMaxDETAndMinCompressedBufferSize(
8263 mode_lib->ms.ip.config_return_buffer_size_in_kbytes,
8264 mode_lib->ms.ip.config_return_buffer_segment_size_in_kbytes,
8265 mode_lib->ms.ip.rob_buffer_size_kbytes,
8266 mode_lib->ms.ip.max_num_dpp,
8267 mode_lib->ms.policy.NomDETInKByteOverrideEnable,
8268 mode_lib->ms.policy.NomDETInKByteOverrideValue,
8269
8270 /* Output */
8271 &mode_lib->ms.MaxTotalDETInKByte,
8272 &mode_lib->ms.NomDETInKByte,
8273 &mode_lib->ms.MinCompressedBufferSizeInKByte);
8274
8275 PixelClockAdjustmentForProgressiveToInterlaceUnit(&mode_lib->ms.cache_display_cfg, mode_lib->ms.ip.ptoi_supported);
8276
8277 mode_lib->ms.ReturnBW = dml_get_return_bw_mbps(&mode_lib->ms.soc,
8278 mode_lib->ms.state.use_ideal_dram_bw_strobe,
8279 mode_lib->ms.cache_display_cfg.plane.HostVMEnable,
8280 mode_lib->ms.DCFCLK,
8281 mode_lib->ms.FabricClock,
8282 mode_lib->ms.DRAMSpeed);
8283 dml_print("DML::%s: ReturnBW = %f\n", __func__, mode_lib->ms.ReturnBW);
8284
8285 } // dml_core_mode_support_partial
8286
8287 /// @brief This is the mode programming function. It is assumed the display cfg is support at the given power state
dml_core_mode_programming(struct display_mode_lib_st * mode_lib,const struct dml_clk_cfg_st * clk_cfg)8288 void dml_core_mode_programming(struct display_mode_lib_st *mode_lib, const struct dml_clk_cfg_st *clk_cfg)
8289 {
8290 struct dml_core_mode_programming_locals_st *s = &mode_lib->scratch.dml_core_mode_programming_locals;
8291 struct CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_params_st *CalculateWatermarks_params = &mode_lib->scratch.CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_params;
8292 struct CalculateVMRowAndSwath_params_st *CalculateVMRowAndSwath_params = &mode_lib->scratch.CalculateVMRowAndSwath_params;
8293 struct CalculateSwathAndDETConfiguration_params_st *CalculateSwathAndDETConfiguration_params = &mode_lib->scratch.CalculateSwathAndDETConfiguration_params;
8294 struct CalculateStutterEfficiency_params_st *CalculateStutterEfficiency_params = &mode_lib->scratch.CalculateStutterEfficiency_params;
8295 struct CalculatePrefetchSchedule_params_st *CalculatePrefetchSchedule_params = &mode_lib->scratch.CalculatePrefetchSchedule_params;
8296
8297 struct mode_program_st *locals = &mode_lib->mp;
8298 struct DmlPipe *myPipe;
8299 dml_uint_t j = 0, k = 0;
8300 dml_float_t TWait;
8301 dml_bool_t isInterlaceTiming;
8302
8303 mode_lib->ms.num_active_planes = dml_get_num_active_planes(&mode_lib->ms.cache_display_cfg);
8304 mode_lib->mp.num_active_pipes = dml_get_num_active_pipes(&mode_lib->ms.cache_display_cfg);
8305 dml_calc_pipe_plane_mapping(&mode_lib->ms.cache_display_cfg.hw, mode_lib->mp.pipe_plane);
8306
8307 #ifdef __DML_VBA_DEBUG__
8308 dml_print("DML::%s: --- START --- \n", __func__);
8309 dml_print("DML::%s: num_active_planes = %u\n", __func__, mode_lib->ms.num_active_planes);
8310 dml_print("DML::%s: num_active_pipes = %u\n", __func__, mode_lib->mp.num_active_pipes);
8311 #endif
8312
8313 s->DSCFormatFactor = 0;
8314
8315 // Unlike dppclk and dispclk which can be calculated in mode_programming
8316 // DCFCLK is calculated in mode_support (which is the state bbox dcfclk or min dcfclk if min dcfclk option is used in mode support calculation)
8317 if (clk_cfg->dcfclk_option != dml_use_override_freq)
8318 locals->Dcfclk = mode_lib->ms.DCFCLK;
8319 else
8320 locals->Dcfclk = clk_cfg->dcfclk_freq_mhz;
8321
8322 #ifdef __DML_VBA_DEBUG__
8323 dml_print_dml_policy(&mode_lib->ms.policy);
8324 dml_print_soc_state_bounding_box(&mode_lib->ms.state);
8325 dml_print_soc_bounding_box(&mode_lib->ms.soc);
8326 dml_print_clk_cfg(clk_cfg);
8327
8328 dml_print("DML::%s: ImmediateFlipSupport = %u\n", __func__, mode_lib->ms.support.ImmediateFlipSupport);
8329 dml_print("DML::%s: Using DCFCLK = %f\n", __func__, locals->Dcfclk);
8330 dml_print("DML::%s: Using SOCCLK = %f\n", __func__, mode_lib->ms.SOCCLK);
8331 #endif
8332
8333 locals->WritebackDISPCLK = 0.0;
8334 locals->GlobalDPPCLK = 0.0;
8335
8336 // DISPCLK and DPPCLK Calculation
8337 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8338 if (mode_lib->ms.cache_display_cfg.writeback.WritebackEnable[k]) {
8339 locals->WritebackDISPCLK =
8340 dml_max(
8341 locals->WritebackDISPCLK,
8342 CalculateWriteBackDISPCLK(
8343 mode_lib->ms.cache_display_cfg.writeback.WritebackPixelFormat[k],
8344 mode_lib->ms.cache_display_cfg.timing.PixelClock[k],
8345 mode_lib->ms.cache_display_cfg.writeback.WritebackHRatio[k],
8346 mode_lib->ms.cache_display_cfg.writeback.WritebackVRatio[k],
8347 mode_lib->ms.cache_display_cfg.writeback.WritebackHTaps[k],
8348 mode_lib->ms.cache_display_cfg.writeback.WritebackVTaps[k],
8349 mode_lib->ms.cache_display_cfg.writeback.WritebackSourceWidth[k],
8350 mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationWidth[k],
8351 mode_lib->ms.cache_display_cfg.timing.HTotal[k],
8352 mode_lib->ms.ip.writeback_line_buffer_buffer_size,
8353 mode_lib->ms.soc.dispclk_dppclk_vco_speed_mhz));
8354 }
8355 }
8356
8357 locals->Dispclk_calculated = locals->WritebackDISPCLK;
8358
8359 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8360 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == k) {
8361 locals->Dispclk_calculated = dml_max(locals->Dispclk_calculated, CalculateRequiredDispclk(
8362 mode_lib->ms.cache_display_cfg.hw.ODMMode[k],
8363 mode_lib->ms.cache_display_cfg.timing.PixelClock[k],
8364 mode_lib->ms.soc.dcn_downspread_percent,
8365 mode_lib->ms.ip.dispclk_ramp_margin_percent,
8366 mode_lib->ms.soc.dispclk_dppclk_vco_speed_mhz,
8367 mode_lib->ms.max_state.dispclk_mhz));
8368 }
8369 }
8370 if (clk_cfg->dispclk_option == dml_use_required_freq)
8371 locals->Dispclk = locals->Dispclk_calculated;
8372 else if (clk_cfg->dispclk_option == dml_use_override_freq)
8373 locals->Dispclk = clk_cfg->dispclk_freq_mhz;
8374 else
8375 locals->Dispclk = mode_lib->ms.state.dispclk_mhz;
8376 #ifdef __DML_VBA_DEBUG__
8377 dml_print("DML::%s: Using Dispclk = %f\n", __func__, locals->Dispclk);
8378 #endif
8379
8380 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8381 CalculateSinglePipeDPPCLKAndSCLThroughput(
8382 mode_lib->ms.cache_display_cfg.plane.HRatio[k],
8383 mode_lib->ms.cache_display_cfg.plane.HRatioChroma[k],
8384 mode_lib->ms.cache_display_cfg.plane.VRatio[k],
8385 mode_lib->ms.cache_display_cfg.plane.VRatioChroma[k],
8386 mode_lib->ms.ip.max_dchub_pscl_bw_pix_per_clk,
8387 mode_lib->ms.ip.max_pscl_lb_bw_pix_per_clk,
8388 mode_lib->ms.cache_display_cfg.timing.PixelClock[k],
8389 mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k],
8390 mode_lib->ms.cache_display_cfg.plane.HTaps[k],
8391 mode_lib->ms.cache_display_cfg.plane.HTapsChroma[k],
8392 mode_lib->ms.cache_display_cfg.plane.VTaps[k],
8393 mode_lib->ms.cache_display_cfg.plane.VTapsChroma[k],
8394
8395 /* Output */
8396 &locals->PSCL_THROUGHPUT[k],
8397 &locals->PSCL_THROUGHPUT_CHROMA[k],
8398 &locals->DPPCLKUsingSingleDPP[k]);
8399 }
8400
8401 CalculateDPPCLK(mode_lib->ms.num_active_planes,
8402 mode_lib->ms.soc.dcn_downspread_percent,
8403 mode_lib->ms.soc.dispclk_dppclk_vco_speed_mhz,
8404 locals->DPPCLKUsingSingleDPP,
8405 mode_lib->ms.cache_display_cfg.hw.DPPPerSurface,
8406 /* Output */
8407 &locals->GlobalDPPCLK,
8408 locals->Dppclk_calculated);
8409
8410 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8411 if (clk_cfg->dppclk_option[k] == dml_use_required_freq)
8412 locals->Dppclk[k] = locals->Dppclk_calculated[k];
8413 else if (clk_cfg->dppclk_option[k] == dml_use_override_freq)
8414 locals->Dppclk[k] = clk_cfg->dppclk_freq_mhz[k];
8415 else
8416 locals->Dppclk[k] = mode_lib->ms.state.dppclk_mhz;
8417 #ifdef __DML_VBA_DEBUG__
8418 dml_print("DML::%s: Using Dppclk[%0d] = %f\n", __func__, k, locals->Dppclk[k]);
8419 #endif
8420 }
8421
8422 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8423 CalculateBytePerPixelAndBlockSizes(
8424 mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k],
8425 mode_lib->ms.cache_display_cfg.surface.SurfaceTiling[k],
8426
8427 /* Output */
8428 &locals->BytePerPixelY[k],
8429 &locals->BytePerPixelC[k],
8430 &locals->BytePerPixelDETY[k],
8431 &locals->BytePerPixelDETC[k],
8432 &locals->BlockHeight256BytesY[k],
8433 &locals->BlockHeight256BytesC[k],
8434 &locals->BlockWidth256BytesY[k],
8435 &locals->BlockWidth256BytesC[k],
8436 &locals->BlockHeightY[k],
8437 &locals->BlockHeightC[k],
8438 &locals->BlockWidthY[k],
8439 &locals->BlockWidthC[k]);
8440 }
8441
8442
8443 dml_print("DML::%s: %u\n", __func__, __LINE__);
8444 CalculateSwathWidth(
8445 false, // ForceSingleDPP
8446 mode_lib->ms.num_active_planes,
8447 mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat,
8448 mode_lib->ms.cache_display_cfg.plane.SourceScan,
8449 mode_lib->ms.cache_display_cfg.plane.ViewportStationary,
8450 mode_lib->ms.cache_display_cfg.plane.ViewportWidth,
8451 mode_lib->ms.cache_display_cfg.plane.ViewportHeight,
8452 mode_lib->ms.cache_display_cfg.plane.ViewportXStart,
8453 mode_lib->ms.cache_display_cfg.plane.ViewportYStart,
8454 mode_lib->ms.cache_display_cfg.plane.ViewportXStartC,
8455 mode_lib->ms.cache_display_cfg.plane.ViewportYStartC,
8456 mode_lib->ms.cache_display_cfg.surface.SurfaceWidthY,
8457 mode_lib->ms.cache_display_cfg.surface.SurfaceWidthC,
8458 mode_lib->ms.cache_display_cfg.surface.SurfaceHeightY,
8459 mode_lib->ms.cache_display_cfg.surface.SurfaceHeightC,
8460 mode_lib->ms.cache_display_cfg.hw.ODMMode,
8461 locals->BytePerPixelY,
8462 locals->BytePerPixelC,
8463 locals->BlockHeight256BytesY,
8464 locals->BlockHeight256BytesC,
8465 locals->BlockWidth256BytesY,
8466 locals->BlockWidth256BytesC,
8467 mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming,
8468 mode_lib->ms.cache_display_cfg.timing.HActive,
8469 mode_lib->ms.cache_display_cfg.plane.HRatio,
8470 mode_lib->ms.cache_display_cfg.hw.DPPPerSurface,
8471
8472 /* Output */
8473 locals->SwathWidthSingleDPPY,
8474 locals->SwathWidthSingleDPPC,
8475 locals->SwathWidthY,
8476 locals->SwathWidthC,
8477 s->dummy_integer_array[0], // dml_uint_t MaximumSwathHeightY[]
8478 s->dummy_integer_array[1], // dml_uint_t MaximumSwathHeightC[]
8479 locals->swath_width_luma_ub,
8480 locals->swath_width_chroma_ub);
8481
8482 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8483 locals->ReadBandwidthSurfaceLuma[k] = locals->SwathWidthSingleDPPY[k] * locals->BytePerPixelY[k] / (mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k]) * mode_lib->ms.cache_display_cfg.plane.VRatio[k];
8484 locals->ReadBandwidthSurfaceChroma[k] = locals->SwathWidthSingleDPPC[k] * locals->BytePerPixelC[k] / (mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k]) * mode_lib->ms.cache_display_cfg.plane.VRatioChroma[k];
8485 dml_print("DML::%s: ReadBandwidthSurfaceLuma[%i] = %fBps\n", __func__, k, locals->ReadBandwidthSurfaceLuma[k]);
8486 dml_print("DML::%s: ReadBandwidthSurfaceChroma[%i] = %fBps\n", __func__, k, locals->ReadBandwidthSurfaceChroma[k]);
8487 }
8488
8489 CalculateSwathAndDETConfiguration_params->DETSizeOverride = mode_lib->ms.cache_display_cfg.plane.DETSizeOverride;
8490 CalculateSwathAndDETConfiguration_params->UseMALLForPStateChange = mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange;
8491 CalculateSwathAndDETConfiguration_params->ConfigReturnBufferSizeInKByte = mode_lib->ms.ip.config_return_buffer_size_in_kbytes;
8492 CalculateSwathAndDETConfiguration_params->ROBBufferSizeInKByte = mode_lib->ms.ip.rob_buffer_size_kbytes;
8493 CalculateSwathAndDETConfiguration_params->MaxTotalDETInKByte = mode_lib->ms.MaxTotalDETInKByte;
8494 CalculateSwathAndDETConfiguration_params->MinCompressedBufferSizeInKByte = mode_lib->ms.MinCompressedBufferSizeInKByte;
8495 CalculateSwathAndDETConfiguration_params->PixelChunkSizeInKByte = mode_lib->ms.ip.pixel_chunk_size_kbytes;
8496 CalculateSwathAndDETConfiguration_params->ForceSingleDPP = false;
8497 CalculateSwathAndDETConfiguration_params->NumberOfActiveSurfaces = mode_lib->ms.num_active_planes;
8498 CalculateSwathAndDETConfiguration_params->nomDETInKByte = mode_lib->ms.NomDETInKByte;
8499 CalculateSwathAndDETConfiguration_params->UseUnboundedRequestingFinal = mode_lib->ms.policy.UseUnboundedRequesting;
8500 CalculateSwathAndDETConfiguration_params->ConfigReturnBufferSegmentSizeInkByte = mode_lib->ms.ip.config_return_buffer_segment_size_in_kbytes;
8501 CalculateSwathAndDETConfiguration_params->CompressedBufferSegmentSizeInkByteFinal = mode_lib->ms.ip.compressed_buffer_segment_size_in_kbytes;
8502 CalculateSwathAndDETConfiguration_params->Output = s->dummy_output_encoder_array;
8503 CalculateSwathAndDETConfiguration_params->ReadBandwidthLuma = locals->ReadBandwidthSurfaceLuma;
8504 CalculateSwathAndDETConfiguration_params->ReadBandwidthChroma = locals->ReadBandwidthSurfaceChroma;
8505 CalculateSwathAndDETConfiguration_params->MaximumSwathWidthLuma = s->dummy_single_array[0];
8506 CalculateSwathAndDETConfiguration_params->MaximumSwathWidthChroma = s->dummy_single_array[1];
8507 CalculateSwathAndDETConfiguration_params->SourceScan = mode_lib->ms.cache_display_cfg.plane.SourceScan;
8508 CalculateSwathAndDETConfiguration_params->ViewportStationary = mode_lib->ms.cache_display_cfg.plane.ViewportStationary;
8509 CalculateSwathAndDETConfiguration_params->SourcePixelFormat = mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat;
8510 CalculateSwathAndDETConfiguration_params->SurfaceTiling = mode_lib->ms.cache_display_cfg.surface.SurfaceTiling;
8511 CalculateSwathAndDETConfiguration_params->ViewportWidth = mode_lib->ms.cache_display_cfg.plane.ViewportWidth;
8512 CalculateSwathAndDETConfiguration_params->ViewportHeight = mode_lib->ms.cache_display_cfg.plane.ViewportHeight;
8513 CalculateSwathAndDETConfiguration_params->ViewportXStart = mode_lib->ms.cache_display_cfg.plane.ViewportXStart;
8514 CalculateSwathAndDETConfiguration_params->ViewportYStart = mode_lib->ms.cache_display_cfg.plane.ViewportYStart;
8515 CalculateSwathAndDETConfiguration_params->ViewportXStartC = mode_lib->ms.cache_display_cfg.plane.ViewportXStartC;
8516 CalculateSwathAndDETConfiguration_params->ViewportYStartC = mode_lib->ms.cache_display_cfg.plane.ViewportYStartC;
8517 CalculateSwathAndDETConfiguration_params->SurfaceWidthY = mode_lib->ms.cache_display_cfg.surface.SurfaceWidthY;
8518 CalculateSwathAndDETConfiguration_params->SurfaceWidthC = mode_lib->ms.cache_display_cfg.surface.SurfaceWidthC;
8519 CalculateSwathAndDETConfiguration_params->SurfaceHeightY = mode_lib->ms.cache_display_cfg.surface.SurfaceHeightY;
8520 CalculateSwathAndDETConfiguration_params->SurfaceHeightC = mode_lib->ms.cache_display_cfg.surface.SurfaceHeightC;
8521 CalculateSwathAndDETConfiguration_params->Read256BytesBlockHeightY = locals->BlockHeight256BytesY;
8522 CalculateSwathAndDETConfiguration_params->Read256BytesBlockHeightC = locals->BlockHeight256BytesC;
8523 CalculateSwathAndDETConfiguration_params->Read256BytesBlockWidthY = locals->BlockWidth256BytesY;
8524 CalculateSwathAndDETConfiguration_params->Read256BytesBlockWidthC = locals->BlockWidth256BytesC;
8525 CalculateSwathAndDETConfiguration_params->ODMMode = mode_lib->ms.cache_display_cfg.hw.ODMMode;
8526 CalculateSwathAndDETConfiguration_params->BlendingAndTiming = mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming;
8527 CalculateSwathAndDETConfiguration_params->BytePerPixY = locals->BytePerPixelY;
8528 CalculateSwathAndDETConfiguration_params->BytePerPixC = locals->BytePerPixelC;
8529 CalculateSwathAndDETConfiguration_params->BytePerPixDETY = locals->BytePerPixelDETY;
8530 CalculateSwathAndDETConfiguration_params->BytePerPixDETC = locals->BytePerPixelDETC;
8531 CalculateSwathAndDETConfiguration_params->HActive = mode_lib->ms.cache_display_cfg.timing.HActive;
8532 CalculateSwathAndDETConfiguration_params->HRatio = mode_lib->ms.cache_display_cfg.plane.HRatio;
8533 CalculateSwathAndDETConfiguration_params->HRatioChroma = mode_lib->ms.cache_display_cfg.plane.HRatioChroma;
8534 CalculateSwathAndDETConfiguration_params->DPPPerSurface = mode_lib->ms.cache_display_cfg.hw.DPPPerSurface;
8535 CalculateSwathAndDETConfiguration_params->swath_width_luma_ub = s->dummy_long_array[0];
8536 CalculateSwathAndDETConfiguration_params->swath_width_chroma_ub = s->dummy_long_array[1];
8537 CalculateSwathAndDETConfiguration_params->SwathWidth = s->dummy_long_array[2];
8538 CalculateSwathAndDETConfiguration_params->SwathWidthChroma = s->dummy_long_array[3];
8539 CalculateSwathAndDETConfiguration_params->SwathHeightY = locals->SwathHeightY;
8540 CalculateSwathAndDETConfiguration_params->SwathHeightC = locals->SwathHeightC;
8541 CalculateSwathAndDETConfiguration_params->DETBufferSizeInKByte = locals->DETBufferSizeInKByte;
8542 CalculateSwathAndDETConfiguration_params->DETBufferSizeY = locals->DETBufferSizeY;
8543 CalculateSwathAndDETConfiguration_params->DETBufferSizeC = locals->DETBufferSizeC;
8544 CalculateSwathAndDETConfiguration_params->UnboundedRequestEnabled = &locals->UnboundedRequestEnabled;
8545 CalculateSwathAndDETConfiguration_params->compbuf_reserved_space_64b = &locals->compbuf_reserved_space_64b;
8546 CalculateSwathAndDETConfiguration_params->compbuf_reserved_space_zs = &locals->compbuf_reserved_space_zs;
8547 CalculateSwathAndDETConfiguration_params->CompressedBufferSizeInkByte = &locals->CompressedBufferSizeInkByte;
8548 CalculateSwathAndDETConfiguration_params->ViewportSizeSupportPerSurface = &s->dummy_boolean_array[0][0];
8549 CalculateSwathAndDETConfiguration_params->ViewportSizeSupport = &s->dummy_boolean[0];
8550
8551 // VBA_DELTA
8552 // Calculate DET size, swath height here. In VBA, they are calculated in mode check stage
8553 CalculateSwathAndDETConfiguration(&mode_lib->scratch,
8554 CalculateSwathAndDETConfiguration_params);
8555
8556 // DCFCLK Deep Sleep
8557 CalculateDCFCLKDeepSleep(
8558 mode_lib->ms.num_active_planes,
8559 locals->BytePerPixelY,
8560 locals->BytePerPixelC,
8561 mode_lib->ms.cache_display_cfg.plane.VRatio,
8562 mode_lib->ms.cache_display_cfg.plane.VRatioChroma,
8563 locals->SwathWidthY,
8564 locals->SwathWidthC,
8565 mode_lib->ms.cache_display_cfg.hw.DPPPerSurface,
8566 mode_lib->ms.cache_display_cfg.plane.HRatio,
8567 mode_lib->ms.cache_display_cfg.plane.HRatioChroma,
8568 mode_lib->ms.cache_display_cfg.timing.PixelClock,
8569 locals->PSCL_THROUGHPUT,
8570 locals->PSCL_THROUGHPUT_CHROMA,
8571 locals->Dppclk,
8572 locals->ReadBandwidthSurfaceLuma,
8573 locals->ReadBandwidthSurfaceChroma,
8574 mode_lib->ms.soc.return_bus_width_bytes,
8575
8576 /* Output */
8577 &locals->DCFCLKDeepSleep);
8578
8579 // DSCCLK
8580 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8581 if ((mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] != k) || !mode_lib->ms.cache_display_cfg.hw.DSCEnabled[k]) {
8582 locals->DSCCLK_calculated[k] = 0.0;
8583 } else {
8584 if (mode_lib->ms.cache_display_cfg.output.OutputFormat[k] == dml_420)
8585 s->DSCFormatFactor = 2;
8586 else if (mode_lib->ms.cache_display_cfg.output.OutputFormat[k] == dml_444)
8587 s->DSCFormatFactor = 1;
8588 else if (mode_lib->ms.cache_display_cfg.output.OutputFormat[k] == dml_n422 || mode_lib->ms.cache_display_cfg.output.OutputEncoder[k] == dml_hdmifrl)
8589 s->DSCFormatFactor = 2;
8590 else
8591 s->DSCFormatFactor = 1;
8592 if (mode_lib->ms.cache_display_cfg.hw.ODMMode[k] == dml_odm_mode_combine_4to1)
8593 locals->DSCCLK_calculated[k] = mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k] / 12 / s->DSCFormatFactor / (1 - mode_lib->ms.soc.dcn_downspread_percent / 100);
8594 else if (mode_lib->ms.cache_display_cfg.hw.ODMMode[k] == dml_odm_mode_combine_2to1)
8595 locals->DSCCLK_calculated[k] = mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k] / 6 / s->DSCFormatFactor / (1 - mode_lib->ms.soc.dcn_downspread_percent / 100);
8596 else
8597 locals->DSCCLK_calculated[k] = mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k] / 3 / s->DSCFormatFactor / (1 - mode_lib->ms.soc.dcn_downspread_percent / 100);
8598 }
8599 }
8600
8601 // DSC Delay
8602 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8603 locals->DSCDelay[k] = DSCDelayRequirement(mode_lib->ms.cache_display_cfg.hw.DSCEnabled[k],
8604 mode_lib->ms.cache_display_cfg.hw.ODMMode[k],
8605 mode_lib->ms.cache_display_cfg.output.DSCInputBitPerComponent[k],
8606 mode_lib->ms.cache_display_cfg.output.OutputBpp[k],
8607 mode_lib->ms.cache_display_cfg.timing.HActive[k],
8608 mode_lib->ms.cache_display_cfg.timing.HTotal[k],
8609 mode_lib->ms.cache_display_cfg.hw.NumberOfDSCSlices[k],
8610 mode_lib->ms.cache_display_cfg.output.OutputFormat[k],
8611 mode_lib->ms.cache_display_cfg.output.OutputEncoder[k],
8612 mode_lib->ms.cache_display_cfg.timing.PixelClock[k],
8613 mode_lib->ms.cache_display_cfg.output.PixelClockBackEnd[k]);
8614 }
8615
8616 for (k = 0; k < mode_lib->ms.num_active_planes; ++k)
8617 for (j = 0; j < mode_lib->ms.num_active_planes; ++j) // NumberOfSurfaces
8618 if (j != k && mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == j && mode_lib->ms.cache_display_cfg.hw.DSCEnabled[j])
8619 locals->DSCDelay[k] = locals->DSCDelay[j];
8620
8621 // Prefetch
8622 CalculateSurfaceSizeInMall(
8623 mode_lib->ms.num_active_planes,
8624 mode_lib->ms.soc.mall_allocated_for_dcn_mbytes,
8625 mode_lib->ms.cache_display_cfg.plane.UseMALLForStaticScreen,
8626 mode_lib->ms.cache_display_cfg.surface.DCCEnable,
8627 mode_lib->ms.cache_display_cfg.plane.ViewportStationary,
8628 mode_lib->ms.cache_display_cfg.plane.ViewportXStart,
8629 mode_lib->ms.cache_display_cfg.plane.ViewportYStart,
8630 mode_lib->ms.cache_display_cfg.plane.ViewportXStartC,
8631 mode_lib->ms.cache_display_cfg.plane.ViewportYStartC,
8632 mode_lib->ms.cache_display_cfg.plane.ViewportWidth,
8633 mode_lib->ms.cache_display_cfg.plane.ViewportHeight,
8634 locals->BytePerPixelY,
8635 mode_lib->ms.cache_display_cfg.plane.ViewportWidthChroma,
8636 mode_lib->ms.cache_display_cfg.plane.ViewportHeightChroma,
8637 locals->BytePerPixelC,
8638 mode_lib->ms.cache_display_cfg.surface.SurfaceWidthY,
8639 mode_lib->ms.cache_display_cfg.surface.SurfaceWidthC,
8640 mode_lib->ms.cache_display_cfg.surface.SurfaceHeightY,
8641 mode_lib->ms.cache_display_cfg.surface.SurfaceHeightC,
8642 locals->BlockWidth256BytesY,
8643 locals->BlockWidth256BytesC,
8644 locals->BlockHeight256BytesY,
8645 locals->BlockHeight256BytesC,
8646 locals->BlockWidthY,
8647 locals->BlockWidthC,
8648 locals->BlockHeightY,
8649 locals->BlockHeightC,
8650
8651 /* Output */
8652 locals->SurfaceSizeInTheMALL,
8653 &s->dummy_boolean[0]); /* dml_bool_t *ExceededMALLSize */
8654
8655 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8656 s->SurfaceParameters[k].PixelClock = mode_lib->ms.cache_display_cfg.timing.PixelClock[k];
8657 s->SurfaceParameters[k].DPPPerSurface = mode_lib->ms.cache_display_cfg.hw.DPPPerSurface[k];
8658 s->SurfaceParameters[k].SourceScan = mode_lib->ms.cache_display_cfg.plane.SourceScan[k];
8659 s->SurfaceParameters[k].ViewportHeight = mode_lib->ms.cache_display_cfg.plane.ViewportHeight[k];
8660 s->SurfaceParameters[k].ViewportHeightChroma = mode_lib->ms.cache_display_cfg.plane.ViewportHeightChroma[k];
8661 s->SurfaceParameters[k].BlockWidth256BytesY = locals->BlockWidth256BytesY[k];
8662 s->SurfaceParameters[k].BlockHeight256BytesY = locals->BlockHeight256BytesY[k];
8663 s->SurfaceParameters[k].BlockWidth256BytesC = locals->BlockWidth256BytesC[k];
8664 s->SurfaceParameters[k].BlockHeight256BytesC = locals->BlockHeight256BytesC[k];
8665 s->SurfaceParameters[k].BlockWidthY = locals->BlockWidthY[k];
8666 s->SurfaceParameters[k].BlockHeightY = locals->BlockHeightY[k];
8667 s->SurfaceParameters[k].BlockWidthC = locals->BlockWidthC[k];
8668 s->SurfaceParameters[k].BlockHeightC = locals->BlockHeightC[k];
8669 s->SurfaceParameters[k].InterlaceEnable = mode_lib->ms.cache_display_cfg.timing.Interlace[k];
8670 s->SurfaceParameters[k].HTotal = mode_lib->ms.cache_display_cfg.timing.HTotal[k];
8671 s->SurfaceParameters[k].DCCEnable = mode_lib->ms.cache_display_cfg.surface.DCCEnable[k];
8672 s->SurfaceParameters[k].SourcePixelFormat = mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k];
8673 s->SurfaceParameters[k].SurfaceTiling = mode_lib->ms.cache_display_cfg.surface.SurfaceTiling[k];
8674 s->SurfaceParameters[k].BytePerPixelY = locals->BytePerPixelY[k];
8675 s->SurfaceParameters[k].BytePerPixelC = locals->BytePerPixelC[k];
8676 s->SurfaceParameters[k].ProgressiveToInterlaceUnitInOPP = mode_lib->ms.ip.ptoi_supported;
8677 s->SurfaceParameters[k].VRatio = mode_lib->ms.cache_display_cfg.plane.VRatio[k];
8678 s->SurfaceParameters[k].VRatioChroma = mode_lib->ms.cache_display_cfg.plane.VRatioChroma[k];
8679 s->SurfaceParameters[k].VTaps = mode_lib->ms.cache_display_cfg.plane.VTaps[k];
8680 s->SurfaceParameters[k].VTapsChroma = mode_lib->ms.cache_display_cfg.plane.VTapsChroma[k];
8681 s->SurfaceParameters[k].PitchY = mode_lib->ms.cache_display_cfg.surface.PitchY[k];
8682 s->SurfaceParameters[k].DCCMetaPitchY = mode_lib->ms.cache_display_cfg.surface.DCCMetaPitchY[k];
8683 s->SurfaceParameters[k].PitchC = mode_lib->ms.cache_display_cfg.surface.PitchC[k];
8684 s->SurfaceParameters[k].DCCMetaPitchC = mode_lib->ms.cache_display_cfg.surface.DCCMetaPitchC[k];
8685 s->SurfaceParameters[k].ViewportStationary = mode_lib->ms.cache_display_cfg.plane.ViewportStationary[k];
8686 s->SurfaceParameters[k].ViewportXStart = mode_lib->ms.cache_display_cfg.plane.ViewportXStart[k];
8687 s->SurfaceParameters[k].ViewportYStart = mode_lib->ms.cache_display_cfg.plane.ViewportYStart[k];
8688 s->SurfaceParameters[k].ViewportXStartC = mode_lib->ms.cache_display_cfg.plane.ViewportXStartC[k];
8689 s->SurfaceParameters[k].ViewportYStartC = mode_lib->ms.cache_display_cfg.plane.ViewportYStartC[k];
8690 s->SurfaceParameters[k].FORCE_ONE_ROW_FOR_FRAME = mode_lib->ms.cache_display_cfg.plane.ForceOneRowForFrame[k];
8691 s->SurfaceParameters[k].SwathHeightY = locals->SwathHeightY[k];
8692 s->SurfaceParameters[k].SwathHeightC = locals->SwathHeightC[k];
8693 }
8694
8695 CalculateVMRowAndSwath_params->NumberOfActiveSurfaces = mode_lib->ms.num_active_planes;
8696 CalculateVMRowAndSwath_params->myPipe = s->SurfaceParameters;
8697 CalculateVMRowAndSwath_params->SurfaceSizeInMALL = locals->SurfaceSizeInTheMALL;
8698 CalculateVMRowAndSwath_params->PTEBufferSizeInRequestsLuma = mode_lib->ms.ip.dpte_buffer_size_in_pte_reqs_luma;
8699 CalculateVMRowAndSwath_params->PTEBufferSizeInRequestsChroma = mode_lib->ms.ip.dpte_buffer_size_in_pte_reqs_chroma;
8700 CalculateVMRowAndSwath_params->DCCMetaBufferSizeBytes = mode_lib->ms.ip.dcc_meta_buffer_size_bytes;
8701 CalculateVMRowAndSwath_params->UseMALLForStaticScreen = mode_lib->ms.cache_display_cfg.plane.UseMALLForStaticScreen;
8702 CalculateVMRowAndSwath_params->UseMALLForPStateChange = mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange;
8703 CalculateVMRowAndSwath_params->MALLAllocatedForDCN = mode_lib->ms.soc.mall_allocated_for_dcn_mbytes;
8704 CalculateVMRowAndSwath_params->SwathWidthY = locals->SwathWidthY;
8705 CalculateVMRowAndSwath_params->SwathWidthC = locals->SwathWidthC;
8706 CalculateVMRowAndSwath_params->GPUVMEnable = mode_lib->ms.cache_display_cfg.plane.GPUVMEnable;
8707 CalculateVMRowAndSwath_params->HostVMEnable = mode_lib->ms.cache_display_cfg.plane.HostVMEnable;
8708 CalculateVMRowAndSwath_params->HostVMMaxNonCachedPageTableLevels = mode_lib->ms.cache_display_cfg.plane.HostVMMaxPageTableLevels;
8709 CalculateVMRowAndSwath_params->GPUVMMaxPageTableLevels = mode_lib->ms.cache_display_cfg.plane.GPUVMMaxPageTableLevels;
8710 CalculateVMRowAndSwath_params->GPUVMMinPageSizeKBytes = mode_lib->ms.cache_display_cfg.plane.GPUVMMinPageSizeKBytes;
8711 CalculateVMRowAndSwath_params->HostVMMinPageSize = mode_lib->ms.soc.hostvm_min_page_size_kbytes * 1024;
8712 CalculateVMRowAndSwath_params->PTEBufferModeOverrideEn = mode_lib->ms.cache_display_cfg.plane.PTEBufferModeOverrideEn;
8713 CalculateVMRowAndSwath_params->PTEBufferModeOverrideVal = mode_lib->ms.cache_display_cfg.plane.PTEBufferMode;
8714 CalculateVMRowAndSwath_params->PTEBufferSizeNotExceeded = s->dummy_boolean_array[0];
8715 CalculateVMRowAndSwath_params->DCCMetaBufferSizeNotExceeded = s->dummy_boolean_array[1];
8716 CalculateVMRowAndSwath_params->dpte_row_width_luma_ub = locals->dpte_row_width_luma_ub;
8717 CalculateVMRowAndSwath_params->dpte_row_width_chroma_ub = locals->dpte_row_width_chroma_ub;
8718 CalculateVMRowAndSwath_params->dpte_row_height_luma = locals->dpte_row_height;
8719 CalculateVMRowAndSwath_params->dpte_row_height_chroma = locals->dpte_row_height_chroma;
8720 CalculateVMRowAndSwath_params->dpte_row_height_linear_luma = locals->dpte_row_height_linear;
8721 CalculateVMRowAndSwath_params->dpte_row_height_linear_chroma = locals->dpte_row_height_linear_chroma;
8722 CalculateVMRowAndSwath_params->meta_req_width = locals->meta_req_width;
8723 CalculateVMRowAndSwath_params->meta_req_width_chroma = locals->meta_req_width_chroma;
8724 CalculateVMRowAndSwath_params->meta_req_height = locals->meta_req_height;
8725 CalculateVMRowAndSwath_params->meta_req_height_chroma = locals->meta_req_height_chroma;
8726 CalculateVMRowAndSwath_params->meta_row_width = locals->meta_row_width;
8727 CalculateVMRowAndSwath_params->meta_row_width_chroma = locals->meta_row_width_chroma;
8728 CalculateVMRowAndSwath_params->meta_row_height = locals->meta_row_height;
8729 CalculateVMRowAndSwath_params->meta_row_height_chroma = locals->meta_row_height_chroma;
8730 CalculateVMRowAndSwath_params->vm_group_bytes = locals->vm_group_bytes;
8731 CalculateVMRowAndSwath_params->dpte_group_bytes = locals->dpte_group_bytes;
8732 CalculateVMRowAndSwath_params->PixelPTEReqWidthY = locals->PixelPTEReqWidthY;
8733 CalculateVMRowAndSwath_params->PixelPTEReqHeightY = locals->PixelPTEReqHeightY;
8734 CalculateVMRowAndSwath_params->PTERequestSizeY = locals->PTERequestSizeY;
8735 CalculateVMRowAndSwath_params->PixelPTEReqWidthC = locals->PixelPTEReqWidthC;
8736 CalculateVMRowAndSwath_params->PixelPTEReqHeightC = locals->PixelPTEReqHeightC;
8737 CalculateVMRowAndSwath_params->PTERequestSizeC = locals->PTERequestSizeC;
8738 CalculateVMRowAndSwath_params->dpde0_bytes_per_frame_ub_l = locals->dpde0_bytes_per_frame_ub_l;
8739 CalculateVMRowAndSwath_params->meta_pte_bytes_per_frame_ub_l = locals->meta_pte_bytes_per_frame_ub_l;
8740 CalculateVMRowAndSwath_params->dpde0_bytes_per_frame_ub_c = locals->dpde0_bytes_per_frame_ub_c;
8741 CalculateVMRowAndSwath_params->meta_pte_bytes_per_frame_ub_c = locals->meta_pte_bytes_per_frame_ub_c;
8742 CalculateVMRowAndSwath_params->PrefetchSourceLinesY = locals->PrefetchSourceLinesY;
8743 CalculateVMRowAndSwath_params->PrefetchSourceLinesC = locals->PrefetchSourceLinesC;
8744 CalculateVMRowAndSwath_params->VInitPreFillY = locals->VInitPreFillY;
8745 CalculateVMRowAndSwath_params->VInitPreFillC = locals->VInitPreFillC;
8746 CalculateVMRowAndSwath_params->MaxNumSwathY = locals->MaxNumSwathY;
8747 CalculateVMRowAndSwath_params->MaxNumSwathC = locals->MaxNumSwathC;
8748 CalculateVMRowAndSwath_params->meta_row_bw = locals->meta_row_bw;
8749 CalculateVMRowAndSwath_params->dpte_row_bw = locals->dpte_row_bw;
8750 CalculateVMRowAndSwath_params->PixelPTEBytesPerRow = locals->PixelPTEBytesPerRow;
8751 CalculateVMRowAndSwath_params->PDEAndMetaPTEBytesFrame = locals->PDEAndMetaPTEBytesFrame;
8752 CalculateVMRowAndSwath_params->MetaRowByte = locals->MetaRowByte;
8753 CalculateVMRowAndSwath_params->use_one_row_for_frame = locals->use_one_row_for_frame;
8754 CalculateVMRowAndSwath_params->use_one_row_for_frame_flip = locals->use_one_row_for_frame_flip;
8755 CalculateVMRowAndSwath_params->UsesMALLForStaticScreen = locals->UsesMALLForStaticScreen;
8756 CalculateVMRowAndSwath_params->PTE_BUFFER_MODE = locals->PTE_BUFFER_MODE;
8757 CalculateVMRowAndSwath_params->BIGK_FRAGMENT_SIZE = locals->BIGK_FRAGMENT_SIZE;
8758
8759 CalculateVMRowAndSwath(&mode_lib->scratch,
8760 CalculateVMRowAndSwath_params);
8761
8762 s->ReorderBytes = (dml_uint_t)(mode_lib->ms.soc.num_chans * dml_max3(
8763 mode_lib->ms.soc.urgent_out_of_order_return_per_channel_pixel_only_bytes,
8764 mode_lib->ms.soc.urgent_out_of_order_return_per_channel_pixel_and_vm_bytes,
8765 mode_lib->ms.soc.urgent_out_of_order_return_per_channel_vm_only_bytes));
8766
8767 s->VMDataOnlyReturnBW = dml_get_return_bw_mbps_vm_only(&mode_lib->ms.soc,
8768 mode_lib->ms.state.use_ideal_dram_bw_strobe,
8769 mode_lib->ms.cache_display_cfg.plane.HostVMEnable,
8770 locals->Dcfclk,
8771 mode_lib->ms.FabricClock,
8772 mode_lib->ms.DRAMSpeed);
8773
8774 #ifdef __DML_VBA_DEBUG__
8775 dml_print("DML::%s: locals->Dcfclk = %f\n", __func__, locals->Dcfclk);
8776 dml_print("DML::%s: mode_lib->ms.soc.return_bus_width_bytes = %u\n", __func__, mode_lib->ms.soc.return_bus_width_bytes);
8777 dml_print("DML::%s: mode_lib->ms.FabricClock = %f\n", __func__, mode_lib->ms.FabricClock);
8778 dml_print("DML::%s: mode_lib->ms.soc.fabric_datapath_to_dcn_data_return_bytes = %u\n", __func__, mode_lib->ms.soc.fabric_datapath_to_dcn_data_return_bytes);
8779 dml_print("DML::%s: mode_lib->ms.soc.pct_ideal_sdp_bw_after_urgent = %f\n", __func__, mode_lib->ms.soc.pct_ideal_sdp_bw_after_urgent);
8780 dml_print("DML::%s: mode_lib->ms.DRAMSpeed = %f\n", __func__, mode_lib->ms.DRAMSpeed);
8781 dml_print("DML::%s: mode_lib->ms.soc.num_chans = %u\n", __func__, mode_lib->ms.soc.num_chans);
8782 dml_print("DML::%s: mode_lib->ms.soc.dram_channel_width_bytes = %u\n", __func__, mode_lib->ms.soc.dram_channel_width_bytes);
8783 dml_print("DML::%s: mode_lib->ms.state_idx = %u\n", __func__, mode_lib->ms.state_idx);
8784 dml_print("DML::%s: mode_lib->ms.max_state_idx = %u\n", __func__, mode_lib->ms.max_state_idx);
8785 dml_print("DML::%s: mode_lib->ms.state.use_ideal_dram_bw_strobe = %u\n", __func__, mode_lib->ms.state.use_ideal_dram_bw_strobe);
8786 dml_print("DML::%s: VMDataOnlyReturnBW = %f\n", __func__, s->VMDataOnlyReturnBW);
8787 dml_print("DML::%s: ReturnBW = %f\n", __func__, mode_lib->ms.ReturnBW);
8788 #endif
8789
8790 s->HostVMInefficiencyFactor = 1.0;
8791 if (mode_lib->ms.cache_display_cfg.plane.GPUVMEnable && mode_lib->ms.cache_display_cfg.plane.HostVMEnable)
8792 s->HostVMInefficiencyFactor = mode_lib->ms.ReturnBW / s->VMDataOnlyReturnBW;
8793
8794 s->TotalDCCActiveDPP = 0;
8795 s->TotalActiveDPP = 0;
8796 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8797 s->TotalActiveDPP = s->TotalActiveDPP + mode_lib->ms.cache_display_cfg.hw.DPPPerSurface[k];
8798 if (mode_lib->ms.cache_display_cfg.surface.DCCEnable[k])
8799 s->TotalDCCActiveDPP = s->TotalDCCActiveDPP + mode_lib->ms.cache_display_cfg.hw.DPPPerSurface[k];
8800 }
8801
8802 locals->UrgentExtraLatency = CalculateExtraLatency(
8803 mode_lib->ms.soc.round_trip_ping_latency_dcfclk_cycles,
8804 s->ReorderBytes,
8805 locals->Dcfclk,
8806 s->TotalActiveDPP,
8807 mode_lib->ms.ip.pixel_chunk_size_kbytes,
8808 s->TotalDCCActiveDPP,
8809 mode_lib->ms.ip.meta_chunk_size_kbytes,
8810 mode_lib->ms.ReturnBW,
8811 mode_lib->ms.cache_display_cfg.plane.GPUVMEnable,
8812 mode_lib->ms.cache_display_cfg.plane.HostVMEnable,
8813 mode_lib->ms.num_active_planes,
8814 mode_lib->ms.cache_display_cfg.hw.DPPPerSurface,
8815 locals->dpte_group_bytes,
8816 s->HostVMInefficiencyFactor,
8817 mode_lib->ms.soc.hostvm_min_page_size_kbytes * 1024,
8818 mode_lib->ms.cache_display_cfg.plane.HostVMMaxPageTableLevels);
8819
8820 locals->TCalc = 24.0 / locals->DCFCLKDeepSleep;
8821
8822 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8823 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == k) {
8824 if (mode_lib->ms.cache_display_cfg.writeback.WritebackEnable[k] == true) {
8825 locals->WritebackDelay[k] =
8826 mode_lib->ms.state.writeback_latency_us
8827 + CalculateWriteBackDelay(
8828 mode_lib->ms.cache_display_cfg.writeback.WritebackPixelFormat[k],
8829 mode_lib->ms.cache_display_cfg.writeback.WritebackHRatio[k],
8830 mode_lib->ms.cache_display_cfg.writeback.WritebackVRatio[k],
8831 mode_lib->ms.cache_display_cfg.writeback.WritebackVTaps[k],
8832 mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationWidth[k],
8833 mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationHeight[k],
8834 mode_lib->ms.cache_display_cfg.writeback.WritebackSourceHeight[k],
8835 mode_lib->ms.cache_display_cfg.timing.HTotal[k]) / locals->Dispclk;
8836 } else
8837 locals->WritebackDelay[k] = 0;
8838 for (j = 0; j < mode_lib->ms.num_active_planes; ++j) {
8839 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[j] == k
8840 && mode_lib->ms.cache_display_cfg.writeback.WritebackEnable[j] == true) {
8841 locals->WritebackDelay[k] =
8842 dml_max(
8843 locals->WritebackDelay[k],
8844 mode_lib->ms.state.writeback_latency_us
8845 + CalculateWriteBackDelay(
8846 mode_lib->ms.cache_display_cfg.writeback.WritebackPixelFormat[j],
8847 mode_lib->ms.cache_display_cfg.writeback.WritebackHRatio[j],
8848 mode_lib->ms.cache_display_cfg.writeback.WritebackVRatio[j],
8849 mode_lib->ms.cache_display_cfg.writeback.WritebackVTaps[j],
8850 mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationWidth[j],
8851 mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationHeight[j],
8852 mode_lib->ms.cache_display_cfg.writeback.WritebackSourceHeight[j],
8853 mode_lib->ms.cache_display_cfg.timing.HTotal[k]) / locals->Dispclk);
8854 }
8855 }
8856 }
8857 }
8858
8859 for (k = 0; k < mode_lib->ms.num_active_planes; ++k)
8860 for (j = 0; j < mode_lib->ms.num_active_planes; ++j)
8861 if (mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming[k] == j)
8862 locals->WritebackDelay[k] = locals->WritebackDelay[j];
8863
8864 locals->UrgentLatency = CalculateUrgentLatency(mode_lib->ms.state.urgent_latency_pixel_data_only_us,
8865 mode_lib->ms.state.urgent_latency_pixel_mixed_with_vm_data_us,
8866 mode_lib->ms.state.urgent_latency_vm_data_only_us,
8867 mode_lib->ms.soc.do_urgent_latency_adjustment,
8868 mode_lib->ms.state.urgent_latency_adjustment_fabric_clock_component_us,
8869 mode_lib->ms.state.urgent_latency_adjustment_fabric_clock_reference_mhz,
8870 mode_lib->ms.FabricClock);
8871
8872 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8873 CalculateUrgentBurstFactor(mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[k],
8874 locals->swath_width_luma_ub[k],
8875 locals->swath_width_chroma_ub[k],
8876 locals->SwathHeightY[k],
8877 locals->SwathHeightC[k],
8878 mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k],
8879 locals->UrgentLatency,
8880 mode_lib->ms.ip.cursor_buffer_size,
8881 mode_lib->ms.cache_display_cfg.plane.CursorWidth[k],
8882 mode_lib->ms.cache_display_cfg.plane.CursorBPP[k],
8883 mode_lib->ms.cache_display_cfg.plane.VRatio[k],
8884 mode_lib->ms.cache_display_cfg.plane.VRatioChroma[k],
8885 locals->BytePerPixelDETY[k],
8886 locals->BytePerPixelDETC[k],
8887 locals->DETBufferSizeY[k],
8888 locals->DETBufferSizeC[k],
8889
8890 /* output */
8891 &locals->UrgBurstFactorCursor[k],
8892 &locals->UrgBurstFactorLuma[k],
8893 &locals->UrgBurstFactorChroma[k],
8894 &locals->NoUrgentLatencyHiding[k]);
8895
8896 locals->cursor_bw[k] = mode_lib->ms.cache_display_cfg.plane.NumberOfCursors[k] * mode_lib->ms.cache_display_cfg.plane.CursorWidth[k] * mode_lib->ms.cache_display_cfg.plane.CursorBPP[k] / 8.0 /
8897 ((dml_float_t) mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k]) * mode_lib->ms.cache_display_cfg.plane.VRatio[k];
8898 }
8899
8900 s->VStartupLines = __DML_VBA_MIN_VSTARTUP__;
8901 s->MaxVStartupAllPlanes = 0;
8902
8903 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8904 s->MaxVStartupLines[k] = CalculateMaxVStartup(k,
8905 mode_lib->ms.ip.ptoi_supported,
8906 mode_lib->ms.ip.vblank_nom_default_us,
8907 &mode_lib->ms.cache_display_cfg.timing,
8908 locals->WritebackDelay[k]);
8909
8910 #ifdef __DML_VBA_DEBUG__
8911 dml_print("DML::%s: k=%u MaxVStartupLines = %u\n", __func__, k, s->MaxVStartupLines[k]);
8912 dml_print("DML::%s: k=%u WritebackDelay = %f\n", __func__, k, locals->WritebackDelay[k]);
8913 #endif
8914 }
8915
8916 for (k = 0; k < mode_lib->ms.num_active_planes; ++k)
8917 s->MaxVStartupAllPlanes = (dml_uint_t)(dml_max(s->MaxVStartupAllPlanes, s->MaxVStartupLines[k]));
8918
8919 s->ImmediateFlipRequirementFinal = false;
8920 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8921 s->ImmediateFlipRequirementFinal = s->ImmediateFlipRequirementFinal || (mode_lib->ms.policy.ImmediateFlipRequirement[k] == dml_immediate_flip_required);
8922 }
8923 #ifdef __DML_VBA_DEBUG__
8924 dml_print("DML::%s: ImmediateFlipRequirementFinal = %u\n", __func__, s->ImmediateFlipRequirementFinal);
8925 #endif
8926
8927 // The prefetch scheduling should only be calculated once as per AllowForPStateChangeOrStutterInVBlank requirement
8928 // If the AllowForPStateChangeOrStutterInVBlank requirement is not strict (i.e. only try those power saving feature
8929 // if possible, then will try to program for the best power saving features in order of difficulty (dram, fclk, stutter)
8930 s->iteration = 0;
8931 s->MaxTotalRDBandwidth = 0;
8932 s->AllPrefetchModeTested = false;
8933 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
8934 CalculatePrefetchMode(mode_lib->ms.policy.AllowForPStateChangeOrStutterInVBlank[k], &s->MinPrefetchMode[k], &s->MaxPrefetchMode[k]);
8935 s->NextPrefetchMode[k] = s->MinPrefetchMode[k];
8936 }
8937
8938 do {
8939 s->MaxTotalRDBandwidthNoUrgentBurst = 0.0;
8940 s->DestinationLineTimesForPrefetchLessThan2 = false;
8941 s->VRatioPrefetchMoreThanMax = false;
8942
8943 dml_print("DML::%s: Start one iteration: VStartupLines = %u\n", __func__, s->VStartupLines);
8944
8945 s->AllPrefetchModeTested = true;
8946 s->MaxTotalRDBandwidth = 0;
8947 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
8948 locals->PrefetchMode[k] = s->NextPrefetchMode[k];
8949 TWait = CalculateTWait(
8950 locals->PrefetchMode[k],
8951 mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[k],
8952 mode_lib->ms.policy.SynchronizeDRRDisplaysForUCLKPStateChangeFinal,
8953 mode_lib->ms.cache_display_cfg.timing.DRRDisplay[k],
8954 mode_lib->ms.state.dram_clock_change_latency_us,
8955 mode_lib->ms.state.fclk_change_latency_us,
8956 locals->UrgentLatency,
8957 mode_lib->ms.state.sr_enter_plus_exit_time_us);
8958
8959 myPipe = &s->myPipe;
8960 myPipe->Dppclk = locals->Dppclk[k];
8961 myPipe->Dispclk = locals->Dispclk;
8962 myPipe->PixelClock = mode_lib->ms.cache_display_cfg.timing.PixelClock[k];
8963 myPipe->DCFClkDeepSleep = locals->DCFCLKDeepSleep;
8964 myPipe->DPPPerSurface = mode_lib->ms.cache_display_cfg.hw.DPPPerSurface[k];
8965 myPipe->ScalerEnabled = mode_lib->ms.cache_display_cfg.plane.ScalerEnabled[k];
8966 myPipe->SourceScan = mode_lib->ms.cache_display_cfg.plane.SourceScan[k];
8967 myPipe->BlockWidth256BytesY = locals->BlockWidth256BytesY[k];
8968 myPipe->BlockHeight256BytesY = locals->BlockHeight256BytesY[k];
8969 myPipe->BlockWidth256BytesC = locals->BlockWidth256BytesC[k];
8970 myPipe->BlockHeight256BytesC = locals->BlockHeight256BytesC[k];
8971 myPipe->InterlaceEnable = mode_lib->ms.cache_display_cfg.timing.Interlace[k];
8972 myPipe->NumberOfCursors = mode_lib->ms.cache_display_cfg.plane.NumberOfCursors[k];
8973 myPipe->VBlank = mode_lib->ms.cache_display_cfg.timing.VTotal[k] - mode_lib->ms.cache_display_cfg.timing.VActive[k];
8974 myPipe->HTotal = mode_lib->ms.cache_display_cfg.timing.HTotal[k];
8975 myPipe->HActive = mode_lib->ms.cache_display_cfg.timing.HActive[k];
8976 myPipe->DCCEnable = mode_lib->ms.cache_display_cfg.surface.DCCEnable[k];
8977 myPipe->ODMMode = mode_lib->ms.cache_display_cfg.hw.ODMMode[k];
8978 myPipe->SourcePixelFormat = mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k];
8979 myPipe->BytePerPixelY = locals->BytePerPixelY[k];
8980 myPipe->BytePerPixelC = locals->BytePerPixelC[k];
8981 myPipe->ProgressiveToInterlaceUnitInOPP = mode_lib->ms.ip.ptoi_supported;
8982
8983 #ifdef __DML_VBA_DEBUG__
8984 dml_print("DML::%s: Calling CalculatePrefetchSchedule for k=%u\n", __func__, k);
8985 dml_print("DML::%s: AllowForPStateChangeOrStutterInVBlank = %u\n", __func__, mode_lib->ms.policy.AllowForPStateChangeOrStutterInVBlank[k]);
8986 dml_print("DML::%s: PrefetchMode[k] = %u (Min=%u Max=%u)\n", __func__, locals->PrefetchMode[k], s->MinPrefetchMode[k], s->MaxPrefetchMode[k]);
8987 #endif
8988
8989 CalculatePrefetchSchedule_params->EnhancedPrefetchScheduleAccelerationFinal = mode_lib->ms.policy.EnhancedPrefetchScheduleAccelerationFinal;
8990 CalculatePrefetchSchedule_params->HostVMInefficiencyFactor = s->HostVMInefficiencyFactor;
8991 CalculatePrefetchSchedule_params->myPipe = myPipe;
8992 CalculatePrefetchSchedule_params->DSCDelay = locals->DSCDelay[k];
8993 CalculatePrefetchSchedule_params->DPPCLKDelaySubtotalPlusCNVCFormater = mode_lib->ms.ip.dppclk_delay_subtotal + mode_lib->ms.ip.dppclk_delay_cnvc_formatter;
8994 CalculatePrefetchSchedule_params->DPPCLKDelaySCL = mode_lib->ms.ip.dppclk_delay_scl;
8995 CalculatePrefetchSchedule_params->DPPCLKDelaySCLLBOnly = mode_lib->ms.ip.dppclk_delay_scl_lb_only;
8996 CalculatePrefetchSchedule_params->DPPCLKDelayCNVCCursor = mode_lib->ms.ip.dppclk_delay_cnvc_cursor;
8997 CalculatePrefetchSchedule_params->DISPCLKDelaySubtotal = mode_lib->ms.ip.dispclk_delay_subtotal;
8998 CalculatePrefetchSchedule_params->DPP_RECOUT_WIDTH = (dml_uint_t)(locals->SwathWidthY[k] / mode_lib->ms.cache_display_cfg.plane.HRatio[k]);
8999 CalculatePrefetchSchedule_params->OutputFormat = mode_lib->ms.cache_display_cfg.output.OutputFormat[k];
9000 CalculatePrefetchSchedule_params->MaxInterDCNTileRepeaters = mode_lib->ms.ip.max_inter_dcn_tile_repeaters;
9001 CalculatePrefetchSchedule_params->VStartup = (dml_uint_t)(dml_min(s->VStartupLines, s->MaxVStartupLines[k]));
9002 CalculatePrefetchSchedule_params->MaxVStartup = s->MaxVStartupLines[k];
9003 CalculatePrefetchSchedule_params->GPUVMPageTableLevels = mode_lib->ms.cache_display_cfg.plane.GPUVMMaxPageTableLevels;
9004 CalculatePrefetchSchedule_params->GPUVMEnable = mode_lib->ms.cache_display_cfg.plane.GPUVMEnable;
9005 CalculatePrefetchSchedule_params->HostVMEnable = mode_lib->ms.cache_display_cfg.plane.HostVMEnable;
9006 CalculatePrefetchSchedule_params->HostVMMaxNonCachedPageTableLevels = mode_lib->ms.cache_display_cfg.plane.HostVMMaxPageTableLevels;
9007 CalculatePrefetchSchedule_params->HostVMMinPageSize = mode_lib->ms.soc.hostvm_min_page_size_kbytes * 1024;
9008 CalculatePrefetchSchedule_params->DynamicMetadataEnable = mode_lib->ms.cache_display_cfg.plane.DynamicMetadataEnable[k];
9009 CalculatePrefetchSchedule_params->DynamicMetadataVMEnabled = mode_lib->ms.ip.dynamic_metadata_vm_enabled;
9010 CalculatePrefetchSchedule_params->DynamicMetadataLinesBeforeActiveRequired = mode_lib->ms.cache_display_cfg.plane.DynamicMetadataLinesBeforeActiveRequired[k];
9011 CalculatePrefetchSchedule_params->DynamicMetadataTransmittedBytes = mode_lib->ms.cache_display_cfg.plane.DynamicMetadataTransmittedBytes[k];
9012 CalculatePrefetchSchedule_params->UrgentLatency = locals->UrgentLatency;
9013 CalculatePrefetchSchedule_params->UrgentExtraLatency = locals->UrgentExtraLatency;
9014 CalculatePrefetchSchedule_params->TCalc = locals->TCalc;
9015 CalculatePrefetchSchedule_params->PDEAndMetaPTEBytesFrame = locals->PDEAndMetaPTEBytesFrame[k];
9016 CalculatePrefetchSchedule_params->MetaRowByte = locals->MetaRowByte[k];
9017 CalculatePrefetchSchedule_params->PixelPTEBytesPerRow = locals->PixelPTEBytesPerRow[k];
9018 CalculatePrefetchSchedule_params->PrefetchSourceLinesY = locals->PrefetchSourceLinesY[k];
9019 CalculatePrefetchSchedule_params->VInitPreFillY = locals->VInitPreFillY[k];
9020 CalculatePrefetchSchedule_params->MaxNumSwathY = locals->MaxNumSwathY[k];
9021 CalculatePrefetchSchedule_params->PrefetchSourceLinesC = locals->PrefetchSourceLinesC[k];
9022 CalculatePrefetchSchedule_params->VInitPreFillC = locals->VInitPreFillC[k];
9023 CalculatePrefetchSchedule_params->MaxNumSwathC = locals->MaxNumSwathC[k];
9024 CalculatePrefetchSchedule_params->swath_width_luma_ub = locals->swath_width_luma_ub[k];
9025 CalculatePrefetchSchedule_params->swath_width_chroma_ub = locals->swath_width_chroma_ub[k];
9026 CalculatePrefetchSchedule_params->SwathHeightY = locals->SwathHeightY[k];
9027 CalculatePrefetchSchedule_params->SwathHeightC = locals->SwathHeightC[k];
9028 CalculatePrefetchSchedule_params->TWait = TWait;
9029 CalculatePrefetchSchedule_params->DSTXAfterScaler = &locals->DSTXAfterScaler[k];
9030 CalculatePrefetchSchedule_params->DSTYAfterScaler = &locals->DSTYAfterScaler[k];
9031 CalculatePrefetchSchedule_params->DestinationLinesForPrefetch = &locals->DestinationLinesForPrefetch[k];
9032 CalculatePrefetchSchedule_params->DestinationLinesToRequestVMInVBlank = &locals->DestinationLinesToRequestVMInVBlank[k];
9033 CalculatePrefetchSchedule_params->DestinationLinesToRequestRowInVBlank = &locals->DestinationLinesToRequestRowInVBlank[k];
9034 CalculatePrefetchSchedule_params->VRatioPrefetchY = &locals->VRatioPrefetchY[k];
9035 CalculatePrefetchSchedule_params->VRatioPrefetchC = &locals->VRatioPrefetchC[k];
9036 CalculatePrefetchSchedule_params->RequiredPrefetchPixDataBWLuma = &locals->RequiredPrefetchPixDataBWLuma[k];
9037 CalculatePrefetchSchedule_params->RequiredPrefetchPixDataBWChroma = &locals->RequiredPrefetchPixDataBWChroma[k];
9038 CalculatePrefetchSchedule_params->NotEnoughTimeForDynamicMetadata = &locals->NotEnoughTimeForDynamicMetadata[k];
9039 CalculatePrefetchSchedule_params->Tno_bw = &locals->Tno_bw[k];
9040 CalculatePrefetchSchedule_params->prefetch_vmrow_bw = &locals->prefetch_vmrow_bw[k];
9041 CalculatePrefetchSchedule_params->Tdmdl_vm = &locals->Tdmdl_vm[k];
9042 CalculatePrefetchSchedule_params->Tdmdl = &locals->Tdmdl[k];
9043 CalculatePrefetchSchedule_params->TSetup = &locals->TSetup[k];
9044 CalculatePrefetchSchedule_params->VUpdateOffsetPix = &locals->VUpdateOffsetPix[k];
9045 CalculatePrefetchSchedule_params->VUpdateWidthPix = &locals->VUpdateWidthPix[k];
9046 CalculatePrefetchSchedule_params->VReadyOffsetPix = &locals->VReadyOffsetPix[k];
9047
9048 locals->NoTimeToPrefetch[k] =
9049 CalculatePrefetchSchedule(&mode_lib->scratch,
9050 CalculatePrefetchSchedule_params);
9051
9052 #ifdef __DML_VBA_DEBUG__
9053 dml_print("DML::%s: k=%0u NoTimeToPrefetch=%0d\n", __func__, k, locals->NoTimeToPrefetch[k]);
9054 #endif
9055 locals->VStartup[k] = (dml_uint_t)(dml_min(s->VStartupLines, s->MaxVStartupLines[k]));
9056 locals->VStartupMin[k] = locals->VStartup[k];
9057 }
9058
9059 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
9060 CalculateUrgentBurstFactor(
9061 mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[k],
9062 locals->swath_width_luma_ub[k],
9063 locals->swath_width_chroma_ub[k],
9064 locals->SwathHeightY[k],
9065 locals->SwathHeightC[k],
9066 mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k],
9067 locals->UrgentLatency,
9068 mode_lib->ms.ip.cursor_buffer_size,
9069 mode_lib->ms.cache_display_cfg.plane.CursorWidth[k],
9070 mode_lib->ms.cache_display_cfg.plane.CursorBPP[k],
9071 locals->VRatioPrefetchY[k],
9072 locals->VRatioPrefetchC[k],
9073 locals->BytePerPixelDETY[k],
9074 locals->BytePerPixelDETC[k],
9075 locals->DETBufferSizeY[k],
9076 locals->DETBufferSizeC[k],
9077 /* Output */
9078 &locals->UrgBurstFactorCursorPre[k],
9079 &locals->UrgBurstFactorLumaPre[k],
9080 &locals->UrgBurstFactorChromaPre[k],
9081 &locals->NoUrgentLatencyHidingPre[k]);
9082
9083 locals->cursor_bw_pre[k] = mode_lib->ms.cache_display_cfg.plane.NumberOfCursors[k] * mode_lib->ms.cache_display_cfg.plane.CursorWidth[k] * mode_lib->ms.cache_display_cfg.plane.CursorBPP[k] / 8.0 / (mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k]) * locals->VRatioPrefetchY[k];
9084
9085 #ifdef __DML_VBA_DEBUG__
9086 dml_print("DML::%s: k=%0u DPPPerSurface=%u\n", __func__, k, mode_lib->ms.cache_display_cfg.hw.DPPPerSurface[k]);
9087 dml_print("DML::%s: k=%0u UrgBurstFactorLuma=%f\n", __func__, k, locals->UrgBurstFactorLuma[k]);
9088 dml_print("DML::%s: k=%0u UrgBurstFactorChroma=%f\n", __func__, k, locals->UrgBurstFactorChroma[k]);
9089 dml_print("DML::%s: k=%0u UrgBurstFactorLumaPre=%f\n", __func__, k, locals->UrgBurstFactorLumaPre[k]);
9090 dml_print("DML::%s: k=%0u UrgBurstFactorChromaPre=%f\n", __func__, k, locals->UrgBurstFactorChromaPre[k]);
9091
9092 dml_print("DML::%s: k=%0u VRatioPrefetchY=%f\n", __func__, k, locals->VRatioPrefetchY[k]);
9093 dml_print("DML::%s: k=%0u VRatioY=%f\n", __func__, k, mode_lib->ms.cache_display_cfg.plane.VRatio[k]);
9094
9095 dml_print("DML::%s: k=%0u prefetch_vmrow_bw=%f\n", __func__, k, locals->prefetch_vmrow_bw[k]);
9096 dml_print("DML::%s: k=%0u ReadBandwidthSurfaceLuma=%f\n", __func__, k, locals->ReadBandwidthSurfaceLuma[k]);
9097 dml_print("DML::%s: k=%0u ReadBandwidthSurfaceChroma=%f\n", __func__, k, locals->ReadBandwidthSurfaceChroma[k]);
9098 dml_print("DML::%s: k=%0u cursor_bw=%f\n", __func__, k, locals->cursor_bw[k]);
9099 dml_print("DML::%s: k=%0u meta_row_bw=%f\n", __func__, k, locals->meta_row_bw[k]);
9100 dml_print("DML::%s: k=%0u dpte_row_bw=%f\n", __func__, k, locals->dpte_row_bw[k]);
9101 dml_print("DML::%s: k=%0u RequiredPrefetchPixDataBWLuma=%f\n", __func__, k, locals->RequiredPrefetchPixDataBWLuma[k]);
9102 dml_print("DML::%s: k=%0u RequiredPrefetchPixDataBWChroma=%f\n", __func__, k, locals->RequiredPrefetchPixDataBWChroma[k]);
9103 dml_print("DML::%s: k=%0u cursor_bw_pre=%f\n", __func__, k, locals->cursor_bw_pre[k]);
9104 dml_print("DML::%s: k=%0u MaxTotalRDBandwidthNoUrgentBurst=%f\n", __func__, k, s->MaxTotalRDBandwidthNoUrgentBurst);
9105 #endif
9106 if (locals->DestinationLinesForPrefetch[k] < 2)
9107 s->DestinationLineTimesForPrefetchLessThan2 = true;
9108
9109 if (locals->VRatioPrefetchY[k] > __DML_MAX_VRATIO_PRE_ENHANCE_PREFETCH_ACC__ ||
9110 locals->VRatioPrefetchC[k] > __DML_MAX_VRATIO_PRE_ENHANCE_PREFETCH_ACC__ ||
9111 ((s->VStartupLines < s->MaxVStartupLines[k] || mode_lib->ms.policy.EnhancedPrefetchScheduleAccelerationFinal == 0) &&
9112 (locals->VRatioPrefetchY[k] > __DML_MAX_VRATIO_PRE__ || locals->VRatioPrefetchC[k] > __DML_MAX_VRATIO_PRE__)))
9113 s->VRatioPrefetchMoreThanMax = true;
9114
9115 //dml_bool_t DestinationLinesToRequestVMInVBlankEqualOrMoreThan32 = false;
9116 //dml_bool_t DestinationLinesToRequestRowInVBlankEqualOrMoreThan16 = false;
9117 //if (locals->DestinationLinesToRequestVMInVBlank[k] >= 32) {
9118 // DestinationLinesToRequestVMInVBlankEqualOrMoreThan32 = true;
9119 //}
9120
9121 //if (locals->DestinationLinesToRequestRowInVBlank[k] >= 16) {
9122 // DestinationLinesToRequestRowInVBlankEqualOrMoreThan16 = true;
9123 //}
9124 }
9125
9126 locals->FractionOfUrgentBandwidth = s->MaxTotalRDBandwidthNoUrgentBurst / mode_lib->ms.ReturnBW;
9127
9128 #ifdef __DML_VBA_DEBUG__
9129 dml_print("DML::%s: MaxTotalRDBandwidthNoUrgentBurst=%f \n", __func__, s->MaxTotalRDBandwidthNoUrgentBurst);
9130 dml_print("DML::%s: ReturnBW=%f \n", __func__, mode_lib->ms.ReturnBW);
9131 dml_print("DML::%s: FractionOfUrgentBandwidth=%f \n", __func__, locals->FractionOfUrgentBandwidth);
9132 #endif
9133
9134 CalculatePrefetchBandwithSupport(
9135 mode_lib->ms.num_active_planes,
9136 mode_lib->ms.ReturnBW,
9137 mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange,
9138 locals->NoUrgentLatencyHidingPre,
9139 locals->ReadBandwidthSurfaceLuma,
9140 locals->ReadBandwidthSurfaceChroma,
9141 locals->RequiredPrefetchPixDataBWLuma,
9142 locals->RequiredPrefetchPixDataBWChroma,
9143 locals->cursor_bw,
9144 locals->meta_row_bw,
9145 locals->dpte_row_bw,
9146 locals->cursor_bw_pre,
9147 locals->prefetch_vmrow_bw,
9148 mode_lib->ms.cache_display_cfg.hw.DPPPerSurface,
9149 locals->UrgBurstFactorLuma,
9150 locals->UrgBurstFactorChroma,
9151 locals->UrgBurstFactorCursor,
9152 locals->UrgBurstFactorLumaPre,
9153 locals->UrgBurstFactorChromaPre,
9154 locals->UrgBurstFactorCursorPre,
9155
9156 /* output */
9157 &s->MaxTotalRDBandwidth, // dml_float_t *PrefetchBandwidth
9158 &s->MaxTotalRDBandwidthNotIncludingMALLPrefetch, // dml_float_t *PrefetchBandwidthNotIncludingMALLPrefetch
9159 &s->dummy_single[0], // dml_float_t *FractionOfUrgentBandwidth
9160 &locals->PrefetchModeSupported);
9161
9162 for (k = 0; k < mode_lib->ms.num_active_planes; ++k)
9163 s->dummy_unit_vector[k] = 1.0;
9164
9165 CalculatePrefetchBandwithSupport(mode_lib->ms.num_active_planes,
9166 mode_lib->ms.ReturnBW,
9167 mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange,
9168 locals->NoUrgentLatencyHidingPre,
9169 locals->ReadBandwidthSurfaceLuma,
9170 locals->ReadBandwidthSurfaceChroma,
9171 locals->RequiredPrefetchPixDataBWLuma,
9172 locals->RequiredPrefetchPixDataBWChroma,
9173 locals->cursor_bw,
9174 locals->meta_row_bw,
9175 locals->dpte_row_bw,
9176 locals->cursor_bw_pre,
9177 locals->prefetch_vmrow_bw,
9178 mode_lib->ms.cache_display_cfg.hw.DPPPerSurface,
9179 s->dummy_unit_vector,
9180 s->dummy_unit_vector,
9181 s->dummy_unit_vector,
9182 s->dummy_unit_vector,
9183 s->dummy_unit_vector,
9184 s->dummy_unit_vector,
9185
9186 /* output */
9187 &s->NonUrgentMaxTotalRDBandwidth, // dml_float_t *PrefetchBandwidth
9188 &s->NonUrgentMaxTotalRDBandwidthNotIncludingMALLPrefetch, // dml_float_t *PrefetchBandwidthNotIncludingMALLPrefetch
9189 &locals->FractionOfUrgentBandwidth,
9190 &s->dummy_boolean[0]); // dml_bool_t *PrefetchBandwidthSupport
9191
9192 if (s->VRatioPrefetchMoreThanMax != false || s->DestinationLineTimesForPrefetchLessThan2 != false) {
9193 dml_print("DML::%s: VRatioPrefetchMoreThanMax = %u\n", __func__, s->VRatioPrefetchMoreThanMax);
9194 dml_print("DML::%s: DestinationLineTimesForPrefetchLessThan2 = %u\n", __func__, s->DestinationLineTimesForPrefetchLessThan2);
9195 locals->PrefetchModeSupported = false;
9196 }
9197
9198 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
9199 if (locals->NoTimeToPrefetch[k] == true || locals->NotEnoughTimeForDynamicMetadata[k]) {
9200 dml_print("DML::%s: k=%u, NoTimeToPrefetch = %0d\n", __func__, k, locals->NoTimeToPrefetch[k]);
9201 dml_print("DML::%s: k=%u, NotEnoughTimeForDynamicMetadata=%u\n", __func__, k, locals->NotEnoughTimeForDynamicMetadata[k]);
9202 locals->PrefetchModeSupported = false;
9203 }
9204 }
9205
9206 if (locals->PrefetchModeSupported == true && mode_lib->ms.support.ImmediateFlipSupport == true) {
9207 locals->BandwidthAvailableForImmediateFlip = CalculateBandwidthAvailableForImmediateFlip(
9208 mode_lib->ms.num_active_planes,
9209 mode_lib->ms.ReturnBW,
9210 locals->ReadBandwidthSurfaceLuma,
9211 locals->ReadBandwidthSurfaceChroma,
9212 locals->RequiredPrefetchPixDataBWLuma,
9213 locals->RequiredPrefetchPixDataBWChroma,
9214 locals->cursor_bw,
9215 locals->cursor_bw_pre,
9216 mode_lib->ms.cache_display_cfg.hw.DPPPerSurface,
9217 locals->UrgBurstFactorLuma,
9218 locals->UrgBurstFactorChroma,
9219 locals->UrgBurstFactorCursor,
9220 locals->UrgBurstFactorLumaPre,
9221 locals->UrgBurstFactorChromaPre,
9222 locals->UrgBurstFactorCursorPre);
9223
9224 locals->TotImmediateFlipBytes = 0;
9225 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
9226 if (mode_lib->ms.policy.ImmediateFlipRequirement[k] != dml_immediate_flip_not_required) {
9227 locals->TotImmediateFlipBytes = locals->TotImmediateFlipBytes + mode_lib->ms.cache_display_cfg.hw.DPPPerSurface[k] * (locals->PDEAndMetaPTEBytesFrame[k] + locals->MetaRowByte[k]);
9228 if (locals->use_one_row_for_frame_flip[k]) {
9229 locals->TotImmediateFlipBytes = locals->TotImmediateFlipBytes + mode_lib->ms.cache_display_cfg.hw.DPPPerSurface[k] * (2 * locals->PixelPTEBytesPerRow[k]);
9230 } else {
9231 locals->TotImmediateFlipBytes = locals->TotImmediateFlipBytes + mode_lib->ms.cache_display_cfg.hw.DPPPerSurface[k] * locals->PixelPTEBytesPerRow[k];
9232 }
9233 #ifdef __DML_VBA_DEBUG__
9234 dml_print("DML::%s: k = %u\n", __func__, k);
9235 dml_print("DML::%s: DPPPerSurface = %u\n", __func__, mode_lib->ms.cache_display_cfg.hw.DPPPerSurface[k]);
9236 dml_print("DML::%s: PDEAndMetaPTEBytesFrame = %u\n", __func__, locals->PDEAndMetaPTEBytesFrame[k]);
9237 dml_print("DML::%s: MetaRowByte = %u\n", __func__, locals->MetaRowByte[k]);
9238 dml_print("DML::%s: PixelPTEBytesPerRow = %u\n", __func__, locals->PixelPTEBytesPerRow[k]);
9239 dml_print("DML::%s: TotImmediateFlipBytes = %u\n", __func__, locals->TotImmediateFlipBytes);
9240 #endif
9241 }
9242 }
9243 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
9244 CalculateFlipSchedule(
9245 s->HostVMInefficiencyFactor,
9246 locals->UrgentExtraLatency,
9247 locals->UrgentLatency,
9248 mode_lib->ms.cache_display_cfg.plane.GPUVMMaxPageTableLevels,
9249 mode_lib->ms.cache_display_cfg.plane.HostVMEnable,
9250 mode_lib->ms.cache_display_cfg.plane.HostVMMaxPageTableLevels,
9251 mode_lib->ms.cache_display_cfg.plane.GPUVMEnable,
9252 mode_lib->ms.soc.hostvm_min_page_size_kbytes * 1024,
9253 locals->PDEAndMetaPTEBytesFrame[k],
9254 locals->MetaRowByte[k],
9255 locals->PixelPTEBytesPerRow[k],
9256 locals->BandwidthAvailableForImmediateFlip,
9257 locals->TotImmediateFlipBytes,
9258 mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k],
9259 mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k],
9260 mode_lib->ms.cache_display_cfg.plane.VRatio[k],
9261 mode_lib->ms.cache_display_cfg.plane.VRatioChroma[k],
9262 locals->Tno_bw[k],
9263 mode_lib->ms.cache_display_cfg.surface.DCCEnable[k],
9264 locals->dpte_row_height[k],
9265 locals->meta_row_height[k],
9266 locals->dpte_row_height_chroma[k],
9267 locals->meta_row_height_chroma[k],
9268 locals->use_one_row_for_frame_flip[k],
9269
9270 /* Output */
9271 &locals->DestinationLinesToRequestVMInImmediateFlip[k],
9272 &locals->DestinationLinesToRequestRowInImmediateFlip[k],
9273 &locals->final_flip_bw[k],
9274 &locals->ImmediateFlipSupportedForPipe[k]);
9275 }
9276
9277 CalculateImmediateFlipBandwithSupport(mode_lib->ms.num_active_planes,
9278 mode_lib->ms.ReturnBW,
9279 mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange,
9280 mode_lib->ms.policy.ImmediateFlipRequirement,
9281 locals->final_flip_bw,
9282 locals->ReadBandwidthSurfaceLuma,
9283 locals->ReadBandwidthSurfaceChroma,
9284 locals->RequiredPrefetchPixDataBWLuma,
9285 locals->RequiredPrefetchPixDataBWChroma,
9286 locals->cursor_bw,
9287 locals->meta_row_bw,
9288 locals->dpte_row_bw,
9289 locals->cursor_bw_pre,
9290 locals->prefetch_vmrow_bw,
9291 mode_lib->ms.cache_display_cfg.hw.DPPPerSurface,
9292 locals->UrgBurstFactorLuma,
9293 locals->UrgBurstFactorChroma,
9294 locals->UrgBurstFactorCursor,
9295 locals->UrgBurstFactorLumaPre,
9296 locals->UrgBurstFactorChromaPre,
9297 locals->UrgBurstFactorCursorPre,
9298
9299 /* output */
9300 &locals->total_dcn_read_bw_with_flip, // dml_float_t *TotalBandwidth
9301 &locals->total_dcn_read_bw_with_flip_not_including_MALL_prefetch, // dml_float_t TotalBandwidthNotIncludingMALLPrefetch
9302 &s->dummy_single[0], // dml_float_t *FractionOfUrgentBandwidth
9303 &locals->ImmediateFlipSupported); // dml_bool_t *ImmediateFlipBandwidthSupport
9304
9305 CalculateImmediateFlipBandwithSupport(mode_lib->ms.num_active_planes,
9306 mode_lib->ms.ReturnBW,
9307 mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange,
9308 mode_lib->ms.policy.ImmediateFlipRequirement,
9309 locals->final_flip_bw,
9310 locals->ReadBandwidthSurfaceLuma,
9311 locals->ReadBandwidthSurfaceChroma,
9312 locals->RequiredPrefetchPixDataBWLuma,
9313 locals->RequiredPrefetchPixDataBWChroma,
9314 locals->cursor_bw,
9315 locals->meta_row_bw,
9316 locals->dpte_row_bw,
9317 locals->cursor_bw_pre,
9318 locals->prefetch_vmrow_bw,
9319 mode_lib->ms.cache_display_cfg.hw.DPPPerSurface,
9320 s->dummy_unit_vector,
9321 s->dummy_unit_vector,
9322 s->dummy_unit_vector,
9323 s->dummy_unit_vector,
9324 s->dummy_unit_vector,
9325 s->dummy_unit_vector,
9326
9327 /* output */
9328 &locals->non_urgent_total_dcn_read_bw_with_flip, // dml_float_t *TotalBandwidth
9329 &locals->non_urgent_total_dcn_read_bw_with_flip_not_including_MALL_prefetch, // dml_float_t TotalBandwidthNotIncludingMALLPrefetch
9330 &locals->FractionOfUrgentBandwidthImmediateFlip, // dml_float_t *FractionOfUrgentBandwidth
9331 &s->dummy_boolean[0]); // dml_bool_t *ImmediateFlipBandwidthSupport
9332
9333 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
9334 if (mode_lib->ms.policy.ImmediateFlipRequirement[k] != dml_immediate_flip_not_required && locals->ImmediateFlipSupportedForPipe[k] == false) {
9335 locals->ImmediateFlipSupported = false;
9336 #ifdef __DML_VBA_DEBUG__
9337 dml_print("DML::%s: Pipe %0d not supporting iflip\n", __func__, k);
9338 #endif
9339 }
9340 }
9341 } else {
9342 locals->ImmediateFlipSupported = false;
9343 locals->total_dcn_read_bw_with_flip = s->MaxTotalRDBandwidth;
9344 locals->total_dcn_read_bw_with_flip_not_including_MALL_prefetch = s->MaxTotalRDBandwidthNotIncludingMALLPrefetch;
9345 locals->non_urgent_total_dcn_read_bw_with_flip = s->NonUrgentMaxTotalRDBandwidth;
9346 locals->non_urgent_total_dcn_read_bw_with_flip_not_including_MALL_prefetch = s->NonUrgentMaxTotalRDBandwidthNotIncludingMALLPrefetch;
9347 }
9348
9349 /* 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) */
9350 locals->PrefetchAndImmediateFlipSupported = (locals->PrefetchModeSupported == true &&
9351 ((!mode_lib->ms.support.ImmediateFlipSupport && !mode_lib->ms.cache_display_cfg.plane.HostVMEnable && !s->ImmediateFlipRequirementFinal) ||
9352 locals->ImmediateFlipSupported)) ? true : false;
9353
9354 #ifdef __DML_VBA_DEBUG__
9355 dml_print("DML::%s: PrefetchModeSupported = %u\n", __func__, locals->PrefetchModeSupported);
9356 for (k = 0; k < mode_lib->ms.num_active_planes; ++k)
9357 dml_print("DML::%s: ImmediateFlipRequirement[%u] = %u\n", __func__, k, mode_lib->ms.policy.ImmediateFlipRequirement[k] == dml_immediate_flip_required);
9358 dml_print("DML::%s: HostVMEnable = %u\n", __func__, mode_lib->ms.cache_display_cfg.plane.HostVMEnable);
9359 dml_print("DML::%s: ImmediateFlipSupport = %u (from mode_support)\n", __func__, mode_lib->ms.support.ImmediateFlipSupport);
9360 dml_print("DML::%s: ImmediateFlipSupported = %u\n", __func__, locals->ImmediateFlipSupported);
9361 dml_print("DML::%s: PrefetchAndImmediateFlipSupported = %u\n", __func__, locals->PrefetchAndImmediateFlipSupported);
9362 #endif
9363 dml_print("DML::%s: Done one iteration: VStartupLines=%u, MaxVStartupAllPlanes=%u\n", __func__, s->VStartupLines, s->MaxVStartupAllPlanes);
9364
9365 s->VStartupLines = s->VStartupLines + 1;
9366
9367 if (s->VStartupLines > s->MaxVStartupAllPlanes) {
9368 s->VStartupLines = __DML_VBA_MIN_VSTARTUP__;
9369
9370 for (k = 0; k <= mode_lib->ms.num_active_planes - 1; k++) {
9371 s->NextPrefetchMode[k] = s->NextPrefetchMode[k] + 1;
9372
9373 if (s->NextPrefetchMode[k] <= s->MaxPrefetchMode[k])
9374 s->AllPrefetchModeTested = false;
9375 dml_print("DML::%s: VStartupLines=%u, reaches max vstartup, try next prefetch mode=%u\n", __func__, s->VStartupLines-1, s->AllPrefetchModeTested);
9376 }
9377 } else {
9378 s->AllPrefetchModeTested = false;
9379 }
9380 s->iteration++;
9381 if (s->iteration > 2500) {
9382 dml_print("ERROR: DML::%s: Too many errors, exit now\n", __func__);
9383 ASSERT(0);
9384 }
9385 } while (!(locals->PrefetchAndImmediateFlipSupported || s->AllPrefetchModeTested));
9386
9387 if (locals->PrefetchAndImmediateFlipSupported) {
9388 dml_print("DML::%s: Good, Prefetch and flip scheduling solution found at VStartupLines=%u (MaxVStartupAllPlanes=%u)\n", __func__, s->VStartupLines-1, s->MaxVStartupAllPlanes);
9389 } else {
9390 dml_print("DML::%s: Bad, Prefetch and flip scheduling solution did NOT find solution! (MaxVStartupAllPlanes=%u)\n", __func__, s->MaxVStartupAllPlanes);
9391 }
9392
9393 //Watermarks and NB P-State/DRAM Clock Change Support
9394 {
9395 s->mmSOCParameters.UrgentLatency = locals->UrgentLatency;
9396 s->mmSOCParameters.ExtraLatency = locals->UrgentExtraLatency;
9397 s->mmSOCParameters.WritebackLatency = mode_lib->ms.state.writeback_latency_us;
9398 s->mmSOCParameters.DRAMClockChangeLatency = mode_lib->ms.state.dram_clock_change_latency_us;
9399 s->mmSOCParameters.FCLKChangeLatency = mode_lib->ms.state.fclk_change_latency_us;
9400 s->mmSOCParameters.SRExitTime = mode_lib->ms.state.sr_exit_time_us;
9401 s->mmSOCParameters.SREnterPlusExitTime = mode_lib->ms.state.sr_enter_plus_exit_time_us;
9402 s->mmSOCParameters.SRExitZ8Time = mode_lib->ms.state.sr_exit_z8_time_us;
9403 s->mmSOCParameters.SREnterPlusExitZ8Time = mode_lib->ms.state.sr_enter_plus_exit_z8_time_us;
9404 s->mmSOCParameters.USRRetrainingLatency = mode_lib->ms.state.usr_retraining_latency_us;
9405 s->mmSOCParameters.SMNLatency = mode_lib->ms.soc.smn_latency_us;
9406
9407 CalculateWatermarks_params->USRRetrainingRequiredFinal = mode_lib->ms.policy.USRRetrainingRequiredFinal;
9408 CalculateWatermarks_params->UseMALLForPStateChange = mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange;
9409 CalculateWatermarks_params->PrefetchMode = locals->PrefetchMode;
9410 CalculateWatermarks_params->NumberOfActiveSurfaces = mode_lib->ms.num_active_planes;
9411 CalculateWatermarks_params->MaxLineBufferLines = mode_lib->ms.ip.max_line_buffer_lines;
9412 CalculateWatermarks_params->LineBufferSize = mode_lib->ms.ip.line_buffer_size_bits;
9413 CalculateWatermarks_params->WritebackInterfaceBufferSize = mode_lib->ms.ip.writeback_interface_buffer_size_kbytes;
9414 CalculateWatermarks_params->DCFCLK = locals->Dcfclk;
9415 CalculateWatermarks_params->ReturnBW = mode_lib->ms.ReturnBW;
9416 CalculateWatermarks_params->SynchronizeTimingsFinal = mode_lib->ms.policy.SynchronizeTimingsFinal;
9417 CalculateWatermarks_params->SynchronizeDRRDisplaysForUCLKPStateChangeFinal = mode_lib->ms.policy.SynchronizeDRRDisplaysForUCLKPStateChangeFinal;
9418 CalculateWatermarks_params->DRRDisplay = mode_lib->ms.cache_display_cfg.timing.DRRDisplay;
9419 CalculateWatermarks_params->dpte_group_bytes = locals->dpte_group_bytes;
9420 CalculateWatermarks_params->meta_row_height = locals->meta_row_height;
9421 CalculateWatermarks_params->meta_row_height_chroma = locals->meta_row_height_chroma;
9422 CalculateWatermarks_params->mmSOCParameters = s->mmSOCParameters;
9423 CalculateWatermarks_params->WritebackChunkSize = mode_lib->ms.ip.writeback_chunk_size_kbytes;
9424 CalculateWatermarks_params->SOCCLK = mode_lib->ms.SOCCLK;
9425 CalculateWatermarks_params->DCFClkDeepSleep = locals->DCFCLKDeepSleep;
9426 CalculateWatermarks_params->DETBufferSizeY = locals->DETBufferSizeY;
9427 CalculateWatermarks_params->DETBufferSizeC = locals->DETBufferSizeC;
9428 CalculateWatermarks_params->SwathHeightY = locals->SwathHeightY;
9429 CalculateWatermarks_params->SwathHeightC = locals->SwathHeightC;
9430 CalculateWatermarks_params->LBBitPerPixel = mode_lib->ms.cache_display_cfg.plane.LBBitPerPixel;
9431 CalculateWatermarks_params->SwathWidthY = locals->SwathWidthY;
9432 CalculateWatermarks_params->SwathWidthC = locals->SwathWidthC;
9433 CalculateWatermarks_params->HRatio = mode_lib->ms.cache_display_cfg.plane.HRatio;
9434 CalculateWatermarks_params->HRatioChroma = mode_lib->ms.cache_display_cfg.plane.HRatioChroma;
9435 CalculateWatermarks_params->VTaps = mode_lib->ms.cache_display_cfg.plane.VTaps;
9436 CalculateWatermarks_params->VTapsChroma = mode_lib->ms.cache_display_cfg.plane.VTapsChroma;
9437 CalculateWatermarks_params->VRatio = mode_lib->ms.cache_display_cfg.plane.VRatio;
9438 CalculateWatermarks_params->VRatioChroma = mode_lib->ms.cache_display_cfg.plane.VRatioChroma;
9439 CalculateWatermarks_params->HTotal = mode_lib->ms.cache_display_cfg.timing.HTotal;
9440 CalculateWatermarks_params->VTotal = mode_lib->ms.cache_display_cfg.timing.VTotal;
9441 CalculateWatermarks_params->VActive = mode_lib->ms.cache_display_cfg.timing.VActive;
9442 CalculateWatermarks_params->PixelClock = mode_lib->ms.cache_display_cfg.timing.PixelClock;
9443 CalculateWatermarks_params->BlendingAndTiming = mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming;
9444 CalculateWatermarks_params->DPPPerSurface = mode_lib->ms.cache_display_cfg.hw.DPPPerSurface;
9445 CalculateWatermarks_params->BytePerPixelDETY = locals->BytePerPixelDETY;
9446 CalculateWatermarks_params->BytePerPixelDETC = locals->BytePerPixelDETC;
9447 CalculateWatermarks_params->DSTXAfterScaler = locals->DSTXAfterScaler;
9448 CalculateWatermarks_params->DSTYAfterScaler = locals->DSTYAfterScaler;
9449 CalculateWatermarks_params->WritebackEnable = mode_lib->ms.cache_display_cfg.writeback.WritebackEnable;
9450 CalculateWatermarks_params->WritebackPixelFormat = mode_lib->ms.cache_display_cfg.writeback.WritebackPixelFormat;
9451 CalculateWatermarks_params->WritebackDestinationWidth = mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationWidth;
9452 CalculateWatermarks_params->WritebackDestinationHeight = mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationHeight;
9453 CalculateWatermarks_params->WritebackSourceHeight = mode_lib->ms.cache_display_cfg.writeback.WritebackSourceHeight;
9454 CalculateWatermarks_params->UnboundedRequestEnabled = locals->UnboundedRequestEnabled;
9455 CalculateWatermarks_params->CompressedBufferSizeInkByte = locals->CompressedBufferSizeInkByte;
9456
9457 // Output
9458 CalculateWatermarks_params->Watermark = &locals->Watermark; // Watermarks *Watermark
9459 CalculateWatermarks_params->DRAMClockChangeSupport = &locals->DRAMClockChangeSupport;
9460 CalculateWatermarks_params->MaxActiveDRAMClockChangeLatencySupported = locals->MaxActiveDRAMClockChangeLatencySupported; // dml_float_t *MaxActiveDRAMClockChangeLatencySupported[]
9461 CalculateWatermarks_params->SubViewportLinesNeededInMALL = locals->SubViewportLinesNeededInMALL; // dml_uint_t SubViewportLinesNeededInMALL[]
9462 CalculateWatermarks_params->FCLKChangeSupport = &locals->FCLKChangeSupport;
9463 CalculateWatermarks_params->MaxActiveFCLKChangeLatencySupported = &locals->MaxActiveFCLKChangeLatencySupported; // dml_float_t *MaxActiveFCLKChangeLatencySupported
9464 CalculateWatermarks_params->USRRetrainingSupport = &locals->USRRetrainingSupport;
9465
9466 CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport(
9467 &mode_lib->scratch,
9468 CalculateWatermarks_params);
9469
9470 /* Copy the calculated watermarks to mp.Watermark as the getter functions are
9471 * implemented by the DML team to copy the calculated values from the mp.Watermark interface.
9472 * &mode_lib->mp.Watermark and &locals->Watermark are the same address, memcpy may lead to
9473 * unexpected behavior. memmove should be used.
9474 */
9475 memmove(&mode_lib->mp.Watermark, CalculateWatermarks_params->Watermark, sizeof(struct Watermarks));
9476
9477 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
9478 if (mode_lib->ms.cache_display_cfg.writeback.WritebackEnable[k] == true) {
9479 locals->WritebackAllowDRAMClockChangeEndPosition[k] = dml_max(0, locals->VStartupMin[k] * mode_lib->ms.cache_display_cfg.timing.HTotal[k] /
9480 mode_lib->ms.cache_display_cfg.timing.PixelClock[k] - locals->Watermark.WritebackDRAMClockChangeWatermark);
9481 locals->WritebackAllowFCLKChangeEndPosition[k] = dml_max(0, locals->VStartupMin[k] * mode_lib->ms.cache_display_cfg.timing.HTotal[k] /
9482 mode_lib->ms.cache_display_cfg.timing.PixelClock[k] - locals->Watermark.WritebackFCLKChangeWatermark);
9483 } else {
9484 locals->WritebackAllowDRAMClockChangeEndPosition[k] = 0;
9485 locals->WritebackAllowFCLKChangeEndPosition[k] = 0;
9486 }
9487 }
9488 }
9489
9490 //Display Pipeline Delivery Time in Prefetch, Groups
9491 CalculatePixelDeliveryTimes(
9492 mode_lib->ms.num_active_planes,
9493 mode_lib->ms.cache_display_cfg.plane.VRatio,
9494 mode_lib->ms.cache_display_cfg.plane.VRatioChroma,
9495 locals->VRatioPrefetchY,
9496 locals->VRatioPrefetchC,
9497 locals->swath_width_luma_ub,
9498 locals->swath_width_chroma_ub,
9499 mode_lib->ms.cache_display_cfg.hw.DPPPerSurface,
9500 mode_lib->ms.cache_display_cfg.plane.HRatio,
9501 mode_lib->ms.cache_display_cfg.plane.HRatioChroma,
9502 mode_lib->ms.cache_display_cfg.timing.PixelClock,
9503 locals->PSCL_THROUGHPUT,
9504 locals->PSCL_THROUGHPUT_CHROMA,
9505 locals->Dppclk,
9506 locals->BytePerPixelC,
9507 mode_lib->ms.cache_display_cfg.plane.SourceScan,
9508 mode_lib->ms.cache_display_cfg.plane.NumberOfCursors,
9509 mode_lib->ms.cache_display_cfg.plane.CursorWidth,
9510 mode_lib->ms.cache_display_cfg.plane.CursorBPP,
9511 locals->BlockWidth256BytesY,
9512 locals->BlockHeight256BytesY,
9513 locals->BlockWidth256BytesC,
9514 locals->BlockHeight256BytesC,
9515
9516 /* Output */
9517 locals->DisplayPipeLineDeliveryTimeLuma,
9518 locals->DisplayPipeLineDeliveryTimeChroma,
9519 locals->DisplayPipeLineDeliveryTimeLumaPrefetch,
9520 locals->DisplayPipeLineDeliveryTimeChromaPrefetch,
9521 locals->DisplayPipeRequestDeliveryTimeLuma,
9522 locals->DisplayPipeRequestDeliveryTimeChroma,
9523 locals->DisplayPipeRequestDeliveryTimeLumaPrefetch,
9524 locals->DisplayPipeRequestDeliveryTimeChromaPrefetch,
9525 locals->CursorRequestDeliveryTime,
9526 locals->CursorRequestDeliveryTimePrefetch);
9527
9528 CalculateMetaAndPTETimes(
9529 locals->use_one_row_for_frame,
9530 mode_lib->ms.num_active_planes,
9531 mode_lib->ms.cache_display_cfg.plane.GPUVMEnable,
9532 mode_lib->ms.ip.meta_chunk_size_kbytes,
9533 mode_lib->ms.ip.min_meta_chunk_size_bytes,
9534 mode_lib->ms.cache_display_cfg.timing.HTotal,
9535 mode_lib->ms.cache_display_cfg.plane.VRatio,
9536 mode_lib->ms.cache_display_cfg.plane.VRatioChroma,
9537 locals->DestinationLinesToRequestRowInVBlank,
9538 locals->DestinationLinesToRequestRowInImmediateFlip,
9539 mode_lib->ms.cache_display_cfg.surface.DCCEnable,
9540 mode_lib->ms.cache_display_cfg.timing.PixelClock,
9541 locals->BytePerPixelY,
9542 locals->BytePerPixelC,
9543 mode_lib->ms.cache_display_cfg.plane.SourceScan,
9544 locals->dpte_row_height,
9545 locals->dpte_row_height_chroma,
9546 locals->meta_row_width,
9547 locals->meta_row_width_chroma,
9548 locals->meta_row_height,
9549 locals->meta_row_height_chroma,
9550 locals->meta_req_width,
9551 locals->meta_req_width_chroma,
9552 locals->meta_req_height,
9553 locals->meta_req_height_chroma,
9554 locals->dpte_group_bytes,
9555 locals->PTERequestSizeY,
9556 locals->PTERequestSizeC,
9557 locals->PixelPTEReqWidthY,
9558 locals->PixelPTEReqHeightY,
9559 locals->PixelPTEReqWidthC,
9560 locals->PixelPTEReqHeightC,
9561 locals->dpte_row_width_luma_ub,
9562 locals->dpte_row_width_chroma_ub,
9563
9564 /* Output */
9565 locals->DST_Y_PER_PTE_ROW_NOM_L,
9566 locals->DST_Y_PER_PTE_ROW_NOM_C,
9567 locals->DST_Y_PER_META_ROW_NOM_L,
9568 locals->DST_Y_PER_META_ROW_NOM_C,
9569 locals->TimePerMetaChunkNominal,
9570 locals->TimePerChromaMetaChunkNominal,
9571 locals->TimePerMetaChunkVBlank,
9572 locals->TimePerChromaMetaChunkVBlank,
9573 locals->TimePerMetaChunkFlip,
9574 locals->TimePerChromaMetaChunkFlip,
9575 locals->time_per_pte_group_nom_luma,
9576 locals->time_per_pte_group_vblank_luma,
9577 locals->time_per_pte_group_flip_luma,
9578 locals->time_per_pte_group_nom_chroma,
9579 locals->time_per_pte_group_vblank_chroma,
9580 locals->time_per_pte_group_flip_chroma);
9581
9582 CalculateVMGroupAndRequestTimes(
9583 mode_lib->ms.num_active_planes,
9584 mode_lib->ms.cache_display_cfg.plane.GPUVMEnable,
9585 mode_lib->ms.cache_display_cfg.plane.GPUVMMaxPageTableLevels,
9586 mode_lib->ms.cache_display_cfg.timing.HTotal,
9587 locals->BytePerPixelC,
9588 locals->DestinationLinesToRequestVMInVBlank,
9589 locals->DestinationLinesToRequestVMInImmediateFlip,
9590 mode_lib->ms.cache_display_cfg.surface.DCCEnable,
9591 mode_lib->ms.cache_display_cfg.timing.PixelClock,
9592 locals->dpte_row_width_luma_ub,
9593 locals->dpte_row_width_chroma_ub,
9594 locals->vm_group_bytes,
9595 locals->dpde0_bytes_per_frame_ub_l,
9596 locals->dpde0_bytes_per_frame_ub_c,
9597 locals->meta_pte_bytes_per_frame_ub_l,
9598 locals->meta_pte_bytes_per_frame_ub_c,
9599
9600 /* Output */
9601 locals->TimePerVMGroupVBlank,
9602 locals->TimePerVMGroupFlip,
9603 locals->TimePerVMRequestVBlank,
9604 locals->TimePerVMRequestFlip);
9605
9606 // Min TTUVBlank
9607 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
9608 if (locals->PrefetchMode[k] == 0) {
9609 locals->MinTTUVBlank[k] = dml_max4(
9610 locals->Watermark.DRAMClockChangeWatermark,
9611 locals->Watermark.FCLKChangeWatermark,
9612 locals->Watermark.StutterEnterPlusExitWatermark,
9613 locals->Watermark.UrgentWatermark);
9614 } else if (locals->PrefetchMode[k] == 1) {
9615 locals->MinTTUVBlank[k] = dml_max3(
9616 locals->Watermark.FCLKChangeWatermark,
9617 locals->Watermark.StutterEnterPlusExitWatermark,
9618 locals->Watermark.UrgentWatermark);
9619 } else if (locals->PrefetchMode[k] == 2) {
9620 locals->MinTTUVBlank[k] = dml_max(
9621 locals->Watermark.StutterEnterPlusExitWatermark,
9622 locals->Watermark.UrgentWatermark);
9623 } else {
9624 locals->MinTTUVBlank[k] = locals->Watermark.UrgentWatermark;
9625 }
9626 if (!mode_lib->ms.cache_display_cfg.plane.DynamicMetadataEnable[k])
9627 locals->MinTTUVBlank[k] = locals->TCalc + locals->MinTTUVBlank[k];
9628 }
9629
9630 // DCC Configuration
9631 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
9632 #ifdef __DML_VBA_DEBUG__
9633 dml_print("DML::%s: Calculate DCC configuration for surface k=%u\n", __func__, k);
9634 #endif
9635 CalculateDCCConfiguration(
9636 mode_lib->ms.cache_display_cfg.surface.DCCEnable[k],
9637 mode_lib->ms.policy.DCCProgrammingAssumesScanDirectionUnknownFinal,
9638 mode_lib->ms.cache_display_cfg.surface.SourcePixelFormat[k],
9639 mode_lib->ms.cache_display_cfg.surface.SurfaceWidthY[k],
9640 mode_lib->ms.cache_display_cfg.surface.SurfaceWidthC[k],
9641 mode_lib->ms.cache_display_cfg.surface.SurfaceHeightY[k],
9642 mode_lib->ms.cache_display_cfg.surface.SurfaceHeightC[k],
9643 mode_lib->ms.NomDETInKByte,
9644 locals->BlockHeight256BytesY[k],
9645 locals->BlockHeight256BytesC[k],
9646 mode_lib->ms.cache_display_cfg.surface.SurfaceTiling[k],
9647 locals->BytePerPixelY[k],
9648 locals->BytePerPixelC[k],
9649 locals->BytePerPixelDETY[k],
9650 locals->BytePerPixelDETC[k],
9651 mode_lib->ms.cache_display_cfg.plane.SourceScan[k],
9652 /* Output */
9653 &locals->DCCYMaxUncompressedBlock[k],
9654 &locals->DCCCMaxUncompressedBlock[k],
9655 &locals->DCCYMaxCompressedBlock[k],
9656 &locals->DCCCMaxCompressedBlock[k],
9657 &locals->DCCYIndependentBlock[k],
9658 &locals->DCCCIndependentBlock[k]);
9659 }
9660
9661 // VStartup Adjustment
9662 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
9663 s->Tvstartup_margin = (s->MaxVStartupLines[k] - locals->VStartupMin[k]) * mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k];
9664 #ifdef __DML_VBA_DEBUG__
9665 dml_print("DML::%s: k=%u, MinTTUVBlank = %f (before vstartup margin)\n", __func__, k, locals->MinTTUVBlank[k]);
9666 #endif
9667
9668 locals->MinTTUVBlank[k] = locals->MinTTUVBlank[k] + s->Tvstartup_margin;
9669
9670 #ifdef __DML_VBA_DEBUG__
9671 dml_print("DML::%s: k=%u, Tvstartup_margin = %f\n", __func__, k, s->Tvstartup_margin);
9672 dml_print("DML::%s: k=%u, MaxVStartupLines = %u\n", __func__, k, s->MaxVStartupLines[k]);
9673 dml_print("DML::%s: k=%u, MinTTUVBlank = %f\n", __func__, k, locals->MinTTUVBlank[k]);
9674 #endif
9675
9676 locals->Tdmdl[k] = locals->Tdmdl[k] + s->Tvstartup_margin;
9677 if (mode_lib->ms.cache_display_cfg.plane.DynamicMetadataEnable[k] && mode_lib->ms.ip.dynamic_metadata_vm_enabled) {
9678 locals->Tdmdl_vm[k] = locals->Tdmdl_vm[k] + s->Tvstartup_margin;
9679 }
9680
9681 isInterlaceTiming = (mode_lib->ms.cache_display_cfg.timing.Interlace[k] && !mode_lib->ms.ip.ptoi_supported);
9682
9683 // The actual positioning of the vstartup
9684 locals->VStartup[k] = (isInterlaceTiming ? (2 * s->MaxVStartupLines[k]) : s->MaxVStartupLines[k]);
9685
9686 s->dlg_vblank_start = ((isInterlaceTiming ? dml_floor((mode_lib->ms.cache_display_cfg.timing.VTotal[k] - mode_lib->ms.cache_display_cfg.timing.VFrontPorch[k]) / 2.0, 1.0) :
9687 mode_lib->ms.cache_display_cfg.timing.VTotal[k]) - mode_lib->ms.cache_display_cfg.timing.VFrontPorch[k]);
9688 s->LSetup = dml_floor(4.0 * locals->TSetup[k] / ((dml_float_t) mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k]), 1.0) / 4.0;
9689 s->blank_lines_remaining = (mode_lib->ms.cache_display_cfg.timing.VTotal[k] - mode_lib->ms.cache_display_cfg.timing.VActive[k]) - locals->VStartup[k];
9690
9691 if (s->blank_lines_remaining < 0) {
9692 dml_print("ERROR: Vstartup is larger than vblank!?\n");
9693 s->blank_lines_remaining = 0;
9694 ASSERT(0);
9695 }
9696 locals->MIN_DST_Y_NEXT_START[k] = s->dlg_vblank_start + s->blank_lines_remaining + s->LSetup;
9697
9698 // debug only
9699 s->old_MIN_DST_Y_NEXT_START = ((isInterlaceTiming ? dml_floor((mode_lib->ms.cache_display_cfg.timing.VTotal[k] - mode_lib->ms.cache_display_cfg.timing.VFrontPorch[k]) / 2.0, 1.0) :
9700 mode_lib->ms.cache_display_cfg.timing.VTotal[k]) - mode_lib->ms.cache_display_cfg.timing.VFrontPorch[k])
9701 + dml_max(1.0, dml_ceil((dml_float_t) locals->WritebackDelay[k] / ((dml_float_t) mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k]), 1.0))
9702 + dml_floor(4.0 * locals->TSetup[k] / ((dml_float_t) mode_lib->ms.cache_display_cfg.timing.HTotal[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k]), 1.0) / 4.0;
9703
9704 if (((locals->VUpdateOffsetPix[k] + locals->VUpdateWidthPix[k] + locals->VReadyOffsetPix[k]) / (double) mode_lib->ms.cache_display_cfg.timing.HTotal[k]) <=
9705 (isInterlaceTiming ?
9706 dml_floor((mode_lib->ms.cache_display_cfg.timing.VTotal[k] - mode_lib->ms.cache_display_cfg.timing.VActive[k] - mode_lib->ms.cache_display_cfg.timing.VFrontPorch[k] - locals->VStartup[k]) / 2.0, 1.0) :
9707 (int) (mode_lib->ms.cache_display_cfg.timing.VTotal[k] - mode_lib->ms.cache_display_cfg.timing.VActive[k] - mode_lib->ms.cache_display_cfg.timing.VFrontPorch[k] - locals->VStartup[k]))) {
9708 locals->VREADY_AT_OR_AFTER_VSYNC[k] = true;
9709 } else {
9710 locals->VREADY_AT_OR_AFTER_VSYNC[k] = false;
9711 }
9712 #ifdef __DML_VBA_DEBUG__
9713 dml_print("DML::%s: k=%u, VStartup = %u (max)\n", __func__, k, locals->VStartup[k]);
9714 dml_print("DML::%s: k=%u, VStartupMin = %u (max)\n", __func__, k, locals->VStartupMin[k]);
9715 dml_print("DML::%s: k=%u, VUpdateOffsetPix = %u\n", __func__, k, locals->VUpdateOffsetPix[k]);
9716 dml_print("DML::%s: k=%u, VUpdateWidthPix = %u\n", __func__, k, locals->VUpdateWidthPix[k]);
9717 dml_print("DML::%s: k=%u, VReadyOffsetPix = %u\n", __func__, k, locals->VReadyOffsetPix[k]);
9718 dml_print("DML::%s: k=%u, HTotal = %u\n", __func__, k, mode_lib->ms.cache_display_cfg.timing.HTotal[k]);
9719 dml_print("DML::%s: k=%u, VTotal = %u\n", __func__, k, mode_lib->ms.cache_display_cfg.timing.VTotal[k]);
9720 dml_print("DML::%s: k=%u, VActive = %u\n", __func__, k, mode_lib->ms.cache_display_cfg.timing.VActive[k]);
9721 dml_print("DML::%s: k=%u, VFrontPorch = %u\n", __func__, k, mode_lib->ms.cache_display_cfg.timing.VFrontPorch[k]);
9722 dml_print("DML::%s: k=%u, TSetup = %f\n", __func__, k, locals->TSetup[k]);
9723 dml_print("DML::%s: k=%u, MIN_DST_Y_NEXT_START = %f\n", __func__, k, locals->MIN_DST_Y_NEXT_START[k]);
9724 dml_print("DML::%s: k=%u, MIN_DST_Y_NEXT_START = %f (old)\n", __func__, k, s->old_MIN_DST_Y_NEXT_START);
9725 dml_print("DML::%s: k=%u, VREADY_AT_OR_AFTER_VSYNC = %u\n", __func__, k, locals->VREADY_AT_OR_AFTER_VSYNC[k]);
9726 #endif
9727 }
9728
9729 //Maximum Bandwidth Used
9730 s->TotalWRBandwidth = 0;
9731 s->WRBandwidth = 0;
9732 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
9733 if (mode_lib->ms.cache_display_cfg.writeback.WritebackEnable[k] == true && mode_lib->ms.cache_display_cfg.writeback.WritebackPixelFormat[k] == dml_444_32) {
9734 s->WRBandwidth = mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationWidth[k] * mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationHeight[k] /
9735 (mode_lib->ms.cache_display_cfg.timing.HTotal[k] * mode_lib->ms.cache_display_cfg.writeback.WritebackSourceHeight[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k]) * 4;
9736 } else if (mode_lib->ms.cache_display_cfg.writeback.WritebackEnable[k] == true) {
9737 s->WRBandwidth = mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationWidth[k] * mode_lib->ms.cache_display_cfg.writeback.WritebackDestinationHeight[k] /
9738 (mode_lib->ms.cache_display_cfg.timing.HTotal[k] * mode_lib->ms.cache_display_cfg.writeback.WritebackSourceHeight[k] / mode_lib->ms.cache_display_cfg.timing.PixelClock[k]) * 8;
9739 }
9740 s->TotalWRBandwidth = s->TotalWRBandwidth + s->WRBandwidth;
9741 }
9742
9743 locals->TotalDataReadBandwidth = 0;
9744 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
9745 locals->TotalDataReadBandwidth = locals->TotalDataReadBandwidth + locals->ReadBandwidthSurfaceLuma[k] + locals->ReadBandwidthSurfaceChroma[k];
9746
9747 #ifdef __DML_VBA_DEBUG__
9748 dml_print("DML::%s: k=%u, TotalDataReadBandwidth = %f\n", __func__, k, locals->TotalDataReadBandwidth);
9749 dml_print("DML::%s: k=%u, ReadBandwidthSurfaceLuma = %f\n", __func__, k, locals->ReadBandwidthSurfaceLuma[k]);
9750 dml_print("DML::%s: k=%u, ReadBandwidthSurfaceChroma = %f\n", __func__, k, locals->ReadBandwidthSurfaceChroma[k]);
9751 #endif
9752 }
9753
9754 locals->TotalDataReadBandwidthNotIncludingMALLPrefetch = 0;
9755 for (k = 0; k < mode_lib->ms.num_active_planes; ++k) {
9756 if (mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[k] != dml_use_mall_pstate_change_phantom_pipe) {
9757 locals->TotalDataReadBandwidthNotIncludingMALLPrefetch = locals->TotalDataReadBandwidthNotIncludingMALLPrefetch
9758 + locals->ReadBandwidthSurfaceLuma[k] + locals->ReadBandwidthSurfaceChroma[k];
9759 }
9760 }
9761
9762 CalculateStutterEfficiency_params->CompressedBufferSizeInkByte = locals->CompressedBufferSizeInkByte;
9763 CalculateStutterEfficiency_params->UseMALLForPStateChange = mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange;
9764 CalculateStutterEfficiency_params->UnboundedRequestEnabled = locals->UnboundedRequestEnabled;
9765 CalculateStutterEfficiency_params->MetaFIFOSizeInKEntries = mode_lib->ms.ip.meta_fifo_size_in_kentries;
9766 CalculateStutterEfficiency_params->ZeroSizeBufferEntries = mode_lib->ms.ip.zero_size_buffer_entries;
9767 CalculateStutterEfficiency_params->PixelChunkSizeInKByte = mode_lib->ms.ip.pixel_chunk_size_kbytes;
9768 CalculateStutterEfficiency_params->NumberOfActiveSurfaces = mode_lib->ms.num_active_planes;
9769 CalculateStutterEfficiency_params->ROBBufferSizeInKByte = mode_lib->ms.ip.rob_buffer_size_kbytes;
9770 CalculateStutterEfficiency_params->TotalDataReadBandwidth = locals->TotalDataReadBandwidth;
9771 CalculateStutterEfficiency_params->DCFCLK = locals->Dcfclk;
9772 CalculateStutterEfficiency_params->ReturnBW = mode_lib->ms.ReturnBW;
9773 CalculateStutterEfficiency_params->CompbufReservedSpace64B = locals->compbuf_reserved_space_64b;
9774 CalculateStutterEfficiency_params->CompbufReservedSpaceZs = locals->compbuf_reserved_space_zs;
9775 CalculateStutterEfficiency_params->SRExitTime = mode_lib->ms.state.sr_exit_time_us;
9776 CalculateStutterEfficiency_params->SRExitZ8Time = mode_lib->ms.state.sr_exit_z8_time_us;
9777 CalculateStutterEfficiency_params->SynchronizeTimingsFinal = mode_lib->ms.policy.SynchronizeTimingsFinal;
9778 CalculateStutterEfficiency_params->BlendingAndTiming = mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming;
9779 CalculateStutterEfficiency_params->StutterEnterPlusExitWatermark = locals->Watermark.StutterEnterPlusExitWatermark;
9780 CalculateStutterEfficiency_params->Z8StutterEnterPlusExitWatermark = locals->Watermark.Z8StutterEnterPlusExitWatermark;
9781 CalculateStutterEfficiency_params->ProgressiveToInterlaceUnitInOPP = mode_lib->ms.ip.ptoi_supported;
9782 CalculateStutterEfficiency_params->Interlace = mode_lib->ms.cache_display_cfg.timing.Interlace;
9783 CalculateStutterEfficiency_params->MinTTUVBlank = locals->MinTTUVBlank;
9784 CalculateStutterEfficiency_params->DPPPerSurface = mode_lib->ms.cache_display_cfg.hw.DPPPerSurface;
9785 CalculateStutterEfficiency_params->DETBufferSizeY = locals->DETBufferSizeY;
9786 CalculateStutterEfficiency_params->BytePerPixelY = locals->BytePerPixelY;
9787 CalculateStutterEfficiency_params->BytePerPixelDETY = locals->BytePerPixelDETY;
9788 CalculateStutterEfficiency_params->SwathWidthY = locals->SwathWidthY;
9789 CalculateStutterEfficiency_params->SwathHeightY = locals->SwathHeightY;
9790 CalculateStutterEfficiency_params->SwathHeightC = locals->SwathHeightC;
9791 CalculateStutterEfficiency_params->NetDCCRateLuma = mode_lib->ms.cache_display_cfg.surface.DCCRateLuma;
9792 CalculateStutterEfficiency_params->NetDCCRateChroma = mode_lib->ms.cache_display_cfg.surface.DCCRateChroma;
9793 CalculateStutterEfficiency_params->DCCFractionOfZeroSizeRequestsLuma = mode_lib->ms.cache_display_cfg.surface.DCCFractionOfZeroSizeRequestsLuma;
9794 CalculateStutterEfficiency_params->DCCFractionOfZeroSizeRequestsChroma = mode_lib->ms.cache_display_cfg.surface.DCCFractionOfZeroSizeRequestsChroma;
9795 CalculateStutterEfficiency_params->HTotal = mode_lib->ms.cache_display_cfg.timing.HTotal;
9796 CalculateStutterEfficiency_params->VTotal = mode_lib->ms.cache_display_cfg.timing.VTotal;
9797 CalculateStutterEfficiency_params->PixelClock = mode_lib->ms.cache_display_cfg.timing.PixelClock;
9798 CalculateStutterEfficiency_params->VRatio = mode_lib->ms.cache_display_cfg.plane.VRatio;
9799 CalculateStutterEfficiency_params->SourceScan = mode_lib->ms.cache_display_cfg.plane.SourceScan;
9800 CalculateStutterEfficiency_params->BlockHeight256BytesY = locals->BlockHeight256BytesY;
9801 CalculateStutterEfficiency_params->BlockWidth256BytesY = locals->BlockWidth256BytesY;
9802 CalculateStutterEfficiency_params->BlockHeight256BytesC = locals->BlockHeight256BytesC;
9803 CalculateStutterEfficiency_params->BlockWidth256BytesC = locals->BlockWidth256BytesC;
9804 CalculateStutterEfficiency_params->DCCYMaxUncompressedBlock = locals->DCCYMaxUncompressedBlock;
9805 CalculateStutterEfficiency_params->DCCCMaxUncompressedBlock = locals->DCCCMaxUncompressedBlock;
9806 CalculateStutterEfficiency_params->VActive = mode_lib->ms.cache_display_cfg.timing.VActive;
9807 CalculateStutterEfficiency_params->DCCEnable = mode_lib->ms.cache_display_cfg.surface.DCCEnable;
9808 CalculateStutterEfficiency_params->WritebackEnable = mode_lib->ms.cache_display_cfg.writeback.WritebackEnable;
9809 CalculateStutterEfficiency_params->ReadBandwidthSurfaceLuma = locals->ReadBandwidthSurfaceLuma;
9810 CalculateStutterEfficiency_params->ReadBandwidthSurfaceChroma = locals->ReadBandwidthSurfaceChroma;
9811 CalculateStutterEfficiency_params->meta_row_bw = locals->meta_row_bw;
9812 CalculateStutterEfficiency_params->dpte_row_bw = locals->dpte_row_bw;
9813 CalculateStutterEfficiency_params->StutterEfficiencyNotIncludingVBlank = &locals->StutterEfficiencyNotIncludingVBlank;
9814 CalculateStutterEfficiency_params->StutterEfficiency = &locals->StutterEfficiency;
9815 CalculateStutterEfficiency_params->NumberOfStutterBurstsPerFrame = &locals->NumberOfStutterBurstsPerFrame;
9816 CalculateStutterEfficiency_params->Z8StutterEfficiencyNotIncludingVBlank = &locals->Z8StutterEfficiencyNotIncludingVBlank;
9817 CalculateStutterEfficiency_params->Z8StutterEfficiency = &locals->Z8StutterEfficiency;
9818 CalculateStutterEfficiency_params->Z8NumberOfStutterBurstsPerFrame = &locals->Z8NumberOfStutterBurstsPerFrame;
9819 CalculateStutterEfficiency_params->StutterPeriod = &locals->StutterPeriod;
9820 CalculateStutterEfficiency_params->DCHUBBUB_ARB_CSTATE_MAX_CAP_MODE = &locals->DCHUBBUB_ARB_CSTATE_MAX_CAP_MODE;
9821
9822 // Stutter Efficiency
9823 CalculateStutterEfficiency(&mode_lib->scratch,
9824 CalculateStutterEfficiency_params);
9825
9826 #ifdef __DML_VBA_ALLOW_DELTA__
9827 {
9828 dml_float_t dummy_single[2];
9829 dml_uint_t dummy_integer[1];
9830 dml_bool_t dummy_boolean[1];
9831
9832 // Calculate z8 stutter eff assuming 0 reserved space
9833 CalculateStutterEfficiency(
9834 locals->CompressedBufferSizeInkByte,
9835 mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange,
9836 locals->UnboundedRequestEnabled,
9837 mode_lib->ms.ip.meta_fifo_size_in_kentries,
9838 mode_lib->ms.ip.zero_size_buffer_entries,
9839 mode_lib->ms.ip.pixel_chunk_size_kbytes,
9840 mode_lib->ms.num_active_planes,
9841 mode_lib->ms.ip.rob_buffer_size_kbytes,
9842 locals->TotalDataReadBandwidth,
9843 locals->Dcfclk,
9844 mode_lib->ms.ReturnBW,
9845 0, //mode_lib->ms.ip.compbuf_reserved_space_64b,
9846 0, //mode_lib->ms.ip.compbuf_reserved_space_zs,
9847 mode_lib->ms.state.sr_exit_time_us,
9848 mode_lib->ms.state.sr_exit_z8_time_us,
9849 mode_lib->ms.policy.SynchronizeTimingsFinal,
9850 mode_lib->ms.cache_display_cfg.plane.BlendingAndTiming,
9851 locals->Watermark.StutterEnterPlusExitWatermark,
9852 locals->Watermark.Z8StutterEnterPlusExitWatermark,
9853 mode_lib->ms.ip.ptoi_supported,
9854 mode_lib->ms.cache_display_cfg.timing.Interlace,
9855 locals->MinTTUVBlank,
9856 mode_lib->ms.cache_display_cfg.hw.DPPPerSurface,
9857 mode_lib->ms.DETBufferSizeY,
9858 locals->BytePerPixelY,
9859 locals->BytePerPixelDETY,
9860 locals->SwathWidthY,
9861 mode_lib->ms.SwathHeightY,
9862 mode_lib->ms.SwathHeightC,
9863 mode_lib->ms.cache_display_cfg.surface.DCCRateLuma,
9864 mode_lib->ms.cache_display_cfg.surface.DCCRateChroma,
9865 mode_lib->ms.cache_display_cfg.surface.DCCFractionOfZeroSizeRequestsLuma,
9866 mode_lib->ms.cache_display_cfg.surface.DCCFractionOfZeroSizeRequestsChroma,
9867 mode_lib->ms.cache_display_cfg.timing.HTotal,
9868 mode_lib->ms.cache_display_cfg.timing.VTotal,
9869 mode_lib->ms.cache_display_cfg.timing.PixelClock,
9870 mode_lib->ms.cache_display_cfg.plane.VRatio,
9871 mode_lib->ms.cache_display_cfg.plane.SourceScan,
9872 locals->BlockHeight256BytesY,
9873 locals->BlockWidth256BytesY,
9874 locals->BlockHeight256BytesC,
9875 locals->BlockWidth256BytesC,
9876 locals->DCCYMaxUncompressedBlock,
9877 locals->DCCCMaxUncompressedBlock,
9878 mode_lib->ms.cache_display_cfg.timing.VActive,
9879 mode_lib->ms.cache_display_cfg.surface.DCCEnable,
9880 mode_lib->ms.cache_display_cfg.writeback.WritebackEnable,
9881 locals->ReadBandwidthSurfaceLuma,
9882 locals->ReadBandwidthSurfaceChroma,
9883 locals->meta_row_bw,
9884 locals->dpte_row_bw,
9885
9886 /* Output */
9887 &dummy_single[0],
9888 &dummy_single[1],
9889 &dummy_integer[0],
9890 &locals->Z8StutterEfficiencyNotIncludingVBlankBestCase,
9891 &locals->Z8StutterEfficiencyBestCase,
9892 &locals->Z8NumberOfStutterBurstsPerFrameBestCase,
9893 &locals->StutterPeriodBestCase,
9894 &dummy_boolean[0]);
9895 }
9896 #else
9897 locals->Z8StutterEfficiencyNotIncludingVBlankBestCase = locals->Z8StutterEfficiencyNotIncludingVBlank;
9898 locals->Z8StutterEfficiencyBestCase = locals->Z8StutterEfficiency;
9899 locals->Z8NumberOfStutterBurstsPerFrameBestCase = locals->Z8NumberOfStutterBurstsPerFrame;
9900 locals->StutterPeriodBestCase = locals->StutterPeriod;
9901 #endif
9902
9903 #ifdef __DML_VBA_DEBUG__
9904 dml_print("DML::%s: --- END --- \n", __func__);
9905 #endif
9906 } // dml_core_mode_programming
9907
9908 /// Function: dml_core_get_row_heights
9909 /// @brief Get row height for DPTE and META with minimal input.
dml_core_get_row_heights(dml_uint_t * dpte_row_height,dml_uint_t * meta_row_height,const struct display_mode_lib_st * mode_lib,dml_bool_t is_plane1,enum dml_source_format_class SourcePixelFormat,enum dml_swizzle_mode SurfaceTiling,enum dml_rotation_angle ScanDirection,dml_uint_t pitch,dml_uint_t GPUVMMinPageSizeKBytes)9910 void dml_core_get_row_heights(
9911 dml_uint_t *dpte_row_height,
9912 dml_uint_t *meta_row_height,
9913 const struct display_mode_lib_st *mode_lib,
9914 dml_bool_t is_plane1,
9915 enum dml_source_format_class SourcePixelFormat,
9916 enum dml_swizzle_mode SurfaceTiling,
9917 enum dml_rotation_angle ScanDirection,
9918 dml_uint_t pitch,
9919 dml_uint_t GPUVMMinPageSizeKBytes)
9920 {
9921 dml_uint_t BytePerPixelY;
9922 dml_uint_t BytePerPixelC;
9923 dml_float_t BytePerPixelInDETY;
9924 dml_float_t BytePerPixelInDETC;
9925 dml_uint_t BlockHeight256BytesY;
9926 dml_uint_t BlockHeight256BytesC;
9927 dml_uint_t BlockWidth256BytesY;
9928 dml_uint_t BlockWidth256BytesC;
9929 dml_uint_t MacroTileWidthY;
9930 dml_uint_t MacroTileWidthC;
9931 dml_uint_t MacroTileHeightY;
9932 dml_uint_t MacroTileHeightC;
9933
9934 dml_uint_t BytePerPixel;
9935 dml_uint_t BlockHeight256Bytes;
9936 dml_uint_t BlockWidth256Bytes;
9937 dml_uint_t MacroTileWidth;
9938 dml_uint_t MacroTileHeight;
9939 dml_uint_t PTEBufferSizeInRequests;
9940
9941 dml_uint_t dummy_integer[16];
9942
9943 CalculateBytePerPixelAndBlockSizes(
9944 SourcePixelFormat,
9945 SurfaceTiling,
9946
9947 /* Output */
9948 &BytePerPixelY,
9949 &BytePerPixelC,
9950 &BytePerPixelInDETY,
9951 &BytePerPixelInDETC,
9952 &BlockHeight256BytesY,
9953 &BlockHeight256BytesC,
9954 &BlockWidth256BytesY,
9955 &BlockWidth256BytesC,
9956 &MacroTileHeightY,
9957 &MacroTileHeightC,
9958 &MacroTileWidthY,
9959 &MacroTileWidthC);
9960
9961 BytePerPixel = is_plane1 ? BytePerPixelC : BytePerPixelY;
9962 BlockHeight256Bytes = is_plane1 ? BlockHeight256BytesC : BlockHeight256BytesY;
9963 BlockWidth256Bytes = is_plane1 ? BlockWidth256BytesC : BlockWidth256BytesY;
9964 MacroTileWidth = is_plane1 ? MacroTileWidthC : MacroTileWidthY;
9965 MacroTileHeight = is_plane1 ? MacroTileHeightC : MacroTileHeightY;
9966 PTEBufferSizeInRequests = is_plane1 ? mode_lib->ip.dpte_buffer_size_in_pte_reqs_chroma : mode_lib->ip.dpte_buffer_size_in_pte_reqs_luma;
9967 #ifdef __DML_RQ_DLG_CALC_DEBUG__
9968 dml_print("DML_DLG: %s: is_plane1 = %u\n", __func__, is_plane1);
9969 dml_print("DML_DLG: %s: BytePerPixel = %u\n", __func__, BytePerPixel);
9970 dml_print("DML_DLG: %s: BlockHeight256Bytes = %u\n", __func__, BlockHeight256Bytes);
9971 dml_print("DML_DLG: %s: BlockWidth256Bytes = %u\n", __func__, BlockWidth256Bytes);
9972 dml_print("DML_DLG: %s: MacroTileWidth = %u\n", __func__, MacroTileWidth);
9973 dml_print("DML_DLG: %s: MacroTileHeight = %u\n", __func__, MacroTileHeight);
9974 dml_print("DML_DLG: %s: PTEBufferSizeInRequests = %u\n", __func__, PTEBufferSizeInRequests);
9975 dml_print("DML_DLG: %s: dpte_buffer_size_in_pte_reqs_luma = %u\n", __func__, mode_lib->ip.dpte_buffer_size_in_pte_reqs_luma);
9976 dml_print("DML_DLG: %s: dpte_buffer_size_in_pte_reqs_chroma = %u\n", __func__, mode_lib->ip.dpte_buffer_size_in_pte_reqs_chroma);
9977 dml_print("DML_DLG: %s: GPUVMMinPageSizeKBytes = %u\n", __func__, GPUVMMinPageSizeKBytes);
9978 #endif
9979
9980 // just supply with enough parameters to calculate meta and dte
9981 CalculateVMAndRowBytes(
9982 0, // dml_bool_t ViewportStationary,
9983 1, // dml_bool_t DCCEnable,
9984 1, // dml_uint_t NumberOfDPPs,
9985 BlockHeight256Bytes,
9986 BlockWidth256Bytes,
9987 SourcePixelFormat,
9988 SurfaceTiling,
9989 BytePerPixel,
9990 ScanDirection,
9991 0, // dml_uint_t SwathWidth,
9992 0, // dml_uint_t ViewportHeight, (Note: DML calculates one_row_for_frame height regardless, would need test input if that height is useful)
9993 0, // dml_uint_t ViewportXStart,
9994 0, // dml_uint_t ViewportYStart,
9995 1, // dml_bool_t GPUVMEnable,
9996 4, // dml_uint_t GPUVMMaxPageTableLevels,
9997 GPUVMMinPageSizeKBytes,
9998 PTEBufferSizeInRequests,
9999 pitch,
10000 0, // dml_uint_t DCCMetaPitch,
10001 MacroTileWidth,
10002 MacroTileHeight,
10003
10004 // /* Output */
10005 &dummy_integer[0], // dml_uint_t *MetaRowByte,
10006 &dummy_integer[1], // dml_uint_t *PixelPTEBytesPerRow,
10007 &dummy_integer[2], // dml_uint_t *PixelPTEBytesPerRowStorage,
10008 &dummy_integer[3], // dml_uint_t *dpte_row_width_ub,
10009 dpte_row_height,
10010 &dummy_integer[4], // dml_uint_t *dpte_row_height_linear
10011 &dummy_integer[5], // dml_uint_t *PixelPTEBytesPerRow_one_row_per_frame,
10012 &dummy_integer[6], // dml_uint_t *dpte_row_width_ub_one_row_per_frame,
10013 &dummy_integer[7], // dml_uint_t *dpte_row_height_one_row_per_frame,
10014 &dummy_integer[8], // dml_uint_t *MetaRequestWidth,
10015 &dummy_integer[9], // dml_uint_t *MetaRequestHeight,
10016 &dummy_integer[10], // dml_uint_t *meta_row_width,
10017 meta_row_height,
10018 &dummy_integer[11], // dml_uint_t *PixelPTEReqWidth,
10019 &dummy_integer[12], // dml_uint_t *PixelPTEReqHeight,
10020 &dummy_integer[13], // dml_uint_t *PTERequestSize,
10021 &dummy_integer[14], // dml_uint_t *DPDE0BytesFrame,
10022 &dummy_integer[15]); // dml_uint_t *MetaPTEBytesFrame)
10023
10024 #ifdef __DML_RQ_DLG_CALC_DEBUG__
10025 dml_print("DML_DLG: %s: dpte_row_height = %u\n", __func__, *dpte_row_height);
10026 dml_print("DML_DLG: %s: meta_row_height = %u\n", __func__, *meta_row_height);
10027 #endif
10028 }
10029
dml_get_soc_state_bounding_box(const struct soc_states_st * states,dml_uint_t state_idx)10030 static struct soc_state_bounding_box_st dml_get_soc_state_bounding_box(
10031 const struct soc_states_st *states,
10032 dml_uint_t state_idx)
10033 {
10034 dml_print("DML::%s: state_idx=%u (num_states=%u)\n", __func__, state_idx, states->num_states);
10035
10036 if (state_idx >= (dml_uint_t)states->num_states) {
10037 dml_print("DML::%s: ERROR: Invalid state_idx=%u! num_states=%u\n", __func__, state_idx, states->num_states);
10038 ASSERT(0);
10039 }
10040 return (states->state_array[state_idx]);
10041 }
10042
10043 /// @brief Copy the parameters to a calculation struct, it actually only need when the DML needs to have
10044 /// the intelligence to re-calculate when any of display cfg, bbox, or policy changes since last calculated.
10045 ///
cache_ip_soc_cfg(struct display_mode_lib_st * mode_lib,dml_uint_t state_idx)10046 static void cache_ip_soc_cfg(struct display_mode_lib_st *mode_lib,
10047 dml_uint_t state_idx)
10048 {
10049 mode_lib->ms.state_idx = state_idx;
10050 mode_lib->ms.max_state_idx = mode_lib->states.num_states - 1;
10051 mode_lib->ms.soc = mode_lib->soc;
10052 mode_lib->ms.ip = mode_lib->ip;
10053 mode_lib->ms.policy = mode_lib->policy;
10054 mode_lib->ms.state = dml_get_soc_state_bounding_box(&mode_lib->states, state_idx);
10055 mode_lib->ms.max_state = dml_get_soc_state_bounding_box(&mode_lib->states, mode_lib->states.num_states - 1);
10056 }
10057
cache_display_cfg(struct display_mode_lib_st * mode_lib,const struct dml_display_cfg_st * display_cfg)10058 static void cache_display_cfg(struct display_mode_lib_st *mode_lib,
10059 const struct dml_display_cfg_st *display_cfg)
10060 {
10061 mode_lib->ms.cache_display_cfg = *display_cfg;
10062 }
10063
fetch_socbb_params(struct display_mode_lib_st * mode_lib)10064 static void fetch_socbb_params(struct display_mode_lib_st *mode_lib)
10065 {
10066 struct soc_state_bounding_box_st *state = &mode_lib->ms.state;
10067
10068 // Default values, SOCCLK, DRAMSpeed, and FabricClock will be reassigned to the same state value in mode_check step
10069 // If UseMinimumRequiredDCFCLK is used, the DCFCLK will be the min dcflk for the mode support
10070 mode_lib->ms.SOCCLK = (dml_float_t)state->socclk_mhz;
10071 mode_lib->ms.DRAMSpeed = (dml_float_t)state->dram_speed_mts;
10072 mode_lib->ms.FabricClock = (dml_float_t)state->fabricclk_mhz;
10073 mode_lib->ms.DCFCLK = (dml_float_t)state->dcfclk_mhz;
10074 }
10075
10076 /// @brief Use display_cfg directly for mode_support calculation
10077 /// Calculated values and informational output are stored in mode_lib.vba data struct
10078 /// The display configuration is described with pipes struct and num_pipes
10079 /// This function is used when physical resource mapping is not finalized (for example,
10080 /// don't know how many pipes to represent a surface)
10081 /// @param mode_lib Contains the bounding box and policy setting.
10082 /// @param state_idx Power state index
10083 /// @param display_cfg Display configurations. A display
dml_mode_support(struct display_mode_lib_st * mode_lib,dml_uint_t state_idx,const struct dml_display_cfg_st * display_cfg)10084 dml_bool_t dml_mode_support(
10085 struct display_mode_lib_st *mode_lib,
10086 dml_uint_t state_idx,
10087 const struct dml_display_cfg_st *display_cfg)
10088 {
10089 dml_bool_t is_mode_support;
10090
10091 dml_print("DML::%s: ------------- START ----------\n", __func__);
10092 cache_ip_soc_cfg(mode_lib, state_idx);
10093 cache_display_cfg(mode_lib, display_cfg);
10094
10095 fetch_socbb_params(mode_lib);
10096
10097 dml_print("DML::%s: state_idx = %u\n", __func__, state_idx);
10098
10099 is_mode_support = dml_core_mode_support(mode_lib);
10100
10101 dml_print("DML::%s: is_mode_support = %u\n", __func__, is_mode_support);
10102 dml_print("DML::%s: ------------- DONE ----------\n", __func__);
10103 return is_mode_support;
10104 }
10105
10106 /// @Brief A function to calculate the programming values for DCN DCHUB (Assume mode is supported)
10107 /// The output will be stored in the mode_lib.mp (mode_program_st) data struct and those can be accessed via the getter functions
10108 /// Calculated values include: watermarks, dlg, rq reg, different clock frequency
10109 /// This function returns 1 when there is no error.
10110 /// Note: In this function, it is assumed that DCFCLK, SOCCLK freq are the state values, and mode_program will just use the DML calculated DPPCLK and DISPCLK
10111 /// @param mode_lib mode_lib data struct that house all the input/output/bbox and calculation values.
10112 /// @param state_idx Power state idx chosen
10113 /// @param display_cfg Display Configuration
10114 /// @param call_standalone Calling mode_programming without calling mode support. Some of the "support" struct member will be pre-calculated before doing mode programming
10115 /// TODO: Add clk_cfg input, could be useful for standalone mode
dml_mode_programming(struct display_mode_lib_st * mode_lib,dml_uint_t state_idx,const struct dml_display_cfg_st * display_cfg,bool call_standalone)10116 dml_bool_t dml_mode_programming(
10117 struct display_mode_lib_st *mode_lib,
10118 dml_uint_t state_idx,
10119 const struct dml_display_cfg_st *display_cfg,
10120 bool call_standalone)
10121 {
10122 struct dml_clk_cfg_st clk_cfg;
10123 memset(&clk_cfg, 0, sizeof(clk_cfg));
10124
10125 clk_cfg.dcfclk_option = dml_use_required_freq;
10126 clk_cfg.dispclk_option = dml_use_required_freq;
10127 for (dml_uint_t k = 0; k < __DML_NUM_PLANES__; ++k)
10128 clk_cfg.dppclk_option[k] = dml_use_required_freq;
10129
10130 dml_print("DML::%s: ------------- START ----------\n", __func__);
10131 dml_print("DML::%s: state_idx = %u\n", __func__, state_idx);
10132 dml_print("DML::%s: call_standalone = %u\n", __func__, call_standalone);
10133
10134 cache_ip_soc_cfg(mode_lib, state_idx);
10135 cache_display_cfg(mode_lib, display_cfg);
10136
10137 fetch_socbb_params(mode_lib);
10138 if (call_standalone) {
10139 mode_lib->ms.support.ImmediateFlipSupport = 1; // assume mode support say immediate flip ok at max state/combine
10140 dml_core_mode_support_partial(mode_lib);
10141 }
10142
10143 dml_core_mode_programming(mode_lib, &clk_cfg);
10144
10145 dml_print("DML::%s: ------------- DONE ----------\n", __func__);
10146 dml_print("DML::%s: PrefetchAndImmediateFlipSupported = %0d\n", __func__, mode_lib->mp.PrefetchAndImmediateFlipSupported);
10147 return mode_lib->mp.PrefetchAndImmediateFlipSupported;
10148 }
10149
mode_support_pwr_states(dml_uint_t * lowest_state_idx,struct display_mode_lib_st * mode_lib,const struct dml_display_cfg_st * display_cfg,dml_uint_t start_state_idx,dml_uint_t end_state_idx)10150 static dml_uint_t mode_support_pwr_states(
10151 dml_uint_t *lowest_state_idx,
10152 struct display_mode_lib_st *mode_lib,
10153 const struct dml_display_cfg_st *display_cfg,
10154 dml_uint_t start_state_idx,
10155 dml_uint_t end_state_idx)
10156 {
10157 dml_uint_t state_idx = 0;
10158 dml_bool_t mode_is_supported = 0;
10159 *lowest_state_idx = end_state_idx;
10160
10161 if (end_state_idx < start_state_idx)
10162 ASSERT(0);
10163
10164 if (end_state_idx >= mode_lib->states.num_states) // idx is 0-based
10165 ASSERT(0);
10166
10167 for (state_idx = start_state_idx; state_idx <= end_state_idx; state_idx++) {
10168 if (dml_mode_support(mode_lib, state_idx, display_cfg)) {
10169 dml_print("DML::%s: Mode is supported at power state_idx = %u\n", __func__, state_idx);
10170 mode_is_supported = 1;
10171 *lowest_state_idx = state_idx;
10172 break;
10173 }
10174 }
10175
10176 return mode_is_supported;
10177 }
10178
dml_mode_support_ex(struct dml_mode_support_ex_params_st * in_out_params)10179 dml_uint_t dml_mode_support_ex(struct dml_mode_support_ex_params_st *in_out_params)
10180 {
10181 dml_uint_t result;
10182
10183 result = mode_support_pwr_states(&in_out_params->out_lowest_state_idx,
10184 in_out_params->mode_lib,
10185 in_out_params->in_display_cfg,
10186 0,
10187 in_out_params->mode_lib->states.num_states - 1);
10188
10189 if (result)
10190 *in_out_params->out_evaluation_info = in_out_params->mode_lib->ms.support;
10191
10192 return result;
10193 }
10194
dml_get_is_phantom_pipe(struct display_mode_lib_st * mode_lib,dml_uint_t pipe_idx)10195 dml_bool_t dml_get_is_phantom_pipe(struct display_mode_lib_st *mode_lib, dml_uint_t pipe_idx)
10196 {
10197 dml_uint_t plane_idx = mode_lib->mp.pipe_plane[pipe_idx];
10198 dml_print("DML::%s: pipe_idx=%d UseMALLForPStateChange=%0d\n", __func__, pipe_idx, mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[plane_idx]);
10199 return (mode_lib->ms.cache_display_cfg.plane.UseMALLForPStateChange[plane_idx] == dml_use_mall_pstate_change_phantom_pipe);
10200 }
10201
10202 #define dml_get_per_surface_var_func(variable, type, interval_var) type dml_get_##variable(struct display_mode_lib_st *mode_lib, dml_uint_t surface_idx) \
10203 { \
10204 dml_uint_t plane_idx; \
10205 plane_idx = mode_lib->mp.pipe_plane[surface_idx]; \
10206 return (type) interval_var[plane_idx]; \
10207 }
10208
10209 #define dml_get_var_func(var, type, internal_var) type dml_get_##var(struct display_mode_lib_st *mode_lib) \
10210 { \
10211 return (type) internal_var; \
10212 }
10213
10214 dml_get_var_func(wm_urgent, dml_float_t, mode_lib->mp.Watermark.UrgentWatermark);
10215 dml_get_var_func(wm_stutter_exit, dml_float_t, mode_lib->mp.Watermark.StutterExitWatermark);
10216 dml_get_var_func(wm_stutter_enter_exit, dml_float_t, mode_lib->mp.Watermark.StutterEnterPlusExitWatermark);
10217 dml_get_var_func(wm_memory_trip, dml_float_t, mode_lib->mp.UrgentLatency);
10218 dml_get_var_func(wm_fclk_change, dml_float_t, mode_lib->mp.Watermark.FCLKChangeWatermark);
10219 dml_get_var_func(wm_usr_retraining, dml_float_t, mode_lib->mp.Watermark.USRRetrainingWatermark);
10220 dml_get_var_func(wm_dram_clock_change, dml_float_t, mode_lib->mp.Watermark.DRAMClockChangeWatermark);
10221 dml_get_var_func(wm_z8_stutter_enter_exit, dml_float_t, mode_lib->mp.Watermark.Z8StutterEnterPlusExitWatermark);
10222 dml_get_var_func(wm_z8_stutter, dml_float_t, mode_lib->mp.Watermark.Z8StutterExitWatermark);
10223 dml_get_var_func(fraction_of_urgent_bandwidth, dml_float_t, mode_lib->mp.FractionOfUrgentBandwidth);
10224 dml_get_var_func(fraction_of_urgent_bandwidth_imm_flip, dml_float_t, mode_lib->mp.FractionOfUrgentBandwidthImmediateFlip);
10225 dml_get_var_func(urgent_latency, dml_float_t, mode_lib->mp.UrgentLatency);
10226 dml_get_var_func(clk_dcf_deepsleep, dml_float_t, mode_lib->mp.DCFCLKDeepSleep);
10227 dml_get_var_func(wm_writeback_dram_clock_change, dml_float_t, mode_lib->mp.Watermark.WritebackDRAMClockChangeWatermark);
10228 dml_get_var_func(wm_writeback_urgent, dml_float_t, mode_lib->mp.Watermark.WritebackUrgentWatermark);
10229 dml_get_var_func(stutter_efficiency, dml_float_t, mode_lib->mp.StutterEfficiency);
10230 dml_get_var_func(stutter_efficiency_no_vblank, dml_float_t, mode_lib->mp.StutterEfficiencyNotIncludingVBlank);
10231 dml_get_var_func(stutter_efficiency_z8, dml_float_t, mode_lib->mp.Z8StutterEfficiency);
10232 dml_get_var_func(stutter_num_bursts_z8, dml_float_t, mode_lib->mp.Z8NumberOfStutterBurstsPerFrame);
10233 dml_get_var_func(stutter_period, dml_float_t, mode_lib->mp.StutterPeriod);
10234 dml_get_var_func(stutter_efficiency_z8_bestcase, dml_float_t, mode_lib->mp.Z8StutterEfficiencyBestCase);
10235 dml_get_var_func(stutter_num_bursts_z8_bestcase, dml_float_t, mode_lib->mp.Z8NumberOfStutterBurstsPerFrameBestCase);
10236 dml_get_var_func(stutter_period_bestcase, dml_float_t, mode_lib->mp.StutterPeriodBestCase);
10237 dml_get_var_func(urgent_extra_latency, dml_float_t, mode_lib->mp.UrgentExtraLatency);
10238 dml_get_var_func(fclk_change_latency, dml_float_t, mode_lib->mp.MaxActiveFCLKChangeLatencySupported);
10239 dml_get_var_func(dispclk_calculated, dml_float_t, mode_lib->mp.Dispclk_calculated);
10240 dml_get_var_func(total_data_read_bw, dml_float_t, mode_lib->mp.TotalDataReadBandwidth);
10241 dml_get_var_func(return_bw, dml_float_t, mode_lib->ms.ReturnBW);
10242 dml_get_var_func(return_dram_bw, dml_float_t, mode_lib->ms.ReturnDRAMBW);
10243 dml_get_var_func(tcalc, dml_float_t, mode_lib->mp.TCalc);
10244 dml_get_var_func(comp_buffer_size_kbytes, dml_uint_t, mode_lib->mp.CompressedBufferSizeInkByte);
10245 dml_get_var_func(pixel_chunk_size_in_kbyte, dml_uint_t, mode_lib->ms.ip.pixel_chunk_size_kbytes);
10246 dml_get_var_func(alpha_pixel_chunk_size_in_kbyte, dml_uint_t, mode_lib->ms.ip.alpha_pixel_chunk_size_kbytes);
10247 dml_get_var_func(meta_chunk_size_in_kbyte, dml_uint_t, mode_lib->ms.ip.meta_chunk_size_kbytes);
10248 dml_get_var_func(min_pixel_chunk_size_in_byte, dml_uint_t, mode_lib->ms.ip.min_pixel_chunk_size_bytes);
10249 dml_get_var_func(min_meta_chunk_size_in_byte, dml_uint_t, mode_lib->ms.ip.min_meta_chunk_size_bytes);
10250 dml_get_var_func(total_immediate_flip_bytes, dml_uint_t, mode_lib->mp.TotImmediateFlipBytes);
10251
10252 dml_get_per_surface_var_func(dsc_delay, dml_uint_t, mode_lib->mp.DSCDelay); // this is the dsc latency
10253 dml_get_per_surface_var_func(dppclk_calculated, dml_float_t, mode_lib->mp.Dppclk_calculated);
10254 dml_get_per_surface_var_func(dscclk_calculated, dml_float_t, mode_lib->mp.DSCCLK_calculated);
10255 dml_get_per_surface_var_func(min_ttu_vblank_in_us, dml_float_t, mode_lib->mp.MinTTUVBlank);
10256 dml_get_per_surface_var_func(vratio_prefetch_l, dml_float_t, mode_lib->mp.VRatioPrefetchY);
10257 dml_get_per_surface_var_func(vratio_prefetch_c, dml_float_t, mode_lib->mp.VRatioPrefetchC);
10258 dml_get_per_surface_var_func(dst_x_after_scaler, dml_uint_t, mode_lib->mp.DSTXAfterScaler);
10259 dml_get_per_surface_var_func(dst_y_after_scaler, dml_uint_t, mode_lib->mp.DSTYAfterScaler);
10260 dml_get_per_surface_var_func(dst_y_per_vm_vblank, dml_float_t, mode_lib->mp.DestinationLinesToRequestVMInVBlank);
10261 dml_get_per_surface_var_func(dst_y_per_row_vblank, dml_float_t, mode_lib->mp.DestinationLinesToRequestRowInVBlank);
10262 dml_get_per_surface_var_func(dst_y_prefetch, dml_float_t, mode_lib->mp.DestinationLinesForPrefetch);
10263 dml_get_per_surface_var_func(dst_y_per_vm_flip, dml_float_t, mode_lib->mp.DestinationLinesToRequestVMInImmediateFlip);
10264 dml_get_per_surface_var_func(dst_y_per_row_flip, dml_float_t, mode_lib->mp.DestinationLinesToRequestRowInImmediateFlip);
10265 dml_get_per_surface_var_func(dst_y_per_pte_row_nom_l, dml_float_t, mode_lib->mp.DST_Y_PER_PTE_ROW_NOM_L);
10266 dml_get_per_surface_var_func(dst_y_per_pte_row_nom_c, dml_float_t, mode_lib->mp.DST_Y_PER_PTE_ROW_NOM_C);
10267 dml_get_per_surface_var_func(dst_y_per_meta_row_nom_l, dml_float_t, mode_lib->mp.DST_Y_PER_META_ROW_NOM_L);
10268 dml_get_per_surface_var_func(dst_y_per_meta_row_nom_c, dml_float_t, mode_lib->mp.DST_Y_PER_META_ROW_NOM_C);
10269 dml_get_per_surface_var_func(refcyc_per_vm_group_vblank_in_us, dml_float_t, mode_lib->mp.TimePerVMGroupVBlank);
10270 dml_get_per_surface_var_func(refcyc_per_vm_group_flip_in_us, dml_float_t, mode_lib->mp.TimePerVMGroupFlip);
10271 dml_get_per_surface_var_func(refcyc_per_vm_req_vblank_in_us, dml_float_t, mode_lib->mp.TimePerVMRequestVBlank);
10272 dml_get_per_surface_var_func(refcyc_per_vm_req_flip_in_us, dml_float_t, mode_lib->mp.TimePerVMRequestFlip);
10273 dml_get_per_surface_var_func(refcyc_per_vm_dmdata_in_us, dml_float_t, mode_lib->mp.Tdmdl_vm);
10274 dml_get_per_surface_var_func(dmdata_dl_delta_in_us, dml_float_t, mode_lib->mp.Tdmdl);
10275 dml_get_per_surface_var_func(refcyc_per_line_delivery_l_in_us, dml_float_t, mode_lib->mp.DisplayPipeLineDeliveryTimeLuma);
10276 dml_get_per_surface_var_func(refcyc_per_line_delivery_c_in_us, dml_float_t, mode_lib->mp.DisplayPipeLineDeliveryTimeChroma);
10277 dml_get_per_surface_var_func(refcyc_per_line_delivery_pre_l_in_us, dml_float_t, mode_lib->mp.DisplayPipeLineDeliveryTimeLumaPrefetch);
10278 dml_get_per_surface_var_func(refcyc_per_line_delivery_pre_c_in_us, dml_float_t, mode_lib->mp.DisplayPipeLineDeliveryTimeChromaPrefetch);
10279 dml_get_per_surface_var_func(refcyc_per_req_delivery_l_in_us, dml_float_t, mode_lib->mp.DisplayPipeRequestDeliveryTimeLuma);
10280 dml_get_per_surface_var_func(refcyc_per_req_delivery_c_in_us, dml_float_t, mode_lib->mp.DisplayPipeRequestDeliveryTimeChroma);
10281 dml_get_per_surface_var_func(refcyc_per_req_delivery_pre_l_in_us, dml_float_t, mode_lib->mp.DisplayPipeRequestDeliveryTimeLumaPrefetch);
10282 dml_get_per_surface_var_func(refcyc_per_req_delivery_pre_c_in_us, dml_float_t, mode_lib->mp.DisplayPipeRequestDeliveryTimeChromaPrefetch);
10283 dml_get_per_surface_var_func(refcyc_per_cursor_req_delivery_in_us, dml_float_t, mode_lib->mp.CursorRequestDeliveryTime);
10284 dml_get_per_surface_var_func(refcyc_per_cursor_req_delivery_pre_in_us, dml_float_t, mode_lib->mp.CursorRequestDeliveryTimePrefetch);
10285 dml_get_per_surface_var_func(refcyc_per_meta_chunk_nom_l_in_us, dml_float_t, mode_lib->mp.TimePerMetaChunkNominal);
10286 dml_get_per_surface_var_func(refcyc_per_meta_chunk_nom_c_in_us, dml_float_t, mode_lib->mp.TimePerChromaMetaChunkNominal);
10287 dml_get_per_surface_var_func(refcyc_per_meta_chunk_vblank_l_in_us, dml_float_t, mode_lib->mp.TimePerMetaChunkVBlank);
10288 dml_get_per_surface_var_func(refcyc_per_meta_chunk_vblank_c_in_us, dml_float_t, mode_lib->mp.TimePerChromaMetaChunkVBlank);
10289 dml_get_per_surface_var_func(refcyc_per_meta_chunk_flip_l_in_us, dml_float_t, mode_lib->mp.TimePerMetaChunkFlip);
10290 dml_get_per_surface_var_func(refcyc_per_meta_chunk_flip_c_in_us, dml_float_t, mode_lib->mp.TimePerChromaMetaChunkFlip);
10291 dml_get_per_surface_var_func(refcyc_per_pte_group_nom_l_in_us, dml_float_t, mode_lib->mp.time_per_pte_group_nom_luma);
10292 dml_get_per_surface_var_func(refcyc_per_pte_group_nom_c_in_us, dml_float_t, mode_lib->mp.time_per_pte_group_nom_chroma);
10293 dml_get_per_surface_var_func(refcyc_per_pte_group_vblank_l_in_us, dml_float_t, mode_lib->mp.time_per_pte_group_vblank_luma);
10294 dml_get_per_surface_var_func(refcyc_per_pte_group_vblank_c_in_us, dml_float_t, mode_lib->mp.time_per_pte_group_vblank_chroma);
10295 dml_get_per_surface_var_func(refcyc_per_pte_group_flip_l_in_us, dml_float_t, mode_lib->mp.time_per_pte_group_flip_luma);
10296 dml_get_per_surface_var_func(refcyc_per_pte_group_flip_c_in_us, dml_float_t, mode_lib->mp.time_per_pte_group_flip_chroma);
10297 dml_get_per_surface_var_func(dpte_group_size_in_bytes, dml_uint_t, mode_lib->mp.dpte_group_bytes);
10298 dml_get_per_surface_var_func(vm_group_size_in_bytes, dml_uint_t, mode_lib->mp.vm_group_bytes);
10299 dml_get_per_surface_var_func(swath_height_l, dml_uint_t, mode_lib->ms.SwathHeightY);
10300 dml_get_per_surface_var_func(swath_height_c, dml_uint_t, mode_lib->ms.SwathHeightC);
10301 dml_get_per_surface_var_func(dpte_row_height_l, dml_uint_t, mode_lib->mp.dpte_row_height);
10302 dml_get_per_surface_var_func(dpte_row_height_c, dml_uint_t, mode_lib->mp.dpte_row_height_chroma);
10303 dml_get_per_surface_var_func(dpte_row_height_linear_l, dml_uint_t, mode_lib->mp.dpte_row_height_linear);
10304 dml_get_per_surface_var_func(dpte_row_height_linear_c, dml_uint_t, mode_lib->mp.dpte_row_height_linear_chroma);
10305 dml_get_per_surface_var_func(meta_row_height_l, dml_uint_t, mode_lib->mp.meta_row_height);
10306 dml_get_per_surface_var_func(meta_row_height_c, dml_uint_t, mode_lib->mp.meta_row_height_chroma);
10307
10308 dml_get_per_surface_var_func(vstartup_calculated, dml_uint_t, mode_lib->mp.VStartup);
10309 dml_get_per_surface_var_func(vupdate_offset, dml_uint_t, mode_lib->mp.VUpdateOffsetPix);
10310 dml_get_per_surface_var_func(vupdate_width, dml_uint_t, mode_lib->mp.VUpdateWidthPix);
10311 dml_get_per_surface_var_func(vready_offset, dml_uint_t, mode_lib->mp.VReadyOffsetPix);
10312 dml_get_per_surface_var_func(vready_at_or_after_vsync, dml_uint_t, mode_lib->mp.VREADY_AT_OR_AFTER_VSYNC);
10313 dml_get_per_surface_var_func(min_dst_y_next_start, dml_uint_t, mode_lib->mp.MIN_DST_Y_NEXT_START);
10314 dml_get_per_surface_var_func(det_stored_buffer_size_l_bytes, dml_uint_t, mode_lib->ms.DETBufferSizeY);
10315 dml_get_per_surface_var_func(det_stored_buffer_size_c_bytes, dml_uint_t, mode_lib->ms.DETBufferSizeC);
10316 dml_get_per_surface_var_func(use_mall_for_static_screen, dml_uint_t, mode_lib->mp.UsesMALLForStaticScreen);
10317 dml_get_per_surface_var_func(surface_size_for_mall, dml_uint_t, mode_lib->mp.SurfaceSizeInTheMALL);
10318 dml_get_per_surface_var_func(dcc_max_uncompressed_block_l, dml_uint_t, mode_lib->mp.DCCYMaxUncompressedBlock);
10319 dml_get_per_surface_var_func(dcc_max_compressed_block_l, dml_uint_t, mode_lib->mp.DCCYMaxCompressedBlock);
10320 dml_get_per_surface_var_func(dcc_independent_block_l, dml_uint_t, mode_lib->mp.DCCYIndependentBlock);
10321 dml_get_per_surface_var_func(dcc_max_uncompressed_block_c, dml_uint_t, mode_lib->mp.DCCCMaxUncompressedBlock);
10322 dml_get_per_surface_var_func(dcc_max_compressed_block_c, dml_uint_t, mode_lib->mp.DCCCMaxCompressedBlock);
10323 dml_get_per_surface_var_func(dcc_independent_block_c, dml_uint_t, mode_lib->mp.DCCCIndependentBlock);
10324 dml_get_per_surface_var_func(max_active_dram_clock_change_latency_supported, dml_uint_t, mode_lib->mp.MaxActiveDRAMClockChangeLatencySupported);
10325 dml_get_per_surface_var_func(pte_buffer_mode, dml_uint_t, mode_lib->mp.PTE_BUFFER_MODE);
10326 dml_get_per_surface_var_func(bigk_fragment_size, dml_uint_t, mode_lib->mp.BIGK_FRAGMENT_SIZE);
10327 dml_get_per_surface_var_func(dpte_bytes_per_row, dml_uint_t, mode_lib->mp.PixelPTEBytesPerRow);
10328 dml_get_per_surface_var_func(meta_bytes_per_row, dml_uint_t, mode_lib->mp.MetaRowByte);
10329 dml_get_per_surface_var_func(det_buffer_size_kbytes, dml_uint_t, mode_lib->ms.DETBufferSizeInKByte);
10330