xref: /linux/drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_shared_types.h (revision 546b928da0427b0d6c663cbb992bd7bfa9ac7971)
1 // SPDX-License-Identifier: MIT
2 //
3 // Copyright 2024 Advanced Micro Devices, Inc.
4 
5 #ifndef __DML2_CORE_SHARED_TYPES_H__
6 #define __DML2_CORE_SHARED_TYPES_H__
7 
8 #include "dml2_external_lib_deps.h"
9 #include "dml_top_display_cfg_types.h"
10 #include "dml_top_types.h"
11 #include "lib_frl_cap_check.h"
12 
13 #define __DML_VBA_DEBUG__
14 #define __DML2_CALCS_MAX_VRATIO_PRE_OTO__ 4.0 //<brief max vratio for one-to-one prefetch bw scheduling
15 #define __DML2_CALCS_MAX_VRATIO_PRE_EQU__ 6.0 //<brief max vratio for equalized prefetch bw scheduling
16 #define __DML2_CALCS_MAX_VRATIO_PRE__ 8.0 //<brief max prefetch vratio register limit
17 #define __DML2_CALCS_MAX_VSTARTUP__ 1023.0 // <brief max vstartup lines supported by hardware
18 
19 #define __DML2_CALCS_DPP_INVALID__ 0
20 #define __DML2_CALCS_DCFCLK_FACTOR__ 1.15 //<brief fudge factor for min dcfclk calclation
21 #define __DML2_CALCS_PIPE_NO_PLANE__ 99
22 
23 struct dml2_core_ip_params {
24 	unsigned int vblank_nom_default_us;
25 	unsigned int remote_iommu_outstanding_translations;
26 	unsigned int rob_buffer_size_kbytes;
27 	unsigned int config_return_buffer_size_in_kbytes;
28 	unsigned int config_return_buffer_segment_size_in_kbytes;
29 	unsigned int compressed_buffer_segment_size_in_kbytes;
30 	unsigned int meta_fifo_size_in_kentries;
31 	unsigned int dpte_buffer_size_in_pte_reqs_luma;
32 	unsigned int dpte_buffer_size_in_pte_reqs_chroma;
33 	unsigned int pixel_chunk_size_kbytes;
34 	unsigned int alpha_pixel_chunk_size_kbytes;
35 	unsigned int min_pixel_chunk_size_bytes;
36 	unsigned int writeback_chunk_size_kbytes;
37 	unsigned int line_buffer_size_bits;
38 	unsigned int max_line_buffer_lines;
39 	unsigned int writeback_interface_buffer_size_kbytes;
40 	unsigned int max_num_dpp;
41 	unsigned int max_num_opp;
42 	unsigned int max_num_otg;
43 	unsigned int TDLUT_33cube_count;
44 	unsigned int max_num_wb;
45 	unsigned int max_dchub_pscl_bw_pix_per_clk;
46 	unsigned int max_pscl_lb_bw_pix_per_clk;
47 	unsigned int max_lb_vscl_bw_pix_per_clk;
48 	unsigned int max_vscl_hscl_bw_pix_per_clk;
49 	double max_hscl_ratio;
50 	double max_vscl_ratio;
51 	unsigned int max_hscl_taps;
52 	unsigned int max_vscl_taps;
53 	unsigned int odm_combine_support_mask;
54 	unsigned int num_dsc;
55 	unsigned int maximum_dsc_slices_per_pipe;
56 	unsigned int maximum_dsc_bits_per_component;
57 	unsigned int maximum_pixels_per_line_per_dsc_unit;
58 	bool dsc422_native_support;
59 	bool cursor_64bpp_support;
60 	double dispclk_ramp_margin_percent;
61 	unsigned int dppclk_delay_subtotal;
62 	unsigned int dppclk_delay_scl;
63 	unsigned int dppclk_delay_scl_lb_only;
64 	unsigned int dppclk_delay_cnvc_formatter;
65 	unsigned int dppclk_delay_cnvc_cursor;
66 	unsigned int cursor_buffer_size;
67 	unsigned int cursor_chunk_size;
68 	unsigned int dispclk_delay_subtotal;
69 	bool dynamic_metadata_vm_enabled;
70 	unsigned int max_inter_dcn_tile_repeaters;
71 	unsigned int max_num_hdmi_frl_outputs;
72 	unsigned int max_num_dp2p0_outputs;
73 	unsigned int max_num_dp2p0_streams;
74 	bool dcc_supported;
75 	bool ptoi_supported;
76 	double writeback_max_hscl_ratio;
77 	double writeback_max_vscl_ratio;
78 	double writeback_min_hscl_ratio;
79 	double writeback_min_vscl_ratio;
80 	unsigned int writeback_max_hscl_taps;
81 	unsigned int writeback_max_vscl_taps;
82 	unsigned int writeback_line_buffer_buffer_size;
83 
84 	unsigned int words_per_channel;
85 	bool imall_supported;
86 	unsigned int max_flip_time_us;
87 	unsigned int max_flip_time_lines;
88 	unsigned int subvp_swath_height_margin_lines;
89 	unsigned int subvp_fw_processing_delay_us;
90 	unsigned int subvp_pstate_allow_width_us;
91 	unsigned int alt_chan_fw_delay_us; // FW delay value required in mode support calculation
92 	// MRQ
93 	bool dcn_mrq_present;
94 	unsigned int zero_size_buffer_entries;
95 	unsigned int compbuf_reserved_space_zs;
96 	unsigned int dcc_meta_buffer_size_bytes;
97 	unsigned int meta_chunk_size_kbytes;
98 	unsigned int min_meta_chunk_size_bytes;
99 
100 	unsigned int dchub_arb_to_ret_delay; // num of dcfclk
101 	unsigned int hostvm_mode;
102 	unsigned int fams2_max_allow_delay_us;
103 	unsigned int fams2_min_allow_width_us;
104 	unsigned int ppt_max_allow_delay_us;
105 	unsigned int temp_read_max_allow_delay_us;
106 	bool use_legacy_dsc_delay_formula;
107 };
108 
109 struct dml2_core_internal_DmlPipe {
110 	double Dppclk;
111 	double Dispclk;
112 	double PixelClock;
113 	double DCFClkDeepSleep;
114 	unsigned int DPPPerSurface;
115 	bool ScalerEnabled;
116 	bool UPSPEnabled;
117 	unsigned int UPSPVTaps;
118 	enum dml2_sample_positioning UPSPSamplePositioning;
119 	enum dml2_rotation_angle RotationAngle;
120 	bool mirrored;
121 	unsigned int ViewportHeight;
122 	unsigned int ViewportHeightC;
123 	unsigned int BlockWidth256BytesY;
124 	unsigned int BlockHeight256BytesY;
125 	unsigned int BlockWidth256BytesC;
126 	unsigned int BlockHeight256BytesC;
127 	unsigned int BlockWidthY;
128 	unsigned int BlockHeightY;
129 	unsigned int BlockWidthC;
130 	unsigned int BlockHeightC;
131 	unsigned int InterlaceEnable;
132 	unsigned int NumberOfCursors;
133 	unsigned int VBlank;
134 	unsigned int HTotal;
135 	unsigned int HActive;
136 	bool DCCEnable;
137 	enum dml2_odm_mode ODMMode;
138 	enum dml2_source_format_class SourcePixelFormat;
139 	enum dml2_swizzle_mode SurfaceTiling;
140 	unsigned int BytePerPixelY;
141 	unsigned int BytePerPixelC;
142 	bool ProgressiveToInterlaceUnitInOPP;
143 	double VRatio;
144 	double VRatioChroma;
145 	unsigned int VTaps;
146 	unsigned int VTapsChroma;
147 	unsigned int PitchY;
148 	unsigned int PitchC;
149 	bool ViewportStationary;
150 	unsigned int ViewportXStart;
151 	unsigned int ViewportYStart;
152 	unsigned int ViewportXStartC;
153 	unsigned int ViewportYStartC;
154 	bool FORCE_ONE_ROW_FOR_FRAME;
155 	unsigned int SwathHeightY;
156 	unsigned int SwathHeightC;
157 
158 	unsigned int DCCMetaPitchY;
159 	unsigned int DCCMetaPitchC;
160 };
161 
162 enum dml2_core_internal_request_type {
163 	dml2_core_internal_request_type_256_bytes = 0,
164 	dml2_core_internal_request_type_128_bytes_non_contiguous = 1,
165 	dml2_core_internal_request_type_128_bytes_contiguous = 2,
166 	dml2_core_internal_request_type_na = 3
167 };
168 enum dml2_core_internal_bw_type {
169 	dml2_core_internal_bw_sdp = 0,
170 	dml2_core_internal_bw_dram = 1,
171 	dml2_core_internal_bw_max
172 };
173 
174 enum dml2_core_internal_soc_state_type {
175 	dml2_core_internal_soc_state_sys_active = 0,
176 	dml2_core_internal_soc_state_svp_prefetch = 1,
177 	dml2_core_internal_soc_state_sys_idle = 2,
178 	dml2_core_internal_soc_state_max
179 };
180 
181 enum dml2_core_internal_output_type {
182 	dml2_core_internal_output_type_unknown = 0,
183 	dml2_core_internal_output_type_dp = 1,
184 	dml2_core_internal_output_type_edp = 2,
185 	dml2_core_internal_output_type_dp2p0 = 3,
186 	dml2_core_internal_output_type_hdmi = 4,
187 	dml2_core_internal_output_type_hdmifrl = 5
188 };
189 
190 enum dml2_core_internal_output_type_rate {
191 	dml2_core_internal_output_rate_unknown = 0,
192 	dml2_core_internal_output_rate_dp_rate_hbr = 1,
193 	dml2_core_internal_output_rate_dp_rate_hbr2 = 2,
194 	dml2_core_internal_output_rate_dp_rate_hbr3 = 3,
195 	dml2_core_internal_output_rate_dp_rate_uhbr10 = 4,
196 	dml2_core_internal_output_rate_dp_rate_uhbr13p5 = 5,
197 	dml2_core_internal_output_rate_dp_rate_uhbr20 = 6,
198 	dml2_core_internal_output_rate_hdmi_rate_3x3 = 7,
199 	dml2_core_internal_output_rate_hdmi_rate_6x3 = 8,
200 	dml2_core_internal_output_rate_hdmi_rate_6x4 = 9,
201 	dml2_core_internal_output_rate_hdmi_rate_8x4 = 10,
202 	dml2_core_internal_output_rate_hdmi_rate_10x4 = 11,
203 	dml2_core_internal_output_rate_hdmi_rate_12x4 = 12,
204 	dml2_core_internal_output_rate_hdmi_rate_16x4 = 13,
205 	dml2_core_internal_output_rate_hdmi_rate_20x4 = 14
206 };
207 
208 struct dml2_core_internal_watermarks {
209 	double UrgentWatermark;
210 	double WritebackUrgentWatermark;
211 	double DRAMClockChangeWatermark;
212 	double FCLKChangeWatermark;
213 	double WritebackDRAMClockChangeWatermark;
214 	double WritebackFCLKChangeWatermark;
215 	double StutterExitWatermark;
216 	double StutterEnterPlusExitWatermark;
217 	double LowPowerStutterExitWatermark;
218 	double LowPowerStutterEnterPlusExitWatermark;
219 	double Z8StutterExitWatermark;
220 	double Z8StutterEnterPlusExitWatermark;
221 	double USRRetrainingWatermark;
222 	double temp_read_or_ppt_watermark_us;
223 	double writeback_temp_read_or_ppt_watermark_us;
224 };
225 
226 struct dml2_core_internal_mode_support_info {
227 	//-----------------
228 	// Mode Support Information
229 	//-----------------
230 	bool ImmediateFlipSupport; //<brief Means mode support immediate flip at the max combine setting; determine in mode support and used in mode programming
231 
232 	// Mode Support Reason/
233 	bool WritebackLatencySupport;
234 	bool ScaleRatioAndTapsSupport;
235 	bool SourceFormatPixelAndScanSupport;
236 	bool P2IWith420;
237 	bool DSCSlicesODMModeSupported;
238 	bool DSCOnlyIfNecessaryWithBPP;
239 	bool DSC422NativeNotSupported;
240 	bool LinkRateDoesNotMatchDPVersion;
241 	bool LinkRateForMultistreamNotIndicated;
242 	bool BPPForMultistreamNotIndicated;
243 	bool MultistreamWithHDMIOreDP;
244 	bool MSOOrODMSplitWithNonDPLink;
245 	bool NotEnoughLanesForMSO;
246 	bool NumberOfOTGSupport;
247 	bool NumberOfTDLUT33cubeSupport;
248 	bool NumberOfHDMIFRLSupport;
249 	bool NumberOfDP2p0Support;
250 	bool WritebackScaleRatioAndTapsSupport;
251 	bool CursorSupport;
252 	bool PitchSupport;
253 	bool ViewportExceedsSurface;
254 	//bool ImmediateFlipRequiredButTheRequirementForEachSurfaceIsNotSpecified;
255 	bool ImmediateFlipOrHostVMAndPStateWithMALLFullFrameOrPhantomPipe;
256 	bool InvalidCombinationOfMALLUseForPStateAndStaticScreen;
257 	bool InvalidCombinationOfMALLUseForPState;
258 	bool ExceededMALLSize;
259 	bool EnoughWritebackUnits;
260 
261 	bool ExceededMultistreamSlots;
262 	bool NotEnoughDSCUnits;
263 	bool NotEnoughDSCSlices;
264 	bool PixelsPerLinePerDSCUnitSupport;
265 	bool DSCCLKRequiredMoreThanSupported;
266 	bool DTBCLKRequiredMoreThanSupported;
267 	bool LinkCapacitySupport;
268 
269 	bool ROBSupport;
270 	bool OutstandingRequestsSupport;
271 	bool OutstandingRequestsUrgencyAvoidance;
272 
273 	bool PTEBufferSizeNotExceeded;
274 	bool DCCMetaBufferSizeNotExceeded;
275 	enum dml2_pstate_change_support DRAMClockChangeSupport[DML2_MAX_PLANES];
276 	enum dml2_pstate_change_support FCLKChangeSupport[DML2_MAX_PLANES];
277 	enum dml2_pstate_change_support temp_read_or_ppt_support[DML2_MAX_PLANES];
278 	bool global_dram_clock_change_support_required;
279 	bool global_dram_clock_change_supported;
280 	bool global_fclk_change_supported;
281 	bool global_temp_read_or_ppt_supported;
282 	bool fclk_pstate_schedule_admissible;
283 	bool temp_read_pstate_schedule_admissible;
284 	bool ppt_pstate_schedule_admissible;
285 	bool USRRetrainingSupport;
286 	bool AvgBandwidthSupport;
287 	bool UrgVactiveBandwidthSupport;
288 	bool EnoughUrgentLatencyHidingSupport;
289 	bool PrefetchScheduleSupported;
290 	bool PrefetchSupported;
291 	bool PrefetchBandwidthSupported;
292 	bool DynamicMetadataSupported;
293 	bool VRatioInPrefetchSupported;
294 	bool DISPCLK_DPPCLK_Support;
295 	bool TotalAvailablePipesSupport;
296 	bool ODMSupport;
297 	bool ModeSupport;
298 	bool ViewportSizeSupport;
299 
300 	bool MPCCombineEnable[DML2_MAX_PLANES]; /// <brief Indicate if the MPC Combine enable in the given state and optimize mpc combine setting
301 	enum dml2_odm_mode ODMMode[DML2_MAX_PLANES]; /// <brief ODM mode that is chosen in the mode check stage and will be used in mode programming stage
302 	unsigned int DPPPerSurface[DML2_MAX_PLANES]; /// <brief How many DPPs are needed drive the surface to output. If MPCC or ODMC could be 2 or 4.
303 	bool DSCEnabled[DML2_MAX_PLANES]; /// <brief Indicate if the DSC is actually required; used in mode_programming
304 	bool FECEnabled[DML2_MAX_PLANES]; /// <brief Indicate if the FEC is actually required
305 	unsigned int NumberOfDSCSlices[DML2_MAX_PLANES]; /// <brief Indicate how many slices needed to support the given mode
306 
307 	double OutputBpp[DML2_MAX_PLANES];
308 	enum dml2_core_internal_output_type OutputType[DML2_MAX_PLANES];
309 	enum dml2_core_internal_output_type_rate OutputRate[DML2_MAX_PLANES];
310 
311 	unsigned int AlignedYPitch[DML2_MAX_PLANES];
312 	unsigned int AlignedCPitch[DML2_MAX_PLANES];
313 
314 	unsigned int AlignedDCCMetaPitchY[DML2_MAX_PLANES];
315 	unsigned int AlignedDCCMetaPitchC[DML2_MAX_PLANES];
316 
317 	unsigned int request_size_bytes_luma[DML2_MAX_PLANES];
318 	unsigned int request_size_bytes_chroma[DML2_MAX_PLANES];
319 	enum dml2_core_internal_request_type RequestLuma[DML2_MAX_PLANES];
320 	enum dml2_core_internal_request_type RequestChroma[DML2_MAX_PLANES];
321 
322 	unsigned int DCCYMaxUncompressedBlock[DML2_MAX_PLANES];
323 	unsigned int DCCYMaxCompressedBlock[DML2_MAX_PLANES];
324 	unsigned int DCCYIndependentBlock[DML2_MAX_PLANES];
325 	unsigned int DCCCMaxUncompressedBlock[DML2_MAX_PLANES];
326 	unsigned int DCCCMaxCompressedBlock[DML2_MAX_PLANES];
327 	unsigned int DCCCIndependentBlock[DML2_MAX_PLANES];
328 
329 	double avg_bandwidth_available_min[dml2_core_internal_soc_state_max];
330 	double avg_bandwidth_available[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max];
331 	double urg_bandwidth_available_min_latency[dml2_core_internal_soc_state_max]; // min between SDP and DRAM, for latency evaluation
332 	double urg_bandwidth_available_min[dml2_core_internal_soc_state_max]; // min between SDP and DRAM
333 	double urg_bandwidth_available[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max];
334 	double urg_bandwidth_available_vm_only[dml2_core_internal_soc_state_max]; // the min of sdp bw and dram_vm_only bw, sdp has no different derate for vm/non-vm etc.
335 	double urg_bandwidth_available_pixel_and_vm[dml2_core_internal_soc_state_max]; // the min of sdp bw and dram_pixel_and_vm bw, sdp has no different derate for vm/non-vm etc.
336 
337 	double avg_bandwidth_required[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max];
338 	double urg_vactive_bandwidth_required[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max]; // active bandwidth, scaled by urg burst factor
339 	double urg_bandwidth_required[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max]; // include vm, prefetch, active bandwidth, scaled by urg burst factor
340 	double urg_bandwidth_required_qual[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max]; // include vm, prefetch, active bandwidth, scaled by urg burst factor, use qual_row_bw
341 	double urg_bandwidth_required_flip[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max]; // include vm, prefetch, active bandwidth + flip
342 
343 	double non_urg_bandwidth_required[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max]; // same as urg_bandwidth, except not scaled by urg burst factor
344 	double non_urg_bandwidth_required_flip[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max];
345 	bool avg_bandwidth_support_ok[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max];
346 	struct dml2_memory_path_bandwidth bandwidth_upper_bound;
347 	double max_urgent_latency_us;
348 	double max_non_urgent_latency_us;
349 	double avg_non_urgent_latency_us;
350 	double avg_urgent_latency_us;
351 	double df_response_time_us;
352 
353 	bool incorrect_imall_usage;
354 
355 	bool g6_temp_read_support;
356 
357 	struct dml2_core_internal_watermarks watermarks;
358 	bool dcfclk_support;
359 	bool qos_bandwidth_support;
360 	bool alternate_channel_size_support;
361 };
362 
363 struct dml2_core_internal_mode_support {
364 	// Physical info; only using for programming
365 	unsigned int state_idx; // <brief min clk state table index for mode support call
366 	unsigned int qos_param_index; // to access the uclk dependent qos_parameters table
367 	unsigned int active_min_uclk_dpm_index; // to access the min_clk table
368 	unsigned int num_active_planes; // <brief As determined by either e2e_pipe_param or display_cfg
369 
370 	// Calculated Clocks
371 	double RequiredDISPCLK; /// <brief Required DISPCLK; depends on pixel rate; odm mode etc.
372 	double RequiredDPPCLK[DML2_MAX_PLANES];
373 	double RequiredDISPCLKPerSurface[DML2_MAX_PLANES];
374 	double RequiredDTBCLK[DML2_MAX_PLANES];
375 
376 	double required_dscclk_freq_mhz[DML2_MAX_PLANES];
377 
378 	double FabricClock; /// <brief Basically just the clock freq at the min (or given) state
379 	double SOCCLK; /// <brief Basically just the clock freq at the min (or given) state
380 	double DCFCLK; /// <brief Basically just the clock freq at the min (or given) state and max combine setting
381 	double GlobalDPPCLK; /// <brief the Max DPPCLK freq out of all pipes
382 	double GlobalDTBCLK; /// <brief the Max DTBCLK freq out of all pipes
383 	double uclk_freq_mhz;
384 	double dram_bw_mbps;
385 	double max_dram_bw_mbps;
386 	double min_available_urgent_bandwidth_MBps; /// <brief Minimum guaranteed available urgent return bandwidth in MBps
387 
388 	double MaxFabricClock; /// <brief Basically just the clock freq at the min (or given) state
389 	double MaxDCFCLK; /// <brief Basically just the clock freq at the min (or given) state and max combine setting
390 	double max_dispclk_freq_mhz;
391 	double max_dppclk_freq_mhz;
392 	double max_dscclk_freq_mhz;
393 
394 	bool NoTimeForPrefetch[DML2_MAX_PLANES];
395 	bool NoTimeForDynamicMetadata[DML2_MAX_PLANES];
396 
397 	// ----------------------------------
398 	// Mode Support Info and fail reason
399 	// ----------------------------------
400 	struct dml2_core_internal_mode_support_info support;
401 
402 	// These are calculated before the ModeSupport and ModeProgram step
403 	// They represent the bound for the return buffer sizing
404 	unsigned int MaxTotalDETInKByte;
405 	unsigned int NomDETInKByte;
406 	unsigned int MinCompressedBufferSizeInKByte;
407 
408 	// Info obtained at the end of mode support calculations
409 	// The reported info is at the "optimal" state and combine setting
410 	unsigned int DETBufferSizeInKByte[DML2_MAX_PLANES]; // <brief Recommended DET size configuration for this plane. All pipes under this plane should program the DET buffer size to the calculated value.
411 	unsigned int DETBufferSizeY[DML2_MAX_PLANES];
412 	unsigned int DETBufferSizeC[DML2_MAX_PLANES];
413 	unsigned int SwathHeightY[DML2_MAX_PLANES];
414 	unsigned int SwathHeightC[DML2_MAX_PLANES];
415 	unsigned int SwathWidthY[DML2_MAX_PLANES]; // per-pipe
416 	unsigned int SwathWidthC[DML2_MAX_PLANES]; // per-pipe
417 
418 	// ----------------------------------
419 	// Intermediates/Informational
420 	// ----------------------------------
421 	unsigned int TotImmediateFlipBytes;
422 	bool DCCEnabledInAnySurface;
423 	double WritebackRequiredDISPCLK;
424 	double TimeCalc;
425 	double TWait[DML2_MAX_PLANES];
426 
427 	bool UnboundedRequestEnabled;
428 	unsigned int compbuf_reserved_space_64b;
429 	bool hw_debug5;
430 	unsigned int CompressedBufferSizeInkByte;
431 	double VRatioPreY[DML2_MAX_PLANES];
432 	double VRatioPreC[DML2_MAX_PLANES];
433 	unsigned int req_per_swath_ub_l[DML2_MAX_PLANES];
434 	unsigned int req_per_swath_ub_c[DML2_MAX_PLANES];
435 	unsigned int swath_width_luma_ub[DML2_MAX_PLANES];
436 	unsigned int swath_width_chroma_ub[DML2_MAX_PLANES];
437 	unsigned int RequiredSlots[DML2_MAX_PLANES];
438 	unsigned int vm_bytes[DML2_MAX_PLANES];
439 	unsigned int DPTEBytesPerRow[DML2_MAX_PLANES];
440 	unsigned int PrefetchLinesY[DML2_MAX_PLANES];
441 	unsigned int PrefetchLinesC[DML2_MAX_PLANES];
442 	unsigned int MaxNumSwathY[DML2_MAX_PLANES]; /// <brief Max number of swath for prefetch
443 	unsigned int MaxNumSwathC[DML2_MAX_PLANES]; /// <brief Max number of swath for prefetch
444 	unsigned int PrefillY[DML2_MAX_PLANES];
445 	unsigned int PrefillC[DML2_MAX_PLANES];
446 	unsigned int full_swath_bytes_l[DML2_MAX_PLANES];
447 	unsigned int full_swath_bytes_c[DML2_MAX_PLANES];
448 
449 	bool use_one_row_for_frame[DML2_MAX_PLANES];
450 	bool use_one_row_for_frame_flip[DML2_MAX_PLANES];
451 
452 	double dst_y_prefetch[DML2_MAX_PLANES];
453 	double LinesForVM[DML2_MAX_PLANES];
454 	double LinesForDPTERow[DML2_MAX_PLANES];
455 	unsigned int SwathWidthYSingleDPP[DML2_MAX_PLANES];
456 	unsigned int SwathWidthCSingleDPP[DML2_MAX_PLANES];
457 	unsigned int BytePerPixelY[DML2_MAX_PLANES];
458 	unsigned int BytePerPixelC[DML2_MAX_PLANES];
459 	double BytePerPixelInDETY[DML2_MAX_PLANES];
460 	double BytePerPixelInDETC[DML2_MAX_PLANES];
461 
462 	unsigned int Read256BlockHeightY[DML2_MAX_PLANES];
463 	unsigned int Read256BlockWidthY[DML2_MAX_PLANES];
464 	unsigned int Read256BlockHeightC[DML2_MAX_PLANES];
465 	unsigned int Read256BlockWidthC[DML2_MAX_PLANES];
466 	unsigned int MacroTileHeightY[DML2_MAX_PLANES];
467 	unsigned int MacroTileHeightC[DML2_MAX_PLANES];
468 	unsigned int MacroTileWidthY[DML2_MAX_PLANES];
469 	unsigned int MacroTileWidthC[DML2_MAX_PLANES];
470 
471 	bool surf_linear128_l[DML2_MAX_PLANES];
472 	bool surf_linear128_c[DML2_MAX_PLANES];
473 
474 	double PSCL_FACTOR[DML2_MAX_PLANES];
475 	double PSCL_FACTOR_CHROMA[DML2_MAX_PLANES];
476 	double MaximumSwathWidthLuma[DML2_MAX_PLANES];
477 	double MaximumSwathWidthChroma[DML2_MAX_PLANES];
478 	double Tno_bw[DML2_MAX_PLANES];
479 	double Tno_bw_flip[DML2_MAX_PLANES];
480 	double dst_y_per_vm_flip[DML2_MAX_PLANES];
481 	double dst_y_per_row_flip[DML2_MAX_PLANES];
482 	double WritebackDelayTime[DML2_MAX_PLANES];
483 	unsigned int dpte_group_bytes[DML2_MAX_PLANES];
484 	unsigned int dpte_row_height[DML2_MAX_PLANES];
485 	unsigned int dpte_row_height_chroma[DML2_MAX_PLANES];
486 	double UrgLatency;
487 	double TripToMemory;
488 	double UrgentBurstFactorCursor[DML2_MAX_PLANES];
489 	double UrgentBurstFactorCursorPre[DML2_MAX_PLANES];
490 	double UrgentBurstFactorLuma[DML2_MAX_PLANES];
491 	double UrgentBurstFactorLumaPre[DML2_MAX_PLANES];
492 	double UrgentBurstFactorChroma[DML2_MAX_PLANES];
493 	double UrgentBurstFactorChromaPre[DML2_MAX_PLANES];
494 	double MaximumSwathWidthInLineBufferLuma;
495 	double MaximumSwathWidthInLineBufferChroma;
496 	double ExtraLatency;
497 	double ExtraLatency_sr;
498 	double ExtraLatencyPrefetch;
499 
500 	double dcc_dram_bw_nom_overhead_factor_p0[DML2_MAX_PLANES]; // overhead to request meta
501 	double dcc_dram_bw_nom_overhead_factor_p1[DML2_MAX_PLANES];
502 	double dcc_dram_bw_pref_overhead_factor_p0[DML2_MAX_PLANES]; // overhead to request meta
503 	double dcc_dram_bw_pref_overhead_factor_p1[DML2_MAX_PLANES];
504 	double mall_prefetch_sdp_overhead_factor[DML2_MAX_PLANES]; // overhead to the imall or phantom pipe
505 	double mall_prefetch_dram_overhead_factor[DML2_MAX_PLANES];
506 
507 	bool is_using_mall_for_ss[DML2_MAX_PLANES];
508 	unsigned int meta_row_width_chroma[DML2_MAX_PLANES];
509 	unsigned int PixelPTEReqHeightC[DML2_MAX_PLANES];
510 	bool PTE_BUFFER_MODE[DML2_MAX_PLANES];
511 	unsigned int meta_req_height_chroma[DML2_MAX_PLANES];
512 	unsigned int meta_pte_bytes_per_frame_ub_c[DML2_MAX_PLANES];
513 	unsigned int dpde0_bytes_per_frame_ub_c[DML2_MAX_PLANES];
514 	unsigned int dpte_row_width_luma_ub[DML2_MAX_PLANES];
515 	unsigned int meta_req_width[DML2_MAX_PLANES];
516 	unsigned int meta_row_width[DML2_MAX_PLANES];
517 	unsigned int PixelPTEReqWidthY[DML2_MAX_PLANES];
518 	unsigned int dpte_row_height_linear[DML2_MAX_PLANES];
519 	unsigned int PTERequestSizeY[DML2_MAX_PLANES];
520 	unsigned int dpte_row_width_chroma_ub[DML2_MAX_PLANES];
521 	unsigned int PixelPTEReqWidthC[DML2_MAX_PLANES];
522 	unsigned int meta_pte_bytes_per_frame_ub_l[DML2_MAX_PLANES];
523 	unsigned int dpte_row_height_linear_chroma[DML2_MAX_PLANES];
524 	unsigned int PTERequestSizeC[DML2_MAX_PLANES];
525 	unsigned int meta_req_height[DML2_MAX_PLANES];
526 	unsigned int dpde0_bytes_per_frame_ub_l[DML2_MAX_PLANES];
527 	unsigned int meta_req_width_chroma[DML2_MAX_PLANES];
528 	unsigned int PixelPTEReqHeightY[DML2_MAX_PLANES];
529 	unsigned int BIGK_FRAGMENT_SIZE[DML2_MAX_PLANES];
530 	unsigned int vm_group_bytes[DML2_MAX_PLANES];
531 	unsigned int VReadyOffsetPix[DML2_MAX_PLANES];
532 	unsigned int VUpdateOffsetPix[DML2_MAX_PLANES];
533 	unsigned int VUpdateWidthPix[DML2_MAX_PLANES];
534 	double TSetup[DML2_MAX_PLANES];
535 	double Tdmdl_vm_raw[DML2_MAX_PLANES];
536 	double Tdmdl_raw[DML2_MAX_PLANES];
537 	unsigned int VStartupMin[DML2_MAX_PLANES]; /// <brief Minimum vstartup to meet the prefetch schedule (i.e. the prefetch solution can be found at this vstartup time); not the actual global sync vstartup pos.
538 	double MaxActiveDRAMClockChangeLatencySupported[DML2_MAX_PLANES];
539 	double MaxActiveFCLKChangeLatencySupported;
540 
541 	// Backend
542 	bool RequiresDSC[DML2_MAX_PLANES];
543 	bool RequiresFEC[DML2_MAX_PLANES];
544 	double OutputBpp[DML2_MAX_PLANES];
545 	double DesiredOutputBpp[DML2_MAX_PLANES];
546 	double PixelClockBackEnd[DML2_MAX_PLANES];
547 	unsigned int DSCDelay[DML2_MAX_PLANES];
548 	bool use_legacy_dsc_delay_formula;
549 	enum dml2_core_internal_output_type OutputType[DML2_MAX_PLANES];
550 	enum dml2_core_internal_output_type_rate OutputRate[DML2_MAX_PLANES];
551 	bool TotalAvailablePipesSupportNoDSC;
552 	bool TotalAvailablePipesSupportDSC;
553 	unsigned int NumberOfDPPNoDSC;
554 	unsigned int NumberOfDPPDSC;
555 	enum dml2_odm_mode ODMModeNoDSC;
556 	enum dml2_odm_mode ODMModeDSC;
557 	double RequiredDISPCLKPerSurfaceNoDSC;
558 	double RequiredDISPCLKPerSurfaceDSC;
559 	unsigned int EstimatedNumberOfDSCSlices[DML2_MAX_PLANES];
560 
561 	// Bandwidth Related Info
562 	double BandwidthAvailableForImmediateFlip;
563 	double vactive_sw_bw_l[DML2_MAX_PLANES]; // no dcc overhead, for the plane
564 	double vactive_sw_bw_c[DML2_MAX_PLANES];
565 	double WriteBandwidth[DML2_MAX_PLANES][DML2_MAX_WRITEBACK];
566 	double RequiredPrefetchPixelDataBWLuma[DML2_MAX_PLANES];
567 	double RequiredPrefetchPixelDataBWChroma[DML2_MAX_PLANES];
568 	/* Max bandwidth calculated from prefetch schedule should be considered in addition to the pixel data bw to avoid ms/mp mismatches.
569 	 * 1. oto bw should also be considered when calculating peak urgent bw to avoid situations oto/equ mismatches between ms and mp
570 	 *
571 	 * 2. equ bandwidth needs to be considered for calculating peak urgent bw when equ schedule is used in mode support.
572 	 *    Some slight difference in variables may cause the pixel data bandwidth to be higher
573 	 *    even though overall equ prefetch bandwidths can be lower going from ms to mp
574 	 */
575 	double RequiredPrefetchBWMax[DML2_MAX_PLANES];
576 	double cursor_bw[DML2_MAX_PLANES];
577 	double prefetch_cursor_bw[DML2_MAX_PLANES];
578 	double prefetch_vmrow_bw[DML2_MAX_PLANES];
579 	double final_flip_bw[DML2_MAX_PLANES];
580 	double meta_row_bw[DML2_MAX_PLANES];
581 	unsigned int meta_row_bytes[DML2_MAX_PLANES];
582 	double dpte_row_bw[DML2_MAX_PLANES];
583 	double excess_vactive_fill_bw_l[DML2_MAX_PLANES];
584 	double excess_vactive_fill_bw_c[DML2_MAX_PLANES];
585 	double surface_avg_vactive_required_bw[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max][DML2_MAX_PLANES];
586 	double surface_peak_required_bw[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max][DML2_MAX_PLANES];
587 
588 	// Something that should be feedback to caller
589 	enum dml2_odm_mode ODMMode[DML2_MAX_PLANES];
590 	unsigned int SurfaceSizeInMALL[DML2_MAX_PLANES];
591 	unsigned int NoOfDPP[DML2_MAX_PLANES];
592 	unsigned int NoOfOPP[DML2_MAX_PLANES];
593 	bool MPCCombine[DML2_MAX_PLANES];
594 	double dcfclk_deepsleep;
595 	double MinDPPCLKUsingSingleDPP[DML2_MAX_PLANES];
596 	bool SingleDPPViewportSizeSupportPerSurface[DML2_MAX_PLANES];
597 	bool ImmediateFlipSupportedForPipe[DML2_MAX_PLANES];
598 	bool NotEnoughUrgentLatencyHiding[DML2_MAX_PLANES];
599 	bool NotEnoughUrgentLatencyHidingPre[DML2_MAX_PLANES];
600 	bool PTEBufferSizeNotExceeded[DML2_MAX_PLANES];
601 	bool DCCMetaBufferSizeNotExceeded[DML2_MAX_PLANES];
602 	unsigned int TotalNumberOfActiveDPP;
603 	unsigned int TotalNumberOfActiveOPP;
604 	unsigned int TotalNumberOfSingleDPPSurfaces;
605 	unsigned int TotalNumberOfDCCActiveDPP;
606 	unsigned int Total3dlutActive;
607 
608 	unsigned int SubViewportLinesNeededInMALL[DML2_MAX_PLANES];
609 	double VActiveLatencyHidingMargin[DML2_MAX_PLANES];
610 	double VActiveLatencyHidingUs[DML2_MAX_PLANES];
611 	unsigned int MaxVStartupLines[DML2_MAX_PLANES];
612 	double pstate_vactive_det_fill_delay_us[dml2_pstate_type_count][DML2_MAX_PLANES];
613 
614 	unsigned int num_mcaches_l[DML2_MAX_PLANES];
615 	unsigned int mcache_row_bytes_l[DML2_MAX_PLANES];
616 	unsigned int mcache_row_bytes_per_channel_l[DML2_MAX_PLANES];
617 	unsigned int mcache_offsets_l[DML2_MAX_PLANES][DML2_MAX_MCACHES + 1];
618 	unsigned int mcache_shift_granularity_l[DML2_MAX_PLANES];
619 
620 	unsigned int num_mcaches_c[DML2_MAX_PLANES];
621 	unsigned int mcache_row_bytes_c[DML2_MAX_PLANES];
622 	unsigned int mcache_row_bytes_per_channel_c[DML2_MAX_PLANES];
623 	unsigned int mcache_offsets_c[DML2_MAX_PLANES][DML2_MAX_MCACHES + 1];
624 	unsigned int mcache_shift_granularity_c[DML2_MAX_PLANES];
625 
626 	bool mall_comb_mcache_l[DML2_MAX_PLANES];
627 	bool mall_comb_mcache_c[DML2_MAX_PLANES];
628 	bool lc_comb_mcache[DML2_MAX_PLANES];
629 
630 	unsigned int vmpg_width_y[DML2_MAX_PLANES];
631 	unsigned int vmpg_height_y[DML2_MAX_PLANES];
632 	unsigned int vmpg_width_c[DML2_MAX_PLANES];
633 	unsigned int vmpg_height_c[DML2_MAX_PLANES];
634 
635 	unsigned int meta_row_height_luma[DML2_MAX_PLANES];
636 	unsigned int meta_row_height_chroma[DML2_MAX_PLANES];
637 	unsigned int meta_row_bytes_per_row_ub_l[DML2_MAX_PLANES];
638 	unsigned int meta_row_bytes_per_row_ub_c[DML2_MAX_PLANES];
639 	unsigned int dpte_row_bytes_per_row_l[DML2_MAX_PLANES];
640 	unsigned int dpte_row_bytes_per_row_c[DML2_MAX_PLANES];
641 
642 	unsigned int pstate_bytes_required_l[dml2_pstate_type_count][DML2_MAX_PLANES];
643 	unsigned int pstate_bytes_required_c[dml2_pstate_type_count][DML2_MAX_PLANES];
644 	unsigned int cursor_bytes_per_chunk[DML2_MAX_PLANES];
645 	unsigned int cursor_bytes_per_line[DML2_MAX_PLANES];
646 
647 	unsigned int MaximumVStartup[DML2_MAX_PLANES];
648 
649 	double HostVMInefficiencyFactor;
650 	double HostVMInefficiencyFactorPrefetch;
651 
652 	unsigned int tdlut_pte_bytes_per_frame[DML2_MAX_PLANES];
653 	unsigned int tdlut_bytes_per_frame[DML2_MAX_PLANES];
654 	unsigned int tdlut_groups_per_2row_ub[DML2_MAX_PLANES];
655 	double tdlut_opt_time[DML2_MAX_PLANES];
656 	double tdlut_drain_time[DML2_MAX_PLANES];
657 	unsigned int tdlut_bytes_per_group[DML2_MAX_PLANES];
658 
659 	double Tvm_trips_flip[DML2_MAX_PLANES];
660 	double Tr0_trips_flip[DML2_MAX_PLANES];
661 	double Tvm_trips_flip_rounded[DML2_MAX_PLANES];
662 	double Tr0_trips_flip_rounded[DML2_MAX_PLANES];
663 
664 	unsigned int DSTYAfterScaler[DML2_MAX_PLANES];
665 	unsigned int DSTXAfterScaler[DML2_MAX_PLANES];
666 
667 	enum dml2_pstate_method uclk_pstate_switch_modes[DML2_MAX_PLANES];
668 	unsigned int svp0_max_bytes;
669 	unsigned int svp1_max_bytes;
670 	unsigned int svp0_max_bytes_per_dpp[DML2_MAX_PLANES]; // max bytes for any DPP under a given plane
671 	unsigned int svp0_max_bytes_per_dpp_c[DML2_MAX_PLANES]; // max bytes for any DPP under a given plane
672 	unsigned int svp1_max_bytes_per_dpp[DML2_MAX_PLANES]; // max bytes for any DPP under a given plane
673 	unsigned int svp1_max_bytes_per_dpp_c[DML2_MAX_PLANES]; // max bytes for any DPP under a given plane
674 	unsigned int svp0_dst_lines[DML2_MAX_PLANES]; // per stream
675 	unsigned int svp1_dst_lines[DML2_MAX_PLANES]; // per stream
676 	unsigned int svp_req_limit[DML2_MAX_PLANES]; // per stream, should be the same value in time between all streams max(2 swaths, dst_y_pre) over all planes
677 	unsigned int nom_req_limit_alt[DML2_MAX_PLANES];
678 	unsigned int min_lead_dst_lines[DML2_MAX_PLANES];
679 	unsigned int total_swaths[DML2_MAX_PLANES];
680 	unsigned int total_swaths_c[DML2_MAX_PLANES];
681 	unsigned int prefetch_swaths[DML2_MAX_PLANES];
682 	unsigned int prefetch_swaths_c[DML2_MAX_PLANES];
683 	double prefetch_hdl_delta[DML2_MAX_PLANES]; // in dst
684 	double recout_hdl_delta[DML2_MAX_PLANES]; // in dst
685 	double prefetch_hdl_delta_c[DML2_MAX_PLANES]; // in dst
686 	double recout_hdl_delta_c[DML2_MAX_PLANES]; // in dst
687 	unsigned int max_prefetch_in_lines[DML2_MAX_PLANES]; // max prefetch time over all planes converted to lines for the given stream
688 	double lsdma_bw_req_for_alt_kbps;
689 
690 	// Synchronized timing group assignement
691 	unsigned int timing_group_id[DML2_MAX_PLANES]; // timing group id for the given plane
692 	unsigned int timing_group_count;
693 
694 	bool fclk_pstate_required;
695 	bool ppt_pstate_required;
696 	bool temp_read_pstate_required;
697 	// P-state schedule windows
698 	double fclk_pstate_allow_start_us[DML2_MAX_PLANES];
699 	double fclk_pstate_allow_end_us[DML2_MAX_PLANES];
700 	double ppt_pstate_allow_start_us[DML2_MAX_PLANES];
701 	double ppt_pstate_allow_end_us[DML2_MAX_PLANES];
702 	double temp_read_pstate_allow_start_us[DML2_MAX_PLANES];
703 	double temp_read_pstate_allow_end_us[DML2_MAX_PLANES];
704 };
705 
706 /// @brief A mega structure that houses various info for model programming step.
707 struct dml2_core_internal_mode_program {
708 	unsigned int qos_param_index; // to access the uclk dependent dpm table
709 	unsigned int active_min_uclk_dpm_index; // to access the min_clk table
710 	double FabricClock; /// <brief Basically just the clock freq at the min (or given) state
711 	//double DCFCLK; /// <brief Basically just the clock freq at the min (or given) state and max combine setting
712 	double dram_bw_mbps;
713 	double min_available_urgent_bandwidth_MBps; /// <brief Minimum guaranteed available urgent return bandwidth in MBps
714 	double uclk_freq_mhz;
715 	unsigned int NoOfDPP[DML2_MAX_PLANES];
716 	enum dml2_odm_mode ODMMode[DML2_MAX_PLANES];
717 
718 	//-------------
719 	// Intermediate/Informational
720 	//-------------
721 	double UrgentLatency;
722 	double TripToMemory;
723 	double MetaTripToMemory;
724 	unsigned int VInitPreFillY[DML2_MAX_PLANES];
725 	unsigned int VInitPreFillC[DML2_MAX_PLANES];
726 	unsigned int MaxNumSwathY[DML2_MAX_PLANES];
727 	unsigned int MaxNumSwathC[DML2_MAX_PLANES];
728 	unsigned int full_swath_bytes_l[DML2_MAX_PLANES];
729 	unsigned int full_swath_bytes_c[DML2_MAX_PLANES];
730 
731 	double BytePerPixelInDETY[DML2_MAX_PLANES];
732 	double BytePerPixelInDETC[DML2_MAX_PLANES];
733 	unsigned int BytePerPixelY[DML2_MAX_PLANES];
734 	unsigned int BytePerPixelC[DML2_MAX_PLANES];
735 	unsigned int SwathWidthY[DML2_MAX_PLANES]; // per-pipe
736 	unsigned int SwathWidthC[DML2_MAX_PLANES]; // per-pipe
737 	unsigned int req_per_swath_ub_l[DML2_MAX_PLANES];
738 	unsigned int req_per_swath_ub_c[DML2_MAX_PLANES];
739 	unsigned int SwathWidthSingleDPPY[DML2_MAX_PLANES];
740 	unsigned int SwathWidthSingleDPPC[DML2_MAX_PLANES];
741 	double vactive_sw_bw_l[DML2_MAX_PLANES];
742 	double vactive_sw_bw_c[DML2_MAX_PLANES];
743 	double excess_vactive_fill_bw_l[DML2_MAX_PLANES];
744 	double excess_vactive_fill_bw_c[DML2_MAX_PLANES];
745 
746 	unsigned int PixelPTEBytesPerRow[DML2_MAX_PLANES];
747 	unsigned int vm_bytes[DML2_MAX_PLANES];
748 	unsigned int PrefetchSourceLinesY[DML2_MAX_PLANES];
749 	double RequiredPrefetchPixelDataBWLuma[DML2_MAX_PLANES];
750 	double RequiredPrefetchPixelDataBWChroma[DML2_MAX_PLANES];
751 	unsigned int PrefetchSourceLinesC[DML2_MAX_PLANES];
752 	double PSCL_THROUGHPUT[DML2_MAX_PLANES];
753 	double PSCL_THROUGHPUT_CHROMA[DML2_MAX_PLANES];
754 	unsigned int DSCDelay[DML2_MAX_PLANES];
755 	bool use_legacy_dsc_delay_formula;
756 	double DPPCLKUsingSingleDPP[DML2_MAX_PLANES];
757 
758 	unsigned int Read256BlockHeightY[DML2_MAX_PLANES];
759 	unsigned int Read256BlockWidthY[DML2_MAX_PLANES];
760 	unsigned int Read256BlockHeightC[DML2_MAX_PLANES];
761 	unsigned int Read256BlockWidthC[DML2_MAX_PLANES];
762 	unsigned int MacroTileHeightY[DML2_MAX_PLANES];
763 	unsigned int MacroTileHeightC[DML2_MAX_PLANES];
764 	unsigned int MacroTileWidthY[DML2_MAX_PLANES];
765 	unsigned int MacroTileWidthC[DML2_MAX_PLANES];
766 	double MaximumSwathWidthLuma[DML2_MAX_PLANES];
767 	double MaximumSwathWidthChroma[DML2_MAX_PLANES];
768 
769 	bool surf_linear128_l[DML2_MAX_PLANES];
770 	bool surf_linear128_c[DML2_MAX_PLANES];
771 
772 	unsigned int SurfaceSizeInTheMALL[DML2_MAX_PLANES];
773 	double VRatioPrefetchY[DML2_MAX_PLANES];
774 	double VRatioPrefetchC[DML2_MAX_PLANES];
775 	double Tno_bw[DML2_MAX_PLANES];
776 	double Tno_bw_flip[DML2_MAX_PLANES];
777 	double final_flip_bw[DML2_MAX_PLANES];
778 	double prefetch_vmrow_bw[DML2_MAX_PLANES];
779 	double cursor_bw[DML2_MAX_PLANES];
780 	double prefetch_cursor_bw[DML2_MAX_PLANES];
781 	double WritebackDelay[DML2_MAX_PLANES];
782 	unsigned int dpte_row_height[DML2_MAX_PLANES];
783 	unsigned int dpte_row_height_linear[DML2_MAX_PLANES];
784 	unsigned int dpte_row_width_luma_ub[DML2_MAX_PLANES];
785 	unsigned int dpte_row_width_chroma_ub[DML2_MAX_PLANES];
786 	unsigned int dpte_row_height_chroma[DML2_MAX_PLANES];
787 	unsigned int dpte_row_height_linear_chroma[DML2_MAX_PLANES];
788 	unsigned int vm_group_bytes[DML2_MAX_PLANES];
789 	unsigned int dpte_group_bytes[DML2_MAX_PLANES];
790 
791 	double dpte_row_bw[DML2_MAX_PLANES];
792 	double time_per_tdlut_group[DML2_MAX_PLANES];
793 	double UrgentBurstFactorCursor[DML2_MAX_PLANES];
794 	double UrgentBurstFactorCursorPre[DML2_MAX_PLANES];
795 	double UrgentBurstFactorLuma[DML2_MAX_PLANES];
796 	double UrgentBurstFactorLumaPre[DML2_MAX_PLANES];
797 	double UrgentBurstFactorChroma[DML2_MAX_PLANES];
798 	double UrgentBurstFactorChromaPre[DML2_MAX_PLANES];
799 
800 	double MaximumSwathWidthInLineBufferLuma;
801 	double MaximumSwathWidthInLineBufferChroma;
802 
803 	unsigned int vmpg_width_y[DML2_MAX_PLANES];
804 	unsigned int vmpg_height_y[DML2_MAX_PLANES];
805 	unsigned int vmpg_width_c[DML2_MAX_PLANES];
806 	unsigned int vmpg_height_c[DML2_MAX_PLANES];
807 
808 	double meta_row_bw[DML2_MAX_PLANES];
809 	unsigned int meta_row_bytes[DML2_MAX_PLANES];
810 	unsigned int meta_req_width[DML2_MAX_PLANES];
811 	unsigned int meta_req_height[DML2_MAX_PLANES];
812 	unsigned int meta_row_width[DML2_MAX_PLANES];
813 	unsigned int meta_row_height[DML2_MAX_PLANES];
814 	unsigned int meta_req_width_chroma[DML2_MAX_PLANES];
815 	unsigned int meta_row_height_chroma[DML2_MAX_PLANES];
816 	unsigned int meta_row_width_chroma[DML2_MAX_PLANES];
817 	unsigned int meta_req_height_chroma[DML2_MAX_PLANES];
818 
819 	unsigned int swath_width_luma_ub[DML2_MAX_PLANES];
820 	unsigned int swath_width_chroma_ub[DML2_MAX_PLANES];
821 	unsigned int PixelPTEReqWidthY[DML2_MAX_PLANES];
822 	unsigned int PixelPTEReqHeightY[DML2_MAX_PLANES];
823 	unsigned int PTERequestSizeY[DML2_MAX_PLANES];
824 	unsigned int PixelPTEReqWidthC[DML2_MAX_PLANES];
825 	unsigned int PixelPTEReqHeightC[DML2_MAX_PLANES];
826 	unsigned int PTERequestSizeC[DML2_MAX_PLANES];
827 
828 	double TWait[DML2_MAX_PLANES];
829 	double Tdmdl_vm_raw[DML2_MAX_PLANES];
830 	double Tdmdl_vm[DML2_MAX_PLANES];
831 	double Tdmdl_raw[DML2_MAX_PLANES];
832 	double Tdmdl[DML2_MAX_PLANES];
833 	double TSetup[DML2_MAX_PLANES];
834 	unsigned int dpde0_bytes_per_frame_ub_l[DML2_MAX_PLANES];
835 	unsigned int dpde0_bytes_per_frame_ub_c[DML2_MAX_PLANES];
836 
837 	unsigned int meta_pte_bytes_per_frame_ub_l[DML2_MAX_PLANES];
838 	unsigned int meta_pte_bytes_per_frame_ub_c[DML2_MAX_PLANES];
839 
840 	bool UnboundedRequestEnabled;
841 	unsigned int CompressedBufferSizeInkByte;
842 	unsigned int compbuf_reserved_space_64b;
843 	bool hw_debug5;
844 	unsigned int dcfclk_deep_sleep_hysteresis;
845 	unsigned int min_return_latency_in_dcfclk;
846 
847 	bool NotEnoughUrgentLatencyHiding[DML2_MAX_PLANES];
848 	bool NotEnoughUrgentLatencyHidingPre[DML2_MAX_PLANES];
849 	double ExtraLatency;
850 	double ExtraLatency_sr;
851 	double ExtraLatencyPrefetch;
852 	bool PrefetchAndImmediateFlipSupported;
853 	double TotalDataReadBandwidth;
854 	double BandwidthAvailableForImmediateFlip;
855 	bool NotEnoughTimeForDynamicMetadata[DML2_MAX_PLANES];
856 
857 	bool use_one_row_for_frame[DML2_MAX_PLANES];
858 	bool use_one_row_for_frame_flip[DML2_MAX_PLANES];
859 
860 	double TCalc;
861 	unsigned int TotImmediateFlipBytes;
862 
863 	unsigned int MaxTotalDETInKByte;
864 	unsigned int NomDETInKByte;
865 	unsigned int MinCompressedBufferSizeInKByte;
866 	double PixelClockBackEnd[DML2_MAX_PLANES];
867 	double OutputBpp[DML2_MAX_PLANES];
868 	bool dsc_enable[DML2_MAX_PLANES];
869 	unsigned int num_dsc_slices[DML2_MAX_PLANES];
870 	unsigned int meta_row_bytes_per_row_ub_l[DML2_MAX_PLANES];
871 	unsigned int meta_row_bytes_per_row_ub_c[DML2_MAX_PLANES];
872 	unsigned int dpte_row_bytes_per_row_l[DML2_MAX_PLANES];
873 	unsigned int dpte_row_bytes_per_row_c[DML2_MAX_PLANES];
874 	unsigned int cursor_bytes_per_chunk[DML2_MAX_PLANES];
875 	unsigned int cursor_bytes_per_line[DML2_MAX_PLANES];
876 	unsigned int MaxVStartupLines[DML2_MAX_PLANES]; /// <brief more like vblank for the plane's OTG
877 	double HostVMInefficiencyFactor;
878 	double HostVMInefficiencyFactorPrefetch;
879 	unsigned int tdlut_pte_bytes_per_frame[DML2_MAX_PLANES];
880 	unsigned int tdlut_bytes_per_frame[DML2_MAX_PLANES];
881 	unsigned int tdlut_groups_per_2row_ub[DML2_MAX_PLANES];
882 	double tdlut_opt_time[DML2_MAX_PLANES];
883 	double tdlut_drain_time[DML2_MAX_PLANES];
884 	unsigned int tdlut_bytes_per_group[DML2_MAX_PLANES];
885 	double Tvm_trips_flip[DML2_MAX_PLANES];
886 	double Tr0_trips_flip[DML2_MAX_PLANES];
887 	double Tvm_trips_flip_rounded[DML2_MAX_PLANES];
888 	double Tr0_trips_flip_rounded[DML2_MAX_PLANES];
889 	bool immediate_flip_required; // any pipes need immediate flip
890 	double SOCCLK; /// <brief Basically just the clock freq at the min (or given) state
891 	double TotalWRBandwidth;
892 	double max_urgent_latency_us;
893 	double df_response_time_us;
894 
895 	enum dml2_pstate_method uclk_pstate_switch_modes[DML2_MAX_PLANES];
896 	unsigned int svp0_max_bytes;
897 	unsigned int svp1_max_bytes;
898 	unsigned int svp0_max_bytes_per_dpp[DML2_MAX_PLANES]; // max bytes for any DPP under a given plane
899 	unsigned int svp0_max_bytes_per_dpp_c[DML2_MAX_PLANES]; // max bytes for any DPP under a given plane
900 	unsigned int svp1_max_bytes_per_dpp[DML2_MAX_PLANES]; // max bytes for any DPP under a given plane
901 	unsigned int svp1_max_bytes_per_dpp_c[DML2_MAX_PLANES]; // max bytes for any DPP under a given plane
902 	unsigned int svp0_dst_lines[DML2_MAX_PLANES]; // per stream
903 	unsigned int svp1_dst_lines[DML2_MAX_PLANES]; // per stream
904 	unsigned int min_lead_dst_lines[DML2_MAX_PLANES]; // per stream, should be max(nominal_req_limit, vstartup_to_vactive). Does not have to be maxed over all planes
905 	unsigned int svp_req_limit[DML2_MAX_PLANES]; // per stream, should be the same value in time between all streams max(2 swaths, dst_y_pre) over all planes
906 	unsigned int nom_req_limit_alt[DML2_MAX_PLANES]; // per stream
907 	unsigned int total_swaths[DML2_MAX_PLANES];
908 	unsigned int total_swaths_c[DML2_MAX_PLANES];
909 	unsigned int prefetch_swaths[DML2_MAX_PLANES];
910 	unsigned int prefetch_swaths_c[DML2_MAX_PLANES];
911 	double prefetch_hdl_delta[DML2_MAX_PLANES]; // in dst
912 	double recout_hdl_delta[DML2_MAX_PLANES]; // in dst
913 	double prefetch_hdl_delta_c[DML2_MAX_PLANES]; // in dst
914 	double recout_hdl_delta_c[DML2_MAX_PLANES]; // in dst
915 	unsigned int max_prefetch_in_lines[DML2_MAX_PLANES]; // max prefetch time over all planes converted to lines for the given stream
916 	// -------------------
917 	// Output
918 	// -------------------
919 	unsigned int pipe_plane[DML2_MAX_PLANES]; // <brief used mainly by dv to map the pipe inst to plane index within DML core; the plane idx of a pipe
920 	unsigned int num_active_pipes;
921 
922 	bool NoTimeToPrefetch[DML2_MAX_PLANES]; // <brief Prefetch schedule calculation result
923 
924 	// Support
925 	bool UrgVactiveBandwidthSupport;
926 	bool PrefetchScheduleSupported;
927 	bool UrgentBandwidthSupport;
928 	bool PrefetchModeSupported; // <brief Is the prefetch mode (bandwidth and latency) supported
929 	bool ImmediateFlipSupported;
930 	bool ImmediateFlipSupportedForPipe[DML2_MAX_PLANES];
931 	bool dcfclk_support;
932 
933 	// Clock
934 	double Dcfclk;
935 	double Dispclk; // <brief dispclk being used in mode programming
936 	double Dppclk[DML2_MAX_PLANES]; // <brief dppclk being used in mode programming
937 	double GlobalDPPCLK;
938 
939 	double DSCCLK[DML2_MAX_PLANES]; //< brief Required DSCCLK freq. Backend; not used in any subsequent calculations for now
940 	double DCFCLKDeepSleep;
941 
942 	// ARB reg
943 	bool DCHUBBUB_ARB_CSTATE_MAX_CAP_MODE;
944 	struct dml2_core_internal_watermarks Watermark;
945 
946 	// DCC compression control
947 	unsigned int request_size_bytes_luma[DML2_MAX_PLANES];
948 	unsigned int request_size_bytes_chroma[DML2_MAX_PLANES];
949 	enum dml2_core_internal_request_type RequestLuma[DML2_MAX_PLANES];
950 	enum dml2_core_internal_request_type RequestChroma[DML2_MAX_PLANES];
951 	unsigned int DCCYMaxUncompressedBlock[DML2_MAX_PLANES];
952 	unsigned int DCCYMaxCompressedBlock[DML2_MAX_PLANES];
953 	unsigned int DCCYIndependentBlock[DML2_MAX_PLANES];
954 	unsigned int DCCCMaxUncompressedBlock[DML2_MAX_PLANES];
955 	unsigned int DCCCMaxCompressedBlock[DML2_MAX_PLANES];
956 	unsigned int DCCCIndependentBlock[DML2_MAX_PLANES];
957 
958 	// Stutter Efficiency
959 	double StutterEfficiency;
960 	double StutterEfficiencyNotIncludingVBlank;
961 	unsigned int NumberOfStutterBurstsPerFrame;
962 	double Z8StutterEfficiency;
963 	unsigned int Z8NumberOfStutterBurstsPerFrame;
964 	double Z8StutterEfficiencyNotIncludingVBlank;
965 	double LowPowerStutterEfficiency;
966 	double LowPowerStutterEfficiencyNotIncludingVBlank;
967 	unsigned int LowPowerNumberOfStutterBurstsPerFrame;
968 	double StutterPeriod;
969 	double Z8StutterEfficiencyBestCase;
970 	unsigned int Z8NumberOfStutterBurstsPerFrameBestCase;
971 	double Z8StutterEfficiencyNotIncludingVBlankBestCase;
972 	double StutterPeriodBestCase;
973 
974 	// DLG TTU reg
975 	double MIN_DST_Y_NEXT_START[DML2_MAX_PLANES];
976 	bool VREADY_AT_OR_AFTER_VSYNC[DML2_MAX_PLANES];
977 	unsigned int DSTYAfterScaler[DML2_MAX_PLANES];
978 	unsigned int DSTXAfterScaler[DML2_MAX_PLANES];
979 	double dst_y_prefetch[DML2_MAX_PLANES];
980 	double dst_y_per_vm_vblank[DML2_MAX_PLANES];
981 	double dst_y_per_row_vblank[DML2_MAX_PLANES];
982 	double dst_y_per_vm_flip[DML2_MAX_PLANES];
983 	double dst_y_per_row_flip[DML2_MAX_PLANES];
984 	double MinTTUVBlank[DML2_MAX_PLANES];
985 	double DisplayPipeLineDeliveryTimeLuma[DML2_MAX_PLANES];
986 	double DisplayPipeLineDeliveryTimeChroma[DML2_MAX_PLANES];
987 	double DisplayPipeLineDeliveryTimeLumaPrefetch[DML2_MAX_PLANES];
988 	double DisplayPipeLineDeliveryTimeChromaPrefetch[DML2_MAX_PLANES];
989 	double DisplayPipeRequestDeliveryTimeLuma[DML2_MAX_PLANES];
990 	double DisplayPipeRequestDeliveryTimeChroma[DML2_MAX_PLANES];
991 	double DisplayPipeRequestDeliveryTimeLumaPrefetch[DML2_MAX_PLANES];
992 	double DisplayPipeRequestDeliveryTimeChromaPrefetch[DML2_MAX_PLANES];
993 	unsigned int CursorDstXOffset[DML2_MAX_PLANES];
994 	unsigned int CursorDstYOffset[DML2_MAX_PLANES];
995 	unsigned int CursorChunkHDLAdjust[DML2_MAX_PLANES];
996 
997 	double DST_Y_PER_PTE_ROW_NOM_L[DML2_MAX_PLANES];
998 	double DST_Y_PER_PTE_ROW_NOM_C[DML2_MAX_PLANES];
999 	double time_per_pte_group_nom_luma[DML2_MAX_PLANES];
1000 	double time_per_pte_group_nom_chroma[DML2_MAX_PLANES];
1001 	double time_per_pte_group_vblank_luma[DML2_MAX_PLANES];
1002 	double time_per_pte_group_vblank_chroma[DML2_MAX_PLANES];
1003 	double time_per_pte_group_flip_luma[DML2_MAX_PLANES];
1004 	double time_per_pte_group_flip_chroma[DML2_MAX_PLANES];
1005 	double TimePerVMGroupVBlank[DML2_MAX_PLANES];
1006 	double TimePerVMGroupFlip[DML2_MAX_PLANES];
1007 	double TimePerVMRequestVBlank[DML2_MAX_PLANES];
1008 	double TimePerVMRequestFlip[DML2_MAX_PLANES];
1009 
1010 	double DST_Y_PER_META_ROW_NOM_L[DML2_MAX_PLANES];
1011 	double DST_Y_PER_META_ROW_NOM_C[DML2_MAX_PLANES];
1012 	double TimePerMetaChunkNominal[DML2_MAX_PLANES];
1013 	double TimePerChromaMetaChunkNominal[DML2_MAX_PLANES];
1014 	double TimePerMetaChunkVBlank[DML2_MAX_PLANES];
1015 	double TimePerChromaMetaChunkVBlank[DML2_MAX_PLANES];
1016 	double TimePerMetaChunkFlip[DML2_MAX_PLANES];
1017 	double TimePerChromaMetaChunkFlip[DML2_MAX_PLANES];
1018 
1019 	double FractionOfUrgentBandwidth;
1020 	double FractionOfUrgentBandwidthImmediateFlip;
1021 	double FractionOfUrgentBandwidthMALL;
1022 
1023 	// RQ registers
1024 	bool PTE_BUFFER_MODE[DML2_MAX_PLANES];
1025 	unsigned int BIGK_FRAGMENT_SIZE[DML2_MAX_PLANES];
1026 	double VActiveLatencyHidingUs[DML2_MAX_PLANES];
1027 	unsigned int SubViewportLinesNeededInMALL[DML2_MAX_PLANES];
1028 	bool is_using_mall_for_ss[DML2_MAX_PLANES];
1029 
1030 	// OTG
1031 	unsigned int VStartupMin[DML2_MAX_PLANES]; /// <brief Minimum vstartup to meet the prefetch schedule (i.e. the prefetch solution can be found at this vstartup time); not the actual global sync vstartup pos.
1032 	unsigned int VStartup[DML2_MAX_PLANES]; /// <brief The vstartup value for OTG programming (will set to max vstartup; but now bounded by min(vblank_nom. actual vblank))
1033 	unsigned int VUpdateOffsetPix[DML2_MAX_PLANES];
1034 	unsigned int VUpdateWidthPix[DML2_MAX_PLANES];
1035 	unsigned int VReadyOffsetPix[DML2_MAX_PLANES];
1036 	unsigned int pstate_keepout_dst_lines[DML2_MAX_PLANES];
1037 
1038 	// Latency and Support
1039 	double MaxActiveFCLKChangeLatencySupported;
1040 	bool USRRetrainingSupport;
1041 	bool g6_temp_read_support;
1042 	enum dml2_pstate_change_support FCLKChangeSupport[DML2_MAX_PLANES];
1043 	enum dml2_pstate_change_support DRAMClockChangeSupport[DML2_MAX_PLANES];
1044 	enum dml2_pstate_change_support temp_read_or_ppt_support[DML2_MAX_PLANES];
1045 	bool global_dram_clock_change_supported;
1046 	bool global_fclk_change_supported;
1047 	bool global_temp_read_or_ppt_supported;
1048 	double MaxActiveDRAMClockChangeLatencySupported[DML2_MAX_PLANES];
1049 	double WritebackAllowFCLKChangeEndPosition[DML2_MAX_PLANES];
1050 	double WritebackAllowDRAMClockChangeEndPosition[DML2_MAX_PLANES];
1051 
1052 	// buffer sizing
1053 	unsigned int DETBufferSizeInKByte[DML2_MAX_PLANES]; // <brief Recommended DET size configuration for this plane. All pipes under this plane should program the DET buffer size to the calculated value.
1054 	unsigned int DETBufferSizeY[DML2_MAX_PLANES];
1055 	unsigned int DETBufferSizeC[DML2_MAX_PLANES];
1056 	unsigned int SwathHeightY[DML2_MAX_PLANES];
1057 	unsigned int SwathHeightC[DML2_MAX_PLANES];
1058 
1059 	double urg_vactive_bandwidth_required[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max]; // active bandwidth, scaled by urg burst factor
1060 	double urg_bandwidth_required[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max]; // include vm, prefetch, active bandwidth, scaled by urg burst factor
1061 	double urg_bandwidth_required_qual[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max]; // include vm, prefetch, active bandwidth, scaled by urg burst factor, use qual_row_bw
1062 	double urg_bandwidth_required_flip[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max]; // include vm, prefetch, active bandwidth + flip
1063 	double non_urg_bandwidth_required[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max]; // same as urg_bandwidth, except not scaled by urg burst factor
1064 	double non_urg_bandwidth_required_flip[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max];
1065 
1066 	double avg_bandwidth_available_min[dml2_core_internal_soc_state_max];
1067 	double avg_bandwidth_available[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max];
1068 	double urg_bandwidth_available_min[dml2_core_internal_soc_state_max]; // min between SDP and DRAM
1069 	double urg_bandwidth_available[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max];
1070 	double urg_bandwidth_available_vm_only[dml2_core_internal_soc_state_max]; // the min of sdp bw and dram_vm_only bw, sdp has no different derate for vm/non-vm traffic etc.
1071 	double urg_bandwidth_available_pixel_and_vm[dml2_core_internal_soc_state_max]; // the min of sdp bw and dram_pixel_and_vm bw, sdp has no different derate for vm/non-vm etc.
1072 
1073 	double dcc_dram_bw_nom_overhead_factor_p0[DML2_MAX_PLANES];
1074 	double dcc_dram_bw_nom_overhead_factor_p1[DML2_MAX_PLANES];
1075 	double dcc_dram_bw_pref_overhead_factor_p0[DML2_MAX_PLANES];
1076 	double dcc_dram_bw_pref_overhead_factor_p1[DML2_MAX_PLANES];
1077 	double mall_prefetch_sdp_overhead_factor[DML2_MAX_PLANES];
1078 	double mall_prefetch_dram_overhead_factor[DML2_MAX_PLANES];
1079 
1080 	unsigned int num_mcaches_l[DML2_MAX_PLANES];
1081 	unsigned int mcache_row_bytes_l[DML2_MAX_PLANES];
1082 	unsigned int mcache_row_bytes_per_channel_l[DML2_MAX_PLANES];
1083 	unsigned int mcache_offsets_l[DML2_MAX_PLANES][DML2_MAX_MCACHES + 1];
1084 	unsigned int mcache_shift_granularity_l[DML2_MAX_PLANES];
1085 
1086 	unsigned int num_mcaches_c[DML2_MAX_PLANES];
1087 	unsigned int mcache_row_bytes_c[DML2_MAX_PLANES];
1088 	unsigned int mcache_row_bytes_per_channel_c[DML2_MAX_PLANES];
1089 	unsigned int mcache_offsets_c[DML2_MAX_PLANES][DML2_MAX_MCACHES + 1];
1090 	unsigned int mcache_shift_granularity_c[DML2_MAX_PLANES];
1091 
1092 	bool mall_comb_mcache_l[DML2_MAX_PLANES];
1093 	bool mall_comb_mcache_c[DML2_MAX_PLANES];
1094 	bool lc_comb_mcache[DML2_MAX_PLANES];
1095 
1096 	double impacted_prefetch_margin_us[DML2_MAX_PLANES];
1097 };
1098 
1099 struct dml2_core_internal_SOCParametersList {
1100 	double UrgentLatency;
1101 	double ExtraLatency_sr;
1102 	double ExtraLatency;
1103 	double WritebackLatency;
1104 	double DRAMClockChangeLatency;
1105 	double FCLKChangeLatency;
1106 	double SRExitTime;
1107 	double SREnterPlusExitTime;
1108 	double SRExitTimeLowPower;
1109 	double SREnterPlusExitTimeLowPower;
1110 	double SRExitZ8Time;
1111 	double SREnterPlusExitZ8Time;
1112 	double USRRetrainingLatency;
1113 	double SMNLatency;
1114 	double g6_temp_read_blackout_us;
1115 	double temp_read_or_ppt_blackout_us;
1116 	double max_urgent_latency_us;
1117 	double df_response_time_us;
1118 	enum dml2_qos_param_type qos_type;
1119 };
1120 
1121 struct dml2_core_calcs_mode_support_locals {
1122 	double PixelClockBackEnd[DML2_MAX_PLANES];
1123 	double OutputBpp[DML2_MAX_PLANES];
1124 
1125 	unsigned int meta_row_height_luma[DML2_MAX_PLANES];
1126 	unsigned int meta_row_height_chroma[DML2_MAX_PLANES];
1127 	unsigned int meta_row_bytes_per_row_ub_l[DML2_MAX_PLANES];
1128 	unsigned int meta_row_bytes_per_row_ub_c[DML2_MAX_PLANES];
1129 	unsigned int dpte_row_bytes_per_row_l[DML2_MAX_PLANES];
1130 	unsigned int dpte_row_bytes_per_row_c[DML2_MAX_PLANES];
1131 
1132 	bool dummy_boolean[3];
1133 	unsigned int dummy_integer[3];
1134 	unsigned int dummy_integer_array[36][DML2_MAX_PLANES];
1135 	enum dml2_odm_mode dummy_odm_mode[DML2_MAX_PLANES];
1136 	bool dummy_boolean_array[2][DML2_MAX_PLANES];
1137 	double dummy_single[3];
1138 	double dummy_single_array[DML2_MAX_PLANES];
1139 	double dummy_double_array[3][DML2_MAX_PLANES];
1140 	enum dml2_pstate_method dummy_pstate_method_array[DML2_MAX_PLANES];
1141 	struct dml2_core_internal_watermarks dummy_watermark;
1142 	double dummy_bw[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max];
1143 	double surface_dummy_bw[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max][DML2_MAX_PLANES];
1144 
1145 	unsigned int MaximumVStartup[DML2_MAX_PLANES];
1146 	unsigned int DSTYAfterScaler[DML2_MAX_PLANES];
1147 	unsigned int DSTXAfterScaler[DML2_MAX_PLANES];
1148 	struct dml2_core_internal_SOCParametersList mSOCParameters;
1149 	struct dml2_core_internal_DmlPipe myPipe;
1150 	struct dml2_core_internal_DmlPipe SurfParameters[DML2_MAX_PLANES];
1151 	unsigned int TotalNumberOfActiveWriteback;
1152 	unsigned int MaximumSwathWidthSupportLuma;
1153 	unsigned int MaximumSwathWidthSupportChroma;
1154 	bool MPCCombineMethodAsNeededForPStateChangeAndVoltage;
1155 	bool MPCCombineMethodAsPossible;
1156 	bool TotalAvailablePipesSupportNoDSC;
1157 	unsigned int NumberOfDPPNoDSC;
1158 	enum dml2_odm_mode ODMModeNoDSC;
1159 	double RequiredDISPCLKPerSurfaceNoDSC;
1160 	bool TotalAvailablePipesSupportDSC;
1161 	unsigned int NumberOfDPPDSC;
1162 	enum dml2_odm_mode ODMModeDSC;
1163 	double RequiredDISPCLKPerSurfaceDSC;
1164 	double BWOfNonCombinedSurfaceOfMaximumBandwidth;
1165 	unsigned int NumberOfNonCombinedSurfaceOfMaximumBandwidth;
1166 	unsigned int TotalNumberOfActiveOTG;
1167 	unsigned int TotalNumberOfActiveHDMIFRL;
1168 	unsigned int TotalNumberOfActiveDP2p0;
1169 	unsigned int TotalNumberOfActiveDP2p0Outputs;
1170 	unsigned int TotalSlots;
1171 	unsigned int DSCFormatFactor;
1172 	unsigned int TotalDSCUnitsRequired;
1173 	unsigned int ReorderingBytes;
1174 	bool ImmediateFlipRequired;
1175 	bool FullFrameMALLPStateMethod;
1176 	bool SubViewportMALLPStateMethod;
1177 	bool PhantomPipeMALLPStateMethod;
1178 	bool SubViewportMALLRefreshGreaterThan120Hz;
1179 
1180 	double HostVMInefficiencyFactor;
1181 	double HostVMInefficiencyFactorPrefetch;
1182 	unsigned int MaxVStartup;
1183 	double PixelClockBackEndFactor;
1184 	unsigned int NumDSCUnitRequired;
1185 
1186 	double Tvm_trips[DML2_MAX_PLANES];
1187 	double Tr0_trips[DML2_MAX_PLANES];
1188 	double Tvm_trips_flip[DML2_MAX_PLANES];
1189 	double Tr0_trips_flip[DML2_MAX_PLANES];
1190 	double Tvm_trips_flip_rounded[DML2_MAX_PLANES];
1191 	double Tr0_trips_flip_rounded[DML2_MAX_PLANES];
1192 	unsigned int per_pipe_flip_bytes[DML2_MAX_PLANES];
1193 
1194 	unsigned int vmpg_width_y[DML2_MAX_PLANES];
1195 	unsigned int vmpg_height_y[DML2_MAX_PLANES];
1196 	unsigned int vmpg_width_c[DML2_MAX_PLANES];
1197 	unsigned int vmpg_height_c[DML2_MAX_PLANES];
1198 	unsigned int full_swath_bytes_l[DML2_MAX_PLANES];
1199 	unsigned int full_swath_bytes_c[DML2_MAX_PLANES];
1200 
1201 	unsigned int tdlut_pte_bytes_per_frame[DML2_MAX_PLANES];
1202 	unsigned int tdlut_bytes_per_frame[DML2_MAX_PLANES];
1203 	unsigned int tdlut_row_bytes[DML2_MAX_PLANES];
1204 	unsigned int tdlut_groups_per_2row_ub[DML2_MAX_PLANES];
1205 	double tdlut_opt_time[DML2_MAX_PLANES];
1206 	double tdlut_drain_time[DML2_MAX_PLANES];
1207 	unsigned int tdlut_bytes_to_deliver[DML2_MAX_PLANES];
1208 	unsigned int tdlut_bytes_per_group[DML2_MAX_PLANES];
1209 
1210 	unsigned int cursor_bytes_per_chunk[DML2_MAX_PLANES];
1211 	unsigned int cursor_bytes_per_line[DML2_MAX_PLANES];
1212 	unsigned int cursor_lines_per_chunk[DML2_MAX_PLANES];
1213 	unsigned int cursor_bytes[DML2_MAX_PLANES];
1214 	bool stream_visited[DML2_MAX_PLANES];
1215 
1216 	unsigned int pstate_bytes_required_l[dml2_pstate_type_count][DML2_MAX_PLANES];
1217 	unsigned int pstate_bytes_required_c[dml2_pstate_type_count][DML2_MAX_PLANES];
1218 
1219 	double prefetch_sw_bytes[DML2_MAX_PLANES];
1220 	double Tpre_rounded[DML2_MAX_PLANES];
1221 	double Tpre_oto[DML2_MAX_PLANES];
1222 	bool recalc_prefetch_schedule;
1223 	bool recalc_prefetch_done;
1224 	double impacted_dst_y_pre[DML2_MAX_PLANES];
1225 	double line_times[DML2_MAX_PLANES];
1226 	enum dml2_source_format_class pixel_format[DML2_MAX_PLANES];
1227 	unsigned int lb_source_lines_l[DML2_MAX_PLANES];
1228 	unsigned int lb_source_lines_c[DML2_MAX_PLANES];
1229 	double prefetch_swath_time_us[DML2_MAX_PLANES];
1230 };
1231 
1232 struct dml2_core_calcs_mode_programming_locals {
1233 	double PixelClockBackEnd[DML2_MAX_PLANES];
1234 	double OutputBpp[DML2_MAX_PLANES];
1235 	unsigned int num_active_planes; // <brief As determined by either e2e_pipe_param or display_cfg
1236 	unsigned int MaxTotalDETInKByte;
1237 	unsigned int NomDETInKByte;
1238 	unsigned int MinCompressedBufferSizeInKByte;
1239 	double SOCCLK; /// <brief Basically just the clock freq at the min (or given) state
1240 
1241 	double dummy_bw[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max];
1242 	double surface_dummy_bw[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max][DML2_MAX_PLANES];
1243 	double surface_dummy_bw0[dml2_core_internal_soc_state_max][dml2_core_internal_bw_max][DML2_MAX_PLANES];
1244 	unsigned int dummy_integer_array[4][DML2_MAX_PLANES];
1245 	enum dml2_output_encoder_class dummy_output_encoder_array[DML2_MAX_PLANES];
1246 	double dummy_single_array[2][DML2_MAX_PLANES];
1247 	unsigned int dummy_long_array[8][DML2_MAX_PLANES];
1248 	bool dummy_boolean_array[2][DML2_MAX_PLANES];
1249 	bool dummy_boolean[2];
1250 	double dummy_single[2];
1251 	struct dml2_core_internal_watermarks dummy_watermark;
1252 
1253 	unsigned int DSCFormatFactor;
1254 	struct dml2_core_internal_DmlPipe SurfaceParameters[DML2_MAX_PLANES];
1255 	unsigned int ReorderingBytes;
1256 	double HostVMInefficiencyFactor;
1257 	double HostVMInefficiencyFactorPrefetch;
1258 	unsigned int TotalDCCActiveDPP;
1259 	unsigned int TotalActiveDPP;
1260 	unsigned int Total3dlutActive;
1261 	unsigned int MaxVStartupLines[DML2_MAX_PLANES]; /// <brief more like vblank for the plane's OTG
1262 	bool immediate_flip_required; // any pipes need immediate flip
1263 	bool DestinationLineTimesForPrefetchLessThan2;
1264 	bool VRatioPrefetchMoreThanMax;
1265 	double MaxTotalRDBandwidthNotIncludingMALLPrefetch;
1266 	struct dml2_core_internal_SOCParametersList mmSOCParameters;
1267 	double Tvstartup_margin;
1268 	double dlg_vblank_start;
1269 	double LSetup;
1270 	double blank_lines_remaining;
1271 	double WRBandwidth;
1272 	struct dml2_core_internal_DmlPipe myPipe;
1273 	double PixelClockBackEndFactor;
1274 	unsigned int vmpg_width_y[DML2_MAX_PLANES];
1275 	unsigned int vmpg_height_y[DML2_MAX_PLANES];
1276 	unsigned int vmpg_width_c[DML2_MAX_PLANES];
1277 	unsigned int vmpg_height_c[DML2_MAX_PLANES];
1278 	unsigned int full_swath_bytes_l[DML2_MAX_PLANES];
1279 	unsigned int full_swath_bytes_c[DML2_MAX_PLANES];
1280 
1281 	unsigned int meta_row_bytes_per_row_ub_l[DML2_MAX_PLANES];
1282 	unsigned int meta_row_bytes_per_row_ub_c[DML2_MAX_PLANES];
1283 	unsigned int dpte_row_bytes_per_row_l[DML2_MAX_PLANES];
1284 	unsigned int dpte_row_bytes_per_row_c[DML2_MAX_PLANES];
1285 
1286 	unsigned int tdlut_pte_bytes_per_frame[DML2_MAX_PLANES];
1287 	unsigned int tdlut_bytes_per_frame[DML2_MAX_PLANES];
1288 	unsigned int tdlut_row_bytes[DML2_MAX_PLANES];
1289 	unsigned int tdlut_groups_per_2row_ub[DML2_MAX_PLANES];
1290 	double tdlut_opt_time[DML2_MAX_PLANES];
1291 	double tdlut_drain_time[DML2_MAX_PLANES];
1292 	unsigned int tdlut_bytes_to_deliver[DML2_MAX_PLANES];
1293 	unsigned int tdlut_bytes_per_group[DML2_MAX_PLANES];
1294 
1295 	unsigned int cursor_bytes_per_chunk[DML2_MAX_PLANES];
1296 	unsigned int cursor_bytes_per_line[DML2_MAX_PLANES];
1297 	unsigned int cursor_lines_per_chunk[DML2_MAX_PLANES];
1298 	unsigned int cursor_bytes[DML2_MAX_PLANES];
1299 
1300 	double Tvm_trips[DML2_MAX_PLANES];
1301 	double Tr0_trips[DML2_MAX_PLANES];
1302 	double Tvm_trips_flip[DML2_MAX_PLANES];
1303 	double Tr0_trips_flip[DML2_MAX_PLANES];
1304 	double Tvm_trips_flip_rounded[DML2_MAX_PLANES];
1305 	double Tr0_trips_flip_rounded[DML2_MAX_PLANES];
1306 	unsigned int per_pipe_flip_bytes[DML2_MAX_PLANES];
1307 
1308 	unsigned int pstate_bytes_required_l[dml2_pstate_type_count][DML2_MAX_PLANES];
1309 	unsigned int pstate_bytes_required_c[dml2_pstate_type_count][DML2_MAX_PLANES];
1310 
1311 	double prefetch_sw_bytes[DML2_MAX_PLANES];
1312 	double Tpre_rounded[DML2_MAX_PLANES];
1313 	double Tpre_oto[DML2_MAX_PLANES];
1314 	bool recalc_prefetch_schedule;
1315 	double impacted_dst_y_pre[DML2_MAX_PLANES];
1316 	double line_times[DML2_MAX_PLANES];
1317 	enum dml2_source_format_class pixel_format[DML2_MAX_PLANES];
1318 	unsigned int lb_source_lines_l[DML2_MAX_PLANES];
1319 	unsigned int lb_source_lines_c[DML2_MAX_PLANES];
1320 	unsigned int num_dsc_slices[DML2_MAX_PLANES];
1321 	bool dsc_enable[DML2_MAX_PLANES];
1322 };
1323 
1324 struct dml2_core_calcs_CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_locals {
1325 	double ActiveDRAMClockChangeLatencyMargin[DML2_MAX_PLANES];
1326 	double ActiveFCLKChangeLatencyMargin[DML2_MAX_PLANES];
1327 	double USRRetrainingLatencyMargin[DML2_MAX_PLANES];
1328 	double g6_temp_read_latency_margin[DML2_MAX_PLANES];
1329 	double temp_read_or_ppt_latency_margin[DML2_MAX_PLANES];
1330 
1331 	double EffectiveLBLatencyHidingY;
1332 	double EffectiveLBLatencyHidingC;
1333 	double LinesInDETY[DML2_MAX_PLANES];
1334 	double LinesInDETC[DML2_MAX_PLANES];
1335 	unsigned int LinesInDETYRoundedDownToSwath[DML2_MAX_PLANES];
1336 	unsigned int LinesInDETCRoundedDownToSwath[DML2_MAX_PLANES];
1337 	double FullDETBufferingTimeY;
1338 	double FullDETBufferingTimeC;
1339 	double WritebackDRAMClockChangeLatencyMargin;
1340 	double WritebackFCLKChangeLatencyMargin;
1341 	double WritebackTempReadOrPptLatencyMargin;
1342 	double WritebackLatencyHiding;
1343 
1344 	unsigned int TotalActiveWriteback;
1345 	unsigned int LBLatencyHidingSourceLinesY[DML2_MAX_PLANES];
1346 	unsigned int LBLatencyHidingSourceLinesC[DML2_MAX_PLANES];
1347 	double TotalPixelBW;
1348 	double EffectiveDETBufferSizeY;
1349 	double ActiveClockChangeLatencyHidingY;
1350 	double ActiveClockChangeLatencyHidingC;
1351 	double ActiveClockChangeLatencyHiding;
1352 	double peak_vactive_p_vblank_latency_hiding_us;
1353 	unsigned int dst_y_pstate;
1354 	unsigned int src_y_pstate_l;
1355 	unsigned int src_y_pstate_c;
1356 	unsigned int src_y_ahead_l;
1357 	unsigned int src_y_ahead_c;
1358 	unsigned int sub_vp_lines_l;
1359 	unsigned int sub_vp_lines_c;
1360 
1361 };
1362 
1363 struct dml2_core_calcs_CalculateVMRowAndSwath_locals {
1364 	unsigned int PTEBufferSizeInRequestsForLuma[DML2_MAX_PLANES];
1365 	unsigned int PTEBufferSizeInRequestsForChroma[DML2_MAX_PLANES];
1366 	unsigned int vm_bytes_l;
1367 	unsigned int vm_bytes_c;
1368 	unsigned int PixelPTEBytesPerRowY[DML2_MAX_PLANES];
1369 	unsigned int PixelPTEBytesPerRowC[DML2_MAX_PLANES];
1370 	unsigned int PixelPTEBytesPerRowStorageY[DML2_MAX_PLANES];
1371 	unsigned int PixelPTEBytesPerRowStorageC[DML2_MAX_PLANES];
1372 	unsigned int PixelPTEBytesPerRowY_one_row_per_frame[DML2_MAX_PLANES];
1373 	unsigned int PixelPTEBytesPerRowC_one_row_per_frame[DML2_MAX_PLANES];
1374 	unsigned int dpte_row_width_luma_ub_one_row_per_frame[DML2_MAX_PLANES];
1375 	unsigned int dpte_row_height_luma_one_row_per_frame[DML2_MAX_PLANES];
1376 	unsigned int dpte_row_width_chroma_ub_one_row_per_frame[DML2_MAX_PLANES];
1377 	unsigned int dpte_row_height_chroma_one_row_per_frame[DML2_MAX_PLANES];
1378 	bool one_row_per_frame_fits_in_buffer[DML2_MAX_PLANES];
1379 	unsigned int HostVMDynamicLevels;
1380 	unsigned int meta_row_bytes_per_row_ub_l[DML2_MAX_PLANES];
1381 	unsigned int meta_row_bytes_per_row_ub_c[DML2_MAX_PLANES];
1382 };
1383 
1384 struct dml2_core_calcs_CalculateVMRowAndSwath_params {
1385 	const struct dml2_display_cfg *display_cfg;
1386 	unsigned int NumberOfActiveSurfaces;
1387 	struct dml2_core_internal_DmlPipe *myPipe;
1388 	unsigned int *SurfaceSizeInMALL;
1389 	unsigned int PTEBufferSizeInRequestsLuma;
1390 	unsigned int PTEBufferSizeInRequestsChroma;
1391 	unsigned int MALLAllocatedForDCN;
1392 	unsigned int *SwathWidthY;
1393 	unsigned int *SwathWidthC;
1394 	unsigned int HostVMMinPageSize;
1395 	unsigned int DCCMetaBufferSizeBytes;
1396 	bool mrq_present;
1397 	enum dml2_pstate_method *uclk_pstate_switch_modes;
1398 
1399 	// Output
1400 	bool *PTEBufferSizeNotExceeded;
1401 	bool *DCCMetaBufferSizeNotExceeded;
1402 
1403 	unsigned int *dpte_row_width_luma_ub;
1404 	unsigned int *dpte_row_width_chroma_ub;
1405 	unsigned int *dpte_row_height_luma;
1406 	unsigned int *dpte_row_height_chroma;
1407 	unsigned int *dpte_row_height_linear_luma; // VBA_DELTA
1408 	unsigned int *dpte_row_height_linear_chroma; // VBA_DELTA
1409 
1410 	unsigned int *vm_group_bytes;
1411 	unsigned int *dpte_group_bytes;
1412 	unsigned int *PixelPTEReqWidthY;
1413 	unsigned int *PixelPTEReqHeightY;
1414 	unsigned int *PTERequestSizeY;
1415 	unsigned int *vmpg_width_y;
1416 	unsigned int *vmpg_height_y;
1417 
1418 	unsigned int *PixelPTEReqWidthC;
1419 	unsigned int *PixelPTEReqHeightC;
1420 	unsigned int *PTERequestSizeC;
1421 	unsigned int *vmpg_width_c;
1422 	unsigned int *vmpg_height_c;
1423 
1424 	unsigned int *dpde0_bytes_per_frame_ub_l;
1425 	unsigned int *dpde0_bytes_per_frame_ub_c;
1426 
1427 	unsigned int *PrefetchSourceLinesY;
1428 	unsigned int *PrefetchSourceLinesC;
1429 	unsigned int *VInitPreFillY;
1430 	unsigned int *VInitPreFillC;
1431 	unsigned int *MaxNumSwathY;
1432 	unsigned int *MaxNumSwathC;
1433 	double *dpte_row_bw;
1434 	unsigned int *PixelPTEBytesPerRow;
1435 	unsigned int *dpte_row_bytes_per_row_l;
1436 	unsigned int *dpte_row_bytes_per_row_c;
1437 	unsigned int *vm_bytes;
1438 	bool *use_one_row_for_frame;
1439 	bool *use_one_row_for_frame_flip;
1440 	bool *is_using_mall_for_ss;
1441 	bool *PTE_BUFFER_MODE;
1442 	unsigned int *BIGK_FRAGMENT_SIZE;
1443 
1444 	// MRQ
1445 	unsigned int *meta_req_width_luma;
1446 	unsigned int *meta_req_height_luma;
1447 	unsigned int *meta_row_width_luma;
1448 	unsigned int *meta_row_height_luma;
1449 	unsigned int *meta_pte_bytes_per_frame_ub_l;
1450 
1451 	unsigned int *meta_req_width_chroma;
1452 	unsigned int *meta_req_height_chroma;
1453 	unsigned int *meta_row_width_chroma;
1454 	unsigned int *meta_row_height_chroma;
1455 	unsigned int *meta_pte_bytes_per_frame_ub_c;
1456 	double *meta_row_bw;
1457 	unsigned int *meta_row_bytes;
1458 	unsigned int *meta_row_bytes_per_row_ub_l;
1459 	unsigned int *meta_row_bytes_per_row_ub_c;
1460 };
1461 
1462 struct dml2_core_calcs_CalculatePrefetchSchedule_locals {
1463 	bool NoTimeToPrefetch;
1464 	unsigned int DPPCycles;
1465 	unsigned int DISPCLKCycles;
1466 	double DSTTotalPixelsAfterScaler;
1467 	double LineTime;
1468 	double dst_y_prefetch_equ;
1469 	double prefetch_bw_oto;
1470 	double per_pipe_vactive_sw_bw;
1471 	double Tvm_oto;
1472 	double Tr0_oto;
1473 	double Tvm_oto_lines;
1474 	double Tr0_oto_lines;
1475 	double dst_y_prefetch_oto;
1476 	double TimeForFetchingVM;
1477 	double TimeForFetchingRowInVBlank;
1478 	double LinesToRequestPrefetchPixelData;
1479 	unsigned int HostVMDynamicLevelsTrips;
1480 	double trip_to_mem;
1481 	double Tvm_trips_rounded;
1482 	double Tr0_trips_rounded;
1483 	double max_Tsw;
1484 	double Lsw_oto;
1485 	double prefetch_bw_equ;
1486 	double Tvm_equ;
1487 	double Tr0_equ;
1488 	double Tdmbf;
1489 	double Tdmec;
1490 	double Tdmsks;
1491 	double total_row_bytes;
1492 	double prefetch_bw_pr;
1493 	double bytes_pp;
1494 	double dep_bytes;
1495 	double min_Lsw_oto;
1496 	double min_Lsw_equ;
1497 	double Tsw_est1;
1498 	double Tsw_est2;
1499 	double Tsw_est3;
1500 	double prefetch_bw1;
1501 	double prefetch_bw2;
1502 	double prefetch_bw3;
1503 	double prefetch_bw4;
1504 	double dst_y_prefetch_equ_impacted;
1505 
1506 	double TWait_p;
1507 	unsigned int cursor_prefetch_bytes;
1508 };
1509 
1510 struct dml2_core_shared_calculate_det_buffer_size_params {
1511 	const struct dml2_display_cfg *display_cfg;
1512 	bool ForceSingleDPP;
1513 	unsigned int NumberOfActiveSurfaces;
1514 	bool UnboundedRequestEnabled;
1515 	unsigned int nomDETInKByte;
1516 	unsigned int MaxTotalDETInKByte;
1517 	unsigned int ConfigReturnBufferSizeInKByte;
1518 	unsigned int MinCompressedBufferSizeInKByte;
1519 	unsigned int ConfigReturnBufferSegmentSizeInkByte;
1520 	unsigned int CompressedBufferSegmentSizeInkByte;
1521 	double *ReadBandwidthLuma;
1522 	double *ReadBandwidthChroma;
1523 	unsigned int *full_swath_bytes_l;
1524 	unsigned int *full_swath_bytes_c;
1525 	unsigned int *swath_time_value_us;
1526 	unsigned int *DPPPerSurface;
1527 	bool TryToAllocateForWriteLatency;
1528 	unsigned int bestEffortMinActiveLatencyHidingUs;
1529 
1530 	// Output
1531 	unsigned int *DETBufferSizeInKByte;
1532 	unsigned int *CompressedBufferSizeInkByte;
1533 };
1534 
1535 struct dml2_core_shared_calculate_vm_and_row_bytes_params {
1536 	bool ViewportStationary;
1537 	bool DCCEnable;
1538 	unsigned int NumberOfDPPs;
1539 	unsigned int BlockHeight256Bytes;
1540 	unsigned int BlockWidth256Bytes;
1541 	enum dml2_source_format_class SourcePixelFormat;
1542 	unsigned int SurfaceTiling;
1543 	unsigned int BytePerPixel;
1544 	enum dml2_rotation_angle RotationAngle;
1545 	unsigned int SwathWidth; // per pipe
1546 	unsigned int ViewportHeight;
1547 	unsigned int ViewportXStart;
1548 	unsigned int ViewportYStart;
1549 	bool GPUVMEnable;
1550 	unsigned int GPUVMMaxPageTableLevels;
1551 	unsigned int GPUVMMinPageSizeKBytes;
1552 	unsigned int PTEBufferSizeInRequests;
1553 	unsigned int Pitch;
1554 	unsigned int MacroTileWidth;
1555 	unsigned int MacroTileHeight;
1556 	bool is_phantom;
1557 	unsigned int DCCMetaPitch;
1558 	bool mrq_present;
1559 
1560 	// Output
1561 	unsigned int *PixelPTEBytesPerRow; // for bandwidth calculation
1562 	unsigned int *PixelPTEBytesPerRowStorage; // for PTE buffer size check
1563 	unsigned int *dpte_row_width_ub;
1564 	unsigned int *dpte_row_height;
1565 	unsigned int *dpte_row_height_linear;
1566 	unsigned int *PixelPTEBytesPerRow_one_row_per_frame;
1567 	unsigned int *dpte_row_width_ub_one_row_per_frame;
1568 	unsigned int *dpte_row_height_one_row_per_frame;
1569 	unsigned int *vmpg_width;
1570 	unsigned int *vmpg_height;
1571 	unsigned int *PixelPTEReqWidth;
1572 	unsigned int *PixelPTEReqHeight;
1573 	unsigned int *PTERequestSize;
1574 	unsigned int *dpde0_bytes_per_frame_ub;
1575 
1576 	unsigned int *meta_row_bytes;
1577 	unsigned int *MetaRequestWidth;
1578 	unsigned int *MetaRequestHeight;
1579 	unsigned int *meta_row_width;
1580 	unsigned int *meta_row_height;
1581 	unsigned int *meta_pte_bytes_per_frame_ub;
1582 };
1583 
1584 struct dml2_core_shared_CalculateSwathAndDETConfiguration_locals {
1585 	unsigned int MaximumSwathHeightY[DML2_MAX_PLANES];
1586 	unsigned int MaximumSwathHeightC[DML2_MAX_PLANES];
1587 	unsigned int RoundedUpSwathSizeBytesY[DML2_MAX_PLANES];
1588 	unsigned int RoundedUpSwathSizeBytesC[DML2_MAX_PLANES];
1589 	unsigned int SwathWidthSingleDPP[DML2_MAX_PLANES];
1590 	unsigned int SwathWidthSingleDPPChroma[DML2_MAX_PLANES];
1591 	unsigned int SwathTimeValueUs[DML2_MAX_PLANES];
1592 
1593 	struct dml2_core_shared_calculate_det_buffer_size_params calculate_det_buffer_size_params;
1594 };
1595 
1596 struct dml2_core_shared_TruncToValidBPP_locals {
1597 	struct lib_frl_cap_check_params hdmifrlparams;
1598 	struct lib_frl_cap_check_intermediates hdmifrlinter;
1599 };
1600 
1601 struct dml2_core_shared_CalculateDETBufferSize_locals {
1602 	unsigned int DETBufferSizePoolInKByte;
1603 	unsigned int NextDETBufferPieceInKByte;
1604 	unsigned int NextSurfaceToAssignDETPiece;
1605 	double TotalBandwidth;
1606 	double BandwidthOfSurfacesNotAssignedDETPiece;
1607 	unsigned int max_minDET;
1608 	unsigned int minDET;
1609 	unsigned int minDET_pipe;
1610 	unsigned int TotalBandwidthPerStream[DML2_MAX_PLANES];
1611 	unsigned int TotalPixelRate;
1612 	unsigned int DETBudgetPerStream[DML2_MAX_PLANES];
1613 	unsigned int RemainingDETBudgetPerStream[DML2_MAX_PLANES];
1614 	unsigned int IdealDETBudget, DeltaDETBudget;
1615 	unsigned int ResidualDETAfterRounding;
1616 };
1617 
1618 struct dml2_core_shared_get_urgent_bandwidth_required_locals {
1619 	double required_bandwidth_mbps;
1620 	double required_bandwidth_mbps_this_surface;
1621 	double adj_factor_p0;
1622 	double adj_factor_p1;
1623 	double adj_factor_cur;
1624 	double adj_factor_p0_pre;
1625 	double adj_factor_p1_pre;
1626 	double adj_factor_cur_pre;
1627 	double per_plane_flip_bw[DML2_MAX_PLANES];
1628 	double mall_svp_prefetch_factor;
1629 	double tmp_nom_adj_factor_p0;
1630 	double tmp_nom_adj_factor_p1;
1631 	double tmp_pref_adj_factor_p0;
1632 	double tmp_pref_adj_factor_p1;
1633 	double vm_row_bw;
1634 	double flip_and_active_bw;
1635 	double flip_and_prefetch_bw;
1636 	double flip_and_prefetch_bw_max;
1637 	double active_and_excess_bw;
1638 };
1639 
1640 struct dml2_core_shared_calculate_peak_bandwidth_required_locals {
1641 	double unity_array[DML2_MAX_PLANES];
1642 	double zero_array[DML2_MAX_PLANES];
1643 	double surface_dummy_bw[DML2_MAX_PLANES];
1644 };
1645 
1646 struct dml2_core_shared_CalculateFlipSchedule_locals {
1647 	double min_row_time;
1648 	double Tvm_flip;
1649 	double Tr0_flip;
1650 	double ImmediateFlipBW;
1651 	double dpte_row_bytes;
1652 	double min_row_height;
1653 	double min_row_height_chroma;
1654 	double max_flip_time;
1655 	double lb_flip_bw;
1656 	double hvm_scaled_vm_bytes;
1657 	double num_rows;
1658 	double hvm_scaled_row_bytes;
1659 	double hvm_scaled_vm_row_bytes;
1660 	bool dual_plane;
1661 };
1662 
1663 struct dml2_core_shared_rq_dlg_get_dlg_reg_locals {
1664 	unsigned int plane_idx;
1665 	unsigned int stream_idx;
1666 	enum dml2_source_format_class source_format;
1667 	const struct dml2_timing_cfg *timing;
1668 	bool dual_plane;
1669 	enum dml2_odm_mode odm_mode;
1670 
1671 	unsigned int htotal;
1672 	unsigned int hactive;
1673 	unsigned int hblank_end;
1674 	unsigned int vblank_end;
1675 	bool interlaced;
1676 	double pclk_freq_in_mhz;
1677 	double refclk_freq_in_mhz;
1678 	double ref_freq_to_pix_freq;
1679 
1680 	unsigned int num_active_pipes;
1681 	unsigned int first_pipe_idx_in_plane;
1682 	unsigned int pipe_idx_in_combine;
1683 	unsigned int odm_combine_factor;
1684 
1685 	double min_ttu_vblank;
1686 	unsigned int min_dst_y_next_start;
1687 
1688 	unsigned int vready_after_vcount0;
1689 
1690 	unsigned int dst_x_after_scaler;
1691 	unsigned int dst_y_after_scaler;
1692 
1693 	double dst_y_prefetch;
1694 	double dst_y_per_vm_vblank;
1695 	double dst_y_per_row_vblank;
1696 	double dst_y_per_vm_flip;
1697 	double dst_y_per_row_flip;
1698 
1699 	double max_dst_y_per_vm_vblank;
1700 	double max_dst_y_per_row_vblank;
1701 
1702 	double vratio_pre_l;
1703 	double vratio_pre_c;
1704 
1705 	double refcyc_per_line_delivery_pre_l;
1706 	double refcyc_per_line_delivery_l;
1707 
1708 	double refcyc_per_line_delivery_pre_c;
1709 	double refcyc_per_line_delivery_c;
1710 
1711 	double refcyc_per_req_delivery_pre_l;
1712 	double refcyc_per_req_delivery_l;
1713 
1714 	double refcyc_per_req_delivery_pre_c;
1715 	double refcyc_per_req_delivery_c;
1716 
1717 	double dst_y_per_pte_row_nom_l;
1718 	double dst_y_per_pte_row_nom_c;
1719 	double refcyc_per_pte_group_nom_l;
1720 	double refcyc_per_pte_group_nom_c;
1721 	double refcyc_per_pte_group_vblank_l;
1722 	double refcyc_per_pte_group_vblank_c;
1723 	double refcyc_per_pte_group_flip_l;
1724 	double refcyc_per_pte_group_flip_c;
1725 	double refcyc_per_tdlut_group;
1726 
1727 	double dst_y_per_meta_row_nom_l;
1728 	double dst_y_per_meta_row_nom_c;
1729 	double refcyc_per_meta_chunk_nom_l;
1730 	double refcyc_per_meta_chunk_nom_c;
1731 	double refcyc_per_meta_chunk_vblank_l;
1732 	double refcyc_per_meta_chunk_vblank_c;
1733 	double refcyc_per_meta_chunk_flip_l;
1734 	double refcyc_per_meta_chunk_flip_c;
1735 };
1736 
1737 struct dml2_core_shared_CalculateMetaAndPTETimes_params {
1738 	struct dml2_core_internal_scratch *scratch;
1739 	const struct dml2_display_cfg *display_cfg;
1740 	unsigned int NumberOfActiveSurfaces;
1741 	bool *use_one_row_for_frame;
1742 	double *dst_y_per_row_vblank;
1743 	double *dst_y_per_row_flip;
1744 	unsigned int *BytePerPixelY;
1745 	unsigned int *BytePerPixelC;
1746 	unsigned int *dpte_row_height;
1747 	unsigned int *dpte_row_height_chroma;
1748 	unsigned int *dpte_group_bytes;
1749 	unsigned int *PTERequestSizeY;
1750 	unsigned int *PTERequestSizeC;
1751 	unsigned int *PixelPTEReqWidthY;
1752 	unsigned int *PixelPTEReqHeightY;
1753 	unsigned int *PixelPTEReqWidthC;
1754 	unsigned int *PixelPTEReqHeightC;
1755 	unsigned int *dpte_row_width_luma_ub;
1756 	unsigned int *dpte_row_width_chroma_ub;
1757 	unsigned int *tdlut_groups_per_2row_ub;
1758 	bool mrq_present;
1759 	unsigned int MetaChunkSize;
1760 	unsigned int MinMetaChunkSizeBytes;
1761 	unsigned int *meta_row_width;
1762 	unsigned int *meta_row_width_chroma;
1763 	unsigned int *meta_row_height;
1764 	unsigned int *meta_row_height_chroma;
1765 	unsigned int *meta_req_width;
1766 	unsigned int *meta_req_width_chroma;
1767 	unsigned int *meta_req_height;
1768 	unsigned int *meta_req_height_chroma;
1769 
1770 	// Output
1771 	double *time_per_tdlut_group;
1772 	double *DST_Y_PER_PTE_ROW_NOM_L;
1773 	double *DST_Y_PER_PTE_ROW_NOM_C;
1774 	double *time_per_pte_group_nom_luma;
1775 	double *time_per_pte_group_vblank_luma;
1776 	double *time_per_pte_group_flip_luma;
1777 	double *time_per_pte_group_nom_chroma;
1778 	double *time_per_pte_group_vblank_chroma;
1779 	double *time_per_pte_group_flip_chroma;
1780 
1781 	double *DST_Y_PER_META_ROW_NOM_L;
1782 	double *DST_Y_PER_META_ROW_NOM_C;
1783 
1784 	double *TimePerMetaChunkNominal;
1785 	double *TimePerChromaMetaChunkNominal;
1786 	double *TimePerMetaChunkVBlank;
1787 	double *TimePerChromaMetaChunkVBlank;
1788 	double *TimePerMetaChunkFlip;
1789 	double *TimePerChromaMetaChunkFlip;
1790 };
1791 
1792 struct dml2_core_calcs_CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_params {
1793 	const struct dml2_display_cfg *display_cfg;
1794 	bool USRRetrainingRequired;
1795 	unsigned int NumberOfActiveSurfaces;
1796 	unsigned int MaxLineBufferLines;
1797 	unsigned int LineBufferSize;
1798 	unsigned int WritebackInterfaceBufferSize;
1799 	double DCFCLK;
1800 	double ReturnBW;
1801 	bool SynchronizeTimings;
1802 	bool SynchronizeDRRDisplaysForUCLKPStateChange;
1803 	const unsigned int *dpte_group_bytes;
1804 	struct dml2_core_internal_SOCParametersList mmSOCParameters;
1805 	unsigned int WritebackChunkSize;
1806 	double SOCCLK;
1807 	double DCFClkDeepSleep;
1808 	const unsigned int *DETBufferSizeY;
1809 	const unsigned int *DETBufferSizeC;
1810 	const unsigned int *SwathHeightY;
1811 	const unsigned int *SwathHeightC;
1812 	const unsigned int *SwathWidthY;
1813 	const unsigned int *SwathWidthC;
1814 	const unsigned int *DPPPerSurface;
1815 	const double *BytePerPixelDETY;
1816 	const double *BytePerPixelDETC;
1817 	const unsigned int *DSTXAfterScaler;
1818 	const unsigned int *DSTYAfterScaler;
1819 	bool UnboundedRequestEnabled;
1820 	unsigned int CompressedBufferSizeInkByte;
1821 	bool max_outstanding_when_urgent_expected;
1822 	unsigned int max_outstanding_requests;
1823 	unsigned int max_request_size_bytes;
1824 	const unsigned int *meta_row_height_l;
1825 	const unsigned int *meta_row_height_c;
1826 	const enum dml2_pstate_method *uclk_pstate_switch_modes;
1827 
1828 	// Output
1829 	struct dml2_core_internal_watermarks *Watermark;
1830 	enum dml2_pstate_change_support *DRAMClockChangeSupport;
1831 	bool *global_dram_clock_change_support_required;
1832 	bool *global_dram_clock_change_supported;
1833 	double *MaxActiveDRAMClockChangeLatencySupported;
1834 	unsigned int *SubViewportLinesNeededInMALL;
1835 	enum dml2_pstate_change_support *FCLKChangeSupport;
1836 	bool *global_fclk_change_supported;
1837 	double *MaxActiveFCLKChangeLatencySupported;
1838 	bool *USRRetrainingSupport;
1839 	double *VActiveLatencyHidingMargin;
1840 	double *VActiveLatencyHidingUs;
1841 	bool *g6_temp_read_support;
1842 	enum dml2_pstate_change_support *temp_read_or_ppt_support;
1843 	bool *global_temp_read_or_ppt_supported;
1844 };
1845 
1846 struct dml2_core_calcs_CalculateSwathAndDETConfiguration_params {
1847 	const struct dml2_display_cfg *display_cfg;
1848 	unsigned int ConfigReturnBufferSizeInKByte;
1849 	unsigned int MaxTotalDETInKByte;
1850 	unsigned int MinCompressedBufferSizeInKByte;
1851 	unsigned int rob_buffer_size_kbytes;
1852 	unsigned int pixel_chunk_size_kbytes;
1853 	bool ForceSingleDPP;
1854 	unsigned int NumberOfActiveSurfaces;
1855 	unsigned int nomDETInKByte;
1856 	unsigned int ConfigReturnBufferSegmentSizeInkByte;
1857 	unsigned int CompressedBufferSegmentSizeInkByte;
1858 	double *ReadBandwidthLuma;
1859 	double *ReadBandwidthChroma;
1860 	double *MaximumSwathWidthLuma;
1861 	double *MaximumSwathWidthChroma;
1862 	unsigned int *Read256BytesBlockHeightY;
1863 	unsigned int *Read256BytesBlockHeightC;
1864 	unsigned int *Read256BytesBlockWidthY;
1865 	unsigned int *Read256BytesBlockWidthC;
1866 	bool *surf_linear128_l;
1867 	bool *surf_linear128_c;
1868 	enum dml2_odm_mode *ODMMode;
1869 	unsigned int *BytePerPixY;
1870 	unsigned int *BytePerPixC;
1871 	double *BytePerPixDETY;
1872 	double *BytePerPixDETC;
1873 	unsigned int *DPPPerSurface;
1874 	bool mrq_present;
1875 	unsigned int dummy[2][DML2_MAX_PLANES];
1876 	unsigned int swath_width_luma_ub_single_dpp[DML2_MAX_PLANES];
1877 	unsigned int swath_width_chroma_ub_single_dpp[DML2_MAX_PLANES];
1878 
1879 	// output
1880 	unsigned int *req_per_swath_ub_l;
1881 	unsigned int *req_per_swath_ub_c;
1882 	unsigned int *swath_width_luma_ub;
1883 	unsigned int *swath_width_chroma_ub;
1884 	unsigned int *SwathWidth;
1885 	unsigned int *SwathWidthChroma;
1886 	unsigned int *SwathHeightY;
1887 	unsigned int *SwathHeightC;
1888 	unsigned int *request_size_bytes_luma;
1889 	unsigned int *request_size_bytes_chroma;
1890 	unsigned int *DETBufferSizeInKByte;
1891 	unsigned int *DETBufferSizeY;
1892 	unsigned int *DETBufferSizeC;
1893 	unsigned int *full_swath_bytes_l;
1894 	unsigned int *full_swath_bytes_c;
1895 	unsigned int *full_swath_bytes_single_dpp_l;
1896 	unsigned int *full_swath_bytes_single_dpp_c;
1897 	bool *UnboundedRequestEnabled;
1898 	unsigned int *compbuf_reserved_space_64b;
1899 	unsigned int *CompressedBufferSizeInkByte;
1900 	bool *ViewportSizeSupportPerSurface;
1901 	bool *ViewportSizeSupport;
1902 	bool *hw_debug5;
1903 
1904 	struct dml2_core_shared_calculation_funcs *funcs;
1905 };
1906 
1907 struct dml2_core_calcs_CalculateStutterEfficiency_locals {
1908 	double DETBufferingTimeY;
1909 	double SwathWidthYCriticalSurface;
1910 	double SwathHeightYCriticalSurface;
1911 	double VActiveTimeCriticalSurface;
1912 	double FrameTimeCriticalSurface;
1913 	unsigned int BytePerPixelYCriticalSurface;
1914 	unsigned int DETBufferSizeYCriticalSurface;
1915 	double MinTTUVBlankCriticalSurface;
1916 	unsigned int BlockWidth256BytesYCriticalSurface;
1917 	bool SinglePlaneCriticalSurface;
1918 	bool SinglePipeCriticalSurface;
1919 	double TotalCompressedReadBandwidth;
1920 	double TotalRowReadBandwidth;
1921 	double AverageDCCCompressionRate;
1922 	double EffectiveCompressedBufferSize;
1923 	double PartOfUncompressedPixelBurstThatFitsInROBAndCompressedBuffer;
1924 	double StutterBurstTime;
1925 	unsigned int TotalActiveWriteback;
1926 	double LinesInDETY;
1927 	double LinesInDETYRoundedDownToSwath;
1928 	double MaximumEffectiveCompressionLuma;
1929 	double MaximumEffectiveCompressionChroma;
1930 	double TotalZeroSizeRequestReadBandwidth;
1931 	double TotalZeroSizeCompressedReadBandwidth;
1932 	double AverageDCCZeroSizeFraction;
1933 	double AverageZeroSizeCompressionRate;
1934 	bool stream_visited[DML2_MAX_PLANES];
1935 };
1936 
1937 struct dml2_core_calcs_CalculateStutterEfficiency_params {
1938 	const struct dml2_display_cfg *display_cfg;
1939 	unsigned int CompressedBufferSizeInkByte;
1940 	bool UnboundedRequestEnabled;
1941 	unsigned int MetaFIFOSizeInKEntries;
1942 	unsigned int ZeroSizeBufferEntries;
1943 	unsigned int PixelChunkSizeInKByte;
1944 	unsigned int NumberOfActiveSurfaces;
1945 	unsigned int ROBBufferSizeInKByte;
1946 	double TotalDataReadBandwidth;
1947 	double DCFCLK;
1948 	double ReturnBW;
1949 	unsigned int CompbufReservedSpace64B;
1950 	unsigned int CompbufReservedSpaceZs;
1951 	bool hw_debug5;
1952 	double SRExitTime;
1953 	double SRExitTimeLowPower;
1954 	double SRExitZ8Time;
1955 	bool SynchronizeTimings;
1956 	double StutterEnterPlusExitWatermark;
1957 	double LowPowerStutterEnterPlusExitWatermark;
1958 	double Z8StutterEnterPlusExitWatermark;
1959 	bool ProgressiveToInterlaceUnitInOPP;
1960 	double *MinTTUVBlank;
1961 	unsigned int *DPPPerSurface;
1962 	unsigned int *DETBufferSizeY;
1963 	unsigned int *BytePerPixelY;
1964 	double *BytePerPixelDETY;
1965 	unsigned int *SwathWidthY;
1966 	unsigned int *SwathHeightY;
1967 	unsigned int *SwathHeightC;
1968 	unsigned int *BlockHeight256BytesY;
1969 	unsigned int *BlockWidth256BytesY;
1970 	unsigned int *BlockHeight256BytesC;
1971 	unsigned int *BlockWidth256BytesC;
1972 	unsigned int *DCCYMaxUncompressedBlock;
1973 	unsigned int *DCCCMaxUncompressedBlock;
1974 	double *ReadBandwidthSurfaceLuma;
1975 	double *ReadBandwidthSurfaceChroma;
1976 	double *meta_row_bw;
1977 	double *dpte_row_bw;
1978 	bool rob_alloc_compressed;
1979 
1980 	// output
1981 	double *StutterEfficiencyNotIncludingVBlank;
1982 	double *StutterEfficiency;
1983 	double *LowPowerStutterEfficiencyNotIncludingVBlank;
1984 	double *LowPowerStutterEfficiency;
1985 	unsigned int *NumberOfStutterBurstsPerFrame;
1986 	unsigned int *LowPowerNumberOfStutterBurstsPerFrame;
1987 	double *Z8StutterEfficiencyNotIncludingVBlank;
1988 	double *Z8StutterEfficiency;
1989 	unsigned int *Z8NumberOfStutterBurstsPerFrame;
1990 	double *StutterPeriod;
1991 	bool *DCHUBBUB_ARB_CSTATE_MAX_CAP_MODE;
1992 };
1993 
1994 struct dml2_core_calcs_CalculatePrefetchSchedule_params {
1995 	const struct dml2_display_cfg *display_cfg;
1996 	double HostVMInefficiencyFactor;
1997 	struct dml2_core_internal_DmlPipe *myPipe;
1998 	unsigned int DSCDelay;
1999 	double DPPCLKDelaySubtotalPlusCNVCFormater;
2000 	double DPPCLKDelaySCL;
2001 	double DPPCLKDelaySCLLBOnly;
2002 	double DPPCLKDelayCNVCCursor;
2003 	double DISPCLKDelaySubtotal;
2004 	unsigned int DPP_RECOUT_WIDTH;
2005 	enum dml2_output_format_class OutputFormat;
2006 	unsigned int MaxInterDCNTileRepeaters;
2007 	unsigned int VStartup;
2008 	unsigned int HostVMMinPageSize;
2009 	bool DynamicMetadataEnable;
2010 	bool DynamicMetadataVMEnabled;
2011 	unsigned int DynamicMetadataLinesBeforeActiveRequired;
2012 	unsigned int DynamicMetadataTransmittedBytes;
2013 	double ExtraLatencyPrefetch;
2014 	double TCalc;
2015 	unsigned int vm_bytes;
2016 	unsigned int PixelPTEBytesPerRow;
2017 	double PrefetchSourceLinesY;
2018 	unsigned int VInitPreFillY;
2019 	unsigned int MaxNumSwathY;
2020 	double PrefetchSourceLinesC;
2021 	unsigned int VInitPreFillC;
2022 	unsigned int MaxNumSwathC;
2023 	unsigned int swath_width_luma_ub;  // per-pipe
2024 	unsigned int swath_width_chroma_ub; // per-pipe
2025 	unsigned int SwathHeightY;
2026 	unsigned int SwathHeightC;
2027 	double TWait;
2028 	double Ttrip;
2029 	double Turg;
2030 	bool setup_for_tdlut;
2031 	bool use_max_lsw;
2032 	unsigned int tdlut_pte_bytes_per_frame;
2033 	unsigned int tdlut_bytes_per_frame;
2034 	double tdlut_opt_time;
2035 	double tdlut_drain_time;
2036 
2037 	unsigned int num_cursors;
2038 	unsigned int cursor_bytes_per_chunk;
2039 	unsigned int cursor_bytes_per_line;
2040 
2041 	// MRQ
2042 	bool dcc_enable;
2043 	bool mrq_present;
2044 	unsigned int meta_row_bytes;
2045 	double mall_prefetch_sdp_overhead_factor;
2046 
2047 	double impacted_dst_y_pre;
2048 	double vactive_sw_bw_l; // per surface bw
2049 	double vactive_sw_bw_c; // per surface bw
2050 
2051 	// output
2052 	unsigned int *DSTXAfterScaler;
2053 	unsigned int *DSTYAfterScaler;
2054 	double *dst_y_prefetch;
2055 	double *dst_y_per_vm_vblank;
2056 	double *dst_y_per_row_vblank;
2057 	double *VRatioPrefetchY;
2058 	double *VRatioPrefetchC;
2059 	double *RequiredPrefetchPixelDataBWLuma;
2060 	double *RequiredPrefetchPixelDataBWChroma;
2061 	double *RequiredPrefetchBWMax;
2062 	bool *NotEnoughTimeForDynamicMetadata;
2063 	double *Tno_bw;
2064 	double *Tno_bw_flip;
2065 	double *prefetch_vmrow_bw;
2066 	double *Tdmdl_vm;
2067 	double *Tdmdl;
2068 	double *TSetup;
2069 	double *Tpre_rounded;
2070 	double *Tpre_oto;
2071 	double *Tvm_trips;
2072 	double *Tr0_trips;
2073 	double *Tvm_trips_flip;
2074 	double *Tr0_trips_flip;
2075 	double *Tvm_trips_flip_rounded;
2076 	double *Tr0_trips_flip_rounded;
2077 	unsigned int *VUpdateOffsetPix;
2078 	unsigned int *VUpdateWidthPix;
2079 	unsigned int *VReadyOffsetPix;
2080 	double *prefetch_cursor_bw;
2081 	double *prefetch_sw_bytes;
2082 	double *prefetch_swath_time_us;
2083 };
2084 
2085 struct dml2_core_calcs_CheckGlobalPrefetchAdmissibility_params {
2086 	unsigned int num_active_planes;
2087 	enum dml2_source_format_class *pixel_format;
2088 	unsigned int rob_buffer_size_kbytes;
2089 	unsigned int compressed_buffer_size_kbytes;
2090 	unsigned int chunk_bytes_l; // same for all planes
2091 	unsigned int chunk_bytes_c;
2092 	unsigned int *detile_buffer_size_bytes_l;
2093 	unsigned int *detile_buffer_size_bytes_c;
2094 	unsigned int *full_swath_bytes_l;
2095 	unsigned int *full_swath_bytes_c;
2096 	unsigned int *lb_source_lines_l;
2097 	unsigned int *lb_source_lines_c;
2098 	unsigned int *swath_height_l;
2099 	unsigned int *swath_height_c;
2100 	double *prefetch_sw_bytes;
2101 	double *Tpre_rounded;
2102 	double *Tpre_oto;
2103 	double estimated_dcfclk_mhz;
2104 	double estimated_urg_bandwidth_required_mbps;
2105 	double *line_time;
2106 	double *dst_y_prefetch;
2107 
2108 	// output
2109 	bool *recalc_prefetch_schedule;
2110 	double *impacted_dst_y_pre;
2111 };
2112 
2113 struct dml2_core_calcs_CheckGlobalPrefetchAdmissibility_locals {
2114 	unsigned int max_Trpd_dcfclk_cycles;
2115 	unsigned int burst_bytes_to_fill_det;
2116 	double time_to_fill_det_us;
2117 	unsigned int accumulated_return_path_dcfclk_cycles[DML2_MAX_PLANES];
2118 	bool prefetch_global_check_passed;
2119 	unsigned int src_swath_bytes_l[DML2_MAX_PLANES];
2120 	unsigned int src_swath_bytes_c[DML2_MAX_PLANES];
2121 	unsigned int src_detile_buf_size_bytes_l[DML2_MAX_PLANES];
2122 	unsigned int src_detile_buf_size_bytes_c[DML2_MAX_PLANES];
2123 };
2124 
2125 struct dml2_core_calcs_calculate_mcache_row_bytes_params {
2126 	unsigned int num_chans;
2127 	unsigned int mem_word_bytes;
2128 	unsigned int mcache_size_bytes;
2129 	unsigned int mcache_line_size_bytes;
2130 	unsigned int gpuvm_enable;
2131 	unsigned int gpuvm_page_size_kbytes;
2132 
2133 	//enum dml_rotation_angle rotation_angle;
2134 	bool surf_vert;
2135 	unsigned int vp_stationary;
2136 	unsigned int tiling_mode;
2137 	bool imall_enable;
2138 
2139 	unsigned int vp_start_x;
2140 	unsigned int vp_start_y;
2141 	unsigned int full_vp_width;
2142 	unsigned int full_vp_height;
2143 	unsigned int blk_width;
2144 	unsigned int blk_height;
2145 	unsigned int vmpg_width;
2146 	unsigned int vmpg_height;
2147 	unsigned int full_swath_bytes;
2148 	unsigned int bytes_per_pixel;
2149 
2150 	// output
2151 	unsigned int *num_mcaches;
2152 	unsigned int *mcache_row_bytes;
2153 	unsigned int *mcache_row_bytes_per_channel;
2154 	unsigned int *meta_row_width_ub;
2155 	double *dcc_dram_bw_nom_overhead_factor;
2156 	double *dcc_dram_bw_pref_overhead_factor;
2157 	unsigned int *mvmpg_width;
2158 	unsigned int *mvmpg_height;
2159 	unsigned int *full_vp_access_width_mvmpg_aligned;
2160 	unsigned int *mvmpg_per_mcache_lb;
2161 };
2162 
2163 struct dml2_core_shared_calculate_mcache_setting_locals {
2164 	struct dml2_core_calcs_calculate_mcache_row_bytes_params l_p;
2165 	struct dml2_core_calcs_calculate_mcache_row_bytes_params c_p;
2166 
2167 	bool is_dual_plane;
2168 	unsigned int mvmpg_width_l;
2169 	unsigned int mvmpg_height_l;
2170 	unsigned int full_vp_access_width_mvmpg_aligned_l;
2171 	unsigned int mvmpg_per_mcache_lb_l;
2172 	unsigned int meta_row_width_l;
2173 
2174 	unsigned int mvmpg_width_c;
2175 	unsigned int mvmpg_height_c;
2176 	unsigned int full_vp_access_width_mvmpg_aligned_c;
2177 	unsigned int mvmpg_per_mcache_lb_c;
2178 	unsigned int meta_row_width_c;
2179 
2180 	unsigned int lc_comb_last_mcache_size;
2181 	double luma_time_factor;
2182 	double mcache_remainder_l;
2183 	double mcache_remainder_c;
2184 	unsigned int mvmpg_access_width_l;
2185 	unsigned int mvmpg_access_width_c;
2186 	unsigned int avg_mcache_element_size_l;
2187 	unsigned int avg_mcache_element_size_c;
2188 
2189 	unsigned int full_vp_access_width_l;
2190 	unsigned int full_vp_access_width_c;
2191 };
2192 
2193 struct dml2_core_calcs_calculate_mcache_setting_params {
2194 	bool dcc_enable;
2195 	unsigned int num_chans;
2196 	unsigned int mem_word_bytes;
2197 	unsigned int mcache_size_bytes;
2198 	unsigned int mcache_line_size_bytes;
2199 	unsigned int gpuvm_enable;
2200 	unsigned int gpuvm_page_size_kbytes;
2201 
2202 	enum dml2_source_format_class source_format;
2203 	bool surf_vert;
2204 	unsigned int vp_stationary;
2205 	unsigned int tiling_mode;
2206 	bool imall_enable;
2207 
2208 	unsigned int vp_start_x_l;
2209 	unsigned int vp_start_y_l;
2210 	unsigned int full_vp_width_l;
2211 	unsigned int full_vp_height_l;
2212 	unsigned int blk_width_l;
2213 	unsigned int blk_height_l;
2214 	unsigned int vmpg_width_l;
2215 	unsigned int vmpg_height_l;
2216 	unsigned int full_swath_bytes_l;
2217 	unsigned int bytes_per_pixel_l;
2218 
2219 	unsigned int vp_start_x_c;
2220 	unsigned int vp_start_y_c;
2221 	unsigned int full_vp_width_c;
2222 	unsigned int full_vp_height_c;
2223 	unsigned int blk_width_c;
2224 	unsigned int blk_height_c;
2225 	unsigned int vmpg_width_c;
2226 	unsigned int vmpg_height_c;
2227 	unsigned int full_swath_bytes_c;
2228 	unsigned int bytes_per_pixel_c;
2229 
2230 	// output
2231 	unsigned int *num_mcaches_l;
2232 	unsigned int *mcache_row_bytes_l;
2233 	unsigned int *mcache_row_bytes_per_channel_l;
2234 	unsigned int *mcache_offsets_l;
2235 	unsigned int *mcache_shift_granularity_l;
2236 	double *dcc_dram_bw_nom_overhead_factor_l;
2237 	double *dcc_dram_bw_pref_overhead_factor_l;
2238 
2239 	unsigned int *num_mcaches_c;
2240 	unsigned int *mcache_row_bytes_c;
2241 	unsigned int *mcache_row_bytes_per_channel_c;
2242 	unsigned int *mcache_offsets_c;
2243 	unsigned int *mcache_shift_granularity_c;
2244 	double *dcc_dram_bw_nom_overhead_factor_c;
2245 	double *dcc_dram_bw_pref_overhead_factor_c;
2246 
2247 	bool *mall_comb_mcache_l;
2248 	bool *mall_comb_mcache_c;
2249 	bool *lc_comb_mcache;
2250 };
2251 
2252 
2253 struct dml2_core_calcs_calculate_alternate_lead_lines {
2254 	/* input params */
2255 	const struct dml2_display_cfg *display_cfg;
2256 	unsigned int *VStartup;
2257 	double *VActiveLatencyHidingUs;
2258 
2259 	/* output params */
2260 	unsigned int *min_lead_dst_lines;
2261 };
2262 
2263 struct dml2_core_calcs_calculate_alternate_svp_lines {
2264 	/* input params */
2265 	const struct dml2_display_cfg *display_cfg;
2266 	unsigned int *SwathHeightY;
2267 	unsigned int *SwathHeightC;
2268 	unsigned int *DETBufferSizeY;
2269 	double *BytePerPixelInDETC;
2270 	double dram_blackout_us;
2271 
2272 	/* output params */
2273 	unsigned int *svp0_dst_lines;
2274 	unsigned int *svp1_dst_lines;
2275 	unsigned int *svp_req_limit;
2276 };
2277 
2278 struct dml2_core_calcs_calculate_alternate_params {
2279 	/* input params */
2280 	const struct dml2_display_cfg *display_cfg;
2281 	double *dst_y_prefetch;
2282 	unsigned int *SwathHeightY;
2283 	unsigned int *SwathHeightC;
2284 	unsigned int *SwathWidthY;
2285 	unsigned int *SwathWidthC;
2286 	unsigned int *DETBufferSizeY;
2287 	unsigned int *DETBufferSizeC;
2288 	unsigned int *BytePerPixelY;
2289 	unsigned int *BytePerPixelC;
2290 	double *BytePerPixelInDETY;
2291 	double *BytePerPixelInDETC;
2292 	unsigned int *Read256BlockWidthY;
2293 	unsigned int *Read256BlockHeightY;
2294 	unsigned int *Read256BlockWidthC;
2295 	unsigned int *Read256BlockHeightC;
2296 	unsigned int *MacroTileWidthY;
2297 	unsigned int *MacroTileWidthC;
2298 	unsigned int *VInitPrefillY;
2299 	unsigned int *VInitPrefillC;
2300 	double *VRatioPrefetchY;
2301 	double *VRatioPrefetchC;
2302 	unsigned int *NoOfDPP;
2303 	unsigned int max_num_dpp;
2304 	double dram_blackout_us;
2305 	double *VActiveLatencyHidingUs;
2306 	unsigned int *svp0_dst_lines;
2307 	unsigned int *svp1_dst_lines;
2308 	unsigned int *svp_req_limit;
2309 	double dcn_non_urgent_bandwidth_kbps;
2310 	unsigned int alt_chan_fw_delay_us;
2311 	double *dst_y_per_vm_vblank;
2312 	double *dst_y_per_row_vblank;
2313 	unsigned int *DSTYAfterScaler;
2314 	enum dml2_odm_mode *ODMMode;
2315 
2316 	/* output params */
2317 	unsigned int *svp0_max_bytes;
2318 	unsigned int *svp1_max_bytes;
2319 	unsigned int *svp0_max_bytes_per_dpp;
2320 	unsigned int *svp0_max_bytes_per_dpp_c;
2321 	unsigned int *svp1_max_bytes_per_dpp;
2322 	unsigned int *svp1_max_bytes_per_dpp_c;
2323 	unsigned int *nom_req_limit_alt;
2324 	unsigned int *min_lead_dst_lines;
2325 	unsigned int *total_swaths;
2326 	unsigned int *total_swaths_c;
2327 	unsigned int *prefetch_swaths;
2328 	unsigned int *prefetch_swaths_c;
2329 	double *prefetch_hdl_delta;
2330 	double *recout_hdl_delta;
2331 	double *prefetch_hdl_delta_c;
2332 	double *recout_hdl_delta_c;
2333 	unsigned int *max_prefetch_in_lines;
2334 	double *lsdma_bw_req_for_alt_kbps;
2335 };
2336 struct dml2_core_calcs_calculate_tdlut_setting_params {
2337 	// input params
2338 	double dispclk_mhz;
2339 	bool setup_for_tdlut;
2340 	enum dml2_tdlut_width_mode tdlut_width_mode;
2341 	enum dml2_tdlut_addressing_mode tdlut_addressing_mode;
2342 	unsigned int cursor_buffer_size;
2343 	bool gpuvm_enable;
2344 	unsigned int gpuvm_page_size_kbytes;
2345 	bool is_gfx11;
2346 	bool tdlut_mpc_width_flag;
2347 
2348 	// output param
2349 	unsigned int *tdlut_pte_bytes_per_frame;
2350 	unsigned int *tdlut_bytes_per_frame;
2351 	unsigned int *tdlut_groups_per_2row_ub;
2352 	double *tdlut_opt_time;
2353 	double *tdlut_drain_time;
2354 	unsigned int *tdlut_bytes_to_deliver;
2355 	unsigned int *tdlut_bytes_per_group;
2356 };
2357 
2358 struct dml2_core_calcs_calculate_peak_bandwidth_required_params {
2359 	// output
2360 	double (*urg_vactive_bandwidth_required)[dml2_core_internal_bw_max];
2361 	double (*urg_bandwidth_required)[dml2_core_internal_bw_max];
2362 	double (*urg_bandwidth_required_qual)[dml2_core_internal_bw_max];
2363 	double (*non_urg_bandwidth_required)[dml2_core_internal_bw_max];
2364 	double (*surface_avg_vactive_required_bw)[dml2_core_internal_bw_max][DML2_MAX_PLANES];
2365 	double (*surface_peak_required_bw)[dml2_core_internal_bw_max][DML2_MAX_PLANES];
2366 
2367 	// input
2368 	const struct dml2_display_cfg *display_cfg;
2369 	bool inc_flip_bw;
2370 	unsigned int num_active_planes;
2371 	unsigned int *num_of_dpp;
2372 	double *dcc_dram_bw_nom_overhead_factor_p0;
2373 	double *dcc_dram_bw_nom_overhead_factor_p1;
2374 	double *dcc_dram_bw_pref_overhead_factor_p0;
2375 	double *dcc_dram_bw_pref_overhead_factor_p1;
2376 	double *mall_prefetch_sdp_overhead_factor;
2377 	double *mall_prefetch_dram_overhead_factor;
2378 	double *surface_read_bandwidth_l;
2379 	double *surface_read_bandwidth_c;
2380 	double *prefetch_bandwidth_l;
2381 	double *prefetch_bandwidth_c;
2382 	double *prefetch_bandwidth_max;
2383 	double *excess_vactive_fill_bw_l;
2384 	double *excess_vactive_fill_bw_c;
2385 	double *cursor_bw;
2386 	double *dpte_row_bw;
2387 	double *meta_row_bw;
2388 	double *prefetch_cursor_bw;
2389 	double *prefetch_vmrow_bw;
2390 	double *flip_bw;
2391 	double *urgent_burst_factor_l;
2392 	double *urgent_burst_factor_c;
2393 	double *urgent_burst_factor_cursor;
2394 	double *urgent_burst_factor_prefetch_l;
2395 	double *urgent_burst_factor_prefetch_c;
2396 	double *urgent_burst_factor_prefetch_cursor;
2397 };
2398 
2399 struct dml2_core_calcs_calculate_bytes_to_fetch_required_to_hide_latency_params {
2400 	/* inputs */
2401 	const struct dml2_display_cfg *display_cfg;
2402 	bool mrq_present;
2403 	unsigned int num_active_planes;
2404 	unsigned int *num_of_dpp;
2405 	unsigned int *meta_row_height_l;
2406 	unsigned int *meta_row_height_c;
2407 	unsigned int *meta_row_bytes_per_row_ub_l;
2408 	unsigned int *meta_row_bytes_per_row_ub_c;
2409 	unsigned int *dpte_row_height_l;
2410 	unsigned int *dpte_row_height_c;
2411 	unsigned int *dpte_bytes_per_row_l;
2412 	unsigned int *dpte_bytes_per_row_c;
2413 	unsigned int *byte_per_pix_l;
2414 	unsigned int *byte_per_pix_c;
2415 	unsigned int *swath_width_l;
2416 	unsigned int *swath_width_c;
2417 	unsigned int *swath_height_l;
2418 	unsigned int *swath_height_c;
2419 	double latency_to_hide_us[DML2_MAX_PLANES];
2420 
2421 	/* outputs */
2422 	unsigned int *bytes_required_l;
2423 	unsigned int *bytes_required_c;
2424 };
2425 
2426 // A list of overridable function pointers in the core
2427 // shared calculation library.
2428 struct dml2_core_shared_calculation_funcs {
2429 	void (*calculate_det_buffer_size)(struct dml2_core_shared_calculate_det_buffer_size_params *p);
2430 };
2431 
2432 struct dml2_core_internal_scratch {
2433 	// Scratch space for function locals
2434 	struct dml2_core_calcs_mode_support_locals dml_core_mode_support_locals;
2435 	struct dml2_core_calcs_mode_programming_locals dml_core_mode_programming_locals;
2436 	struct dml2_core_calcs_CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_locals CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_locals;
2437 	struct dml2_core_calcs_CalculateVMRowAndSwath_locals CalculateVMRowAndSwath_locals;
2438 	struct dml2_core_calcs_CalculatePrefetchSchedule_locals CalculatePrefetchSchedule_locals;
2439 	struct dml2_core_calcs_CheckGlobalPrefetchAdmissibility_locals CheckGlobalPrefetchAdmissibility_locals;
2440 	struct dml2_core_shared_CalculateSwathAndDETConfiguration_locals CalculateSwathAndDETConfiguration_locals;
2441 	struct dml2_core_shared_TruncToValidBPP_locals TruncToValidBPP_locals;
2442 	struct dml2_core_shared_CalculateDETBufferSize_locals CalculateDETBufferSize_locals;
2443 	struct dml2_core_shared_get_urgent_bandwidth_required_locals get_urgent_bandwidth_required_locals;
2444 	struct dml2_core_shared_calculate_peak_bandwidth_required_locals calculate_peak_bandwidth_required_locals;
2445 	struct dml2_core_shared_CalculateFlipSchedule_locals CalculateFlipSchedule_locals;
2446 	struct dml2_core_shared_rq_dlg_get_dlg_reg_locals rq_dlg_get_dlg_reg_locals;
2447 	struct dml2_core_calcs_CalculateStutterEfficiency_locals CalculateStutterEfficiency_locals;
2448 
2449 	// Scratch space for function params
2450 	struct dml2_core_calcs_CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_params CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_params;
2451 	struct dml2_core_calcs_CalculateVMRowAndSwath_params CalculateVMRowAndSwath_params;
2452 	struct dml2_core_calcs_CalculateSwathAndDETConfiguration_params CalculateSwathAndDETConfiguration_params;
2453 	struct dml2_core_calcs_CalculateStutterEfficiency_params CalculateStutterEfficiency_params;
2454 	struct dml2_core_calcs_CalculatePrefetchSchedule_params CalculatePrefetchSchedule_params;
2455 	struct dml2_core_calcs_CheckGlobalPrefetchAdmissibility_params CheckGlobalPrefetchAdmissibility_params;
2456 	struct dml2_core_calcs_calculate_mcache_setting_params calculate_mcache_setting_params;
2457 	struct dml2_core_calcs_calculate_tdlut_setting_params calculate_tdlut_setting_params;
2458 	struct dml2_core_shared_calculate_vm_and_row_bytes_params calculate_vm_and_row_bytes_params;
2459 	struct dml2_core_shared_calculate_mcache_setting_locals calculate_mcache_setting_locals;
2460 	struct dml2_core_shared_CalculateMetaAndPTETimes_params CalculateMetaAndPTETimes_params;
2461 	struct dml2_core_calcs_calculate_peak_bandwidth_required_params calculate_peak_bandwidth_params;
2462 	struct dml2_core_calcs_calculate_bytes_to_fetch_required_to_hide_latency_params calculate_bytes_to_fetch_required_to_hide_latency_params;
2463 	struct dml2_core_calcs_calculate_alternate_params calculate_alternate_params;
2464 	struct dml2_core_calcs_calculate_alternate_svp_lines calculate_alternate_svp_lines;
2465 	struct dml2_core_calcs_calculate_alternate_lead_lines calculate_alternate_lead_lines;
2466 };
2467 
2468 //struct dml2_svp_mode_override;
2469 struct dml2_core_internal_display_mode_lib {
2470 	struct dml2_core_ip_params ip;
2471 	struct dml2_soc_bb soc;
2472 	struct dml2_ip_capabilities ip_caps;
2473 
2474 	//@brief Mode Support and Mode programming struct
2475 	// Used to hold input; intermediate and output of the calculations
2476 	struct dml2_core_internal_mode_support ms; // struct for mode support
2477 	struct dml2_core_internal_mode_program mp; // struct for mode programming
2478 	// Available overridable calculators for core_shared.
2479 	// if null, core_shared will use default calculators.
2480 	struct dml2_core_shared_calculation_funcs funcs;
2481 
2482 	struct dml2_core_internal_scratch scratch;
2483 };
2484 
2485 struct dml2_core_calcs_mode_support_ex {
2486 	struct dml2_core_internal_display_mode_lib *mode_lib;
2487 	const struct dml2_display_cfg *in_display_cfg;
2488 	const struct dml2_mcg_min_clock_table *min_clk_table;
2489 	int min_clk_index;
2490 	const struct dml2_utm_soc_bb *utm_soc_bb;
2491 	//unsigned int in_state_index;
2492 	struct dml2_core_internal_mode_support_info *out_evaluation_info;
2493 	const enum dml2_pstate_method *uclk_pstate_switch_modes;
2494 };
2495 
2496 struct core_display_cfg_support_info;
2497 
2498 struct dml2_core_calcs_mode_programming_ex {
2499 	struct dml2_core_internal_display_mode_lib *mode_lib;
2500 	const struct dml2_display_cfg *in_display_cfg;
2501 	const struct dml2_mcg_min_clock_table *min_clk_table;
2502 	const struct core_display_cfg_support_info *cfg_support_info;
2503 	int min_clk_index;
2504 	const struct dml2_uclk_pstate_params *uclk_params;
2505 	const struct dml2_display_solution *solution;
2506 	const struct dml2_utm_soc_bb *utm_soc_bb;
2507 	struct dml2_display_cfg_programming *programming;
2508 };
2509 
2510 #endif
2511