2 * Copyright 2017 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
27 #include "../display_mode_lib.h"
28 #include "../dml_inline_defs.h"
29 #include "../display_mode_vba.h"
30 #include "display_mode_vba_21.h"
35 * This file is gcc-parsable HW gospel, coming straight from HW engineers.
37 * It doesn't adhere to Linux kernel style and sometimes will do things in odd
38 * ways. Unless there is something clearly wrong with it the code should
39 * remain as-is as it provides us with a guarantee from HW that it is correct.
45 double DCFCLKDeepSleep;
46 unsigned int DPPPerPlane;
48 enum scan_direction_class SourceScan;
49 unsigned int BlockWidth256BytesY;
50 unsigned int BlockHeight256BytesY;
51 unsigned int BlockWidth256BytesC;
52 unsigned int BlockHeight256BytesC;
53 unsigned int InterlaceEnable;
54 unsigned int NumberOfCursors;
61 unsigned int MaxPageTableLevels;
62 unsigned int CachedPageTableLevels;
66 #define BPP_BLENDED_PIPE 0xffffffff
67 #define DCN21_MAX_DSC_IMAGE_WIDTH 5184
68 #define DCN21_MAX_420_IMAGE_WIDTH 4096
70 static void DisplayPipeConfiguration(struct display_mode_lib *mode_lib);
71 static void DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation(
72 struct display_mode_lib *mode_lib);
73 static unsigned int dscceComputeDelay(
76 unsigned int sliceWidth,
77 unsigned int numSlices,
78 enum output_format_class pixelFormat);
79 static unsigned int dscComputeDelay(enum output_format_class pixelFormat);
80 // Super monster function with some 45 argument
81 static bool CalculatePrefetchSchedule(
82 struct display_mode_lib *mode_lib,
83 double PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData,
84 double PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly,
86 unsigned int DSCDelay,
87 double DPPCLKDelaySubtotal,
88 double DPPCLKDelaySCL,
89 double DPPCLKDelaySCLLBOnly,
90 double DPPCLKDelayCNVCFormater,
91 double DPPCLKDelayCNVCCursor,
92 double DISPCLKDelaySubtotal,
93 unsigned int ScalerRecoutWidth,
94 enum output_format_class OutputFormat,
95 unsigned int MaxInterDCNTileRepeaters,
96 unsigned int VStartup,
97 unsigned int MaxVStartup,
98 unsigned int GPUVMPageTableLevels,
101 bool DynamicMetadataEnable,
102 int DynamicMetadataLinesBeforeActiveRequired,
103 unsigned int DynamicMetadataTransmittedBytes,
105 double UrgentLatency,
106 double UrgentExtraLatency,
108 unsigned int PDEAndMetaPTEBytesFrame,
109 unsigned int MetaRowByte,
110 unsigned int PixelPTEBytesPerRow,
111 double PrefetchSourceLinesY,
112 unsigned int SwathWidthY,
113 double BytePerPixelDETY,
114 double VInitPreFillY,
115 unsigned int MaxNumSwathY,
116 double PrefetchSourceLinesC,
117 double BytePerPixelDETC,
118 double VInitPreFillC,
119 unsigned int MaxNumSwathC,
120 unsigned int SwathHeightY,
121 unsigned int SwathHeightC,
124 double XFCRemoteSurfaceFlipDelay,
125 bool ProgressiveToInterlaceUnitInOPP,
126 double *DSTXAfterScaler,
127 double *DSTYAfterScaler,
128 double *DestinationLinesForPrefetch,
129 double *PrefetchBandwidth,
130 double *DestinationLinesToRequestVMInVBlank,
131 double *DestinationLinesToRequestRowInVBlank,
132 double *VRatioPrefetchY,
133 double *VRatioPrefetchC,
134 double *RequiredPrefetchPixDataBWLuma,
135 double *RequiredPrefetchPixDataBWChroma,
136 unsigned int *VStartupRequiredWhenNotEnoughTimeForDynamicMetadata,
138 double *prefetch_vmrow_bw,
139 unsigned int *swath_width_luma_ub,
140 unsigned int *swath_width_chroma_ub,
141 unsigned int *VUpdateOffsetPix,
142 double *VUpdateWidthPix,
143 double *VReadyOffsetPix);
144 static double RoundToDFSGranularityUp(double Clock, double VCOSpeed);
145 static double RoundToDFSGranularityDown(double Clock, double VCOSpeed);
146 static double CalculateDCCConfiguration(
148 bool DCCProgrammingAssumesScanDirectionUnknown,
149 unsigned int ViewportWidth,
150 unsigned int ViewportHeight,
151 double DETBufferSize,
152 unsigned int RequestHeight256Byte,
153 unsigned int SwathHeight,
154 enum dm_swizzle_mode TilingFormat,
155 unsigned int BytePerPixel,
156 enum scan_direction_class ScanOrientation,
157 unsigned int *MaxUncompressedBlock,
158 unsigned int *MaxCompressedBlock,
159 unsigned int *Independent64ByteBlock);
160 static double CalculatePrefetchSourceLines(
161 struct display_mode_lib *mode_lib,
165 bool ProgressiveToInterlaceUnitInOPP,
166 unsigned int SwathHeight,
167 unsigned int ViewportYStart,
168 double *VInitPreFill,
169 unsigned int *MaxNumSwath);
170 static unsigned int CalculateVMAndRowBytes(
171 struct display_mode_lib *mode_lib,
173 unsigned int BlockHeight256Bytes,
174 unsigned int BlockWidth256Bytes,
175 enum source_format_class SourcePixelFormat,
176 unsigned int SurfaceTiling,
177 unsigned int BytePerPixel,
178 enum scan_direction_class ScanDirection,
179 unsigned int ViewportWidth,
180 unsigned int ViewportHeight,
181 unsigned int SwathWidthY,
184 unsigned int HostVMMaxPageTableLevels,
185 unsigned int HostVMCachedPageTableLevels,
186 unsigned int VMMPageSize,
187 unsigned int PTEBufferSizeInRequests,
189 unsigned int DCCMetaPitch,
190 unsigned int *MacroTileWidth,
191 unsigned int *MetaRowByte,
192 unsigned int *PixelPTEBytesPerRow,
193 bool *PTEBufferSizeNotExceeded,
194 unsigned int *dpte_row_width_ub,
195 unsigned int *dpte_row_height,
196 unsigned int *MetaRequestWidth,
197 unsigned int *MetaRequestHeight,
198 unsigned int *meta_row_width,
199 unsigned int *meta_row_height,
200 unsigned int *vm_group_bytes,
201 unsigned int *dpte_group_bytes,
202 unsigned int *PixelPTEReqWidth,
203 unsigned int *PixelPTEReqHeight,
204 unsigned int *PTERequestSize,
205 unsigned int *DPDE0BytesFrame,
206 unsigned int *MetaPTEBytesFrame);
208 static double CalculateTWait(
209 unsigned int PrefetchMode,
210 double DRAMClockChangeLatency,
211 double UrgentLatency,
212 double SREnterPlusExitTime);
213 static double CalculateRemoteSurfaceFlipDelay(
214 struct display_mode_lib *mode_lib,
219 double XFCTSlvVupdateOffset,
220 double XFCTSlvVupdateWidth,
221 double XFCTSlvVreadyOffset,
222 double XFCXBUFLatencyTolerance,
223 double XFCFillBWOverhead,
224 double XFCSlvChunkSize,
225 double XFCBusTransportTime,
228 double *SrcActiveDrainRate,
231 static void CalculateActiveRowBandwidth(
233 enum source_format_class SourcePixelFormat,
237 unsigned int MetaRowByteLuma,
238 unsigned int MetaRowByteChroma,
239 unsigned int meta_row_height_luma,
240 unsigned int meta_row_height_chroma,
241 unsigned int PixelPTEBytesPerRowLuma,
242 unsigned int PixelPTEBytesPerRowChroma,
243 unsigned int dpte_row_height_luma,
244 unsigned int dpte_row_height_chroma,
246 double *dpte_row_bw);
247 static void CalculateFlipSchedule(
248 struct display_mode_lib *mode_lib,
249 double PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData,
250 double PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly,
251 double UrgentExtraLatency,
252 double UrgentLatency,
253 unsigned int GPUVMMaxPageTableLevels,
255 unsigned int HostVMMaxPageTableLevels,
256 unsigned int HostVMCachedPageTableLevels,
258 double PDEAndMetaPTEBytesPerFrame,
260 double DPTEBytesPerRow,
261 double BandwidthAvailableForImmediateFlip,
262 unsigned int TotImmediateFlipBytes,
263 enum source_format_class SourcePixelFormat,
268 unsigned int dpte_row_height,
269 unsigned int meta_row_height,
270 unsigned int dpte_row_height_chroma,
271 unsigned int meta_row_height_chroma,
272 double *DestinationLinesToRequestVMInImmediateFlip,
273 double *DestinationLinesToRequestRowInImmediateFlip,
274 double *final_flip_bw,
275 bool *ImmediateFlipSupportedForPipe);
276 static double CalculateWriteBackDelay(
277 enum source_format_class WritebackPixelFormat,
278 double WritebackHRatio,
279 double WritebackVRatio,
280 unsigned int WritebackLumaHTaps,
281 unsigned int WritebackLumaVTaps,
282 unsigned int WritebackChromaHTaps,
283 unsigned int WritebackChromaVTaps,
284 unsigned int WritebackDestinationWidth);
285 static void CalculateWatermarksAndDRAMSpeedChangeSupport(
286 struct display_mode_lib *mode_lib,
287 unsigned int PrefetchMode,
288 unsigned int NumberOfActivePlanes,
289 unsigned int MaxLineBufferLines,
290 unsigned int LineBufferSize,
291 unsigned int DPPOutputBufferPixels,
292 double DETBufferSizeInKByte,
293 unsigned int WritebackInterfaceLumaBufferSize,
294 unsigned int WritebackInterfaceChromaBufferSize,
296 double UrgentOutOfOrderReturn,
299 int dpte_group_bytes[],
300 unsigned int MetaChunkSize,
301 double UrgentLatency,
303 double WritebackLatency,
304 double WritebackChunkSize,
306 double DRAMClockChangeLatency,
308 double SREnterPlusExitTime,
309 double DCFCLKDeepSleep,
313 double SwathWidthSingleDPPY[],
314 unsigned int SwathHeightY[],
315 double ReadBandwidthPlaneLuma[],
316 unsigned int SwathHeightC[],
317 double ReadBandwidthPlaneChroma[],
318 unsigned int LBBitPerPixel[],
319 double SwathWidthY[],
321 unsigned int vtaps[],
322 unsigned int VTAPsChroma[],
324 unsigned int HTotal[],
326 unsigned int BlendingAndTiming[],
327 double BytePerPixelDETY[],
328 double BytePerPixelDETC[],
329 bool WritebackEnable[],
330 enum source_format_class WritebackPixelFormat[],
331 double WritebackDestinationWidth[],
332 double WritebackDestinationHeight[],
333 double WritebackSourceHeight[],
334 enum clock_change_support *DRAMClockChangeSupport,
335 double *UrgentWatermark,
336 double *WritebackUrgentWatermark,
337 double *DRAMClockChangeWatermark,
338 double *WritebackDRAMClockChangeWatermark,
339 double *StutterExitWatermark,
340 double *StutterEnterPlusExitWatermark,
341 double *MinActiveDRAMClockChangeLatencySupported);
342 static void CalculateDCFCLKDeepSleep(
343 struct display_mode_lib *mode_lib,
344 unsigned int NumberOfActivePlanes,
345 double BytePerPixelDETY[],
346 double BytePerPixelDETC[],
348 double SwathWidthY[],
352 double PSCL_THROUGHPUT[],
353 double PSCL_THROUGHPUT_CHROMA[],
355 double *DCFCLKDeepSleep);
356 static void CalculateDETBufferSize(
357 double DETBufferSizeInKByte,
358 unsigned int SwathHeightY,
359 unsigned int SwathHeightC,
360 double *DETBufferSizeY,
361 double *DETBufferSizeC);
362 static void CalculateUrgentBurstFactor(
363 unsigned int DETBufferSizeInKByte,
364 unsigned int SwathHeightY,
365 unsigned int SwathHeightC,
366 unsigned int SwathWidthY,
368 double UrgentLatency,
369 double CursorBufferSize,
370 unsigned int CursorWidth,
371 unsigned int CursorBPP,
375 double BytePerPixelInDETY,
376 double BytePerPixelInDETC,
377 double *UrgentBurstFactorCursor,
378 double *UrgentBurstFactorCursorPre,
379 double *UrgentBurstFactorLuma,
380 double *UrgentBurstFactorLumaPre,
381 double *UrgentBurstFactorChroma,
382 double *UrgentBurstFactorChromaPre,
383 unsigned int *NotEnoughUrgentLatencyHiding,
384 unsigned int *NotEnoughUrgentLatencyHidingPre);
386 static void CalculatePixelDeliveryTimes(
387 unsigned int NumberOfActivePlanes,
389 double VRatioPrefetchY[],
390 double VRatioPrefetchC[],
391 unsigned int swath_width_luma_ub[],
392 unsigned int swath_width_chroma_ub[],
396 double PSCL_THROUGHPUT[],
397 double PSCL_THROUGHPUT_CHROMA[],
399 double BytePerPixelDETC[],
400 enum scan_direction_class SourceScan[],
401 unsigned int BlockWidth256BytesY[],
402 unsigned int BlockHeight256BytesY[],
403 unsigned int BlockWidth256BytesC[],
404 unsigned int BlockHeight256BytesC[],
405 double DisplayPipeLineDeliveryTimeLuma[],
406 double DisplayPipeLineDeliveryTimeChroma[],
407 double DisplayPipeLineDeliveryTimeLumaPrefetch[],
408 double DisplayPipeLineDeliveryTimeChromaPrefetch[],
409 double DisplayPipeRequestDeliveryTimeLuma[],
410 double DisplayPipeRequestDeliveryTimeChroma[],
411 double DisplayPipeRequestDeliveryTimeLumaPrefetch[],
412 double DisplayPipeRequestDeliveryTimeChromaPrefetch[]);
414 static void CalculateMetaAndPTETimes(
415 unsigned int NumberOfActivePlanes,
417 unsigned int MetaChunkSize,
418 unsigned int MinMetaChunkSizeBytes,
419 unsigned int GPUVMMaxPageTableLevels,
420 unsigned int HTotal[],
422 double VRatioPrefetchY[],
423 double VRatioPrefetchC[],
424 double DestinationLinesToRequestRowInVBlank[],
425 double DestinationLinesToRequestRowInImmediateFlip[],
426 double DestinationLinesToRequestVMInVBlank[],
427 double DestinationLinesToRequestVMInImmediateFlip[],
430 double BytePerPixelDETY[],
431 double BytePerPixelDETC[],
432 enum scan_direction_class SourceScan[],
433 unsigned int dpte_row_height[],
434 unsigned int dpte_row_height_chroma[],
435 unsigned int meta_row_width[],
436 unsigned int meta_row_height[],
437 unsigned int meta_req_width[],
438 unsigned int meta_req_height[],
439 int dpte_group_bytes[],
440 unsigned int PTERequestSizeY[],
441 unsigned int PTERequestSizeC[],
442 unsigned int PixelPTEReqWidthY[],
443 unsigned int PixelPTEReqHeightY[],
444 unsigned int PixelPTEReqWidthC[],
445 unsigned int PixelPTEReqHeightC[],
446 unsigned int dpte_row_width_luma_ub[],
447 unsigned int dpte_row_width_chroma_ub[],
448 unsigned int vm_group_bytes[],
449 unsigned int dpde0_bytes_per_frame_ub_l[],
450 unsigned int dpde0_bytes_per_frame_ub_c[],
451 unsigned int meta_pte_bytes_per_frame_ub_l[],
452 unsigned int meta_pte_bytes_per_frame_ub_c[],
453 double DST_Y_PER_PTE_ROW_NOM_L[],
454 double DST_Y_PER_PTE_ROW_NOM_C[],
455 double DST_Y_PER_META_ROW_NOM_L[],
456 double TimePerMetaChunkNominal[],
457 double TimePerMetaChunkVBlank[],
458 double TimePerMetaChunkFlip[],
459 double time_per_pte_group_nom_luma[],
460 double time_per_pte_group_vblank_luma[],
461 double time_per_pte_group_flip_luma[],
462 double time_per_pte_group_nom_chroma[],
463 double time_per_pte_group_vblank_chroma[],
464 double time_per_pte_group_flip_chroma[],
465 double TimePerVMGroupVBlank[],
466 double TimePerVMGroupFlip[],
467 double TimePerVMRequestVBlank[],
468 double TimePerVMRequestFlip[]);
470 static double CalculateExtraLatency(
471 double UrgentRoundTripAndOutOfOrderLatency,
472 int TotalNumberOfActiveDPP,
473 int PixelChunkSizeInKByte,
474 int TotalNumberOfDCCActiveDPP,
479 int NumberOfActivePlanes,
481 int dpte_group_bytes[],
482 double PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData,
483 double PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly,
484 int HostVMMaxPageTableLevels,
485 int HostVMCachedPageTableLevels);
487 void dml21_recalculate(struct display_mode_lib *mode_lib)
489 ModeSupportAndSystemConfiguration(mode_lib);
490 PixelClockAdjustmentForProgressiveToInterlaceUnit(mode_lib);
491 DisplayPipeConfiguration(mode_lib);
492 DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation(mode_lib);
495 static unsigned int dscceComputeDelay(
498 unsigned int sliceWidth,
499 unsigned int numSlices,
500 enum output_format_class pixelFormat)
502 // valid bpc = source bits per component in the set of {8, 10, 12}
503 // valid bpp = increments of 1/16 of a bit
504 // min = 6/7/8 in N420/N422/444, respectively
505 // max = such that compression is 1:1
506 //valid sliceWidth = number of pixels per slice line, must be less than or equal to 5184/numSlices (or 4096/numSlices in 420 mode)
507 //valid numSlices = number of slices in the horiziontal direction per DSC engine in the set of {1, 2, 3, 4}
508 //valid pixelFormat = pixel/color format in the set of {:N444_RGB, :S422, :N422, :N420}
511 unsigned int rcModelSize = 8192;
513 // N422/N420 operate at 2 pixels per clock
514 unsigned int pixelsPerClock, lstall, D, initalXmitDelay, w, S, ix, wx, p, l0, a, ax, l,
517 if (pixelFormat == dm_n422 || pixelFormat == dm_420)
519 // #all other modes operate at 1 pixel per clock
523 //initial transmit delay as per PPS
524 initalXmitDelay = dml_round(rcModelSize / 2.0 / bpp / pixelsPerClock);
534 //divide by pixel per cycle to compute slice width as seen by DSC
535 w = sliceWidth / pixelsPerClock;
537 //422 mode has an additional cycle of delay
538 if (pixelFormat == dm_s422)
543 //main calculation for the dscce
544 ix = initalXmitDelay + 45;
549 ax = (a + 2) / 3 + D + 6 + 1;
550 l = (ax + wx - 1) / wx;
551 if ((ix % w) == 0 && p != 0)
555 Delay = l * wx * (numSlices - 1) + ax + S + lstall + 22;
557 //dsc processes 3 pixel containers per cycle and a container can contain 1 or 2 pixels
558 pixels = Delay * 3 * pixelsPerClock;
562 static unsigned int dscComputeDelay(enum output_format_class pixelFormat)
564 unsigned int Delay = 0;
566 if (pixelFormat == dm_420) {
571 // dscc - input deserializer
573 // dscc gets pixels every other cycle
575 // dscc - input cdc fifo
577 // dscc gets pixels every other cycle
579 // dscc - cdc uncertainty
581 // dscc - output cdc fifo
583 // dscc gets pixels every other cycle
585 // dscc - cdc uncertainty
587 // dscc - output serializer
591 } else if (pixelFormat == dm_n422) {
596 // dscc - input deserializer
598 // dscc - input cdc fifo
600 // dscc - cdc uncertainty
602 // dscc - output cdc fifo
604 // dscc - cdc uncertainty
606 // dscc - output serializer
615 // dscc - input deserializer
617 // dscc - input cdc fifo
619 // dscc - cdc uncertainty
621 // dscc - output cdc fifo
623 // dscc - output serializer
625 // dscc - cdc uncertainty
634 static bool CalculatePrefetchSchedule(
635 struct display_mode_lib *mode_lib,
636 double PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData,
637 double PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly,
639 unsigned int DSCDelay,
640 double DPPCLKDelaySubtotal,
641 double DPPCLKDelaySCL,
642 double DPPCLKDelaySCLLBOnly,
643 double DPPCLKDelayCNVCFormater,
644 double DPPCLKDelayCNVCCursor,
645 double DISPCLKDelaySubtotal,
646 unsigned int ScalerRecoutWidth,
647 enum output_format_class OutputFormat,
648 unsigned int MaxInterDCNTileRepeaters,
649 unsigned int VStartup,
650 unsigned int MaxVStartup,
651 unsigned int GPUVMPageTableLevels,
654 bool DynamicMetadataEnable,
655 int DynamicMetadataLinesBeforeActiveRequired,
656 unsigned int DynamicMetadataTransmittedBytes,
658 double UrgentLatency,
659 double UrgentExtraLatency,
661 unsigned int PDEAndMetaPTEBytesFrame,
662 unsigned int MetaRowByte,
663 unsigned int PixelPTEBytesPerRow,
664 double PrefetchSourceLinesY,
665 unsigned int SwathWidthY,
666 double BytePerPixelDETY,
667 double VInitPreFillY,
668 unsigned int MaxNumSwathY,
669 double PrefetchSourceLinesC,
670 double BytePerPixelDETC,
671 double VInitPreFillC,
672 unsigned int MaxNumSwathC,
673 unsigned int SwathHeightY,
674 unsigned int SwathHeightC,
677 double XFCRemoteSurfaceFlipDelay,
678 bool ProgressiveToInterlaceUnitInOPP,
679 double *DSTXAfterScaler,
680 double *DSTYAfterScaler,
681 double *DestinationLinesForPrefetch,
682 double *PrefetchBandwidth,
683 double *DestinationLinesToRequestVMInVBlank,
684 double *DestinationLinesToRequestRowInVBlank,
685 double *VRatioPrefetchY,
686 double *VRatioPrefetchC,
687 double *RequiredPrefetchPixDataBWLuma,
688 double *RequiredPrefetchPixDataBWChroma,
689 unsigned int *VStartupRequiredWhenNotEnoughTimeForDynamicMetadata,
691 double *prefetch_vmrow_bw,
692 unsigned int *swath_width_luma_ub,
693 unsigned int *swath_width_chroma_ub,
694 unsigned int *VUpdateOffsetPix,
695 double *VUpdateWidthPix,
696 double *VReadyOffsetPix)
698 bool MyError = false;
699 unsigned int DPPCycles, DISPCLKCycles;
700 double DSTTotalPixelsAfterScaler, TotalRepeaterDelayTime;
701 double Tdm, LineTime, Tsetup;
702 double dst_y_prefetch_equ;
704 double prefetch_bw_oto;
707 double Tvm_oto_lines;
708 double Tr0_oto_lines;
709 double Tsw_oto_lines;
710 double dst_y_prefetch_oto;
711 double TimeForFetchingMetaPTE = 0;
712 double TimeForFetchingRowInVBlank = 0;
713 double LinesToRequestPrefetchPixelData = 0;
714 double HostVMInefficiencyFactor;
715 unsigned int HostVMDynamicLevels;
717 if (GPUVMEnable == true && myHostVM->Enable == true) {
718 HostVMInefficiencyFactor =
719 PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData
720 / PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly;
721 HostVMDynamicLevels = myHostVM->MaxPageTableLevels
722 - myHostVM->CachedPageTableLevels;
724 HostVMInefficiencyFactor = 1;
725 HostVMDynamicLevels = 0;
728 if (myPipe->ScalerEnabled)
729 DPPCycles = DPPCLKDelaySubtotal + DPPCLKDelaySCL;
731 DPPCycles = DPPCLKDelaySubtotal + DPPCLKDelaySCLLBOnly;
733 DPPCycles = DPPCycles + DPPCLKDelayCNVCFormater + myPipe->NumberOfCursors * DPPCLKDelayCNVCCursor;
735 DISPCLKCycles = DISPCLKDelaySubtotal;
737 if (myPipe->DPPCLK == 0.0 || myPipe->DISPCLK == 0.0)
740 *DSTXAfterScaler = DPPCycles * myPipe->PixelClock / myPipe->DPPCLK
741 + DISPCLKCycles * myPipe->PixelClock / myPipe->DISPCLK + DSCDelay;
743 if (myPipe->DPPPerPlane > 1)
744 *DSTXAfterScaler = *DSTXAfterScaler + ScalerRecoutWidth;
746 if (OutputFormat == dm_420 || (myPipe->InterlaceEnable && ProgressiveToInterlaceUnitInOPP))
747 *DSTYAfterScaler = 1;
749 *DSTYAfterScaler = 0;
751 DSTTotalPixelsAfterScaler = ((double) (*DSTYAfterScaler * myPipe->HTotal)) + *DSTXAfterScaler;
752 *DSTYAfterScaler = dml_floor(DSTTotalPixelsAfterScaler / myPipe->HTotal, 1);
753 *DSTXAfterScaler = DSTTotalPixelsAfterScaler - ((double) (*DSTYAfterScaler * myPipe->HTotal));
755 *VUpdateOffsetPix = dml_ceil(myPipe->HTotal / 4.0, 1);
756 TotalRepeaterDelayTime = MaxInterDCNTileRepeaters * (2.0 / myPipe->DPPCLK + 3.0 / myPipe->DISPCLK);
757 *VUpdateWidthPix = (14.0 / myPipe->DCFCLKDeepSleep + 12.0 / myPipe->DPPCLK + TotalRepeaterDelayTime)
758 * myPipe->PixelClock;
760 *VReadyOffsetPix = dml_max(
761 150.0 / myPipe->DPPCLK,
762 TotalRepeaterDelayTime + 20.0 / myPipe->DCFCLKDeepSleep + 10.0 / myPipe->DPPCLK)
763 * myPipe->PixelClock;
765 Tsetup = (double) (*VUpdateOffsetPix + *VUpdateWidthPix + *VReadyOffsetPix) / myPipe->PixelClock;
767 LineTime = (double) myPipe->HTotal / myPipe->PixelClock;
769 if (DynamicMetadataEnable) {
770 double Tdmbf, Tdmec, Tdmsks;
772 Tdm = dml_max(0.0, UrgentExtraLatency - TCalc);
773 Tdmbf = DynamicMetadataTransmittedBytes / 4.0 / myPipe->DISPCLK;
775 if (DynamicMetadataLinesBeforeActiveRequired == -1)
776 Tdmsks = myPipe->VBlank * LineTime / 2.0;
778 Tdmsks = DynamicMetadataLinesBeforeActiveRequired * LineTime;
779 if (myPipe->InterlaceEnable && !ProgressiveToInterlaceUnitInOPP)
781 if (VStartup * LineTime
782 < Tsetup + TWait + UrgentExtraLatency + Tdmbf + Tdmec + Tdmsks) {
784 *VStartupRequiredWhenNotEnoughTimeForDynamicMetadata = (Tsetup + TWait
785 + UrgentExtraLatency + Tdmbf + Tdmec + Tdmsks) / LineTime;
787 *VStartupRequiredWhenNotEnoughTimeForDynamicMetadata = 0.0;
792 if (GPUVMPageTableLevels >= 3)
793 *Tno_bw = UrgentExtraLatency + UrgentLatency * ((GPUVMPageTableLevels - 2) * (myHostVM->MaxPageTableLevels + 1) - 1);
796 } else if (!DCCEnable)
799 *Tno_bw = LineTime / 4;
801 dst_y_prefetch_equ = VStartup - dml_max(TCalc + TWait, XFCRemoteSurfaceFlipDelay) / LineTime
802 - (Tsetup + Tdm) / LineTime
803 - (*DSTYAfterScaler + *DSTXAfterScaler / myPipe->HTotal);
805 Tsw_oto = dml_max(PrefetchSourceLinesY, PrefetchSourceLinesC) * LineTime;
807 if (myPipe->SourceScan == dm_horz) {
808 *swath_width_luma_ub = dml_ceil(SwathWidthY - 1, myPipe->BlockWidth256BytesY) + myPipe->BlockWidth256BytesY;
809 *swath_width_chroma_ub = dml_ceil(SwathWidthY / 2 - 1, myPipe->BlockWidth256BytesC) + myPipe->BlockWidth256BytesC;
811 *swath_width_luma_ub = dml_ceil(SwathWidthY - 1, myPipe->BlockHeight256BytesY) + myPipe->BlockHeight256BytesY;
812 *swath_width_chroma_ub = dml_ceil(SwathWidthY / 2 - 1, myPipe->BlockHeight256BytesC) + myPipe->BlockHeight256BytesC;
815 prefetch_bw_oto = (PrefetchSourceLinesY * *swath_width_luma_ub * dml_ceil(BytePerPixelDETY, 1) + PrefetchSourceLinesC * *swath_width_chroma_ub * dml_ceil(BytePerPixelDETC, 2)) / Tsw_oto;
818 if (GPUVMEnable == true) {
819 Tvm_oto = dml_max(*Tno_bw + PDEAndMetaPTEBytesFrame * HostVMInefficiencyFactor / prefetch_bw_oto,
820 dml_max(UrgentExtraLatency + UrgentLatency * (GPUVMPageTableLevels * (HostVMDynamicLevels + 1) - 1),
823 Tvm_oto = LineTime / 4.0;
825 if ((GPUVMEnable == true || DCCEnable == true)) {
827 (MetaRowByte + PixelPTEBytesPerRow * HostVMInefficiencyFactor) / prefetch_bw_oto,
828 dml_max(UrgentLatency * (HostVMDynamicLevels + 1), dml_max(LineTime - Tvm_oto, LineTime / 4)));
830 Tr0_oto = (LineTime - Tvm_oto) / 2.0;
832 Tvm_oto_lines = dml_ceil(4 * Tvm_oto / LineTime, 1) / 4.0;
833 Tr0_oto_lines = dml_ceil(4 * Tr0_oto / LineTime, 1) / 4.0;
834 Tsw_oto_lines = dml_ceil(4 * Tsw_oto / LineTime, 1) / 4.0;
835 dst_y_prefetch_oto = Tvm_oto_lines + 2 * Tr0_oto_lines + Tsw_oto_lines + 0.75;
837 dst_y_prefetch_equ = dml_floor(4.0 * (dst_y_prefetch_equ + 0.125), 1) / 4.0;
839 if (dst_y_prefetch_oto < dst_y_prefetch_equ)
840 *DestinationLinesForPrefetch = dst_y_prefetch_oto;
842 *DestinationLinesForPrefetch = dst_y_prefetch_equ;
844 dml_print("DML: VStartup: %d\n", VStartup);
845 dml_print("DML: TCalc: %f\n", TCalc);
846 dml_print("DML: TWait: %f\n", TWait);
847 dml_print("DML: XFCRemoteSurfaceFlipDelay: %f\n", XFCRemoteSurfaceFlipDelay);
848 dml_print("DML: LineTime: %f\n", LineTime);
849 dml_print("DML: Tsetup: %f\n", Tsetup);
850 dml_print("DML: Tdm: %f\n", Tdm);
851 dml_print("DML: DSTYAfterScaler: %f\n", *DSTYAfterScaler);
852 dml_print("DML: DSTXAfterScaler: %f\n", *DSTXAfterScaler);
853 dml_print("DML: HTotal: %d\n", myPipe->HTotal);
855 *PrefetchBandwidth = 0;
856 *DestinationLinesToRequestVMInVBlank = 0;
857 *DestinationLinesToRequestRowInVBlank = 0;
858 *VRatioPrefetchY = 0;
859 *VRatioPrefetchC = 0;
860 *RequiredPrefetchPixDataBWLuma = 0;
861 if (*DestinationLinesForPrefetch > 1) {
862 double PrefetchBandwidth1 = (PDEAndMetaPTEBytesFrame * HostVMInefficiencyFactor + 2 * MetaRowByte
863 + 2 * PixelPTEBytesPerRow * HostVMInefficiencyFactor
864 + PrefetchSourceLinesY * *swath_width_luma_ub * dml_ceil(BytePerPixelDETY, 1)
865 + PrefetchSourceLinesC * *swath_width_chroma_ub * dml_ceil(BytePerPixelDETC, 2))
866 / (*DestinationLinesForPrefetch * LineTime - *Tno_bw);
868 double PrefetchBandwidth2 = (PDEAndMetaPTEBytesFrame *
869 HostVMInefficiencyFactor + PrefetchSourceLinesY *
870 *swath_width_luma_ub * dml_ceil(BytePerPixelDETY, 1) +
871 PrefetchSourceLinesC * *swath_width_chroma_ub *
872 dml_ceil(BytePerPixelDETC, 2)) /
873 (*DestinationLinesForPrefetch * LineTime - *Tno_bw - 2 *
874 UrgentLatency * (1 + HostVMDynamicLevels));
876 double PrefetchBandwidth3 = (2 * MetaRowByte + 2 * PixelPTEBytesPerRow
877 * HostVMInefficiencyFactor + PrefetchSourceLinesY *
878 *swath_width_luma_ub * dml_ceil(BytePerPixelDETY, 1) +
879 PrefetchSourceLinesC * *swath_width_chroma_ub *
880 dml_ceil(BytePerPixelDETC, 2)) /
881 (*DestinationLinesForPrefetch * LineTime -
882 UrgentExtraLatency - UrgentLatency * (GPUVMPageTableLevels
883 * (HostVMDynamicLevels + 1) - 1));
885 double PrefetchBandwidth4 = (PrefetchSourceLinesY * *swath_width_luma_ub *
886 dml_ceil(BytePerPixelDETY, 1) + PrefetchSourceLinesC *
887 *swath_width_chroma_ub * dml_ceil(BytePerPixelDETC, 2)) /
888 (*DestinationLinesForPrefetch * LineTime -
889 UrgentExtraLatency - UrgentLatency * (GPUVMPageTableLevels
890 * (HostVMDynamicLevels + 1) - 1) - 2 * UrgentLatency *
891 (1 + HostVMDynamicLevels));
893 if (VStartup == MaxVStartup && (PrefetchBandwidth1 > 4 * prefetch_bw_oto) && (*DestinationLinesForPrefetch - dml_ceil(Tsw_oto_lines, 1) / 4.0 - 0.75) * LineTime - *Tno_bw > 0) {
894 PrefetchBandwidth1 = (PDEAndMetaPTEBytesFrame * HostVMInefficiencyFactor + 2 * MetaRowByte + 2 * PixelPTEBytesPerRow * HostVMInefficiencyFactor) / ((*DestinationLinesForPrefetch - dml_ceil(Tsw_oto_lines, 1) / 4.0 - 0.75) * LineTime - *Tno_bw);
896 if (*Tno_bw + PDEAndMetaPTEBytesFrame * HostVMInefficiencyFactor / PrefetchBandwidth1 >= UrgentExtraLatency + UrgentLatency * (GPUVMPageTableLevels * (HostVMDynamicLevels + 1) - 1) && (MetaRowByte + PixelPTEBytesPerRow * HostVMInefficiencyFactor) / PrefetchBandwidth1 >= UrgentLatency * (1 + HostVMDynamicLevels)) {
897 *PrefetchBandwidth = PrefetchBandwidth1;
898 } else if (*Tno_bw + PDEAndMetaPTEBytesFrame * HostVMInefficiencyFactor / PrefetchBandwidth2 >= UrgentExtraLatency + UrgentLatency * (GPUVMPageTableLevels * (HostVMDynamicLevels + 1) - 1) && (MetaRowByte + PixelPTEBytesPerRow * HostVMInefficiencyFactor) / PrefetchBandwidth2 < UrgentLatency * (1 + HostVMDynamicLevels)) {
899 *PrefetchBandwidth = PrefetchBandwidth2;
900 } else if (*Tno_bw + PDEAndMetaPTEBytesFrame * HostVMInefficiencyFactor / PrefetchBandwidth3 < UrgentExtraLatency + UrgentLatency * (GPUVMPageTableLevels * (HostVMDynamicLevels + 1) - 1) && (MetaRowByte + PixelPTEBytesPerRow * HostVMInefficiencyFactor) / PrefetchBandwidth3 >= UrgentLatency * (1 + HostVMDynamicLevels)) {
901 *PrefetchBandwidth = PrefetchBandwidth3;
903 *PrefetchBandwidth = PrefetchBandwidth4;
907 TimeForFetchingMetaPTE = dml_max(*Tno_bw + (double) PDEAndMetaPTEBytesFrame * HostVMInefficiencyFactor / *PrefetchBandwidth,
908 dml_max(UrgentExtraLatency + UrgentLatency * (GPUVMPageTableLevels * (HostVMDynamicLevels + 1) - 1), LineTime / 4));
910 // 5/30/2018 - This was an optimization requested from Sy but now NumberOfCursors is no longer a factor
911 // so if this needs to be reinstated, then it should be officially done in the VBA code as well.
912 // if (mode_lib->NumberOfCursors > 0 || XFCEnabled)
913 TimeForFetchingMetaPTE = LineTime / 4;
915 // TimeForFetchingMetaPTE = 0.0;
918 if ((GPUVMEnable == true || DCCEnable == true)) {
919 TimeForFetchingRowInVBlank =
921 (MetaRowByte + PixelPTEBytesPerRow * HostVMInefficiencyFactor)
922 / *PrefetchBandwidth,
924 UrgentLatency * (1 + HostVMDynamicLevels),
927 - TimeForFetchingMetaPTE) / 2.0,
931 // See note above dated 5/30/2018
932 // if (NumberOfCursors > 0 || XFCEnabled)
933 TimeForFetchingRowInVBlank = (LineTime - TimeForFetchingMetaPTE) / 2.0;
934 // else // TODO: Did someone else add this??
935 // TimeForFetchingRowInVBlank = 0.0;
938 *DestinationLinesToRequestVMInVBlank = dml_ceil(4.0 * TimeForFetchingMetaPTE / LineTime, 1.0) / 4.0;
940 *DestinationLinesToRequestRowInVBlank = dml_ceil(4.0 * TimeForFetchingRowInVBlank / LineTime, 1.0) / 4.0;
942 LinesToRequestPrefetchPixelData = *DestinationLinesForPrefetch
943 // See note above dated 5/30/2018
944 // - ((NumberOfCursors > 0 || GPUVMEnable || DCCEnable) ?
945 - ((GPUVMEnable || DCCEnable) ?
946 (*DestinationLinesToRequestVMInVBlank + 2 * *DestinationLinesToRequestRowInVBlank) :
947 0.0); // TODO: Did someone else add this??
949 if (LinesToRequestPrefetchPixelData > 0) {
951 *VRatioPrefetchY = (double) PrefetchSourceLinesY
952 / LinesToRequestPrefetchPixelData;
953 *VRatioPrefetchY = dml_max(*VRatioPrefetchY, 1.0);
954 if ((SwathHeightY > 4) && (VInitPreFillY > 3)) {
955 if (LinesToRequestPrefetchPixelData > (VInitPreFillY - 3.0) / 2.0) {
958 (double) PrefetchSourceLinesY
959 / LinesToRequestPrefetchPixelData,
960 (double) MaxNumSwathY
962 / (LinesToRequestPrefetchPixelData
966 *VRatioPrefetchY = dml_max(*VRatioPrefetchY, 1.0);
969 *VRatioPrefetchY = 0;
973 *VRatioPrefetchC = (double) PrefetchSourceLinesC
974 / LinesToRequestPrefetchPixelData;
975 *VRatioPrefetchC = dml_max(*VRatioPrefetchC, 1.0);
977 if ((SwathHeightC > 4)) {
978 if (LinesToRequestPrefetchPixelData > (VInitPreFillC - 3.0) / 2.0) {
982 (double) MaxNumSwathC
984 / (LinesToRequestPrefetchPixelData
988 *VRatioPrefetchC = dml_max(*VRatioPrefetchC, 1.0);
991 *VRatioPrefetchC = 0;
995 *RequiredPrefetchPixDataBWLuma = myPipe->DPPPerPlane
996 * (double) PrefetchSourceLinesY / LinesToRequestPrefetchPixelData
997 * dml_ceil(BytePerPixelDETY, 1)
998 * *swath_width_luma_ub / LineTime;
999 *RequiredPrefetchPixDataBWChroma = myPipe->DPPPerPlane
1000 * (double) PrefetchSourceLinesC / LinesToRequestPrefetchPixelData
1001 * dml_ceil(BytePerPixelDETC, 2)
1002 * *swath_width_chroma_ub / LineTime;
1005 *VRatioPrefetchY = 0;
1006 *VRatioPrefetchC = 0;
1007 *RequiredPrefetchPixDataBWLuma = 0;
1008 *RequiredPrefetchPixDataBWChroma = 0;
1011 dml_print("DML: Tvm: %fus\n", TimeForFetchingMetaPTE);
1012 dml_print("DML: Tr0: %fus\n", TimeForFetchingRowInVBlank);
1013 dml_print("DML: Tsw: %fus\n", (double)(*DestinationLinesForPrefetch) * LineTime - TimeForFetchingMetaPTE - TimeForFetchingRowInVBlank);
1014 dml_print("DML: Tpre: %fus\n", (double)(*DestinationLinesForPrefetch) * LineTime);
1015 dml_print("DML: row_bytes = dpte_row_bytes (per_pipe) = PixelPTEBytesPerRow = : %d\n", PixelPTEBytesPerRow);
1022 double prefetch_vm_bw;
1023 double prefetch_row_bw;
1025 if (PDEAndMetaPTEBytesFrame == 0) {
1027 } else if (*DestinationLinesToRequestVMInVBlank > 0) {
1028 prefetch_vm_bw = PDEAndMetaPTEBytesFrame * HostVMInefficiencyFactor / (*DestinationLinesToRequestVMInVBlank * LineTime);
1033 if (MetaRowByte + PixelPTEBytesPerRow == 0) {
1034 prefetch_row_bw = 0;
1035 } else if (*DestinationLinesToRequestRowInVBlank > 0) {
1036 prefetch_row_bw = (MetaRowByte + PixelPTEBytesPerRow * HostVMInefficiencyFactor) / (*DestinationLinesToRequestRowInVBlank * LineTime);
1038 prefetch_row_bw = 0;
1042 *prefetch_vmrow_bw = dml_max(prefetch_vm_bw, prefetch_row_bw);
1046 *PrefetchBandwidth = 0;
1047 TimeForFetchingMetaPTE = 0;
1048 TimeForFetchingRowInVBlank = 0;
1049 *DestinationLinesToRequestVMInVBlank = 0;
1050 *DestinationLinesToRequestRowInVBlank = 0;
1051 *DestinationLinesForPrefetch = 0;
1052 LinesToRequestPrefetchPixelData = 0;
1053 *VRatioPrefetchY = 0;
1054 *VRatioPrefetchC = 0;
1055 *RequiredPrefetchPixDataBWLuma = 0;
1056 *RequiredPrefetchPixDataBWChroma = 0;
1062 static double RoundToDFSGranularityUp(double Clock, double VCOSpeed)
1064 return VCOSpeed * 4 / dml_floor(VCOSpeed * 4 / Clock, 1);
1067 static double RoundToDFSGranularityDown(double Clock, double VCOSpeed)
1069 return VCOSpeed * 4 / dml_ceil(VCOSpeed * 4 / Clock, 1);
1072 static double CalculateDCCConfiguration(
1074 bool DCCProgrammingAssumesScanDirectionUnknown,
1075 unsigned int ViewportWidth,
1076 unsigned int ViewportHeight,
1077 double DETBufferSize,
1078 unsigned int RequestHeight256Byte,
1079 unsigned int SwathHeight,
1080 enum dm_swizzle_mode TilingFormat,
1081 unsigned int BytePerPixel,
1082 enum scan_direction_class ScanOrientation,
1083 unsigned int *MaxUncompressedBlock,
1084 unsigned int *MaxCompressedBlock,
1085 unsigned int *Independent64ByteBlock)
1087 double MaximumDCCCompressionSurface = 0.0;
1090 REQ_128BytesNonContiguous,
1091 REQ_128BytesContiguous,
1095 if (DCCEnabled == true) {
1096 if (DCCProgrammingAssumesScanDirectionUnknown == true) {
1097 if (DETBufferSize >= RequestHeight256Byte * ViewportWidth * BytePerPixel
1099 >= 256 / RequestHeight256Byte
1101 Request = REQ_256Bytes;
1102 } else if ((DETBufferSize
1103 < RequestHeight256Byte * ViewportWidth * BytePerPixel
1104 && (BytePerPixel == 2 || BytePerPixel == 4))
1106 < 256 / RequestHeight256Byte
1108 && BytePerPixel == 8
1109 && (TilingFormat == dm_sw_4kb_d
1123 == dm_sw_64kb_r_x))) {
1124 Request = REQ_128BytesNonContiguous;
1126 Request = REQ_128BytesContiguous;
1129 if (BytePerPixel == 1) {
1130 if (ScanOrientation == dm_vert || SwathHeight == 16) {
1131 Request = REQ_256Bytes;
1133 Request = REQ_128BytesContiguous;
1135 } else if (BytePerPixel == 2) {
1136 if ((ScanOrientation == dm_vert && SwathHeight == 16) || (ScanOrientation != dm_vert && SwathHeight == 8)) {
1137 Request = REQ_256Bytes;
1138 } else if (ScanOrientation == dm_vert) {
1139 Request = REQ_128BytesContiguous;
1141 Request = REQ_128BytesNonContiguous;
1143 } else if (BytePerPixel == 4) {
1144 if (SwathHeight == 8) {
1145 Request = REQ_256Bytes;
1146 } else if (ScanOrientation == dm_vert) {
1147 Request = REQ_128BytesContiguous;
1149 Request = REQ_128BytesNonContiguous;
1151 } else if (BytePerPixel == 8) {
1152 if (TilingFormat == dm_sw_4kb_d || TilingFormat == dm_sw_4kb_d_x
1153 || TilingFormat == dm_sw_var_d
1154 || TilingFormat == dm_sw_var_d_x
1155 || TilingFormat == dm_sw_64kb_d
1156 || TilingFormat == dm_sw_64kb_d_x
1157 || TilingFormat == dm_sw_64kb_d_t
1158 || TilingFormat == dm_sw_64kb_r_x) {
1159 if ((ScanOrientation == dm_vert && SwathHeight == 8)
1160 || (ScanOrientation != dm_vert
1161 && SwathHeight == 4)) {
1162 Request = REQ_256Bytes;
1163 } else if (ScanOrientation != dm_vert) {
1164 Request = REQ_128BytesContiguous;
1166 Request = REQ_128BytesNonContiguous;
1169 if (ScanOrientation != dm_vert || SwathHeight == 8) {
1170 Request = REQ_256Bytes;
1172 Request = REQ_128BytesContiguous;
1181 if (Request == REQ_256Bytes) {
1182 *MaxUncompressedBlock = 256;
1183 *MaxCompressedBlock = 256;
1184 *Independent64ByteBlock = false;
1185 MaximumDCCCompressionSurface = 4.0;
1186 } else if (Request == REQ_128BytesContiguous) {
1187 *MaxUncompressedBlock = 128;
1188 *MaxCompressedBlock = 128;
1189 *Independent64ByteBlock = false;
1190 MaximumDCCCompressionSurface = 2.0;
1191 } else if (Request == REQ_128BytesNonContiguous) {
1192 *MaxUncompressedBlock = 256;
1193 *MaxCompressedBlock = 64;
1194 *Independent64ByteBlock = true;
1195 MaximumDCCCompressionSurface = 4.0;
1197 *MaxUncompressedBlock = 0;
1198 *MaxCompressedBlock = 0;
1199 *Independent64ByteBlock = 0;
1200 MaximumDCCCompressionSurface = 0.0;
1203 return MaximumDCCCompressionSurface;
1206 static double CalculatePrefetchSourceLines(
1207 struct display_mode_lib *mode_lib,
1211 bool ProgressiveToInterlaceUnitInOPP,
1212 unsigned int SwathHeight,
1213 unsigned int ViewportYStart,
1214 double *VInitPreFill,
1215 unsigned int *MaxNumSwath)
1217 unsigned int MaxPartialSwath;
1219 if (ProgressiveToInterlaceUnitInOPP)
1220 *VInitPreFill = dml_floor((VRatio + vtaps + 1) / 2.0, 1);
1222 *VInitPreFill = dml_floor((VRatio + vtaps + 1 + Interlace * 0.5 * VRatio) / 2.0, 1);
1224 if (!mode_lib->vba.IgnoreViewportPositioning) {
1226 *MaxNumSwath = dml_ceil((*VInitPreFill - 1.0) / SwathHeight, 1) + 1.0;
1228 if (*VInitPreFill > 1.0)
1229 MaxPartialSwath = (unsigned int) (*VInitPreFill - 2) % SwathHeight;
1231 MaxPartialSwath = (unsigned int) (*VInitPreFill + SwathHeight - 2)
1233 MaxPartialSwath = dml_max(1U, MaxPartialSwath);
1237 if (ViewportYStart != 0)
1239 "WARNING DML: using viewport y position of 0 even though actual viewport y position is non-zero in prefetch source lines calculation\n");
1241 *MaxNumSwath = dml_ceil(*VInitPreFill / SwathHeight, 1);
1243 if (*VInitPreFill > 1.0)
1244 MaxPartialSwath = (unsigned int) (*VInitPreFill - 1) % SwathHeight;
1246 MaxPartialSwath = (unsigned int) (*VInitPreFill + SwathHeight - 1)
1250 return *MaxNumSwath * SwathHeight + MaxPartialSwath;
1253 static unsigned int CalculateVMAndRowBytes(
1254 struct display_mode_lib *mode_lib,
1256 unsigned int BlockHeight256Bytes,
1257 unsigned int BlockWidth256Bytes,
1258 enum source_format_class SourcePixelFormat,
1259 unsigned int SurfaceTiling,
1260 unsigned int BytePerPixel,
1261 enum scan_direction_class ScanDirection,
1262 unsigned int ViewportWidth,
1263 unsigned int ViewportHeight,
1264 unsigned int SwathWidth,
1267 unsigned int HostVMMaxPageTableLevels,
1268 unsigned int HostVMCachedPageTableLevels,
1269 unsigned int VMMPageSize,
1270 unsigned int PTEBufferSizeInRequests,
1272 unsigned int DCCMetaPitch,
1273 unsigned int *MacroTileWidth,
1274 unsigned int *MetaRowByte,
1275 unsigned int *PixelPTEBytesPerRow,
1276 bool *PTEBufferSizeNotExceeded,
1277 unsigned int *dpte_row_width_ub,
1278 unsigned int *dpte_row_height,
1279 unsigned int *MetaRequestWidth,
1280 unsigned int *MetaRequestHeight,
1281 unsigned int *meta_row_width,
1282 unsigned int *meta_row_height,
1283 unsigned int *vm_group_bytes,
1284 unsigned int *dpte_group_bytes,
1285 unsigned int *PixelPTEReqWidth,
1286 unsigned int *PixelPTEReqHeight,
1287 unsigned int *PTERequestSize,
1288 unsigned int *DPDE0BytesFrame,
1289 unsigned int *MetaPTEBytesFrame)
1291 unsigned int MPDEBytesFrame;
1292 unsigned int DCCMetaSurfaceBytes;
1293 unsigned int MacroTileSizeBytes;
1294 unsigned int MacroTileHeight;
1295 unsigned int ExtraDPDEBytesFrame;
1296 unsigned int PDEAndMetaPTEBytesFrame;
1297 unsigned int PixelPTEReqHeightPTEs = 0;
1299 if (DCCEnable == true) {
1300 *MetaRequestHeight = 8 * BlockHeight256Bytes;
1301 *MetaRequestWidth = 8 * BlockWidth256Bytes;
1302 if (ScanDirection == dm_horz) {
1303 *meta_row_height = *MetaRequestHeight;
1304 *meta_row_width = dml_ceil((double) SwathWidth - 1, *MetaRequestWidth)
1305 + *MetaRequestWidth;
1306 *MetaRowByte = *meta_row_width * *MetaRequestHeight * BytePerPixel / 256.0;
1308 *meta_row_height = *MetaRequestWidth;
1309 *meta_row_width = dml_ceil((double) SwathWidth - 1, *MetaRequestHeight)
1310 + *MetaRequestHeight;
1311 *MetaRowByte = *meta_row_width * *MetaRequestWidth * BytePerPixel / 256.0;
1313 if (ScanDirection == dm_horz) {
1314 DCCMetaSurfaceBytes = DCCMetaPitch
1315 * (dml_ceil(ViewportHeight - 1, 64 * BlockHeight256Bytes)
1316 + 64 * BlockHeight256Bytes) * BytePerPixel
1319 DCCMetaSurfaceBytes = DCCMetaPitch
1321 (double) ViewportHeight - 1,
1322 64 * BlockHeight256Bytes)
1323 + 64 * BlockHeight256Bytes) * BytePerPixel
1326 if (GPUVMEnable == true) {
1327 *MetaPTEBytesFrame = (dml_ceil(
1328 (double) (DCCMetaSurfaceBytes - VMMPageSize)
1329 / (8 * VMMPageSize),
1331 MPDEBytesFrame = 128 * ((mode_lib->vba.GPUVMMaxPageTableLevels + 1) * (mode_lib->vba.HostVMMaxPageTableLevels + 1) - 2);
1333 *MetaPTEBytesFrame = 0;
1337 *MetaPTEBytesFrame = 0;
1342 if (SurfaceTiling == dm_sw_linear || SurfaceTiling == dm_sw_gfx7_2d_thin_gl || SurfaceTiling == dm_sw_gfx7_2d_thin_l_vp) {
1343 MacroTileSizeBytes = 256;
1344 MacroTileHeight = BlockHeight256Bytes;
1345 } else if (SurfaceTiling == dm_sw_4kb_s || SurfaceTiling == dm_sw_4kb_s_x
1346 || SurfaceTiling == dm_sw_4kb_d || SurfaceTiling == dm_sw_4kb_d_x) {
1347 MacroTileSizeBytes = 4096;
1348 MacroTileHeight = 4 * BlockHeight256Bytes;
1349 } else if (SurfaceTiling == dm_sw_64kb_s || SurfaceTiling == dm_sw_64kb_s_t
1350 || SurfaceTiling == dm_sw_64kb_s_x || SurfaceTiling == dm_sw_64kb_d
1351 || SurfaceTiling == dm_sw_64kb_d_t || SurfaceTiling == dm_sw_64kb_d_x
1352 || SurfaceTiling == dm_sw_64kb_r_x) {
1353 MacroTileSizeBytes = 65536;
1354 MacroTileHeight = 16 * BlockHeight256Bytes;
1356 MacroTileSizeBytes = 262144;
1357 MacroTileHeight = 32 * BlockHeight256Bytes;
1359 *MacroTileWidth = MacroTileSizeBytes / BytePerPixel / MacroTileHeight;
1361 if (GPUVMEnable == true && (mode_lib->vba.GPUVMMaxPageTableLevels + 1) * (mode_lib->vba.HostVMMaxPageTableLevels + 1) > 2) {
1362 if (ScanDirection == dm_horz) {
1363 *DPDE0BytesFrame = 64 * (dml_ceil(((Pitch * (dml_ceil(ViewportHeight - 1, MacroTileHeight) + MacroTileHeight) * BytePerPixel) - MacroTileSizeBytes) / (8 * 2097152), 1) + 1);
1365 *DPDE0BytesFrame = 64 * (dml_ceil(((Pitch * (dml_ceil((double) SwathWidth - 1, MacroTileHeight) + MacroTileHeight) * BytePerPixel) - MacroTileSizeBytes) / (8 * 2097152), 1) + 1);
1367 ExtraDPDEBytesFrame = 128 * ((mode_lib->vba.GPUVMMaxPageTableLevels + 1) * (mode_lib->vba.HostVMMaxPageTableLevels + 1) - 3);
1369 *DPDE0BytesFrame = 0;
1370 ExtraDPDEBytesFrame = 0;
1373 PDEAndMetaPTEBytesFrame = *MetaPTEBytesFrame + MPDEBytesFrame + *DPDE0BytesFrame
1374 + ExtraDPDEBytesFrame;
1376 if (HostVMEnable == true) {
1377 PDEAndMetaPTEBytesFrame = PDEAndMetaPTEBytesFrame * (1 + 8 * (HostVMMaxPageTableLevels - HostVMCachedPageTableLevels));
1380 if (GPUVMEnable == true) {
1381 double FractionOfPTEReturnDrop;
1383 if (SurfaceTiling == dm_sw_linear) {
1384 PixelPTEReqHeightPTEs = 1;
1385 *PixelPTEReqHeight = 1;
1386 *PixelPTEReqWidth = 8.0 * VMMPageSize / BytePerPixel;
1387 *PTERequestSize = 64;
1388 FractionOfPTEReturnDrop = 0;
1389 } else if (MacroTileSizeBytes == 4096) {
1390 PixelPTEReqHeightPTEs = 1;
1391 *PixelPTEReqHeight = MacroTileHeight;
1392 *PixelPTEReqWidth = 8 * *MacroTileWidth;
1393 *PTERequestSize = 64;
1394 if (ScanDirection == dm_horz)
1395 FractionOfPTEReturnDrop = 0;
1397 FractionOfPTEReturnDrop = 7 / 8;
1398 } else if (VMMPageSize == 4096 && MacroTileSizeBytes > 4096) {
1399 PixelPTEReqHeightPTEs = 16;
1400 *PixelPTEReqHeight = 16 * BlockHeight256Bytes;
1401 *PixelPTEReqWidth = 16 * BlockWidth256Bytes;
1402 *PTERequestSize = 128;
1403 FractionOfPTEReturnDrop = 0;
1405 PixelPTEReqHeightPTEs = 1;
1406 *PixelPTEReqHeight = MacroTileHeight;
1407 *PixelPTEReqWidth = 8 * *MacroTileWidth;
1408 *PTERequestSize = 64;
1409 FractionOfPTEReturnDrop = 0;
1412 if (SurfaceTiling == dm_sw_linear) {
1413 *dpte_row_height = dml_min(128,
1414 1 << (unsigned int) dml_floor(
1416 (double) PTEBufferSizeInRequests * *PixelPTEReqWidth / Pitch),
1418 *dpte_row_width_ub = (dml_ceil((double) (Pitch * *dpte_row_height - 1) / *PixelPTEReqWidth, 1) + 1) * *PixelPTEReqWidth;
1419 *PixelPTEBytesPerRow = *dpte_row_width_ub / *PixelPTEReqWidth * *PTERequestSize;
1420 } else if (ScanDirection == dm_horz) {
1421 *dpte_row_height = *PixelPTEReqHeight;
1422 *dpte_row_width_ub = (dml_ceil((double) (SwathWidth - 1) / *PixelPTEReqWidth, 1) + 1) * *PixelPTEReqWidth;
1423 *PixelPTEBytesPerRow = *dpte_row_width_ub / *PixelPTEReqWidth * *PTERequestSize;
1425 *dpte_row_height = dml_min(*PixelPTEReqWidth, *MacroTileWidth);
1426 *dpte_row_width_ub = (dml_ceil((double) (SwathWidth - 1) / *PixelPTEReqHeight, 1) + 1) * *PixelPTEReqHeight;
1427 *PixelPTEBytesPerRow = *dpte_row_width_ub / *PixelPTEReqHeight * *PTERequestSize;
1429 if (*PixelPTEBytesPerRow * (1 - FractionOfPTEReturnDrop)
1430 <= 64 * PTEBufferSizeInRequests) {
1431 *PTEBufferSizeNotExceeded = true;
1433 *PTEBufferSizeNotExceeded = false;
1436 *PixelPTEBytesPerRow = 0;
1437 *PTEBufferSizeNotExceeded = true;
1439 dml_print("DML: vm_bytes = meta_pte_bytes_per_frame (per_pipe) = MetaPTEBytesFrame = : %d\n", *MetaPTEBytesFrame);
1441 if (HostVMEnable == true) {
1442 *PixelPTEBytesPerRow = *PixelPTEBytesPerRow * (1 + 8 * (HostVMMaxPageTableLevels - HostVMCachedPageTableLevels));
1445 if (HostVMEnable == true) {
1446 *vm_group_bytes = 512;
1447 *dpte_group_bytes = 512;
1448 } else if (GPUVMEnable == true) {
1449 *vm_group_bytes = 2048;
1450 if (SurfaceTiling != dm_sw_linear && PixelPTEReqHeightPTEs == 1 && ScanDirection != dm_horz) {
1451 *dpte_group_bytes = 512;
1453 *dpte_group_bytes = 2048;
1456 *vm_group_bytes = 0;
1457 *dpte_group_bytes = 0;
1460 return PDEAndMetaPTEBytesFrame;
1463 static void DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation(
1464 struct display_mode_lib *mode_lib)
1466 struct vba_vars_st *locals = &mode_lib->vba;
1469 mode_lib->vba.WritebackDISPCLK = 0.0;
1470 mode_lib->vba.DISPCLKWithRamping = 0;
1471 mode_lib->vba.DISPCLKWithoutRamping = 0;
1472 mode_lib->vba.GlobalDPPCLK = 0.0;
1474 // DISPCLK and DPPCLK Calculation
1476 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
1477 if (mode_lib->vba.WritebackEnable[k]) {
1478 mode_lib->vba.WritebackDISPCLK =
1480 mode_lib->vba.WritebackDISPCLK,
1481 CalculateWriteBackDISPCLK(
1482 mode_lib->vba.WritebackPixelFormat[k],
1483 mode_lib->vba.PixelClock[k],
1484 mode_lib->vba.WritebackHRatio[k],
1485 mode_lib->vba.WritebackVRatio[k],
1486 mode_lib->vba.WritebackLumaHTaps[k],
1487 mode_lib->vba.WritebackLumaVTaps[k],
1488 mode_lib->vba.WritebackChromaHTaps[k],
1489 mode_lib->vba.WritebackChromaVTaps[k],
1490 mode_lib->vba.WritebackDestinationWidth[k],
1491 mode_lib->vba.HTotal[k],
1492 mode_lib->vba.WritebackChromaLineBufferWidth));
1496 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
1497 if (mode_lib->vba.HRatio[k] > 1) {
1498 locals->PSCL_THROUGHPUT_LUMA[k] = dml_min(
1499 mode_lib->vba.MaxDCHUBToPSCLThroughput,
1500 mode_lib->vba.MaxPSCLToLBThroughput
1501 * mode_lib->vba.HRatio[k]
1503 mode_lib->vba.htaps[k]
1507 locals->PSCL_THROUGHPUT_LUMA[k] = dml_min(
1508 mode_lib->vba.MaxDCHUBToPSCLThroughput,
1509 mode_lib->vba.MaxPSCLToLBThroughput);
1512 mode_lib->vba.DPPCLKUsingSingleDPPLuma =
1513 mode_lib->vba.PixelClock[k]
1515 mode_lib->vba.vtaps[k] / 6.0
1518 mode_lib->vba.HRatio[k]),
1520 mode_lib->vba.HRatio[k]
1521 * mode_lib->vba.VRatio[k]
1522 / locals->PSCL_THROUGHPUT_LUMA[k],
1525 if ((mode_lib->vba.htaps[k] > 6 || mode_lib->vba.vtaps[k] > 6)
1526 && mode_lib->vba.DPPCLKUsingSingleDPPLuma
1527 < 2 * mode_lib->vba.PixelClock[k]) {
1528 mode_lib->vba.DPPCLKUsingSingleDPPLuma = 2 * mode_lib->vba.PixelClock[k];
1531 if ((mode_lib->vba.SourcePixelFormat[k] != dm_420_8
1532 && mode_lib->vba.SourcePixelFormat[k] != dm_420_10)) {
1533 locals->PSCL_THROUGHPUT_CHROMA[k] = 0.0;
1534 locals->DPPCLKUsingSingleDPP[k] =
1535 mode_lib->vba.DPPCLKUsingSingleDPPLuma;
1537 if (mode_lib->vba.HRatio[k] > 1) {
1538 locals->PSCL_THROUGHPUT_CHROMA[k] =
1540 mode_lib->vba.MaxDCHUBToPSCLThroughput,
1541 mode_lib->vba.MaxPSCLToLBThroughput
1542 * mode_lib->vba.HRatio[k]
1545 mode_lib->vba.HTAPsChroma[k]
1549 locals->PSCL_THROUGHPUT_CHROMA[k] = dml_min(
1550 mode_lib->vba.MaxDCHUBToPSCLThroughput,
1551 mode_lib->vba.MaxPSCLToLBThroughput);
1553 mode_lib->vba.DPPCLKUsingSingleDPPChroma =
1554 mode_lib->vba.PixelClock[k]
1556 mode_lib->vba.VTAPsChroma[k]
1560 mode_lib->vba.HRatio[k]
1563 mode_lib->vba.HRatio[k]
1564 * mode_lib->vba.VRatio[k]
1566 / locals->PSCL_THROUGHPUT_CHROMA[k],
1569 if ((mode_lib->vba.HTAPsChroma[k] > 6 || mode_lib->vba.VTAPsChroma[k] > 6)
1570 && mode_lib->vba.DPPCLKUsingSingleDPPChroma
1571 < 2 * mode_lib->vba.PixelClock[k]) {
1572 mode_lib->vba.DPPCLKUsingSingleDPPChroma = 2
1573 * mode_lib->vba.PixelClock[k];
1576 locals->DPPCLKUsingSingleDPP[k] = dml_max(
1577 mode_lib->vba.DPPCLKUsingSingleDPPLuma,
1578 mode_lib->vba.DPPCLKUsingSingleDPPChroma);
1582 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
1583 if (mode_lib->vba.BlendingAndTiming[k] != k)
1585 if (mode_lib->vba.ODMCombineEnabled[k]) {
1586 mode_lib->vba.DISPCLKWithRamping =
1588 mode_lib->vba.DISPCLKWithRamping,
1589 mode_lib->vba.PixelClock[k] / 2
1591 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading
1594 + mode_lib->vba.DISPCLKRampingMargin
1596 mode_lib->vba.DISPCLKWithoutRamping =
1598 mode_lib->vba.DISPCLKWithoutRamping,
1599 mode_lib->vba.PixelClock[k] / 2
1601 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading
1603 } else if (!mode_lib->vba.ODMCombineEnabled[k]) {
1604 mode_lib->vba.DISPCLKWithRamping =
1606 mode_lib->vba.DISPCLKWithRamping,
1607 mode_lib->vba.PixelClock[k]
1609 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading
1612 + mode_lib->vba.DISPCLKRampingMargin
1614 mode_lib->vba.DISPCLKWithoutRamping =
1616 mode_lib->vba.DISPCLKWithoutRamping,
1617 mode_lib->vba.PixelClock[k]
1619 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading
1624 mode_lib->vba.DISPCLKWithRamping = dml_max(
1625 mode_lib->vba.DISPCLKWithRamping,
1626 mode_lib->vba.WritebackDISPCLK);
1627 mode_lib->vba.DISPCLKWithoutRamping = dml_max(
1628 mode_lib->vba.DISPCLKWithoutRamping,
1629 mode_lib->vba.WritebackDISPCLK);
1631 ASSERT(mode_lib->vba.DISPCLKDPPCLKVCOSpeed != 0);
1632 mode_lib->vba.DISPCLKWithRampingRoundedToDFSGranularity = RoundToDFSGranularityUp(
1633 mode_lib->vba.DISPCLKWithRamping,
1634 mode_lib->vba.DISPCLKDPPCLKVCOSpeed);
1635 mode_lib->vba.DISPCLKWithoutRampingRoundedToDFSGranularity = RoundToDFSGranularityUp(
1636 mode_lib->vba.DISPCLKWithoutRamping,
1637 mode_lib->vba.DISPCLKDPPCLKVCOSpeed);
1638 mode_lib->vba.MaxDispclkRoundedToDFSGranularity = RoundToDFSGranularityDown(
1639 mode_lib->vba.soc.clock_limits[mode_lib->vba.soc.num_states - 1].dispclk_mhz,
1640 mode_lib->vba.DISPCLKDPPCLKVCOSpeed);
1641 if (mode_lib->vba.DISPCLKWithoutRampingRoundedToDFSGranularity
1642 > mode_lib->vba.MaxDispclkRoundedToDFSGranularity) {
1643 mode_lib->vba.DISPCLK_calculated =
1644 mode_lib->vba.DISPCLKWithoutRampingRoundedToDFSGranularity;
1645 } else if (mode_lib->vba.DISPCLKWithRampingRoundedToDFSGranularity
1646 > mode_lib->vba.MaxDispclkRoundedToDFSGranularity) {
1647 mode_lib->vba.DISPCLK_calculated = mode_lib->vba.MaxDispclkRoundedToDFSGranularity;
1649 mode_lib->vba.DISPCLK_calculated =
1650 mode_lib->vba.DISPCLKWithRampingRoundedToDFSGranularity;
1652 DTRACE(" dispclk_mhz (calculated) = %f", mode_lib->vba.DISPCLK_calculated);
1654 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
1655 mode_lib->vba.DPPCLK_calculated[k] = locals->DPPCLKUsingSingleDPP[k]
1656 / mode_lib->vba.DPPPerPlane[k]
1657 * (1 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100);
1658 mode_lib->vba.GlobalDPPCLK = dml_max(
1659 mode_lib->vba.GlobalDPPCLK,
1660 mode_lib->vba.DPPCLK_calculated[k]);
1662 mode_lib->vba.GlobalDPPCLK = RoundToDFSGranularityUp(
1663 mode_lib->vba.GlobalDPPCLK,
1664 mode_lib->vba.DISPCLKDPPCLKVCOSpeed);
1665 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
1666 mode_lib->vba.DPPCLK_calculated[k] = mode_lib->vba.GlobalDPPCLK / 255
1668 mode_lib->vba.DPPCLK_calculated[k] * 255
1669 / mode_lib->vba.GlobalDPPCLK,
1671 DTRACE(" dppclk_mhz[%i] (calculated) = %f", k, mode_lib->vba.DPPCLK_calculated[k]);
1674 // Urgent and B P-State/DRAM Clock Change Watermark
1675 DTRACE(" dcfclk_mhz = %f", mode_lib->vba.DCFCLK);
1676 DTRACE(" return_bw_to_dcn = %f", mode_lib->vba.ReturnBandwidthToDCN);
1677 DTRACE(" return_bus_bw = %f", mode_lib->vba.ReturnBW);
1679 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
1680 bool MainPlaneDoesODMCombine = false;
1682 if (mode_lib->vba.SourceScan[k] == dm_horz)
1683 locals->SwathWidthSingleDPPY[k] = mode_lib->vba.ViewportWidth[k];
1685 locals->SwathWidthSingleDPPY[k] = mode_lib->vba.ViewportHeight[k];
1687 if (mode_lib->vba.ODMCombineEnabled[k] == dm_odm_combine_mode_2to1)
1688 MainPlaneDoesODMCombine = true;
1689 for (j = 0; j < mode_lib->vba.NumberOfActivePlanes; ++j)
1690 if (mode_lib->vba.BlendingAndTiming[k] == j
1691 && mode_lib->vba.ODMCombineEnabled[k] == dm_odm_combine_mode_2to1)
1692 MainPlaneDoesODMCombine = true;
1694 if (MainPlaneDoesODMCombine == true)
1695 locals->SwathWidthY[k] = dml_min(
1696 (double) locals->SwathWidthSingleDPPY[k],
1698 mode_lib->vba.HActive[k] / 2.0
1699 * mode_lib->vba.HRatio[k]));
1701 locals->SwathWidthY[k] = locals->SwathWidthSingleDPPY[k]
1702 / mode_lib->vba.DPPPerPlane[k];
1705 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
1706 if (mode_lib->vba.SourcePixelFormat[k] == dm_444_64) {
1707 locals->BytePerPixelDETY[k] = 8;
1708 locals->BytePerPixelDETC[k] = 0;
1709 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_444_32) {
1710 locals->BytePerPixelDETY[k] = 4;
1711 locals->BytePerPixelDETC[k] = 0;
1712 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_444_16 || mode_lib->vba.SourcePixelFormat[k] == dm_mono_16) {
1713 locals->BytePerPixelDETY[k] = 2;
1714 locals->BytePerPixelDETC[k] = 0;
1715 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_444_8 || mode_lib->vba.SourcePixelFormat[k] == dm_mono_8) {
1716 locals->BytePerPixelDETY[k] = 1;
1717 locals->BytePerPixelDETC[k] = 0;
1718 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_420_8) {
1719 locals->BytePerPixelDETY[k] = 1;
1720 locals->BytePerPixelDETC[k] = 2;
1721 } else { // dm_420_10
1722 locals->BytePerPixelDETY[k] = 4.0 / 3.0;
1723 locals->BytePerPixelDETC[k] = 8.0 / 3.0;
1727 mode_lib->vba.TotalDataReadBandwidth = 0.0;
1728 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
1729 locals->ReadBandwidthPlaneLuma[k] = locals->SwathWidthSingleDPPY[k]
1730 * dml_ceil(locals->BytePerPixelDETY[k], 1)
1731 / (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k])
1732 * mode_lib->vba.VRatio[k];
1733 locals->ReadBandwidthPlaneChroma[k] = locals->SwathWidthSingleDPPY[k]
1734 / 2 * dml_ceil(locals->BytePerPixelDETC[k], 2)
1735 / (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k])
1736 * mode_lib->vba.VRatio[k] / 2;
1738 " read_bw[%i] = %fBps",
1740 locals->ReadBandwidthPlaneLuma[k]
1741 + locals->ReadBandwidthPlaneChroma[k]);
1742 mode_lib->vba.TotalDataReadBandwidth += locals->ReadBandwidthPlaneLuma[k]
1743 + locals->ReadBandwidthPlaneChroma[k];
1746 // DCFCLK Deep Sleep
1747 CalculateDCFCLKDeepSleep(
1749 mode_lib->vba.NumberOfActivePlanes,
1750 locals->BytePerPixelDETY,
1751 locals->BytePerPixelDETC,
1752 mode_lib->vba.VRatio,
1753 locals->SwathWidthY,
1754 mode_lib->vba.DPPPerPlane,
1755 mode_lib->vba.HRatio,
1756 mode_lib->vba.PixelClock,
1757 locals->PSCL_THROUGHPUT_LUMA,
1758 locals->PSCL_THROUGHPUT_CHROMA,
1760 &mode_lib->vba.DCFCLKDeepSleep);
1763 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
1764 if ((mode_lib->vba.BlendingAndTiming[k] != k) || !mode_lib->vba.DSCEnabled[k]) {
1765 locals->DSCCLK_calculated[k] = 0.0;
1767 if (mode_lib->vba.OutputFormat[k] == dm_420
1768 || mode_lib->vba.OutputFormat[k] == dm_n422)
1769 mode_lib->vba.DSCFormatFactor = 2;
1771 mode_lib->vba.DSCFormatFactor = 1;
1772 if (mode_lib->vba.ODMCombineEnabled[k])
1773 locals->DSCCLK_calculated[k] =
1774 mode_lib->vba.PixelClockBackEnd[k] / 6
1775 / mode_lib->vba.DSCFormatFactor
1777 - mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading
1780 locals->DSCCLK_calculated[k] =
1781 mode_lib->vba.PixelClockBackEnd[k] / 3
1782 / mode_lib->vba.DSCFormatFactor
1784 - mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading
1791 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
1792 double bpp = mode_lib->vba.OutputBpp[k];
1793 unsigned int slices = mode_lib->vba.NumberOfDSCSlices[k];
1795 if (mode_lib->vba.DSCEnabled[k] && bpp != 0) {
1796 if (!mode_lib->vba.ODMCombineEnabled[k]) {
1797 locals->DSCDelay[k] =
1799 mode_lib->vba.DSCInputBitPerComponent[k],
1802 (double) mode_lib->vba.HActive[k]
1803 / mode_lib->vba.NumberOfDSCSlices[k],
1806 mode_lib->vba.OutputFormat[k])
1808 mode_lib->vba.OutputFormat[k]);
1810 locals->DSCDelay[k] =
1812 * (dscceComputeDelay(
1813 mode_lib->vba.DSCInputBitPerComponent[k],
1816 (double) mode_lib->vba.HActive[k]
1817 / mode_lib->vba.NumberOfDSCSlices[k],
1820 mode_lib->vba.OutputFormat[k])
1822 mode_lib->vba.OutputFormat[k]));
1824 locals->DSCDelay[k] = locals->DSCDelay[k]
1825 * mode_lib->vba.PixelClock[k]
1826 / mode_lib->vba.PixelClockBackEnd[k];
1828 locals->DSCDelay[k] = 0;
1832 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k)
1833 for (j = 0; j < mode_lib->vba.NumberOfActivePlanes; ++j) // NumberOfPlanes
1834 if (j != k && mode_lib->vba.BlendingAndTiming[k] == j
1835 && mode_lib->vba.DSCEnabled[j])
1836 locals->DSCDelay[k] = locals->DSCDelay[j];
1839 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
1840 unsigned int PDEAndMetaPTEBytesFrameY;
1841 unsigned int PixelPTEBytesPerRowY;
1842 unsigned int MetaRowByteY;
1843 unsigned int MetaRowByteC;
1844 unsigned int PDEAndMetaPTEBytesFrameC;
1845 unsigned int PixelPTEBytesPerRowC;
1846 bool PTEBufferSizeNotExceededY;
1847 bool PTEBufferSizeNotExceededC;
1849 Calculate256BBlockSizes(
1850 mode_lib->vba.SourcePixelFormat[k],
1851 mode_lib->vba.SurfaceTiling[k],
1852 dml_ceil(locals->BytePerPixelDETY[k], 1),
1853 dml_ceil(locals->BytePerPixelDETC[k], 2),
1854 &locals->BlockHeight256BytesY[k],
1855 &locals->BlockHeight256BytesC[k],
1856 &locals->BlockWidth256BytesY[k],
1857 &locals->BlockWidth256BytesC[k]);
1859 locals->PrefetchSourceLinesY[k] = CalculatePrefetchSourceLines(
1861 mode_lib->vba.VRatio[k],
1862 mode_lib->vba.vtaps[k],
1863 mode_lib->vba.Interlace[k],
1864 mode_lib->vba.ProgressiveToInterlaceUnitInOPP,
1865 mode_lib->vba.SwathHeightY[k],
1866 mode_lib->vba.ViewportYStartY[k],
1867 &locals->VInitPreFillY[k],
1868 &locals->MaxNumSwathY[k]);
1870 if ((mode_lib->vba.SourcePixelFormat[k] != dm_444_64
1871 && mode_lib->vba.SourcePixelFormat[k] != dm_444_32
1872 && mode_lib->vba.SourcePixelFormat[k] != dm_444_16
1873 && mode_lib->vba.SourcePixelFormat[k] != dm_444_8)) {
1874 PDEAndMetaPTEBytesFrameC =
1875 CalculateVMAndRowBytes(
1877 mode_lib->vba.DCCEnable[k],
1878 locals->BlockHeight256BytesC[k],
1879 locals->BlockWidth256BytesC[k],
1880 mode_lib->vba.SourcePixelFormat[k],
1881 mode_lib->vba.SurfaceTiling[k],
1883 locals->BytePerPixelDETC[k],
1885 mode_lib->vba.SourceScan[k],
1886 mode_lib->vba.ViewportWidth[k] / 2,
1887 mode_lib->vba.ViewportHeight[k] / 2,
1888 locals->SwathWidthY[k] / 2,
1889 mode_lib->vba.GPUVMEnable,
1890 mode_lib->vba.HostVMEnable,
1891 mode_lib->vba.HostVMMaxPageTableLevels,
1892 mode_lib->vba.HostVMCachedPageTableLevels,
1893 mode_lib->vba.VMMPageSize,
1894 mode_lib->vba.PTEBufferSizeInRequestsChroma,
1895 mode_lib->vba.PitchC[k],
1896 mode_lib->vba.DCCMetaPitchC[k],
1897 &locals->MacroTileWidthC[k],
1899 &PixelPTEBytesPerRowC,
1900 &PTEBufferSizeNotExceededC,
1901 &locals->dpte_row_width_chroma_ub[k],
1902 &locals->dpte_row_height_chroma[k],
1903 &locals->meta_req_width_chroma[k],
1904 &locals->meta_req_height_chroma[k],
1905 &locals->meta_row_width_chroma[k],
1906 &locals->meta_row_height_chroma[k],
1907 &locals->vm_group_bytes_chroma,
1908 &locals->dpte_group_bytes_chroma,
1909 &locals->PixelPTEReqWidthC[k],
1910 &locals->PixelPTEReqHeightC[k],
1911 &locals->PTERequestSizeC[k],
1912 &locals->dpde0_bytes_per_frame_ub_c[k],
1913 &locals->meta_pte_bytes_per_frame_ub_c[k]);
1915 locals->PrefetchSourceLinesC[k] = CalculatePrefetchSourceLines(
1917 mode_lib->vba.VRatio[k] / 2,
1918 mode_lib->vba.VTAPsChroma[k],
1919 mode_lib->vba.Interlace[k],
1920 mode_lib->vba.ProgressiveToInterlaceUnitInOPP,
1921 mode_lib->vba.SwathHeightC[k],
1922 mode_lib->vba.ViewportYStartC[k],
1923 &locals->VInitPreFillC[k],
1924 &locals->MaxNumSwathC[k]);
1926 PixelPTEBytesPerRowC = 0;
1927 PDEAndMetaPTEBytesFrameC = 0;
1929 locals->MaxNumSwathC[k] = 0;
1930 locals->PrefetchSourceLinesC[k] = 0;
1931 locals->PTEBufferSizeInRequestsForLuma = mode_lib->vba.PTEBufferSizeInRequestsLuma + mode_lib->vba.PTEBufferSizeInRequestsChroma;
1934 PDEAndMetaPTEBytesFrameY = CalculateVMAndRowBytes(
1936 mode_lib->vba.DCCEnable[k],
1937 locals->BlockHeight256BytesY[k],
1938 locals->BlockWidth256BytesY[k],
1939 mode_lib->vba.SourcePixelFormat[k],
1940 mode_lib->vba.SurfaceTiling[k],
1941 dml_ceil(locals->BytePerPixelDETY[k], 1),
1942 mode_lib->vba.SourceScan[k],
1943 mode_lib->vba.ViewportWidth[k],
1944 mode_lib->vba.ViewportHeight[k],
1945 locals->SwathWidthY[k],
1946 mode_lib->vba.GPUVMEnable,
1947 mode_lib->vba.HostVMEnable,
1948 mode_lib->vba.HostVMMaxPageTableLevels,
1949 mode_lib->vba.HostVMCachedPageTableLevels,
1950 mode_lib->vba.VMMPageSize,
1951 locals->PTEBufferSizeInRequestsForLuma,
1952 mode_lib->vba.PitchY[k],
1953 mode_lib->vba.DCCMetaPitchY[k],
1954 &locals->MacroTileWidthY[k],
1956 &PixelPTEBytesPerRowY,
1957 &PTEBufferSizeNotExceededY,
1958 &locals->dpte_row_width_luma_ub[k],
1959 &locals->dpte_row_height[k],
1960 &locals->meta_req_width[k],
1961 &locals->meta_req_height[k],
1962 &locals->meta_row_width[k],
1963 &locals->meta_row_height[k],
1964 &locals->vm_group_bytes[k],
1965 &locals->dpte_group_bytes[k],
1966 &locals->PixelPTEReqWidthY[k],
1967 &locals->PixelPTEReqHeightY[k],
1968 &locals->PTERequestSizeY[k],
1969 &locals->dpde0_bytes_per_frame_ub_l[k],
1970 &locals->meta_pte_bytes_per_frame_ub_l[k]);
1972 locals->PixelPTEBytesPerRow[k] = PixelPTEBytesPerRowY + PixelPTEBytesPerRowC;
1973 locals->PDEAndMetaPTEBytesFrame[k] = PDEAndMetaPTEBytesFrameY
1974 + PDEAndMetaPTEBytesFrameC;
1975 locals->MetaRowByte[k] = MetaRowByteY + MetaRowByteC;
1977 CalculateActiveRowBandwidth(
1978 mode_lib->vba.GPUVMEnable,
1979 mode_lib->vba.SourcePixelFormat[k],
1980 mode_lib->vba.VRatio[k],
1981 mode_lib->vba.DCCEnable[k],
1982 mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k],
1985 locals->meta_row_height[k],
1986 locals->meta_row_height_chroma[k],
1987 PixelPTEBytesPerRowY,
1988 PixelPTEBytesPerRowC,
1989 locals->dpte_row_height[k],
1990 locals->dpte_row_height_chroma[k],
1991 &locals->meta_row_bw[k],
1992 &locals->dpte_row_bw[k]);
1995 mode_lib->vba.TotalDCCActiveDPP = 0;
1996 mode_lib->vba.TotalActiveDPP = 0;
1997 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
1998 mode_lib->vba.TotalActiveDPP = mode_lib->vba.TotalActiveDPP
1999 + mode_lib->vba.DPPPerPlane[k];
2000 if (mode_lib->vba.DCCEnable[k])
2001 mode_lib->vba.TotalDCCActiveDPP = mode_lib->vba.TotalDCCActiveDPP
2002 + mode_lib->vba.DPPPerPlane[k];
2005 mode_lib->vba.UrgentOutOfOrderReturnPerChannel = dml_max3(
2006 mode_lib->vba.UrgentOutOfOrderReturnPerChannelPixelDataOnly,
2007 mode_lib->vba.UrgentOutOfOrderReturnPerChannelPixelMixedWithVMData,
2008 mode_lib->vba.UrgentOutOfOrderReturnPerChannelVMDataOnly);
2010 mode_lib->vba.UrgentRoundTripAndOutOfOrderLatency =
2011 (mode_lib->vba.RoundTripPingLatencyCycles + 32) / mode_lib->vba.DCFCLK
2012 + mode_lib->vba.UrgentOutOfOrderReturnPerChannel
2013 * mode_lib->vba.NumberOfChannels
2014 / mode_lib->vba.ReturnBW;
2016 mode_lib->vba.UrgentExtraLatency = CalculateExtraLatency(
2017 mode_lib->vba.UrgentRoundTripAndOutOfOrderLatency,
2018 mode_lib->vba.TotalActiveDPP,
2019 mode_lib->vba.PixelChunkSizeInKByte,
2020 mode_lib->vba.TotalDCCActiveDPP,
2021 mode_lib->vba.MetaChunkSize,
2022 mode_lib->vba.ReturnBW,
2023 mode_lib->vba.GPUVMEnable,
2024 mode_lib->vba.HostVMEnable,
2025 mode_lib->vba.NumberOfActivePlanes,
2026 mode_lib->vba.DPPPerPlane,
2027 locals->dpte_group_bytes,
2028 mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData,
2029 mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly,
2030 mode_lib->vba.HostVMMaxPageTableLevels,
2031 mode_lib->vba.HostVMCachedPageTableLevels);
2034 mode_lib->vba.TCalc = 24.0 / mode_lib->vba.DCFCLKDeepSleep;
2036 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2037 if (mode_lib->vba.BlendingAndTiming[k] == k) {
2038 if (mode_lib->vba.WritebackEnable[k] == true) {
2039 locals->WritebackDelay[mode_lib->vba.VoltageLevel][k] =
2040 mode_lib->vba.WritebackLatency
2041 + CalculateWriteBackDelay(
2042 mode_lib->vba.WritebackPixelFormat[k],
2043 mode_lib->vba.WritebackHRatio[k],
2044 mode_lib->vba.WritebackVRatio[k],
2045 mode_lib->vba.WritebackLumaHTaps[k],
2046 mode_lib->vba.WritebackLumaVTaps[k],
2047 mode_lib->vba.WritebackChromaHTaps[k],
2048 mode_lib->vba.WritebackChromaVTaps[k],
2049 mode_lib->vba.WritebackDestinationWidth[k])
2050 / mode_lib->vba.DISPCLK;
2052 locals->WritebackDelay[mode_lib->vba.VoltageLevel][k] = 0;
2053 for (j = 0; j < mode_lib->vba.NumberOfActivePlanes; ++j) {
2054 if (mode_lib->vba.BlendingAndTiming[j] == k
2055 && mode_lib->vba.WritebackEnable[j] == true) {
2056 locals->WritebackDelay[mode_lib->vba.VoltageLevel][k] =
2058 locals->WritebackDelay[mode_lib->vba.VoltageLevel][k],
2059 mode_lib->vba.WritebackLatency
2060 + CalculateWriteBackDelay(
2061 mode_lib->vba.WritebackPixelFormat[j],
2062 mode_lib->vba.WritebackHRatio[j],
2063 mode_lib->vba.WritebackVRatio[j],
2064 mode_lib->vba.WritebackLumaHTaps[j],
2065 mode_lib->vba.WritebackLumaVTaps[j],
2066 mode_lib->vba.WritebackChromaHTaps[j],
2067 mode_lib->vba.WritebackChromaVTaps[j],
2068 mode_lib->vba.WritebackDestinationWidth[j])
2069 / mode_lib->vba.DISPCLK);
2075 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k)
2076 for (j = 0; j < mode_lib->vba.NumberOfActivePlanes; ++j)
2077 if (mode_lib->vba.BlendingAndTiming[k] == j)
2078 locals->WritebackDelay[mode_lib->vba.VoltageLevel][k] =
2079 locals->WritebackDelay[mode_lib->vba.VoltageLevel][j];
2081 mode_lib->vba.VStartupLines = 13;
2082 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2083 locals->MaxVStartupLines[k] = mode_lib->vba.VTotal[k] - mode_lib->vba.VActive[k] - dml_max(1.0, dml_ceil(locals->WritebackDelay[mode_lib->vba.VoltageLevel][k] / (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]), 1));
2086 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k)
2087 locals->MaximumMaxVStartupLines = dml_max(locals->MaximumMaxVStartupLines, locals->MaxVStartupLines[k]);
2089 // We don't really care to iterate between the various prefetch modes
2090 //mode_lib->vba.PrefetchERROR = CalculateMinAndMaxPrefetchMode(mode_lib->vba.AllowDRAMSelfRefreshOrDRAMClockChangeInVblank, &mode_lib->vba.MinPrefetchMode, &mode_lib->vba.MaxPrefetchMode);
2091 mode_lib->vba.UrgentLatency = dml_max3(mode_lib->vba.UrgentLatencyPixelDataOnly, mode_lib->vba.UrgentLatencyPixelMixedWithVMData, mode_lib->vba.UrgentLatencyVMDataOnly);
2094 double MaxTotalRDBandwidth = 0;
2095 double MaxTotalRDBandwidthNoUrgentBurst = 0;
2096 bool DestinationLineTimesForPrefetchLessThan2 = false;
2097 bool VRatioPrefetchMoreThan4 = false;
2098 double TWait = CalculateTWait(
2099 mode_lib->vba.PrefetchMode[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb],
2100 mode_lib->vba.DRAMClockChangeLatency,
2101 mode_lib->vba.UrgentLatency,
2102 mode_lib->vba.SREnterPlusExitTime);
2104 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2108 if (mode_lib->vba.XFCEnabled[k] == true) {
2109 mode_lib->vba.XFCRemoteSurfaceFlipDelay =
2110 CalculateRemoteSurfaceFlipDelay(
2112 mode_lib->vba.VRatio[k],
2113 locals->SwathWidthY[k],
2115 locals->BytePerPixelDETY[k],
2117 mode_lib->vba.HTotal[k]
2118 / mode_lib->vba.PixelClock[k],
2119 mode_lib->vba.XFCTSlvVupdateOffset,
2120 mode_lib->vba.XFCTSlvVupdateWidth,
2121 mode_lib->vba.XFCTSlvVreadyOffset,
2122 mode_lib->vba.XFCXBUFLatencyTolerance,
2123 mode_lib->vba.XFCFillBWOverhead,
2124 mode_lib->vba.XFCSlvChunkSize,
2125 mode_lib->vba.XFCBusTransportTime,
2126 mode_lib->vba.TCalc,
2128 &mode_lib->vba.SrcActiveDrainRate,
2129 &mode_lib->vba.TInitXFill,
2130 &mode_lib->vba.TslvChk);
2132 mode_lib->vba.XFCRemoteSurfaceFlipDelay = 0;
2135 myPipe.DPPCLK = locals->DPPCLK[k];
2136 myPipe.DISPCLK = mode_lib->vba.DISPCLK;
2137 myPipe.PixelClock = mode_lib->vba.PixelClock[k];
2138 myPipe.DCFCLKDeepSleep = mode_lib->vba.DCFCLKDeepSleep;
2139 myPipe.DPPPerPlane = mode_lib->vba.DPPPerPlane[k];
2140 myPipe.ScalerEnabled = mode_lib->vba.ScalerEnabled[k];
2141 myPipe.SourceScan = mode_lib->vba.SourceScan[k];
2142 myPipe.BlockWidth256BytesY = locals->BlockWidth256BytesY[k];
2143 myPipe.BlockHeight256BytesY = locals->BlockHeight256BytesY[k];
2144 myPipe.BlockWidth256BytesC = locals->BlockWidth256BytesC[k];
2145 myPipe.BlockHeight256BytesC = locals->BlockHeight256BytesC[k];
2146 myPipe.InterlaceEnable = mode_lib->vba.Interlace[k];
2147 myPipe.NumberOfCursors = mode_lib->vba.NumberOfCursors[k];
2148 myPipe.VBlank = mode_lib->vba.VTotal[k] - mode_lib->vba.VActive[k];
2149 myPipe.HTotal = mode_lib->vba.HTotal[k];
2152 myHostVM.Enable = mode_lib->vba.HostVMEnable;
2153 myHostVM.MaxPageTableLevels = mode_lib->vba.HostVMMaxPageTableLevels;
2154 myHostVM.CachedPageTableLevels = mode_lib->vba.HostVMCachedPageTableLevels;
2156 mode_lib->vba.ErrorResult[k] =
2157 CalculatePrefetchSchedule(
2159 mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData,
2160 mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly,
2162 locals->DSCDelay[k],
2163 mode_lib->vba.DPPCLKDelaySubtotal,
2164 mode_lib->vba.DPPCLKDelaySCL,
2165 mode_lib->vba.DPPCLKDelaySCLLBOnly,
2166 mode_lib->vba.DPPCLKDelayCNVCFormater,
2167 mode_lib->vba.DPPCLKDelayCNVCCursor,
2168 mode_lib->vba.DISPCLKDelaySubtotal,
2169 (unsigned int) (locals->SwathWidthY[k]
2170 / mode_lib->vba.HRatio[k]),
2171 mode_lib->vba.OutputFormat[k],
2172 mode_lib->vba.MaxInterDCNTileRepeaters,
2173 dml_min(mode_lib->vba.VStartupLines, locals->MaxVStartupLines[k]),
2174 locals->MaxVStartupLines[k],
2175 mode_lib->vba.GPUVMMaxPageTableLevels,
2176 mode_lib->vba.GPUVMEnable,
2178 mode_lib->vba.DynamicMetadataEnable[k],
2179 mode_lib->vba.DynamicMetadataLinesBeforeActiveRequired[k],
2180 mode_lib->vba.DynamicMetadataTransmittedBytes[k],
2181 mode_lib->vba.DCCEnable[k],
2182 mode_lib->vba.UrgentLatency,
2183 mode_lib->vba.UrgentExtraLatency,
2184 mode_lib->vba.TCalc,
2185 locals->PDEAndMetaPTEBytesFrame[k],
2186 locals->MetaRowByte[k],
2187 locals->PixelPTEBytesPerRow[k],
2188 locals->PrefetchSourceLinesY[k],
2189 locals->SwathWidthY[k],
2190 locals->BytePerPixelDETY[k],
2191 locals->VInitPreFillY[k],
2192 locals->MaxNumSwathY[k],
2193 locals->PrefetchSourceLinesC[k],
2194 locals->BytePerPixelDETC[k],
2195 locals->VInitPreFillC[k],
2196 locals->MaxNumSwathC[k],
2197 mode_lib->vba.SwathHeightY[k],
2198 mode_lib->vba.SwathHeightC[k],
2200 mode_lib->vba.XFCEnabled[k],
2201 mode_lib->vba.XFCRemoteSurfaceFlipDelay,
2202 mode_lib->vba.ProgressiveToInterlaceUnitInOPP,
2203 &locals->DSTXAfterScaler[k],
2204 &locals->DSTYAfterScaler[k],
2205 &locals->DestinationLinesForPrefetch[k],
2206 &locals->PrefetchBandwidth[k],
2207 &locals->DestinationLinesToRequestVMInVBlank[k],
2208 &locals->DestinationLinesToRequestRowInVBlank[k],
2209 &locals->VRatioPrefetchY[k],
2210 &locals->VRatioPrefetchC[k],
2211 &locals->RequiredPrefetchPixDataBWLuma[k],
2212 &locals->RequiredPrefetchPixDataBWChroma[k],
2213 &locals->VStartupRequiredWhenNotEnoughTimeForDynamicMetadata,
2215 &locals->prefetch_vmrow_bw[k],
2216 &locals->swath_width_luma_ub[k],
2217 &locals->swath_width_chroma_ub[k],
2218 &mode_lib->vba.VUpdateOffsetPix[k],
2219 &mode_lib->vba.VUpdateWidthPix[k],
2220 &mode_lib->vba.VReadyOffsetPix[k]);
2221 if (mode_lib->vba.BlendingAndTiming[k] == k) {
2222 locals->VStartup[k] = dml_min(
2223 mode_lib->vba.VStartupLines,
2224 locals->MaxVStartupLines[k]);
2225 if (locals->VStartupRequiredWhenNotEnoughTimeForDynamicMetadata
2227 locals->VStartup[k] =
2228 locals->VStartupRequiredWhenNotEnoughTimeForDynamicMetadata;
2231 locals->VStartup[k] =
2233 mode_lib->vba.VStartupLines,
2234 locals->MaxVStartupLines[mode_lib->vba.BlendingAndTiming[k]]);
2238 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2241 locals->cursor_bw[k] = 0;
2242 locals->cursor_bw_pre[k] = 0;
2243 for (m = 0; m < mode_lib->vba.NumberOfCursors[k]; m++) {
2244 locals->cursor_bw[k] += mode_lib->vba.CursorWidth[k][m] * mode_lib->vba.CursorBPP[k][m] / 8.0 / (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]) * mode_lib->vba.VRatio[k];
2245 locals->cursor_bw_pre[k] += mode_lib->vba.CursorWidth[k][m] * mode_lib->vba.CursorBPP[k][m] / 8.0 / (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]) * locals->VRatioPrefetchY[k];
2248 CalculateUrgentBurstFactor(
2249 mode_lib->vba.DETBufferSizeInKByte,
2250 mode_lib->vba.SwathHeightY[k],
2251 mode_lib->vba.SwathHeightC[k],
2252 locals->SwathWidthY[k],
2253 mode_lib->vba.HTotal[k] /
2254 mode_lib->vba.PixelClock[k],
2255 mode_lib->vba.UrgentLatency,
2256 mode_lib->vba.CursorBufferSize,
2257 mode_lib->vba.CursorWidth[k][0] + mode_lib->vba.CursorWidth[k][1],
2258 dml_max(mode_lib->vba.CursorBPP[k][0], mode_lib->vba.CursorBPP[k][1]),
2259 mode_lib->vba.VRatio[k],
2260 locals->VRatioPrefetchY[k],
2261 locals->VRatioPrefetchC[k],
2262 locals->BytePerPixelDETY[k],
2263 locals->BytePerPixelDETC[k],
2264 &locals->UrgentBurstFactorCursor[k],
2265 &locals->UrgentBurstFactorCursorPre[k],
2266 &locals->UrgentBurstFactorLuma[k],
2267 &locals->UrgentBurstFactorLumaPre[k],
2268 &locals->UrgentBurstFactorChroma[k],
2269 &locals->UrgentBurstFactorChromaPre[k],
2270 &locals->NotEnoughUrgentLatencyHiding,
2271 &locals->NotEnoughUrgentLatencyHidingPre);
2273 if (mode_lib->vba.UseUrgentBurstBandwidth == false) {
2274 locals->UrgentBurstFactorLuma[k] = 1;
2275 locals->UrgentBurstFactorChroma[k] = 1;
2276 locals->UrgentBurstFactorCursor[k] = 1;
2277 locals->UrgentBurstFactorLumaPre[k] = 1;
2278 locals->UrgentBurstFactorChromaPre[k] = 1;
2279 locals->UrgentBurstFactorCursorPre[k] = 1;
2282 MaxTotalRDBandwidth = MaxTotalRDBandwidth +
2283 dml_max3(locals->prefetch_vmrow_bw[k],
2284 locals->ReadBandwidthPlaneLuma[k] * locals->UrgentBurstFactorLuma[k]
2285 + locals->ReadBandwidthPlaneChroma[k] * locals->UrgentBurstFactorChroma[k] + locals->cursor_bw[k]
2286 * locals->UrgentBurstFactorCursor[k] + locals->meta_row_bw[k] + locals->dpte_row_bw[k],
2287 locals->RequiredPrefetchPixDataBWLuma[k] * locals->UrgentBurstFactorLumaPre[k] + locals->RequiredPrefetchPixDataBWChroma[k]
2288 * locals->UrgentBurstFactorChromaPre[k] + locals->cursor_bw_pre[k] * locals->UrgentBurstFactorCursorPre[k]);
2290 MaxTotalRDBandwidthNoUrgentBurst = MaxTotalRDBandwidthNoUrgentBurst +
2291 dml_max3(locals->prefetch_vmrow_bw[k],
2292 locals->ReadBandwidthPlaneLuma[k] + locals->ReadBandwidthPlaneChroma[k] + locals->cursor_bw[k]
2293 + locals->meta_row_bw[k] + locals->dpte_row_bw[k],
2294 locals->RequiredPrefetchPixDataBWLuma[k] + locals->RequiredPrefetchPixDataBWChroma[k] + locals->cursor_bw_pre[k]);
2296 if (locals->DestinationLinesForPrefetch[k] < 2)
2297 DestinationLineTimesForPrefetchLessThan2 = true;
2298 if (locals->VRatioPrefetchY[k] > 4 || locals->VRatioPrefetchC[k] > 4)
2299 VRatioPrefetchMoreThan4 = true;
2301 mode_lib->vba.FractionOfUrgentBandwidth = MaxTotalRDBandwidthNoUrgentBurst / mode_lib->vba.ReturnBW;
2303 if (MaxTotalRDBandwidth <= mode_lib->vba.ReturnBW && locals->NotEnoughUrgentLatencyHiding == 0 && locals->NotEnoughUrgentLatencyHidingPre == 0 && !VRatioPrefetchMoreThan4
2304 && !DestinationLineTimesForPrefetchLessThan2)
2305 mode_lib->vba.PrefetchModeSupported = true;
2307 mode_lib->vba.PrefetchModeSupported = false;
2309 "DML: CalculatePrefetchSchedule ***failed***. Bandwidth violation. Results are NOT valid\n");
2312 if (mode_lib->vba.PrefetchModeSupported == true) {
2313 mode_lib->vba.BandwidthAvailableForImmediateFlip = mode_lib->vba.ReturnBW;
2314 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2315 mode_lib->vba.BandwidthAvailableForImmediateFlip =
2316 mode_lib->vba.BandwidthAvailableForImmediateFlip
2318 locals->ReadBandwidthPlaneLuma[k] * locals->UrgentBurstFactorLuma[k]
2319 + locals->ReadBandwidthPlaneChroma[k] * locals->UrgentBurstFactorChroma[k]
2320 + locals->cursor_bw[k] * locals->UrgentBurstFactorCursor[k],
2321 locals->RequiredPrefetchPixDataBWLuma[k] * locals->UrgentBurstFactorLumaPre[k] +
2322 locals->RequiredPrefetchPixDataBWChroma[k] * locals->UrgentBurstFactorChromaPre[k] +
2323 locals->cursor_bw_pre[k] * locals->UrgentBurstFactorCursorPre[k]);
2326 mode_lib->vba.TotImmediateFlipBytes = 0;
2327 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2328 mode_lib->vba.TotImmediateFlipBytes = mode_lib->vba.TotImmediateFlipBytes + locals->PDEAndMetaPTEBytesFrame[k] + locals->MetaRowByte[k] + locals->PixelPTEBytesPerRow[k];
2330 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2331 CalculateFlipSchedule(
2333 mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData,
2334 mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly,
2335 mode_lib->vba.UrgentExtraLatency,
2336 mode_lib->vba.UrgentLatency,
2337 mode_lib->vba.GPUVMMaxPageTableLevels,
2338 mode_lib->vba.HostVMEnable,
2339 mode_lib->vba.HostVMMaxPageTableLevels,
2340 mode_lib->vba.HostVMCachedPageTableLevels,
2341 mode_lib->vba.GPUVMEnable,
2342 locals->PDEAndMetaPTEBytesFrame[k],
2343 locals->MetaRowByte[k],
2344 locals->PixelPTEBytesPerRow[k],
2345 mode_lib->vba.BandwidthAvailableForImmediateFlip,
2346 mode_lib->vba.TotImmediateFlipBytes,
2347 mode_lib->vba.SourcePixelFormat[k],
2348 mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k],
2349 mode_lib->vba.VRatio[k],
2351 mode_lib->vba.DCCEnable[k],
2352 locals->dpte_row_height[k],
2353 locals->meta_row_height[k],
2354 locals->dpte_row_height_chroma[k],
2355 locals->meta_row_height_chroma[k],
2356 &locals->DestinationLinesToRequestVMInImmediateFlip[k],
2357 &locals->DestinationLinesToRequestRowInImmediateFlip[k],
2358 &locals->final_flip_bw[k],
2359 &locals->ImmediateFlipSupportedForPipe[k]);
2361 mode_lib->vba.total_dcn_read_bw_with_flip = 0.0;
2362 mode_lib->vba.total_dcn_read_bw_with_flip_no_urgent_burst = 0.0;
2363 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2364 mode_lib->vba.total_dcn_read_bw_with_flip =
2365 mode_lib->vba.total_dcn_read_bw_with_flip + dml_max3(
2366 locals->prefetch_vmrow_bw[k],
2367 locals->final_flip_bw[k] + locals->ReadBandwidthLuma[k] * locals->UrgentBurstFactorLuma[k]
2368 + locals->ReadBandwidthChroma[k] * locals->UrgentBurstFactorChroma[k] + locals->cursor_bw[k] * locals->UrgentBurstFactorCursor[k],
2369 locals->final_flip_bw[k] + locals->RequiredPrefetchPixDataBWLuma[k] * locals->UrgentBurstFactorLumaPre[k]
2370 + locals->RequiredPrefetchPixDataBWChroma[k] * locals->UrgentBurstFactorChromaPre[k]
2371 + locals->cursor_bw_pre[k] * locals->UrgentBurstFactorCursorPre[k]);
2372 mode_lib->vba.total_dcn_read_bw_with_flip_no_urgent_burst =
2373 mode_lib->vba.total_dcn_read_bw_with_flip_no_urgent_burst +
2374 dml_max3(locals->prefetch_vmrow_bw[k],
2375 locals->final_flip_bw[k] + locals->ReadBandwidthPlaneLuma[k] + locals->ReadBandwidthPlaneChroma[k] + locals->cursor_bw[k],
2376 locals->final_flip_bw[k] + locals->RequiredPrefetchPixDataBWLuma[k] + locals->RequiredPrefetchPixDataBWChroma[k] + locals->cursor_bw_pre[k]);
2379 mode_lib->vba.FractionOfUrgentBandwidthImmediateFlip = mode_lib->vba.total_dcn_read_bw_with_flip_no_urgent_burst / mode_lib->vba.ReturnBW;
2381 mode_lib->vba.ImmediateFlipSupported = true;
2382 if (mode_lib->vba.total_dcn_read_bw_with_flip > mode_lib->vba.ReturnBW) {
2383 mode_lib->vba.ImmediateFlipSupported = false;
2385 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2386 if (locals->ImmediateFlipSupportedForPipe[k] == false) {
2387 mode_lib->vba.ImmediateFlipSupported = false;
2391 mode_lib->vba.ImmediateFlipSupported = false;
2394 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2395 if (mode_lib->vba.ErrorResult[k]) {
2396 mode_lib->vba.PrefetchModeSupported = false;
2398 "DML: CalculatePrefetchSchedule ***failed***. Prefetch schedule violation. Results are NOT valid\n");
2402 mode_lib->vba.VStartupLines = mode_lib->vba.VStartupLines + 1;
2403 } while (!((mode_lib->vba.PrefetchModeSupported
2404 && ((!mode_lib->vba.ImmediateFlipSupport && !mode_lib->vba.HostVMEnable)
2405 || mode_lib->vba.ImmediateFlipSupported))
2406 || locals->MaximumMaxVStartupLines < mode_lib->vba.VStartupLines));
2408 //Watermarks and NB P-State/DRAM Clock Change Support
2410 enum clock_change_support DRAMClockChangeSupport; // dummy
2411 CalculateWatermarksAndDRAMSpeedChangeSupport(
2413 mode_lib->vba.PrefetchMode[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb],
2414 mode_lib->vba.NumberOfActivePlanes,
2415 mode_lib->vba.MaxLineBufferLines,
2416 mode_lib->vba.LineBufferSize,
2417 mode_lib->vba.DPPOutputBufferPixels,
2418 mode_lib->vba.DETBufferSizeInKByte,
2419 mode_lib->vba.WritebackInterfaceLumaBufferSize,
2420 mode_lib->vba.WritebackInterfaceChromaBufferSize,
2421 mode_lib->vba.DCFCLK,
2422 mode_lib->vba.UrgentOutOfOrderReturnPerChannel * mode_lib->vba.NumberOfChannels,
2423 mode_lib->vba.ReturnBW,
2424 mode_lib->vba.GPUVMEnable,
2425 locals->dpte_group_bytes,
2426 mode_lib->vba.MetaChunkSize,
2427 mode_lib->vba.UrgentLatency,
2428 mode_lib->vba.UrgentExtraLatency,
2429 mode_lib->vba.WritebackLatency,
2430 mode_lib->vba.WritebackChunkSize,
2431 mode_lib->vba.SOCCLK,
2432 mode_lib->vba.DRAMClockChangeLatency,
2433 mode_lib->vba.SRExitTime,
2434 mode_lib->vba.SREnterPlusExitTime,
2435 mode_lib->vba.DCFCLKDeepSleep,
2436 mode_lib->vba.DPPPerPlane,
2437 mode_lib->vba.DCCEnable,
2439 locals->SwathWidthSingleDPPY,
2440 mode_lib->vba.SwathHeightY,
2441 locals->ReadBandwidthPlaneLuma,
2442 mode_lib->vba.SwathHeightC,
2443 locals->ReadBandwidthPlaneChroma,
2444 mode_lib->vba.LBBitPerPixel,
2445 locals->SwathWidthY,
2446 mode_lib->vba.HRatio,
2447 mode_lib->vba.vtaps,
2448 mode_lib->vba.VTAPsChroma,
2449 mode_lib->vba.VRatio,
2450 mode_lib->vba.HTotal,
2451 mode_lib->vba.PixelClock,
2452 mode_lib->vba.BlendingAndTiming,
2453 locals->BytePerPixelDETY,
2454 locals->BytePerPixelDETC,
2455 mode_lib->vba.WritebackEnable,
2456 mode_lib->vba.WritebackPixelFormat,
2457 mode_lib->vba.WritebackDestinationWidth,
2458 mode_lib->vba.WritebackDestinationHeight,
2459 mode_lib->vba.WritebackSourceHeight,
2460 &DRAMClockChangeSupport,
2461 &mode_lib->vba.UrgentWatermark,
2462 &mode_lib->vba.WritebackUrgentWatermark,
2463 &mode_lib->vba.DRAMClockChangeWatermark,
2464 &mode_lib->vba.WritebackDRAMClockChangeWatermark,
2465 &mode_lib->vba.StutterExitWatermark,
2466 &mode_lib->vba.StutterEnterPlusExitWatermark,
2467 &mode_lib->vba.MinActiveDRAMClockChangeLatencySupported);
2471 //Display Pipeline Delivery Time in Prefetch, Groups
2472 CalculatePixelDeliveryTimes(
2473 mode_lib->vba.NumberOfActivePlanes,
2474 mode_lib->vba.VRatio,
2475 locals->VRatioPrefetchY,
2476 locals->VRatioPrefetchC,
2477 locals->swath_width_luma_ub,
2478 locals->swath_width_chroma_ub,
2479 mode_lib->vba.DPPPerPlane,
2480 mode_lib->vba.HRatio,
2481 mode_lib->vba.PixelClock,
2482 locals->PSCL_THROUGHPUT_LUMA,
2483 locals->PSCL_THROUGHPUT_CHROMA,
2485 locals->BytePerPixelDETC,
2486 mode_lib->vba.SourceScan,
2487 locals->BlockWidth256BytesY,
2488 locals->BlockHeight256BytesY,
2489 locals->BlockWidth256BytesC,
2490 locals->BlockHeight256BytesC,
2491 locals->DisplayPipeLineDeliveryTimeLuma,
2492 locals->DisplayPipeLineDeliveryTimeChroma,
2493 locals->DisplayPipeLineDeliveryTimeLumaPrefetch,
2494 locals->DisplayPipeLineDeliveryTimeChromaPrefetch,
2495 locals->DisplayPipeRequestDeliveryTimeLuma,
2496 locals->DisplayPipeRequestDeliveryTimeChroma,
2497 locals->DisplayPipeRequestDeliveryTimeLumaPrefetch,
2498 locals->DisplayPipeRequestDeliveryTimeChromaPrefetch);
2500 CalculateMetaAndPTETimes(
2501 mode_lib->vba.NumberOfActivePlanes,
2502 mode_lib->vba.GPUVMEnable,
2503 mode_lib->vba.MetaChunkSize,
2504 mode_lib->vba.MinMetaChunkSizeBytes,
2505 mode_lib->vba.GPUVMMaxPageTableLevels,
2506 mode_lib->vba.HTotal,
2507 mode_lib->vba.VRatio,
2508 locals->VRatioPrefetchY,
2509 locals->VRatioPrefetchC,
2510 locals->DestinationLinesToRequestRowInVBlank,
2511 locals->DestinationLinesToRequestRowInImmediateFlip,
2512 locals->DestinationLinesToRequestVMInVBlank,
2513 locals->DestinationLinesToRequestVMInImmediateFlip,
2514 mode_lib->vba.DCCEnable,
2515 mode_lib->vba.PixelClock,
2516 locals->BytePerPixelDETY,
2517 locals->BytePerPixelDETC,
2518 mode_lib->vba.SourceScan,
2519 locals->dpte_row_height,
2520 locals->dpte_row_height_chroma,
2521 locals->meta_row_width,
2522 locals->meta_row_height,
2523 locals->meta_req_width,
2524 locals->meta_req_height,
2525 locals->dpte_group_bytes,
2526 locals->PTERequestSizeY,
2527 locals->PTERequestSizeC,
2528 locals->PixelPTEReqWidthY,
2529 locals->PixelPTEReqHeightY,
2530 locals->PixelPTEReqWidthC,
2531 locals->PixelPTEReqHeightC,
2532 locals->dpte_row_width_luma_ub,
2533 locals->dpte_row_width_chroma_ub,
2534 locals->vm_group_bytes,
2535 locals->dpde0_bytes_per_frame_ub_l,
2536 locals->dpde0_bytes_per_frame_ub_c,
2537 locals->meta_pte_bytes_per_frame_ub_l,
2538 locals->meta_pte_bytes_per_frame_ub_c,
2539 locals->DST_Y_PER_PTE_ROW_NOM_L,
2540 locals->DST_Y_PER_PTE_ROW_NOM_C,
2541 locals->DST_Y_PER_META_ROW_NOM_L,
2542 locals->TimePerMetaChunkNominal,
2543 locals->TimePerMetaChunkVBlank,
2544 locals->TimePerMetaChunkFlip,
2545 locals->time_per_pte_group_nom_luma,
2546 locals->time_per_pte_group_vblank_luma,
2547 locals->time_per_pte_group_flip_luma,
2548 locals->time_per_pte_group_nom_chroma,
2549 locals->time_per_pte_group_vblank_chroma,
2550 locals->time_per_pte_group_flip_chroma,
2551 locals->TimePerVMGroupVBlank,
2552 locals->TimePerVMGroupFlip,
2553 locals->TimePerVMRequestVBlank,
2554 locals->TimePerVMRequestFlip);
2558 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2559 if (mode_lib->vba.PrefetchMode[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb] == 0) {
2560 locals->AllowDRAMClockChangeDuringVBlank[k] = true;
2561 locals->AllowDRAMSelfRefreshDuringVBlank[k] = true;
2562 locals->MinTTUVBlank[k] = dml_max(
2563 mode_lib->vba.DRAMClockChangeWatermark,
2565 mode_lib->vba.StutterEnterPlusExitWatermark,
2566 mode_lib->vba.UrgentWatermark));
2567 } else if (mode_lib->vba.PrefetchMode[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb] == 1) {
2568 locals->AllowDRAMClockChangeDuringVBlank[k] = false;
2569 locals->AllowDRAMSelfRefreshDuringVBlank[k] = true;
2570 locals->MinTTUVBlank[k] = dml_max(
2571 mode_lib->vba.StutterEnterPlusExitWatermark,
2572 mode_lib->vba.UrgentWatermark);
2574 locals->AllowDRAMClockChangeDuringVBlank[k] = false;
2575 locals->AllowDRAMSelfRefreshDuringVBlank[k] = false;
2576 locals->MinTTUVBlank[k] = mode_lib->vba.UrgentWatermark;
2578 if (!mode_lib->vba.DynamicMetadataEnable[k])
2579 locals->MinTTUVBlank[k] = mode_lib->vba.TCalc
2580 + locals->MinTTUVBlank[k];
2583 // DCC Configuration
2584 mode_lib->vba.ActiveDPPs = 0;
2585 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2586 locals->MaximumDCCCompressionYSurface[k] = CalculateDCCConfiguration(
2587 mode_lib->vba.DCCEnable[k],
2588 false, // We should always know the direction DCCProgrammingAssumesScanDirectionUnknown,
2589 mode_lib->vba.ViewportWidth[k],
2590 mode_lib->vba.ViewportHeight[k],
2591 mode_lib->vba.DETBufferSizeInKByte * 1024,
2592 locals->BlockHeight256BytesY[k],
2593 mode_lib->vba.SwathHeightY[k],
2594 mode_lib->vba.SurfaceTiling[k],
2595 locals->BytePerPixelDETY[k],
2596 mode_lib->vba.SourceScan[k],
2597 &locals->DCCYMaxUncompressedBlock[k],
2598 &locals->DCCYMaxCompressedBlock[k],
2599 &locals->DCCYIndependent64ByteBlock[k]);
2603 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2604 if (mode_lib->vba.XFCEnabled[k] == true) {
2607 locals->XFCSlaveVUpdateOffset[k] = mode_lib->vba.XFCTSlvVupdateOffset;
2608 locals->XFCSlaveVupdateWidth[k] = mode_lib->vba.XFCTSlvVupdateWidth;
2609 locals->XFCSlaveVReadyOffset[k] = mode_lib->vba.XFCTSlvVreadyOffset;
2610 TWait = CalculateTWait(
2611 mode_lib->vba.PrefetchMode[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb],
2612 mode_lib->vba.DRAMClockChangeLatency,
2613 mode_lib->vba.UrgentLatency,
2614 mode_lib->vba.SREnterPlusExitTime);
2615 mode_lib->vba.XFCRemoteSurfaceFlipDelay = CalculateRemoteSurfaceFlipDelay(
2617 mode_lib->vba.VRatio[k],
2618 locals->SwathWidthY[k],
2619 dml_ceil(locals->BytePerPixelDETY[k], 1),
2620 mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k],
2621 mode_lib->vba.XFCTSlvVupdateOffset,
2622 mode_lib->vba.XFCTSlvVupdateWidth,
2623 mode_lib->vba.XFCTSlvVreadyOffset,
2624 mode_lib->vba.XFCXBUFLatencyTolerance,
2625 mode_lib->vba.XFCFillBWOverhead,
2626 mode_lib->vba.XFCSlvChunkSize,
2627 mode_lib->vba.XFCBusTransportTime,
2628 mode_lib->vba.TCalc,
2630 &mode_lib->vba.SrcActiveDrainRate,
2631 &mode_lib->vba.TInitXFill,
2632 &mode_lib->vba.TslvChk);
2633 locals->XFCRemoteSurfaceFlipLatency[k] =
2635 mode_lib->vba.XFCRemoteSurfaceFlipDelay
2636 / (mode_lib->vba.HTotal[k]
2637 / mode_lib->vba.PixelClock[k]),
2639 locals->XFCTransferDelay[k] =
2641 mode_lib->vba.XFCBusTransportTime
2642 / (mode_lib->vba.HTotal[k]
2643 / mode_lib->vba.PixelClock[k]),
2645 locals->XFCPrechargeDelay[k] =
2647 (mode_lib->vba.XFCBusTransportTime
2648 + mode_lib->vba.TInitXFill
2649 + mode_lib->vba.TslvChk)
2650 / (mode_lib->vba.HTotal[k]
2651 / mode_lib->vba.PixelClock[k]),
2653 mode_lib->vba.InitFillLevel = mode_lib->vba.XFCXBUFLatencyTolerance
2654 * mode_lib->vba.SrcActiveDrainRate;
2655 mode_lib->vba.FinalFillMargin =
2656 (locals->DestinationLinesToRequestVMInVBlank[k]
2657 + locals->DestinationLinesToRequestRowInVBlank[k])
2658 * mode_lib->vba.HTotal[k]
2659 / mode_lib->vba.PixelClock[k]
2660 * mode_lib->vba.SrcActiveDrainRate
2661 + mode_lib->vba.XFCFillConstant;
2662 mode_lib->vba.FinalFillLevel = mode_lib->vba.XFCRemoteSurfaceFlipDelay
2663 * mode_lib->vba.SrcActiveDrainRate
2664 + mode_lib->vba.FinalFillMargin;
2665 mode_lib->vba.RemainingFillLevel = dml_max(
2667 mode_lib->vba.FinalFillLevel - mode_lib->vba.InitFillLevel);
2668 mode_lib->vba.TFinalxFill = mode_lib->vba.RemainingFillLevel
2669 / (mode_lib->vba.SrcActiveDrainRate
2670 * mode_lib->vba.XFCFillBWOverhead / 100);
2671 locals->XFCPrefetchMargin[k] =
2672 mode_lib->vba.XFCRemoteSurfaceFlipDelay
2673 + mode_lib->vba.TFinalxFill
2674 + (locals->DestinationLinesToRequestVMInVBlank[k]
2675 + locals->DestinationLinesToRequestRowInVBlank[k])
2676 * mode_lib->vba.HTotal[k]
2677 / mode_lib->vba.PixelClock[k];
2679 locals->XFCSlaveVUpdateOffset[k] = 0;
2680 locals->XFCSlaveVupdateWidth[k] = 0;
2681 locals->XFCSlaveVReadyOffset[k] = 0;
2682 locals->XFCRemoteSurfaceFlipLatency[k] = 0;
2683 locals->XFCPrechargeDelay[k] = 0;
2684 locals->XFCTransferDelay[k] = 0;
2685 locals->XFCPrefetchMargin[k] = 0;
2689 // Stutter Efficiency
2690 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2691 CalculateDETBufferSize(
2692 mode_lib->vba.DETBufferSizeInKByte,
2693 mode_lib->vba.SwathHeightY[k],
2694 mode_lib->vba.SwathHeightC[k],
2695 &locals->DETBufferSizeY[k],
2696 &locals->DETBufferSizeC[k]);
2698 locals->LinesInDETY[k] = locals->DETBufferSizeY[k]
2699 / locals->BytePerPixelDETY[k] / locals->SwathWidthY[k];
2700 locals->LinesInDETYRoundedDownToSwath[k] = dml_floor(
2701 locals->LinesInDETY[k],
2702 mode_lib->vba.SwathHeightY[k]);
2703 locals->FullDETBufferingTimeY[k] =
2704 locals->LinesInDETYRoundedDownToSwath[k]
2705 * (mode_lib->vba.HTotal[k]
2706 / mode_lib->vba.PixelClock[k])
2707 / mode_lib->vba.VRatio[k];
2710 mode_lib->vba.StutterPeriod = 999999.0;
2711 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2712 if (locals->FullDETBufferingTimeY[k] < mode_lib->vba.StutterPeriod) {
2713 mode_lib->vba.StutterPeriod = locals->FullDETBufferingTimeY[k];
2714 mode_lib->vba.FrameTimeForMinFullDETBufferingTime =
2715 (double) mode_lib->vba.VTotal[k] * mode_lib->vba.HTotal[k]
2716 / mode_lib->vba.PixelClock[k];
2717 locals->BytePerPixelYCriticalPlane = dml_ceil(locals->BytePerPixelDETY[k], 1);
2718 locals->SwathWidthYCriticalPlane = locals->SwathWidthY[k];
2719 locals->LinesToFinishSwathTransferStutterCriticalPlane =
2720 mode_lib->vba.SwathHeightY[k] - (locals->LinesInDETY[k] - locals->LinesInDETYRoundedDownToSwath[k]);
2724 mode_lib->vba.AverageReadBandwidth = 0.0;
2725 mode_lib->vba.TotalRowReadBandwidth = 0.0;
2726 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2727 unsigned int DCCRateLimit;
2729 if (mode_lib->vba.DCCEnable[k]) {
2730 if (locals->DCCYMaxCompressedBlock[k] == 256)
2735 mode_lib->vba.AverageReadBandwidth =
2736 mode_lib->vba.AverageReadBandwidth
2737 + (locals->ReadBandwidthPlaneLuma[k] + locals->ReadBandwidthPlaneChroma[k]) /
2738 dml_min(mode_lib->vba.DCCRate[k], DCCRateLimit);
2740 mode_lib->vba.AverageReadBandwidth =
2741 mode_lib->vba.AverageReadBandwidth
2742 + locals->ReadBandwidthPlaneLuma[k]
2743 + locals->ReadBandwidthPlaneChroma[k];
2745 mode_lib->vba.TotalRowReadBandwidth = mode_lib->vba.TotalRowReadBandwidth +
2746 locals->meta_row_bw[k] + locals->dpte_row_bw[k];
2749 mode_lib->vba.AverageDCCCompressionRate = mode_lib->vba.TotalDataReadBandwidth / mode_lib->vba.AverageReadBandwidth;
2751 mode_lib->vba.PartOfBurstThatFitsInROB =
2753 mode_lib->vba.StutterPeriod
2754 * mode_lib->vba.TotalDataReadBandwidth,
2755 mode_lib->vba.ROBBufferSizeInKByte * 1024
2756 * mode_lib->vba.AverageDCCCompressionRate);
2757 mode_lib->vba.StutterBurstTime = mode_lib->vba.PartOfBurstThatFitsInROB
2758 / mode_lib->vba.AverageDCCCompressionRate / mode_lib->vba.ReturnBW
2759 + (mode_lib->vba.StutterPeriod * mode_lib->vba.TotalDataReadBandwidth
2760 - mode_lib->vba.PartOfBurstThatFitsInROB)
2761 / (mode_lib->vba.DCFCLK * 64)
2762 + mode_lib->vba.StutterPeriod * mode_lib->vba.TotalRowReadBandwidth / mode_lib->vba.ReturnBW;
2763 mode_lib->vba.StutterBurstTime = dml_max(
2764 mode_lib->vba.StutterBurstTime,
2765 (locals->LinesToFinishSwathTransferStutterCriticalPlane * locals->BytePerPixelYCriticalPlane *
2766 locals->SwathWidthYCriticalPlane / mode_lib->vba.ReturnBW)
2769 mode_lib->vba.TotalActiveWriteback = 0;
2770 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2771 if (mode_lib->vba.WritebackEnable[k] == true) {
2772 mode_lib->vba.TotalActiveWriteback = mode_lib->vba.TotalActiveWriteback + 1;
2776 if (mode_lib->vba.TotalActiveWriteback == 0) {
2777 mode_lib->vba.StutterEfficiencyNotIncludingVBlank = (1
2778 - (mode_lib->vba.SRExitTime + mode_lib->vba.StutterBurstTime)
2779 / mode_lib->vba.StutterPeriod) * 100;
2781 mode_lib->vba.StutterEfficiencyNotIncludingVBlank = 0;
2784 mode_lib->vba.SmallestVBlank = 999999;
2785 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2786 if (mode_lib->vba.SynchronizedVBlank || mode_lib->vba.NumberOfActivePlanes == 1) {
2787 mode_lib->vba.VBlankTime = (double) (mode_lib->vba.VTotal[k]
2788 - mode_lib->vba.VActive[k]) * mode_lib->vba.HTotal[k]
2789 / mode_lib->vba.PixelClock[k];
2791 mode_lib->vba.VBlankTime = 0;
2793 mode_lib->vba.SmallestVBlank = dml_min(
2794 mode_lib->vba.SmallestVBlank,
2795 mode_lib->vba.VBlankTime);
2798 mode_lib->vba.StutterEfficiency = (mode_lib->vba.StutterEfficiencyNotIncludingVBlank / 100
2799 * (mode_lib->vba.FrameTimeForMinFullDETBufferingTime
2800 - mode_lib->vba.SmallestVBlank)
2801 + mode_lib->vba.SmallestVBlank)
2802 / mode_lib->vba.FrameTimeForMinFullDETBufferingTime * 100;
2805 static void DisplayPipeConfiguration(struct display_mode_lib *mode_lib)
2807 // Display Pipe Configuration
2808 double BytePerPixDETY;
2809 double BytePerPixDETC;
2810 double Read256BytesBlockHeightY;
2811 double Read256BytesBlockHeightC;
2812 double Read256BytesBlockWidthY;
2813 double Read256BytesBlockWidthC;
2814 double MaximumSwathHeightY;
2815 double MaximumSwathHeightC;
2816 double MinimumSwathHeightY;
2817 double MinimumSwathHeightC;
2819 double SwathWidthGranularityY;
2820 double SwathWidthGranularityC;
2821 double RoundedUpMaxSwathSizeBytesY;
2822 double RoundedUpMaxSwathSizeBytesC;
2825 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2826 bool MainPlaneDoesODMCombine = false;
2828 if (mode_lib->vba.SourcePixelFormat[k] == dm_444_64) {
2831 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_444_32) {
2834 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_444_16) {
2837 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_444_8) {
2840 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_420_8) {
2844 BytePerPixDETY = 4.0 / 3.0;
2845 BytePerPixDETC = 8.0 / 3.0;
2848 if ((mode_lib->vba.SourcePixelFormat[k] == dm_444_64
2849 || mode_lib->vba.SourcePixelFormat[k] == dm_444_32
2850 || mode_lib->vba.SourcePixelFormat[k] == dm_444_16
2851 || mode_lib->vba.SourcePixelFormat[k] == dm_444_8)) {
2852 if (mode_lib->vba.SurfaceTiling[k] == dm_sw_linear) {
2853 Read256BytesBlockHeightY = 1;
2854 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_444_64) {
2855 Read256BytesBlockHeightY = 4;
2856 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_444_32
2857 || mode_lib->vba.SourcePixelFormat[k] == dm_444_16) {
2858 Read256BytesBlockHeightY = 8;
2860 Read256BytesBlockHeightY = 16;
2862 Read256BytesBlockWidthY = 256 / dml_ceil(BytePerPixDETY, 1)
2863 / Read256BytesBlockHeightY;
2864 Read256BytesBlockHeightC = 0;
2865 Read256BytesBlockWidthC = 0;
2867 if (mode_lib->vba.SurfaceTiling[k] == dm_sw_linear) {
2868 Read256BytesBlockHeightY = 1;
2869 Read256BytesBlockHeightC = 1;
2870 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_420_8) {
2871 Read256BytesBlockHeightY = 16;
2872 Read256BytesBlockHeightC = 8;
2874 Read256BytesBlockHeightY = 8;
2875 Read256BytesBlockHeightC = 8;
2877 Read256BytesBlockWidthY = 256 / dml_ceil(BytePerPixDETY, 1)
2878 / Read256BytesBlockHeightY;
2879 Read256BytesBlockWidthC = 256 / dml_ceil(BytePerPixDETC, 2)
2880 / Read256BytesBlockHeightC;
2883 if (mode_lib->vba.SourceScan[k] == dm_horz) {
2884 MaximumSwathHeightY = Read256BytesBlockHeightY;
2885 MaximumSwathHeightC = Read256BytesBlockHeightC;
2887 MaximumSwathHeightY = Read256BytesBlockWidthY;
2888 MaximumSwathHeightC = Read256BytesBlockWidthC;
2891 if ((mode_lib->vba.SourcePixelFormat[k] == dm_444_64
2892 || mode_lib->vba.SourcePixelFormat[k] == dm_444_32
2893 || mode_lib->vba.SourcePixelFormat[k] == dm_444_16
2894 || mode_lib->vba.SourcePixelFormat[k] == dm_444_8)) {
2895 if (mode_lib->vba.SurfaceTiling[k] == dm_sw_linear
2896 || (mode_lib->vba.SourcePixelFormat[k] == dm_444_64
2897 && (mode_lib->vba.SurfaceTiling[k]
2899 || mode_lib->vba.SurfaceTiling[k]
2901 || mode_lib->vba.SurfaceTiling[k]
2903 || mode_lib->vba.SurfaceTiling[k]
2905 || mode_lib->vba.SurfaceTiling[k]
2907 || mode_lib->vba.SurfaceTiling[k]
2909 || mode_lib->vba.SurfaceTiling[k]
2911 && mode_lib->vba.SourceScan[k] == dm_horz)) {
2912 MinimumSwathHeightY = MaximumSwathHeightY;
2913 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_444_8
2914 && mode_lib->vba.SourceScan[k] != dm_horz) {
2915 MinimumSwathHeightY = MaximumSwathHeightY;
2917 MinimumSwathHeightY = MaximumSwathHeightY / 2.0;
2919 MinimumSwathHeightC = MaximumSwathHeightC;
2921 if (mode_lib->vba.SurfaceTiling[k] == dm_sw_linear) {
2922 MinimumSwathHeightY = MaximumSwathHeightY;
2923 MinimumSwathHeightC = MaximumSwathHeightC;
2924 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_420_8
2925 && mode_lib->vba.SourceScan[k] == dm_horz) {
2926 MinimumSwathHeightY = MaximumSwathHeightY / 2.0;
2927 MinimumSwathHeightC = MaximumSwathHeightC;
2928 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_420_10
2929 && mode_lib->vba.SourceScan[k] == dm_horz) {
2930 MinimumSwathHeightC = MaximumSwathHeightC / 2.0;
2931 MinimumSwathHeightY = MaximumSwathHeightY;
2933 MinimumSwathHeightY = MaximumSwathHeightY;
2934 MinimumSwathHeightC = MaximumSwathHeightC;
2938 if (mode_lib->vba.SourceScan[k] == dm_horz) {
2939 SwathWidth = mode_lib->vba.ViewportWidth[k];
2941 SwathWidth = mode_lib->vba.ViewportHeight[k];
2944 if (mode_lib->vba.ODMCombineEnabled[k] == dm_odm_combine_mode_2to1) {
2945 MainPlaneDoesODMCombine = true;
2947 for (j = 0; j < mode_lib->vba.NumberOfActivePlanes; ++j) {
2948 if (mode_lib->vba.BlendingAndTiming[k] == j
2949 && mode_lib->vba.ODMCombineEnabled[k] == dm_odm_combine_mode_2to1) {
2950 MainPlaneDoesODMCombine = true;
2954 if (MainPlaneDoesODMCombine == true) {
2955 SwathWidth = dml_min(
2957 mode_lib->vba.HActive[k] / 2.0 * mode_lib->vba.HRatio[k]);
2959 SwathWidth = SwathWidth / mode_lib->vba.DPPPerPlane[k];
2962 SwathWidthGranularityY = 256 / dml_ceil(BytePerPixDETY, 1) / MaximumSwathHeightY;
2963 RoundedUpMaxSwathSizeBytesY = (dml_ceil(
2964 (double) (SwathWidth - 1),
2965 SwathWidthGranularityY) + SwathWidthGranularityY) * BytePerPixDETY
2966 * MaximumSwathHeightY;
2967 if (mode_lib->vba.SourcePixelFormat[k] == dm_420_10) {
2968 RoundedUpMaxSwathSizeBytesY = dml_ceil(RoundedUpMaxSwathSizeBytesY, 256)
2971 if (MaximumSwathHeightC > 0) {
2972 SwathWidthGranularityC = 256.0 / dml_ceil(BytePerPixDETC, 2)
2973 / MaximumSwathHeightC;
2974 RoundedUpMaxSwathSizeBytesC = (dml_ceil(
2975 (double) (SwathWidth / 2.0 - 1),
2976 SwathWidthGranularityC) + SwathWidthGranularityC)
2977 * BytePerPixDETC * MaximumSwathHeightC;
2978 if (mode_lib->vba.SourcePixelFormat[k] == dm_420_10) {
2979 RoundedUpMaxSwathSizeBytesC = dml_ceil(
2980 RoundedUpMaxSwathSizeBytesC,
2984 RoundedUpMaxSwathSizeBytesC = 0.0;
2986 if (RoundedUpMaxSwathSizeBytesY + RoundedUpMaxSwathSizeBytesC
2987 <= mode_lib->vba.DETBufferSizeInKByte * 1024.0 / 2.0) {
2988 mode_lib->vba.SwathHeightY[k] = MaximumSwathHeightY;
2989 mode_lib->vba.SwathHeightC[k] = MaximumSwathHeightC;
2991 mode_lib->vba.SwathHeightY[k] = MinimumSwathHeightY;
2992 mode_lib->vba.SwathHeightC[k] = MinimumSwathHeightC;
2995 CalculateDETBufferSize(
2996 mode_lib->vba.DETBufferSizeInKByte,
2997 mode_lib->vba.SwathHeightY[k],
2998 mode_lib->vba.SwathHeightC[k],
2999 &mode_lib->vba.DETBufferSizeY[k],
3000 &mode_lib->vba.DETBufferSizeC[k]);
3004 static double CalculateTWait(
3005 unsigned int PrefetchMode,
3006 double DRAMClockChangeLatency,
3007 double UrgentLatency,
3008 double SREnterPlusExitTime)
3010 if (PrefetchMode == 0) {
3012 DRAMClockChangeLatency + UrgentLatency,
3013 dml_max(SREnterPlusExitTime, UrgentLatency));
3014 } else if (PrefetchMode == 1) {
3015 return dml_max(SREnterPlusExitTime, UrgentLatency);
3017 return UrgentLatency;
3021 static double CalculateRemoteSurfaceFlipDelay(
3022 struct display_mode_lib *mode_lib,
3027 double XFCTSlvVupdateOffset,
3028 double XFCTSlvVupdateWidth,
3029 double XFCTSlvVreadyOffset,
3030 double XFCXBUFLatencyTolerance,
3031 double XFCFillBWOverhead,
3032 double XFCSlvChunkSize,
3033 double XFCBusTransportTime,
3036 double *SrcActiveDrainRate,
3040 double TSlvSetup, AvgfillRate, result;
3042 *SrcActiveDrainRate = VRatio * SwathWidth * Bpp / LineTime;
3043 TSlvSetup = XFCTSlvVupdateOffset + XFCTSlvVupdateWidth + XFCTSlvVreadyOffset;
3044 *TInitXFill = XFCXBUFLatencyTolerance / (1 + XFCFillBWOverhead / 100);
3045 AvgfillRate = *SrcActiveDrainRate * (1 + XFCFillBWOverhead / 100);
3046 *TslvChk = XFCSlvChunkSize / AvgfillRate;
3048 "DML::CalculateRemoteSurfaceFlipDelay: SrcActiveDrainRate: %f\n",
3049 *SrcActiveDrainRate);
3050 dml_print("DML::CalculateRemoteSurfaceFlipDelay: TSlvSetup: %f\n", TSlvSetup);
3051 dml_print("DML::CalculateRemoteSurfaceFlipDelay: TInitXFill: %f\n", *TInitXFill);
3052 dml_print("DML::CalculateRemoteSurfaceFlipDelay: AvgfillRate: %f\n", AvgfillRate);
3053 dml_print("DML::CalculateRemoteSurfaceFlipDelay: TslvChk: %f\n", *TslvChk);
3054 result = 2 * XFCBusTransportTime + TSlvSetup + TCalc + TWait + *TslvChk + *TInitXFill; // TODO: This doesn't seem to match programming guide
3055 dml_print("DML::CalculateRemoteSurfaceFlipDelay: RemoteSurfaceFlipDelay: %f\n", result);
3059 static double CalculateWriteBackDelay(
3060 enum source_format_class WritebackPixelFormat,
3061 double WritebackHRatio,
3062 double WritebackVRatio,
3063 unsigned int WritebackLumaHTaps,
3064 unsigned int WritebackLumaVTaps,
3065 unsigned int WritebackChromaHTaps,
3066 unsigned int WritebackChromaVTaps,
3067 unsigned int WritebackDestinationWidth)
3069 double CalculateWriteBackDelay =
3071 dml_ceil(WritebackLumaHTaps / 4.0, 1) / WritebackHRatio,
3072 WritebackLumaVTaps * dml_ceil(1.0 / WritebackVRatio, 1)
3074 WritebackDestinationWidth
3077 + dml_ceil(1.0 / WritebackVRatio, 1)
3083 if (WritebackPixelFormat != dm_444_32) {
3084 CalculateWriteBackDelay =
3086 CalculateWriteBackDelay,
3089 WritebackChromaHTaps
3094 WritebackChromaVTaps
3101 WritebackDestinationWidth
3111 WritebackChromaVTaps
3116 return CalculateWriteBackDelay;
3119 static void CalculateActiveRowBandwidth(
3121 enum source_format_class SourcePixelFormat,
3125 unsigned int MetaRowByteLuma,
3126 unsigned int MetaRowByteChroma,
3127 unsigned int meta_row_height_luma,
3128 unsigned int meta_row_height_chroma,
3129 unsigned int PixelPTEBytesPerRowLuma,
3130 unsigned int PixelPTEBytesPerRowChroma,
3131 unsigned int dpte_row_height_luma,
3132 unsigned int dpte_row_height_chroma,
3133 double *meta_row_bw,
3134 double *dpte_row_bw)
3136 if (DCCEnable != true) {
3138 } else if (SourcePixelFormat == dm_420_8 || SourcePixelFormat == dm_420_10) {
3139 *meta_row_bw = VRatio * MetaRowByteLuma / (meta_row_height_luma * LineTime)
3140 + VRatio / 2 * MetaRowByteChroma
3141 / (meta_row_height_chroma * LineTime);
3143 *meta_row_bw = VRatio * MetaRowByteLuma / (meta_row_height_luma * LineTime);
3146 if (GPUVMEnable != true) {
3148 } else if (SourcePixelFormat == dm_420_8 || SourcePixelFormat == dm_420_10) {
3149 *dpte_row_bw = VRatio * PixelPTEBytesPerRowLuma / (dpte_row_height_luma * LineTime)
3150 + VRatio / 2 * PixelPTEBytesPerRowChroma
3151 / (dpte_row_height_chroma * LineTime);
3153 *dpte_row_bw = VRatio * PixelPTEBytesPerRowLuma / (dpte_row_height_luma * LineTime);
3157 static void CalculateFlipSchedule(
3158 struct display_mode_lib *mode_lib,
3159 double PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData,
3160 double PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly,
3161 double UrgentExtraLatency,
3162 double UrgentLatency,
3163 unsigned int GPUVMMaxPageTableLevels,
3165 unsigned int HostVMMaxPageTableLevels,
3166 unsigned int HostVMCachedPageTableLevels,
3168 double PDEAndMetaPTEBytesPerFrame,
3169 double MetaRowBytes,
3170 double DPTEBytesPerRow,
3171 double BandwidthAvailableForImmediateFlip,
3172 unsigned int TotImmediateFlipBytes,
3173 enum source_format_class SourcePixelFormat,
3178 unsigned int dpte_row_height,
3179 unsigned int meta_row_height,
3180 unsigned int dpte_row_height_chroma,
3181 unsigned int meta_row_height_chroma,
3182 double *DestinationLinesToRequestVMInImmediateFlip,
3183 double *DestinationLinesToRequestRowInImmediateFlip,
3184 double *final_flip_bw,
3185 bool *ImmediateFlipSupportedForPipe)
3187 double min_row_time = 0.0;
3188 unsigned int HostVMDynamicLevels;
3189 double TimeForFetchingMetaPTEImmediateFlip;
3190 double TimeForFetchingRowInVBlankImmediateFlip;
3191 double ImmediateFlipBW;
3192 double HostVMInefficiencyFactor;
3193 double VRatioClamped;
3195 if (GPUVMEnable == true && HostVMEnable == true) {
3196 HostVMInefficiencyFactor =
3197 PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData
3198 / PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly;
3199 HostVMDynamicLevels = HostVMMaxPageTableLevels - HostVMCachedPageTableLevels;
3201 HostVMInefficiencyFactor = 1;
3202 HostVMDynamicLevels = 0;
3205 ImmediateFlipBW = (PDEAndMetaPTEBytesPerFrame + MetaRowBytes + DPTEBytesPerRow)
3206 * BandwidthAvailableForImmediateFlip / TotImmediateFlipBytes;
3208 if (GPUVMEnable == true) {
3209 TimeForFetchingMetaPTEImmediateFlip = dml_max3(
3210 Tno_bw + PDEAndMetaPTEBytesPerFrame * HostVMInefficiencyFactor / ImmediateFlipBW,
3211 UrgentExtraLatency + UrgentLatency * (GPUVMMaxPageTableLevels * (HostVMDynamicLevels + 1) - 1),
3214 TimeForFetchingMetaPTEImmediateFlip = 0;
3217 *DestinationLinesToRequestVMInImmediateFlip = dml_ceil(4.0 * (TimeForFetchingMetaPTEImmediateFlip / LineTime), 1) / 4.0;
3218 if ((GPUVMEnable == true || DCCEnable == true)) {
3219 TimeForFetchingRowInVBlankImmediateFlip = dml_max3((MetaRowBytes + DPTEBytesPerRow) * HostVMInefficiencyFactor / ImmediateFlipBW, UrgentLatency * (HostVMDynamicLevels + 1), LineTime / 4);
3221 TimeForFetchingRowInVBlankImmediateFlip = 0;
3224 *DestinationLinesToRequestRowInImmediateFlip = dml_ceil(4.0 * (TimeForFetchingRowInVBlankImmediateFlip / LineTime), 1) / 4.0;
3225 *final_flip_bw = dml_max(PDEAndMetaPTEBytesPerFrame * HostVMInefficiencyFactor / (*DestinationLinesToRequestVMInImmediateFlip * LineTime), (MetaRowBytes + DPTEBytesPerRow) * HostVMInefficiencyFactor / (*DestinationLinesToRequestRowInImmediateFlip * LineTime));
3226 VRatioClamped = (VRatio < 1.0) ? 1.0 : VRatio;
3227 if (SourcePixelFormat == dm_420_8 || SourcePixelFormat == dm_420_10) {
3228 if (GPUVMEnable == true && DCCEnable != true) {
3229 min_row_time = dml_min(
3230 dpte_row_height * LineTime / VRatioClamped,
3231 dpte_row_height_chroma * LineTime / (VRatioClamped / 2));
3232 } else if (GPUVMEnable != true && DCCEnable == true) {
3233 min_row_time = dml_min(
3234 meta_row_height * LineTime / VRatioClamped,
3235 meta_row_height_chroma * LineTime / (VRatioClamped / 2));
3237 min_row_time = dml_min4(
3238 dpte_row_height * LineTime / VRatioClamped,
3239 meta_row_height * LineTime / VRatioClamped,
3240 dpte_row_height_chroma * LineTime / (VRatioClamped / 2),
3241 meta_row_height_chroma * LineTime / (VRatioClamped / 2));
3244 if (GPUVMEnable == true && DCCEnable != true) {
3245 min_row_time = dpte_row_height * LineTime / VRatioClamped;
3246 } else if (GPUVMEnable != true && DCCEnable == true) {
3247 min_row_time = meta_row_height * LineTime / VRatioClamped;
3249 min_row_time = dml_min(
3250 dpte_row_height * LineTime / VRatioClamped,
3251 meta_row_height * LineTime / VRatioClamped);
3255 if (*DestinationLinesToRequestVMInImmediateFlip >= 32
3256 || *DestinationLinesToRequestRowInImmediateFlip >= 16
3257 || TimeForFetchingMetaPTEImmediateFlip + 2 * TimeForFetchingRowInVBlankImmediateFlip > min_row_time) {
3258 *ImmediateFlipSupportedForPipe = false;
3260 *ImmediateFlipSupportedForPipe = true;
3264 static unsigned int TruncToValidBPP(
3268 enum output_encoder_class Output,
3269 enum output_format_class Format,
3270 unsigned int DSCInputBitPerComponent)
3272 if (Output == dm_hdmi) {
3273 if (Format == dm_420) {
3274 if (DecimalBPP >= 18 && (DesiredBPP == 0 || DesiredBPP == 18))
3276 else if (DecimalBPP >= 15 && (DesiredBPP == 0 || DesiredBPP == 15))
3278 else if (DecimalBPP >= 12 && (DesiredBPP == 0 || DesiredBPP == 12))
3282 } else if (Format == dm_444) {
3283 if (DecimalBPP >= 36 && (DesiredBPP == 0 || DesiredBPP == 36))
3285 else if (DecimalBPP >= 30 && (DesiredBPP == 0 || DesiredBPP == 30))
3287 else if (DecimalBPP >= 24 && (DesiredBPP == 0 || DesiredBPP == 24))
3289 else if (DecimalBPP >= 18 && (DesiredBPP == 0 || DesiredBPP == 18))
3294 if (DecimalBPP / 1.5 >= 24 && (DesiredBPP == 0 || DesiredBPP == 24))
3296 else if (DecimalBPP / 1.5 >= 20 && (DesiredBPP == 0 || DesiredBPP == 20))
3298 else if (DecimalBPP / 1.5 >= 16 && (DesiredBPP == 0 || DesiredBPP == 16))
3305 if (Format == dm_420) {
3306 if (DesiredBPP == 0) {
3309 else if (DecimalBPP >= 1.5 * DSCInputBitPerComponent - 1.0 / 16.0)
3310 return 1.5 * DSCInputBitPerComponent - 1.0 / 16.0;
3312 return dml_floor(16 * DecimalBPP, 1) / 16.0;
3316 || DesiredBPP > 1.5 * DSCInputBitPerComponent - 1.0 / 16.0
3317 || DecimalBPP < DesiredBPP) {
3323 } else if (Format == dm_n422) {
3324 if (DesiredBPP == 0) {
3327 else if (DecimalBPP >= 2 * DSCInputBitPerComponent - 1.0 / 16.0)
3328 return 2 * DSCInputBitPerComponent - 1.0 / 16.0;
3330 return dml_floor(16 * DecimalBPP, 1) / 16.0;
3334 || DesiredBPP > 2 * DSCInputBitPerComponent - 1.0 / 16.0
3335 || DecimalBPP < DesiredBPP) {
3342 if (DesiredBPP == 0) {
3345 else if (DecimalBPP >= 3 * DSCInputBitPerComponent - 1.0 / 16.0)
3346 return 3 * DSCInputBitPerComponent - 1.0 / 16.0;
3348 return dml_floor(16 * DecimalBPP, 1) / 16.0;
3352 || DesiredBPP > 3 * DSCInputBitPerComponent - 1.0 / 16.0
3353 || DecimalBPP < DesiredBPP) {
3360 } else if (Format == dm_420) {
3361 if (DecimalBPP >= 18 && (DesiredBPP == 0 || DesiredBPP == 18))
3363 else if (DecimalBPP >= 15 && (DesiredBPP == 0 || DesiredBPP == 15))
3365 else if (DecimalBPP >= 12 && (DesiredBPP == 0 || DesiredBPP == 12))
3369 } else if (Format == dm_s422 || Format == dm_n422) {
3370 if (DecimalBPP >= 24 && (DesiredBPP == 0 || DesiredBPP == 24))
3372 else if (DecimalBPP >= 20 && (DesiredBPP == 0 || DesiredBPP == 20))
3374 else if (DecimalBPP >= 16 && (DesiredBPP == 0 || DesiredBPP == 16))
3379 if (DecimalBPP >= 36 && (DesiredBPP == 0 || DesiredBPP == 36))
3381 else if (DecimalBPP >= 30 && (DesiredBPP == 0 || DesiredBPP == 30))
3383 else if (DecimalBPP >= 24 && (DesiredBPP == 0 || DesiredBPP == 24))
3385 else if (DecimalBPP >= 18 && (DesiredBPP == 0 || DesiredBPP == 18))
3393 void dml21_ModeSupportAndSystemConfigurationFull(struct display_mode_lib *mode_lib)
3395 struct vba_vars_st *locals = &mode_lib->vba;
3398 unsigned int j, k, m;
3400 /*MODE SUPPORT, VOLTAGE STATE AND SOC CONFIGURATION*/
3402 /*Scale Ratio, taps Support Check*/
3404 mode_lib->vba.ScaleRatioAndTapsSupport = true;
3405 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
3406 if (mode_lib->vba.ScalerEnabled[k] == false
3407 && ((mode_lib->vba.SourcePixelFormat[k] != dm_444_64
3408 && mode_lib->vba.SourcePixelFormat[k] != dm_444_32
3409 && mode_lib->vba.SourcePixelFormat[k] != dm_444_16
3410 && mode_lib->vba.SourcePixelFormat[k] != dm_mono_16
3411 && mode_lib->vba.SourcePixelFormat[k] != dm_mono_8)
3412 || mode_lib->vba.HRatio[k] != 1.0
3413 || mode_lib->vba.htaps[k] != 1.0
3414 || mode_lib->vba.VRatio[k] != 1.0
3415 || mode_lib->vba.vtaps[k] != 1.0)) {
3416 mode_lib->vba.ScaleRatioAndTapsSupport = false;
3417 } else if (mode_lib->vba.vtaps[k] < 1.0 || mode_lib->vba.vtaps[k] > 8.0
3418 || mode_lib->vba.htaps[k] < 1.0 || mode_lib->vba.htaps[k] > 8.0
3419 || (mode_lib->vba.htaps[k] > 1.0
3420 && (mode_lib->vba.htaps[k] % 2) == 1)
3421 || mode_lib->vba.HRatio[k] > mode_lib->vba.MaxHSCLRatio
3422 || mode_lib->vba.VRatio[k] > mode_lib->vba.MaxVSCLRatio
3423 || mode_lib->vba.HRatio[k] > mode_lib->vba.htaps[k]
3424 || mode_lib->vba.VRatio[k] > mode_lib->vba.vtaps[k]
3425 || (mode_lib->vba.SourcePixelFormat[k] != dm_444_64
3426 && mode_lib->vba.SourcePixelFormat[k] != dm_444_32
3427 && mode_lib->vba.SourcePixelFormat[k] != dm_444_16
3428 && mode_lib->vba.SourcePixelFormat[k] != dm_mono_16
3429 && mode_lib->vba.SourcePixelFormat[k] != dm_mono_8
3430 && (mode_lib->vba.HRatio[k] / 2.0
3431 > mode_lib->vba.HTAPsChroma[k]
3432 || mode_lib->vba.VRatio[k] / 2.0
3433 > mode_lib->vba.VTAPsChroma[k]))) {
3434 mode_lib->vba.ScaleRatioAndTapsSupport = false;
3437 /*Source Format, Pixel Format and Scan Support Check*/
3439 mode_lib->vba.SourceFormatPixelAndScanSupport = true;
3440 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
3441 if ((mode_lib->vba.SurfaceTiling[k] == dm_sw_linear
3442 && mode_lib->vba.SourceScan[k] != dm_horz)
3443 || ((mode_lib->vba.SurfaceTiling[k] == dm_sw_4kb_d
3444 || mode_lib->vba.SurfaceTiling[k] == dm_sw_4kb_d_x
3445 || mode_lib->vba.SurfaceTiling[k] == dm_sw_64kb_d
3446 || mode_lib->vba.SurfaceTiling[k] == dm_sw_64kb_d_t
3447 || mode_lib->vba.SurfaceTiling[k] == dm_sw_64kb_d_x
3448 || mode_lib->vba.SurfaceTiling[k] == dm_sw_var_d
3449 || mode_lib->vba.SurfaceTiling[k] == dm_sw_var_d_x)
3450 && mode_lib->vba.SourcePixelFormat[k] != dm_444_64)
3451 || (mode_lib->vba.SurfaceTiling[k] == dm_sw_64kb_r_x
3452 && (mode_lib->vba.SourcePixelFormat[k] == dm_mono_8
3453 || mode_lib->vba.SourcePixelFormat[k]
3455 || mode_lib->vba.SourcePixelFormat[k]
3457 || (((mode_lib->vba.SurfaceTiling[k] == dm_sw_gfx7_2d_thin_gl
3458 || mode_lib->vba.SurfaceTiling[k]
3459 == dm_sw_gfx7_2d_thin_l_vp)
3460 && !((mode_lib->vba.SourcePixelFormat[k]
3462 || mode_lib->vba.SourcePixelFormat[k]
3464 && mode_lib->vba.SourceScan[k]
3466 && mode_lib->vba.SupportGFX7CompatibleTilingIn32bppAnd64bpp
3468 && mode_lib->vba.DCCEnable[k]
3470 || (mode_lib->vba.DCCEnable[k] == true
3471 && (mode_lib->vba.SurfaceTiling[k]
3473 || mode_lib->vba.SourcePixelFormat[k]
3475 || mode_lib->vba.SourcePixelFormat[k]
3477 mode_lib->vba.SourceFormatPixelAndScanSupport = false;
3480 /*Bandwidth Support Check*/
3482 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
3483 if (mode_lib->vba.SourcePixelFormat[k] == dm_444_64) {
3484 locals->BytePerPixelInDETY[k] = 8.0;
3485 locals->BytePerPixelInDETC[k] = 0.0;
3486 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_444_32) {
3487 locals->BytePerPixelInDETY[k] = 4.0;
3488 locals->BytePerPixelInDETC[k] = 0.0;
3489 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_444_16
3490 || mode_lib->vba.SourcePixelFormat[k] == dm_mono_16) {
3491 locals->BytePerPixelInDETY[k] = 2.0;
3492 locals->BytePerPixelInDETC[k] = 0.0;
3493 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_mono_8) {
3494 locals->BytePerPixelInDETY[k] = 1.0;
3495 locals->BytePerPixelInDETC[k] = 0.0;
3496 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_420_8) {
3497 locals->BytePerPixelInDETY[k] = 1.0;
3498 locals->BytePerPixelInDETC[k] = 2.0;
3500 locals->BytePerPixelInDETY[k] = 4.0 / 3;
3501 locals->BytePerPixelInDETC[k] = 8.0 / 3;
3503 if (mode_lib->vba.SourceScan[k] == dm_horz) {
3504 locals->SwathWidthYSingleDPP[k] = mode_lib->vba.ViewportWidth[k];
3506 locals->SwathWidthYSingleDPP[k] = mode_lib->vba.ViewportHeight[k];
3509 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
3510 locals->ReadBandwidthLuma[k] = locals->SwathWidthYSingleDPP[k] * dml_ceil(locals->BytePerPixelInDETY[k], 1.0)
3511 / (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]) * mode_lib->vba.VRatio[k];
3512 locals->ReadBandwidthChroma[k] = locals->SwathWidthYSingleDPP[k] / 2 * dml_ceil(locals->BytePerPixelInDETC[k], 2.0)
3513 / (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]) * mode_lib->vba.VRatio[k] / 2.0;
3514 locals->ReadBandwidth[k] = locals->ReadBandwidthLuma[k] + locals->ReadBandwidthChroma[k];
3516 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
3517 if (mode_lib->vba.WritebackEnable[k] == true
3518 && mode_lib->vba.WritebackPixelFormat[k] == dm_444_32) {
3519 locals->WriteBandwidth[k] = mode_lib->vba.WritebackDestinationWidth[k]
3520 * mode_lib->vba.WritebackDestinationHeight[k]
3521 / (mode_lib->vba.WritebackSourceHeight[k]
3522 * mode_lib->vba.HTotal[k]
3523 / mode_lib->vba.PixelClock[k]) * 4.0;
3524 } else if (mode_lib->vba.WritebackEnable[k] == true
3525 && mode_lib->vba.WritebackPixelFormat[k] == dm_420_10) {
3526 locals->WriteBandwidth[k] = mode_lib->vba.WritebackDestinationWidth[k]
3527 * mode_lib->vba.WritebackDestinationHeight[k]
3528 / (mode_lib->vba.WritebackSourceHeight[k]
3529 * mode_lib->vba.HTotal[k]
3530 / mode_lib->vba.PixelClock[k]) * 3.0;
3531 } else if (mode_lib->vba.WritebackEnable[k] == true) {
3532 locals->WriteBandwidth[k] = mode_lib->vba.WritebackDestinationWidth[k]
3533 * mode_lib->vba.WritebackDestinationHeight[k]
3534 / (mode_lib->vba.WritebackSourceHeight[k]
3535 * mode_lib->vba.HTotal[k]
3536 / mode_lib->vba.PixelClock[k]) * 1.5;
3538 locals->WriteBandwidth[k] = 0.0;
3541 mode_lib->vba.DCCEnabledInAnyPlane = false;
3542 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
3543 if (mode_lib->vba.DCCEnable[k] == true) {
3544 mode_lib->vba.DCCEnabledInAnyPlane = true;
3547 for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
3548 locals->IdealSDPPortBandwidthPerState[i][0] = dml_min3(
3549 mode_lib->vba.ReturnBusWidth * mode_lib->vba.DCFCLKPerState[i],
3550 mode_lib->vba.DRAMSpeedPerState[i] * mode_lib->vba.NumberOfChannels
3551 * mode_lib->vba.DRAMChannelWidth,
3552 mode_lib->vba.FabricClockPerState[i]
3553 * mode_lib->vba.FabricDatapathToDCNDataReturn);
3554 if (mode_lib->vba.HostVMEnable == false) {
3555 locals->ReturnBWPerState[i][0] = locals->IdealSDPPortBandwidthPerState[i][0]
3556 * mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelDataOnly / 100.0;
3558 locals->ReturnBWPerState[i][0] = locals->IdealSDPPortBandwidthPerState[i][0]
3559 * mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData / 100.0;
3562 /*Writeback Latency support check*/
3564 mode_lib->vba.WritebackLatencySupport = true;
3565 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
3566 if (mode_lib->vba.WritebackEnable[k] == true) {
3567 if (mode_lib->vba.WritebackPixelFormat[k] == dm_444_32) {
3568 if (locals->WriteBandwidth[k]
3569 > (mode_lib->vba.WritebackInterfaceLumaBufferSize
3570 + mode_lib->vba.WritebackInterfaceChromaBufferSize)
3571 / mode_lib->vba.WritebackLatency) {
3572 mode_lib->vba.WritebackLatencySupport = false;
3575 if (locals->WriteBandwidth[k]
3578 mode_lib->vba.WritebackInterfaceLumaBufferSize,
3580 * mode_lib->vba.WritebackInterfaceChromaBufferSize)
3581 / mode_lib->vba.WritebackLatency) {
3582 mode_lib->vba.WritebackLatencySupport = false;
3587 /*Re-ordering Buffer Support Check*/
3589 for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
3590 locals->UrgentRoundTripAndOutOfOrderLatencyPerState[i] =
3591 (mode_lib->vba.RoundTripPingLatencyCycles + 32.0) / mode_lib->vba.DCFCLKPerState[i]
3592 + dml_max3(mode_lib->vba.UrgentOutOfOrderReturnPerChannelPixelDataOnly,
3593 mode_lib->vba.UrgentOutOfOrderReturnPerChannelPixelMixedWithVMData,
3594 mode_lib->vba.UrgentOutOfOrderReturnPerChannelVMDataOnly)
3595 * mode_lib->vba.NumberOfChannels / locals->ReturnBWPerState[i][0];
3596 if ((mode_lib->vba.ROBBufferSizeInKByte - mode_lib->vba.PixelChunkSizeInKByte) * 1024.0 / locals->ReturnBWPerState[i][0]
3597 > locals->UrgentRoundTripAndOutOfOrderLatencyPerState[i]) {
3598 locals->ROBSupport[i][0] = true;
3600 locals->ROBSupport[i][0] = false;
3603 /*Writeback Mode Support Check*/
3605 mode_lib->vba.TotalNumberOfActiveWriteback = 0;
3606 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
3607 if (mode_lib->vba.WritebackEnable[k] == true) {
3608 if (mode_lib->vba.ActiveWritebacksPerPlane[k] == 0)
3609 mode_lib->vba.ActiveWritebacksPerPlane[k] = 1;
3610 mode_lib->vba.TotalNumberOfActiveWriteback =
3611 mode_lib->vba.TotalNumberOfActiveWriteback
3612 + mode_lib->vba.ActiveWritebacksPerPlane[k];
3615 mode_lib->vba.WritebackModeSupport = true;
3616 if (mode_lib->vba.TotalNumberOfActiveWriteback > mode_lib->vba.MaxNumWriteback) {
3617 mode_lib->vba.WritebackModeSupport = false;
3619 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
3620 if (mode_lib->vba.WritebackEnable[k] == true
3621 && mode_lib->vba.Writeback10bpc420Supported != true
3622 && mode_lib->vba.WritebackPixelFormat[k] == dm_420_10) {
3623 mode_lib->vba.WritebackModeSupport = false;
3626 /*Writeback Scale Ratio and Taps Support Check*/
3628 mode_lib->vba.WritebackScaleRatioAndTapsSupport = true;
3629 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
3630 if (mode_lib->vba.WritebackEnable[k] == true) {
3631 if (mode_lib->vba.WritebackLumaAndChromaScalingSupported == false
3632 && (mode_lib->vba.WritebackHRatio[k] != 1.0
3633 || mode_lib->vba.WritebackVRatio[k] != 1.0)) {
3634 mode_lib->vba.WritebackScaleRatioAndTapsSupport = false;
3636 if (mode_lib->vba.WritebackHRatio[k] > mode_lib->vba.WritebackMaxHSCLRatio
3637 || mode_lib->vba.WritebackVRatio[k]
3638 > mode_lib->vba.WritebackMaxVSCLRatio
3639 || mode_lib->vba.WritebackHRatio[k]
3640 < mode_lib->vba.WritebackMinHSCLRatio
3641 || mode_lib->vba.WritebackVRatio[k]
3642 < mode_lib->vba.WritebackMinVSCLRatio
3643 || mode_lib->vba.WritebackLumaHTaps[k]
3644 > mode_lib->vba.WritebackMaxHSCLTaps
3645 || mode_lib->vba.WritebackLumaVTaps[k]
3646 > mode_lib->vba.WritebackMaxVSCLTaps
3647 || mode_lib->vba.WritebackHRatio[k]
3648 > mode_lib->vba.WritebackLumaHTaps[k]
3649 || mode_lib->vba.WritebackVRatio[k]
3650 > mode_lib->vba.WritebackLumaVTaps[k]
3651 || (mode_lib->vba.WritebackLumaHTaps[k] > 2.0
3652 && ((mode_lib->vba.WritebackLumaHTaps[k] % 2)
3654 || (mode_lib->vba.WritebackPixelFormat[k] != dm_444_32
3655 && (mode_lib->vba.WritebackChromaHTaps[k]
3656 > mode_lib->vba.WritebackMaxHSCLTaps
3657 || mode_lib->vba.WritebackChromaVTaps[k]
3658 > mode_lib->vba.WritebackMaxVSCLTaps
3660 * mode_lib->vba.WritebackHRatio[k]
3661 > mode_lib->vba.WritebackChromaHTaps[k]
3663 * mode_lib->vba.WritebackVRatio[k]
3664 > mode_lib->vba.WritebackChromaVTaps[k]
3665 || (mode_lib->vba.WritebackChromaHTaps[k] > 2.0
3666 && ((mode_lib->vba.WritebackChromaHTaps[k] % 2) == 1))))) {
3667 mode_lib->vba.WritebackScaleRatioAndTapsSupport = false;
3669 if (mode_lib->vba.WritebackVRatio[k] < 1.0) {
3670 mode_lib->vba.WritebackLumaVExtra =
3671 dml_max(1.0 - 2.0 / dml_ceil(1.0 / mode_lib->vba.WritebackVRatio[k], 1.0), 0.0);
3673 mode_lib->vba.WritebackLumaVExtra = -1;
3675 if ((mode_lib->vba.WritebackPixelFormat[k] == dm_444_32
3676 && mode_lib->vba.WritebackLumaVTaps[k]
3677 > (mode_lib->vba.WritebackLineBufferLumaBufferSize
3678 + mode_lib->vba.WritebackLineBufferChromaBufferSize)
3680 / mode_lib->vba.WritebackDestinationWidth[k]
3681 - mode_lib->vba.WritebackLumaVExtra)
3682 || (mode_lib->vba.WritebackPixelFormat[k] == dm_420_8
3683 && mode_lib->vba.WritebackLumaVTaps[k]
3684 > mode_lib->vba.WritebackLineBufferLumaBufferSize
3685 * 8.0 / 10.0 / mode_lib->vba.WritebackDestinationWidth[k]
3686 - mode_lib->vba.WritebackLumaVExtra)
3687 || (mode_lib->vba.WritebackPixelFormat[k] == dm_420_10
3688 && mode_lib->vba.WritebackLumaVTaps[k]
3689 > mode_lib->vba.WritebackLineBufferLumaBufferSize
3691 / mode_lib->vba.WritebackDestinationWidth[k]
3692 - mode_lib->vba.WritebackLumaVExtra)) {
3693 mode_lib->vba.WritebackScaleRatioAndTapsSupport = false;
3695 if (2.0 * mode_lib->vba.WritebackVRatio[k] < 1) {
3696 mode_lib->vba.WritebackChromaVExtra = 0.0;
3698 mode_lib->vba.WritebackChromaVExtra = -1;
3700 if ((mode_lib->vba.WritebackPixelFormat[k] == dm_420_8
3701 && mode_lib->vba.WritebackChromaVTaps[k]
3702 > mode_lib->vba.WritebackLineBufferChromaBufferSize
3703 * 8.0 / 10.0 / mode_lib->vba.WritebackDestinationWidth[k]
3704 - mode_lib->vba.WritebackChromaVExtra)
3705 || (mode_lib->vba.WritebackPixelFormat[k] == dm_420_10
3706 && mode_lib->vba.WritebackChromaVTaps[k]
3707 > mode_lib->vba.WritebackLineBufferChromaBufferSize
3709 / mode_lib->vba.WritebackDestinationWidth[k]
3710 - mode_lib->vba.WritebackChromaVExtra)) {
3711 mode_lib->vba.WritebackScaleRatioAndTapsSupport = false;
3715 /*Maximum DISPCLK/DPPCLK Support check*/
3717 mode_lib->vba.WritebackRequiredDISPCLK = 0.0;
3718 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
3719 if (mode_lib->vba.WritebackEnable[k] == true) {
3720 mode_lib->vba.WritebackRequiredDISPCLK =
3722 mode_lib->vba.WritebackRequiredDISPCLK,
3723 CalculateWriteBackDISPCLK(
3724 mode_lib->vba.WritebackPixelFormat[k],
3725 mode_lib->vba.PixelClock[k],
3726 mode_lib->vba.WritebackHRatio[k],
3727 mode_lib->vba.WritebackVRatio[k],
3728 mode_lib->vba.WritebackLumaHTaps[k],
3729 mode_lib->vba.WritebackLumaVTaps[k],
3730 mode_lib->vba.WritebackChromaHTaps[k],
3731 mode_lib->vba.WritebackChromaVTaps[k],
3732 mode_lib->vba.WritebackDestinationWidth[k],
3733 mode_lib->vba.HTotal[k],
3734 mode_lib->vba.WritebackChromaLineBufferWidth));
3737 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
3738 if (mode_lib->vba.HRatio[k] > 1.0) {
3739 locals->PSCL_FACTOR[k] = dml_min(
3740 mode_lib->vba.MaxDCHUBToPSCLThroughput,
3741 mode_lib->vba.MaxPSCLToLBThroughput
3742 * mode_lib->vba.HRatio[k]
3744 mode_lib->vba.htaps[k]
3748 locals->PSCL_FACTOR[k] = dml_min(
3749 mode_lib->vba.MaxDCHUBToPSCLThroughput,
3750 mode_lib->vba.MaxPSCLToLBThroughput);
3752 if (locals->BytePerPixelInDETC[k] == 0.0) {
3753 locals->PSCL_FACTOR_CHROMA[k] = 0.0;
3754 locals->MinDPPCLKUsingSingleDPP[k] =
3755 mode_lib->vba.PixelClock[k]
3757 mode_lib->vba.vtaps[k] / 6.0
3760 mode_lib->vba.HRatio[k]),
3761 mode_lib->vba.HRatio[k]
3762 * mode_lib->vba.VRatio[k]
3763 / locals->PSCL_FACTOR[k],
3765 if ((mode_lib->vba.htaps[k] > 6.0 || mode_lib->vba.vtaps[k] > 6.0)
3766 && locals->MinDPPCLKUsingSingleDPP[k]
3767 < 2.0 * mode_lib->vba.PixelClock[k]) {
3768 locals->MinDPPCLKUsingSingleDPP[k] = 2.0
3769 * mode_lib->vba.PixelClock[k];
3772 if (mode_lib->vba.HRatio[k] / 2.0 > 1.0) {
3773 locals->PSCL_FACTOR_CHROMA[k] =
3775 mode_lib->vba.MaxDCHUBToPSCLThroughput,
3776 mode_lib->vba.MaxPSCLToLBThroughput
3777 * mode_lib->vba.HRatio[k]
3780 mode_lib->vba.HTAPsChroma[k]
3784 locals->PSCL_FACTOR_CHROMA[k] = dml_min(
3785 mode_lib->vba.MaxDCHUBToPSCLThroughput,
3786 mode_lib->vba.MaxPSCLToLBThroughput);
3788 locals->MinDPPCLKUsingSingleDPP[k] =
3789 mode_lib->vba.PixelClock[k]
3791 mode_lib->vba.vtaps[k] / 6.0
3794 mode_lib->vba.HRatio[k]),
3795 mode_lib->vba.HRatio[k]
3796 * mode_lib->vba.VRatio[k]
3797 / locals->PSCL_FACTOR[k],
3798 mode_lib->vba.VTAPsChroma[k]
3802 mode_lib->vba.HRatio[k]
3804 mode_lib->vba.HRatio[k]
3805 * mode_lib->vba.VRatio[k]
3807 / locals->PSCL_FACTOR_CHROMA[k],
3809 if ((mode_lib->vba.htaps[k] > 6.0 || mode_lib->vba.vtaps[k] > 6.0
3810 || mode_lib->vba.HTAPsChroma[k] > 6.0
3811 || mode_lib->vba.VTAPsChroma[k] > 6.0)
3812 && locals->MinDPPCLKUsingSingleDPP[k]
3813 < 2.0 * mode_lib->vba.PixelClock[k]) {
3814 locals->MinDPPCLKUsingSingleDPP[k] = 2.0
3815 * mode_lib->vba.PixelClock[k];
3819 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
3820 Calculate256BBlockSizes(
3821 mode_lib->vba.SourcePixelFormat[k],
3822 mode_lib->vba.SurfaceTiling[k],
3823 dml_ceil(locals->BytePerPixelInDETY[k], 1.0),
3824 dml_ceil(locals->BytePerPixelInDETC[k], 2.0),
3825 &locals->Read256BlockHeightY[k],
3826 &locals->Read256BlockHeightC[k],
3827 &locals->Read256BlockWidthY[k],
3828 &locals->Read256BlockWidthC[k]);
3829 if (mode_lib->vba.SourceScan[k] == dm_horz) {
3830 locals->MaxSwathHeightY[k] = locals->Read256BlockHeightY[k];
3831 locals->MaxSwathHeightC[k] = locals->Read256BlockHeightC[k];
3833 locals->MaxSwathHeightY[k] = locals->Read256BlockWidthY[k];
3834 locals->MaxSwathHeightC[k] = locals->Read256BlockWidthC[k];
3836 if ((mode_lib->vba.SourcePixelFormat[k] == dm_444_64
3837 || mode_lib->vba.SourcePixelFormat[k] == dm_444_32
3838 || mode_lib->vba.SourcePixelFormat[k] == dm_444_16
3839 || mode_lib->vba.SourcePixelFormat[k] == dm_mono_16
3840 || mode_lib->vba.SourcePixelFormat[k] == dm_mono_8)) {
3841 if (mode_lib->vba.SurfaceTiling[k] == dm_sw_linear
3842 || (mode_lib->vba.SourcePixelFormat[k] == dm_444_64
3843 && (mode_lib->vba.SurfaceTiling[k]
3845 || mode_lib->vba.SurfaceTiling[k]
3847 || mode_lib->vba.SurfaceTiling[k]
3849 || mode_lib->vba.SurfaceTiling[k]
3851 || mode_lib->vba.SurfaceTiling[k]
3853 || mode_lib->vba.SurfaceTiling[k]
3855 || mode_lib->vba.SurfaceTiling[k]
3857 && mode_lib->vba.SourceScan[k] == dm_horz)) {
3858 locals->MinSwathHeightY[k] = locals->MaxSwathHeightY[k];
3860 locals->MinSwathHeightY[k] = locals->MaxSwathHeightY[k]
3863 locals->MinSwathHeightC[k] = locals->MaxSwathHeightC[k];
3865 if (mode_lib->vba.SurfaceTiling[k] == dm_sw_linear) {
3866 locals->MinSwathHeightY[k] = locals->MaxSwathHeightY[k];
3867 locals->MinSwathHeightC[k] = locals->MaxSwathHeightC[k];
3868 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_420_8
3869 && mode_lib->vba.SourceScan[k] == dm_horz) {
3870 locals->MinSwathHeightY[k] = locals->MaxSwathHeightY[k]
3872 locals->MinSwathHeightC[k] = locals->MaxSwathHeightC[k];
3873 } else if (mode_lib->vba.SourcePixelFormat[k] == dm_420_10
3874 && mode_lib->vba.SourceScan[k] == dm_horz) {
3875 locals->MinSwathHeightC[k] = locals->MaxSwathHeightC[k]
3877 locals->MinSwathHeightY[k] = locals->MaxSwathHeightY[k];
3879 locals->MinSwathHeightY[k] = locals->MaxSwathHeightY[k];
3880 locals->MinSwathHeightC[k] = locals->MaxSwathHeightC[k];
3883 if (mode_lib->vba.SurfaceTiling[k] == dm_sw_linear) {
3884 mode_lib->vba.MaximumSwathWidthSupport = 8192.0;
3886 mode_lib->vba.MaximumSwathWidthSupport = 5120.0;
3888 mode_lib->vba.MaximumSwathWidthInDETBuffer =
3890 mode_lib->vba.MaximumSwathWidthSupport,
3891 mode_lib->vba.DETBufferSizeInKByte * 1024.0 / 2.0
3892 / (locals->BytePerPixelInDETY[k]
3893 * locals->MinSwathHeightY[k]
3894 + locals->BytePerPixelInDETC[k]
3896 * locals->MinSwathHeightC[k]));
3897 if (locals->BytePerPixelInDETC[k] == 0.0) {
3898 mode_lib->vba.MaximumSwathWidthInLineBuffer =
3899 mode_lib->vba.LineBufferSize
3900 * dml_max(mode_lib->vba.HRatio[k], 1.0)
3901 / mode_lib->vba.LBBitPerPixel[k]
3902 / (mode_lib->vba.vtaps[k]
3905 mode_lib->vba.VRatio[k],
3910 mode_lib->vba.MaximumSwathWidthInLineBuffer =
3912 mode_lib->vba.LineBufferSize
3914 mode_lib->vba.HRatio[k],
3916 / mode_lib->vba.LBBitPerPixel[k]
3917 / (mode_lib->vba.vtaps[k]
3920 mode_lib->vba.VRatio[k],
3924 2.0 * mode_lib->vba.LineBufferSize
3926 mode_lib->vba.HRatio[k]
3929 / mode_lib->vba.LBBitPerPixel[k]
3930 / (mode_lib->vba.VTAPsChroma[k]
3933 mode_lib->vba.VRatio[k]
3939 locals->MaximumSwathWidth[k] = dml_min(
3940 mode_lib->vba.MaximumSwathWidthInDETBuffer,
3941 mode_lib->vba.MaximumSwathWidthInLineBuffer);
3943 for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
3944 double MaxMaxDispclkRoundedDown = RoundToDFSGranularityDown(
3945 mode_lib->vba.MaxDispclk[mode_lib->vba.soc.num_states],
3946 mode_lib->vba.DISPCLKDPPCLKVCOSpeed);
3948 for (j = 0; j < 2; j++) {
3949 mode_lib->vba.MaxDispclkRoundedDownToDFSGranularity = RoundToDFSGranularityDown(
3950 mode_lib->vba.MaxDispclk[i],
3951 mode_lib->vba.DISPCLKDPPCLKVCOSpeed);
3952 mode_lib->vba.MaxDppclkRoundedDownToDFSGranularity = RoundToDFSGranularityDown(
3953 mode_lib->vba.MaxDppclk[i],
3954 mode_lib->vba.DISPCLKDPPCLKVCOSpeed);
3955 locals->RequiredDISPCLK[i][j] = 0.0;
3956 locals->DISPCLK_DPPCLK_Support[i][j] = true;
3957 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
3958 mode_lib->vba.PlaneRequiredDISPCLKWithoutODMCombine =
3959 mode_lib->vba.PixelClock[k]
3961 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading
3964 + mode_lib->vba.DISPCLKRampingMargin
3966 if (mode_lib->vba.PlaneRequiredDISPCLKWithoutODMCombine >= mode_lib->vba.MaxDispclk[i]
3967 && i == mode_lib->vba.soc.num_states)
3968 mode_lib->vba.PlaneRequiredDISPCLKWithoutODMCombine = mode_lib->vba.PixelClock[k]
3969 * (1 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0);
3971 mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine = mode_lib->vba.PixelClock[k] / 2
3972 * (1 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0) * (1 + mode_lib->vba.DISPCLKRampingMargin / 100.0);
3973 if (mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine >= mode_lib->vba.MaxDispclk[i]
3974 && i == mode_lib->vba.soc.num_states)
3975 mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine = mode_lib->vba.PixelClock[k] / 2
3976 * (1 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0);
3978 locals->ODMCombineEnablePerState[i][k] = false;
3979 mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PlaneRequiredDISPCLKWithoutODMCombine;
3980 if (mode_lib->vba.ODMCapability) {
3981 if (locals->PlaneRequiredDISPCLKWithoutODMCombine > MaxMaxDispclkRoundedDown) {
3982 locals->ODMCombineEnablePerState[i][k] = true;
3983 mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine;
3984 } else if (locals->DSCEnabled[k] && (locals->HActive[k] > DCN21_MAX_DSC_IMAGE_WIDTH)) {
3985 locals->ODMCombineEnablePerState[i][k] = true;
3986 mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine;
3987 } else if (locals->HActive[k] > DCN21_MAX_420_IMAGE_WIDTH && locals->OutputFormat[k] == dm_420) {
3988 locals->ODMCombineEnablePerState[i][k] = true;
3989 mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine;
3993 if (locals->MinDPPCLKUsingSingleDPP[k] * (1.0 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0) <= mode_lib->vba.MaxDppclkRoundedDownToDFSGranularity
3994 && locals->SwathWidthYSingleDPP[k] <= locals->MaximumSwathWidth[k]
3995 && locals->ODMCombineEnablePerState[i][k] == dm_odm_combine_mode_disabled) {
3996 locals->NoOfDPP[i][j][k] = 1;
3997 locals->RequiredDPPCLK[i][j][k] =
3998 locals->MinDPPCLKUsingSingleDPP[k] * (1.0 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0);
4000 locals->NoOfDPP[i][j][k] = 2;
4001 locals->RequiredDPPCLK[i][j][k] =
4002 locals->MinDPPCLKUsingSingleDPP[k] * (1.0 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0) / 2.0;
4004 locals->RequiredDISPCLK[i][j] = dml_max(
4005 locals->RequiredDISPCLK[i][j],
4006 mode_lib->vba.PlaneRequiredDISPCLK);
4007 if ((locals->MinDPPCLKUsingSingleDPP[k] / locals->NoOfDPP[i][j][k] * (1.0 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0)
4008 > mode_lib->vba.MaxDppclkRoundedDownToDFSGranularity)
4009 || (mode_lib->vba.PlaneRequiredDISPCLK > mode_lib->vba.MaxDispclkRoundedDownToDFSGranularity)) {
4010 locals->DISPCLK_DPPCLK_Support[i][j] = false;
4013 locals->TotalNumberOfActiveDPP[i][j] = 0.0;
4014 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++)
4015 locals->TotalNumberOfActiveDPP[i][j] = locals->TotalNumberOfActiveDPP[i][j] + locals->NoOfDPP[i][j][k];
4017 while (locals->TotalNumberOfActiveDPP[i][j] < mode_lib->vba.MaxNumDPP
4018 && locals->TotalNumberOfActiveDPP[i][j] < 2 * mode_lib->vba.NumberOfActivePlanes) {
4019 double BWOfNonSplitPlaneOfMaximumBandwidth;
4020 unsigned int NumberOfNonSplitPlaneOfMaximumBandwidth;
4022 BWOfNonSplitPlaneOfMaximumBandwidth = 0;
4023 NumberOfNonSplitPlaneOfMaximumBandwidth = 0;
4024 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
4025 if (locals->ReadBandwidth[k] > BWOfNonSplitPlaneOfMaximumBandwidth && locals->NoOfDPP[i][j][k] == 1) {
4026 BWOfNonSplitPlaneOfMaximumBandwidth = locals->ReadBandwidth[k];
4027 NumberOfNonSplitPlaneOfMaximumBandwidth = k;
4030 locals->NoOfDPP[i][j][NumberOfNonSplitPlaneOfMaximumBandwidth] = 2;
4031 locals->RequiredDPPCLK[i][j][NumberOfNonSplitPlaneOfMaximumBandwidth] =
4032 locals->MinDPPCLKUsingSingleDPP[NumberOfNonSplitPlaneOfMaximumBandwidth]
4033 * (1 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100) / 2;
4034 locals->TotalNumberOfActiveDPP[i][j] = locals->TotalNumberOfActiveDPP[i][j] + 1;
4037 if (locals->TotalNumberOfActiveDPP[i][j] > mode_lib->vba.MaxNumDPP) {
4038 locals->RequiredDISPCLK[i][j] = 0.0;
4039 locals->DISPCLK_DPPCLK_Support[i][j] = true;
4040 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4041 locals->ODMCombineEnablePerState[i][k] = false;
4042 if (locals->SwathWidthYSingleDPP[k] <= locals->MaximumSwathWidth[k]) {
4043 locals->NoOfDPP[i][j][k] = 1;
4044 locals->RequiredDPPCLK[i][j][k] = locals->MinDPPCLKUsingSingleDPP[k]
4045 * (1.0 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0);
4047 locals->NoOfDPP[i][j][k] = 2;
4048 locals->RequiredDPPCLK[i][j][k] = locals->MinDPPCLKUsingSingleDPP[k]
4049 * (1.0 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0) / 2.0;
4051 if (i != mode_lib->vba.soc.num_states) {
4052 mode_lib->vba.PlaneRequiredDISPCLK =
4053 mode_lib->vba.PixelClock[k]
4054 * (1.0 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0)
4055 * (1.0 + mode_lib->vba.DISPCLKRampingMargin / 100.0);
4057 mode_lib->vba.PlaneRequiredDISPCLK = mode_lib->vba.PixelClock[k]
4058 * (1.0 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0);
4060 locals->RequiredDISPCLK[i][j] = dml_max(
4061 locals->RequiredDISPCLK[i][j],
4062 mode_lib->vba.PlaneRequiredDISPCLK);
4063 if (locals->MinDPPCLKUsingSingleDPP[k] / locals->NoOfDPP[i][j][k] * (1.0 + mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0)
4064 > mode_lib->vba.MaxDppclkRoundedDownToDFSGranularity
4065 || mode_lib->vba.PlaneRequiredDISPCLK > mode_lib->vba.MaxDispclkRoundedDownToDFSGranularity)
4066 locals->DISPCLK_DPPCLK_Support[i][j] = false;
4068 locals->TotalNumberOfActiveDPP[i][j] = 0.0;
4069 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++)
4070 locals->TotalNumberOfActiveDPP[i][j] = locals->TotalNumberOfActiveDPP[i][j] + locals->NoOfDPP[i][j][k];
4072 locals->RequiredDISPCLK[i][j] = dml_max(
4073 locals->RequiredDISPCLK[i][j],
4074 mode_lib->vba.WritebackRequiredDISPCLK);
4075 if (mode_lib->vba.MaxDispclkRoundedDownToDFSGranularity
4076 < mode_lib->vba.WritebackRequiredDISPCLK) {
4077 locals->DISPCLK_DPPCLK_Support[i][j] = false;
4081 /*Viewport Size Check*/
4083 for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
4084 locals->ViewportSizeSupport[i][0] = true;
4085 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4086 if (locals->ODMCombineEnablePerState[i][k] == dm_odm_combine_mode_2to1) {
4087 if (dml_min(locals->SwathWidthYSingleDPP[k], dml_round(mode_lib->vba.HActive[k] / 2.0 * mode_lib->vba.HRatio[k]))
4088 > locals->MaximumSwathWidth[k]) {
4089 locals->ViewportSizeSupport[i][0] = false;
4092 if (locals->SwathWidthYSingleDPP[k] / 2.0 > locals->MaximumSwathWidth[k]) {
4093 locals->ViewportSizeSupport[i][0] = false;
4098 /*Total Available Pipes Support Check*/
4100 for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
4101 for (j = 0; j < 2; j++) {
4102 if (locals->TotalNumberOfActiveDPP[i][j] <= mode_lib->vba.MaxNumDPP)
4103 locals->TotalAvailablePipesSupport[i][j] = true;
4105 locals->TotalAvailablePipesSupport[i][j] = false;
4108 /*Total Available OTG Support Check*/
4110 mode_lib->vba.TotalNumberOfActiveOTG = 0.0;
4111 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4112 if (mode_lib->vba.BlendingAndTiming[k] == k) {
4113 mode_lib->vba.TotalNumberOfActiveOTG = mode_lib->vba.TotalNumberOfActiveOTG
4117 if (mode_lib->vba.TotalNumberOfActiveOTG <= mode_lib->vba.MaxNumOTG) {
4118 mode_lib->vba.NumberOfOTGSupport = true;
4120 mode_lib->vba.NumberOfOTGSupport = false;
4122 /*Display IO and DSC Support Check*/
4124 mode_lib->vba.NonsupportedDSCInputBPC = false;
4125 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4126 if (!(mode_lib->vba.DSCInputBitPerComponent[k] == 12.0
4127 || mode_lib->vba.DSCInputBitPerComponent[k] == 10.0
4128 || mode_lib->vba.DSCInputBitPerComponent[k] == 8.0)) {
4129 mode_lib->vba.NonsupportedDSCInputBPC = true;
4132 for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
4133 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4134 locals->RequiresDSC[i][k] = false;
4135 locals->RequiresFEC[i][k] = 0;
4136 if (mode_lib->vba.BlendingAndTiming[k] == k) {
4137 if (mode_lib->vba.Output[k] == dm_hdmi) {
4138 locals->RequiresDSC[i][k] = false;
4139 locals->RequiresFEC[i][k] = 0;
4140 locals->OutputBppPerState[i][k] = TruncToValidBPP(
4141 dml_min(600.0, mode_lib->vba.PHYCLKPerState[i]) / mode_lib->vba.PixelClockBackEnd[k] * 24,
4142 mode_lib->vba.ForcedOutputLinkBPP[k],
4144 mode_lib->vba.Output[k],
4145 mode_lib->vba.OutputFormat[k],
4146 mode_lib->vba.DSCInputBitPerComponent[k]);
4147 } else if (mode_lib->vba.Output[k] == dm_dp
4148 || mode_lib->vba.Output[k] == dm_edp) {
4149 if (mode_lib->vba.Output[k] == dm_edp) {
4150 mode_lib->vba.EffectiveFECOverhead = 0.0;
4152 mode_lib->vba.EffectiveFECOverhead =
4153 mode_lib->vba.FECOverhead;
4155 if (mode_lib->vba.PHYCLKPerState[i] >= 270.0) {
4156 mode_lib->vba.Outbpp = TruncToValidBPP(
4157 (1.0 - mode_lib->vba.Downspreading / 100.0) * 270.0
4158 * mode_lib->vba.OutputLinkDPLanes[k] / mode_lib->vba.PixelClockBackEnd[k] * 8.0,
4159 mode_lib->vba.ForcedOutputLinkBPP[k],
4161 mode_lib->vba.Output[k],
4162 mode_lib->vba.OutputFormat[k],
4163 mode_lib->vba.DSCInputBitPerComponent[k]);
4164 mode_lib->vba.OutbppDSC = TruncToValidBPP(
4165 (1.0 - mode_lib->vba.Downspreading / 100.0) * (1.0 - mode_lib->vba.EffectiveFECOverhead / 100.0) * 270.0
4166 * mode_lib->vba.OutputLinkDPLanes[k] / mode_lib->vba.PixelClockBackEnd[k] * 8.0,
4167 mode_lib->vba.ForcedOutputLinkBPP[k],
4169 mode_lib->vba.Output[k],
4170 mode_lib->vba.OutputFormat[k],
4171 mode_lib->vba.DSCInputBitPerComponent[k]);
4172 if (mode_lib->vba.DSCEnabled[k] == true) {
4173 locals->RequiresDSC[i][k] = true;
4174 if (mode_lib->vba.Output[k] == dm_dp) {
4175 locals->RequiresFEC[i][k] = true;
4177 locals->RequiresFEC[i][k] = false;
4179 mode_lib->vba.Outbpp = mode_lib->vba.OutbppDSC;
4181 locals->RequiresDSC[i][k] = false;
4182 locals->RequiresFEC[i][k] = false;
4184 locals->OutputBppPerState[i][k] = mode_lib->vba.Outbpp;
4186 if (mode_lib->vba.Outbpp == BPP_INVALID && mode_lib->vba.PHYCLKPerState[i] >= 540.0) {
4187 mode_lib->vba.Outbpp = TruncToValidBPP(
4188 (1.0 - mode_lib->vba.Downspreading / 100.0) * 540.0
4189 * mode_lib->vba.OutputLinkDPLanes[k] / mode_lib->vba.PixelClockBackEnd[k] * 8.0,
4190 mode_lib->vba.ForcedOutputLinkBPP[k],
4192 mode_lib->vba.Output[k],
4193 mode_lib->vba.OutputFormat[k],
4194 mode_lib->vba.DSCInputBitPerComponent[k]);
4195 mode_lib->vba.OutbppDSC = TruncToValidBPP(
4196 (1.0 - mode_lib->vba.Downspreading / 100.0) * (1.0 - mode_lib->vba.EffectiveFECOverhead / 100.0) * 540.0
4197 * mode_lib->vba.OutputLinkDPLanes[k] / mode_lib->vba.PixelClockBackEnd[k] * 8.0,
4198 mode_lib->vba.ForcedOutputLinkBPP[k],
4200 mode_lib->vba.Output[k],
4201 mode_lib->vba.OutputFormat[k],
4202 mode_lib->vba.DSCInputBitPerComponent[k]);
4203 if (mode_lib->vba.DSCEnabled[k] == true) {
4204 locals->RequiresDSC[i][k] = true;
4205 if (mode_lib->vba.Output[k] == dm_dp) {
4206 locals->RequiresFEC[i][k] = true;
4208 locals->RequiresFEC[i][k] = false;
4210 mode_lib->vba.Outbpp = mode_lib->vba.OutbppDSC;
4212 locals->RequiresDSC[i][k] = false;
4213 locals->RequiresFEC[i][k] = false;
4215 locals->OutputBppPerState[i][k] = mode_lib->vba.Outbpp;
4217 if (mode_lib->vba.Outbpp == BPP_INVALID
4218 && mode_lib->vba.PHYCLKPerState[i]
4220 mode_lib->vba.Outbpp = TruncToValidBPP(
4221 (1.0 - mode_lib->vba.Downspreading / 100.0) * 810.0
4222 * mode_lib->vba.OutputLinkDPLanes[k] / mode_lib->vba.PixelClockBackEnd[k] * 8.0,
4223 mode_lib->vba.ForcedOutputLinkBPP[k],
4225 mode_lib->vba.Output[k],
4226 mode_lib->vba.OutputFormat[k],
4227 mode_lib->vba.DSCInputBitPerComponent[k]);
4228 mode_lib->vba.OutbppDSC = TruncToValidBPP(
4229 (1.0 - mode_lib->vba.Downspreading / 100.0) * (1.0 - mode_lib->vba.EffectiveFECOverhead / 100.0) * 810.0
4230 * mode_lib->vba.OutputLinkDPLanes[k] / mode_lib->vba.PixelClockBackEnd[k] * 8.0,
4231 mode_lib->vba.ForcedOutputLinkBPP[k],
4233 mode_lib->vba.Output[k],
4234 mode_lib->vba.OutputFormat[k],
4235 mode_lib->vba.DSCInputBitPerComponent[k]);
4236 if (mode_lib->vba.DSCEnabled[k] == true || mode_lib->vba.Outbpp == BPP_INVALID) {
4237 locals->RequiresDSC[i][k] = true;
4238 if (mode_lib->vba.Output[k] == dm_dp) {
4239 locals->RequiresFEC[i][k] = true;
4241 locals->RequiresFEC[i][k] = false;
4243 mode_lib->vba.Outbpp = mode_lib->vba.OutbppDSC;
4245 locals->RequiresDSC[i][k] = false;
4246 locals->RequiresFEC[i][k] = false;
4248 locals->OutputBppPerState[i][k] =
4249 mode_lib->vba.Outbpp;
4253 locals->OutputBppPerState[i][k] = BPP_BLENDED_PIPE;
4257 for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
4258 locals->DIOSupport[i] = true;
4259 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4260 if (!mode_lib->vba.skip_dio_check[k]
4261 && (locals->OutputBppPerState[i][k] == BPP_INVALID
4262 || (mode_lib->vba.OutputFormat[k] == dm_420
4263 && mode_lib->vba.Interlace[k] == true
4264 && mode_lib->vba.ProgressiveToInterlaceUnitInOPP == true))) {
4265 locals->DIOSupport[i] = false;
4269 for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
4270 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4271 locals->DSCCLKRequiredMoreThanSupported[i] = false;
4272 if (mode_lib->vba.BlendingAndTiming[k] == k) {
4273 if ((mode_lib->vba.Output[k] == dm_dp
4274 || mode_lib->vba.Output[k] == dm_edp)) {
4275 if (mode_lib->vba.OutputFormat[k] == dm_420
4276 || mode_lib->vba.OutputFormat[k]
4278 mode_lib->vba.DSCFormatFactor = 2;
4280 mode_lib->vba.DSCFormatFactor = 1;
4282 if (locals->RequiresDSC[i][k] == true) {
4283 if (locals->ODMCombineEnablePerState[i][k] == dm_odm_combine_mode_2to1) {
4284 if (mode_lib->vba.PixelClockBackEnd[k] / 6.0 / mode_lib->vba.DSCFormatFactor
4285 > (1.0 - mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0) * mode_lib->vba.MaxDSCCLK[i]) {
4286 locals->DSCCLKRequiredMoreThanSupported[i] =
4290 if (mode_lib->vba.PixelClockBackEnd[k] / 3.0 / mode_lib->vba.DSCFormatFactor
4291 > (1.0 - mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0) * mode_lib->vba.MaxDSCCLK[i]) {
4292 locals->DSCCLKRequiredMoreThanSupported[i] =
4301 for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
4302 locals->NotEnoughDSCUnits[i] = false;
4303 mode_lib->vba.TotalDSCUnitsRequired = 0.0;
4304 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4305 if (locals->RequiresDSC[i][k] == true) {
4306 if (locals->ODMCombineEnablePerState[i][k] == dm_odm_combine_mode_2to1) {
4307 mode_lib->vba.TotalDSCUnitsRequired =
4308 mode_lib->vba.TotalDSCUnitsRequired + 2.0;
4310 mode_lib->vba.TotalDSCUnitsRequired =
4311 mode_lib->vba.TotalDSCUnitsRequired + 1.0;
4315 if (mode_lib->vba.TotalDSCUnitsRequired > mode_lib->vba.NumberOfDSC) {
4316 locals->NotEnoughDSCUnits[i] = true;
4319 /*DSC Delay per state*/
4321 for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
4322 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4323 if (mode_lib->vba.BlendingAndTiming[k] != k) {
4324 mode_lib->vba.slices = 0;
4325 } else if (locals->RequiresDSC[i][k] == 0
4326 || locals->RequiresDSC[i][k] == false) {
4327 mode_lib->vba.slices = 0;
4328 } else if (mode_lib->vba.PixelClockBackEnd[k] > 3200.0) {
4329 mode_lib->vba.slices = dml_ceil(
4330 mode_lib->vba.PixelClockBackEnd[k] / 400.0,
4332 } else if (mode_lib->vba.PixelClockBackEnd[k] > 1360.0) {
4333 mode_lib->vba.slices = 8.0;
4334 } else if (mode_lib->vba.PixelClockBackEnd[k] > 680.0) {
4335 mode_lib->vba.slices = 4.0;
4336 } else if (mode_lib->vba.PixelClockBackEnd[k] > 340.0) {
4337 mode_lib->vba.slices = 2.0;
4339 mode_lib->vba.slices = 1.0;
4341 if (locals->OutputBppPerState[i][k] == BPP_BLENDED_PIPE
4342 || locals->OutputBppPerState[i][k] == BPP_INVALID) {
4343 mode_lib->vba.bpp = 0.0;
4345 mode_lib->vba.bpp = locals->OutputBppPerState[i][k];
4347 if (locals->RequiresDSC[i][k] == true && mode_lib->vba.bpp != 0.0) {
4348 if (locals->ODMCombineEnablePerState[i][k] == dm_odm_combine_mode_disabled) {
4349 locals->DSCDelayPerState[i][k] =
4351 mode_lib->vba.DSCInputBitPerComponent[k],
4354 mode_lib->vba.HActive[k]
4355 / mode_lib->vba.slices,
4357 mode_lib->vba.slices,
4358 mode_lib->vba.OutputFormat[k])
4360 mode_lib->vba.OutputFormat[k]);
4362 locals->DSCDelayPerState[i][k] =
4363 2.0 * (dscceComputeDelay(
4364 mode_lib->vba.DSCInputBitPerComponent[k],
4366 dml_ceil(mode_lib->vba.HActive[k] / mode_lib->vba.slices, 1.0),
4367 mode_lib->vba.slices / 2,
4368 mode_lib->vba.OutputFormat[k])
4369 + dscComputeDelay(mode_lib->vba.OutputFormat[k]));
4371 locals->DSCDelayPerState[i][k] =
4372 locals->DSCDelayPerState[i][k] * mode_lib->vba.PixelClock[k] / mode_lib->vba.PixelClockBackEnd[k];
4374 locals->DSCDelayPerState[i][k] = 0.0;
4377 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4378 for (m = 0; m <= mode_lib->vba.NumberOfActivePlanes - 1; m++) {
4379 for (j = 0; j <= mode_lib->vba.NumberOfActivePlanes - 1; j++) {
4380 if (mode_lib->vba.BlendingAndTiming[k] == m && locals->RequiresDSC[i][m] == true)
4381 locals->DSCDelayPerState[i][k] = locals->DSCDelayPerState[i][m];
4388 for (i = 0; i <= mode_lib->vba.soc.num_states; ++i) {
4389 for (j = 0; j <= 1; ++j) {
4390 locals->TotalNumberOfDCCActiveDPP[i][j] = 0;
4391 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
4392 if (mode_lib->vba.DCCEnable[k] == true)
4393 locals->TotalNumberOfDCCActiveDPP[i][j] = locals->TotalNumberOfDCCActiveDPP[i][j] + locals->NoOfDPP[i][j][k];
4398 mode_lib->vba.UrgentLatency = dml_max3(
4399 mode_lib->vba.UrgentLatencyPixelDataOnly,
4400 mode_lib->vba.UrgentLatencyPixelMixedWithVMData,
4401 mode_lib->vba.UrgentLatencyVMDataOnly);
4402 mode_lib->vba.PrefetchERROR = CalculateMinAndMaxPrefetchMode(
4403 mode_lib->vba.AllowDRAMSelfRefreshOrDRAMClockChangeInVblank,
4404 &mode_lib->vba.MinPrefetchMode,
4405 &mode_lib->vba.MaxPrefetchMode);
4407 for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
4408 for (j = 0; j < 2; j++) {
4409 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4410 locals->RequiredDPPCLKThisState[k] = locals->RequiredDPPCLK[i][j][k];
4411 locals->NoOfDPPThisState[k] = locals->NoOfDPP[i][j][k];
4412 if (locals->ODMCombineEnablePerState[i][k] == dm_odm_combine_mode_2to1) {
4413 locals->SwathWidthYThisState[k] =
4414 dml_min(locals->SwathWidthYSingleDPP[k], dml_round(mode_lib->vba.HActive[k] / 2.0 * mode_lib->vba.HRatio[k]));
4416 locals->SwathWidthYThisState[k] = locals->SwathWidthYSingleDPP[k] / locals->NoOfDPP[i][j][k];
4418 mode_lib->vba.SwathWidthGranularityY = 256.0
4419 / dml_ceil(locals->BytePerPixelInDETY[k], 1.0)
4420 / locals->MaxSwathHeightY[k];
4421 mode_lib->vba.RoundedUpMaxSwathSizeBytesY =
4422 (dml_ceil(locals->SwathWidthYThisState[k] - 1.0, mode_lib->vba.SwathWidthGranularityY)
4423 + mode_lib->vba.SwathWidthGranularityY) * locals->BytePerPixelInDETY[k] * locals->MaxSwathHeightY[k];
4424 if (mode_lib->vba.SourcePixelFormat[k] == dm_420_10) {
4425 mode_lib->vba.RoundedUpMaxSwathSizeBytesY = dml_ceil(
4426 mode_lib->vba.RoundedUpMaxSwathSizeBytesY,
4429 if (locals->MaxSwathHeightC[k] > 0.0) {
4430 mode_lib->vba.SwathWidthGranularityC = 256.0 / dml_ceil(locals->BytePerPixelInDETC[k], 2.0) / locals->MaxSwathHeightC[k];
4431 mode_lib->vba.RoundedUpMaxSwathSizeBytesC = (dml_ceil(locals->SwathWidthYThisState[k] / 2.0 - 1.0, mode_lib->vba.SwathWidthGranularityC)
4432 + mode_lib->vba.SwathWidthGranularityC) * locals->BytePerPixelInDETC[k] * locals->MaxSwathHeightC[k];
4433 if (mode_lib->vba.SourcePixelFormat[k] == dm_420_10) {
4434 mode_lib->vba.RoundedUpMaxSwathSizeBytesC = dml_ceil(mode_lib->vba.RoundedUpMaxSwathSizeBytesC, 256.0) + 256;
4437 mode_lib->vba.RoundedUpMaxSwathSizeBytesC = 0.0;
4439 if (mode_lib->vba.RoundedUpMaxSwathSizeBytesY + mode_lib->vba.RoundedUpMaxSwathSizeBytesC
4440 <= mode_lib->vba.DETBufferSizeInKByte * 1024.0 / 2.0) {
4441 locals->SwathHeightYThisState[k] = locals->MaxSwathHeightY[k];
4442 locals->SwathHeightCThisState[k] = locals->MaxSwathHeightC[k];
4444 locals->SwathHeightYThisState[k] =
4445 locals->MinSwathHeightY[k];
4446 locals->SwathHeightCThisState[k] =
4447 locals->MinSwathHeightC[k];
4451 CalculateDCFCLKDeepSleep(
4453 mode_lib->vba.NumberOfActivePlanes,
4454 locals->BytePerPixelInDETY,
4455 locals->BytePerPixelInDETC,
4456 mode_lib->vba.VRatio,
4457 locals->SwathWidthYThisState,
4458 locals->NoOfDPPThisState,
4459 mode_lib->vba.HRatio,
4460 mode_lib->vba.PixelClock,
4461 locals->PSCL_FACTOR,
4462 locals->PSCL_FACTOR_CHROMA,
4463 locals->RequiredDPPCLKThisState,
4464 &mode_lib->vba.ProjectedDCFCLKDeepSleep[0][0]);
4466 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4467 if ((mode_lib->vba.SourcePixelFormat[k] != dm_444_64
4468 && mode_lib->vba.SourcePixelFormat[k] != dm_444_32
4469 && mode_lib->vba.SourcePixelFormat[k] != dm_444_16
4470 && mode_lib->vba.SourcePixelFormat[k] != dm_mono_16
4471 && mode_lib->vba.SourcePixelFormat[k] != dm_mono_8)) {
4472 mode_lib->vba.PDEAndMetaPTEBytesPerFrameC = CalculateVMAndRowBytes(
4474 mode_lib->vba.DCCEnable[k],
4475 locals->Read256BlockHeightC[k],
4476 locals->Read256BlockWidthC[k],
4477 mode_lib->vba.SourcePixelFormat[k],
4478 mode_lib->vba.SurfaceTiling[k],
4479 dml_ceil(locals->BytePerPixelInDETC[k], 2.0),
4480 mode_lib->vba.SourceScan[k],
4481 mode_lib->vba.ViewportWidth[k] / 2.0,
4482 mode_lib->vba.ViewportHeight[k] / 2.0,
4483 locals->SwathWidthYThisState[k] / 2.0,
4484 mode_lib->vba.GPUVMEnable,
4485 mode_lib->vba.HostVMEnable,
4486 mode_lib->vba.HostVMMaxPageTableLevels,
4487 mode_lib->vba.HostVMCachedPageTableLevels,
4488 mode_lib->vba.VMMPageSize,
4489 mode_lib->vba.PTEBufferSizeInRequestsChroma,
4490 mode_lib->vba.PitchC[k],
4492 &locals->MacroTileWidthC[k],
4493 &mode_lib->vba.MetaRowBytesC,
4494 &mode_lib->vba.DPTEBytesPerRowC,
4495 &locals->PTEBufferSizeNotExceededC[i][j][k],
4496 locals->dpte_row_width_chroma_ub,
4497 &locals->dpte_row_height_chroma[k],
4498 &locals->meta_req_width_chroma[k],
4499 &locals->meta_req_height_chroma[k],
4500 &locals->meta_row_width_chroma[k],
4501 &locals->meta_row_height_chroma[k],
4502 &locals->vm_group_bytes_chroma,
4503 &locals->dpte_group_bytes_chroma,
4504 locals->PixelPTEReqWidthC,
4505 locals->PixelPTEReqHeightC,
4506 locals->PTERequestSizeC,
4507 locals->dpde0_bytes_per_frame_ub_c,
4508 locals->meta_pte_bytes_per_frame_ub_c);
4509 locals->PrefetchLinesC[0][0][k] = CalculatePrefetchSourceLines(
4511 mode_lib->vba.VRatio[k]/2,
4512 mode_lib->vba.VTAPsChroma[k],
4513 mode_lib->vba.Interlace[k],
4514 mode_lib->vba.ProgressiveToInterlaceUnitInOPP,
4515 locals->SwathHeightCThisState[k],
4516 mode_lib->vba.ViewportYStartC[k],
4517 &locals->PrefillC[k],
4518 &locals->MaxNumSwC[k]);
4519 locals->PTEBufferSizeInRequestsForLuma = mode_lib->vba.PTEBufferSizeInRequestsLuma;
4521 mode_lib->vba.PDEAndMetaPTEBytesPerFrameC = 0.0;
4522 mode_lib->vba.MetaRowBytesC = 0.0;
4523 mode_lib->vba.DPTEBytesPerRowC = 0.0;
4524 locals->PrefetchLinesC[0][0][k] = 0.0;
4525 locals->PTEBufferSizeNotExceededC[i][j][k] = true;
4526 locals->PTEBufferSizeInRequestsForLuma = mode_lib->vba.PTEBufferSizeInRequestsLuma + mode_lib->vba.PTEBufferSizeInRequestsChroma;
4528 mode_lib->vba.PDEAndMetaPTEBytesPerFrameY = CalculateVMAndRowBytes(
4530 mode_lib->vba.DCCEnable[k],
4531 locals->Read256BlockHeightY[k],
4532 locals->Read256BlockWidthY[k],
4533 mode_lib->vba.SourcePixelFormat[k],
4534 mode_lib->vba.SurfaceTiling[k],
4535 dml_ceil(locals->BytePerPixelInDETY[k], 1.0),
4536 mode_lib->vba.SourceScan[k],
4537 mode_lib->vba.ViewportWidth[k],
4538 mode_lib->vba.ViewportHeight[k],
4539 locals->SwathWidthYThisState[k],
4540 mode_lib->vba.GPUVMEnable,
4541 mode_lib->vba.HostVMEnable,
4542 mode_lib->vba.HostVMMaxPageTableLevels,
4543 mode_lib->vba.HostVMCachedPageTableLevels,
4544 mode_lib->vba.VMMPageSize,
4545 locals->PTEBufferSizeInRequestsForLuma,
4546 mode_lib->vba.PitchY[k],
4547 mode_lib->vba.DCCMetaPitchY[k],
4548 &locals->MacroTileWidthY[k],
4549 &mode_lib->vba.MetaRowBytesY,
4550 &mode_lib->vba.DPTEBytesPerRowY,
4551 &locals->PTEBufferSizeNotExceededY[i][j][k],
4552 locals->dpte_row_width_luma_ub,
4553 &locals->dpte_row_height[k],
4554 &locals->meta_req_width[k],
4555 &locals->meta_req_height[k],
4556 &locals->meta_row_width[k],
4557 &locals->meta_row_height[k],
4558 &locals->vm_group_bytes[k],
4559 &locals->dpte_group_bytes[k],
4560 locals->PixelPTEReqWidthY,
4561 locals->PixelPTEReqHeightY,
4562 locals->PTERequestSizeY,
4563 locals->dpde0_bytes_per_frame_ub_l,
4564 locals->meta_pte_bytes_per_frame_ub_l);
4565 locals->PrefetchLinesY[0][0][k] = CalculatePrefetchSourceLines(
4567 mode_lib->vba.VRatio[k],
4568 mode_lib->vba.vtaps[k],
4569 mode_lib->vba.Interlace[k],
4570 mode_lib->vba.ProgressiveToInterlaceUnitInOPP,
4571 locals->SwathHeightYThisState[k],
4572 mode_lib->vba.ViewportYStartY[k],
4573 &locals->PrefillY[k],
4574 &locals->MaxNumSwY[k]);
4575 locals->PDEAndMetaPTEBytesPerFrame[0][0][k] =
4576 mode_lib->vba.PDEAndMetaPTEBytesPerFrameY + mode_lib->vba.PDEAndMetaPTEBytesPerFrameC;
4577 locals->MetaRowBytes[0][0][k] = mode_lib->vba.MetaRowBytesY + mode_lib->vba.MetaRowBytesC;
4578 locals->DPTEBytesPerRow[0][0][k] = mode_lib->vba.DPTEBytesPerRowY + mode_lib->vba.DPTEBytesPerRowC;
4580 CalculateActiveRowBandwidth(
4581 mode_lib->vba.GPUVMEnable,
4582 mode_lib->vba.SourcePixelFormat[k],
4583 mode_lib->vba.VRatio[k],
4584 mode_lib->vba.DCCEnable[k],
4585 mode_lib->vba.HTotal[k] /
4586 mode_lib->vba.PixelClock[k],
4587 mode_lib->vba.MetaRowBytesY,
4588 mode_lib->vba.MetaRowBytesC,
4589 locals->meta_row_height[k],
4590 locals->meta_row_height_chroma[k],
4591 mode_lib->vba.DPTEBytesPerRowY,
4592 mode_lib->vba.DPTEBytesPerRowC,
4593 locals->dpte_row_height[k],
4594 locals->dpte_row_height_chroma[k],
4595 &locals->meta_row_bw[k],
4596 &locals->dpte_row_bw[k]);
4598 mode_lib->vba.ExtraLatency = CalculateExtraLatency(
4599 locals->UrgentRoundTripAndOutOfOrderLatencyPerState[i],
4600 locals->TotalNumberOfActiveDPP[i][j],
4601 mode_lib->vba.PixelChunkSizeInKByte,
4602 locals->TotalNumberOfDCCActiveDPP[i][j],
4603 mode_lib->vba.MetaChunkSize,
4604 locals->ReturnBWPerState[i][0],
4605 mode_lib->vba.GPUVMEnable,
4606 mode_lib->vba.HostVMEnable,
4607 mode_lib->vba.NumberOfActivePlanes,
4608 locals->NoOfDPPThisState,
4609 locals->dpte_group_bytes,
4610 mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData,
4611 mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly,
4612 mode_lib->vba.HostVMMaxPageTableLevels,
4613 mode_lib->vba.HostVMCachedPageTableLevels);
4615 mode_lib->vba.TimeCalc = 24.0 / mode_lib->vba.ProjectedDCFCLKDeepSleep[0][0];
4616 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4617 if (mode_lib->vba.BlendingAndTiming[k] == k) {
4618 if (mode_lib->vba.WritebackEnable[k] == true) {
4619 locals->WritebackDelay[i][k] = mode_lib->vba.WritebackLatency
4620 + CalculateWriteBackDelay(
4621 mode_lib->vba.WritebackPixelFormat[k],
4622 mode_lib->vba.WritebackHRatio[k],
4623 mode_lib->vba.WritebackVRatio[k],
4624 mode_lib->vba.WritebackLumaHTaps[k],
4625 mode_lib->vba.WritebackLumaVTaps[k],
4626 mode_lib->vba.WritebackChromaHTaps[k],
4627 mode_lib->vba.WritebackChromaVTaps[k],
4628 mode_lib->vba.WritebackDestinationWidth[k]) / locals->RequiredDISPCLK[i][j];
4630 locals->WritebackDelay[i][k] = 0.0;
4632 for (m = 0; m <= mode_lib->vba.NumberOfActivePlanes - 1; m++) {
4633 if (mode_lib->vba.BlendingAndTiming[m] == k
4634 && mode_lib->vba.WritebackEnable[m]
4636 locals->WritebackDelay[i][k] = dml_max(locals->WritebackDelay[i][k],
4637 mode_lib->vba.WritebackLatency + CalculateWriteBackDelay(
4638 mode_lib->vba.WritebackPixelFormat[m],
4639 mode_lib->vba.WritebackHRatio[m],
4640 mode_lib->vba.WritebackVRatio[m],
4641 mode_lib->vba.WritebackLumaHTaps[m],
4642 mode_lib->vba.WritebackLumaVTaps[m],
4643 mode_lib->vba.WritebackChromaHTaps[m],
4644 mode_lib->vba.WritebackChromaVTaps[m],
4645 mode_lib->vba.WritebackDestinationWidth[m]) / locals->RequiredDISPCLK[i][j]);
4650 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4651 for (m = 0; m <= mode_lib->vba.NumberOfActivePlanes - 1; m++) {
4652 if (mode_lib->vba.BlendingAndTiming[k] == m) {
4653 locals->WritebackDelay[i][k] = locals->WritebackDelay[i][m];
4657 mode_lib->vba.MaxMaxVStartup[0][0] = 0;
4658 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4659 locals->MaximumVStartup[0][0][k] = mode_lib->vba.VTotal[k] - mode_lib->vba.VActive[k]
4660 - dml_max(1.0, dml_ceil(locals->WritebackDelay[i][k] / (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]), 1.0));
4661 mode_lib->vba.MaxMaxVStartup[0][0] = dml_max(mode_lib->vba.MaxMaxVStartup[0][0], locals->MaximumVStartup[0][0][k]);
4664 mode_lib->vba.NextPrefetchMode = mode_lib->vba.MinPrefetchMode;
4665 mode_lib->vba.NextMaxVStartup = mode_lib->vba.MaxMaxVStartup[0][0];
4667 mode_lib->vba.PrefetchMode[i][j] = mode_lib->vba.NextPrefetchMode;
4668 mode_lib->vba.MaxVStartup = mode_lib->vba.NextMaxVStartup;
4670 mode_lib->vba.TWait = CalculateTWait(
4671 mode_lib->vba.PrefetchMode[i][j],
4672 mode_lib->vba.DRAMClockChangeLatency,
4673 mode_lib->vba.UrgentLatency,
4674 mode_lib->vba.SREnterPlusExitTime);
4675 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4679 if (mode_lib->vba.XFCEnabled[k] == true) {
4680 mode_lib->vba.XFCRemoteSurfaceFlipDelay =
4681 CalculateRemoteSurfaceFlipDelay(
4683 mode_lib->vba.VRatio[k],
4684 locals->SwathWidthYThisState[k],
4685 dml_ceil(locals->BytePerPixelInDETY[k], 1.0),
4686 mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k],
4687 mode_lib->vba.XFCTSlvVupdateOffset,
4688 mode_lib->vba.XFCTSlvVupdateWidth,
4689 mode_lib->vba.XFCTSlvVreadyOffset,
4690 mode_lib->vba.XFCXBUFLatencyTolerance,
4691 mode_lib->vba.XFCFillBWOverhead,
4692 mode_lib->vba.XFCSlvChunkSize,
4693 mode_lib->vba.XFCBusTransportTime,
4694 mode_lib->vba.TimeCalc,
4695 mode_lib->vba.TWait,
4696 &mode_lib->vba.SrcActiveDrainRate,
4697 &mode_lib->vba.TInitXFill,
4698 &mode_lib->vba.TslvChk);
4700 mode_lib->vba.XFCRemoteSurfaceFlipDelay = 0.0;
4703 myPipe.DPPCLK = locals->RequiredDPPCLK[i][j][k];
4704 myPipe.DISPCLK = locals->RequiredDISPCLK[i][j];
4705 myPipe.PixelClock = mode_lib->vba.PixelClock[k];
4706 myPipe.DCFCLKDeepSleep = mode_lib->vba.ProjectedDCFCLKDeepSleep[0][0];
4707 myPipe.DPPPerPlane = locals->NoOfDPP[i][j][k];
4708 myPipe.ScalerEnabled = mode_lib->vba.ScalerEnabled[k];
4709 myPipe.SourceScan = mode_lib->vba.SourceScan[k];
4710 myPipe.BlockWidth256BytesY = locals->Read256BlockWidthY[k];
4711 myPipe.BlockHeight256BytesY = locals->Read256BlockHeightY[k];
4712 myPipe.BlockWidth256BytesC = locals->Read256BlockWidthC[k];
4713 myPipe.BlockHeight256BytesC = locals->Read256BlockHeightC[k];
4714 myPipe.InterlaceEnable = mode_lib->vba.Interlace[k];
4715 myPipe.NumberOfCursors = mode_lib->vba.NumberOfCursors[k];
4716 myPipe.VBlank = mode_lib->vba.VTotal[k] - mode_lib->vba.VActive[k];
4717 myPipe.HTotal = mode_lib->vba.HTotal[k];
4720 myHostVM.Enable = mode_lib->vba.HostVMEnable;
4721 myHostVM.MaxPageTableLevels = mode_lib->vba.HostVMMaxPageTableLevels;
4722 myHostVM.CachedPageTableLevels = mode_lib->vba.HostVMCachedPageTableLevels;
4725 mode_lib->vba.IsErrorResult[i][j][k] = CalculatePrefetchSchedule(
4727 mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData,
4728 mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly,
4730 locals->DSCDelayPerState[i][k],
4731 mode_lib->vba.DPPCLKDelaySubtotal,
4732 mode_lib->vba.DPPCLKDelaySCL,
4733 mode_lib->vba.DPPCLKDelaySCLLBOnly,
4734 mode_lib->vba.DPPCLKDelayCNVCFormater,
4735 mode_lib->vba.DPPCLKDelayCNVCCursor,
4736 mode_lib->vba.DISPCLKDelaySubtotal,
4737 locals->SwathWidthYThisState[k] / mode_lib->vba.HRatio[k],
4738 mode_lib->vba.OutputFormat[k],
4739 mode_lib->vba.MaxInterDCNTileRepeaters,
4740 dml_min(mode_lib->vba.MaxVStartup, locals->MaximumVStartup[0][0][k]),
4741 locals->MaximumVStartup[0][0][k],
4742 mode_lib->vba.GPUVMMaxPageTableLevels,
4743 mode_lib->vba.GPUVMEnable,
4745 mode_lib->vba.DynamicMetadataEnable[k],
4746 mode_lib->vba.DynamicMetadataLinesBeforeActiveRequired[k],
4747 mode_lib->vba.DynamicMetadataTransmittedBytes[k],
4748 mode_lib->vba.DCCEnable[k],
4749 mode_lib->vba.UrgentLatency,
4750 mode_lib->vba.ExtraLatency,
4751 mode_lib->vba.TimeCalc,
4752 locals->PDEAndMetaPTEBytesPerFrame[0][0][k],
4753 locals->MetaRowBytes[0][0][k],
4754 locals->DPTEBytesPerRow[0][0][k],
4755 locals->PrefetchLinesY[0][0][k],
4756 locals->SwathWidthYThisState[k],
4757 locals->BytePerPixelInDETY[k],
4758 locals->PrefillY[k],
4759 locals->MaxNumSwY[k],
4760 locals->PrefetchLinesC[0][0][k],
4761 locals->BytePerPixelInDETC[k],
4762 locals->PrefillC[k],
4763 locals->MaxNumSwC[k],
4764 locals->SwathHeightYThisState[k],
4765 locals->SwathHeightCThisState[k],
4766 mode_lib->vba.TWait,
4767 mode_lib->vba.XFCEnabled[k],
4768 mode_lib->vba.XFCRemoteSurfaceFlipDelay,
4769 mode_lib->vba.ProgressiveToInterlaceUnitInOPP,
4770 &locals->dst_x_after_scaler,
4771 &locals->dst_y_after_scaler,
4772 &locals->LineTimesForPrefetch[k],
4773 &locals->PrefetchBW[k],
4774 &locals->LinesForMetaPTE[k],
4775 &locals->LinesForMetaAndDPTERow[k],
4776 &locals->VRatioPreY[i][j][k],
4777 &locals->VRatioPreC[i][j][k],
4778 &locals->RequiredPrefetchPixelDataBWLuma[i][j][k],
4779 &locals->RequiredPrefetchPixelDataBWChroma[i][j][k],
4780 &locals->VStartupRequiredWhenNotEnoughTimeForDynamicMetadata,
4782 &locals->prefetch_vmrow_bw[k],
4783 locals->swath_width_luma_ub,
4784 locals->swath_width_chroma_ub,
4785 &mode_lib->vba.VUpdateOffsetPix[k],
4786 &mode_lib->vba.VUpdateWidthPix[k],
4787 &mode_lib->vba.VReadyOffsetPix[k]);
4789 mode_lib->vba.MaximumReadBandwidthWithoutPrefetch = 0.0;
4790 mode_lib->vba.MaximumReadBandwidthWithPrefetch = 0.0;
4791 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4794 locals->cursor_bw[k] = 0;
4795 locals->cursor_bw_pre[k] = 0;
4796 for (m = 0; m < mode_lib->vba.NumberOfCursors[k]; m++) {
4797 locals->cursor_bw[k] = mode_lib->vba.CursorWidth[k][m] * mode_lib->vba.CursorBPP[k][m]
4798 / 8.0 / (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]) * mode_lib->vba.VRatio[k];
4799 locals->cursor_bw_pre[k] = mode_lib->vba.CursorWidth[k][m] * mode_lib->vba.CursorBPP[k][m]
4800 / 8.0 / (mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k]) * locals->VRatioPreY[i][j][k];
4803 CalculateUrgentBurstFactor(
4804 mode_lib->vba.DETBufferSizeInKByte,
4805 locals->SwathHeightYThisState[k],
4806 locals->SwathHeightCThisState[k],
4807 locals->SwathWidthYThisState[k],
4808 mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k],
4809 mode_lib->vba.UrgentLatency,
4810 mode_lib->vba.CursorBufferSize,
4811 mode_lib->vba.CursorWidth[k][0] + mode_lib->vba.CursorWidth[k][1],
4812 dml_max(mode_lib->vba.CursorBPP[k][0], mode_lib->vba.CursorBPP[k][1]),
4813 mode_lib->vba.VRatio[k],
4814 locals->VRatioPreY[i][j][k],
4815 locals->VRatioPreC[i][j][k],
4816 locals->BytePerPixelInDETY[k],
4817 locals->BytePerPixelInDETC[k],
4818 &locals->UrgentBurstFactorCursor[k],
4819 &locals->UrgentBurstFactorCursorPre[k],
4820 &locals->UrgentBurstFactorLuma[k],
4821 &locals->UrgentBurstFactorLumaPre[k],
4822 &locals->UrgentBurstFactorChroma[k],
4823 &locals->UrgentBurstFactorChromaPre[k],
4824 &locals->NotEnoughUrgentLatencyHiding,
4825 &locals->NotEnoughUrgentLatencyHidingPre);
4827 if (mode_lib->vba.UseUrgentBurstBandwidth == false) {
4828 locals->UrgentBurstFactorCursor[k] = 1;
4829 locals->UrgentBurstFactorCursorPre[k] = 1;
4830 locals->UrgentBurstFactorLuma[k] = 1;
4831 locals->UrgentBurstFactorLumaPre[k] = 1;
4832 locals->UrgentBurstFactorChroma[k] = 1;
4833 locals->UrgentBurstFactorChromaPre[k] = 1;
4836 mode_lib->vba.MaximumReadBandwidthWithoutPrefetch = mode_lib->vba.MaximumReadBandwidthWithoutPrefetch
4837 + locals->cursor_bw[k] * locals->UrgentBurstFactorCursor[k] + locals->ReadBandwidthLuma[k]
4838 * locals->UrgentBurstFactorLuma[k] + locals->ReadBandwidthChroma[k]
4839 * locals->UrgentBurstFactorChroma[k] + locals->meta_row_bw[k] + locals->dpte_row_bw[k];
4840 mode_lib->vba.MaximumReadBandwidthWithPrefetch = mode_lib->vba.MaximumReadBandwidthWithPrefetch
4841 + dml_max3(locals->prefetch_vmrow_bw[k],
4842 locals->ReadBandwidthLuma[k] * locals->UrgentBurstFactorLuma[k] + locals->ReadBandwidthChroma[k]
4843 * locals->UrgentBurstFactorChroma[k] + locals->cursor_bw[k] * locals->UrgentBurstFactorCursor[k]
4844 + locals->meta_row_bw[k] + locals->dpte_row_bw[k],
4845 locals->RequiredPrefetchPixelDataBWLuma[i][j][k] * locals->UrgentBurstFactorLumaPre[k]
4846 + locals->RequiredPrefetchPixelDataBWChroma[i][j][k] * locals->UrgentBurstFactorChromaPre[k]
4847 + locals->cursor_bw_pre[k] * locals->UrgentBurstFactorCursorPre[k]);
4849 locals->BandwidthWithoutPrefetchSupported[i][0] = true;
4850 if (mode_lib->vba.MaximumReadBandwidthWithoutPrefetch > locals->ReturnBWPerState[i][0]
4851 || locals->NotEnoughUrgentLatencyHiding == 1) {
4852 locals->BandwidthWithoutPrefetchSupported[i][0] = false;
4855 locals->PrefetchSupported[i][j] = true;
4856 if (mode_lib->vba.MaximumReadBandwidthWithPrefetch > locals->ReturnBWPerState[i][0]
4857 || locals->NotEnoughUrgentLatencyHiding == 1
4858 || locals->NotEnoughUrgentLatencyHidingPre == 1) {
4859 locals->PrefetchSupported[i][j] = false;
4861 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4862 if (locals->LineTimesForPrefetch[k] < 2.0
4863 || locals->LinesForMetaPTE[k] >= 32.0
4864 || locals->LinesForMetaAndDPTERow[k] >= 16.0
4865 || mode_lib->vba.IsErrorResult[i][j][k] == true) {
4866 locals->PrefetchSupported[i][j] = false;
4869 locals->VRatioInPrefetchSupported[i][j] = true;
4870 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4871 if (locals->VRatioPreY[i][j][k] > 4.0
4872 || locals->VRatioPreC[i][j][k] > 4.0
4873 || mode_lib->vba.IsErrorResult[i][j][k] == true) {
4874 locals->VRatioInPrefetchSupported[i][j] = false;
4877 mode_lib->vba.AnyLinesForVMOrRowTooLarge = false;
4878 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
4879 if (locals->LinesForMetaAndDPTERow[k] >= 16 || locals->LinesForMetaPTE[k] >= 32) {
4880 mode_lib->vba.AnyLinesForVMOrRowTooLarge = true;
4884 if (mode_lib->vba.MaxVStartup <= 13 || mode_lib->vba.AnyLinesForVMOrRowTooLarge == false) {
4885 mode_lib->vba.NextMaxVStartup = mode_lib->vba.MaxMaxVStartup[0][0];
4886 mode_lib->vba.NextPrefetchMode = mode_lib->vba.NextPrefetchMode + 1;
4888 mode_lib->vba.NextMaxVStartup = mode_lib->vba.NextMaxVStartup - 1;
4890 } while ((locals->PrefetchSupported[i][j] != true || locals->VRatioInPrefetchSupported[i][j] != true)
4891 && (mode_lib->vba.NextMaxVStartup != mode_lib->vba.MaxMaxVStartup[0][0]
4892 || mode_lib->vba.NextPrefetchMode < mode_lib->vba.MaxPrefetchMode));
4894 if (locals->PrefetchSupported[i][j] == true && locals->VRatioInPrefetchSupported[i][j] == true) {
4895 mode_lib->vba.BandwidthAvailableForImmediateFlip = locals->ReturnBWPerState[i][0];
4896 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4897 mode_lib->vba.BandwidthAvailableForImmediateFlip = mode_lib->vba.BandwidthAvailableForImmediateFlip
4898 - dml_max(locals->ReadBandwidthLuma[k] * locals->UrgentBurstFactorLuma[k]
4899 + locals->ReadBandwidthChroma[k] * locals->UrgentBurstFactorChroma[k]
4900 + locals->cursor_bw[k] * locals->UrgentBurstFactorCursor[k],
4901 locals->RequiredPrefetchPixelDataBWLuma[i][j][k] * locals->UrgentBurstFactorLumaPre[k]
4902 + locals->RequiredPrefetchPixelDataBWChroma[i][j][k] * locals->UrgentBurstFactorChromaPre[k]
4903 + locals->cursor_bw_pre[k] * locals->UrgentBurstFactorCursorPre[k]);
4905 mode_lib->vba.TotImmediateFlipBytes = 0.0;
4906 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4907 mode_lib->vba.TotImmediateFlipBytes = mode_lib->vba.TotImmediateFlipBytes
4908 + locals->PDEAndMetaPTEBytesPerFrame[0][0][k] + locals->MetaRowBytes[0][0][k] + locals->DPTEBytesPerRow[0][0][k];
4911 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4912 CalculateFlipSchedule(
4914 mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData,
4915 mode_lib->vba.PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly,
4916 mode_lib->vba.ExtraLatency,
4917 mode_lib->vba.UrgentLatency,
4918 mode_lib->vba.GPUVMMaxPageTableLevels,
4919 mode_lib->vba.HostVMEnable,
4920 mode_lib->vba.HostVMMaxPageTableLevels,
4921 mode_lib->vba.HostVMCachedPageTableLevels,
4922 mode_lib->vba.GPUVMEnable,
4923 locals->PDEAndMetaPTEBytesPerFrame[0][0][k],
4924 locals->MetaRowBytes[0][0][k],
4925 locals->DPTEBytesPerRow[0][0][k],
4926 mode_lib->vba.BandwidthAvailableForImmediateFlip,
4927 mode_lib->vba.TotImmediateFlipBytes,
4928 mode_lib->vba.SourcePixelFormat[k],
4929 mode_lib->vba.HTotal[k] / mode_lib->vba.PixelClock[k],
4930 mode_lib->vba.VRatio[k],
4932 mode_lib->vba.DCCEnable[k],
4933 locals->dpte_row_height[k],
4934 locals->meta_row_height[k],
4935 locals->dpte_row_height_chroma[k],
4936 locals->meta_row_height_chroma[k],
4937 &locals->DestinationLinesToRequestVMInImmediateFlip[k],
4938 &locals->DestinationLinesToRequestRowInImmediateFlip[k],
4939 &locals->final_flip_bw[k],
4940 &locals->ImmediateFlipSupportedForPipe[k]);
4942 mode_lib->vba.total_dcn_read_bw_with_flip = 0.0;
4943 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4944 mode_lib->vba.total_dcn_read_bw_with_flip = mode_lib->vba.total_dcn_read_bw_with_flip + dml_max3(
4945 locals->prefetch_vmrow_bw[k],
4946 locals->final_flip_bw[k] + locals->ReadBandwidthLuma[k] * locals->UrgentBurstFactorLuma[k]
4947 + locals->ReadBandwidthChroma[k] * locals->UrgentBurstFactorChroma[k]
4948 + locals->cursor_bw[k] * locals->UrgentBurstFactorCursor[k],
4949 locals->final_flip_bw[k] + locals->RequiredPrefetchPixelDataBWLuma[i][j][k]
4950 * locals->UrgentBurstFactorLumaPre[k] + locals->RequiredPrefetchPixelDataBWChroma[i][j][k]
4951 * locals->UrgentBurstFactorChromaPre[k] + locals->cursor_bw_pre[k]
4952 * locals->UrgentBurstFactorCursorPre[k]);
4954 locals->ImmediateFlipSupportedForState[i][j] = true;
4955 if (mode_lib->vba.total_dcn_read_bw_with_flip
4956 > locals->ReturnBWPerState[i][0]) {
4957 locals->ImmediateFlipSupportedForState[i][j] = false;
4959 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
4960 if (locals->ImmediateFlipSupportedForPipe[k] == false) {
4961 locals->ImmediateFlipSupportedForState[i][j] = false;
4965 locals->ImmediateFlipSupportedForState[i][j] = false;
4967 mode_lib->vba.UrgentOutOfOrderReturnPerChannel = dml_max3(
4968 mode_lib->vba.UrgentOutOfOrderReturnPerChannelPixelDataOnly,
4969 mode_lib->vba.UrgentOutOfOrderReturnPerChannelPixelMixedWithVMData,
4970 mode_lib->vba.UrgentOutOfOrderReturnPerChannelVMDataOnly);
4971 CalculateWatermarksAndDRAMSpeedChangeSupport(
4973 mode_lib->vba.PrefetchMode[i][j],
4974 mode_lib->vba.NumberOfActivePlanes,
4975 mode_lib->vba.MaxLineBufferLines,
4976 mode_lib->vba.LineBufferSize,
4977 mode_lib->vba.DPPOutputBufferPixels,
4978 mode_lib->vba.DETBufferSizeInKByte,
4979 mode_lib->vba.WritebackInterfaceLumaBufferSize,
4980 mode_lib->vba.WritebackInterfaceChromaBufferSize,
4981 mode_lib->vba.DCFCLKPerState[i],
4982 mode_lib->vba.UrgentOutOfOrderReturnPerChannel * mode_lib->vba.NumberOfChannels,
4983 locals->ReturnBWPerState[i][0],
4984 mode_lib->vba.GPUVMEnable,
4985 locals->dpte_group_bytes,
4986 mode_lib->vba.MetaChunkSize,
4987 mode_lib->vba.UrgentLatency,
4988 mode_lib->vba.ExtraLatency,
4989 mode_lib->vba.WritebackLatency,
4990 mode_lib->vba.WritebackChunkSize,
4991 mode_lib->vba.SOCCLKPerState[i],
4992 mode_lib->vba.DRAMClockChangeLatency,
4993 mode_lib->vba.SRExitTime,
4994 mode_lib->vba.SREnterPlusExitTime,
4995 mode_lib->vba.ProjectedDCFCLKDeepSleep[0][0],
4996 locals->NoOfDPPThisState,
4997 mode_lib->vba.DCCEnable,
4998 locals->RequiredDPPCLKThisState,
4999 locals->SwathWidthYSingleDPP,
5000 locals->SwathHeightYThisState,
5001 locals->ReadBandwidthLuma,
5002 locals->SwathHeightCThisState,
5003 locals->ReadBandwidthChroma,
5004 mode_lib->vba.LBBitPerPixel,
5005 locals->SwathWidthYThisState,
5006 mode_lib->vba.HRatio,
5007 mode_lib->vba.vtaps,
5008 mode_lib->vba.VTAPsChroma,
5009 mode_lib->vba.VRatio,
5010 mode_lib->vba.HTotal,
5011 mode_lib->vba.PixelClock,
5012 mode_lib->vba.BlendingAndTiming,
5013 locals->BytePerPixelInDETY,
5014 locals->BytePerPixelInDETC,
5015 mode_lib->vba.WritebackEnable,
5016 mode_lib->vba.WritebackPixelFormat,
5017 mode_lib->vba.WritebackDestinationWidth,
5018 mode_lib->vba.WritebackDestinationHeight,
5019 mode_lib->vba.WritebackSourceHeight,
5020 &locals->DRAMClockChangeSupport[i][j],
5021 &mode_lib->vba.UrgentWatermark,
5022 &mode_lib->vba.WritebackUrgentWatermark,
5023 &mode_lib->vba.DRAMClockChangeWatermark,
5024 &mode_lib->vba.WritebackDRAMClockChangeWatermark,
5025 &mode_lib->vba.StutterExitWatermark,
5026 &mode_lib->vba.StutterEnterPlusExitWatermark,
5027 &mode_lib->vba.MinActiveDRAMClockChangeLatencySupported);
5031 /*Vertical Active BW support*/
5033 double MaxTotalVActiveRDBandwidth = 0.0;
5034 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
5035 MaxTotalVActiveRDBandwidth = MaxTotalVActiveRDBandwidth + locals->ReadBandwidth[k];
5037 for (i = 0; i <= mode_lib->vba.soc.num_states; ++i) {
5038 locals->MaxTotalVerticalActiveAvailableBandwidth[i][0] = dml_min(
5039 locals->IdealSDPPortBandwidthPerState[i][0] *
5040 mode_lib->vba.MaxAveragePercentOfIdealSDPPortBWDisplayCanUseInNormalSystemOperation
5041 / 100.0, mode_lib->vba.DRAMSpeedPerState[i] *
5042 mode_lib->vba.NumberOfChannels *
5043 mode_lib->vba.DRAMChannelWidth *
5044 mode_lib->vba.MaxAveragePercentOfIdealDRAMBWDisplayCanUseInNormalSystemOperation
5047 if (MaxTotalVActiveRDBandwidth <= locals->MaxTotalVerticalActiveAvailableBandwidth[i][0]) {
5048 locals->TotalVerticalActiveBandwidthSupport[i][0] = true;
5050 locals->TotalVerticalActiveBandwidthSupport[i][0] = false;
5055 /*PTE Buffer Size Check*/
5057 for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
5058 for (j = 0; j < 2; j++) {
5059 locals->PTEBufferSizeNotExceeded[i][j] = true;
5060 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
5061 if (locals->PTEBufferSizeNotExceededY[i][j][k] == false
5062 || locals->PTEBufferSizeNotExceededC[i][j][k] == false) {
5063 locals->PTEBufferSizeNotExceeded[i][j] = false;
5068 /*Cursor Support Check*/
5070 mode_lib->vba.CursorSupport = true;
5071 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
5072 if (mode_lib->vba.CursorWidth[k][0] > 0.0) {
5073 for (m = 0; m < mode_lib->vba.NumberOfCursors[k]; m++) {
5074 if (mode_lib->vba.CursorBPP[k][m] == 64 && mode_lib->vba.Cursor64BppSupport == false) {
5075 mode_lib->vba.CursorSupport = false;
5080 /*Valid Pitch Check*/
5082 mode_lib->vba.PitchSupport = true;
5083 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
5084 locals->AlignedYPitch[k] = dml_ceil(
5085 dml_max(mode_lib->vba.PitchY[k], mode_lib->vba.ViewportWidth[k]),
5086 locals->MacroTileWidthY[k]);
5087 if (locals->AlignedYPitch[k] > mode_lib->vba.PitchY[k]) {
5088 mode_lib->vba.PitchSupport = false;
5090 if (mode_lib->vba.DCCEnable[k] == true) {
5091 locals->AlignedDCCMetaPitch[k] = dml_ceil(
5093 mode_lib->vba.DCCMetaPitchY[k],
5094 mode_lib->vba.ViewportWidth[k]),
5095 64.0 * locals->Read256BlockWidthY[k]);
5097 locals->AlignedDCCMetaPitch[k] = mode_lib->vba.DCCMetaPitchY[k];
5099 if (locals->AlignedDCCMetaPitch[k] > mode_lib->vba.DCCMetaPitchY[k]) {
5100 mode_lib->vba.PitchSupport = false;
5102 if (mode_lib->vba.SourcePixelFormat[k] != dm_444_64
5103 && mode_lib->vba.SourcePixelFormat[k] != dm_444_32
5104 && mode_lib->vba.SourcePixelFormat[k] != dm_444_16
5105 && mode_lib->vba.SourcePixelFormat[k] != dm_mono_16
5106 && mode_lib->vba.SourcePixelFormat[k] != dm_mono_8) {
5107 locals->AlignedCPitch[k] = dml_ceil(
5109 mode_lib->vba.PitchC[k],
5110 mode_lib->vba.ViewportWidth[k] / 2.0),
5111 locals->MacroTileWidthC[k]);
5113 locals->AlignedCPitch[k] = mode_lib->vba.PitchC[k];
5115 if (locals->AlignedCPitch[k] > mode_lib->vba.PitchC[k]) {
5116 mode_lib->vba.PitchSupport = false;
5119 /*Mode Support, Voltage State and SOC Configuration*/
5121 for (i = mode_lib->vba.soc.num_states; i >= 0; i--) {
5122 for (j = 0; j < 2; j++) {
5123 enum dm_validation_status status = DML_VALIDATION_OK;
5125 if (!mode_lib->vba.ScaleRatioAndTapsSupport) {
5126 status = DML_FAIL_SCALE_RATIO_TAP;
5127 } else if (!mode_lib->vba.SourceFormatPixelAndScanSupport) {
5128 status = DML_FAIL_SOURCE_PIXEL_FORMAT;
5129 } else if (!locals->ViewportSizeSupport[i][0]) {
5130 status = DML_FAIL_VIEWPORT_SIZE;
5131 } else if (!locals->DIOSupport[i]) {
5132 status = DML_FAIL_DIO_SUPPORT;
5133 } else if (locals->NotEnoughDSCUnits[i]) {
5134 status = DML_FAIL_NOT_ENOUGH_DSC;
5135 } else if (locals->DSCCLKRequiredMoreThanSupported[i]) {
5136 status = DML_FAIL_DSC_CLK_REQUIRED;
5137 } else if (!locals->ROBSupport[i][0]) {
5138 status = DML_FAIL_REORDERING_BUFFER;
5139 } else if (!locals->DISPCLK_DPPCLK_Support[i][j]) {
5140 status = DML_FAIL_DISPCLK_DPPCLK;
5141 } else if (!locals->TotalAvailablePipesSupport[i][j]) {
5142 status = DML_FAIL_TOTAL_AVAILABLE_PIPES;
5143 } else if (!mode_lib->vba.NumberOfOTGSupport) {
5144 status = DML_FAIL_NUM_OTG;
5145 } else if (!mode_lib->vba.WritebackModeSupport) {
5146 status = DML_FAIL_WRITEBACK_MODE;
5147 } else if (!mode_lib->vba.WritebackLatencySupport) {
5148 status = DML_FAIL_WRITEBACK_LATENCY;
5149 } else if (!mode_lib->vba.WritebackScaleRatioAndTapsSupport) {
5150 status = DML_FAIL_WRITEBACK_SCALE_RATIO_TAP;
5151 } else if (!mode_lib->vba.CursorSupport) {
5152 status = DML_FAIL_CURSOR_SUPPORT;
5153 } else if (!mode_lib->vba.PitchSupport) {
5154 status = DML_FAIL_PITCH_SUPPORT;
5155 } else if (!locals->TotalVerticalActiveBandwidthSupport[i][0]) {
5156 status = DML_FAIL_TOTAL_V_ACTIVE_BW;
5157 } else if (!locals->PTEBufferSizeNotExceeded[i][j]) {
5158 status = DML_FAIL_PTE_BUFFER_SIZE;
5159 } else if (mode_lib->vba.NonsupportedDSCInputBPC) {
5160 status = DML_FAIL_DSC_INPUT_BPC;
5161 } else if ((mode_lib->vba.HostVMEnable
5162 && !locals->ImmediateFlipSupportedForState[i][j])) {
5163 status = DML_FAIL_HOST_VM_IMMEDIATE_FLIP;
5164 } else if (!locals->PrefetchSupported[i][j]) {
5165 status = DML_FAIL_PREFETCH_SUPPORT;
5166 } else if (!locals->VRatioInPrefetchSupported[i][j]) {
5167 status = DML_FAIL_V_RATIO_PREFETCH;
5170 if (status == DML_VALIDATION_OK) {
5171 locals->ModeSupport[i][j] = true;
5173 locals->ModeSupport[i][j] = false;
5175 locals->ValidationStatus[i] = status;
5179 unsigned int MaximumMPCCombine = 0;
5180 mode_lib->vba.VoltageLevel = mode_lib->vba.soc.num_states + 1;
5181 for (i = mode_lib->vba.VoltageOverrideLevel; i <= mode_lib->vba.soc.num_states; i++) {
5182 if (locals->ModeSupport[i][0] == true || locals->ModeSupport[i][1] == true) {
5183 mode_lib->vba.VoltageLevel = i;
5184 if (locals->ModeSupport[i][1] == true && (locals->ModeSupport[i][0] == false
5185 || mode_lib->vba.WhenToDoMPCCombine == dm_mpc_always_when_possible
5186 || (mode_lib->vba.WhenToDoMPCCombine == dm_mpc_reduce_voltage_and_clocks
5187 && ((locals->DRAMClockChangeSupport[i][1] == dm_dram_clock_change_vactive
5188 && locals->DRAMClockChangeSupport[i][0] != dm_dram_clock_change_vactive)
5189 || (locals->DRAMClockChangeSupport[i][1] == dm_dram_clock_change_vblank
5190 && locals->DRAMClockChangeSupport[i][0] == dm_dram_clock_change_unsupported))))) {
5191 MaximumMPCCombine = 1;
5193 MaximumMPCCombine = 0;
5198 mode_lib->vba.ImmediateFlipSupport =
5199 locals->ImmediateFlipSupportedForState[mode_lib->vba.VoltageLevel][MaximumMPCCombine];
5200 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
5201 mode_lib->vba.DPPPerPlane[k] = locals->NoOfDPP[mode_lib->vba.VoltageLevel][MaximumMPCCombine][k];
5202 locals->DPPCLK[k] = locals->RequiredDPPCLK[mode_lib->vba.VoltageLevel][MaximumMPCCombine][k];
5204 mode_lib->vba.DISPCLK = locals->RequiredDISPCLK[mode_lib->vba.VoltageLevel][MaximumMPCCombine];
5205 mode_lib->vba.maxMpcComb = MaximumMPCCombine;
5207 mode_lib->vba.DCFCLK = mode_lib->vba.DCFCLKPerState[mode_lib->vba.VoltageLevel];
5208 mode_lib->vba.DRAMSpeed = mode_lib->vba.DRAMSpeedPerState[mode_lib->vba.VoltageLevel];
5209 mode_lib->vba.FabricClock = mode_lib->vba.FabricClockPerState[mode_lib->vba.VoltageLevel];
5210 mode_lib->vba.SOCCLK = mode_lib->vba.SOCCLKPerState[mode_lib->vba.VoltageLevel];
5211 mode_lib->vba.ReturnBW = locals->ReturnBWPerState[mode_lib->vba.VoltageLevel][0];
5212 for (k = 0; k <= mode_lib->vba.NumberOfActivePlanes - 1; k++) {
5213 if (mode_lib->vba.BlendingAndTiming[k] == k) {
5214 mode_lib->vba.ODMCombineEnabled[k] =
5215 locals->ODMCombineEnablePerState[mode_lib->vba.VoltageLevel][k];
5217 mode_lib->vba.ODMCombineEnabled[k] = false;
5219 mode_lib->vba.DSCEnabled[k] =
5220 locals->RequiresDSC[mode_lib->vba.VoltageLevel][k];
5221 mode_lib->vba.OutputBpp[k] =
5222 locals->OutputBppPerState[mode_lib->vba.VoltageLevel][k];
5226 static void CalculateWatermarksAndDRAMSpeedChangeSupport(
5227 struct display_mode_lib *mode_lib,
5228 unsigned int PrefetchMode,
5229 unsigned int NumberOfActivePlanes,
5230 unsigned int MaxLineBufferLines,
5231 unsigned int LineBufferSize,
5232 unsigned int DPPOutputBufferPixels,
5233 double DETBufferSizeInKByte,
5234 unsigned int WritebackInterfaceLumaBufferSize,
5235 unsigned int WritebackInterfaceChromaBufferSize,
5237 double UrgentOutOfOrderReturn,
5240 int dpte_group_bytes[],
5241 unsigned int MetaChunkSize,
5242 double UrgentLatency,
5243 double ExtraLatency,
5244 double WritebackLatency,
5245 double WritebackChunkSize,
5247 double DRAMClockChangeLatency,
5249 double SREnterPlusExitTime,
5250 double DCFCLKDeepSleep,
5254 double SwathWidthSingleDPPY[],
5255 unsigned int SwathHeightY[],
5256 double ReadBandwidthPlaneLuma[],
5257 unsigned int SwathHeightC[],
5258 double ReadBandwidthPlaneChroma[],
5259 unsigned int LBBitPerPixel[],
5260 double SwathWidthY[],
5262 unsigned int vtaps[],
5263 unsigned int VTAPsChroma[],
5265 unsigned int HTotal[],
5266 double PixelClock[],
5267 unsigned int BlendingAndTiming[],
5268 double BytePerPixelDETY[],
5269 double BytePerPixelDETC[],
5270 bool WritebackEnable[],
5271 enum source_format_class WritebackPixelFormat[],
5272 double WritebackDestinationWidth[],
5273 double WritebackDestinationHeight[],
5274 double WritebackSourceHeight[],
5275 enum clock_change_support *DRAMClockChangeSupport,
5276 double *UrgentWatermark,
5277 double *WritebackUrgentWatermark,
5278 double *DRAMClockChangeWatermark,
5279 double *WritebackDRAMClockChangeWatermark,
5280 double *StutterExitWatermark,
5281 double *StutterEnterPlusExitWatermark,
5282 double *MinActiveDRAMClockChangeLatencySupported)
5284 double EffectiveLBLatencyHidingY;
5285 double EffectiveLBLatencyHidingC;
5286 double DPPOutputBufferLinesY;
5287 double DPPOutputBufferLinesC;
5288 double DETBufferSizeY;
5289 double DETBufferSizeC;
5290 double LinesInDETY[DC__NUM_DPP__MAX];
5292 unsigned int LinesInDETYRoundedDownToSwath[DC__NUM_DPP__MAX];
5293 unsigned int LinesInDETCRoundedDownToSwath;
5294 double FullDETBufferingTimeY[DC__NUM_DPP__MAX];
5295 double FullDETBufferingTimeC;
5296 double ActiveDRAMClockChangeLatencyMarginY;
5297 double ActiveDRAMClockChangeLatencyMarginC;
5298 double WritebackDRAMClockChangeLatencyMargin;
5299 double PlaneWithMinActiveDRAMClockChangeMargin;
5300 double SecondMinActiveDRAMClockChangeMarginOneDisplayInVBLank;
5301 double FullDETBufferingTimeYStutterCriticalPlane = 0;
5302 double TimeToFinishSwathTransferStutterCriticalPlane = 0;
5305 mode_lib->vba.TotalActiveDPP = 0;
5306 mode_lib->vba.TotalDCCActiveDPP = 0;
5307 for (k = 0; k < NumberOfActivePlanes; ++k) {
5308 mode_lib->vba.TotalActiveDPP = mode_lib->vba.TotalActiveDPP + DPPPerPlane[k];
5309 if (DCCEnable[k] == true) {
5310 mode_lib->vba.TotalDCCActiveDPP = mode_lib->vba.TotalDCCActiveDPP + DPPPerPlane[k];
5314 mode_lib->vba.TotalDataReadBandwidth = 0;
5315 for (k = 0; k < NumberOfActivePlanes; ++k) {
5316 mode_lib->vba.TotalDataReadBandwidth = mode_lib->vba.TotalDataReadBandwidth
5317 + ReadBandwidthPlaneLuma[k] + ReadBandwidthPlaneChroma[k];
5320 *UrgentWatermark = UrgentLatency + ExtraLatency;
5322 *DRAMClockChangeWatermark = DRAMClockChangeLatency + *UrgentWatermark;
5324 mode_lib->vba.TotalActiveWriteback = 0;
5325 for (k = 0; k < NumberOfActivePlanes; ++k) {
5326 if (WritebackEnable[k] == true) {
5327 mode_lib->vba.TotalActiveWriteback = mode_lib->vba.TotalActiveWriteback + 1;
5331 if (mode_lib->vba.TotalActiveWriteback <= 1) {
5332 *WritebackUrgentWatermark = WritebackLatency;
5334 *WritebackUrgentWatermark = WritebackLatency
5335 + WritebackChunkSize * 1024.0 / 32.0 / SOCCLK;
5338 if (mode_lib->vba.TotalActiveWriteback <= 1) {
5339 *WritebackDRAMClockChangeWatermark = DRAMClockChangeLatency + WritebackLatency;
5341 *WritebackDRAMClockChangeWatermark = DRAMClockChangeLatency + WritebackLatency
5342 + WritebackChunkSize * 1024.0 / 32.0 / SOCCLK;
5345 for (k = 0; k < NumberOfActivePlanes; ++k) {
5347 mode_lib->vba.LBLatencyHidingSourceLinesY = dml_min((double) MaxLineBufferLines,
5348 dml_floor(LineBufferSize / LBBitPerPixel[k] / (SwathWidthY[k] / dml_max(HRatio[k], 1.0)), 1))
5351 mode_lib->vba.LBLatencyHidingSourceLinesC = dml_min((double) MaxLineBufferLines,
5352 dml_floor(LineBufferSize / LBBitPerPixel[k] / (SwathWidthY[k] / 2 / dml_max(HRatio[k] / 2, 1.0)), 1))
5353 - (VTAPsChroma[k] - 1);
5355 EffectiveLBLatencyHidingY = mode_lib->vba.LBLatencyHidingSourceLinesY / VRatio[k]
5356 * (HTotal[k] / PixelClock[k]);
5358 EffectiveLBLatencyHidingC = mode_lib->vba.LBLatencyHidingSourceLinesC
5359 / (VRatio[k] / 2) * (HTotal[k] / PixelClock[k]);
5361 if (SwathWidthY[k] > 2 * DPPOutputBufferPixels) {
5362 DPPOutputBufferLinesY = (double) DPPOutputBufferPixels / SwathWidthY[k];
5363 } else if (SwathWidthY[k] > DPPOutputBufferPixels) {
5364 DPPOutputBufferLinesY = 0.5;
5366 DPPOutputBufferLinesY = 1;
5369 if (SwathWidthY[k] / 2.0 > 2 * DPPOutputBufferPixels) {
5370 DPPOutputBufferLinesC = (double) DPPOutputBufferPixels
5371 / (SwathWidthY[k] / 2.0);
5372 } else if (SwathWidthY[k] / 2.0 > DPPOutputBufferPixels) {
5373 DPPOutputBufferLinesC = 0.5;
5375 DPPOutputBufferLinesC = 1;
5378 CalculateDETBufferSize(
5379 DETBufferSizeInKByte,
5385 LinesInDETY[k] = DETBufferSizeY / BytePerPixelDETY[k] / SwathWidthY[k];
5386 LinesInDETYRoundedDownToSwath[k] = dml_floor(LinesInDETY[k], SwathHeightY[k]);
5387 FullDETBufferingTimeY[k] = LinesInDETYRoundedDownToSwath[k]
5388 * (HTotal[k] / PixelClock[k]) / VRatio[k];
5389 if (BytePerPixelDETC[k] > 0) {
5390 LinesInDETC = DETBufferSizeC / BytePerPixelDETC[k] / (SwathWidthY[k] / 2.0);
5391 LinesInDETCRoundedDownToSwath = dml_floor(LinesInDETC, SwathHeightC[k]);
5392 FullDETBufferingTimeC = LinesInDETCRoundedDownToSwath
5393 * (HTotal[k] / PixelClock[k]) / (VRatio[k] / 2);
5396 FullDETBufferingTimeC = 999999;
5399 ActiveDRAMClockChangeLatencyMarginY = HTotal[k] / PixelClock[k]
5400 * DPPOutputBufferLinesY + EffectiveLBLatencyHidingY
5401 + FullDETBufferingTimeY[k] - *DRAMClockChangeWatermark;
5403 if (NumberOfActivePlanes > 1) {
5404 ActiveDRAMClockChangeLatencyMarginY = ActiveDRAMClockChangeLatencyMarginY
5405 - (1 - 1.0 / NumberOfActivePlanes) * SwathHeightY[k] * HTotal[k] / PixelClock[k] / VRatio[k];
5408 if (BytePerPixelDETC[k] > 0) {
5409 ActiveDRAMClockChangeLatencyMarginC = HTotal[k] / PixelClock[k]
5410 * DPPOutputBufferLinesC + EffectiveLBLatencyHidingC
5411 + FullDETBufferingTimeC - *DRAMClockChangeWatermark;
5412 if (NumberOfActivePlanes > 1) {
5413 ActiveDRAMClockChangeLatencyMarginC = ActiveDRAMClockChangeLatencyMarginC
5414 - (1 - 1.0 / NumberOfActivePlanes) * SwathHeightC[k] * HTotal[k] / PixelClock[k] / (VRatio[k] / 2);
5416 mode_lib->vba.ActiveDRAMClockChangeLatencyMargin[k] = dml_min(
5417 ActiveDRAMClockChangeLatencyMarginY,
5418 ActiveDRAMClockChangeLatencyMarginC);
5420 mode_lib->vba.ActiveDRAMClockChangeLatencyMargin[k] = ActiveDRAMClockChangeLatencyMarginY;
5423 if (WritebackEnable[k] == true) {
5424 if (WritebackPixelFormat[k] == dm_444_32) {
5425 WritebackDRAMClockChangeLatencyMargin = (WritebackInterfaceLumaBufferSize
5426 + WritebackInterfaceChromaBufferSize) / (WritebackDestinationWidth[k]
5427 * WritebackDestinationHeight[k] / (WritebackSourceHeight[k] * HTotal[k]
5428 / PixelClock[k]) * 4) - *WritebackDRAMClockChangeWatermark;
5430 WritebackDRAMClockChangeLatencyMargin = dml_min(
5431 WritebackInterfaceLumaBufferSize * 8.0 / 10,
5432 2 * WritebackInterfaceChromaBufferSize * 8.0 / 10) / (WritebackDestinationWidth[k]
5433 * WritebackDestinationHeight[k] / (WritebackSourceHeight[k] * HTotal[k] / PixelClock[k]))
5434 - *WritebackDRAMClockChangeWatermark;
5436 mode_lib->vba.ActiveDRAMClockChangeLatencyMargin[k] = dml_min(
5437 mode_lib->vba.ActiveDRAMClockChangeLatencyMargin[k],
5438 WritebackDRAMClockChangeLatencyMargin);
5442 mode_lib->vba.MinActiveDRAMClockChangeMargin = 999999;
5443 PlaneWithMinActiveDRAMClockChangeMargin = 0;
5444 for (k = 0; k < NumberOfActivePlanes; ++k) {
5445 if (mode_lib->vba.ActiveDRAMClockChangeLatencyMargin[k]
5446 < mode_lib->vba.MinActiveDRAMClockChangeMargin) {
5447 mode_lib->vba.MinActiveDRAMClockChangeMargin =
5448 mode_lib->vba.ActiveDRAMClockChangeLatencyMargin[k];
5449 if (BlendingAndTiming[k] == k) {
5450 PlaneWithMinActiveDRAMClockChangeMargin = k;
5452 for (j = 0; j < NumberOfActivePlanes; ++j) {
5453 if (BlendingAndTiming[k] == j) {
5454 PlaneWithMinActiveDRAMClockChangeMargin = j;
5461 *MinActiveDRAMClockChangeLatencySupported = mode_lib->vba.MinActiveDRAMClockChangeMargin + DRAMClockChangeLatency;
5463 SecondMinActiveDRAMClockChangeMarginOneDisplayInVBLank = 999999;
5464 for (k = 0; k < NumberOfActivePlanes; ++k) {
5465 if (!((k == PlaneWithMinActiveDRAMClockChangeMargin) && (BlendingAndTiming[k] == k))
5466 && !(BlendingAndTiming[k] == PlaneWithMinActiveDRAMClockChangeMargin)
5467 && mode_lib->vba.ActiveDRAMClockChangeLatencyMargin[k]
5468 < SecondMinActiveDRAMClockChangeMarginOneDisplayInVBLank) {
5469 SecondMinActiveDRAMClockChangeMarginOneDisplayInVBLank =
5470 mode_lib->vba.ActiveDRAMClockChangeLatencyMargin[k];
5474 mode_lib->vba.TotalNumberOfActiveOTG = 0;
5475 for (k = 0; k < NumberOfActivePlanes; ++k) {
5476 if (BlendingAndTiming[k] == k) {
5477 mode_lib->vba.TotalNumberOfActiveOTG = mode_lib->vba.TotalNumberOfActiveOTG + 1;
5481 if (mode_lib->vba.MinActiveDRAMClockChangeMargin > 0 && PrefetchMode == 0) {
5482 *DRAMClockChangeSupport = dm_dram_clock_change_vactive;
5483 } else if (((mode_lib->vba.SynchronizedVBlank == true
5484 || mode_lib->vba.TotalNumberOfActiveOTG == 1
5485 || SecondMinActiveDRAMClockChangeMarginOneDisplayInVBLank > 0)
5486 && PrefetchMode == 0)) {
5487 *DRAMClockChangeSupport = dm_dram_clock_change_vblank;
5489 *DRAMClockChangeSupport = dm_dram_clock_change_unsupported;
5492 FullDETBufferingTimeYStutterCriticalPlane = FullDETBufferingTimeY[0];
5493 for (k = 0; k < NumberOfActivePlanes; ++k) {
5494 if (FullDETBufferingTimeY[k] <= FullDETBufferingTimeYStutterCriticalPlane) {
5495 TimeToFinishSwathTransferStutterCriticalPlane = (SwathHeightY[k]
5496 - (LinesInDETY[k] - LinesInDETYRoundedDownToSwath[k]))
5497 * (HTotal[k] / PixelClock[k]) / VRatio[k];
5501 *StutterExitWatermark = SRExitTime + mode_lib->vba.LastPixelOfLineExtraWatermark
5502 + ExtraLatency + 10 / DCFCLKDeepSleep;
5503 *StutterEnterPlusExitWatermark = dml_max(
5504 SREnterPlusExitTime + mode_lib->vba.LastPixelOfLineExtraWatermark
5505 + ExtraLatency + 10 / DCFCLKDeepSleep,
5506 TimeToFinishSwathTransferStutterCriticalPlane);
5510 static void CalculateDCFCLKDeepSleep(
5511 struct display_mode_lib *mode_lib,
5512 unsigned int NumberOfActivePlanes,
5513 double BytePerPixelDETY[],
5514 double BytePerPixelDETC[],
5516 double SwathWidthY[],
5519 double PixelClock[],
5520 double PSCL_THROUGHPUT[],
5521 double PSCL_THROUGHPUT_CHROMA[],
5523 double *DCFCLKDeepSleep)
5526 double DisplayPipeLineDeliveryTimeLuma;
5527 double DisplayPipeLineDeliveryTimeChroma;
5528 //double DCFCLKDeepSleepPerPlane[DC__NUM_DPP__MAX];
5530 for (k = 0; k < NumberOfActivePlanes; ++k) {
5531 if (VRatio[k] <= 1) {
5532 DisplayPipeLineDeliveryTimeLuma = SwathWidthY[k] * DPPPerPlane[k]
5533 / HRatio[k] / PixelClock[k];
5535 DisplayPipeLineDeliveryTimeLuma = SwathWidthY[k] / PSCL_THROUGHPUT[k]
5538 if (BytePerPixelDETC[k] == 0) {
5539 DisplayPipeLineDeliveryTimeChroma = 0;
5541 if (VRatio[k] / 2 <= 1) {
5542 DisplayPipeLineDeliveryTimeChroma = SwathWidthY[k] / 2.0
5543 * DPPPerPlane[k] / (HRatio[k] / 2) / PixelClock[k];
5545 DisplayPipeLineDeliveryTimeChroma = SwathWidthY[k] / 2.0
5546 / PSCL_THROUGHPUT_CHROMA[k] / DPPCLK[k];
5550 if (BytePerPixelDETC[k] > 0) {
5551 mode_lib->vba.DCFCLKDeepSleepPerPlane[k] = dml_max(
5552 1.1 * SwathWidthY[k] * dml_ceil(BytePerPixelDETY[k], 1)
5553 / 32.0 / DisplayPipeLineDeliveryTimeLuma,
5554 1.1 * SwathWidthY[k] / 2.0
5555 * dml_ceil(BytePerPixelDETC[k], 2) / 32.0
5556 / DisplayPipeLineDeliveryTimeChroma);
5558 mode_lib->vba.DCFCLKDeepSleepPerPlane[k] = 1.1 * SwathWidthY[k]
5559 * dml_ceil(BytePerPixelDETY[k], 1) / 64.0
5560 / DisplayPipeLineDeliveryTimeLuma;
5562 mode_lib->vba.DCFCLKDeepSleepPerPlane[k] = dml_max(
5563 mode_lib->vba.DCFCLKDeepSleepPerPlane[k],
5564 PixelClock[k] / 16);
5568 *DCFCLKDeepSleep = 8;
5569 for (k = 0; k < NumberOfActivePlanes; ++k) {
5570 *DCFCLKDeepSleep = dml_max(
5572 mode_lib->vba.DCFCLKDeepSleepPerPlane[k]);
5576 static void CalculateDETBufferSize(
5577 double DETBufferSizeInKByte,
5578 unsigned int SwathHeightY,
5579 unsigned int SwathHeightC,
5580 double *DETBufferSizeY,
5581 double *DETBufferSizeC)
5583 if (SwathHeightC == 0) {
5584 *DETBufferSizeY = DETBufferSizeInKByte * 1024;
5585 *DETBufferSizeC = 0;
5586 } else if (SwathHeightY <= SwathHeightC) {
5587 *DETBufferSizeY = DETBufferSizeInKByte * 1024 / 2;
5588 *DETBufferSizeC = DETBufferSizeInKByte * 1024 / 2;
5590 *DETBufferSizeY = DETBufferSizeInKByte * 1024 * 2 / 3;
5591 *DETBufferSizeC = DETBufferSizeInKByte * 1024 / 3;
5595 static void CalculateUrgentBurstFactor(
5596 unsigned int DETBufferSizeInKByte,
5597 unsigned int SwathHeightY,
5598 unsigned int SwathHeightC,
5599 unsigned int SwathWidthY,
5601 double UrgentLatency,
5602 double CursorBufferSize,
5603 unsigned int CursorWidth,
5604 unsigned int CursorBPP,
5608 double BytePerPixelInDETY,
5609 double BytePerPixelInDETC,
5610 double *UrgentBurstFactorCursor,
5611 double *UrgentBurstFactorCursorPre,
5612 double *UrgentBurstFactorLuma,
5613 double *UrgentBurstFactorLumaPre,
5614 double *UrgentBurstFactorChroma,
5615 double *UrgentBurstFactorChromaPre,
5616 unsigned int *NotEnoughUrgentLatencyHiding,
5617 unsigned int *NotEnoughUrgentLatencyHidingPre)
5619 double LinesInDETLuma;
5620 double LinesInDETChroma;
5621 unsigned int LinesInCursorBuffer;
5622 double CursorBufferSizeInTime;
5623 double CursorBufferSizeInTimePre;
5624 double DETBufferSizeInTimeLuma;
5625 double DETBufferSizeInTimeLumaPre;
5626 double DETBufferSizeInTimeChroma;
5627 double DETBufferSizeInTimeChromaPre;
5628 double DETBufferSizeY;
5629 double DETBufferSizeC;
5631 *NotEnoughUrgentLatencyHiding = 0;
5632 *NotEnoughUrgentLatencyHidingPre = 0;
5634 if (CursorWidth > 0) {
5635 LinesInCursorBuffer = 1 << (unsigned int) dml_floor(
5636 dml_log2(CursorBufferSize * 1024.0 / (CursorWidth * CursorBPP / 8.0)), 1.0);
5637 CursorBufferSizeInTime = LinesInCursorBuffer * LineTime / VRatio;
5638 if (CursorBufferSizeInTime - UrgentLatency <= 0) {
5639 *NotEnoughUrgentLatencyHiding = 1;
5640 *UrgentBurstFactorCursor = 0;
5642 *UrgentBurstFactorCursor = CursorBufferSizeInTime
5643 / (CursorBufferSizeInTime - UrgentLatency);
5645 if (VRatioPreY > 0) {
5646 CursorBufferSizeInTimePre = LinesInCursorBuffer * LineTime / VRatioPreY;
5647 if (CursorBufferSizeInTimePre - UrgentLatency <= 0) {
5648 *NotEnoughUrgentLatencyHidingPre = 1;
5649 *UrgentBurstFactorCursorPre = 0;
5651 *UrgentBurstFactorCursorPre = CursorBufferSizeInTimePre
5652 / (CursorBufferSizeInTimePre - UrgentLatency);
5655 *UrgentBurstFactorCursorPre = 1;
5659 CalculateDETBufferSize(
5660 DETBufferSizeInKByte,
5666 LinesInDETLuma = DETBufferSizeY / BytePerPixelInDETY / SwathWidthY;
5667 DETBufferSizeInTimeLuma = dml_floor(LinesInDETLuma, SwathHeightY) * LineTime / VRatio;
5668 if (DETBufferSizeInTimeLuma - UrgentLatency <= 0) {
5669 *NotEnoughUrgentLatencyHiding = 1;
5670 *UrgentBurstFactorLuma = 0;
5672 *UrgentBurstFactorLuma = DETBufferSizeInTimeLuma
5673 / (DETBufferSizeInTimeLuma - UrgentLatency);
5675 if (VRatioPreY > 0) {
5676 DETBufferSizeInTimeLumaPre = dml_floor(LinesInDETLuma, SwathHeightY) * LineTime
5678 if (DETBufferSizeInTimeLumaPre - UrgentLatency <= 0) {
5679 *NotEnoughUrgentLatencyHidingPre = 1;
5680 *UrgentBurstFactorLumaPre = 0;
5682 *UrgentBurstFactorLumaPre = DETBufferSizeInTimeLumaPre
5683 / (DETBufferSizeInTimeLumaPre - UrgentLatency);
5686 *UrgentBurstFactorLumaPre = 1;
5689 if (BytePerPixelInDETC > 0) {
5690 LinesInDETChroma = DETBufferSizeC / BytePerPixelInDETC / (SwathWidthY / 2);
5691 DETBufferSizeInTimeChroma = dml_floor(LinesInDETChroma, SwathHeightC) * LineTime
5693 if (DETBufferSizeInTimeChroma - UrgentLatency <= 0) {
5694 *NotEnoughUrgentLatencyHiding = 1;
5695 *UrgentBurstFactorChroma = 0;
5697 *UrgentBurstFactorChroma = DETBufferSizeInTimeChroma
5698 / (DETBufferSizeInTimeChroma - UrgentLatency);
5700 if (VRatioPreC > 0) {
5701 DETBufferSizeInTimeChromaPre = dml_floor(LinesInDETChroma, SwathHeightC)
5702 * LineTime / VRatioPreC;
5703 if (DETBufferSizeInTimeChromaPre - UrgentLatency <= 0) {
5704 *NotEnoughUrgentLatencyHidingPre = 1;
5705 *UrgentBurstFactorChromaPre = 0;
5707 *UrgentBurstFactorChromaPre = DETBufferSizeInTimeChromaPre
5708 / (DETBufferSizeInTimeChromaPre - UrgentLatency);
5711 *UrgentBurstFactorChromaPre = 1;
5716 static void CalculatePixelDeliveryTimes(
5717 unsigned int NumberOfActivePlanes,
5719 double VRatioPrefetchY[],
5720 double VRatioPrefetchC[],
5721 unsigned int swath_width_luma_ub[],
5722 unsigned int swath_width_chroma_ub[],
5725 double PixelClock[],
5726 double PSCL_THROUGHPUT[],
5727 double PSCL_THROUGHPUT_CHROMA[],
5729 double BytePerPixelDETC[],
5730 enum scan_direction_class SourceScan[],
5731 unsigned int BlockWidth256BytesY[],
5732 unsigned int BlockHeight256BytesY[],
5733 unsigned int BlockWidth256BytesC[],
5734 unsigned int BlockHeight256BytesC[],
5735 double DisplayPipeLineDeliveryTimeLuma[],
5736 double DisplayPipeLineDeliveryTimeChroma[],
5737 double DisplayPipeLineDeliveryTimeLumaPrefetch[],
5738 double DisplayPipeLineDeliveryTimeChromaPrefetch[],
5739 double DisplayPipeRequestDeliveryTimeLuma[],
5740 double DisplayPipeRequestDeliveryTimeChroma[],
5741 double DisplayPipeRequestDeliveryTimeLumaPrefetch[],
5742 double DisplayPipeRequestDeliveryTimeChromaPrefetch[])
5744 double req_per_swath_ub;
5747 for (k = 0; k < NumberOfActivePlanes; ++k) {
5748 if (VRatio[k] <= 1) {
5749 DisplayPipeLineDeliveryTimeLuma[k] = swath_width_luma_ub[k] * DPPPerPlane[k]
5750 / HRatio[k] / PixelClock[k];
5752 DisplayPipeLineDeliveryTimeLuma[k] = swath_width_luma_ub[k]
5753 / PSCL_THROUGHPUT[k] / DPPCLK[k];
5756 if (BytePerPixelDETC[k] == 0) {
5757 DisplayPipeLineDeliveryTimeChroma[k] = 0;
5759 if (VRatio[k] / 2 <= 1) {
5760 DisplayPipeLineDeliveryTimeChroma[k] = swath_width_chroma_ub[k]
5761 * DPPPerPlane[k] / (HRatio[k] / 2) / PixelClock[k];
5763 DisplayPipeLineDeliveryTimeChroma[k] = swath_width_chroma_ub[k]
5764 / PSCL_THROUGHPUT_CHROMA[k] / DPPCLK[k];
5768 if (VRatioPrefetchY[k] <= 1) {
5769 DisplayPipeLineDeliveryTimeLumaPrefetch[k] = swath_width_luma_ub[k]
5770 * DPPPerPlane[k] / HRatio[k] / PixelClock[k];
5772 DisplayPipeLineDeliveryTimeLumaPrefetch[k] = swath_width_luma_ub[k]
5773 / PSCL_THROUGHPUT[k] / DPPCLK[k];
5776 if (BytePerPixelDETC[k] == 0) {
5777 DisplayPipeLineDeliveryTimeChromaPrefetch[k] = 0;
5779 if (VRatioPrefetchC[k] <= 1) {
5780 DisplayPipeLineDeliveryTimeChromaPrefetch[k] =
5781 swath_width_chroma_ub[k] * DPPPerPlane[k]
5782 / (HRatio[k] / 2) / PixelClock[k];
5784 DisplayPipeLineDeliveryTimeChromaPrefetch[k] =
5785 swath_width_chroma_ub[k] / PSCL_THROUGHPUT_CHROMA[k] / DPPCLK[k];
5790 for (k = 0; k < NumberOfActivePlanes; ++k) {
5791 if (SourceScan[k] == dm_horz) {
5792 req_per_swath_ub = swath_width_luma_ub[k] / BlockWidth256BytesY[k];
5794 req_per_swath_ub = swath_width_luma_ub[k] / BlockHeight256BytesY[k];
5796 DisplayPipeRequestDeliveryTimeLuma[k] = DisplayPipeLineDeliveryTimeLuma[k]
5798 DisplayPipeRequestDeliveryTimeLumaPrefetch[k] =
5799 DisplayPipeLineDeliveryTimeLumaPrefetch[k] / req_per_swath_ub;
5800 if (BytePerPixelDETC[k] == 0) {
5801 DisplayPipeRequestDeliveryTimeChroma[k] = 0;
5802 DisplayPipeRequestDeliveryTimeChromaPrefetch[k] = 0;
5804 if (SourceScan[k] == dm_horz) {
5805 req_per_swath_ub = swath_width_chroma_ub[k]
5806 / BlockWidth256BytesC[k];
5808 req_per_swath_ub = swath_width_chroma_ub[k]
5809 / BlockHeight256BytesC[k];
5811 DisplayPipeRequestDeliveryTimeChroma[k] =
5812 DisplayPipeLineDeliveryTimeChroma[k] / req_per_swath_ub;
5813 DisplayPipeRequestDeliveryTimeChromaPrefetch[k] =
5814 DisplayPipeLineDeliveryTimeChromaPrefetch[k] / req_per_swath_ub;
5819 static void CalculateMetaAndPTETimes(
5820 unsigned int NumberOfActivePlanes,
5822 unsigned int MetaChunkSize,
5823 unsigned int MinMetaChunkSizeBytes,
5824 unsigned int GPUVMMaxPageTableLevels,
5825 unsigned int HTotal[],
5827 double VRatioPrefetchY[],
5828 double VRatioPrefetchC[],
5829 double DestinationLinesToRequestRowInVBlank[],
5830 double DestinationLinesToRequestRowInImmediateFlip[],
5831 double DestinationLinesToRequestVMInVBlank[],
5832 double DestinationLinesToRequestVMInImmediateFlip[],
5834 double PixelClock[],
5835 double BytePerPixelDETY[],
5836 double BytePerPixelDETC[],
5837 enum scan_direction_class SourceScan[],
5838 unsigned int dpte_row_height[],
5839 unsigned int dpte_row_height_chroma[],
5840 unsigned int meta_row_width[],
5841 unsigned int meta_row_height[],
5842 unsigned int meta_req_width[],
5843 unsigned int meta_req_height[],
5844 int dpte_group_bytes[],
5845 unsigned int PTERequestSizeY[],
5846 unsigned int PTERequestSizeC[],
5847 unsigned int PixelPTEReqWidthY[],
5848 unsigned int PixelPTEReqHeightY[],
5849 unsigned int PixelPTEReqWidthC[],
5850 unsigned int PixelPTEReqHeightC[],
5851 unsigned int dpte_row_width_luma_ub[],
5852 unsigned int dpte_row_width_chroma_ub[],
5853 unsigned int vm_group_bytes[],
5854 unsigned int dpde0_bytes_per_frame_ub_l[],
5855 unsigned int dpde0_bytes_per_frame_ub_c[],
5856 unsigned int meta_pte_bytes_per_frame_ub_l[],
5857 unsigned int meta_pte_bytes_per_frame_ub_c[],
5858 double DST_Y_PER_PTE_ROW_NOM_L[],
5859 double DST_Y_PER_PTE_ROW_NOM_C[],
5860 double DST_Y_PER_META_ROW_NOM_L[],
5861 double TimePerMetaChunkNominal[],
5862 double TimePerMetaChunkVBlank[],
5863 double TimePerMetaChunkFlip[],
5864 double time_per_pte_group_nom_luma[],
5865 double time_per_pte_group_vblank_luma[],
5866 double time_per_pte_group_flip_luma[],
5867 double time_per_pte_group_nom_chroma[],
5868 double time_per_pte_group_vblank_chroma[],
5869 double time_per_pte_group_flip_chroma[],
5870 double TimePerVMGroupVBlank[],
5871 double TimePerVMGroupFlip[],
5872 double TimePerVMRequestVBlank[],
5873 double TimePerVMRequestFlip[])
5875 unsigned int meta_chunk_width;
5876 unsigned int min_meta_chunk_width;
5877 unsigned int meta_chunk_per_row_int;
5878 unsigned int meta_row_remainder;
5879 unsigned int meta_chunk_threshold;
5880 unsigned int meta_chunks_per_row_ub;
5881 unsigned int dpte_group_width_luma;
5882 unsigned int dpte_group_width_chroma;
5883 unsigned int dpte_groups_per_row_luma_ub;
5884 unsigned int dpte_groups_per_row_chroma_ub;
5885 unsigned int num_group_per_lower_vm_stage;
5886 unsigned int num_req_per_lower_vm_stage;
5889 for (k = 0; k < NumberOfActivePlanes; ++k) {
5890 if (GPUVMEnable == true) {
5891 DST_Y_PER_PTE_ROW_NOM_L[k] = dpte_row_height[k] / VRatio[k];
5892 if (BytePerPixelDETC[k] == 0) {
5893 DST_Y_PER_PTE_ROW_NOM_C[k] = 0;
5895 DST_Y_PER_PTE_ROW_NOM_C[k] = dpte_row_height_chroma[k] / (VRatio[k] / 2);
5898 DST_Y_PER_PTE_ROW_NOM_L[k] = 0;
5899 DST_Y_PER_PTE_ROW_NOM_C[k] = 0;
5901 if (DCCEnable[k] == true) {
5902 DST_Y_PER_META_ROW_NOM_L[k] = meta_row_height[k] / VRatio[k];
5904 DST_Y_PER_META_ROW_NOM_L[k] = 0;
5908 for (k = 0; k < NumberOfActivePlanes; ++k) {
5909 if (DCCEnable[k] == true) {
5910 meta_chunk_width = MetaChunkSize * 1024 * 256
5911 / dml_ceil(BytePerPixelDETY[k], 1) / meta_row_height[k];
5912 min_meta_chunk_width = MinMetaChunkSizeBytes * 256
5913 / dml_ceil(BytePerPixelDETY[k], 1) / meta_row_height[k];
5914 meta_chunk_per_row_int = meta_row_width[k] / meta_chunk_width;
5915 meta_row_remainder = meta_row_width[k] % meta_chunk_width;
5916 if (SourceScan[k] == dm_horz) {
5917 meta_chunk_threshold = 2 * min_meta_chunk_width - meta_req_width[k];
5919 meta_chunk_threshold = 2 * min_meta_chunk_width
5920 - meta_req_height[k];
5922 if (meta_row_remainder <= meta_chunk_threshold) {
5923 meta_chunks_per_row_ub = meta_chunk_per_row_int + 1;
5925 meta_chunks_per_row_ub = meta_chunk_per_row_int + 2;
5927 TimePerMetaChunkNominal[k] = meta_row_height[k] / VRatio[k] * HTotal[k]
5928 / PixelClock[k] / meta_chunks_per_row_ub;
5929 TimePerMetaChunkVBlank[k] = DestinationLinesToRequestRowInVBlank[k]
5930 * HTotal[k] / PixelClock[k] / meta_chunks_per_row_ub;
5931 TimePerMetaChunkFlip[k] = DestinationLinesToRequestRowInImmediateFlip[k]
5932 * HTotal[k] / PixelClock[k] / meta_chunks_per_row_ub;
5934 TimePerMetaChunkNominal[k] = 0;
5935 TimePerMetaChunkVBlank[k] = 0;
5936 TimePerMetaChunkFlip[k] = 0;
5940 for (k = 0; k < NumberOfActivePlanes; ++k) {
5941 if (GPUVMEnable == true) {
5942 if (SourceScan[k] == dm_horz) {
5943 dpte_group_width_luma = dpte_group_bytes[k] / PTERequestSizeY[k]
5944 * PixelPTEReqWidthY[k];
5946 dpte_group_width_luma = dpte_group_bytes[k] / PTERequestSizeY[k]
5947 * PixelPTEReqHeightY[k];
5949 dpte_groups_per_row_luma_ub = dml_ceil(
5950 (float) dpte_row_width_luma_ub[k] / dpte_group_width_luma,
5952 time_per_pte_group_nom_luma[k] = DST_Y_PER_PTE_ROW_NOM_L[k] * HTotal[k]
5953 / PixelClock[k] / dpte_groups_per_row_luma_ub;
5954 time_per_pte_group_vblank_luma[k] = DestinationLinesToRequestRowInVBlank[k]
5955 * HTotal[k] / PixelClock[k] / dpte_groups_per_row_luma_ub;
5956 time_per_pte_group_flip_luma[k] =
5957 DestinationLinesToRequestRowInImmediateFlip[k] * HTotal[k]
5959 / dpte_groups_per_row_luma_ub;
5960 if (BytePerPixelDETC[k] == 0) {
5961 time_per_pte_group_nom_chroma[k] = 0;
5962 time_per_pte_group_vblank_chroma[k] = 0;
5963 time_per_pte_group_flip_chroma[k] = 0;
5965 if (SourceScan[k] == dm_horz) {
5966 dpte_group_width_chroma = dpte_group_bytes[k]
5967 / PTERequestSizeC[k] * PixelPTEReqWidthC[k];
5969 dpte_group_width_chroma = dpte_group_bytes[k]
5970 / PTERequestSizeC[k]
5971 * PixelPTEReqHeightC[k];
5973 dpte_groups_per_row_chroma_ub = dml_ceil(
5974 (float) dpte_row_width_chroma_ub[k]
5975 / dpte_group_width_chroma,
5977 time_per_pte_group_nom_chroma[k] = DST_Y_PER_PTE_ROW_NOM_C[k]
5978 * HTotal[k] / PixelClock[k]
5979 / dpte_groups_per_row_chroma_ub;
5980 time_per_pte_group_vblank_chroma[k] =
5981 DestinationLinesToRequestRowInVBlank[k] * HTotal[k]
5983 / dpte_groups_per_row_chroma_ub;
5984 time_per_pte_group_flip_chroma[k] =
5985 DestinationLinesToRequestRowInImmediateFlip[k]
5986 * HTotal[k] / PixelClock[k]
5987 / dpte_groups_per_row_chroma_ub;
5990 time_per_pte_group_nom_luma[k] = 0;
5991 time_per_pte_group_vblank_luma[k] = 0;
5992 time_per_pte_group_flip_luma[k] = 0;
5993 time_per_pte_group_nom_chroma[k] = 0;
5994 time_per_pte_group_vblank_chroma[k] = 0;
5995 time_per_pte_group_flip_chroma[k] = 0;
5999 for (k = 0; k < NumberOfActivePlanes; ++k) {
6000 if (GPUVMEnable == true && (DCCEnable[k] == true || GPUVMMaxPageTableLevels > 1)) {
6001 if (DCCEnable[k] == false) {
6002 if (BytePerPixelDETC[k] > 0) {
6003 num_group_per_lower_vm_stage =
6004 dml_ceil((double) (dpde0_bytes_per_frame_ub_l[k]) / (double) (vm_group_bytes[k]), 1)
6005 + dml_ceil((double) (dpde0_bytes_per_frame_ub_c[k]) / (double) (vm_group_bytes[k]), 1);
6007 num_group_per_lower_vm_stage =
6008 dml_ceil((double) (dpde0_bytes_per_frame_ub_l[k]) / (double) (vm_group_bytes[k]), 1);
6011 if (GPUVMMaxPageTableLevels == 1) {
6012 if (BytePerPixelDETC[k] > 0) {
6013 num_group_per_lower_vm_stage =
6014 dml_ceil((double) (meta_pte_bytes_per_frame_ub_l[k]) / (double) (vm_group_bytes[k]), 1)
6015 + dml_ceil((double) (meta_pte_bytes_per_frame_ub_c[k]) / (double) (vm_group_bytes[k]), 1);
6017 num_group_per_lower_vm_stage =
6018 dml_ceil((double) (meta_pte_bytes_per_frame_ub_l[k]) / (double) (vm_group_bytes[k]), 1);
6021 if (BytePerPixelDETC[k] > 0) {
6022 num_group_per_lower_vm_stage =
6023 dml_ceil((double) (dpde0_bytes_per_frame_ub_l[k]) / (double) (vm_group_bytes[k]), 1)
6024 + dml_ceil((double) (dpde0_bytes_per_frame_ub_c[k]) / (double) (vm_group_bytes[k]), 1)
6025 + dml_ceil((double) (meta_pte_bytes_per_frame_ub_l[k]) / (double) (vm_group_bytes[k]), 1)
6026 + dml_ceil((double) (meta_pte_bytes_per_frame_ub_c[k]) / (double) (vm_group_bytes[k]), 1);
6028 num_group_per_lower_vm_stage =
6029 dml_ceil((double) (dpde0_bytes_per_frame_ub_l[k]) / (double) (vm_group_bytes[k]), 1)
6030 + dml_ceil((double) (meta_pte_bytes_per_frame_ub_l[k]) / (double) (vm_group_bytes[k]), 1);
6035 if (DCCEnable[k] == false) {
6036 if (BytePerPixelDETC[k] > 0) {
6037 num_req_per_lower_vm_stage = dpde0_bytes_per_frame_ub_l[k]
6038 / 64 + dpde0_bytes_per_frame_ub_c[k] / 64;
6040 num_req_per_lower_vm_stage = dpde0_bytes_per_frame_ub_l[k]
6044 if (GPUVMMaxPageTableLevels == 1) {
6045 if (BytePerPixelDETC[k] > 0) {
6046 num_req_per_lower_vm_stage = meta_pte_bytes_per_frame_ub_l[k] / 64
6047 + meta_pte_bytes_per_frame_ub_c[k] / 64;
6049 num_req_per_lower_vm_stage = meta_pte_bytes_per_frame_ub_l[k] / 64;
6052 if (BytePerPixelDETC[k] > 0) {
6053 num_req_per_lower_vm_stage = dpde0_bytes_per_frame_ub_l[k] / 64
6054 + dpde0_bytes_per_frame_ub_c[k] / 64
6055 + meta_pte_bytes_per_frame_ub_l[k] / 64
6056 + meta_pte_bytes_per_frame_ub_c[k] / 64;
6058 num_req_per_lower_vm_stage = dpde0_bytes_per_frame_ub_l[k] / 64
6059 + meta_pte_bytes_per_frame_ub_l[k] / 64;
6064 TimePerVMGroupVBlank[k] = DestinationLinesToRequestVMInVBlank[k] * HTotal[k]
6065 / PixelClock[k] / num_group_per_lower_vm_stage;
6066 TimePerVMGroupFlip[k] = DestinationLinesToRequestVMInImmediateFlip[k]
6067 * HTotal[k] / PixelClock[k] / num_group_per_lower_vm_stage;
6068 TimePerVMRequestVBlank[k] = DestinationLinesToRequestVMInVBlank[k]
6069 * HTotal[k] / PixelClock[k] / num_req_per_lower_vm_stage;
6070 TimePerVMRequestFlip[k] = DestinationLinesToRequestVMInImmediateFlip[k]
6071 * HTotal[k] / PixelClock[k] / num_req_per_lower_vm_stage;
6073 if (GPUVMMaxPageTableLevels > 2) {
6074 TimePerVMGroupVBlank[k] = TimePerVMGroupVBlank[k] / 2;
6075 TimePerVMGroupFlip[k] = TimePerVMGroupFlip[k] / 2;
6076 TimePerVMRequestVBlank[k] = TimePerVMRequestVBlank[k] / 2;
6077 TimePerVMRequestFlip[k] = TimePerVMRequestFlip[k] / 2;
6081 TimePerVMGroupVBlank[k] = 0;
6082 TimePerVMGroupFlip[k] = 0;
6083 TimePerVMRequestVBlank[k] = 0;
6084 TimePerVMRequestFlip[k] = 0;
6089 static double CalculateExtraLatency(
6090 double UrgentRoundTripAndOutOfOrderLatency,
6091 int TotalNumberOfActiveDPP,
6092 int PixelChunkSizeInKByte,
6093 int TotalNumberOfDCCActiveDPP,
6098 int NumberOfActivePlanes,
6100 int dpte_group_bytes[],
6101 double PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData,
6102 double PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly,
6103 int HostVMMaxPageTableLevels,
6104 int HostVMCachedPageTableLevels)
6106 double CalculateExtraLatency;
6107 double HostVMInefficiencyFactor;
6108 int HostVMDynamicLevels;
6110 if (GPUVMEnable && HostVMEnable) {
6111 HostVMInefficiencyFactor =
6112 PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyPixelMixedWithVMData
6113 / PercentOfIdealDRAMFabricAndSDPPortBWReceivedAfterUrgLatencyVMDataOnly;
6114 HostVMDynamicLevels = HostVMMaxPageTableLevels - HostVMCachedPageTableLevels;
6116 HostVMInefficiencyFactor = 1;
6117 HostVMDynamicLevels = 0;
6120 CalculateExtraLatency = UrgentRoundTripAndOutOfOrderLatency
6121 + (TotalNumberOfActiveDPP * PixelChunkSizeInKByte
6122 + TotalNumberOfDCCActiveDPP * MetaChunkSize) * 1024.0
6128 for (k = 0; k < NumberOfActivePlanes; k++) {
6129 CalculateExtraLatency = CalculateExtraLatency
6130 + NumberOfDPP[k] * dpte_group_bytes[k]
6131 * (1 + 8 * HostVMDynamicLevels)
6132 * HostVMInefficiencyFactor / ReturnBW;
6135 return CalculateExtraLatency;