drm/amd/display: move calcs folder into DML
authorIsabella Basso <isabbasso@riseup.net>
Fri, 7 Jan 2022 21:33:36 +0000 (18:33 -0300)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 18 Jan 2022 22:43:36 +0000 (17:43 -0500)
The calcs folder has FPU code on it, which should be isolated inside the
DML folder as per https://patchwork.freedesktop.org/series/93042/.

This commit aims single-handedly to correct the location of such FPU
code and does not refactor any functions.

Changes since v2:
- Corrected problems to compile when DCN was disabled.

Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Isabella Basso <isabbasso@riseup.net>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
19 files changed:
drivers/gpu/drm/amd/display/dc/Makefile
drivers/gpu/drm/amd/display/dc/calcs/Makefile [deleted file]
drivers/gpu/drm/amd/display/dc/calcs/bw_fixed.c [deleted file]
drivers/gpu/drm/amd/display/dc/calcs/calcs_logger.h [deleted file]
drivers/gpu/drm/amd/display/dc/calcs/custom_float.c [deleted file]
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c [deleted file]
drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.c [deleted file]
drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.h [deleted file]
drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c [deleted file]
drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c [deleted file]
drivers/gpu/drm/amd/display/dc/dml/Makefile
drivers/gpu/drm/amd/display/dc/dml/calcs/bw_fixed.c [new file with mode: 0644]
drivers/gpu/drm/amd/display/dc/dml/calcs/calcs_logger.h [new file with mode: 0644]
drivers/gpu/drm/amd/display/dc/dml/calcs/custom_float.c [new file with mode: 0644]
drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c [new file with mode: 0644]
drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_auto.c [new file with mode: 0644]
drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_auto.h [new file with mode: 0644]
drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c [new file with mode: 0644]
drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calcs.c [new file with mode: 0644]

index b1f0d6260226e504cb51c1bf063cab8436f6fbd5..a4ef8f314307e7736b2da334690c8f9f7ffc8d02 100644 (file)
 # Makefile for Display Core (dc) component.
 #
 
-DC_LIBS = basics bios calcs clk_mgr dce gpio irq virtual
+DC_LIBS = basics bios clk_mgr dce dml gpio irq virtual
 
 ifdef CONFIG_DRM_AMD_DC_DCN
 DC_LIBS += dcn20
 DC_LIBS += dsc
-DC_LIBS += dcn10 dml
+DC_LIBS += dcn10
 DC_LIBS += dcn21
 DC_LIBS += dcn201
 DC_LIBS += dcn30
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/Makefile b/drivers/gpu/drm/amd/display/dc/calcs/Makefile
deleted file mode 100644 (file)
index f3c00f4..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# Copyright 2017 Advanced Micro Devices, Inc.
-# Copyright 2019 Raptor Engineering, LLC
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-# THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
-# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-# OTHER DEALINGS IN THE SOFTWARE.
-#
-#
-# Makefile for the 'calcs' sub-component of DAL.
-# It calculates Bandwidth and Watermarks values for HW programming
-#
-
-ifdef CONFIG_X86
-calcs_ccflags := -mhard-float -msse
-endif
-
-ifdef CONFIG_PPC64
-calcs_ccflags := -mhard-float -maltivec
-endif
-
-ifdef CONFIG_CC_IS_GCC
-ifeq ($(call cc-ifversion, -lt, 0701, y), y)
-IS_OLD_GCC = 1
-endif
-endif
-
-ifdef CONFIG_X86
-ifdef IS_OLD_GCC
-# Stack alignment mismatch, proceed with caution.
-# GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3
-# (8B stack alignment).
-calcs_ccflags += -mpreferred-stack-boundary=4
-else
-calcs_ccflags += -msse2
-endif
-endif
-
-CFLAGS_$(AMDDALPATH)/dc/calcs/dcn_calcs.o := $(calcs_ccflags)
-CFLAGS_$(AMDDALPATH)/dc/calcs/dcn_calc_auto.o := $(calcs_ccflags)
-CFLAGS_$(AMDDALPATH)/dc/calcs/dcn_calc_math.o := $(calcs_ccflags) -Wno-tautological-compare
-CFLAGS_REMOVE_$(AMDDALPATH)/dc/calcs/dcn_calcs.o := $(calcs_rcflags)
-CFLAGS_REMOVE_$(AMDDALPATH)/dc/calcs/dcn_calc_auto.o := $(calcs_rcflags)
-CFLAGS_REMOVE_$(AMDDALPATH)/dc/calcs/dcn_calc_math.o := $(calcs_rcflags)
-
-BW_CALCS = dce_calcs.o bw_fixed.o custom_float.o
-
-ifdef CONFIG_DRM_AMD_DC_DCN
-BW_CALCS += dcn_calcs.o dcn_calc_math.o dcn_calc_auto.o
-endif
-
-AMD_DAL_BW_CALCS = $(addprefix $(AMDDALPATH)/dc/calcs/,$(BW_CALCS))
-
-AMD_DISPLAY_FILES += $(AMD_DAL_BW_CALCS)
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/bw_fixed.c b/drivers/gpu/drm/amd/display/dc/calcs/bw_fixed.c
deleted file mode 100644 (file)
index 6ca288f..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright 2015 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-#include "dm_services.h"
-#include "bw_fixed.h"
-
-
-#define MIN_I64 \
-       (int64_t)(-(1LL << 63))
-
-#define MAX_I64 \
-       (int64_t)((1ULL << 63) - 1)
-
-#define FRACTIONAL_PART_MASK \
-       ((1ULL << BW_FIXED_BITS_PER_FRACTIONAL_PART) - 1)
-
-#define GET_FRACTIONAL_PART(x) \
-       (FRACTIONAL_PART_MASK & (x))
-
-static uint64_t abs_i64(int64_t arg)
-{
-       if (arg >= 0)
-               return (uint64_t)(arg);
-       else
-               return (uint64_t)(-arg);
-}
-
-struct bw_fixed bw_int_to_fixed_nonconst(int64_t value)
-{
-       struct bw_fixed res;
-       ASSERT(value < BW_FIXED_MAX_I32 && value > BW_FIXED_MIN_I32);
-       res.value = value << BW_FIXED_BITS_PER_FRACTIONAL_PART;
-       return res;
-}
-
-struct bw_fixed bw_frc_to_fixed(int64_t numerator, int64_t denominator)
-{
-       struct bw_fixed res;
-       bool arg1_negative = numerator < 0;
-       bool arg2_negative = denominator < 0;
-       uint64_t arg1_value;
-       uint64_t arg2_value;
-       uint64_t remainder;
-
-       /* determine integer part */
-       uint64_t res_value;
-
-       ASSERT(denominator != 0);
-
-       arg1_value = abs_i64(numerator);
-       arg2_value = abs_i64(denominator);
-       res_value = div64_u64_rem(arg1_value, arg2_value, &remainder);
-
-       ASSERT(res_value <= BW_FIXED_MAX_I32);
-
-       /* determine fractional part */
-       {
-               uint32_t i = BW_FIXED_BITS_PER_FRACTIONAL_PART;
-
-               do
-               {
-                       remainder <<= 1;
-
-                       res_value <<= 1;
-
-                       if (remainder >= arg2_value)
-                       {
-                               res_value |= 1;
-                               remainder -= arg2_value;
-                       }
-               } while (--i != 0);
-       }
-
-       /* round up LSB */
-       {
-               uint64_t summand = (remainder << 1) >= arg2_value;
-
-               ASSERT(res_value <= MAX_I64 - summand);
-
-               res_value += summand;
-       }
-
-       res.value = (int64_t)(res_value);
-
-       if (arg1_negative ^ arg2_negative)
-               res.value = -res.value;
-       return res;
-}
-
-struct bw_fixed bw_floor2(
-       const struct bw_fixed arg,
-       const struct bw_fixed significance)
-{
-       struct bw_fixed result;
-       int64_t multiplicand;
-
-       multiplicand = div64_s64(arg.value, abs_i64(significance.value));
-       result.value = abs_i64(significance.value) * multiplicand;
-       ASSERT(abs_i64(result.value) <= abs_i64(arg.value));
-       return result;
-}
-
-struct bw_fixed bw_ceil2(
-       const struct bw_fixed arg,
-       const struct bw_fixed significance)
-{
-       struct bw_fixed result;
-       int64_t multiplicand;
-
-       multiplicand = div64_s64(arg.value, abs_i64(significance.value));
-       result.value = abs_i64(significance.value) * multiplicand;
-       if (abs_i64(result.value) < abs_i64(arg.value)) {
-               if (arg.value < 0)
-                       result.value -= abs_i64(significance.value);
-               else
-                       result.value += abs_i64(significance.value);
-       }
-       return result;
-}
-
-struct bw_fixed bw_mul(const struct bw_fixed arg1, const struct bw_fixed arg2)
-{
-       struct bw_fixed res;
-
-       bool arg1_negative = arg1.value < 0;
-       bool arg2_negative = arg2.value < 0;
-
-       uint64_t arg1_value = abs_i64(arg1.value);
-       uint64_t arg2_value = abs_i64(arg2.value);
-
-       uint64_t arg1_int = BW_FIXED_GET_INTEGER_PART(arg1_value);
-       uint64_t arg2_int = BW_FIXED_GET_INTEGER_PART(arg2_value);
-
-       uint64_t arg1_fra = GET_FRACTIONAL_PART(arg1_value);
-       uint64_t arg2_fra = GET_FRACTIONAL_PART(arg2_value);
-
-       uint64_t tmp;
-
-       res.value = arg1_int * arg2_int;
-
-       ASSERT(res.value <= BW_FIXED_MAX_I32);
-
-       res.value <<= BW_FIXED_BITS_PER_FRACTIONAL_PART;
-
-       tmp = arg1_int * arg2_fra;
-
-       ASSERT(tmp <= (uint64_t)(MAX_I64 - res.value));
-
-       res.value += tmp;
-
-       tmp = arg2_int * arg1_fra;
-
-       ASSERT(tmp <= (uint64_t)(MAX_I64 - res.value));
-
-       res.value += tmp;
-
-       tmp = arg1_fra * arg2_fra;
-
-       tmp = (tmp >> BW_FIXED_BITS_PER_FRACTIONAL_PART) +
-               (tmp >= (uint64_t)(bw_frc_to_fixed(1, 2).value));
-
-       ASSERT(tmp <= (uint64_t)(MAX_I64 - res.value));
-
-       res.value += tmp;
-
-       if (arg1_negative ^ arg2_negative)
-               res.value = -res.value;
-       return res;
-}
-
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/calcs_logger.h b/drivers/gpu/drm/amd/display/dc/calcs/calcs_logger.h
deleted file mode 100644 (file)
index 62435bf..0000000
+++ /dev/null
@@ -1,578 +0,0 @@
-/*
- * Copyright 2018 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-
-#ifndef _CALCS_CALCS_LOGGER_H_
-#define _CALCS_CALCS_LOGGER_H_
-#define DC_LOGGER ctx->logger
-
-static void print_bw_calcs_dceip(struct dc_context *ctx, const struct bw_calcs_dceip *dceip)
-{
-
-       DC_LOG_BANDWIDTH_CALCS("#####################################################################");
-       DC_LOG_BANDWIDTH_CALCS("struct bw_calcs_dceip");
-       DC_LOG_BANDWIDTH_CALCS("#####################################################################");
-       DC_LOG_BANDWIDTH_CALCS("        [enum]   bw_calcs_version version %d", dceip->version);
-       DC_LOG_BANDWIDTH_CALCS("        [bool] large_cursor: %d", dceip->large_cursor);
-       DC_LOG_BANDWIDTH_CALCS("        [bool] dmif_pipe_en_fbc_chunk_tracker: %d", dceip->dmif_pipe_en_fbc_chunk_tracker);
-       DC_LOG_BANDWIDTH_CALCS("        [bool] display_write_back_supported: %d", dceip->display_write_back_supported);
-       DC_LOG_BANDWIDTH_CALCS("        [bool] argb_compression_support: %d", dceip->argb_compression_support);
-       DC_LOG_BANDWIDTH_CALCS("        [bool] pre_downscaler_enabled: %d", dceip->pre_downscaler_enabled);
-       DC_LOG_BANDWIDTH_CALCS("        [bool] underlay_downscale_prefetch_enabled: %d",
-                               dceip->underlay_downscale_prefetch_enabled);
-       DC_LOG_BANDWIDTH_CALCS("        [bool] graphics_lb_nodownscaling_multi_line_prefetching: %d",
-                               dceip->graphics_lb_nodownscaling_multi_line_prefetching);
-       DC_LOG_BANDWIDTH_CALCS("        [bool] limit_excessive_outstanding_dmif_requests: %d",
-                               dceip->limit_excessive_outstanding_dmif_requests);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] cursor_max_outstanding_group_num: %d",
-                               dceip->cursor_max_outstanding_group_num);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] lines_interleaved_into_lb: %d", dceip->lines_interleaved_into_lb);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] low_power_tiling_mode: %d", dceip->low_power_tiling_mode);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] chunk_width: %d", dceip->chunk_width);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_graphics_pipes: %d", dceip->number_of_graphics_pipes);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_underlay_pipes: %d", dceip->number_of_underlay_pipes);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] max_dmif_buffer_allocated: %d", dceip->max_dmif_buffer_allocated);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] graphics_dmif_size: %d", dceip->graphics_dmif_size);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] underlay_luma_dmif_size: %d", dceip->underlay_luma_dmif_size);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] underlay_chroma_dmif_size: %d", dceip->underlay_chroma_dmif_size);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] scatter_gather_lines_of_pte_prefetching_in_linear_mode: %d",
-                               dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] display_write_back420_luma_mcifwr_buffer_size: %d",
-                               dceip->display_write_back420_luma_mcifwr_buffer_size);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] display_write_back420_chroma_mcifwr_buffer_size: %d",
-                               dceip->display_write_back420_chroma_mcifwr_buffer_size);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] scatter_gather_pte_request_rows_in_tiling_mode: %d",
-                               dceip->scatter_gather_pte_request_rows_in_tiling_mode);
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay_vscaler_efficiency10_bit_per_component: %d",
-                               bw_fixed_to_int(dceip->underlay_vscaler_efficiency10_bit_per_component));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay_vscaler_efficiency12_bit_per_component: %d",
-                               bw_fixed_to_int(dceip->underlay_vscaler_efficiency12_bit_per_component));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] graphics_vscaler_efficiency6_bit_per_component: %d",
-                               bw_fixed_to_int(dceip->graphics_vscaler_efficiency6_bit_per_component));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] graphics_vscaler_efficiency8_bit_per_component: %d",
-                               bw_fixed_to_int(dceip->graphics_vscaler_efficiency8_bit_per_component));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] graphics_vscaler_efficiency10_bit_per_component: %d",
-                               bw_fixed_to_int(dceip->graphics_vscaler_efficiency10_bit_per_component));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] graphics_vscaler_efficiency12_bit_per_component: %d",
-                               bw_fixed_to_int(dceip->graphics_vscaler_efficiency12_bit_per_component));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] alpha_vscaler_efficiency: %d",
-                               bw_fixed_to_int(dceip->alpha_vscaler_efficiency));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_write_pixels_per_dispclk: %d",
-                               bw_fixed_to_int(dceip->lb_write_pixels_per_dispclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_size_per_component444: %d",
-                               bw_fixed_to_int(dceip->lb_size_per_component444));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_and_dram_clock_state_change_gated_before_cursor: %d",
-                               bw_fixed_to_int(dceip->stutter_and_dram_clock_state_change_gated_before_cursor));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay420_luma_lb_size_per_component: %d",
-                               bw_fixed_to_int(dceip->underlay420_luma_lb_size_per_component));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay420_chroma_lb_size_per_component: %d",
-                               bw_fixed_to_int(dceip->underlay420_chroma_lb_size_per_component));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay422_lb_size_per_component: %d",
-                               bw_fixed_to_int(dceip->underlay422_lb_size_per_component));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] cursor_chunk_width: %d", bw_fixed_to_int(dceip->cursor_chunk_width));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] cursor_dcp_buffer_lines: %d",
-                               bw_fixed_to_int(dceip->cursor_dcp_buffer_lines));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay_maximum_width_efficient_for_tiling: %d",
-                               bw_fixed_to_int(dceip->underlay_maximum_width_efficient_for_tiling));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay_maximum_height_efficient_for_tiling: %d",
-                               bw_fixed_to_int(dceip->underlay_maximum_height_efficient_for_tiling));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display: %d",
-                               bw_fixed_to_int(dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation: %d",
-                               bw_fixed_to_int(dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] minimum_outstanding_pte_request_limit: %d",
-                               bw_fixed_to_int(dceip->minimum_outstanding_pte_request_limit));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] maximum_total_outstanding_pte_requests_allowed_by_saw: %d",
-                               bw_fixed_to_int(dceip->maximum_total_outstanding_pte_requests_allowed_by_saw));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] linear_mode_line_request_alternation_slice: %d",
-                               bw_fixed_to_int(dceip->linear_mode_line_request_alternation_slice));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] request_efficiency: %d", bw_fixed_to_int(dceip->request_efficiency));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_per_request: %d", bw_fixed_to_int(dceip->dispclk_per_request));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_ramping_factor: %d",
-                               bw_fixed_to_int(dceip->dispclk_ramping_factor));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_pipe_throughput_factor: %d",
-                               bw_fixed_to_int(dceip->display_pipe_throughput_factor));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwr_all_surfaces_burst_time: %d",
-                               bw_fixed_to_int(dceip->mcifwr_all_surfaces_burst_time));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_request_buffer_size: %d",
-                               bw_fixed_to_int(dceip->dmif_request_buffer_size));
-
-
-}
-
-static void print_bw_calcs_vbios(struct dc_context *ctx, const struct bw_calcs_vbios *vbios)
-{
-
-       DC_LOG_BANDWIDTH_CALCS("#####################################################################");
-       DC_LOG_BANDWIDTH_CALCS("struct bw_calcs_vbios vbios");
-       DC_LOG_BANDWIDTH_CALCS("#####################################################################");
-       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines memory_type: %d", vbios->memory_type);
-       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines memory_type: %d", vbios->memory_type);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] dram_channel_width_in_bits: %d", vbios->dram_channel_width_in_bits);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_dram_channels: %d", vbios->number_of_dram_channels);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_dram_banks: %d", vbios->number_of_dram_banks);
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] low_yclk: %d", bw_fixed_to_int(vbios->low_yclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid_yclk: %d", bw_fixed_to_int(vbios->mid_yclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] high_yclk: %d", bw_fixed_to_int(vbios->high_yclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] low_sclk: %d", bw_fixed_to_int(vbios->low_sclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid1_sclk: %d", bw_fixed_to_int(vbios->mid1_sclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid2_sclk: %d", bw_fixed_to_int(vbios->mid2_sclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid3_sclk: %d", bw_fixed_to_int(vbios->mid3_sclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid4_sclk: %d", bw_fixed_to_int(vbios->mid4_sclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid5_sclk: %d", bw_fixed_to_int(vbios->mid5_sclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid6_sclk: %d", bw_fixed_to_int(vbios->mid6_sclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] high_sclk: %d", bw_fixed_to_int(vbios->high_sclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] low_voltage_max_dispclk: %d",
-                               bw_fixed_to_int(vbios->low_voltage_max_dispclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid_voltage_max_dispclk;: %d",
-                               bw_fixed_to_int(vbios->mid_voltage_max_dispclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] high_voltage_max_dispclk;: %d",
-                               bw_fixed_to_int(vbios->high_voltage_max_dispclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] low_voltage_max_phyclk: %d",
-                               bw_fixed_to_int(vbios->low_voltage_max_phyclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid_voltage_max_phyclk: %d",
-                               bw_fixed_to_int(vbios->mid_voltage_max_phyclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] high_voltage_max_phyclk: %d",
-                               bw_fixed_to_int(vbios->high_voltage_max_phyclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] data_return_bus_width: %d", bw_fixed_to_int(vbios->data_return_bus_width));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] trc: %d", bw_fixed_to_int(vbios->trc));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmifmc_urgent_latency: %d", bw_fixed_to_int(vbios->dmifmc_urgent_latency));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_self_refresh_exit_latency: %d",
-                               bw_fixed_to_int(vbios->stutter_self_refresh_exit_latency));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_self_refresh_entry_latency: %d",
-                               bw_fixed_to_int(vbios->stutter_self_refresh_entry_latency));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] nbp_state_change_latency: %d",
-                               bw_fixed_to_int(vbios->nbp_state_change_latency));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwrmc_urgent_latency: %d",
-                               bw_fixed_to_int(vbios->mcifwrmc_urgent_latency));
-       DC_LOG_BANDWIDTH_CALCS("        [bool] scatter_gather_enable: %d", vbios->scatter_gather_enable);
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] down_spread_percentage: %d",
-                               bw_fixed_to_int(vbios->down_spread_percentage));
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] cursor_width: %d", vbios->cursor_width);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] average_compression_rate: %d", vbios->average_compression_rate);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_request_slots_gmc_reserves_for_dmif_per_channel: %d",
-                               vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel);
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] blackout_duration: %d", bw_fixed_to_int(vbios->blackout_duration));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] maximum_blackout_recovery_time: %d",
-                               bw_fixed_to_int(vbios->maximum_blackout_recovery_time));
-
-
-}
-
-static void print_bw_calcs_data(struct dc_context *ctx, struct bw_calcs_data *data)
-{
-
-       int i, j, k;
-
-       DC_LOG_BANDWIDTH_CALCS("#####################################################################");
-       DC_LOG_BANDWIDTH_CALCS("struct bw_calcs_data data");
-       DC_LOG_BANDWIDTH_CALCS("#####################################################################");
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_displays: %d", data->number_of_displays);
-       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines underlay_surface_type: %d", data->underlay_surface_type);
-       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines panning_and_bezel_adjustment: %d",
-                               data->panning_and_bezel_adjustment);
-       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines graphics_tiling_mode: %d", data->graphics_tiling_mode);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] graphics_lb_bpc: %d", data->graphics_lb_bpc);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] underlay_lb_bpc: %d", data->underlay_lb_bpc);
-       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines underlay_tiling_mode: %d", data->underlay_tiling_mode);
-       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines d0_underlay_mode: %d", data->d0_underlay_mode);
-       DC_LOG_BANDWIDTH_CALCS("        [bool] d1_display_write_back_dwb_enable: %d", data->d1_display_write_back_dwb_enable);
-       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines d1_underlay_mode: %d", data->d1_underlay_mode);
-       DC_LOG_BANDWIDTH_CALCS("        [bool] cpup_state_change_enable: %d", data->cpup_state_change_enable);
-       DC_LOG_BANDWIDTH_CALCS("        [bool] cpuc_state_change_enable: %d", data->cpuc_state_change_enable);
-       DC_LOG_BANDWIDTH_CALCS("        [bool] nbp_state_change_enable: %d", data->nbp_state_change_enable);
-       DC_LOG_BANDWIDTH_CALCS("        [bool] stutter_mode_enable: %d", data->stutter_mode_enable);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] y_clk_level: %d", data->y_clk_level);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] sclk_level: %d", data->sclk_level);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_underlay_surfaces: %d", data->number_of_underlay_surfaces);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_dram_wrchannels: %d", data->number_of_dram_wrchannels);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] chunk_request_delay: %d", data->chunk_request_delay);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_dram_channels: %d", data->number_of_dram_channels);
-       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines underlay_micro_tile_mode: %d", data->underlay_micro_tile_mode);
-       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines graphics_micro_tile_mode: %d", data->graphics_micro_tile_mode);
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] max_phyclk: %d", bw_fixed_to_int(data->max_phyclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dram_efficiency: %d", bw_fixed_to_int(data->dram_efficiency));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_width_after_surface_type: %d",
-                               bw_fixed_to_int(data->src_width_after_surface_type));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_height_after_surface_type: %d",
-                               bw_fixed_to_int(data->src_height_after_surface_type));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] hsr_after_surface_type: %d",
-                               bw_fixed_to_int(data->hsr_after_surface_type));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] vsr_after_surface_type: %d", bw_fixed_to_int(data->vsr_after_surface_type));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_width_after_rotation: %d",
-                               bw_fixed_to_int(data->src_width_after_rotation));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_height_after_rotation: %d",
-                               bw_fixed_to_int(data->src_height_after_rotation));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] hsr_after_rotation: %d", bw_fixed_to_int(data->hsr_after_rotation));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] vsr_after_rotation: %d", bw_fixed_to_int(data->vsr_after_rotation));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] source_height_pixels: %d", bw_fixed_to_int(data->source_height_pixels));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] hsr_after_stereo: %d", bw_fixed_to_int(data->hsr_after_stereo));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] vsr_after_stereo: %d", bw_fixed_to_int(data->vsr_after_stereo));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] source_width_in_lb: %d", bw_fixed_to_int(data->source_width_in_lb));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_line_pitch: %d", bw_fixed_to_int(data->lb_line_pitch));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay_maximum_source_efficient_for_tiling: %d",
-                               bw_fixed_to_int(data->underlay_maximum_source_efficient_for_tiling));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] num_lines_at_frame_start: %d",
-                               bw_fixed_to_int(data->num_lines_at_frame_start));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_dmif_size_in_time: %d", bw_fixed_to_int(data->min_dmif_size_in_time));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_mcifwr_size_in_time: %d",
-                               bw_fixed_to_int(data->min_mcifwr_size_in_time));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_requests_for_dmif_size: %d",
-                               bw_fixed_to_int(data->total_requests_for_dmif_size));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] peak_pte_request_to_eviction_ratio_limiting: %d",
-                               bw_fixed_to_int(data->peak_pte_request_to_eviction_ratio_limiting));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] useful_pte_per_pte_request: %d",
-                               bw_fixed_to_int(data->useful_pte_per_pte_request));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_pte_request_rows: %d",
-                               bw_fixed_to_int(data->scatter_gather_pte_request_rows));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_row_height: %d",
-                               bw_fixed_to_int(data->scatter_gather_row_height));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_pte_requests_in_vblank: %d",
-                               bw_fixed_to_int(data->scatter_gather_pte_requests_in_vblank));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] inefficient_linear_pitch_in_bytes: %d",
-                               bw_fixed_to_int(data->inefficient_linear_pitch_in_bytes));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] cursor_total_data: %d", bw_fixed_to_int(data->cursor_total_data));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] cursor_total_request_groups: %d",
-                               bw_fixed_to_int(data->cursor_total_request_groups));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_total_pte_requests: %d",
-                               bw_fixed_to_int(data->scatter_gather_total_pte_requests));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_total_pte_request_groups: %d",
-                               bw_fixed_to_int(data->scatter_gather_total_pte_request_groups));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] tile_width_in_pixels: %d", bw_fixed_to_int(data->tile_width_in_pixels));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_total_number_of_data_request_page_close_open: %d",
-                               bw_fixed_to_int(data->dmif_total_number_of_data_request_page_close_open));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwr_total_number_of_data_request_page_close_open: %d",
-                               bw_fixed_to_int(data->mcifwr_total_number_of_data_request_page_close_open));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] bytes_per_page_close_open: %d",
-                               bw_fixed_to_int(data->bytes_per_page_close_open));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwr_total_page_close_open_time: %d",
-                               bw_fixed_to_int(data->mcifwr_total_page_close_open_time));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_requests_for_adjusted_dmif_size: %d",
-                               bw_fixed_to_int(data->total_requests_for_adjusted_dmif_size));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_dmifmc_urgent_trips: %d",
-                               bw_fixed_to_int(data->total_dmifmc_urgent_trips));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_dmifmc_urgent_latency: %d",
-                               bw_fixed_to_int(data->total_dmifmc_urgent_latency));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_display_reads_required_data: %d",
-                               bw_fixed_to_int(data->total_display_reads_required_data));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_display_reads_required_dram_access_data: %d",
-                               bw_fixed_to_int(data->total_display_reads_required_dram_access_data));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_display_writes_required_data: %d",
-                               bw_fixed_to_int(data->total_display_writes_required_data));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_display_writes_required_dram_access_data: %d",
-                               bw_fixed_to_int(data->total_display_writes_required_dram_access_data));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_reads_required_data: %d",
-                               bw_fixed_to_int(data->display_reads_required_data));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_reads_required_dram_access_data: %d",
-                               bw_fixed_to_int(data->display_reads_required_dram_access_data));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_total_page_close_open_time: %d",
-                               bw_fixed_to_int(data->dmif_total_page_close_open_time));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_cursor_memory_interface_buffer_size_in_time: %d",
-                               bw_fixed_to_int(data->min_cursor_memory_interface_buffer_size_in_time));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_read_buffer_size_in_time: %d",
-                               bw_fixed_to_int(data->min_read_buffer_size_in_time));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_reads_time_for_data_transfer: %d",
-                               bw_fixed_to_int(data->display_reads_time_for_data_transfer));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_writes_time_for_data_transfer: %d",
-                               bw_fixed_to_int(data->display_writes_time_for_data_transfer));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_required_dram_bandwidth: %d",
-                               bw_fixed_to_int(data->dmif_required_dram_bandwidth));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwr_required_dram_bandwidth: %d",
-                               bw_fixed_to_int(data->mcifwr_required_dram_bandwidth));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] required_dmifmc_urgent_latency_for_page_close_open: %d",
-                               bw_fixed_to_int(data->required_dmifmc_urgent_latency_for_page_close_open));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] required_mcifmcwr_urgent_latency: %d",
-                               bw_fixed_to_int(data->required_mcifmcwr_urgent_latency));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] required_dram_bandwidth_gbyte_per_second: %d",
-                               bw_fixed_to_int(data->required_dram_bandwidth_gbyte_per_second));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dram_bandwidth: %d", bw_fixed_to_int(data->dram_bandwidth));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_required_sclk: %d", bw_fixed_to_int(data->dmif_required_sclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwr_required_sclk: %d", bw_fixed_to_int(data->mcifwr_required_sclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] required_sclk: %d", bw_fixed_to_int(data->required_sclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] downspread_factor: %d", bw_fixed_to_int(data->downspread_factor));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] v_scaler_efficiency: %d", bw_fixed_to_int(data->v_scaler_efficiency));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scaler_limits_factor: %d", bw_fixed_to_int(data->scaler_limits_factor));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_pipe_pixel_throughput: %d",
-                               bw_fixed_to_int(data->display_pipe_pixel_throughput));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_dispclk_required_with_ramping: %d",
-                               bw_fixed_to_int(data->total_dispclk_required_with_ramping));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_dispclk_required_without_ramping: %d",
-                               bw_fixed_to_int(data->total_dispclk_required_without_ramping));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_read_request_bandwidth: %d",
-                               bw_fixed_to_int(data->total_read_request_bandwidth));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_write_request_bandwidth: %d",
-                               bw_fixed_to_int(data->total_write_request_bandwidth));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_required_for_total_read_request_bandwidth: %d",
-                               bw_fixed_to_int(data->dispclk_required_for_total_read_request_bandwidth));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_dispclk_required_with_ramping_with_request_bandwidth: %d",
-                               bw_fixed_to_int(data->total_dispclk_required_with_ramping_with_request_bandwidth));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_dispclk_required_without_ramping_with_request_bandwidth: %d",
-                               bw_fixed_to_int(data->total_dispclk_required_without_ramping_with_request_bandwidth));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk: %d", bw_fixed_to_int(data->dispclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] blackout_recovery_time: %d", bw_fixed_to_int(data->blackout_recovery_time));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_pixels_per_data_fifo_entry: %d",
-                               bw_fixed_to_int(data->min_pixels_per_data_fifo_entry));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] sclk_deep_sleep: %d", bw_fixed_to_int(data->sclk_deep_sleep));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] chunk_request_time: %d", bw_fixed_to_int(data->chunk_request_time));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] cursor_request_time: %d", bw_fixed_to_int(data->cursor_request_time));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] line_source_pixels_transfer_time: %d",
-                               bw_fixed_to_int(data->line_source_pixels_transfer_time));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmifdram_access_efficiency: %d",
-                               bw_fixed_to_int(data->dmifdram_access_efficiency));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwrdram_access_efficiency: %d",
-                               bw_fixed_to_int(data->mcifwrdram_access_efficiency));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_average_bandwidth_no_compression: %d",
-                               bw_fixed_to_int(data->total_average_bandwidth_no_compression));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_average_bandwidth: %d",
-                               bw_fixed_to_int(data->total_average_bandwidth));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_stutter_cycle_duration: %d",
-                               bw_fixed_to_int(data->total_stutter_cycle_duration));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_burst_time: %d", bw_fixed_to_int(data->stutter_burst_time));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] time_in_self_refresh: %d", bw_fixed_to_int(data->time_in_self_refresh));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_efficiency: %d", bw_fixed_to_int(data->stutter_efficiency));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] worst_number_of_trips_to_memory: %d",
-                               bw_fixed_to_int(data->worst_number_of_trips_to_memory));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] immediate_flip_time: %d", bw_fixed_to_int(data->immediate_flip_time));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] latency_for_non_dmif_clients: %d",
-                               bw_fixed_to_int(data->latency_for_non_dmif_clients));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] latency_for_non_mcifwr_clients: %d",
-                               bw_fixed_to_int(data->latency_for_non_mcifwr_clients));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmifmc_urgent_latency_supported_in_high_sclk_and_yclk: %d",
-                               bw_fixed_to_int(data->dmifmc_urgent_latency_supported_in_high_sclk_and_yclk));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] nbp_state_dram_speed_change_margin: %d",
-                               bw_fixed_to_int(data->nbp_state_dram_speed_change_margin));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_reads_time_for_data_transfer_and_urgent_latency: %d",
-                               bw_fixed_to_int(data->display_reads_time_for_data_transfer_and_urgent_latency));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dram_speed_change_margin: %d",
-                               bw_fixed_to_int(data->dram_speed_change_margin));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_vblank_dram_speed_change_margin: %d",
-                               bw_fixed_to_int(data->min_vblank_dram_speed_change_margin));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_stutter_refresh_duration: %d",
-                               bw_fixed_to_int(data->min_stutter_refresh_duration));
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] total_stutter_dmif_buffer_size: %d", data->total_stutter_dmif_buffer_size);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] total_bytes_requested: %d", data->total_bytes_requested);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] min_stutter_dmif_buffer_size: %d", data->min_stutter_dmif_buffer_size);
-       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] num_stutter_bursts: %d", data->num_stutter_bursts);
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] v_blank_nbp_state_dram_speed_change_latency_supported: %d",
-                               bw_fixed_to_int(data->v_blank_nbp_state_dram_speed_change_latency_supported));
-       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] nbp_state_dram_speed_change_latency_supported: %d",
-                               bw_fixed_to_int(data->nbp_state_dram_speed_change_latency_supported));
-
-       for (i = 0; i < maximum_number_of_surfaces; i++) {
-               DC_LOG_BANDWIDTH_CALCS("        [bool] fbc_en[%d]:%d\n", i, data->fbc_en[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [bool] lpt_en[%d]:%d", i, data->lpt_en[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [bool] displays_match_flag[%d]:%d", i, data->displays_match_flag[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [bool] use_alpha[%d]:%d", i, data->use_alpha[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [bool] orthogonal_rotation[%d]:%d", i, data->orthogonal_rotation[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [bool] enable[%d]:%d", i, data->enable[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [bool] access_one_channel_only[%d]:%d", i, data->access_one_channel_only[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [bool] scatter_gather_enable_for_pipe[%d]:%d",
-                                       i, data->scatter_gather_enable_for_pipe[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [bool] interlace_mode[%d]:%d",
-                                       i, data->interlace_mode[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [bool] display_pstate_change_enable[%d]:%d",
-                                       i, data->display_pstate_change_enable[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [bool] line_buffer_prefetch[%d]:%d", i, data->line_buffer_prefetch[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [uint32_t] bytes_per_pixel[%d]:%d", i, data->bytes_per_pixel[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [uint32_t] max_chunks_non_fbc_mode[%d]:%d",
-                                       i, data->max_chunks_non_fbc_mode[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [uint32_t] lb_bpc[%d]:%d", i, data->lb_bpc[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [uint32_t] output_bpphdmi[%d]:%d", i, data->output_bpphdmi[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [uint32_t] output_bppdp4_lane_hbr[%d]:%d", i, data->output_bppdp4_lane_hbr[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [uint32_t] output_bppdp4_lane_hbr2[%d]:%d",
-                                       i, data->output_bppdp4_lane_hbr2[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [uint32_t] output_bppdp4_lane_hbr3[%d]:%d",
-                                       i, data->output_bppdp4_lane_hbr3[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines stereo_mode[%d]:%d", i, data->stereo_mode[i]);
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_buffer_transfer_time[%d]:%d",
-                                       i, bw_fixed_to_int(data->dmif_buffer_transfer_time[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] displays_with_same_mode[%d]:%d",
-                                       i, bw_fixed_to_int(data->displays_with_same_mode[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_dmif_buffer_size[%d]:%d",
-                                       i, bw_fixed_to_int(data->stutter_dmif_buffer_size[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_refresh_duration[%d]:%d",
-                                       i, bw_fixed_to_int(data->stutter_refresh_duration[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_exit_watermark[%d]:%d",
-                                       i, bw_fixed_to_int(data->stutter_exit_watermark[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_entry_watermark[%d]:%d",
-                                       i, bw_fixed_to_int(data->stutter_entry_watermark[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] h_total[%d]:%d", i, bw_fixed_to_int(data->h_total[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] v_total[%d]:%d", i, bw_fixed_to_int(data->v_total[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] pixel_rate[%d]:%d", i, bw_fixed_to_int(data->pixel_rate[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_width[%d]:%d", i, bw_fixed_to_int(data->src_width[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] pitch_in_pixels[%d]:%d",
-                                       i, bw_fixed_to_int(data->pitch_in_pixels[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] pitch_in_pixels_after_surface_type[%d]:%d",
-                                       i, bw_fixed_to_int(data->pitch_in_pixels_after_surface_type[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_height[%d]:%d", i, bw_fixed_to_int(data->src_height[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scale_ratio[%d]:%d", i, bw_fixed_to_int(data->scale_ratio[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] h_taps[%d]:%d", i, bw_fixed_to_int(data->h_taps[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] v_taps[%d]:%d", i, bw_fixed_to_int(data->v_taps[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] h_scale_ratio[%d]:%d", i, bw_fixed_to_int(data->h_scale_ratio[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] v_scale_ratio[%d]:%d", i, bw_fixed_to_int(data->v_scale_ratio[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] rotation_angle[%d]:%d",
-                                       i, bw_fixed_to_int(data->rotation_angle[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] compression_rate[%d]:%d",
-                                       i, bw_fixed_to_int(data->compression_rate[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] hsr[%d]:%d", i, bw_fixed_to_int(data->hsr[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] vsr[%d]:%d", i, bw_fixed_to_int(data->vsr[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] source_width_rounded_up_to_chunks[%d]:%d",
-                                       i, bw_fixed_to_int(data->source_width_rounded_up_to_chunks[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] source_width_pixels[%d]:%d",
-                                       i, bw_fixed_to_int(data->source_width_pixels[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] source_height_rounded_up_to_chunks[%d]:%d",
-                                       i, bw_fixed_to_int(data->source_height_rounded_up_to_chunks[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_bandwidth[%d]:%d",
-                                       i, bw_fixed_to_int(data->display_bandwidth[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] request_bandwidth[%d]:%d",
-                                       i, bw_fixed_to_int(data->request_bandwidth[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] bytes_per_request[%d]:%d",
-                                       i, bw_fixed_to_int(data->bytes_per_request[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] useful_bytes_per_request[%d]:%d",
-                                       i, bw_fixed_to_int(data->useful_bytes_per_request[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lines_interleaved_in_mem_access[%d]:%d",
-                                       i, bw_fixed_to_int(data->lines_interleaved_in_mem_access[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] latency_hiding_lines[%d]:%d",
-                                       i, bw_fixed_to_int(data->latency_hiding_lines[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_partitions[%d]:%d",
-                                       i, bw_fixed_to_int(data->lb_partitions[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_partitions_max[%d]:%d",
-                                       i, bw_fixed_to_int(data->lb_partitions_max[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_required_with_ramping[%d]:%d",
-                                       i, bw_fixed_to_int(data->dispclk_required_with_ramping[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_required_without_ramping[%d]:%d",
-                                       i, bw_fixed_to_int(data->dispclk_required_without_ramping[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] data_buffer_size[%d]:%d",
-                                       i, bw_fixed_to_int(data->data_buffer_size[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] outstanding_chunk_request_limit[%d]:%d",
-                                       i, bw_fixed_to_int(data->outstanding_chunk_request_limit[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] urgent_watermark[%d]:%d",
-                                       i, bw_fixed_to_int(data->urgent_watermark[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] nbp_state_change_watermark[%d]:%d",
-                                       i, bw_fixed_to_int(data->nbp_state_change_watermark[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] v_filter_init[%d]:%d", i, bw_fixed_to_int(data->v_filter_init[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_cycle_duration[%d]:%d",
-                                       i, bw_fixed_to_int(data->stutter_cycle_duration[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] average_bandwidth[%d]:%d",
-                                       i, bw_fixed_to_int(data->average_bandwidth[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] average_bandwidth_no_compression[%d]:%d",
-                                       i, bw_fixed_to_int(data->average_bandwidth_no_compression[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_pte_request_limit[%d]:%d",
-                                       i, bw_fixed_to_int(data->scatter_gather_pte_request_limit[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_size_per_component[%d]:%d",
-                                       i, bw_fixed_to_int(data->lb_size_per_component[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] memory_chunk_size_in_bytes[%d]:%d",
-                                       i, bw_fixed_to_int(data->memory_chunk_size_in_bytes[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] pipe_chunk_size_in_bytes[%d]:%d",
-                                       i, bw_fixed_to_int(data->pipe_chunk_size_in_bytes[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] number_of_trips_to_memory_for_getting_apte_row[%d]:%d",
-                                       i, bw_fixed_to_int(data->number_of_trips_to_memory_for_getting_apte_row[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] adjusted_data_buffer_size[%d]:%d",
-                                       i, bw_fixed_to_int(data->adjusted_data_buffer_size[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] adjusted_data_buffer_size_in_memory[%d]:%d",
-                                       i, bw_fixed_to_int(data->adjusted_data_buffer_size_in_memory[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] pixels_per_data_fifo_entry[%d]:%d",
-                                       i, bw_fixed_to_int(data->pixels_per_data_fifo_entry[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_pte_requests_in_row[%d]:%d",
-                                       i, bw_fixed_to_int(data->scatter_gather_pte_requests_in_row[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] pte_request_per_chunk[%d]:%d",
-                                       i, bw_fixed_to_int(data->pte_request_per_chunk[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_page_width[%d]:%d",
-                                       i, bw_fixed_to_int(data->scatter_gather_page_width[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_page_height[%d]:%d",
-                                       i, bw_fixed_to_int(data->scatter_gather_page_height[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_lines_in_per_line_out_in_beginning_of_frame[%d]:%d",
-                                       i, bw_fixed_to_int(data->lb_lines_in_per_line_out_in_beginning_of_frame[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_lines_in_per_line_out_in_middle_of_frame[%d]:%d",
-                                       i, bw_fixed_to_int(data->lb_lines_in_per_line_out_in_middle_of_frame[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] cursor_width_pixels[%d]:%d",
-                                       i, bw_fixed_to_int(data->cursor_width_pixels[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] minimum_latency_hiding[%d]:%d",
-                                       i, bw_fixed_to_int(data->minimum_latency_hiding[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] maximum_latency_hiding[%d]:%d",
-                                       i, bw_fixed_to_int(data->maximum_latency_hiding[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] minimum_latency_hiding_with_cursor[%d]:%d",
-                                       i, bw_fixed_to_int(data->minimum_latency_hiding_with_cursor[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] maximum_latency_hiding_with_cursor[%d]:%d",
-                                       i, bw_fixed_to_int(data->maximum_latency_hiding_with_cursor[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_pixels_for_first_output_pixel[%d]:%d",
-                                       i, bw_fixed_to_int(data->src_pixels_for_first_output_pixel[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_pixels_for_last_output_pixel[%d]:%d",
-                                       i, bw_fixed_to_int(data->src_pixels_for_last_output_pixel[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_data_for_first_output_pixel[%d]:%d",
-                                       i, bw_fixed_to_int(data->src_data_for_first_output_pixel[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_data_for_last_output_pixel[%d]:%d",
-                                       i, bw_fixed_to_int(data->src_data_for_last_output_pixel[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] active_time[%d]:%d", i, bw_fixed_to_int(data->active_time[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] horizontal_blank_and_chunk_granularity_factor[%d]:%d",
-                                       i, bw_fixed_to_int(data->horizontal_blank_and_chunk_granularity_factor[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] cursor_latency_hiding[%d]:%d",
-                                       i, bw_fixed_to_int(data->cursor_latency_hiding[i]));
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] v_blank_dram_speed_change_margin[%d]:%d",
-                                       i, bw_fixed_to_int(data->v_blank_dram_speed_change_margin[i]));
-               }
-
-       for (i = 0; i < maximum_number_of_surfaces; i++) {
-               for (j = 0; j < 3; j++) {
-                       for (k = 0; k < 8; k++) {
-
-                               DC_LOG_BANDWIDTH_CALCS("\n      [bw_fixed] line_source_transfer_time[%d][%d][%d]:%d",
-                                       i, j, k, bw_fixed_to_int(data->line_source_transfer_time[i][j][k]));
-                               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dram_speed_change_line_source_transfer_time[%d][%d][%d]:%d",
-                                       i, j, k,
-                                       bw_fixed_to_int(data->dram_speed_change_line_source_transfer_time[i][j][k]));
-                       }
-               }
-       }
-
-       for (i = 0; i < 3; i++) {
-               for (j = 0; j < 8; j++) {
-
-                       DC_LOG_BANDWIDTH_CALCS("\n      [uint32_t] num_displays_with_margin[%d][%d]:%d",
-                                       i, j, data->num_displays_with_margin[i][j]);
-                       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_burst_time[%d][%d]:%d",
-                                       i, j, bw_fixed_to_int(data->dmif_burst_time[i][j]));
-                       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwr_burst_time[%d][%d]:%d",
-                                       i, j, bw_fixed_to_int(data->mcifwr_burst_time[i][j]));
-                       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_dram_speed_change_margin[%d][%d]:%d",
-                                       i, j, bw_fixed_to_int(data->min_dram_speed_change_margin[i][j]));
-                       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_required_for_dram_speed_change[%d][%d]:%d",
-                                       i, j, bw_fixed_to_int(data->dispclk_required_for_dram_speed_change[i][j]));
-                       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] blackout_duration_margin[%d][%d]:%d",
-                                       i, j, bw_fixed_to_int(data->blackout_duration_margin[i][j]));
-                       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_required_for_blackout_duration[%d][%d]:%d",
-                                       i, j, bw_fixed_to_int(data->dispclk_required_for_blackout_duration[i][j]));
-                       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_required_for_blackout_recovery[%d][%d]:%d",
-                                       i, j, bw_fixed_to_int(data->dispclk_required_for_blackout_recovery[i][j]));
-               }
-       }
-
-       for (i = 0; i < 6; i++) {
-               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_required_sclk_for_urgent_latency[%d]:%d",
-                                       i, bw_fixed_to_int(data->dmif_required_sclk_for_urgent_latency[i]));
-       }
-}
-;
-
-#endif /* _CALCS_CALCS_LOGGER_H_ */
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/custom_float.c b/drivers/gpu/drm/amd/display/dc/calcs/custom_float.c
deleted file mode 100644 (file)
index 31d167b..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright 2017 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-#include "dm_services.h"
-#include "custom_float.h"
-
-
-static bool build_custom_float(
-       struct fixed31_32 value,
-       const struct custom_float_format *format,
-       bool *negative,
-       uint32_t *mantissa,
-       uint32_t *exponenta)
-{
-       uint32_t exp_offset = (1 << (format->exponenta_bits - 1)) - 1;
-
-       const struct fixed31_32 mantissa_constant_plus_max_fraction =
-               dc_fixpt_from_fraction(
-                       (1LL << (format->mantissa_bits + 1)) - 1,
-                       1LL << format->mantissa_bits);
-
-       struct fixed31_32 mantiss;
-
-       if (dc_fixpt_eq(
-               value,
-               dc_fixpt_zero)) {
-               *negative = false;
-               *mantissa = 0;
-               *exponenta = 0;
-               return true;
-       }
-
-       if (dc_fixpt_lt(
-               value,
-               dc_fixpt_zero)) {
-               *negative = format->sign;
-               value = dc_fixpt_neg(value);
-       } else {
-               *negative = false;
-       }
-
-       if (dc_fixpt_lt(
-               value,
-               dc_fixpt_one)) {
-               uint32_t i = 1;
-
-               do {
-                       value = dc_fixpt_shl(value, 1);
-                       ++i;
-               } while (dc_fixpt_lt(
-                       value,
-                       dc_fixpt_one));
-
-               --i;
-
-               if (exp_offset <= i) {
-                       *mantissa = 0;
-                       *exponenta = 0;
-                       return true;
-               }
-
-               *exponenta = exp_offset - i;
-       } else if (dc_fixpt_le(
-               mantissa_constant_plus_max_fraction,
-               value)) {
-               uint32_t i = 1;
-
-               do {
-                       value = dc_fixpt_shr(value, 1);
-                       ++i;
-               } while (dc_fixpt_lt(
-                       mantissa_constant_plus_max_fraction,
-                       value));
-
-               *exponenta = exp_offset + i - 1;
-       } else {
-               *exponenta = exp_offset;
-       }
-
-       mantiss = dc_fixpt_sub(
-               value,
-               dc_fixpt_one);
-
-       if (dc_fixpt_lt(
-                       mantiss,
-                       dc_fixpt_zero) ||
-               dc_fixpt_lt(
-                       dc_fixpt_one,
-                       mantiss))
-               mantiss = dc_fixpt_zero;
-       else
-               mantiss = dc_fixpt_shl(
-                       mantiss,
-                       format->mantissa_bits);
-
-       *mantissa = dc_fixpt_floor(mantiss);
-
-       return true;
-}
-
-static bool setup_custom_float(
-       const struct custom_float_format *format,
-       bool negative,
-       uint32_t mantissa,
-       uint32_t exponenta,
-       uint32_t *result)
-{
-       uint32_t i = 0;
-       uint32_t j = 0;
-
-       uint32_t value = 0;
-
-       /* verification code:
-        * once calculation is ok we can remove it
-        */
-
-       const uint32_t mantissa_mask =
-               (1 << (format->mantissa_bits + 1)) - 1;
-
-       const uint32_t exponenta_mask =
-               (1 << (format->exponenta_bits + 1)) - 1;
-
-       if (mantissa & ~mantissa_mask) {
-               BREAK_TO_DEBUGGER();
-               mantissa = mantissa_mask;
-       }
-
-       if (exponenta & ~exponenta_mask) {
-               BREAK_TO_DEBUGGER();
-               exponenta = exponenta_mask;
-       }
-
-       /* end of verification code */
-
-       while (i < format->mantissa_bits) {
-               uint32_t mask = 1 << i;
-
-               if (mantissa & mask)
-                       value |= mask;
-
-               ++i;
-       }
-
-       while (j < format->exponenta_bits) {
-               uint32_t mask = 1 << j;
-
-               if (exponenta & mask)
-                       value |= mask << i;
-
-               ++j;
-       }
-
-       if (negative && format->sign)
-               value |= 1 << (i + j);
-
-       *result = value;
-
-       return true;
-}
-
-bool convert_to_custom_float_format(
-       struct fixed31_32 value,
-       const struct custom_float_format *format,
-       uint32_t *result)
-{
-       uint32_t mantissa;
-       uint32_t exponenta;
-       bool negative;
-
-       return build_custom_float(
-               value, format, &negative, &mantissa, &exponenta) &&
-       setup_custom_float(
-               format, negative, mantissa, exponenta, result);
-}
-
-
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
deleted file mode 100644 (file)
index ff5bb15..0000000
+++ /dev/null
@@ -1,3625 +0,0 @@
-/*
- * Copyright 2015 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-
-#include <linux/slab.h>
-
-#include "resource.h"
-#include "dm_services.h"
-#include "dce_calcs.h"
-#include "dc.h"
-#include "core_types.h"
-#include "dal_asic_id.h"
-#include "calcs_logger.h"
-
-/*
- * NOTE:
- *   This file is gcc-parseable HW gospel, coming straight from HW engineers.
- *
- * It doesn't adhere to Linux kernel style and sometimes will do things in odd
- * ways. Unless there is something clearly wrong with it the code should
- * remain as-is as it provides us with a guarantee from HW that it is correct.
- */
-
-/*******************************************************************************
- * Private Functions
- ******************************************************************************/
-
-static enum bw_calcs_version bw_calcs_version_from_asic_id(struct hw_asic_id asic_id)
-{
-       switch (asic_id.chip_family) {
-
-       case FAMILY_CZ:
-               if (ASIC_REV_IS_STONEY(asic_id.hw_internal_rev))
-                       return BW_CALCS_VERSION_STONEY;
-               return BW_CALCS_VERSION_CARRIZO;
-
-       case FAMILY_VI:
-               if (ASIC_REV_IS_POLARIS12_V(asic_id.hw_internal_rev))
-                       return BW_CALCS_VERSION_POLARIS12;
-               if (ASIC_REV_IS_POLARIS10_P(asic_id.hw_internal_rev))
-                       return BW_CALCS_VERSION_POLARIS10;
-               if (ASIC_REV_IS_POLARIS11_M(asic_id.hw_internal_rev))
-                       return BW_CALCS_VERSION_POLARIS11;
-               if (ASIC_REV_IS_VEGAM(asic_id.hw_internal_rev))
-                       return BW_CALCS_VERSION_VEGAM;
-               return BW_CALCS_VERSION_INVALID;
-
-       case FAMILY_AI:
-               return BW_CALCS_VERSION_VEGA10;
-
-       default:
-               return BW_CALCS_VERSION_INVALID;
-       }
-}
-
-static void calculate_bandwidth(
-       const struct bw_calcs_dceip *dceip,
-       const struct bw_calcs_vbios *vbios,
-       struct bw_calcs_data *data)
-
-{
-       const int32_t pixels_per_chunk = 512;
-       const int32_t high = 2;
-       const int32_t mid = 1;
-       const int32_t low = 0;
-       const uint32_t s_low = 0;
-       const uint32_t s_mid1 = 1;
-       const uint32_t s_mid2 = 2;
-       const uint32_t s_mid3 = 3;
-       const uint32_t s_mid4 = 4;
-       const uint32_t s_mid5 = 5;
-       const uint32_t s_mid6 = 6;
-       const uint32_t s_high = 7;
-       const uint32_t dmif_chunk_buff_margin = 1;
-
-       uint32_t max_chunks_fbc_mode;
-       int32_t num_cursor_lines;
-
-       int32_t i, j, k;
-       struct bw_fixed *yclk;
-       struct bw_fixed *sclk;
-       bool d0_underlay_enable;
-       bool d1_underlay_enable;
-       bool fbc_enabled;
-       bool lpt_enabled;
-       enum bw_defines sclk_message;
-       enum bw_defines yclk_message;
-       enum bw_defines *tiling_mode;
-       enum bw_defines *surface_type;
-       enum bw_defines voltage;
-       enum bw_defines pipe_check;
-       enum bw_defines hsr_check;
-       enum bw_defines vsr_check;
-       enum bw_defines lb_size_check;
-       enum bw_defines fbc_check;
-       enum bw_defines rotation_check;
-       enum bw_defines mode_check;
-       enum bw_defines nbp_state_change_enable_blank;
-       /*initialize variables*/
-       int32_t number_of_displays_enabled = 0;
-       int32_t number_of_displays_enabled_with_margin = 0;
-       int32_t number_of_aligned_displays_with_no_margin = 0;
-
-       yclk = kcalloc(3, sizeof(*yclk), GFP_KERNEL);
-       if (!yclk)
-               return;
-
-       sclk = kcalloc(8, sizeof(*sclk), GFP_KERNEL);
-       if (!sclk)
-               goto free_yclk;
-
-       tiling_mode = kcalloc(maximum_number_of_surfaces, sizeof(*tiling_mode), GFP_KERNEL);
-       if (!tiling_mode)
-               goto free_sclk;
-
-       surface_type = kcalloc(maximum_number_of_surfaces, sizeof(*surface_type), GFP_KERNEL);
-       if (!surface_type)
-               goto free_tiling_mode;
-
-       yclk[low] = vbios->low_yclk;
-       yclk[mid] = vbios->mid_yclk;
-       yclk[high] = vbios->high_yclk;
-       sclk[s_low] = vbios->low_sclk;
-       sclk[s_mid1] = vbios->mid1_sclk;
-       sclk[s_mid2] = vbios->mid2_sclk;
-       sclk[s_mid3] = vbios->mid3_sclk;
-       sclk[s_mid4] = vbios->mid4_sclk;
-       sclk[s_mid5] = vbios->mid5_sclk;
-       sclk[s_mid6] = vbios->mid6_sclk;
-       sclk[s_high] = vbios->high_sclk;
-       /*''''''''''''''''''*/
-       /* surface assignment:*/
-       /* 0: d0 underlay or underlay luma*/
-       /* 1: d0 underlay chroma*/
-       /* 2: d1 underlay or underlay luma*/
-       /* 3: d1 underlay chroma*/
-       /* 4: d0 graphics*/
-       /* 5: d1 graphics*/
-       /* 6: d2 graphics*/
-       /* 7: d3 graphics, same mode as d2*/
-       /* 8: d4 graphics, same mode as d2*/
-       /* 9: d5 graphics, same mode as d2*/
-       /* ...*/
-       /* maximum_number_of_surfaces-2: d1 display_write_back420 luma*/
-       /* maximum_number_of_surfaces-1: d1 display_write_back420 chroma*/
-       /* underlay luma and chroma surface parameters from spreadsheet*/
-
-
-
-
-       if (data->d0_underlay_mode == bw_def_none)
-               d0_underlay_enable = false;
-       else
-               d0_underlay_enable = true;
-       if (data->d1_underlay_mode == bw_def_none)
-               d1_underlay_enable = false;
-       else
-               d1_underlay_enable = true;
-       data->number_of_underlay_surfaces = d0_underlay_enable + d1_underlay_enable;
-       switch (data->underlay_surface_type) {
-       case bw_def_420:
-               surface_type[0] = bw_def_underlay420_luma;
-               surface_type[2] = bw_def_underlay420_luma;
-               data->bytes_per_pixel[0] = 1;
-               data->bytes_per_pixel[2] = 1;
-               surface_type[1] = bw_def_underlay420_chroma;
-               surface_type[3] = bw_def_underlay420_chroma;
-               data->bytes_per_pixel[1] = 2;
-               data->bytes_per_pixel[3] = 2;
-               data->lb_size_per_component[0] = dceip->underlay420_luma_lb_size_per_component;
-               data->lb_size_per_component[1] = dceip->underlay420_chroma_lb_size_per_component;
-               data->lb_size_per_component[2] = dceip->underlay420_luma_lb_size_per_component;
-               data->lb_size_per_component[3] = dceip->underlay420_chroma_lb_size_per_component;
-               break;
-       case bw_def_422:
-               surface_type[0] = bw_def_underlay422;
-               surface_type[2] = bw_def_underlay422;
-               data->bytes_per_pixel[0] = 2;
-               data->bytes_per_pixel[2] = 2;
-               data->lb_size_per_component[0] = dceip->underlay422_lb_size_per_component;
-               data->lb_size_per_component[2] = dceip->underlay422_lb_size_per_component;
-               break;
-       default:
-               surface_type[0] = bw_def_underlay444;
-               surface_type[2] = bw_def_underlay444;
-               data->bytes_per_pixel[0] = 4;
-               data->bytes_per_pixel[2] = 4;
-               data->lb_size_per_component[0] = dceip->lb_size_per_component444;
-               data->lb_size_per_component[2] = dceip->lb_size_per_component444;
-               break;
-       }
-       if (d0_underlay_enable) {
-               switch (data->underlay_surface_type) {
-               case bw_def_420:
-                       data->enable[0] = 1;
-                       data->enable[1] = 1;
-                       break;
-               default:
-                       data->enable[0] = 1;
-                       data->enable[1] = 0;
-                       break;
-               }
-       }
-       else {
-               data->enable[0] = 0;
-               data->enable[1] = 0;
-       }
-       if (d1_underlay_enable) {
-               switch (data->underlay_surface_type) {
-               case bw_def_420:
-                       data->enable[2] = 1;
-                       data->enable[3] = 1;
-                       break;
-               default:
-                       data->enable[2] = 1;
-                       data->enable[3] = 0;
-                       break;
-               }
-       }
-       else {
-               data->enable[2] = 0;
-               data->enable[3] = 0;
-       }
-       data->use_alpha[0] = 0;
-       data->use_alpha[1] = 0;
-       data->use_alpha[2] = 0;
-       data->use_alpha[3] = 0;
-       data->scatter_gather_enable_for_pipe[0] = vbios->scatter_gather_enable;
-       data->scatter_gather_enable_for_pipe[1] = vbios->scatter_gather_enable;
-       data->scatter_gather_enable_for_pipe[2] = vbios->scatter_gather_enable;
-       data->scatter_gather_enable_for_pipe[3] = vbios->scatter_gather_enable;
-       /*underlay0 same and graphics display pipe0*/
-       data->interlace_mode[0] = data->interlace_mode[4];
-       data->interlace_mode[1] = data->interlace_mode[4];
-       /*underlay1 same and graphics display pipe1*/
-       data->interlace_mode[2] = data->interlace_mode[5];
-       data->interlace_mode[3] = data->interlace_mode[5];
-       /*underlay0 same and graphics display pipe0*/
-       data->h_total[0] = data->h_total[4];
-       data->v_total[0] = data->v_total[4];
-       data->h_total[1] = data->h_total[4];
-       data->v_total[1] = data->v_total[4];
-       /*underlay1 same and graphics display pipe1*/
-       data->h_total[2] = data->h_total[5];
-       data->v_total[2] = data->v_total[5];
-       data->h_total[3] = data->h_total[5];
-       data->v_total[3] = data->v_total[5];
-       /*underlay0 same and graphics display pipe0*/
-       data->pixel_rate[0] = data->pixel_rate[4];
-       data->pixel_rate[1] = data->pixel_rate[4];
-       /*underlay1 same and graphics display pipe1*/
-       data->pixel_rate[2] = data->pixel_rate[5];
-       data->pixel_rate[3] = data->pixel_rate[5];
-       if ((data->underlay_tiling_mode == bw_def_array_linear_general || data->underlay_tiling_mode == bw_def_array_linear_aligned)) {
-               tiling_mode[0] = bw_def_linear;
-               tiling_mode[1] = bw_def_linear;
-               tiling_mode[2] = bw_def_linear;
-               tiling_mode[3] = bw_def_linear;
-       }
-       else {
-               tiling_mode[0] = bw_def_landscape;
-               tiling_mode[1] = bw_def_landscape;
-               tiling_mode[2] = bw_def_landscape;
-               tiling_mode[3] = bw_def_landscape;
-       }
-       data->lb_bpc[0] = data->underlay_lb_bpc;
-       data->lb_bpc[1] = data->underlay_lb_bpc;
-       data->lb_bpc[2] = data->underlay_lb_bpc;
-       data->lb_bpc[3] = data->underlay_lb_bpc;
-       data->compression_rate[0] = bw_int_to_fixed(1);
-       data->compression_rate[1] = bw_int_to_fixed(1);
-       data->compression_rate[2] = bw_int_to_fixed(1);
-       data->compression_rate[3] = bw_int_to_fixed(1);
-       data->access_one_channel_only[0] = 0;
-       data->access_one_channel_only[1] = 0;
-       data->access_one_channel_only[2] = 0;
-       data->access_one_channel_only[3] = 0;
-       data->cursor_width_pixels[0] = bw_int_to_fixed(0);
-       data->cursor_width_pixels[1] = bw_int_to_fixed(0);
-       data->cursor_width_pixels[2] = bw_int_to_fixed(0);
-       data->cursor_width_pixels[3] = bw_int_to_fixed(0);
-       /* graphics surface parameters from spreadsheet*/
-       fbc_enabled = false;
-       lpt_enabled = false;
-       for (i = 4; i <= maximum_number_of_surfaces - 3; i++) {
-               if (i < data->number_of_displays + 4) {
-                       if (i == 4 && data->d0_underlay_mode == bw_def_underlay_only) {
-                               data->enable[i] = 0;
-                               data->use_alpha[i] = 0;
-                       }
-                       else if (i == 4 && data->d0_underlay_mode == bw_def_blend) {
-                               data->enable[i] = 1;
-                               data->use_alpha[i] = 1;
-                       }
-                       else if (i == 4) {
-                               data->enable[i] = 1;
-                               data->use_alpha[i] = 0;
-                       }
-                       else if (i == 5 && data->d1_underlay_mode == bw_def_underlay_only) {
-                               data->enable[i] = 0;
-                               data->use_alpha[i] = 0;
-                       }
-                       else if (i == 5 && data->d1_underlay_mode == bw_def_blend) {
-                               data->enable[i] = 1;
-                               data->use_alpha[i] = 1;
-                       }
-                       else {
-                               data->enable[i] = 1;
-                               data->use_alpha[i] = 0;
-                       }
-               }
-               else {
-                       data->enable[i] = 0;
-                       data->use_alpha[i] = 0;
-               }
-               data->scatter_gather_enable_for_pipe[i] = vbios->scatter_gather_enable;
-               surface_type[i] = bw_def_graphics;
-               data->lb_size_per_component[i] = dceip->lb_size_per_component444;
-               if (data->graphics_tiling_mode == bw_def_array_linear_general || data->graphics_tiling_mode == bw_def_array_linear_aligned) {
-                       tiling_mode[i] = bw_def_linear;
-               }
-               else {
-                       tiling_mode[i] = bw_def_tiled;
-               }
-               data->lb_bpc[i] = data->graphics_lb_bpc;
-               if ((data->fbc_en[i] == 1 && (dceip->argb_compression_support || data->d0_underlay_mode != bw_def_blended))) {
-                       data->compression_rate[i] = bw_int_to_fixed(vbios->average_compression_rate);
-                       data->access_one_channel_only[i] = data->lpt_en[i];
-               }
-               else {
-                       data->compression_rate[i] = bw_int_to_fixed(1);
-                       data->access_one_channel_only[i] = 0;
-               }
-               if (data->fbc_en[i] == 1) {
-                       fbc_enabled = true;
-                       if (data->lpt_en[i] == 1) {
-                               lpt_enabled = true;
-                       }
-               }
-               data->cursor_width_pixels[i] = bw_int_to_fixed(vbios->cursor_width);
-       }
-       /* display_write_back420*/
-       data->scatter_gather_enable_for_pipe[maximum_number_of_surfaces - 2] = 0;
-       data->scatter_gather_enable_for_pipe[maximum_number_of_surfaces - 1] = 0;
-       if (data->d1_display_write_back_dwb_enable == 1) {
-               data->enable[maximum_number_of_surfaces - 2] = 1;
-               data->enable[maximum_number_of_surfaces - 1] = 1;
-       }
-       else {
-               data->enable[maximum_number_of_surfaces - 2] = 0;
-               data->enable[maximum_number_of_surfaces - 1] = 0;
-       }
-       surface_type[maximum_number_of_surfaces - 2] = bw_def_display_write_back420_luma;
-       surface_type[maximum_number_of_surfaces - 1] = bw_def_display_write_back420_chroma;
-       data->lb_size_per_component[maximum_number_of_surfaces - 2] = dceip->underlay420_luma_lb_size_per_component;
-       data->lb_size_per_component[maximum_number_of_surfaces - 1] = dceip->underlay420_chroma_lb_size_per_component;
-       data->bytes_per_pixel[maximum_number_of_surfaces - 2] = 1;
-       data->bytes_per_pixel[maximum_number_of_surfaces - 1] = 2;
-       data->interlace_mode[maximum_number_of_surfaces - 2] = data->interlace_mode[5];
-       data->interlace_mode[maximum_number_of_surfaces - 1] = data->interlace_mode[5];
-       data->h_taps[maximum_number_of_surfaces - 2] = bw_int_to_fixed(1);
-       data->h_taps[maximum_number_of_surfaces - 1] = bw_int_to_fixed(1);
-       data->v_taps[maximum_number_of_surfaces - 2] = bw_int_to_fixed(1);
-       data->v_taps[maximum_number_of_surfaces - 1] = bw_int_to_fixed(1);
-       data->rotation_angle[maximum_number_of_surfaces - 2] = bw_int_to_fixed(0);
-       data->rotation_angle[maximum_number_of_surfaces - 1] = bw_int_to_fixed(0);
-       tiling_mode[maximum_number_of_surfaces - 2] = bw_def_linear;
-       tiling_mode[maximum_number_of_surfaces - 1] = bw_def_linear;
-       data->lb_bpc[maximum_number_of_surfaces - 2] = 8;
-       data->lb_bpc[maximum_number_of_surfaces - 1] = 8;
-       data->compression_rate[maximum_number_of_surfaces - 2] = bw_int_to_fixed(1);
-       data->compression_rate[maximum_number_of_surfaces - 1] = bw_int_to_fixed(1);
-       data->access_one_channel_only[maximum_number_of_surfaces - 2] = 0;
-       data->access_one_channel_only[maximum_number_of_surfaces - 1] = 0;
-       /*assume display pipe1 has dwb enabled*/
-       data->h_total[maximum_number_of_surfaces - 2] = data->h_total[5];
-       data->h_total[maximum_number_of_surfaces - 1] = data->h_total[5];
-       data->v_total[maximum_number_of_surfaces - 2] = data->v_total[5];
-       data->v_total[maximum_number_of_surfaces - 1] = data->v_total[5];
-       data->pixel_rate[maximum_number_of_surfaces - 2] = data->pixel_rate[5];
-       data->pixel_rate[maximum_number_of_surfaces - 1] = data->pixel_rate[5];
-       data->src_width[maximum_number_of_surfaces - 2] = data->src_width[5];
-       data->src_width[maximum_number_of_surfaces - 1] = data->src_width[5];
-       data->src_height[maximum_number_of_surfaces - 2] = data->src_height[5];
-       data->src_height[maximum_number_of_surfaces - 1] = data->src_height[5];
-       data->pitch_in_pixels[maximum_number_of_surfaces - 2] = data->src_width[5];
-       data->pitch_in_pixels[maximum_number_of_surfaces - 1] = data->src_width[5];
-       data->h_scale_ratio[maximum_number_of_surfaces - 2] = bw_int_to_fixed(1);
-       data->h_scale_ratio[maximum_number_of_surfaces - 1] = bw_int_to_fixed(1);
-       data->v_scale_ratio[maximum_number_of_surfaces - 2] = bw_int_to_fixed(1);
-       data->v_scale_ratio[maximum_number_of_surfaces - 1] = bw_int_to_fixed(1);
-       data->stereo_mode[maximum_number_of_surfaces - 2] = bw_def_mono;
-       data->stereo_mode[maximum_number_of_surfaces - 1] = bw_def_mono;
-       data->cursor_width_pixels[maximum_number_of_surfaces - 2] = bw_int_to_fixed(0);
-       data->cursor_width_pixels[maximum_number_of_surfaces - 1] = bw_int_to_fixed(0);
-       data->use_alpha[maximum_number_of_surfaces - 2] = 0;
-       data->use_alpha[maximum_number_of_surfaces - 1] = 0;
-       /*mode check calculations:*/
-       /* mode within dce ip capabilities*/
-       /* fbc*/
-       /* hsr*/
-       /* vsr*/
-       /* lb size*/
-       /*effective scaling source and ratios:*/
-       /*for graphics, non-stereo, non-interlace surfaces when the size of the source and destination are the same, only one tap is used*/
-       /*420 chroma has half the width, height, horizontal and vertical scaling ratios than luma*/
-       /*rotating a graphic or underlay surface swaps the width, height, horizontal and vertical scaling ratios*/
-       /*in top-bottom stereo mode there is 2:1 vertical downscaling for each eye*/
-       /*in side-by-side stereo mode there is 2:1 horizontal downscaling for each eye*/
-       /*in interlace mode there is 2:1 vertical downscaling for each field*/
-       /*in panning or bezel adjustment mode the source width has an extra 128 pixels*/
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (bw_equ(data->h_scale_ratio[i], bw_int_to_fixed(1)) && bw_equ(data->v_scale_ratio[i], bw_int_to_fixed(1)) && surface_type[i] == bw_def_graphics && data->stereo_mode[i] == bw_def_mono && data->interlace_mode[i] == 0) {
-                               data->h_taps[i] = bw_int_to_fixed(1);
-                               data->v_taps[i] = bw_int_to_fixed(1);
-                       }
-                       if (surface_type[i] == bw_def_display_write_back420_chroma || surface_type[i] == bw_def_underlay420_chroma) {
-                               data->pitch_in_pixels_after_surface_type[i] = bw_div(data->pitch_in_pixels[i], bw_int_to_fixed(2));
-                               data->src_width_after_surface_type = bw_div(data->src_width[i], bw_int_to_fixed(2));
-                               data->src_height_after_surface_type = bw_div(data->src_height[i], bw_int_to_fixed(2));
-                               data->hsr_after_surface_type = bw_div(data->h_scale_ratio[i], bw_int_to_fixed(2));
-                               data->vsr_after_surface_type = bw_div(data->v_scale_ratio[i], bw_int_to_fixed(2));
-                       }
-                       else {
-                               data->pitch_in_pixels_after_surface_type[i] = data->pitch_in_pixels[i];
-                               data->src_width_after_surface_type = data->src_width[i];
-                               data->src_height_after_surface_type = data->src_height[i];
-                               data->hsr_after_surface_type = data->h_scale_ratio[i];
-                               data->vsr_after_surface_type = data->v_scale_ratio[i];
-                       }
-                       if ((bw_equ(data->rotation_angle[i], bw_int_to_fixed(90)) || bw_equ(data->rotation_angle[i], bw_int_to_fixed(270))) && surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
-                               data->src_width_after_rotation = data->src_height_after_surface_type;
-                               data->src_height_after_rotation = data->src_width_after_surface_type;
-                               data->hsr_after_rotation = data->vsr_after_surface_type;
-                               data->vsr_after_rotation = data->hsr_after_surface_type;
-                       }
-                       else {
-                               data->src_width_after_rotation = data->src_width_after_surface_type;
-                               data->src_height_after_rotation = data->src_height_after_surface_type;
-                               data->hsr_after_rotation = data->hsr_after_surface_type;
-                               data->vsr_after_rotation = data->vsr_after_surface_type;
-                       }
-                       switch (data->stereo_mode[i]) {
-                       case bw_def_top_bottom:
-                               data->source_width_pixels[i] = data->src_width_after_rotation;
-                               data->source_height_pixels = bw_mul(bw_int_to_fixed(2), data->src_height_after_rotation);
-                               data->hsr_after_stereo = data->hsr_after_rotation;
-                               data->vsr_after_stereo = bw_mul(bw_int_to_fixed(1), data->vsr_after_rotation);
-                               break;
-                       case bw_def_side_by_side:
-                               data->source_width_pixels[i] = bw_mul(bw_int_to_fixed(2), data->src_width_after_rotation);
-                               data->source_height_pixels = data->src_height_after_rotation;
-                               data->hsr_after_stereo = bw_mul(bw_int_to_fixed(1), data->hsr_after_rotation);
-                               data->vsr_after_stereo = data->vsr_after_rotation;
-                               break;
-                       default:
-                               data->source_width_pixels[i] = data->src_width_after_rotation;
-                               data->source_height_pixels = data->src_height_after_rotation;
-                               data->hsr_after_stereo = data->hsr_after_rotation;
-                               data->vsr_after_stereo = data->vsr_after_rotation;
-                               break;
-                       }
-                       data->hsr[i] = data->hsr_after_stereo;
-                       if (data->interlace_mode[i]) {
-                               data->vsr[i] = bw_mul(data->vsr_after_stereo, bw_int_to_fixed(2));
-                       }
-                       else {
-                               data->vsr[i] = data->vsr_after_stereo;
-                       }
-                       if (data->panning_and_bezel_adjustment != bw_def_none) {
-                               data->source_width_rounded_up_to_chunks[i] = bw_add(bw_floor2(bw_sub(data->source_width_pixels[i], bw_int_to_fixed(1)), bw_int_to_fixed(128)), bw_int_to_fixed(256));
-                       }
-                       else {
-                               data->source_width_rounded_up_to_chunks[i] = bw_ceil2(data->source_width_pixels[i], bw_int_to_fixed(128));
-                       }
-                       data->source_height_rounded_up_to_chunks[i] = data->source_height_pixels;
-               }
-       }
-       /*mode support checks:*/
-       /*the number of graphics and underlay pipes is limited by the ip support*/
-       /*maximum horizontal and vertical scale ratio is 4, and should not exceed the number of taps*/
-       /*for downscaling with the pre-downscaler, the horizontal scale ratio must be more than the ceiling of one quarter of the number of taps*/
-       /*the pre-downscaler reduces the line buffer source by the horizontal scale ratio*/
-       /*the number of lines in the line buffer has to exceed the number of vertical taps*/
-       /*the size of the line in the line buffer is the product of the source width and the bits per component, rounded up to a multiple of 48*/
-       /*the size of the line in the line buffer in the case of 10 bit per component is the product of the source width rounded up to multiple of 8 and 30.023438 / 3, rounded up to a multiple of 48*/
-       /*the size of the line in the line buffer in the case of 8 bit per component is the product of the source width rounded up to multiple of 8 and 30.023438 / 3, rounded up to a multiple of 48*/
-       /*frame buffer compression is not supported with stereo mode, rotation, or non- 888 formats*/
-       /*rotation is not supported with linear of stereo modes*/
-       if (dceip->number_of_graphics_pipes >= data->number_of_displays && dceip->number_of_underlay_pipes >= data->number_of_underlay_surfaces && !(dceip->display_write_back_supported == 0 && data->d1_display_write_back_dwb_enable == 1)) {
-               pipe_check = bw_def_ok;
-       }
-       else {
-               pipe_check = bw_def_notok;
-       }
-       hsr_check = bw_def_ok;
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (bw_neq(data->hsr[i], bw_int_to_fixed(1))) {
-                               if (bw_mtn(data->hsr[i], bw_int_to_fixed(4))) {
-                                       hsr_check = bw_def_hsr_mtn_4;
-                               }
-                               else {
-                                       if (bw_mtn(data->hsr[i], data->h_taps[i])) {
-                                               hsr_check = bw_def_hsr_mtn_h_taps;
-                                       }
-                                       else {
-                                               if (dceip->pre_downscaler_enabled == 1 && bw_mtn(data->hsr[i], bw_int_to_fixed(1)) && bw_leq(data->hsr[i], bw_ceil2(bw_div(data->h_taps[i], bw_int_to_fixed(4)), bw_int_to_fixed(1)))) {
-                                                       hsr_check = bw_def_ceiling__h_taps_div_4___meq_hsr;
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-       vsr_check = bw_def_ok;
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (bw_neq(data->vsr[i], bw_int_to_fixed(1))) {
-                               if (bw_mtn(data->vsr[i], bw_int_to_fixed(4))) {
-                                       vsr_check = bw_def_vsr_mtn_4;
-                               }
-                               else {
-                                       if (bw_mtn(data->vsr[i], data->v_taps[i])) {
-                                               vsr_check = bw_def_vsr_mtn_v_taps;
-                                       }
-                               }
-                       }
-               }
-       }
-       lb_size_check = bw_def_ok;
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if ((dceip->pre_downscaler_enabled && bw_mtn(data->hsr[i], bw_int_to_fixed(1)))) {
-                               data->source_width_in_lb = bw_div(data->source_width_pixels[i], data->hsr[i]);
-                       }
-                       else {
-                               data->source_width_in_lb = data->source_width_pixels[i];
-                       }
-                       switch (data->lb_bpc[i]) {
-                       case 8:
-                               data->lb_line_pitch = bw_ceil2(bw_mul(bw_div(bw_frc_to_fixed(2401171875ul, 100000000), bw_int_to_fixed(3)), bw_ceil2(data->source_width_in_lb, bw_int_to_fixed(8))), bw_int_to_fixed(48));
-                               break;
-                       case 10:
-                               data->lb_line_pitch = bw_ceil2(bw_mul(bw_div(bw_frc_to_fixed(300234375, 10000000), bw_int_to_fixed(3)), bw_ceil2(data->source_width_in_lb, bw_int_to_fixed(8))), bw_int_to_fixed(48));
-                               break;
-                       default:
-                               data->lb_line_pitch = bw_ceil2(bw_mul(bw_int_to_fixed(data->lb_bpc[i]), data->source_width_in_lb), bw_int_to_fixed(48));
-                               break;
-                       }
-                       data->lb_partitions[i] = bw_floor2(bw_div(data->lb_size_per_component[i], data->lb_line_pitch), bw_int_to_fixed(1));
-                       /*clamp the partitions to the maxium number supported by the lb*/
-                       if ((surface_type[i] != bw_def_graphics || dceip->graphics_lb_nodownscaling_multi_line_prefetching == 1)) {
-                               data->lb_partitions_max[i] = bw_int_to_fixed(10);
-                       }
-                       else {
-                               data->lb_partitions_max[i] = bw_int_to_fixed(7);
-                       }
-                       data->lb_partitions[i] = bw_min2(data->lb_partitions_max[i], data->lb_partitions[i]);
-                       if (bw_mtn(bw_add(data->v_taps[i], bw_int_to_fixed(1)), data->lb_partitions[i])) {
-                               lb_size_check = bw_def_notok;
-                       }
-               }
-       }
-       fbc_check = bw_def_ok;
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i] && data->fbc_en[i] == 1 && (bw_equ(data->rotation_angle[i], bw_int_to_fixed(90)) || bw_equ(data->rotation_angle[i], bw_int_to_fixed(270)) || data->stereo_mode[i] != bw_def_mono || data->bytes_per_pixel[i] != 4)) {
-                       fbc_check = bw_def_invalid_rotation_or_bpp_or_stereo;
-               }
-       }
-       rotation_check = bw_def_ok;
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if ((bw_equ(data->rotation_angle[i], bw_int_to_fixed(90)) || bw_equ(data->rotation_angle[i], bw_int_to_fixed(270))) && (tiling_mode[i] == bw_def_linear || data->stereo_mode[i] != bw_def_mono)) {
-                               rotation_check = bw_def_invalid_linear_or_stereo_mode;
-                       }
-               }
-       }
-       if (pipe_check == bw_def_ok && hsr_check == bw_def_ok && vsr_check == bw_def_ok && lb_size_check == bw_def_ok && fbc_check == bw_def_ok && rotation_check == bw_def_ok) {
-               mode_check = bw_def_ok;
-       }
-       else {
-               mode_check = bw_def_notok;
-       }
-       /*number of memory channels for write-back client*/
-       data->number_of_dram_wrchannels = vbios->number_of_dram_channels;
-       data->number_of_dram_channels = vbios->number_of_dram_channels;
-       /*modify number of memory channels if lpt mode is enabled*/
-       /* low power tiling mode register*/
-       /* 0 = use channel 0*/
-       /* 1 = use channel 0 and 1*/
-       /* 2 = use channel 0,1,2,3*/
-       if ((fbc_enabled == 1 && lpt_enabled == 1)) {
-               if (vbios->memory_type == bw_def_hbm)
-                       data->dram_efficiency = bw_frc_to_fixed(5, 10);
-               else
-                       data->dram_efficiency = bw_int_to_fixed(1);
-
-
-               if (dceip->low_power_tiling_mode == 0) {
-                       data->number_of_dram_channels = 1;
-               }
-               else if (dceip->low_power_tiling_mode == 1) {
-                       data->number_of_dram_channels = 2;
-               }
-               else if (dceip->low_power_tiling_mode == 2) {
-                       data->number_of_dram_channels = 4;
-               }
-               else {
-                       data->number_of_dram_channels = 1;
-               }
-       }
-       else {
-               if (vbios->memory_type == bw_def_hbm)
-                       data->dram_efficiency = bw_frc_to_fixed(5, 10);
-               else
-                       data->dram_efficiency = bw_frc_to_fixed(8, 10);
-       }
-       /*memory request size and latency hiding:*/
-       /*request size is normally 64 byte, 2-line interleaved, with full latency hiding*/
-       /*the display write-back requests are single line*/
-       /*for tiled graphics surfaces, or undelay surfaces with width higher than the maximum size for full efficiency, request size is 32 byte in 8 and 16 bpp or if the rotation is orthogonal to the tiling grain. only half is useful of the bytes in the request size in 8 bpp or in 32 bpp if the rotation is orthogonal to the tiling grain.*/
-       /*for undelay surfaces with width lower than the maximum size for full efficiency, requests are 4-line interleaved in 16bpp if the rotation is parallel to the tiling grain, and 8-line interleaved with 4-line latency hiding in 8bpp or if the rotation is orthogonal to the tiling grain.*/
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if ((bw_equ(data->rotation_angle[i], bw_int_to_fixed(90)) || bw_equ(data->rotation_angle[i], bw_int_to_fixed(270)))) {
-                               if ((i < 4)) {
-                                       /*underlay portrait tiling mode is not supported*/
-                                       data->orthogonal_rotation[i] = 1;
-                               }
-                               else {
-                                       /*graphics portrait tiling mode*/
-                                       if (data->graphics_micro_tile_mode == bw_def_rotated_micro_tiling) {
-                                               data->orthogonal_rotation[i] = 0;
-                                       }
-                                       else {
-                                               data->orthogonal_rotation[i] = 1;
-                                       }
-                               }
-                       }
-                       else {
-                               if ((i < 4)) {
-                                       /*underlay landscape tiling mode is only supported*/
-                                       if (data->underlay_micro_tile_mode == bw_def_display_micro_tiling) {
-                                               data->orthogonal_rotation[i] = 0;
-                                       }
-                                       else {
-                                               data->orthogonal_rotation[i] = 1;
-                                       }
-                               }
-                               else {
-                                       /*graphics landscape tiling mode*/
-                                       if (data->graphics_micro_tile_mode == bw_def_display_micro_tiling) {
-                                               data->orthogonal_rotation[i] = 0;
-                                       }
-                                       else {
-                                               data->orthogonal_rotation[i] = 1;
-                                       }
-                               }
-                       }
-                       if (bw_equ(data->rotation_angle[i], bw_int_to_fixed(90)) || bw_equ(data->rotation_angle[i], bw_int_to_fixed(270))) {
-                               data->underlay_maximum_source_efficient_for_tiling = dceip->underlay_maximum_height_efficient_for_tiling;
-                       }
-                       else {
-                               data->underlay_maximum_source_efficient_for_tiling = dceip->underlay_maximum_width_efficient_for_tiling;
-                       }
-                       if (surface_type[i] == bw_def_display_write_back420_luma || surface_type[i] == bw_def_display_write_back420_chroma) {
-                               data->bytes_per_request[i] = bw_int_to_fixed(64);
-                               data->useful_bytes_per_request[i] = bw_int_to_fixed(64);
-                               data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(1);
-                               data->latency_hiding_lines[i] = bw_int_to_fixed(1);
-                       }
-                       else if (tiling_mode[i] == bw_def_linear) {
-                               data->bytes_per_request[i] = bw_int_to_fixed(64);
-                               data->useful_bytes_per_request[i] = bw_int_to_fixed(64);
-                               data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(2);
-                               data->latency_hiding_lines[i] = bw_int_to_fixed(2);
-                       }
-                       else {
-                               if (surface_type[i] == bw_def_graphics || (bw_mtn(data->source_width_rounded_up_to_chunks[i], bw_ceil2(data->underlay_maximum_source_efficient_for_tiling, bw_int_to_fixed(256))))) {
-                                       switch (data->bytes_per_pixel[i]) {
-                                       case 8:
-                                               data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(2);
-                                               data->latency_hiding_lines[i] = bw_int_to_fixed(2);
-                                               if (data->orthogonal_rotation[i]) {
-                                                       data->bytes_per_request[i] = bw_int_to_fixed(32);
-                                                       data->useful_bytes_per_request[i] = bw_int_to_fixed(32);
-                                               }
-                                               else {
-                                                       data->bytes_per_request[i] = bw_int_to_fixed(64);
-                                                       data->useful_bytes_per_request[i] = bw_int_to_fixed(64);
-                                               }
-                                               break;
-                                       case 4:
-                                               if (data->orthogonal_rotation[i]) {
-                                                       data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(2);
-                                                       data->latency_hiding_lines[i] = bw_int_to_fixed(2);
-                                                       data->bytes_per_request[i] = bw_int_to_fixed(32);
-                                                       data->useful_bytes_per_request[i] = bw_int_to_fixed(16);
-                                               }
-                                               else {
-                                                       data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(2);
-                                                       data->latency_hiding_lines[i] = bw_int_to_fixed(2);
-                                                       data->bytes_per_request[i] = bw_int_to_fixed(64);
-                                                       data->useful_bytes_per_request[i] = bw_int_to_fixed(64);
-                                               }
-                                               break;
-                                       case 2:
-                                               data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(2);
-                                               data->latency_hiding_lines[i] = bw_int_to_fixed(2);
-                                               data->bytes_per_request[i] = bw_int_to_fixed(32);
-                                               data->useful_bytes_per_request[i] = bw_int_to_fixed(32);
-                                               break;
-                                       default:
-                                               data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(2);
-                                               data->latency_hiding_lines[i] = bw_int_to_fixed(2);
-                                               data->bytes_per_request[i] = bw_int_to_fixed(32);
-                                               data->useful_bytes_per_request[i] = bw_int_to_fixed(16);
-                                               break;
-                                       }
-                               }
-                               else {
-                                       data->bytes_per_request[i] = bw_int_to_fixed(64);
-                                       data->useful_bytes_per_request[i] = bw_int_to_fixed(64);
-                                       if (data->orthogonal_rotation[i]) {
-                                               data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(8);
-                                               data->latency_hiding_lines[i] = bw_int_to_fixed(4);
-                                       }
-                                       else {
-                                               switch (data->bytes_per_pixel[i]) {
-                                               case 4:
-                                                       data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(2);
-                                                       data->latency_hiding_lines[i] = bw_int_to_fixed(2);
-                                                       break;
-                                               case 2:
-                                                       data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(4);
-                                                       data->latency_hiding_lines[i] = bw_int_to_fixed(4);
-                                                       break;
-                                               default:
-                                                       data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(8);
-                                                       data->latency_hiding_lines[i] = bw_int_to_fixed(4);
-                                                       break;
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-       /*requested peak bandwidth:*/
-       /*the peak request-per-second bandwidth is the product of the maximum source lines in per line out in the beginning*/
-       /*and in the middle of the frame, the ratio of the source width to the line time, the ratio of line interleaving*/
-       /*in memory to lines of latency hiding, and the ratio of bytes per pixel to useful bytes per request.*/
-       /**/
-       /*if the dmif data buffer size holds more than vta_ps worth of source lines, then only vsr is used.*/
-       /*the peak bandwidth is the peak request-per-second bandwidth times the request size.*/
-       /**/
-       /*the line buffer lines in per line out in the beginning of the frame is the vertical filter initialization value*/
-       /*rounded up to even and divided by the line times for initialization, which is normally three.*/
-       /*the line buffer lines in per line out in the middle of the frame is at least one, or the vertical scale ratio,*/
-       /*rounded up to line pairs if not doing line buffer prefetching.*/
-       /**/
-       /*the non-prefetching rounding up of the vertical scale ratio can also be done up to 1 (for a 0,2 pattern), 4/3 (for a 0,2,2 pattern),*/
-       /*6/4 (for a 0,2,2,2 pattern), or 3 (for a 2,4 pattern).*/
-       /**/
-       /*the scaler vertical filter initialization value is calculated by the hardware as the floor of the average of the*/
-       /*vertical scale ratio and the number of vertical taps increased by one.  add one more for possible odd line*/
-       /*panning/bezel adjustment mode.*/
-       /**/
-       /*for the bottom interlace field an extra 50% of the vertical scale ratio is considered for this calculation.*/
-       /*in top-bottom stereo mode software has to set the filter initialization value manually and explicitly limit it to 4.*/
-       /*furthermore, there is only one line time for initialization.*/
-       /**/
-       /*line buffer prefetching is done when the number of lines in the line buffer exceeds the number of taps plus*/
-       /*the ceiling of the vertical scale ratio.*/
-       /**/
-       /*multi-line buffer prefetching is only done in the graphics pipe when the scaler is disabled or when upscaling and the vsr <= 0.8.'*/
-       /**/
-       /*the horizontal blank and chunk granularity factor is indirectly used indicate the interval of time required to transfer the source pixels.*/
-       /*the denominator of this term represents the total number of destination output pixels required for the input source pixels.*/
-       /*it applies when the lines in per line out is not 2 or 4.  it does not apply when there is a line buffer between the scl and blnd.*/
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       data->v_filter_init[i] = bw_floor2(bw_div((bw_add(bw_add(bw_add(bw_int_to_fixed(1), data->v_taps[i]), data->vsr[i]), bw_mul(bw_mul(bw_int_to_fixed(data->interlace_mode[i]), bw_frc_to_fixed(5, 10)), data->vsr[i]))), bw_int_to_fixed(2)), bw_int_to_fixed(1));
-                       if (data->panning_and_bezel_adjustment == bw_def_any_lines) {
-                               data->v_filter_init[i] = bw_add(data->v_filter_init[i], bw_int_to_fixed(1));
-                       }
-                       if (data->stereo_mode[i] == bw_def_top_bottom) {
-                               data->v_filter_init[i] = bw_min2(data->v_filter_init[i], bw_int_to_fixed(4));
-                       }
-                       if (data->stereo_mode[i] == bw_def_top_bottom) {
-                               data->num_lines_at_frame_start = bw_int_to_fixed(1);
-                       }
-                       else {
-                               data->num_lines_at_frame_start = bw_int_to_fixed(3);
-                       }
-                       if ((bw_mtn(data->vsr[i], bw_int_to_fixed(1)) && surface_type[i] == bw_def_graphics) || data->panning_and_bezel_adjustment == bw_def_any_lines) {
-                               data->line_buffer_prefetch[i] = 0;
-                       }
-                       else if ((((dceip->underlay_downscale_prefetch_enabled == 1 && surface_type[i] != bw_def_graphics) || surface_type[i] == bw_def_graphics) && (bw_mtn(data->lb_partitions[i], bw_add(data->v_taps[i], bw_ceil2(data->vsr[i], bw_int_to_fixed(1))))))) {
-                               data->line_buffer_prefetch[i] = 1;
-                       }
-                       else {
-                               data->line_buffer_prefetch[i] = 0;
-                       }
-                       data->lb_lines_in_per_line_out_in_beginning_of_frame[i] = bw_div(bw_ceil2(data->v_filter_init[i], bw_int_to_fixed(dceip->lines_interleaved_into_lb)), data->num_lines_at_frame_start);
-                       if (data->line_buffer_prefetch[i] == 1) {
-                               data->lb_lines_in_per_line_out_in_middle_of_frame[i] = bw_max2(bw_int_to_fixed(1), data->vsr[i]);
-                       }
-                       else if (bw_leq(data->vsr[i], bw_int_to_fixed(1))) {
-                               data->lb_lines_in_per_line_out_in_middle_of_frame[i] = bw_int_to_fixed(1);
-                       } else if (bw_leq(data->vsr[i],
-                                       bw_frc_to_fixed(4, 3))) {
-                               data->lb_lines_in_per_line_out_in_middle_of_frame[i] = bw_div(bw_int_to_fixed(4), bw_int_to_fixed(3));
-                       } else if (bw_leq(data->vsr[i],
-                                       bw_frc_to_fixed(6, 4))) {
-                               data->lb_lines_in_per_line_out_in_middle_of_frame[i] = bw_div(bw_int_to_fixed(6), bw_int_to_fixed(4));
-                       }
-                       else if (bw_leq(data->vsr[i], bw_int_to_fixed(2))) {
-                               data->lb_lines_in_per_line_out_in_middle_of_frame[i] = bw_int_to_fixed(2);
-                       }
-                       else if (bw_leq(data->vsr[i], bw_int_to_fixed(3))) {
-                               data->lb_lines_in_per_line_out_in_middle_of_frame[i] = bw_int_to_fixed(3);
-                       }
-                       else {
-                               data->lb_lines_in_per_line_out_in_middle_of_frame[i] = bw_int_to_fixed(4);
-                       }
-                       if (data->line_buffer_prefetch[i] == 1 || bw_equ(data->lb_lines_in_per_line_out_in_middle_of_frame[i], bw_int_to_fixed(2)) || bw_equ(data->lb_lines_in_per_line_out_in_middle_of_frame[i], bw_int_to_fixed(4))) {
-                               data->horizontal_blank_and_chunk_granularity_factor[i] = bw_int_to_fixed(1);
-                       }
-                       else {
-                               data->horizontal_blank_and_chunk_granularity_factor[i] = bw_div(data->h_total[i], (bw_div((bw_add(data->h_total[i], bw_div((bw_sub(data->source_width_pixels[i], bw_int_to_fixed(dceip->chunk_width))), data->hsr[i]))), bw_int_to_fixed(2))));
-                       }
-                       data->request_bandwidth[i] = bw_div(bw_mul(bw_div(bw_mul(bw_div(bw_mul(bw_max2(data->lb_lines_in_per_line_out_in_beginning_of_frame[i], data->lb_lines_in_per_line_out_in_middle_of_frame[i]), data->source_width_rounded_up_to_chunks[i]), (bw_div(data->h_total[i], data->pixel_rate[i]))), bw_int_to_fixed(data->bytes_per_pixel[i])), data->useful_bytes_per_request[i]), data->lines_interleaved_in_mem_access[i]), data->latency_hiding_lines[i]);
-                       data->display_bandwidth[i] = bw_mul(data->request_bandwidth[i], data->bytes_per_request[i]);
-               }
-       }
-       /*outstanding chunk request limit*/
-       /*if underlay buffer sharing is enabled, the data buffer size for underlay in 422 or 444 is the sum of the luma and chroma data buffer sizes.*/
-       /*underlay buffer sharing mode is only permitted in orthogonal rotation modes.*/
-       /**/
-       /*if there is only one display enabled, the dmif data buffer size for the graphics surface is increased by concatenating the adjacent buffers.*/
-       /**/
-       /*the memory chunk size in bytes is 1024 for the writeback, and 256 times the memory line interleaving and the bytes per pixel for graphics*/
-       /*and underlay.*/
-       /**/
-       /*the pipe chunk size uses 2 for line interleaving, except for the write back, in which case it is 1.*/
-       /*graphics and underlay data buffer size is adjusted (limited) using the outstanding chunk request limit if there is more than one*/
-       /*display enabled or if the dmif request buffer is not large enough for the total data buffer size.*/
-       /*the outstanding chunk request limit is the ceiling of the adjusted data buffer size divided by the chunk size in bytes*/
-       /*the adjusted data buffer size is the product of the display bandwidth and the minimum effective data buffer size in terms of time,*/
-       /*rounded up to the chunk size in bytes, but should not exceed the original data buffer size*/
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if ((dceip->dmif_pipe_en_fbc_chunk_tracker + 3 == i && fbc_enabled == 0 && tiling_mode[i] != bw_def_linear)) {
-                               data->max_chunks_non_fbc_mode[i] = 128 - dmif_chunk_buff_margin;
-                       }
-                       else {
-                               data->max_chunks_non_fbc_mode[i] = 16 - dmif_chunk_buff_margin;
-                       }
-               }
-               if (data->fbc_en[i] == 1) {
-                       max_chunks_fbc_mode = 128 - dmif_chunk_buff_margin;
-               }
-       }
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       switch (surface_type[i]) {
-                       case bw_def_display_write_back420_luma:
-                               data->data_buffer_size[i] = bw_int_to_fixed(dceip->display_write_back420_luma_mcifwr_buffer_size);
-                               break;
-                       case bw_def_display_write_back420_chroma:
-                               data->data_buffer_size[i] = bw_int_to_fixed(dceip->display_write_back420_chroma_mcifwr_buffer_size);
-                               break;
-                       case bw_def_underlay420_luma:
-                               data->data_buffer_size[i] = bw_int_to_fixed(dceip->underlay_luma_dmif_size);
-                               break;
-                       case bw_def_underlay420_chroma:
-                               data->data_buffer_size[i] = bw_div(bw_int_to_fixed(dceip->underlay_chroma_dmif_size), bw_int_to_fixed(2));
-                               break;
-                       case bw_def_underlay422:case bw_def_underlay444:
-                               if (data->orthogonal_rotation[i] == 0) {
-                                       data->data_buffer_size[i] = bw_int_to_fixed(dceip->underlay_luma_dmif_size);
-                               }
-                               else {
-                                       data->data_buffer_size[i] = bw_add(bw_int_to_fixed(dceip->underlay_luma_dmif_size), bw_int_to_fixed(dceip->underlay_chroma_dmif_size));
-                               }
-                               break;
-                       default:
-                               if (data->fbc_en[i] == 1) {
-                                       /*data_buffer_size(i) = max_dmif_buffer_allocated * graphics_dmif_size*/
-                                       if (data->number_of_displays == 1) {
-                                               data->data_buffer_size[i] = bw_min2(bw_mul(bw_mul(bw_int_to_fixed(max_chunks_fbc_mode), bw_int_to_fixed(pixels_per_chunk)), bw_int_to_fixed(data->bytes_per_pixel[i])), bw_mul(bw_int_to_fixed(dceip->max_dmif_buffer_allocated), bw_int_to_fixed(dceip->graphics_dmif_size)));
-                                       }
-                                       else {
-                                               data->data_buffer_size[i] = bw_min2(bw_mul(bw_mul(bw_int_to_fixed(max_chunks_fbc_mode), bw_int_to_fixed(pixels_per_chunk)), bw_int_to_fixed(data->bytes_per_pixel[i])), bw_int_to_fixed(dceip->graphics_dmif_size));
-                                       }
-                               }
-                               else {
-                                       /*the effective dmif buffer size in non-fbc mode is limited by the 16 entry chunk tracker*/
-                                       if (data->number_of_displays == 1) {
-                                               data->data_buffer_size[i] = bw_min2(bw_mul(bw_mul(bw_int_to_fixed(data->max_chunks_non_fbc_mode[i]), bw_int_to_fixed(pixels_per_chunk)), bw_int_to_fixed(data->bytes_per_pixel[i])), bw_mul(bw_int_to_fixed(dceip->max_dmif_buffer_allocated), bw_int_to_fixed(dceip->graphics_dmif_size)));
-                                       }
-                                       else {
-                                               data->data_buffer_size[i] = bw_min2(bw_mul(bw_mul(bw_int_to_fixed(data->max_chunks_non_fbc_mode[i]), bw_int_to_fixed(pixels_per_chunk)), bw_int_to_fixed(data->bytes_per_pixel[i])), bw_int_to_fixed(dceip->graphics_dmif_size));
-                                       }
-                               }
-                               break;
-                       }
-                       if (surface_type[i] == bw_def_display_write_back420_luma || surface_type[i] == bw_def_display_write_back420_chroma) {
-                               data->memory_chunk_size_in_bytes[i] = bw_int_to_fixed(1024);
-                               data->pipe_chunk_size_in_bytes[i] = bw_int_to_fixed(1024);
-                       }
-                       else {
-                               data->memory_chunk_size_in_bytes[i] = bw_mul(bw_mul(bw_int_to_fixed(dceip->chunk_width), data->lines_interleaved_in_mem_access[i]), bw_int_to_fixed(data->bytes_per_pixel[i]));
-                               data->pipe_chunk_size_in_bytes[i] = bw_mul(bw_mul(bw_int_to_fixed(dceip->chunk_width), bw_int_to_fixed(dceip->lines_interleaved_into_lb)), bw_int_to_fixed(data->bytes_per_pixel[i]));
-                       }
-               }
-       }
-       data->min_dmif_size_in_time = bw_int_to_fixed(9999);
-       data->min_mcifwr_size_in_time = bw_int_to_fixed(9999);
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
-                               if (bw_ltn(bw_div(bw_div(bw_mul(data->data_buffer_size[i], data->bytes_per_request[i]), data->useful_bytes_per_request[i]), data->display_bandwidth[i]), data->min_dmif_size_in_time)) {
-                                       data->min_dmif_size_in_time = bw_div(bw_div(bw_mul(data->data_buffer_size[i], data->bytes_per_request[i]), data->useful_bytes_per_request[i]), data->display_bandwidth[i]);
-                               }
-                       }
-                       else {
-                               if (bw_ltn(bw_div(bw_div(bw_mul(data->data_buffer_size[i], data->bytes_per_request[i]), data->useful_bytes_per_request[i]), data->display_bandwidth[i]), data->min_mcifwr_size_in_time)) {
-                                       data->min_mcifwr_size_in_time = bw_div(bw_div(bw_mul(data->data_buffer_size[i], data->bytes_per_request[i]), data->useful_bytes_per_request[i]), data->display_bandwidth[i]);
-                               }
-                       }
-               }
-       }
-       data->total_requests_for_dmif_size = bw_int_to_fixed(0);
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i] && surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
-                       data->total_requests_for_dmif_size = bw_add(data->total_requests_for_dmif_size, bw_div(data->data_buffer_size[i], data->useful_bytes_per_request[i]));
-               }
-       }
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma && dceip->limit_excessive_outstanding_dmif_requests && (data->number_of_displays > 1 || bw_mtn(data->total_requests_for_dmif_size, dceip->dmif_request_buffer_size))) {
-                               data->adjusted_data_buffer_size[i] = bw_min2(data->data_buffer_size[i], bw_ceil2(bw_mul(data->min_dmif_size_in_time, data->display_bandwidth[i]), data->memory_chunk_size_in_bytes[i]));
-                       }
-                       else {
-                               data->adjusted_data_buffer_size[i] = data->data_buffer_size[i];
-                       }
-               }
-       }
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (data->number_of_displays == 1 && data->number_of_underlay_surfaces == 0) {
-                               /*set maximum chunk limit if only one graphic pipe is enabled*/
-                               data->outstanding_chunk_request_limit[i] = bw_int_to_fixed(127);
-                       }
-                       else {
-                               data->outstanding_chunk_request_limit[i] = bw_ceil2(bw_div(data->adjusted_data_buffer_size[i], data->pipe_chunk_size_in_bytes[i]), bw_int_to_fixed(1));
-                               /*clamp maximum chunk limit in the graphic display pipe*/
-                               if (i >= 4) {
-                                       data->outstanding_chunk_request_limit[i] = bw_max2(bw_int_to_fixed(127), data->outstanding_chunk_request_limit[i]);
-                               }
-                       }
-               }
-       }
-       /*outstanding pte request limit*/
-       /*in tiling mode with no rotation the sg pte requests are 8 useful pt_es, the sg row height is the page height and the sg page width x height is 64x64 for 8bpp, 64x32 for 16 bpp, 32x32 for 32 bpp*/
-       /*in tiling mode with rotation the sg pte requests are only one useful pte, and the sg row height is also the page height, but the sg page width and height are swapped*/
-       /*in linear mode the pte requests are 8 useful pt_es, the sg page width is 4096 divided by the bytes per pixel, the sg page height is 1, but there is just one row whose height is the lines of pte prefetching*/
-       /*the outstanding pte request limit is obtained by multiplying the outstanding chunk request limit by the peak pte request to eviction limiting ratio, rounding up to integer, multiplying by the pte requests per chunk, and rounding up to integer again*/
-       /*if not using peak pte request to eviction limiting, the outstanding pte request limit is the pte requests in the vblank*/
-       /*the pte requests in the vblank is the product of the number of pte request rows times the number of pte requests in a row*/
-       /*the number of pte requests in a row is the quotient of the source width divided by 256, multiplied by the pte requests per chunk, rounded up to even, multiplied by the scatter-gather row height and divided by the scatter-gather page height*/
-       /*the pte requests per chunk is 256 divided by the scatter-gather page width and the useful pt_es per pte request*/
-       if (data->number_of_displays > 1 || (bw_neq(data->rotation_angle[4], bw_int_to_fixed(0)) && bw_neq(data->rotation_angle[4], bw_int_to_fixed(180)))) {
-               data->peak_pte_request_to_eviction_ratio_limiting = dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display;
-       }
-       else {
-               data->peak_pte_request_to_eviction_ratio_limiting = dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation;
-       }
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i] && data->scatter_gather_enable_for_pipe[i] == 1) {
-                       if (tiling_mode[i] == bw_def_linear) {
-                               data->useful_pte_per_pte_request = bw_int_to_fixed(8);
-                               data->scatter_gather_page_width[i] = bw_div(bw_int_to_fixed(4096), bw_int_to_fixed(data->bytes_per_pixel[i]));
-                               data->scatter_gather_page_height[i] = bw_int_to_fixed(1);
-                               data->scatter_gather_pte_request_rows = bw_int_to_fixed(1);
-                               data->scatter_gather_row_height = bw_int_to_fixed(dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode);
-                       }
-                       else if (bw_equ(data->rotation_angle[i], bw_int_to_fixed(0)) || bw_equ(data->rotation_angle[i], bw_int_to_fixed(180))) {
-                               data->useful_pte_per_pte_request = bw_int_to_fixed(8);
-                               switch (data->bytes_per_pixel[i]) {
-                               case 4:
-                                       data->scatter_gather_page_width[i] = bw_int_to_fixed(32);
-                                       data->scatter_gather_page_height[i] = bw_int_to_fixed(32);
-                                       break;
-                               case 2:
-                                       data->scatter_gather_page_width[i] = bw_int_to_fixed(64);
-                                       data->scatter_gather_page_height[i] = bw_int_to_fixed(32);
-                                       break;
-                               default:
-                                       data->scatter_gather_page_width[i] = bw_int_to_fixed(64);
-                                       data->scatter_gather_page_height[i] = bw_int_to_fixed(64);
-                                       break;
-                               }
-                               data->scatter_gather_pte_request_rows = bw_int_to_fixed(dceip->scatter_gather_pte_request_rows_in_tiling_mode);
-                               data->scatter_gather_row_height = data->scatter_gather_page_height[i];
-                       }
-                       else {
-                               data->useful_pte_per_pte_request = bw_int_to_fixed(1);
-                               switch (data->bytes_per_pixel[i]) {
-                               case 4:
-                                       data->scatter_gather_page_width[i] = bw_int_to_fixed(32);
-                                       data->scatter_gather_page_height[i] = bw_int_to_fixed(32);
-                                       break;
-                               case 2:
-                                       data->scatter_gather_page_width[i] = bw_int_to_fixed(32);
-                                       data->scatter_gather_page_height[i] = bw_int_to_fixed(64);
-                                       break;
-                               default:
-                                       data->scatter_gather_page_width[i] = bw_int_to_fixed(64);
-                                       data->scatter_gather_page_height[i] = bw_int_to_fixed(64);
-                                       break;
-                               }
-                               data->scatter_gather_pte_request_rows = bw_int_to_fixed(dceip->scatter_gather_pte_request_rows_in_tiling_mode);
-                               data->scatter_gather_row_height = data->scatter_gather_page_height[i];
-                       }
-                       data->pte_request_per_chunk[i] = bw_div(bw_div(bw_int_to_fixed(dceip->chunk_width), data->scatter_gather_page_width[i]), data->useful_pte_per_pte_request);
-                       data->scatter_gather_pte_requests_in_row[i] = bw_div(bw_mul(bw_ceil2(bw_mul(bw_div(data->source_width_rounded_up_to_chunks[i], bw_int_to_fixed(dceip->chunk_width)), data->pte_request_per_chunk[i]), bw_int_to_fixed(1)), data->scatter_gather_row_height), data->scatter_gather_page_height[i]);
-                       data->scatter_gather_pte_requests_in_vblank = bw_mul(data->scatter_gather_pte_request_rows, data->scatter_gather_pte_requests_in_row[i]);
-                       if (bw_equ(data->peak_pte_request_to_eviction_ratio_limiting, bw_int_to_fixed(0))) {
-                               data->scatter_gather_pte_request_limit[i] = data->scatter_gather_pte_requests_in_vblank;
-                       }
-                       else {
-                               data->scatter_gather_pte_request_limit[i] = bw_max2(dceip->minimum_outstanding_pte_request_limit, bw_min2(data->scatter_gather_pte_requests_in_vblank, bw_ceil2(bw_mul(bw_mul(bw_div(bw_ceil2(data->adjusted_data_buffer_size[i], data->memory_chunk_size_in_bytes[i]), data->memory_chunk_size_in_bytes[i]), data->pte_request_per_chunk[i]), data->peak_pte_request_to_eviction_ratio_limiting), bw_int_to_fixed(1))));
-                       }
-               }
-       }
-       /*pitch padding recommended for efficiency in linear mode*/
-       /*in linear mode graphics or underlay with scatter gather, a pitch that is a multiple of the channel interleave (256 bytes) times the channel-bank rotation is not efficient*/
-       /*if that is the case it is recommended to pad the pitch by at least 256 pixels*/
-       data->inefficient_linear_pitch_in_bytes = bw_mul(bw_mul(bw_int_to_fixed(256), bw_int_to_fixed(vbios->number_of_dram_banks)), bw_int_to_fixed(data->number_of_dram_channels));
-
-       /*pixel transfer time*/
-       /*the dmif and mcifwr yclk(pclk) required is the one that allows the transfer of all pipe's data buffer size in memory in the time for data transfer*/
-       /*for dmif, pte and cursor requests have to be included.*/
-       /*the dram data requirement is doubled when the data request size in bytes is less than the dram channel width times the burst size (8)*/
-       /*the dram data requirement is also multiplied by the number of channels in the case of low power tiling*/
-       /*the page close-open time is determined by trc and the number of page close-opens*/
-       /*in tiled mode graphics or underlay with scatter-gather enabled the bytes per page close-open is the product of the memory line interleave times the maximum of the scatter-gather page width and the product of the tile width (8 pixels) times the number of channels times the number of banks.*/
-       /*in linear mode graphics or underlay with scatter-gather enabled and inefficient pitch, the bytes per page close-open is the line request alternation slice, because different lines are in completely different 4k address bases.*/
-       /*otherwise, the bytes page close-open is the chunk size because that is the arbitration slice.*/
-       /*pte requests are grouped by pte requests per chunk if that is more than 1. each group costs a page close-open time for dmif reads*/
-       /*cursor requests outstanding are limited to a group of two source lines. each group costs a page close-open time for dmif reads*/
-       /*the display reads and writes time for data transfer is the minimum data or cursor buffer size in time minus the mc urgent latency*/
-       /*the mc urgent latency is experienced more than one time if the number of dmif requests in the data buffer exceeds the request buffer size plus the request slots reserved for dmif in the dram channel arbiter queues*/
-       /*the dispclk required is the maximum for all surfaces of the maximum of the source pixels for first output pixel times the throughput factor, divided by the pixels per dispclk, and divided by the minimum latency hiding minus the dram speed/p-state change latency minus the burst time, and the source pixels for last output pixel, times the throughput factor, divided by the pixels per dispclk, and divided by the minimum latency hiding minus the dram speed/p-state change latency minus the burst time, plus the active time.*/
-       /*the data burst time is the maximum of the total page close-open time, total dmif/mcifwr buffer size in memory divided by the dram bandwidth, and the total dmif/mcifwr buffer size in memory divided by the 32 byte sclk data bus bandwidth, each multiplied by its efficiency.*/
-       /*the source line transfer time is the maximum for all surfaces of the maximum of the burst time plus the urgent latency times the floor of the data required divided by the buffer size for the fist pixel, and the burst time plus the urgent latency times the floor of the data required divided by the buffer size for the last pixel plus the active time.*/
-       /*the source pixels for the first output pixel is 512 if the scaler vertical filter initialization value is greater than 2, and it is 4 times the source width if it is greater than 4.*/
-       /*the source pixels for the last output pixel is the source width times the scaler vertical filter initialization value rounded up to even*/
-       /*the source data for these pixels is the number of pixels times the bytes per pixel times the bytes per request divided by the useful bytes per request.*/
-       data->cursor_total_data = bw_int_to_fixed(0);
-       data->cursor_total_request_groups = bw_int_to_fixed(0);
-       data->scatter_gather_total_pte_requests = bw_int_to_fixed(0);
-       data->scatter_gather_total_pte_request_groups = bw_int_to_fixed(0);
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       data->cursor_total_data = bw_add(data->cursor_total_data, bw_mul(bw_mul(bw_int_to_fixed(2), data->cursor_width_pixels[i]), bw_int_to_fixed(4)));
-                       if (dceip->large_cursor == 1) {
-                               data->cursor_total_request_groups = bw_add(data->cursor_total_request_groups, bw_int_to_fixed((dceip->cursor_max_outstanding_group_num + 1)));
-                       }
-                       else {
-                               data->cursor_total_request_groups = bw_add(data->cursor_total_request_groups, bw_ceil2(bw_div(data->cursor_width_pixels[i], dceip->cursor_chunk_width), bw_int_to_fixed(1)));
-                       }
-                       if (data->scatter_gather_enable_for_pipe[i]) {
-                               data->scatter_gather_total_pte_requests = bw_add(data->scatter_gather_total_pte_requests, data->scatter_gather_pte_request_limit[i]);
-                               data->scatter_gather_total_pte_request_groups = bw_add(data->scatter_gather_total_pte_request_groups, bw_ceil2(bw_div(data->scatter_gather_pte_request_limit[i], bw_ceil2(data->pte_request_per_chunk[i], bw_int_to_fixed(1))), bw_int_to_fixed(1)));
-                       }
-               }
-       }
-       data->tile_width_in_pixels = bw_int_to_fixed(8);
-       data->dmif_total_number_of_data_request_page_close_open = bw_int_to_fixed(0);
-       data->mcifwr_total_number_of_data_request_page_close_open = bw_int_to_fixed(0);
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (data->scatter_gather_enable_for_pipe[i] == 1 && tiling_mode[i] != bw_def_linear) {
-                               data->bytes_per_page_close_open = bw_mul(data->lines_interleaved_in_mem_access[i], bw_max2(bw_mul(bw_mul(bw_mul(bw_int_to_fixed(data->bytes_per_pixel[i]), data->tile_width_in_pixels), bw_int_to_fixed(vbios->number_of_dram_banks)), bw_int_to_fixed(data->number_of_dram_channels)), bw_mul(bw_int_to_fixed(data->bytes_per_pixel[i]), data->scatter_gather_page_width[i])));
-                       }
-                       else if (data->scatter_gather_enable_for_pipe[i] == 1 && tiling_mode[i] == bw_def_linear && bw_equ(bw_mod((bw_mul(data->pitch_in_pixels_after_surface_type[i], bw_int_to_fixed(data->bytes_per_pixel[i]))), data->inefficient_linear_pitch_in_bytes), bw_int_to_fixed(0))) {
-                               data->bytes_per_page_close_open = dceip->linear_mode_line_request_alternation_slice;
-                       }
-                       else {
-                               data->bytes_per_page_close_open = data->memory_chunk_size_in_bytes[i];
-                       }
-                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
-                               data->dmif_total_number_of_data_request_page_close_open = bw_add(data->dmif_total_number_of_data_request_page_close_open, bw_div(bw_ceil2(data->adjusted_data_buffer_size[i], data->memory_chunk_size_in_bytes[i]), data->bytes_per_page_close_open));
-                       }
-                       else {
-                               data->mcifwr_total_number_of_data_request_page_close_open = bw_add(data->mcifwr_total_number_of_data_request_page_close_open, bw_div(bw_ceil2(data->adjusted_data_buffer_size[i], data->memory_chunk_size_in_bytes[i]), data->bytes_per_page_close_open));
-                       }
-               }
-       }
-       data->dmif_total_page_close_open_time = bw_div(bw_mul((bw_add(bw_add(data->dmif_total_number_of_data_request_page_close_open, data->scatter_gather_total_pte_request_groups), data->cursor_total_request_groups)), vbios->trc), bw_int_to_fixed(1000));
-       data->mcifwr_total_page_close_open_time = bw_div(bw_mul(data->mcifwr_total_number_of_data_request_page_close_open, vbios->trc), bw_int_to_fixed(1000));
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       data->adjusted_data_buffer_size_in_memory[i] = bw_div(bw_mul(data->adjusted_data_buffer_size[i], data->bytes_per_request[i]), data->useful_bytes_per_request[i]);
-               }
-       }
-       data->total_requests_for_adjusted_dmif_size = bw_int_to_fixed(0);
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
-                               data->total_requests_for_adjusted_dmif_size = bw_add(data->total_requests_for_adjusted_dmif_size, bw_div(data->adjusted_data_buffer_size[i], data->useful_bytes_per_request[i]));
-                       }
-               }
-       }
-       data->total_dmifmc_urgent_trips = bw_ceil2(bw_div(data->total_requests_for_adjusted_dmif_size, (bw_add(dceip->dmif_request_buffer_size, bw_int_to_fixed(vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel * data->number_of_dram_channels)))), bw_int_to_fixed(1));
-       data->total_dmifmc_urgent_latency = bw_mul(vbios->dmifmc_urgent_latency, data->total_dmifmc_urgent_trips);
-       data->total_display_reads_required_data = bw_int_to_fixed(0);
-       data->total_display_reads_required_dram_access_data = bw_int_to_fixed(0);
-       data->total_display_writes_required_data = bw_int_to_fixed(0);
-       data->total_display_writes_required_dram_access_data = bw_int_to_fixed(0);
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
-                               data->display_reads_required_data = data->adjusted_data_buffer_size_in_memory[i];
-                               /*for hbm memories, each channel is split into 2 pseudo-channels that are each 64 bits in width.  each*/
-                               /*pseudo-channel may be read independently of one another.*/
-                               /*the read burst length (bl) for hbm memories is 4, so each read command will access 32 bytes of data.*/
-                               /*the 64 or 32 byte sized data is stored in one pseudo-channel.*/
-                               /*it will take 4 memclk cycles or 8 yclk cycles to fetch 64 bytes of data from the hbm memory (2 read commands).*/
-                               /*it will take 2 memclk cycles or 4 yclk cycles to fetch 32 bytes of data from the hbm memory (1 read command).*/
-                               /*for gddr5/ddr4 memories, there is additional overhead if the size of the request is smaller than 64 bytes.*/
-                               /*the read burst length (bl) for gddr5/ddr4 memories is 8, regardless of the size of the data request.*/
-                               /*therefore it will require 8 cycles to fetch 64 or 32 bytes of data from the memory.*/
-                               /*the memory efficiency will be 50% for the 32 byte sized data.*/
-                               if (vbios->memory_type == bw_def_hbm) {
-                                       data->display_reads_required_dram_access_data = data->adjusted_data_buffer_size_in_memory[i];
-                               }
-                               else {
-                                       data->display_reads_required_dram_access_data = bw_mul(data->adjusted_data_buffer_size_in_memory[i], bw_ceil2(bw_div(bw_int_to_fixed((8 * vbios->dram_channel_width_in_bits / 8)), data->bytes_per_request[i]), bw_int_to_fixed(1)));
-                               }
-                               data->total_display_reads_required_data = bw_add(data->total_display_reads_required_data, data->display_reads_required_data);
-                               data->total_display_reads_required_dram_access_data = bw_add(data->total_display_reads_required_dram_access_data, data->display_reads_required_dram_access_data);
-                       }
-                       else {
-                               data->total_display_writes_required_data = bw_add(data->total_display_writes_required_data, data->adjusted_data_buffer_size_in_memory[i]);
-                               data->total_display_writes_required_dram_access_data = bw_add(data->total_display_writes_required_dram_access_data, bw_mul(data->adjusted_data_buffer_size_in_memory[i], bw_ceil2(bw_div(bw_int_to_fixed(vbios->dram_channel_width_in_bits), data->bytes_per_request[i]), bw_int_to_fixed(1))));
-                       }
-               }
-       }
-       data->total_display_reads_required_data = bw_add(bw_add(data->total_display_reads_required_data, data->cursor_total_data), bw_mul(data->scatter_gather_total_pte_requests, bw_int_to_fixed(64)));
-       data->total_display_reads_required_dram_access_data = bw_add(bw_add(data->total_display_reads_required_dram_access_data, data->cursor_total_data), bw_mul(data->scatter_gather_total_pte_requests, bw_int_to_fixed(64)));
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (bw_mtn(data->v_filter_init[i], bw_int_to_fixed(4))) {
-                               data->src_pixels_for_first_output_pixel[i] = bw_mul(bw_int_to_fixed(4), data->source_width_rounded_up_to_chunks[i]);
-                       }
-                       else {
-                               if (bw_mtn(data->v_filter_init[i], bw_int_to_fixed(2))) {
-                                       data->src_pixels_for_first_output_pixel[i] = bw_int_to_fixed(512);
-                               }
-                               else {
-                                       data->src_pixels_for_first_output_pixel[i] = bw_int_to_fixed(0);
-                               }
-                       }
-                       data->src_data_for_first_output_pixel[i] = bw_div(bw_mul(bw_mul(data->src_pixels_for_first_output_pixel[i], bw_int_to_fixed(data->bytes_per_pixel[i])), data->bytes_per_request[i]), data->useful_bytes_per_request[i]);
-                       data->src_pixels_for_last_output_pixel[i] = bw_mul(data->source_width_rounded_up_to_chunks[i], bw_max2(bw_ceil2(data->v_filter_init[i], bw_int_to_fixed(dceip->lines_interleaved_into_lb)), bw_mul(bw_ceil2(data->vsr[i], bw_int_to_fixed(dceip->lines_interleaved_into_lb)), data->horizontal_blank_and_chunk_granularity_factor[i])));
-                       data->src_data_for_last_output_pixel[i] = bw_div(bw_mul(bw_mul(bw_mul(data->source_width_rounded_up_to_chunks[i], bw_max2(bw_ceil2(data->v_filter_init[i], bw_int_to_fixed(dceip->lines_interleaved_into_lb)), data->lines_interleaved_in_mem_access[i])), bw_int_to_fixed(data->bytes_per_pixel[i])), data->bytes_per_request[i]), data->useful_bytes_per_request[i]);
-                       data->active_time[i] = bw_div(bw_div(data->source_width_rounded_up_to_chunks[i], data->hsr[i]), data->pixel_rate[i]);
-               }
-       }
-       for (i = 0; i <= 2; i++) {
-               for (j = 0; j <= 7; j++) {
-                       data->dmif_burst_time[i][j] = bw_max3(data->dmif_total_page_close_open_time, bw_div(data->total_display_reads_required_dram_access_data, (bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[i]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels)))), bw_div(data->total_display_reads_required_data, (bw_mul(bw_mul(sclk[j], vbios->data_return_bus_width), bw_frc_to_fixed(dceip->percent_of_ideal_port_bw_received_after_urgent_latency, 100)))));
-                       if (data->d1_display_write_back_dwb_enable == 1) {
-                               data->mcifwr_burst_time[i][j] = bw_max3(data->mcifwr_total_page_close_open_time, bw_div(data->total_display_writes_required_dram_access_data, (bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[i]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_wrchannels)))), bw_div(data->total_display_writes_required_data, (bw_mul(sclk[j], vbios->data_return_bus_width))));
-                       }
-               }
-       }
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               for (j = 0; j <= 2; j++) {
-                       for (k = 0; k <= 7; k++) {
-                               if (data->enable[i]) {
-                                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
-                                               /*time to transfer data from the dmif buffer to the lb.  since the mc to dmif transfer time overlaps*/
-                                               /*with the dmif to lb transfer time, only time to transfer the last chunk  is considered.*/
-                                               data->dmif_buffer_transfer_time[i] = bw_mul(data->source_width_rounded_up_to_chunks[i], (bw_div(dceip->lb_write_pixels_per_dispclk, (bw_div(vbios->low_voltage_max_dispclk, dceip->display_pipe_throughput_factor)))));
-                                               data->line_source_transfer_time[i][j][k] = bw_max2(bw_mul((bw_add(data->total_dmifmc_urgent_latency, data->dmif_burst_time[j][k])), bw_floor2(bw_div(data->src_data_for_first_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1))), bw_sub(bw_add(bw_mul((bw_add(data->total_dmifmc_urgent_latency, data->dmif_burst_time[j][k])), bw_floor2(bw_div(data->src_data_for_last_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1))), data->dmif_buffer_transfer_time[i]), data->active_time[i]));
-                                               /*during an mclk switch the requests from the dce ip are stored in the gmc/arb.  these requests should be serviced immediately*/
-                                               /*after the mclk switch sequence and not incur an urgent latency penalty.  it is assumed that the gmc/arb can hold up to 256 requests*/
-                                               /*per memory channel.  if the dce ip is urgent after the mclk switch sequence, all pending requests and subsequent requests should be*/
-                                               /*immediately serviced without a gap in the urgent requests.*/
-                                               /*the latency incurred would be the time to issue the requests and return the data for the first or last output pixel.*/
-                                               if (surface_type[i] == bw_def_graphics) {
-                                                       switch (data->lb_bpc[i]) {
-                                                       case 6:
-                                                               data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency6_bit_per_component;
-                                                               break;
-                                                       case 8:
-                                                               data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency8_bit_per_component;
-                                                               break;
-                                                       case 10:
-                                                               data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency10_bit_per_component;
-                                                               break;
-                                                       default:
-                                                               data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency12_bit_per_component;
-                                                               break;
-                                                       }
-                                                       if (data->use_alpha[i] == 1) {
-                                                               data->v_scaler_efficiency = bw_min2(data->v_scaler_efficiency, dceip->alpha_vscaler_efficiency);
-                                                       }
-                                               }
-                                               else {
-                                                       switch (data->lb_bpc[i]) {
-                                                       case 6:
-                                                               data->v_scaler_efficiency = dceip->underlay_vscaler_efficiency6_bit_per_component;
-                                                               break;
-                                                       case 8:
-                                                               data->v_scaler_efficiency = dceip->underlay_vscaler_efficiency8_bit_per_component;
-                                                               break;
-                                                       case 10:
-                                                               data->v_scaler_efficiency = dceip->underlay_vscaler_efficiency10_bit_per_component;
-                                                               break;
-                                                       default:
-                                                               data->v_scaler_efficiency = bw_int_to_fixed(3);
-                                                               break;
-                                                       }
-                                               }
-                                               if (dceip->pre_downscaler_enabled && bw_mtn(data->hsr[i], bw_int_to_fixed(1))) {
-                                                       data->scaler_limits_factor = bw_max2(bw_div(data->v_taps[i], data->v_scaler_efficiency), bw_div(data->source_width_rounded_up_to_chunks[i], data->h_total[i]));
-                                               }
-                                               else {
-                                                       data->scaler_limits_factor = bw_max3(bw_int_to_fixed(1), bw_ceil2(bw_div(data->h_taps[i], bw_int_to_fixed(4)), bw_int_to_fixed(1)), bw_mul(data->hsr[i], bw_max2(bw_div(data->v_taps[i], data->v_scaler_efficiency), bw_int_to_fixed(1))));
-                                               }
-                                               data->dram_speed_change_line_source_transfer_time[i][j][k] = bw_mul(bw_int_to_fixed(2), bw_max2((bw_add((bw_div(data->src_data_for_first_output_pixel[i], bw_min2(bw_mul(data->bytes_per_request[i], sclk[k]), bw_div(bw_mul(bw_mul(data->bytes_per_request[i], data->pixel_rate[i]), data->scaler_limits_factor), bw_int_to_fixed(2))))), (bw_mul(data->dmif_burst_time[j][k], bw_floor2(bw_div(data->src_data_for_first_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1)))))), (bw_add((bw_div(data->src_data_for_last_output_pixel[i], bw_min2(bw_mul(data->bytes_per_request[i], sclk[k]), bw_div(bw_mul(bw_mul(data->bytes_per_request[i], data->pixel_rate[i]), data->scaler_limits_factor), bw_int_to_fixed(2))))), (bw_sub(bw_mul(data->dmif_burst_time[j][k], bw_floor2(bw_div(data->src_data_for_last_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1))), data->active_time[i]))))));
-                                       }
-                                       else {
-                                               data->line_source_transfer_time[i][j][k] = bw_max2(bw_mul((bw_add(vbios->mcifwrmc_urgent_latency, data->mcifwr_burst_time[j][k])), bw_floor2(bw_div(data->src_data_for_first_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1))), bw_sub(bw_mul((bw_add(vbios->mcifwrmc_urgent_latency, data->mcifwr_burst_time[j][k])), bw_floor2(bw_div(data->src_data_for_last_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1))), data->active_time[i]));
-                                               /*during an mclk switch the requests from the dce ip are stored in the gmc/arb.  these requests should be serviced immediately*/
-                                               /*after the mclk switch sequence and not incur an urgent latency penalty.  it is assumed that the gmc/arb can hold up to 256 requests*/
-                                               /*per memory channel.  if the dce ip is urgent after the mclk switch sequence, all pending requests and subsequent requests should be*/
-                                               /*immediately serviced without a gap in the urgent requests.*/
-                                               /*the latency incurred would be the time to issue the requests and return the data for the first or last output pixel.*/
-                                               data->dram_speed_change_line_source_transfer_time[i][j][k] = bw_max2((bw_add((bw_div(data->src_data_for_first_output_pixel[i], bw_min2(bw_mul(data->bytes_per_request[i], sclk[k]), bw_div(bw_mul(data->bytes_per_request[i], vbios->low_voltage_max_dispclk), bw_int_to_fixed(2))))), (bw_mul(data->mcifwr_burst_time[j][k], bw_floor2(bw_div(data->src_data_for_first_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1)))))), (bw_add((bw_div(data->src_data_for_last_output_pixel[i], bw_min2(bw_mul(data->bytes_per_request[i], sclk[k]), bw_div(bw_mul(data->bytes_per_request[i], vbios->low_voltage_max_dispclk), bw_int_to_fixed(2))))), (bw_sub(bw_mul(data->mcifwr_burst_time[j][k], bw_floor2(bw_div(data->src_data_for_last_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1))), data->active_time[i])))));
-                                       }
-                               }
-                       }
-               }
-       }
-       /*cpu c-state and p-state change enable*/
-       /*for cpu p-state change to be possible for a yclk(pclk) and sclk level the dispclk required has to be enough for the blackout duration*/
-       /*for cpu c-state change to be possible for a yclk(pclk) and sclk level the dispclk required has to be enough for the blackout duration and recovery*/
-       /*condition for the blackout duration:*/
-       /* minimum latency hiding > blackout duration + dmif burst time + line source transfer time*/
-       /*condition for the blackout recovery:*/
-       /* recovery time >  dmif burst time + 2 * urgent latency*/
-       /* recovery time > (display bw * blackout duration  + (2 * urgent latency + dmif burst time)*dispclk - dmif size )*/
-       /*                  / (dispclk - display bw)*/
-       /*the minimum latency hiding is the minimum for all pipes of one screen line time, plus one more line time if doing lb prefetch, plus the dmif data buffer size equivalent in time, minus the urgent latency.*/
-       /*the minimum latency hiding is  further limited by the cursor.  the cursor latency hiding is the number of lines of the cursor buffer, minus one if the downscaling is less than two, or minus three if it is more*/
-
-       /*initialize variables*/
-       number_of_displays_enabled = 0;
-       number_of_displays_enabled_with_margin = 0;
-       for (k = 0; k <= maximum_number_of_surfaces - 1; k++) {
-               if (data->enable[k]) {
-                       number_of_displays_enabled = number_of_displays_enabled + 1;
-               }
-               data->display_pstate_change_enable[k] = 0;
-       }
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if ((bw_equ(dceip->stutter_and_dram_clock_state_change_gated_before_cursor, bw_int_to_fixed(0)) && bw_mtn(data->cursor_width_pixels[i], bw_int_to_fixed(0)))) {
-                               if (bw_ltn(data->vsr[i], bw_int_to_fixed(2))) {
-                                       data->cursor_latency_hiding[i] = bw_div(bw_div(bw_mul((bw_sub(dceip->cursor_dcp_buffer_lines, bw_int_to_fixed(1))), data->h_total[i]), data->vsr[i]), data->pixel_rate[i]);
-                               }
-                               else {
-                                       data->cursor_latency_hiding[i] = bw_div(bw_div(bw_mul((bw_sub(dceip->cursor_dcp_buffer_lines, bw_int_to_fixed(3))), data->h_total[i]), data->vsr[i]), data->pixel_rate[i]);
-                               }
-                       }
-                       else {
-                               data->cursor_latency_hiding[i] = bw_int_to_fixed(9999);
-                       }
-               }
-       }
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (dceip->graphics_lb_nodownscaling_multi_line_prefetching == 1 && (bw_equ(data->vsr[i], bw_int_to_fixed(1)) || (bw_leq(data->vsr[i], bw_frc_to_fixed(8, 10)) && bw_leq(data->v_taps[i], bw_int_to_fixed(2)) && data->lb_bpc[i] == 8)) && surface_type[i] == bw_def_graphics) {
-                               if (number_of_displays_enabled > 2)
-                                       data->minimum_latency_hiding[i] = bw_sub(bw_div(bw_mul((bw_div((bw_add(bw_sub(data->lb_partitions[i], bw_int_to_fixed(2)), bw_div(bw_div(data->data_buffer_size[i], bw_int_to_fixed(data->bytes_per_pixel[i])), data->source_width_pixels[i]))), data->vsr[i])), data->h_total[i]), data->pixel_rate[i]), data->total_dmifmc_urgent_latency);
-                               else
-                                       data->minimum_latency_hiding[i] = bw_sub(bw_div(bw_mul((bw_div((bw_add(bw_sub(data->lb_partitions[i], bw_int_to_fixed(1)), bw_div(bw_div(data->data_buffer_size[i], bw_int_to_fixed(data->bytes_per_pixel[i])), data->source_width_pixels[i]))), data->vsr[i])), data->h_total[i]), data->pixel_rate[i]), data->total_dmifmc_urgent_latency);
-                       }
-                       else {
-                               data->minimum_latency_hiding[i] = bw_sub(bw_div(bw_mul((bw_div((bw_add(bw_int_to_fixed(1 + data->line_buffer_prefetch[i]), bw_div(bw_div(data->data_buffer_size[i], bw_int_to_fixed(data->bytes_per_pixel[i])), data->source_width_pixels[i]))), data->vsr[i])), data->h_total[i]), data->pixel_rate[i]), data->total_dmifmc_urgent_latency);
-                       }
-                       data->minimum_latency_hiding_with_cursor[i] = bw_min2(data->minimum_latency_hiding[i], data->cursor_latency_hiding[i]);
-               }
-       }
-       for (i = 0; i <= 2; i++) {
-               for (j = 0; j <= 7; j++) {
-                       data->blackout_duration_margin[i][j] = bw_int_to_fixed(9999);
-                       data->dispclk_required_for_blackout_duration[i][j] = bw_int_to_fixed(0);
-                       data->dispclk_required_for_blackout_recovery[i][j] = bw_int_to_fixed(0);
-                       for (k = 0; k <= maximum_number_of_surfaces - 1; k++) {
-                               if (data->enable[k] && bw_mtn(vbios->blackout_duration, bw_int_to_fixed(0))) {
-                                       if (surface_type[k] != bw_def_display_write_back420_luma && surface_type[k] != bw_def_display_write_back420_chroma) {
-                                               data->blackout_duration_margin[i][j] = bw_min2(data->blackout_duration_margin[i][j], bw_sub(bw_sub(bw_sub(data->minimum_latency_hiding_with_cursor[k], vbios->blackout_duration), data->dmif_burst_time[i][j]), data->line_source_transfer_time[k][i][j]));
-                                               data->dispclk_required_for_blackout_duration[i][j] = bw_max3(data->dispclk_required_for_blackout_duration[i][j], bw_div(bw_div(bw_mul(data->src_pixels_for_first_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_sub(bw_sub(data->minimum_latency_hiding_with_cursor[k], vbios->blackout_duration), data->dmif_burst_time[i][j]))), bw_div(bw_div(bw_mul(data->src_pixels_for_last_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_add(bw_sub(bw_sub(data->minimum_latency_hiding_with_cursor[k], vbios->blackout_duration), data->dmif_burst_time[i][j]), data->active_time[k]))));
-                                               if (bw_leq(vbios->maximum_blackout_recovery_time, bw_add(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[i][j]))) {
-                                                       data->dispclk_required_for_blackout_recovery[i][j] = bw_int_to_fixed(9999);
-                                               }
-                                               else if (bw_ltn(data->adjusted_data_buffer_size[k], bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), (bw_add(vbios->blackout_duration, bw_add(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[i][j])))))) {
-                                                       data->dispclk_required_for_blackout_recovery[i][j] = bw_max2(data->dispclk_required_for_blackout_recovery[i][j], bw_div(bw_mul(bw_div(bw_div((bw_sub(bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), (bw_add(vbios->blackout_duration, vbios->maximum_blackout_recovery_time))), data->adjusted_data_buffer_size[k])), bw_int_to_fixed(data->bytes_per_pixel[k])), (bw_sub(vbios->maximum_blackout_recovery_time, bw_sub(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[i][j])))), data->latency_hiding_lines[k]), data->lines_interleaved_in_mem_access[k]));
-                                               }
-                                       }
-                                       else {
-                                               data->blackout_duration_margin[i][j] = bw_min2(data->blackout_duration_margin[i][j], bw_sub(bw_sub(bw_sub(bw_sub(data->minimum_latency_hiding_with_cursor[k], vbios->blackout_duration), data->dmif_burst_time[i][j]), data->mcifwr_burst_time[i][j]), data->line_source_transfer_time[k][i][j]));
-                                               data->dispclk_required_for_blackout_duration[i][j] = bw_max3(data->dispclk_required_for_blackout_duration[i][j], bw_div(bw_div(bw_mul(data->src_pixels_for_first_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_sub(bw_sub(bw_sub(data->minimum_latency_hiding_with_cursor[k], vbios->blackout_duration), data->dmif_burst_time[i][j]), data->mcifwr_burst_time[i][j]))), bw_div(bw_div(bw_mul(data->src_pixels_for_last_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_add(bw_sub(bw_sub(bw_sub(data->minimum_latency_hiding_with_cursor[k], vbios->blackout_duration), data->dmif_burst_time[i][j]), data->mcifwr_burst_time[i][j]), data->active_time[k]))));
-                                               if (bw_ltn(vbios->maximum_blackout_recovery_time, bw_add(bw_add(bw_mul(bw_int_to_fixed(2), vbios->mcifwrmc_urgent_latency), data->dmif_burst_time[i][j]), data->mcifwr_burst_time[i][j]))) {
-                                                       data->dispclk_required_for_blackout_recovery[i][j] = bw_int_to_fixed(9999);
-                                               }
-                                               else if (bw_ltn(data->adjusted_data_buffer_size[k], bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), (bw_add(vbios->blackout_duration, bw_add(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[i][j])))))) {
-                                                       data->dispclk_required_for_blackout_recovery[i][j] = bw_max2(data->dispclk_required_for_blackout_recovery[i][j], bw_div(bw_mul(bw_div(bw_div((bw_sub(bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), (bw_add(vbios->blackout_duration, vbios->maximum_blackout_recovery_time))), data->adjusted_data_buffer_size[k])), bw_int_to_fixed(data->bytes_per_pixel[k])), (bw_sub(vbios->maximum_blackout_recovery_time, (bw_add(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[i][j]))))), data->latency_hiding_lines[k]), data->lines_interleaved_in_mem_access[k]));
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-       if (bw_mtn(data->blackout_duration_margin[high][s_high], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[high][s_high], vbios->high_voltage_max_dispclk)) {
-               data->cpup_state_change_enable = bw_def_yes;
-               if (bw_ltn(data->dispclk_required_for_blackout_recovery[high][s_high], vbios->high_voltage_max_dispclk)) {
-                       data->cpuc_state_change_enable = bw_def_yes;
-               }
-               else {
-                       data->cpuc_state_change_enable = bw_def_no;
-               }
-       }
-       else {
-               data->cpup_state_change_enable = bw_def_no;
-               data->cpuc_state_change_enable = bw_def_no;
-       }
-       /*nb p-state change enable*/
-       /*for dram speed/p-state change to be possible for a yclk(pclk) and sclk level there has to be positive margin and the dispclk required has to be*/
-       /*below the maximum.*/
-       /*the dram speed/p-state change margin is the minimum for all surfaces of the maximum latency hiding minus the dram speed/p-state change latency,*/
-       /*minus the dmif burst time, minus the source line transfer time*/
-       /*the maximum latency hiding is the minimum latency hiding plus one source line used for de-tiling in the line buffer, plus half the urgent latency*/
-       /*if stutter and dram clock state change are gated before cursor then the cursor latency hiding does not limit stutter or dram clock state change*/
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       /*maximum_latency_hiding(i) = minimum_latency_hiding(i) + 1 / vsr(i) **/
-                       /*      h_total(i) / pixel_rate(i) + 0.5 * total_dmifmc_urgent_latency*/
-                       data->maximum_latency_hiding[i] = bw_add(data->minimum_latency_hiding[i],
-                               bw_mul(bw_frc_to_fixed(5, 10), data->total_dmifmc_urgent_latency));
-                       data->maximum_latency_hiding_with_cursor[i] = bw_min2(data->maximum_latency_hiding[i], data->cursor_latency_hiding[i]);
-               }
-       }
-       for (i = 0; i <= 2; i++) {
-               for (j = 0; j <= 7; j++) {
-                       data->min_dram_speed_change_margin[i][j] = bw_int_to_fixed(9999);
-                       data->dram_speed_change_margin = bw_int_to_fixed(9999);
-                       data->dispclk_required_for_dram_speed_change[i][j] = bw_int_to_fixed(0);
-                       data->num_displays_with_margin[i][j] = 0;
-                       for (k = 0; k <= maximum_number_of_surfaces - 1; k++) {
-                               if (data->enable[k]) {
-                                       if (surface_type[k] != bw_def_display_write_back420_luma && surface_type[k] != bw_def_display_write_back420_chroma) {
-                                               data->dram_speed_change_margin = bw_sub(bw_sub(bw_sub(data->maximum_latency_hiding_with_cursor[k], vbios->nbp_state_change_latency), data->dmif_burst_time[i][j]), data->dram_speed_change_line_source_transfer_time[k][i][j]);
-                                               if ((bw_mtn(data->dram_speed_change_margin, bw_int_to_fixed(0)) && bw_ltn(data->dram_speed_change_margin, bw_int_to_fixed(9999)))) {
-                                                       /*determine the minimum dram clock change margin for each set of clock frequencies*/
-                                                       data->min_dram_speed_change_margin[i][j] = bw_min2(data->min_dram_speed_change_margin[i][j], data->dram_speed_change_margin);
-                                                       /*compute the maximum clock frequuency required for the dram clock change at each set of clock frequencies*/
-                                                       data->dispclk_required_for_dram_speed_change_pipe[i][j] = bw_max2(bw_div(bw_div(bw_mul(data->src_pixels_for_first_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_sub(bw_sub(bw_sub(data->maximum_latency_hiding_with_cursor[k], vbios->nbp_state_change_latency), data->dmif_burst_time[i][j]), data->dram_speed_change_line_source_transfer_time[k][i][j]))), bw_div(bw_div(bw_mul(data->src_pixels_for_last_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_add(bw_sub(bw_sub(bw_sub(data->maximum_latency_hiding_with_cursor[k], vbios->nbp_state_change_latency), data->dmif_burst_time[i][j]), data->dram_speed_change_line_source_transfer_time[k][i][j]), data->active_time[k]))));
-                                                       if ((bw_ltn(data->dispclk_required_for_dram_speed_change_pipe[i][j], vbios->high_voltage_max_dispclk))) {
-                                                               data->display_pstate_change_enable[k] = 1;
-                                                               data->num_displays_with_margin[i][j] = data->num_displays_with_margin[i][j] + 1;
-                                                               data->dispclk_required_for_dram_speed_change[i][j] = bw_max2(data->dispclk_required_for_dram_speed_change[i][j], data->dispclk_required_for_dram_speed_change_pipe[i][j]);
-                                                       }
-                                               }
-                                       }
-                                       else {
-                                               data->dram_speed_change_margin = bw_sub(bw_sub(bw_sub(bw_sub(data->maximum_latency_hiding_with_cursor[k], vbios->nbp_state_change_latency), data->dmif_burst_time[i][j]), data->mcifwr_burst_time[i][j]), data->dram_speed_change_line_source_transfer_time[k][i][j]);
-                                               if ((bw_mtn(data->dram_speed_change_margin, bw_int_to_fixed(0)) && bw_ltn(data->dram_speed_change_margin, bw_int_to_fixed(9999)))) {
-                                                       /*determine the minimum dram clock change margin for each display pipe*/
-                                                       data->min_dram_speed_change_margin[i][j] = bw_min2(data->min_dram_speed_change_margin[i][j], data->dram_speed_change_margin);
-                                                       /*compute the maximum clock frequuency required for the dram clock change at each set of clock frequencies*/
-                                                       data->dispclk_required_for_dram_speed_change_pipe[i][j] = bw_max2(bw_div(bw_div(bw_mul(data->src_pixels_for_first_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_sub(bw_sub(bw_sub(bw_sub(data->maximum_latency_hiding_with_cursor[k], vbios->nbp_state_change_latency), data->dmif_burst_time[i][j]), data->dram_speed_change_line_source_transfer_time[k][i][j]), data->mcifwr_burst_time[i][j]))), bw_div(bw_div(bw_mul(data->src_pixels_for_last_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_add(bw_sub(bw_sub(bw_sub(bw_sub(data->maximum_latency_hiding_with_cursor[k], vbios->nbp_state_change_latency), data->dmif_burst_time[i][j]), data->dram_speed_change_line_source_transfer_time[k][i][j]), data->mcifwr_burst_time[i][j]), data->active_time[k]))));
-                                                       if ((bw_ltn(data->dispclk_required_for_dram_speed_change_pipe[i][j], vbios->high_voltage_max_dispclk))) {
-                                                               data->display_pstate_change_enable[k] = 1;
-                                                               data->num_displays_with_margin[i][j] = data->num_displays_with_margin[i][j] + 1;
-                                                               data->dispclk_required_for_dram_speed_change[i][j] = bw_max2(data->dispclk_required_for_dram_speed_change[i][j], data->dispclk_required_for_dram_speed_change_pipe[i][j]);
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
-       /*determine the number of displays with margin to switch in the v_active region*/
-       for (k = 0; k <= maximum_number_of_surfaces - 1; k++) {
-               if (data->enable[k] == 1 && data->display_pstate_change_enable[k] == 1) {
-                       number_of_displays_enabled_with_margin = number_of_displays_enabled_with_margin + 1;
-               }
-       }
-       /*determine the number of displays that don't have any dram clock change margin, but*/
-       /*have the same resolution.  these displays can switch in a common vblank region if*/
-       /*their frames are aligned.*/
-       data->min_vblank_dram_speed_change_margin = bw_int_to_fixed(9999);
-       for (k = 0; k <= maximum_number_of_surfaces - 1; k++) {
-               if (data->enable[k]) {
-                       if (surface_type[k] != bw_def_display_write_back420_luma && surface_type[k] != bw_def_display_write_back420_chroma) {
-                               data->v_blank_dram_speed_change_margin[k] = bw_sub(bw_sub(bw_sub(bw_div(bw_mul((bw_sub(data->v_total[k], bw_sub(bw_div(data->src_height[k], data->v_scale_ratio[k]), bw_int_to_fixed(4)))), data->h_total[k]), data->pixel_rate[k]), vbios->nbp_state_change_latency), data->dmif_burst_time[low][s_low]), data->dram_speed_change_line_source_transfer_time[k][low][s_low]);
-                               data->min_vblank_dram_speed_change_margin = bw_min2(data->min_vblank_dram_speed_change_margin, data->v_blank_dram_speed_change_margin[k]);
-                       }
-                       else {
-                               data->v_blank_dram_speed_change_margin[k] = bw_sub(bw_sub(bw_sub(bw_sub(bw_div(bw_mul((bw_sub(data->v_total[k], bw_sub(bw_div(data->src_height[k], data->v_scale_ratio[k]), bw_int_to_fixed(4)))), data->h_total[k]), data->pixel_rate[k]), vbios->nbp_state_change_latency), data->dmif_burst_time[low][s_low]), data->mcifwr_burst_time[low][s_low]), data->dram_speed_change_line_source_transfer_time[k][low][s_low]);
-                               data->min_vblank_dram_speed_change_margin = bw_min2(data->min_vblank_dram_speed_change_margin, data->v_blank_dram_speed_change_margin[k]);
-                       }
-               }
-       }
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               data->displays_with_same_mode[i] = bw_int_to_fixed(0);
-               if (data->enable[i] == 1 && data->display_pstate_change_enable[i] == 0 && bw_mtn(data->v_blank_dram_speed_change_margin[i], bw_int_to_fixed(0))) {
-                       for (j = 0; j <= maximum_number_of_surfaces - 1; j++) {
-                               if ((i == j || data->display_synchronization_enabled) && (data->enable[j] == 1 && bw_equ(data->source_width_rounded_up_to_chunks[i], data->source_width_rounded_up_to_chunks[j]) && bw_equ(data->source_height_rounded_up_to_chunks[i], data->source_height_rounded_up_to_chunks[j]) && bw_equ(data->vsr[i], data->vsr[j]) && bw_equ(data->hsr[i], data->hsr[j]) && bw_equ(data->pixel_rate[i], data->pixel_rate[j]))) {
-                                       data->displays_with_same_mode[i] = bw_add(data->displays_with_same_mode[i], bw_int_to_fixed(1));
-                               }
-                       }
-               }
-       }
-       /*compute the maximum number of aligned displays with no margin*/
-       number_of_aligned_displays_with_no_margin = 0;
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               number_of_aligned_displays_with_no_margin = bw_fixed_to_int(bw_max2(bw_int_to_fixed(number_of_aligned_displays_with_no_margin), data->displays_with_same_mode[i]));
-       }
-       /*dram clock change is possible, if all displays have positive margin except for one display or a group of*/
-       /*aligned displays with the same timing.*/
-       /*the display(s) with the negative margin can be switched in the v_blank region while the other*/
-       /*displays are in v_blank or v_active.*/
-       if (number_of_displays_enabled_with_margin > 0 && (number_of_displays_enabled_with_margin + number_of_aligned_displays_with_no_margin) == number_of_displays_enabled && bw_mtn(data->min_dram_speed_change_margin[high][s_high], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[high][s_high], bw_int_to_fixed(9999)) && bw_ltn(data->dispclk_required_for_dram_speed_change[high][s_high], vbios->high_voltage_max_dispclk)) {
-               data->nbp_state_change_enable = bw_def_yes;
-       }
-       else {
-               data->nbp_state_change_enable = bw_def_no;
-       }
-       /*dram clock change is possible only in vblank if all displays are aligned and have no margin*/
-       if (number_of_aligned_displays_with_no_margin == number_of_displays_enabled) {
-               nbp_state_change_enable_blank = bw_def_yes;
-       }
-       else {
-               nbp_state_change_enable_blank = bw_def_no;
-       }
-
-       /*average bandwidth*/
-       /*the average bandwidth with no compression is the vertical active time is the source width times the bytes per pixel divided by the line time, multiplied by the vertical scale ratio and the ratio of bytes per request divided by the useful bytes per request.*/
-       /*the average bandwidth with compression is the same, divided by the compression ratio*/
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       data->average_bandwidth_no_compression[i] = bw_div(bw_mul(bw_mul(bw_div(bw_mul(data->source_width_rounded_up_to_chunks[i], bw_int_to_fixed(data->bytes_per_pixel[i])), (bw_div(data->h_total[i], data->pixel_rate[i]))), data->vsr[i]), data->bytes_per_request[i]), data->useful_bytes_per_request[i]);
-                       data->average_bandwidth[i] = bw_div(data->average_bandwidth_no_compression[i], data->compression_rate[i]);
-               }
-       }
-       data->total_average_bandwidth_no_compression = bw_int_to_fixed(0);
-       data->total_average_bandwidth = bw_int_to_fixed(0);
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       data->total_average_bandwidth_no_compression = bw_add(data->total_average_bandwidth_no_compression, data->average_bandwidth_no_compression[i]);
-                       data->total_average_bandwidth = bw_add(data->total_average_bandwidth, data->average_bandwidth[i]);
-               }
-       }
-
-       /*required yclk(pclk)*/
-       /*yclk requirement only makes sense if the dmif and mcifwr data total page close-open time is less than the time for data transfer and the total pte requests fit in the scatter-gather saw queque size*/
-       /*if that is the case, the yclk requirement is the maximum of the ones required by dmif and mcifwr, and the high/low yclk(pclk) is chosen accordingly*/
-       /*high yclk(pclk) has to be selected when dram speed/p-state change is not possible.*/
-       data->min_cursor_memory_interface_buffer_size_in_time = bw_int_to_fixed(9999);
-       /* number of cursor lines stored in the cursor data return buffer*/
-       num_cursor_lines = 0;
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (bw_mtn(data->cursor_width_pixels[i], bw_int_to_fixed(0))) {
-                               /*compute number of cursor lines stored in data return buffer*/
-                               if (bw_leq(data->cursor_width_pixels[i], bw_int_to_fixed(64)) && dceip->large_cursor == 1) {
-                                       num_cursor_lines = 4;
-                               }
-                               else {
-                                       num_cursor_lines = 2;
-                               }
-                               data->min_cursor_memory_interface_buffer_size_in_time = bw_min2(data->min_cursor_memory_interface_buffer_size_in_time, bw_div(bw_mul(bw_div(bw_int_to_fixed(num_cursor_lines), data->vsr[i]), data->h_total[i]), data->pixel_rate[i]));
-                       }
-               }
-       }
-       /*compute minimum time to read one chunk from the dmif buffer*/
-       if (number_of_displays_enabled > 2) {
-               data->chunk_request_delay = 0;
-       }
-       else {
-               data->chunk_request_delay = bw_fixed_to_int(bw_div(bw_int_to_fixed(512), vbios->high_voltage_max_dispclk));
-       }
-       data->min_read_buffer_size_in_time = bw_min2(data->min_cursor_memory_interface_buffer_size_in_time, data->min_dmif_size_in_time);
-       data->display_reads_time_for_data_transfer = bw_sub(bw_sub(data->min_read_buffer_size_in_time, data->total_dmifmc_urgent_latency), bw_int_to_fixed(data->chunk_request_delay));
-       data->display_writes_time_for_data_transfer = bw_sub(data->min_mcifwr_size_in_time, vbios->mcifwrmc_urgent_latency);
-       data->dmif_required_dram_bandwidth = bw_div(data->total_display_reads_required_dram_access_data, data->display_reads_time_for_data_transfer);
-       data->mcifwr_required_dram_bandwidth = bw_div(data->total_display_writes_required_dram_access_data, data->display_writes_time_for_data_transfer);
-       data->required_dmifmc_urgent_latency_for_page_close_open = bw_div((bw_sub(data->min_read_buffer_size_in_time, data->dmif_total_page_close_open_time)), data->total_dmifmc_urgent_trips);
-       data->required_mcifmcwr_urgent_latency = bw_sub(data->min_mcifwr_size_in_time, data->mcifwr_total_page_close_open_time);
-       if (bw_mtn(data->scatter_gather_total_pte_requests, dceip->maximum_total_outstanding_pte_requests_allowed_by_saw)) {
-               data->required_dram_bandwidth_gbyte_per_second = bw_int_to_fixed(9999);
-               yclk_message = bw_def_exceeded_allowed_outstanding_pte_req_queue_size;
-               data->y_clk_level = high;
-               data->dram_bandwidth = bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[high]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels));
-       }
-       else if (bw_mtn(vbios->dmifmc_urgent_latency, data->required_dmifmc_urgent_latency_for_page_close_open) || bw_mtn(vbios->mcifwrmc_urgent_latency, data->required_mcifmcwr_urgent_latency)) {
-               data->required_dram_bandwidth_gbyte_per_second = bw_int_to_fixed(9999);
-               yclk_message = bw_def_exceeded_allowed_page_close_open;
-               data->y_clk_level = high;
-               data->dram_bandwidth = bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[high]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels));
-       }
-       else {
-               data->required_dram_bandwidth_gbyte_per_second = bw_div(bw_max2(data->dmif_required_dram_bandwidth, data->mcifwr_required_dram_bandwidth), bw_int_to_fixed(1000));
-               if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation, 100),yclk[low]),bw_div(bw_int_to_fixed(vbios->dram_channel_width_in_bits),bw_int_to_fixed(8))),bw_int_to_fixed(vbios->number_of_dram_channels)))
-                               && bw_ltn(bw_mul(data->required_dram_bandwidth_gbyte_per_second, bw_int_to_fixed(1000)), bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[low]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels))) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[low][s_high], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[low][s_high], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[low][s_high], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[low][s_high], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[low][s_high], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[low][s_high], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[low][s_high], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[low][s_high], vbios->high_voltage_max_dispclk) && data->num_displays_with_margin[low][s_high] == number_of_displays_enabled_with_margin))) {
-                       yclk_message = bw_fixed_to_int(vbios->low_yclk);
-                       data->y_clk_level = low;
-                       data->dram_bandwidth = bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[low]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels));
-               }
-               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation, 100),yclk[mid]),bw_div(bw_int_to_fixed(vbios->dram_channel_width_in_bits),bw_int_to_fixed(8))),bw_int_to_fixed(vbios->number_of_dram_channels)))
-                               && bw_ltn(bw_mul(data->required_dram_bandwidth_gbyte_per_second, bw_int_to_fixed(1000)), bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[mid]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels))) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[mid][s_high], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[mid][s_high], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[mid][s_high], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[mid][s_high], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[mid][s_high], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[mid][s_high], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[mid][s_high], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[mid][s_high], vbios->high_voltage_max_dispclk) && data->num_displays_with_margin[mid][s_high] == number_of_displays_enabled_with_margin))) {
-                       yclk_message = bw_fixed_to_int(vbios->mid_yclk);
-                       data->y_clk_level = mid;
-                       data->dram_bandwidth = bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[mid]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels));
-               }
-               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation, 100),yclk[high]),bw_div(bw_int_to_fixed(vbios->dram_channel_width_in_bits),bw_int_to_fixed(8))),bw_int_to_fixed(vbios->number_of_dram_channels)))
-                               && bw_ltn(bw_mul(data->required_dram_bandwidth_gbyte_per_second, bw_int_to_fixed(1000)), bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[high]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels)))) {
-                       yclk_message = bw_fixed_to_int(vbios->high_yclk);
-                       data->y_clk_level = high;
-                       data->dram_bandwidth = bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[high]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels));
-               }
-               else {
-                       yclk_message = bw_def_exceeded_allowed_maximum_bw;
-                       data->y_clk_level = high;
-                       data->dram_bandwidth = bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[high]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels));
-               }
-       }
-       /*required sclk*/
-       /*sclk requirement only makes sense if the total pte requests fit in the scatter-gather saw queque size*/
-       /*if that is the case, the sclk requirement is the maximum of the ones required by dmif and mcifwr, and the high/mid/low sclk is chosen accordingly, unless that choice results in foresaking dram speed/nb p-state change.*/
-       /*the dmif and mcifwr sclk required is the one that allows the transfer of all pipe's data buffer size through the sclk bus in the time for data transfer*/
-       /*for dmif, pte and cursor requests have to be included.*/
-       data->dmif_required_sclk = bw_div(bw_div(data->total_display_reads_required_data, data->display_reads_time_for_data_transfer), (bw_mul(vbios->data_return_bus_width, bw_frc_to_fixed(dceip->percent_of_ideal_port_bw_received_after_urgent_latency, 100))));
-       data->mcifwr_required_sclk = bw_div(bw_div(data->total_display_writes_required_data, data->display_writes_time_for_data_transfer), vbios->data_return_bus_width);
-       if (bw_mtn(data->scatter_gather_total_pte_requests, dceip->maximum_total_outstanding_pte_requests_allowed_by_saw)) {
-               data->required_sclk = bw_int_to_fixed(9999);
-               sclk_message = bw_def_exceeded_allowed_outstanding_pte_req_queue_size;
-               data->sclk_level = s_high;
-       }
-       else if (bw_mtn(vbios->dmifmc_urgent_latency, data->required_dmifmc_urgent_latency_for_page_close_open) || bw_mtn(vbios->mcifwrmc_urgent_latency, data->required_mcifmcwr_urgent_latency)) {
-               data->required_sclk = bw_int_to_fixed(9999);
-               sclk_message = bw_def_exceeded_allowed_page_close_open;
-               data->sclk_level = s_high;
-       }
-       else {
-               data->required_sclk = bw_max2(data->dmif_required_sclk, data->mcifwr_required_sclk);
-               if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[low]),vbios->data_return_bus_width))
-                               && bw_ltn(data->required_sclk, sclk[s_low]) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_low], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_low], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_low], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_low], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[data->y_clk_level][s_low], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[data->y_clk_level][s_low], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[data->y_clk_level][s_low], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[data->y_clk_level][s_low], vbios->low_voltage_max_dispclk) && data->num_displays_with_margin[data->y_clk_level][s_low] == number_of_displays_enabled_with_margin))) {
-                       sclk_message = bw_def_low;
-                       data->sclk_level = s_low;
-                       data->required_sclk = vbios->low_sclk;
-               }
-               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[mid]),vbios->data_return_bus_width))
-                               && bw_ltn(data->required_sclk, sclk[s_mid1]) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid1], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid1], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid1], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid1], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[data->y_clk_level][s_mid1], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid1], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid1], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[data->y_clk_level][s_mid1], vbios->mid_voltage_max_dispclk) && data->num_displays_with_margin[data->y_clk_level][s_mid1] == number_of_displays_enabled_with_margin))) {
-                       sclk_message = bw_def_mid;
-                       data->sclk_level = s_mid1;
-                       data->required_sclk = vbios->mid1_sclk;
-               }
-               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[s_mid2]),vbios->data_return_bus_width))
-                               && bw_ltn(data->required_sclk, sclk[s_mid2]) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid2], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid2], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid2], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid2], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[data->y_clk_level][s_mid2], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid2], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid2], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[data->y_clk_level][s_mid2], vbios->mid_voltage_max_dispclk) && data->num_displays_with_margin[data->y_clk_level][s_mid2] == number_of_displays_enabled_with_margin))) {
-                       sclk_message = bw_def_mid;
-                       data->sclk_level = s_mid2;
-                       data->required_sclk = vbios->mid2_sclk;
-               }
-               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[s_mid3]),vbios->data_return_bus_width))
-                               && bw_ltn(data->required_sclk, sclk[s_mid3]) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid3], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid3], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid3], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid3], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[data->y_clk_level][s_mid3], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid3], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid3], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[data->y_clk_level][s_mid3], vbios->mid_voltage_max_dispclk) && data->num_displays_with_margin[data->y_clk_level][s_mid3] == number_of_displays_enabled_with_margin))) {
-                       sclk_message = bw_def_mid;
-                       data->sclk_level = s_mid3;
-                       data->required_sclk = vbios->mid3_sclk;
-               }
-               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[s_mid4]),vbios->data_return_bus_width))
-                               && bw_ltn(data->required_sclk, sclk[s_mid4]) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid4], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid4], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid4], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid4], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[data->y_clk_level][s_mid4], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid4], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid4], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[data->y_clk_level][s_mid4], vbios->mid_voltage_max_dispclk) && data->num_displays_with_margin[data->y_clk_level][s_mid4] == number_of_displays_enabled_with_margin))) {
-                       sclk_message = bw_def_mid;
-                       data->sclk_level = s_mid4;
-                       data->required_sclk = vbios->mid4_sclk;
-               }
-               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[s_mid5]),vbios->data_return_bus_width))
-                               && bw_ltn(data->required_sclk, sclk[s_mid5]) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid5], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid5], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid5], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid5], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[data->y_clk_level][s_mid5], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid5], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid5], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[data->y_clk_level][s_mid5], vbios->mid_voltage_max_dispclk) && data->num_displays_with_margin[data->y_clk_level][s_mid5] == number_of_displays_enabled_with_margin))) {
-                       sclk_message = bw_def_mid;
-                       data->sclk_level = s_mid5;
-                       data->required_sclk = vbios->mid5_sclk;
-               }
-               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[s_mid6]),vbios->data_return_bus_width))
-                               && bw_ltn(data->required_sclk, sclk[s_mid6]) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid6], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid6], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid6], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid6], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[data->y_clk_level][s_mid6], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid6], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid6], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[data->y_clk_level][s_mid6], vbios->high_voltage_max_dispclk) && data->num_displays_with_margin[data->y_clk_level][s_mid6] == number_of_displays_enabled_with_margin))) {
-                       sclk_message = bw_def_mid;
-                       data->sclk_level = s_mid6;
-                       data->required_sclk = vbios->mid6_sclk;
-               }
-               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[s_high]),vbios->data_return_bus_width))
-                               && bw_ltn(data->required_sclk, sclk[s_high])) {
-                       sclk_message = bw_def_high;
-                       data->sclk_level = s_high;
-                       data->required_sclk = vbios->high_sclk;
-               }
-               else if (bw_meq(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[s_high]),vbios->data_return_bus_width))
-                               && bw_ltn(data->required_sclk, sclk[s_high])) {
-                       sclk_message = bw_def_high;
-                       data->sclk_level = s_high;
-                       data->required_sclk = vbios->high_sclk;
-               }
-               else {
-                       sclk_message = bw_def_exceeded_allowed_maximum_sclk;
-                       data->sclk_level = s_high;
-                       /*required_sclk = high_sclk*/
-               }
-       }
-       /*dispclk*/
-       /*if dispclk is set to the maximum, ramping is not required.  dispclk required without ramping is less than the dispclk required with ramping.*/
-       /*if dispclk required without ramping is more than the maximum dispclk, that is the dispclk required, and the mode is not supported*/
-       /*if that does not happen, but dispclk required with ramping is more than the maximum dispclk, dispclk required is just the maximum dispclk*/
-       /*if that does not happen either, dispclk required is the dispclk required with ramping.*/
-       /*dispclk required without ramping is the maximum of the one required for display pipe pixel throughput, for scaler throughput, for total read request thrrougput and for dram/np p-state change if enabled.*/
-       /*the display pipe pixel throughput is the maximum of lines in per line out in the beginning of the frame and lines in per line out in the middle of the frame multiplied by the horizontal blank and chunk granularity factor, altogether multiplied by the ratio of the source width to the line time, divided by the line buffer pixels per dispclk throughput, and multiplied by the display pipe throughput factor.*/
-       /*the horizontal blank and chunk granularity factor is the ratio of the line time divided by the line time minus half the horizontal blank and chunk time.  it applies when the lines in per line out is not 2 or 4.*/
-       /*the dispclk required for scaler throughput is the product of the pixel rate and the scaling limits factor.*/
-       /*the dispclk required for total read request throughput is the product of the peak request-per-second bandwidth and the dispclk cycles per request, divided by the request efficiency.*/
-       /*for the dispclk required with ramping, instead of multiplying just the pipe throughput by the display pipe throughput factor, we multiply the scaler and pipe throughput by the ramping factor.*/
-       /*the scaling limits factor is the product of the horizontal scale ratio, and the ratio of the vertical taps divided by the scaler efficiency clamped to at least 1.*/
-       /*the scaling limits factor itself it also clamped to at least 1*/
-       /*if doing downscaling with the pre-downscaler enabled, the horizontal scale ratio should not be considered above (use "1")*/
-       data->downspread_factor = bw_add(bw_int_to_fixed(1), bw_div(vbios->down_spread_percentage, bw_int_to_fixed(100)));
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (surface_type[i] == bw_def_graphics) {
-                               switch (data->lb_bpc[i]) {
-                               case 6:
-                                       data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency6_bit_per_component;
-                                       break;
-                               case 8:
-                                       data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency8_bit_per_component;
-                                       break;
-                               case 10:
-                                       data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency10_bit_per_component;
-                                       break;
-                               default:
-                                       data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency12_bit_per_component;
-                                       break;
-                               }
-                               if (data->use_alpha[i] == 1) {
-                                       data->v_scaler_efficiency = bw_min2(data->v_scaler_efficiency, dceip->alpha_vscaler_efficiency);
-                               }
-                       }
-                       else {
-                               switch (data->lb_bpc[i]) {
-                               case 6:
-                                       data->v_scaler_efficiency = dceip->underlay_vscaler_efficiency6_bit_per_component;
-                                       break;
-                               case 8:
-                                       data->v_scaler_efficiency = dceip->underlay_vscaler_efficiency8_bit_per_component;
-                                       break;
-                               case 10:
-                                       data->v_scaler_efficiency = dceip->underlay_vscaler_efficiency10_bit_per_component;
-                                       break;
-                               default:
-                                       data->v_scaler_efficiency = dceip->underlay_vscaler_efficiency12_bit_per_component;
-                                       break;
-                               }
-                       }
-                       if (dceip->pre_downscaler_enabled && bw_mtn(data->hsr[i], bw_int_to_fixed(1))) {
-                               data->scaler_limits_factor = bw_max2(bw_div(data->v_taps[i], data->v_scaler_efficiency), bw_div(data->source_width_rounded_up_to_chunks[i], data->h_total[i]));
-                       }
-                       else {
-                               data->scaler_limits_factor = bw_max3(bw_int_to_fixed(1), bw_ceil2(bw_div(data->h_taps[i], bw_int_to_fixed(4)), bw_int_to_fixed(1)), bw_mul(data->hsr[i], bw_max2(bw_div(data->v_taps[i], data->v_scaler_efficiency), bw_int_to_fixed(1))));
-                       }
-                       data->display_pipe_pixel_throughput = bw_div(bw_div(bw_mul(bw_max2(data->lb_lines_in_per_line_out_in_beginning_of_frame[i], bw_mul(data->lb_lines_in_per_line_out_in_middle_of_frame[i], data->horizontal_blank_and_chunk_granularity_factor[i])), data->source_width_rounded_up_to_chunks[i]), (bw_div(data->h_total[i], data->pixel_rate[i]))), dceip->lb_write_pixels_per_dispclk);
-                       data->dispclk_required_without_ramping[i] = bw_mul(data->downspread_factor, bw_max2(bw_mul(data->pixel_rate[i], data->scaler_limits_factor), bw_mul(dceip->display_pipe_throughput_factor, data->display_pipe_pixel_throughput)));
-                       data->dispclk_required_with_ramping[i] = bw_mul(dceip->dispclk_ramping_factor, bw_max2(bw_mul(data->pixel_rate[i], data->scaler_limits_factor), data->display_pipe_pixel_throughput));
-               }
-       }
-       data->total_dispclk_required_with_ramping = bw_int_to_fixed(0);
-       data->total_dispclk_required_without_ramping = bw_int_to_fixed(0);
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (bw_ltn(data->total_dispclk_required_with_ramping, data->dispclk_required_with_ramping[i])) {
-                               data->total_dispclk_required_with_ramping = data->dispclk_required_with_ramping[i];
-                       }
-                       if (bw_ltn(data->total_dispclk_required_without_ramping, data->dispclk_required_without_ramping[i])) {
-                               data->total_dispclk_required_without_ramping = data->dispclk_required_without_ramping[i];
-                       }
-               }
-       }
-       data->total_read_request_bandwidth = bw_int_to_fixed(0);
-       data->total_write_request_bandwidth = bw_int_to_fixed(0);
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
-                               data->total_read_request_bandwidth = bw_add(data->total_read_request_bandwidth, data->request_bandwidth[i]);
-                       }
-                       else {
-                               data->total_write_request_bandwidth = bw_add(data->total_write_request_bandwidth, data->request_bandwidth[i]);
-                       }
-               }
-       }
-       data->dispclk_required_for_total_read_request_bandwidth = bw_div(bw_mul(data->total_read_request_bandwidth, dceip->dispclk_per_request), dceip->request_efficiency);
-       data->total_dispclk_required_with_ramping_with_request_bandwidth = bw_max2(data->total_dispclk_required_with_ramping, data->dispclk_required_for_total_read_request_bandwidth);
-       data->total_dispclk_required_without_ramping_with_request_bandwidth = bw_max2(data->total_dispclk_required_without_ramping, data->dispclk_required_for_total_read_request_bandwidth);
-       if (data->cpuc_state_change_enable == bw_def_yes) {
-               data->total_dispclk_required_with_ramping_with_request_bandwidth = bw_max3(data->total_dispclk_required_with_ramping_with_request_bandwidth, data->dispclk_required_for_blackout_duration[data->y_clk_level][data->sclk_level], data->dispclk_required_for_blackout_recovery[data->y_clk_level][data->sclk_level]);
-               data->total_dispclk_required_without_ramping_with_request_bandwidth = bw_max3(data->total_dispclk_required_without_ramping_with_request_bandwidth, data->dispclk_required_for_blackout_duration[data->y_clk_level][data->sclk_level], data->dispclk_required_for_blackout_recovery[data->y_clk_level][data->sclk_level]);
-       }
-       if (data->cpup_state_change_enable == bw_def_yes) {
-               data->total_dispclk_required_with_ramping_with_request_bandwidth = bw_max2(data->total_dispclk_required_with_ramping_with_request_bandwidth, data->dispclk_required_for_blackout_duration[data->y_clk_level][data->sclk_level]);
-               data->total_dispclk_required_without_ramping_with_request_bandwidth = bw_max2(data->total_dispclk_required_without_ramping_with_request_bandwidth, data->dispclk_required_for_blackout_duration[data->y_clk_level][data->sclk_level]);
-       }
-       if (data->nbp_state_change_enable == bw_def_yes && data->increase_voltage_to_support_mclk_switch) {
-               data->total_dispclk_required_with_ramping_with_request_bandwidth = bw_max2(data->total_dispclk_required_with_ramping_with_request_bandwidth, data->dispclk_required_for_dram_speed_change[data->y_clk_level][data->sclk_level]);
-               data->total_dispclk_required_without_ramping_with_request_bandwidth = bw_max2(data->total_dispclk_required_without_ramping_with_request_bandwidth, data->dispclk_required_for_dram_speed_change[data->y_clk_level][data->sclk_level]);
-       }
-       if (bw_ltn(data->total_dispclk_required_with_ramping_with_request_bandwidth, vbios->high_voltage_max_dispclk)) {
-               data->dispclk = data->total_dispclk_required_with_ramping_with_request_bandwidth;
-       }
-       else if (bw_ltn(data->total_dispclk_required_without_ramping_with_request_bandwidth, vbios->high_voltage_max_dispclk)) {
-               data->dispclk = vbios->high_voltage_max_dispclk;
-       }
-       else {
-               data->dispclk = data->total_dispclk_required_without_ramping_with_request_bandwidth;
-       }
-       /* required core voltage*/
-       /* the core voltage required is low if sclk, yclk(pclk)and dispclk are within the low limits*/
-       /* otherwise, the core voltage required is medium if yclk (pclk) is within the low limit and sclk and dispclk are within the medium limit*/
-       /* otherwise, the core voltage required is high if the three clocks are within the high limits*/
-       /* otherwise, or if the mode is not supported, core voltage requirement is not applicable*/
-       if (pipe_check == bw_def_notok) {
-               voltage = bw_def_na;
-       }
-       else if (mode_check == bw_def_notok) {
-               voltage = bw_def_notok;
-       }
-       else if (bw_equ(bw_int_to_fixed(yclk_message), vbios->low_yclk) && sclk_message == bw_def_low && bw_ltn(data->dispclk, vbios->low_voltage_max_dispclk)) {
-               voltage = bw_def_0_72;
-       }
-       else if ((bw_equ(bw_int_to_fixed(yclk_message), vbios->low_yclk) || bw_equ(bw_int_to_fixed(yclk_message), vbios->mid_yclk)) && (sclk_message == bw_def_low || sclk_message == bw_def_mid) && bw_ltn(data->dispclk, vbios->mid_voltage_max_dispclk)) {
-               voltage = bw_def_0_8;
-       }
-       else if ((bw_equ(bw_int_to_fixed(yclk_message), vbios->low_yclk) || bw_equ(bw_int_to_fixed(yclk_message), vbios->mid_yclk) || bw_equ(bw_int_to_fixed(yclk_message), vbios->high_yclk)) && (sclk_message == bw_def_low || sclk_message == bw_def_mid || sclk_message == bw_def_high) && bw_leq(data->dispclk, vbios->high_voltage_max_dispclk)) {
-               if ((data->nbp_state_change_enable == bw_def_no && nbp_state_change_enable_blank == bw_def_no)) {
-                       voltage = bw_def_high_no_nbp_state_change;
-               }
-               else {
-                       voltage = bw_def_0_9;
-               }
-       }
-       else {
-               voltage = bw_def_notok;
-       }
-       if (voltage == bw_def_0_72) {
-               data->max_phyclk = vbios->low_voltage_max_phyclk;
-       }
-       else if (voltage == bw_def_0_8) {
-               data->max_phyclk = vbios->mid_voltage_max_phyclk;
-       }
-       else {
-               data->max_phyclk = vbios->high_voltage_max_phyclk;
-       }
-       /*required blackout recovery time*/
-       data->blackout_recovery_time = bw_int_to_fixed(0);
-       for (k = 0; k <= maximum_number_of_surfaces - 1; k++) {
-               if (data->enable[k] && bw_mtn(vbios->blackout_duration, bw_int_to_fixed(0)) && data->cpup_state_change_enable == bw_def_yes) {
-                       if (surface_type[k] != bw_def_display_write_back420_luma && surface_type[k] != bw_def_display_write_back420_chroma) {
-                               data->blackout_recovery_time = bw_max2(data->blackout_recovery_time, bw_add(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[data->y_clk_level][data->sclk_level]));
-                               if (bw_ltn(data->adjusted_data_buffer_size[k], bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), (bw_add(vbios->blackout_duration, bw_add(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[data->y_clk_level][data->sclk_level])))))) {
-                                       data->blackout_recovery_time = bw_max2(data->blackout_recovery_time, bw_div((bw_add(bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), vbios->blackout_duration), bw_sub(bw_div(bw_mul(bw_mul(bw_mul((bw_add(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[data->y_clk_level][data->sclk_level])), data->dispclk), bw_int_to_fixed(data->bytes_per_pixel[k])), data->lines_interleaved_in_mem_access[k]), data->latency_hiding_lines[k]), data->adjusted_data_buffer_size[k]))), (bw_sub(bw_div(bw_mul(bw_mul(data->dispclk, bw_int_to_fixed(data->bytes_per_pixel[k])), data->lines_interleaved_in_mem_access[k]), data->latency_hiding_lines[k]), bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k])))));
-                               }
-                       }
-                       else {
-                               data->blackout_recovery_time = bw_max2(data->blackout_recovery_time, bw_add(bw_mul(bw_int_to_fixed(2), vbios->mcifwrmc_urgent_latency), data->mcifwr_burst_time[data->y_clk_level][data->sclk_level]));
-                               if (bw_ltn(data->adjusted_data_buffer_size[k], bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), (bw_add(vbios->blackout_duration, bw_add(bw_mul(bw_int_to_fixed(2), vbios->mcifwrmc_urgent_latency), data->mcifwr_burst_time[data->y_clk_level][data->sclk_level])))))) {
-                                       data->blackout_recovery_time = bw_max2(data->blackout_recovery_time, bw_div((bw_add(bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), vbios->blackout_duration), bw_sub(bw_div(bw_mul(bw_mul(bw_mul((bw_add(bw_add(bw_mul(bw_int_to_fixed(2), vbios->mcifwrmc_urgent_latency), data->dmif_burst_time[data->y_clk_level][data->sclk_level]), data->mcifwr_burst_time[data->y_clk_level][data->sclk_level])), data->dispclk), bw_int_to_fixed(data->bytes_per_pixel[k])), data->lines_interleaved_in_mem_access[k]), data->latency_hiding_lines[k]), data->adjusted_data_buffer_size[k]))), (bw_sub(bw_div(bw_mul(bw_mul(data->dispclk, bw_int_to_fixed(data->bytes_per_pixel[k])), data->lines_interleaved_in_mem_access[k]), data->latency_hiding_lines[k]), bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k])))));
-                               }
-                       }
-               }
-       }
-       /*sclk deep sleep*/
-       /*during self-refresh, sclk can be reduced to dispclk divided by the minimum pixels in the data fifo entry, with 15% margin, but shoudl not be set to less than the request bandwidth.*/
-       /*the data fifo entry is 16 pixels for the writeback, 64 bytes/bytes_per_pixel for the graphics, 16 pixels for the parallel rotation underlay,*/
-       /*and 16 bytes/bytes_per_pixel for the orthogonal rotation underlay.*/
-       /*in parallel mode (underlay pipe), the data read from the dmifv buffer is variable and based on the pixel depth (8bbp - 16 bytes, 16 bpp - 32 bytes, 32 bpp - 64 bytes)*/
-       /*in orthogonal mode (underlay pipe), the data read from the dmifv buffer is fixed at 16 bytes.*/
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (surface_type[i] == bw_def_display_write_back420_luma || surface_type[i] == bw_def_display_write_back420_chroma) {
-                               data->pixels_per_data_fifo_entry[i] = bw_int_to_fixed(16);
-                       }
-                       else if (surface_type[i] == bw_def_graphics) {
-                               data->pixels_per_data_fifo_entry[i] = bw_div(bw_int_to_fixed(64), bw_int_to_fixed(data->bytes_per_pixel[i]));
-                       }
-                       else if (data->orthogonal_rotation[i] == 0) {
-                               data->pixels_per_data_fifo_entry[i] = bw_int_to_fixed(16);
-                       }
-                       else {
-                               data->pixels_per_data_fifo_entry[i] = bw_div(bw_int_to_fixed(16), bw_int_to_fixed(data->bytes_per_pixel[i]));
-                       }
-               }
-       }
-       data->min_pixels_per_data_fifo_entry = bw_int_to_fixed(9999);
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (bw_mtn(data->min_pixels_per_data_fifo_entry, data->pixels_per_data_fifo_entry[i])) {
-                               data->min_pixels_per_data_fifo_entry = data->pixels_per_data_fifo_entry[i];
-                       }
-               }
-       }
-       data->sclk_deep_sleep = bw_max2(bw_div(bw_mul(data->dispclk, bw_frc_to_fixed(115, 100)), data->min_pixels_per_data_fifo_entry), data->total_read_request_bandwidth);
-       /*urgent, stutter and nb-p_state watermark*/
-       /*the urgent watermark is the maximum of the urgent trip time plus the pixel transfer time, the urgent trip times to get data for the first pixel, and the urgent trip times to get data for the last pixel.*/
-       /*the stutter exit watermark is the self refresh exit time plus the maximum of the data burst time plus the pixel transfer time, the data burst times to get data for the first pixel, and the data burst times to get data for the last pixel.  it does not apply to the writeback.*/
-       /*the nb p-state change watermark is the dram speed/p-state change time plus the maximum of the data burst time plus the pixel transfer time, the data burst times to get data for the first pixel, and the data burst times to get data for the last pixel.*/
-       /*the pixel transfer time is the maximum of the time to transfer the source pixels required for the first output pixel, and the time to transfer the pixels for the last output pixel minus the active line time.*/
-       /*blackout_duration is added to the urgent watermark*/
-       data->chunk_request_time = bw_int_to_fixed(0);
-       data->cursor_request_time = bw_int_to_fixed(0);
-       /*compute total time to request one chunk from each active display pipe*/
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       data->chunk_request_time = bw_add(data->chunk_request_time, (bw_div((bw_div(bw_int_to_fixed(pixels_per_chunk * data->bytes_per_pixel[i]), data->useful_bytes_per_request[i])), bw_min2(sclk[data->sclk_level], bw_div(data->dispclk, bw_int_to_fixed(2))))));
-               }
-       }
-       /*compute total time to request cursor data*/
-       data->cursor_request_time = (bw_div(data->cursor_total_data, (bw_mul(bw_int_to_fixed(32), sclk[data->sclk_level]))));
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       data->line_source_pixels_transfer_time = bw_max2(bw_div(bw_div(data->src_pixels_for_first_output_pixel[i], dceip->lb_write_pixels_per_dispclk), (bw_div(data->dispclk, dceip->display_pipe_throughput_factor))), bw_sub(bw_div(bw_div(data->src_pixels_for_last_output_pixel[i], dceip->lb_write_pixels_per_dispclk), (bw_div(data->dispclk, dceip->display_pipe_throughput_factor))), data->active_time[i]));
-                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
-                               data->urgent_watermark[i] = bw_add(bw_add(bw_add(bw_add(bw_add(data->total_dmifmc_urgent_latency, data->dmif_burst_time[data->y_clk_level][data->sclk_level]), bw_max2(data->line_source_pixels_transfer_time, data->line_source_transfer_time[i][data->y_clk_level][data->sclk_level])), vbios->blackout_duration), data->chunk_request_time), data->cursor_request_time);
-                               data->stutter_exit_watermark[i] = bw_add(bw_sub(vbios->stutter_self_refresh_exit_latency, data->total_dmifmc_urgent_latency), data->urgent_watermark[i]);
-                               data->stutter_entry_watermark[i] = bw_add(bw_sub(bw_add(vbios->stutter_self_refresh_exit_latency, vbios->stutter_self_refresh_entry_latency), data->total_dmifmc_urgent_latency), data->urgent_watermark[i]);
-                               /*unconditionally remove black out time from the nb p_state watermark*/
-                               if (data->display_pstate_change_enable[i] == 1) {
-                                       data->nbp_state_change_watermark[i] = bw_add(bw_add(vbios->nbp_state_change_latency, data->dmif_burst_time[data->y_clk_level][data->sclk_level]), bw_max2(data->line_source_pixels_transfer_time, data->dram_speed_change_line_source_transfer_time[i][data->y_clk_level][data->sclk_level]));
-                               }
-                               else {
-                                       /*maximize the watermark to force the switch in the vb_lank region of the frame*/
-                                       data->nbp_state_change_watermark[i] = bw_int_to_fixed(131000);
-                               }
-                       }
-                       else {
-                               data->urgent_watermark[i] = bw_add(bw_add(bw_add(bw_add(bw_add(vbios->mcifwrmc_urgent_latency, data->mcifwr_burst_time[data->y_clk_level][data->sclk_level]), bw_max2(data->line_source_pixels_transfer_time, data->line_source_transfer_time[i][data->y_clk_level][data->sclk_level])), vbios->blackout_duration), data->chunk_request_time), data->cursor_request_time);
-                               data->stutter_exit_watermark[i] = bw_int_to_fixed(0);
-                               data->stutter_entry_watermark[i] = bw_int_to_fixed(0);
-                               if (data->display_pstate_change_enable[i] == 1) {
-                                       data->nbp_state_change_watermark[i] = bw_add(bw_add(vbios->nbp_state_change_latency, data->mcifwr_burst_time[data->y_clk_level][data->sclk_level]), bw_max2(data->line_source_pixels_transfer_time, data->dram_speed_change_line_source_transfer_time[i][data->y_clk_level][data->sclk_level]));
-                               }
-                               else {
-                                       /*maximize the watermark to force the switch in the vb_lank region of the frame*/
-                                       data->nbp_state_change_watermark[i] = bw_int_to_fixed(131000);
-                               }
-                       }
-               }
-       }
-       /*stutter mode enable*/
-       /*in the multi-display case the stutter exit or entry watermark cannot exceed the minimum latency hiding capabilities of the*/
-       /*display pipe.*/
-       data->stutter_mode_enable = data->cpuc_state_change_enable;
-       if (data->number_of_displays > 1) {
-               for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-                       if (data->enable[i]) {
-                               if ((bw_mtn(data->stutter_exit_watermark[i], data->minimum_latency_hiding[i]) || bw_mtn(data->stutter_entry_watermark[i], data->minimum_latency_hiding[i]))) {
-                                       data->stutter_mode_enable = bw_def_no;
-                               }
-                       }
-               }
-       }
-       /*performance metrics*/
-       /* display read access efficiency (%)*/
-       /* display write back access efficiency (%)*/
-       /* stutter efficiency (%)*/
-       /* extra underlay pitch recommended for efficiency (pixels)*/
-       /* immediate flip time (us)*/
-       /* latency for other clients due to urgent display read (us)*/
-       /* latency for other clients due to urgent display write (us)*/
-       /* average bandwidth consumed by display (no compression) (gb/s)*/
-       /* required dram  bandwidth (gb/s)*/
-       /* required sclk (m_hz)*/
-       /* required rd urgent latency (us)*/
-       /* nb p-state change margin (us)*/
-       /*dmif and mcifwr dram access efficiency*/
-       /*is the ratio between the ideal dram access time (which is the data buffer size in memory divided by the dram bandwidth), and the actual time which is the total page close-open time.  but it cannot exceed the dram efficiency provided by the memory subsystem*/
-       data->dmifdram_access_efficiency = bw_min2(bw_div(bw_div(data->total_display_reads_required_dram_access_data, data->dram_bandwidth), data->dmif_total_page_close_open_time), bw_int_to_fixed(1));
-       if (bw_mtn(data->total_display_writes_required_dram_access_data, bw_int_to_fixed(0))) {
-               data->mcifwrdram_access_efficiency = bw_min2(bw_div(bw_div(data->total_display_writes_required_dram_access_data, data->dram_bandwidth), data->mcifwr_total_page_close_open_time), bw_int_to_fixed(1));
-       }
-       else {
-               data->mcifwrdram_access_efficiency = bw_int_to_fixed(0);
-       }
-       /*stutter efficiency*/
-       /*the stutter efficiency is the frame-average time in self-refresh divided by the frame-average stutter cycle duration.  only applies if the display write-back is not enabled.*/
-       /*the frame-average stutter cycle used is the minimum for all pipes of the frame-average data buffer size in time, times the compression rate*/
-       /*the frame-average time in self-refresh is the stutter cycle minus the self refresh exit latency and the burst time*/
-       /*the stutter cycle is the dmif buffer size reduced by the excess of the stutter exit watermark over the lb size in time.*/
-       /*the burst time is the data needed during the stutter cycle divided by the available bandwidth*/
-       /*compute the time read all the data from the dmif buffer to the lb (dram refresh period)*/
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       data->stutter_refresh_duration[i] = bw_sub(bw_mul(bw_div(bw_div(bw_mul(bw_div(bw_div(data->adjusted_data_buffer_size[i], bw_int_to_fixed(data->bytes_per_pixel[i])), data->source_width_rounded_up_to_chunks[i]), data->h_total[i]), data->vsr[i]), data->pixel_rate[i]), data->compression_rate[i]), bw_max2(bw_int_to_fixed(0), bw_sub(data->stutter_exit_watermark[i], bw_div(bw_mul((bw_sub(data->lb_partitions[i], bw_int_to_fixed(1))), data->h_total[i]), data->pixel_rate[i]))));
-                       data->stutter_dmif_buffer_size[i] = bw_div(bw_mul(bw_mul(bw_div(bw_mul(bw_mul(data->stutter_refresh_duration[i], bw_int_to_fixed(data->bytes_per_pixel[i])), data->source_width_rounded_up_to_chunks[i]), data->h_total[i]), data->vsr[i]), data->pixel_rate[i]), data->compression_rate[i]);
-               }
-       }
-       data->min_stutter_refresh_duration = bw_int_to_fixed(9999);
-       data->total_stutter_dmif_buffer_size = 0;
-       data->total_bytes_requested = 0;
-       data->min_stutter_dmif_buffer_size = 9999;
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       if (bw_mtn(data->min_stutter_refresh_duration, data->stutter_refresh_duration[i])) {
-                               data->min_stutter_refresh_duration = data->stutter_refresh_duration[i];
-                               data->total_bytes_requested = bw_fixed_to_int(bw_add(bw_int_to_fixed(data->total_bytes_requested), (bw_mul(bw_mul(data->source_height_rounded_up_to_chunks[i], data->source_width_rounded_up_to_chunks[i]), bw_int_to_fixed(data->bytes_per_pixel[i])))));
-                               data->min_stutter_dmif_buffer_size = bw_fixed_to_int(data->stutter_dmif_buffer_size[i]);
-                       }
-                       data->total_stutter_dmif_buffer_size = bw_fixed_to_int(bw_add(data->stutter_dmif_buffer_size[i], bw_int_to_fixed(data->total_stutter_dmif_buffer_size)));
-               }
-       }
-       data->stutter_burst_time = bw_div(bw_int_to_fixed(data->total_stutter_dmif_buffer_size), bw_mul(sclk[data->sclk_level], vbios->data_return_bus_width));
-       data->num_stutter_bursts = data->total_bytes_requested / data->min_stutter_dmif_buffer_size;
-       data->total_stutter_cycle_duration = bw_add(bw_add(data->min_stutter_refresh_duration, vbios->stutter_self_refresh_exit_latency), data->stutter_burst_time);
-       data->time_in_self_refresh = data->min_stutter_refresh_duration;
-       if (data->d1_display_write_back_dwb_enable == 1) {
-               data->stutter_efficiency = bw_int_to_fixed(0);
-       }
-       else if (bw_ltn(data->time_in_self_refresh, bw_int_to_fixed(0))) {
-               data->stutter_efficiency = bw_int_to_fixed(0);
-       }
-       else {
-               /*compute stutter efficiency assuming 60 hz refresh rate*/
-               data->stutter_efficiency = bw_max2(bw_int_to_fixed(0), bw_mul((bw_sub(bw_int_to_fixed(1), (bw_div(bw_mul((bw_add(vbios->stutter_self_refresh_exit_latency, data->stutter_burst_time)), bw_int_to_fixed(data->num_stutter_bursts)), bw_frc_to_fixed(166666667, 10000))))), bw_int_to_fixed(100)));
-       }
-       /*immediate flip time*/
-       /*if scatter gather is enabled, the immediate flip takes a number of urgent memory trips equivalent to the pte requests in a row divided by the pte request limit.*/
-       /*otherwise, it may take just one urgenr memory trip*/
-       data->worst_number_of_trips_to_memory = bw_int_to_fixed(1);
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i] && data->scatter_gather_enable_for_pipe[i] == 1) {
-                       data->number_of_trips_to_memory_for_getting_apte_row[i] = bw_ceil2(bw_div(data->scatter_gather_pte_requests_in_row[i], data->scatter_gather_pte_request_limit[i]), bw_int_to_fixed(1));
-                       if (bw_ltn(data->worst_number_of_trips_to_memory, data->number_of_trips_to_memory_for_getting_apte_row[i])) {
-                               data->worst_number_of_trips_to_memory = data->number_of_trips_to_memory_for_getting_apte_row[i];
-                       }
-               }
-       }
-       data->immediate_flip_time = bw_mul(data->worst_number_of_trips_to_memory, data->total_dmifmc_urgent_latency);
-       /*worst latency for other clients*/
-       /*it is the urgent latency plus the urgent burst time*/
-       data->latency_for_non_dmif_clients = bw_add(data->total_dmifmc_urgent_latency, data->dmif_burst_time[data->y_clk_level][data->sclk_level]);
-       if (data->d1_display_write_back_dwb_enable == 1) {
-               data->latency_for_non_mcifwr_clients = bw_add(vbios->mcifwrmc_urgent_latency, dceip->mcifwr_all_surfaces_burst_time);
-       }
-       else {
-               data->latency_for_non_mcifwr_clients = bw_int_to_fixed(0);
-       }
-       /*dmif mc urgent latency supported in high sclk and yclk*/
-       data->dmifmc_urgent_latency_supported_in_high_sclk_and_yclk = bw_div((bw_sub(data->min_read_buffer_size_in_time, data->dmif_burst_time[high][s_high])), data->total_dmifmc_urgent_trips);
-       /*dram speed/p-state change margin*/
-       /*in the multi-display case the nb p-state change watermark cannot exceed the average lb size plus the dmif size or the cursor dcp buffer size*/
-       data->v_blank_nbp_state_dram_speed_change_latency_supported = bw_int_to_fixed(99999);
-       data->nbp_state_dram_speed_change_latency_supported = bw_int_to_fixed(99999);
-       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
-               if (data->enable[i]) {
-                       data->nbp_state_dram_speed_change_latency_supported = bw_min2(data->nbp_state_dram_speed_change_latency_supported, bw_add(bw_sub(data->maximum_latency_hiding_with_cursor[i], data->nbp_state_change_watermark[i]), vbios->nbp_state_change_latency));
-                       data->v_blank_nbp_state_dram_speed_change_latency_supported = bw_min2(data->v_blank_nbp_state_dram_speed_change_latency_supported, bw_add(bw_sub(bw_div(bw_mul((bw_sub(data->v_total[i], bw_sub(bw_div(data->src_height[i], data->v_scale_ratio[i]), bw_int_to_fixed(4)))), data->h_total[i]), data->pixel_rate[i]), data->nbp_state_change_watermark[i]), vbios->nbp_state_change_latency));
-               }
-       }
-       /*sclk required vs urgent latency*/
-       for (i = 1; i <= 5; i++) {
-               data->display_reads_time_for_data_transfer_and_urgent_latency = bw_sub(data->min_read_buffer_size_in_time, bw_mul(data->total_dmifmc_urgent_trips, bw_int_to_fixed(i)));
-               if (pipe_check == bw_def_ok && (bw_mtn(data->display_reads_time_for_data_transfer_and_urgent_latency, data->dmif_total_page_close_open_time))) {
-                       data->dmif_required_sclk_for_urgent_latency[i] = bw_div(bw_div(data->total_display_reads_required_data, data->display_reads_time_for_data_transfer_and_urgent_latency), (bw_mul(vbios->data_return_bus_width, bw_frc_to_fixed(dceip->percent_of_ideal_port_bw_received_after_urgent_latency, 100))));
-               }
-               else {
-                       data->dmif_required_sclk_for_urgent_latency[i] = bw_int_to_fixed(bw_def_na);
-               }
-       }
-       /*output link bit per pixel supported*/
-       for (k = 0; k <= maximum_number_of_surfaces - 1; k++) {
-               data->output_bpphdmi[k] = bw_def_na;
-               data->output_bppdp4_lane_hbr[k] = bw_def_na;
-               data->output_bppdp4_lane_hbr2[k] = bw_def_na;
-               data->output_bppdp4_lane_hbr3[k] = bw_def_na;
-               if (data->enable[k]) {
-                       data->output_bpphdmi[k] = bw_fixed_to_int(bw_mul(bw_div(bw_min2(bw_int_to_fixed(600), data->max_phyclk), data->pixel_rate[k]), bw_int_to_fixed(24)));
-                       if (bw_meq(data->max_phyclk, bw_int_to_fixed(270))) {
-                               data->output_bppdp4_lane_hbr[k] = bw_fixed_to_int(bw_mul(bw_div(bw_mul(bw_int_to_fixed(270), bw_int_to_fixed(4)), data->pixel_rate[k]), bw_int_to_fixed(8)));
-                       }
-                       if (bw_meq(data->max_phyclk, bw_int_to_fixed(540))) {
-                               data->output_bppdp4_lane_hbr2[k] = bw_fixed_to_int(bw_mul(bw_div(bw_mul(bw_int_to_fixed(540), bw_int_to_fixed(4)), data->pixel_rate[k]), bw_int_to_fixed(8)));
-                       }
-                       if (bw_meq(data->max_phyclk, bw_int_to_fixed(810))) {
-                               data->output_bppdp4_lane_hbr3[k] = bw_fixed_to_int(bw_mul(bw_div(bw_mul(bw_int_to_fixed(810), bw_int_to_fixed(4)), data->pixel_rate[k]), bw_int_to_fixed(8)));
-                       }
-               }
-       }
-
-       kfree(surface_type);
-free_tiling_mode:
-       kfree(tiling_mode);
-free_yclk:
-       kfree(yclk);
-free_sclk:
-       kfree(sclk);
-}
-
-/*******************************************************************************
- * Public functions
- ******************************************************************************/
-void bw_calcs_init(struct bw_calcs_dceip *bw_dceip,
-       struct bw_calcs_vbios *bw_vbios,
-       struct hw_asic_id asic_id)
-{
-       struct bw_calcs_dceip *dceip;
-       struct bw_calcs_vbios *vbios;
-
-       enum bw_calcs_version version = bw_calcs_version_from_asic_id(asic_id);
-
-       dceip = kzalloc(sizeof(*dceip), GFP_KERNEL);
-       if (!dceip)
-               return;
-
-       vbios = kzalloc(sizeof(*vbios), GFP_KERNEL);
-       if (!vbios) {
-               kfree(dceip);
-               return;
-       }
-
-       dceip->version = version;
-
-       switch (version) {
-       case BW_CALCS_VERSION_CARRIZO:
-               vbios->memory_type = bw_def_gddr5;
-               vbios->dram_channel_width_in_bits = 64;
-               vbios->number_of_dram_channels = asic_id.vram_width / vbios->dram_channel_width_in_bits;
-               vbios->number_of_dram_banks = 8;
-               vbios->high_yclk = bw_int_to_fixed(1600);
-               vbios->mid_yclk = bw_int_to_fixed(1600);
-               vbios->low_yclk = bw_frc_to_fixed(66666, 100);
-               vbios->low_sclk = bw_int_to_fixed(200);
-               vbios->mid1_sclk = bw_int_to_fixed(300);
-               vbios->mid2_sclk = bw_int_to_fixed(300);
-               vbios->mid3_sclk = bw_int_to_fixed(300);
-               vbios->mid4_sclk = bw_int_to_fixed(300);
-               vbios->mid5_sclk = bw_int_to_fixed(300);
-               vbios->mid6_sclk = bw_int_to_fixed(300);
-               vbios->high_sclk = bw_frc_to_fixed(62609, 100);
-               vbios->low_voltage_max_dispclk = bw_int_to_fixed(352);
-               vbios->mid_voltage_max_dispclk = bw_int_to_fixed(467);
-               vbios->high_voltage_max_dispclk = bw_int_to_fixed(643);
-               vbios->low_voltage_max_phyclk = bw_int_to_fixed(540);
-               vbios->mid_voltage_max_phyclk = bw_int_to_fixed(810);
-               vbios->high_voltage_max_phyclk = bw_int_to_fixed(810);
-               vbios->data_return_bus_width = bw_int_to_fixed(32);
-               vbios->trc = bw_int_to_fixed(50);
-               vbios->dmifmc_urgent_latency = bw_int_to_fixed(4);
-               vbios->stutter_self_refresh_exit_latency = bw_frc_to_fixed(153, 10);
-               vbios->stutter_self_refresh_entry_latency = bw_int_to_fixed(0);
-               vbios->nbp_state_change_latency = bw_frc_to_fixed(19649, 1000);
-               vbios->mcifwrmc_urgent_latency = bw_int_to_fixed(10);
-               vbios->scatter_gather_enable = true;
-               vbios->down_spread_percentage = bw_frc_to_fixed(5, 10);
-               vbios->cursor_width = 32;
-               vbios->average_compression_rate = 4;
-               vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel = 256;
-               vbios->blackout_duration = bw_int_to_fixed(0); /* us */
-               vbios->maximum_blackout_recovery_time = bw_int_to_fixed(0);
-
-               dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation = 100;
-               dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation = 100;
-               dceip->percent_of_ideal_port_bw_received_after_urgent_latency = 100;
-               dceip->large_cursor = false;
-               dceip->dmif_request_buffer_size = bw_int_to_fixed(768);
-               dceip->dmif_pipe_en_fbc_chunk_tracker = false;
-               dceip->cursor_max_outstanding_group_num = 1;
-               dceip->lines_interleaved_into_lb = 2;
-               dceip->chunk_width = 256;
-               dceip->number_of_graphics_pipes = 3;
-               dceip->number_of_underlay_pipes = 1;
-               dceip->low_power_tiling_mode = 0;
-               dceip->display_write_back_supported = false;
-               dceip->argb_compression_support = false;
-               dceip->underlay_vscaler_efficiency6_bit_per_component =
-                       bw_frc_to_fixed(35556, 10000);
-               dceip->underlay_vscaler_efficiency8_bit_per_component =
-                       bw_frc_to_fixed(34286, 10000);
-               dceip->underlay_vscaler_efficiency10_bit_per_component =
-                       bw_frc_to_fixed(32, 10);
-               dceip->underlay_vscaler_efficiency12_bit_per_component =
-                       bw_int_to_fixed(3);
-               dceip->graphics_vscaler_efficiency6_bit_per_component =
-                       bw_frc_to_fixed(35, 10);
-               dceip->graphics_vscaler_efficiency8_bit_per_component =
-                       bw_frc_to_fixed(34286, 10000);
-               dceip->graphics_vscaler_efficiency10_bit_per_component =
-                       bw_frc_to_fixed(32, 10);
-               dceip->graphics_vscaler_efficiency12_bit_per_component =
-                       bw_int_to_fixed(3);
-               dceip->alpha_vscaler_efficiency = bw_int_to_fixed(3);
-               dceip->max_dmif_buffer_allocated = 2;
-               dceip->graphics_dmif_size = 12288;
-               dceip->underlay_luma_dmif_size = 19456;
-               dceip->underlay_chroma_dmif_size = 23552;
-               dceip->pre_downscaler_enabled = true;
-               dceip->underlay_downscale_prefetch_enabled = true;
-               dceip->lb_write_pixels_per_dispclk = bw_int_to_fixed(1);
-               dceip->lb_size_per_component444 = bw_int_to_fixed(82176);
-               dceip->graphics_lb_nodownscaling_multi_line_prefetching = false;
-               dceip->stutter_and_dram_clock_state_change_gated_before_cursor =
-                       bw_int_to_fixed(0);
-               dceip->underlay420_luma_lb_size_per_component = bw_int_to_fixed(
-                       82176);
-               dceip->underlay420_chroma_lb_size_per_component =
-                       bw_int_to_fixed(164352);
-               dceip->underlay422_lb_size_per_component = bw_int_to_fixed(
-                       82176);
-               dceip->cursor_chunk_width = bw_int_to_fixed(64);
-               dceip->cursor_dcp_buffer_lines = bw_int_to_fixed(4);
-               dceip->underlay_maximum_width_efficient_for_tiling =
-                       bw_int_to_fixed(1920);
-               dceip->underlay_maximum_height_efficient_for_tiling =
-                       bw_int_to_fixed(1080);
-               dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display =
-                       bw_frc_to_fixed(3, 10);
-               dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation =
-                       bw_int_to_fixed(25);
-               dceip->minimum_outstanding_pte_request_limit = bw_int_to_fixed(
-                       2);
-               dceip->maximum_total_outstanding_pte_requests_allowed_by_saw =
-                       bw_int_to_fixed(128);
-               dceip->limit_excessive_outstanding_dmif_requests = true;
-               dceip->linear_mode_line_request_alternation_slice =
-                       bw_int_to_fixed(64);
-               dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode =
-                       32;
-               dceip->display_write_back420_luma_mcifwr_buffer_size = 12288;
-               dceip->display_write_back420_chroma_mcifwr_buffer_size = 8192;
-               dceip->request_efficiency = bw_frc_to_fixed(8, 10);
-               dceip->dispclk_per_request = bw_int_to_fixed(2);
-               dceip->dispclk_ramping_factor = bw_frc_to_fixed(105, 100);
-               dceip->display_pipe_throughput_factor = bw_frc_to_fixed(105, 100);
-               dceip->scatter_gather_pte_request_rows_in_tiling_mode = 2;
-               dceip->mcifwr_all_surfaces_burst_time = bw_int_to_fixed(0); /* todo: this is a bug*/
-               break;
-       case BW_CALCS_VERSION_POLARIS10:
-               /* TODO: Treat VEGAM the same as P10 for now
-                * Need to tune the para for VEGAM if needed */
-       case BW_CALCS_VERSION_VEGAM:
-               vbios->memory_type = bw_def_gddr5;
-               vbios->dram_channel_width_in_bits = 32;
-               vbios->number_of_dram_channels = asic_id.vram_width / vbios->dram_channel_width_in_bits;
-               vbios->number_of_dram_banks = 8;
-               vbios->high_yclk = bw_int_to_fixed(6000);
-               vbios->mid_yclk = bw_int_to_fixed(3200);
-               vbios->low_yclk = bw_int_to_fixed(1000);
-               vbios->low_sclk = bw_int_to_fixed(300);
-               vbios->mid1_sclk = bw_int_to_fixed(400);
-               vbios->mid2_sclk = bw_int_to_fixed(500);
-               vbios->mid3_sclk = bw_int_to_fixed(600);
-               vbios->mid4_sclk = bw_int_to_fixed(700);
-               vbios->mid5_sclk = bw_int_to_fixed(800);
-               vbios->mid6_sclk = bw_int_to_fixed(974);
-               vbios->high_sclk = bw_int_to_fixed(1154);
-               vbios->low_voltage_max_dispclk = bw_int_to_fixed(459);
-               vbios->mid_voltage_max_dispclk = bw_int_to_fixed(654);
-               vbios->high_voltage_max_dispclk = bw_int_to_fixed(1108);
-               vbios->low_voltage_max_phyclk = bw_int_to_fixed(540);
-               vbios->mid_voltage_max_phyclk = bw_int_to_fixed(810);
-               vbios->high_voltage_max_phyclk = bw_int_to_fixed(810);
-               vbios->data_return_bus_width = bw_int_to_fixed(32);
-               vbios->trc = bw_int_to_fixed(48);
-               vbios->dmifmc_urgent_latency = bw_int_to_fixed(3);
-               vbios->stutter_self_refresh_exit_latency = bw_int_to_fixed(5);
-               vbios->stutter_self_refresh_entry_latency = bw_int_to_fixed(0);
-               vbios->nbp_state_change_latency = bw_int_to_fixed(45);
-               vbios->mcifwrmc_urgent_latency = bw_int_to_fixed(10);
-               vbios->scatter_gather_enable = true;
-               vbios->down_spread_percentage = bw_frc_to_fixed(5, 10);
-               vbios->cursor_width = 32;
-               vbios->average_compression_rate = 4;
-               vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel = 256;
-               vbios->blackout_duration = bw_int_to_fixed(0); /* us */
-               vbios->maximum_blackout_recovery_time = bw_int_to_fixed(0);
-
-               dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation = 100;
-               dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation = 100;
-               dceip->percent_of_ideal_port_bw_received_after_urgent_latency = 100;
-               dceip->large_cursor = false;
-               dceip->dmif_request_buffer_size = bw_int_to_fixed(768);
-               dceip->dmif_pipe_en_fbc_chunk_tracker = false;
-               dceip->cursor_max_outstanding_group_num = 1;
-               dceip->lines_interleaved_into_lb = 2;
-               dceip->chunk_width = 256;
-               dceip->number_of_graphics_pipes = 6;
-               dceip->number_of_underlay_pipes = 0;
-               dceip->low_power_tiling_mode = 0;
-               dceip->display_write_back_supported = false;
-               dceip->argb_compression_support = true;
-               dceip->underlay_vscaler_efficiency6_bit_per_component =
-                       bw_frc_to_fixed(35556, 10000);
-               dceip->underlay_vscaler_efficiency8_bit_per_component =
-                       bw_frc_to_fixed(34286, 10000);
-               dceip->underlay_vscaler_efficiency10_bit_per_component =
-                       bw_frc_to_fixed(32, 10);
-               dceip->underlay_vscaler_efficiency12_bit_per_component =
-                       bw_int_to_fixed(3);
-               dceip->graphics_vscaler_efficiency6_bit_per_component =
-                       bw_frc_to_fixed(35, 10);
-               dceip->graphics_vscaler_efficiency8_bit_per_component =
-                       bw_frc_to_fixed(34286, 10000);
-               dceip->graphics_vscaler_efficiency10_bit_per_component =
-                       bw_frc_to_fixed(32, 10);
-               dceip->graphics_vscaler_efficiency12_bit_per_component =
-                       bw_int_to_fixed(3);
-               dceip->alpha_vscaler_efficiency = bw_int_to_fixed(3);
-               dceip->max_dmif_buffer_allocated = 4;
-               dceip->graphics_dmif_size = 12288;
-               dceip->underlay_luma_dmif_size = 19456;
-               dceip->underlay_chroma_dmif_size = 23552;
-               dceip->pre_downscaler_enabled = true;
-               dceip->underlay_downscale_prefetch_enabled = true;
-               dceip->lb_write_pixels_per_dispclk = bw_int_to_fixed(1);
-               dceip->lb_size_per_component444 = bw_int_to_fixed(245952);
-               dceip->graphics_lb_nodownscaling_multi_line_prefetching = true;
-               dceip->stutter_and_dram_clock_state_change_gated_before_cursor =
-                       bw_int_to_fixed(1);
-               dceip->underlay420_luma_lb_size_per_component = bw_int_to_fixed(
-                       82176);
-               dceip->underlay420_chroma_lb_size_per_component =
-                       bw_int_to_fixed(164352);
-               dceip->underlay422_lb_size_per_component = bw_int_to_fixed(
-                       82176);
-               dceip->cursor_chunk_width = bw_int_to_fixed(64);
-               dceip->cursor_dcp_buffer_lines = bw_int_to_fixed(4);
-               dceip->underlay_maximum_width_efficient_for_tiling =
-                       bw_int_to_fixed(1920);
-               dceip->underlay_maximum_height_efficient_for_tiling =
-                       bw_int_to_fixed(1080);
-               dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display =
-                       bw_frc_to_fixed(3, 10);
-               dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation =
-                       bw_int_to_fixed(25);
-               dceip->minimum_outstanding_pte_request_limit = bw_int_to_fixed(
-                       2);
-               dceip->maximum_total_outstanding_pte_requests_allowed_by_saw =
-                       bw_int_to_fixed(128);
-               dceip->limit_excessive_outstanding_dmif_requests = true;
-               dceip->linear_mode_line_request_alternation_slice =
-                       bw_int_to_fixed(64);
-               dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode =
-                       32;
-               dceip->display_write_back420_luma_mcifwr_buffer_size = 12288;
-               dceip->display_write_back420_chroma_mcifwr_buffer_size = 8192;
-               dceip->request_efficiency = bw_frc_to_fixed(8, 10);
-               dceip->dispclk_per_request = bw_int_to_fixed(2);
-               dceip->dispclk_ramping_factor = bw_frc_to_fixed(105, 100);
-               dceip->display_pipe_throughput_factor = bw_frc_to_fixed(105, 100);
-               dceip->scatter_gather_pte_request_rows_in_tiling_mode = 2;
-               dceip->mcifwr_all_surfaces_burst_time = bw_int_to_fixed(0);
-               break;
-       case BW_CALCS_VERSION_POLARIS11:
-               vbios->memory_type = bw_def_gddr5;
-               vbios->dram_channel_width_in_bits = 32;
-               vbios->number_of_dram_channels = asic_id.vram_width / vbios->dram_channel_width_in_bits;
-               vbios->number_of_dram_banks = 8;
-               vbios->high_yclk = bw_int_to_fixed(6000);
-               vbios->mid_yclk = bw_int_to_fixed(3200);
-               vbios->low_yclk = bw_int_to_fixed(1000);
-               vbios->low_sclk = bw_int_to_fixed(300);
-               vbios->mid1_sclk = bw_int_to_fixed(400);
-               vbios->mid2_sclk = bw_int_to_fixed(500);
-               vbios->mid3_sclk = bw_int_to_fixed(600);
-               vbios->mid4_sclk = bw_int_to_fixed(700);
-               vbios->mid5_sclk = bw_int_to_fixed(800);
-               vbios->mid6_sclk = bw_int_to_fixed(974);
-               vbios->high_sclk = bw_int_to_fixed(1154);
-               vbios->low_voltage_max_dispclk = bw_int_to_fixed(459);
-               vbios->mid_voltage_max_dispclk = bw_int_to_fixed(654);
-               vbios->high_voltage_max_dispclk = bw_int_to_fixed(1108);
-               vbios->low_voltage_max_phyclk = bw_int_to_fixed(540);
-               vbios->mid_voltage_max_phyclk = bw_int_to_fixed(810);
-               vbios->high_voltage_max_phyclk = bw_int_to_fixed(810);
-               vbios->data_return_bus_width = bw_int_to_fixed(32);
-               vbios->trc = bw_int_to_fixed(48);
-               if (vbios->number_of_dram_channels == 2) // 64-bit
-                       vbios->dmifmc_urgent_latency = bw_int_to_fixed(4);
-               else
-                       vbios->dmifmc_urgent_latency = bw_int_to_fixed(3);
-               vbios->stutter_self_refresh_exit_latency = bw_int_to_fixed(5);
-               vbios->stutter_self_refresh_entry_latency = bw_int_to_fixed(0);
-               vbios->nbp_state_change_latency = bw_int_to_fixed(45);
-               vbios->mcifwrmc_urgent_latency = bw_int_to_fixed(10);
-               vbios->scatter_gather_enable = true;
-               vbios->down_spread_percentage = bw_frc_to_fixed(5, 10);
-               vbios->cursor_width = 32;
-               vbios->average_compression_rate = 4;
-               vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel = 256;
-               vbios->blackout_duration = bw_int_to_fixed(0); /* us */
-               vbios->maximum_blackout_recovery_time = bw_int_to_fixed(0);
-
-               dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation = 100;
-               dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation = 100;
-               dceip->percent_of_ideal_port_bw_received_after_urgent_latency = 100;
-               dceip->large_cursor = false;
-               dceip->dmif_request_buffer_size = bw_int_to_fixed(768);
-               dceip->dmif_pipe_en_fbc_chunk_tracker = false;
-               dceip->cursor_max_outstanding_group_num = 1;
-               dceip->lines_interleaved_into_lb = 2;
-               dceip->chunk_width = 256;
-               dceip->number_of_graphics_pipes = 5;
-               dceip->number_of_underlay_pipes = 0;
-               dceip->low_power_tiling_mode = 0;
-               dceip->display_write_back_supported = false;
-               dceip->argb_compression_support = true;
-               dceip->underlay_vscaler_efficiency6_bit_per_component =
-                       bw_frc_to_fixed(35556, 10000);
-               dceip->underlay_vscaler_efficiency8_bit_per_component =
-                       bw_frc_to_fixed(34286, 10000);
-               dceip->underlay_vscaler_efficiency10_bit_per_component =
-                       bw_frc_to_fixed(32, 10);
-               dceip->underlay_vscaler_efficiency12_bit_per_component =
-                       bw_int_to_fixed(3);
-               dceip->graphics_vscaler_efficiency6_bit_per_component =
-                       bw_frc_to_fixed(35, 10);
-               dceip->graphics_vscaler_efficiency8_bit_per_component =
-                       bw_frc_to_fixed(34286, 10000);
-               dceip->graphics_vscaler_efficiency10_bit_per_component =
-                       bw_frc_to_fixed(32, 10);
-               dceip->graphics_vscaler_efficiency12_bit_per_component =
-                       bw_int_to_fixed(3);
-               dceip->alpha_vscaler_efficiency = bw_int_to_fixed(3);
-               dceip->max_dmif_buffer_allocated = 4;
-               dceip->graphics_dmif_size = 12288;
-               dceip->underlay_luma_dmif_size = 19456;
-               dceip->underlay_chroma_dmif_size = 23552;
-               dceip->pre_downscaler_enabled = true;
-               dceip->underlay_downscale_prefetch_enabled = true;
-               dceip->lb_write_pixels_per_dispclk = bw_int_to_fixed(1);
-               dceip->lb_size_per_component444 = bw_int_to_fixed(245952);
-               dceip->graphics_lb_nodownscaling_multi_line_prefetching = true;
-               dceip->stutter_and_dram_clock_state_change_gated_before_cursor =
-                       bw_int_to_fixed(1);
-               dceip->underlay420_luma_lb_size_per_component = bw_int_to_fixed(
-                       82176);
-               dceip->underlay420_chroma_lb_size_per_component =
-                       bw_int_to_fixed(164352);
-               dceip->underlay422_lb_size_per_component = bw_int_to_fixed(
-                       82176);
-               dceip->cursor_chunk_width = bw_int_to_fixed(64);
-               dceip->cursor_dcp_buffer_lines = bw_int_to_fixed(4);
-               dceip->underlay_maximum_width_efficient_for_tiling =
-                       bw_int_to_fixed(1920);
-               dceip->underlay_maximum_height_efficient_for_tiling =
-                       bw_int_to_fixed(1080);
-               dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display =
-                       bw_frc_to_fixed(3, 10);
-               dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation =
-                       bw_int_to_fixed(25);
-               dceip->minimum_outstanding_pte_request_limit = bw_int_to_fixed(
-                       2);
-               dceip->maximum_total_outstanding_pte_requests_allowed_by_saw =
-                       bw_int_to_fixed(128);
-               dceip->limit_excessive_outstanding_dmif_requests = true;
-               dceip->linear_mode_line_request_alternation_slice =
-                       bw_int_to_fixed(64);
-               dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode =
-                       32;
-               dceip->display_write_back420_luma_mcifwr_buffer_size = 12288;
-               dceip->display_write_back420_chroma_mcifwr_buffer_size = 8192;
-               dceip->request_efficiency = bw_frc_to_fixed(8, 10);
-               dceip->dispclk_per_request = bw_int_to_fixed(2);
-               dceip->dispclk_ramping_factor = bw_frc_to_fixed(105, 100);
-               dceip->display_pipe_throughput_factor = bw_frc_to_fixed(105, 100);
-               dceip->scatter_gather_pte_request_rows_in_tiling_mode = 2;
-               dceip->mcifwr_all_surfaces_burst_time = bw_int_to_fixed(0);
-               break;
-       case BW_CALCS_VERSION_POLARIS12:
-               vbios->memory_type = bw_def_gddr5;
-               vbios->dram_channel_width_in_bits = 32;
-               vbios->number_of_dram_channels = asic_id.vram_width / vbios->dram_channel_width_in_bits;
-               vbios->number_of_dram_banks = 8;
-               vbios->high_yclk = bw_int_to_fixed(6000);
-               vbios->mid_yclk = bw_int_to_fixed(3200);
-               vbios->low_yclk = bw_int_to_fixed(1000);
-               vbios->low_sclk = bw_int_to_fixed(678);
-               vbios->mid1_sclk = bw_int_to_fixed(864);
-               vbios->mid2_sclk = bw_int_to_fixed(900);
-               vbios->mid3_sclk = bw_int_to_fixed(920);
-               vbios->mid4_sclk = bw_int_to_fixed(940);
-               vbios->mid5_sclk = bw_int_to_fixed(960);
-               vbios->mid6_sclk = bw_int_to_fixed(980);
-               vbios->high_sclk = bw_int_to_fixed(1049);
-               vbios->low_voltage_max_dispclk = bw_int_to_fixed(459);
-               vbios->mid_voltage_max_dispclk = bw_int_to_fixed(654);
-               vbios->high_voltage_max_dispclk = bw_int_to_fixed(1108);
-               vbios->low_voltage_max_phyclk = bw_int_to_fixed(540);
-               vbios->mid_voltage_max_phyclk = bw_int_to_fixed(810);
-               vbios->high_voltage_max_phyclk = bw_int_to_fixed(810);
-               vbios->data_return_bus_width = bw_int_to_fixed(32);
-               vbios->trc = bw_int_to_fixed(48);
-               if (vbios->number_of_dram_channels == 2) // 64-bit
-                       vbios->dmifmc_urgent_latency = bw_int_to_fixed(4);
-               else
-                       vbios->dmifmc_urgent_latency = bw_int_to_fixed(3);
-               vbios->stutter_self_refresh_exit_latency = bw_int_to_fixed(5);
-               vbios->stutter_self_refresh_entry_latency = bw_int_to_fixed(0);
-               vbios->nbp_state_change_latency = bw_int_to_fixed(250);
-               vbios->mcifwrmc_urgent_latency = bw_int_to_fixed(10);
-               vbios->scatter_gather_enable = false;
-               vbios->down_spread_percentage = bw_frc_to_fixed(5, 10);
-               vbios->cursor_width = 32;
-               vbios->average_compression_rate = 4;
-               vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel = 256;
-               vbios->blackout_duration = bw_int_to_fixed(0); /* us */
-               vbios->maximum_blackout_recovery_time = bw_int_to_fixed(0);
-
-               dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation = 100;
-               dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation = 100;
-               dceip->percent_of_ideal_port_bw_received_after_urgent_latency = 100;
-               dceip->large_cursor = false;
-               dceip->dmif_request_buffer_size = bw_int_to_fixed(768);
-               dceip->dmif_pipe_en_fbc_chunk_tracker = false;
-               dceip->cursor_max_outstanding_group_num = 1;
-               dceip->lines_interleaved_into_lb = 2;
-               dceip->chunk_width = 256;
-               dceip->number_of_graphics_pipes = 5;
-               dceip->number_of_underlay_pipes = 0;
-               dceip->low_power_tiling_mode = 0;
-               dceip->display_write_back_supported = true;
-               dceip->argb_compression_support = true;
-               dceip->underlay_vscaler_efficiency6_bit_per_component =
-                       bw_frc_to_fixed(35556, 10000);
-               dceip->underlay_vscaler_efficiency8_bit_per_component =
-                       bw_frc_to_fixed(34286, 10000);
-               dceip->underlay_vscaler_efficiency10_bit_per_component =
-                       bw_frc_to_fixed(32, 10);
-               dceip->underlay_vscaler_efficiency12_bit_per_component =
-                       bw_int_to_fixed(3);
-               dceip->graphics_vscaler_efficiency6_bit_per_component =
-                       bw_frc_to_fixed(35, 10);
-               dceip->graphics_vscaler_efficiency8_bit_per_component =
-                       bw_frc_to_fixed(34286, 10000);
-               dceip->graphics_vscaler_efficiency10_bit_per_component =
-                       bw_frc_to_fixed(32, 10);
-               dceip->graphics_vscaler_efficiency12_bit_per_component =
-                       bw_int_to_fixed(3);
-               dceip->alpha_vscaler_efficiency = bw_int_to_fixed(3);
-               dceip->max_dmif_buffer_allocated = 4;
-               dceip->graphics_dmif_size = 12288;
-               dceip->underlay_luma_dmif_size = 19456;
-               dceip->underlay_chroma_dmif_size = 23552;
-               dceip->pre_downscaler_enabled = true;
-               dceip->underlay_downscale_prefetch_enabled = true;
-               dceip->lb_write_pixels_per_dispclk = bw_int_to_fixed(1);
-               dceip->lb_size_per_component444 = bw_int_to_fixed(245952);
-               dceip->graphics_lb_nodownscaling_multi_line_prefetching = true;
-               dceip->stutter_and_dram_clock_state_change_gated_before_cursor =
-                       bw_int_to_fixed(1);
-               dceip->underlay420_luma_lb_size_per_component = bw_int_to_fixed(
-                       82176);
-               dceip->underlay420_chroma_lb_size_per_component =
-                       bw_int_to_fixed(164352);
-               dceip->underlay422_lb_size_per_component = bw_int_to_fixed(
-                       82176);
-               dceip->cursor_chunk_width = bw_int_to_fixed(64);
-               dceip->cursor_dcp_buffer_lines = bw_int_to_fixed(4);
-               dceip->underlay_maximum_width_efficient_for_tiling =
-                       bw_int_to_fixed(1920);
-               dceip->underlay_maximum_height_efficient_for_tiling =
-                       bw_int_to_fixed(1080);
-               dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display =
-                       bw_frc_to_fixed(3, 10);
-               dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation =
-                       bw_int_to_fixed(25);
-               dceip->minimum_outstanding_pte_request_limit = bw_int_to_fixed(
-                       2);
-               dceip->maximum_total_outstanding_pte_requests_allowed_by_saw =
-                       bw_int_to_fixed(128);
-               dceip->limit_excessive_outstanding_dmif_requests = true;
-               dceip->linear_mode_line_request_alternation_slice =
-                       bw_int_to_fixed(64);
-               dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode =
-                       32;
-               dceip->display_write_back420_luma_mcifwr_buffer_size = 12288;
-               dceip->display_write_back420_chroma_mcifwr_buffer_size = 8192;
-               dceip->request_efficiency = bw_frc_to_fixed(8, 10);
-               dceip->dispclk_per_request = bw_int_to_fixed(2);
-               dceip->dispclk_ramping_factor = bw_frc_to_fixed(105, 100);
-               dceip->display_pipe_throughput_factor = bw_frc_to_fixed(105, 100);
-               dceip->scatter_gather_pte_request_rows_in_tiling_mode = 2;
-               dceip->mcifwr_all_surfaces_burst_time = bw_int_to_fixed(0);
-               break;
-       case BW_CALCS_VERSION_STONEY:
-               vbios->memory_type = bw_def_gddr5;
-               vbios->dram_channel_width_in_bits = 64;
-               vbios->number_of_dram_channels = asic_id.vram_width / vbios->dram_channel_width_in_bits;
-               vbios->number_of_dram_banks = 8;
-               vbios->high_yclk = bw_int_to_fixed(1866);
-               vbios->mid_yclk = bw_int_to_fixed(1866);
-               vbios->low_yclk = bw_int_to_fixed(1333);
-               vbios->low_sclk = bw_int_to_fixed(200);
-               vbios->mid1_sclk = bw_int_to_fixed(600);
-               vbios->mid2_sclk = bw_int_to_fixed(600);
-               vbios->mid3_sclk = bw_int_to_fixed(600);
-               vbios->mid4_sclk = bw_int_to_fixed(600);
-               vbios->mid5_sclk = bw_int_to_fixed(600);
-               vbios->mid6_sclk = bw_int_to_fixed(600);
-               vbios->high_sclk = bw_int_to_fixed(800);
-               vbios->low_voltage_max_dispclk = bw_int_to_fixed(352);
-               vbios->mid_voltage_max_dispclk = bw_int_to_fixed(467);
-               vbios->high_voltage_max_dispclk = bw_int_to_fixed(643);
-               vbios->low_voltage_max_phyclk = bw_int_to_fixed(540);
-               vbios->mid_voltage_max_phyclk = bw_int_to_fixed(810);
-               vbios->high_voltage_max_phyclk = bw_int_to_fixed(810);
-               vbios->data_return_bus_width = bw_int_to_fixed(32);
-               vbios->trc = bw_int_to_fixed(50);
-               vbios->dmifmc_urgent_latency = bw_int_to_fixed(4);
-               vbios->stutter_self_refresh_exit_latency = bw_frc_to_fixed(158, 10);
-               vbios->stutter_self_refresh_entry_latency = bw_int_to_fixed(0);
-               vbios->nbp_state_change_latency = bw_frc_to_fixed(2008, 100);
-               vbios->mcifwrmc_urgent_latency = bw_int_to_fixed(10);
-               vbios->scatter_gather_enable = true;
-               vbios->down_spread_percentage = bw_frc_to_fixed(5, 10);
-               vbios->cursor_width = 32;
-               vbios->average_compression_rate = 4;
-               vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel = 256;
-               vbios->blackout_duration = bw_int_to_fixed(0); /* us */
-               vbios->maximum_blackout_recovery_time = bw_int_to_fixed(0);
-
-               dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation = 100;
-               dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation = 100;
-               dceip->percent_of_ideal_port_bw_received_after_urgent_latency = 100;
-               dceip->large_cursor = false;
-               dceip->dmif_request_buffer_size = bw_int_to_fixed(768);
-               dceip->dmif_pipe_en_fbc_chunk_tracker = false;
-               dceip->cursor_max_outstanding_group_num = 1;
-               dceip->lines_interleaved_into_lb = 2;
-               dceip->chunk_width = 256;
-               dceip->number_of_graphics_pipes = 2;
-               dceip->number_of_underlay_pipes = 1;
-               dceip->low_power_tiling_mode = 0;
-               dceip->display_write_back_supported = false;
-               dceip->argb_compression_support = true;
-               dceip->underlay_vscaler_efficiency6_bit_per_component =
-                       bw_frc_to_fixed(35556, 10000);
-               dceip->underlay_vscaler_efficiency8_bit_per_component =
-                       bw_frc_to_fixed(34286, 10000);
-               dceip->underlay_vscaler_efficiency10_bit_per_component =
-                       bw_frc_to_fixed(32, 10);
-               dceip->underlay_vscaler_efficiency12_bit_per_component =
-                       bw_int_to_fixed(3);
-               dceip->graphics_vscaler_efficiency6_bit_per_component =
-                       bw_frc_to_fixed(35, 10);
-               dceip->graphics_vscaler_efficiency8_bit_per_component =
-                       bw_frc_to_fixed(34286, 10000);
-               dceip->graphics_vscaler_efficiency10_bit_per_component =
-                       bw_frc_to_fixed(32, 10);
-               dceip->graphics_vscaler_efficiency12_bit_per_component =
-                       bw_int_to_fixed(3);
-               dceip->alpha_vscaler_efficiency = bw_int_to_fixed(3);
-               dceip->max_dmif_buffer_allocated = 2;
-               dceip->graphics_dmif_size = 12288;
-               dceip->underlay_luma_dmif_size = 19456;
-               dceip->underlay_chroma_dmif_size = 23552;
-               dceip->pre_downscaler_enabled = true;
-               dceip->underlay_downscale_prefetch_enabled = true;
-               dceip->lb_write_pixels_per_dispclk = bw_int_to_fixed(1);
-               dceip->lb_size_per_component444 = bw_int_to_fixed(82176);
-               dceip->graphics_lb_nodownscaling_multi_line_prefetching = false;
-               dceip->stutter_and_dram_clock_state_change_gated_before_cursor =
-                       bw_int_to_fixed(0);
-               dceip->underlay420_luma_lb_size_per_component = bw_int_to_fixed(
-                       82176);
-               dceip->underlay420_chroma_lb_size_per_component =
-                       bw_int_to_fixed(164352);
-               dceip->underlay422_lb_size_per_component = bw_int_to_fixed(
-                       82176);
-               dceip->cursor_chunk_width = bw_int_to_fixed(64);
-               dceip->cursor_dcp_buffer_lines = bw_int_to_fixed(4);
-               dceip->underlay_maximum_width_efficient_for_tiling =
-                       bw_int_to_fixed(1920);
-               dceip->underlay_maximum_height_efficient_for_tiling =
-                       bw_int_to_fixed(1080);
-               dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display =
-                       bw_frc_to_fixed(3, 10);
-               dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation =
-                       bw_int_to_fixed(25);
-               dceip->minimum_outstanding_pte_request_limit = bw_int_to_fixed(
-                       2);
-               dceip->maximum_total_outstanding_pte_requests_allowed_by_saw =
-                       bw_int_to_fixed(128);
-               dceip->limit_excessive_outstanding_dmif_requests = true;
-               dceip->linear_mode_line_request_alternation_slice =
-                       bw_int_to_fixed(64);
-               dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode =
-                       32;
-               dceip->display_write_back420_luma_mcifwr_buffer_size = 12288;
-               dceip->display_write_back420_chroma_mcifwr_buffer_size = 8192;
-               dceip->request_efficiency = bw_frc_to_fixed(8, 10);
-               dceip->dispclk_per_request = bw_int_to_fixed(2);
-               dceip->dispclk_ramping_factor = bw_frc_to_fixed(105, 100);
-               dceip->display_pipe_throughput_factor = bw_frc_to_fixed(105, 100);
-               dceip->scatter_gather_pte_request_rows_in_tiling_mode = 2;
-               dceip->mcifwr_all_surfaces_burst_time = bw_int_to_fixed(0);
-               break;
-       case BW_CALCS_VERSION_VEGA10:
-               vbios->memory_type = bw_def_hbm;
-               vbios->dram_channel_width_in_bits = 128;
-               vbios->number_of_dram_channels = asic_id.vram_width / vbios->dram_channel_width_in_bits;
-               vbios->number_of_dram_banks = 16;
-               vbios->high_yclk = bw_int_to_fixed(2400);
-               vbios->mid_yclk = bw_int_to_fixed(1700);
-               vbios->low_yclk = bw_int_to_fixed(1000);
-               vbios->low_sclk = bw_int_to_fixed(300);
-               vbios->mid1_sclk = bw_int_to_fixed(350);
-               vbios->mid2_sclk = bw_int_to_fixed(400);
-               vbios->mid3_sclk = bw_int_to_fixed(500);
-               vbios->mid4_sclk = bw_int_to_fixed(600);
-               vbios->mid5_sclk = bw_int_to_fixed(700);
-               vbios->mid6_sclk = bw_int_to_fixed(760);
-               vbios->high_sclk = bw_int_to_fixed(776);
-               vbios->low_voltage_max_dispclk = bw_int_to_fixed(460);
-               vbios->mid_voltage_max_dispclk = bw_int_to_fixed(670);
-               vbios->high_voltage_max_dispclk = bw_int_to_fixed(1133);
-               vbios->low_voltage_max_phyclk = bw_int_to_fixed(540);
-               vbios->mid_voltage_max_phyclk = bw_int_to_fixed(810);
-               vbios->high_voltage_max_phyclk = bw_int_to_fixed(810);
-               vbios->data_return_bus_width = bw_int_to_fixed(32);
-               vbios->trc = bw_int_to_fixed(48);
-               vbios->dmifmc_urgent_latency = bw_int_to_fixed(3);
-               vbios->stutter_self_refresh_exit_latency = bw_frc_to_fixed(75, 10);
-               vbios->stutter_self_refresh_entry_latency = bw_frc_to_fixed(19, 10);
-               vbios->nbp_state_change_latency = bw_int_to_fixed(39);
-               vbios->mcifwrmc_urgent_latency = bw_int_to_fixed(10);
-               vbios->scatter_gather_enable = false;
-               vbios->down_spread_percentage = bw_frc_to_fixed(5, 10);
-               vbios->cursor_width = 32;
-               vbios->average_compression_rate = 4;
-               vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel = 8;
-               vbios->blackout_duration = bw_int_to_fixed(0); /* us */
-               vbios->maximum_blackout_recovery_time = bw_int_to_fixed(0);
-
-               dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation = 100;
-               dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation = 100;
-               dceip->percent_of_ideal_port_bw_received_after_urgent_latency = 100;
-               dceip->large_cursor = false;
-               dceip->dmif_request_buffer_size = bw_int_to_fixed(2304);
-               dceip->dmif_pipe_en_fbc_chunk_tracker = true;
-               dceip->cursor_max_outstanding_group_num = 1;
-               dceip->lines_interleaved_into_lb = 2;
-               dceip->chunk_width = 256;
-               dceip->number_of_graphics_pipes = 6;
-               dceip->number_of_underlay_pipes = 0;
-               dceip->low_power_tiling_mode = 0;
-               dceip->display_write_back_supported = true;
-               dceip->argb_compression_support = true;
-               dceip->underlay_vscaler_efficiency6_bit_per_component =
-                       bw_frc_to_fixed(35556, 10000);
-               dceip->underlay_vscaler_efficiency8_bit_per_component =
-                       bw_frc_to_fixed(34286, 10000);
-               dceip->underlay_vscaler_efficiency10_bit_per_component =
-                       bw_frc_to_fixed(32, 10);
-               dceip->underlay_vscaler_efficiency12_bit_per_component =
-                       bw_int_to_fixed(3);
-               dceip->graphics_vscaler_efficiency6_bit_per_component =
-                       bw_frc_to_fixed(35, 10);
-               dceip->graphics_vscaler_efficiency8_bit_per_component =
-                       bw_frc_to_fixed(34286, 10000);
-               dceip->graphics_vscaler_efficiency10_bit_per_component =
-                       bw_frc_to_fixed(32, 10);
-               dceip->graphics_vscaler_efficiency12_bit_per_component =
-                       bw_int_to_fixed(3);
-               dceip->alpha_vscaler_efficiency = bw_int_to_fixed(3);
-               dceip->max_dmif_buffer_allocated = 4;
-               dceip->graphics_dmif_size = 24576;
-               dceip->underlay_luma_dmif_size = 19456;
-               dceip->underlay_chroma_dmif_size = 23552;
-               dceip->pre_downscaler_enabled = true;
-               dceip->underlay_downscale_prefetch_enabled = false;
-               dceip->lb_write_pixels_per_dispclk = bw_int_to_fixed(1);
-               dceip->lb_size_per_component444 = bw_int_to_fixed(245952);
-               dceip->graphics_lb_nodownscaling_multi_line_prefetching = true;
-               dceip->stutter_and_dram_clock_state_change_gated_before_cursor =
-                       bw_int_to_fixed(1);
-               dceip->underlay420_luma_lb_size_per_component = bw_int_to_fixed(
-                       82176);
-               dceip->underlay420_chroma_lb_size_per_component =
-                       bw_int_to_fixed(164352);
-               dceip->underlay422_lb_size_per_component = bw_int_to_fixed(
-                       82176);
-               dceip->cursor_chunk_width = bw_int_to_fixed(64);
-               dceip->cursor_dcp_buffer_lines = bw_int_to_fixed(4);
-               dceip->underlay_maximum_width_efficient_for_tiling =
-                       bw_int_to_fixed(1920);
-               dceip->underlay_maximum_height_efficient_for_tiling =
-                       bw_int_to_fixed(1080);
-               dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display =
-                       bw_frc_to_fixed(3, 10);
-               dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation =
-                       bw_int_to_fixed(25);
-               dceip->minimum_outstanding_pte_request_limit = bw_int_to_fixed(
-                       2);
-               dceip->maximum_total_outstanding_pte_requests_allowed_by_saw =
-                       bw_int_to_fixed(128);
-               dceip->limit_excessive_outstanding_dmif_requests = true;
-               dceip->linear_mode_line_request_alternation_slice =
-                       bw_int_to_fixed(64);
-               dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode =
-                       32;
-               dceip->display_write_back420_luma_mcifwr_buffer_size = 12288;
-               dceip->display_write_back420_chroma_mcifwr_buffer_size = 8192;
-               dceip->request_efficiency = bw_frc_to_fixed(8, 10);
-               dceip->dispclk_per_request = bw_int_to_fixed(2);
-               dceip->dispclk_ramping_factor = bw_frc_to_fixed(105, 100);
-               dceip->display_pipe_throughput_factor = bw_frc_to_fixed(105, 100);
-               dceip->scatter_gather_pte_request_rows_in_tiling_mode = 2;
-               dceip->mcifwr_all_surfaces_burst_time = bw_int_to_fixed(0);
-               break;
-       default:
-               break;
-       }
-       *bw_dceip = *dceip;
-       *bw_vbios = *vbios;
-
-       kfree(dceip);
-       kfree(vbios);
-}
-
-/*
- * Compare calculated (required) clocks against the clocks available at
- * maximum voltage (max Performance Level).
- */
-static bool is_display_configuration_supported(
-       const struct bw_calcs_vbios *vbios,
-       const struct dce_bw_output *calcs_output)
-{
-       uint32_t int_max_clk;
-
-       int_max_clk = bw_fixed_to_int(vbios->high_voltage_max_dispclk);
-       int_max_clk *= 1000; /* MHz to kHz */
-       if (calcs_output->dispclk_khz > int_max_clk)
-               return false;
-
-       int_max_clk = bw_fixed_to_int(vbios->high_sclk);
-       int_max_clk *= 1000; /* MHz to kHz */
-       if (calcs_output->sclk_khz > int_max_clk)
-               return false;
-
-       return true;
-}
-
-static void populate_initial_data(
-       const struct pipe_ctx pipe[], int pipe_count, struct bw_calcs_data *data)
-{
-       int i, j;
-       int num_displays = 0;
-
-       data->underlay_surface_type = bw_def_420;
-       data->panning_and_bezel_adjustment = bw_def_none;
-       data->graphics_lb_bpc = 10;
-       data->underlay_lb_bpc = 8;
-       data->underlay_tiling_mode = bw_def_tiled;
-       data->graphics_tiling_mode = bw_def_tiled;
-       data->underlay_micro_tile_mode = bw_def_display_micro_tiling;
-       data->graphics_micro_tile_mode = bw_def_display_micro_tiling;
-       data->increase_voltage_to_support_mclk_switch = true;
-
-       /* Pipes with underlay first */
-       for (i = 0; i < pipe_count; i++) {
-               if (!pipe[i].stream || !pipe[i].bottom_pipe)
-                       continue;
-
-               ASSERT(pipe[i].plane_state);
-
-               if (num_displays == 0) {
-                       if (!pipe[i].plane_state->visible)
-                               data->d0_underlay_mode = bw_def_underlay_only;
-                       else
-                               data->d0_underlay_mode = bw_def_blend;
-               } else {
-                       if (!pipe[i].plane_state->visible)
-                               data->d1_underlay_mode = bw_def_underlay_only;
-                       else
-                               data->d1_underlay_mode = bw_def_blend;
-               }
-
-               data->fbc_en[num_displays + 4] = false;
-               data->lpt_en[num_displays + 4] = false;
-               data->h_total[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.h_total);
-               data->v_total[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.v_total);
-               data->pixel_rate[num_displays + 4] = bw_frc_to_fixed(pipe[i].stream->timing.pix_clk_100hz, 10000);
-               data->src_width[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.viewport.width);
-               data->pitch_in_pixels[num_displays + 4] = data->src_width[num_displays + 4];
-               data->src_height[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.viewport.height);
-               data->h_taps[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.taps.h_taps);
-               data->v_taps[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.taps.v_taps);
-               data->h_scale_ratio[num_displays + 4] = fixed31_32_to_bw_fixed(pipe[i].plane_res.scl_data.ratios.horz.value);
-               data->v_scale_ratio[num_displays + 4] = fixed31_32_to_bw_fixed(pipe[i].plane_res.scl_data.ratios.vert.value);
-               switch (pipe[i].plane_state->rotation) {
-               case ROTATION_ANGLE_0:
-                       data->rotation_angle[num_displays + 4] = bw_int_to_fixed(0);
-                       break;
-               case ROTATION_ANGLE_90:
-                       data->rotation_angle[num_displays + 4] = bw_int_to_fixed(90);
-                       break;
-               case ROTATION_ANGLE_180:
-                       data->rotation_angle[num_displays + 4] = bw_int_to_fixed(180);
-                       break;
-               case ROTATION_ANGLE_270:
-                       data->rotation_angle[num_displays + 4] = bw_int_to_fixed(270);
-                       break;
-               default:
-                       break;
-               }
-               switch (pipe[i].plane_state->format) {
-               case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
-               case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555:
-               case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
-                       data->bytes_per_pixel[num_displays + 4] = 2;
-                       break;
-               case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
-               case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
-               case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
-               case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
-               case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
-               case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
-               case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
-                       data->bytes_per_pixel[num_displays + 4] = 4;
-                       break;
-               case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
-               case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616:
-               case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
-                       data->bytes_per_pixel[num_displays + 4] = 8;
-                       break;
-               default:
-                       data->bytes_per_pixel[num_displays + 4] = 4;
-                       break;
-               }
-               data->interlace_mode[num_displays + 4] = false;
-               data->stereo_mode[num_displays + 4] = bw_def_mono;
-
-
-               for (j = 0; j < 2; j++) {
-                       data->fbc_en[num_displays * 2 + j] = false;
-                       data->lpt_en[num_displays * 2 + j] = false;
-
-                       data->src_height[num_displays * 2 + j] = bw_int_to_fixed(pipe[i].bottom_pipe->plane_res.scl_data.viewport.height);
-                       data->src_width[num_displays * 2 + j] = bw_int_to_fixed(pipe[i].bottom_pipe->plane_res.scl_data.viewport.width);
-                       data->pitch_in_pixels[num_displays * 2 + j] = bw_int_to_fixed(
-                                       pipe[i].bottom_pipe->plane_state->plane_size.surface_pitch);
-                       data->h_taps[num_displays * 2 + j] = bw_int_to_fixed(pipe[i].bottom_pipe->plane_res.scl_data.taps.h_taps);
-                       data->v_taps[num_displays * 2 + j] = bw_int_to_fixed(pipe[i].bottom_pipe->plane_res.scl_data.taps.v_taps);
-                       data->h_scale_ratio[num_displays * 2 + j] = fixed31_32_to_bw_fixed(
-                                       pipe[i].bottom_pipe->plane_res.scl_data.ratios.horz.value);
-                       data->v_scale_ratio[num_displays * 2 + j] = fixed31_32_to_bw_fixed(
-                                       pipe[i].bottom_pipe->plane_res.scl_data.ratios.vert.value);
-                       switch (pipe[i].bottom_pipe->plane_state->rotation) {
-                       case ROTATION_ANGLE_0:
-                               data->rotation_angle[num_displays * 2 + j] = bw_int_to_fixed(0);
-                               break;
-                       case ROTATION_ANGLE_90:
-                               data->rotation_angle[num_displays * 2 + j] = bw_int_to_fixed(90);
-                               break;
-                       case ROTATION_ANGLE_180:
-                               data->rotation_angle[num_displays * 2 + j] = bw_int_to_fixed(180);
-                               break;
-                       case ROTATION_ANGLE_270:
-                               data->rotation_angle[num_displays * 2 + j] = bw_int_to_fixed(270);
-                               break;
-                       default:
-                               break;
-                       }
-                       data->stereo_mode[num_displays * 2 + j] = bw_def_mono;
-               }
-
-               num_displays++;
-       }
-
-       /* Pipes without underlay after */
-       for (i = 0; i < pipe_count; i++) {
-               unsigned int pixel_clock_100hz;
-               if (!pipe[i].stream || pipe[i].bottom_pipe)
-                       continue;
-
-
-               data->fbc_en[num_displays + 4] = false;
-               data->lpt_en[num_displays + 4] = false;
-               data->h_total[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.h_total);
-               data->v_total[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.v_total);
-               pixel_clock_100hz = pipe[i].stream->timing.pix_clk_100hz;
-               if (pipe[i].stream->timing.timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING)
-                       pixel_clock_100hz *= 2;
-               data->pixel_rate[num_displays + 4] = bw_frc_to_fixed(pixel_clock_100hz, 10000);
-               if (pipe[i].plane_state) {
-                       data->src_width[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.viewport.width);
-                       data->pitch_in_pixels[num_displays + 4] = data->src_width[num_displays + 4];
-                       data->src_height[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.viewport.height);
-                       data->h_taps[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.taps.h_taps);
-                       data->v_taps[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.taps.v_taps);
-                       data->h_scale_ratio[num_displays + 4] = fixed31_32_to_bw_fixed(pipe[i].plane_res.scl_data.ratios.horz.value);
-                       data->v_scale_ratio[num_displays + 4] = fixed31_32_to_bw_fixed(pipe[i].plane_res.scl_data.ratios.vert.value);
-                       switch (pipe[i].plane_state->rotation) {
-                       case ROTATION_ANGLE_0:
-                               data->rotation_angle[num_displays + 4] = bw_int_to_fixed(0);
-                               break;
-                       case ROTATION_ANGLE_90:
-                               data->rotation_angle[num_displays + 4] = bw_int_to_fixed(90);
-                               break;
-                       case ROTATION_ANGLE_180:
-                               data->rotation_angle[num_displays + 4] = bw_int_to_fixed(180);
-                               break;
-                       case ROTATION_ANGLE_270:
-                               data->rotation_angle[num_displays + 4] = bw_int_to_fixed(270);
-                               break;
-                       default:
-                               break;
-                       }
-                       switch (pipe[i].plane_state->format) {
-                       case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
-                       case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb:
-                       case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555:
-                       case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
-                               data->bytes_per_pixel[num_displays + 4] = 2;
-                               break;
-                       case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
-                       case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
-                       case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
-                       case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
-                       case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
-                       case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
-                       case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
-                               data->bytes_per_pixel[num_displays + 4] = 4;
-                               break;
-                       case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
-                       case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616:
-                       case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
-                               data->bytes_per_pixel[num_displays + 4] = 8;
-                               break;
-                       default:
-                               data->bytes_per_pixel[num_displays + 4] = 4;
-                               break;
-                       }
-               } else if (pipe[i].stream->dst.width != 0 &&
-                                       pipe[i].stream->dst.height != 0 &&
-                                       pipe[i].stream->src.width != 0 &&
-                                       pipe[i].stream->src.height != 0) {
-                       data->src_width[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->src.width);
-                       data->pitch_in_pixels[num_displays + 4] = data->src_width[num_displays + 4];
-                       data->src_height[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->src.height);
-                       data->h_taps[num_displays + 4] = pipe[i].stream->src.width == pipe[i].stream->dst.width ? bw_int_to_fixed(1) : bw_int_to_fixed(2);
-                       data->v_taps[num_displays + 4] = pipe[i].stream->src.height == pipe[i].stream->dst.height ? bw_int_to_fixed(1) : bw_int_to_fixed(2);
-                       data->h_scale_ratio[num_displays + 4] = bw_frc_to_fixed(pipe[i].stream->src.width, pipe[i].stream->dst.width);
-                       data->v_scale_ratio[num_displays + 4] = bw_frc_to_fixed(pipe[i].stream->src.height, pipe[i].stream->dst.height);
-                       data->rotation_angle[num_displays + 4] = bw_int_to_fixed(0);
-                       data->bytes_per_pixel[num_displays + 4] = 4;
-               } else {
-                       data->src_width[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.h_addressable);
-                       data->pitch_in_pixels[num_displays + 4] = data->src_width[num_displays + 4];
-                       data->src_height[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.v_addressable);
-                       data->h_taps[num_displays + 4] = bw_int_to_fixed(1);
-                       data->v_taps[num_displays + 4] = bw_int_to_fixed(1);
-                       data->h_scale_ratio[num_displays + 4] = bw_int_to_fixed(1);
-                       data->v_scale_ratio[num_displays + 4] = bw_int_to_fixed(1);
-                       data->rotation_angle[num_displays + 4] = bw_int_to_fixed(0);
-                       data->bytes_per_pixel[num_displays + 4] = 4;
-               }
-
-               data->interlace_mode[num_displays + 4] = false;
-               data->stereo_mode[num_displays + 4] = bw_def_mono;
-               num_displays++;
-       }
-
-       data->number_of_displays = num_displays;
-}
-
-static bool all_displays_in_sync(const struct pipe_ctx pipe[],
-                                int pipe_count)
-{
-       const struct pipe_ctx *active_pipes[MAX_PIPES];
-       int i, num_active_pipes = 0;
-
-       for (i = 0; i < pipe_count; i++) {
-               if (!pipe[i].stream || pipe[i].top_pipe)
-                       continue;
-
-               active_pipes[num_active_pipes++] = &pipe[i];
-       }
-
-       if (!num_active_pipes)
-               return false;
-
-       for (i = 1; i < num_active_pipes; ++i) {
-               if (!resource_are_streams_timing_synchronizable(
-                           active_pipes[0]->stream, active_pipes[i]->stream)) {
-                       return false;
-               }
-       }
-
-       return true;
-}
-
-/*
- * Return:
- *     true -  Display(s) configuration supported.
- *             In this case 'calcs_output' contains data for HW programming
- *     false - Display(s) configuration not supported (not enough bandwidth).
- */
-bool bw_calcs(struct dc_context *ctx,
-       const struct bw_calcs_dceip *dceip,
-       const struct bw_calcs_vbios *vbios,
-       const struct pipe_ctx pipe[],
-       int pipe_count,
-       struct dce_bw_output *calcs_output)
-{
-       struct bw_calcs_data *data = kzalloc(sizeof(struct bw_calcs_data),
-                                            GFP_KERNEL);
-       if (!data)
-               return false;
-
-       populate_initial_data(pipe, pipe_count, data);
-
-       if (ctx->dc->config.multi_mon_pp_mclk_switch)
-               calcs_output->all_displays_in_sync = all_displays_in_sync(pipe, pipe_count);
-       else
-               calcs_output->all_displays_in_sync = false;
-
-       if (data->number_of_displays != 0) {
-               uint8_t yclk_lvl;
-               struct bw_fixed high_sclk = vbios->high_sclk;
-               struct bw_fixed mid1_sclk = vbios->mid1_sclk;
-               struct bw_fixed mid2_sclk = vbios->mid2_sclk;
-               struct bw_fixed mid3_sclk = vbios->mid3_sclk;
-               struct bw_fixed mid4_sclk = vbios->mid4_sclk;
-               struct bw_fixed mid5_sclk = vbios->mid5_sclk;
-               struct bw_fixed mid6_sclk = vbios->mid6_sclk;
-               struct bw_fixed low_sclk = vbios->low_sclk;
-               struct bw_fixed high_yclk = vbios->high_yclk;
-               struct bw_fixed mid_yclk = vbios->mid_yclk;
-               struct bw_fixed low_yclk = vbios->low_yclk;
-
-               if (ctx->dc->debug.bandwidth_calcs_trace) {
-                       print_bw_calcs_dceip(ctx, dceip);
-                       print_bw_calcs_vbios(ctx, vbios);
-                       print_bw_calcs_data(ctx, data);
-               }
-               calculate_bandwidth(dceip, vbios, data);
-
-               yclk_lvl = data->y_clk_level;
-
-               calcs_output->nbp_state_change_enable =
-                       data->nbp_state_change_enable;
-               calcs_output->cpuc_state_change_enable =
-                               data->cpuc_state_change_enable;
-               calcs_output->cpup_state_change_enable =
-                               data->cpup_state_change_enable;
-               calcs_output->stutter_mode_enable =
-                               data->stutter_mode_enable;
-               calcs_output->dispclk_khz =
-                       bw_fixed_to_int(bw_mul(data->dispclk,
-                                       bw_int_to_fixed(1000)));
-               calcs_output->blackout_recovery_time_us =
-                       bw_fixed_to_int(data->blackout_recovery_time);
-               calcs_output->sclk_khz =
-                       bw_fixed_to_int(bw_mul(data->required_sclk,
-                                       bw_int_to_fixed(1000)));
-               calcs_output->sclk_deep_sleep_khz =
-                       bw_fixed_to_int(bw_mul(data->sclk_deep_sleep,
-                                       bw_int_to_fixed(1000)));
-               if (yclk_lvl == 0)
-                       calcs_output->yclk_khz = bw_fixed_to_int(
-                               bw_mul(low_yclk, bw_int_to_fixed(1000)));
-               else if (yclk_lvl == 1)
-                       calcs_output->yclk_khz = bw_fixed_to_int(
-                               bw_mul(mid_yclk, bw_int_to_fixed(1000)));
-               else
-                       calcs_output->yclk_khz = bw_fixed_to_int(
-                               bw_mul(high_yclk, bw_int_to_fixed(1000)));
-
-               /* units: nanosecond, 16bit storage. */
-
-               calcs_output->nbp_state_change_wm_ns[0].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               nbp_state_change_watermark[4], bw_int_to_fixed(1000)));
-               calcs_output->nbp_state_change_wm_ns[1].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               nbp_state_change_watermark[5], bw_int_to_fixed(1000)));
-               calcs_output->nbp_state_change_wm_ns[2].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               nbp_state_change_watermark[6], bw_int_to_fixed(1000)));
-
-               if (ctx->dc->caps.max_slave_planes) {
-                       calcs_output->nbp_state_change_wm_ns[3].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       nbp_state_change_watermark[0], bw_int_to_fixed(1000)));
-                       calcs_output->nbp_state_change_wm_ns[4].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                                       nbp_state_change_watermark[1], bw_int_to_fixed(1000)));
-               } else {
-                       calcs_output->nbp_state_change_wm_ns[3].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       nbp_state_change_watermark[7], bw_int_to_fixed(1000)));
-                       calcs_output->nbp_state_change_wm_ns[4].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       nbp_state_change_watermark[8], bw_int_to_fixed(1000)));
-               }
-               calcs_output->nbp_state_change_wm_ns[5].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               nbp_state_change_watermark[9], bw_int_to_fixed(1000)));
-
-
-
-               calcs_output->stutter_exit_wm_ns[0].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_exit_watermark[4], bw_int_to_fixed(1000)));
-               calcs_output->stutter_exit_wm_ns[1].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_exit_watermark[5], bw_int_to_fixed(1000)));
-               calcs_output->stutter_exit_wm_ns[2].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_exit_watermark[6], bw_int_to_fixed(1000)));
-               if (ctx->dc->caps.max_slave_planes) {
-                       calcs_output->stutter_exit_wm_ns[3].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[0], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_exit_wm_ns[4].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[1], bw_int_to_fixed(1000)));
-               } else {
-                       calcs_output->stutter_exit_wm_ns[3].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[7], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_exit_wm_ns[4].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[8], bw_int_to_fixed(1000)));
-               }
-               calcs_output->stutter_exit_wm_ns[5].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_exit_watermark[9], bw_int_to_fixed(1000)));
-
-               calcs_output->stutter_entry_wm_ns[0].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_entry_watermark[4], bw_int_to_fixed(1000)));
-               calcs_output->stutter_entry_wm_ns[1].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_entry_watermark[5], bw_int_to_fixed(1000)));
-               calcs_output->stutter_entry_wm_ns[2].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_entry_watermark[6], bw_int_to_fixed(1000)));
-               if (ctx->dc->caps.max_slave_planes) {
-                       calcs_output->stutter_entry_wm_ns[3].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[0], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_entry_wm_ns[4].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[1], bw_int_to_fixed(1000)));
-               } else {
-                       calcs_output->stutter_entry_wm_ns[3].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[7], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_entry_wm_ns[4].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[8], bw_int_to_fixed(1000)));
-               }
-               calcs_output->stutter_entry_wm_ns[5].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_entry_watermark[9], bw_int_to_fixed(1000)));
-
-               calcs_output->urgent_wm_ns[0].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               urgent_watermark[4], bw_int_to_fixed(1000)));
-               calcs_output->urgent_wm_ns[1].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               urgent_watermark[5], bw_int_to_fixed(1000)));
-               calcs_output->urgent_wm_ns[2].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               urgent_watermark[6], bw_int_to_fixed(1000)));
-               if (ctx->dc->caps.max_slave_planes) {
-                       calcs_output->urgent_wm_ns[3].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[0], bw_int_to_fixed(1000)));
-                       calcs_output->urgent_wm_ns[4].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[1], bw_int_to_fixed(1000)));
-               } else {
-                       calcs_output->urgent_wm_ns[3].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[7], bw_int_to_fixed(1000)));
-                       calcs_output->urgent_wm_ns[4].a_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[8], bw_int_to_fixed(1000)));
-               }
-               calcs_output->urgent_wm_ns[5].a_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               urgent_watermark[9], bw_int_to_fixed(1000)));
-
-               if (dceip->version != BW_CALCS_VERSION_CARRIZO) {
-                       ((struct bw_calcs_vbios *)vbios)->low_sclk = mid3_sclk;
-                       ((struct bw_calcs_vbios *)vbios)->mid1_sclk = mid3_sclk;
-                       ((struct bw_calcs_vbios *)vbios)->mid2_sclk = mid3_sclk;
-                       calculate_bandwidth(dceip, vbios, data);
-
-                       calcs_output->nbp_state_change_wm_ns[0].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       nbp_state_change_watermark[4],bw_int_to_fixed(1000)));
-                       calcs_output->nbp_state_change_wm_ns[1].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       nbp_state_change_watermark[5], bw_int_to_fixed(1000)));
-                       calcs_output->nbp_state_change_wm_ns[2].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       nbp_state_change_watermark[6], bw_int_to_fixed(1000)));
-
-                       if (ctx->dc->caps.max_slave_planes) {
-                               calcs_output->nbp_state_change_wm_ns[3].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               nbp_state_change_watermark[0], bw_int_to_fixed(1000)));
-                               calcs_output->nbp_state_change_wm_ns[4].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               nbp_state_change_watermark[1], bw_int_to_fixed(1000)));
-                       } else {
-                               calcs_output->nbp_state_change_wm_ns[3].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               nbp_state_change_watermark[7], bw_int_to_fixed(1000)));
-                               calcs_output->nbp_state_change_wm_ns[4].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               nbp_state_change_watermark[8], bw_int_to_fixed(1000)));
-                       }
-                       calcs_output->nbp_state_change_wm_ns[5].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       nbp_state_change_watermark[9], bw_int_to_fixed(1000)));
-
-
-
-                       calcs_output->stutter_exit_wm_ns[0].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[4], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_exit_wm_ns[1].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[5], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_exit_wm_ns[2].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[6], bw_int_to_fixed(1000)));
-                       if (ctx->dc->caps.max_slave_planes) {
-                               calcs_output->stutter_exit_wm_ns[3].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               stutter_exit_watermark[0], bw_int_to_fixed(1000)));
-                               calcs_output->stutter_exit_wm_ns[4].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               stutter_exit_watermark[1], bw_int_to_fixed(1000)));
-                       } else {
-                               calcs_output->stutter_exit_wm_ns[3].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               stutter_exit_watermark[7], bw_int_to_fixed(1000)));
-                               calcs_output->stutter_exit_wm_ns[4].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               stutter_exit_watermark[8], bw_int_to_fixed(1000)));
-                       }
-                       calcs_output->stutter_exit_wm_ns[5].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[9], bw_int_to_fixed(1000)));
-
-                       calcs_output->stutter_entry_wm_ns[0].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[4], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_entry_wm_ns[1].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[5], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_entry_wm_ns[2].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[6], bw_int_to_fixed(1000)));
-                       if (ctx->dc->caps.max_slave_planes) {
-                               calcs_output->stutter_entry_wm_ns[3].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               stutter_entry_watermark[0], bw_int_to_fixed(1000)));
-                               calcs_output->stutter_entry_wm_ns[4].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               stutter_entry_watermark[1], bw_int_to_fixed(1000)));
-                       } else {
-                               calcs_output->stutter_entry_wm_ns[3].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               stutter_entry_watermark[7], bw_int_to_fixed(1000)));
-                               calcs_output->stutter_entry_wm_ns[4].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               stutter_entry_watermark[8], bw_int_to_fixed(1000)));
-                       }
-                       calcs_output->stutter_entry_wm_ns[5].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[9], bw_int_to_fixed(1000)));
-
-                       calcs_output->urgent_wm_ns[0].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[4], bw_int_to_fixed(1000)));
-                       calcs_output->urgent_wm_ns[1].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[5], bw_int_to_fixed(1000)));
-                       calcs_output->urgent_wm_ns[2].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[6], bw_int_to_fixed(1000)));
-                       if (ctx->dc->caps.max_slave_planes) {
-                               calcs_output->urgent_wm_ns[3].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               urgent_watermark[0], bw_int_to_fixed(1000)));
-                               calcs_output->urgent_wm_ns[4].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               urgent_watermark[1], bw_int_to_fixed(1000)));
-                       } else {
-                               calcs_output->urgent_wm_ns[3].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               urgent_watermark[7], bw_int_to_fixed(1000)));
-                               calcs_output->urgent_wm_ns[4].b_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               urgent_watermark[8], bw_int_to_fixed(1000)));
-                       }
-                       calcs_output->urgent_wm_ns[5].b_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[9], bw_int_to_fixed(1000)));
-
-                       ((struct bw_calcs_vbios *)vbios)->low_sclk = low_sclk;
-                       ((struct bw_calcs_vbios *)vbios)->mid1_sclk = mid1_sclk;
-                       ((struct bw_calcs_vbios *)vbios)->mid2_sclk = mid2_sclk;
-                       ((struct bw_calcs_vbios *)vbios)->low_yclk = mid_yclk;
-                       calculate_bandwidth(dceip, vbios, data);
-
-                       calcs_output->nbp_state_change_wm_ns[0].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       nbp_state_change_watermark[4], bw_int_to_fixed(1000)));
-                       calcs_output->nbp_state_change_wm_ns[1].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       nbp_state_change_watermark[5], bw_int_to_fixed(1000)));
-                       calcs_output->nbp_state_change_wm_ns[2].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       nbp_state_change_watermark[6], bw_int_to_fixed(1000)));
-                       if (ctx->dc->caps.max_slave_planes) {
-                               calcs_output->nbp_state_change_wm_ns[3].c_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               nbp_state_change_watermark[0], bw_int_to_fixed(1000)));
-                               calcs_output->nbp_state_change_wm_ns[4].c_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               nbp_state_change_watermark[1], bw_int_to_fixed(1000)));
-                       } else {
-                               calcs_output->nbp_state_change_wm_ns[3].c_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               nbp_state_change_watermark[7], bw_int_to_fixed(1000)));
-                               calcs_output->nbp_state_change_wm_ns[4].c_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               nbp_state_change_watermark[8], bw_int_to_fixed(1000)));
-                       }
-                       calcs_output->nbp_state_change_wm_ns[5].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       nbp_state_change_watermark[9], bw_int_to_fixed(1000)));
-
-
-                       calcs_output->stutter_exit_wm_ns[0].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[4], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_exit_wm_ns[1].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[5], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_exit_wm_ns[2].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[6], bw_int_to_fixed(1000)));
-                       if (ctx->dc->caps.max_slave_planes) {
-                               calcs_output->stutter_exit_wm_ns[3].c_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               stutter_exit_watermark[0], bw_int_to_fixed(1000)));
-                               calcs_output->stutter_exit_wm_ns[4].c_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               stutter_exit_watermark[1], bw_int_to_fixed(1000)));
-                       } else {
-                               calcs_output->stutter_exit_wm_ns[3].c_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               stutter_exit_watermark[7], bw_int_to_fixed(1000)));
-                               calcs_output->stutter_exit_wm_ns[4].c_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               stutter_exit_watermark[8], bw_int_to_fixed(1000)));
-                       }
-                       calcs_output->stutter_exit_wm_ns[5].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[9], bw_int_to_fixed(1000)));
-
-               calcs_output->stutter_entry_wm_ns[0].c_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_entry_watermark[4], bw_int_to_fixed(1000)));
-               calcs_output->stutter_entry_wm_ns[1].c_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_entry_watermark[5], bw_int_to_fixed(1000)));
-               calcs_output->stutter_entry_wm_ns[2].c_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_entry_watermark[6], bw_int_to_fixed(1000)));
-               if (ctx->dc->caps.max_slave_planes) {
-                       calcs_output->stutter_entry_wm_ns[3].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[0], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_entry_wm_ns[4].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[1], bw_int_to_fixed(1000)));
-               } else {
-                       calcs_output->stutter_entry_wm_ns[3].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[7], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_entry_wm_ns[4].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[8], bw_int_to_fixed(1000)));
-               }
-               calcs_output->stutter_entry_wm_ns[5].c_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_entry_watermark[9], bw_int_to_fixed(1000)));
-
-                       calcs_output->urgent_wm_ns[0].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[4], bw_int_to_fixed(1000)));
-                       calcs_output->urgent_wm_ns[1].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[5], bw_int_to_fixed(1000)));
-                       calcs_output->urgent_wm_ns[2].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[6], bw_int_to_fixed(1000)));
-                       if (ctx->dc->caps.max_slave_planes) {
-                               calcs_output->urgent_wm_ns[3].c_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               urgent_watermark[0], bw_int_to_fixed(1000)));
-                               calcs_output->urgent_wm_ns[4].c_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               urgent_watermark[1], bw_int_to_fixed(1000)));
-                       } else {
-                               calcs_output->urgent_wm_ns[3].c_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               urgent_watermark[7], bw_int_to_fixed(1000)));
-                               calcs_output->urgent_wm_ns[4].c_mark =
-                                       bw_fixed_to_int(bw_mul(data->
-                                               urgent_watermark[8], bw_int_to_fixed(1000)));
-                       }
-                       calcs_output->urgent_wm_ns[5].c_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[9], bw_int_to_fixed(1000)));
-               }
-
-               if (dceip->version == BW_CALCS_VERSION_CARRIZO) {
-                       ((struct bw_calcs_vbios *)vbios)->low_yclk = high_yclk;
-                       ((struct bw_calcs_vbios *)vbios)->mid_yclk = high_yclk;
-                       ((struct bw_calcs_vbios *)vbios)->low_sclk = high_sclk;
-                       ((struct bw_calcs_vbios *)vbios)->mid1_sclk = high_sclk;
-                       ((struct bw_calcs_vbios *)vbios)->mid2_sclk = high_sclk;
-                       ((struct bw_calcs_vbios *)vbios)->mid3_sclk = high_sclk;
-                       ((struct bw_calcs_vbios *)vbios)->mid4_sclk = high_sclk;
-                       ((struct bw_calcs_vbios *)vbios)->mid5_sclk = high_sclk;
-                       ((struct bw_calcs_vbios *)vbios)->mid6_sclk = high_sclk;
-               } else {
-                       ((struct bw_calcs_vbios *)vbios)->low_yclk = mid_yclk;
-                       ((struct bw_calcs_vbios *)vbios)->low_sclk = mid3_sclk;
-                       ((struct bw_calcs_vbios *)vbios)->mid1_sclk = mid3_sclk;
-                       ((struct bw_calcs_vbios *)vbios)->mid2_sclk = mid3_sclk;
-               }
-
-               calculate_bandwidth(dceip, vbios, data);
-
-               calcs_output->nbp_state_change_wm_ns[0].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               nbp_state_change_watermark[4], bw_int_to_fixed(1000)));
-               calcs_output->nbp_state_change_wm_ns[1].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               nbp_state_change_watermark[5], bw_int_to_fixed(1000)));
-               calcs_output->nbp_state_change_wm_ns[2].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               nbp_state_change_watermark[6], bw_int_to_fixed(1000)));
-               if (ctx->dc->caps.max_slave_planes) {
-                       calcs_output->nbp_state_change_wm_ns[3].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       nbp_state_change_watermark[0], bw_int_to_fixed(1000)));
-                       calcs_output->nbp_state_change_wm_ns[4].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       nbp_state_change_watermark[1], bw_int_to_fixed(1000)));
-               } else {
-                       calcs_output->nbp_state_change_wm_ns[3].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       nbp_state_change_watermark[7], bw_int_to_fixed(1000)));
-                       calcs_output->nbp_state_change_wm_ns[4].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       nbp_state_change_watermark[8], bw_int_to_fixed(1000)));
-               }
-               calcs_output->nbp_state_change_wm_ns[5].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               nbp_state_change_watermark[9], bw_int_to_fixed(1000)));
-
-               calcs_output->stutter_exit_wm_ns[0].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_exit_watermark[4], bw_int_to_fixed(1000)));
-               calcs_output->stutter_exit_wm_ns[1].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_exit_watermark[5], bw_int_to_fixed(1000)));
-               calcs_output->stutter_exit_wm_ns[2].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_exit_watermark[6], bw_int_to_fixed(1000)));
-               if (ctx->dc->caps.max_slave_planes) {
-                       calcs_output->stutter_exit_wm_ns[3].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[0], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_exit_wm_ns[4].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[1], bw_int_to_fixed(1000)));
-               } else {
-                       calcs_output->stutter_exit_wm_ns[3].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[7], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_exit_wm_ns[4].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_exit_watermark[8], bw_int_to_fixed(1000)));
-               }
-               calcs_output->stutter_exit_wm_ns[5].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_exit_watermark[9], bw_int_to_fixed(1000)));
-
-               calcs_output->stutter_entry_wm_ns[0].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_entry_watermark[4], bw_int_to_fixed(1000)));
-               calcs_output->stutter_entry_wm_ns[1].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_entry_watermark[5], bw_int_to_fixed(1000)));
-               calcs_output->stutter_entry_wm_ns[2].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_entry_watermark[6], bw_int_to_fixed(1000)));
-               if (ctx->dc->caps.max_slave_planes) {
-                       calcs_output->stutter_entry_wm_ns[3].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[0], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_entry_wm_ns[4].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[1], bw_int_to_fixed(1000)));
-               } else {
-                       calcs_output->stutter_entry_wm_ns[3].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[7], bw_int_to_fixed(1000)));
-                       calcs_output->stutter_entry_wm_ns[4].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       stutter_entry_watermark[8], bw_int_to_fixed(1000)));
-               }
-               calcs_output->stutter_entry_wm_ns[5].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               stutter_entry_watermark[9], bw_int_to_fixed(1000)));
-
-               calcs_output->urgent_wm_ns[0].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               urgent_watermark[4], bw_int_to_fixed(1000)));
-               calcs_output->urgent_wm_ns[1].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               urgent_watermark[5], bw_int_to_fixed(1000)));
-               calcs_output->urgent_wm_ns[2].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               urgent_watermark[6], bw_int_to_fixed(1000)));
-               if (ctx->dc->caps.max_slave_planes) {
-                       calcs_output->urgent_wm_ns[3].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[0], bw_int_to_fixed(1000)));
-                       calcs_output->urgent_wm_ns[4].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[1], bw_int_to_fixed(1000)));
-               } else {
-                       calcs_output->urgent_wm_ns[3].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[7], bw_int_to_fixed(1000)));
-                       calcs_output->urgent_wm_ns[4].d_mark =
-                               bw_fixed_to_int(bw_mul(data->
-                                       urgent_watermark[8], bw_int_to_fixed(1000)));
-               }
-               calcs_output->urgent_wm_ns[5].d_mark =
-                       bw_fixed_to_int(bw_mul(data->
-                               urgent_watermark[9], bw_int_to_fixed(1000)));
-
-               ((struct bw_calcs_vbios *)vbios)->low_yclk = low_yclk;
-               ((struct bw_calcs_vbios *)vbios)->mid_yclk = mid_yclk;
-               ((struct bw_calcs_vbios *)vbios)->low_sclk = low_sclk;
-               ((struct bw_calcs_vbios *)vbios)->mid1_sclk = mid1_sclk;
-               ((struct bw_calcs_vbios *)vbios)->mid2_sclk = mid2_sclk;
-               ((struct bw_calcs_vbios *)vbios)->mid3_sclk = mid3_sclk;
-               ((struct bw_calcs_vbios *)vbios)->mid4_sclk = mid4_sclk;
-               ((struct bw_calcs_vbios *)vbios)->mid5_sclk = mid5_sclk;
-               ((struct bw_calcs_vbios *)vbios)->mid6_sclk = mid6_sclk;
-               ((struct bw_calcs_vbios *)vbios)->high_sclk = high_sclk;
-       } else {
-               calcs_output->nbp_state_change_enable = true;
-               calcs_output->cpuc_state_change_enable = true;
-               calcs_output->cpup_state_change_enable = true;
-               calcs_output->stutter_mode_enable = true;
-               calcs_output->dispclk_khz = 0;
-               calcs_output->sclk_khz = 0;
-       }
-
-       kfree(data);
-
-       return is_display_configuration_supported(vbios, calcs_output);
-}
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.c b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.c
deleted file mode 100644 (file)
index 41284e2..0000000
+++ /dev/null
@@ -1,1933 +0,0 @@
-/*
- * Copyright 2017 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-
-#include "dm_services.h"
-#include "dcn_calc_auto.h"
-#include "dcn_calc_math.h"
-
-/*
- * NOTE:
- *   This file is gcc-parseable HW gospel, coming straight from HW engineers.
- *
- * It doesn't adhere to Linux kernel style and sometimes will do things in odd
- * ways. Unless there is something clearly wrong with it the code should
- * remain as-is as it provides us with a guarantee from HW that it is correct.
- */
-
-/*REVISION#250*/
-void scaler_settings_calculation(struct dcn_bw_internal_vars *v)
-{
-       int k;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->allow_different_hratio_vratio == dcn_bw_yes) {
-                       if (v->source_scan[k] == dcn_bw_hor) {
-                               v->h_ratio[k] = v->viewport_width[k] / v->scaler_rec_out_width[k];
-                               v->v_ratio[k] = v->viewport_height[k] / v->scaler_recout_height[k];
-                       }
-                       else {
-                               v->h_ratio[k] = v->viewport_height[k] / v->scaler_rec_out_width[k];
-                               v->v_ratio[k] = v->viewport_width[k] / v->scaler_recout_height[k];
-                       }
-               }
-               else {
-                       if (v->source_scan[k] == dcn_bw_hor) {
-                               v->h_ratio[k] =dcn_bw_max2(v->viewport_width[k] / v->scaler_rec_out_width[k], v->viewport_height[k] / v->scaler_recout_height[k]);
-                       }
-                       else {
-                               v->h_ratio[k] =dcn_bw_max2(v->viewport_height[k] / v->scaler_rec_out_width[k], v->viewport_width[k] / v->scaler_recout_height[k]);
-                       }
-                       v->v_ratio[k] = v->h_ratio[k];
-               }
-               if (v->interlace_output[k] == 1.0) {
-                       v->v_ratio[k] = 2.0 * v->v_ratio[k];
-               }
-               if (v->underscan_output[k] == 1.0) {
-                       v->h_ratio[k] = v->h_ratio[k] * v->under_scan_factor;
-                       v->v_ratio[k] = v->v_ratio[k] * v->under_scan_factor;
-               }
-       }
-       /*scaler taps calculation*/
-
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->h_ratio[k] > 1.0) {
-                       v->acceptable_quality_hta_ps =dcn_bw_min2(v->max_hscl_taps, 2.0 *dcn_bw_ceil2(v->h_ratio[k], 1.0));
-               }
-               else if (v->h_ratio[k] < 1.0) {
-                       v->acceptable_quality_hta_ps = 4.0;
-               }
-               else {
-                       v->acceptable_quality_hta_ps = 1.0;
-               }
-               if (v->ta_pscalculation == dcn_bw_override) {
-                       v->htaps[k] = v->override_hta_ps[k];
-               }
-               else {
-                       v->htaps[k] = v->acceptable_quality_hta_ps;
-               }
-               if (v->v_ratio[k] > 1.0) {
-                       v->acceptable_quality_vta_ps =dcn_bw_min2(v->max_vscl_taps, 2.0 *dcn_bw_ceil2(v->v_ratio[k], 1.0));
-               }
-               else if (v->v_ratio[k] < 1.0) {
-                       v->acceptable_quality_vta_ps = 4.0;
-               }
-               else {
-                       v->acceptable_quality_vta_ps = 1.0;
-               }
-               if (v->ta_pscalculation == dcn_bw_override) {
-                       v->vtaps[k] = v->override_vta_ps[k];
-               }
-               else {
-                       v->vtaps[k] = v->acceptable_quality_vta_ps;
-               }
-               if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64 || v->source_pixel_format[k] == dcn_bw_rgb_sub_32 || v->source_pixel_format[k] == dcn_bw_rgb_sub_16) {
-                       v->vta_pschroma[k] = 0.0;
-                       v->hta_pschroma[k] = 0.0;
-               }
-               else {
-                       if (v->ta_pscalculation == dcn_bw_override) {
-                               v->vta_pschroma[k] = v->override_vta_pschroma[k];
-                               v->hta_pschroma[k] = v->override_hta_pschroma[k];
-                       }
-                       else {
-                               v->vta_pschroma[k] = v->acceptable_quality_vta_ps;
-                               v->hta_pschroma[k] = v->acceptable_quality_hta_ps;
-                       }
-               }
-       }
-}
-
-void mode_support_and_system_configuration(struct dcn_bw_internal_vars *v)
-{
-       int i;
-       int j;
-       int k;
-       /*mode support, voltage state and soc configuration*/
-
-       /*scale ratio support check*/
-
-       v->scale_ratio_support = dcn_bw_yes;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->h_ratio[k] > v->max_hscl_ratio || v->v_ratio[k] > v->max_vscl_ratio || v->h_ratio[k] > v->htaps[k] || v->v_ratio[k] > v->vtaps[k] || (v->source_pixel_format[k] != dcn_bw_rgb_sub_64 && v->source_pixel_format[k] != dcn_bw_rgb_sub_32 && v->source_pixel_format[k] != dcn_bw_rgb_sub_16 && (v->h_ratio[k] / 2.0 > v->hta_pschroma[k] || v->v_ratio[k] / 2.0 > v->vta_pschroma[k]))) {
-                       v->scale_ratio_support = dcn_bw_no;
-               }
-       }
-       /*source format, pixel format and scan support check*/
-
-       v->source_format_pixel_and_scan_support = dcn_bw_yes;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if ((v->source_surface_mode[k] == dcn_bw_sw_linear && v->source_scan[k] != dcn_bw_hor) || ((v->source_surface_mode[k] == dcn_bw_sw_4_kb_d || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_x || v->source_surface_mode[k] == dcn_bw_sw_var_d || v->source_surface_mode[k] == dcn_bw_sw_var_d_x) && v->source_pixel_format[k] != dcn_bw_rgb_sub_64)) {
-                       v->source_format_pixel_and_scan_support = dcn_bw_no;
-               }
-       }
-       /*bandwidth support check*/
-
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->source_scan[k] == dcn_bw_hor) {
-                       v->swath_width_ysingle_dpp[k] = v->viewport_width[k];
-               }
-               else {
-                       v->swath_width_ysingle_dpp[k] = v->viewport_height[k];
-               }
-               if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
-                       v->byte_per_pixel_in_dety[k] = 8.0;
-                       v->byte_per_pixel_in_detc[k] = 0.0;
-               }
-               else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_32) {
-                       v->byte_per_pixel_in_dety[k] = 4.0;
-                       v->byte_per_pixel_in_detc[k] = 0.0;
-               }
-               else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_16) {
-                       v->byte_per_pixel_in_dety[k] = 2.0;
-                       v->byte_per_pixel_in_detc[k] = 0.0;
-               }
-               else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
-                       v->byte_per_pixel_in_dety[k] = 1.0;
-                       v->byte_per_pixel_in_detc[k] = 2.0;
-               }
-               else {
-                       v->byte_per_pixel_in_dety[k] = 4.0f / 3.0f;
-                       v->byte_per_pixel_in_detc[k] = 8.0f / 3.0f;
-               }
-       }
-       v->total_read_bandwidth_consumed_gbyte_per_second = 0.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               v->read_bandwidth[k] = v->swath_width_ysingle_dpp[k] * (dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) * v->v_ratio[k] +dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 2.0 * v->v_ratio[k] / 2) / (v->htotal[k] / v->pixel_clock[k]);
-               if (v->dcc_enable[k] == dcn_bw_yes) {
-                       v->read_bandwidth[k] = v->read_bandwidth[k] * (1 + 1 / 256);
-               }
-               if (v->pte_enable == dcn_bw_yes && v->source_scan[k] != dcn_bw_hor && (v->source_surface_mode[k] == dcn_bw_sw_4_kb_s || v->source_surface_mode[k] == dcn_bw_sw_4_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d_x)) {
-                       v->read_bandwidth[k] = v->read_bandwidth[k] * (1 + 1 / 64);
-               }
-               else if (v->pte_enable == dcn_bw_yes && v->source_scan[k] == dcn_bw_hor && (v->source_pixel_format[k] == dcn_bw_rgb_sub_64 || v->source_pixel_format[k] == dcn_bw_rgb_sub_32) && (v->source_surface_mode[k] == dcn_bw_sw_64_kb_s || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_x)) {
-                       v->read_bandwidth[k] = v->read_bandwidth[k] * (1 + 1 / 256);
-               }
-               else if (v->pte_enable == dcn_bw_yes) {
-                       v->read_bandwidth[k] = v->read_bandwidth[k] * (1 + 1 / 512);
-               }
-               v->total_read_bandwidth_consumed_gbyte_per_second = v->total_read_bandwidth_consumed_gbyte_per_second + v->read_bandwidth[k] / 1000.0;
-       }
-       v->total_write_bandwidth_consumed_gbyte_per_second = 0.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->output[k] == dcn_bw_writeback && v->output_format[k] == dcn_bw_444) {
-                       v->write_bandwidth[k] = v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) * 4.0;
-               }
-               else if (v->output[k] == dcn_bw_writeback) {
-                       v->write_bandwidth[k] = v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) * 1.5;
-               }
-               else {
-                       v->write_bandwidth[k] = 0.0;
-               }
-               v->total_write_bandwidth_consumed_gbyte_per_second = v->total_write_bandwidth_consumed_gbyte_per_second + v->write_bandwidth[k] / 1000.0;
-       }
-       v->total_bandwidth_consumed_gbyte_per_second = v->total_read_bandwidth_consumed_gbyte_per_second + v->total_write_bandwidth_consumed_gbyte_per_second;
-       v->dcc_enabled_in_any_plane = dcn_bw_no;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->dcc_enable[k] == dcn_bw_yes) {
-                       v->dcc_enabled_in_any_plane = dcn_bw_yes;
-               }
-       }
-       for (i = 0; i <= number_of_states_plus_one; i++) {
-               v->return_bw_todcn_per_state =dcn_bw_min2(v->return_bus_width * v->dcfclk_per_state[i], v->fabric_and_dram_bandwidth_per_state[i] * 1000.0 * v->percent_of_ideal_drambw_received_after_urg_latency / 100.0);
-               v->return_bw_per_state[i] = v->return_bw_todcn_per_state;
-               if (v->dcc_enabled_in_any_plane == dcn_bw_yes && v->return_bw_todcn_per_state > v->dcfclk_per_state[i] * v->return_bus_width / 4.0) {
-                       v->return_bw_per_state[i] =dcn_bw_min2(v->return_bw_per_state[i], v->return_bw_todcn_per_state * 4.0 * (1.0 - v->urgent_latency / ((v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 / (v->return_bw_todcn_per_state - v->dcfclk_per_state[i] * v->return_bus_width / 4.0) + v->urgent_latency)));
-               }
-               v->critical_point = 2.0 * v->return_bus_width * v->dcfclk_per_state[i] * v->urgent_latency / (v->return_bw_todcn_per_state * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0);
-               if (v->dcc_enabled_in_any_plane == dcn_bw_yes && v->critical_point > 1.0 && v->critical_point < 4.0) {
-                       v->return_bw_per_state[i] =dcn_bw_min2(v->return_bw_per_state[i], dcn_bw_pow(4.0 * v->return_bw_todcn_per_state * (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 * v->return_bus_width * v->dcfclk_per_state[i] * v->urgent_latency / (v->return_bw_todcn_per_state * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0), 2));
-               }
-               v->return_bw_todcn_per_state =dcn_bw_min2(v->return_bus_width * v->dcfclk_per_state[i], v->fabric_and_dram_bandwidth_per_state[i] * 1000.0);
-               if (v->dcc_enabled_in_any_plane == dcn_bw_yes && v->return_bw_todcn_per_state > v->dcfclk_per_state[i] * v->return_bus_width / 4.0) {
-                       v->return_bw_per_state[i] =dcn_bw_min2(v->return_bw_per_state[i], v->return_bw_todcn_per_state * 4.0 * (1.0 - v->urgent_latency / ((v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 / (v->return_bw_todcn_per_state - v->dcfclk_per_state[i] * v->return_bus_width / 4.0) + v->urgent_latency)));
-               }
-               v->critical_point = 2.0 * v->return_bus_width * v->dcfclk_per_state[i] * v->urgent_latency / (v->return_bw_todcn_per_state * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0);
-               if (v->dcc_enabled_in_any_plane == dcn_bw_yes && v->critical_point > 1.0 && v->critical_point < 4.0) {
-                       v->return_bw_per_state[i] =dcn_bw_min2(v->return_bw_per_state[i], dcn_bw_pow(4.0 * v->return_bw_todcn_per_state * (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 * v->return_bus_width * v->dcfclk_per_state[i] * v->urgent_latency / (v->return_bw_todcn_per_state * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0), 2));
-               }
-       }
-       for (i = 0; i <= number_of_states_plus_one; i++) {
-               if ((v->total_read_bandwidth_consumed_gbyte_per_second * 1000.0 <= v->return_bw_per_state[i]) && (v->total_bandwidth_consumed_gbyte_per_second * 1000.0 <= v->fabric_and_dram_bandwidth_per_state[i] * 1000.0 * v->percent_of_ideal_drambw_received_after_urg_latency / 100.0)) {
-                       v->bandwidth_support[i] = dcn_bw_yes;
-               }
-               else {
-                       v->bandwidth_support[i] = dcn_bw_no;
-               }
-       }
-       /*writeback latency support check*/
-
-       v->writeback_latency_support = dcn_bw_yes;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->output[k] == dcn_bw_writeback && v->output_format[k] == dcn_bw_444 && v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) * 4.0 > (v->writeback_luma_buffer_size + v->writeback_chroma_buffer_size) * 1024.0 / v->write_back_latency) {
-                       v->writeback_latency_support = dcn_bw_no;
-               }
-               else if (v->output[k] == dcn_bw_writeback && v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) >dcn_bw_min2(v->writeback_luma_buffer_size, 2.0 * v->writeback_chroma_buffer_size) * 1024.0 / v->write_back_latency) {
-                       v->writeback_latency_support = dcn_bw_no;
-               }
-       }
-       /*re-ordering buffer support check*/
-
-       for (i = 0; i <= number_of_states_plus_one; i++) {
-               v->urgent_round_trip_and_out_of_order_latency_per_state[i] = (v->round_trip_ping_latency_cycles + 32.0) / v->dcfclk_per_state[i] + v->urgent_out_of_order_return_per_channel * v->number_of_channels / v->return_bw_per_state[i];
-               if ((v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 / v->return_bw_per_state[i] > v->urgent_round_trip_and_out_of_order_latency_per_state[i]) {
-                       v->rob_support[i] = dcn_bw_yes;
-               }
-               else {
-                       v->rob_support[i] = dcn_bw_no;
-               }
-       }
-       /*display io support check*/
-
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->output[k] == dcn_bw_dp && v->dsc_capability == dcn_bw_yes) {
-                       if (v->output_format[k] == dcn_bw_420) {
-                               v->required_output_bw = v->pixel_clock[k] / 2.0;
-                       }
-                       else {
-                               v->required_output_bw = v->pixel_clock[k];
-                       }
-               }
-               else if (v->output_format[k] == dcn_bw_420) {
-                       v->required_output_bw = v->pixel_clock[k] * 3.0 / 2.0;
-               }
-               else {
-                       v->required_output_bw = v->pixel_clock[k] * 3.0;
-               }
-               if (v->output[k] == dcn_bw_hdmi) {
-                       v->required_phyclk[k] = v->required_output_bw;
-                       switch (v->output_deep_color[k]) {
-                       case dcn_bw_encoder_10bpc:
-                               v->required_phyclk[k] =  v->required_phyclk[k] * 5.0 / 4;
-                       break;
-                       case dcn_bw_encoder_12bpc:
-                               v->required_phyclk[k] =  v->required_phyclk[k] * 3.0 / 2;
-                               break;
-                       default:
-                               break;
-                       }
-                       v->required_phyclk[k] = v->required_phyclk[k] / 3.0;
-               }
-               else if (v->output[k] == dcn_bw_dp) {
-                       v->required_phyclk[k] = v->required_output_bw / 4.0;
-               }
-               else {
-                       v->required_phyclk[k] = 0.0;
-               }
-       }
-       for (i = 0; i <= number_of_states_plus_one; i++) {
-               v->dio_support[i] = dcn_bw_yes;
-               for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                       if (v->required_phyclk[k] > v->phyclk_per_state[i] || (v->output[k] == dcn_bw_hdmi && v->required_phyclk[k] > 600.0)) {
-                               v->dio_support[i] = dcn_bw_no;
-                       }
-               }
-       }
-       /*total available writeback support check*/
-
-       v->total_number_of_active_writeback = 0.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->output[k] == dcn_bw_writeback) {
-                       v->total_number_of_active_writeback = v->total_number_of_active_writeback + 1.0;
-               }
-       }
-       if (v->total_number_of_active_writeback <= v->max_num_writeback) {
-               v->total_available_writeback_support = dcn_bw_yes;
-       }
-       else {
-               v->total_available_writeback_support = dcn_bw_no;
-       }
-       /*maximum dispclk/dppclk support check*/
-
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->h_ratio[k] > 1.0) {
-                       v->pscl_factor[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput * v->h_ratio[k] /dcn_bw_ceil2(v->htaps[k] / 6.0, 1.0));
-               }
-               else {
-                       v->pscl_factor[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput);
-               }
-               if (v->byte_per_pixel_in_detc[k] == 0.0) {
-                       v->pscl_factor_chroma[k] = 0.0;
-                       v->min_dppclk_using_single_dpp[k] = v->pixel_clock[k] *dcn_bw_max3(v->vtaps[k] / 6.0 *dcn_bw_min2(1.0, v->h_ratio[k]), v->h_ratio[k] * v->v_ratio[k] / v->pscl_factor[k], 1.0);
-               }
-               else {
-                       if (v->h_ratio[k] / 2.0 > 1.0) {
-                               v->pscl_factor_chroma[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput * v->h_ratio[k] / 2.0 /dcn_bw_ceil2(v->hta_pschroma[k] / 6.0, 1.0));
-                       }
-                       else {
-                               v->pscl_factor_chroma[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput);
-                       }
-                       v->min_dppclk_using_single_dpp[k] = v->pixel_clock[k] *dcn_bw_max5(v->vtaps[k] / 6.0 *dcn_bw_min2(1.0, v->h_ratio[k]), v->h_ratio[k] * v->v_ratio[k] / v->pscl_factor[k], v->vta_pschroma[k] / 6.0 *dcn_bw_min2(1.0, v->h_ratio[k] / 2.0), v->h_ratio[k] * v->v_ratio[k] / 4.0 / v->pscl_factor_chroma[k], 1.0);
-               }
-       }
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if ((v->source_pixel_format[k] == dcn_bw_rgb_sub_64 || v->source_pixel_format[k] == dcn_bw_rgb_sub_32 || v->source_pixel_format[k] == dcn_bw_rgb_sub_16)) {
-                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                               v->read256_block_height_y[k] = 1.0;
-                       }
-                       else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
-                               v->read256_block_height_y[k] = 4.0;
-                       }
-                       else {
-                               v->read256_block_height_y[k] = 8.0;
-                       }
-                       v->read256_block_width_y[k] = 256.0 /dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / v->read256_block_height_y[k];
-                       v->read256_block_height_c[k] = 0.0;
-                       v->read256_block_width_c[k] = 0.0;
-               }
-               else {
-                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                               v->read256_block_height_y[k] = 1.0;
-                               v->read256_block_height_c[k] = 1.0;
-                       }
-                       else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
-                               v->read256_block_height_y[k] = 16.0;
-                               v->read256_block_height_c[k] = 8.0;
-                       }
-                       else {
-                               v->read256_block_height_y[k] = 8.0;
-                               v->read256_block_height_c[k] = 8.0;
-                       }
-                       v->read256_block_width_y[k] = 256.0 /dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / v->read256_block_height_y[k];
-                       v->read256_block_width_c[k] = 256.0 /dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / v->read256_block_height_c[k];
-               }
-               if (v->source_scan[k] == dcn_bw_hor) {
-                       v->max_swath_height_y[k] = v->read256_block_height_y[k];
-                       v->max_swath_height_c[k] = v->read256_block_height_c[k];
-               }
-               else {
-                       v->max_swath_height_y[k] = v->read256_block_width_y[k];
-                       v->max_swath_height_c[k] = v->read256_block_width_c[k];
-               }
-               if ((v->source_pixel_format[k] == dcn_bw_rgb_sub_64 || v->source_pixel_format[k] == dcn_bw_rgb_sub_32 || v->source_pixel_format[k] == dcn_bw_rgb_sub_16)) {
-                       if (v->source_surface_mode[k] == dcn_bw_sw_linear || (v->source_pixel_format[k] == dcn_bw_rgb_sub_64 && (v->source_surface_mode[k] == dcn_bw_sw_4_kb_s || v->source_surface_mode[k] == dcn_bw_sw_4_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_var_s || v->source_surface_mode[k] == dcn_bw_sw_var_s_x) && v->source_scan[k] == dcn_bw_hor)) {
-                               v->min_swath_height_y[k] = v->max_swath_height_y[k];
-                       }
-                       else {
-                               v->min_swath_height_y[k] = v->max_swath_height_y[k] / 2.0;
-                       }
-                       v->min_swath_height_c[k] = v->max_swath_height_c[k];
-               }
-               else {
-                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                               v->min_swath_height_y[k] = v->max_swath_height_y[k];
-                               v->min_swath_height_c[k] = v->max_swath_height_c[k];
-                       }
-                       else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8 && v->source_scan[k] == dcn_bw_hor) {
-                               v->min_swath_height_y[k] = v->max_swath_height_y[k] / 2.0;
-                               if (v->bug_forcing_luma_and_chroma_request_to_same_size_fixed == dcn_bw_yes) {
-                                       v->min_swath_height_c[k] = v->max_swath_height_c[k];
-                               }
-                               else {
-                                       v->min_swath_height_c[k] = v->max_swath_height_c[k] / 2.0;
-                               }
-                       }
-                       else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10 && v->source_scan[k] == dcn_bw_hor) {
-                               v->min_swath_height_c[k] = v->max_swath_height_c[k] / 2.0;
-                               if (v->bug_forcing_luma_and_chroma_request_to_same_size_fixed == dcn_bw_yes) {
-                                       v->min_swath_height_y[k] = v->max_swath_height_y[k];
-                               }
-                               else {
-                                       v->min_swath_height_y[k] = v->max_swath_height_y[k] / 2.0;
-                               }
-                       }
-                       else {
-                               v->min_swath_height_y[k] = v->max_swath_height_y[k];
-                               v->min_swath_height_c[k] = v->max_swath_height_c[k];
-                       }
-               }
-               if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                       v->maximum_swath_width = 8192.0;
-               }
-               else {
-                       v->maximum_swath_width = 5120.0;
-               }
-               v->number_of_dpp_required_for_det_size =dcn_bw_ceil2(v->swath_width_ysingle_dpp[k] /dcn_bw_min2(v->maximum_swath_width, v->det_buffer_size_in_kbyte * 1024.0 / 2.0 / (v->byte_per_pixel_in_dety[k] * v->min_swath_height_y[k] + v->byte_per_pixel_in_detc[k] / 2.0 * v->min_swath_height_c[k])), 1.0);
-               if (v->byte_per_pixel_in_detc[k] == 0.0) {
-                       v->number_of_dpp_required_for_lb_size =dcn_bw_ceil2((v->vtaps[k] +dcn_bw_max2(dcn_bw_ceil2(v->v_ratio[k], 1.0) - 2, 0.0)) * v->swath_width_ysingle_dpp[k] /dcn_bw_max2(v->h_ratio[k], 1.0) * v->lb_bit_per_pixel[k] / v->line_buffer_size, 1.0);
-               }
-               else {
-                       v->number_of_dpp_required_for_lb_size =dcn_bw_max2(dcn_bw_ceil2((v->vtaps[k] +dcn_bw_max2(dcn_bw_ceil2(v->v_ratio[k], 1.0) - 2, 0.0)) * v->swath_width_ysingle_dpp[k] /dcn_bw_max2(v->h_ratio[k], 1.0) * v->lb_bit_per_pixel[k] / v->line_buffer_size, 1.0),dcn_bw_ceil2((v->vta_pschroma[k] +dcn_bw_max2(dcn_bw_ceil2(v->v_ratio[k] / 2.0, 1.0) - 2, 0.0)) * v->swath_width_ysingle_dpp[k] / 2.0 /dcn_bw_max2(v->h_ratio[k] / 2.0, 1.0) * v->lb_bit_per_pixel[k] / v->line_buffer_size, 1.0));
-               }
-               v->number_of_dpp_required_for_det_and_lb_size[k] =dcn_bw_max2(v->number_of_dpp_required_for_det_size, v->number_of_dpp_required_for_lb_size);
-       }
-       for (i = 0; i <= number_of_states_plus_one; i++) {
-               for (j = 0; j <= 1; j++) {
-                       v->total_number_of_active_dpp[i][j] = 0.0;
-                       v->required_dispclk[i][j] = 0.0;
-                       v->dispclk_dppclk_support[i][j] = dcn_bw_yes;
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               v->min_dispclk_using_single_dpp =dcn_bw_max2(v->pixel_clock[k], v->min_dppclk_using_single_dpp[k] * (j + 1)) * (1.0 + v->downspreading / 100.0);
-                               if (v->odm_capability == dcn_bw_yes) {
-                                       v->min_dispclk_using_dual_dpp =dcn_bw_max2(v->pixel_clock[k] / 2.0, v->min_dppclk_using_single_dpp[k] / 2.0 * (j + 1)) * (1.0 + v->downspreading / 100.0);
-                               }
-                               else {
-                                       v->min_dispclk_using_dual_dpp =dcn_bw_max2(v->pixel_clock[k], v->min_dppclk_using_single_dpp[k] / 2.0 * (j + 1)) * (1.0 + v->downspreading / 100.0);
-                               }
-                               if (i < number_of_states) {
-                                       v->min_dispclk_using_single_dpp = v->min_dispclk_using_single_dpp * (1.0 + v->dispclk_ramping_margin / 100.0);
-                                       v->min_dispclk_using_dual_dpp = v->min_dispclk_using_dual_dpp * (1.0 + v->dispclk_ramping_margin / 100.0);
-                               }
-                               if (v->min_dispclk_using_single_dpp <=dcn_bw_min2(v->max_dispclk[i], (j + 1) * v->max_dppclk[i]) && v->number_of_dpp_required_for_det_and_lb_size[k] <= 1.0) {
-                                       v->no_of_dpp[i][j][k] = 1.0;
-                                       v->required_dispclk[i][j] =dcn_bw_max2(v->required_dispclk[i][j], v->min_dispclk_using_single_dpp);
-                               }
-                               else if (v->min_dispclk_using_dual_dpp <=dcn_bw_min2(v->max_dispclk[i], (j + 1) * v->max_dppclk[i])) {
-                                       v->no_of_dpp[i][j][k] = 2.0;
-                                       v->required_dispclk[i][j] =dcn_bw_max2(v->required_dispclk[i][j], v->min_dispclk_using_dual_dpp);
-                               }
-                               else {
-                                       v->no_of_dpp[i][j][k] = 2.0;
-                                       v->required_dispclk[i][j] =dcn_bw_max2(v->required_dispclk[i][j], v->min_dispclk_using_dual_dpp);
-                                       v->dispclk_dppclk_support[i][j] = dcn_bw_no;
-                               }
-                               v->total_number_of_active_dpp[i][j] = v->total_number_of_active_dpp[i][j] + v->no_of_dpp[i][j][k];
-                       }
-                       if (v->total_number_of_active_dpp[i][j] > v->max_num_dpp) {
-                               v->total_number_of_active_dpp[i][j] = 0.0;
-                               v->required_dispclk[i][j] = 0.0;
-                               v->dispclk_dppclk_support[i][j] = dcn_bw_yes;
-                               for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                                       v->min_dispclk_using_single_dpp =dcn_bw_max2(v->pixel_clock[k], v->min_dppclk_using_single_dpp[k] * (j + 1)) * (1.0 + v->downspreading / 100.0);
-                                       v->min_dispclk_using_dual_dpp =dcn_bw_max2(v->pixel_clock[k], v->min_dppclk_using_single_dpp[k] / 2.0 * (j + 1)) * (1.0 + v->downspreading / 100.0);
-                                       if (i < number_of_states) {
-                                               v->min_dispclk_using_single_dpp = v->min_dispclk_using_single_dpp * (1.0 + v->dispclk_ramping_margin / 100.0);
-                                               v->min_dispclk_using_dual_dpp = v->min_dispclk_using_dual_dpp * (1.0 + v->dispclk_ramping_margin / 100.0);
-                                       }
-                                       if (v->number_of_dpp_required_for_det_and_lb_size[k] <= 1.0) {
-                                               v->no_of_dpp[i][j][k] = 1.0;
-                                               v->required_dispclk[i][j] =dcn_bw_max2(v->required_dispclk[i][j], v->min_dispclk_using_single_dpp);
-                                               if (v->min_dispclk_using_single_dpp >dcn_bw_min2(v->max_dispclk[i], (j + 1) * v->max_dppclk[i])) {
-                                                       v->dispclk_dppclk_support[i][j] = dcn_bw_no;
-                                               }
-                                       }
-                                       else {
-                                               v->no_of_dpp[i][j][k] = 2.0;
-                                               v->required_dispclk[i][j] =dcn_bw_max2(v->required_dispclk[i][j], v->min_dispclk_using_dual_dpp);
-                                               if (v->min_dispclk_using_dual_dpp >dcn_bw_min2(v->max_dispclk[i], (j + 1) * v->max_dppclk[i])) {
-                                                       v->dispclk_dppclk_support[i][j] = dcn_bw_no;
-                                               }
-                                       }
-                                       v->total_number_of_active_dpp[i][j] = v->total_number_of_active_dpp[i][j] + v->no_of_dpp[i][j][k];
-                               }
-                       }
-               }
-       }
-       /*viewport size check*/
-
-       v->viewport_size_support = dcn_bw_yes;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->number_of_dpp_required_for_det_and_lb_size[k] > 2.0) {
-                       v->viewport_size_support = dcn_bw_no;
-               }
-       }
-       /*total available pipes support check*/
-
-       for (i = 0; i <= number_of_states_plus_one; i++) {
-               for (j = 0; j <= 1; j++) {
-                       if (v->total_number_of_active_dpp[i][j] <= v->max_num_dpp) {
-                               v->total_available_pipes_support[i][j] = dcn_bw_yes;
-                       }
-                       else {
-                               v->total_available_pipes_support[i][j] = dcn_bw_no;
-                       }
-               }
-       }
-       /*urgent latency support check*/
-
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               for (i = 0; i <= number_of_states_plus_one; i++) {
-                       for (j = 0; j <= 1; j++) {
-                               v->swath_width_yper_state[i][j][k] = v->swath_width_ysingle_dpp[k] / v->no_of_dpp[i][j][k];
-                               v->swath_width_granularity_y = 256.0 /dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / v->max_swath_height_y[k];
-                               v->rounded_up_max_swath_size_bytes_y = (dcn_bw_ceil2(v->swath_width_yper_state[i][j][k] - 1.0, v->swath_width_granularity_y) + v->swath_width_granularity_y) * v->byte_per_pixel_in_dety[k] * v->max_swath_height_y[k];
-                               if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10) {
-                                       v->rounded_up_max_swath_size_bytes_y =dcn_bw_ceil2(v->rounded_up_max_swath_size_bytes_y, 256.0) + 256;
-                               }
-                               if (v->max_swath_height_c[k] > 0.0) {
-                                       v->swath_width_granularity_c = 256.0 /dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / v->max_swath_height_c[k];
-                               }
-                               v->rounded_up_max_swath_size_bytes_c = (dcn_bw_ceil2(v->swath_width_yper_state[i][j][k] / 2.0 - 1.0, v->swath_width_granularity_c) + v->swath_width_granularity_c) * v->byte_per_pixel_in_detc[k] * v->max_swath_height_c[k];
-                               if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10) {
-                                       v->rounded_up_max_swath_size_bytes_c =dcn_bw_ceil2(v->rounded_up_max_swath_size_bytes_c, 256.0) + 256;
-                               }
-                               if (v->rounded_up_max_swath_size_bytes_y + v->rounded_up_max_swath_size_bytes_c <= v->det_buffer_size_in_kbyte * 1024.0 / 2.0) {
-                                       v->swath_height_yper_state[i][j][k] = v->max_swath_height_y[k];
-                                       v->swath_height_cper_state[i][j][k] = v->max_swath_height_c[k];
-                               }
-                               else {
-                                       v->swath_height_yper_state[i][j][k] = v->min_swath_height_y[k];
-                                       v->swath_height_cper_state[i][j][k] = v->min_swath_height_c[k];
-                               }
-                               if (v->byte_per_pixel_in_detc[k] == 0.0) {
-                                       v->lines_in_det_luma = v->det_buffer_size_in_kbyte * 1024.0 / v->byte_per_pixel_in_dety[k] / v->swath_width_yper_state[i][j][k];
-                                       v->lines_in_det_chroma = 0.0;
-                               }
-                               else if (v->swath_height_yper_state[i][j][k] <= v->swath_height_cper_state[i][j][k]) {
-                                       v->lines_in_det_luma = v->det_buffer_size_in_kbyte * 1024.0 / 2.0 / v->byte_per_pixel_in_dety[k] / v->swath_width_yper_state[i][j][k];
-                                       v->lines_in_det_chroma = v->det_buffer_size_in_kbyte * 1024.0 / 2.0 / v->byte_per_pixel_in_detc[k] / (v->swath_width_yper_state[i][j][k] / 2.0);
-                               }
-                               else {
-                                       v->lines_in_det_luma = v->det_buffer_size_in_kbyte * 1024.0 * 2.0 / 3.0 / v->byte_per_pixel_in_dety[k] / v->swath_width_yper_state[i][j][k];
-                                       v->lines_in_det_chroma = v->det_buffer_size_in_kbyte * 1024.0 / 3.0 / v->byte_per_pixel_in_dety[k] / (v->swath_width_yper_state[i][j][k] / 2.0);
-                               }
-                               v->effective_lb_latency_hiding_source_lines_luma =dcn_bw_min2(v->max_line_buffer_lines,dcn_bw_floor2(v->line_buffer_size / v->lb_bit_per_pixel[k] / (v->swath_width_yper_state[i][j][k] /dcn_bw_max2(v->h_ratio[k], 1.0)), 1.0)) - (v->vtaps[k] - 1.0);
-                               v->effective_lb_latency_hiding_source_lines_chroma =dcn_bw_min2(v->max_line_buffer_lines,dcn_bw_floor2(v->line_buffer_size / v->lb_bit_per_pixel[k] / (v->swath_width_yper_state[i][j][k] / 2.0 /dcn_bw_max2(v->h_ratio[k] / 2.0, 1.0)), 1.0)) - (v->vta_pschroma[k] - 1.0);
-                               v->effective_detlb_lines_luma =dcn_bw_floor2(v->lines_in_det_luma +dcn_bw_min2(v->lines_in_det_luma * v->required_dispclk[i][j] * v->byte_per_pixel_in_dety[k] * v->pscl_factor[k] / v->return_bw_per_state[i], v->effective_lb_latency_hiding_source_lines_luma), v->swath_height_yper_state[i][j][k]);
-                               v->effective_detlb_lines_chroma =dcn_bw_floor2(v->lines_in_det_chroma +dcn_bw_min2(v->lines_in_det_chroma * v->required_dispclk[i][j] * v->byte_per_pixel_in_detc[k] * v->pscl_factor_chroma[k] / v->return_bw_per_state[i], v->effective_lb_latency_hiding_source_lines_chroma), v->swath_height_cper_state[i][j][k]);
-                               if (v->byte_per_pixel_in_detc[k] == 0.0) {
-                                       v->urgent_latency_support_us_per_state[i][j][k] = v->effective_detlb_lines_luma * (v->htotal[k] / v->pixel_clock[k]) / v->v_ratio[k] - v->effective_detlb_lines_luma * v->swath_width_yper_state[i][j][k] *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / (v->return_bw_per_state[i] / v->no_of_dpp[i][j][k]);
-                               }
-                               else {
-                                       v->urgent_latency_support_us_per_state[i][j][k] =dcn_bw_min2(v->effective_detlb_lines_luma * (v->htotal[k] / v->pixel_clock[k]) / v->v_ratio[k] - v->effective_detlb_lines_luma * v->swath_width_yper_state[i][j][k] *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / (v->return_bw_per_state[i] / v->no_of_dpp[i][j][k]), v->effective_detlb_lines_chroma * (v->htotal[k] / v->pixel_clock[k]) / (v->v_ratio[k] / 2.0) - v->effective_detlb_lines_chroma * v->swath_width_yper_state[i][j][k] / 2.0 *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / (v->return_bw_per_state[i] / v->no_of_dpp[i][j][k]));
-                               }
-                       }
-               }
-       }
-       for (i = 0; i <= number_of_states_plus_one; i++) {
-               for (j = 0; j <= 1; j++) {
-                       v->urgent_latency_support[i][j] = dcn_bw_yes;
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               if (v->urgent_latency_support_us_per_state[i][j][k] < v->urgent_latency / 1.0) {
-                                       v->urgent_latency_support[i][j] = dcn_bw_no;
-                               }
-                       }
-               }
-       }
-       /*prefetch check*/
-
-       for (i = 0; i <= number_of_states_plus_one; i++) {
-               for (j = 0; j <= 1; j++) {
-                       v->total_number_of_dcc_active_dpp[i][j] = 0.0;
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               if (v->dcc_enable[k] == dcn_bw_yes) {
-                                       v->total_number_of_dcc_active_dpp[i][j] = v->total_number_of_dcc_active_dpp[i][j] + v->no_of_dpp[i][j][k];
-                               }
-                       }
-               }
-       }
-       for (i = 0; i <= number_of_states_plus_one; i++) {
-               for (j = 0; j <= 1; j++) {
-                       v->projected_dcfclk_deep_sleep = 8.0;
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               v->projected_dcfclk_deep_sleep =dcn_bw_max2(v->projected_dcfclk_deep_sleep, v->pixel_clock[k] / 16.0);
-                               if (v->byte_per_pixel_in_detc[k] == 0.0) {
-                                       if (v->v_ratio[k] <= 1.0) {
-                                               v->projected_dcfclk_deep_sleep =dcn_bw_max2(v->projected_dcfclk_deep_sleep, 1.1 *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / 64.0 * v->h_ratio[k] * v->pixel_clock[k] / v->no_of_dpp[i][j][k]);
-                                       }
-                                       else {
-                                               v->projected_dcfclk_deep_sleep =dcn_bw_max2(v->projected_dcfclk_deep_sleep, 1.1 *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / 64.0 * v->pscl_factor[k] * v->required_dispclk[i][j] / (1 + j));
-                                       }
-                               }
-                               else {
-                                       if (v->v_ratio[k] <= 1.0) {
-                                               v->projected_dcfclk_deep_sleep =dcn_bw_max2(v->projected_dcfclk_deep_sleep, 1.1 *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / 32.0 * v->h_ratio[k] * v->pixel_clock[k] / v->no_of_dpp[i][j][k]);
-                                       }
-                                       else {
-                                               v->projected_dcfclk_deep_sleep =dcn_bw_max2(v->projected_dcfclk_deep_sleep, 1.1 *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / 32.0 * v->pscl_factor[k] * v->required_dispclk[i][j] / (1 + j));
-                                       }
-                                       if (v->v_ratio[k] / 2.0 <= 1.0) {
-                                               v->projected_dcfclk_deep_sleep =dcn_bw_max2(v->projected_dcfclk_deep_sleep, 1.1 *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 32.0 * v->h_ratio[k] / 2.0 * v->pixel_clock[k] / v->no_of_dpp[i][j][k]);
-                                       }
-                                       else {
-                                               v->projected_dcfclk_deep_sleep =dcn_bw_max2(v->projected_dcfclk_deep_sleep, 1.1 *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 32.0 * v->pscl_factor_chroma[k] * v->required_dispclk[i][j] / (1 + j));
-                                       }
-                               }
-                       }
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               if (v->dcc_enable[k] == dcn_bw_yes) {
-                                       v->meta_req_height_y = 8.0 * v->read256_block_height_y[k];
-                                       v->meta_req_width_y = 64.0 * 256.0 /dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / v->meta_req_height_y;
-                                       v->meta_surface_width_y =dcn_bw_ceil2(v->viewport_width[k] / v->no_of_dpp[i][j][k] - 1.0, v->meta_req_width_y) + v->meta_req_width_y;
-                                       v->meta_surface_height_y =dcn_bw_ceil2(v->viewport_height[k] - 1.0, v->meta_req_height_y) + v->meta_req_height_y;
-                                       if (v->pte_enable == dcn_bw_yes) {
-                                               v->meta_pte_bytes_per_frame_y = (dcn_bw_ceil2((v->meta_surface_width_y * v->meta_surface_height_y *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / 256.0 - 4096.0) / 8.0 / 4096.0, 1.0) + 1) * 64.0;
-                                       }
-                                       else {
-                                               v->meta_pte_bytes_per_frame_y = 0.0;
-                                       }
-                                       if (v->source_scan[k] == dcn_bw_hor) {
-                                               v->meta_row_bytes_y = v->meta_surface_width_y * v->meta_req_height_y *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / 256.0;
-                                       }
-                                       else {
-                                               v->meta_row_bytes_y = v->meta_surface_height_y * v->meta_req_width_y *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / 256.0;
-                                       }
-                               }
-                               else {
-                                       v->meta_pte_bytes_per_frame_y = 0.0;
-                                       v->meta_row_bytes_y = 0.0;
-                               }
-                               if (v->pte_enable == dcn_bw_yes) {
-                                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                                               v->macro_tile_block_size_bytes_y = 256.0;
-                                               v->macro_tile_block_height_y = 1.0;
-                                       }
-                                       else if (v->source_surface_mode[k] == dcn_bw_sw_4_kb_s || v->source_surface_mode[k] == dcn_bw_sw_4_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d_x) {
-                                               v->macro_tile_block_size_bytes_y = 4096.0;
-                                               v->macro_tile_block_height_y = 4.0 * v->read256_block_height_y[k];
-                                       }
-                                       else if (v->source_surface_mode[k] == dcn_bw_sw_64_kb_s || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_x) {
-                                               v->macro_tile_block_size_bytes_y = 64.0 * 1024;
-                                               v->macro_tile_block_height_y = 16.0 * v->read256_block_height_y[k];
-                                       }
-                                       else {
-                                               v->macro_tile_block_size_bytes_y = 256.0 * 1024;
-                                               v->macro_tile_block_height_y = 32.0 * v->read256_block_height_y[k];
-                                       }
-                                       if (v->macro_tile_block_size_bytes_y <= 65536.0) {
-                                               v->data_pte_req_height_y = v->macro_tile_block_height_y;
-                                       }
-                                       else {
-                                               v->data_pte_req_height_y = 16.0 * v->read256_block_height_y[k];
-                                       }
-                                       v->data_pte_req_width_y = 4096.0 /dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / v->data_pte_req_height_y * 8;
-                                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                                               v->dpte_bytes_per_row_y = 64.0 * (dcn_bw_ceil2((v->viewport_width[k] / v->no_of_dpp[i][j][k] *dcn_bw_min2(128.0, dcn_bw_pow(2.0,dcn_bw_floor2(dcn_bw_log(v->pte_buffer_size_in_requests * v->data_pte_req_width_y / (v->viewport_width[k] / v->no_of_dpp[i][j][k]), 2.0), 1.0))) - 1.0) / v->data_pte_req_width_y, 1.0) + 1);
-                                       }
-                                       else if (v->source_scan[k] == dcn_bw_hor) {
-                                               v->dpte_bytes_per_row_y = 64.0 * (dcn_bw_ceil2((v->viewport_width[k] / v->no_of_dpp[i][j][k] - 1.0) / v->data_pte_req_width_y, 1.0) + 1);
-                                       }
-                                       else {
-                                               v->dpte_bytes_per_row_y = 64.0 * (dcn_bw_ceil2((v->viewport_height[k] - 1.0) / v->data_pte_req_height_y, 1.0) + 1);
-                                       }
-                               }
-                               else {
-                                       v->dpte_bytes_per_row_y = 0.0;
-                               }
-                               if ((v->source_pixel_format[k] != dcn_bw_rgb_sub_64 && v->source_pixel_format[k] != dcn_bw_rgb_sub_32 && v->source_pixel_format[k] != dcn_bw_rgb_sub_16)) {
-                                       if (v->dcc_enable[k] == dcn_bw_yes) {
-                                               v->meta_req_height_c = 8.0 * v->read256_block_height_c[k];
-                                               v->meta_req_width_c = 64.0 * 256.0 /dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / v->meta_req_height_c;
-                                               v->meta_surface_width_c =dcn_bw_ceil2(v->viewport_width[k] / v->no_of_dpp[i][j][k] / 2.0 - 1.0, v->meta_req_width_c) + v->meta_req_width_c;
-                                               v->meta_surface_height_c =dcn_bw_ceil2(v->viewport_height[k] / 2.0 - 1.0, v->meta_req_height_c) + v->meta_req_height_c;
-                                               if (v->pte_enable == dcn_bw_yes) {
-                                                       v->meta_pte_bytes_per_frame_c = (dcn_bw_ceil2((v->meta_surface_width_c * v->meta_surface_height_c *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 256.0 - 4096.0) / 8.0 / 4096.0, 1.0) + 1) * 64.0;
-                                               }
-                                               else {
-                                                       v->meta_pte_bytes_per_frame_c = 0.0;
-                                               }
-                                               if (v->source_scan[k] == dcn_bw_hor) {
-                                                       v->meta_row_bytes_c = v->meta_surface_width_c * v->meta_req_height_c *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 256.0;
-                                               }
-                                               else {
-                                                       v->meta_row_bytes_c = v->meta_surface_height_c * v->meta_req_width_c *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 256.0;
-                                               }
-                                       }
-                                       else {
-                                               v->meta_pte_bytes_per_frame_c = 0.0;
-                                               v->meta_row_bytes_c = 0.0;
-                                       }
-                                       if (v->pte_enable == dcn_bw_yes) {
-                                               if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                                                       v->macro_tile_block_size_bytes_c = 256.0;
-                                                       v->macro_tile_block_height_c = 1.0;
-                                               }
-                                               else if (v->source_surface_mode[k] == dcn_bw_sw_4_kb_s || v->source_surface_mode[k] == dcn_bw_sw_4_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d_x) {
-                                                       v->macro_tile_block_size_bytes_c = 4096.0;
-                                                       v->macro_tile_block_height_c = 4.0 * v->read256_block_height_c[k];
-                                               }
-                                               else if (v->source_surface_mode[k] == dcn_bw_sw_64_kb_s || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_x) {
-                                                       v->macro_tile_block_size_bytes_c = 64.0 * 1024;
-                                                       v->macro_tile_block_height_c = 16.0 * v->read256_block_height_c[k];
-                                               }
-                                               else {
-                                                       v->macro_tile_block_size_bytes_c = 256.0 * 1024;
-                                                       v->macro_tile_block_height_c = 32.0 * v->read256_block_height_c[k];
-                                               }
-                                               v->macro_tile_block_width_c = v->macro_tile_block_size_bytes_c /dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / v->macro_tile_block_height_c;
-                                               if (v->macro_tile_block_size_bytes_c <= 65536.0) {
-                                                       v->data_pte_req_height_c = v->macro_tile_block_height_c;
-                                               }
-                                               else {
-                                                       v->data_pte_req_height_c = 16.0 * v->read256_block_height_c[k];
-                                               }
-                                               v->data_pte_req_width_c = 4096.0 /dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / v->data_pte_req_height_c * 8;
-                                               if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                                                       v->dpte_bytes_per_row_c = 64.0 * (dcn_bw_ceil2((v->viewport_width[k] / v->no_of_dpp[i][j][k] / 2.0 * dcn_bw_min2(128.0, dcn_bw_pow(2.0,dcn_bw_floor2(dcn_bw_log(v->pte_buffer_size_in_requests * v->data_pte_req_width_c / (v->viewport_width[k] / v->no_of_dpp[i][j][k] / 2.0), 2.0), 1.0))) - 1.0) / v->data_pte_req_width_c, 1.0) + 1);
-                                               }
-                                               else if (v->source_scan[k] == dcn_bw_hor) {
-                                                       v->dpte_bytes_per_row_c = 64.0 * (dcn_bw_ceil2((v->viewport_width[k] / v->no_of_dpp[i][j][k] / 2.0 - 1.0) / v->data_pte_req_width_c, 1.0) + 1);
-                                               }
-                                               else {
-                                                       v->dpte_bytes_per_row_c = 64.0 * (dcn_bw_ceil2((v->viewport_height[k] / 2.0 - 1.0) / v->data_pte_req_height_c, 1.0) + 1);
-                                               }
-                                       }
-                                       else {
-                                               v->dpte_bytes_per_row_c = 0.0;
-                                       }
-                               }
-                               else {
-                                       v->dpte_bytes_per_row_c = 0.0;
-                                       v->meta_pte_bytes_per_frame_c = 0.0;
-                                       v->meta_row_bytes_c = 0.0;
-                               }
-                               v->dpte_bytes_per_row[k] = v->dpte_bytes_per_row_y + v->dpte_bytes_per_row_c;
-                               v->meta_pte_bytes_per_frame[k] = v->meta_pte_bytes_per_frame_y + v->meta_pte_bytes_per_frame_c;
-                               v->meta_row_bytes[k] = v->meta_row_bytes_y + v->meta_row_bytes_c;
-                               v->v_init_y = (v->v_ratio[k] + v->vtaps[k] + 1.0 + v->interlace_output[k] * 0.5 * v->v_ratio[k]) / 2.0;
-                               v->prefill_y[k] =dcn_bw_floor2(v->v_init_y, 1.0);
-                               v->max_num_sw_y[k] =dcn_bw_ceil2((v->prefill_y[k] - 1.0) / v->swath_height_yper_state[i][j][k], 1.0) + 1;
-                               if (v->prefill_y[k] > 1.0) {
-                                       v->max_partial_sw_y =dcn_bw_mod((v->prefill_y[k] - 2.0), v->swath_height_yper_state[i][j][k]);
-                               }
-                               else {
-                                       v->max_partial_sw_y =dcn_bw_mod((v->prefill_y[k] + v->swath_height_yper_state[i][j][k] - 2.0), v->swath_height_yper_state[i][j][k]);
-                               }
-                               v->max_partial_sw_y =dcn_bw_max2(1.0, v->max_partial_sw_y);
-                               v->prefetch_lines_y[k] = v->max_num_sw_y[k] * v->swath_height_yper_state[i][j][k] + v->max_partial_sw_y;
-                               if ((v->source_pixel_format[k] != dcn_bw_rgb_sub_64 && v->source_pixel_format[k] != dcn_bw_rgb_sub_32 && v->source_pixel_format[k] != dcn_bw_rgb_sub_16)) {
-                                       v->v_init_c = (v->v_ratio[k] / 2.0 + v->vtaps[k] + 1.0 + v->interlace_output[k] * 0.5 * v->v_ratio[k] / 2.0) / 2.0;
-                                       v->prefill_c[k] =dcn_bw_floor2(v->v_init_c, 1.0);
-                                       v->max_num_sw_c[k] =dcn_bw_ceil2((v->prefill_c[k] - 1.0) / v->swath_height_cper_state[i][j][k], 1.0) + 1;
-                                       if (v->prefill_c[k] > 1.0) {
-                                               v->max_partial_sw_c =dcn_bw_mod((v->prefill_c[k] - 2.0), v->swath_height_cper_state[i][j][k]);
-                                       }
-                                       else {
-                                               v->max_partial_sw_c =dcn_bw_mod((v->prefill_c[k] + v->swath_height_cper_state[i][j][k] - 2.0), v->swath_height_cper_state[i][j][k]);
-                                       }
-                                       v->max_partial_sw_c =dcn_bw_max2(1.0, v->max_partial_sw_c);
-                                       v->prefetch_lines_c[k] = v->max_num_sw_c[k] * v->swath_height_cper_state[i][j][k] + v->max_partial_sw_c;
-                               }
-                               else {
-                                       v->prefetch_lines_c[k] = 0.0;
-                               }
-                               v->dst_x_after_scaler = 90.0 * v->pixel_clock[k] / (v->required_dispclk[i][j] / (j + 1)) + 42.0 * v->pixel_clock[k] / v->required_dispclk[i][j];
-                               if (v->no_of_dpp[i][j][k] > 1.0) {
-                                       v->dst_x_after_scaler = v->dst_x_after_scaler + v->scaler_rec_out_width[k] / 2.0;
-                               }
-                               if (v->output_format[k] == dcn_bw_420) {
-                                       v->dst_y_after_scaler = 1.0;
-                               }
-                               else {
-                                       v->dst_y_after_scaler = 0.0;
-                               }
-                               v->time_calc = 24.0 / v->projected_dcfclk_deep_sleep;
-                               v->v_update_offset[k][j] = dcn_bw_ceil2(v->htotal[k] / 4.0, 1.0);
-                               v->total_repeater_delay = v->max_inter_dcn_tile_repeaters * (2.0 / (v->required_dispclk[i][j] / (j + 1)) + 3.0 / v->required_dispclk[i][j]);
-                               v->v_update_width[k][j] = (14.0 / v->projected_dcfclk_deep_sleep + 12.0 / (v->required_dispclk[i][j] / (j + 1)) + v->total_repeater_delay) * v->pixel_clock[k];
-                               v->v_ready_offset[k][j] = dcn_bw_max2(150.0 / (v->required_dispclk[i][j] / (j + 1)), v->total_repeater_delay + 20.0 / v->projected_dcfclk_deep_sleep + 10.0 / (v->required_dispclk[i][j] / (j + 1))) * v->pixel_clock[k];
-                               v->time_setup = (v->v_update_offset[k][j] + v->v_update_width[k][j] + v->v_ready_offset[k][j]) / v->pixel_clock[k];
-                               v->extra_latency = v->urgent_round_trip_and_out_of_order_latency_per_state[i] + (v->total_number_of_active_dpp[i][j] * v->pixel_chunk_size_in_kbyte + v->total_number_of_dcc_active_dpp[i][j] * v->meta_chunk_size) * 1024.0 / v->return_bw_per_state[i];
-                               if (v->pte_enable == dcn_bw_yes) {
-                                       v->extra_latency = v->extra_latency + v->total_number_of_active_dpp[i][j] * v->pte_chunk_size * 1024.0 / v->return_bw_per_state[i];
-                               }
-                               if (v->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one == dcn_bw_yes) {
-                                       v->maximum_vstartup = v->vtotal[k] - v->vactive[k] - 1.0;
-                               }
-                               else {
-                                       v->maximum_vstartup = v->v_sync_plus_back_porch[k] - 1.0;
-                               }
-
-                               do {
-                                       v->line_times_for_prefetch[k] = v->maximum_vstartup - v->urgent_latency / (v->htotal[k] / v->pixel_clock[k]) - (v->time_calc + v->time_setup) / (v->htotal[k] / v->pixel_clock[k]) - (v->dst_y_after_scaler + v->dst_x_after_scaler / v->htotal[k]);
-                                       v->line_times_for_prefetch[k] =dcn_bw_floor2(4.0 * (v->line_times_for_prefetch[k] + 0.125), 1.0) / 4;
-                                       v->prefetch_bw[k] = (v->meta_pte_bytes_per_frame[k] + 2.0 * v->meta_row_bytes[k] + 2.0 * v->dpte_bytes_per_row[k] + v->prefetch_lines_y[k] * v->swath_width_yper_state[i][j][k] *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) + v->prefetch_lines_c[k] * v->swath_width_yper_state[i][j][k] / 2.0 *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0)) / (v->line_times_for_prefetch[k] * v->htotal[k] / v->pixel_clock[k]);
-
-                                       if (v->pte_enable == dcn_bw_yes && v->dcc_enable[k] == dcn_bw_yes) {
-                                               v->time_for_meta_pte_without_immediate_flip = dcn_bw_max3(
-                                                               v->meta_pte_bytes_frame[k] / v->prefetch_bw[k],
-                                                               v->extra_latency,
-                                                               v->htotal[k] / v->pixel_clock[k] / 4.0);
-                                       } else {
-                                               v->time_for_meta_pte_without_immediate_flip = v->htotal[k] / v->pixel_clock[k] / 4.0;
-                                       }
-
-                                       if (v->pte_enable == dcn_bw_yes || v->dcc_enable[k] == dcn_bw_yes) {
-                                               v->time_for_meta_and_dpte_row_without_immediate_flip = dcn_bw_max3((
-                                                               v->meta_row_bytes[k] + v->dpte_bytes_per_row[k]) / v->prefetch_bw[k],
-                                                               v->htotal[k] / v->pixel_clock[k] - v->time_for_meta_pte_without_immediate_flip,
-                                                               v->extra_latency);
-                                       } else {
-                                               v->time_for_meta_and_dpte_row_without_immediate_flip = dcn_bw_max2(
-                                                               v->htotal[k] / v->pixel_clock[k] - v->time_for_meta_pte_without_immediate_flip,
-                                                               v->extra_latency - v->time_for_meta_pte_with_immediate_flip);
-                                       }
-
-                                       v->lines_for_meta_pte_without_immediate_flip[k] =dcn_bw_floor2(4.0 * (v->time_for_meta_pte_without_immediate_flip / (v->htotal[k] / v->pixel_clock[k]) + 0.125), 1.0) / 4;
-                                       v->lines_for_meta_and_dpte_row_without_immediate_flip[k] =dcn_bw_floor2(4.0 * (v->time_for_meta_and_dpte_row_without_immediate_flip / (v->htotal[k] / v->pixel_clock[k]) + 0.125), 1.0) / 4;
-                                       v->maximum_vstartup = v->maximum_vstartup - 1;
-
-                                       if (v->lines_for_meta_pte_without_immediate_flip[k] < 32.0 && v->lines_for_meta_and_dpte_row_without_immediate_flip[k] < 16.0)
-                                               break;
-
-                               } while(1);
-                       }
-                       v->bw_available_for_immediate_flip = v->return_bw_per_state[i];
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               v->bw_available_for_immediate_flip = v->bw_available_for_immediate_flip -dcn_bw_max2(v->read_bandwidth[k], v->prefetch_bw[k]);
-                       }
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               v->total_immediate_flip_bytes[k] = 0.0;
-                               if ((v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
-                                       v->total_immediate_flip_bytes[k] = v->total_immediate_flip_bytes[k] + v->meta_pte_bytes_per_frame[k] + v->meta_row_bytes[k] + v->dpte_bytes_per_row[k];
-                               }
-                       }
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               if (v->pte_enable == dcn_bw_yes && v->dcc_enable[k] == dcn_bw_yes) {
-                                       v->time_for_meta_pte_with_immediate_flip =dcn_bw_max5(v->meta_pte_bytes_per_frame[k] / v->prefetch_bw[k], v->meta_pte_bytes_per_frame[k] * v->total_immediate_flip_bytes[k] / (v->bw_available_for_immediate_flip * (v->meta_pte_bytes_per_frame[k] + v->meta_row_bytes[k] + v->dpte_bytes_per_row[k])), v->extra_latency, v->urgent_latency, v->htotal[k] / v->pixel_clock[k] / 4.0);
-                               }
-                               else {
-                                       v->time_for_meta_pte_with_immediate_flip = v->htotal[k] / v->pixel_clock[k] / 4.0;
-                               }
-                               if (v->pte_enable == dcn_bw_yes || v->dcc_enable[k] == dcn_bw_yes) {
-                                       v->time_for_meta_and_dpte_row_with_immediate_flip =dcn_bw_max5((v->meta_row_bytes[k] + v->dpte_bytes_per_row[k]) / v->prefetch_bw[k], (v->meta_row_bytes[k] + v->dpte_bytes_per_row[k]) * v->total_immediate_flip_bytes[k] / (v->bw_available_for_immediate_flip * (v->meta_pte_bytes_per_frame[k] + v->meta_row_bytes[k] + v->dpte_bytes_per_row[k])), v->htotal[k] / v->pixel_clock[k] - v->time_for_meta_pte_with_immediate_flip, v->extra_latency, 2.0 * v->urgent_latency);
-                               }
-                               else {
-                                       v->time_for_meta_and_dpte_row_with_immediate_flip =dcn_bw_max2(v->htotal[k] / v->pixel_clock[k] - v->time_for_meta_pte_with_immediate_flip, v->extra_latency - v->time_for_meta_pte_with_immediate_flip);
-                               }
-                               v->lines_for_meta_pte_with_immediate_flip[k] =dcn_bw_floor2(4.0 * (v->time_for_meta_pte_with_immediate_flip / (v->htotal[k] / v->pixel_clock[k]) + 0.125), 1.0) / 4;
-                               v->lines_for_meta_and_dpte_row_with_immediate_flip[k] =dcn_bw_floor2(4.0 * (v->time_for_meta_and_dpte_row_with_immediate_flip / (v->htotal[k] / v->pixel_clock[k]) + 0.125), 1.0) / 4;
-                               v->line_times_to_request_prefetch_pixel_data_with_immediate_flip = v->line_times_for_prefetch[k] - v->lines_for_meta_pte_with_immediate_flip[k] - v->lines_for_meta_and_dpte_row_with_immediate_flip[k];
-                               v->line_times_to_request_prefetch_pixel_data_without_immediate_flip = v->line_times_for_prefetch[k] - v->lines_for_meta_pte_without_immediate_flip[k] - v->lines_for_meta_and_dpte_row_without_immediate_flip[k];
-                               if (v->line_times_to_request_prefetch_pixel_data_with_immediate_flip > 0.0) {
-                                       v->v_ratio_pre_ywith_immediate_flip[i][j][k] = v->prefetch_lines_y[k] / v->line_times_to_request_prefetch_pixel_data_with_immediate_flip;
-                                       if ((v->swath_height_yper_state[i][j][k] > 4.0)) {
-                                               if (v->line_times_to_request_prefetch_pixel_data_with_immediate_flip - (v->prefill_y[k] - 3.0) / 2.0 > 0.0) {
-                                                       v->v_ratio_pre_ywith_immediate_flip[i][j][k] =dcn_bw_max2(v->v_ratio_pre_ywith_immediate_flip[i][j][k], (v->max_num_sw_y[k] * v->swath_height_yper_state[i][j][k]) / (v->line_times_to_request_prefetch_pixel_data_with_immediate_flip - (v->prefill_y[k] - 3.0) / 2.0));
-                                               }
-                                               else {
-                                                       v->v_ratio_pre_ywith_immediate_flip[i][j][k] = 999999.0;
-                                               }
-                                       }
-                                       v->v_ratio_pre_cwith_immediate_flip[i][j][k] = v->prefetch_lines_c[k] / v->line_times_to_request_prefetch_pixel_data_with_immediate_flip;
-                                       if ((v->swath_height_cper_state[i][j][k] > 4.0)) {
-                                               if (v->line_times_to_request_prefetch_pixel_data_with_immediate_flip - (v->prefill_c[k] - 3.0) / 2.0 > 0.0) {
-                                                       v->v_ratio_pre_cwith_immediate_flip[i][j][k] =dcn_bw_max2(v->v_ratio_pre_cwith_immediate_flip[i][j][k], (v->max_num_sw_c[k] * v->swath_height_cper_state[i][j][k]) / (v->line_times_to_request_prefetch_pixel_data_with_immediate_flip - (v->prefill_c[k] - 3.0) / 2.0));
-                                               }
-                                               else {
-                                                       v->v_ratio_pre_cwith_immediate_flip[i][j][k] = 999999.0;
-                                               }
-                                       }
-                                       v->required_prefetch_pixel_data_bw_with_immediate_flip[i][j][k] = v->no_of_dpp[i][j][k] * (v->prefetch_lines_y[k] / v->line_times_to_request_prefetch_pixel_data_with_immediate_flip *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) + v->prefetch_lines_c[k] / v->line_times_to_request_prefetch_pixel_data_with_immediate_flip *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 2.0) * v->swath_width_yper_state[i][j][k] / (v->htotal[k] / v->pixel_clock[k]);
-                               }
-                               else {
-                                       v->v_ratio_pre_ywith_immediate_flip[i][j][k] = 999999.0;
-                                       v->v_ratio_pre_cwith_immediate_flip[i][j][k] = 999999.0;
-                                       v->required_prefetch_pixel_data_bw_with_immediate_flip[i][j][k] = 999999.0;
-                               }
-                               if (v->line_times_to_request_prefetch_pixel_data_without_immediate_flip > 0.0) {
-                                       v->v_ratio_pre_ywithout_immediate_flip[i][j][k] = v->prefetch_lines_y[k] / v->line_times_to_request_prefetch_pixel_data_without_immediate_flip;
-                                       if ((v->swath_height_yper_state[i][j][k] > 4.0)) {
-                                               if (v->line_times_to_request_prefetch_pixel_data_without_immediate_flip - (v->prefill_y[k] - 3.0) / 2.0 > 0.0) {
-                                                       v->v_ratio_pre_ywithout_immediate_flip[i][j][k] =dcn_bw_max2(v->v_ratio_pre_ywithout_immediate_flip[i][j][k], (v->max_num_sw_y[k] * v->swath_height_yper_state[i][j][k]) / (v->line_times_to_request_prefetch_pixel_data_without_immediate_flip - (v->prefill_y[k] - 3.0) / 2.0));
-                                               }
-                                               else {
-                                                       v->v_ratio_pre_ywithout_immediate_flip[i][j][k] = 999999.0;
-                                               }
-                                       }
-                                       v->v_ratio_pre_cwithout_immediate_flip[i][j][k] = v->prefetch_lines_c[k] / v->line_times_to_request_prefetch_pixel_data_without_immediate_flip;
-                                       if ((v->swath_height_cper_state[i][j][k] > 4.0)) {
-                                               if (v->line_times_to_request_prefetch_pixel_data_without_immediate_flip - (v->prefill_c[k] - 3.0) / 2.0 > 0.0) {
-                                                       v->v_ratio_pre_cwithout_immediate_flip[i][j][k] =dcn_bw_max2(v->v_ratio_pre_cwithout_immediate_flip[i][j][k], (v->max_num_sw_c[k] * v->swath_height_cper_state[i][j][k]) / (v->line_times_to_request_prefetch_pixel_data_without_immediate_flip - (v->prefill_c[k] - 3.0) / 2.0));
-                                               }
-                                               else {
-                                                       v->v_ratio_pre_cwithout_immediate_flip[i][j][k] = 999999.0;
-                                               }
-                                       }
-                                       v->required_prefetch_pixel_data_bw_without_immediate_flip[i][j][k] = v->no_of_dpp[i][j][k] * (v->prefetch_lines_y[k] / v->line_times_to_request_prefetch_pixel_data_without_immediate_flip *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) + v->prefetch_lines_c[k] / v->line_times_to_request_prefetch_pixel_data_without_immediate_flip *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 2.0) * v->swath_width_yper_state[i][j][k] / (v->htotal[k] / v->pixel_clock[k]);
-                               }
-                               else {
-                                       v->v_ratio_pre_ywithout_immediate_flip[i][j][k] = 999999.0;
-                                       v->v_ratio_pre_cwithout_immediate_flip[i][j][k] = 999999.0;
-                                       v->required_prefetch_pixel_data_bw_without_immediate_flip[i][j][k] = 999999.0;
-                               }
-                       }
-                       v->maximum_read_bandwidth_with_prefetch_with_immediate_flip = 0.0;
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               if ((v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
-                                       v->maximum_read_bandwidth_with_prefetch_with_immediate_flip = v->maximum_read_bandwidth_with_prefetch_with_immediate_flip +dcn_bw_max2(v->read_bandwidth[k], v->required_prefetch_pixel_data_bw_with_immediate_flip[i][j][k]) +dcn_bw_max2(v->meta_pte_bytes_per_frame[k] / (v->lines_for_meta_pte_with_immediate_flip[k] * v->htotal[k] / v->pixel_clock[k]), (v->meta_row_bytes[k] + v->dpte_bytes_per_row[k]) / (v->lines_for_meta_and_dpte_row_with_immediate_flip[k] * v->htotal[k] / v->pixel_clock[k]));
-                               }
-                               else {
-                                       v->maximum_read_bandwidth_with_prefetch_with_immediate_flip = v->maximum_read_bandwidth_with_prefetch_with_immediate_flip +dcn_bw_max2(v->read_bandwidth[k], v->required_prefetch_pixel_data_bw_without_immediate_flip[i][j][k]);
-                               }
-                       }
-                       v->maximum_read_bandwidth_with_prefetch_without_immediate_flip = 0.0;
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               v->maximum_read_bandwidth_with_prefetch_without_immediate_flip = v->maximum_read_bandwidth_with_prefetch_without_immediate_flip +dcn_bw_max2(v->read_bandwidth[k], v->required_prefetch_pixel_data_bw_without_immediate_flip[i][j][k]);
-                       }
-                       v->prefetch_supported_with_immediate_flip[i][j] = dcn_bw_yes;
-                       if (v->maximum_read_bandwidth_with_prefetch_with_immediate_flip > v->return_bw_per_state[i]) {
-                               v->prefetch_supported_with_immediate_flip[i][j] = dcn_bw_no;
-                       }
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               if (v->line_times_for_prefetch[k] < 2.0 || v->lines_for_meta_pte_with_immediate_flip[k] >= 8.0 || v->lines_for_meta_and_dpte_row_with_immediate_flip[k] >= 16.0) {
-                                       v->prefetch_supported_with_immediate_flip[i][j] = dcn_bw_no;
-                               }
-                       }
-                       v->prefetch_supported_without_immediate_flip[i][j] = dcn_bw_yes;
-                       if (v->maximum_read_bandwidth_with_prefetch_without_immediate_flip > v->return_bw_per_state[i]) {
-                               v->prefetch_supported_without_immediate_flip[i][j] = dcn_bw_no;
-                       }
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               if (v->line_times_for_prefetch[k] < 2.0 || v->lines_for_meta_pte_without_immediate_flip[k] >= 8.0 || v->lines_for_meta_and_dpte_row_without_immediate_flip[k] >= 16.0) {
-                                       v->prefetch_supported_without_immediate_flip[i][j] = dcn_bw_no;
-                               }
-                       }
-               }
-       }
-       for (i = 0; i <= number_of_states_plus_one; i++) {
-               for (j = 0; j <= 1; j++) {
-                       v->v_ratio_in_prefetch_supported_with_immediate_flip[i][j] = dcn_bw_yes;
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               if ((((v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10) && (v->v_ratio_pre_ywith_immediate_flip[i][j][k] > 4.0 || v->v_ratio_pre_cwith_immediate_flip[i][j][k] > 4.0)) || ((v->source_pixel_format[k] == dcn_bw_yuv420_sub_8 || v->source_pixel_format[k] == dcn_bw_yuv420_sub_10) && (v->v_ratio_pre_ywithout_immediate_flip[i][j][k] > 4.0 || v->v_ratio_pre_cwithout_immediate_flip[i][j][k] > 4.0)))) {
-                                       v->v_ratio_in_prefetch_supported_with_immediate_flip[i][j] = dcn_bw_no;
-                               }
-                       }
-                       v->v_ratio_in_prefetch_supported_without_immediate_flip[i][j] = dcn_bw_yes;
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               if ((v->v_ratio_pre_ywithout_immediate_flip[i][j][k] > 4.0 || v->v_ratio_pre_cwithout_immediate_flip[i][j][k] > 4.0)) {
-                                       v->v_ratio_in_prefetch_supported_without_immediate_flip[i][j] = dcn_bw_no;
-                               }
-                       }
-               }
-       }
-       /*mode support, voltage state and soc configuration*/
-
-       for (i = number_of_states_plus_one; i >= 0; i--) {
-               for (j = 0; j <= 1; j++) {
-                       if (v->scale_ratio_support == dcn_bw_yes && v->source_format_pixel_and_scan_support == dcn_bw_yes && v->viewport_size_support == dcn_bw_yes && v->bandwidth_support[i] == dcn_bw_yes && v->dio_support[i] == dcn_bw_yes && v->urgent_latency_support[i][j] == dcn_bw_yes && v->rob_support[i] == dcn_bw_yes && v->dispclk_dppclk_support[i][j] == dcn_bw_yes && v->total_available_pipes_support[i][j] == dcn_bw_yes && v->total_available_writeback_support == dcn_bw_yes && v->writeback_latency_support == dcn_bw_yes) {
-                               if (v->prefetch_supported_with_immediate_flip[i][j] == dcn_bw_yes && v->v_ratio_in_prefetch_supported_with_immediate_flip[i][j] == dcn_bw_yes) {
-                                       v->mode_support_with_immediate_flip[i][j] = dcn_bw_yes;
-                               }
-                               else {
-                                       v->mode_support_with_immediate_flip[i][j] = dcn_bw_no;
-                               }
-                               if (v->prefetch_supported_without_immediate_flip[i][j] == dcn_bw_yes && v->v_ratio_in_prefetch_supported_without_immediate_flip[i][j] == dcn_bw_yes) {
-                                       v->mode_support_without_immediate_flip[i][j] = dcn_bw_yes;
-                               }
-                               else {
-                                       v->mode_support_without_immediate_flip[i][j] = dcn_bw_no;
-                               }
-                       }
-                       else {
-                               v->mode_support_with_immediate_flip[i][j] = dcn_bw_no;
-                               v->mode_support_without_immediate_flip[i][j] = dcn_bw_no;
-                       }
-               }
-       }
-       for (i = number_of_states_plus_one; i >= 0; i--) {
-               if ((i == number_of_states_plus_one || v->mode_support_with_immediate_flip[i][1] == dcn_bw_yes || v->mode_support_with_immediate_flip[i][0] == dcn_bw_yes) && i >= v->voltage_override_level) {
-                       v->voltage_level_with_immediate_flip = i;
-               }
-       }
-       for (i = number_of_states_plus_one; i >= 0; i--) {
-               if ((i == number_of_states_plus_one || v->mode_support_without_immediate_flip[i][1] == dcn_bw_yes || v->mode_support_without_immediate_flip[i][0] == dcn_bw_yes) && i >= v->voltage_override_level) {
-                       v->voltage_level_without_immediate_flip = i;
-               }
-       }
-       if (v->voltage_level_with_immediate_flip == number_of_states_plus_one) {
-               v->immediate_flip_supported = dcn_bw_no;
-               v->voltage_level = v->voltage_level_without_immediate_flip;
-       }
-       else {
-               v->immediate_flip_supported = dcn_bw_yes;
-               v->voltage_level = v->voltage_level_with_immediate_flip;
-       }
-       v->dcfclk = v->dcfclk_per_state[v->voltage_level];
-       v->fabric_and_dram_bandwidth = v->fabric_and_dram_bandwidth_per_state[v->voltage_level];
-       for (j = 0; j <= 1; j++) {
-               v->required_dispclk_per_ratio[j] = v->required_dispclk[v->voltage_level][j];
-               for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                       v->dpp_per_plane_per_ratio[j][k] = v->no_of_dpp[v->voltage_level][j][k];
-               }
-               v->dispclk_dppclk_support_per_ratio[j] = v->dispclk_dppclk_support[v->voltage_level][j];
-       }
-       v->max_phyclk = v->phyclk_per_state[v->voltage_level];
-}
-void display_pipe_configuration(struct dcn_bw_internal_vars *v)
-{
-       int j;
-       int k;
-       /*display pipe configuration*/
-
-       for (j = 0; j <= 1; j++) {
-               v->total_number_of_active_dpp_per_ratio[j] = 0.0;
-               for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                       v->total_number_of_active_dpp_per_ratio[j] = v->total_number_of_active_dpp_per_ratio[j] + v->dpp_per_plane_per_ratio[j][k];
-               }
-       }
-       if ((v->dispclk_dppclk_support_per_ratio[0] == dcn_bw_yes && v->dispclk_dppclk_support_per_ratio[1] == dcn_bw_no) || (v->dispclk_dppclk_support_per_ratio[0] == v->dispclk_dppclk_support_per_ratio[1] && (v->total_number_of_active_dpp_per_ratio[0] < v->total_number_of_active_dpp_per_ratio[1] || (((v->total_number_of_active_dpp_per_ratio[0] == v->total_number_of_active_dpp_per_ratio[1]) && v->required_dispclk_per_ratio[0] <= 0.5 * v->required_dispclk_per_ratio[1]))))) {
-               v->dispclk_dppclk_ratio = 1;
-               v->final_error_message = v->error_message[0];
-       }
-       else {
-               v->dispclk_dppclk_ratio = 2;
-               v->final_error_message = v->error_message[1];
-       }
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               v->dpp_per_plane[k] = v->dpp_per_plane_per_ratio[v->dispclk_dppclk_ratio - 1][k];
-       }
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
-                       v->byte_per_pix_dety = 8.0;
-                       v->byte_per_pix_detc = 0.0;
-               }
-               else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_32) {
-                       v->byte_per_pix_dety = 4.0;
-                       v->byte_per_pix_detc = 0.0;
-               }
-               else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_16) {
-                       v->byte_per_pix_dety = 2.0;
-                       v->byte_per_pix_detc = 0.0;
-               }
-               else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
-                       v->byte_per_pix_dety = 1.0;
-                       v->byte_per_pix_detc = 2.0;
-               }
-               else {
-                       v->byte_per_pix_dety = 4.0f / 3.0f;
-                       v->byte_per_pix_detc = 8.0f / 3.0f;
-               }
-               if ((v->source_pixel_format[k] == dcn_bw_rgb_sub_64 || v->source_pixel_format[k] == dcn_bw_rgb_sub_32 || v->source_pixel_format[k] == dcn_bw_rgb_sub_16)) {
-                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                               v->read256_bytes_block_height_y = 1.0;
-                       }
-                       else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
-                               v->read256_bytes_block_height_y = 4.0;
-                       }
-                       else {
-                               v->read256_bytes_block_height_y = 8.0;
-                       }
-                       v->read256_bytes_block_width_y = 256.0 /dcn_bw_ceil2(v->byte_per_pix_dety, 1.0) / v->read256_bytes_block_height_y;
-                       v->read256_bytes_block_height_c = 0.0;
-                       v->read256_bytes_block_width_c = 0.0;
-               }
-               else {
-                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                               v->read256_bytes_block_height_y = 1.0;
-                               v->read256_bytes_block_height_c = 1.0;
-                       }
-                       else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
-                               v->read256_bytes_block_height_y = 16.0;
-                               v->read256_bytes_block_height_c = 8.0;
-                       }
-                       else {
-                               v->read256_bytes_block_height_y = 8.0;
-                               v->read256_bytes_block_height_c = 8.0;
-                       }
-                       v->read256_bytes_block_width_y = 256.0 /dcn_bw_ceil2(v->byte_per_pix_dety, 1.0) / v->read256_bytes_block_height_y;
-                       v->read256_bytes_block_width_c = 256.0 /dcn_bw_ceil2(v->byte_per_pix_detc, 2.0) / v->read256_bytes_block_height_c;
-               }
-               if (v->source_scan[k] == dcn_bw_hor) {
-                       v->maximum_swath_height_y = v->read256_bytes_block_height_y;
-                       v->maximum_swath_height_c = v->read256_bytes_block_height_c;
-               }
-               else {
-                       v->maximum_swath_height_y = v->read256_bytes_block_width_y;
-                       v->maximum_swath_height_c = v->read256_bytes_block_width_c;
-               }
-               if ((v->source_pixel_format[k] == dcn_bw_rgb_sub_64 || v->source_pixel_format[k] == dcn_bw_rgb_sub_32 || v->source_pixel_format[k] == dcn_bw_rgb_sub_16)) {
-                       if (v->source_surface_mode[k] == dcn_bw_sw_linear || (v->source_pixel_format[k] == dcn_bw_rgb_sub_64 && (v->source_surface_mode[k] == dcn_bw_sw_4_kb_s || v->source_surface_mode[k] == dcn_bw_sw_4_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_var_s || v->source_surface_mode[k] == dcn_bw_sw_var_s_x) && v->source_scan[k] == dcn_bw_hor)) {
-                               v->minimum_swath_height_y = v->maximum_swath_height_y;
-                       }
-                       else {
-                               v->minimum_swath_height_y = v->maximum_swath_height_y / 2.0;
-                       }
-                       v->minimum_swath_height_c = v->maximum_swath_height_c;
-               }
-               else {
-                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                               v->minimum_swath_height_y = v->maximum_swath_height_y;
-                               v->minimum_swath_height_c = v->maximum_swath_height_c;
-                       }
-                       else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8 && v->source_scan[k] == dcn_bw_hor) {
-                               v->minimum_swath_height_y = v->maximum_swath_height_y / 2.0;
-                               if (v->bug_forcing_luma_and_chroma_request_to_same_size_fixed == dcn_bw_yes) {
-                                       v->minimum_swath_height_c = v->maximum_swath_height_c;
-                               }
-                               else {
-                                       v->minimum_swath_height_c = v->maximum_swath_height_c / 2.0;
-                               }
-                       }
-                       else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10 && v->source_scan[k] == dcn_bw_hor) {
-                               v->minimum_swath_height_c = v->maximum_swath_height_c / 2.0;
-                               if (v->bug_forcing_luma_and_chroma_request_to_same_size_fixed == dcn_bw_yes) {
-                                       v->minimum_swath_height_y = v->maximum_swath_height_y;
-                               }
-                               else {
-                                       v->minimum_swath_height_y = v->maximum_swath_height_y / 2.0;
-                               }
-                       }
-                       else {
-                               v->minimum_swath_height_y = v->maximum_swath_height_y;
-                               v->minimum_swath_height_c = v->maximum_swath_height_c;
-                       }
-               }
-               if (v->source_scan[k] == dcn_bw_hor) {
-                       v->swath_width = v->viewport_width[k] / v->dpp_per_plane[k];
-               }
-               else {
-                       v->swath_width = v->viewport_height[k] / v->dpp_per_plane[k];
-               }
-               v->swath_width_granularity_y = 256.0 /dcn_bw_ceil2(v->byte_per_pix_dety, 1.0) / v->maximum_swath_height_y;
-               v->rounded_up_max_swath_size_bytes_y = (dcn_bw_ceil2(v->swath_width - 1.0, v->swath_width_granularity_y) + v->swath_width_granularity_y) * v->byte_per_pix_dety * v->maximum_swath_height_y;
-               if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10) {
-                       v->rounded_up_max_swath_size_bytes_y =dcn_bw_ceil2(v->rounded_up_max_swath_size_bytes_y, 256.0) + 256;
-               }
-               if (v->maximum_swath_height_c > 0.0) {
-                       v->swath_width_granularity_c = 256.0 /dcn_bw_ceil2(v->byte_per_pix_detc, 2.0) / v->maximum_swath_height_c;
-               }
-               v->rounded_up_max_swath_size_bytes_c = (dcn_bw_ceil2(v->swath_width / 2.0 - 1.0, v->swath_width_granularity_c) + v->swath_width_granularity_c) * v->byte_per_pix_detc * v->maximum_swath_height_c;
-               if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10) {
-                       v->rounded_up_max_swath_size_bytes_c =dcn_bw_ceil2(v->rounded_up_max_swath_size_bytes_c, 256.0) + 256;
-               }
-               if (v->rounded_up_max_swath_size_bytes_y + v->rounded_up_max_swath_size_bytes_c <= v->det_buffer_size_in_kbyte * 1024.0 / 2.0) {
-                       v->swath_height_y[k] = v->maximum_swath_height_y;
-                       v->swath_height_c[k] = v->maximum_swath_height_c;
-               }
-               else {
-                       v->swath_height_y[k] = v->minimum_swath_height_y;
-                       v->swath_height_c[k] = v->minimum_swath_height_c;
-               }
-               if (v->swath_height_c[k] == 0.0) {
-                       v->det_buffer_size_y[k] = v->det_buffer_size_in_kbyte * 1024.0;
-                       v->det_buffer_size_c[k] = 0.0;
-               }
-               else if (v->swath_height_y[k] <= v->swath_height_c[k]) {
-                       v->det_buffer_size_y[k] = v->det_buffer_size_in_kbyte * 1024.0 / 2.0;
-                       v->det_buffer_size_c[k] = v->det_buffer_size_in_kbyte * 1024.0 / 2.0;
-               }
-               else {
-                       v->det_buffer_size_y[k] = v->det_buffer_size_in_kbyte * 1024.0 * 2.0 / 3.0;
-                       v->det_buffer_size_c[k] = v->det_buffer_size_in_kbyte * 1024.0 / 3.0;
-               }
-       }
-}
-void dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(struct dcn_bw_internal_vars *v)
-{
-       int k;
-       /*dispclk and dppclk calculation*/
-
-       v->dispclk_with_ramping = 0.0;
-       v->dispclk_without_ramping = 0.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->h_ratio[k] > 1.0) {
-                       v->pscl_throughput[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput * v->h_ratio[k] /dcn_bw_ceil2(v->htaps[k] / 6.0, 1.0));
-               }
-               else {
-                       v->pscl_throughput[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput);
-               }
-               v->dppclk_using_single_dpp_luma = v->pixel_clock[k] *dcn_bw_max3(v->vtaps[k] / 6.0 *dcn_bw_min2(1.0, v->h_ratio[k]), v->h_ratio[k] * v->v_ratio[k] / v->pscl_throughput[k], 1.0);
-               if ((v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
-                       v->pscl_throughput_chroma[k] = 0.0;
-                       v->dppclk_using_single_dpp = v->dppclk_using_single_dpp_luma;
-               }
-               else {
-                       if (v->h_ratio[k] > 1.0) {
-                               v->pscl_throughput_chroma[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput * v->h_ratio[k] / 2.0 /dcn_bw_ceil2(v->hta_pschroma[k] / 6.0, 1.0));
-                       }
-                       else {
-                               v->pscl_throughput_chroma[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput);
-                       }
-                       v->dppclk_using_single_dpp_chroma = v->pixel_clock[k] *dcn_bw_max3(v->vta_pschroma[k] / 6.0 *dcn_bw_min2(1.0, v->h_ratio[k] / 2.0), v->h_ratio[k] * v->v_ratio[k] / 4.0 / v->pscl_throughput_chroma[k], 1.0);
-                       v->dppclk_using_single_dpp =dcn_bw_max2(v->dppclk_using_single_dpp_luma, v->dppclk_using_single_dpp_chroma);
-               }
-               if (v->odm_capable == dcn_bw_yes) {
-                       v->dispclk_with_ramping =dcn_bw_max2(v->dispclk_with_ramping,dcn_bw_max2(v->dppclk_using_single_dpp / v->dpp_per_plane[k] * v->dispclk_dppclk_ratio, v->pixel_clock[k] / v->dpp_per_plane[k]) * (1.0 + v->downspreading / 100.0) * (1.0 + v->dispclk_ramping_margin / 100.0));
-                       v->dispclk_without_ramping =dcn_bw_max2(v->dispclk_without_ramping,dcn_bw_max2(v->dppclk_using_single_dpp / v->dpp_per_plane[k] * v->dispclk_dppclk_ratio, v->pixel_clock[k] / v->dpp_per_plane[k]) * (1.0 + v->downspreading / 100.0));
-               }
-               else {
-                       v->dispclk_with_ramping =dcn_bw_max2(v->dispclk_with_ramping,dcn_bw_max2(v->dppclk_using_single_dpp / v->dpp_per_plane[k] * v->dispclk_dppclk_ratio, v->pixel_clock[k]) * (1.0 + v->downspreading / 100.0) * (1.0 + v->dispclk_ramping_margin / 100.0));
-                       v->dispclk_without_ramping =dcn_bw_max2(v->dispclk_without_ramping,dcn_bw_max2(v->dppclk_using_single_dpp / v->dpp_per_plane[k] * v->dispclk_dppclk_ratio, v->pixel_clock[k]) * (1.0 + v->downspreading / 100.0));
-               }
-       }
-       if (v->dispclk_without_ramping > v->max_dispclk[number_of_states]) {
-               v->dispclk = v->dispclk_without_ramping;
-       }
-       else if (v->dispclk_with_ramping > v->max_dispclk[number_of_states]) {
-               v->dispclk = v->max_dispclk[number_of_states];
-       }
-       else {
-               v->dispclk = v->dispclk_with_ramping;
-       }
-       v->dppclk = v->dispclk / v->dispclk_dppclk_ratio;
-       /*urgent watermark*/
-
-       v->return_bandwidth_to_dcn =dcn_bw_min2(v->return_bus_width * v->dcfclk, v->fabric_and_dram_bandwidth * 1000.0 * v->percent_of_ideal_drambw_received_after_urg_latency / 100.0);
-       v->dcc_enabled_any_plane = dcn_bw_no;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->dcc_enable[k] == dcn_bw_yes) {
-                       v->dcc_enabled_any_plane = dcn_bw_yes;
-               }
-       }
-       v->return_bw = v->return_bandwidth_to_dcn;
-       if (v->dcc_enabled_any_plane == dcn_bw_yes && v->return_bandwidth_to_dcn > v->dcfclk * v->return_bus_width / 4.0) {
-               v->return_bw =dcn_bw_min2(v->return_bw, v->return_bandwidth_to_dcn * 4.0 * (1.0 - v->urgent_latency / ((v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 / (v->return_bandwidth_to_dcn - v->dcfclk * v->return_bus_width / 4.0) + v->urgent_latency)));
-       }
-       v->critical_compression = 2.0 * v->return_bus_width * v->dcfclk * v->urgent_latency / (v->return_bandwidth_to_dcn * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0);
-       if (v->dcc_enabled_any_plane == dcn_bw_yes && v->critical_compression > 1.0 && v->critical_compression < 4.0) {
-               v->return_bw =dcn_bw_min2(v->return_bw, dcn_bw_pow(4.0 * v->return_bandwidth_to_dcn * (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 * v->return_bus_width * v->dcfclk * v->urgent_latency / (v->return_bandwidth_to_dcn * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0), 2));
-       }
-       v->return_bandwidth_to_dcn =dcn_bw_min2(v->return_bus_width * v->dcfclk, v->fabric_and_dram_bandwidth * 1000.0);
-       if (v->dcc_enabled_any_plane == dcn_bw_yes && v->return_bandwidth_to_dcn > v->dcfclk * v->return_bus_width / 4.0) {
-               v->return_bw =dcn_bw_min2(v->return_bw, v->return_bandwidth_to_dcn * 4.0 * (1.0 - v->urgent_latency / ((v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 / (v->return_bandwidth_to_dcn - v->dcfclk * v->return_bus_width / 4.0) + v->urgent_latency)));
-       }
-       v->critical_compression = 2.0 * v->return_bus_width * v->dcfclk * v->urgent_latency / (v->return_bandwidth_to_dcn * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0);
-       if (v->dcc_enabled_any_plane == dcn_bw_yes && v->critical_compression > 1.0 && v->critical_compression < 4.0) {
-               v->return_bw =dcn_bw_min2(v->return_bw, dcn_bw_pow(4.0 * v->return_bandwidth_to_dcn * (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 * v->return_bus_width * v->dcfclk * v->urgent_latency / (v->return_bandwidth_to_dcn * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0), 2));
-       }
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->source_scan[k] == dcn_bw_hor) {
-                       v->swath_width_y[k] = v->viewport_width[k] / v->dpp_per_plane[k];
-               }
-               else {
-                       v->swath_width_y[k] = v->viewport_height[k] / v->dpp_per_plane[k];
-               }
-       }
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
-                       v->byte_per_pixel_dety[k] = 8.0;
-                       v->byte_per_pixel_detc[k] = 0.0;
-               }
-               else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_32) {
-                       v->byte_per_pixel_dety[k] = 4.0;
-                       v->byte_per_pixel_detc[k] = 0.0;
-               }
-               else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_16) {
-                       v->byte_per_pixel_dety[k] = 2.0;
-                       v->byte_per_pixel_detc[k] = 0.0;
-               }
-               else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
-                       v->byte_per_pixel_dety[k] = 1.0;
-                       v->byte_per_pixel_detc[k] = 2.0;
-               }
-               else {
-                       v->byte_per_pixel_dety[k] = 4.0f / 3.0f;
-                       v->byte_per_pixel_detc[k] = 8.0f / 3.0f;
-               }
-       }
-       v->total_data_read_bandwidth = 0.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               v->read_bandwidth_plane_luma[k] = v->swath_width_y[k] * v->dpp_per_plane[k] *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / (v->htotal[k] / v->pixel_clock[k]) * v->v_ratio[k];
-               v->read_bandwidth_plane_chroma[k] = v->swath_width_y[k] / 2.0 * v->dpp_per_plane[k] *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / (v->htotal[k] / v->pixel_clock[k]) * v->v_ratio[k] / 2.0;
-               v->total_data_read_bandwidth = v->total_data_read_bandwidth + v->read_bandwidth_plane_luma[k] + v->read_bandwidth_plane_chroma[k];
-       }
-       v->total_active_dpp = 0.0;
-       v->total_dcc_active_dpp = 0.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               v->total_active_dpp = v->total_active_dpp + v->dpp_per_plane[k];
-               if (v->dcc_enable[k] == dcn_bw_yes) {
-                       v->total_dcc_active_dpp = v->total_dcc_active_dpp + v->dpp_per_plane[k];
-               }
-       }
-       v->urgent_round_trip_and_out_of_order_latency = (v->round_trip_ping_latency_cycles + 32.0) / v->dcfclk + v->urgent_out_of_order_return_per_channel * v->number_of_channels / v->return_bw;
-       v->last_pixel_of_line_extra_watermark = 0.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->v_ratio[k] <= 1.0) {
-                       v->display_pipe_line_delivery_time_luma[k] = v->swath_width_y[k] * v->dpp_per_plane[k] / v->h_ratio[k] / v->pixel_clock[k];
-               }
-               else {
-                       v->display_pipe_line_delivery_time_luma[k] = v->swath_width_y[k] / v->pscl_throughput[k] / v->dppclk;
-               }
-               v->data_fabric_line_delivery_time_luma = v->swath_width_y[k] * v->swath_height_y[k] *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / (v->return_bw * v->read_bandwidth_plane_luma[k] / v->dpp_per_plane[k] / v->total_data_read_bandwidth);
-               v->last_pixel_of_line_extra_watermark =dcn_bw_max2(v->last_pixel_of_line_extra_watermark, v->data_fabric_line_delivery_time_luma - v->display_pipe_line_delivery_time_luma[k]);
-               if (v->byte_per_pixel_detc[k] == 0.0) {
-                       v->display_pipe_line_delivery_time_chroma[k] = 0.0;
-               }
-               else {
-                       if (v->v_ratio[k] / 2.0 <= 1.0) {
-                               v->display_pipe_line_delivery_time_chroma[k] = v->swath_width_y[k] / 2.0 * v->dpp_per_plane[k] / (v->h_ratio[k] / 2.0) / v->pixel_clock[k];
-                       }
-                       else {
-                               v->display_pipe_line_delivery_time_chroma[k] = v->swath_width_y[k] / 2.0 / v->pscl_throughput_chroma[k] / v->dppclk;
-                       }
-                       v->data_fabric_line_delivery_time_chroma = v->swath_width_y[k] / 2.0 * v->swath_height_c[k] *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / (v->return_bw * v->read_bandwidth_plane_chroma[k] / v->dpp_per_plane[k] / v->total_data_read_bandwidth);
-                       v->last_pixel_of_line_extra_watermark =dcn_bw_max2(v->last_pixel_of_line_extra_watermark, v->data_fabric_line_delivery_time_chroma - v->display_pipe_line_delivery_time_chroma[k]);
-               }
-       }
-       v->urgent_extra_latency = v->urgent_round_trip_and_out_of_order_latency + (v->total_active_dpp * v->pixel_chunk_size_in_kbyte + v->total_dcc_active_dpp * v->meta_chunk_size) * 1024.0 / v->return_bw;
-       if (v->pte_enable == dcn_bw_yes) {
-               v->urgent_extra_latency = v->urgent_extra_latency + v->total_active_dpp * v->pte_chunk_size * 1024.0 / v->return_bw;
-       }
-       v->urgent_watermark = v->urgent_latency + v->last_pixel_of_line_extra_watermark + v->urgent_extra_latency;
-       v->ptemeta_urgent_watermark = v->urgent_watermark + 2.0 * v->urgent_latency;
-       /*nb p-state/dram clock change watermark*/
-
-       v->dram_clock_change_watermark = v->dram_clock_change_latency + v->urgent_watermark;
-       v->total_active_writeback = 0.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->output[k] == dcn_bw_writeback) {
-                       v->total_active_writeback = v->total_active_writeback + 1.0;
-               }
-       }
-       if (v->total_active_writeback <= 1.0) {
-               v->writeback_dram_clock_change_watermark = v->dram_clock_change_latency + v->write_back_latency;
-       }
-       else {
-               v->writeback_dram_clock_change_watermark = v->dram_clock_change_latency + v->write_back_latency + v->writeback_chunk_size * 1024.0 / 32.0 / v->socclk;
-       }
-       /*stutter efficiency*/
-
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               v->lines_in_dety[k] = v->det_buffer_size_y[k] / v->byte_per_pixel_dety[k] / v->swath_width_y[k];
-               v->lines_in_dety_rounded_down_to_swath[k] =dcn_bw_floor2(v->lines_in_dety[k], v->swath_height_y[k]);
-               v->full_det_buffering_time_y[k] = v->lines_in_dety_rounded_down_to_swath[k] * (v->htotal[k] / v->pixel_clock[k]) / v->v_ratio[k];
-               if (v->byte_per_pixel_detc[k] > 0.0) {
-                       v->lines_in_detc[k] = v->det_buffer_size_c[k] / v->byte_per_pixel_detc[k] / (v->swath_width_y[k] / 2.0);
-                       v->lines_in_detc_rounded_down_to_swath[k] =dcn_bw_floor2(v->lines_in_detc[k], v->swath_height_c[k]);
-                       v->full_det_buffering_time_c[k] = v->lines_in_detc_rounded_down_to_swath[k] * (v->htotal[k] / v->pixel_clock[k]) / (v->v_ratio[k] / 2.0);
-               }
-               else {
-                       v->lines_in_detc[k] = 0.0;
-                       v->lines_in_detc_rounded_down_to_swath[k] = 0.0;
-                       v->full_det_buffering_time_c[k] = 999999.0;
-               }
-       }
-       v->min_full_det_buffering_time = 999999.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->full_det_buffering_time_y[k] < v->min_full_det_buffering_time) {
-                       v->min_full_det_buffering_time = v->full_det_buffering_time_y[k];
-                       v->frame_time_for_min_full_det_buffering_time = v->vtotal[k] * v->htotal[k] / v->pixel_clock[k];
-               }
-               if (v->full_det_buffering_time_c[k] < v->min_full_det_buffering_time) {
-                       v->min_full_det_buffering_time = v->full_det_buffering_time_c[k];
-                       v->frame_time_for_min_full_det_buffering_time = v->vtotal[k] * v->htotal[k] / v->pixel_clock[k];
-               }
-       }
-       v->average_read_bandwidth_gbyte_per_second = 0.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->dcc_enable[k] == dcn_bw_yes) {
-                       v->average_read_bandwidth_gbyte_per_second = v->average_read_bandwidth_gbyte_per_second + v->read_bandwidth_plane_luma[k] / v->dcc_rate[k] / 1000.0 + v->read_bandwidth_plane_chroma[k] / v->dcc_rate[k] / 1000.0;
-               }
-               else {
-                       v->average_read_bandwidth_gbyte_per_second = v->average_read_bandwidth_gbyte_per_second + v->read_bandwidth_plane_luma[k] / 1000.0 + v->read_bandwidth_plane_chroma[k] / 1000.0;
-               }
-               if (v->dcc_enable[k] == dcn_bw_yes) {
-                       v->average_read_bandwidth_gbyte_per_second = v->average_read_bandwidth_gbyte_per_second + v->read_bandwidth_plane_luma[k] / 1000.0 / 256.0 + v->read_bandwidth_plane_chroma[k] / 1000.0 / 256.0;
-               }
-               if (v->pte_enable == dcn_bw_yes) {
-                       v->average_read_bandwidth_gbyte_per_second = v->average_read_bandwidth_gbyte_per_second + v->read_bandwidth_plane_luma[k] / 1000.0 / 512.0 + v->read_bandwidth_plane_chroma[k] / 1000.0 / 512.0;
-               }
-       }
-       v->part_of_burst_that_fits_in_rob =dcn_bw_min2(v->min_full_det_buffering_time * v->total_data_read_bandwidth, v->rob_buffer_size_in_kbyte * 1024.0 * v->total_data_read_bandwidth / (v->average_read_bandwidth_gbyte_per_second * 1000.0));
-       v->stutter_burst_time = v->part_of_burst_that_fits_in_rob * (v->average_read_bandwidth_gbyte_per_second * 1000.0) / v->total_data_read_bandwidth / v->return_bw + (v->min_full_det_buffering_time * v->total_data_read_bandwidth - v->part_of_burst_that_fits_in_rob) / (v->dcfclk * 64.0);
-       if (v->total_active_writeback == 0.0) {
-               v->stutter_efficiency_not_including_vblank = (1.0 - (v->sr_exit_time + v->stutter_burst_time) / v->min_full_det_buffering_time) * 100.0;
-       }
-       else {
-               v->stutter_efficiency_not_including_vblank = 0.0;
-       }
-       v->smallest_vblank = 999999.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->synchronized_vblank == dcn_bw_yes || v->number_of_active_planes == 1) {
-                       v->v_blank_time = (v->vtotal[k] - v->vactive[k]) * v->htotal[k] / v->pixel_clock[k];
-               }
-               else {
-                       v->v_blank_time = 0.0;
-               }
-               v->smallest_vblank =dcn_bw_min2(v->smallest_vblank, v->v_blank_time);
-       }
-       v->stutter_efficiency = (v->stutter_efficiency_not_including_vblank / 100.0 * (v->frame_time_for_min_full_det_buffering_time - v->smallest_vblank) + v->smallest_vblank) / v->frame_time_for_min_full_det_buffering_time * 100.0;
-       /*dcfclk deep sleep*/
-
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->byte_per_pixel_detc[k] > 0.0) {
-                       v->dcfclk_deep_sleep_per_plane[k] =dcn_bw_max2(1.1 * v->swath_width_y[k] *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / 32.0 / v->display_pipe_line_delivery_time_luma[k], 1.1 * v->swath_width_y[k] / 2.0 *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / 32.0 / v->display_pipe_line_delivery_time_chroma[k]);
-               }
-               else {
-                       v->dcfclk_deep_sleep_per_plane[k] = 1.1 * v->swath_width_y[k] *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / 64.0 / v->display_pipe_line_delivery_time_luma[k];
-               }
-               v->dcfclk_deep_sleep_per_plane[k] =dcn_bw_max2(v->dcfclk_deep_sleep_per_plane[k], v->pixel_clock[k] / 16.0);
-       }
-       v->dcf_clk_deep_sleep = 8.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               v->dcf_clk_deep_sleep =dcn_bw_max2(v->dcf_clk_deep_sleep, v->dcfclk_deep_sleep_per_plane[k]);
-       }
-       /*stutter watermark*/
-
-       v->stutter_exit_watermark = v->sr_exit_time + v->last_pixel_of_line_extra_watermark + v->urgent_extra_latency + 10.0 / v->dcf_clk_deep_sleep;
-       v->stutter_enter_plus_exit_watermark = v->sr_enter_plus_exit_time + v->last_pixel_of_line_extra_watermark + v->urgent_extra_latency;
-       /*urgent latency supported*/
-
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               v->effective_det_plus_lb_lines_luma =dcn_bw_floor2(v->lines_in_dety[k] +dcn_bw_min2(v->lines_in_dety[k] * v->dppclk * v->byte_per_pixel_dety[k] * v->pscl_throughput[k] / (v->return_bw / v->dpp_per_plane[k]), v->effective_lb_latency_hiding_source_lines_luma), v->swath_height_y[k]);
-               v->urgent_latency_support_us_luma = v->effective_det_plus_lb_lines_luma * (v->htotal[k] / v->pixel_clock[k]) / v->v_ratio[k] - v->effective_det_plus_lb_lines_luma * v->swath_width_y[k] * v->byte_per_pixel_dety[k] / (v->return_bw / v->dpp_per_plane[k]);
-               if (v->byte_per_pixel_detc[k] > 0.0) {
-                       v->effective_det_plus_lb_lines_chroma =dcn_bw_floor2(v->lines_in_detc[k] +dcn_bw_min2(v->lines_in_detc[k] * v->dppclk * v->byte_per_pixel_detc[k] * v->pscl_throughput_chroma[k] / (v->return_bw / v->dpp_per_plane[k]), v->effective_lb_latency_hiding_source_lines_chroma), v->swath_height_c[k]);
-                       v->urgent_latency_support_us_chroma = v->effective_det_plus_lb_lines_chroma * (v->htotal[k] / v->pixel_clock[k]) / (v->v_ratio[k] / 2.0) - v->effective_det_plus_lb_lines_chroma * (v->swath_width_y[k] / 2.0) * v->byte_per_pixel_detc[k] / (v->return_bw / v->dpp_per_plane[k]);
-                       v->urgent_latency_support_us[k] =dcn_bw_min2(v->urgent_latency_support_us_luma, v->urgent_latency_support_us_chroma);
-               }
-               else {
-                       v->urgent_latency_support_us[k] = v->urgent_latency_support_us_luma;
-               }
-       }
-       v->min_urgent_latency_support_us = 999999.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               v->min_urgent_latency_support_us =dcn_bw_min2(v->min_urgent_latency_support_us, v->urgent_latency_support_us[k]);
-       }
-       /*non-urgent latency tolerance*/
-
-       v->non_urgent_latency_tolerance = v->min_urgent_latency_support_us - v->urgent_watermark;
-       /*prefetch*/
-
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if ((v->source_pixel_format[k] == dcn_bw_rgb_sub_64 || v->source_pixel_format[k] == dcn_bw_rgb_sub_32 || v->source_pixel_format[k] == dcn_bw_rgb_sub_16)) {
-                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                               v->block_height256_bytes_y = 1.0;
-                       }
-                       else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
-                               v->block_height256_bytes_y = 4.0;
-                       }
-                       else {
-                               v->block_height256_bytes_y = 8.0;
-                       }
-                       v->block_height256_bytes_c = 0.0;
-               }
-               else {
-                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                               v->block_height256_bytes_y = 1.0;
-                               v->block_height256_bytes_c = 1.0;
-                       }
-                       else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
-                               v->block_height256_bytes_y = 16.0;
-                               v->block_height256_bytes_c = 8.0;
-                       }
-                       else {
-                               v->block_height256_bytes_y = 8.0;
-                               v->block_height256_bytes_c = 8.0;
-                       }
-               }
-               if (v->dcc_enable[k] == dcn_bw_yes) {
-                       v->meta_request_width_y = 64.0 * 256.0 /dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / (8.0 * v->block_height256_bytes_y);
-                       v->meta_surf_width_y =dcn_bw_ceil2(v->swath_width_y[k] - 1.0, v->meta_request_width_y) + v->meta_request_width_y;
-                       v->meta_surf_height_y =dcn_bw_ceil2(v->viewport_height[k] - 1.0, 8.0 * v->block_height256_bytes_y) + 8.0 * v->block_height256_bytes_y;
-                       if (v->pte_enable == dcn_bw_yes) {
-                               v->meta_pte_bytes_frame_y = (dcn_bw_ceil2((v->meta_surf_width_y * v->meta_surf_height_y *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / 256.0 - 4096.0) / 8.0 / 4096.0, 1.0) + 1) * 64.0;
-                       }
-                       else {
-                               v->meta_pte_bytes_frame_y = 0.0;
-                       }
-                       if (v->source_scan[k] == dcn_bw_hor) {
-                               v->meta_row_byte_y = v->meta_surf_width_y * 8.0 * v->block_height256_bytes_y *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / 256.0;
-                       }
-                       else {
-                               v->meta_row_byte_y = v->meta_surf_height_y * v->meta_request_width_y *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / 256.0;
-                       }
-               }
-               else {
-                       v->meta_pte_bytes_frame_y = 0.0;
-                       v->meta_row_byte_y = 0.0;
-               }
-               if (v->pte_enable == dcn_bw_yes) {
-                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                               v->macro_tile_size_byte_y = 256.0;
-                               v->macro_tile_height_y = 1.0;
-                       }
-                       else if (v->source_surface_mode[k] == dcn_bw_sw_4_kb_s || v->source_surface_mode[k] == dcn_bw_sw_4_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d_x) {
-                               v->macro_tile_size_byte_y = 4096.0;
-                               v->macro_tile_height_y = 4.0 * v->block_height256_bytes_y;
-                       }
-                       else if (v->source_surface_mode[k] == dcn_bw_sw_64_kb_s || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_x) {
-                               v->macro_tile_size_byte_y = 64.0 * 1024;
-                               v->macro_tile_height_y = 16.0 * v->block_height256_bytes_y;
-                       }
-                       else {
-                               v->macro_tile_size_byte_y = 256.0 * 1024;
-                               v->macro_tile_height_y = 32.0 * v->block_height256_bytes_y;
-                       }
-                       if (v->macro_tile_size_byte_y <= 65536.0) {
-                               v->pixel_pte_req_height_y = v->macro_tile_height_y;
-                       }
-                       else {
-                               v->pixel_pte_req_height_y = 16.0 * v->block_height256_bytes_y;
-                       }
-                       v->pixel_pte_req_width_y = 4096.0 /dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / v->pixel_pte_req_height_y * 8;
-                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                               v->pixel_pte_bytes_per_row_y = 64.0 * (dcn_bw_ceil2((v->swath_width_y[k] *dcn_bw_min2(128.0, dcn_bw_pow(2.0,dcn_bw_floor2(dcn_bw_log(v->pte_buffer_size_in_requests * v->pixel_pte_req_width_y / v->swath_width_y[k], 2.0), 1.0))) - 1.0) / v->pixel_pte_req_width_y, 1.0) + 1);
-                       }
-                       else if (v->source_scan[k] == dcn_bw_hor) {
-                               v->pixel_pte_bytes_per_row_y = 64.0 * (dcn_bw_ceil2((v->swath_width_y[k] - 1.0) / v->pixel_pte_req_width_y, 1.0) + 1);
-                       }
-                       else {
-                               v->pixel_pte_bytes_per_row_y = 64.0 * (dcn_bw_ceil2((v->viewport_height[k] - 1.0) / v->pixel_pte_req_height_y, 1.0) + 1);
-                       }
-               }
-               else {
-                       v->pixel_pte_bytes_per_row_y = 0.0;
-               }
-               if ((v->source_pixel_format[k] != dcn_bw_rgb_sub_64 && v->source_pixel_format[k] != dcn_bw_rgb_sub_32 && v->source_pixel_format[k] != dcn_bw_rgb_sub_16)) {
-                       if (v->dcc_enable[k] == dcn_bw_yes) {
-                               v->meta_request_width_c = 64.0 * 256.0 /dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / (8.0 * v->block_height256_bytes_c);
-                               v->meta_surf_width_c =dcn_bw_ceil2(v->swath_width_y[k] / 2.0 - 1.0, v->meta_request_width_c) + v->meta_request_width_c;
-                               v->meta_surf_height_c =dcn_bw_ceil2(v->viewport_height[k] / 2.0 - 1.0, 8.0 * v->block_height256_bytes_c) + 8.0 * v->block_height256_bytes_c;
-                               if (v->pte_enable == dcn_bw_yes) {
-                                       v->meta_pte_bytes_frame_c = (dcn_bw_ceil2((v->meta_surf_width_c * v->meta_surf_height_c *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / 256.0 - 4096.0) / 8.0 / 4096.0, 1.0) + 1) * 64.0;
-                               }
-                               else {
-                                       v->meta_pte_bytes_frame_c = 0.0;
-                               }
-                               if (v->source_scan[k] == dcn_bw_hor) {
-                                       v->meta_row_byte_c = v->meta_surf_width_c * 8.0 * v->block_height256_bytes_c *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / 256.0;
-                               }
-                               else {
-                                       v->meta_row_byte_c = v->meta_surf_height_c * v->meta_request_width_c *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / 256.0;
-                               }
-                       }
-                       else {
-                               v->meta_pte_bytes_frame_c = 0.0;
-                               v->meta_row_byte_c = 0.0;
-                       }
-                       if (v->pte_enable == dcn_bw_yes) {
-                               if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                                       v->macro_tile_size_bytes_c = 256.0;
-                                       v->macro_tile_height_c = 1.0;
-                               }
-                               else if (v->source_surface_mode[k] == dcn_bw_sw_4_kb_s || v->source_surface_mode[k] == dcn_bw_sw_4_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d_x) {
-                                       v->macro_tile_size_bytes_c = 4096.0;
-                                       v->macro_tile_height_c = 4.0 * v->block_height256_bytes_c;
-                               }
-                               else if (v->source_surface_mode[k] == dcn_bw_sw_64_kb_s || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_x) {
-                                       v->macro_tile_size_bytes_c = 64.0 * 1024;
-                                       v->macro_tile_height_c = 16.0 * v->block_height256_bytes_c;
-                               }
-                               else {
-                                       v->macro_tile_size_bytes_c = 256.0 * 1024;
-                                       v->macro_tile_height_c = 32.0 * v->block_height256_bytes_c;
-                               }
-                               if (v->macro_tile_size_bytes_c <= 65536.0) {
-                                       v->pixel_pte_req_height_c = v->macro_tile_height_c;
-                               }
-                               else {
-                                       v->pixel_pte_req_height_c = 16.0 * v->block_height256_bytes_c;
-                               }
-                               v->pixel_pte_req_width_c = 4096.0 /dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / v->pixel_pte_req_height_c * 8;
-                               if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
-                                       v->pixel_pte_bytes_per_row_c = 64.0 * (dcn_bw_ceil2((v->swath_width_y[k] / 2.0 * dcn_bw_min2(128.0, dcn_bw_pow(2.0,dcn_bw_floor2(dcn_bw_log(v->pte_buffer_size_in_requests * v->pixel_pte_req_width_c / (v->swath_width_y[k] / 2.0), 2.0), 1.0))) - 1.0) / v->pixel_pte_req_width_c, 1.0) + 1);
-                               }
-                               else if (v->source_scan[k] == dcn_bw_hor) {
-                                       v->pixel_pte_bytes_per_row_c = 64.0 * (dcn_bw_ceil2((v->swath_width_y[k] / 2.0 - 1.0) / v->pixel_pte_req_width_c, 1.0) + 1);
-                               }
-                               else {
-                                       v->pixel_pte_bytes_per_row_c = 64.0 * (dcn_bw_ceil2((v->viewport_height[k] / 2.0 - 1.0) / v->pixel_pte_req_height_c, 1.0) + 1);
-                               }
-                       }
-                       else {
-                               v->pixel_pte_bytes_per_row_c = 0.0;
-                       }
-               }
-               else {
-                       v->pixel_pte_bytes_per_row_c = 0.0;
-                       v->meta_pte_bytes_frame_c = 0.0;
-                       v->meta_row_byte_c = 0.0;
-               }
-               v->pixel_pte_bytes_per_row[k] = v->pixel_pte_bytes_per_row_y + v->pixel_pte_bytes_per_row_c;
-               v->meta_pte_bytes_frame[k] = v->meta_pte_bytes_frame_y + v->meta_pte_bytes_frame_c;
-               v->meta_row_byte[k] = v->meta_row_byte_y + v->meta_row_byte_c;
-               v->v_init_pre_fill_y[k] =dcn_bw_floor2((v->v_ratio[k] + v->vtaps[k] + 1.0 + v->interlace_output[k] * 0.5 * v->v_ratio[k]) / 2.0, 1.0);
-               v->max_num_swath_y[k] =dcn_bw_ceil2((v->v_init_pre_fill_y[k] - 1.0) / v->swath_height_y[k], 1.0) + 1;
-               if (v->v_init_pre_fill_y[k] > 1.0) {
-                       v->max_partial_swath_y =dcn_bw_mod((v->v_init_pre_fill_y[k] - 2.0), v->swath_height_y[k]);
-               }
-               else {
-                       v->max_partial_swath_y =dcn_bw_mod((v->v_init_pre_fill_y[k] + v->swath_height_y[k] - 2.0), v->swath_height_y[k]);
-               }
-               v->max_partial_swath_y =dcn_bw_max2(1.0, v->max_partial_swath_y);
-               v->prefetch_source_lines_y[k] = v->max_num_swath_y[k] * v->swath_height_y[k] + v->max_partial_swath_y;
-               if ((v->source_pixel_format[k] != dcn_bw_rgb_sub_64 && v->source_pixel_format[k] != dcn_bw_rgb_sub_32 && v->source_pixel_format[k] != dcn_bw_rgb_sub_16)) {
-                       v->v_init_pre_fill_c[k] =dcn_bw_floor2((v->v_ratio[k] / 2.0 + v->vtaps[k] + 1.0 + v->interlace_output[k] * 0.5 * v->v_ratio[k] / 2.0) / 2.0, 1.0);
-                       v->max_num_swath_c[k] =dcn_bw_ceil2((v->v_init_pre_fill_c[k] - 1.0) / v->swath_height_c[k], 1.0) + 1;
-                       if (v->v_init_pre_fill_c[k] > 1.0) {
-                               v->max_partial_swath_c =dcn_bw_mod((v->v_init_pre_fill_c[k] - 2.0), v->swath_height_c[k]);
-                       }
-                       else {
-                               v->max_partial_swath_c =dcn_bw_mod((v->v_init_pre_fill_c[k] + v->swath_height_c[k] - 2.0), v->swath_height_c[k]);
-                       }
-                       v->max_partial_swath_c =dcn_bw_max2(1.0, v->max_partial_swath_c);
-               }
-               else {
-                       v->max_num_swath_c[k] = 0.0;
-                       v->max_partial_swath_c = 0.0;
-               }
-               v->prefetch_source_lines_c[k] = v->max_num_swath_c[k] * v->swath_height_c[k] + v->max_partial_swath_c;
-       }
-       v->t_calc = 24.0 / v->dcf_clk_deep_sleep;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one == dcn_bw_yes) {
-                       v->max_vstartup_lines[k] = v->vtotal[k] - v->vactive[k] - 1.0;
-               }
-               else {
-                       v->max_vstartup_lines[k] = v->v_sync_plus_back_porch[k] - 1.0;
-               }
-       }
-       v->next_prefetch_mode = 0.0;
-       do {
-               v->v_startup_lines = 13.0;
-               do {
-                       v->planes_with_room_to_increase_vstartup_prefetch_bw_less_than_active_bw = dcn_bw_yes;
-                       v->planes_with_room_to_increase_vstartup_vratio_prefetch_more_than4 = dcn_bw_no;
-                       v->planes_with_room_to_increase_vstartup_destination_line_times_for_prefetch_less_than2 = dcn_bw_no;
-                       v->v_ratio_prefetch_more_than4 = dcn_bw_no;
-                       v->destination_line_times_for_prefetch_less_than2 = dcn_bw_no;
-                       v->prefetch_mode = v->next_prefetch_mode;
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               v->dstx_after_scaler = 90.0 * v->pixel_clock[k] / v->dppclk + 42.0 * v->pixel_clock[k] / v->dispclk;
-                               if (v->dpp_per_plane[k] > 1.0) {
-                                       v->dstx_after_scaler = v->dstx_after_scaler + v->scaler_rec_out_width[k] / 2.0;
-                               }
-                               if (v->output_format[k] == dcn_bw_420) {
-                                       v->dsty_after_scaler = 1.0;
-                               }
-                               else {
-                                       v->dsty_after_scaler = 0.0;
-                               }
-                               v->v_update_offset_pix[k] = dcn_bw_ceil2(v->htotal[k] / 4.0, 1.0);
-                               v->total_repeater_delay_time = v->max_inter_dcn_tile_repeaters * (2.0 / v->dppclk + 3.0 / v->dispclk);
-                               v->v_update_width_pix[k] = (14.0 / v->dcf_clk_deep_sleep + 12.0 / v->dppclk + v->total_repeater_delay_time) * v->pixel_clock[k];
-                               v->v_ready_offset_pix[k] = dcn_bw_max2(150.0 / v->dppclk, v->total_repeater_delay_time + 20.0 / v->dcf_clk_deep_sleep + 10.0 / v->dppclk) * v->pixel_clock[k];
-                               v->t_setup = (v->v_update_offset_pix[k] + v->v_update_width_pix[k] + v->v_ready_offset_pix[k]) / v->pixel_clock[k];
-                               v->v_startup[k] =dcn_bw_min2(v->v_startup_lines, v->max_vstartup_lines[k]);
-                               if (v->prefetch_mode == 0.0) {
-                                       v->t_wait =dcn_bw_max3(v->dram_clock_change_latency + v->urgent_latency, v->sr_enter_plus_exit_time, v->urgent_latency);
-                               }
-                               else if (v->prefetch_mode == 1.0) {
-                                       v->t_wait =dcn_bw_max2(v->sr_enter_plus_exit_time, v->urgent_latency);
-                               }
-                               else {
-                                       v->t_wait = v->urgent_latency;
-                               }
-                               v->destination_lines_for_prefetch[k] =dcn_bw_floor2(4.0 * (v->v_startup[k] - v->t_wait / (v->htotal[k] / v->pixel_clock[k]) - (v->t_calc + v->t_setup) / (v->htotal[k] / v->pixel_clock[k]) - (v->dsty_after_scaler + v->dstx_after_scaler / v->htotal[k]) + 0.125), 1.0) / 4;
-                               if (v->destination_lines_for_prefetch[k] > 0.0) {
-                                       v->prefetch_bandwidth[k] = (v->meta_pte_bytes_frame[k] + 2.0 * v->meta_row_byte[k] + 2.0 * v->pixel_pte_bytes_per_row[k] + v->prefetch_source_lines_y[k] * v->swath_width_y[k] *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) + v->prefetch_source_lines_c[k] * v->swath_width_y[k] / 2.0 *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0)) / (v->destination_lines_for_prefetch[k] * v->htotal[k] / v->pixel_clock[k]);
-                               }
-                               else {
-                                       v->prefetch_bandwidth[k] = 999999.0;
-                               }
-                       }
-                       v->bandwidth_available_for_immediate_flip = v->return_bw;
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               v->bandwidth_available_for_immediate_flip = v->bandwidth_available_for_immediate_flip -dcn_bw_max2(v->read_bandwidth_plane_luma[k] + v->read_bandwidth_plane_chroma[k], v->prefetch_bandwidth[k]);
-                       }
-                       v->tot_immediate_flip_bytes = 0.0;
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               if (v->immediate_flip_supported == dcn_bw_yes && (v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
-                                       v->tot_immediate_flip_bytes = v->tot_immediate_flip_bytes + v->meta_pte_bytes_frame[k] + v->meta_row_byte[k] + v->pixel_pte_bytes_per_row[k];
-                               }
-                       }
-                       v->max_rd_bandwidth = 0.0;
-                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-                               if (v->pte_enable == dcn_bw_yes && v->dcc_enable[k] == dcn_bw_yes) {
-                                       if (v->immediate_flip_supported == dcn_bw_yes && (v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
-                                               v->time_for_fetching_meta_pte =dcn_bw_max5(v->meta_pte_bytes_frame[k] / v->prefetch_bandwidth[k], v->meta_pte_bytes_frame[k] * v->tot_immediate_flip_bytes / (v->bandwidth_available_for_immediate_flip * (v->meta_pte_bytes_frame[k] + v->meta_row_byte[k] + v->pixel_pte_bytes_per_row[k])), v->urgent_extra_latency, v->urgent_latency, v->htotal[k] / v->pixel_clock[k] / 4.0);
-                                       }
-                                       else {
-                                               v->time_for_fetching_meta_pte =dcn_bw_max3(v->meta_pte_bytes_frame[k] / v->prefetch_bandwidth[k], v->urgent_extra_latency, v->htotal[k] / v->pixel_clock[k] / 4.0);
-                                       }
-                               }
-                               else {
-                                       v->time_for_fetching_meta_pte = v->htotal[k] / v->pixel_clock[k] / 4.0;
-                               }
-                               v->destination_lines_to_request_vm_inv_blank[k] =dcn_bw_floor2(4.0 * (v->time_for_fetching_meta_pte / (v->htotal[k] / v->pixel_clock[k]) + 0.125), 1.0) / 4;
-                               if ((v->pte_enable == dcn_bw_yes || v->dcc_enable[k] == dcn_bw_yes)) {
-                                       if (v->immediate_flip_supported == dcn_bw_yes && (v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
-                                               v->time_for_fetching_row_in_vblank =dcn_bw_max5((v->meta_row_byte[k] + v->pixel_pte_bytes_per_row[k]) / v->prefetch_bandwidth[k], (v->meta_row_byte[k] + v->pixel_pte_bytes_per_row[k]) * v->tot_immediate_flip_bytes / (v->bandwidth_available_for_immediate_flip * (v->meta_pte_bytes_frame[k] + v->meta_row_byte[k] + v->pixel_pte_bytes_per_row[k])), v->urgent_extra_latency, 2.0 * v->urgent_latency, v->htotal[k] / v->pixel_clock[k] - v->time_for_fetching_meta_pte);
-                                       }
-                                       else {
-                                               v->time_for_fetching_row_in_vblank =dcn_bw_max3((v->meta_row_byte[k] + v->pixel_pte_bytes_per_row[k]) / v->prefetch_bandwidth[k], v->urgent_extra_latency, v->htotal[k] / v->pixel_clock[k] - v->time_for_fetching_meta_pte);
-                                       }
-                               }
-                               else {
-                                       v->time_for_fetching_row_in_vblank =dcn_bw_max2(v->urgent_extra_latency - v->time_for_fetching_meta_pte, v->htotal[k] / v->pixel_clock[k] - v->time_for_fetching_meta_pte);
-                               }
-                               v->destination_lines_to_request_row_in_vblank[k] =dcn_bw_floor2(4.0 * (v->time_for_fetching_row_in_vblank / (v->htotal[k] / v->pixel_clock[k]) + 0.125), 1.0) / 4;
-                               v->lines_to_request_prefetch_pixel_data = v->destination_lines_for_prefetch[k] - v->destination_lines_to_request_vm_inv_blank[k] - v->destination_lines_to_request_row_in_vblank[k];
-                               if (v->lines_to_request_prefetch_pixel_data > 0.0) {
-                                       v->v_ratio_prefetch_y[k] = v->prefetch_source_lines_y[k] / v->lines_to_request_prefetch_pixel_data;
-                                       if ((v->swath_height_y[k] > 4.0)) {
-                                               if (v->lines_to_request_prefetch_pixel_data > (v->v_init_pre_fill_y[k] - 3.0) / 2.0) {
-                                                       v->v_ratio_prefetch_y[k] =dcn_bw_max2(v->v_ratio_prefetch_y[k], v->max_num_swath_y[k] * v->swath_height_y[k] / (v->lines_to_request_prefetch_pixel_data - (v->v_init_pre_fill_y[k] - 3.0) / 2.0));
-                                               }
-                                               else {
-                                                       v->v_ratio_prefetch_y[k] = 999999.0;
-                                               }
-                                       }
-                               }
-                               else {
-                                       v->v_ratio_prefetch_y[k] = 999999.0;
-                               }
-                               v->v_ratio_prefetch_y[k] =dcn_bw_max2(v->v_ratio_prefetch_y[k], 1.0);
-                               if (v->lines_to_request_prefetch_pixel_data > 0.0) {
-                                       v->v_ratio_prefetch_c[k] = v->prefetch_source_lines_c[k] / v->lines_to_request_prefetch_pixel_data;
-                                       if ((v->swath_height_c[k] > 4.0)) {
-                                               if (v->lines_to_request_prefetch_pixel_data > (v->v_init_pre_fill_c[k] - 3.0) / 2.0) {
-                                                       v->v_ratio_prefetch_c[k] =dcn_bw_max2(v->v_ratio_prefetch_c[k], v->max_num_swath_c[k] * v->swath_height_c[k] / (v->lines_to_request_prefetch_pixel_data - (v->v_init_pre_fill_c[k] - 3.0) / 2.0));
-                                               }
-                                               else {
-                                                       v->v_ratio_prefetch_c[k] = 999999.0;
-                                               }
-                                       }
-                               }
-                               else {
-                                       v->v_ratio_prefetch_c[k] = 999999.0;
-                               }
-                               v->v_ratio_prefetch_c[k] =dcn_bw_max2(v->v_ratio_prefetch_c[k], 1.0);
-                               if (v->lines_to_request_prefetch_pixel_data > 0.0) {
-                                       v->required_prefetch_pix_data_bw = v->dpp_per_plane[k] * (v->prefetch_source_lines_y[k] / v->lines_to_request_prefetch_pixel_data *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) + v->prefetch_source_lines_c[k] / v->lines_to_request_prefetch_pixel_data *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / 2.0) * v->swath_width_y[k] / (v->htotal[k] / v->pixel_clock[k]);
-                               }
-                               else {
-                                       v->required_prefetch_pix_data_bw = 999999.0;
-                               }
-                               v->max_rd_bandwidth = v->max_rd_bandwidth +dcn_bw_max2(v->read_bandwidth_plane_luma[k] + v->read_bandwidth_plane_chroma[k], v->required_prefetch_pix_data_bw);
-                               if (v->immediate_flip_supported == dcn_bw_yes && (v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
-                                       v->max_rd_bandwidth = v->max_rd_bandwidth +dcn_bw_max2(v->meta_pte_bytes_frame[k] / (v->destination_lines_to_request_vm_inv_blank[k] * v->htotal[k] / v->pixel_clock[k]), (v->meta_row_byte[k] + v->pixel_pte_bytes_per_row[k]) / (v->destination_lines_to_request_row_in_vblank[k] * v->htotal[k] / v->pixel_clock[k]));
-                               }
-                               if (v->v_ratio_prefetch_y[k] > 4.0 || v->v_ratio_prefetch_c[k] > 4.0) {
-                                       v->v_ratio_prefetch_more_than4 = dcn_bw_yes;
-                               }
-                               if (v->destination_lines_for_prefetch[k] < 2.0) {
-                                       v->destination_line_times_for_prefetch_less_than2 = dcn_bw_yes;
-                               }
-                               if (v->max_vstartup_lines[k] > v->v_startup_lines) {
-                                       if (v->required_prefetch_pix_data_bw > (v->read_bandwidth_plane_luma[k] + v->read_bandwidth_plane_chroma[k])) {
-                                               v->planes_with_room_to_increase_vstartup_prefetch_bw_less_than_active_bw = dcn_bw_no;
-                                       }
-                                       if (v->v_ratio_prefetch_y[k] > 4.0 || v->v_ratio_prefetch_c[k] > 4.0) {
-                                               v->planes_with_room_to_increase_vstartup_vratio_prefetch_more_than4 = dcn_bw_yes;
-                                       }
-                                       if (v->destination_lines_for_prefetch[k] < 2.0) {
-                                               v->planes_with_room_to_increase_vstartup_destination_line_times_for_prefetch_less_than2 = dcn_bw_yes;
-                                       }
-                               }
-                       }
-                       if (v->max_rd_bandwidth <= v->return_bw && v->v_ratio_prefetch_more_than4 == dcn_bw_no && v->destination_line_times_for_prefetch_less_than2 == dcn_bw_no) {
-                               v->prefetch_mode_supported = dcn_bw_yes;
-                       }
-                       else {
-                               v->prefetch_mode_supported = dcn_bw_no;
-                       }
-                       v->v_startup_lines = v->v_startup_lines + 1.0;
-               } while (!(v->prefetch_mode_supported == dcn_bw_yes || (v->planes_with_room_to_increase_vstartup_prefetch_bw_less_than_active_bw == dcn_bw_yes && v->planes_with_room_to_increase_vstartup_vratio_prefetch_more_than4 == dcn_bw_no && v->planes_with_room_to_increase_vstartup_destination_line_times_for_prefetch_less_than2 == dcn_bw_no)));
-               v->next_prefetch_mode = v->next_prefetch_mode + 1.0;
-       } while (!(v->prefetch_mode_supported == dcn_bw_yes || v->prefetch_mode == 2.0));
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->v_ratio_prefetch_y[k] <= 1.0) {
-                       v->display_pipe_line_delivery_time_luma_prefetch[k] = v->swath_width_y[k] * v->dpp_per_plane[k] / v->h_ratio[k] / v->pixel_clock[k];
-               }
-               else {
-                       v->display_pipe_line_delivery_time_luma_prefetch[k] = v->swath_width_y[k] / v->pscl_throughput[k] / v->dppclk;
-               }
-               if (v->byte_per_pixel_detc[k] == 0.0) {
-                       v->display_pipe_line_delivery_time_chroma_prefetch[k] = 0.0;
-               }
-               else {
-                       if (v->v_ratio_prefetch_c[k] <= 1.0) {
-                               v->display_pipe_line_delivery_time_chroma_prefetch[k] = v->swath_width_y[k] * v->dpp_per_plane[k] / v->h_ratio[k] / v->pixel_clock[k];
-                       }
-                       else {
-                               v->display_pipe_line_delivery_time_chroma_prefetch[k] = v->swath_width_y[k] / v->pscl_throughput[k] / v->dppclk;
-                       }
-               }
-       }
-       /*min ttuv_blank*/
-
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->prefetch_mode == 0.0) {
-                       v->allow_dram_clock_change_during_vblank[k] = dcn_bw_yes;
-                       v->allow_dram_self_refresh_during_vblank[k] = dcn_bw_yes;
-                       v->min_ttuv_blank[k] = v->t_calc +dcn_bw_max3(v->dram_clock_change_watermark, v->stutter_enter_plus_exit_watermark, v->urgent_watermark);
-               }
-               else if (v->prefetch_mode == 1.0) {
-                       v->allow_dram_clock_change_during_vblank[k] = dcn_bw_no;
-                       v->allow_dram_self_refresh_during_vblank[k] = dcn_bw_yes;
-                       v->min_ttuv_blank[k] = v->t_calc +dcn_bw_max2(v->stutter_enter_plus_exit_watermark, v->urgent_watermark);
-               }
-               else {
-                       v->allow_dram_clock_change_during_vblank[k] = dcn_bw_no;
-                       v->allow_dram_self_refresh_during_vblank[k] = dcn_bw_no;
-                       v->min_ttuv_blank[k] = v->t_calc + v->urgent_watermark;
-               }
-       }
-       /*nb p-state/dram clock change support*/
-
-       v->active_dp_ps = 0.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               v->active_dp_ps = v->active_dp_ps + v->dpp_per_plane[k];
-       }
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               v->lb_latency_hiding_source_lines_y =dcn_bw_min2(v->max_line_buffer_lines,dcn_bw_floor2(v->line_buffer_size / v->lb_bit_per_pixel[k] / (v->swath_width_y[k] /dcn_bw_max2(v->h_ratio[k], 1.0)), 1.0)) - (v->vtaps[k] - 1.0);
-               v->lb_latency_hiding_source_lines_c =dcn_bw_min2(v->max_line_buffer_lines,dcn_bw_floor2(v->line_buffer_size / v->lb_bit_per_pixel[k] / (v->swath_width_y[k] / 2.0 /dcn_bw_max2(v->h_ratio[k] / 2.0, 1.0)), 1.0)) - (v->vta_pschroma[k] - 1.0);
-               v->effective_lb_latency_hiding_y = v->lb_latency_hiding_source_lines_y / v->v_ratio[k] * (v->htotal[k] / v->pixel_clock[k]);
-               v->effective_lb_latency_hiding_c = v->lb_latency_hiding_source_lines_c / (v->v_ratio[k] / 2.0) * (v->htotal[k] / v->pixel_clock[k]);
-               if (v->swath_width_y[k] > 2.0 * v->dpp_output_buffer_pixels) {
-                       v->dpp_output_buffer_lines_y = v->dpp_output_buffer_pixels / v->swath_width_y[k];
-               }
-               else if (v->swath_width_y[k] > v->dpp_output_buffer_pixels) {
-                       v->dpp_output_buffer_lines_y = 0.5;
-               }
-               else {
-                       v->dpp_output_buffer_lines_y = 1.0;
-               }
-               if (v->swath_width_y[k] / 2.0 > 2.0 * v->dpp_output_buffer_pixels) {
-                       v->dpp_output_buffer_lines_c = v->dpp_output_buffer_pixels / (v->swath_width_y[k] / 2.0);
-               }
-               else if (v->swath_width_y[k] / 2.0 > v->dpp_output_buffer_pixels) {
-                       v->dpp_output_buffer_lines_c = 0.5;
-               }
-               else {
-                       v->dpp_output_buffer_lines_c = 1.0;
-               }
-               v->dppopp_buffering_y = (v->htotal[k] / v->pixel_clock[k]) * (v->dpp_output_buffer_lines_y + v->opp_output_buffer_lines);
-               v->max_det_buffering_time_y = v->full_det_buffering_time_y[k] + (v->lines_in_dety[k] - v->lines_in_dety_rounded_down_to_swath[k]) / v->swath_height_y[k] * (v->htotal[k] / v->pixel_clock[k]);
-               v->active_dram_clock_change_latency_margin_y = v->dppopp_buffering_y + v->effective_lb_latency_hiding_y + v->max_det_buffering_time_y - v->dram_clock_change_watermark;
-               if (v->active_dp_ps > 1.0) {
-                       v->active_dram_clock_change_latency_margin_y = v->active_dram_clock_change_latency_margin_y - (1.0 - 1.0 / (v->active_dp_ps - 1.0)) * v->swath_height_y[k] * (v->htotal[k] / v->pixel_clock[k]);
-               }
-               if (v->byte_per_pixel_detc[k] > 0.0) {
-                       v->dppopp_buffering_c = (v->htotal[k] / v->pixel_clock[k]) * (v->dpp_output_buffer_lines_c + v->opp_output_buffer_lines);
-                       v->max_det_buffering_time_c = v->full_det_buffering_time_c[k] + (v->lines_in_detc[k] - v->lines_in_detc_rounded_down_to_swath[k]) / v->swath_height_c[k] * (v->htotal[k] / v->pixel_clock[k]);
-                       v->active_dram_clock_change_latency_margin_c = v->dppopp_buffering_c + v->effective_lb_latency_hiding_c + v->max_det_buffering_time_c - v->dram_clock_change_watermark;
-                       if (v->active_dp_ps > 1.0) {
-                               v->active_dram_clock_change_latency_margin_c = v->active_dram_clock_change_latency_margin_c - (1.0 - 1.0 / (v->active_dp_ps - 1.0)) * v->swath_height_c[k] * (v->htotal[k] / v->pixel_clock[k]);
-                       }
-                       v->active_dram_clock_change_latency_margin[k] =dcn_bw_min2(v->active_dram_clock_change_latency_margin_y, v->active_dram_clock_change_latency_margin_c);
-               }
-               else {
-                       v->active_dram_clock_change_latency_margin[k] = v->active_dram_clock_change_latency_margin_y;
-               }
-               if (v->output_format[k] == dcn_bw_444) {
-                       v->writeback_dram_clock_change_latency_margin = (v->writeback_luma_buffer_size + v->writeback_chroma_buffer_size) * 1024.0 / (v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) * 4.0) - v->writeback_dram_clock_change_watermark;
-               }
-               else {
-                       v->writeback_dram_clock_change_latency_margin =dcn_bw_min2(v->writeback_luma_buffer_size, 2.0 * v->writeback_chroma_buffer_size) * 1024.0 / (v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k])) - v->writeback_dram_clock_change_watermark;
-               }
-               if (v->output[k] == dcn_bw_writeback) {
-                       v->active_dram_clock_change_latency_margin[k] =dcn_bw_min2(v->active_dram_clock_change_latency_margin[k], v->writeback_dram_clock_change_latency_margin);
-               }
-       }
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->allow_dram_clock_change_during_vblank[k] == dcn_bw_yes) {
-                       v->v_blank_dram_clock_change_latency_margin[k] = (v->vtotal[k] - v->scaler_recout_height[k]) * (v->htotal[k] / v->pixel_clock[k]) -dcn_bw_max2(v->dram_clock_change_watermark, v->writeback_dram_clock_change_watermark);
-               }
-               else {
-                       v->v_blank_dram_clock_change_latency_margin[k] = 0.0;
-               }
-       }
-       v->min_active_dram_clock_change_margin = 999999.0;
-       v->v_blank_of_min_active_dram_clock_change_margin = 999999.0;
-       v->second_min_active_dram_clock_change_margin = 999999.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->active_dram_clock_change_latency_margin[k] < v->min_active_dram_clock_change_margin) {
-                       v->second_min_active_dram_clock_change_margin = v->min_active_dram_clock_change_margin;
-                       v->min_active_dram_clock_change_margin = v->active_dram_clock_change_latency_margin[k];
-                       v->v_blank_of_min_active_dram_clock_change_margin = v->v_blank_dram_clock_change_latency_margin[k];
-               }
-               else if (v->active_dram_clock_change_latency_margin[k] < v->second_min_active_dram_clock_change_margin) {
-                       v->second_min_active_dram_clock_change_margin = v->active_dram_clock_change_latency_margin[k];
-               }
-       }
-       v->min_vblank_dram_clock_change_margin = 999999.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->min_vblank_dram_clock_change_margin > v->v_blank_dram_clock_change_latency_margin[k]) {
-                       v->min_vblank_dram_clock_change_margin = v->v_blank_dram_clock_change_latency_margin[k];
-               }
-       }
-       if (v->synchronized_vblank == dcn_bw_yes || v->number_of_active_planes == 1) {
-               v->dram_clock_change_margin =dcn_bw_max2(v->min_active_dram_clock_change_margin, v->min_vblank_dram_clock_change_margin);
-       }
-       else if (v->v_blank_of_min_active_dram_clock_change_margin > v->min_active_dram_clock_change_margin) {
-               v->dram_clock_change_margin =dcn_bw_min2(v->second_min_active_dram_clock_change_margin, v->v_blank_of_min_active_dram_clock_change_margin);
-       }
-       else {
-               v->dram_clock_change_margin = v->min_active_dram_clock_change_margin;
-       }
-       if (v->min_active_dram_clock_change_margin > 0.0) {
-               v->dram_clock_change_support = dcn_bw_supported_in_v_active;
-       }
-       else if (v->dram_clock_change_margin > 0.0) {
-               v->dram_clock_change_support = dcn_bw_supported_in_v_blank;
-       }
-       else {
-               v->dram_clock_change_support = dcn_bw_not_supported;
-       }
-       /*maximum bandwidth used*/
-
-       v->wr_bandwidth = 0.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->output[k] == dcn_bw_writeback && v->output_format[k] == dcn_bw_444) {
-                       v->wr_bandwidth = v->wr_bandwidth + v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) * 4.0;
-               }
-               else if (v->output[k] == dcn_bw_writeback) {
-                       v->wr_bandwidth = v->wr_bandwidth + v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) * 1.5;
-               }
-       }
-       v->max_used_bw = v->max_rd_bandwidth + v->wr_bandwidth;
-}
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.h b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_auto.h
deleted file mode 100644 (file)
index ce35de7..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2017 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-
-#ifndef _DCN_CALC_AUTO_H_
-#define _DCN_CALC_AUTO_H_
-
-#include "dc.h"
-#include "dcn_calcs.h"
-
-void scaler_settings_calculation(struct dcn_bw_internal_vars *v);
-void mode_support_and_system_configuration(struct dcn_bw_internal_vars *v);
-void display_pipe_configuration(struct dcn_bw_internal_vars *v);
-void dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(
-               struct dcn_bw_internal_vars *v);
-
-#endif /* _DCN_CALC_AUTO_H_ */
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c
deleted file mode 100644 (file)
index 07d18e7..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2017 Advanced Micro Devices, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-
-#include "dcn_calc_math.h"
-
-#define isNaN(number) ((number) != (number))
-
-/*
- * NOTE:
- *   This file is gcc-parseable HW gospel, coming straight from HW engineers.
- *
- * It doesn't adhere to Linux kernel style and sometimes will do things in odd
- * ways. Unless there is something clearly wrong with it the code should
- * remain as-is as it provides us with a guarantee from HW that it is correct.
- */
-
-float dcn_bw_mod(const float arg1, const float arg2)
-{
-       if (isNaN(arg1))
-               return arg2;
-       if (isNaN(arg2))
-               return arg1;
-       return arg1 - arg1 * ((int) (arg1 / arg2));
-}
-
-float dcn_bw_min2(const float arg1, const float arg2)
-{
-       if (isNaN(arg1))
-               return arg2;
-       if (isNaN(arg2))
-               return arg1;
-       return arg1 < arg2 ? arg1 : arg2;
-}
-
-unsigned int dcn_bw_max(const unsigned int arg1, const unsigned int arg2)
-{
-       return arg1 > arg2 ? arg1 : arg2;
-}
-float dcn_bw_max2(const float arg1, const float arg2)
-{
-       if (isNaN(arg1))
-               return arg2;
-       if (isNaN(arg2))
-               return arg1;
-       return arg1 > arg2 ? arg1 : arg2;
-}
-
-float dcn_bw_floor2(const float arg, const float significance)
-{
-       if (significance == 0)
-               return 0;
-       return ((int) (arg / significance)) * significance;
-}
-float dcn_bw_floor(const float arg)
-{
-       return ((int) (arg));
-}
-
-float dcn_bw_ceil(const float arg)
-{
-       float flr = dcn_bw_floor2(arg, 1);
-
-       return flr + 0.00001 >= arg ? arg : flr + 1;
-}
-
-float dcn_bw_ceil2(const float arg, const float significance)
-{
-       float flr = dcn_bw_floor2(arg, significance);
-       if (significance == 0)
-               return 0;
-       return flr + 0.00001 >= arg ? arg : flr + significance;
-}
-
-float dcn_bw_max3(float v1, float v2, float v3)
-{
-       return v3 > dcn_bw_max2(v1, v2) ? v3 : dcn_bw_max2(v1, v2);
-}
-
-float dcn_bw_max5(float v1, float v2, float v3, float v4, float v5)
-{
-       return dcn_bw_max3(v1, v2, v3) > dcn_bw_max2(v4, v5) ? dcn_bw_max3(v1, v2, v3) : dcn_bw_max2(v4, v5);
-}
-
-float dcn_bw_pow(float a, float exp)
-{
-       float temp;
-       /*ASSERT(exp == (int)exp);*/
-       if ((int)exp == 0)
-               return 1;
-       temp = dcn_bw_pow(a, (int)(exp / 2));
-       if (((int)exp % 2) == 0) {
-               return temp * temp;
-       } else {
-               if ((int)exp > 0)
-                       return a * temp * temp;
-               else
-                       return (temp * temp) / a;
-       }
-}
-
-double dcn_bw_fabs(double a)
-{
-       if (a > 0)
-               return (a);
-       else
-               return (-a);
-}
-
-
-float dcn_bw_log(float a, float b)
-{
-       int * const exp_ptr = (int *)(&a);
-       int x = *exp_ptr;
-       const int log_2 = ((x >> 23) & 255) - 128;
-       x &= ~(255 << 23);
-       x += 127 << 23;
-       *exp_ptr = x;
-
-       a = ((-1.0f / 3) * a + 2) * a - 2.0f / 3;
-
-       if (b > 2.00001 || b < 1.99999)
-               return (a + log_2) / dcn_bw_log(b, 2);
-       else
-               return (a + log_2);
-}
diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c
deleted file mode 100644 (file)
index ec19678..0000000
+++ /dev/null
@@ -1,1808 +0,0 @@
-/*
- * Copyright 2017 Advanced Micro Devices, Inc.
- * Copyright 2019 Raptor Engineering, LLC
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors: AMD
- *
- */
-
-#include "dm_services.h"
-#include "dc.h"
-#include "dcn_calcs.h"
-#include "dcn_calc_auto.h"
-#include "dal_asic_id.h"
-#include "resource.h"
-#include "dcn10/dcn10_resource.h"
-#include "dcn10/dcn10_hubbub.h"
-#include "dml/dml1_display_rq_dlg_calc.h"
-
-#include "dcn_calc_math.h"
-
-#define DC_LOGGER \
-       dc->ctx->logger
-
-#define WM_SET_COUNT 4
-#define WM_A 0
-#define WM_B 1
-#define WM_C 2
-#define WM_D 3
-
-/*
- * NOTE:
- *   This file is gcc-parseable HW gospel, coming straight from HW engineers.
- *
- * It doesn't adhere to Linux kernel style and sometimes will do things in odd
- * ways. Unless there is something clearly wrong with it the code should
- * remain as-is as it provides us with a guarantee from HW that it is correct.
- */
-
-/* Defaults from spreadsheet rev#247.
- * RV2 delta: dram_clock_change_latency, max_num_dpp
- */
-const struct dcn_soc_bounding_box dcn10_soc_defaults = {
-               /* latencies */
-               .sr_exit_time = 17, /*us*/
-               .sr_enter_plus_exit_time = 19, /*us*/
-               .urgent_latency = 4, /*us*/
-               .dram_clock_change_latency = 17, /*us*/
-               .write_back_latency = 12, /*us*/
-               .percent_of_ideal_drambw_received_after_urg_latency = 80, /*%*/
-
-               /* below default clocks derived from STA target base on
-                * slow-slow corner + 10% margin with voltages aligned to FCLK.
-                *
-                * Use these value if fused value doesn't make sense as earlier
-                * part don't have correct value fused */
-               /* default DCF CLK DPM on RV*/
-               .dcfclkv_max0p9 = 655,  /* MHz, = 3600/5.5 */
-               .dcfclkv_nom0p8 = 626,  /* MHz, = 3600/5.75 */
-               .dcfclkv_mid0p72 = 600, /* MHz, = 3600/6, bypass */
-               .dcfclkv_min0p65 = 300, /* MHz, = 3600/12, bypass */
-
-               /* default DISP CLK voltage state on RV */
-               .max_dispclk_vmax0p9 = 1108,    /* MHz, = 3600/3.25 */
-               .max_dispclk_vnom0p8 = 1029,    /* MHz, = 3600/3.5 */
-               .max_dispclk_vmid0p72 = 960,    /* MHz, = 3600/3.75 */
-               .max_dispclk_vmin0p65 = 626,    /* MHz, = 3600/5.75 */
-
-               /* default DPP CLK voltage state on RV */
-               .max_dppclk_vmax0p9 = 720,      /* MHz, = 3600/5 */
-               .max_dppclk_vnom0p8 = 686,      /* MHz, = 3600/5.25 */
-               .max_dppclk_vmid0p72 = 626,     /* MHz, = 3600/5.75 */
-               .max_dppclk_vmin0p65 = 400,     /* MHz, = 3600/9 */
-
-               /* default PHY CLK voltage state on RV */
-               .phyclkv_max0p9 = 900, /*MHz*/
-               .phyclkv_nom0p8 = 847, /*MHz*/
-               .phyclkv_mid0p72 = 800, /*MHz*/
-               .phyclkv_min0p65 = 600, /*MHz*/
-
-               /* BW depend on FCLK, MCLK, # of channels */
-               /* dual channel BW */
-               .fabric_and_dram_bandwidth_vmax0p9 = 38.4f, /*GB/s*/
-               .fabric_and_dram_bandwidth_vnom0p8 = 34.133f, /*GB/s*/
-               .fabric_and_dram_bandwidth_vmid0p72 = 29.866f, /*GB/s*/
-               .fabric_and_dram_bandwidth_vmin0p65 = 12.8f, /*GB/s*/
-               /* single channel BW
-               .fabric_and_dram_bandwidth_vmax0p9 = 19.2f,
-               .fabric_and_dram_bandwidth_vnom0p8 = 17.066f,
-               .fabric_and_dram_bandwidth_vmid0p72 = 14.933f,
-               .fabric_and_dram_bandwidth_vmin0p65 = 12.8f,
-               */
-
-               .number_of_channels = 2,
-
-               .socclk = 208, /*MHz*/
-               .downspreading = 0.5f, /*%*/
-               .round_trip_ping_latency_cycles = 128, /*DCFCLK Cycles*/
-               .urgent_out_of_order_return_per_channel = 256, /*bytes*/
-               .vmm_page_size = 4096, /*bytes*/
-               .return_bus_width = 64, /*bytes*/
-               .max_request_size = 256, /*bytes*/
-
-               /* Depends on user class (client vs embedded, workstation, etc) */
-               .percent_disp_bw_limit = 0.3f /*%*/
-};
-
-const struct dcn_ip_params dcn10_ip_defaults = {
-               .rob_buffer_size_in_kbyte = 64,
-               .det_buffer_size_in_kbyte = 164,
-               .dpp_output_buffer_pixels = 2560,
-               .opp_output_buffer_lines = 1,
-               .pixel_chunk_size_in_kbyte = 8,
-               .pte_enable = dcn_bw_yes,
-               .pte_chunk_size = 2, /*kbytes*/
-               .meta_chunk_size = 2, /*kbytes*/
-               .writeback_chunk_size = 2, /*kbytes*/
-               .odm_capability = dcn_bw_no,
-               .dsc_capability = dcn_bw_no,
-               .line_buffer_size = 589824, /*bit*/
-               .max_line_buffer_lines = 12,
-               .is_line_buffer_bpp_fixed = dcn_bw_no,
-               .line_buffer_fixed_bpp = dcn_bw_na,
-               .writeback_luma_buffer_size = 12, /*kbytes*/
-               .writeback_chroma_buffer_size = 8, /*kbytes*/
-               .max_num_dpp = 4,
-               .max_num_writeback = 2,
-               .max_dchub_topscl_throughput = 4, /*pixels/dppclk*/
-               .max_pscl_tolb_throughput = 2, /*pixels/dppclk*/
-               .max_lb_tovscl_throughput = 4, /*pixels/dppclk*/
-               .max_vscl_tohscl_throughput = 4, /*pixels/dppclk*/
-               .max_hscl_ratio = 4,
-               .max_vscl_ratio = 4,
-               .max_hscl_taps = 8,
-               .max_vscl_taps = 8,
-               .pte_buffer_size_in_requests = 42,
-               .dispclk_ramping_margin = 1, /*%*/
-               .under_scan_factor = 1.11f,
-               .max_inter_dcn_tile_repeaters = 8,
-               .can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one = dcn_bw_no,
-               .bug_forcing_luma_and_chroma_request_to_same_size_fixed = dcn_bw_no,
-               .dcfclk_cstate_latency = 10 /*TODO clone of something else? sr_enter_plus_exit_time?*/
-};
-
-static enum dcn_bw_defs tl_sw_mode_to_bw_defs(enum swizzle_mode_values sw_mode)
-{
-       switch (sw_mode) {
-       case DC_SW_LINEAR:
-               return dcn_bw_sw_linear;
-       case DC_SW_4KB_S:
-               return dcn_bw_sw_4_kb_s;
-       case DC_SW_4KB_D:
-               return dcn_bw_sw_4_kb_d;
-       case DC_SW_64KB_S:
-               return dcn_bw_sw_64_kb_s;
-       case DC_SW_64KB_D:
-               return dcn_bw_sw_64_kb_d;
-       case DC_SW_VAR_S:
-               return dcn_bw_sw_var_s;
-       case DC_SW_VAR_D:
-               return dcn_bw_sw_var_d;
-       case DC_SW_64KB_S_T:
-               return dcn_bw_sw_64_kb_s_t;
-       case DC_SW_64KB_D_T:
-               return dcn_bw_sw_64_kb_d_t;
-       case DC_SW_4KB_S_X:
-               return dcn_bw_sw_4_kb_s_x;
-       case DC_SW_4KB_D_X:
-               return dcn_bw_sw_4_kb_d_x;
-       case DC_SW_64KB_S_X:
-               return dcn_bw_sw_64_kb_s_x;
-       case DC_SW_64KB_D_X:
-               return dcn_bw_sw_64_kb_d_x;
-       case DC_SW_VAR_S_X:
-               return dcn_bw_sw_var_s_x;
-       case DC_SW_VAR_D_X:
-               return dcn_bw_sw_var_d_x;
-       case DC_SW_256B_S:
-       case DC_SW_256_D:
-       case DC_SW_256_R:
-       case DC_SW_4KB_R:
-       case DC_SW_64KB_R:
-       case DC_SW_VAR_R:
-       case DC_SW_4KB_R_X:
-       case DC_SW_64KB_R_X:
-       case DC_SW_VAR_R_X:
-       default:
-               BREAK_TO_DEBUGGER(); /*not in formula*/
-               return dcn_bw_sw_4_kb_s;
-       }
-}
-
-static int tl_lb_bpp_to_int(enum lb_pixel_depth depth)
-{
-       switch (depth) {
-       case LB_PIXEL_DEPTH_18BPP:
-               return 18;
-       case LB_PIXEL_DEPTH_24BPP:
-               return 24;
-       case LB_PIXEL_DEPTH_30BPP:
-               return 30;
-       case LB_PIXEL_DEPTH_36BPP:
-               return 36;
-       default:
-               return 30;
-       }
-}
-
-static enum dcn_bw_defs tl_pixel_format_to_bw_defs(enum surface_pixel_format format)
-{
-       switch (format) {
-       case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555:
-       case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
-               return dcn_bw_rgb_sub_16;
-       case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
-       case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
-       case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
-       case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
-       case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
-               return dcn_bw_rgb_sub_32;
-       case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
-       case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616:
-       case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F:
-       case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
-               return dcn_bw_rgb_sub_64;
-       case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
-       case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb:
-               return dcn_bw_yuv420_sub_8;
-       case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
-       case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
-               return dcn_bw_yuv420_sub_10;
-       default:
-               return dcn_bw_rgb_sub_32;
-       }
-}
-
-enum source_macro_tile_size swizzle_mode_to_macro_tile_size(enum swizzle_mode_values sw_mode)
-{
-       switch (sw_mode) {
-       /* for 4/8/16 high tiles */
-       case DC_SW_LINEAR:
-               return dm_4k_tile;
-       case DC_SW_4KB_S:
-       case DC_SW_4KB_S_X:
-               return dm_4k_tile;
-       case DC_SW_64KB_S:
-       case DC_SW_64KB_S_X:
-       case DC_SW_64KB_S_T:
-               return dm_64k_tile;
-       case DC_SW_VAR_S:
-       case DC_SW_VAR_S_X:
-               return dm_256k_tile;
-
-       /* For 64bpp 2 high tiles */
-       case DC_SW_4KB_D:
-       case DC_SW_4KB_D_X:
-               return dm_4k_tile;
-       case DC_SW_64KB_D:
-       case DC_SW_64KB_D_X:
-       case DC_SW_64KB_D_T:
-               return dm_64k_tile;
-       case DC_SW_VAR_D:
-       case DC_SW_VAR_D_X:
-               return dm_256k_tile;
-
-       case DC_SW_4KB_R:
-       case DC_SW_4KB_R_X:
-               return dm_4k_tile;
-       case DC_SW_64KB_R:
-       case DC_SW_64KB_R_X:
-               return dm_64k_tile;
-       case DC_SW_VAR_R:
-       case DC_SW_VAR_R_X:
-               return dm_256k_tile;
-
-       /* Unsupported swizzle modes for dcn */
-       case DC_SW_256B_S:
-       default:
-               ASSERT(0); /* Not supported */
-               return 0;
-       }
-}
-
-static void pipe_ctx_to_e2e_pipe_params (
-               const struct pipe_ctx *pipe,
-               struct _vcs_dpi_display_pipe_params_st *input)
-{
-       input->src.is_hsplit = false;
-
-       /* stereo can never be split */
-       if (pipe->plane_state->stereo_format == PLANE_STEREO_FORMAT_SIDE_BY_SIDE ||
-           pipe->plane_state->stereo_format == PLANE_STEREO_FORMAT_TOP_AND_BOTTOM) {
-               /* reset the split group if it was already considered split. */
-               input->src.hsplit_grp = pipe->pipe_idx;
-       } else if (pipe->top_pipe != NULL && pipe->top_pipe->plane_state == pipe->plane_state) {
-               input->src.is_hsplit = true;
-       } else if (pipe->bottom_pipe != NULL && pipe->bottom_pipe->plane_state == pipe->plane_state) {
-               input->src.is_hsplit = true;
-       }
-
-       if (pipe->plane_res.dpp->ctx->dc->debug.optimized_watermark) {
-               /*
-                * this method requires us to always re-calculate watermark when dcc change
-                * between flip.
-                */
-               input->src.dcc = pipe->plane_state->dcc.enable ? 1 : 0;
-       } else {
-               /*
-                * allow us to disable dcc on the fly without re-calculating WM
-                *
-                * extra overhead for DCC is quite small.  for 1080p WM without
-                * DCC is only 0.417us lower (urgent goes from 6.979us to 6.562us)
-                */
-               unsigned int bpe;
-
-               input->src.dcc = pipe->plane_res.dpp->ctx->dc->res_pool->hubbub->funcs->
-                       dcc_support_pixel_format(pipe->plane_state->format, &bpe) ? 1 : 0;
-       }
-       input->src.dcc_rate            = 1;
-       input->src.meta_pitch          = pipe->plane_state->dcc.meta_pitch;
-       input->src.source_scan         = dm_horz;
-       input->src.sw_mode             = pipe->plane_state->tiling_info.gfx9.swizzle;
-
-       input->src.viewport_width      = pipe->plane_res.scl_data.viewport.width;
-       input->src.viewport_height     = pipe->plane_res.scl_data.viewport.height;
-       input->src.data_pitch          = pipe->plane_res.scl_data.viewport.width;
-       input->src.data_pitch_c        = pipe->plane_res.scl_data.viewport.width;
-       input->src.cur0_src_width      = 128; /* TODO: Cursor calcs, not curently stored */
-       input->src.cur0_bpp            = 32;
-
-       input->src.macro_tile_size = swizzle_mode_to_macro_tile_size(pipe->plane_state->tiling_info.gfx9.swizzle);
-
-       switch (pipe->plane_state->rotation) {
-       case ROTATION_ANGLE_0:
-       case ROTATION_ANGLE_180:
-               input->src.source_scan = dm_horz;
-               break;
-       case ROTATION_ANGLE_90:
-       case ROTATION_ANGLE_270:
-               input->src.source_scan = dm_vert;
-               break;
-       default:
-               ASSERT(0); /* Not supported */
-               break;
-       }
-
-       /* TODO: Fix pixel format mappings */
-       switch (pipe->plane_state->format) {
-       case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
-       case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb:
-               input->src.source_format = dm_420_8;
-               input->src.viewport_width_c    = input->src.viewport_width / 2;
-               input->src.viewport_height_c   = input->src.viewport_height / 2;
-               break;
-       case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
-       case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
-               input->src.source_format = dm_420_10;
-               input->src.viewport_width_c    = input->src.viewport_width / 2;
-               input->src.viewport_height_c   = input->src.viewport_height / 2;
-               break;
-       case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
-       case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616:
-       case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F:
-       case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
-               input->src.source_format = dm_444_64;
-               input->src.viewport_width_c    = input->src.viewport_width;
-               input->src.viewport_height_c   = input->src.viewport_height;
-               break;
-       case SURFACE_PIXEL_FORMAT_GRPH_RGBE_ALPHA:
-               input->src.source_format = dm_rgbe_alpha;
-               input->src.viewport_width_c    = input->src.viewport_width;
-               input->src.viewport_height_c   = input->src.viewport_height;
-               break;
-       default:
-               input->src.source_format = dm_444_32;
-               input->src.viewport_width_c    = input->src.viewport_width;
-               input->src.viewport_height_c   = input->src.viewport_height;
-               break;
-       }
-
-       input->scale_taps.htaps                = pipe->plane_res.scl_data.taps.h_taps;
-       input->scale_ratio_depth.hscl_ratio    = pipe->plane_res.scl_data.ratios.horz.value/4294967296.0;
-       input->scale_ratio_depth.vscl_ratio    = pipe->plane_res.scl_data.ratios.vert.value/4294967296.0;
-       input->scale_ratio_depth.vinit =  pipe->plane_res.scl_data.inits.v.value/4294967296.0;
-       if (input->scale_ratio_depth.vinit < 1.0)
-                       input->scale_ratio_depth.vinit = 1;
-       input->scale_taps.vtaps = pipe->plane_res.scl_data.taps.v_taps;
-       input->scale_taps.vtaps_c = pipe->plane_res.scl_data.taps.v_taps_c;
-       input->scale_taps.htaps_c              = pipe->plane_res.scl_data.taps.h_taps_c;
-       input->scale_ratio_depth.hscl_ratio_c  = pipe->plane_res.scl_data.ratios.horz_c.value/4294967296.0;
-       input->scale_ratio_depth.vscl_ratio_c  = pipe->plane_res.scl_data.ratios.vert_c.value/4294967296.0;
-       input->scale_ratio_depth.vinit_c       = pipe->plane_res.scl_data.inits.v_c.value/4294967296.0;
-       if (input->scale_ratio_depth.vinit_c < 1.0)
-                       input->scale_ratio_depth.vinit_c = 1;
-       switch (pipe->plane_res.scl_data.lb_params.depth) {
-       case LB_PIXEL_DEPTH_30BPP:
-               input->scale_ratio_depth.lb_depth = 30; break;
-       case LB_PIXEL_DEPTH_36BPP:
-               input->scale_ratio_depth.lb_depth = 36; break;
-       default:
-               input->scale_ratio_depth.lb_depth = 24; break;
-       }
-
-
-       input->dest.vactive        = pipe->stream->timing.v_addressable + pipe->stream->timing.v_border_top
-                       + pipe->stream->timing.v_border_bottom;
-
-       input->dest.recout_width   = pipe->plane_res.scl_data.recout.width;
-       input->dest.recout_height  = pipe->plane_res.scl_data.recout.height;
-
-       input->dest.full_recout_width   = pipe->plane_res.scl_data.recout.width;
-       input->dest.full_recout_height  = pipe->plane_res.scl_data.recout.height;
-
-       input->dest.htotal         = pipe->stream->timing.h_total;
-       input->dest.hblank_start   = input->dest.htotal - pipe->stream->timing.h_front_porch;
-       input->dest.hblank_end     = input->dest.hblank_start
-                       - pipe->stream->timing.h_addressable
-                       - pipe->stream->timing.h_border_left
-                       - pipe->stream->timing.h_border_right;
-
-       input->dest.vtotal         = pipe->stream->timing.v_total;
-       input->dest.vblank_start   = input->dest.vtotal - pipe->stream->timing.v_front_porch;
-       input->dest.vblank_end     = input->dest.vblank_start
-                       - pipe->stream->timing.v_addressable
-                       - pipe->stream->timing.v_border_bottom
-                       - pipe->stream->timing.v_border_top;
-       input->dest.pixel_rate_mhz = pipe->stream->timing.pix_clk_100hz/10000.0;
-       input->dest.vstartup_start = pipe->pipe_dlg_param.vstartup_start;
-       input->dest.vupdate_offset = pipe->pipe_dlg_param.vupdate_offset;
-       input->dest.vupdate_offset = pipe->pipe_dlg_param.vupdate_offset;
-       input->dest.vupdate_width = pipe->pipe_dlg_param.vupdate_width;
-
-}
-
-static void dcn_bw_calc_rq_dlg_ttu(
-               const struct dc *dc,
-               const struct dcn_bw_internal_vars *v,
-               struct pipe_ctx *pipe,
-               int in_idx)
-{
-       struct display_mode_lib *dml = (struct display_mode_lib *)(&dc->dml);
-       struct _vcs_dpi_display_dlg_regs_st *dlg_regs = &pipe->dlg_regs;
-       struct _vcs_dpi_display_ttu_regs_st *ttu_regs = &pipe->ttu_regs;
-       struct _vcs_dpi_display_rq_regs_st *rq_regs = &pipe->rq_regs;
-       struct _vcs_dpi_display_rq_params_st *rq_param = &pipe->dml_rq_param;
-       struct _vcs_dpi_display_dlg_sys_params_st *dlg_sys_param = &pipe->dml_dlg_sys_param;
-       struct _vcs_dpi_display_e2e_pipe_params_st *input = &pipe->dml_input;
-       float total_active_bw = 0;
-       float total_prefetch_bw = 0;
-       int total_flip_bytes = 0;
-       int i;
-
-       memset(dlg_regs, 0, sizeof(*dlg_regs));
-       memset(ttu_regs, 0, sizeof(*ttu_regs));
-       memset(rq_regs, 0, sizeof(*rq_regs));
-       memset(rq_param, 0, sizeof(*rq_param));
-       memset(dlg_sys_param, 0, sizeof(*dlg_sys_param));
-       memset(input, 0, sizeof(*input));
-
-       for (i = 0; i < number_of_planes; i++) {
-               total_active_bw += v->read_bandwidth[i];
-               total_prefetch_bw += v->prefetch_bandwidth[i];
-               total_flip_bytes += v->total_immediate_flip_bytes[i];
-       }
-       dlg_sys_param->total_flip_bw = v->return_bw - dcn_bw_max2(total_active_bw, total_prefetch_bw);
-       if (dlg_sys_param->total_flip_bw < 0.0)
-               dlg_sys_param->total_flip_bw = 0;
-
-       dlg_sys_param->t_mclk_wm_us = v->dram_clock_change_watermark;
-       dlg_sys_param->t_sr_wm_us = v->stutter_enter_plus_exit_watermark;
-       dlg_sys_param->t_urg_wm_us = v->urgent_watermark;
-       dlg_sys_param->t_extra_us = v->urgent_extra_latency;
-       dlg_sys_param->deepsleep_dcfclk_mhz = v->dcf_clk_deep_sleep;
-       dlg_sys_param->total_flip_bytes = total_flip_bytes;
-
-       pipe_ctx_to_e2e_pipe_params(pipe, &input->pipe);
-       input->clks_cfg.dcfclk_mhz = v->dcfclk;
-       input->clks_cfg.dispclk_mhz = v->dispclk;
-       input->clks_cfg.dppclk_mhz = v->dppclk;
-       input->clks_cfg.refclk_mhz = dc->res_pool->ref_clocks.dchub_ref_clock_inKhz / 1000.0;
-       input->clks_cfg.socclk_mhz = v->socclk;
-       input->clks_cfg.voltage = v->voltage_level;
-//     dc->dml.logger = pool->base.logger;
-       input->dout.output_format = (v->output_format[in_idx] == dcn_bw_420) ? dm_420 : dm_444;
-       input->dout.output_type  = (v->output[in_idx] == dcn_bw_hdmi) ? dm_hdmi : dm_dp;
-       //input[in_idx].dout.output_standard;
-
-       /*todo: soc->sr_enter_plus_exit_time??*/
-       dlg_sys_param->t_srx_delay_us = dc->dcn_ip->dcfclk_cstate_latency / v->dcf_clk_deep_sleep;
-
-       dml1_rq_dlg_get_rq_params(dml, rq_param, &input->pipe.src);
-       dml1_extract_rq_regs(dml, rq_regs, rq_param);
-       dml1_rq_dlg_get_dlg_params(
-                       dml,
-                       dlg_regs,
-                       ttu_regs,
-                       &rq_param->dlg,
-                       dlg_sys_param,
-                       input,
-                       true,
-                       true,
-                       v->pte_enable == dcn_bw_yes,
-                       pipe->plane_state->flip_immediate);
-}
-
-static void split_stream_across_pipes(
-               struct resource_context *res_ctx,
-               const struct resource_pool *pool,
-               struct pipe_ctx *primary_pipe,
-               struct pipe_ctx *secondary_pipe)
-{
-       int pipe_idx = secondary_pipe->pipe_idx;
-
-       if (!primary_pipe->plane_state)
-               return;
-
-       *secondary_pipe = *primary_pipe;
-
-       secondary_pipe->pipe_idx = pipe_idx;
-       secondary_pipe->plane_res.mi = pool->mis[secondary_pipe->pipe_idx];
-       secondary_pipe->plane_res.hubp = pool->hubps[secondary_pipe->pipe_idx];
-       secondary_pipe->plane_res.ipp = pool->ipps[secondary_pipe->pipe_idx];
-       secondary_pipe->plane_res.xfm = pool->transforms[secondary_pipe->pipe_idx];
-       secondary_pipe->plane_res.dpp = pool->dpps[secondary_pipe->pipe_idx];
-       secondary_pipe->plane_res.mpcc_inst = pool->dpps[secondary_pipe->pipe_idx]->inst;
-       if (primary_pipe->bottom_pipe) {
-               ASSERT(primary_pipe->bottom_pipe != secondary_pipe);
-               secondary_pipe->bottom_pipe = primary_pipe->bottom_pipe;
-               secondary_pipe->bottom_pipe->top_pipe = secondary_pipe;
-       }
-       primary_pipe->bottom_pipe = secondary_pipe;
-       secondary_pipe->top_pipe = primary_pipe;
-
-       resource_build_scaling_params(primary_pipe);
-       resource_build_scaling_params(secondary_pipe);
-}
-
-#if 0
-static void calc_wm_sets_and_perf_params(
-               struct dc_state *context,
-               struct dcn_bw_internal_vars *v)
-{
-       /* Calculate set A last to keep internal var state consistent for required config */
-       if (v->voltage_level < 2) {
-               v->fabric_and_dram_bandwidth_per_state[1] = v->fabric_and_dram_bandwidth_vnom0p8;
-               v->fabric_and_dram_bandwidth_per_state[0] = v->fabric_and_dram_bandwidth_vnom0p8;
-               v->fabric_and_dram_bandwidth = v->fabric_and_dram_bandwidth_vnom0p8;
-               dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(v);
-
-               context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_exit_ns =
-                       v->stutter_exit_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_enter_plus_exit_ns =
-                               v->stutter_enter_plus_exit_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.pstate_change_ns =
-                               v->dram_clock_change_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.b.pte_meta_urgent_ns = v->ptemeta_urgent_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.b.urgent_ns = v->urgent_watermark * 1000;
-
-               v->dcfclk_per_state[1] = v->dcfclkv_nom0p8;
-               v->dcfclk_per_state[0] = v->dcfclkv_nom0p8;
-               v->dcfclk = v->dcfclkv_nom0p8;
-               dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(v);
-
-               context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_exit_ns =
-                       v->stutter_exit_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_enter_plus_exit_ns =
-                               v->stutter_enter_plus_exit_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.pstate_change_ns =
-                               v->dram_clock_change_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.c.pte_meta_urgent_ns = v->ptemeta_urgent_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.c.urgent_ns = v->urgent_watermark * 1000;
-       }
-
-       if (v->voltage_level < 3) {
-               v->fabric_and_dram_bandwidth_per_state[2] = v->fabric_and_dram_bandwidth_vmax0p9;
-               v->fabric_and_dram_bandwidth_per_state[1] = v->fabric_and_dram_bandwidth_vmax0p9;
-               v->fabric_and_dram_bandwidth_per_state[0] = v->fabric_and_dram_bandwidth_vmax0p9;
-               v->fabric_and_dram_bandwidth = v->fabric_and_dram_bandwidth_vmax0p9;
-               v->dcfclk_per_state[2] = v->dcfclkv_max0p9;
-               v->dcfclk_per_state[1] = v->dcfclkv_max0p9;
-               v->dcfclk_per_state[0] = v->dcfclkv_max0p9;
-               v->dcfclk = v->dcfclkv_max0p9;
-               dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(v);
-
-               context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_exit_ns =
-                       v->stutter_exit_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_enter_plus_exit_ns =
-                               v->stutter_enter_plus_exit_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.pstate_change_ns =
-                               v->dram_clock_change_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.d.pte_meta_urgent_ns = v->ptemeta_urgent_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.d.urgent_ns = v->urgent_watermark * 1000;
-       }
-
-       v->fabric_and_dram_bandwidth_per_state[2] = v->fabric_and_dram_bandwidth_vnom0p8;
-       v->fabric_and_dram_bandwidth_per_state[1] = v->fabric_and_dram_bandwidth_vmid0p72;
-       v->fabric_and_dram_bandwidth_per_state[0] = v->fabric_and_dram_bandwidth_vmin0p65;
-       v->fabric_and_dram_bandwidth = v->fabric_and_dram_bandwidth_per_state[v->voltage_level];
-       v->dcfclk_per_state[2] = v->dcfclkv_nom0p8;
-       v->dcfclk_per_state[1] = v->dcfclkv_mid0p72;
-       v->dcfclk_per_state[0] = v->dcfclkv_min0p65;
-       v->dcfclk = v->dcfclk_per_state[v->voltage_level];
-       dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(v);
-
-       context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_exit_ns =
-               v->stutter_exit_watermark * 1000;
-       context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_enter_plus_exit_ns =
-                       v->stutter_enter_plus_exit_watermark * 1000;
-       context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.pstate_change_ns =
-                       v->dram_clock_change_watermark * 1000;
-       context->bw_ctx.bw.dcn.watermarks.a.pte_meta_urgent_ns = v->ptemeta_urgent_watermark * 1000;
-       context->bw_ctx.bw.dcn.watermarks.a.urgent_ns = v->urgent_watermark * 1000;
-       if (v->voltage_level >= 2) {
-               context->bw_ctx.bw.dcn.watermarks.b = context->bw_ctx.bw.dcn.watermarks.a;
-               context->bw_ctx.bw.dcn.watermarks.c = context->bw_ctx.bw.dcn.watermarks.a;
-       }
-       if (v->voltage_level >= 3)
-               context->bw_ctx.bw.dcn.watermarks.d = context->bw_ctx.bw.dcn.watermarks.a;
-}
-#endif
-
-static bool dcn_bw_apply_registry_override(struct dc *dc)
-{
-       bool updated = false;
-
-       DC_FP_START();
-       if ((int)(dc->dcn_soc->sr_exit_time * 1000) != dc->debug.sr_exit_time_ns
-                       && dc->debug.sr_exit_time_ns) {
-               updated = true;
-               dc->dcn_soc->sr_exit_time = dc->debug.sr_exit_time_ns / 1000.0;
-       }
-
-       if ((int)(dc->dcn_soc->sr_enter_plus_exit_time * 1000)
-                               != dc->debug.sr_enter_plus_exit_time_ns
-                       && dc->debug.sr_enter_plus_exit_time_ns) {
-               updated = true;
-               dc->dcn_soc->sr_enter_plus_exit_time =
-                               dc->debug.sr_enter_plus_exit_time_ns / 1000.0;
-       }
-
-       if ((int)(dc->dcn_soc->urgent_latency * 1000) != dc->debug.urgent_latency_ns
-                       && dc->debug.urgent_latency_ns) {
-               updated = true;
-               dc->dcn_soc->urgent_latency = dc->debug.urgent_latency_ns / 1000.0;
-       }
-
-       if ((int)(dc->dcn_soc->percent_of_ideal_drambw_received_after_urg_latency * 1000)
-                               != dc->debug.percent_of_ideal_drambw
-                       && dc->debug.percent_of_ideal_drambw) {
-               updated = true;
-               dc->dcn_soc->percent_of_ideal_drambw_received_after_urg_latency =
-                               dc->debug.percent_of_ideal_drambw;
-       }
-
-       if ((int)(dc->dcn_soc->dram_clock_change_latency * 1000)
-                               != dc->debug.dram_clock_change_latency_ns
-                       && dc->debug.dram_clock_change_latency_ns) {
-               updated = true;
-               dc->dcn_soc->dram_clock_change_latency =
-                               dc->debug.dram_clock_change_latency_ns / 1000.0;
-       }
-       DC_FP_END();
-
-       return updated;
-}
-
-static void hack_disable_optional_pipe_split(struct dcn_bw_internal_vars *v)
-{
-       /*
-        * disable optional pipe split by lower dispclk bounding box
-        * at DPM0
-        */
-       v->max_dispclk[0] = v->max_dppclk_vmin0p65;
-}
-
-static void hack_force_pipe_split(struct dcn_bw_internal_vars *v,
-               unsigned int pixel_rate_100hz)
-{
-       float pixel_rate_mhz = pixel_rate_100hz / 10000;
-
-       /*
-        * force enabling pipe split by lower dpp clock for DPM0 to just
-        * below the specify pixel_rate, so bw calc would split pipe.
-        */
-       if (pixel_rate_mhz < v->max_dppclk[0])
-               v->max_dppclk[0] = pixel_rate_mhz;
-}
-
-static void hack_bounding_box(struct dcn_bw_internal_vars *v,
-               struct dc_debug_options *dbg,
-               struct dc_state *context)
-{
-       int i;
-
-       for (i = 0; i < MAX_PIPES; i++) {
-               struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
-
-               /**
-                * Workaround for avoiding pipe-split in cases where we'd split
-                * planes that are too small, resulting in splits that aren't
-                * valid for the scaler.
-                */
-               if (pipe->plane_state &&
-                   (pipe->plane_state->dst_rect.width <= 16 ||
-                    pipe->plane_state->dst_rect.height <= 16 ||
-                    pipe->plane_state->src_rect.width <= 16 ||
-                    pipe->plane_state->src_rect.height <= 16)) {
-                       hack_disable_optional_pipe_split(v);
-                       return;
-               }
-       }
-
-       if (dbg->pipe_split_policy == MPC_SPLIT_AVOID)
-               hack_disable_optional_pipe_split(v);
-
-       if (dbg->pipe_split_policy == MPC_SPLIT_AVOID_MULT_DISP &&
-               context->stream_count >= 2)
-               hack_disable_optional_pipe_split(v);
-
-       if (context->stream_count == 1 &&
-                       dbg->force_single_disp_pipe_split)
-               hack_force_pipe_split(v, context->streams[0]->timing.pix_clk_100hz);
-}
-
-static unsigned int get_highest_allowed_voltage_level(uint32_t chip_family,
-                                                     uint32_t hw_internal_rev,
-                                                     uint32_t pci_revision_id)
-{
-       /* for low power RV2 variants, the highest voltage level we want is 0 */
-       if ((chip_family == FAMILY_RV) &&
-            ASICREV_IS_RAVEN2(hw_internal_rev))
-               switch (pci_revision_id) {
-               case PRID_DALI_DE:
-               case PRID_DALI_DF:
-               case PRID_DALI_E3:
-               case PRID_DALI_E4:
-               case PRID_POLLOCK_94:
-               case PRID_POLLOCK_95:
-               case PRID_POLLOCK_E9:
-               case PRID_POLLOCK_EA:
-               case PRID_POLLOCK_EB:
-                       return 0;
-               default:
-                       break;
-               }
-
-       /* we are ok with all levels */
-       return 4;
-}
-
-bool dcn10_validate_bandwidth(
-               struct dc *dc,
-               struct dc_state *context,
-               bool fast_validate)
-{
-       /*
-        * we want a breakdown of the various stages of validation, which the
-        * perf_trace macro doesn't support
-        */
-       BW_VAL_TRACE_SETUP();
-
-       const struct resource_pool *pool = dc->res_pool;
-       struct dcn_bw_internal_vars *v = &context->dcn_bw_vars;
-       int i, input_idx, k;
-       int vesa_sync_start, asic_blank_end, asic_blank_start;
-       bool bw_limit_pass;
-       float bw_limit;
-
-       PERFORMANCE_TRACE_START();
-
-       BW_VAL_TRACE_COUNT();
-
-       if (dcn_bw_apply_registry_override(dc))
-               dcn_bw_sync_calcs_and_dml(dc);
-
-       memset(v, 0, sizeof(*v));
-       DC_FP_START();
-
-       v->sr_exit_time = dc->dcn_soc->sr_exit_time;
-       v->sr_enter_plus_exit_time = dc->dcn_soc->sr_enter_plus_exit_time;
-       v->urgent_latency = dc->dcn_soc->urgent_latency;
-       v->write_back_latency = dc->dcn_soc->write_back_latency;
-       v->percent_of_ideal_drambw_received_after_urg_latency =
-                       dc->dcn_soc->percent_of_ideal_drambw_received_after_urg_latency;
-
-       v->dcfclkv_min0p65 = dc->dcn_soc->dcfclkv_min0p65;
-       v->dcfclkv_mid0p72 = dc->dcn_soc->dcfclkv_mid0p72;
-       v->dcfclkv_nom0p8 = dc->dcn_soc->dcfclkv_nom0p8;
-       v->dcfclkv_max0p9 = dc->dcn_soc->dcfclkv_max0p9;
-
-       v->max_dispclk_vmin0p65 = dc->dcn_soc->max_dispclk_vmin0p65;
-       v->max_dispclk_vmid0p72 = dc->dcn_soc->max_dispclk_vmid0p72;
-       v->max_dispclk_vnom0p8 = dc->dcn_soc->max_dispclk_vnom0p8;
-       v->max_dispclk_vmax0p9 = dc->dcn_soc->max_dispclk_vmax0p9;
-
-       v->max_dppclk_vmin0p65 = dc->dcn_soc->max_dppclk_vmin0p65;
-       v->max_dppclk_vmid0p72 = dc->dcn_soc->max_dppclk_vmid0p72;
-       v->max_dppclk_vnom0p8 = dc->dcn_soc->max_dppclk_vnom0p8;
-       v->max_dppclk_vmax0p9 = dc->dcn_soc->max_dppclk_vmax0p9;
-
-       v->socclk = dc->dcn_soc->socclk;
-
-       v->fabric_and_dram_bandwidth_vmin0p65 = dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65;
-       v->fabric_and_dram_bandwidth_vmid0p72 = dc->dcn_soc->fabric_and_dram_bandwidth_vmid0p72;
-       v->fabric_and_dram_bandwidth_vnom0p8 = dc->dcn_soc->fabric_and_dram_bandwidth_vnom0p8;
-       v->fabric_and_dram_bandwidth_vmax0p9 = dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9;
-
-       v->phyclkv_min0p65 = dc->dcn_soc->phyclkv_min0p65;
-       v->phyclkv_mid0p72 = dc->dcn_soc->phyclkv_mid0p72;
-       v->phyclkv_nom0p8 = dc->dcn_soc->phyclkv_nom0p8;
-       v->phyclkv_max0p9 = dc->dcn_soc->phyclkv_max0p9;
-
-       v->downspreading = dc->dcn_soc->downspreading;
-       v->round_trip_ping_latency_cycles = dc->dcn_soc->round_trip_ping_latency_cycles;
-       v->urgent_out_of_order_return_per_channel = dc->dcn_soc->urgent_out_of_order_return_per_channel;
-       v->number_of_channels = dc->dcn_soc->number_of_channels;
-       v->vmm_page_size = dc->dcn_soc->vmm_page_size;
-       v->dram_clock_change_latency = dc->dcn_soc->dram_clock_change_latency;
-       v->return_bus_width = dc->dcn_soc->return_bus_width;
-
-       v->rob_buffer_size_in_kbyte = dc->dcn_ip->rob_buffer_size_in_kbyte;
-       v->det_buffer_size_in_kbyte = dc->dcn_ip->det_buffer_size_in_kbyte;
-       v->dpp_output_buffer_pixels = dc->dcn_ip->dpp_output_buffer_pixels;
-       v->opp_output_buffer_lines = dc->dcn_ip->opp_output_buffer_lines;
-       v->pixel_chunk_size_in_kbyte = dc->dcn_ip->pixel_chunk_size_in_kbyte;
-       v->pte_enable = dc->dcn_ip->pte_enable;
-       v->pte_chunk_size = dc->dcn_ip->pte_chunk_size;
-       v->meta_chunk_size = dc->dcn_ip->meta_chunk_size;
-       v->writeback_chunk_size = dc->dcn_ip->writeback_chunk_size;
-       v->odm_capability = dc->dcn_ip->odm_capability;
-       v->dsc_capability = dc->dcn_ip->dsc_capability;
-       v->line_buffer_size = dc->dcn_ip->line_buffer_size;
-       v->is_line_buffer_bpp_fixed = dc->dcn_ip->is_line_buffer_bpp_fixed;
-       v->line_buffer_fixed_bpp = dc->dcn_ip->line_buffer_fixed_bpp;
-       v->max_line_buffer_lines = dc->dcn_ip->max_line_buffer_lines;
-       v->writeback_luma_buffer_size = dc->dcn_ip->writeback_luma_buffer_size;
-       v->writeback_chroma_buffer_size = dc->dcn_ip->writeback_chroma_buffer_size;
-       v->max_num_dpp = dc->dcn_ip->max_num_dpp;
-       v->max_num_writeback = dc->dcn_ip->max_num_writeback;
-       v->max_dchub_topscl_throughput = dc->dcn_ip->max_dchub_topscl_throughput;
-       v->max_pscl_tolb_throughput = dc->dcn_ip->max_pscl_tolb_throughput;
-       v->max_lb_tovscl_throughput = dc->dcn_ip->max_lb_tovscl_throughput;
-       v->max_vscl_tohscl_throughput = dc->dcn_ip->max_vscl_tohscl_throughput;
-       v->max_hscl_ratio = dc->dcn_ip->max_hscl_ratio;
-       v->max_vscl_ratio = dc->dcn_ip->max_vscl_ratio;
-       v->max_hscl_taps = dc->dcn_ip->max_hscl_taps;
-       v->max_vscl_taps = dc->dcn_ip->max_vscl_taps;
-       v->under_scan_factor = dc->dcn_ip->under_scan_factor;
-       v->pte_buffer_size_in_requests = dc->dcn_ip->pte_buffer_size_in_requests;
-       v->dispclk_ramping_margin = dc->dcn_ip->dispclk_ramping_margin;
-       v->max_inter_dcn_tile_repeaters = dc->dcn_ip->max_inter_dcn_tile_repeaters;
-       v->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one =
-                       dc->dcn_ip->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one;
-       v->bug_forcing_luma_and_chroma_request_to_same_size_fixed =
-                       dc->dcn_ip->bug_forcing_luma_and_chroma_request_to_same_size_fixed;
-
-       v->voltage[5] = dcn_bw_no_support;
-       v->voltage[4] = dcn_bw_v_max0p9;
-       v->voltage[3] = dcn_bw_v_max0p9;
-       v->voltage[2] = dcn_bw_v_nom0p8;
-       v->voltage[1] = dcn_bw_v_mid0p72;
-       v->voltage[0] = dcn_bw_v_min0p65;
-       v->fabric_and_dram_bandwidth_per_state[5] = v->fabric_and_dram_bandwidth_vmax0p9;
-       v->fabric_and_dram_bandwidth_per_state[4] = v->fabric_and_dram_bandwidth_vmax0p9;
-       v->fabric_and_dram_bandwidth_per_state[3] = v->fabric_and_dram_bandwidth_vmax0p9;
-       v->fabric_and_dram_bandwidth_per_state[2] = v->fabric_and_dram_bandwidth_vnom0p8;
-       v->fabric_and_dram_bandwidth_per_state[1] = v->fabric_and_dram_bandwidth_vmid0p72;
-       v->fabric_and_dram_bandwidth_per_state[0] = v->fabric_and_dram_bandwidth_vmin0p65;
-       v->dcfclk_per_state[5] = v->dcfclkv_max0p9;
-       v->dcfclk_per_state[4] = v->dcfclkv_max0p9;
-       v->dcfclk_per_state[3] = v->dcfclkv_max0p9;
-       v->dcfclk_per_state[2] = v->dcfclkv_nom0p8;
-       v->dcfclk_per_state[1] = v->dcfclkv_mid0p72;
-       v->dcfclk_per_state[0] = v->dcfclkv_min0p65;
-       v->max_dispclk[5] = v->max_dispclk_vmax0p9;
-       v->max_dispclk[4] = v->max_dispclk_vmax0p9;
-       v->max_dispclk[3] = v->max_dispclk_vmax0p9;
-       v->max_dispclk[2] = v->max_dispclk_vnom0p8;
-       v->max_dispclk[1] = v->max_dispclk_vmid0p72;
-       v->max_dispclk[0] = v->max_dispclk_vmin0p65;
-       v->max_dppclk[5] = v->max_dppclk_vmax0p9;
-       v->max_dppclk[4] = v->max_dppclk_vmax0p9;
-       v->max_dppclk[3] = v->max_dppclk_vmax0p9;
-       v->max_dppclk[2] = v->max_dppclk_vnom0p8;
-       v->max_dppclk[1] = v->max_dppclk_vmid0p72;
-       v->max_dppclk[0] = v->max_dppclk_vmin0p65;
-       v->phyclk_per_state[5] = v->phyclkv_max0p9;
-       v->phyclk_per_state[4] = v->phyclkv_max0p9;
-       v->phyclk_per_state[3] = v->phyclkv_max0p9;
-       v->phyclk_per_state[2] = v->phyclkv_nom0p8;
-       v->phyclk_per_state[1] = v->phyclkv_mid0p72;
-       v->phyclk_per_state[0] = v->phyclkv_min0p65;
-       v->synchronized_vblank = dcn_bw_no;
-       v->ta_pscalculation = dcn_bw_override;
-       v->allow_different_hratio_vratio = dcn_bw_yes;
-
-       for (i = 0, input_idx = 0; i < pool->pipe_count; i++) {
-               struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
-
-               if (!pipe->stream)
-                       continue;
-               /* skip all but first of split pipes */
-               if (pipe->top_pipe && pipe->top_pipe->plane_state == pipe->plane_state)
-                       continue;
-
-               v->underscan_output[input_idx] = false; /* taken care of in recout already*/
-               v->interlace_output[input_idx] = false;
-
-               v->htotal[input_idx] = pipe->stream->timing.h_total;
-               v->vtotal[input_idx] = pipe->stream->timing.v_total;
-               v->vactive[input_idx] = pipe->stream->timing.v_addressable +
-                               pipe->stream->timing.v_border_top + pipe->stream->timing.v_border_bottom;
-               v->v_sync_plus_back_porch[input_idx] = pipe->stream->timing.v_total
-                               - v->vactive[input_idx]
-                               - pipe->stream->timing.v_front_porch;
-               v->pixel_clock[input_idx] = pipe->stream->timing.pix_clk_100hz/10000.0;
-               if (pipe->stream->timing.timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING)
-                       v->pixel_clock[input_idx] *= 2;
-               if (!pipe->plane_state) {
-                       v->dcc_enable[input_idx] = dcn_bw_yes;
-                       v->source_pixel_format[input_idx] = dcn_bw_rgb_sub_32;
-                       v->source_surface_mode[input_idx] = dcn_bw_sw_4_kb_s;
-                       v->lb_bit_per_pixel[input_idx] = 30;
-                       v->viewport_width[input_idx] = pipe->stream->timing.h_addressable;
-                       v->viewport_height[input_idx] = pipe->stream->timing.v_addressable;
-                       /*
-                        * for cases where we have no plane, we want to validate up to 1080p
-                        * source size because here we are only interested in if the output
-                        * timing is supported or not. if we cannot support native resolution
-                        * of the high res display, we still want to support lower res up scale
-                        * to native
-                        */
-                       if (v->viewport_width[input_idx] > 1920)
-                               v->viewport_width[input_idx] = 1920;
-                       if (v->viewport_height[input_idx] > 1080)
-                               v->viewport_height[input_idx] = 1080;
-                       v->scaler_rec_out_width[input_idx] = v->viewport_width[input_idx];
-                       v->scaler_recout_height[input_idx] = v->viewport_height[input_idx];
-                       v->override_hta_ps[input_idx] = 1;
-                       v->override_vta_ps[input_idx] = 1;
-                       v->override_hta_pschroma[input_idx] = 1;
-                       v->override_vta_pschroma[input_idx] = 1;
-                       v->source_scan[input_idx] = dcn_bw_hor;
-
-               } else {
-                       v->viewport_height[input_idx] =  pipe->plane_res.scl_data.viewport.height;
-                       v->viewport_width[input_idx] = pipe->plane_res.scl_data.viewport.width;
-                       v->scaler_rec_out_width[input_idx] = pipe->plane_res.scl_data.recout.width;
-                       v->scaler_recout_height[input_idx] = pipe->plane_res.scl_data.recout.height;
-                       if (pipe->bottom_pipe && pipe->bottom_pipe->plane_state == pipe->plane_state) {
-                               if (pipe->plane_state->rotation % 2 == 0) {
-                                       int viewport_end = pipe->plane_res.scl_data.viewport.width
-                                                       + pipe->plane_res.scl_data.viewport.x;
-                                       int viewport_b_end = pipe->bottom_pipe->plane_res.scl_data.viewport.width
-                                                       + pipe->bottom_pipe->plane_res.scl_data.viewport.x;
-
-                                       if (viewport_end > viewport_b_end)
-                                               v->viewport_width[input_idx] = viewport_end
-                                                       - pipe->bottom_pipe->plane_res.scl_data.viewport.x;
-                                       else
-                                               v->viewport_width[input_idx] = viewport_b_end
-                                                                       - pipe->plane_res.scl_data.viewport.x;
-                               } else  {
-                                       int viewport_end = pipe->plane_res.scl_data.viewport.height
-                                               + pipe->plane_res.scl_data.viewport.y;
-                                       int viewport_b_end = pipe->bottom_pipe->plane_res.scl_data.viewport.height
-                                               + pipe->bottom_pipe->plane_res.scl_data.viewport.y;
-
-                                       if (viewport_end > viewport_b_end)
-                                               v->viewport_height[input_idx] = viewport_end
-                                                       - pipe->bottom_pipe->plane_res.scl_data.viewport.y;
-                                       else
-                                               v->viewport_height[input_idx] = viewport_b_end
-                                                                       - pipe->plane_res.scl_data.viewport.y;
-                               }
-                               v->scaler_rec_out_width[input_idx] = pipe->plane_res.scl_data.recout.width
-                                               + pipe->bottom_pipe->plane_res.scl_data.recout.width;
-                       }
-
-                       if (pipe->plane_state->rotation % 2 == 0) {
-                               ASSERT(pipe->plane_res.scl_data.ratios.horz.value != dc_fixpt_one.value
-                                       || v->scaler_rec_out_width[input_idx] == v->viewport_width[input_idx]);
-                               ASSERT(pipe->plane_res.scl_data.ratios.vert.value != dc_fixpt_one.value
-                                       || v->scaler_recout_height[input_idx] == v->viewport_height[input_idx]);
-                       } else {
-                               ASSERT(pipe->plane_res.scl_data.ratios.horz.value != dc_fixpt_one.value
-                                       || v->scaler_recout_height[input_idx] == v->viewport_width[input_idx]);
-                               ASSERT(pipe->plane_res.scl_data.ratios.vert.value != dc_fixpt_one.value
-                                       || v->scaler_rec_out_width[input_idx] == v->viewport_height[input_idx]);
-                       }
-
-                       if (dc->debug.optimized_watermark) {
-                               /*
-                                * this method requires us to always re-calculate watermark when dcc change
-                                * between flip.
-                                */
-                               v->dcc_enable[input_idx] = pipe->plane_state->dcc.enable ? dcn_bw_yes : dcn_bw_no;
-                       } else {
-                               /*
-                                * allow us to disable dcc on the fly without re-calculating WM
-                                *
-                                * extra overhead for DCC is quite small.  for 1080p WM without
-                                * DCC is only 0.417us lower (urgent goes from 6.979us to 6.562us)
-                                */
-                               unsigned int bpe;
-
-                               v->dcc_enable[input_idx] = dc->res_pool->hubbub->funcs->dcc_support_pixel_format(
-                                               pipe->plane_state->format, &bpe) ? dcn_bw_yes : dcn_bw_no;
-                       }
-
-                       v->source_pixel_format[input_idx] = tl_pixel_format_to_bw_defs(
-                                       pipe->plane_state->format);
-                       v->source_surface_mode[input_idx] = tl_sw_mode_to_bw_defs(
-                                       pipe->plane_state->tiling_info.gfx9.swizzle);
-                       v->lb_bit_per_pixel[input_idx] = tl_lb_bpp_to_int(pipe->plane_res.scl_data.lb_params.depth);
-                       v->override_hta_ps[input_idx] = pipe->plane_res.scl_data.taps.h_taps;
-                       v->override_vta_ps[input_idx] = pipe->plane_res.scl_data.taps.v_taps;
-                       v->override_hta_pschroma[input_idx] = pipe->plane_res.scl_data.taps.h_taps_c;
-                       v->override_vta_pschroma[input_idx] = pipe->plane_res.scl_data.taps.v_taps_c;
-                       /*
-                        * Spreadsheet doesn't handle taps_c is one properly,
-                        * need to force Chroma to always be scaled to pass
-                        * bandwidth validation.
-                        */
-                       if (v->override_hta_pschroma[input_idx] == 1)
-                               v->override_hta_pschroma[input_idx] = 2;
-                       if (v->override_vta_pschroma[input_idx] == 1)
-                               v->override_vta_pschroma[input_idx] = 2;
-                       v->source_scan[input_idx] = (pipe->plane_state->rotation % 2) ? dcn_bw_vert : dcn_bw_hor;
-               }
-               if (v->is_line_buffer_bpp_fixed == dcn_bw_yes)
-                       v->lb_bit_per_pixel[input_idx] = v->line_buffer_fixed_bpp;
-               v->dcc_rate[input_idx] = 1; /*TODO: Worst case? does this change?*/
-               v->output_format[input_idx] = pipe->stream->timing.pixel_encoding ==
-                               PIXEL_ENCODING_YCBCR420 ? dcn_bw_420 : dcn_bw_444;
-               v->output[input_idx] = pipe->stream->signal ==
-                               SIGNAL_TYPE_HDMI_TYPE_A ? dcn_bw_hdmi : dcn_bw_dp;
-               v->output_deep_color[input_idx] = dcn_bw_encoder_8bpc;
-               if (v->output[input_idx] == dcn_bw_hdmi) {
-                       switch (pipe->stream->timing.display_color_depth) {
-                       case COLOR_DEPTH_101010:
-                               v->output_deep_color[input_idx] = dcn_bw_encoder_10bpc;
-                               break;
-                       case COLOR_DEPTH_121212:
-                               v->output_deep_color[input_idx]  = dcn_bw_encoder_12bpc;
-                               break;
-                       case COLOR_DEPTH_161616:
-                               v->output_deep_color[input_idx]  = dcn_bw_encoder_16bpc;
-                               break;
-                       default:
-                               break;
-                       }
-               }
-
-               input_idx++;
-       }
-       v->number_of_active_planes = input_idx;
-
-       scaler_settings_calculation(v);
-
-       hack_bounding_box(v, &dc->debug, context);
-
-       mode_support_and_system_configuration(v);
-
-       /* Unhack dppclk: dont bother with trying to pipe split if we cannot maintain dpm0 */
-       if (v->voltage_level != 0
-                       && context->stream_count == 1
-                       && dc->debug.force_single_disp_pipe_split) {
-               v->max_dppclk[0] = v->max_dppclk_vmin0p65;
-               mode_support_and_system_configuration(v);
-       }
-
-       if (v->voltage_level == 0 &&
-                       (dc->debug.sr_exit_time_dpm0_ns
-                               || dc->debug.sr_enter_plus_exit_time_dpm0_ns)) {
-
-               if (dc->debug.sr_enter_plus_exit_time_dpm0_ns)
-                       v->sr_enter_plus_exit_time =
-                               dc->debug.sr_enter_plus_exit_time_dpm0_ns / 1000.0f;
-               if (dc->debug.sr_exit_time_dpm0_ns)
-                       v->sr_exit_time =  dc->debug.sr_exit_time_dpm0_ns / 1000.0f;
-               context->bw_ctx.dml.soc.sr_enter_plus_exit_time_us = v->sr_enter_plus_exit_time;
-               context->bw_ctx.dml.soc.sr_exit_time_us = v->sr_exit_time;
-               mode_support_and_system_configuration(v);
-       }
-
-       display_pipe_configuration(v);
-
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->source_scan[k] == dcn_bw_hor)
-                       v->swath_width_y[k] = v->viewport_width[k] / v->dpp_per_plane[k];
-               else
-                       v->swath_width_y[k] = v->viewport_height[k] / v->dpp_per_plane[k];
-       }
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
-                       v->byte_per_pixel_dety[k] = 8.0;
-                       v->byte_per_pixel_detc[k] = 0.0;
-               } else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_32) {
-                       v->byte_per_pixel_dety[k] = 4.0;
-                       v->byte_per_pixel_detc[k] = 0.0;
-               } else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_16) {
-                       v->byte_per_pixel_dety[k] = 2.0;
-                       v->byte_per_pixel_detc[k] = 0.0;
-               } else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
-                       v->byte_per_pixel_dety[k] = 1.0;
-                       v->byte_per_pixel_detc[k] = 2.0;
-               } else {
-                       v->byte_per_pixel_dety[k] = 4.0f / 3.0f;
-                       v->byte_per_pixel_detc[k] = 8.0f / 3.0f;
-               }
-       }
-
-       v->total_data_read_bandwidth = 0.0;
-       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
-               v->read_bandwidth_plane_luma[k] = v->swath_width_y[k] * v->dpp_per_plane[k] *
-                               dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / (v->htotal[k] / v->pixel_clock[k]) * v->v_ratio[k];
-               v->read_bandwidth_plane_chroma[k] = v->swath_width_y[k] / 2.0 * v->dpp_per_plane[k] *
-                               dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / (v->htotal[k] / v->pixel_clock[k]) * v->v_ratio[k] / 2.0;
-               v->total_data_read_bandwidth = v->total_data_read_bandwidth +
-                               v->read_bandwidth_plane_luma[k] + v->read_bandwidth_plane_chroma[k];
-       }
-
-       BW_VAL_TRACE_END_VOLTAGE_LEVEL();
-
-       if (v->voltage_level != number_of_states_plus_one && !fast_validate) {
-               float bw_consumed = v->total_bandwidth_consumed_gbyte_per_second;
-
-               if (bw_consumed < v->fabric_and_dram_bandwidth_vmin0p65)
-                       bw_consumed = v->fabric_and_dram_bandwidth_vmin0p65;
-               else if (bw_consumed < v->fabric_and_dram_bandwidth_vmid0p72)
-                       bw_consumed = v->fabric_and_dram_bandwidth_vmid0p72;
-               else if (bw_consumed < v->fabric_and_dram_bandwidth_vnom0p8)
-                       bw_consumed = v->fabric_and_dram_bandwidth_vnom0p8;
-               else
-                       bw_consumed = v->fabric_and_dram_bandwidth_vmax0p9;
-
-               if (bw_consumed < v->fabric_and_dram_bandwidth)
-                       if (dc->debug.voltage_align_fclk)
-                               bw_consumed = v->fabric_and_dram_bandwidth;
-
-               display_pipe_configuration(v);
-               /*calc_wm_sets_and_perf_params(context, v);*/
-               /* Only 1 set is used by dcn since no noticeable
-                * performance improvement was measured and due to hw bug DEGVIDCN10-254
-                */
-               dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(v);
-
-               context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_exit_ns =
-                       v->stutter_exit_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_enter_plus_exit_ns =
-                               v->stutter_enter_plus_exit_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.pstate_change_ns =
-                               v->dram_clock_change_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.a.pte_meta_urgent_ns = v->ptemeta_urgent_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.a.urgent_ns = v->urgent_watermark * 1000;
-               context->bw_ctx.bw.dcn.watermarks.b = context->bw_ctx.bw.dcn.watermarks.a;
-               context->bw_ctx.bw.dcn.watermarks.c = context->bw_ctx.bw.dcn.watermarks.a;
-               context->bw_ctx.bw.dcn.watermarks.d = context->bw_ctx.bw.dcn.watermarks.a;
-
-               context->bw_ctx.bw.dcn.clk.fclk_khz = (int)(bw_consumed * 1000000 /
-                               (ddr4_dram_factor_single_Channel * v->number_of_channels));
-               if (bw_consumed == v->fabric_and_dram_bandwidth_vmin0p65)
-                       context->bw_ctx.bw.dcn.clk.fclk_khz = (int)(bw_consumed * 1000000 / 32);
-
-               context->bw_ctx.bw.dcn.clk.dcfclk_deep_sleep_khz = (int)(v->dcf_clk_deep_sleep * 1000);
-               context->bw_ctx.bw.dcn.clk.dcfclk_khz = (int)(v->dcfclk * 1000);
-
-               context->bw_ctx.bw.dcn.clk.dispclk_khz = (int)(v->dispclk * 1000);
-               if (dc->debug.max_disp_clk == true)
-                       context->bw_ctx.bw.dcn.clk.dispclk_khz = (int)(dc->dcn_soc->max_dispclk_vmax0p9 * 1000);
-
-               if (context->bw_ctx.bw.dcn.clk.dispclk_khz <
-                               dc->debug.min_disp_clk_khz) {
-                       context->bw_ctx.bw.dcn.clk.dispclk_khz =
-                                       dc->debug.min_disp_clk_khz;
-               }
-
-               context->bw_ctx.bw.dcn.clk.dppclk_khz = context->bw_ctx.bw.dcn.clk.dispclk_khz /
-                               v->dispclk_dppclk_ratio;
-               context->bw_ctx.bw.dcn.clk.phyclk_khz = v->phyclk_per_state[v->voltage_level];
-               switch (v->voltage_level) {
-               case 0:
-                       context->bw_ctx.bw.dcn.clk.max_supported_dppclk_khz =
-                                       (int)(dc->dcn_soc->max_dppclk_vmin0p65 * 1000);
-                       break;
-               case 1:
-                       context->bw_ctx.bw.dcn.clk.max_supported_dppclk_khz =
-                                       (int)(dc->dcn_soc->max_dppclk_vmid0p72 * 1000);
-                       break;
-               case 2:
-                       context->bw_ctx.bw.dcn.clk.max_supported_dppclk_khz =
-                                       (int)(dc->dcn_soc->max_dppclk_vnom0p8 * 1000);
-                       break;
-               default:
-                       context->bw_ctx.bw.dcn.clk.max_supported_dppclk_khz =
-                                       (int)(dc->dcn_soc->max_dppclk_vmax0p9 * 1000);
-                       break;
-               }
-
-               BW_VAL_TRACE_END_WATERMARKS();
-
-               for (i = 0, input_idx = 0; i < pool->pipe_count; i++) {
-                       struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
-
-                       /* skip inactive pipe */
-                       if (!pipe->stream)
-                               continue;
-                       /* skip all but first of split pipes */
-                       if (pipe->top_pipe && pipe->top_pipe->plane_state == pipe->plane_state)
-                               continue;
-
-                       pipe->pipe_dlg_param.vupdate_width = v->v_update_width_pix[input_idx];
-                       pipe->pipe_dlg_param.vupdate_offset = v->v_update_offset_pix[input_idx];
-                       pipe->pipe_dlg_param.vready_offset = v->v_ready_offset_pix[input_idx];
-                       pipe->pipe_dlg_param.vstartup_start = v->v_startup[input_idx];
-
-                       pipe->pipe_dlg_param.htotal = pipe->stream->timing.h_total;
-                       pipe->pipe_dlg_param.vtotal = pipe->stream->timing.v_total;
-                       vesa_sync_start = pipe->stream->timing.v_addressable +
-                                               pipe->stream->timing.v_border_bottom +
-                                               pipe->stream->timing.v_front_porch;
-
-                       asic_blank_end = (pipe->stream->timing.v_total -
-                                               vesa_sync_start -
-                                               pipe->stream->timing.v_border_top)
-                       * (pipe->stream->timing.flags.INTERLACE ? 1 : 0);
-
-                       asic_blank_start = asic_blank_end +
-                                               (pipe->stream->timing.v_border_top +
-                                               pipe->stream->timing.v_addressable +
-                                               pipe->stream->timing.v_border_bottom)
-                       * (pipe->stream->timing.flags.INTERLACE ? 1 : 0);
-
-                       pipe->pipe_dlg_param.vblank_start = asic_blank_start;
-                       pipe->pipe_dlg_param.vblank_end = asic_blank_end;
-
-                       if (pipe->plane_state) {
-                               struct pipe_ctx *hsplit_pipe = pipe->bottom_pipe;
-
-                               pipe->plane_state->update_flags.bits.full_update = 1;
-
-                               if (v->dpp_per_plane[input_idx] == 2 ||
-                                       ((pipe->stream->view_format ==
-                                         VIEW_3D_FORMAT_SIDE_BY_SIDE ||
-                                         pipe->stream->view_format ==
-                                         VIEW_3D_FORMAT_TOP_AND_BOTTOM) &&
-                                       (pipe->stream->timing.timing_3d_format ==
-                                        TIMING_3D_FORMAT_TOP_AND_BOTTOM ||
-                                        pipe->stream->timing.timing_3d_format ==
-                                        TIMING_3D_FORMAT_SIDE_BY_SIDE))) {
-                                       if (hsplit_pipe && hsplit_pipe->plane_state == pipe->plane_state) {
-                                               /* update previously split pipe */
-                                               hsplit_pipe->pipe_dlg_param.vupdate_width = v->v_update_width_pix[input_idx];
-                                               hsplit_pipe->pipe_dlg_param.vupdate_offset = v->v_update_offset_pix[input_idx];
-                                               hsplit_pipe->pipe_dlg_param.vready_offset = v->v_ready_offset_pix[input_idx];
-                                               hsplit_pipe->pipe_dlg_param.vstartup_start = v->v_startup[input_idx];
-
-                                               hsplit_pipe->pipe_dlg_param.htotal = pipe->stream->timing.h_total;
-                                               hsplit_pipe->pipe_dlg_param.vtotal = pipe->stream->timing.v_total;
-                                               hsplit_pipe->pipe_dlg_param.vblank_start = pipe->pipe_dlg_param.vblank_start;
-                                               hsplit_pipe->pipe_dlg_param.vblank_end = pipe->pipe_dlg_param.vblank_end;
-                                       } else {
-                                               /* pipe not split previously needs split */
-                                               hsplit_pipe = find_idle_secondary_pipe(&context->res_ctx, pool, pipe);
-                                               ASSERT(hsplit_pipe);
-                                               split_stream_across_pipes(&context->res_ctx, pool, pipe, hsplit_pipe);
-                                       }
-
-                                       dcn_bw_calc_rq_dlg_ttu(dc, v, hsplit_pipe, input_idx);
-                               } else if (hsplit_pipe && hsplit_pipe->plane_state == pipe->plane_state) {
-                                       /* merge previously split pipe */
-                                       pipe->bottom_pipe = hsplit_pipe->bottom_pipe;
-                                       if (hsplit_pipe->bottom_pipe)
-                                               hsplit_pipe->bottom_pipe->top_pipe = pipe;
-                                       hsplit_pipe->plane_state = NULL;
-                                       hsplit_pipe->stream = NULL;
-                                       hsplit_pipe->top_pipe = NULL;
-                                       hsplit_pipe->bottom_pipe = NULL;
-                                       /* Clear plane_res and stream_res */
-                                       memset(&hsplit_pipe->plane_res, 0, sizeof(hsplit_pipe->plane_res));
-                                       memset(&hsplit_pipe->stream_res, 0, sizeof(hsplit_pipe->stream_res));
-                                       resource_build_scaling_params(pipe);
-                               }
-                               /* for now important to do this after pipe split for building e2e params */
-                               dcn_bw_calc_rq_dlg_ttu(dc, v, pipe, input_idx);
-                       }
-
-                       input_idx++;
-               }
-       } else if (v->voltage_level == number_of_states_plus_one) {
-               BW_VAL_TRACE_SKIP(fail);
-       } else if (fast_validate) {
-               BW_VAL_TRACE_SKIP(fast);
-       }
-
-       if (v->voltage_level == 0) {
-               context->bw_ctx.dml.soc.sr_enter_plus_exit_time_us =
-                               dc->dcn_soc->sr_enter_plus_exit_time;
-               context->bw_ctx.dml.soc.sr_exit_time_us = dc->dcn_soc->sr_exit_time;
-       }
-
-       /*
-        * BW limit is set to prevent display from impacting other system functions
-        */
-
-       bw_limit = dc->dcn_soc->percent_disp_bw_limit * v->fabric_and_dram_bandwidth_vmax0p9;
-       bw_limit_pass = (v->total_data_read_bandwidth / 1000.0) < bw_limit;
-
-       DC_FP_END();
-
-       PERFORMANCE_TRACE_END();
-       BW_VAL_TRACE_FINISH();
-
-       if (bw_limit_pass && v->voltage_level <= get_highest_allowed_voltage_level(
-                                                       dc->ctx->asic_id.chip_family,
-                                                       dc->ctx->asic_id.hw_internal_rev,
-                                                       dc->ctx->asic_id.pci_revision_id))
-               return true;
-       else
-               return false;
-}
-
-static unsigned int dcn_find_normalized_clock_vdd_Level(
-       const struct dc *dc,
-       enum dm_pp_clock_type clocks_type,
-       int clocks_in_khz)
-{
-       int vdd_level = dcn_bw_v_min0p65;
-
-       if (clocks_in_khz == 0)/*todo some clock not in the considerations*/
-               return vdd_level;
-
-       switch (clocks_type) {
-       case DM_PP_CLOCK_TYPE_DISPLAY_CLK:
-               if (clocks_in_khz > dc->dcn_soc->max_dispclk_vmax0p9*1000) {
-                       vdd_level = dcn_bw_v_max0p91;
-                       BREAK_TO_DEBUGGER();
-               } else if (clocks_in_khz > dc->dcn_soc->max_dispclk_vnom0p8*1000) {
-                       vdd_level = dcn_bw_v_max0p9;
-               } else if (clocks_in_khz > dc->dcn_soc->max_dispclk_vmid0p72*1000) {
-                       vdd_level = dcn_bw_v_nom0p8;
-               } else if (clocks_in_khz > dc->dcn_soc->max_dispclk_vmin0p65*1000) {
-                       vdd_level = dcn_bw_v_mid0p72;
-               } else
-                       vdd_level = dcn_bw_v_min0p65;
-               break;
-       case DM_PP_CLOCK_TYPE_DISPLAYPHYCLK:
-               if (clocks_in_khz > dc->dcn_soc->phyclkv_max0p9*1000) {
-                       vdd_level = dcn_bw_v_max0p91;
-                       BREAK_TO_DEBUGGER();
-               } else if (clocks_in_khz > dc->dcn_soc->phyclkv_nom0p8*1000) {
-                       vdd_level = dcn_bw_v_max0p9;
-               } else if (clocks_in_khz > dc->dcn_soc->phyclkv_mid0p72*1000) {
-                       vdd_level = dcn_bw_v_nom0p8;
-               } else if (clocks_in_khz > dc->dcn_soc->phyclkv_min0p65*1000) {
-                       vdd_level = dcn_bw_v_mid0p72;
-               } else
-                       vdd_level = dcn_bw_v_min0p65;
-               break;
-
-       case DM_PP_CLOCK_TYPE_DPPCLK:
-               if (clocks_in_khz > dc->dcn_soc->max_dppclk_vmax0p9*1000) {
-                       vdd_level = dcn_bw_v_max0p91;
-                       BREAK_TO_DEBUGGER();
-               } else if (clocks_in_khz > dc->dcn_soc->max_dppclk_vnom0p8*1000) {
-                       vdd_level = dcn_bw_v_max0p9;
-               } else if (clocks_in_khz > dc->dcn_soc->max_dppclk_vmid0p72*1000) {
-                       vdd_level = dcn_bw_v_nom0p8;
-               } else if (clocks_in_khz > dc->dcn_soc->max_dppclk_vmin0p65*1000) {
-                       vdd_level = dcn_bw_v_mid0p72;
-               } else
-                       vdd_level = dcn_bw_v_min0p65;
-               break;
-
-       case DM_PP_CLOCK_TYPE_MEMORY_CLK:
-               {
-                       unsigned factor = (ddr4_dram_factor_single_Channel * dc->dcn_soc->number_of_channels);
-
-                       if (clocks_in_khz > dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9*1000000/factor) {
-                               vdd_level = dcn_bw_v_max0p91;
-                               BREAK_TO_DEBUGGER();
-                       } else if (clocks_in_khz > dc->dcn_soc->fabric_and_dram_bandwidth_vnom0p8*1000000/factor) {
-                               vdd_level = dcn_bw_v_max0p9;
-                       } else if (clocks_in_khz > dc->dcn_soc->fabric_and_dram_bandwidth_vmid0p72*1000000/factor) {
-                               vdd_level = dcn_bw_v_nom0p8;
-                       } else if (clocks_in_khz > dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65*1000000/factor) {
-                               vdd_level = dcn_bw_v_mid0p72;
-                       } else
-                               vdd_level = dcn_bw_v_min0p65;
-               }
-               break;
-
-       case DM_PP_CLOCK_TYPE_DCFCLK:
-               if (clocks_in_khz > dc->dcn_soc->dcfclkv_max0p9*1000) {
-                       vdd_level = dcn_bw_v_max0p91;
-                       BREAK_TO_DEBUGGER();
-               } else if (clocks_in_khz > dc->dcn_soc->dcfclkv_nom0p8*1000) {
-                       vdd_level = dcn_bw_v_max0p9;
-               } else if (clocks_in_khz > dc->dcn_soc->dcfclkv_mid0p72*1000) {
-                       vdd_level = dcn_bw_v_nom0p8;
-               } else if (clocks_in_khz > dc->dcn_soc->dcfclkv_min0p65*1000) {
-                       vdd_level = dcn_bw_v_mid0p72;
-               } else
-                       vdd_level = dcn_bw_v_min0p65;
-               break;
-
-       default:
-                break;
-       }
-       return vdd_level;
-}
-
-unsigned int dcn_find_dcfclk_suits_all(
-       const struct dc *dc,
-       struct dc_clocks *clocks)
-{
-       unsigned vdd_level, vdd_level_temp;
-       unsigned dcf_clk;
-
-       /*find a common supported voltage level*/
-       vdd_level = dcn_find_normalized_clock_vdd_Level(
-               dc, DM_PP_CLOCK_TYPE_DISPLAY_CLK, clocks->dispclk_khz);
-       vdd_level_temp = dcn_find_normalized_clock_vdd_Level(
-               dc, DM_PP_CLOCK_TYPE_DISPLAYPHYCLK, clocks->phyclk_khz);
-
-       vdd_level = dcn_bw_max(vdd_level, vdd_level_temp);
-       vdd_level_temp = dcn_find_normalized_clock_vdd_Level(
-               dc, DM_PP_CLOCK_TYPE_DPPCLK, clocks->dppclk_khz);
-       vdd_level = dcn_bw_max(vdd_level, vdd_level_temp);
-
-       vdd_level_temp = dcn_find_normalized_clock_vdd_Level(
-               dc, DM_PP_CLOCK_TYPE_MEMORY_CLK, clocks->fclk_khz);
-       vdd_level = dcn_bw_max(vdd_level, vdd_level_temp);
-       vdd_level_temp = dcn_find_normalized_clock_vdd_Level(
-               dc, DM_PP_CLOCK_TYPE_DCFCLK, clocks->dcfclk_khz);
-
-       /*find that level conresponding dcfclk*/
-       vdd_level = dcn_bw_max(vdd_level, vdd_level_temp);
-       if (vdd_level == dcn_bw_v_max0p91) {
-               BREAK_TO_DEBUGGER();
-               dcf_clk = dc->dcn_soc->dcfclkv_max0p9*1000;
-       } else if (vdd_level == dcn_bw_v_max0p9)
-               dcf_clk =  dc->dcn_soc->dcfclkv_max0p9*1000;
-       else if (vdd_level == dcn_bw_v_nom0p8)
-               dcf_clk =  dc->dcn_soc->dcfclkv_nom0p8*1000;
-       else if (vdd_level == dcn_bw_v_mid0p72)
-               dcf_clk =  dc->dcn_soc->dcfclkv_mid0p72*1000;
-       else
-               dcf_clk =  dc->dcn_soc->dcfclkv_min0p65*1000;
-
-       DC_LOG_BANDWIDTH_CALCS("\tdcf_clk for voltage = %d\n", dcf_clk);
-       return dcf_clk;
-}
-
-static bool verify_clock_values(struct dm_pp_clock_levels_with_voltage *clks)
-{
-       int i;
-
-       if (clks->num_levels == 0)
-               return false;
-
-       for (i = 0; i < clks->num_levels; i++)
-               /* Ensure that the result is sane */
-               if (clks->data[i].clocks_in_khz == 0)
-                       return false;
-
-       return true;
-}
-
-void dcn_bw_update_from_pplib(struct dc *dc)
-{
-       struct dc_context *ctx = dc->ctx;
-       struct dm_pp_clock_levels_with_voltage fclks = {0}, dcfclks = {0};
-       bool res;
-       unsigned vmin0p65_idx, vmid0p72_idx, vnom0p8_idx, vmax0p9_idx;
-
-       /* TODO: This is not the proper way to obtain fabric_and_dram_bandwidth, should be min(fclk, memclk) */
-       res = dm_pp_get_clock_levels_by_type_with_voltage(
-                       ctx, DM_PP_CLOCK_TYPE_FCLK, &fclks);
-
-       DC_FP_START();
-
-       if (res)
-               res = verify_clock_values(&fclks);
-
-       if (res) {
-               ASSERT(fclks.num_levels);
-
-               vmin0p65_idx = 0;
-               vmid0p72_idx = fclks.num_levels -
-                       (fclks.num_levels > 2 ? 3 : (fclks.num_levels > 1 ? 2 : 1));
-               vnom0p8_idx = fclks.num_levels - (fclks.num_levels > 1 ? 2 : 1);
-               vmax0p9_idx = fclks.num_levels - 1;
-
-               dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65 =
-                       32 * (fclks.data[vmin0p65_idx].clocks_in_khz / 1000.0) / 1000.0;
-               dc->dcn_soc->fabric_and_dram_bandwidth_vmid0p72 =
-                       dc->dcn_soc->number_of_channels *
-                       (fclks.data[vmid0p72_idx].clocks_in_khz / 1000.0)
-                       * ddr4_dram_factor_single_Channel / 1000.0;
-               dc->dcn_soc->fabric_and_dram_bandwidth_vnom0p8 =
-                       dc->dcn_soc->number_of_channels *
-                       (fclks.data[vnom0p8_idx].clocks_in_khz / 1000.0)
-                       * ddr4_dram_factor_single_Channel / 1000.0;
-               dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9 =
-                       dc->dcn_soc->number_of_channels *
-                       (fclks.data[vmax0p9_idx].clocks_in_khz / 1000.0)
-                       * ddr4_dram_factor_single_Channel / 1000.0;
-       } else
-               BREAK_TO_DEBUGGER();
-
-       DC_FP_END();
-
-       res = dm_pp_get_clock_levels_by_type_with_voltage(
-                       ctx, DM_PP_CLOCK_TYPE_DCFCLK, &dcfclks);
-
-       DC_FP_START();
-
-       if (res)
-               res = verify_clock_values(&dcfclks);
-
-       if (res && dcfclks.num_levels >= 3) {
-               dc->dcn_soc->dcfclkv_min0p65 = dcfclks.data[0].clocks_in_khz / 1000.0;
-               dc->dcn_soc->dcfclkv_mid0p72 = dcfclks.data[dcfclks.num_levels - 3].clocks_in_khz / 1000.0;
-               dc->dcn_soc->dcfclkv_nom0p8 = dcfclks.data[dcfclks.num_levels - 2].clocks_in_khz / 1000.0;
-               dc->dcn_soc->dcfclkv_max0p9 = dcfclks.data[dcfclks.num_levels - 1].clocks_in_khz / 1000.0;
-       } else
-               BREAK_TO_DEBUGGER();
-
-       DC_FP_END();
-}
-
-void dcn_bw_notify_pplib_of_wm_ranges(struct dc *dc)
-{
-       struct pp_smu_funcs_rv *pp = NULL;
-       struct pp_smu_wm_range_sets ranges = {0};
-       int min_fclk_khz, min_dcfclk_khz, socclk_khz;
-       const int overdrive = 5000000; /* 5 GHz to cover Overdrive */
-
-       if (dc->res_pool->pp_smu)
-               pp = &dc->res_pool->pp_smu->rv_funcs;
-       if (!pp || !pp->set_wm_ranges)
-               return;
-
-       DC_FP_START();
-       min_fclk_khz = dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65 * 1000000 / 32;
-       min_dcfclk_khz = dc->dcn_soc->dcfclkv_min0p65 * 1000;
-       socclk_khz = dc->dcn_soc->socclk * 1000;
-       DC_FP_END();
-
-       /* Now notify PPLib/SMU about which Watermarks sets they should select
-        * depending on DPM state they are in. And update BW MGR GFX Engine and
-        * Memory clock member variables for Watermarks calculations for each
-        * Watermark Set. Only one watermark set for dcn1 due to hw bug DEGVIDCN10-254.
-        */
-       /* SOCCLK does not affect anytihng but writeback for DCN so for now we dont
-        * care what the value is, hence min to overdrive level
-        */
-       ranges.num_reader_wm_sets = WM_SET_COUNT;
-       ranges.num_writer_wm_sets = WM_SET_COUNT;
-       ranges.reader_wm_sets[0].wm_inst = WM_A;
-       ranges.reader_wm_sets[0].min_drain_clk_mhz = min_dcfclk_khz / 1000;
-       ranges.reader_wm_sets[0].max_drain_clk_mhz = overdrive / 1000;
-       ranges.reader_wm_sets[0].min_fill_clk_mhz = min_fclk_khz / 1000;
-       ranges.reader_wm_sets[0].max_fill_clk_mhz = overdrive / 1000;
-       ranges.writer_wm_sets[0].wm_inst = WM_A;
-       ranges.writer_wm_sets[0].min_fill_clk_mhz = socclk_khz / 1000;
-       ranges.writer_wm_sets[0].max_fill_clk_mhz = overdrive / 1000;
-       ranges.writer_wm_sets[0].min_drain_clk_mhz = min_fclk_khz / 1000;
-       ranges.writer_wm_sets[0].max_drain_clk_mhz = overdrive / 1000;
-
-       if (dc->debug.pplib_wm_report_mode == WM_REPORT_OVERRIDE) {
-               ranges.reader_wm_sets[0].wm_inst = WM_A;
-               ranges.reader_wm_sets[0].min_drain_clk_mhz = 300;
-               ranges.reader_wm_sets[0].max_drain_clk_mhz = 5000;
-               ranges.reader_wm_sets[0].min_fill_clk_mhz = 800;
-               ranges.reader_wm_sets[0].max_fill_clk_mhz = 5000;
-               ranges.writer_wm_sets[0].wm_inst = WM_A;
-               ranges.writer_wm_sets[0].min_fill_clk_mhz = 200;
-               ranges.writer_wm_sets[0].max_fill_clk_mhz = 5000;
-               ranges.writer_wm_sets[0].min_drain_clk_mhz = 800;
-               ranges.writer_wm_sets[0].max_drain_clk_mhz = 5000;
-       }
-
-       ranges.reader_wm_sets[1] = ranges.writer_wm_sets[0];
-       ranges.reader_wm_sets[1].wm_inst = WM_B;
-
-       ranges.reader_wm_sets[2] = ranges.writer_wm_sets[0];
-       ranges.reader_wm_sets[2].wm_inst = WM_C;
-
-       ranges.reader_wm_sets[3] = ranges.writer_wm_sets[0];
-       ranges.reader_wm_sets[3].wm_inst = WM_D;
-
-       /* Notify PP Lib/SMU which Watermarks to use for which clock ranges */
-       pp->set_wm_ranges(&pp->pp_smu, &ranges);
-}
-
-void dcn_bw_sync_calcs_and_dml(struct dc *dc)
-{
-       DC_FP_START();
-       DC_LOG_BANDWIDTH_CALCS("sr_exit_time: %f ns\n"
-                       "sr_enter_plus_exit_time: %f ns\n"
-                       "urgent_latency: %f ns\n"
-                       "write_back_latency: %f ns\n"
-                       "percent_of_ideal_drambw_received_after_urg_latency: %f %%\n"
-                       "max_request_size: %d bytes\n"
-                       "dcfclkv_max0p9: %f kHz\n"
-                       "dcfclkv_nom0p8: %f kHz\n"
-                       "dcfclkv_mid0p72: %f kHz\n"
-                       "dcfclkv_min0p65: %f kHz\n"
-                       "max_dispclk_vmax0p9: %f kHz\n"
-                       "max_dispclk_vnom0p8: %f kHz\n"
-                       "max_dispclk_vmid0p72: %f kHz\n"
-                       "max_dispclk_vmin0p65: %f kHz\n"
-                       "max_dppclk_vmax0p9: %f kHz\n"
-                       "max_dppclk_vnom0p8: %f kHz\n"
-                       "max_dppclk_vmid0p72: %f kHz\n"
-                       "max_dppclk_vmin0p65: %f kHz\n"
-                       "socclk: %f kHz\n"
-                       "fabric_and_dram_bandwidth_vmax0p9: %f MB/s\n"
-                       "fabric_and_dram_bandwidth_vnom0p8: %f MB/s\n"
-                       "fabric_and_dram_bandwidth_vmid0p72: %f MB/s\n"
-                       "fabric_and_dram_bandwidth_vmin0p65: %f MB/s\n"
-                       "phyclkv_max0p9: %f kHz\n"
-                       "phyclkv_nom0p8: %f kHz\n"
-                       "phyclkv_mid0p72: %f kHz\n"
-                       "phyclkv_min0p65: %f kHz\n"
-                       "downspreading: %f %%\n"
-                       "round_trip_ping_latency_cycles: %d DCFCLK Cycles\n"
-                       "urgent_out_of_order_return_per_channel: %d Bytes\n"
-                       "number_of_channels: %d\n"
-                       "vmm_page_size: %d Bytes\n"
-                       "dram_clock_change_latency: %f ns\n"
-                       "return_bus_width: %d Bytes\n",
-                       dc->dcn_soc->sr_exit_time * 1000,
-                       dc->dcn_soc->sr_enter_plus_exit_time * 1000,
-                       dc->dcn_soc->urgent_latency * 1000,
-                       dc->dcn_soc->write_back_latency * 1000,
-                       dc->dcn_soc->percent_of_ideal_drambw_received_after_urg_latency,
-                       dc->dcn_soc->max_request_size,
-                       dc->dcn_soc->dcfclkv_max0p9 * 1000,
-                       dc->dcn_soc->dcfclkv_nom0p8 * 1000,
-                       dc->dcn_soc->dcfclkv_mid0p72 * 1000,
-                       dc->dcn_soc->dcfclkv_min0p65 * 1000,
-                       dc->dcn_soc->max_dispclk_vmax0p9 * 1000,
-                       dc->dcn_soc->max_dispclk_vnom0p8 * 1000,
-                       dc->dcn_soc->max_dispclk_vmid0p72 * 1000,
-                       dc->dcn_soc->max_dispclk_vmin0p65 * 1000,
-                       dc->dcn_soc->max_dppclk_vmax0p9 * 1000,
-                       dc->dcn_soc->max_dppclk_vnom0p8 * 1000,
-                       dc->dcn_soc->max_dppclk_vmid0p72 * 1000,
-                       dc->dcn_soc->max_dppclk_vmin0p65 * 1000,
-                       dc->dcn_soc->socclk * 1000,
-                       dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9 * 1000,
-                       dc->dcn_soc->fabric_and_dram_bandwidth_vnom0p8 * 1000,
-                       dc->dcn_soc->fabric_and_dram_bandwidth_vmid0p72 * 1000,
-                       dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65 * 1000,
-                       dc->dcn_soc->phyclkv_max0p9 * 1000,
-                       dc->dcn_soc->phyclkv_nom0p8 * 1000,
-                       dc->dcn_soc->phyclkv_mid0p72 * 1000,
-                       dc->dcn_soc->phyclkv_min0p65 * 1000,
-                       dc->dcn_soc->downspreading * 100,
-                       dc->dcn_soc->round_trip_ping_latency_cycles,
-                       dc->dcn_soc->urgent_out_of_order_return_per_channel,
-                       dc->dcn_soc->number_of_channels,
-                       dc->dcn_soc->vmm_page_size,
-                       dc->dcn_soc->dram_clock_change_latency * 1000,
-                       dc->dcn_soc->return_bus_width);
-       DC_LOG_BANDWIDTH_CALCS("rob_buffer_size_in_kbyte: %f\n"
-                       "det_buffer_size_in_kbyte: %f\n"
-                       "dpp_output_buffer_pixels: %f\n"
-                       "opp_output_buffer_lines: %f\n"
-                       "pixel_chunk_size_in_kbyte: %f\n"
-                       "pte_enable: %d\n"
-                       "pte_chunk_size: %d kbytes\n"
-                       "meta_chunk_size: %d kbytes\n"
-                       "writeback_chunk_size: %d kbytes\n"
-                       "odm_capability: %d\n"
-                       "dsc_capability: %d\n"
-                       "line_buffer_size: %d bits\n"
-                       "max_line_buffer_lines: %d\n"
-                       "is_line_buffer_bpp_fixed: %d\n"
-                       "line_buffer_fixed_bpp: %d\n"
-                       "writeback_luma_buffer_size: %d kbytes\n"
-                       "writeback_chroma_buffer_size: %d kbytes\n"
-                       "max_num_dpp: %d\n"
-                       "max_num_writeback: %d\n"
-                       "max_dchub_topscl_throughput: %d pixels/dppclk\n"
-                       "max_pscl_tolb_throughput: %d pixels/dppclk\n"
-                       "max_lb_tovscl_throughput: %d pixels/dppclk\n"
-                       "max_vscl_tohscl_throughput: %d pixels/dppclk\n"
-                       "max_hscl_ratio: %f\n"
-                       "max_vscl_ratio: %f\n"
-                       "max_hscl_taps: %d\n"
-                       "max_vscl_taps: %d\n"
-                       "pte_buffer_size_in_requests: %d\n"
-                       "dispclk_ramping_margin: %f %%\n"
-                       "under_scan_factor: %f %%\n"
-                       "max_inter_dcn_tile_repeaters: %d\n"
-                       "can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one: %d\n"
-                       "bug_forcing_luma_and_chroma_request_to_same_size_fixed: %d\n"
-                       "dcfclk_cstate_latency: %d\n",
-                       dc->dcn_ip->rob_buffer_size_in_kbyte,
-                       dc->dcn_ip->det_buffer_size_in_kbyte,
-                       dc->dcn_ip->dpp_output_buffer_pixels,
-                       dc->dcn_ip->opp_output_buffer_lines,
-                       dc->dcn_ip->pixel_chunk_size_in_kbyte,
-                       dc->dcn_ip->pte_enable,
-                       dc->dcn_ip->pte_chunk_size,
-                       dc->dcn_ip->meta_chunk_size,
-                       dc->dcn_ip->writeback_chunk_size,
-                       dc->dcn_ip->odm_capability,
-                       dc->dcn_ip->dsc_capability,
-                       dc->dcn_ip->line_buffer_size,
-                       dc->dcn_ip->max_line_buffer_lines,
-                       dc->dcn_ip->is_line_buffer_bpp_fixed,
-                       dc->dcn_ip->line_buffer_fixed_bpp,
-                       dc->dcn_ip->writeback_luma_buffer_size,
-                       dc->dcn_ip->writeback_chroma_buffer_size,
-                       dc->dcn_ip->max_num_dpp,
-                       dc->dcn_ip->max_num_writeback,
-                       dc->dcn_ip->max_dchub_topscl_throughput,
-                       dc->dcn_ip->max_pscl_tolb_throughput,
-                       dc->dcn_ip->max_lb_tovscl_throughput,
-                       dc->dcn_ip->max_vscl_tohscl_throughput,
-                       dc->dcn_ip->max_hscl_ratio,
-                       dc->dcn_ip->max_vscl_ratio,
-                       dc->dcn_ip->max_hscl_taps,
-                       dc->dcn_ip->max_vscl_taps,
-                       dc->dcn_ip->pte_buffer_size_in_requests,
-                       dc->dcn_ip->dispclk_ramping_margin,
-                       dc->dcn_ip->under_scan_factor * 100,
-                       dc->dcn_ip->max_inter_dcn_tile_repeaters,
-                       dc->dcn_ip->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one,
-                       dc->dcn_ip->bug_forcing_luma_and_chroma_request_to_same_size_fixed,
-                       dc->dcn_ip->dcfclk_cstate_latency);
-
-       dc->dml.soc.sr_exit_time_us = dc->dcn_soc->sr_exit_time;
-       dc->dml.soc.sr_enter_plus_exit_time_us = dc->dcn_soc->sr_enter_plus_exit_time;
-       dc->dml.soc.urgent_latency_us = dc->dcn_soc->urgent_latency;
-       dc->dml.soc.writeback_latency_us = dc->dcn_soc->write_back_latency;
-       dc->dml.soc.ideal_dram_bw_after_urgent_percent =
-                       dc->dcn_soc->percent_of_ideal_drambw_received_after_urg_latency;
-       dc->dml.soc.max_request_size_bytes = dc->dcn_soc->max_request_size;
-       dc->dml.soc.downspread_percent = dc->dcn_soc->downspreading;
-       dc->dml.soc.round_trip_ping_latency_dcfclk_cycles =
-                       dc->dcn_soc->round_trip_ping_latency_cycles;
-       dc->dml.soc.urgent_out_of_order_return_per_channel_bytes =
-                       dc->dcn_soc->urgent_out_of_order_return_per_channel;
-       dc->dml.soc.num_chans = dc->dcn_soc->number_of_channels;
-       dc->dml.soc.vmm_page_size_bytes = dc->dcn_soc->vmm_page_size;
-       dc->dml.soc.dram_clock_change_latency_us = dc->dcn_soc->dram_clock_change_latency;
-       dc->dml.soc.return_bus_width_bytes = dc->dcn_soc->return_bus_width;
-
-       dc->dml.ip.rob_buffer_size_kbytes = dc->dcn_ip->rob_buffer_size_in_kbyte;
-       dc->dml.ip.det_buffer_size_kbytes = dc->dcn_ip->det_buffer_size_in_kbyte;
-       dc->dml.ip.dpp_output_buffer_pixels = dc->dcn_ip->dpp_output_buffer_pixels;
-       dc->dml.ip.opp_output_buffer_lines = dc->dcn_ip->opp_output_buffer_lines;
-       dc->dml.ip.pixel_chunk_size_kbytes = dc->dcn_ip->pixel_chunk_size_in_kbyte;
-       dc->dml.ip.pte_enable = dc->dcn_ip->pte_enable == dcn_bw_yes;
-       dc->dml.ip.pte_chunk_size_kbytes = dc->dcn_ip->pte_chunk_size;
-       dc->dml.ip.meta_chunk_size_kbytes = dc->dcn_ip->meta_chunk_size;
-       dc->dml.ip.writeback_chunk_size_kbytes = dc->dcn_ip->writeback_chunk_size;
-       dc->dml.ip.line_buffer_size_bits = dc->dcn_ip->line_buffer_size;
-       dc->dml.ip.max_line_buffer_lines = dc->dcn_ip->max_line_buffer_lines;
-       dc->dml.ip.IsLineBufferBppFixed = dc->dcn_ip->is_line_buffer_bpp_fixed == dcn_bw_yes;
-       dc->dml.ip.LineBufferFixedBpp = dc->dcn_ip->line_buffer_fixed_bpp;
-       dc->dml.ip.writeback_luma_buffer_size_kbytes = dc->dcn_ip->writeback_luma_buffer_size;
-       dc->dml.ip.writeback_chroma_buffer_size_kbytes = dc->dcn_ip->writeback_chroma_buffer_size;
-       dc->dml.ip.max_num_dpp = dc->dcn_ip->max_num_dpp;
-       dc->dml.ip.max_num_wb = dc->dcn_ip->max_num_writeback;
-       dc->dml.ip.max_dchub_pscl_bw_pix_per_clk = dc->dcn_ip->max_dchub_topscl_throughput;
-       dc->dml.ip.max_pscl_lb_bw_pix_per_clk = dc->dcn_ip->max_pscl_tolb_throughput;
-       dc->dml.ip.max_lb_vscl_bw_pix_per_clk = dc->dcn_ip->max_lb_tovscl_throughput;
-       dc->dml.ip.max_vscl_hscl_bw_pix_per_clk = dc->dcn_ip->max_vscl_tohscl_throughput;
-       dc->dml.ip.max_hscl_ratio = dc->dcn_ip->max_hscl_ratio;
-       dc->dml.ip.max_vscl_ratio = dc->dcn_ip->max_vscl_ratio;
-       dc->dml.ip.max_hscl_taps = dc->dcn_ip->max_hscl_taps;
-       dc->dml.ip.max_vscl_taps = dc->dcn_ip->max_vscl_taps;
-       /*pte_buffer_size_in_requests missing in dml*/
-       dc->dml.ip.dispclk_ramp_margin_percent = dc->dcn_ip->dispclk_ramping_margin;
-       dc->dml.ip.underscan_factor = dc->dcn_ip->under_scan_factor;
-       dc->dml.ip.max_inter_dcn_tile_repeaters = dc->dcn_ip->max_inter_dcn_tile_repeaters;
-       dc->dml.ip.can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one =
-               dc->dcn_ip->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one == dcn_bw_yes;
-       dc->dml.ip.bug_forcing_LC_req_same_size_fixed =
-               dc->dcn_ip->bug_forcing_luma_and_chroma_request_to_same_size_fixed == dcn_bw_yes;
-       dc->dml.ip.dcfclk_cstate_latency = dc->dcn_ip->dcfclk_cstate_latency;
-       DC_FP_END();
-}
index 06910b1f5965df74e4c60493af1d6b82fdd164f9..b16c492593e23737410139944dd34094da0eaf5b 100644 (file)
@@ -74,6 +74,9 @@ CFLAGS_$(AMDDALPATH)/dc/dml/dcn301/dcn301_fpu.o := $(dml_ccflags)
 CFLAGS_$(AMDDALPATH)/dc/dml/dcn302/dcn302_fpu.o := $(dml_ccflags)
 CFLAGS_$(AMDDALPATH)/dc/dml/dsc/rc_calc_fpu.o := $(dml_ccflags)
 CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_lib.o := $(dml_ccflags)
+CFLAGS_$(AMDDALPATH)/dc/dml/calcs/dcn_calcs.o := $(dml_ccflags)
+CFLAGS_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_auto.o := $(dml_ccflags)
+CFLAGS_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_math.o := $(dml_ccflags) -Wno-tautological-compare
 CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/display_mode_vba.o := $(dml_rcflags)
 CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn2x/dcn2x.o := $(dml_rcflags)
 CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn20/display_mode_vba_20.o := $(dml_rcflags)
@@ -94,10 +97,14 @@ CFLAGS_$(AMDDALPATH)/dc/dml/dml1_display_rq_dlg_calc.o := $(dml_ccflags)
 CFLAGS_$(AMDDALPATH)/dc/dml/display_rq_dlg_helpers.o := $(dml_ccflags)
 CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dml1_display_rq_dlg_calc.o := $(dml_rcflags)
 CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/display_rq_dlg_helpers.o := $(dml_rcflags)
+CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/calcs/dcn_calcs.o := $(dml_rcflags)
+CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_auto.o := $(dml_rcflags)
+CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/calcs/dcn_calc_math.o := $(dml_rcflags)
 
-DML = display_mode_lib.o display_rq_dlg_helpers.o dml1_display_rq_dlg_calc.o \
+DML = calcs/dce_calcs.o calcs/custom_float.o calcs/bw_fixed.o
 
 ifdef CONFIG_DRM_AMD_DC_DCN
+DML += display_mode_lib.o display_rq_dlg_helpers.o dml1_display_rq_dlg_calc.o
 DML += dcn20/dcn20_fpu.o
 DML += display_mode_vba.o dcn20/display_rq_dlg_calc_20.o dcn20/display_mode_vba_20.o
 DML += dcn20/display_rq_dlg_calc_20v2.o dcn20/display_mode_vba_20v2.o
@@ -107,6 +114,7 @@ DML += dcn31/display_mode_vba_31.o dcn31/display_rq_dlg_calc_31.o
 DML += dcn301/dcn301_fpu.o
 DML += dcn302/dcn302_fpu.o
 DML += dsc/rc_calc_fpu.o
+DML += calcs/dcn_calcs.o calcs/dcn_calc_math.o calcs/dcn_calc_auto.o
 endif
 
 AMD_DAL_DML = $(addprefix $(AMDDALPATH)/dc/dml/,$(DML))
diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/bw_fixed.c b/drivers/gpu/drm/amd/display/dc/dml/calcs/bw_fixed.c
new file mode 100644 (file)
index 0000000..6ca288f
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+#include "dm_services.h"
+#include "bw_fixed.h"
+
+
+#define MIN_I64 \
+       (int64_t)(-(1LL << 63))
+
+#define MAX_I64 \
+       (int64_t)((1ULL << 63) - 1)
+
+#define FRACTIONAL_PART_MASK \
+       ((1ULL << BW_FIXED_BITS_PER_FRACTIONAL_PART) - 1)
+
+#define GET_FRACTIONAL_PART(x) \
+       (FRACTIONAL_PART_MASK & (x))
+
+static uint64_t abs_i64(int64_t arg)
+{
+       if (arg >= 0)
+               return (uint64_t)(arg);
+       else
+               return (uint64_t)(-arg);
+}
+
+struct bw_fixed bw_int_to_fixed_nonconst(int64_t value)
+{
+       struct bw_fixed res;
+       ASSERT(value < BW_FIXED_MAX_I32 && value > BW_FIXED_MIN_I32);
+       res.value = value << BW_FIXED_BITS_PER_FRACTIONAL_PART;
+       return res;
+}
+
+struct bw_fixed bw_frc_to_fixed(int64_t numerator, int64_t denominator)
+{
+       struct bw_fixed res;
+       bool arg1_negative = numerator < 0;
+       bool arg2_negative = denominator < 0;
+       uint64_t arg1_value;
+       uint64_t arg2_value;
+       uint64_t remainder;
+
+       /* determine integer part */
+       uint64_t res_value;
+
+       ASSERT(denominator != 0);
+
+       arg1_value = abs_i64(numerator);
+       arg2_value = abs_i64(denominator);
+       res_value = div64_u64_rem(arg1_value, arg2_value, &remainder);
+
+       ASSERT(res_value <= BW_FIXED_MAX_I32);
+
+       /* determine fractional part */
+       {
+               uint32_t i = BW_FIXED_BITS_PER_FRACTIONAL_PART;
+
+               do
+               {
+                       remainder <<= 1;
+
+                       res_value <<= 1;
+
+                       if (remainder >= arg2_value)
+                       {
+                               res_value |= 1;
+                               remainder -= arg2_value;
+                       }
+               } while (--i != 0);
+       }
+
+       /* round up LSB */
+       {
+               uint64_t summand = (remainder << 1) >= arg2_value;
+
+               ASSERT(res_value <= MAX_I64 - summand);
+
+               res_value += summand;
+       }
+
+       res.value = (int64_t)(res_value);
+
+       if (arg1_negative ^ arg2_negative)
+               res.value = -res.value;
+       return res;
+}
+
+struct bw_fixed bw_floor2(
+       const struct bw_fixed arg,
+       const struct bw_fixed significance)
+{
+       struct bw_fixed result;
+       int64_t multiplicand;
+
+       multiplicand = div64_s64(arg.value, abs_i64(significance.value));
+       result.value = abs_i64(significance.value) * multiplicand;
+       ASSERT(abs_i64(result.value) <= abs_i64(arg.value));
+       return result;
+}
+
+struct bw_fixed bw_ceil2(
+       const struct bw_fixed arg,
+       const struct bw_fixed significance)
+{
+       struct bw_fixed result;
+       int64_t multiplicand;
+
+       multiplicand = div64_s64(arg.value, abs_i64(significance.value));
+       result.value = abs_i64(significance.value) * multiplicand;
+       if (abs_i64(result.value) < abs_i64(arg.value)) {
+               if (arg.value < 0)
+                       result.value -= abs_i64(significance.value);
+               else
+                       result.value += abs_i64(significance.value);
+       }
+       return result;
+}
+
+struct bw_fixed bw_mul(const struct bw_fixed arg1, const struct bw_fixed arg2)
+{
+       struct bw_fixed res;
+
+       bool arg1_negative = arg1.value < 0;
+       bool arg2_negative = arg2.value < 0;
+
+       uint64_t arg1_value = abs_i64(arg1.value);
+       uint64_t arg2_value = abs_i64(arg2.value);
+
+       uint64_t arg1_int = BW_FIXED_GET_INTEGER_PART(arg1_value);
+       uint64_t arg2_int = BW_FIXED_GET_INTEGER_PART(arg2_value);
+
+       uint64_t arg1_fra = GET_FRACTIONAL_PART(arg1_value);
+       uint64_t arg2_fra = GET_FRACTIONAL_PART(arg2_value);
+
+       uint64_t tmp;
+
+       res.value = arg1_int * arg2_int;
+
+       ASSERT(res.value <= BW_FIXED_MAX_I32);
+
+       res.value <<= BW_FIXED_BITS_PER_FRACTIONAL_PART;
+
+       tmp = arg1_int * arg2_fra;
+
+       ASSERT(tmp <= (uint64_t)(MAX_I64 - res.value));
+
+       res.value += tmp;
+
+       tmp = arg2_int * arg1_fra;
+
+       ASSERT(tmp <= (uint64_t)(MAX_I64 - res.value));
+
+       res.value += tmp;
+
+       tmp = arg1_fra * arg2_fra;
+
+       tmp = (tmp >> BW_FIXED_BITS_PER_FRACTIONAL_PART) +
+               (tmp >= (uint64_t)(bw_frc_to_fixed(1, 2).value));
+
+       ASSERT(tmp <= (uint64_t)(MAX_I64 - res.value));
+
+       res.value += tmp;
+
+       if (arg1_negative ^ arg2_negative)
+               res.value = -res.value;
+       return res;
+}
+
diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/calcs_logger.h b/drivers/gpu/drm/amd/display/dc/dml/calcs/calcs_logger.h
new file mode 100644 (file)
index 0000000..62435bf
--- /dev/null
@@ -0,0 +1,578 @@
+/*
+ * Copyright 2018 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
+#ifndef _CALCS_CALCS_LOGGER_H_
+#define _CALCS_CALCS_LOGGER_H_
+#define DC_LOGGER ctx->logger
+
+static void print_bw_calcs_dceip(struct dc_context *ctx, const struct bw_calcs_dceip *dceip)
+{
+
+       DC_LOG_BANDWIDTH_CALCS("#####################################################################");
+       DC_LOG_BANDWIDTH_CALCS("struct bw_calcs_dceip");
+       DC_LOG_BANDWIDTH_CALCS("#####################################################################");
+       DC_LOG_BANDWIDTH_CALCS("        [enum]   bw_calcs_version version %d", dceip->version);
+       DC_LOG_BANDWIDTH_CALCS("        [bool] large_cursor: %d", dceip->large_cursor);
+       DC_LOG_BANDWIDTH_CALCS("        [bool] dmif_pipe_en_fbc_chunk_tracker: %d", dceip->dmif_pipe_en_fbc_chunk_tracker);
+       DC_LOG_BANDWIDTH_CALCS("        [bool] display_write_back_supported: %d", dceip->display_write_back_supported);
+       DC_LOG_BANDWIDTH_CALCS("        [bool] argb_compression_support: %d", dceip->argb_compression_support);
+       DC_LOG_BANDWIDTH_CALCS("        [bool] pre_downscaler_enabled: %d", dceip->pre_downscaler_enabled);
+       DC_LOG_BANDWIDTH_CALCS("        [bool] underlay_downscale_prefetch_enabled: %d",
+                               dceip->underlay_downscale_prefetch_enabled);
+       DC_LOG_BANDWIDTH_CALCS("        [bool] graphics_lb_nodownscaling_multi_line_prefetching: %d",
+                               dceip->graphics_lb_nodownscaling_multi_line_prefetching);
+       DC_LOG_BANDWIDTH_CALCS("        [bool] limit_excessive_outstanding_dmif_requests: %d",
+                               dceip->limit_excessive_outstanding_dmif_requests);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] cursor_max_outstanding_group_num: %d",
+                               dceip->cursor_max_outstanding_group_num);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] lines_interleaved_into_lb: %d", dceip->lines_interleaved_into_lb);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] low_power_tiling_mode: %d", dceip->low_power_tiling_mode);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] chunk_width: %d", dceip->chunk_width);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_graphics_pipes: %d", dceip->number_of_graphics_pipes);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_underlay_pipes: %d", dceip->number_of_underlay_pipes);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] max_dmif_buffer_allocated: %d", dceip->max_dmif_buffer_allocated);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] graphics_dmif_size: %d", dceip->graphics_dmif_size);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] underlay_luma_dmif_size: %d", dceip->underlay_luma_dmif_size);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] underlay_chroma_dmif_size: %d", dceip->underlay_chroma_dmif_size);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] scatter_gather_lines_of_pte_prefetching_in_linear_mode: %d",
+                               dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] display_write_back420_luma_mcifwr_buffer_size: %d",
+                               dceip->display_write_back420_luma_mcifwr_buffer_size);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] display_write_back420_chroma_mcifwr_buffer_size: %d",
+                               dceip->display_write_back420_chroma_mcifwr_buffer_size);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] scatter_gather_pte_request_rows_in_tiling_mode: %d",
+                               dceip->scatter_gather_pte_request_rows_in_tiling_mode);
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay_vscaler_efficiency10_bit_per_component: %d",
+                               bw_fixed_to_int(dceip->underlay_vscaler_efficiency10_bit_per_component));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay_vscaler_efficiency12_bit_per_component: %d",
+                               bw_fixed_to_int(dceip->underlay_vscaler_efficiency12_bit_per_component));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] graphics_vscaler_efficiency6_bit_per_component: %d",
+                               bw_fixed_to_int(dceip->graphics_vscaler_efficiency6_bit_per_component));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] graphics_vscaler_efficiency8_bit_per_component: %d",
+                               bw_fixed_to_int(dceip->graphics_vscaler_efficiency8_bit_per_component));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] graphics_vscaler_efficiency10_bit_per_component: %d",
+                               bw_fixed_to_int(dceip->graphics_vscaler_efficiency10_bit_per_component));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] graphics_vscaler_efficiency12_bit_per_component: %d",
+                               bw_fixed_to_int(dceip->graphics_vscaler_efficiency12_bit_per_component));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] alpha_vscaler_efficiency: %d",
+                               bw_fixed_to_int(dceip->alpha_vscaler_efficiency));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_write_pixels_per_dispclk: %d",
+                               bw_fixed_to_int(dceip->lb_write_pixels_per_dispclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_size_per_component444: %d",
+                               bw_fixed_to_int(dceip->lb_size_per_component444));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_and_dram_clock_state_change_gated_before_cursor: %d",
+                               bw_fixed_to_int(dceip->stutter_and_dram_clock_state_change_gated_before_cursor));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay420_luma_lb_size_per_component: %d",
+                               bw_fixed_to_int(dceip->underlay420_luma_lb_size_per_component));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay420_chroma_lb_size_per_component: %d",
+                               bw_fixed_to_int(dceip->underlay420_chroma_lb_size_per_component));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay422_lb_size_per_component: %d",
+                               bw_fixed_to_int(dceip->underlay422_lb_size_per_component));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] cursor_chunk_width: %d", bw_fixed_to_int(dceip->cursor_chunk_width));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] cursor_dcp_buffer_lines: %d",
+                               bw_fixed_to_int(dceip->cursor_dcp_buffer_lines));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay_maximum_width_efficient_for_tiling: %d",
+                               bw_fixed_to_int(dceip->underlay_maximum_width_efficient_for_tiling));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay_maximum_height_efficient_for_tiling: %d",
+                               bw_fixed_to_int(dceip->underlay_maximum_height_efficient_for_tiling));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display: %d",
+                               bw_fixed_to_int(dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation: %d",
+                               bw_fixed_to_int(dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] minimum_outstanding_pte_request_limit: %d",
+                               bw_fixed_to_int(dceip->minimum_outstanding_pte_request_limit));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] maximum_total_outstanding_pte_requests_allowed_by_saw: %d",
+                               bw_fixed_to_int(dceip->maximum_total_outstanding_pte_requests_allowed_by_saw));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] linear_mode_line_request_alternation_slice: %d",
+                               bw_fixed_to_int(dceip->linear_mode_line_request_alternation_slice));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] request_efficiency: %d", bw_fixed_to_int(dceip->request_efficiency));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_per_request: %d", bw_fixed_to_int(dceip->dispclk_per_request));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_ramping_factor: %d",
+                               bw_fixed_to_int(dceip->dispclk_ramping_factor));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_pipe_throughput_factor: %d",
+                               bw_fixed_to_int(dceip->display_pipe_throughput_factor));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwr_all_surfaces_burst_time: %d",
+                               bw_fixed_to_int(dceip->mcifwr_all_surfaces_burst_time));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_request_buffer_size: %d",
+                               bw_fixed_to_int(dceip->dmif_request_buffer_size));
+
+
+}
+
+static void print_bw_calcs_vbios(struct dc_context *ctx, const struct bw_calcs_vbios *vbios)
+{
+
+       DC_LOG_BANDWIDTH_CALCS("#####################################################################");
+       DC_LOG_BANDWIDTH_CALCS("struct bw_calcs_vbios vbios");
+       DC_LOG_BANDWIDTH_CALCS("#####################################################################");
+       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines memory_type: %d", vbios->memory_type);
+       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines memory_type: %d", vbios->memory_type);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] dram_channel_width_in_bits: %d", vbios->dram_channel_width_in_bits);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_dram_channels: %d", vbios->number_of_dram_channels);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_dram_banks: %d", vbios->number_of_dram_banks);
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] low_yclk: %d", bw_fixed_to_int(vbios->low_yclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid_yclk: %d", bw_fixed_to_int(vbios->mid_yclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] high_yclk: %d", bw_fixed_to_int(vbios->high_yclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] low_sclk: %d", bw_fixed_to_int(vbios->low_sclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid1_sclk: %d", bw_fixed_to_int(vbios->mid1_sclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid2_sclk: %d", bw_fixed_to_int(vbios->mid2_sclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid3_sclk: %d", bw_fixed_to_int(vbios->mid3_sclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid4_sclk: %d", bw_fixed_to_int(vbios->mid4_sclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid5_sclk: %d", bw_fixed_to_int(vbios->mid5_sclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid6_sclk: %d", bw_fixed_to_int(vbios->mid6_sclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] high_sclk: %d", bw_fixed_to_int(vbios->high_sclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] low_voltage_max_dispclk: %d",
+                               bw_fixed_to_int(vbios->low_voltage_max_dispclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid_voltage_max_dispclk;: %d",
+                               bw_fixed_to_int(vbios->mid_voltage_max_dispclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] high_voltage_max_dispclk;: %d",
+                               bw_fixed_to_int(vbios->high_voltage_max_dispclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] low_voltage_max_phyclk: %d",
+                               bw_fixed_to_int(vbios->low_voltage_max_phyclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mid_voltage_max_phyclk: %d",
+                               bw_fixed_to_int(vbios->mid_voltage_max_phyclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] high_voltage_max_phyclk: %d",
+                               bw_fixed_to_int(vbios->high_voltage_max_phyclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] data_return_bus_width: %d", bw_fixed_to_int(vbios->data_return_bus_width));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] trc: %d", bw_fixed_to_int(vbios->trc));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmifmc_urgent_latency: %d", bw_fixed_to_int(vbios->dmifmc_urgent_latency));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_self_refresh_exit_latency: %d",
+                               bw_fixed_to_int(vbios->stutter_self_refresh_exit_latency));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_self_refresh_entry_latency: %d",
+                               bw_fixed_to_int(vbios->stutter_self_refresh_entry_latency));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] nbp_state_change_latency: %d",
+                               bw_fixed_to_int(vbios->nbp_state_change_latency));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwrmc_urgent_latency: %d",
+                               bw_fixed_to_int(vbios->mcifwrmc_urgent_latency));
+       DC_LOG_BANDWIDTH_CALCS("        [bool] scatter_gather_enable: %d", vbios->scatter_gather_enable);
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] down_spread_percentage: %d",
+                               bw_fixed_to_int(vbios->down_spread_percentage));
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] cursor_width: %d", vbios->cursor_width);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] average_compression_rate: %d", vbios->average_compression_rate);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_request_slots_gmc_reserves_for_dmif_per_channel: %d",
+                               vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel);
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] blackout_duration: %d", bw_fixed_to_int(vbios->blackout_duration));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] maximum_blackout_recovery_time: %d",
+                               bw_fixed_to_int(vbios->maximum_blackout_recovery_time));
+
+
+}
+
+static void print_bw_calcs_data(struct dc_context *ctx, struct bw_calcs_data *data)
+{
+
+       int i, j, k;
+
+       DC_LOG_BANDWIDTH_CALCS("#####################################################################");
+       DC_LOG_BANDWIDTH_CALCS("struct bw_calcs_data data");
+       DC_LOG_BANDWIDTH_CALCS("#####################################################################");
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_displays: %d", data->number_of_displays);
+       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines underlay_surface_type: %d", data->underlay_surface_type);
+       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines panning_and_bezel_adjustment: %d",
+                               data->panning_and_bezel_adjustment);
+       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines graphics_tiling_mode: %d", data->graphics_tiling_mode);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] graphics_lb_bpc: %d", data->graphics_lb_bpc);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] underlay_lb_bpc: %d", data->underlay_lb_bpc);
+       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines underlay_tiling_mode: %d", data->underlay_tiling_mode);
+       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines d0_underlay_mode: %d", data->d0_underlay_mode);
+       DC_LOG_BANDWIDTH_CALCS("        [bool] d1_display_write_back_dwb_enable: %d", data->d1_display_write_back_dwb_enable);
+       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines d1_underlay_mode: %d", data->d1_underlay_mode);
+       DC_LOG_BANDWIDTH_CALCS("        [bool] cpup_state_change_enable: %d", data->cpup_state_change_enable);
+       DC_LOG_BANDWIDTH_CALCS("        [bool] cpuc_state_change_enable: %d", data->cpuc_state_change_enable);
+       DC_LOG_BANDWIDTH_CALCS("        [bool] nbp_state_change_enable: %d", data->nbp_state_change_enable);
+       DC_LOG_BANDWIDTH_CALCS("        [bool] stutter_mode_enable: %d", data->stutter_mode_enable);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] y_clk_level: %d", data->y_clk_level);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] sclk_level: %d", data->sclk_level);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_underlay_surfaces: %d", data->number_of_underlay_surfaces);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_dram_wrchannels: %d", data->number_of_dram_wrchannels);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] chunk_request_delay: %d", data->chunk_request_delay);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] number_of_dram_channels: %d", data->number_of_dram_channels);
+       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines underlay_micro_tile_mode: %d", data->underlay_micro_tile_mode);
+       DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines graphics_micro_tile_mode: %d", data->graphics_micro_tile_mode);
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] max_phyclk: %d", bw_fixed_to_int(data->max_phyclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dram_efficiency: %d", bw_fixed_to_int(data->dram_efficiency));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_width_after_surface_type: %d",
+                               bw_fixed_to_int(data->src_width_after_surface_type));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_height_after_surface_type: %d",
+                               bw_fixed_to_int(data->src_height_after_surface_type));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] hsr_after_surface_type: %d",
+                               bw_fixed_to_int(data->hsr_after_surface_type));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] vsr_after_surface_type: %d", bw_fixed_to_int(data->vsr_after_surface_type));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_width_after_rotation: %d",
+                               bw_fixed_to_int(data->src_width_after_rotation));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_height_after_rotation: %d",
+                               bw_fixed_to_int(data->src_height_after_rotation));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] hsr_after_rotation: %d", bw_fixed_to_int(data->hsr_after_rotation));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] vsr_after_rotation: %d", bw_fixed_to_int(data->vsr_after_rotation));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] source_height_pixels: %d", bw_fixed_to_int(data->source_height_pixels));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] hsr_after_stereo: %d", bw_fixed_to_int(data->hsr_after_stereo));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] vsr_after_stereo: %d", bw_fixed_to_int(data->vsr_after_stereo));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] source_width_in_lb: %d", bw_fixed_to_int(data->source_width_in_lb));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_line_pitch: %d", bw_fixed_to_int(data->lb_line_pitch));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] underlay_maximum_source_efficient_for_tiling: %d",
+                               bw_fixed_to_int(data->underlay_maximum_source_efficient_for_tiling));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] num_lines_at_frame_start: %d",
+                               bw_fixed_to_int(data->num_lines_at_frame_start));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_dmif_size_in_time: %d", bw_fixed_to_int(data->min_dmif_size_in_time));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_mcifwr_size_in_time: %d",
+                               bw_fixed_to_int(data->min_mcifwr_size_in_time));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_requests_for_dmif_size: %d",
+                               bw_fixed_to_int(data->total_requests_for_dmif_size));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] peak_pte_request_to_eviction_ratio_limiting: %d",
+                               bw_fixed_to_int(data->peak_pte_request_to_eviction_ratio_limiting));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] useful_pte_per_pte_request: %d",
+                               bw_fixed_to_int(data->useful_pte_per_pte_request));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_pte_request_rows: %d",
+                               bw_fixed_to_int(data->scatter_gather_pte_request_rows));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_row_height: %d",
+                               bw_fixed_to_int(data->scatter_gather_row_height));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_pte_requests_in_vblank: %d",
+                               bw_fixed_to_int(data->scatter_gather_pte_requests_in_vblank));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] inefficient_linear_pitch_in_bytes: %d",
+                               bw_fixed_to_int(data->inefficient_linear_pitch_in_bytes));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] cursor_total_data: %d", bw_fixed_to_int(data->cursor_total_data));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] cursor_total_request_groups: %d",
+                               bw_fixed_to_int(data->cursor_total_request_groups));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_total_pte_requests: %d",
+                               bw_fixed_to_int(data->scatter_gather_total_pte_requests));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_total_pte_request_groups: %d",
+                               bw_fixed_to_int(data->scatter_gather_total_pte_request_groups));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] tile_width_in_pixels: %d", bw_fixed_to_int(data->tile_width_in_pixels));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_total_number_of_data_request_page_close_open: %d",
+                               bw_fixed_to_int(data->dmif_total_number_of_data_request_page_close_open));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwr_total_number_of_data_request_page_close_open: %d",
+                               bw_fixed_to_int(data->mcifwr_total_number_of_data_request_page_close_open));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] bytes_per_page_close_open: %d",
+                               bw_fixed_to_int(data->bytes_per_page_close_open));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwr_total_page_close_open_time: %d",
+                               bw_fixed_to_int(data->mcifwr_total_page_close_open_time));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_requests_for_adjusted_dmif_size: %d",
+                               bw_fixed_to_int(data->total_requests_for_adjusted_dmif_size));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_dmifmc_urgent_trips: %d",
+                               bw_fixed_to_int(data->total_dmifmc_urgent_trips));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_dmifmc_urgent_latency: %d",
+                               bw_fixed_to_int(data->total_dmifmc_urgent_latency));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_display_reads_required_data: %d",
+                               bw_fixed_to_int(data->total_display_reads_required_data));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_display_reads_required_dram_access_data: %d",
+                               bw_fixed_to_int(data->total_display_reads_required_dram_access_data));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_display_writes_required_data: %d",
+                               bw_fixed_to_int(data->total_display_writes_required_data));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_display_writes_required_dram_access_data: %d",
+                               bw_fixed_to_int(data->total_display_writes_required_dram_access_data));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_reads_required_data: %d",
+                               bw_fixed_to_int(data->display_reads_required_data));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_reads_required_dram_access_data: %d",
+                               bw_fixed_to_int(data->display_reads_required_dram_access_data));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_total_page_close_open_time: %d",
+                               bw_fixed_to_int(data->dmif_total_page_close_open_time));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_cursor_memory_interface_buffer_size_in_time: %d",
+                               bw_fixed_to_int(data->min_cursor_memory_interface_buffer_size_in_time));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_read_buffer_size_in_time: %d",
+                               bw_fixed_to_int(data->min_read_buffer_size_in_time));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_reads_time_for_data_transfer: %d",
+                               bw_fixed_to_int(data->display_reads_time_for_data_transfer));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_writes_time_for_data_transfer: %d",
+                               bw_fixed_to_int(data->display_writes_time_for_data_transfer));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_required_dram_bandwidth: %d",
+                               bw_fixed_to_int(data->dmif_required_dram_bandwidth));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwr_required_dram_bandwidth: %d",
+                               bw_fixed_to_int(data->mcifwr_required_dram_bandwidth));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] required_dmifmc_urgent_latency_for_page_close_open: %d",
+                               bw_fixed_to_int(data->required_dmifmc_urgent_latency_for_page_close_open));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] required_mcifmcwr_urgent_latency: %d",
+                               bw_fixed_to_int(data->required_mcifmcwr_urgent_latency));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] required_dram_bandwidth_gbyte_per_second: %d",
+                               bw_fixed_to_int(data->required_dram_bandwidth_gbyte_per_second));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dram_bandwidth: %d", bw_fixed_to_int(data->dram_bandwidth));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_required_sclk: %d", bw_fixed_to_int(data->dmif_required_sclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwr_required_sclk: %d", bw_fixed_to_int(data->mcifwr_required_sclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] required_sclk: %d", bw_fixed_to_int(data->required_sclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] downspread_factor: %d", bw_fixed_to_int(data->downspread_factor));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] v_scaler_efficiency: %d", bw_fixed_to_int(data->v_scaler_efficiency));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scaler_limits_factor: %d", bw_fixed_to_int(data->scaler_limits_factor));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_pipe_pixel_throughput: %d",
+                               bw_fixed_to_int(data->display_pipe_pixel_throughput));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_dispclk_required_with_ramping: %d",
+                               bw_fixed_to_int(data->total_dispclk_required_with_ramping));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_dispclk_required_without_ramping: %d",
+                               bw_fixed_to_int(data->total_dispclk_required_without_ramping));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_read_request_bandwidth: %d",
+                               bw_fixed_to_int(data->total_read_request_bandwidth));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_write_request_bandwidth: %d",
+                               bw_fixed_to_int(data->total_write_request_bandwidth));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_required_for_total_read_request_bandwidth: %d",
+                               bw_fixed_to_int(data->dispclk_required_for_total_read_request_bandwidth));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_dispclk_required_with_ramping_with_request_bandwidth: %d",
+                               bw_fixed_to_int(data->total_dispclk_required_with_ramping_with_request_bandwidth));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_dispclk_required_without_ramping_with_request_bandwidth: %d",
+                               bw_fixed_to_int(data->total_dispclk_required_without_ramping_with_request_bandwidth));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk: %d", bw_fixed_to_int(data->dispclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] blackout_recovery_time: %d", bw_fixed_to_int(data->blackout_recovery_time));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_pixels_per_data_fifo_entry: %d",
+                               bw_fixed_to_int(data->min_pixels_per_data_fifo_entry));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] sclk_deep_sleep: %d", bw_fixed_to_int(data->sclk_deep_sleep));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] chunk_request_time: %d", bw_fixed_to_int(data->chunk_request_time));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] cursor_request_time: %d", bw_fixed_to_int(data->cursor_request_time));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] line_source_pixels_transfer_time: %d",
+                               bw_fixed_to_int(data->line_source_pixels_transfer_time));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmifdram_access_efficiency: %d",
+                               bw_fixed_to_int(data->dmifdram_access_efficiency));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwrdram_access_efficiency: %d",
+                               bw_fixed_to_int(data->mcifwrdram_access_efficiency));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_average_bandwidth_no_compression: %d",
+                               bw_fixed_to_int(data->total_average_bandwidth_no_compression));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_average_bandwidth: %d",
+                               bw_fixed_to_int(data->total_average_bandwidth));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] total_stutter_cycle_duration: %d",
+                               bw_fixed_to_int(data->total_stutter_cycle_duration));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_burst_time: %d", bw_fixed_to_int(data->stutter_burst_time));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] time_in_self_refresh: %d", bw_fixed_to_int(data->time_in_self_refresh));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_efficiency: %d", bw_fixed_to_int(data->stutter_efficiency));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] worst_number_of_trips_to_memory: %d",
+                               bw_fixed_to_int(data->worst_number_of_trips_to_memory));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] immediate_flip_time: %d", bw_fixed_to_int(data->immediate_flip_time));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] latency_for_non_dmif_clients: %d",
+                               bw_fixed_to_int(data->latency_for_non_dmif_clients));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] latency_for_non_mcifwr_clients: %d",
+                               bw_fixed_to_int(data->latency_for_non_mcifwr_clients));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmifmc_urgent_latency_supported_in_high_sclk_and_yclk: %d",
+                               bw_fixed_to_int(data->dmifmc_urgent_latency_supported_in_high_sclk_and_yclk));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] nbp_state_dram_speed_change_margin: %d",
+                               bw_fixed_to_int(data->nbp_state_dram_speed_change_margin));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_reads_time_for_data_transfer_and_urgent_latency: %d",
+                               bw_fixed_to_int(data->display_reads_time_for_data_transfer_and_urgent_latency));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dram_speed_change_margin: %d",
+                               bw_fixed_to_int(data->dram_speed_change_margin));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_vblank_dram_speed_change_margin: %d",
+                               bw_fixed_to_int(data->min_vblank_dram_speed_change_margin));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_stutter_refresh_duration: %d",
+                               bw_fixed_to_int(data->min_stutter_refresh_duration));
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] total_stutter_dmif_buffer_size: %d", data->total_stutter_dmif_buffer_size);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] total_bytes_requested: %d", data->total_bytes_requested);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] min_stutter_dmif_buffer_size: %d", data->min_stutter_dmif_buffer_size);
+       DC_LOG_BANDWIDTH_CALCS("        [uint32_t] num_stutter_bursts: %d", data->num_stutter_bursts);
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] v_blank_nbp_state_dram_speed_change_latency_supported: %d",
+                               bw_fixed_to_int(data->v_blank_nbp_state_dram_speed_change_latency_supported));
+       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] nbp_state_dram_speed_change_latency_supported: %d",
+                               bw_fixed_to_int(data->nbp_state_dram_speed_change_latency_supported));
+
+       for (i = 0; i < maximum_number_of_surfaces; i++) {
+               DC_LOG_BANDWIDTH_CALCS("        [bool] fbc_en[%d]:%d\n", i, data->fbc_en[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [bool] lpt_en[%d]:%d", i, data->lpt_en[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [bool] displays_match_flag[%d]:%d", i, data->displays_match_flag[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [bool] use_alpha[%d]:%d", i, data->use_alpha[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [bool] orthogonal_rotation[%d]:%d", i, data->orthogonal_rotation[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [bool] enable[%d]:%d", i, data->enable[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [bool] access_one_channel_only[%d]:%d", i, data->access_one_channel_only[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [bool] scatter_gather_enable_for_pipe[%d]:%d",
+                                       i, data->scatter_gather_enable_for_pipe[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [bool] interlace_mode[%d]:%d",
+                                       i, data->interlace_mode[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [bool] display_pstate_change_enable[%d]:%d",
+                                       i, data->display_pstate_change_enable[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [bool] line_buffer_prefetch[%d]:%d", i, data->line_buffer_prefetch[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [uint32_t] bytes_per_pixel[%d]:%d", i, data->bytes_per_pixel[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [uint32_t] max_chunks_non_fbc_mode[%d]:%d",
+                                       i, data->max_chunks_non_fbc_mode[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [uint32_t] lb_bpc[%d]:%d", i, data->lb_bpc[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [uint32_t] output_bpphdmi[%d]:%d", i, data->output_bpphdmi[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [uint32_t] output_bppdp4_lane_hbr[%d]:%d", i, data->output_bppdp4_lane_hbr[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [uint32_t] output_bppdp4_lane_hbr2[%d]:%d",
+                                       i, data->output_bppdp4_lane_hbr2[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [uint32_t] output_bppdp4_lane_hbr3[%d]:%d",
+                                       i, data->output_bppdp4_lane_hbr3[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [enum] bw_defines stereo_mode[%d]:%d", i, data->stereo_mode[i]);
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_buffer_transfer_time[%d]:%d",
+                                       i, bw_fixed_to_int(data->dmif_buffer_transfer_time[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] displays_with_same_mode[%d]:%d",
+                                       i, bw_fixed_to_int(data->displays_with_same_mode[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_dmif_buffer_size[%d]:%d",
+                                       i, bw_fixed_to_int(data->stutter_dmif_buffer_size[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_refresh_duration[%d]:%d",
+                                       i, bw_fixed_to_int(data->stutter_refresh_duration[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_exit_watermark[%d]:%d",
+                                       i, bw_fixed_to_int(data->stutter_exit_watermark[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_entry_watermark[%d]:%d",
+                                       i, bw_fixed_to_int(data->stutter_entry_watermark[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] h_total[%d]:%d", i, bw_fixed_to_int(data->h_total[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] v_total[%d]:%d", i, bw_fixed_to_int(data->v_total[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] pixel_rate[%d]:%d", i, bw_fixed_to_int(data->pixel_rate[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_width[%d]:%d", i, bw_fixed_to_int(data->src_width[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] pitch_in_pixels[%d]:%d",
+                                       i, bw_fixed_to_int(data->pitch_in_pixels[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] pitch_in_pixels_after_surface_type[%d]:%d",
+                                       i, bw_fixed_to_int(data->pitch_in_pixels_after_surface_type[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_height[%d]:%d", i, bw_fixed_to_int(data->src_height[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scale_ratio[%d]:%d", i, bw_fixed_to_int(data->scale_ratio[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] h_taps[%d]:%d", i, bw_fixed_to_int(data->h_taps[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] v_taps[%d]:%d", i, bw_fixed_to_int(data->v_taps[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] h_scale_ratio[%d]:%d", i, bw_fixed_to_int(data->h_scale_ratio[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] v_scale_ratio[%d]:%d", i, bw_fixed_to_int(data->v_scale_ratio[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] rotation_angle[%d]:%d",
+                                       i, bw_fixed_to_int(data->rotation_angle[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] compression_rate[%d]:%d",
+                                       i, bw_fixed_to_int(data->compression_rate[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] hsr[%d]:%d", i, bw_fixed_to_int(data->hsr[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] vsr[%d]:%d", i, bw_fixed_to_int(data->vsr[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] source_width_rounded_up_to_chunks[%d]:%d",
+                                       i, bw_fixed_to_int(data->source_width_rounded_up_to_chunks[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] source_width_pixels[%d]:%d",
+                                       i, bw_fixed_to_int(data->source_width_pixels[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] source_height_rounded_up_to_chunks[%d]:%d",
+                                       i, bw_fixed_to_int(data->source_height_rounded_up_to_chunks[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] display_bandwidth[%d]:%d",
+                                       i, bw_fixed_to_int(data->display_bandwidth[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] request_bandwidth[%d]:%d",
+                                       i, bw_fixed_to_int(data->request_bandwidth[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] bytes_per_request[%d]:%d",
+                                       i, bw_fixed_to_int(data->bytes_per_request[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] useful_bytes_per_request[%d]:%d",
+                                       i, bw_fixed_to_int(data->useful_bytes_per_request[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lines_interleaved_in_mem_access[%d]:%d",
+                                       i, bw_fixed_to_int(data->lines_interleaved_in_mem_access[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] latency_hiding_lines[%d]:%d",
+                                       i, bw_fixed_to_int(data->latency_hiding_lines[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_partitions[%d]:%d",
+                                       i, bw_fixed_to_int(data->lb_partitions[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_partitions_max[%d]:%d",
+                                       i, bw_fixed_to_int(data->lb_partitions_max[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_required_with_ramping[%d]:%d",
+                                       i, bw_fixed_to_int(data->dispclk_required_with_ramping[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_required_without_ramping[%d]:%d",
+                                       i, bw_fixed_to_int(data->dispclk_required_without_ramping[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] data_buffer_size[%d]:%d",
+                                       i, bw_fixed_to_int(data->data_buffer_size[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] outstanding_chunk_request_limit[%d]:%d",
+                                       i, bw_fixed_to_int(data->outstanding_chunk_request_limit[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] urgent_watermark[%d]:%d",
+                                       i, bw_fixed_to_int(data->urgent_watermark[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] nbp_state_change_watermark[%d]:%d",
+                                       i, bw_fixed_to_int(data->nbp_state_change_watermark[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] v_filter_init[%d]:%d", i, bw_fixed_to_int(data->v_filter_init[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] stutter_cycle_duration[%d]:%d",
+                                       i, bw_fixed_to_int(data->stutter_cycle_duration[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] average_bandwidth[%d]:%d",
+                                       i, bw_fixed_to_int(data->average_bandwidth[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] average_bandwidth_no_compression[%d]:%d",
+                                       i, bw_fixed_to_int(data->average_bandwidth_no_compression[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_pte_request_limit[%d]:%d",
+                                       i, bw_fixed_to_int(data->scatter_gather_pte_request_limit[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_size_per_component[%d]:%d",
+                                       i, bw_fixed_to_int(data->lb_size_per_component[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] memory_chunk_size_in_bytes[%d]:%d",
+                                       i, bw_fixed_to_int(data->memory_chunk_size_in_bytes[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] pipe_chunk_size_in_bytes[%d]:%d",
+                                       i, bw_fixed_to_int(data->pipe_chunk_size_in_bytes[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] number_of_trips_to_memory_for_getting_apte_row[%d]:%d",
+                                       i, bw_fixed_to_int(data->number_of_trips_to_memory_for_getting_apte_row[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] adjusted_data_buffer_size[%d]:%d",
+                                       i, bw_fixed_to_int(data->adjusted_data_buffer_size[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] adjusted_data_buffer_size_in_memory[%d]:%d",
+                                       i, bw_fixed_to_int(data->adjusted_data_buffer_size_in_memory[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] pixels_per_data_fifo_entry[%d]:%d",
+                                       i, bw_fixed_to_int(data->pixels_per_data_fifo_entry[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_pte_requests_in_row[%d]:%d",
+                                       i, bw_fixed_to_int(data->scatter_gather_pte_requests_in_row[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] pte_request_per_chunk[%d]:%d",
+                                       i, bw_fixed_to_int(data->pte_request_per_chunk[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_page_width[%d]:%d",
+                                       i, bw_fixed_to_int(data->scatter_gather_page_width[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] scatter_gather_page_height[%d]:%d",
+                                       i, bw_fixed_to_int(data->scatter_gather_page_height[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_lines_in_per_line_out_in_beginning_of_frame[%d]:%d",
+                                       i, bw_fixed_to_int(data->lb_lines_in_per_line_out_in_beginning_of_frame[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] lb_lines_in_per_line_out_in_middle_of_frame[%d]:%d",
+                                       i, bw_fixed_to_int(data->lb_lines_in_per_line_out_in_middle_of_frame[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] cursor_width_pixels[%d]:%d",
+                                       i, bw_fixed_to_int(data->cursor_width_pixels[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] minimum_latency_hiding[%d]:%d",
+                                       i, bw_fixed_to_int(data->minimum_latency_hiding[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] maximum_latency_hiding[%d]:%d",
+                                       i, bw_fixed_to_int(data->maximum_latency_hiding[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] minimum_latency_hiding_with_cursor[%d]:%d",
+                                       i, bw_fixed_to_int(data->minimum_latency_hiding_with_cursor[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] maximum_latency_hiding_with_cursor[%d]:%d",
+                                       i, bw_fixed_to_int(data->maximum_latency_hiding_with_cursor[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_pixels_for_first_output_pixel[%d]:%d",
+                                       i, bw_fixed_to_int(data->src_pixels_for_first_output_pixel[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_pixels_for_last_output_pixel[%d]:%d",
+                                       i, bw_fixed_to_int(data->src_pixels_for_last_output_pixel[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_data_for_first_output_pixel[%d]:%d",
+                                       i, bw_fixed_to_int(data->src_data_for_first_output_pixel[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] src_data_for_last_output_pixel[%d]:%d",
+                                       i, bw_fixed_to_int(data->src_data_for_last_output_pixel[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] active_time[%d]:%d", i, bw_fixed_to_int(data->active_time[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] horizontal_blank_and_chunk_granularity_factor[%d]:%d",
+                                       i, bw_fixed_to_int(data->horizontal_blank_and_chunk_granularity_factor[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] cursor_latency_hiding[%d]:%d",
+                                       i, bw_fixed_to_int(data->cursor_latency_hiding[i]));
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] v_blank_dram_speed_change_margin[%d]:%d",
+                                       i, bw_fixed_to_int(data->v_blank_dram_speed_change_margin[i]));
+               }
+
+       for (i = 0; i < maximum_number_of_surfaces; i++) {
+               for (j = 0; j < 3; j++) {
+                       for (k = 0; k < 8; k++) {
+
+                               DC_LOG_BANDWIDTH_CALCS("\n      [bw_fixed] line_source_transfer_time[%d][%d][%d]:%d",
+                                       i, j, k, bw_fixed_to_int(data->line_source_transfer_time[i][j][k]));
+                               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dram_speed_change_line_source_transfer_time[%d][%d][%d]:%d",
+                                       i, j, k,
+                                       bw_fixed_to_int(data->dram_speed_change_line_source_transfer_time[i][j][k]));
+                       }
+               }
+       }
+
+       for (i = 0; i < 3; i++) {
+               for (j = 0; j < 8; j++) {
+
+                       DC_LOG_BANDWIDTH_CALCS("\n      [uint32_t] num_displays_with_margin[%d][%d]:%d",
+                                       i, j, data->num_displays_with_margin[i][j]);
+                       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_burst_time[%d][%d]:%d",
+                                       i, j, bw_fixed_to_int(data->dmif_burst_time[i][j]));
+                       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] mcifwr_burst_time[%d][%d]:%d",
+                                       i, j, bw_fixed_to_int(data->mcifwr_burst_time[i][j]));
+                       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] min_dram_speed_change_margin[%d][%d]:%d",
+                                       i, j, bw_fixed_to_int(data->min_dram_speed_change_margin[i][j]));
+                       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_required_for_dram_speed_change[%d][%d]:%d",
+                                       i, j, bw_fixed_to_int(data->dispclk_required_for_dram_speed_change[i][j]));
+                       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] blackout_duration_margin[%d][%d]:%d",
+                                       i, j, bw_fixed_to_int(data->blackout_duration_margin[i][j]));
+                       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_required_for_blackout_duration[%d][%d]:%d",
+                                       i, j, bw_fixed_to_int(data->dispclk_required_for_blackout_duration[i][j]));
+                       DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dispclk_required_for_blackout_recovery[%d][%d]:%d",
+                                       i, j, bw_fixed_to_int(data->dispclk_required_for_blackout_recovery[i][j]));
+               }
+       }
+
+       for (i = 0; i < 6; i++) {
+               DC_LOG_BANDWIDTH_CALCS("        [bw_fixed] dmif_required_sclk_for_urgent_latency[%d]:%d",
+                                       i, bw_fixed_to_int(data->dmif_required_sclk_for_urgent_latency[i]));
+       }
+}
+;
+
+#endif /* _CALCS_CALCS_LOGGER_H_ */
diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/custom_float.c b/drivers/gpu/drm/amd/display/dc/dml/calcs/custom_float.c
new file mode 100644 (file)
index 0000000..31d167b
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2017 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+#include "dm_services.h"
+#include "custom_float.h"
+
+
+static bool build_custom_float(
+       struct fixed31_32 value,
+       const struct custom_float_format *format,
+       bool *negative,
+       uint32_t *mantissa,
+       uint32_t *exponenta)
+{
+       uint32_t exp_offset = (1 << (format->exponenta_bits - 1)) - 1;
+
+       const struct fixed31_32 mantissa_constant_plus_max_fraction =
+               dc_fixpt_from_fraction(
+                       (1LL << (format->mantissa_bits + 1)) - 1,
+                       1LL << format->mantissa_bits);
+
+       struct fixed31_32 mantiss;
+
+       if (dc_fixpt_eq(
+               value,
+               dc_fixpt_zero)) {
+               *negative = false;
+               *mantissa = 0;
+               *exponenta = 0;
+               return true;
+       }
+
+       if (dc_fixpt_lt(
+               value,
+               dc_fixpt_zero)) {
+               *negative = format->sign;
+               value = dc_fixpt_neg(value);
+       } else {
+               *negative = false;
+       }
+
+       if (dc_fixpt_lt(
+               value,
+               dc_fixpt_one)) {
+               uint32_t i = 1;
+
+               do {
+                       value = dc_fixpt_shl(value, 1);
+                       ++i;
+               } while (dc_fixpt_lt(
+                       value,
+                       dc_fixpt_one));
+
+               --i;
+
+               if (exp_offset <= i) {
+                       *mantissa = 0;
+                       *exponenta = 0;
+                       return true;
+               }
+
+               *exponenta = exp_offset - i;
+       } else if (dc_fixpt_le(
+               mantissa_constant_plus_max_fraction,
+               value)) {
+               uint32_t i = 1;
+
+               do {
+                       value = dc_fixpt_shr(value, 1);
+                       ++i;
+               } while (dc_fixpt_lt(
+                       mantissa_constant_plus_max_fraction,
+                       value));
+
+               *exponenta = exp_offset + i - 1;
+       } else {
+               *exponenta = exp_offset;
+       }
+
+       mantiss = dc_fixpt_sub(
+               value,
+               dc_fixpt_one);
+
+       if (dc_fixpt_lt(
+                       mantiss,
+                       dc_fixpt_zero) ||
+               dc_fixpt_lt(
+                       dc_fixpt_one,
+                       mantiss))
+               mantiss = dc_fixpt_zero;
+       else
+               mantiss = dc_fixpt_shl(
+                       mantiss,
+                       format->mantissa_bits);
+
+       *mantissa = dc_fixpt_floor(mantiss);
+
+       return true;
+}
+
+static bool setup_custom_float(
+       const struct custom_float_format *format,
+       bool negative,
+       uint32_t mantissa,
+       uint32_t exponenta,
+       uint32_t *result)
+{
+       uint32_t i = 0;
+       uint32_t j = 0;
+
+       uint32_t value = 0;
+
+       /* verification code:
+        * once calculation is ok we can remove it
+        */
+
+       const uint32_t mantissa_mask =
+               (1 << (format->mantissa_bits + 1)) - 1;
+
+       const uint32_t exponenta_mask =
+               (1 << (format->exponenta_bits + 1)) - 1;
+
+       if (mantissa & ~mantissa_mask) {
+               BREAK_TO_DEBUGGER();
+               mantissa = mantissa_mask;
+       }
+
+       if (exponenta & ~exponenta_mask) {
+               BREAK_TO_DEBUGGER();
+               exponenta = exponenta_mask;
+       }
+
+       /* end of verification code */
+
+       while (i < format->mantissa_bits) {
+               uint32_t mask = 1 << i;
+
+               if (mantissa & mask)
+                       value |= mask;
+
+               ++i;
+       }
+
+       while (j < format->exponenta_bits) {
+               uint32_t mask = 1 << j;
+
+               if (exponenta & mask)
+                       value |= mask << i;
+
+               ++j;
+       }
+
+       if (negative && format->sign)
+               value |= 1 << (i + j);
+
+       *result = value;
+
+       return true;
+}
+
+bool convert_to_custom_float_format(
+       struct fixed31_32 value,
+       const struct custom_float_format *format,
+       uint32_t *result)
+{
+       uint32_t mantissa;
+       uint32_t exponenta;
+       bool negative;
+
+       return build_custom_float(
+               value, format, &negative, &mantissa, &exponenta) &&
+       setup_custom_float(
+               format, negative, mantissa, exponenta, result);
+}
+
+
diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c b/drivers/gpu/drm/amd/display/dc/dml/calcs/dce_calcs.c
new file mode 100644 (file)
index 0000000..ff5bb15
--- /dev/null
@@ -0,0 +1,3625 @@
+/*
+ * Copyright 2015 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
+#include <linux/slab.h>
+
+#include "resource.h"
+#include "dm_services.h"
+#include "dce_calcs.h"
+#include "dc.h"
+#include "core_types.h"
+#include "dal_asic_id.h"
+#include "calcs_logger.h"
+
+/*
+ * NOTE:
+ *   This file is gcc-parseable HW gospel, coming straight from HW engineers.
+ *
+ * It doesn't adhere to Linux kernel style and sometimes will do things in odd
+ * ways. Unless there is something clearly wrong with it the code should
+ * remain as-is as it provides us with a guarantee from HW that it is correct.
+ */
+
+/*******************************************************************************
+ * Private Functions
+ ******************************************************************************/
+
+static enum bw_calcs_version bw_calcs_version_from_asic_id(struct hw_asic_id asic_id)
+{
+       switch (asic_id.chip_family) {
+
+       case FAMILY_CZ:
+               if (ASIC_REV_IS_STONEY(asic_id.hw_internal_rev))
+                       return BW_CALCS_VERSION_STONEY;
+               return BW_CALCS_VERSION_CARRIZO;
+
+       case FAMILY_VI:
+               if (ASIC_REV_IS_POLARIS12_V(asic_id.hw_internal_rev))
+                       return BW_CALCS_VERSION_POLARIS12;
+               if (ASIC_REV_IS_POLARIS10_P(asic_id.hw_internal_rev))
+                       return BW_CALCS_VERSION_POLARIS10;
+               if (ASIC_REV_IS_POLARIS11_M(asic_id.hw_internal_rev))
+                       return BW_CALCS_VERSION_POLARIS11;
+               if (ASIC_REV_IS_VEGAM(asic_id.hw_internal_rev))
+                       return BW_CALCS_VERSION_VEGAM;
+               return BW_CALCS_VERSION_INVALID;
+
+       case FAMILY_AI:
+               return BW_CALCS_VERSION_VEGA10;
+
+       default:
+               return BW_CALCS_VERSION_INVALID;
+       }
+}
+
+static void calculate_bandwidth(
+       const struct bw_calcs_dceip *dceip,
+       const struct bw_calcs_vbios *vbios,
+       struct bw_calcs_data *data)
+
+{
+       const int32_t pixels_per_chunk = 512;
+       const int32_t high = 2;
+       const int32_t mid = 1;
+       const int32_t low = 0;
+       const uint32_t s_low = 0;
+       const uint32_t s_mid1 = 1;
+       const uint32_t s_mid2 = 2;
+       const uint32_t s_mid3 = 3;
+       const uint32_t s_mid4 = 4;
+       const uint32_t s_mid5 = 5;
+       const uint32_t s_mid6 = 6;
+       const uint32_t s_high = 7;
+       const uint32_t dmif_chunk_buff_margin = 1;
+
+       uint32_t max_chunks_fbc_mode;
+       int32_t num_cursor_lines;
+
+       int32_t i, j, k;
+       struct bw_fixed *yclk;
+       struct bw_fixed *sclk;
+       bool d0_underlay_enable;
+       bool d1_underlay_enable;
+       bool fbc_enabled;
+       bool lpt_enabled;
+       enum bw_defines sclk_message;
+       enum bw_defines yclk_message;
+       enum bw_defines *tiling_mode;
+       enum bw_defines *surface_type;
+       enum bw_defines voltage;
+       enum bw_defines pipe_check;
+       enum bw_defines hsr_check;
+       enum bw_defines vsr_check;
+       enum bw_defines lb_size_check;
+       enum bw_defines fbc_check;
+       enum bw_defines rotation_check;
+       enum bw_defines mode_check;
+       enum bw_defines nbp_state_change_enable_blank;
+       /*initialize variables*/
+       int32_t number_of_displays_enabled = 0;
+       int32_t number_of_displays_enabled_with_margin = 0;
+       int32_t number_of_aligned_displays_with_no_margin = 0;
+
+       yclk = kcalloc(3, sizeof(*yclk), GFP_KERNEL);
+       if (!yclk)
+               return;
+
+       sclk = kcalloc(8, sizeof(*sclk), GFP_KERNEL);
+       if (!sclk)
+               goto free_yclk;
+
+       tiling_mode = kcalloc(maximum_number_of_surfaces, sizeof(*tiling_mode), GFP_KERNEL);
+       if (!tiling_mode)
+               goto free_sclk;
+
+       surface_type = kcalloc(maximum_number_of_surfaces, sizeof(*surface_type), GFP_KERNEL);
+       if (!surface_type)
+               goto free_tiling_mode;
+
+       yclk[low] = vbios->low_yclk;
+       yclk[mid] = vbios->mid_yclk;
+       yclk[high] = vbios->high_yclk;
+       sclk[s_low] = vbios->low_sclk;
+       sclk[s_mid1] = vbios->mid1_sclk;
+       sclk[s_mid2] = vbios->mid2_sclk;
+       sclk[s_mid3] = vbios->mid3_sclk;
+       sclk[s_mid4] = vbios->mid4_sclk;
+       sclk[s_mid5] = vbios->mid5_sclk;
+       sclk[s_mid6] = vbios->mid6_sclk;
+       sclk[s_high] = vbios->high_sclk;
+       /*''''''''''''''''''*/
+       /* surface assignment:*/
+       /* 0: d0 underlay or underlay luma*/
+       /* 1: d0 underlay chroma*/
+       /* 2: d1 underlay or underlay luma*/
+       /* 3: d1 underlay chroma*/
+       /* 4: d0 graphics*/
+       /* 5: d1 graphics*/
+       /* 6: d2 graphics*/
+       /* 7: d3 graphics, same mode as d2*/
+       /* 8: d4 graphics, same mode as d2*/
+       /* 9: d5 graphics, same mode as d2*/
+       /* ...*/
+       /* maximum_number_of_surfaces-2: d1 display_write_back420 luma*/
+       /* maximum_number_of_surfaces-1: d1 display_write_back420 chroma*/
+       /* underlay luma and chroma surface parameters from spreadsheet*/
+
+
+
+
+       if (data->d0_underlay_mode == bw_def_none)
+               d0_underlay_enable = false;
+       else
+               d0_underlay_enable = true;
+       if (data->d1_underlay_mode == bw_def_none)
+               d1_underlay_enable = false;
+       else
+               d1_underlay_enable = true;
+       data->number_of_underlay_surfaces = d0_underlay_enable + d1_underlay_enable;
+       switch (data->underlay_surface_type) {
+       case bw_def_420:
+               surface_type[0] = bw_def_underlay420_luma;
+               surface_type[2] = bw_def_underlay420_luma;
+               data->bytes_per_pixel[0] = 1;
+               data->bytes_per_pixel[2] = 1;
+               surface_type[1] = bw_def_underlay420_chroma;
+               surface_type[3] = bw_def_underlay420_chroma;
+               data->bytes_per_pixel[1] = 2;
+               data->bytes_per_pixel[3] = 2;
+               data->lb_size_per_component[0] = dceip->underlay420_luma_lb_size_per_component;
+               data->lb_size_per_component[1] = dceip->underlay420_chroma_lb_size_per_component;
+               data->lb_size_per_component[2] = dceip->underlay420_luma_lb_size_per_component;
+               data->lb_size_per_component[3] = dceip->underlay420_chroma_lb_size_per_component;
+               break;
+       case bw_def_422:
+               surface_type[0] = bw_def_underlay422;
+               surface_type[2] = bw_def_underlay422;
+               data->bytes_per_pixel[0] = 2;
+               data->bytes_per_pixel[2] = 2;
+               data->lb_size_per_component[0] = dceip->underlay422_lb_size_per_component;
+               data->lb_size_per_component[2] = dceip->underlay422_lb_size_per_component;
+               break;
+       default:
+               surface_type[0] = bw_def_underlay444;
+               surface_type[2] = bw_def_underlay444;
+               data->bytes_per_pixel[0] = 4;
+               data->bytes_per_pixel[2] = 4;
+               data->lb_size_per_component[0] = dceip->lb_size_per_component444;
+               data->lb_size_per_component[2] = dceip->lb_size_per_component444;
+               break;
+       }
+       if (d0_underlay_enable) {
+               switch (data->underlay_surface_type) {
+               case bw_def_420:
+                       data->enable[0] = 1;
+                       data->enable[1] = 1;
+                       break;
+               default:
+                       data->enable[0] = 1;
+                       data->enable[1] = 0;
+                       break;
+               }
+       }
+       else {
+               data->enable[0] = 0;
+               data->enable[1] = 0;
+       }
+       if (d1_underlay_enable) {
+               switch (data->underlay_surface_type) {
+               case bw_def_420:
+                       data->enable[2] = 1;
+                       data->enable[3] = 1;
+                       break;
+               default:
+                       data->enable[2] = 1;
+                       data->enable[3] = 0;
+                       break;
+               }
+       }
+       else {
+               data->enable[2] = 0;
+               data->enable[3] = 0;
+       }
+       data->use_alpha[0] = 0;
+       data->use_alpha[1] = 0;
+       data->use_alpha[2] = 0;
+       data->use_alpha[3] = 0;
+       data->scatter_gather_enable_for_pipe[0] = vbios->scatter_gather_enable;
+       data->scatter_gather_enable_for_pipe[1] = vbios->scatter_gather_enable;
+       data->scatter_gather_enable_for_pipe[2] = vbios->scatter_gather_enable;
+       data->scatter_gather_enable_for_pipe[3] = vbios->scatter_gather_enable;
+       /*underlay0 same and graphics display pipe0*/
+       data->interlace_mode[0] = data->interlace_mode[4];
+       data->interlace_mode[1] = data->interlace_mode[4];
+       /*underlay1 same and graphics display pipe1*/
+       data->interlace_mode[2] = data->interlace_mode[5];
+       data->interlace_mode[3] = data->interlace_mode[5];
+       /*underlay0 same and graphics display pipe0*/
+       data->h_total[0] = data->h_total[4];
+       data->v_total[0] = data->v_total[4];
+       data->h_total[1] = data->h_total[4];
+       data->v_total[1] = data->v_total[4];
+       /*underlay1 same and graphics display pipe1*/
+       data->h_total[2] = data->h_total[5];
+       data->v_total[2] = data->v_total[5];
+       data->h_total[3] = data->h_total[5];
+       data->v_total[3] = data->v_total[5];
+       /*underlay0 same and graphics display pipe0*/
+       data->pixel_rate[0] = data->pixel_rate[4];
+       data->pixel_rate[1] = data->pixel_rate[4];
+       /*underlay1 same and graphics display pipe1*/
+       data->pixel_rate[2] = data->pixel_rate[5];
+       data->pixel_rate[3] = data->pixel_rate[5];
+       if ((data->underlay_tiling_mode == bw_def_array_linear_general || data->underlay_tiling_mode == bw_def_array_linear_aligned)) {
+               tiling_mode[0] = bw_def_linear;
+               tiling_mode[1] = bw_def_linear;
+               tiling_mode[2] = bw_def_linear;
+               tiling_mode[3] = bw_def_linear;
+       }
+       else {
+               tiling_mode[0] = bw_def_landscape;
+               tiling_mode[1] = bw_def_landscape;
+               tiling_mode[2] = bw_def_landscape;
+               tiling_mode[3] = bw_def_landscape;
+       }
+       data->lb_bpc[0] = data->underlay_lb_bpc;
+       data->lb_bpc[1] = data->underlay_lb_bpc;
+       data->lb_bpc[2] = data->underlay_lb_bpc;
+       data->lb_bpc[3] = data->underlay_lb_bpc;
+       data->compression_rate[0] = bw_int_to_fixed(1);
+       data->compression_rate[1] = bw_int_to_fixed(1);
+       data->compression_rate[2] = bw_int_to_fixed(1);
+       data->compression_rate[3] = bw_int_to_fixed(1);
+       data->access_one_channel_only[0] = 0;
+       data->access_one_channel_only[1] = 0;
+       data->access_one_channel_only[2] = 0;
+       data->access_one_channel_only[3] = 0;
+       data->cursor_width_pixels[0] = bw_int_to_fixed(0);
+       data->cursor_width_pixels[1] = bw_int_to_fixed(0);
+       data->cursor_width_pixels[2] = bw_int_to_fixed(0);
+       data->cursor_width_pixels[3] = bw_int_to_fixed(0);
+       /* graphics surface parameters from spreadsheet*/
+       fbc_enabled = false;
+       lpt_enabled = false;
+       for (i = 4; i <= maximum_number_of_surfaces - 3; i++) {
+               if (i < data->number_of_displays + 4) {
+                       if (i == 4 && data->d0_underlay_mode == bw_def_underlay_only) {
+                               data->enable[i] = 0;
+                               data->use_alpha[i] = 0;
+                       }
+                       else if (i == 4 && data->d0_underlay_mode == bw_def_blend) {
+                               data->enable[i] = 1;
+                               data->use_alpha[i] = 1;
+                       }
+                       else if (i == 4) {
+                               data->enable[i] = 1;
+                               data->use_alpha[i] = 0;
+                       }
+                       else if (i == 5 && data->d1_underlay_mode == bw_def_underlay_only) {
+                               data->enable[i] = 0;
+                               data->use_alpha[i] = 0;
+                       }
+                       else if (i == 5 && data->d1_underlay_mode == bw_def_blend) {
+                               data->enable[i] = 1;
+                               data->use_alpha[i] = 1;
+                       }
+                       else {
+                               data->enable[i] = 1;
+                               data->use_alpha[i] = 0;
+                       }
+               }
+               else {
+                       data->enable[i] = 0;
+                       data->use_alpha[i] = 0;
+               }
+               data->scatter_gather_enable_for_pipe[i] = vbios->scatter_gather_enable;
+               surface_type[i] = bw_def_graphics;
+               data->lb_size_per_component[i] = dceip->lb_size_per_component444;
+               if (data->graphics_tiling_mode == bw_def_array_linear_general || data->graphics_tiling_mode == bw_def_array_linear_aligned) {
+                       tiling_mode[i] = bw_def_linear;
+               }
+               else {
+                       tiling_mode[i] = bw_def_tiled;
+               }
+               data->lb_bpc[i] = data->graphics_lb_bpc;
+               if ((data->fbc_en[i] == 1 && (dceip->argb_compression_support || data->d0_underlay_mode != bw_def_blended))) {
+                       data->compression_rate[i] = bw_int_to_fixed(vbios->average_compression_rate);
+                       data->access_one_channel_only[i] = data->lpt_en[i];
+               }
+               else {
+                       data->compression_rate[i] = bw_int_to_fixed(1);
+                       data->access_one_channel_only[i] = 0;
+               }
+               if (data->fbc_en[i] == 1) {
+                       fbc_enabled = true;
+                       if (data->lpt_en[i] == 1) {
+                               lpt_enabled = true;
+                       }
+               }
+               data->cursor_width_pixels[i] = bw_int_to_fixed(vbios->cursor_width);
+       }
+       /* display_write_back420*/
+       data->scatter_gather_enable_for_pipe[maximum_number_of_surfaces - 2] = 0;
+       data->scatter_gather_enable_for_pipe[maximum_number_of_surfaces - 1] = 0;
+       if (data->d1_display_write_back_dwb_enable == 1) {
+               data->enable[maximum_number_of_surfaces - 2] = 1;
+               data->enable[maximum_number_of_surfaces - 1] = 1;
+       }
+       else {
+               data->enable[maximum_number_of_surfaces - 2] = 0;
+               data->enable[maximum_number_of_surfaces - 1] = 0;
+       }
+       surface_type[maximum_number_of_surfaces - 2] = bw_def_display_write_back420_luma;
+       surface_type[maximum_number_of_surfaces - 1] = bw_def_display_write_back420_chroma;
+       data->lb_size_per_component[maximum_number_of_surfaces - 2] = dceip->underlay420_luma_lb_size_per_component;
+       data->lb_size_per_component[maximum_number_of_surfaces - 1] = dceip->underlay420_chroma_lb_size_per_component;
+       data->bytes_per_pixel[maximum_number_of_surfaces - 2] = 1;
+       data->bytes_per_pixel[maximum_number_of_surfaces - 1] = 2;
+       data->interlace_mode[maximum_number_of_surfaces - 2] = data->interlace_mode[5];
+       data->interlace_mode[maximum_number_of_surfaces - 1] = data->interlace_mode[5];
+       data->h_taps[maximum_number_of_surfaces - 2] = bw_int_to_fixed(1);
+       data->h_taps[maximum_number_of_surfaces - 1] = bw_int_to_fixed(1);
+       data->v_taps[maximum_number_of_surfaces - 2] = bw_int_to_fixed(1);
+       data->v_taps[maximum_number_of_surfaces - 1] = bw_int_to_fixed(1);
+       data->rotation_angle[maximum_number_of_surfaces - 2] = bw_int_to_fixed(0);
+       data->rotation_angle[maximum_number_of_surfaces - 1] = bw_int_to_fixed(0);
+       tiling_mode[maximum_number_of_surfaces - 2] = bw_def_linear;
+       tiling_mode[maximum_number_of_surfaces - 1] = bw_def_linear;
+       data->lb_bpc[maximum_number_of_surfaces - 2] = 8;
+       data->lb_bpc[maximum_number_of_surfaces - 1] = 8;
+       data->compression_rate[maximum_number_of_surfaces - 2] = bw_int_to_fixed(1);
+       data->compression_rate[maximum_number_of_surfaces - 1] = bw_int_to_fixed(1);
+       data->access_one_channel_only[maximum_number_of_surfaces - 2] = 0;
+       data->access_one_channel_only[maximum_number_of_surfaces - 1] = 0;
+       /*assume display pipe1 has dwb enabled*/
+       data->h_total[maximum_number_of_surfaces - 2] = data->h_total[5];
+       data->h_total[maximum_number_of_surfaces - 1] = data->h_total[5];
+       data->v_total[maximum_number_of_surfaces - 2] = data->v_total[5];
+       data->v_total[maximum_number_of_surfaces - 1] = data->v_total[5];
+       data->pixel_rate[maximum_number_of_surfaces - 2] = data->pixel_rate[5];
+       data->pixel_rate[maximum_number_of_surfaces - 1] = data->pixel_rate[5];
+       data->src_width[maximum_number_of_surfaces - 2] = data->src_width[5];
+       data->src_width[maximum_number_of_surfaces - 1] = data->src_width[5];
+       data->src_height[maximum_number_of_surfaces - 2] = data->src_height[5];
+       data->src_height[maximum_number_of_surfaces - 1] = data->src_height[5];
+       data->pitch_in_pixels[maximum_number_of_surfaces - 2] = data->src_width[5];
+       data->pitch_in_pixels[maximum_number_of_surfaces - 1] = data->src_width[5];
+       data->h_scale_ratio[maximum_number_of_surfaces - 2] = bw_int_to_fixed(1);
+       data->h_scale_ratio[maximum_number_of_surfaces - 1] = bw_int_to_fixed(1);
+       data->v_scale_ratio[maximum_number_of_surfaces - 2] = bw_int_to_fixed(1);
+       data->v_scale_ratio[maximum_number_of_surfaces - 1] = bw_int_to_fixed(1);
+       data->stereo_mode[maximum_number_of_surfaces - 2] = bw_def_mono;
+       data->stereo_mode[maximum_number_of_surfaces - 1] = bw_def_mono;
+       data->cursor_width_pixels[maximum_number_of_surfaces - 2] = bw_int_to_fixed(0);
+       data->cursor_width_pixels[maximum_number_of_surfaces - 1] = bw_int_to_fixed(0);
+       data->use_alpha[maximum_number_of_surfaces - 2] = 0;
+       data->use_alpha[maximum_number_of_surfaces - 1] = 0;
+       /*mode check calculations:*/
+       /* mode within dce ip capabilities*/
+       /* fbc*/
+       /* hsr*/
+       /* vsr*/
+       /* lb size*/
+       /*effective scaling source and ratios:*/
+       /*for graphics, non-stereo, non-interlace surfaces when the size of the source and destination are the same, only one tap is used*/
+       /*420 chroma has half the width, height, horizontal and vertical scaling ratios than luma*/
+       /*rotating a graphic or underlay surface swaps the width, height, horizontal and vertical scaling ratios*/
+       /*in top-bottom stereo mode there is 2:1 vertical downscaling for each eye*/
+       /*in side-by-side stereo mode there is 2:1 horizontal downscaling for each eye*/
+       /*in interlace mode there is 2:1 vertical downscaling for each field*/
+       /*in panning or bezel adjustment mode the source width has an extra 128 pixels*/
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (bw_equ(data->h_scale_ratio[i], bw_int_to_fixed(1)) && bw_equ(data->v_scale_ratio[i], bw_int_to_fixed(1)) && surface_type[i] == bw_def_graphics && data->stereo_mode[i] == bw_def_mono && data->interlace_mode[i] == 0) {
+                               data->h_taps[i] = bw_int_to_fixed(1);
+                               data->v_taps[i] = bw_int_to_fixed(1);
+                       }
+                       if (surface_type[i] == bw_def_display_write_back420_chroma || surface_type[i] == bw_def_underlay420_chroma) {
+                               data->pitch_in_pixels_after_surface_type[i] = bw_div(data->pitch_in_pixels[i], bw_int_to_fixed(2));
+                               data->src_width_after_surface_type = bw_div(data->src_width[i], bw_int_to_fixed(2));
+                               data->src_height_after_surface_type = bw_div(data->src_height[i], bw_int_to_fixed(2));
+                               data->hsr_after_surface_type = bw_div(data->h_scale_ratio[i], bw_int_to_fixed(2));
+                               data->vsr_after_surface_type = bw_div(data->v_scale_ratio[i], bw_int_to_fixed(2));
+                       }
+                       else {
+                               data->pitch_in_pixels_after_surface_type[i] = data->pitch_in_pixels[i];
+                               data->src_width_after_surface_type = data->src_width[i];
+                               data->src_height_after_surface_type = data->src_height[i];
+                               data->hsr_after_surface_type = data->h_scale_ratio[i];
+                               data->vsr_after_surface_type = data->v_scale_ratio[i];
+                       }
+                       if ((bw_equ(data->rotation_angle[i], bw_int_to_fixed(90)) || bw_equ(data->rotation_angle[i], bw_int_to_fixed(270))) && surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
+                               data->src_width_after_rotation = data->src_height_after_surface_type;
+                               data->src_height_after_rotation = data->src_width_after_surface_type;
+                               data->hsr_after_rotation = data->vsr_after_surface_type;
+                               data->vsr_after_rotation = data->hsr_after_surface_type;
+                       }
+                       else {
+                               data->src_width_after_rotation = data->src_width_after_surface_type;
+                               data->src_height_after_rotation = data->src_height_after_surface_type;
+                               data->hsr_after_rotation = data->hsr_after_surface_type;
+                               data->vsr_after_rotation = data->vsr_after_surface_type;
+                       }
+                       switch (data->stereo_mode[i]) {
+                       case bw_def_top_bottom:
+                               data->source_width_pixels[i] = data->src_width_after_rotation;
+                               data->source_height_pixels = bw_mul(bw_int_to_fixed(2), data->src_height_after_rotation);
+                               data->hsr_after_stereo = data->hsr_after_rotation;
+                               data->vsr_after_stereo = bw_mul(bw_int_to_fixed(1), data->vsr_after_rotation);
+                               break;
+                       case bw_def_side_by_side:
+                               data->source_width_pixels[i] = bw_mul(bw_int_to_fixed(2), data->src_width_after_rotation);
+                               data->source_height_pixels = data->src_height_after_rotation;
+                               data->hsr_after_stereo = bw_mul(bw_int_to_fixed(1), data->hsr_after_rotation);
+                               data->vsr_after_stereo = data->vsr_after_rotation;
+                               break;
+                       default:
+                               data->source_width_pixels[i] = data->src_width_after_rotation;
+                               data->source_height_pixels = data->src_height_after_rotation;
+                               data->hsr_after_stereo = data->hsr_after_rotation;
+                               data->vsr_after_stereo = data->vsr_after_rotation;
+                               break;
+                       }
+                       data->hsr[i] = data->hsr_after_stereo;
+                       if (data->interlace_mode[i]) {
+                               data->vsr[i] = bw_mul(data->vsr_after_stereo, bw_int_to_fixed(2));
+                       }
+                       else {
+                               data->vsr[i] = data->vsr_after_stereo;
+                       }
+                       if (data->panning_and_bezel_adjustment != bw_def_none) {
+                               data->source_width_rounded_up_to_chunks[i] = bw_add(bw_floor2(bw_sub(data->source_width_pixels[i], bw_int_to_fixed(1)), bw_int_to_fixed(128)), bw_int_to_fixed(256));
+                       }
+                       else {
+                               data->source_width_rounded_up_to_chunks[i] = bw_ceil2(data->source_width_pixels[i], bw_int_to_fixed(128));
+                       }
+                       data->source_height_rounded_up_to_chunks[i] = data->source_height_pixels;
+               }
+       }
+       /*mode support checks:*/
+       /*the number of graphics and underlay pipes is limited by the ip support*/
+       /*maximum horizontal and vertical scale ratio is 4, and should not exceed the number of taps*/
+       /*for downscaling with the pre-downscaler, the horizontal scale ratio must be more than the ceiling of one quarter of the number of taps*/
+       /*the pre-downscaler reduces the line buffer source by the horizontal scale ratio*/
+       /*the number of lines in the line buffer has to exceed the number of vertical taps*/
+       /*the size of the line in the line buffer is the product of the source width and the bits per component, rounded up to a multiple of 48*/
+       /*the size of the line in the line buffer in the case of 10 bit per component is the product of the source width rounded up to multiple of 8 and 30.023438 / 3, rounded up to a multiple of 48*/
+       /*the size of the line in the line buffer in the case of 8 bit per component is the product of the source width rounded up to multiple of 8 and 30.023438 / 3, rounded up to a multiple of 48*/
+       /*frame buffer compression is not supported with stereo mode, rotation, or non- 888 formats*/
+       /*rotation is not supported with linear of stereo modes*/
+       if (dceip->number_of_graphics_pipes >= data->number_of_displays && dceip->number_of_underlay_pipes >= data->number_of_underlay_surfaces && !(dceip->display_write_back_supported == 0 && data->d1_display_write_back_dwb_enable == 1)) {
+               pipe_check = bw_def_ok;
+       }
+       else {
+               pipe_check = bw_def_notok;
+       }
+       hsr_check = bw_def_ok;
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (bw_neq(data->hsr[i], bw_int_to_fixed(1))) {
+                               if (bw_mtn(data->hsr[i], bw_int_to_fixed(4))) {
+                                       hsr_check = bw_def_hsr_mtn_4;
+                               }
+                               else {
+                                       if (bw_mtn(data->hsr[i], data->h_taps[i])) {
+                                               hsr_check = bw_def_hsr_mtn_h_taps;
+                                       }
+                                       else {
+                                               if (dceip->pre_downscaler_enabled == 1 && bw_mtn(data->hsr[i], bw_int_to_fixed(1)) && bw_leq(data->hsr[i], bw_ceil2(bw_div(data->h_taps[i], bw_int_to_fixed(4)), bw_int_to_fixed(1)))) {
+                                                       hsr_check = bw_def_ceiling__h_taps_div_4___meq_hsr;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       vsr_check = bw_def_ok;
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (bw_neq(data->vsr[i], bw_int_to_fixed(1))) {
+                               if (bw_mtn(data->vsr[i], bw_int_to_fixed(4))) {
+                                       vsr_check = bw_def_vsr_mtn_4;
+                               }
+                               else {
+                                       if (bw_mtn(data->vsr[i], data->v_taps[i])) {
+                                               vsr_check = bw_def_vsr_mtn_v_taps;
+                                       }
+                               }
+                       }
+               }
+       }
+       lb_size_check = bw_def_ok;
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if ((dceip->pre_downscaler_enabled && bw_mtn(data->hsr[i], bw_int_to_fixed(1)))) {
+                               data->source_width_in_lb = bw_div(data->source_width_pixels[i], data->hsr[i]);
+                       }
+                       else {
+                               data->source_width_in_lb = data->source_width_pixels[i];
+                       }
+                       switch (data->lb_bpc[i]) {
+                       case 8:
+                               data->lb_line_pitch = bw_ceil2(bw_mul(bw_div(bw_frc_to_fixed(2401171875ul, 100000000), bw_int_to_fixed(3)), bw_ceil2(data->source_width_in_lb, bw_int_to_fixed(8))), bw_int_to_fixed(48));
+                               break;
+                       case 10:
+                               data->lb_line_pitch = bw_ceil2(bw_mul(bw_div(bw_frc_to_fixed(300234375, 10000000), bw_int_to_fixed(3)), bw_ceil2(data->source_width_in_lb, bw_int_to_fixed(8))), bw_int_to_fixed(48));
+                               break;
+                       default:
+                               data->lb_line_pitch = bw_ceil2(bw_mul(bw_int_to_fixed(data->lb_bpc[i]), data->source_width_in_lb), bw_int_to_fixed(48));
+                               break;
+                       }
+                       data->lb_partitions[i] = bw_floor2(bw_div(data->lb_size_per_component[i], data->lb_line_pitch), bw_int_to_fixed(1));
+                       /*clamp the partitions to the maxium number supported by the lb*/
+                       if ((surface_type[i] != bw_def_graphics || dceip->graphics_lb_nodownscaling_multi_line_prefetching == 1)) {
+                               data->lb_partitions_max[i] = bw_int_to_fixed(10);
+                       }
+                       else {
+                               data->lb_partitions_max[i] = bw_int_to_fixed(7);
+                       }
+                       data->lb_partitions[i] = bw_min2(data->lb_partitions_max[i], data->lb_partitions[i]);
+                       if (bw_mtn(bw_add(data->v_taps[i], bw_int_to_fixed(1)), data->lb_partitions[i])) {
+                               lb_size_check = bw_def_notok;
+                       }
+               }
+       }
+       fbc_check = bw_def_ok;
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i] && data->fbc_en[i] == 1 && (bw_equ(data->rotation_angle[i], bw_int_to_fixed(90)) || bw_equ(data->rotation_angle[i], bw_int_to_fixed(270)) || data->stereo_mode[i] != bw_def_mono || data->bytes_per_pixel[i] != 4)) {
+                       fbc_check = bw_def_invalid_rotation_or_bpp_or_stereo;
+               }
+       }
+       rotation_check = bw_def_ok;
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if ((bw_equ(data->rotation_angle[i], bw_int_to_fixed(90)) || bw_equ(data->rotation_angle[i], bw_int_to_fixed(270))) && (tiling_mode[i] == bw_def_linear || data->stereo_mode[i] != bw_def_mono)) {
+                               rotation_check = bw_def_invalid_linear_or_stereo_mode;
+                       }
+               }
+       }
+       if (pipe_check == bw_def_ok && hsr_check == bw_def_ok && vsr_check == bw_def_ok && lb_size_check == bw_def_ok && fbc_check == bw_def_ok && rotation_check == bw_def_ok) {
+               mode_check = bw_def_ok;
+       }
+       else {
+               mode_check = bw_def_notok;
+       }
+       /*number of memory channels for write-back client*/
+       data->number_of_dram_wrchannels = vbios->number_of_dram_channels;
+       data->number_of_dram_channels = vbios->number_of_dram_channels;
+       /*modify number of memory channels if lpt mode is enabled*/
+       /* low power tiling mode register*/
+       /* 0 = use channel 0*/
+       /* 1 = use channel 0 and 1*/
+       /* 2 = use channel 0,1,2,3*/
+       if ((fbc_enabled == 1 && lpt_enabled == 1)) {
+               if (vbios->memory_type == bw_def_hbm)
+                       data->dram_efficiency = bw_frc_to_fixed(5, 10);
+               else
+                       data->dram_efficiency = bw_int_to_fixed(1);
+
+
+               if (dceip->low_power_tiling_mode == 0) {
+                       data->number_of_dram_channels = 1;
+               }
+               else if (dceip->low_power_tiling_mode == 1) {
+                       data->number_of_dram_channels = 2;
+               }
+               else if (dceip->low_power_tiling_mode == 2) {
+                       data->number_of_dram_channels = 4;
+               }
+               else {
+                       data->number_of_dram_channels = 1;
+               }
+       }
+       else {
+               if (vbios->memory_type == bw_def_hbm)
+                       data->dram_efficiency = bw_frc_to_fixed(5, 10);
+               else
+                       data->dram_efficiency = bw_frc_to_fixed(8, 10);
+       }
+       /*memory request size and latency hiding:*/
+       /*request size is normally 64 byte, 2-line interleaved, with full latency hiding*/
+       /*the display write-back requests are single line*/
+       /*for tiled graphics surfaces, or undelay surfaces with width higher than the maximum size for full efficiency, request size is 32 byte in 8 and 16 bpp or if the rotation is orthogonal to the tiling grain. only half is useful of the bytes in the request size in 8 bpp or in 32 bpp if the rotation is orthogonal to the tiling grain.*/
+       /*for undelay surfaces with width lower than the maximum size for full efficiency, requests are 4-line interleaved in 16bpp if the rotation is parallel to the tiling grain, and 8-line interleaved with 4-line latency hiding in 8bpp or if the rotation is orthogonal to the tiling grain.*/
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if ((bw_equ(data->rotation_angle[i], bw_int_to_fixed(90)) || bw_equ(data->rotation_angle[i], bw_int_to_fixed(270)))) {
+                               if ((i < 4)) {
+                                       /*underlay portrait tiling mode is not supported*/
+                                       data->orthogonal_rotation[i] = 1;
+                               }
+                               else {
+                                       /*graphics portrait tiling mode*/
+                                       if (data->graphics_micro_tile_mode == bw_def_rotated_micro_tiling) {
+                                               data->orthogonal_rotation[i] = 0;
+                                       }
+                                       else {
+                                               data->orthogonal_rotation[i] = 1;
+                                       }
+                               }
+                       }
+                       else {
+                               if ((i < 4)) {
+                                       /*underlay landscape tiling mode is only supported*/
+                                       if (data->underlay_micro_tile_mode == bw_def_display_micro_tiling) {
+                                               data->orthogonal_rotation[i] = 0;
+                                       }
+                                       else {
+                                               data->orthogonal_rotation[i] = 1;
+                                       }
+                               }
+                               else {
+                                       /*graphics landscape tiling mode*/
+                                       if (data->graphics_micro_tile_mode == bw_def_display_micro_tiling) {
+                                               data->orthogonal_rotation[i] = 0;
+                                       }
+                                       else {
+                                               data->orthogonal_rotation[i] = 1;
+                                       }
+                               }
+                       }
+                       if (bw_equ(data->rotation_angle[i], bw_int_to_fixed(90)) || bw_equ(data->rotation_angle[i], bw_int_to_fixed(270))) {
+                               data->underlay_maximum_source_efficient_for_tiling = dceip->underlay_maximum_height_efficient_for_tiling;
+                       }
+                       else {
+                               data->underlay_maximum_source_efficient_for_tiling = dceip->underlay_maximum_width_efficient_for_tiling;
+                       }
+                       if (surface_type[i] == bw_def_display_write_back420_luma || surface_type[i] == bw_def_display_write_back420_chroma) {
+                               data->bytes_per_request[i] = bw_int_to_fixed(64);
+                               data->useful_bytes_per_request[i] = bw_int_to_fixed(64);
+                               data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(1);
+                               data->latency_hiding_lines[i] = bw_int_to_fixed(1);
+                       }
+                       else if (tiling_mode[i] == bw_def_linear) {
+                               data->bytes_per_request[i] = bw_int_to_fixed(64);
+                               data->useful_bytes_per_request[i] = bw_int_to_fixed(64);
+                               data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(2);
+                               data->latency_hiding_lines[i] = bw_int_to_fixed(2);
+                       }
+                       else {
+                               if (surface_type[i] == bw_def_graphics || (bw_mtn(data->source_width_rounded_up_to_chunks[i], bw_ceil2(data->underlay_maximum_source_efficient_for_tiling, bw_int_to_fixed(256))))) {
+                                       switch (data->bytes_per_pixel[i]) {
+                                       case 8:
+                                               data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(2);
+                                               data->latency_hiding_lines[i] = bw_int_to_fixed(2);
+                                               if (data->orthogonal_rotation[i]) {
+                                                       data->bytes_per_request[i] = bw_int_to_fixed(32);
+                                                       data->useful_bytes_per_request[i] = bw_int_to_fixed(32);
+                                               }
+                                               else {
+                                                       data->bytes_per_request[i] = bw_int_to_fixed(64);
+                                                       data->useful_bytes_per_request[i] = bw_int_to_fixed(64);
+                                               }
+                                               break;
+                                       case 4:
+                                               if (data->orthogonal_rotation[i]) {
+                                                       data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(2);
+                                                       data->latency_hiding_lines[i] = bw_int_to_fixed(2);
+                                                       data->bytes_per_request[i] = bw_int_to_fixed(32);
+                                                       data->useful_bytes_per_request[i] = bw_int_to_fixed(16);
+                                               }
+                                               else {
+                                                       data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(2);
+                                                       data->latency_hiding_lines[i] = bw_int_to_fixed(2);
+                                                       data->bytes_per_request[i] = bw_int_to_fixed(64);
+                                                       data->useful_bytes_per_request[i] = bw_int_to_fixed(64);
+                                               }
+                                               break;
+                                       case 2:
+                                               data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(2);
+                                               data->latency_hiding_lines[i] = bw_int_to_fixed(2);
+                                               data->bytes_per_request[i] = bw_int_to_fixed(32);
+                                               data->useful_bytes_per_request[i] = bw_int_to_fixed(32);
+                                               break;
+                                       default:
+                                               data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(2);
+                                               data->latency_hiding_lines[i] = bw_int_to_fixed(2);
+                                               data->bytes_per_request[i] = bw_int_to_fixed(32);
+                                               data->useful_bytes_per_request[i] = bw_int_to_fixed(16);
+                                               break;
+                                       }
+                               }
+                               else {
+                                       data->bytes_per_request[i] = bw_int_to_fixed(64);
+                                       data->useful_bytes_per_request[i] = bw_int_to_fixed(64);
+                                       if (data->orthogonal_rotation[i]) {
+                                               data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(8);
+                                               data->latency_hiding_lines[i] = bw_int_to_fixed(4);
+                                       }
+                                       else {
+                                               switch (data->bytes_per_pixel[i]) {
+                                               case 4:
+                                                       data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(2);
+                                                       data->latency_hiding_lines[i] = bw_int_to_fixed(2);
+                                                       break;
+                                               case 2:
+                                                       data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(4);
+                                                       data->latency_hiding_lines[i] = bw_int_to_fixed(4);
+                                                       break;
+                                               default:
+                                                       data->lines_interleaved_in_mem_access[i] = bw_int_to_fixed(8);
+                                                       data->latency_hiding_lines[i] = bw_int_to_fixed(4);
+                                                       break;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       /*requested peak bandwidth:*/
+       /*the peak request-per-second bandwidth is the product of the maximum source lines in per line out in the beginning*/
+       /*and in the middle of the frame, the ratio of the source width to the line time, the ratio of line interleaving*/
+       /*in memory to lines of latency hiding, and the ratio of bytes per pixel to useful bytes per request.*/
+       /**/
+       /*if the dmif data buffer size holds more than vta_ps worth of source lines, then only vsr is used.*/
+       /*the peak bandwidth is the peak request-per-second bandwidth times the request size.*/
+       /**/
+       /*the line buffer lines in per line out in the beginning of the frame is the vertical filter initialization value*/
+       /*rounded up to even and divided by the line times for initialization, which is normally three.*/
+       /*the line buffer lines in per line out in the middle of the frame is at least one, or the vertical scale ratio,*/
+       /*rounded up to line pairs if not doing line buffer prefetching.*/
+       /**/
+       /*the non-prefetching rounding up of the vertical scale ratio can also be done up to 1 (for a 0,2 pattern), 4/3 (for a 0,2,2 pattern),*/
+       /*6/4 (for a 0,2,2,2 pattern), or 3 (for a 2,4 pattern).*/
+       /**/
+       /*the scaler vertical filter initialization value is calculated by the hardware as the floor of the average of the*/
+       /*vertical scale ratio and the number of vertical taps increased by one.  add one more for possible odd line*/
+       /*panning/bezel adjustment mode.*/
+       /**/
+       /*for the bottom interlace field an extra 50% of the vertical scale ratio is considered for this calculation.*/
+       /*in top-bottom stereo mode software has to set the filter initialization value manually and explicitly limit it to 4.*/
+       /*furthermore, there is only one line time for initialization.*/
+       /**/
+       /*line buffer prefetching is done when the number of lines in the line buffer exceeds the number of taps plus*/
+       /*the ceiling of the vertical scale ratio.*/
+       /**/
+       /*multi-line buffer prefetching is only done in the graphics pipe when the scaler is disabled or when upscaling and the vsr <= 0.8.'*/
+       /**/
+       /*the horizontal blank and chunk granularity factor is indirectly used indicate the interval of time required to transfer the source pixels.*/
+       /*the denominator of this term represents the total number of destination output pixels required for the input source pixels.*/
+       /*it applies when the lines in per line out is not 2 or 4.  it does not apply when there is a line buffer between the scl and blnd.*/
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       data->v_filter_init[i] = bw_floor2(bw_div((bw_add(bw_add(bw_add(bw_int_to_fixed(1), data->v_taps[i]), data->vsr[i]), bw_mul(bw_mul(bw_int_to_fixed(data->interlace_mode[i]), bw_frc_to_fixed(5, 10)), data->vsr[i]))), bw_int_to_fixed(2)), bw_int_to_fixed(1));
+                       if (data->panning_and_bezel_adjustment == bw_def_any_lines) {
+                               data->v_filter_init[i] = bw_add(data->v_filter_init[i], bw_int_to_fixed(1));
+                       }
+                       if (data->stereo_mode[i] == bw_def_top_bottom) {
+                               data->v_filter_init[i] = bw_min2(data->v_filter_init[i], bw_int_to_fixed(4));
+                       }
+                       if (data->stereo_mode[i] == bw_def_top_bottom) {
+                               data->num_lines_at_frame_start = bw_int_to_fixed(1);
+                       }
+                       else {
+                               data->num_lines_at_frame_start = bw_int_to_fixed(3);
+                       }
+                       if ((bw_mtn(data->vsr[i], bw_int_to_fixed(1)) && surface_type[i] == bw_def_graphics) || data->panning_and_bezel_adjustment == bw_def_any_lines) {
+                               data->line_buffer_prefetch[i] = 0;
+                       }
+                       else if ((((dceip->underlay_downscale_prefetch_enabled == 1 && surface_type[i] != bw_def_graphics) || surface_type[i] == bw_def_graphics) && (bw_mtn(data->lb_partitions[i], bw_add(data->v_taps[i], bw_ceil2(data->vsr[i], bw_int_to_fixed(1))))))) {
+                               data->line_buffer_prefetch[i] = 1;
+                       }
+                       else {
+                               data->line_buffer_prefetch[i] = 0;
+                       }
+                       data->lb_lines_in_per_line_out_in_beginning_of_frame[i] = bw_div(bw_ceil2(data->v_filter_init[i], bw_int_to_fixed(dceip->lines_interleaved_into_lb)), data->num_lines_at_frame_start);
+                       if (data->line_buffer_prefetch[i] == 1) {
+                               data->lb_lines_in_per_line_out_in_middle_of_frame[i] = bw_max2(bw_int_to_fixed(1), data->vsr[i]);
+                       }
+                       else if (bw_leq(data->vsr[i], bw_int_to_fixed(1))) {
+                               data->lb_lines_in_per_line_out_in_middle_of_frame[i] = bw_int_to_fixed(1);
+                       } else if (bw_leq(data->vsr[i],
+                                       bw_frc_to_fixed(4, 3))) {
+                               data->lb_lines_in_per_line_out_in_middle_of_frame[i] = bw_div(bw_int_to_fixed(4), bw_int_to_fixed(3));
+                       } else if (bw_leq(data->vsr[i],
+                                       bw_frc_to_fixed(6, 4))) {
+                               data->lb_lines_in_per_line_out_in_middle_of_frame[i] = bw_div(bw_int_to_fixed(6), bw_int_to_fixed(4));
+                       }
+                       else if (bw_leq(data->vsr[i], bw_int_to_fixed(2))) {
+                               data->lb_lines_in_per_line_out_in_middle_of_frame[i] = bw_int_to_fixed(2);
+                       }
+                       else if (bw_leq(data->vsr[i], bw_int_to_fixed(3))) {
+                               data->lb_lines_in_per_line_out_in_middle_of_frame[i] = bw_int_to_fixed(3);
+                       }
+                       else {
+                               data->lb_lines_in_per_line_out_in_middle_of_frame[i] = bw_int_to_fixed(4);
+                       }
+                       if (data->line_buffer_prefetch[i] == 1 || bw_equ(data->lb_lines_in_per_line_out_in_middle_of_frame[i], bw_int_to_fixed(2)) || bw_equ(data->lb_lines_in_per_line_out_in_middle_of_frame[i], bw_int_to_fixed(4))) {
+                               data->horizontal_blank_and_chunk_granularity_factor[i] = bw_int_to_fixed(1);
+                       }
+                       else {
+                               data->horizontal_blank_and_chunk_granularity_factor[i] = bw_div(data->h_total[i], (bw_div((bw_add(data->h_total[i], bw_div((bw_sub(data->source_width_pixels[i], bw_int_to_fixed(dceip->chunk_width))), data->hsr[i]))), bw_int_to_fixed(2))));
+                       }
+                       data->request_bandwidth[i] = bw_div(bw_mul(bw_div(bw_mul(bw_div(bw_mul(bw_max2(data->lb_lines_in_per_line_out_in_beginning_of_frame[i], data->lb_lines_in_per_line_out_in_middle_of_frame[i]), data->source_width_rounded_up_to_chunks[i]), (bw_div(data->h_total[i], data->pixel_rate[i]))), bw_int_to_fixed(data->bytes_per_pixel[i])), data->useful_bytes_per_request[i]), data->lines_interleaved_in_mem_access[i]), data->latency_hiding_lines[i]);
+                       data->display_bandwidth[i] = bw_mul(data->request_bandwidth[i], data->bytes_per_request[i]);
+               }
+       }
+       /*outstanding chunk request limit*/
+       /*if underlay buffer sharing is enabled, the data buffer size for underlay in 422 or 444 is the sum of the luma and chroma data buffer sizes.*/
+       /*underlay buffer sharing mode is only permitted in orthogonal rotation modes.*/
+       /**/
+       /*if there is only one display enabled, the dmif data buffer size for the graphics surface is increased by concatenating the adjacent buffers.*/
+       /**/
+       /*the memory chunk size in bytes is 1024 for the writeback, and 256 times the memory line interleaving and the bytes per pixel for graphics*/
+       /*and underlay.*/
+       /**/
+       /*the pipe chunk size uses 2 for line interleaving, except for the write back, in which case it is 1.*/
+       /*graphics and underlay data buffer size is adjusted (limited) using the outstanding chunk request limit if there is more than one*/
+       /*display enabled or if the dmif request buffer is not large enough for the total data buffer size.*/
+       /*the outstanding chunk request limit is the ceiling of the adjusted data buffer size divided by the chunk size in bytes*/
+       /*the adjusted data buffer size is the product of the display bandwidth and the minimum effective data buffer size in terms of time,*/
+       /*rounded up to the chunk size in bytes, but should not exceed the original data buffer size*/
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if ((dceip->dmif_pipe_en_fbc_chunk_tracker + 3 == i && fbc_enabled == 0 && tiling_mode[i] != bw_def_linear)) {
+                               data->max_chunks_non_fbc_mode[i] = 128 - dmif_chunk_buff_margin;
+                       }
+                       else {
+                               data->max_chunks_non_fbc_mode[i] = 16 - dmif_chunk_buff_margin;
+                       }
+               }
+               if (data->fbc_en[i] == 1) {
+                       max_chunks_fbc_mode = 128 - dmif_chunk_buff_margin;
+               }
+       }
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       switch (surface_type[i]) {
+                       case bw_def_display_write_back420_luma:
+                               data->data_buffer_size[i] = bw_int_to_fixed(dceip->display_write_back420_luma_mcifwr_buffer_size);
+                               break;
+                       case bw_def_display_write_back420_chroma:
+                               data->data_buffer_size[i] = bw_int_to_fixed(dceip->display_write_back420_chroma_mcifwr_buffer_size);
+                               break;
+                       case bw_def_underlay420_luma:
+                               data->data_buffer_size[i] = bw_int_to_fixed(dceip->underlay_luma_dmif_size);
+                               break;
+                       case bw_def_underlay420_chroma:
+                               data->data_buffer_size[i] = bw_div(bw_int_to_fixed(dceip->underlay_chroma_dmif_size), bw_int_to_fixed(2));
+                               break;
+                       case bw_def_underlay422:case bw_def_underlay444:
+                               if (data->orthogonal_rotation[i] == 0) {
+                                       data->data_buffer_size[i] = bw_int_to_fixed(dceip->underlay_luma_dmif_size);
+                               }
+                               else {
+                                       data->data_buffer_size[i] = bw_add(bw_int_to_fixed(dceip->underlay_luma_dmif_size), bw_int_to_fixed(dceip->underlay_chroma_dmif_size));
+                               }
+                               break;
+                       default:
+                               if (data->fbc_en[i] == 1) {
+                                       /*data_buffer_size(i) = max_dmif_buffer_allocated * graphics_dmif_size*/
+                                       if (data->number_of_displays == 1) {
+                                               data->data_buffer_size[i] = bw_min2(bw_mul(bw_mul(bw_int_to_fixed(max_chunks_fbc_mode), bw_int_to_fixed(pixels_per_chunk)), bw_int_to_fixed(data->bytes_per_pixel[i])), bw_mul(bw_int_to_fixed(dceip->max_dmif_buffer_allocated), bw_int_to_fixed(dceip->graphics_dmif_size)));
+                                       }
+                                       else {
+                                               data->data_buffer_size[i] = bw_min2(bw_mul(bw_mul(bw_int_to_fixed(max_chunks_fbc_mode), bw_int_to_fixed(pixels_per_chunk)), bw_int_to_fixed(data->bytes_per_pixel[i])), bw_int_to_fixed(dceip->graphics_dmif_size));
+                                       }
+                               }
+                               else {
+                                       /*the effective dmif buffer size in non-fbc mode is limited by the 16 entry chunk tracker*/
+                                       if (data->number_of_displays == 1) {
+                                               data->data_buffer_size[i] = bw_min2(bw_mul(bw_mul(bw_int_to_fixed(data->max_chunks_non_fbc_mode[i]), bw_int_to_fixed(pixels_per_chunk)), bw_int_to_fixed(data->bytes_per_pixel[i])), bw_mul(bw_int_to_fixed(dceip->max_dmif_buffer_allocated), bw_int_to_fixed(dceip->graphics_dmif_size)));
+                                       }
+                                       else {
+                                               data->data_buffer_size[i] = bw_min2(bw_mul(bw_mul(bw_int_to_fixed(data->max_chunks_non_fbc_mode[i]), bw_int_to_fixed(pixels_per_chunk)), bw_int_to_fixed(data->bytes_per_pixel[i])), bw_int_to_fixed(dceip->graphics_dmif_size));
+                                       }
+                               }
+                               break;
+                       }
+                       if (surface_type[i] == bw_def_display_write_back420_luma || surface_type[i] == bw_def_display_write_back420_chroma) {
+                               data->memory_chunk_size_in_bytes[i] = bw_int_to_fixed(1024);
+                               data->pipe_chunk_size_in_bytes[i] = bw_int_to_fixed(1024);
+                       }
+                       else {
+                               data->memory_chunk_size_in_bytes[i] = bw_mul(bw_mul(bw_int_to_fixed(dceip->chunk_width), data->lines_interleaved_in_mem_access[i]), bw_int_to_fixed(data->bytes_per_pixel[i]));
+                               data->pipe_chunk_size_in_bytes[i] = bw_mul(bw_mul(bw_int_to_fixed(dceip->chunk_width), bw_int_to_fixed(dceip->lines_interleaved_into_lb)), bw_int_to_fixed(data->bytes_per_pixel[i]));
+                       }
+               }
+       }
+       data->min_dmif_size_in_time = bw_int_to_fixed(9999);
+       data->min_mcifwr_size_in_time = bw_int_to_fixed(9999);
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
+                               if (bw_ltn(bw_div(bw_div(bw_mul(data->data_buffer_size[i], data->bytes_per_request[i]), data->useful_bytes_per_request[i]), data->display_bandwidth[i]), data->min_dmif_size_in_time)) {
+                                       data->min_dmif_size_in_time = bw_div(bw_div(bw_mul(data->data_buffer_size[i], data->bytes_per_request[i]), data->useful_bytes_per_request[i]), data->display_bandwidth[i]);
+                               }
+                       }
+                       else {
+                               if (bw_ltn(bw_div(bw_div(bw_mul(data->data_buffer_size[i], data->bytes_per_request[i]), data->useful_bytes_per_request[i]), data->display_bandwidth[i]), data->min_mcifwr_size_in_time)) {
+                                       data->min_mcifwr_size_in_time = bw_div(bw_div(bw_mul(data->data_buffer_size[i], data->bytes_per_request[i]), data->useful_bytes_per_request[i]), data->display_bandwidth[i]);
+                               }
+                       }
+               }
+       }
+       data->total_requests_for_dmif_size = bw_int_to_fixed(0);
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i] && surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
+                       data->total_requests_for_dmif_size = bw_add(data->total_requests_for_dmif_size, bw_div(data->data_buffer_size[i], data->useful_bytes_per_request[i]));
+               }
+       }
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma && dceip->limit_excessive_outstanding_dmif_requests && (data->number_of_displays > 1 || bw_mtn(data->total_requests_for_dmif_size, dceip->dmif_request_buffer_size))) {
+                               data->adjusted_data_buffer_size[i] = bw_min2(data->data_buffer_size[i], bw_ceil2(bw_mul(data->min_dmif_size_in_time, data->display_bandwidth[i]), data->memory_chunk_size_in_bytes[i]));
+                       }
+                       else {
+                               data->adjusted_data_buffer_size[i] = data->data_buffer_size[i];
+                       }
+               }
+       }
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (data->number_of_displays == 1 && data->number_of_underlay_surfaces == 0) {
+                               /*set maximum chunk limit if only one graphic pipe is enabled*/
+                               data->outstanding_chunk_request_limit[i] = bw_int_to_fixed(127);
+                       }
+                       else {
+                               data->outstanding_chunk_request_limit[i] = bw_ceil2(bw_div(data->adjusted_data_buffer_size[i], data->pipe_chunk_size_in_bytes[i]), bw_int_to_fixed(1));
+                               /*clamp maximum chunk limit in the graphic display pipe*/
+                               if (i >= 4) {
+                                       data->outstanding_chunk_request_limit[i] = bw_max2(bw_int_to_fixed(127), data->outstanding_chunk_request_limit[i]);
+                               }
+                       }
+               }
+       }
+       /*outstanding pte request limit*/
+       /*in tiling mode with no rotation the sg pte requests are 8 useful pt_es, the sg row height is the page height and the sg page width x height is 64x64 for 8bpp, 64x32 for 16 bpp, 32x32 for 32 bpp*/
+       /*in tiling mode with rotation the sg pte requests are only one useful pte, and the sg row height is also the page height, but the sg page width and height are swapped*/
+       /*in linear mode the pte requests are 8 useful pt_es, the sg page width is 4096 divided by the bytes per pixel, the sg page height is 1, but there is just one row whose height is the lines of pte prefetching*/
+       /*the outstanding pte request limit is obtained by multiplying the outstanding chunk request limit by the peak pte request to eviction limiting ratio, rounding up to integer, multiplying by the pte requests per chunk, and rounding up to integer again*/
+       /*if not using peak pte request to eviction limiting, the outstanding pte request limit is the pte requests in the vblank*/
+       /*the pte requests in the vblank is the product of the number of pte request rows times the number of pte requests in a row*/
+       /*the number of pte requests in a row is the quotient of the source width divided by 256, multiplied by the pte requests per chunk, rounded up to even, multiplied by the scatter-gather row height and divided by the scatter-gather page height*/
+       /*the pte requests per chunk is 256 divided by the scatter-gather page width and the useful pt_es per pte request*/
+       if (data->number_of_displays > 1 || (bw_neq(data->rotation_angle[4], bw_int_to_fixed(0)) && bw_neq(data->rotation_angle[4], bw_int_to_fixed(180)))) {
+               data->peak_pte_request_to_eviction_ratio_limiting = dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display;
+       }
+       else {
+               data->peak_pte_request_to_eviction_ratio_limiting = dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation;
+       }
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i] && data->scatter_gather_enable_for_pipe[i] == 1) {
+                       if (tiling_mode[i] == bw_def_linear) {
+                               data->useful_pte_per_pte_request = bw_int_to_fixed(8);
+                               data->scatter_gather_page_width[i] = bw_div(bw_int_to_fixed(4096), bw_int_to_fixed(data->bytes_per_pixel[i]));
+                               data->scatter_gather_page_height[i] = bw_int_to_fixed(1);
+                               data->scatter_gather_pte_request_rows = bw_int_to_fixed(1);
+                               data->scatter_gather_row_height = bw_int_to_fixed(dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode);
+                       }
+                       else if (bw_equ(data->rotation_angle[i], bw_int_to_fixed(0)) || bw_equ(data->rotation_angle[i], bw_int_to_fixed(180))) {
+                               data->useful_pte_per_pte_request = bw_int_to_fixed(8);
+                               switch (data->bytes_per_pixel[i]) {
+                               case 4:
+                                       data->scatter_gather_page_width[i] = bw_int_to_fixed(32);
+                                       data->scatter_gather_page_height[i] = bw_int_to_fixed(32);
+                                       break;
+                               case 2:
+                                       data->scatter_gather_page_width[i] = bw_int_to_fixed(64);
+                                       data->scatter_gather_page_height[i] = bw_int_to_fixed(32);
+                                       break;
+                               default:
+                                       data->scatter_gather_page_width[i] = bw_int_to_fixed(64);
+                                       data->scatter_gather_page_height[i] = bw_int_to_fixed(64);
+                                       break;
+                               }
+                               data->scatter_gather_pte_request_rows = bw_int_to_fixed(dceip->scatter_gather_pte_request_rows_in_tiling_mode);
+                               data->scatter_gather_row_height = data->scatter_gather_page_height[i];
+                       }
+                       else {
+                               data->useful_pte_per_pte_request = bw_int_to_fixed(1);
+                               switch (data->bytes_per_pixel[i]) {
+                               case 4:
+                                       data->scatter_gather_page_width[i] = bw_int_to_fixed(32);
+                                       data->scatter_gather_page_height[i] = bw_int_to_fixed(32);
+                                       break;
+                               case 2:
+                                       data->scatter_gather_page_width[i] = bw_int_to_fixed(32);
+                                       data->scatter_gather_page_height[i] = bw_int_to_fixed(64);
+                                       break;
+                               default:
+                                       data->scatter_gather_page_width[i] = bw_int_to_fixed(64);
+                                       data->scatter_gather_page_height[i] = bw_int_to_fixed(64);
+                                       break;
+                               }
+                               data->scatter_gather_pte_request_rows = bw_int_to_fixed(dceip->scatter_gather_pte_request_rows_in_tiling_mode);
+                               data->scatter_gather_row_height = data->scatter_gather_page_height[i];
+                       }
+                       data->pte_request_per_chunk[i] = bw_div(bw_div(bw_int_to_fixed(dceip->chunk_width), data->scatter_gather_page_width[i]), data->useful_pte_per_pte_request);
+                       data->scatter_gather_pte_requests_in_row[i] = bw_div(bw_mul(bw_ceil2(bw_mul(bw_div(data->source_width_rounded_up_to_chunks[i], bw_int_to_fixed(dceip->chunk_width)), data->pte_request_per_chunk[i]), bw_int_to_fixed(1)), data->scatter_gather_row_height), data->scatter_gather_page_height[i]);
+                       data->scatter_gather_pte_requests_in_vblank = bw_mul(data->scatter_gather_pte_request_rows, data->scatter_gather_pte_requests_in_row[i]);
+                       if (bw_equ(data->peak_pte_request_to_eviction_ratio_limiting, bw_int_to_fixed(0))) {
+                               data->scatter_gather_pte_request_limit[i] = data->scatter_gather_pte_requests_in_vblank;
+                       }
+                       else {
+                               data->scatter_gather_pte_request_limit[i] = bw_max2(dceip->minimum_outstanding_pte_request_limit, bw_min2(data->scatter_gather_pte_requests_in_vblank, bw_ceil2(bw_mul(bw_mul(bw_div(bw_ceil2(data->adjusted_data_buffer_size[i], data->memory_chunk_size_in_bytes[i]), data->memory_chunk_size_in_bytes[i]), data->pte_request_per_chunk[i]), data->peak_pte_request_to_eviction_ratio_limiting), bw_int_to_fixed(1))));
+                       }
+               }
+       }
+       /*pitch padding recommended for efficiency in linear mode*/
+       /*in linear mode graphics or underlay with scatter gather, a pitch that is a multiple of the channel interleave (256 bytes) times the channel-bank rotation is not efficient*/
+       /*if that is the case it is recommended to pad the pitch by at least 256 pixels*/
+       data->inefficient_linear_pitch_in_bytes = bw_mul(bw_mul(bw_int_to_fixed(256), bw_int_to_fixed(vbios->number_of_dram_banks)), bw_int_to_fixed(data->number_of_dram_channels));
+
+       /*pixel transfer time*/
+       /*the dmif and mcifwr yclk(pclk) required is the one that allows the transfer of all pipe's data buffer size in memory in the time for data transfer*/
+       /*for dmif, pte and cursor requests have to be included.*/
+       /*the dram data requirement is doubled when the data request size in bytes is less than the dram channel width times the burst size (8)*/
+       /*the dram data requirement is also multiplied by the number of channels in the case of low power tiling*/
+       /*the page close-open time is determined by trc and the number of page close-opens*/
+       /*in tiled mode graphics or underlay with scatter-gather enabled the bytes per page close-open is the product of the memory line interleave times the maximum of the scatter-gather page width and the product of the tile width (8 pixels) times the number of channels times the number of banks.*/
+       /*in linear mode graphics or underlay with scatter-gather enabled and inefficient pitch, the bytes per page close-open is the line request alternation slice, because different lines are in completely different 4k address bases.*/
+       /*otherwise, the bytes page close-open is the chunk size because that is the arbitration slice.*/
+       /*pte requests are grouped by pte requests per chunk if that is more than 1. each group costs a page close-open time for dmif reads*/
+       /*cursor requests outstanding are limited to a group of two source lines. each group costs a page close-open time for dmif reads*/
+       /*the display reads and writes time for data transfer is the minimum data or cursor buffer size in time minus the mc urgent latency*/
+       /*the mc urgent latency is experienced more than one time if the number of dmif requests in the data buffer exceeds the request buffer size plus the request slots reserved for dmif in the dram channel arbiter queues*/
+       /*the dispclk required is the maximum for all surfaces of the maximum of the source pixels for first output pixel times the throughput factor, divided by the pixels per dispclk, and divided by the minimum latency hiding minus the dram speed/p-state change latency minus the burst time, and the source pixels for last output pixel, times the throughput factor, divided by the pixels per dispclk, and divided by the minimum latency hiding minus the dram speed/p-state change latency minus the burst time, plus the active time.*/
+       /*the data burst time is the maximum of the total page close-open time, total dmif/mcifwr buffer size in memory divided by the dram bandwidth, and the total dmif/mcifwr buffer size in memory divided by the 32 byte sclk data bus bandwidth, each multiplied by its efficiency.*/
+       /*the source line transfer time is the maximum for all surfaces of the maximum of the burst time plus the urgent latency times the floor of the data required divided by the buffer size for the fist pixel, and the burst time plus the urgent latency times the floor of the data required divided by the buffer size for the last pixel plus the active time.*/
+       /*the source pixels for the first output pixel is 512 if the scaler vertical filter initialization value is greater than 2, and it is 4 times the source width if it is greater than 4.*/
+       /*the source pixels for the last output pixel is the source width times the scaler vertical filter initialization value rounded up to even*/
+       /*the source data for these pixels is the number of pixels times the bytes per pixel times the bytes per request divided by the useful bytes per request.*/
+       data->cursor_total_data = bw_int_to_fixed(0);
+       data->cursor_total_request_groups = bw_int_to_fixed(0);
+       data->scatter_gather_total_pte_requests = bw_int_to_fixed(0);
+       data->scatter_gather_total_pte_request_groups = bw_int_to_fixed(0);
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       data->cursor_total_data = bw_add(data->cursor_total_data, bw_mul(bw_mul(bw_int_to_fixed(2), data->cursor_width_pixels[i]), bw_int_to_fixed(4)));
+                       if (dceip->large_cursor == 1) {
+                               data->cursor_total_request_groups = bw_add(data->cursor_total_request_groups, bw_int_to_fixed((dceip->cursor_max_outstanding_group_num + 1)));
+                       }
+                       else {
+                               data->cursor_total_request_groups = bw_add(data->cursor_total_request_groups, bw_ceil2(bw_div(data->cursor_width_pixels[i], dceip->cursor_chunk_width), bw_int_to_fixed(1)));
+                       }
+                       if (data->scatter_gather_enable_for_pipe[i]) {
+                               data->scatter_gather_total_pte_requests = bw_add(data->scatter_gather_total_pte_requests, data->scatter_gather_pte_request_limit[i]);
+                               data->scatter_gather_total_pte_request_groups = bw_add(data->scatter_gather_total_pte_request_groups, bw_ceil2(bw_div(data->scatter_gather_pte_request_limit[i], bw_ceil2(data->pte_request_per_chunk[i], bw_int_to_fixed(1))), bw_int_to_fixed(1)));
+                       }
+               }
+       }
+       data->tile_width_in_pixels = bw_int_to_fixed(8);
+       data->dmif_total_number_of_data_request_page_close_open = bw_int_to_fixed(0);
+       data->mcifwr_total_number_of_data_request_page_close_open = bw_int_to_fixed(0);
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (data->scatter_gather_enable_for_pipe[i] == 1 && tiling_mode[i] != bw_def_linear) {
+                               data->bytes_per_page_close_open = bw_mul(data->lines_interleaved_in_mem_access[i], bw_max2(bw_mul(bw_mul(bw_mul(bw_int_to_fixed(data->bytes_per_pixel[i]), data->tile_width_in_pixels), bw_int_to_fixed(vbios->number_of_dram_banks)), bw_int_to_fixed(data->number_of_dram_channels)), bw_mul(bw_int_to_fixed(data->bytes_per_pixel[i]), data->scatter_gather_page_width[i])));
+                       }
+                       else if (data->scatter_gather_enable_for_pipe[i] == 1 && tiling_mode[i] == bw_def_linear && bw_equ(bw_mod((bw_mul(data->pitch_in_pixels_after_surface_type[i], bw_int_to_fixed(data->bytes_per_pixel[i]))), data->inefficient_linear_pitch_in_bytes), bw_int_to_fixed(0))) {
+                               data->bytes_per_page_close_open = dceip->linear_mode_line_request_alternation_slice;
+                       }
+                       else {
+                               data->bytes_per_page_close_open = data->memory_chunk_size_in_bytes[i];
+                       }
+                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
+                               data->dmif_total_number_of_data_request_page_close_open = bw_add(data->dmif_total_number_of_data_request_page_close_open, bw_div(bw_ceil2(data->adjusted_data_buffer_size[i], data->memory_chunk_size_in_bytes[i]), data->bytes_per_page_close_open));
+                       }
+                       else {
+                               data->mcifwr_total_number_of_data_request_page_close_open = bw_add(data->mcifwr_total_number_of_data_request_page_close_open, bw_div(bw_ceil2(data->adjusted_data_buffer_size[i], data->memory_chunk_size_in_bytes[i]), data->bytes_per_page_close_open));
+                       }
+               }
+       }
+       data->dmif_total_page_close_open_time = bw_div(bw_mul((bw_add(bw_add(data->dmif_total_number_of_data_request_page_close_open, data->scatter_gather_total_pte_request_groups), data->cursor_total_request_groups)), vbios->trc), bw_int_to_fixed(1000));
+       data->mcifwr_total_page_close_open_time = bw_div(bw_mul(data->mcifwr_total_number_of_data_request_page_close_open, vbios->trc), bw_int_to_fixed(1000));
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       data->adjusted_data_buffer_size_in_memory[i] = bw_div(bw_mul(data->adjusted_data_buffer_size[i], data->bytes_per_request[i]), data->useful_bytes_per_request[i]);
+               }
+       }
+       data->total_requests_for_adjusted_dmif_size = bw_int_to_fixed(0);
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
+                               data->total_requests_for_adjusted_dmif_size = bw_add(data->total_requests_for_adjusted_dmif_size, bw_div(data->adjusted_data_buffer_size[i], data->useful_bytes_per_request[i]));
+                       }
+               }
+       }
+       data->total_dmifmc_urgent_trips = bw_ceil2(bw_div(data->total_requests_for_adjusted_dmif_size, (bw_add(dceip->dmif_request_buffer_size, bw_int_to_fixed(vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel * data->number_of_dram_channels)))), bw_int_to_fixed(1));
+       data->total_dmifmc_urgent_latency = bw_mul(vbios->dmifmc_urgent_latency, data->total_dmifmc_urgent_trips);
+       data->total_display_reads_required_data = bw_int_to_fixed(0);
+       data->total_display_reads_required_dram_access_data = bw_int_to_fixed(0);
+       data->total_display_writes_required_data = bw_int_to_fixed(0);
+       data->total_display_writes_required_dram_access_data = bw_int_to_fixed(0);
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
+                               data->display_reads_required_data = data->adjusted_data_buffer_size_in_memory[i];
+                               /*for hbm memories, each channel is split into 2 pseudo-channels that are each 64 bits in width.  each*/
+                               /*pseudo-channel may be read independently of one another.*/
+                               /*the read burst length (bl) for hbm memories is 4, so each read command will access 32 bytes of data.*/
+                               /*the 64 or 32 byte sized data is stored in one pseudo-channel.*/
+                               /*it will take 4 memclk cycles or 8 yclk cycles to fetch 64 bytes of data from the hbm memory (2 read commands).*/
+                               /*it will take 2 memclk cycles or 4 yclk cycles to fetch 32 bytes of data from the hbm memory (1 read command).*/
+                               /*for gddr5/ddr4 memories, there is additional overhead if the size of the request is smaller than 64 bytes.*/
+                               /*the read burst length (bl) for gddr5/ddr4 memories is 8, regardless of the size of the data request.*/
+                               /*therefore it will require 8 cycles to fetch 64 or 32 bytes of data from the memory.*/
+                               /*the memory efficiency will be 50% for the 32 byte sized data.*/
+                               if (vbios->memory_type == bw_def_hbm) {
+                                       data->display_reads_required_dram_access_data = data->adjusted_data_buffer_size_in_memory[i];
+                               }
+                               else {
+                                       data->display_reads_required_dram_access_data = bw_mul(data->adjusted_data_buffer_size_in_memory[i], bw_ceil2(bw_div(bw_int_to_fixed((8 * vbios->dram_channel_width_in_bits / 8)), data->bytes_per_request[i]), bw_int_to_fixed(1)));
+                               }
+                               data->total_display_reads_required_data = bw_add(data->total_display_reads_required_data, data->display_reads_required_data);
+                               data->total_display_reads_required_dram_access_data = bw_add(data->total_display_reads_required_dram_access_data, data->display_reads_required_dram_access_data);
+                       }
+                       else {
+                               data->total_display_writes_required_data = bw_add(data->total_display_writes_required_data, data->adjusted_data_buffer_size_in_memory[i]);
+                               data->total_display_writes_required_dram_access_data = bw_add(data->total_display_writes_required_dram_access_data, bw_mul(data->adjusted_data_buffer_size_in_memory[i], bw_ceil2(bw_div(bw_int_to_fixed(vbios->dram_channel_width_in_bits), data->bytes_per_request[i]), bw_int_to_fixed(1))));
+                       }
+               }
+       }
+       data->total_display_reads_required_data = bw_add(bw_add(data->total_display_reads_required_data, data->cursor_total_data), bw_mul(data->scatter_gather_total_pte_requests, bw_int_to_fixed(64)));
+       data->total_display_reads_required_dram_access_data = bw_add(bw_add(data->total_display_reads_required_dram_access_data, data->cursor_total_data), bw_mul(data->scatter_gather_total_pte_requests, bw_int_to_fixed(64)));
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (bw_mtn(data->v_filter_init[i], bw_int_to_fixed(4))) {
+                               data->src_pixels_for_first_output_pixel[i] = bw_mul(bw_int_to_fixed(4), data->source_width_rounded_up_to_chunks[i]);
+                       }
+                       else {
+                               if (bw_mtn(data->v_filter_init[i], bw_int_to_fixed(2))) {
+                                       data->src_pixels_for_first_output_pixel[i] = bw_int_to_fixed(512);
+                               }
+                               else {
+                                       data->src_pixels_for_first_output_pixel[i] = bw_int_to_fixed(0);
+                               }
+                       }
+                       data->src_data_for_first_output_pixel[i] = bw_div(bw_mul(bw_mul(data->src_pixels_for_first_output_pixel[i], bw_int_to_fixed(data->bytes_per_pixel[i])), data->bytes_per_request[i]), data->useful_bytes_per_request[i]);
+                       data->src_pixels_for_last_output_pixel[i] = bw_mul(data->source_width_rounded_up_to_chunks[i], bw_max2(bw_ceil2(data->v_filter_init[i], bw_int_to_fixed(dceip->lines_interleaved_into_lb)), bw_mul(bw_ceil2(data->vsr[i], bw_int_to_fixed(dceip->lines_interleaved_into_lb)), data->horizontal_blank_and_chunk_granularity_factor[i])));
+                       data->src_data_for_last_output_pixel[i] = bw_div(bw_mul(bw_mul(bw_mul(data->source_width_rounded_up_to_chunks[i], bw_max2(bw_ceil2(data->v_filter_init[i], bw_int_to_fixed(dceip->lines_interleaved_into_lb)), data->lines_interleaved_in_mem_access[i])), bw_int_to_fixed(data->bytes_per_pixel[i])), data->bytes_per_request[i]), data->useful_bytes_per_request[i]);
+                       data->active_time[i] = bw_div(bw_div(data->source_width_rounded_up_to_chunks[i], data->hsr[i]), data->pixel_rate[i]);
+               }
+       }
+       for (i = 0; i <= 2; i++) {
+               for (j = 0; j <= 7; j++) {
+                       data->dmif_burst_time[i][j] = bw_max3(data->dmif_total_page_close_open_time, bw_div(data->total_display_reads_required_dram_access_data, (bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[i]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels)))), bw_div(data->total_display_reads_required_data, (bw_mul(bw_mul(sclk[j], vbios->data_return_bus_width), bw_frc_to_fixed(dceip->percent_of_ideal_port_bw_received_after_urgent_latency, 100)))));
+                       if (data->d1_display_write_back_dwb_enable == 1) {
+                               data->mcifwr_burst_time[i][j] = bw_max3(data->mcifwr_total_page_close_open_time, bw_div(data->total_display_writes_required_dram_access_data, (bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[i]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_wrchannels)))), bw_div(data->total_display_writes_required_data, (bw_mul(sclk[j], vbios->data_return_bus_width))));
+                       }
+               }
+       }
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               for (j = 0; j <= 2; j++) {
+                       for (k = 0; k <= 7; k++) {
+                               if (data->enable[i]) {
+                                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
+                                               /*time to transfer data from the dmif buffer to the lb.  since the mc to dmif transfer time overlaps*/
+                                               /*with the dmif to lb transfer time, only time to transfer the last chunk  is considered.*/
+                                               data->dmif_buffer_transfer_time[i] = bw_mul(data->source_width_rounded_up_to_chunks[i], (bw_div(dceip->lb_write_pixels_per_dispclk, (bw_div(vbios->low_voltage_max_dispclk, dceip->display_pipe_throughput_factor)))));
+                                               data->line_source_transfer_time[i][j][k] = bw_max2(bw_mul((bw_add(data->total_dmifmc_urgent_latency, data->dmif_burst_time[j][k])), bw_floor2(bw_div(data->src_data_for_first_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1))), bw_sub(bw_add(bw_mul((bw_add(data->total_dmifmc_urgent_latency, data->dmif_burst_time[j][k])), bw_floor2(bw_div(data->src_data_for_last_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1))), data->dmif_buffer_transfer_time[i]), data->active_time[i]));
+                                               /*during an mclk switch the requests from the dce ip are stored in the gmc/arb.  these requests should be serviced immediately*/
+                                               /*after the mclk switch sequence and not incur an urgent latency penalty.  it is assumed that the gmc/arb can hold up to 256 requests*/
+                                               /*per memory channel.  if the dce ip is urgent after the mclk switch sequence, all pending requests and subsequent requests should be*/
+                                               /*immediately serviced without a gap in the urgent requests.*/
+                                               /*the latency incurred would be the time to issue the requests and return the data for the first or last output pixel.*/
+                                               if (surface_type[i] == bw_def_graphics) {
+                                                       switch (data->lb_bpc[i]) {
+                                                       case 6:
+                                                               data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency6_bit_per_component;
+                                                               break;
+                                                       case 8:
+                                                               data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency8_bit_per_component;
+                                                               break;
+                                                       case 10:
+                                                               data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency10_bit_per_component;
+                                                               break;
+                                                       default:
+                                                               data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency12_bit_per_component;
+                                                               break;
+                                                       }
+                                                       if (data->use_alpha[i] == 1) {
+                                                               data->v_scaler_efficiency = bw_min2(data->v_scaler_efficiency, dceip->alpha_vscaler_efficiency);
+                                                       }
+                                               }
+                                               else {
+                                                       switch (data->lb_bpc[i]) {
+                                                       case 6:
+                                                               data->v_scaler_efficiency = dceip->underlay_vscaler_efficiency6_bit_per_component;
+                                                               break;
+                                                       case 8:
+                                                               data->v_scaler_efficiency = dceip->underlay_vscaler_efficiency8_bit_per_component;
+                                                               break;
+                                                       case 10:
+                                                               data->v_scaler_efficiency = dceip->underlay_vscaler_efficiency10_bit_per_component;
+                                                               break;
+                                                       default:
+                                                               data->v_scaler_efficiency = bw_int_to_fixed(3);
+                                                               break;
+                                                       }
+                                               }
+                                               if (dceip->pre_downscaler_enabled && bw_mtn(data->hsr[i], bw_int_to_fixed(1))) {
+                                                       data->scaler_limits_factor = bw_max2(bw_div(data->v_taps[i], data->v_scaler_efficiency), bw_div(data->source_width_rounded_up_to_chunks[i], data->h_total[i]));
+                                               }
+                                               else {
+                                                       data->scaler_limits_factor = bw_max3(bw_int_to_fixed(1), bw_ceil2(bw_div(data->h_taps[i], bw_int_to_fixed(4)), bw_int_to_fixed(1)), bw_mul(data->hsr[i], bw_max2(bw_div(data->v_taps[i], data->v_scaler_efficiency), bw_int_to_fixed(1))));
+                                               }
+                                               data->dram_speed_change_line_source_transfer_time[i][j][k] = bw_mul(bw_int_to_fixed(2), bw_max2((bw_add((bw_div(data->src_data_for_first_output_pixel[i], bw_min2(bw_mul(data->bytes_per_request[i], sclk[k]), bw_div(bw_mul(bw_mul(data->bytes_per_request[i], data->pixel_rate[i]), data->scaler_limits_factor), bw_int_to_fixed(2))))), (bw_mul(data->dmif_burst_time[j][k], bw_floor2(bw_div(data->src_data_for_first_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1)))))), (bw_add((bw_div(data->src_data_for_last_output_pixel[i], bw_min2(bw_mul(data->bytes_per_request[i], sclk[k]), bw_div(bw_mul(bw_mul(data->bytes_per_request[i], data->pixel_rate[i]), data->scaler_limits_factor), bw_int_to_fixed(2))))), (bw_sub(bw_mul(data->dmif_burst_time[j][k], bw_floor2(bw_div(data->src_data_for_last_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1))), data->active_time[i]))))));
+                                       }
+                                       else {
+                                               data->line_source_transfer_time[i][j][k] = bw_max2(bw_mul((bw_add(vbios->mcifwrmc_urgent_latency, data->mcifwr_burst_time[j][k])), bw_floor2(bw_div(data->src_data_for_first_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1))), bw_sub(bw_mul((bw_add(vbios->mcifwrmc_urgent_latency, data->mcifwr_burst_time[j][k])), bw_floor2(bw_div(data->src_data_for_last_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1))), data->active_time[i]));
+                                               /*during an mclk switch the requests from the dce ip are stored in the gmc/arb.  these requests should be serviced immediately*/
+                                               /*after the mclk switch sequence and not incur an urgent latency penalty.  it is assumed that the gmc/arb can hold up to 256 requests*/
+                                               /*per memory channel.  if the dce ip is urgent after the mclk switch sequence, all pending requests and subsequent requests should be*/
+                                               /*immediately serviced without a gap in the urgent requests.*/
+                                               /*the latency incurred would be the time to issue the requests and return the data for the first or last output pixel.*/
+                                               data->dram_speed_change_line_source_transfer_time[i][j][k] = bw_max2((bw_add((bw_div(data->src_data_for_first_output_pixel[i], bw_min2(bw_mul(data->bytes_per_request[i], sclk[k]), bw_div(bw_mul(data->bytes_per_request[i], vbios->low_voltage_max_dispclk), bw_int_to_fixed(2))))), (bw_mul(data->mcifwr_burst_time[j][k], bw_floor2(bw_div(data->src_data_for_first_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1)))))), (bw_add((bw_div(data->src_data_for_last_output_pixel[i], bw_min2(bw_mul(data->bytes_per_request[i], sclk[k]), bw_div(bw_mul(data->bytes_per_request[i], vbios->low_voltage_max_dispclk), bw_int_to_fixed(2))))), (bw_sub(bw_mul(data->mcifwr_burst_time[j][k], bw_floor2(bw_div(data->src_data_for_last_output_pixel[i], data->adjusted_data_buffer_size_in_memory[i]), bw_int_to_fixed(1))), data->active_time[i])))));
+                                       }
+                               }
+                       }
+               }
+       }
+       /*cpu c-state and p-state change enable*/
+       /*for cpu p-state change to be possible for a yclk(pclk) and sclk level the dispclk required has to be enough for the blackout duration*/
+       /*for cpu c-state change to be possible for a yclk(pclk) and sclk level the dispclk required has to be enough for the blackout duration and recovery*/
+       /*condition for the blackout duration:*/
+       /* minimum latency hiding > blackout duration + dmif burst time + line source transfer time*/
+       /*condition for the blackout recovery:*/
+       /* recovery time >  dmif burst time + 2 * urgent latency*/
+       /* recovery time > (display bw * blackout duration  + (2 * urgent latency + dmif burst time)*dispclk - dmif size )*/
+       /*                  / (dispclk - display bw)*/
+       /*the minimum latency hiding is the minimum for all pipes of one screen line time, plus one more line time if doing lb prefetch, plus the dmif data buffer size equivalent in time, minus the urgent latency.*/
+       /*the minimum latency hiding is  further limited by the cursor.  the cursor latency hiding is the number of lines of the cursor buffer, minus one if the downscaling is less than two, or minus three if it is more*/
+
+       /*initialize variables*/
+       number_of_displays_enabled = 0;
+       number_of_displays_enabled_with_margin = 0;
+       for (k = 0; k <= maximum_number_of_surfaces - 1; k++) {
+               if (data->enable[k]) {
+                       number_of_displays_enabled = number_of_displays_enabled + 1;
+               }
+               data->display_pstate_change_enable[k] = 0;
+       }
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if ((bw_equ(dceip->stutter_and_dram_clock_state_change_gated_before_cursor, bw_int_to_fixed(0)) && bw_mtn(data->cursor_width_pixels[i], bw_int_to_fixed(0)))) {
+                               if (bw_ltn(data->vsr[i], bw_int_to_fixed(2))) {
+                                       data->cursor_latency_hiding[i] = bw_div(bw_div(bw_mul((bw_sub(dceip->cursor_dcp_buffer_lines, bw_int_to_fixed(1))), data->h_total[i]), data->vsr[i]), data->pixel_rate[i]);
+                               }
+                               else {
+                                       data->cursor_latency_hiding[i] = bw_div(bw_div(bw_mul((bw_sub(dceip->cursor_dcp_buffer_lines, bw_int_to_fixed(3))), data->h_total[i]), data->vsr[i]), data->pixel_rate[i]);
+                               }
+                       }
+                       else {
+                               data->cursor_latency_hiding[i] = bw_int_to_fixed(9999);
+                       }
+               }
+       }
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (dceip->graphics_lb_nodownscaling_multi_line_prefetching == 1 && (bw_equ(data->vsr[i], bw_int_to_fixed(1)) || (bw_leq(data->vsr[i], bw_frc_to_fixed(8, 10)) && bw_leq(data->v_taps[i], bw_int_to_fixed(2)) && data->lb_bpc[i] == 8)) && surface_type[i] == bw_def_graphics) {
+                               if (number_of_displays_enabled > 2)
+                                       data->minimum_latency_hiding[i] = bw_sub(bw_div(bw_mul((bw_div((bw_add(bw_sub(data->lb_partitions[i], bw_int_to_fixed(2)), bw_div(bw_div(data->data_buffer_size[i], bw_int_to_fixed(data->bytes_per_pixel[i])), data->source_width_pixels[i]))), data->vsr[i])), data->h_total[i]), data->pixel_rate[i]), data->total_dmifmc_urgent_latency);
+                               else
+                                       data->minimum_latency_hiding[i] = bw_sub(bw_div(bw_mul((bw_div((bw_add(bw_sub(data->lb_partitions[i], bw_int_to_fixed(1)), bw_div(bw_div(data->data_buffer_size[i], bw_int_to_fixed(data->bytes_per_pixel[i])), data->source_width_pixels[i]))), data->vsr[i])), data->h_total[i]), data->pixel_rate[i]), data->total_dmifmc_urgent_latency);
+                       }
+                       else {
+                               data->minimum_latency_hiding[i] = bw_sub(bw_div(bw_mul((bw_div((bw_add(bw_int_to_fixed(1 + data->line_buffer_prefetch[i]), bw_div(bw_div(data->data_buffer_size[i], bw_int_to_fixed(data->bytes_per_pixel[i])), data->source_width_pixels[i]))), data->vsr[i])), data->h_total[i]), data->pixel_rate[i]), data->total_dmifmc_urgent_latency);
+                       }
+                       data->minimum_latency_hiding_with_cursor[i] = bw_min2(data->minimum_latency_hiding[i], data->cursor_latency_hiding[i]);
+               }
+       }
+       for (i = 0; i <= 2; i++) {
+               for (j = 0; j <= 7; j++) {
+                       data->blackout_duration_margin[i][j] = bw_int_to_fixed(9999);
+                       data->dispclk_required_for_blackout_duration[i][j] = bw_int_to_fixed(0);
+                       data->dispclk_required_for_blackout_recovery[i][j] = bw_int_to_fixed(0);
+                       for (k = 0; k <= maximum_number_of_surfaces - 1; k++) {
+                               if (data->enable[k] && bw_mtn(vbios->blackout_duration, bw_int_to_fixed(0))) {
+                                       if (surface_type[k] != bw_def_display_write_back420_luma && surface_type[k] != bw_def_display_write_back420_chroma) {
+                                               data->blackout_duration_margin[i][j] = bw_min2(data->blackout_duration_margin[i][j], bw_sub(bw_sub(bw_sub(data->minimum_latency_hiding_with_cursor[k], vbios->blackout_duration), data->dmif_burst_time[i][j]), data->line_source_transfer_time[k][i][j]));
+                                               data->dispclk_required_for_blackout_duration[i][j] = bw_max3(data->dispclk_required_for_blackout_duration[i][j], bw_div(bw_div(bw_mul(data->src_pixels_for_first_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_sub(bw_sub(data->minimum_latency_hiding_with_cursor[k], vbios->blackout_duration), data->dmif_burst_time[i][j]))), bw_div(bw_div(bw_mul(data->src_pixels_for_last_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_add(bw_sub(bw_sub(data->minimum_latency_hiding_with_cursor[k], vbios->blackout_duration), data->dmif_burst_time[i][j]), data->active_time[k]))));
+                                               if (bw_leq(vbios->maximum_blackout_recovery_time, bw_add(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[i][j]))) {
+                                                       data->dispclk_required_for_blackout_recovery[i][j] = bw_int_to_fixed(9999);
+                                               }
+                                               else if (bw_ltn(data->adjusted_data_buffer_size[k], bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), (bw_add(vbios->blackout_duration, bw_add(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[i][j])))))) {
+                                                       data->dispclk_required_for_blackout_recovery[i][j] = bw_max2(data->dispclk_required_for_blackout_recovery[i][j], bw_div(bw_mul(bw_div(bw_div((bw_sub(bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), (bw_add(vbios->blackout_duration, vbios->maximum_blackout_recovery_time))), data->adjusted_data_buffer_size[k])), bw_int_to_fixed(data->bytes_per_pixel[k])), (bw_sub(vbios->maximum_blackout_recovery_time, bw_sub(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[i][j])))), data->latency_hiding_lines[k]), data->lines_interleaved_in_mem_access[k]));
+                                               }
+                                       }
+                                       else {
+                                               data->blackout_duration_margin[i][j] = bw_min2(data->blackout_duration_margin[i][j], bw_sub(bw_sub(bw_sub(bw_sub(data->minimum_latency_hiding_with_cursor[k], vbios->blackout_duration), data->dmif_burst_time[i][j]), data->mcifwr_burst_time[i][j]), data->line_source_transfer_time[k][i][j]));
+                                               data->dispclk_required_for_blackout_duration[i][j] = bw_max3(data->dispclk_required_for_blackout_duration[i][j], bw_div(bw_div(bw_mul(data->src_pixels_for_first_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_sub(bw_sub(bw_sub(data->minimum_latency_hiding_with_cursor[k], vbios->blackout_duration), data->dmif_burst_time[i][j]), data->mcifwr_burst_time[i][j]))), bw_div(bw_div(bw_mul(data->src_pixels_for_last_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_add(bw_sub(bw_sub(bw_sub(data->minimum_latency_hiding_with_cursor[k], vbios->blackout_duration), data->dmif_burst_time[i][j]), data->mcifwr_burst_time[i][j]), data->active_time[k]))));
+                                               if (bw_ltn(vbios->maximum_blackout_recovery_time, bw_add(bw_add(bw_mul(bw_int_to_fixed(2), vbios->mcifwrmc_urgent_latency), data->dmif_burst_time[i][j]), data->mcifwr_burst_time[i][j]))) {
+                                                       data->dispclk_required_for_blackout_recovery[i][j] = bw_int_to_fixed(9999);
+                                               }
+                                               else if (bw_ltn(data->adjusted_data_buffer_size[k], bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), (bw_add(vbios->blackout_duration, bw_add(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[i][j])))))) {
+                                                       data->dispclk_required_for_blackout_recovery[i][j] = bw_max2(data->dispclk_required_for_blackout_recovery[i][j], bw_div(bw_mul(bw_div(bw_div((bw_sub(bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), (bw_add(vbios->blackout_duration, vbios->maximum_blackout_recovery_time))), data->adjusted_data_buffer_size[k])), bw_int_to_fixed(data->bytes_per_pixel[k])), (bw_sub(vbios->maximum_blackout_recovery_time, (bw_add(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[i][j]))))), data->latency_hiding_lines[k]), data->lines_interleaved_in_mem_access[k]));
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       if (bw_mtn(data->blackout_duration_margin[high][s_high], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[high][s_high], vbios->high_voltage_max_dispclk)) {
+               data->cpup_state_change_enable = bw_def_yes;
+               if (bw_ltn(data->dispclk_required_for_blackout_recovery[high][s_high], vbios->high_voltage_max_dispclk)) {
+                       data->cpuc_state_change_enable = bw_def_yes;
+               }
+               else {
+                       data->cpuc_state_change_enable = bw_def_no;
+               }
+       }
+       else {
+               data->cpup_state_change_enable = bw_def_no;
+               data->cpuc_state_change_enable = bw_def_no;
+       }
+       /*nb p-state change enable*/
+       /*for dram speed/p-state change to be possible for a yclk(pclk) and sclk level there has to be positive margin and the dispclk required has to be*/
+       /*below the maximum.*/
+       /*the dram speed/p-state change margin is the minimum for all surfaces of the maximum latency hiding minus the dram speed/p-state change latency,*/
+       /*minus the dmif burst time, minus the source line transfer time*/
+       /*the maximum latency hiding is the minimum latency hiding plus one source line used for de-tiling in the line buffer, plus half the urgent latency*/
+       /*if stutter and dram clock state change are gated before cursor then the cursor latency hiding does not limit stutter or dram clock state change*/
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       /*maximum_latency_hiding(i) = minimum_latency_hiding(i) + 1 / vsr(i) **/
+                       /*      h_total(i) / pixel_rate(i) + 0.5 * total_dmifmc_urgent_latency*/
+                       data->maximum_latency_hiding[i] = bw_add(data->minimum_latency_hiding[i],
+                               bw_mul(bw_frc_to_fixed(5, 10), data->total_dmifmc_urgent_latency));
+                       data->maximum_latency_hiding_with_cursor[i] = bw_min2(data->maximum_latency_hiding[i], data->cursor_latency_hiding[i]);
+               }
+       }
+       for (i = 0; i <= 2; i++) {
+               for (j = 0; j <= 7; j++) {
+                       data->min_dram_speed_change_margin[i][j] = bw_int_to_fixed(9999);
+                       data->dram_speed_change_margin = bw_int_to_fixed(9999);
+                       data->dispclk_required_for_dram_speed_change[i][j] = bw_int_to_fixed(0);
+                       data->num_displays_with_margin[i][j] = 0;
+                       for (k = 0; k <= maximum_number_of_surfaces - 1; k++) {
+                               if (data->enable[k]) {
+                                       if (surface_type[k] != bw_def_display_write_back420_luma && surface_type[k] != bw_def_display_write_back420_chroma) {
+                                               data->dram_speed_change_margin = bw_sub(bw_sub(bw_sub(data->maximum_latency_hiding_with_cursor[k], vbios->nbp_state_change_latency), data->dmif_burst_time[i][j]), data->dram_speed_change_line_source_transfer_time[k][i][j]);
+                                               if ((bw_mtn(data->dram_speed_change_margin, bw_int_to_fixed(0)) && bw_ltn(data->dram_speed_change_margin, bw_int_to_fixed(9999)))) {
+                                                       /*determine the minimum dram clock change margin for each set of clock frequencies*/
+                                                       data->min_dram_speed_change_margin[i][j] = bw_min2(data->min_dram_speed_change_margin[i][j], data->dram_speed_change_margin);
+                                                       /*compute the maximum clock frequuency required for the dram clock change at each set of clock frequencies*/
+                                                       data->dispclk_required_for_dram_speed_change_pipe[i][j] = bw_max2(bw_div(bw_div(bw_mul(data->src_pixels_for_first_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_sub(bw_sub(bw_sub(data->maximum_latency_hiding_with_cursor[k], vbios->nbp_state_change_latency), data->dmif_burst_time[i][j]), data->dram_speed_change_line_source_transfer_time[k][i][j]))), bw_div(bw_div(bw_mul(data->src_pixels_for_last_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_add(bw_sub(bw_sub(bw_sub(data->maximum_latency_hiding_with_cursor[k], vbios->nbp_state_change_latency), data->dmif_burst_time[i][j]), data->dram_speed_change_line_source_transfer_time[k][i][j]), data->active_time[k]))));
+                                                       if ((bw_ltn(data->dispclk_required_for_dram_speed_change_pipe[i][j], vbios->high_voltage_max_dispclk))) {
+                                                               data->display_pstate_change_enable[k] = 1;
+                                                               data->num_displays_with_margin[i][j] = data->num_displays_with_margin[i][j] + 1;
+                                                               data->dispclk_required_for_dram_speed_change[i][j] = bw_max2(data->dispclk_required_for_dram_speed_change[i][j], data->dispclk_required_for_dram_speed_change_pipe[i][j]);
+                                                       }
+                                               }
+                                       }
+                                       else {
+                                               data->dram_speed_change_margin = bw_sub(bw_sub(bw_sub(bw_sub(data->maximum_latency_hiding_with_cursor[k], vbios->nbp_state_change_latency), data->dmif_burst_time[i][j]), data->mcifwr_burst_time[i][j]), data->dram_speed_change_line_source_transfer_time[k][i][j]);
+                                               if ((bw_mtn(data->dram_speed_change_margin, bw_int_to_fixed(0)) && bw_ltn(data->dram_speed_change_margin, bw_int_to_fixed(9999)))) {
+                                                       /*determine the minimum dram clock change margin for each display pipe*/
+                                                       data->min_dram_speed_change_margin[i][j] = bw_min2(data->min_dram_speed_change_margin[i][j], data->dram_speed_change_margin);
+                                                       /*compute the maximum clock frequuency required for the dram clock change at each set of clock frequencies*/
+                                                       data->dispclk_required_for_dram_speed_change_pipe[i][j] = bw_max2(bw_div(bw_div(bw_mul(data->src_pixels_for_first_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_sub(bw_sub(bw_sub(bw_sub(data->maximum_latency_hiding_with_cursor[k], vbios->nbp_state_change_latency), data->dmif_burst_time[i][j]), data->dram_speed_change_line_source_transfer_time[k][i][j]), data->mcifwr_burst_time[i][j]))), bw_div(bw_div(bw_mul(data->src_pixels_for_last_output_pixel[k], dceip->display_pipe_throughput_factor), dceip->lb_write_pixels_per_dispclk), (bw_add(bw_sub(bw_sub(bw_sub(bw_sub(data->maximum_latency_hiding_with_cursor[k], vbios->nbp_state_change_latency), data->dmif_burst_time[i][j]), data->dram_speed_change_line_source_transfer_time[k][i][j]), data->mcifwr_burst_time[i][j]), data->active_time[k]))));
+                                                       if ((bw_ltn(data->dispclk_required_for_dram_speed_change_pipe[i][j], vbios->high_voltage_max_dispclk))) {
+                                                               data->display_pstate_change_enable[k] = 1;
+                                                               data->num_displays_with_margin[i][j] = data->num_displays_with_margin[i][j] + 1;
+                                                               data->dispclk_required_for_dram_speed_change[i][j] = bw_max2(data->dispclk_required_for_dram_speed_change[i][j], data->dispclk_required_for_dram_speed_change_pipe[i][j]);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       /*determine the number of displays with margin to switch in the v_active region*/
+       for (k = 0; k <= maximum_number_of_surfaces - 1; k++) {
+               if (data->enable[k] == 1 && data->display_pstate_change_enable[k] == 1) {
+                       number_of_displays_enabled_with_margin = number_of_displays_enabled_with_margin + 1;
+               }
+       }
+       /*determine the number of displays that don't have any dram clock change margin, but*/
+       /*have the same resolution.  these displays can switch in a common vblank region if*/
+       /*their frames are aligned.*/
+       data->min_vblank_dram_speed_change_margin = bw_int_to_fixed(9999);
+       for (k = 0; k <= maximum_number_of_surfaces - 1; k++) {
+               if (data->enable[k]) {
+                       if (surface_type[k] != bw_def_display_write_back420_luma && surface_type[k] != bw_def_display_write_back420_chroma) {
+                               data->v_blank_dram_speed_change_margin[k] = bw_sub(bw_sub(bw_sub(bw_div(bw_mul((bw_sub(data->v_total[k], bw_sub(bw_div(data->src_height[k], data->v_scale_ratio[k]), bw_int_to_fixed(4)))), data->h_total[k]), data->pixel_rate[k]), vbios->nbp_state_change_latency), data->dmif_burst_time[low][s_low]), data->dram_speed_change_line_source_transfer_time[k][low][s_low]);
+                               data->min_vblank_dram_speed_change_margin = bw_min2(data->min_vblank_dram_speed_change_margin, data->v_blank_dram_speed_change_margin[k]);
+                       }
+                       else {
+                               data->v_blank_dram_speed_change_margin[k] = bw_sub(bw_sub(bw_sub(bw_sub(bw_div(bw_mul((bw_sub(data->v_total[k], bw_sub(bw_div(data->src_height[k], data->v_scale_ratio[k]), bw_int_to_fixed(4)))), data->h_total[k]), data->pixel_rate[k]), vbios->nbp_state_change_latency), data->dmif_burst_time[low][s_low]), data->mcifwr_burst_time[low][s_low]), data->dram_speed_change_line_source_transfer_time[k][low][s_low]);
+                               data->min_vblank_dram_speed_change_margin = bw_min2(data->min_vblank_dram_speed_change_margin, data->v_blank_dram_speed_change_margin[k]);
+                       }
+               }
+       }
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               data->displays_with_same_mode[i] = bw_int_to_fixed(0);
+               if (data->enable[i] == 1 && data->display_pstate_change_enable[i] == 0 && bw_mtn(data->v_blank_dram_speed_change_margin[i], bw_int_to_fixed(0))) {
+                       for (j = 0; j <= maximum_number_of_surfaces - 1; j++) {
+                               if ((i == j || data->display_synchronization_enabled) && (data->enable[j] == 1 && bw_equ(data->source_width_rounded_up_to_chunks[i], data->source_width_rounded_up_to_chunks[j]) && bw_equ(data->source_height_rounded_up_to_chunks[i], data->source_height_rounded_up_to_chunks[j]) && bw_equ(data->vsr[i], data->vsr[j]) && bw_equ(data->hsr[i], data->hsr[j]) && bw_equ(data->pixel_rate[i], data->pixel_rate[j]))) {
+                                       data->displays_with_same_mode[i] = bw_add(data->displays_with_same_mode[i], bw_int_to_fixed(1));
+                               }
+                       }
+               }
+       }
+       /*compute the maximum number of aligned displays with no margin*/
+       number_of_aligned_displays_with_no_margin = 0;
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               number_of_aligned_displays_with_no_margin = bw_fixed_to_int(bw_max2(bw_int_to_fixed(number_of_aligned_displays_with_no_margin), data->displays_with_same_mode[i]));
+       }
+       /*dram clock change is possible, if all displays have positive margin except for one display or a group of*/
+       /*aligned displays with the same timing.*/
+       /*the display(s) with the negative margin can be switched in the v_blank region while the other*/
+       /*displays are in v_blank or v_active.*/
+       if (number_of_displays_enabled_with_margin > 0 && (number_of_displays_enabled_with_margin + number_of_aligned_displays_with_no_margin) == number_of_displays_enabled && bw_mtn(data->min_dram_speed_change_margin[high][s_high], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[high][s_high], bw_int_to_fixed(9999)) && bw_ltn(data->dispclk_required_for_dram_speed_change[high][s_high], vbios->high_voltage_max_dispclk)) {
+               data->nbp_state_change_enable = bw_def_yes;
+       }
+       else {
+               data->nbp_state_change_enable = bw_def_no;
+       }
+       /*dram clock change is possible only in vblank if all displays are aligned and have no margin*/
+       if (number_of_aligned_displays_with_no_margin == number_of_displays_enabled) {
+               nbp_state_change_enable_blank = bw_def_yes;
+       }
+       else {
+               nbp_state_change_enable_blank = bw_def_no;
+       }
+
+       /*average bandwidth*/
+       /*the average bandwidth with no compression is the vertical active time is the source width times the bytes per pixel divided by the line time, multiplied by the vertical scale ratio and the ratio of bytes per request divided by the useful bytes per request.*/
+       /*the average bandwidth with compression is the same, divided by the compression ratio*/
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       data->average_bandwidth_no_compression[i] = bw_div(bw_mul(bw_mul(bw_div(bw_mul(data->source_width_rounded_up_to_chunks[i], bw_int_to_fixed(data->bytes_per_pixel[i])), (bw_div(data->h_total[i], data->pixel_rate[i]))), data->vsr[i]), data->bytes_per_request[i]), data->useful_bytes_per_request[i]);
+                       data->average_bandwidth[i] = bw_div(data->average_bandwidth_no_compression[i], data->compression_rate[i]);
+               }
+       }
+       data->total_average_bandwidth_no_compression = bw_int_to_fixed(0);
+       data->total_average_bandwidth = bw_int_to_fixed(0);
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       data->total_average_bandwidth_no_compression = bw_add(data->total_average_bandwidth_no_compression, data->average_bandwidth_no_compression[i]);
+                       data->total_average_bandwidth = bw_add(data->total_average_bandwidth, data->average_bandwidth[i]);
+               }
+       }
+
+       /*required yclk(pclk)*/
+       /*yclk requirement only makes sense if the dmif and mcifwr data total page close-open time is less than the time for data transfer and the total pte requests fit in the scatter-gather saw queque size*/
+       /*if that is the case, the yclk requirement is the maximum of the ones required by dmif and mcifwr, and the high/low yclk(pclk) is chosen accordingly*/
+       /*high yclk(pclk) has to be selected when dram speed/p-state change is not possible.*/
+       data->min_cursor_memory_interface_buffer_size_in_time = bw_int_to_fixed(9999);
+       /* number of cursor lines stored in the cursor data return buffer*/
+       num_cursor_lines = 0;
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (bw_mtn(data->cursor_width_pixels[i], bw_int_to_fixed(0))) {
+                               /*compute number of cursor lines stored in data return buffer*/
+                               if (bw_leq(data->cursor_width_pixels[i], bw_int_to_fixed(64)) && dceip->large_cursor == 1) {
+                                       num_cursor_lines = 4;
+                               }
+                               else {
+                                       num_cursor_lines = 2;
+                               }
+                               data->min_cursor_memory_interface_buffer_size_in_time = bw_min2(data->min_cursor_memory_interface_buffer_size_in_time, bw_div(bw_mul(bw_div(bw_int_to_fixed(num_cursor_lines), data->vsr[i]), data->h_total[i]), data->pixel_rate[i]));
+                       }
+               }
+       }
+       /*compute minimum time to read one chunk from the dmif buffer*/
+       if (number_of_displays_enabled > 2) {
+               data->chunk_request_delay = 0;
+       }
+       else {
+               data->chunk_request_delay = bw_fixed_to_int(bw_div(bw_int_to_fixed(512), vbios->high_voltage_max_dispclk));
+       }
+       data->min_read_buffer_size_in_time = bw_min2(data->min_cursor_memory_interface_buffer_size_in_time, data->min_dmif_size_in_time);
+       data->display_reads_time_for_data_transfer = bw_sub(bw_sub(data->min_read_buffer_size_in_time, data->total_dmifmc_urgent_latency), bw_int_to_fixed(data->chunk_request_delay));
+       data->display_writes_time_for_data_transfer = bw_sub(data->min_mcifwr_size_in_time, vbios->mcifwrmc_urgent_latency);
+       data->dmif_required_dram_bandwidth = bw_div(data->total_display_reads_required_dram_access_data, data->display_reads_time_for_data_transfer);
+       data->mcifwr_required_dram_bandwidth = bw_div(data->total_display_writes_required_dram_access_data, data->display_writes_time_for_data_transfer);
+       data->required_dmifmc_urgent_latency_for_page_close_open = bw_div((bw_sub(data->min_read_buffer_size_in_time, data->dmif_total_page_close_open_time)), data->total_dmifmc_urgent_trips);
+       data->required_mcifmcwr_urgent_latency = bw_sub(data->min_mcifwr_size_in_time, data->mcifwr_total_page_close_open_time);
+       if (bw_mtn(data->scatter_gather_total_pte_requests, dceip->maximum_total_outstanding_pte_requests_allowed_by_saw)) {
+               data->required_dram_bandwidth_gbyte_per_second = bw_int_to_fixed(9999);
+               yclk_message = bw_def_exceeded_allowed_outstanding_pte_req_queue_size;
+               data->y_clk_level = high;
+               data->dram_bandwidth = bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[high]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels));
+       }
+       else if (bw_mtn(vbios->dmifmc_urgent_latency, data->required_dmifmc_urgent_latency_for_page_close_open) || bw_mtn(vbios->mcifwrmc_urgent_latency, data->required_mcifmcwr_urgent_latency)) {
+               data->required_dram_bandwidth_gbyte_per_second = bw_int_to_fixed(9999);
+               yclk_message = bw_def_exceeded_allowed_page_close_open;
+               data->y_clk_level = high;
+               data->dram_bandwidth = bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[high]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels));
+       }
+       else {
+               data->required_dram_bandwidth_gbyte_per_second = bw_div(bw_max2(data->dmif_required_dram_bandwidth, data->mcifwr_required_dram_bandwidth), bw_int_to_fixed(1000));
+               if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation, 100),yclk[low]),bw_div(bw_int_to_fixed(vbios->dram_channel_width_in_bits),bw_int_to_fixed(8))),bw_int_to_fixed(vbios->number_of_dram_channels)))
+                               && bw_ltn(bw_mul(data->required_dram_bandwidth_gbyte_per_second, bw_int_to_fixed(1000)), bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[low]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels))) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[low][s_high], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[low][s_high], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[low][s_high], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[low][s_high], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[low][s_high], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[low][s_high], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[low][s_high], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[low][s_high], vbios->high_voltage_max_dispclk) && data->num_displays_with_margin[low][s_high] == number_of_displays_enabled_with_margin))) {
+                       yclk_message = bw_fixed_to_int(vbios->low_yclk);
+                       data->y_clk_level = low;
+                       data->dram_bandwidth = bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[low]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels));
+               }
+               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation, 100),yclk[mid]),bw_div(bw_int_to_fixed(vbios->dram_channel_width_in_bits),bw_int_to_fixed(8))),bw_int_to_fixed(vbios->number_of_dram_channels)))
+                               && bw_ltn(bw_mul(data->required_dram_bandwidth_gbyte_per_second, bw_int_to_fixed(1000)), bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[mid]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels))) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[mid][s_high], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[mid][s_high], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[mid][s_high], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[mid][s_high], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[mid][s_high], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[mid][s_high], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[mid][s_high], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[mid][s_high], vbios->high_voltage_max_dispclk) && data->num_displays_with_margin[mid][s_high] == number_of_displays_enabled_with_margin))) {
+                       yclk_message = bw_fixed_to_int(vbios->mid_yclk);
+                       data->y_clk_level = mid;
+                       data->dram_bandwidth = bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[mid]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels));
+               }
+               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation, 100),yclk[high]),bw_div(bw_int_to_fixed(vbios->dram_channel_width_in_bits),bw_int_to_fixed(8))),bw_int_to_fixed(vbios->number_of_dram_channels)))
+                               && bw_ltn(bw_mul(data->required_dram_bandwidth_gbyte_per_second, bw_int_to_fixed(1000)), bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[high]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels)))) {
+                       yclk_message = bw_fixed_to_int(vbios->high_yclk);
+                       data->y_clk_level = high;
+                       data->dram_bandwidth = bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[high]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels));
+               }
+               else {
+                       yclk_message = bw_def_exceeded_allowed_maximum_bw;
+                       data->y_clk_level = high;
+                       data->dram_bandwidth = bw_mul(bw_div(bw_mul(bw_mul(data->dram_efficiency, yclk[high]), bw_int_to_fixed(vbios->dram_channel_width_in_bits)), bw_int_to_fixed(8)), bw_int_to_fixed(data->number_of_dram_channels));
+               }
+       }
+       /*required sclk*/
+       /*sclk requirement only makes sense if the total pte requests fit in the scatter-gather saw queque size*/
+       /*if that is the case, the sclk requirement is the maximum of the ones required by dmif and mcifwr, and the high/mid/low sclk is chosen accordingly, unless that choice results in foresaking dram speed/nb p-state change.*/
+       /*the dmif and mcifwr sclk required is the one that allows the transfer of all pipe's data buffer size through the sclk bus in the time for data transfer*/
+       /*for dmif, pte and cursor requests have to be included.*/
+       data->dmif_required_sclk = bw_div(bw_div(data->total_display_reads_required_data, data->display_reads_time_for_data_transfer), (bw_mul(vbios->data_return_bus_width, bw_frc_to_fixed(dceip->percent_of_ideal_port_bw_received_after_urgent_latency, 100))));
+       data->mcifwr_required_sclk = bw_div(bw_div(data->total_display_writes_required_data, data->display_writes_time_for_data_transfer), vbios->data_return_bus_width);
+       if (bw_mtn(data->scatter_gather_total_pte_requests, dceip->maximum_total_outstanding_pte_requests_allowed_by_saw)) {
+               data->required_sclk = bw_int_to_fixed(9999);
+               sclk_message = bw_def_exceeded_allowed_outstanding_pte_req_queue_size;
+               data->sclk_level = s_high;
+       }
+       else if (bw_mtn(vbios->dmifmc_urgent_latency, data->required_dmifmc_urgent_latency_for_page_close_open) || bw_mtn(vbios->mcifwrmc_urgent_latency, data->required_mcifmcwr_urgent_latency)) {
+               data->required_sclk = bw_int_to_fixed(9999);
+               sclk_message = bw_def_exceeded_allowed_page_close_open;
+               data->sclk_level = s_high;
+       }
+       else {
+               data->required_sclk = bw_max2(data->dmif_required_sclk, data->mcifwr_required_sclk);
+               if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[low]),vbios->data_return_bus_width))
+                               && bw_ltn(data->required_sclk, sclk[s_low]) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_low], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_low], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_low], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_low], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[data->y_clk_level][s_low], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[data->y_clk_level][s_low], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[data->y_clk_level][s_low], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[data->y_clk_level][s_low], vbios->low_voltage_max_dispclk) && data->num_displays_with_margin[data->y_clk_level][s_low] == number_of_displays_enabled_with_margin))) {
+                       sclk_message = bw_def_low;
+                       data->sclk_level = s_low;
+                       data->required_sclk = vbios->low_sclk;
+               }
+               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[mid]),vbios->data_return_bus_width))
+                               && bw_ltn(data->required_sclk, sclk[s_mid1]) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid1], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid1], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid1], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid1], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[data->y_clk_level][s_mid1], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid1], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid1], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[data->y_clk_level][s_mid1], vbios->mid_voltage_max_dispclk) && data->num_displays_with_margin[data->y_clk_level][s_mid1] == number_of_displays_enabled_with_margin))) {
+                       sclk_message = bw_def_mid;
+                       data->sclk_level = s_mid1;
+                       data->required_sclk = vbios->mid1_sclk;
+               }
+               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[s_mid2]),vbios->data_return_bus_width))
+                               && bw_ltn(data->required_sclk, sclk[s_mid2]) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid2], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid2], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid2], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid2], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[data->y_clk_level][s_mid2], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid2], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid2], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[data->y_clk_level][s_mid2], vbios->mid_voltage_max_dispclk) && data->num_displays_with_margin[data->y_clk_level][s_mid2] == number_of_displays_enabled_with_margin))) {
+                       sclk_message = bw_def_mid;
+                       data->sclk_level = s_mid2;
+                       data->required_sclk = vbios->mid2_sclk;
+               }
+               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[s_mid3]),vbios->data_return_bus_width))
+                               && bw_ltn(data->required_sclk, sclk[s_mid3]) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid3], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid3], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid3], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid3], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[data->y_clk_level][s_mid3], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid3], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid3], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[data->y_clk_level][s_mid3], vbios->mid_voltage_max_dispclk) && data->num_displays_with_margin[data->y_clk_level][s_mid3] == number_of_displays_enabled_with_margin))) {
+                       sclk_message = bw_def_mid;
+                       data->sclk_level = s_mid3;
+                       data->required_sclk = vbios->mid3_sclk;
+               }
+               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[s_mid4]),vbios->data_return_bus_width))
+                               && bw_ltn(data->required_sclk, sclk[s_mid4]) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid4], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid4], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid4], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid4], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[data->y_clk_level][s_mid4], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid4], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid4], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[data->y_clk_level][s_mid4], vbios->mid_voltage_max_dispclk) && data->num_displays_with_margin[data->y_clk_level][s_mid4] == number_of_displays_enabled_with_margin))) {
+                       sclk_message = bw_def_mid;
+                       data->sclk_level = s_mid4;
+                       data->required_sclk = vbios->mid4_sclk;
+               }
+               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[s_mid5]),vbios->data_return_bus_width))
+                               && bw_ltn(data->required_sclk, sclk[s_mid5]) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid5], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid5], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid5], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid5], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[data->y_clk_level][s_mid5], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid5], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid5], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[data->y_clk_level][s_mid5], vbios->mid_voltage_max_dispclk) && data->num_displays_with_margin[data->y_clk_level][s_mid5] == number_of_displays_enabled_with_margin))) {
+                       sclk_message = bw_def_mid;
+                       data->sclk_level = s_mid5;
+                       data->required_sclk = vbios->mid5_sclk;
+               }
+               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[s_mid6]),vbios->data_return_bus_width))
+                               && bw_ltn(data->required_sclk, sclk[s_mid6]) && (data->cpup_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid6], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid6], vbios->high_voltage_max_dispclk))) && (data->cpuc_state_change_enable == bw_def_no || (bw_mtn(data->blackout_duration_margin[data->y_clk_level][s_mid6], bw_int_to_fixed(0)) && bw_ltn(data->dispclk_required_for_blackout_duration[data->y_clk_level][s_mid6], vbios->high_voltage_max_dispclk) && bw_ltn(data->dispclk_required_for_blackout_recovery[data->y_clk_level][s_mid6], vbios->high_voltage_max_dispclk))) && (!data->increase_voltage_to_support_mclk_switch || data->nbp_state_change_enable == bw_def_no || (bw_mtn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid6], bw_int_to_fixed(0)) && bw_ltn(data->min_dram_speed_change_margin[data->y_clk_level][s_mid6], bw_int_to_fixed(9999)) && bw_leq(data->dispclk_required_for_dram_speed_change[data->y_clk_level][s_mid6], vbios->high_voltage_max_dispclk) && data->num_displays_with_margin[data->y_clk_level][s_mid6] == number_of_displays_enabled_with_margin))) {
+                       sclk_message = bw_def_mid;
+                       data->sclk_level = s_mid6;
+                       data->required_sclk = vbios->mid6_sclk;
+               }
+               else if (bw_ltn(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[s_high]),vbios->data_return_bus_width))
+                               && bw_ltn(data->required_sclk, sclk[s_high])) {
+                       sclk_message = bw_def_high;
+                       data->sclk_level = s_high;
+                       data->required_sclk = vbios->high_sclk;
+               }
+               else if (bw_meq(data->total_average_bandwidth_no_compression, bw_mul(bw_mul(bw_frc_to_fixed(dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation, 100),sclk[s_high]),vbios->data_return_bus_width))
+                               && bw_ltn(data->required_sclk, sclk[s_high])) {
+                       sclk_message = bw_def_high;
+                       data->sclk_level = s_high;
+                       data->required_sclk = vbios->high_sclk;
+               }
+               else {
+                       sclk_message = bw_def_exceeded_allowed_maximum_sclk;
+                       data->sclk_level = s_high;
+                       /*required_sclk = high_sclk*/
+               }
+       }
+       /*dispclk*/
+       /*if dispclk is set to the maximum, ramping is not required.  dispclk required without ramping is less than the dispclk required with ramping.*/
+       /*if dispclk required without ramping is more than the maximum dispclk, that is the dispclk required, and the mode is not supported*/
+       /*if that does not happen, but dispclk required with ramping is more than the maximum dispclk, dispclk required is just the maximum dispclk*/
+       /*if that does not happen either, dispclk required is the dispclk required with ramping.*/
+       /*dispclk required without ramping is the maximum of the one required for display pipe pixel throughput, for scaler throughput, for total read request thrrougput and for dram/np p-state change if enabled.*/
+       /*the display pipe pixel throughput is the maximum of lines in per line out in the beginning of the frame and lines in per line out in the middle of the frame multiplied by the horizontal blank and chunk granularity factor, altogether multiplied by the ratio of the source width to the line time, divided by the line buffer pixels per dispclk throughput, and multiplied by the display pipe throughput factor.*/
+       /*the horizontal blank and chunk granularity factor is the ratio of the line time divided by the line time minus half the horizontal blank and chunk time.  it applies when the lines in per line out is not 2 or 4.*/
+       /*the dispclk required for scaler throughput is the product of the pixel rate and the scaling limits factor.*/
+       /*the dispclk required for total read request throughput is the product of the peak request-per-second bandwidth and the dispclk cycles per request, divided by the request efficiency.*/
+       /*for the dispclk required with ramping, instead of multiplying just the pipe throughput by the display pipe throughput factor, we multiply the scaler and pipe throughput by the ramping factor.*/
+       /*the scaling limits factor is the product of the horizontal scale ratio, and the ratio of the vertical taps divided by the scaler efficiency clamped to at least 1.*/
+       /*the scaling limits factor itself it also clamped to at least 1*/
+       /*if doing downscaling with the pre-downscaler enabled, the horizontal scale ratio should not be considered above (use "1")*/
+       data->downspread_factor = bw_add(bw_int_to_fixed(1), bw_div(vbios->down_spread_percentage, bw_int_to_fixed(100)));
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (surface_type[i] == bw_def_graphics) {
+                               switch (data->lb_bpc[i]) {
+                               case 6:
+                                       data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency6_bit_per_component;
+                                       break;
+                               case 8:
+                                       data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency8_bit_per_component;
+                                       break;
+                               case 10:
+                                       data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency10_bit_per_component;
+                                       break;
+                               default:
+                                       data->v_scaler_efficiency = dceip->graphics_vscaler_efficiency12_bit_per_component;
+                                       break;
+                               }
+                               if (data->use_alpha[i] == 1) {
+                                       data->v_scaler_efficiency = bw_min2(data->v_scaler_efficiency, dceip->alpha_vscaler_efficiency);
+                               }
+                       }
+                       else {
+                               switch (data->lb_bpc[i]) {
+                               case 6:
+                                       data->v_scaler_efficiency = dceip->underlay_vscaler_efficiency6_bit_per_component;
+                                       break;
+                               case 8:
+                                       data->v_scaler_efficiency = dceip->underlay_vscaler_efficiency8_bit_per_component;
+                                       break;
+                               case 10:
+                                       data->v_scaler_efficiency = dceip->underlay_vscaler_efficiency10_bit_per_component;
+                                       break;
+                               default:
+                                       data->v_scaler_efficiency = dceip->underlay_vscaler_efficiency12_bit_per_component;
+                                       break;
+                               }
+                       }
+                       if (dceip->pre_downscaler_enabled && bw_mtn(data->hsr[i], bw_int_to_fixed(1))) {
+                               data->scaler_limits_factor = bw_max2(bw_div(data->v_taps[i], data->v_scaler_efficiency), bw_div(data->source_width_rounded_up_to_chunks[i], data->h_total[i]));
+                       }
+                       else {
+                               data->scaler_limits_factor = bw_max3(bw_int_to_fixed(1), bw_ceil2(bw_div(data->h_taps[i], bw_int_to_fixed(4)), bw_int_to_fixed(1)), bw_mul(data->hsr[i], bw_max2(bw_div(data->v_taps[i], data->v_scaler_efficiency), bw_int_to_fixed(1))));
+                       }
+                       data->display_pipe_pixel_throughput = bw_div(bw_div(bw_mul(bw_max2(data->lb_lines_in_per_line_out_in_beginning_of_frame[i], bw_mul(data->lb_lines_in_per_line_out_in_middle_of_frame[i], data->horizontal_blank_and_chunk_granularity_factor[i])), data->source_width_rounded_up_to_chunks[i]), (bw_div(data->h_total[i], data->pixel_rate[i]))), dceip->lb_write_pixels_per_dispclk);
+                       data->dispclk_required_without_ramping[i] = bw_mul(data->downspread_factor, bw_max2(bw_mul(data->pixel_rate[i], data->scaler_limits_factor), bw_mul(dceip->display_pipe_throughput_factor, data->display_pipe_pixel_throughput)));
+                       data->dispclk_required_with_ramping[i] = bw_mul(dceip->dispclk_ramping_factor, bw_max2(bw_mul(data->pixel_rate[i], data->scaler_limits_factor), data->display_pipe_pixel_throughput));
+               }
+       }
+       data->total_dispclk_required_with_ramping = bw_int_to_fixed(0);
+       data->total_dispclk_required_without_ramping = bw_int_to_fixed(0);
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (bw_ltn(data->total_dispclk_required_with_ramping, data->dispclk_required_with_ramping[i])) {
+                               data->total_dispclk_required_with_ramping = data->dispclk_required_with_ramping[i];
+                       }
+                       if (bw_ltn(data->total_dispclk_required_without_ramping, data->dispclk_required_without_ramping[i])) {
+                               data->total_dispclk_required_without_ramping = data->dispclk_required_without_ramping[i];
+                       }
+               }
+       }
+       data->total_read_request_bandwidth = bw_int_to_fixed(0);
+       data->total_write_request_bandwidth = bw_int_to_fixed(0);
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
+                               data->total_read_request_bandwidth = bw_add(data->total_read_request_bandwidth, data->request_bandwidth[i]);
+                       }
+                       else {
+                               data->total_write_request_bandwidth = bw_add(data->total_write_request_bandwidth, data->request_bandwidth[i]);
+                       }
+               }
+       }
+       data->dispclk_required_for_total_read_request_bandwidth = bw_div(bw_mul(data->total_read_request_bandwidth, dceip->dispclk_per_request), dceip->request_efficiency);
+       data->total_dispclk_required_with_ramping_with_request_bandwidth = bw_max2(data->total_dispclk_required_with_ramping, data->dispclk_required_for_total_read_request_bandwidth);
+       data->total_dispclk_required_without_ramping_with_request_bandwidth = bw_max2(data->total_dispclk_required_without_ramping, data->dispclk_required_for_total_read_request_bandwidth);
+       if (data->cpuc_state_change_enable == bw_def_yes) {
+               data->total_dispclk_required_with_ramping_with_request_bandwidth = bw_max3(data->total_dispclk_required_with_ramping_with_request_bandwidth, data->dispclk_required_for_blackout_duration[data->y_clk_level][data->sclk_level], data->dispclk_required_for_blackout_recovery[data->y_clk_level][data->sclk_level]);
+               data->total_dispclk_required_without_ramping_with_request_bandwidth = bw_max3(data->total_dispclk_required_without_ramping_with_request_bandwidth, data->dispclk_required_for_blackout_duration[data->y_clk_level][data->sclk_level], data->dispclk_required_for_blackout_recovery[data->y_clk_level][data->sclk_level]);
+       }
+       if (data->cpup_state_change_enable == bw_def_yes) {
+               data->total_dispclk_required_with_ramping_with_request_bandwidth = bw_max2(data->total_dispclk_required_with_ramping_with_request_bandwidth, data->dispclk_required_for_blackout_duration[data->y_clk_level][data->sclk_level]);
+               data->total_dispclk_required_without_ramping_with_request_bandwidth = bw_max2(data->total_dispclk_required_without_ramping_with_request_bandwidth, data->dispclk_required_for_blackout_duration[data->y_clk_level][data->sclk_level]);
+       }
+       if (data->nbp_state_change_enable == bw_def_yes && data->increase_voltage_to_support_mclk_switch) {
+               data->total_dispclk_required_with_ramping_with_request_bandwidth = bw_max2(data->total_dispclk_required_with_ramping_with_request_bandwidth, data->dispclk_required_for_dram_speed_change[data->y_clk_level][data->sclk_level]);
+               data->total_dispclk_required_without_ramping_with_request_bandwidth = bw_max2(data->total_dispclk_required_without_ramping_with_request_bandwidth, data->dispclk_required_for_dram_speed_change[data->y_clk_level][data->sclk_level]);
+       }
+       if (bw_ltn(data->total_dispclk_required_with_ramping_with_request_bandwidth, vbios->high_voltage_max_dispclk)) {
+               data->dispclk = data->total_dispclk_required_with_ramping_with_request_bandwidth;
+       }
+       else if (bw_ltn(data->total_dispclk_required_without_ramping_with_request_bandwidth, vbios->high_voltage_max_dispclk)) {
+               data->dispclk = vbios->high_voltage_max_dispclk;
+       }
+       else {
+               data->dispclk = data->total_dispclk_required_without_ramping_with_request_bandwidth;
+       }
+       /* required core voltage*/
+       /* the core voltage required is low if sclk, yclk(pclk)and dispclk are within the low limits*/
+       /* otherwise, the core voltage required is medium if yclk (pclk) is within the low limit and sclk and dispclk are within the medium limit*/
+       /* otherwise, the core voltage required is high if the three clocks are within the high limits*/
+       /* otherwise, or if the mode is not supported, core voltage requirement is not applicable*/
+       if (pipe_check == bw_def_notok) {
+               voltage = bw_def_na;
+       }
+       else if (mode_check == bw_def_notok) {
+               voltage = bw_def_notok;
+       }
+       else if (bw_equ(bw_int_to_fixed(yclk_message), vbios->low_yclk) && sclk_message == bw_def_low && bw_ltn(data->dispclk, vbios->low_voltage_max_dispclk)) {
+               voltage = bw_def_0_72;
+       }
+       else if ((bw_equ(bw_int_to_fixed(yclk_message), vbios->low_yclk) || bw_equ(bw_int_to_fixed(yclk_message), vbios->mid_yclk)) && (sclk_message == bw_def_low || sclk_message == bw_def_mid) && bw_ltn(data->dispclk, vbios->mid_voltage_max_dispclk)) {
+               voltage = bw_def_0_8;
+       }
+       else if ((bw_equ(bw_int_to_fixed(yclk_message), vbios->low_yclk) || bw_equ(bw_int_to_fixed(yclk_message), vbios->mid_yclk) || bw_equ(bw_int_to_fixed(yclk_message), vbios->high_yclk)) && (sclk_message == bw_def_low || sclk_message == bw_def_mid || sclk_message == bw_def_high) && bw_leq(data->dispclk, vbios->high_voltage_max_dispclk)) {
+               if ((data->nbp_state_change_enable == bw_def_no && nbp_state_change_enable_blank == bw_def_no)) {
+                       voltage = bw_def_high_no_nbp_state_change;
+               }
+               else {
+                       voltage = bw_def_0_9;
+               }
+       }
+       else {
+               voltage = bw_def_notok;
+       }
+       if (voltage == bw_def_0_72) {
+               data->max_phyclk = vbios->low_voltage_max_phyclk;
+       }
+       else if (voltage == bw_def_0_8) {
+               data->max_phyclk = vbios->mid_voltage_max_phyclk;
+       }
+       else {
+               data->max_phyclk = vbios->high_voltage_max_phyclk;
+       }
+       /*required blackout recovery time*/
+       data->blackout_recovery_time = bw_int_to_fixed(0);
+       for (k = 0; k <= maximum_number_of_surfaces - 1; k++) {
+               if (data->enable[k] && bw_mtn(vbios->blackout_duration, bw_int_to_fixed(0)) && data->cpup_state_change_enable == bw_def_yes) {
+                       if (surface_type[k] != bw_def_display_write_back420_luma && surface_type[k] != bw_def_display_write_back420_chroma) {
+                               data->blackout_recovery_time = bw_max2(data->blackout_recovery_time, bw_add(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[data->y_clk_level][data->sclk_level]));
+                               if (bw_ltn(data->adjusted_data_buffer_size[k], bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), (bw_add(vbios->blackout_duration, bw_add(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[data->y_clk_level][data->sclk_level])))))) {
+                                       data->blackout_recovery_time = bw_max2(data->blackout_recovery_time, bw_div((bw_add(bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), vbios->blackout_duration), bw_sub(bw_div(bw_mul(bw_mul(bw_mul((bw_add(bw_mul(bw_int_to_fixed(2), data->total_dmifmc_urgent_latency), data->dmif_burst_time[data->y_clk_level][data->sclk_level])), data->dispclk), bw_int_to_fixed(data->bytes_per_pixel[k])), data->lines_interleaved_in_mem_access[k]), data->latency_hiding_lines[k]), data->adjusted_data_buffer_size[k]))), (bw_sub(bw_div(bw_mul(bw_mul(data->dispclk, bw_int_to_fixed(data->bytes_per_pixel[k])), data->lines_interleaved_in_mem_access[k]), data->latency_hiding_lines[k]), bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k])))));
+                               }
+                       }
+                       else {
+                               data->blackout_recovery_time = bw_max2(data->blackout_recovery_time, bw_add(bw_mul(bw_int_to_fixed(2), vbios->mcifwrmc_urgent_latency), data->mcifwr_burst_time[data->y_clk_level][data->sclk_level]));
+                               if (bw_ltn(data->adjusted_data_buffer_size[k], bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), (bw_add(vbios->blackout_duration, bw_add(bw_mul(bw_int_to_fixed(2), vbios->mcifwrmc_urgent_latency), data->mcifwr_burst_time[data->y_clk_level][data->sclk_level])))))) {
+                                       data->blackout_recovery_time = bw_max2(data->blackout_recovery_time, bw_div((bw_add(bw_mul(bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k]), vbios->blackout_duration), bw_sub(bw_div(bw_mul(bw_mul(bw_mul((bw_add(bw_add(bw_mul(bw_int_to_fixed(2), vbios->mcifwrmc_urgent_latency), data->dmif_burst_time[data->y_clk_level][data->sclk_level]), data->mcifwr_burst_time[data->y_clk_level][data->sclk_level])), data->dispclk), bw_int_to_fixed(data->bytes_per_pixel[k])), data->lines_interleaved_in_mem_access[k]), data->latency_hiding_lines[k]), data->adjusted_data_buffer_size[k]))), (bw_sub(bw_div(bw_mul(bw_mul(data->dispclk, bw_int_to_fixed(data->bytes_per_pixel[k])), data->lines_interleaved_in_mem_access[k]), data->latency_hiding_lines[k]), bw_div(bw_mul(data->display_bandwidth[k], data->useful_bytes_per_request[k]), data->bytes_per_request[k])))));
+                               }
+                       }
+               }
+       }
+       /*sclk deep sleep*/
+       /*during self-refresh, sclk can be reduced to dispclk divided by the minimum pixels in the data fifo entry, with 15% margin, but shoudl not be set to less than the request bandwidth.*/
+       /*the data fifo entry is 16 pixels for the writeback, 64 bytes/bytes_per_pixel for the graphics, 16 pixels for the parallel rotation underlay,*/
+       /*and 16 bytes/bytes_per_pixel for the orthogonal rotation underlay.*/
+       /*in parallel mode (underlay pipe), the data read from the dmifv buffer is variable and based on the pixel depth (8bbp - 16 bytes, 16 bpp - 32 bytes, 32 bpp - 64 bytes)*/
+       /*in orthogonal mode (underlay pipe), the data read from the dmifv buffer is fixed at 16 bytes.*/
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (surface_type[i] == bw_def_display_write_back420_luma || surface_type[i] == bw_def_display_write_back420_chroma) {
+                               data->pixels_per_data_fifo_entry[i] = bw_int_to_fixed(16);
+                       }
+                       else if (surface_type[i] == bw_def_graphics) {
+                               data->pixels_per_data_fifo_entry[i] = bw_div(bw_int_to_fixed(64), bw_int_to_fixed(data->bytes_per_pixel[i]));
+                       }
+                       else if (data->orthogonal_rotation[i] == 0) {
+                               data->pixels_per_data_fifo_entry[i] = bw_int_to_fixed(16);
+                       }
+                       else {
+                               data->pixels_per_data_fifo_entry[i] = bw_div(bw_int_to_fixed(16), bw_int_to_fixed(data->bytes_per_pixel[i]));
+                       }
+               }
+       }
+       data->min_pixels_per_data_fifo_entry = bw_int_to_fixed(9999);
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (bw_mtn(data->min_pixels_per_data_fifo_entry, data->pixels_per_data_fifo_entry[i])) {
+                               data->min_pixels_per_data_fifo_entry = data->pixels_per_data_fifo_entry[i];
+                       }
+               }
+       }
+       data->sclk_deep_sleep = bw_max2(bw_div(bw_mul(data->dispclk, bw_frc_to_fixed(115, 100)), data->min_pixels_per_data_fifo_entry), data->total_read_request_bandwidth);
+       /*urgent, stutter and nb-p_state watermark*/
+       /*the urgent watermark is the maximum of the urgent trip time plus the pixel transfer time, the urgent trip times to get data for the first pixel, and the urgent trip times to get data for the last pixel.*/
+       /*the stutter exit watermark is the self refresh exit time plus the maximum of the data burst time plus the pixel transfer time, the data burst times to get data for the first pixel, and the data burst times to get data for the last pixel.  it does not apply to the writeback.*/
+       /*the nb p-state change watermark is the dram speed/p-state change time plus the maximum of the data burst time plus the pixel transfer time, the data burst times to get data for the first pixel, and the data burst times to get data for the last pixel.*/
+       /*the pixel transfer time is the maximum of the time to transfer the source pixels required for the first output pixel, and the time to transfer the pixels for the last output pixel minus the active line time.*/
+       /*blackout_duration is added to the urgent watermark*/
+       data->chunk_request_time = bw_int_to_fixed(0);
+       data->cursor_request_time = bw_int_to_fixed(0);
+       /*compute total time to request one chunk from each active display pipe*/
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       data->chunk_request_time = bw_add(data->chunk_request_time, (bw_div((bw_div(bw_int_to_fixed(pixels_per_chunk * data->bytes_per_pixel[i]), data->useful_bytes_per_request[i])), bw_min2(sclk[data->sclk_level], bw_div(data->dispclk, bw_int_to_fixed(2))))));
+               }
+       }
+       /*compute total time to request cursor data*/
+       data->cursor_request_time = (bw_div(data->cursor_total_data, (bw_mul(bw_int_to_fixed(32), sclk[data->sclk_level]))));
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       data->line_source_pixels_transfer_time = bw_max2(bw_div(bw_div(data->src_pixels_for_first_output_pixel[i], dceip->lb_write_pixels_per_dispclk), (bw_div(data->dispclk, dceip->display_pipe_throughput_factor))), bw_sub(bw_div(bw_div(data->src_pixels_for_last_output_pixel[i], dceip->lb_write_pixels_per_dispclk), (bw_div(data->dispclk, dceip->display_pipe_throughput_factor))), data->active_time[i]));
+                       if (surface_type[i] != bw_def_display_write_back420_luma && surface_type[i] != bw_def_display_write_back420_chroma) {
+                               data->urgent_watermark[i] = bw_add(bw_add(bw_add(bw_add(bw_add(data->total_dmifmc_urgent_latency, data->dmif_burst_time[data->y_clk_level][data->sclk_level]), bw_max2(data->line_source_pixels_transfer_time, data->line_source_transfer_time[i][data->y_clk_level][data->sclk_level])), vbios->blackout_duration), data->chunk_request_time), data->cursor_request_time);
+                               data->stutter_exit_watermark[i] = bw_add(bw_sub(vbios->stutter_self_refresh_exit_latency, data->total_dmifmc_urgent_latency), data->urgent_watermark[i]);
+                               data->stutter_entry_watermark[i] = bw_add(bw_sub(bw_add(vbios->stutter_self_refresh_exit_latency, vbios->stutter_self_refresh_entry_latency), data->total_dmifmc_urgent_latency), data->urgent_watermark[i]);
+                               /*unconditionally remove black out time from the nb p_state watermark*/
+                               if (data->display_pstate_change_enable[i] == 1) {
+                                       data->nbp_state_change_watermark[i] = bw_add(bw_add(vbios->nbp_state_change_latency, data->dmif_burst_time[data->y_clk_level][data->sclk_level]), bw_max2(data->line_source_pixels_transfer_time, data->dram_speed_change_line_source_transfer_time[i][data->y_clk_level][data->sclk_level]));
+                               }
+                               else {
+                                       /*maximize the watermark to force the switch in the vb_lank region of the frame*/
+                                       data->nbp_state_change_watermark[i] = bw_int_to_fixed(131000);
+                               }
+                       }
+                       else {
+                               data->urgent_watermark[i] = bw_add(bw_add(bw_add(bw_add(bw_add(vbios->mcifwrmc_urgent_latency, data->mcifwr_burst_time[data->y_clk_level][data->sclk_level]), bw_max2(data->line_source_pixels_transfer_time, data->line_source_transfer_time[i][data->y_clk_level][data->sclk_level])), vbios->blackout_duration), data->chunk_request_time), data->cursor_request_time);
+                               data->stutter_exit_watermark[i] = bw_int_to_fixed(0);
+                               data->stutter_entry_watermark[i] = bw_int_to_fixed(0);
+                               if (data->display_pstate_change_enable[i] == 1) {
+                                       data->nbp_state_change_watermark[i] = bw_add(bw_add(vbios->nbp_state_change_latency, data->mcifwr_burst_time[data->y_clk_level][data->sclk_level]), bw_max2(data->line_source_pixels_transfer_time, data->dram_speed_change_line_source_transfer_time[i][data->y_clk_level][data->sclk_level]));
+                               }
+                               else {
+                                       /*maximize the watermark to force the switch in the vb_lank region of the frame*/
+                                       data->nbp_state_change_watermark[i] = bw_int_to_fixed(131000);
+                               }
+                       }
+               }
+       }
+       /*stutter mode enable*/
+       /*in the multi-display case the stutter exit or entry watermark cannot exceed the minimum latency hiding capabilities of the*/
+       /*display pipe.*/
+       data->stutter_mode_enable = data->cpuc_state_change_enable;
+       if (data->number_of_displays > 1) {
+               for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+                       if (data->enable[i]) {
+                               if ((bw_mtn(data->stutter_exit_watermark[i], data->minimum_latency_hiding[i]) || bw_mtn(data->stutter_entry_watermark[i], data->minimum_latency_hiding[i]))) {
+                                       data->stutter_mode_enable = bw_def_no;
+                               }
+                       }
+               }
+       }
+       /*performance metrics*/
+       /* display read access efficiency (%)*/
+       /* display write back access efficiency (%)*/
+       /* stutter efficiency (%)*/
+       /* extra underlay pitch recommended for efficiency (pixels)*/
+       /* immediate flip time (us)*/
+       /* latency for other clients due to urgent display read (us)*/
+       /* latency for other clients due to urgent display write (us)*/
+       /* average bandwidth consumed by display (no compression) (gb/s)*/
+       /* required dram  bandwidth (gb/s)*/
+       /* required sclk (m_hz)*/
+       /* required rd urgent latency (us)*/
+       /* nb p-state change margin (us)*/
+       /*dmif and mcifwr dram access efficiency*/
+       /*is the ratio between the ideal dram access time (which is the data buffer size in memory divided by the dram bandwidth), and the actual time which is the total page close-open time.  but it cannot exceed the dram efficiency provided by the memory subsystem*/
+       data->dmifdram_access_efficiency = bw_min2(bw_div(bw_div(data->total_display_reads_required_dram_access_data, data->dram_bandwidth), data->dmif_total_page_close_open_time), bw_int_to_fixed(1));
+       if (bw_mtn(data->total_display_writes_required_dram_access_data, bw_int_to_fixed(0))) {
+               data->mcifwrdram_access_efficiency = bw_min2(bw_div(bw_div(data->total_display_writes_required_dram_access_data, data->dram_bandwidth), data->mcifwr_total_page_close_open_time), bw_int_to_fixed(1));
+       }
+       else {
+               data->mcifwrdram_access_efficiency = bw_int_to_fixed(0);
+       }
+       /*stutter efficiency*/
+       /*the stutter efficiency is the frame-average time in self-refresh divided by the frame-average stutter cycle duration.  only applies if the display write-back is not enabled.*/
+       /*the frame-average stutter cycle used is the minimum for all pipes of the frame-average data buffer size in time, times the compression rate*/
+       /*the frame-average time in self-refresh is the stutter cycle minus the self refresh exit latency and the burst time*/
+       /*the stutter cycle is the dmif buffer size reduced by the excess of the stutter exit watermark over the lb size in time.*/
+       /*the burst time is the data needed during the stutter cycle divided by the available bandwidth*/
+       /*compute the time read all the data from the dmif buffer to the lb (dram refresh period)*/
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       data->stutter_refresh_duration[i] = bw_sub(bw_mul(bw_div(bw_div(bw_mul(bw_div(bw_div(data->adjusted_data_buffer_size[i], bw_int_to_fixed(data->bytes_per_pixel[i])), data->source_width_rounded_up_to_chunks[i]), data->h_total[i]), data->vsr[i]), data->pixel_rate[i]), data->compression_rate[i]), bw_max2(bw_int_to_fixed(0), bw_sub(data->stutter_exit_watermark[i], bw_div(bw_mul((bw_sub(data->lb_partitions[i], bw_int_to_fixed(1))), data->h_total[i]), data->pixel_rate[i]))));
+                       data->stutter_dmif_buffer_size[i] = bw_div(bw_mul(bw_mul(bw_div(bw_mul(bw_mul(data->stutter_refresh_duration[i], bw_int_to_fixed(data->bytes_per_pixel[i])), data->source_width_rounded_up_to_chunks[i]), data->h_total[i]), data->vsr[i]), data->pixel_rate[i]), data->compression_rate[i]);
+               }
+       }
+       data->min_stutter_refresh_duration = bw_int_to_fixed(9999);
+       data->total_stutter_dmif_buffer_size = 0;
+       data->total_bytes_requested = 0;
+       data->min_stutter_dmif_buffer_size = 9999;
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       if (bw_mtn(data->min_stutter_refresh_duration, data->stutter_refresh_duration[i])) {
+                               data->min_stutter_refresh_duration = data->stutter_refresh_duration[i];
+                               data->total_bytes_requested = bw_fixed_to_int(bw_add(bw_int_to_fixed(data->total_bytes_requested), (bw_mul(bw_mul(data->source_height_rounded_up_to_chunks[i], data->source_width_rounded_up_to_chunks[i]), bw_int_to_fixed(data->bytes_per_pixel[i])))));
+                               data->min_stutter_dmif_buffer_size = bw_fixed_to_int(data->stutter_dmif_buffer_size[i]);
+                       }
+                       data->total_stutter_dmif_buffer_size = bw_fixed_to_int(bw_add(data->stutter_dmif_buffer_size[i], bw_int_to_fixed(data->total_stutter_dmif_buffer_size)));
+               }
+       }
+       data->stutter_burst_time = bw_div(bw_int_to_fixed(data->total_stutter_dmif_buffer_size), bw_mul(sclk[data->sclk_level], vbios->data_return_bus_width));
+       data->num_stutter_bursts = data->total_bytes_requested / data->min_stutter_dmif_buffer_size;
+       data->total_stutter_cycle_duration = bw_add(bw_add(data->min_stutter_refresh_duration, vbios->stutter_self_refresh_exit_latency), data->stutter_burst_time);
+       data->time_in_self_refresh = data->min_stutter_refresh_duration;
+       if (data->d1_display_write_back_dwb_enable == 1) {
+               data->stutter_efficiency = bw_int_to_fixed(0);
+       }
+       else if (bw_ltn(data->time_in_self_refresh, bw_int_to_fixed(0))) {
+               data->stutter_efficiency = bw_int_to_fixed(0);
+       }
+       else {
+               /*compute stutter efficiency assuming 60 hz refresh rate*/
+               data->stutter_efficiency = bw_max2(bw_int_to_fixed(0), bw_mul((bw_sub(bw_int_to_fixed(1), (bw_div(bw_mul((bw_add(vbios->stutter_self_refresh_exit_latency, data->stutter_burst_time)), bw_int_to_fixed(data->num_stutter_bursts)), bw_frc_to_fixed(166666667, 10000))))), bw_int_to_fixed(100)));
+       }
+       /*immediate flip time*/
+       /*if scatter gather is enabled, the immediate flip takes a number of urgent memory trips equivalent to the pte requests in a row divided by the pte request limit.*/
+       /*otherwise, it may take just one urgenr memory trip*/
+       data->worst_number_of_trips_to_memory = bw_int_to_fixed(1);
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i] && data->scatter_gather_enable_for_pipe[i] == 1) {
+                       data->number_of_trips_to_memory_for_getting_apte_row[i] = bw_ceil2(bw_div(data->scatter_gather_pte_requests_in_row[i], data->scatter_gather_pte_request_limit[i]), bw_int_to_fixed(1));
+                       if (bw_ltn(data->worst_number_of_trips_to_memory, data->number_of_trips_to_memory_for_getting_apte_row[i])) {
+                               data->worst_number_of_trips_to_memory = data->number_of_trips_to_memory_for_getting_apte_row[i];
+                       }
+               }
+       }
+       data->immediate_flip_time = bw_mul(data->worst_number_of_trips_to_memory, data->total_dmifmc_urgent_latency);
+       /*worst latency for other clients*/
+       /*it is the urgent latency plus the urgent burst time*/
+       data->latency_for_non_dmif_clients = bw_add(data->total_dmifmc_urgent_latency, data->dmif_burst_time[data->y_clk_level][data->sclk_level]);
+       if (data->d1_display_write_back_dwb_enable == 1) {
+               data->latency_for_non_mcifwr_clients = bw_add(vbios->mcifwrmc_urgent_latency, dceip->mcifwr_all_surfaces_burst_time);
+       }
+       else {
+               data->latency_for_non_mcifwr_clients = bw_int_to_fixed(0);
+       }
+       /*dmif mc urgent latency supported in high sclk and yclk*/
+       data->dmifmc_urgent_latency_supported_in_high_sclk_and_yclk = bw_div((bw_sub(data->min_read_buffer_size_in_time, data->dmif_burst_time[high][s_high])), data->total_dmifmc_urgent_trips);
+       /*dram speed/p-state change margin*/
+       /*in the multi-display case the nb p-state change watermark cannot exceed the average lb size plus the dmif size or the cursor dcp buffer size*/
+       data->v_blank_nbp_state_dram_speed_change_latency_supported = bw_int_to_fixed(99999);
+       data->nbp_state_dram_speed_change_latency_supported = bw_int_to_fixed(99999);
+       for (i = 0; i <= maximum_number_of_surfaces - 1; i++) {
+               if (data->enable[i]) {
+                       data->nbp_state_dram_speed_change_latency_supported = bw_min2(data->nbp_state_dram_speed_change_latency_supported, bw_add(bw_sub(data->maximum_latency_hiding_with_cursor[i], data->nbp_state_change_watermark[i]), vbios->nbp_state_change_latency));
+                       data->v_blank_nbp_state_dram_speed_change_latency_supported = bw_min2(data->v_blank_nbp_state_dram_speed_change_latency_supported, bw_add(bw_sub(bw_div(bw_mul((bw_sub(data->v_total[i], bw_sub(bw_div(data->src_height[i], data->v_scale_ratio[i]), bw_int_to_fixed(4)))), data->h_total[i]), data->pixel_rate[i]), data->nbp_state_change_watermark[i]), vbios->nbp_state_change_latency));
+               }
+       }
+       /*sclk required vs urgent latency*/
+       for (i = 1; i <= 5; i++) {
+               data->display_reads_time_for_data_transfer_and_urgent_latency = bw_sub(data->min_read_buffer_size_in_time, bw_mul(data->total_dmifmc_urgent_trips, bw_int_to_fixed(i)));
+               if (pipe_check == bw_def_ok && (bw_mtn(data->display_reads_time_for_data_transfer_and_urgent_latency, data->dmif_total_page_close_open_time))) {
+                       data->dmif_required_sclk_for_urgent_latency[i] = bw_div(bw_div(data->total_display_reads_required_data, data->display_reads_time_for_data_transfer_and_urgent_latency), (bw_mul(vbios->data_return_bus_width, bw_frc_to_fixed(dceip->percent_of_ideal_port_bw_received_after_urgent_latency, 100))));
+               }
+               else {
+                       data->dmif_required_sclk_for_urgent_latency[i] = bw_int_to_fixed(bw_def_na);
+               }
+       }
+       /*output link bit per pixel supported*/
+       for (k = 0; k <= maximum_number_of_surfaces - 1; k++) {
+               data->output_bpphdmi[k] = bw_def_na;
+               data->output_bppdp4_lane_hbr[k] = bw_def_na;
+               data->output_bppdp4_lane_hbr2[k] = bw_def_na;
+               data->output_bppdp4_lane_hbr3[k] = bw_def_na;
+               if (data->enable[k]) {
+                       data->output_bpphdmi[k] = bw_fixed_to_int(bw_mul(bw_div(bw_min2(bw_int_to_fixed(600), data->max_phyclk), data->pixel_rate[k]), bw_int_to_fixed(24)));
+                       if (bw_meq(data->max_phyclk, bw_int_to_fixed(270))) {
+                               data->output_bppdp4_lane_hbr[k] = bw_fixed_to_int(bw_mul(bw_div(bw_mul(bw_int_to_fixed(270), bw_int_to_fixed(4)), data->pixel_rate[k]), bw_int_to_fixed(8)));
+                       }
+                       if (bw_meq(data->max_phyclk, bw_int_to_fixed(540))) {
+                               data->output_bppdp4_lane_hbr2[k] = bw_fixed_to_int(bw_mul(bw_div(bw_mul(bw_int_to_fixed(540), bw_int_to_fixed(4)), data->pixel_rate[k]), bw_int_to_fixed(8)));
+                       }
+                       if (bw_meq(data->max_phyclk, bw_int_to_fixed(810))) {
+                               data->output_bppdp4_lane_hbr3[k] = bw_fixed_to_int(bw_mul(bw_div(bw_mul(bw_int_to_fixed(810), bw_int_to_fixed(4)), data->pixel_rate[k]), bw_int_to_fixed(8)));
+                       }
+               }
+       }
+
+       kfree(surface_type);
+free_tiling_mode:
+       kfree(tiling_mode);
+free_yclk:
+       kfree(yclk);
+free_sclk:
+       kfree(sclk);
+}
+
+/*******************************************************************************
+ * Public functions
+ ******************************************************************************/
+void bw_calcs_init(struct bw_calcs_dceip *bw_dceip,
+       struct bw_calcs_vbios *bw_vbios,
+       struct hw_asic_id asic_id)
+{
+       struct bw_calcs_dceip *dceip;
+       struct bw_calcs_vbios *vbios;
+
+       enum bw_calcs_version version = bw_calcs_version_from_asic_id(asic_id);
+
+       dceip = kzalloc(sizeof(*dceip), GFP_KERNEL);
+       if (!dceip)
+               return;
+
+       vbios = kzalloc(sizeof(*vbios), GFP_KERNEL);
+       if (!vbios) {
+               kfree(dceip);
+               return;
+       }
+
+       dceip->version = version;
+
+       switch (version) {
+       case BW_CALCS_VERSION_CARRIZO:
+               vbios->memory_type = bw_def_gddr5;
+               vbios->dram_channel_width_in_bits = 64;
+               vbios->number_of_dram_channels = asic_id.vram_width / vbios->dram_channel_width_in_bits;
+               vbios->number_of_dram_banks = 8;
+               vbios->high_yclk = bw_int_to_fixed(1600);
+               vbios->mid_yclk = bw_int_to_fixed(1600);
+               vbios->low_yclk = bw_frc_to_fixed(66666, 100);
+               vbios->low_sclk = bw_int_to_fixed(200);
+               vbios->mid1_sclk = bw_int_to_fixed(300);
+               vbios->mid2_sclk = bw_int_to_fixed(300);
+               vbios->mid3_sclk = bw_int_to_fixed(300);
+               vbios->mid4_sclk = bw_int_to_fixed(300);
+               vbios->mid5_sclk = bw_int_to_fixed(300);
+               vbios->mid6_sclk = bw_int_to_fixed(300);
+               vbios->high_sclk = bw_frc_to_fixed(62609, 100);
+               vbios->low_voltage_max_dispclk = bw_int_to_fixed(352);
+               vbios->mid_voltage_max_dispclk = bw_int_to_fixed(467);
+               vbios->high_voltage_max_dispclk = bw_int_to_fixed(643);
+               vbios->low_voltage_max_phyclk = bw_int_to_fixed(540);
+               vbios->mid_voltage_max_phyclk = bw_int_to_fixed(810);
+               vbios->high_voltage_max_phyclk = bw_int_to_fixed(810);
+               vbios->data_return_bus_width = bw_int_to_fixed(32);
+               vbios->trc = bw_int_to_fixed(50);
+               vbios->dmifmc_urgent_latency = bw_int_to_fixed(4);
+               vbios->stutter_self_refresh_exit_latency = bw_frc_to_fixed(153, 10);
+               vbios->stutter_self_refresh_entry_latency = bw_int_to_fixed(0);
+               vbios->nbp_state_change_latency = bw_frc_to_fixed(19649, 1000);
+               vbios->mcifwrmc_urgent_latency = bw_int_to_fixed(10);
+               vbios->scatter_gather_enable = true;
+               vbios->down_spread_percentage = bw_frc_to_fixed(5, 10);
+               vbios->cursor_width = 32;
+               vbios->average_compression_rate = 4;
+               vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel = 256;
+               vbios->blackout_duration = bw_int_to_fixed(0); /* us */
+               vbios->maximum_blackout_recovery_time = bw_int_to_fixed(0);
+
+               dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation = 100;
+               dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation = 100;
+               dceip->percent_of_ideal_port_bw_received_after_urgent_latency = 100;
+               dceip->large_cursor = false;
+               dceip->dmif_request_buffer_size = bw_int_to_fixed(768);
+               dceip->dmif_pipe_en_fbc_chunk_tracker = false;
+               dceip->cursor_max_outstanding_group_num = 1;
+               dceip->lines_interleaved_into_lb = 2;
+               dceip->chunk_width = 256;
+               dceip->number_of_graphics_pipes = 3;
+               dceip->number_of_underlay_pipes = 1;
+               dceip->low_power_tiling_mode = 0;
+               dceip->display_write_back_supported = false;
+               dceip->argb_compression_support = false;
+               dceip->underlay_vscaler_efficiency6_bit_per_component =
+                       bw_frc_to_fixed(35556, 10000);
+               dceip->underlay_vscaler_efficiency8_bit_per_component =
+                       bw_frc_to_fixed(34286, 10000);
+               dceip->underlay_vscaler_efficiency10_bit_per_component =
+                       bw_frc_to_fixed(32, 10);
+               dceip->underlay_vscaler_efficiency12_bit_per_component =
+                       bw_int_to_fixed(3);
+               dceip->graphics_vscaler_efficiency6_bit_per_component =
+                       bw_frc_to_fixed(35, 10);
+               dceip->graphics_vscaler_efficiency8_bit_per_component =
+                       bw_frc_to_fixed(34286, 10000);
+               dceip->graphics_vscaler_efficiency10_bit_per_component =
+                       bw_frc_to_fixed(32, 10);
+               dceip->graphics_vscaler_efficiency12_bit_per_component =
+                       bw_int_to_fixed(3);
+               dceip->alpha_vscaler_efficiency = bw_int_to_fixed(3);
+               dceip->max_dmif_buffer_allocated = 2;
+               dceip->graphics_dmif_size = 12288;
+               dceip->underlay_luma_dmif_size = 19456;
+               dceip->underlay_chroma_dmif_size = 23552;
+               dceip->pre_downscaler_enabled = true;
+               dceip->underlay_downscale_prefetch_enabled = true;
+               dceip->lb_write_pixels_per_dispclk = bw_int_to_fixed(1);
+               dceip->lb_size_per_component444 = bw_int_to_fixed(82176);
+               dceip->graphics_lb_nodownscaling_multi_line_prefetching = false;
+               dceip->stutter_and_dram_clock_state_change_gated_before_cursor =
+                       bw_int_to_fixed(0);
+               dceip->underlay420_luma_lb_size_per_component = bw_int_to_fixed(
+                       82176);
+               dceip->underlay420_chroma_lb_size_per_component =
+                       bw_int_to_fixed(164352);
+               dceip->underlay422_lb_size_per_component = bw_int_to_fixed(
+                       82176);
+               dceip->cursor_chunk_width = bw_int_to_fixed(64);
+               dceip->cursor_dcp_buffer_lines = bw_int_to_fixed(4);
+               dceip->underlay_maximum_width_efficient_for_tiling =
+                       bw_int_to_fixed(1920);
+               dceip->underlay_maximum_height_efficient_for_tiling =
+                       bw_int_to_fixed(1080);
+               dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display =
+                       bw_frc_to_fixed(3, 10);
+               dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation =
+                       bw_int_to_fixed(25);
+               dceip->minimum_outstanding_pte_request_limit = bw_int_to_fixed(
+                       2);
+               dceip->maximum_total_outstanding_pte_requests_allowed_by_saw =
+                       bw_int_to_fixed(128);
+               dceip->limit_excessive_outstanding_dmif_requests = true;
+               dceip->linear_mode_line_request_alternation_slice =
+                       bw_int_to_fixed(64);
+               dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode =
+                       32;
+               dceip->display_write_back420_luma_mcifwr_buffer_size = 12288;
+               dceip->display_write_back420_chroma_mcifwr_buffer_size = 8192;
+               dceip->request_efficiency = bw_frc_to_fixed(8, 10);
+               dceip->dispclk_per_request = bw_int_to_fixed(2);
+               dceip->dispclk_ramping_factor = bw_frc_to_fixed(105, 100);
+               dceip->display_pipe_throughput_factor = bw_frc_to_fixed(105, 100);
+               dceip->scatter_gather_pte_request_rows_in_tiling_mode = 2;
+               dceip->mcifwr_all_surfaces_burst_time = bw_int_to_fixed(0); /* todo: this is a bug*/
+               break;
+       case BW_CALCS_VERSION_POLARIS10:
+               /* TODO: Treat VEGAM the same as P10 for now
+                * Need to tune the para for VEGAM if needed */
+       case BW_CALCS_VERSION_VEGAM:
+               vbios->memory_type = bw_def_gddr5;
+               vbios->dram_channel_width_in_bits = 32;
+               vbios->number_of_dram_channels = asic_id.vram_width / vbios->dram_channel_width_in_bits;
+               vbios->number_of_dram_banks = 8;
+               vbios->high_yclk = bw_int_to_fixed(6000);
+               vbios->mid_yclk = bw_int_to_fixed(3200);
+               vbios->low_yclk = bw_int_to_fixed(1000);
+               vbios->low_sclk = bw_int_to_fixed(300);
+               vbios->mid1_sclk = bw_int_to_fixed(400);
+               vbios->mid2_sclk = bw_int_to_fixed(500);
+               vbios->mid3_sclk = bw_int_to_fixed(600);
+               vbios->mid4_sclk = bw_int_to_fixed(700);
+               vbios->mid5_sclk = bw_int_to_fixed(800);
+               vbios->mid6_sclk = bw_int_to_fixed(974);
+               vbios->high_sclk = bw_int_to_fixed(1154);
+               vbios->low_voltage_max_dispclk = bw_int_to_fixed(459);
+               vbios->mid_voltage_max_dispclk = bw_int_to_fixed(654);
+               vbios->high_voltage_max_dispclk = bw_int_to_fixed(1108);
+               vbios->low_voltage_max_phyclk = bw_int_to_fixed(540);
+               vbios->mid_voltage_max_phyclk = bw_int_to_fixed(810);
+               vbios->high_voltage_max_phyclk = bw_int_to_fixed(810);
+               vbios->data_return_bus_width = bw_int_to_fixed(32);
+               vbios->trc = bw_int_to_fixed(48);
+               vbios->dmifmc_urgent_latency = bw_int_to_fixed(3);
+               vbios->stutter_self_refresh_exit_latency = bw_int_to_fixed(5);
+               vbios->stutter_self_refresh_entry_latency = bw_int_to_fixed(0);
+               vbios->nbp_state_change_latency = bw_int_to_fixed(45);
+               vbios->mcifwrmc_urgent_latency = bw_int_to_fixed(10);
+               vbios->scatter_gather_enable = true;
+               vbios->down_spread_percentage = bw_frc_to_fixed(5, 10);
+               vbios->cursor_width = 32;
+               vbios->average_compression_rate = 4;
+               vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel = 256;
+               vbios->blackout_duration = bw_int_to_fixed(0); /* us */
+               vbios->maximum_blackout_recovery_time = bw_int_to_fixed(0);
+
+               dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation = 100;
+               dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation = 100;
+               dceip->percent_of_ideal_port_bw_received_after_urgent_latency = 100;
+               dceip->large_cursor = false;
+               dceip->dmif_request_buffer_size = bw_int_to_fixed(768);
+               dceip->dmif_pipe_en_fbc_chunk_tracker = false;
+               dceip->cursor_max_outstanding_group_num = 1;
+               dceip->lines_interleaved_into_lb = 2;
+               dceip->chunk_width = 256;
+               dceip->number_of_graphics_pipes = 6;
+               dceip->number_of_underlay_pipes = 0;
+               dceip->low_power_tiling_mode = 0;
+               dceip->display_write_back_supported = false;
+               dceip->argb_compression_support = true;
+               dceip->underlay_vscaler_efficiency6_bit_per_component =
+                       bw_frc_to_fixed(35556, 10000);
+               dceip->underlay_vscaler_efficiency8_bit_per_component =
+                       bw_frc_to_fixed(34286, 10000);
+               dceip->underlay_vscaler_efficiency10_bit_per_component =
+                       bw_frc_to_fixed(32, 10);
+               dceip->underlay_vscaler_efficiency12_bit_per_component =
+                       bw_int_to_fixed(3);
+               dceip->graphics_vscaler_efficiency6_bit_per_component =
+                       bw_frc_to_fixed(35, 10);
+               dceip->graphics_vscaler_efficiency8_bit_per_component =
+                       bw_frc_to_fixed(34286, 10000);
+               dceip->graphics_vscaler_efficiency10_bit_per_component =
+                       bw_frc_to_fixed(32, 10);
+               dceip->graphics_vscaler_efficiency12_bit_per_component =
+                       bw_int_to_fixed(3);
+               dceip->alpha_vscaler_efficiency = bw_int_to_fixed(3);
+               dceip->max_dmif_buffer_allocated = 4;
+               dceip->graphics_dmif_size = 12288;
+               dceip->underlay_luma_dmif_size = 19456;
+               dceip->underlay_chroma_dmif_size = 23552;
+               dceip->pre_downscaler_enabled = true;
+               dceip->underlay_downscale_prefetch_enabled = true;
+               dceip->lb_write_pixels_per_dispclk = bw_int_to_fixed(1);
+               dceip->lb_size_per_component444 = bw_int_to_fixed(245952);
+               dceip->graphics_lb_nodownscaling_multi_line_prefetching = true;
+               dceip->stutter_and_dram_clock_state_change_gated_before_cursor =
+                       bw_int_to_fixed(1);
+               dceip->underlay420_luma_lb_size_per_component = bw_int_to_fixed(
+                       82176);
+               dceip->underlay420_chroma_lb_size_per_component =
+                       bw_int_to_fixed(164352);
+               dceip->underlay422_lb_size_per_component = bw_int_to_fixed(
+                       82176);
+               dceip->cursor_chunk_width = bw_int_to_fixed(64);
+               dceip->cursor_dcp_buffer_lines = bw_int_to_fixed(4);
+               dceip->underlay_maximum_width_efficient_for_tiling =
+                       bw_int_to_fixed(1920);
+               dceip->underlay_maximum_height_efficient_for_tiling =
+                       bw_int_to_fixed(1080);
+               dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display =
+                       bw_frc_to_fixed(3, 10);
+               dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation =
+                       bw_int_to_fixed(25);
+               dceip->minimum_outstanding_pte_request_limit = bw_int_to_fixed(
+                       2);
+               dceip->maximum_total_outstanding_pte_requests_allowed_by_saw =
+                       bw_int_to_fixed(128);
+               dceip->limit_excessive_outstanding_dmif_requests = true;
+               dceip->linear_mode_line_request_alternation_slice =
+                       bw_int_to_fixed(64);
+               dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode =
+                       32;
+               dceip->display_write_back420_luma_mcifwr_buffer_size = 12288;
+               dceip->display_write_back420_chroma_mcifwr_buffer_size = 8192;
+               dceip->request_efficiency = bw_frc_to_fixed(8, 10);
+               dceip->dispclk_per_request = bw_int_to_fixed(2);
+               dceip->dispclk_ramping_factor = bw_frc_to_fixed(105, 100);
+               dceip->display_pipe_throughput_factor = bw_frc_to_fixed(105, 100);
+               dceip->scatter_gather_pte_request_rows_in_tiling_mode = 2;
+               dceip->mcifwr_all_surfaces_burst_time = bw_int_to_fixed(0);
+               break;
+       case BW_CALCS_VERSION_POLARIS11:
+               vbios->memory_type = bw_def_gddr5;
+               vbios->dram_channel_width_in_bits = 32;
+               vbios->number_of_dram_channels = asic_id.vram_width / vbios->dram_channel_width_in_bits;
+               vbios->number_of_dram_banks = 8;
+               vbios->high_yclk = bw_int_to_fixed(6000);
+               vbios->mid_yclk = bw_int_to_fixed(3200);
+               vbios->low_yclk = bw_int_to_fixed(1000);
+               vbios->low_sclk = bw_int_to_fixed(300);
+               vbios->mid1_sclk = bw_int_to_fixed(400);
+               vbios->mid2_sclk = bw_int_to_fixed(500);
+               vbios->mid3_sclk = bw_int_to_fixed(600);
+               vbios->mid4_sclk = bw_int_to_fixed(700);
+               vbios->mid5_sclk = bw_int_to_fixed(800);
+               vbios->mid6_sclk = bw_int_to_fixed(974);
+               vbios->high_sclk = bw_int_to_fixed(1154);
+               vbios->low_voltage_max_dispclk = bw_int_to_fixed(459);
+               vbios->mid_voltage_max_dispclk = bw_int_to_fixed(654);
+               vbios->high_voltage_max_dispclk = bw_int_to_fixed(1108);
+               vbios->low_voltage_max_phyclk = bw_int_to_fixed(540);
+               vbios->mid_voltage_max_phyclk = bw_int_to_fixed(810);
+               vbios->high_voltage_max_phyclk = bw_int_to_fixed(810);
+               vbios->data_return_bus_width = bw_int_to_fixed(32);
+               vbios->trc = bw_int_to_fixed(48);
+               if (vbios->number_of_dram_channels == 2) // 64-bit
+                       vbios->dmifmc_urgent_latency = bw_int_to_fixed(4);
+               else
+                       vbios->dmifmc_urgent_latency = bw_int_to_fixed(3);
+               vbios->stutter_self_refresh_exit_latency = bw_int_to_fixed(5);
+               vbios->stutter_self_refresh_entry_latency = bw_int_to_fixed(0);
+               vbios->nbp_state_change_latency = bw_int_to_fixed(45);
+               vbios->mcifwrmc_urgent_latency = bw_int_to_fixed(10);
+               vbios->scatter_gather_enable = true;
+               vbios->down_spread_percentage = bw_frc_to_fixed(5, 10);
+               vbios->cursor_width = 32;
+               vbios->average_compression_rate = 4;
+               vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel = 256;
+               vbios->blackout_duration = bw_int_to_fixed(0); /* us */
+               vbios->maximum_blackout_recovery_time = bw_int_to_fixed(0);
+
+               dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation = 100;
+               dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation = 100;
+               dceip->percent_of_ideal_port_bw_received_after_urgent_latency = 100;
+               dceip->large_cursor = false;
+               dceip->dmif_request_buffer_size = bw_int_to_fixed(768);
+               dceip->dmif_pipe_en_fbc_chunk_tracker = false;
+               dceip->cursor_max_outstanding_group_num = 1;
+               dceip->lines_interleaved_into_lb = 2;
+               dceip->chunk_width = 256;
+               dceip->number_of_graphics_pipes = 5;
+               dceip->number_of_underlay_pipes = 0;
+               dceip->low_power_tiling_mode = 0;
+               dceip->display_write_back_supported = false;
+               dceip->argb_compression_support = true;
+               dceip->underlay_vscaler_efficiency6_bit_per_component =
+                       bw_frc_to_fixed(35556, 10000);
+               dceip->underlay_vscaler_efficiency8_bit_per_component =
+                       bw_frc_to_fixed(34286, 10000);
+               dceip->underlay_vscaler_efficiency10_bit_per_component =
+                       bw_frc_to_fixed(32, 10);
+               dceip->underlay_vscaler_efficiency12_bit_per_component =
+                       bw_int_to_fixed(3);
+               dceip->graphics_vscaler_efficiency6_bit_per_component =
+                       bw_frc_to_fixed(35, 10);
+               dceip->graphics_vscaler_efficiency8_bit_per_component =
+                       bw_frc_to_fixed(34286, 10000);
+               dceip->graphics_vscaler_efficiency10_bit_per_component =
+                       bw_frc_to_fixed(32, 10);
+               dceip->graphics_vscaler_efficiency12_bit_per_component =
+                       bw_int_to_fixed(3);
+               dceip->alpha_vscaler_efficiency = bw_int_to_fixed(3);
+               dceip->max_dmif_buffer_allocated = 4;
+               dceip->graphics_dmif_size = 12288;
+               dceip->underlay_luma_dmif_size = 19456;
+               dceip->underlay_chroma_dmif_size = 23552;
+               dceip->pre_downscaler_enabled = true;
+               dceip->underlay_downscale_prefetch_enabled = true;
+               dceip->lb_write_pixels_per_dispclk = bw_int_to_fixed(1);
+               dceip->lb_size_per_component444 = bw_int_to_fixed(245952);
+               dceip->graphics_lb_nodownscaling_multi_line_prefetching = true;
+               dceip->stutter_and_dram_clock_state_change_gated_before_cursor =
+                       bw_int_to_fixed(1);
+               dceip->underlay420_luma_lb_size_per_component = bw_int_to_fixed(
+                       82176);
+               dceip->underlay420_chroma_lb_size_per_component =
+                       bw_int_to_fixed(164352);
+               dceip->underlay422_lb_size_per_component = bw_int_to_fixed(
+                       82176);
+               dceip->cursor_chunk_width = bw_int_to_fixed(64);
+               dceip->cursor_dcp_buffer_lines = bw_int_to_fixed(4);
+               dceip->underlay_maximum_width_efficient_for_tiling =
+                       bw_int_to_fixed(1920);
+               dceip->underlay_maximum_height_efficient_for_tiling =
+                       bw_int_to_fixed(1080);
+               dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display =
+                       bw_frc_to_fixed(3, 10);
+               dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation =
+                       bw_int_to_fixed(25);
+               dceip->minimum_outstanding_pte_request_limit = bw_int_to_fixed(
+                       2);
+               dceip->maximum_total_outstanding_pte_requests_allowed_by_saw =
+                       bw_int_to_fixed(128);
+               dceip->limit_excessive_outstanding_dmif_requests = true;
+               dceip->linear_mode_line_request_alternation_slice =
+                       bw_int_to_fixed(64);
+               dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode =
+                       32;
+               dceip->display_write_back420_luma_mcifwr_buffer_size = 12288;
+               dceip->display_write_back420_chroma_mcifwr_buffer_size = 8192;
+               dceip->request_efficiency = bw_frc_to_fixed(8, 10);
+               dceip->dispclk_per_request = bw_int_to_fixed(2);
+               dceip->dispclk_ramping_factor = bw_frc_to_fixed(105, 100);
+               dceip->display_pipe_throughput_factor = bw_frc_to_fixed(105, 100);
+               dceip->scatter_gather_pte_request_rows_in_tiling_mode = 2;
+               dceip->mcifwr_all_surfaces_burst_time = bw_int_to_fixed(0);
+               break;
+       case BW_CALCS_VERSION_POLARIS12:
+               vbios->memory_type = bw_def_gddr5;
+               vbios->dram_channel_width_in_bits = 32;
+               vbios->number_of_dram_channels = asic_id.vram_width / vbios->dram_channel_width_in_bits;
+               vbios->number_of_dram_banks = 8;
+               vbios->high_yclk = bw_int_to_fixed(6000);
+               vbios->mid_yclk = bw_int_to_fixed(3200);
+               vbios->low_yclk = bw_int_to_fixed(1000);
+               vbios->low_sclk = bw_int_to_fixed(678);
+               vbios->mid1_sclk = bw_int_to_fixed(864);
+               vbios->mid2_sclk = bw_int_to_fixed(900);
+               vbios->mid3_sclk = bw_int_to_fixed(920);
+               vbios->mid4_sclk = bw_int_to_fixed(940);
+               vbios->mid5_sclk = bw_int_to_fixed(960);
+               vbios->mid6_sclk = bw_int_to_fixed(980);
+               vbios->high_sclk = bw_int_to_fixed(1049);
+               vbios->low_voltage_max_dispclk = bw_int_to_fixed(459);
+               vbios->mid_voltage_max_dispclk = bw_int_to_fixed(654);
+               vbios->high_voltage_max_dispclk = bw_int_to_fixed(1108);
+               vbios->low_voltage_max_phyclk = bw_int_to_fixed(540);
+               vbios->mid_voltage_max_phyclk = bw_int_to_fixed(810);
+               vbios->high_voltage_max_phyclk = bw_int_to_fixed(810);
+               vbios->data_return_bus_width = bw_int_to_fixed(32);
+               vbios->trc = bw_int_to_fixed(48);
+               if (vbios->number_of_dram_channels == 2) // 64-bit
+                       vbios->dmifmc_urgent_latency = bw_int_to_fixed(4);
+               else
+                       vbios->dmifmc_urgent_latency = bw_int_to_fixed(3);
+               vbios->stutter_self_refresh_exit_latency = bw_int_to_fixed(5);
+               vbios->stutter_self_refresh_entry_latency = bw_int_to_fixed(0);
+               vbios->nbp_state_change_latency = bw_int_to_fixed(250);
+               vbios->mcifwrmc_urgent_latency = bw_int_to_fixed(10);
+               vbios->scatter_gather_enable = false;
+               vbios->down_spread_percentage = bw_frc_to_fixed(5, 10);
+               vbios->cursor_width = 32;
+               vbios->average_compression_rate = 4;
+               vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel = 256;
+               vbios->blackout_duration = bw_int_to_fixed(0); /* us */
+               vbios->maximum_blackout_recovery_time = bw_int_to_fixed(0);
+
+               dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation = 100;
+               dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation = 100;
+               dceip->percent_of_ideal_port_bw_received_after_urgent_latency = 100;
+               dceip->large_cursor = false;
+               dceip->dmif_request_buffer_size = bw_int_to_fixed(768);
+               dceip->dmif_pipe_en_fbc_chunk_tracker = false;
+               dceip->cursor_max_outstanding_group_num = 1;
+               dceip->lines_interleaved_into_lb = 2;
+               dceip->chunk_width = 256;
+               dceip->number_of_graphics_pipes = 5;
+               dceip->number_of_underlay_pipes = 0;
+               dceip->low_power_tiling_mode = 0;
+               dceip->display_write_back_supported = true;
+               dceip->argb_compression_support = true;
+               dceip->underlay_vscaler_efficiency6_bit_per_component =
+                       bw_frc_to_fixed(35556, 10000);
+               dceip->underlay_vscaler_efficiency8_bit_per_component =
+                       bw_frc_to_fixed(34286, 10000);
+               dceip->underlay_vscaler_efficiency10_bit_per_component =
+                       bw_frc_to_fixed(32, 10);
+               dceip->underlay_vscaler_efficiency12_bit_per_component =
+                       bw_int_to_fixed(3);
+               dceip->graphics_vscaler_efficiency6_bit_per_component =
+                       bw_frc_to_fixed(35, 10);
+               dceip->graphics_vscaler_efficiency8_bit_per_component =
+                       bw_frc_to_fixed(34286, 10000);
+               dceip->graphics_vscaler_efficiency10_bit_per_component =
+                       bw_frc_to_fixed(32, 10);
+               dceip->graphics_vscaler_efficiency12_bit_per_component =
+                       bw_int_to_fixed(3);
+               dceip->alpha_vscaler_efficiency = bw_int_to_fixed(3);
+               dceip->max_dmif_buffer_allocated = 4;
+               dceip->graphics_dmif_size = 12288;
+               dceip->underlay_luma_dmif_size = 19456;
+               dceip->underlay_chroma_dmif_size = 23552;
+               dceip->pre_downscaler_enabled = true;
+               dceip->underlay_downscale_prefetch_enabled = true;
+               dceip->lb_write_pixels_per_dispclk = bw_int_to_fixed(1);
+               dceip->lb_size_per_component444 = bw_int_to_fixed(245952);
+               dceip->graphics_lb_nodownscaling_multi_line_prefetching = true;
+               dceip->stutter_and_dram_clock_state_change_gated_before_cursor =
+                       bw_int_to_fixed(1);
+               dceip->underlay420_luma_lb_size_per_component = bw_int_to_fixed(
+                       82176);
+               dceip->underlay420_chroma_lb_size_per_component =
+                       bw_int_to_fixed(164352);
+               dceip->underlay422_lb_size_per_component = bw_int_to_fixed(
+                       82176);
+               dceip->cursor_chunk_width = bw_int_to_fixed(64);
+               dceip->cursor_dcp_buffer_lines = bw_int_to_fixed(4);
+               dceip->underlay_maximum_width_efficient_for_tiling =
+                       bw_int_to_fixed(1920);
+               dceip->underlay_maximum_height_efficient_for_tiling =
+                       bw_int_to_fixed(1080);
+               dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display =
+                       bw_frc_to_fixed(3, 10);
+               dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation =
+                       bw_int_to_fixed(25);
+               dceip->minimum_outstanding_pte_request_limit = bw_int_to_fixed(
+                       2);
+               dceip->maximum_total_outstanding_pte_requests_allowed_by_saw =
+                       bw_int_to_fixed(128);
+               dceip->limit_excessive_outstanding_dmif_requests = true;
+               dceip->linear_mode_line_request_alternation_slice =
+                       bw_int_to_fixed(64);
+               dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode =
+                       32;
+               dceip->display_write_back420_luma_mcifwr_buffer_size = 12288;
+               dceip->display_write_back420_chroma_mcifwr_buffer_size = 8192;
+               dceip->request_efficiency = bw_frc_to_fixed(8, 10);
+               dceip->dispclk_per_request = bw_int_to_fixed(2);
+               dceip->dispclk_ramping_factor = bw_frc_to_fixed(105, 100);
+               dceip->display_pipe_throughput_factor = bw_frc_to_fixed(105, 100);
+               dceip->scatter_gather_pte_request_rows_in_tiling_mode = 2;
+               dceip->mcifwr_all_surfaces_burst_time = bw_int_to_fixed(0);
+               break;
+       case BW_CALCS_VERSION_STONEY:
+               vbios->memory_type = bw_def_gddr5;
+               vbios->dram_channel_width_in_bits = 64;
+               vbios->number_of_dram_channels = asic_id.vram_width / vbios->dram_channel_width_in_bits;
+               vbios->number_of_dram_banks = 8;
+               vbios->high_yclk = bw_int_to_fixed(1866);
+               vbios->mid_yclk = bw_int_to_fixed(1866);
+               vbios->low_yclk = bw_int_to_fixed(1333);
+               vbios->low_sclk = bw_int_to_fixed(200);
+               vbios->mid1_sclk = bw_int_to_fixed(600);
+               vbios->mid2_sclk = bw_int_to_fixed(600);
+               vbios->mid3_sclk = bw_int_to_fixed(600);
+               vbios->mid4_sclk = bw_int_to_fixed(600);
+               vbios->mid5_sclk = bw_int_to_fixed(600);
+               vbios->mid6_sclk = bw_int_to_fixed(600);
+               vbios->high_sclk = bw_int_to_fixed(800);
+               vbios->low_voltage_max_dispclk = bw_int_to_fixed(352);
+               vbios->mid_voltage_max_dispclk = bw_int_to_fixed(467);
+               vbios->high_voltage_max_dispclk = bw_int_to_fixed(643);
+               vbios->low_voltage_max_phyclk = bw_int_to_fixed(540);
+               vbios->mid_voltage_max_phyclk = bw_int_to_fixed(810);
+               vbios->high_voltage_max_phyclk = bw_int_to_fixed(810);
+               vbios->data_return_bus_width = bw_int_to_fixed(32);
+               vbios->trc = bw_int_to_fixed(50);
+               vbios->dmifmc_urgent_latency = bw_int_to_fixed(4);
+               vbios->stutter_self_refresh_exit_latency = bw_frc_to_fixed(158, 10);
+               vbios->stutter_self_refresh_entry_latency = bw_int_to_fixed(0);
+               vbios->nbp_state_change_latency = bw_frc_to_fixed(2008, 100);
+               vbios->mcifwrmc_urgent_latency = bw_int_to_fixed(10);
+               vbios->scatter_gather_enable = true;
+               vbios->down_spread_percentage = bw_frc_to_fixed(5, 10);
+               vbios->cursor_width = 32;
+               vbios->average_compression_rate = 4;
+               vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel = 256;
+               vbios->blackout_duration = bw_int_to_fixed(0); /* us */
+               vbios->maximum_blackout_recovery_time = bw_int_to_fixed(0);
+
+               dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation = 100;
+               dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation = 100;
+               dceip->percent_of_ideal_port_bw_received_after_urgent_latency = 100;
+               dceip->large_cursor = false;
+               dceip->dmif_request_buffer_size = bw_int_to_fixed(768);
+               dceip->dmif_pipe_en_fbc_chunk_tracker = false;
+               dceip->cursor_max_outstanding_group_num = 1;
+               dceip->lines_interleaved_into_lb = 2;
+               dceip->chunk_width = 256;
+               dceip->number_of_graphics_pipes = 2;
+               dceip->number_of_underlay_pipes = 1;
+               dceip->low_power_tiling_mode = 0;
+               dceip->display_write_back_supported = false;
+               dceip->argb_compression_support = true;
+               dceip->underlay_vscaler_efficiency6_bit_per_component =
+                       bw_frc_to_fixed(35556, 10000);
+               dceip->underlay_vscaler_efficiency8_bit_per_component =
+                       bw_frc_to_fixed(34286, 10000);
+               dceip->underlay_vscaler_efficiency10_bit_per_component =
+                       bw_frc_to_fixed(32, 10);
+               dceip->underlay_vscaler_efficiency12_bit_per_component =
+                       bw_int_to_fixed(3);
+               dceip->graphics_vscaler_efficiency6_bit_per_component =
+                       bw_frc_to_fixed(35, 10);
+               dceip->graphics_vscaler_efficiency8_bit_per_component =
+                       bw_frc_to_fixed(34286, 10000);
+               dceip->graphics_vscaler_efficiency10_bit_per_component =
+                       bw_frc_to_fixed(32, 10);
+               dceip->graphics_vscaler_efficiency12_bit_per_component =
+                       bw_int_to_fixed(3);
+               dceip->alpha_vscaler_efficiency = bw_int_to_fixed(3);
+               dceip->max_dmif_buffer_allocated = 2;
+               dceip->graphics_dmif_size = 12288;
+               dceip->underlay_luma_dmif_size = 19456;
+               dceip->underlay_chroma_dmif_size = 23552;
+               dceip->pre_downscaler_enabled = true;
+               dceip->underlay_downscale_prefetch_enabled = true;
+               dceip->lb_write_pixels_per_dispclk = bw_int_to_fixed(1);
+               dceip->lb_size_per_component444 = bw_int_to_fixed(82176);
+               dceip->graphics_lb_nodownscaling_multi_line_prefetching = false;
+               dceip->stutter_and_dram_clock_state_change_gated_before_cursor =
+                       bw_int_to_fixed(0);
+               dceip->underlay420_luma_lb_size_per_component = bw_int_to_fixed(
+                       82176);
+               dceip->underlay420_chroma_lb_size_per_component =
+                       bw_int_to_fixed(164352);
+               dceip->underlay422_lb_size_per_component = bw_int_to_fixed(
+                       82176);
+               dceip->cursor_chunk_width = bw_int_to_fixed(64);
+               dceip->cursor_dcp_buffer_lines = bw_int_to_fixed(4);
+               dceip->underlay_maximum_width_efficient_for_tiling =
+                       bw_int_to_fixed(1920);
+               dceip->underlay_maximum_height_efficient_for_tiling =
+                       bw_int_to_fixed(1080);
+               dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display =
+                       bw_frc_to_fixed(3, 10);
+               dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation =
+                       bw_int_to_fixed(25);
+               dceip->minimum_outstanding_pte_request_limit = bw_int_to_fixed(
+                       2);
+               dceip->maximum_total_outstanding_pte_requests_allowed_by_saw =
+                       bw_int_to_fixed(128);
+               dceip->limit_excessive_outstanding_dmif_requests = true;
+               dceip->linear_mode_line_request_alternation_slice =
+                       bw_int_to_fixed(64);
+               dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode =
+                       32;
+               dceip->display_write_back420_luma_mcifwr_buffer_size = 12288;
+               dceip->display_write_back420_chroma_mcifwr_buffer_size = 8192;
+               dceip->request_efficiency = bw_frc_to_fixed(8, 10);
+               dceip->dispclk_per_request = bw_int_to_fixed(2);
+               dceip->dispclk_ramping_factor = bw_frc_to_fixed(105, 100);
+               dceip->display_pipe_throughput_factor = bw_frc_to_fixed(105, 100);
+               dceip->scatter_gather_pte_request_rows_in_tiling_mode = 2;
+               dceip->mcifwr_all_surfaces_burst_time = bw_int_to_fixed(0);
+               break;
+       case BW_CALCS_VERSION_VEGA10:
+               vbios->memory_type = bw_def_hbm;
+               vbios->dram_channel_width_in_bits = 128;
+               vbios->number_of_dram_channels = asic_id.vram_width / vbios->dram_channel_width_in_bits;
+               vbios->number_of_dram_banks = 16;
+               vbios->high_yclk = bw_int_to_fixed(2400);
+               vbios->mid_yclk = bw_int_to_fixed(1700);
+               vbios->low_yclk = bw_int_to_fixed(1000);
+               vbios->low_sclk = bw_int_to_fixed(300);
+               vbios->mid1_sclk = bw_int_to_fixed(350);
+               vbios->mid2_sclk = bw_int_to_fixed(400);
+               vbios->mid3_sclk = bw_int_to_fixed(500);
+               vbios->mid4_sclk = bw_int_to_fixed(600);
+               vbios->mid5_sclk = bw_int_to_fixed(700);
+               vbios->mid6_sclk = bw_int_to_fixed(760);
+               vbios->high_sclk = bw_int_to_fixed(776);
+               vbios->low_voltage_max_dispclk = bw_int_to_fixed(460);
+               vbios->mid_voltage_max_dispclk = bw_int_to_fixed(670);
+               vbios->high_voltage_max_dispclk = bw_int_to_fixed(1133);
+               vbios->low_voltage_max_phyclk = bw_int_to_fixed(540);
+               vbios->mid_voltage_max_phyclk = bw_int_to_fixed(810);
+               vbios->high_voltage_max_phyclk = bw_int_to_fixed(810);
+               vbios->data_return_bus_width = bw_int_to_fixed(32);
+               vbios->trc = bw_int_to_fixed(48);
+               vbios->dmifmc_urgent_latency = bw_int_to_fixed(3);
+               vbios->stutter_self_refresh_exit_latency = bw_frc_to_fixed(75, 10);
+               vbios->stutter_self_refresh_entry_latency = bw_frc_to_fixed(19, 10);
+               vbios->nbp_state_change_latency = bw_int_to_fixed(39);
+               vbios->mcifwrmc_urgent_latency = bw_int_to_fixed(10);
+               vbios->scatter_gather_enable = false;
+               vbios->down_spread_percentage = bw_frc_to_fixed(5, 10);
+               vbios->cursor_width = 32;
+               vbios->average_compression_rate = 4;
+               vbios->number_of_request_slots_gmc_reserves_for_dmif_per_channel = 8;
+               vbios->blackout_duration = bw_int_to_fixed(0); /* us */
+               vbios->maximum_blackout_recovery_time = bw_int_to_fixed(0);
+
+               dceip->max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation = 100;
+               dceip->max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation = 100;
+               dceip->percent_of_ideal_port_bw_received_after_urgent_latency = 100;
+               dceip->large_cursor = false;
+               dceip->dmif_request_buffer_size = bw_int_to_fixed(2304);
+               dceip->dmif_pipe_en_fbc_chunk_tracker = true;
+               dceip->cursor_max_outstanding_group_num = 1;
+               dceip->lines_interleaved_into_lb = 2;
+               dceip->chunk_width = 256;
+               dceip->number_of_graphics_pipes = 6;
+               dceip->number_of_underlay_pipes = 0;
+               dceip->low_power_tiling_mode = 0;
+               dceip->display_write_back_supported = true;
+               dceip->argb_compression_support = true;
+               dceip->underlay_vscaler_efficiency6_bit_per_component =
+                       bw_frc_to_fixed(35556, 10000);
+               dceip->underlay_vscaler_efficiency8_bit_per_component =
+                       bw_frc_to_fixed(34286, 10000);
+               dceip->underlay_vscaler_efficiency10_bit_per_component =
+                       bw_frc_to_fixed(32, 10);
+               dceip->underlay_vscaler_efficiency12_bit_per_component =
+                       bw_int_to_fixed(3);
+               dceip->graphics_vscaler_efficiency6_bit_per_component =
+                       bw_frc_to_fixed(35, 10);
+               dceip->graphics_vscaler_efficiency8_bit_per_component =
+                       bw_frc_to_fixed(34286, 10000);
+               dceip->graphics_vscaler_efficiency10_bit_per_component =
+                       bw_frc_to_fixed(32, 10);
+               dceip->graphics_vscaler_efficiency12_bit_per_component =
+                       bw_int_to_fixed(3);
+               dceip->alpha_vscaler_efficiency = bw_int_to_fixed(3);
+               dceip->max_dmif_buffer_allocated = 4;
+               dceip->graphics_dmif_size = 24576;
+               dceip->underlay_luma_dmif_size = 19456;
+               dceip->underlay_chroma_dmif_size = 23552;
+               dceip->pre_downscaler_enabled = true;
+               dceip->underlay_downscale_prefetch_enabled = false;
+               dceip->lb_write_pixels_per_dispclk = bw_int_to_fixed(1);
+               dceip->lb_size_per_component444 = bw_int_to_fixed(245952);
+               dceip->graphics_lb_nodownscaling_multi_line_prefetching = true;
+               dceip->stutter_and_dram_clock_state_change_gated_before_cursor =
+                       bw_int_to_fixed(1);
+               dceip->underlay420_luma_lb_size_per_component = bw_int_to_fixed(
+                       82176);
+               dceip->underlay420_chroma_lb_size_per_component =
+                       bw_int_to_fixed(164352);
+               dceip->underlay422_lb_size_per_component = bw_int_to_fixed(
+                       82176);
+               dceip->cursor_chunk_width = bw_int_to_fixed(64);
+               dceip->cursor_dcp_buffer_lines = bw_int_to_fixed(4);
+               dceip->underlay_maximum_width_efficient_for_tiling =
+                       bw_int_to_fixed(1920);
+               dceip->underlay_maximum_height_efficient_for_tiling =
+                       bw_int_to_fixed(1080);
+               dceip->peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display =
+                       bw_frc_to_fixed(3, 10);
+               dceip->peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation =
+                       bw_int_to_fixed(25);
+               dceip->minimum_outstanding_pte_request_limit = bw_int_to_fixed(
+                       2);
+               dceip->maximum_total_outstanding_pte_requests_allowed_by_saw =
+                       bw_int_to_fixed(128);
+               dceip->limit_excessive_outstanding_dmif_requests = true;
+               dceip->linear_mode_line_request_alternation_slice =
+                       bw_int_to_fixed(64);
+               dceip->scatter_gather_lines_of_pte_prefetching_in_linear_mode =
+                       32;
+               dceip->display_write_back420_luma_mcifwr_buffer_size = 12288;
+               dceip->display_write_back420_chroma_mcifwr_buffer_size = 8192;
+               dceip->request_efficiency = bw_frc_to_fixed(8, 10);
+               dceip->dispclk_per_request = bw_int_to_fixed(2);
+               dceip->dispclk_ramping_factor = bw_frc_to_fixed(105, 100);
+               dceip->display_pipe_throughput_factor = bw_frc_to_fixed(105, 100);
+               dceip->scatter_gather_pte_request_rows_in_tiling_mode = 2;
+               dceip->mcifwr_all_surfaces_burst_time = bw_int_to_fixed(0);
+               break;
+       default:
+               break;
+       }
+       *bw_dceip = *dceip;
+       *bw_vbios = *vbios;
+
+       kfree(dceip);
+       kfree(vbios);
+}
+
+/*
+ * Compare calculated (required) clocks against the clocks available at
+ * maximum voltage (max Performance Level).
+ */
+static bool is_display_configuration_supported(
+       const struct bw_calcs_vbios *vbios,
+       const struct dce_bw_output *calcs_output)
+{
+       uint32_t int_max_clk;
+
+       int_max_clk = bw_fixed_to_int(vbios->high_voltage_max_dispclk);
+       int_max_clk *= 1000; /* MHz to kHz */
+       if (calcs_output->dispclk_khz > int_max_clk)
+               return false;
+
+       int_max_clk = bw_fixed_to_int(vbios->high_sclk);
+       int_max_clk *= 1000; /* MHz to kHz */
+       if (calcs_output->sclk_khz > int_max_clk)
+               return false;
+
+       return true;
+}
+
+static void populate_initial_data(
+       const struct pipe_ctx pipe[], int pipe_count, struct bw_calcs_data *data)
+{
+       int i, j;
+       int num_displays = 0;
+
+       data->underlay_surface_type = bw_def_420;
+       data->panning_and_bezel_adjustment = bw_def_none;
+       data->graphics_lb_bpc = 10;
+       data->underlay_lb_bpc = 8;
+       data->underlay_tiling_mode = bw_def_tiled;
+       data->graphics_tiling_mode = bw_def_tiled;
+       data->underlay_micro_tile_mode = bw_def_display_micro_tiling;
+       data->graphics_micro_tile_mode = bw_def_display_micro_tiling;
+       data->increase_voltage_to_support_mclk_switch = true;
+
+       /* Pipes with underlay first */
+       for (i = 0; i < pipe_count; i++) {
+               if (!pipe[i].stream || !pipe[i].bottom_pipe)
+                       continue;
+
+               ASSERT(pipe[i].plane_state);
+
+               if (num_displays == 0) {
+                       if (!pipe[i].plane_state->visible)
+                               data->d0_underlay_mode = bw_def_underlay_only;
+                       else
+                               data->d0_underlay_mode = bw_def_blend;
+               } else {
+                       if (!pipe[i].plane_state->visible)
+                               data->d1_underlay_mode = bw_def_underlay_only;
+                       else
+                               data->d1_underlay_mode = bw_def_blend;
+               }
+
+               data->fbc_en[num_displays + 4] = false;
+               data->lpt_en[num_displays + 4] = false;
+               data->h_total[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.h_total);
+               data->v_total[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.v_total);
+               data->pixel_rate[num_displays + 4] = bw_frc_to_fixed(pipe[i].stream->timing.pix_clk_100hz, 10000);
+               data->src_width[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.viewport.width);
+               data->pitch_in_pixels[num_displays + 4] = data->src_width[num_displays + 4];
+               data->src_height[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.viewport.height);
+               data->h_taps[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.taps.h_taps);
+               data->v_taps[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.taps.v_taps);
+               data->h_scale_ratio[num_displays + 4] = fixed31_32_to_bw_fixed(pipe[i].plane_res.scl_data.ratios.horz.value);
+               data->v_scale_ratio[num_displays + 4] = fixed31_32_to_bw_fixed(pipe[i].plane_res.scl_data.ratios.vert.value);
+               switch (pipe[i].plane_state->rotation) {
+               case ROTATION_ANGLE_0:
+                       data->rotation_angle[num_displays + 4] = bw_int_to_fixed(0);
+                       break;
+               case ROTATION_ANGLE_90:
+                       data->rotation_angle[num_displays + 4] = bw_int_to_fixed(90);
+                       break;
+               case ROTATION_ANGLE_180:
+                       data->rotation_angle[num_displays + 4] = bw_int_to_fixed(180);
+                       break;
+               case ROTATION_ANGLE_270:
+                       data->rotation_angle[num_displays + 4] = bw_int_to_fixed(270);
+                       break;
+               default:
+                       break;
+               }
+               switch (pipe[i].plane_state->format) {
+               case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
+               case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555:
+               case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
+                       data->bytes_per_pixel[num_displays + 4] = 2;
+                       break;
+               case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
+               case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+               case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
+               case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
+               case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
+               case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
+               case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
+                       data->bytes_per_pixel[num_displays + 4] = 4;
+                       break;
+               case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
+               case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616:
+               case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
+                       data->bytes_per_pixel[num_displays + 4] = 8;
+                       break;
+               default:
+                       data->bytes_per_pixel[num_displays + 4] = 4;
+                       break;
+               }
+               data->interlace_mode[num_displays + 4] = false;
+               data->stereo_mode[num_displays + 4] = bw_def_mono;
+
+
+               for (j = 0; j < 2; j++) {
+                       data->fbc_en[num_displays * 2 + j] = false;
+                       data->lpt_en[num_displays * 2 + j] = false;
+
+                       data->src_height[num_displays * 2 + j] = bw_int_to_fixed(pipe[i].bottom_pipe->plane_res.scl_data.viewport.height);
+                       data->src_width[num_displays * 2 + j] = bw_int_to_fixed(pipe[i].bottom_pipe->plane_res.scl_data.viewport.width);
+                       data->pitch_in_pixels[num_displays * 2 + j] = bw_int_to_fixed(
+                                       pipe[i].bottom_pipe->plane_state->plane_size.surface_pitch);
+                       data->h_taps[num_displays * 2 + j] = bw_int_to_fixed(pipe[i].bottom_pipe->plane_res.scl_data.taps.h_taps);
+                       data->v_taps[num_displays * 2 + j] = bw_int_to_fixed(pipe[i].bottom_pipe->plane_res.scl_data.taps.v_taps);
+                       data->h_scale_ratio[num_displays * 2 + j] = fixed31_32_to_bw_fixed(
+                                       pipe[i].bottom_pipe->plane_res.scl_data.ratios.horz.value);
+                       data->v_scale_ratio[num_displays * 2 + j] = fixed31_32_to_bw_fixed(
+                                       pipe[i].bottom_pipe->plane_res.scl_data.ratios.vert.value);
+                       switch (pipe[i].bottom_pipe->plane_state->rotation) {
+                       case ROTATION_ANGLE_0:
+                               data->rotation_angle[num_displays * 2 + j] = bw_int_to_fixed(0);
+                               break;
+                       case ROTATION_ANGLE_90:
+                               data->rotation_angle[num_displays * 2 + j] = bw_int_to_fixed(90);
+                               break;
+                       case ROTATION_ANGLE_180:
+                               data->rotation_angle[num_displays * 2 + j] = bw_int_to_fixed(180);
+                               break;
+                       case ROTATION_ANGLE_270:
+                               data->rotation_angle[num_displays * 2 + j] = bw_int_to_fixed(270);
+                               break;
+                       default:
+                               break;
+                       }
+                       data->stereo_mode[num_displays * 2 + j] = bw_def_mono;
+               }
+
+               num_displays++;
+       }
+
+       /* Pipes without underlay after */
+       for (i = 0; i < pipe_count; i++) {
+               unsigned int pixel_clock_100hz;
+               if (!pipe[i].stream || pipe[i].bottom_pipe)
+                       continue;
+
+
+               data->fbc_en[num_displays + 4] = false;
+               data->lpt_en[num_displays + 4] = false;
+               data->h_total[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.h_total);
+               data->v_total[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.v_total);
+               pixel_clock_100hz = pipe[i].stream->timing.pix_clk_100hz;
+               if (pipe[i].stream->timing.timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING)
+                       pixel_clock_100hz *= 2;
+               data->pixel_rate[num_displays + 4] = bw_frc_to_fixed(pixel_clock_100hz, 10000);
+               if (pipe[i].plane_state) {
+                       data->src_width[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.viewport.width);
+                       data->pitch_in_pixels[num_displays + 4] = data->src_width[num_displays + 4];
+                       data->src_height[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.viewport.height);
+                       data->h_taps[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.taps.h_taps);
+                       data->v_taps[num_displays + 4] = bw_int_to_fixed(pipe[i].plane_res.scl_data.taps.v_taps);
+                       data->h_scale_ratio[num_displays + 4] = fixed31_32_to_bw_fixed(pipe[i].plane_res.scl_data.ratios.horz.value);
+                       data->v_scale_ratio[num_displays + 4] = fixed31_32_to_bw_fixed(pipe[i].plane_res.scl_data.ratios.vert.value);
+                       switch (pipe[i].plane_state->rotation) {
+                       case ROTATION_ANGLE_0:
+                               data->rotation_angle[num_displays + 4] = bw_int_to_fixed(0);
+                               break;
+                       case ROTATION_ANGLE_90:
+                               data->rotation_angle[num_displays + 4] = bw_int_to_fixed(90);
+                               break;
+                       case ROTATION_ANGLE_180:
+                               data->rotation_angle[num_displays + 4] = bw_int_to_fixed(180);
+                               break;
+                       case ROTATION_ANGLE_270:
+                               data->rotation_angle[num_displays + 4] = bw_int_to_fixed(270);
+                               break;
+                       default:
+                               break;
+                       }
+                       switch (pipe[i].plane_state->format) {
+                       case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
+                       case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb:
+                       case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555:
+                       case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
+                               data->bytes_per_pixel[num_displays + 4] = 2;
+                               break;
+                       case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
+                       case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+                       case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
+                       case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
+                       case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
+                       case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
+                       case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
+                               data->bytes_per_pixel[num_displays + 4] = 4;
+                               break;
+                       case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
+                       case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616:
+                       case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
+                               data->bytes_per_pixel[num_displays + 4] = 8;
+                               break;
+                       default:
+                               data->bytes_per_pixel[num_displays + 4] = 4;
+                               break;
+                       }
+               } else if (pipe[i].stream->dst.width != 0 &&
+                                       pipe[i].stream->dst.height != 0 &&
+                                       pipe[i].stream->src.width != 0 &&
+                                       pipe[i].stream->src.height != 0) {
+                       data->src_width[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->src.width);
+                       data->pitch_in_pixels[num_displays + 4] = data->src_width[num_displays + 4];
+                       data->src_height[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->src.height);
+                       data->h_taps[num_displays + 4] = pipe[i].stream->src.width == pipe[i].stream->dst.width ? bw_int_to_fixed(1) : bw_int_to_fixed(2);
+                       data->v_taps[num_displays + 4] = pipe[i].stream->src.height == pipe[i].stream->dst.height ? bw_int_to_fixed(1) : bw_int_to_fixed(2);
+                       data->h_scale_ratio[num_displays + 4] = bw_frc_to_fixed(pipe[i].stream->src.width, pipe[i].stream->dst.width);
+                       data->v_scale_ratio[num_displays + 4] = bw_frc_to_fixed(pipe[i].stream->src.height, pipe[i].stream->dst.height);
+                       data->rotation_angle[num_displays + 4] = bw_int_to_fixed(0);
+                       data->bytes_per_pixel[num_displays + 4] = 4;
+               } else {
+                       data->src_width[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.h_addressable);
+                       data->pitch_in_pixels[num_displays + 4] = data->src_width[num_displays + 4];
+                       data->src_height[num_displays + 4] = bw_int_to_fixed(pipe[i].stream->timing.v_addressable);
+                       data->h_taps[num_displays + 4] = bw_int_to_fixed(1);
+                       data->v_taps[num_displays + 4] = bw_int_to_fixed(1);
+                       data->h_scale_ratio[num_displays + 4] = bw_int_to_fixed(1);
+                       data->v_scale_ratio[num_displays + 4] = bw_int_to_fixed(1);
+                       data->rotation_angle[num_displays + 4] = bw_int_to_fixed(0);
+                       data->bytes_per_pixel[num_displays + 4] = 4;
+               }
+
+               data->interlace_mode[num_displays + 4] = false;
+               data->stereo_mode[num_displays + 4] = bw_def_mono;
+               num_displays++;
+       }
+
+       data->number_of_displays = num_displays;
+}
+
+static bool all_displays_in_sync(const struct pipe_ctx pipe[],
+                                int pipe_count)
+{
+       const struct pipe_ctx *active_pipes[MAX_PIPES];
+       int i, num_active_pipes = 0;
+
+       for (i = 0; i < pipe_count; i++) {
+               if (!pipe[i].stream || pipe[i].top_pipe)
+                       continue;
+
+               active_pipes[num_active_pipes++] = &pipe[i];
+       }
+
+       if (!num_active_pipes)
+               return false;
+
+       for (i = 1; i < num_active_pipes; ++i) {
+               if (!resource_are_streams_timing_synchronizable(
+                           active_pipes[0]->stream, active_pipes[i]->stream)) {
+                       return false;
+               }
+       }
+
+       return true;
+}
+
+/*
+ * Return:
+ *     true -  Display(s) configuration supported.
+ *             In this case 'calcs_output' contains data for HW programming
+ *     false - Display(s) configuration not supported (not enough bandwidth).
+ */
+bool bw_calcs(struct dc_context *ctx,
+       const struct bw_calcs_dceip *dceip,
+       const struct bw_calcs_vbios *vbios,
+       const struct pipe_ctx pipe[],
+       int pipe_count,
+       struct dce_bw_output *calcs_output)
+{
+       struct bw_calcs_data *data = kzalloc(sizeof(struct bw_calcs_data),
+                                            GFP_KERNEL);
+       if (!data)
+               return false;
+
+       populate_initial_data(pipe, pipe_count, data);
+
+       if (ctx->dc->config.multi_mon_pp_mclk_switch)
+               calcs_output->all_displays_in_sync = all_displays_in_sync(pipe, pipe_count);
+       else
+               calcs_output->all_displays_in_sync = false;
+
+       if (data->number_of_displays != 0) {
+               uint8_t yclk_lvl;
+               struct bw_fixed high_sclk = vbios->high_sclk;
+               struct bw_fixed mid1_sclk = vbios->mid1_sclk;
+               struct bw_fixed mid2_sclk = vbios->mid2_sclk;
+               struct bw_fixed mid3_sclk = vbios->mid3_sclk;
+               struct bw_fixed mid4_sclk = vbios->mid4_sclk;
+               struct bw_fixed mid5_sclk = vbios->mid5_sclk;
+               struct bw_fixed mid6_sclk = vbios->mid6_sclk;
+               struct bw_fixed low_sclk = vbios->low_sclk;
+               struct bw_fixed high_yclk = vbios->high_yclk;
+               struct bw_fixed mid_yclk = vbios->mid_yclk;
+               struct bw_fixed low_yclk = vbios->low_yclk;
+
+               if (ctx->dc->debug.bandwidth_calcs_trace) {
+                       print_bw_calcs_dceip(ctx, dceip);
+                       print_bw_calcs_vbios(ctx, vbios);
+                       print_bw_calcs_data(ctx, data);
+               }
+               calculate_bandwidth(dceip, vbios, data);
+
+               yclk_lvl = data->y_clk_level;
+
+               calcs_output->nbp_state_change_enable =
+                       data->nbp_state_change_enable;
+               calcs_output->cpuc_state_change_enable =
+                               data->cpuc_state_change_enable;
+               calcs_output->cpup_state_change_enable =
+                               data->cpup_state_change_enable;
+               calcs_output->stutter_mode_enable =
+                               data->stutter_mode_enable;
+               calcs_output->dispclk_khz =
+                       bw_fixed_to_int(bw_mul(data->dispclk,
+                                       bw_int_to_fixed(1000)));
+               calcs_output->blackout_recovery_time_us =
+                       bw_fixed_to_int(data->blackout_recovery_time);
+               calcs_output->sclk_khz =
+                       bw_fixed_to_int(bw_mul(data->required_sclk,
+                                       bw_int_to_fixed(1000)));
+               calcs_output->sclk_deep_sleep_khz =
+                       bw_fixed_to_int(bw_mul(data->sclk_deep_sleep,
+                                       bw_int_to_fixed(1000)));
+               if (yclk_lvl == 0)
+                       calcs_output->yclk_khz = bw_fixed_to_int(
+                               bw_mul(low_yclk, bw_int_to_fixed(1000)));
+               else if (yclk_lvl == 1)
+                       calcs_output->yclk_khz = bw_fixed_to_int(
+                               bw_mul(mid_yclk, bw_int_to_fixed(1000)));
+               else
+                       calcs_output->yclk_khz = bw_fixed_to_int(
+                               bw_mul(high_yclk, bw_int_to_fixed(1000)));
+
+               /* units: nanosecond, 16bit storage. */
+
+               calcs_output->nbp_state_change_wm_ns[0].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               nbp_state_change_watermark[4], bw_int_to_fixed(1000)));
+               calcs_output->nbp_state_change_wm_ns[1].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               nbp_state_change_watermark[5], bw_int_to_fixed(1000)));
+               calcs_output->nbp_state_change_wm_ns[2].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               nbp_state_change_watermark[6], bw_int_to_fixed(1000)));
+
+               if (ctx->dc->caps.max_slave_planes) {
+                       calcs_output->nbp_state_change_wm_ns[3].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       nbp_state_change_watermark[0], bw_int_to_fixed(1000)));
+                       calcs_output->nbp_state_change_wm_ns[4].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                                       nbp_state_change_watermark[1], bw_int_to_fixed(1000)));
+               } else {
+                       calcs_output->nbp_state_change_wm_ns[3].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       nbp_state_change_watermark[7], bw_int_to_fixed(1000)));
+                       calcs_output->nbp_state_change_wm_ns[4].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       nbp_state_change_watermark[8], bw_int_to_fixed(1000)));
+               }
+               calcs_output->nbp_state_change_wm_ns[5].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               nbp_state_change_watermark[9], bw_int_to_fixed(1000)));
+
+
+
+               calcs_output->stutter_exit_wm_ns[0].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_exit_watermark[4], bw_int_to_fixed(1000)));
+               calcs_output->stutter_exit_wm_ns[1].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_exit_watermark[5], bw_int_to_fixed(1000)));
+               calcs_output->stutter_exit_wm_ns[2].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_exit_watermark[6], bw_int_to_fixed(1000)));
+               if (ctx->dc->caps.max_slave_planes) {
+                       calcs_output->stutter_exit_wm_ns[3].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[0], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_exit_wm_ns[4].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[1], bw_int_to_fixed(1000)));
+               } else {
+                       calcs_output->stutter_exit_wm_ns[3].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[7], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_exit_wm_ns[4].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[8], bw_int_to_fixed(1000)));
+               }
+               calcs_output->stutter_exit_wm_ns[5].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_exit_watermark[9], bw_int_to_fixed(1000)));
+
+               calcs_output->stutter_entry_wm_ns[0].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_entry_watermark[4], bw_int_to_fixed(1000)));
+               calcs_output->stutter_entry_wm_ns[1].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_entry_watermark[5], bw_int_to_fixed(1000)));
+               calcs_output->stutter_entry_wm_ns[2].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_entry_watermark[6], bw_int_to_fixed(1000)));
+               if (ctx->dc->caps.max_slave_planes) {
+                       calcs_output->stutter_entry_wm_ns[3].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[0], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_entry_wm_ns[4].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[1], bw_int_to_fixed(1000)));
+               } else {
+                       calcs_output->stutter_entry_wm_ns[3].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[7], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_entry_wm_ns[4].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[8], bw_int_to_fixed(1000)));
+               }
+               calcs_output->stutter_entry_wm_ns[5].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_entry_watermark[9], bw_int_to_fixed(1000)));
+
+               calcs_output->urgent_wm_ns[0].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               urgent_watermark[4], bw_int_to_fixed(1000)));
+               calcs_output->urgent_wm_ns[1].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               urgent_watermark[5], bw_int_to_fixed(1000)));
+               calcs_output->urgent_wm_ns[2].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               urgent_watermark[6], bw_int_to_fixed(1000)));
+               if (ctx->dc->caps.max_slave_planes) {
+                       calcs_output->urgent_wm_ns[3].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[0], bw_int_to_fixed(1000)));
+                       calcs_output->urgent_wm_ns[4].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[1], bw_int_to_fixed(1000)));
+               } else {
+                       calcs_output->urgent_wm_ns[3].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[7], bw_int_to_fixed(1000)));
+                       calcs_output->urgent_wm_ns[4].a_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[8], bw_int_to_fixed(1000)));
+               }
+               calcs_output->urgent_wm_ns[5].a_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               urgent_watermark[9], bw_int_to_fixed(1000)));
+
+               if (dceip->version != BW_CALCS_VERSION_CARRIZO) {
+                       ((struct bw_calcs_vbios *)vbios)->low_sclk = mid3_sclk;
+                       ((struct bw_calcs_vbios *)vbios)->mid1_sclk = mid3_sclk;
+                       ((struct bw_calcs_vbios *)vbios)->mid2_sclk = mid3_sclk;
+                       calculate_bandwidth(dceip, vbios, data);
+
+                       calcs_output->nbp_state_change_wm_ns[0].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       nbp_state_change_watermark[4],bw_int_to_fixed(1000)));
+                       calcs_output->nbp_state_change_wm_ns[1].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       nbp_state_change_watermark[5], bw_int_to_fixed(1000)));
+                       calcs_output->nbp_state_change_wm_ns[2].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       nbp_state_change_watermark[6], bw_int_to_fixed(1000)));
+
+                       if (ctx->dc->caps.max_slave_planes) {
+                               calcs_output->nbp_state_change_wm_ns[3].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               nbp_state_change_watermark[0], bw_int_to_fixed(1000)));
+                               calcs_output->nbp_state_change_wm_ns[4].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               nbp_state_change_watermark[1], bw_int_to_fixed(1000)));
+                       } else {
+                               calcs_output->nbp_state_change_wm_ns[3].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               nbp_state_change_watermark[7], bw_int_to_fixed(1000)));
+                               calcs_output->nbp_state_change_wm_ns[4].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               nbp_state_change_watermark[8], bw_int_to_fixed(1000)));
+                       }
+                       calcs_output->nbp_state_change_wm_ns[5].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       nbp_state_change_watermark[9], bw_int_to_fixed(1000)));
+
+
+
+                       calcs_output->stutter_exit_wm_ns[0].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[4], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_exit_wm_ns[1].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[5], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_exit_wm_ns[2].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[6], bw_int_to_fixed(1000)));
+                       if (ctx->dc->caps.max_slave_planes) {
+                               calcs_output->stutter_exit_wm_ns[3].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               stutter_exit_watermark[0], bw_int_to_fixed(1000)));
+                               calcs_output->stutter_exit_wm_ns[4].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               stutter_exit_watermark[1], bw_int_to_fixed(1000)));
+                       } else {
+                               calcs_output->stutter_exit_wm_ns[3].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               stutter_exit_watermark[7], bw_int_to_fixed(1000)));
+                               calcs_output->stutter_exit_wm_ns[4].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               stutter_exit_watermark[8], bw_int_to_fixed(1000)));
+                       }
+                       calcs_output->stutter_exit_wm_ns[5].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[9], bw_int_to_fixed(1000)));
+
+                       calcs_output->stutter_entry_wm_ns[0].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[4], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_entry_wm_ns[1].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[5], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_entry_wm_ns[2].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[6], bw_int_to_fixed(1000)));
+                       if (ctx->dc->caps.max_slave_planes) {
+                               calcs_output->stutter_entry_wm_ns[3].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               stutter_entry_watermark[0], bw_int_to_fixed(1000)));
+                               calcs_output->stutter_entry_wm_ns[4].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               stutter_entry_watermark[1], bw_int_to_fixed(1000)));
+                       } else {
+                               calcs_output->stutter_entry_wm_ns[3].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               stutter_entry_watermark[7], bw_int_to_fixed(1000)));
+                               calcs_output->stutter_entry_wm_ns[4].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               stutter_entry_watermark[8], bw_int_to_fixed(1000)));
+                       }
+                       calcs_output->stutter_entry_wm_ns[5].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[9], bw_int_to_fixed(1000)));
+
+                       calcs_output->urgent_wm_ns[0].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[4], bw_int_to_fixed(1000)));
+                       calcs_output->urgent_wm_ns[1].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[5], bw_int_to_fixed(1000)));
+                       calcs_output->urgent_wm_ns[2].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[6], bw_int_to_fixed(1000)));
+                       if (ctx->dc->caps.max_slave_planes) {
+                               calcs_output->urgent_wm_ns[3].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               urgent_watermark[0], bw_int_to_fixed(1000)));
+                               calcs_output->urgent_wm_ns[4].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               urgent_watermark[1], bw_int_to_fixed(1000)));
+                       } else {
+                               calcs_output->urgent_wm_ns[3].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               urgent_watermark[7], bw_int_to_fixed(1000)));
+                               calcs_output->urgent_wm_ns[4].b_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               urgent_watermark[8], bw_int_to_fixed(1000)));
+                       }
+                       calcs_output->urgent_wm_ns[5].b_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[9], bw_int_to_fixed(1000)));
+
+                       ((struct bw_calcs_vbios *)vbios)->low_sclk = low_sclk;
+                       ((struct bw_calcs_vbios *)vbios)->mid1_sclk = mid1_sclk;
+                       ((struct bw_calcs_vbios *)vbios)->mid2_sclk = mid2_sclk;
+                       ((struct bw_calcs_vbios *)vbios)->low_yclk = mid_yclk;
+                       calculate_bandwidth(dceip, vbios, data);
+
+                       calcs_output->nbp_state_change_wm_ns[0].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       nbp_state_change_watermark[4], bw_int_to_fixed(1000)));
+                       calcs_output->nbp_state_change_wm_ns[1].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       nbp_state_change_watermark[5], bw_int_to_fixed(1000)));
+                       calcs_output->nbp_state_change_wm_ns[2].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       nbp_state_change_watermark[6], bw_int_to_fixed(1000)));
+                       if (ctx->dc->caps.max_slave_planes) {
+                               calcs_output->nbp_state_change_wm_ns[3].c_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               nbp_state_change_watermark[0], bw_int_to_fixed(1000)));
+                               calcs_output->nbp_state_change_wm_ns[4].c_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               nbp_state_change_watermark[1], bw_int_to_fixed(1000)));
+                       } else {
+                               calcs_output->nbp_state_change_wm_ns[3].c_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               nbp_state_change_watermark[7], bw_int_to_fixed(1000)));
+                               calcs_output->nbp_state_change_wm_ns[4].c_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               nbp_state_change_watermark[8], bw_int_to_fixed(1000)));
+                       }
+                       calcs_output->nbp_state_change_wm_ns[5].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       nbp_state_change_watermark[9], bw_int_to_fixed(1000)));
+
+
+                       calcs_output->stutter_exit_wm_ns[0].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[4], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_exit_wm_ns[1].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[5], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_exit_wm_ns[2].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[6], bw_int_to_fixed(1000)));
+                       if (ctx->dc->caps.max_slave_planes) {
+                               calcs_output->stutter_exit_wm_ns[3].c_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               stutter_exit_watermark[0], bw_int_to_fixed(1000)));
+                               calcs_output->stutter_exit_wm_ns[4].c_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               stutter_exit_watermark[1], bw_int_to_fixed(1000)));
+                       } else {
+                               calcs_output->stutter_exit_wm_ns[3].c_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               stutter_exit_watermark[7], bw_int_to_fixed(1000)));
+                               calcs_output->stutter_exit_wm_ns[4].c_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               stutter_exit_watermark[8], bw_int_to_fixed(1000)));
+                       }
+                       calcs_output->stutter_exit_wm_ns[5].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[9], bw_int_to_fixed(1000)));
+
+               calcs_output->stutter_entry_wm_ns[0].c_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_entry_watermark[4], bw_int_to_fixed(1000)));
+               calcs_output->stutter_entry_wm_ns[1].c_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_entry_watermark[5], bw_int_to_fixed(1000)));
+               calcs_output->stutter_entry_wm_ns[2].c_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_entry_watermark[6], bw_int_to_fixed(1000)));
+               if (ctx->dc->caps.max_slave_planes) {
+                       calcs_output->stutter_entry_wm_ns[3].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[0], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_entry_wm_ns[4].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[1], bw_int_to_fixed(1000)));
+               } else {
+                       calcs_output->stutter_entry_wm_ns[3].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[7], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_entry_wm_ns[4].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[8], bw_int_to_fixed(1000)));
+               }
+               calcs_output->stutter_entry_wm_ns[5].c_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_entry_watermark[9], bw_int_to_fixed(1000)));
+
+                       calcs_output->urgent_wm_ns[0].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[4], bw_int_to_fixed(1000)));
+                       calcs_output->urgent_wm_ns[1].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[5], bw_int_to_fixed(1000)));
+                       calcs_output->urgent_wm_ns[2].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[6], bw_int_to_fixed(1000)));
+                       if (ctx->dc->caps.max_slave_planes) {
+                               calcs_output->urgent_wm_ns[3].c_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               urgent_watermark[0], bw_int_to_fixed(1000)));
+                               calcs_output->urgent_wm_ns[4].c_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               urgent_watermark[1], bw_int_to_fixed(1000)));
+                       } else {
+                               calcs_output->urgent_wm_ns[3].c_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               urgent_watermark[7], bw_int_to_fixed(1000)));
+                               calcs_output->urgent_wm_ns[4].c_mark =
+                                       bw_fixed_to_int(bw_mul(data->
+                                               urgent_watermark[8], bw_int_to_fixed(1000)));
+                       }
+                       calcs_output->urgent_wm_ns[5].c_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[9], bw_int_to_fixed(1000)));
+               }
+
+               if (dceip->version == BW_CALCS_VERSION_CARRIZO) {
+                       ((struct bw_calcs_vbios *)vbios)->low_yclk = high_yclk;
+                       ((struct bw_calcs_vbios *)vbios)->mid_yclk = high_yclk;
+                       ((struct bw_calcs_vbios *)vbios)->low_sclk = high_sclk;
+                       ((struct bw_calcs_vbios *)vbios)->mid1_sclk = high_sclk;
+                       ((struct bw_calcs_vbios *)vbios)->mid2_sclk = high_sclk;
+                       ((struct bw_calcs_vbios *)vbios)->mid3_sclk = high_sclk;
+                       ((struct bw_calcs_vbios *)vbios)->mid4_sclk = high_sclk;
+                       ((struct bw_calcs_vbios *)vbios)->mid5_sclk = high_sclk;
+                       ((struct bw_calcs_vbios *)vbios)->mid6_sclk = high_sclk;
+               } else {
+                       ((struct bw_calcs_vbios *)vbios)->low_yclk = mid_yclk;
+                       ((struct bw_calcs_vbios *)vbios)->low_sclk = mid3_sclk;
+                       ((struct bw_calcs_vbios *)vbios)->mid1_sclk = mid3_sclk;
+                       ((struct bw_calcs_vbios *)vbios)->mid2_sclk = mid3_sclk;
+               }
+
+               calculate_bandwidth(dceip, vbios, data);
+
+               calcs_output->nbp_state_change_wm_ns[0].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               nbp_state_change_watermark[4], bw_int_to_fixed(1000)));
+               calcs_output->nbp_state_change_wm_ns[1].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               nbp_state_change_watermark[5], bw_int_to_fixed(1000)));
+               calcs_output->nbp_state_change_wm_ns[2].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               nbp_state_change_watermark[6], bw_int_to_fixed(1000)));
+               if (ctx->dc->caps.max_slave_planes) {
+                       calcs_output->nbp_state_change_wm_ns[3].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       nbp_state_change_watermark[0], bw_int_to_fixed(1000)));
+                       calcs_output->nbp_state_change_wm_ns[4].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       nbp_state_change_watermark[1], bw_int_to_fixed(1000)));
+               } else {
+                       calcs_output->nbp_state_change_wm_ns[3].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       nbp_state_change_watermark[7], bw_int_to_fixed(1000)));
+                       calcs_output->nbp_state_change_wm_ns[4].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       nbp_state_change_watermark[8], bw_int_to_fixed(1000)));
+               }
+               calcs_output->nbp_state_change_wm_ns[5].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               nbp_state_change_watermark[9], bw_int_to_fixed(1000)));
+
+               calcs_output->stutter_exit_wm_ns[0].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_exit_watermark[4], bw_int_to_fixed(1000)));
+               calcs_output->stutter_exit_wm_ns[1].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_exit_watermark[5], bw_int_to_fixed(1000)));
+               calcs_output->stutter_exit_wm_ns[2].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_exit_watermark[6], bw_int_to_fixed(1000)));
+               if (ctx->dc->caps.max_slave_planes) {
+                       calcs_output->stutter_exit_wm_ns[3].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[0], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_exit_wm_ns[4].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[1], bw_int_to_fixed(1000)));
+               } else {
+                       calcs_output->stutter_exit_wm_ns[3].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[7], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_exit_wm_ns[4].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_exit_watermark[8], bw_int_to_fixed(1000)));
+               }
+               calcs_output->stutter_exit_wm_ns[5].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_exit_watermark[9], bw_int_to_fixed(1000)));
+
+               calcs_output->stutter_entry_wm_ns[0].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_entry_watermark[4], bw_int_to_fixed(1000)));
+               calcs_output->stutter_entry_wm_ns[1].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_entry_watermark[5], bw_int_to_fixed(1000)));
+               calcs_output->stutter_entry_wm_ns[2].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_entry_watermark[6], bw_int_to_fixed(1000)));
+               if (ctx->dc->caps.max_slave_planes) {
+                       calcs_output->stutter_entry_wm_ns[3].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[0], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_entry_wm_ns[4].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[1], bw_int_to_fixed(1000)));
+               } else {
+                       calcs_output->stutter_entry_wm_ns[3].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[7], bw_int_to_fixed(1000)));
+                       calcs_output->stutter_entry_wm_ns[4].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       stutter_entry_watermark[8], bw_int_to_fixed(1000)));
+               }
+               calcs_output->stutter_entry_wm_ns[5].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               stutter_entry_watermark[9], bw_int_to_fixed(1000)));
+
+               calcs_output->urgent_wm_ns[0].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               urgent_watermark[4], bw_int_to_fixed(1000)));
+               calcs_output->urgent_wm_ns[1].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               urgent_watermark[5], bw_int_to_fixed(1000)));
+               calcs_output->urgent_wm_ns[2].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               urgent_watermark[6], bw_int_to_fixed(1000)));
+               if (ctx->dc->caps.max_slave_planes) {
+                       calcs_output->urgent_wm_ns[3].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[0], bw_int_to_fixed(1000)));
+                       calcs_output->urgent_wm_ns[4].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[1], bw_int_to_fixed(1000)));
+               } else {
+                       calcs_output->urgent_wm_ns[3].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[7], bw_int_to_fixed(1000)));
+                       calcs_output->urgent_wm_ns[4].d_mark =
+                               bw_fixed_to_int(bw_mul(data->
+                                       urgent_watermark[8], bw_int_to_fixed(1000)));
+               }
+               calcs_output->urgent_wm_ns[5].d_mark =
+                       bw_fixed_to_int(bw_mul(data->
+                               urgent_watermark[9], bw_int_to_fixed(1000)));
+
+               ((struct bw_calcs_vbios *)vbios)->low_yclk = low_yclk;
+               ((struct bw_calcs_vbios *)vbios)->mid_yclk = mid_yclk;
+               ((struct bw_calcs_vbios *)vbios)->low_sclk = low_sclk;
+               ((struct bw_calcs_vbios *)vbios)->mid1_sclk = mid1_sclk;
+               ((struct bw_calcs_vbios *)vbios)->mid2_sclk = mid2_sclk;
+               ((struct bw_calcs_vbios *)vbios)->mid3_sclk = mid3_sclk;
+               ((struct bw_calcs_vbios *)vbios)->mid4_sclk = mid4_sclk;
+               ((struct bw_calcs_vbios *)vbios)->mid5_sclk = mid5_sclk;
+               ((struct bw_calcs_vbios *)vbios)->mid6_sclk = mid6_sclk;
+               ((struct bw_calcs_vbios *)vbios)->high_sclk = high_sclk;
+       } else {
+               calcs_output->nbp_state_change_enable = true;
+               calcs_output->cpuc_state_change_enable = true;
+               calcs_output->cpup_state_change_enable = true;
+               calcs_output->stutter_mode_enable = true;
+               calcs_output->dispclk_khz = 0;
+               calcs_output->sclk_khz = 0;
+       }
+
+       kfree(data);
+
+       return is_display_configuration_supported(vbios, calcs_output);
+}
diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_auto.c b/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_auto.c
new file mode 100644 (file)
index 0000000..41284e2
--- /dev/null
@@ -0,0 +1,1933 @@
+/*
+ * Copyright 2017 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
+#include "dm_services.h"
+#include "dcn_calc_auto.h"
+#include "dcn_calc_math.h"
+
+/*
+ * NOTE:
+ *   This file is gcc-parseable HW gospel, coming straight from HW engineers.
+ *
+ * It doesn't adhere to Linux kernel style and sometimes will do things in odd
+ * ways. Unless there is something clearly wrong with it the code should
+ * remain as-is as it provides us with a guarantee from HW that it is correct.
+ */
+
+/*REVISION#250*/
+void scaler_settings_calculation(struct dcn_bw_internal_vars *v)
+{
+       int k;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->allow_different_hratio_vratio == dcn_bw_yes) {
+                       if (v->source_scan[k] == dcn_bw_hor) {
+                               v->h_ratio[k] = v->viewport_width[k] / v->scaler_rec_out_width[k];
+                               v->v_ratio[k] = v->viewport_height[k] / v->scaler_recout_height[k];
+                       }
+                       else {
+                               v->h_ratio[k] = v->viewport_height[k] / v->scaler_rec_out_width[k];
+                               v->v_ratio[k] = v->viewport_width[k] / v->scaler_recout_height[k];
+                       }
+               }
+               else {
+                       if (v->source_scan[k] == dcn_bw_hor) {
+                               v->h_ratio[k] =dcn_bw_max2(v->viewport_width[k] / v->scaler_rec_out_width[k], v->viewport_height[k] / v->scaler_recout_height[k]);
+                       }
+                       else {
+                               v->h_ratio[k] =dcn_bw_max2(v->viewport_height[k] / v->scaler_rec_out_width[k], v->viewport_width[k] / v->scaler_recout_height[k]);
+                       }
+                       v->v_ratio[k] = v->h_ratio[k];
+               }
+               if (v->interlace_output[k] == 1.0) {
+                       v->v_ratio[k] = 2.0 * v->v_ratio[k];
+               }
+               if (v->underscan_output[k] == 1.0) {
+                       v->h_ratio[k] = v->h_ratio[k] * v->under_scan_factor;
+                       v->v_ratio[k] = v->v_ratio[k] * v->under_scan_factor;
+               }
+       }
+       /*scaler taps calculation*/
+
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->h_ratio[k] > 1.0) {
+                       v->acceptable_quality_hta_ps =dcn_bw_min2(v->max_hscl_taps, 2.0 *dcn_bw_ceil2(v->h_ratio[k], 1.0));
+               }
+               else if (v->h_ratio[k] < 1.0) {
+                       v->acceptable_quality_hta_ps = 4.0;
+               }
+               else {
+                       v->acceptable_quality_hta_ps = 1.0;
+               }
+               if (v->ta_pscalculation == dcn_bw_override) {
+                       v->htaps[k] = v->override_hta_ps[k];
+               }
+               else {
+                       v->htaps[k] = v->acceptable_quality_hta_ps;
+               }
+               if (v->v_ratio[k] > 1.0) {
+                       v->acceptable_quality_vta_ps =dcn_bw_min2(v->max_vscl_taps, 2.0 *dcn_bw_ceil2(v->v_ratio[k], 1.0));
+               }
+               else if (v->v_ratio[k] < 1.0) {
+                       v->acceptable_quality_vta_ps = 4.0;
+               }
+               else {
+                       v->acceptable_quality_vta_ps = 1.0;
+               }
+               if (v->ta_pscalculation == dcn_bw_override) {
+                       v->vtaps[k] = v->override_vta_ps[k];
+               }
+               else {
+                       v->vtaps[k] = v->acceptable_quality_vta_ps;
+               }
+               if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64 || v->source_pixel_format[k] == dcn_bw_rgb_sub_32 || v->source_pixel_format[k] == dcn_bw_rgb_sub_16) {
+                       v->vta_pschroma[k] = 0.0;
+                       v->hta_pschroma[k] = 0.0;
+               }
+               else {
+                       if (v->ta_pscalculation == dcn_bw_override) {
+                               v->vta_pschroma[k] = v->override_vta_pschroma[k];
+                               v->hta_pschroma[k] = v->override_hta_pschroma[k];
+                       }
+                       else {
+                               v->vta_pschroma[k] = v->acceptable_quality_vta_ps;
+                               v->hta_pschroma[k] = v->acceptable_quality_hta_ps;
+                       }
+               }
+       }
+}
+
+void mode_support_and_system_configuration(struct dcn_bw_internal_vars *v)
+{
+       int i;
+       int j;
+       int k;
+       /*mode support, voltage state and soc configuration*/
+
+       /*scale ratio support check*/
+
+       v->scale_ratio_support = dcn_bw_yes;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->h_ratio[k] > v->max_hscl_ratio || v->v_ratio[k] > v->max_vscl_ratio || v->h_ratio[k] > v->htaps[k] || v->v_ratio[k] > v->vtaps[k] || (v->source_pixel_format[k] != dcn_bw_rgb_sub_64 && v->source_pixel_format[k] != dcn_bw_rgb_sub_32 && v->source_pixel_format[k] != dcn_bw_rgb_sub_16 && (v->h_ratio[k] / 2.0 > v->hta_pschroma[k] || v->v_ratio[k] / 2.0 > v->vta_pschroma[k]))) {
+                       v->scale_ratio_support = dcn_bw_no;
+               }
+       }
+       /*source format, pixel format and scan support check*/
+
+       v->source_format_pixel_and_scan_support = dcn_bw_yes;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if ((v->source_surface_mode[k] == dcn_bw_sw_linear && v->source_scan[k] != dcn_bw_hor) || ((v->source_surface_mode[k] == dcn_bw_sw_4_kb_d || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_x || v->source_surface_mode[k] == dcn_bw_sw_var_d || v->source_surface_mode[k] == dcn_bw_sw_var_d_x) && v->source_pixel_format[k] != dcn_bw_rgb_sub_64)) {
+                       v->source_format_pixel_and_scan_support = dcn_bw_no;
+               }
+       }
+       /*bandwidth support check*/
+
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->source_scan[k] == dcn_bw_hor) {
+                       v->swath_width_ysingle_dpp[k] = v->viewport_width[k];
+               }
+               else {
+                       v->swath_width_ysingle_dpp[k] = v->viewport_height[k];
+               }
+               if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
+                       v->byte_per_pixel_in_dety[k] = 8.0;
+                       v->byte_per_pixel_in_detc[k] = 0.0;
+               }
+               else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_32) {
+                       v->byte_per_pixel_in_dety[k] = 4.0;
+                       v->byte_per_pixel_in_detc[k] = 0.0;
+               }
+               else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_16) {
+                       v->byte_per_pixel_in_dety[k] = 2.0;
+                       v->byte_per_pixel_in_detc[k] = 0.0;
+               }
+               else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
+                       v->byte_per_pixel_in_dety[k] = 1.0;
+                       v->byte_per_pixel_in_detc[k] = 2.0;
+               }
+               else {
+                       v->byte_per_pixel_in_dety[k] = 4.0f / 3.0f;
+                       v->byte_per_pixel_in_detc[k] = 8.0f / 3.0f;
+               }
+       }
+       v->total_read_bandwidth_consumed_gbyte_per_second = 0.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               v->read_bandwidth[k] = v->swath_width_ysingle_dpp[k] * (dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) * v->v_ratio[k] +dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 2.0 * v->v_ratio[k] / 2) / (v->htotal[k] / v->pixel_clock[k]);
+               if (v->dcc_enable[k] == dcn_bw_yes) {
+                       v->read_bandwidth[k] = v->read_bandwidth[k] * (1 + 1 / 256);
+               }
+               if (v->pte_enable == dcn_bw_yes && v->source_scan[k] != dcn_bw_hor && (v->source_surface_mode[k] == dcn_bw_sw_4_kb_s || v->source_surface_mode[k] == dcn_bw_sw_4_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d_x)) {
+                       v->read_bandwidth[k] = v->read_bandwidth[k] * (1 + 1 / 64);
+               }
+               else if (v->pte_enable == dcn_bw_yes && v->source_scan[k] == dcn_bw_hor && (v->source_pixel_format[k] == dcn_bw_rgb_sub_64 || v->source_pixel_format[k] == dcn_bw_rgb_sub_32) && (v->source_surface_mode[k] == dcn_bw_sw_64_kb_s || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_x)) {
+                       v->read_bandwidth[k] = v->read_bandwidth[k] * (1 + 1 / 256);
+               }
+               else if (v->pte_enable == dcn_bw_yes) {
+                       v->read_bandwidth[k] = v->read_bandwidth[k] * (1 + 1 / 512);
+               }
+               v->total_read_bandwidth_consumed_gbyte_per_second = v->total_read_bandwidth_consumed_gbyte_per_second + v->read_bandwidth[k] / 1000.0;
+       }
+       v->total_write_bandwidth_consumed_gbyte_per_second = 0.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->output[k] == dcn_bw_writeback && v->output_format[k] == dcn_bw_444) {
+                       v->write_bandwidth[k] = v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) * 4.0;
+               }
+               else if (v->output[k] == dcn_bw_writeback) {
+                       v->write_bandwidth[k] = v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) * 1.5;
+               }
+               else {
+                       v->write_bandwidth[k] = 0.0;
+               }
+               v->total_write_bandwidth_consumed_gbyte_per_second = v->total_write_bandwidth_consumed_gbyte_per_second + v->write_bandwidth[k] / 1000.0;
+       }
+       v->total_bandwidth_consumed_gbyte_per_second = v->total_read_bandwidth_consumed_gbyte_per_second + v->total_write_bandwidth_consumed_gbyte_per_second;
+       v->dcc_enabled_in_any_plane = dcn_bw_no;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->dcc_enable[k] == dcn_bw_yes) {
+                       v->dcc_enabled_in_any_plane = dcn_bw_yes;
+               }
+       }
+       for (i = 0; i <= number_of_states_plus_one; i++) {
+               v->return_bw_todcn_per_state =dcn_bw_min2(v->return_bus_width * v->dcfclk_per_state[i], v->fabric_and_dram_bandwidth_per_state[i] * 1000.0 * v->percent_of_ideal_drambw_received_after_urg_latency / 100.0);
+               v->return_bw_per_state[i] = v->return_bw_todcn_per_state;
+               if (v->dcc_enabled_in_any_plane == dcn_bw_yes && v->return_bw_todcn_per_state > v->dcfclk_per_state[i] * v->return_bus_width / 4.0) {
+                       v->return_bw_per_state[i] =dcn_bw_min2(v->return_bw_per_state[i], v->return_bw_todcn_per_state * 4.0 * (1.0 - v->urgent_latency / ((v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 / (v->return_bw_todcn_per_state - v->dcfclk_per_state[i] * v->return_bus_width / 4.0) + v->urgent_latency)));
+               }
+               v->critical_point = 2.0 * v->return_bus_width * v->dcfclk_per_state[i] * v->urgent_latency / (v->return_bw_todcn_per_state * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0);
+               if (v->dcc_enabled_in_any_plane == dcn_bw_yes && v->critical_point > 1.0 && v->critical_point < 4.0) {
+                       v->return_bw_per_state[i] =dcn_bw_min2(v->return_bw_per_state[i], dcn_bw_pow(4.0 * v->return_bw_todcn_per_state * (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 * v->return_bus_width * v->dcfclk_per_state[i] * v->urgent_latency / (v->return_bw_todcn_per_state * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0), 2));
+               }
+               v->return_bw_todcn_per_state =dcn_bw_min2(v->return_bus_width * v->dcfclk_per_state[i], v->fabric_and_dram_bandwidth_per_state[i] * 1000.0);
+               if (v->dcc_enabled_in_any_plane == dcn_bw_yes && v->return_bw_todcn_per_state > v->dcfclk_per_state[i] * v->return_bus_width / 4.0) {
+                       v->return_bw_per_state[i] =dcn_bw_min2(v->return_bw_per_state[i], v->return_bw_todcn_per_state * 4.0 * (1.0 - v->urgent_latency / ((v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 / (v->return_bw_todcn_per_state - v->dcfclk_per_state[i] * v->return_bus_width / 4.0) + v->urgent_latency)));
+               }
+               v->critical_point = 2.0 * v->return_bus_width * v->dcfclk_per_state[i] * v->urgent_latency / (v->return_bw_todcn_per_state * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0);
+               if (v->dcc_enabled_in_any_plane == dcn_bw_yes && v->critical_point > 1.0 && v->critical_point < 4.0) {
+                       v->return_bw_per_state[i] =dcn_bw_min2(v->return_bw_per_state[i], dcn_bw_pow(4.0 * v->return_bw_todcn_per_state * (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 * v->return_bus_width * v->dcfclk_per_state[i] * v->urgent_latency / (v->return_bw_todcn_per_state * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0), 2));
+               }
+       }
+       for (i = 0; i <= number_of_states_plus_one; i++) {
+               if ((v->total_read_bandwidth_consumed_gbyte_per_second * 1000.0 <= v->return_bw_per_state[i]) && (v->total_bandwidth_consumed_gbyte_per_second * 1000.0 <= v->fabric_and_dram_bandwidth_per_state[i] * 1000.0 * v->percent_of_ideal_drambw_received_after_urg_latency / 100.0)) {
+                       v->bandwidth_support[i] = dcn_bw_yes;
+               }
+               else {
+                       v->bandwidth_support[i] = dcn_bw_no;
+               }
+       }
+       /*writeback latency support check*/
+
+       v->writeback_latency_support = dcn_bw_yes;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->output[k] == dcn_bw_writeback && v->output_format[k] == dcn_bw_444 && v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) * 4.0 > (v->writeback_luma_buffer_size + v->writeback_chroma_buffer_size) * 1024.0 / v->write_back_latency) {
+                       v->writeback_latency_support = dcn_bw_no;
+               }
+               else if (v->output[k] == dcn_bw_writeback && v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) >dcn_bw_min2(v->writeback_luma_buffer_size, 2.0 * v->writeback_chroma_buffer_size) * 1024.0 / v->write_back_latency) {
+                       v->writeback_latency_support = dcn_bw_no;
+               }
+       }
+       /*re-ordering buffer support check*/
+
+       for (i = 0; i <= number_of_states_plus_one; i++) {
+               v->urgent_round_trip_and_out_of_order_latency_per_state[i] = (v->round_trip_ping_latency_cycles + 32.0) / v->dcfclk_per_state[i] + v->urgent_out_of_order_return_per_channel * v->number_of_channels / v->return_bw_per_state[i];
+               if ((v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 / v->return_bw_per_state[i] > v->urgent_round_trip_and_out_of_order_latency_per_state[i]) {
+                       v->rob_support[i] = dcn_bw_yes;
+               }
+               else {
+                       v->rob_support[i] = dcn_bw_no;
+               }
+       }
+       /*display io support check*/
+
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->output[k] == dcn_bw_dp && v->dsc_capability == dcn_bw_yes) {
+                       if (v->output_format[k] == dcn_bw_420) {
+                               v->required_output_bw = v->pixel_clock[k] / 2.0;
+                       }
+                       else {
+                               v->required_output_bw = v->pixel_clock[k];
+                       }
+               }
+               else if (v->output_format[k] == dcn_bw_420) {
+                       v->required_output_bw = v->pixel_clock[k] * 3.0 / 2.0;
+               }
+               else {
+                       v->required_output_bw = v->pixel_clock[k] * 3.0;
+               }
+               if (v->output[k] == dcn_bw_hdmi) {
+                       v->required_phyclk[k] = v->required_output_bw;
+                       switch (v->output_deep_color[k]) {
+                       case dcn_bw_encoder_10bpc:
+                               v->required_phyclk[k] =  v->required_phyclk[k] * 5.0 / 4;
+                       break;
+                       case dcn_bw_encoder_12bpc:
+                               v->required_phyclk[k] =  v->required_phyclk[k] * 3.0 / 2;
+                               break;
+                       default:
+                               break;
+                       }
+                       v->required_phyclk[k] = v->required_phyclk[k] / 3.0;
+               }
+               else if (v->output[k] == dcn_bw_dp) {
+                       v->required_phyclk[k] = v->required_output_bw / 4.0;
+               }
+               else {
+                       v->required_phyclk[k] = 0.0;
+               }
+       }
+       for (i = 0; i <= number_of_states_plus_one; i++) {
+               v->dio_support[i] = dcn_bw_yes;
+               for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                       if (v->required_phyclk[k] > v->phyclk_per_state[i] || (v->output[k] == dcn_bw_hdmi && v->required_phyclk[k] > 600.0)) {
+                               v->dio_support[i] = dcn_bw_no;
+                       }
+               }
+       }
+       /*total available writeback support check*/
+
+       v->total_number_of_active_writeback = 0.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->output[k] == dcn_bw_writeback) {
+                       v->total_number_of_active_writeback = v->total_number_of_active_writeback + 1.0;
+               }
+       }
+       if (v->total_number_of_active_writeback <= v->max_num_writeback) {
+               v->total_available_writeback_support = dcn_bw_yes;
+       }
+       else {
+               v->total_available_writeback_support = dcn_bw_no;
+       }
+       /*maximum dispclk/dppclk support check*/
+
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->h_ratio[k] > 1.0) {
+                       v->pscl_factor[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput * v->h_ratio[k] /dcn_bw_ceil2(v->htaps[k] / 6.0, 1.0));
+               }
+               else {
+                       v->pscl_factor[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput);
+               }
+               if (v->byte_per_pixel_in_detc[k] == 0.0) {
+                       v->pscl_factor_chroma[k] = 0.0;
+                       v->min_dppclk_using_single_dpp[k] = v->pixel_clock[k] *dcn_bw_max3(v->vtaps[k] / 6.0 *dcn_bw_min2(1.0, v->h_ratio[k]), v->h_ratio[k] * v->v_ratio[k] / v->pscl_factor[k], 1.0);
+               }
+               else {
+                       if (v->h_ratio[k] / 2.0 > 1.0) {
+                               v->pscl_factor_chroma[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput * v->h_ratio[k] / 2.0 /dcn_bw_ceil2(v->hta_pschroma[k] / 6.0, 1.0));
+                       }
+                       else {
+                               v->pscl_factor_chroma[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput);
+                       }
+                       v->min_dppclk_using_single_dpp[k] = v->pixel_clock[k] *dcn_bw_max5(v->vtaps[k] / 6.0 *dcn_bw_min2(1.0, v->h_ratio[k]), v->h_ratio[k] * v->v_ratio[k] / v->pscl_factor[k], v->vta_pschroma[k] / 6.0 *dcn_bw_min2(1.0, v->h_ratio[k] / 2.0), v->h_ratio[k] * v->v_ratio[k] / 4.0 / v->pscl_factor_chroma[k], 1.0);
+               }
+       }
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if ((v->source_pixel_format[k] == dcn_bw_rgb_sub_64 || v->source_pixel_format[k] == dcn_bw_rgb_sub_32 || v->source_pixel_format[k] == dcn_bw_rgb_sub_16)) {
+                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                               v->read256_block_height_y[k] = 1.0;
+                       }
+                       else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
+                               v->read256_block_height_y[k] = 4.0;
+                       }
+                       else {
+                               v->read256_block_height_y[k] = 8.0;
+                       }
+                       v->read256_block_width_y[k] = 256.0 /dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / v->read256_block_height_y[k];
+                       v->read256_block_height_c[k] = 0.0;
+                       v->read256_block_width_c[k] = 0.0;
+               }
+               else {
+                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                               v->read256_block_height_y[k] = 1.0;
+                               v->read256_block_height_c[k] = 1.0;
+                       }
+                       else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
+                               v->read256_block_height_y[k] = 16.0;
+                               v->read256_block_height_c[k] = 8.0;
+                       }
+                       else {
+                               v->read256_block_height_y[k] = 8.0;
+                               v->read256_block_height_c[k] = 8.0;
+                       }
+                       v->read256_block_width_y[k] = 256.0 /dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / v->read256_block_height_y[k];
+                       v->read256_block_width_c[k] = 256.0 /dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / v->read256_block_height_c[k];
+               }
+               if (v->source_scan[k] == dcn_bw_hor) {
+                       v->max_swath_height_y[k] = v->read256_block_height_y[k];
+                       v->max_swath_height_c[k] = v->read256_block_height_c[k];
+               }
+               else {
+                       v->max_swath_height_y[k] = v->read256_block_width_y[k];
+                       v->max_swath_height_c[k] = v->read256_block_width_c[k];
+               }
+               if ((v->source_pixel_format[k] == dcn_bw_rgb_sub_64 || v->source_pixel_format[k] == dcn_bw_rgb_sub_32 || v->source_pixel_format[k] == dcn_bw_rgb_sub_16)) {
+                       if (v->source_surface_mode[k] == dcn_bw_sw_linear || (v->source_pixel_format[k] == dcn_bw_rgb_sub_64 && (v->source_surface_mode[k] == dcn_bw_sw_4_kb_s || v->source_surface_mode[k] == dcn_bw_sw_4_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_var_s || v->source_surface_mode[k] == dcn_bw_sw_var_s_x) && v->source_scan[k] == dcn_bw_hor)) {
+                               v->min_swath_height_y[k] = v->max_swath_height_y[k];
+                       }
+                       else {
+                               v->min_swath_height_y[k] = v->max_swath_height_y[k] / 2.0;
+                       }
+                       v->min_swath_height_c[k] = v->max_swath_height_c[k];
+               }
+               else {
+                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                               v->min_swath_height_y[k] = v->max_swath_height_y[k];
+                               v->min_swath_height_c[k] = v->max_swath_height_c[k];
+                       }
+                       else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8 && v->source_scan[k] == dcn_bw_hor) {
+                               v->min_swath_height_y[k] = v->max_swath_height_y[k] / 2.0;
+                               if (v->bug_forcing_luma_and_chroma_request_to_same_size_fixed == dcn_bw_yes) {
+                                       v->min_swath_height_c[k] = v->max_swath_height_c[k];
+                               }
+                               else {
+                                       v->min_swath_height_c[k] = v->max_swath_height_c[k] / 2.0;
+                               }
+                       }
+                       else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10 && v->source_scan[k] == dcn_bw_hor) {
+                               v->min_swath_height_c[k] = v->max_swath_height_c[k] / 2.0;
+                               if (v->bug_forcing_luma_and_chroma_request_to_same_size_fixed == dcn_bw_yes) {
+                                       v->min_swath_height_y[k] = v->max_swath_height_y[k];
+                               }
+                               else {
+                                       v->min_swath_height_y[k] = v->max_swath_height_y[k] / 2.0;
+                               }
+                       }
+                       else {
+                               v->min_swath_height_y[k] = v->max_swath_height_y[k];
+                               v->min_swath_height_c[k] = v->max_swath_height_c[k];
+                       }
+               }
+               if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                       v->maximum_swath_width = 8192.0;
+               }
+               else {
+                       v->maximum_swath_width = 5120.0;
+               }
+               v->number_of_dpp_required_for_det_size =dcn_bw_ceil2(v->swath_width_ysingle_dpp[k] /dcn_bw_min2(v->maximum_swath_width, v->det_buffer_size_in_kbyte * 1024.0 / 2.0 / (v->byte_per_pixel_in_dety[k] * v->min_swath_height_y[k] + v->byte_per_pixel_in_detc[k] / 2.0 * v->min_swath_height_c[k])), 1.0);
+               if (v->byte_per_pixel_in_detc[k] == 0.0) {
+                       v->number_of_dpp_required_for_lb_size =dcn_bw_ceil2((v->vtaps[k] +dcn_bw_max2(dcn_bw_ceil2(v->v_ratio[k], 1.0) - 2, 0.0)) * v->swath_width_ysingle_dpp[k] /dcn_bw_max2(v->h_ratio[k], 1.0) * v->lb_bit_per_pixel[k] / v->line_buffer_size, 1.0);
+               }
+               else {
+                       v->number_of_dpp_required_for_lb_size =dcn_bw_max2(dcn_bw_ceil2((v->vtaps[k] +dcn_bw_max2(dcn_bw_ceil2(v->v_ratio[k], 1.0) - 2, 0.0)) * v->swath_width_ysingle_dpp[k] /dcn_bw_max2(v->h_ratio[k], 1.0) * v->lb_bit_per_pixel[k] / v->line_buffer_size, 1.0),dcn_bw_ceil2((v->vta_pschroma[k] +dcn_bw_max2(dcn_bw_ceil2(v->v_ratio[k] / 2.0, 1.0) - 2, 0.0)) * v->swath_width_ysingle_dpp[k] / 2.0 /dcn_bw_max2(v->h_ratio[k] / 2.0, 1.0) * v->lb_bit_per_pixel[k] / v->line_buffer_size, 1.0));
+               }
+               v->number_of_dpp_required_for_det_and_lb_size[k] =dcn_bw_max2(v->number_of_dpp_required_for_det_size, v->number_of_dpp_required_for_lb_size);
+       }
+       for (i = 0; i <= number_of_states_plus_one; i++) {
+               for (j = 0; j <= 1; j++) {
+                       v->total_number_of_active_dpp[i][j] = 0.0;
+                       v->required_dispclk[i][j] = 0.0;
+                       v->dispclk_dppclk_support[i][j] = dcn_bw_yes;
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               v->min_dispclk_using_single_dpp =dcn_bw_max2(v->pixel_clock[k], v->min_dppclk_using_single_dpp[k] * (j + 1)) * (1.0 + v->downspreading / 100.0);
+                               if (v->odm_capability == dcn_bw_yes) {
+                                       v->min_dispclk_using_dual_dpp =dcn_bw_max2(v->pixel_clock[k] / 2.0, v->min_dppclk_using_single_dpp[k] / 2.0 * (j + 1)) * (1.0 + v->downspreading / 100.0);
+                               }
+                               else {
+                                       v->min_dispclk_using_dual_dpp =dcn_bw_max2(v->pixel_clock[k], v->min_dppclk_using_single_dpp[k] / 2.0 * (j + 1)) * (1.0 + v->downspreading / 100.0);
+                               }
+                               if (i < number_of_states) {
+                                       v->min_dispclk_using_single_dpp = v->min_dispclk_using_single_dpp * (1.0 + v->dispclk_ramping_margin / 100.0);
+                                       v->min_dispclk_using_dual_dpp = v->min_dispclk_using_dual_dpp * (1.0 + v->dispclk_ramping_margin / 100.0);
+                               }
+                               if (v->min_dispclk_using_single_dpp <=dcn_bw_min2(v->max_dispclk[i], (j + 1) * v->max_dppclk[i]) && v->number_of_dpp_required_for_det_and_lb_size[k] <= 1.0) {
+                                       v->no_of_dpp[i][j][k] = 1.0;
+                                       v->required_dispclk[i][j] =dcn_bw_max2(v->required_dispclk[i][j], v->min_dispclk_using_single_dpp);
+                               }
+                               else if (v->min_dispclk_using_dual_dpp <=dcn_bw_min2(v->max_dispclk[i], (j + 1) * v->max_dppclk[i])) {
+                                       v->no_of_dpp[i][j][k] = 2.0;
+                                       v->required_dispclk[i][j] =dcn_bw_max2(v->required_dispclk[i][j], v->min_dispclk_using_dual_dpp);
+                               }
+                               else {
+                                       v->no_of_dpp[i][j][k] = 2.0;
+                                       v->required_dispclk[i][j] =dcn_bw_max2(v->required_dispclk[i][j], v->min_dispclk_using_dual_dpp);
+                                       v->dispclk_dppclk_support[i][j] = dcn_bw_no;
+                               }
+                               v->total_number_of_active_dpp[i][j] = v->total_number_of_active_dpp[i][j] + v->no_of_dpp[i][j][k];
+                       }
+                       if (v->total_number_of_active_dpp[i][j] > v->max_num_dpp) {
+                               v->total_number_of_active_dpp[i][j] = 0.0;
+                               v->required_dispclk[i][j] = 0.0;
+                               v->dispclk_dppclk_support[i][j] = dcn_bw_yes;
+                               for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                                       v->min_dispclk_using_single_dpp =dcn_bw_max2(v->pixel_clock[k], v->min_dppclk_using_single_dpp[k] * (j + 1)) * (1.0 + v->downspreading / 100.0);
+                                       v->min_dispclk_using_dual_dpp =dcn_bw_max2(v->pixel_clock[k], v->min_dppclk_using_single_dpp[k] / 2.0 * (j + 1)) * (1.0 + v->downspreading / 100.0);
+                                       if (i < number_of_states) {
+                                               v->min_dispclk_using_single_dpp = v->min_dispclk_using_single_dpp * (1.0 + v->dispclk_ramping_margin / 100.0);
+                                               v->min_dispclk_using_dual_dpp = v->min_dispclk_using_dual_dpp * (1.0 + v->dispclk_ramping_margin / 100.0);
+                                       }
+                                       if (v->number_of_dpp_required_for_det_and_lb_size[k] <= 1.0) {
+                                               v->no_of_dpp[i][j][k] = 1.0;
+                                               v->required_dispclk[i][j] =dcn_bw_max2(v->required_dispclk[i][j], v->min_dispclk_using_single_dpp);
+                                               if (v->min_dispclk_using_single_dpp >dcn_bw_min2(v->max_dispclk[i], (j + 1) * v->max_dppclk[i])) {
+                                                       v->dispclk_dppclk_support[i][j] = dcn_bw_no;
+                                               }
+                                       }
+                                       else {
+                                               v->no_of_dpp[i][j][k] = 2.0;
+                                               v->required_dispclk[i][j] =dcn_bw_max2(v->required_dispclk[i][j], v->min_dispclk_using_dual_dpp);
+                                               if (v->min_dispclk_using_dual_dpp >dcn_bw_min2(v->max_dispclk[i], (j + 1) * v->max_dppclk[i])) {
+                                                       v->dispclk_dppclk_support[i][j] = dcn_bw_no;
+                                               }
+                                       }
+                                       v->total_number_of_active_dpp[i][j] = v->total_number_of_active_dpp[i][j] + v->no_of_dpp[i][j][k];
+                               }
+                       }
+               }
+       }
+       /*viewport size check*/
+
+       v->viewport_size_support = dcn_bw_yes;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->number_of_dpp_required_for_det_and_lb_size[k] > 2.0) {
+                       v->viewport_size_support = dcn_bw_no;
+               }
+       }
+       /*total available pipes support check*/
+
+       for (i = 0; i <= number_of_states_plus_one; i++) {
+               for (j = 0; j <= 1; j++) {
+                       if (v->total_number_of_active_dpp[i][j] <= v->max_num_dpp) {
+                               v->total_available_pipes_support[i][j] = dcn_bw_yes;
+                       }
+                       else {
+                               v->total_available_pipes_support[i][j] = dcn_bw_no;
+                       }
+               }
+       }
+       /*urgent latency support check*/
+
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               for (i = 0; i <= number_of_states_plus_one; i++) {
+                       for (j = 0; j <= 1; j++) {
+                               v->swath_width_yper_state[i][j][k] = v->swath_width_ysingle_dpp[k] / v->no_of_dpp[i][j][k];
+                               v->swath_width_granularity_y = 256.0 /dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / v->max_swath_height_y[k];
+                               v->rounded_up_max_swath_size_bytes_y = (dcn_bw_ceil2(v->swath_width_yper_state[i][j][k] - 1.0, v->swath_width_granularity_y) + v->swath_width_granularity_y) * v->byte_per_pixel_in_dety[k] * v->max_swath_height_y[k];
+                               if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10) {
+                                       v->rounded_up_max_swath_size_bytes_y =dcn_bw_ceil2(v->rounded_up_max_swath_size_bytes_y, 256.0) + 256;
+                               }
+                               if (v->max_swath_height_c[k] > 0.0) {
+                                       v->swath_width_granularity_c = 256.0 /dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / v->max_swath_height_c[k];
+                               }
+                               v->rounded_up_max_swath_size_bytes_c = (dcn_bw_ceil2(v->swath_width_yper_state[i][j][k] / 2.0 - 1.0, v->swath_width_granularity_c) + v->swath_width_granularity_c) * v->byte_per_pixel_in_detc[k] * v->max_swath_height_c[k];
+                               if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10) {
+                                       v->rounded_up_max_swath_size_bytes_c =dcn_bw_ceil2(v->rounded_up_max_swath_size_bytes_c, 256.0) + 256;
+                               }
+                               if (v->rounded_up_max_swath_size_bytes_y + v->rounded_up_max_swath_size_bytes_c <= v->det_buffer_size_in_kbyte * 1024.0 / 2.0) {
+                                       v->swath_height_yper_state[i][j][k] = v->max_swath_height_y[k];
+                                       v->swath_height_cper_state[i][j][k] = v->max_swath_height_c[k];
+                               }
+                               else {
+                                       v->swath_height_yper_state[i][j][k] = v->min_swath_height_y[k];
+                                       v->swath_height_cper_state[i][j][k] = v->min_swath_height_c[k];
+                               }
+                               if (v->byte_per_pixel_in_detc[k] == 0.0) {
+                                       v->lines_in_det_luma = v->det_buffer_size_in_kbyte * 1024.0 / v->byte_per_pixel_in_dety[k] / v->swath_width_yper_state[i][j][k];
+                                       v->lines_in_det_chroma = 0.0;
+                               }
+                               else if (v->swath_height_yper_state[i][j][k] <= v->swath_height_cper_state[i][j][k]) {
+                                       v->lines_in_det_luma = v->det_buffer_size_in_kbyte * 1024.0 / 2.0 / v->byte_per_pixel_in_dety[k] / v->swath_width_yper_state[i][j][k];
+                                       v->lines_in_det_chroma = v->det_buffer_size_in_kbyte * 1024.0 / 2.0 / v->byte_per_pixel_in_detc[k] / (v->swath_width_yper_state[i][j][k] / 2.0);
+                               }
+                               else {
+                                       v->lines_in_det_luma = v->det_buffer_size_in_kbyte * 1024.0 * 2.0 / 3.0 / v->byte_per_pixel_in_dety[k] / v->swath_width_yper_state[i][j][k];
+                                       v->lines_in_det_chroma = v->det_buffer_size_in_kbyte * 1024.0 / 3.0 / v->byte_per_pixel_in_dety[k] / (v->swath_width_yper_state[i][j][k] / 2.0);
+                               }
+                               v->effective_lb_latency_hiding_source_lines_luma =dcn_bw_min2(v->max_line_buffer_lines,dcn_bw_floor2(v->line_buffer_size / v->lb_bit_per_pixel[k] / (v->swath_width_yper_state[i][j][k] /dcn_bw_max2(v->h_ratio[k], 1.0)), 1.0)) - (v->vtaps[k] - 1.0);
+                               v->effective_lb_latency_hiding_source_lines_chroma =dcn_bw_min2(v->max_line_buffer_lines,dcn_bw_floor2(v->line_buffer_size / v->lb_bit_per_pixel[k] / (v->swath_width_yper_state[i][j][k] / 2.0 /dcn_bw_max2(v->h_ratio[k] / 2.0, 1.0)), 1.0)) - (v->vta_pschroma[k] - 1.0);
+                               v->effective_detlb_lines_luma =dcn_bw_floor2(v->lines_in_det_luma +dcn_bw_min2(v->lines_in_det_luma * v->required_dispclk[i][j] * v->byte_per_pixel_in_dety[k] * v->pscl_factor[k] / v->return_bw_per_state[i], v->effective_lb_latency_hiding_source_lines_luma), v->swath_height_yper_state[i][j][k]);
+                               v->effective_detlb_lines_chroma =dcn_bw_floor2(v->lines_in_det_chroma +dcn_bw_min2(v->lines_in_det_chroma * v->required_dispclk[i][j] * v->byte_per_pixel_in_detc[k] * v->pscl_factor_chroma[k] / v->return_bw_per_state[i], v->effective_lb_latency_hiding_source_lines_chroma), v->swath_height_cper_state[i][j][k]);
+                               if (v->byte_per_pixel_in_detc[k] == 0.0) {
+                                       v->urgent_latency_support_us_per_state[i][j][k] = v->effective_detlb_lines_luma * (v->htotal[k] / v->pixel_clock[k]) / v->v_ratio[k] - v->effective_detlb_lines_luma * v->swath_width_yper_state[i][j][k] *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / (v->return_bw_per_state[i] / v->no_of_dpp[i][j][k]);
+                               }
+                               else {
+                                       v->urgent_latency_support_us_per_state[i][j][k] =dcn_bw_min2(v->effective_detlb_lines_luma * (v->htotal[k] / v->pixel_clock[k]) / v->v_ratio[k] - v->effective_detlb_lines_luma * v->swath_width_yper_state[i][j][k] *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / (v->return_bw_per_state[i] / v->no_of_dpp[i][j][k]), v->effective_detlb_lines_chroma * (v->htotal[k] / v->pixel_clock[k]) / (v->v_ratio[k] / 2.0) - v->effective_detlb_lines_chroma * v->swath_width_yper_state[i][j][k] / 2.0 *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / (v->return_bw_per_state[i] / v->no_of_dpp[i][j][k]));
+                               }
+                       }
+               }
+       }
+       for (i = 0; i <= number_of_states_plus_one; i++) {
+               for (j = 0; j <= 1; j++) {
+                       v->urgent_latency_support[i][j] = dcn_bw_yes;
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               if (v->urgent_latency_support_us_per_state[i][j][k] < v->urgent_latency / 1.0) {
+                                       v->urgent_latency_support[i][j] = dcn_bw_no;
+                               }
+                       }
+               }
+       }
+       /*prefetch check*/
+
+       for (i = 0; i <= number_of_states_plus_one; i++) {
+               for (j = 0; j <= 1; j++) {
+                       v->total_number_of_dcc_active_dpp[i][j] = 0.0;
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               if (v->dcc_enable[k] == dcn_bw_yes) {
+                                       v->total_number_of_dcc_active_dpp[i][j] = v->total_number_of_dcc_active_dpp[i][j] + v->no_of_dpp[i][j][k];
+                               }
+                       }
+               }
+       }
+       for (i = 0; i <= number_of_states_plus_one; i++) {
+               for (j = 0; j <= 1; j++) {
+                       v->projected_dcfclk_deep_sleep = 8.0;
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               v->projected_dcfclk_deep_sleep =dcn_bw_max2(v->projected_dcfclk_deep_sleep, v->pixel_clock[k] / 16.0);
+                               if (v->byte_per_pixel_in_detc[k] == 0.0) {
+                                       if (v->v_ratio[k] <= 1.0) {
+                                               v->projected_dcfclk_deep_sleep =dcn_bw_max2(v->projected_dcfclk_deep_sleep, 1.1 *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / 64.0 * v->h_ratio[k] * v->pixel_clock[k] / v->no_of_dpp[i][j][k]);
+                                       }
+                                       else {
+                                               v->projected_dcfclk_deep_sleep =dcn_bw_max2(v->projected_dcfclk_deep_sleep, 1.1 *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / 64.0 * v->pscl_factor[k] * v->required_dispclk[i][j] / (1 + j));
+                                       }
+                               }
+                               else {
+                                       if (v->v_ratio[k] <= 1.0) {
+                                               v->projected_dcfclk_deep_sleep =dcn_bw_max2(v->projected_dcfclk_deep_sleep, 1.1 *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / 32.0 * v->h_ratio[k] * v->pixel_clock[k] / v->no_of_dpp[i][j][k]);
+                                       }
+                                       else {
+                                               v->projected_dcfclk_deep_sleep =dcn_bw_max2(v->projected_dcfclk_deep_sleep, 1.1 *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / 32.0 * v->pscl_factor[k] * v->required_dispclk[i][j] / (1 + j));
+                                       }
+                                       if (v->v_ratio[k] / 2.0 <= 1.0) {
+                                               v->projected_dcfclk_deep_sleep =dcn_bw_max2(v->projected_dcfclk_deep_sleep, 1.1 *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 32.0 * v->h_ratio[k] / 2.0 * v->pixel_clock[k] / v->no_of_dpp[i][j][k]);
+                                       }
+                                       else {
+                                               v->projected_dcfclk_deep_sleep =dcn_bw_max2(v->projected_dcfclk_deep_sleep, 1.1 *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 32.0 * v->pscl_factor_chroma[k] * v->required_dispclk[i][j] / (1 + j));
+                                       }
+                               }
+                       }
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               if (v->dcc_enable[k] == dcn_bw_yes) {
+                                       v->meta_req_height_y = 8.0 * v->read256_block_height_y[k];
+                                       v->meta_req_width_y = 64.0 * 256.0 /dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / v->meta_req_height_y;
+                                       v->meta_surface_width_y =dcn_bw_ceil2(v->viewport_width[k] / v->no_of_dpp[i][j][k] - 1.0, v->meta_req_width_y) + v->meta_req_width_y;
+                                       v->meta_surface_height_y =dcn_bw_ceil2(v->viewport_height[k] - 1.0, v->meta_req_height_y) + v->meta_req_height_y;
+                                       if (v->pte_enable == dcn_bw_yes) {
+                                               v->meta_pte_bytes_per_frame_y = (dcn_bw_ceil2((v->meta_surface_width_y * v->meta_surface_height_y *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / 256.0 - 4096.0) / 8.0 / 4096.0, 1.0) + 1) * 64.0;
+                                       }
+                                       else {
+                                               v->meta_pte_bytes_per_frame_y = 0.0;
+                                       }
+                                       if (v->source_scan[k] == dcn_bw_hor) {
+                                               v->meta_row_bytes_y = v->meta_surface_width_y * v->meta_req_height_y *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / 256.0;
+                                       }
+                                       else {
+                                               v->meta_row_bytes_y = v->meta_surface_height_y * v->meta_req_width_y *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / 256.0;
+                                       }
+                               }
+                               else {
+                                       v->meta_pte_bytes_per_frame_y = 0.0;
+                                       v->meta_row_bytes_y = 0.0;
+                               }
+                               if (v->pte_enable == dcn_bw_yes) {
+                                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                                               v->macro_tile_block_size_bytes_y = 256.0;
+                                               v->macro_tile_block_height_y = 1.0;
+                                       }
+                                       else if (v->source_surface_mode[k] == dcn_bw_sw_4_kb_s || v->source_surface_mode[k] == dcn_bw_sw_4_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d_x) {
+                                               v->macro_tile_block_size_bytes_y = 4096.0;
+                                               v->macro_tile_block_height_y = 4.0 * v->read256_block_height_y[k];
+                                       }
+                                       else if (v->source_surface_mode[k] == dcn_bw_sw_64_kb_s || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_x) {
+                                               v->macro_tile_block_size_bytes_y = 64.0 * 1024;
+                                               v->macro_tile_block_height_y = 16.0 * v->read256_block_height_y[k];
+                                       }
+                                       else {
+                                               v->macro_tile_block_size_bytes_y = 256.0 * 1024;
+                                               v->macro_tile_block_height_y = 32.0 * v->read256_block_height_y[k];
+                                       }
+                                       if (v->macro_tile_block_size_bytes_y <= 65536.0) {
+                                               v->data_pte_req_height_y = v->macro_tile_block_height_y;
+                                       }
+                                       else {
+                                               v->data_pte_req_height_y = 16.0 * v->read256_block_height_y[k];
+                                       }
+                                       v->data_pte_req_width_y = 4096.0 /dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) / v->data_pte_req_height_y * 8;
+                                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                                               v->dpte_bytes_per_row_y = 64.0 * (dcn_bw_ceil2((v->viewport_width[k] / v->no_of_dpp[i][j][k] *dcn_bw_min2(128.0, dcn_bw_pow(2.0,dcn_bw_floor2(dcn_bw_log(v->pte_buffer_size_in_requests * v->data_pte_req_width_y / (v->viewport_width[k] / v->no_of_dpp[i][j][k]), 2.0), 1.0))) - 1.0) / v->data_pte_req_width_y, 1.0) + 1);
+                                       }
+                                       else if (v->source_scan[k] == dcn_bw_hor) {
+                                               v->dpte_bytes_per_row_y = 64.0 * (dcn_bw_ceil2((v->viewport_width[k] / v->no_of_dpp[i][j][k] - 1.0) / v->data_pte_req_width_y, 1.0) + 1);
+                                       }
+                                       else {
+                                               v->dpte_bytes_per_row_y = 64.0 * (dcn_bw_ceil2((v->viewport_height[k] - 1.0) / v->data_pte_req_height_y, 1.0) + 1);
+                                       }
+                               }
+                               else {
+                                       v->dpte_bytes_per_row_y = 0.0;
+                               }
+                               if ((v->source_pixel_format[k] != dcn_bw_rgb_sub_64 && v->source_pixel_format[k] != dcn_bw_rgb_sub_32 && v->source_pixel_format[k] != dcn_bw_rgb_sub_16)) {
+                                       if (v->dcc_enable[k] == dcn_bw_yes) {
+                                               v->meta_req_height_c = 8.0 * v->read256_block_height_c[k];
+                                               v->meta_req_width_c = 64.0 * 256.0 /dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / v->meta_req_height_c;
+                                               v->meta_surface_width_c =dcn_bw_ceil2(v->viewport_width[k] / v->no_of_dpp[i][j][k] / 2.0 - 1.0, v->meta_req_width_c) + v->meta_req_width_c;
+                                               v->meta_surface_height_c =dcn_bw_ceil2(v->viewport_height[k] / 2.0 - 1.0, v->meta_req_height_c) + v->meta_req_height_c;
+                                               if (v->pte_enable == dcn_bw_yes) {
+                                                       v->meta_pte_bytes_per_frame_c = (dcn_bw_ceil2((v->meta_surface_width_c * v->meta_surface_height_c *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 256.0 - 4096.0) / 8.0 / 4096.0, 1.0) + 1) * 64.0;
+                                               }
+                                               else {
+                                                       v->meta_pte_bytes_per_frame_c = 0.0;
+                                               }
+                                               if (v->source_scan[k] == dcn_bw_hor) {
+                                                       v->meta_row_bytes_c = v->meta_surface_width_c * v->meta_req_height_c *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 256.0;
+                                               }
+                                               else {
+                                                       v->meta_row_bytes_c = v->meta_surface_height_c * v->meta_req_width_c *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 256.0;
+                                               }
+                                       }
+                                       else {
+                                               v->meta_pte_bytes_per_frame_c = 0.0;
+                                               v->meta_row_bytes_c = 0.0;
+                                       }
+                                       if (v->pte_enable == dcn_bw_yes) {
+                                               if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                                                       v->macro_tile_block_size_bytes_c = 256.0;
+                                                       v->macro_tile_block_height_c = 1.0;
+                                               }
+                                               else if (v->source_surface_mode[k] == dcn_bw_sw_4_kb_s || v->source_surface_mode[k] == dcn_bw_sw_4_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d_x) {
+                                                       v->macro_tile_block_size_bytes_c = 4096.0;
+                                                       v->macro_tile_block_height_c = 4.0 * v->read256_block_height_c[k];
+                                               }
+                                               else if (v->source_surface_mode[k] == dcn_bw_sw_64_kb_s || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_x) {
+                                                       v->macro_tile_block_size_bytes_c = 64.0 * 1024;
+                                                       v->macro_tile_block_height_c = 16.0 * v->read256_block_height_c[k];
+                                               }
+                                               else {
+                                                       v->macro_tile_block_size_bytes_c = 256.0 * 1024;
+                                                       v->macro_tile_block_height_c = 32.0 * v->read256_block_height_c[k];
+                                               }
+                                               v->macro_tile_block_width_c = v->macro_tile_block_size_bytes_c /dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / v->macro_tile_block_height_c;
+                                               if (v->macro_tile_block_size_bytes_c <= 65536.0) {
+                                                       v->data_pte_req_height_c = v->macro_tile_block_height_c;
+                                               }
+                                               else {
+                                                       v->data_pte_req_height_c = 16.0 * v->read256_block_height_c[k];
+                                               }
+                                               v->data_pte_req_width_c = 4096.0 /dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / v->data_pte_req_height_c * 8;
+                                               if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                                                       v->dpte_bytes_per_row_c = 64.0 * (dcn_bw_ceil2((v->viewport_width[k] / v->no_of_dpp[i][j][k] / 2.0 * dcn_bw_min2(128.0, dcn_bw_pow(2.0,dcn_bw_floor2(dcn_bw_log(v->pte_buffer_size_in_requests * v->data_pte_req_width_c / (v->viewport_width[k] / v->no_of_dpp[i][j][k] / 2.0), 2.0), 1.0))) - 1.0) / v->data_pte_req_width_c, 1.0) + 1);
+                                               }
+                                               else if (v->source_scan[k] == dcn_bw_hor) {
+                                                       v->dpte_bytes_per_row_c = 64.0 * (dcn_bw_ceil2((v->viewport_width[k] / v->no_of_dpp[i][j][k] / 2.0 - 1.0) / v->data_pte_req_width_c, 1.0) + 1);
+                                               }
+                                               else {
+                                                       v->dpte_bytes_per_row_c = 64.0 * (dcn_bw_ceil2((v->viewport_height[k] / 2.0 - 1.0) / v->data_pte_req_height_c, 1.0) + 1);
+                                               }
+                                       }
+                                       else {
+                                               v->dpte_bytes_per_row_c = 0.0;
+                                       }
+                               }
+                               else {
+                                       v->dpte_bytes_per_row_c = 0.0;
+                                       v->meta_pte_bytes_per_frame_c = 0.0;
+                                       v->meta_row_bytes_c = 0.0;
+                               }
+                               v->dpte_bytes_per_row[k] = v->dpte_bytes_per_row_y + v->dpte_bytes_per_row_c;
+                               v->meta_pte_bytes_per_frame[k] = v->meta_pte_bytes_per_frame_y + v->meta_pte_bytes_per_frame_c;
+                               v->meta_row_bytes[k] = v->meta_row_bytes_y + v->meta_row_bytes_c;
+                               v->v_init_y = (v->v_ratio[k] + v->vtaps[k] + 1.0 + v->interlace_output[k] * 0.5 * v->v_ratio[k]) / 2.0;
+                               v->prefill_y[k] =dcn_bw_floor2(v->v_init_y, 1.0);
+                               v->max_num_sw_y[k] =dcn_bw_ceil2((v->prefill_y[k] - 1.0) / v->swath_height_yper_state[i][j][k], 1.0) + 1;
+                               if (v->prefill_y[k] > 1.0) {
+                                       v->max_partial_sw_y =dcn_bw_mod((v->prefill_y[k] - 2.0), v->swath_height_yper_state[i][j][k]);
+                               }
+                               else {
+                                       v->max_partial_sw_y =dcn_bw_mod((v->prefill_y[k] + v->swath_height_yper_state[i][j][k] - 2.0), v->swath_height_yper_state[i][j][k]);
+                               }
+                               v->max_partial_sw_y =dcn_bw_max2(1.0, v->max_partial_sw_y);
+                               v->prefetch_lines_y[k] = v->max_num_sw_y[k] * v->swath_height_yper_state[i][j][k] + v->max_partial_sw_y;
+                               if ((v->source_pixel_format[k] != dcn_bw_rgb_sub_64 && v->source_pixel_format[k] != dcn_bw_rgb_sub_32 && v->source_pixel_format[k] != dcn_bw_rgb_sub_16)) {
+                                       v->v_init_c = (v->v_ratio[k] / 2.0 + v->vtaps[k] + 1.0 + v->interlace_output[k] * 0.5 * v->v_ratio[k] / 2.0) / 2.0;
+                                       v->prefill_c[k] =dcn_bw_floor2(v->v_init_c, 1.0);
+                                       v->max_num_sw_c[k] =dcn_bw_ceil2((v->prefill_c[k] - 1.0) / v->swath_height_cper_state[i][j][k], 1.0) + 1;
+                                       if (v->prefill_c[k] > 1.0) {
+                                               v->max_partial_sw_c =dcn_bw_mod((v->prefill_c[k] - 2.0), v->swath_height_cper_state[i][j][k]);
+                                       }
+                                       else {
+                                               v->max_partial_sw_c =dcn_bw_mod((v->prefill_c[k] + v->swath_height_cper_state[i][j][k] - 2.0), v->swath_height_cper_state[i][j][k]);
+                                       }
+                                       v->max_partial_sw_c =dcn_bw_max2(1.0, v->max_partial_sw_c);
+                                       v->prefetch_lines_c[k] = v->max_num_sw_c[k] * v->swath_height_cper_state[i][j][k] + v->max_partial_sw_c;
+                               }
+                               else {
+                                       v->prefetch_lines_c[k] = 0.0;
+                               }
+                               v->dst_x_after_scaler = 90.0 * v->pixel_clock[k] / (v->required_dispclk[i][j] / (j + 1)) + 42.0 * v->pixel_clock[k] / v->required_dispclk[i][j];
+                               if (v->no_of_dpp[i][j][k] > 1.0) {
+                                       v->dst_x_after_scaler = v->dst_x_after_scaler + v->scaler_rec_out_width[k] / 2.0;
+                               }
+                               if (v->output_format[k] == dcn_bw_420) {
+                                       v->dst_y_after_scaler = 1.0;
+                               }
+                               else {
+                                       v->dst_y_after_scaler = 0.0;
+                               }
+                               v->time_calc = 24.0 / v->projected_dcfclk_deep_sleep;
+                               v->v_update_offset[k][j] = dcn_bw_ceil2(v->htotal[k] / 4.0, 1.0);
+                               v->total_repeater_delay = v->max_inter_dcn_tile_repeaters * (2.0 / (v->required_dispclk[i][j] / (j + 1)) + 3.0 / v->required_dispclk[i][j]);
+                               v->v_update_width[k][j] = (14.0 / v->projected_dcfclk_deep_sleep + 12.0 / (v->required_dispclk[i][j] / (j + 1)) + v->total_repeater_delay) * v->pixel_clock[k];
+                               v->v_ready_offset[k][j] = dcn_bw_max2(150.0 / (v->required_dispclk[i][j] / (j + 1)), v->total_repeater_delay + 20.0 / v->projected_dcfclk_deep_sleep + 10.0 / (v->required_dispclk[i][j] / (j + 1))) * v->pixel_clock[k];
+                               v->time_setup = (v->v_update_offset[k][j] + v->v_update_width[k][j] + v->v_ready_offset[k][j]) / v->pixel_clock[k];
+                               v->extra_latency = v->urgent_round_trip_and_out_of_order_latency_per_state[i] + (v->total_number_of_active_dpp[i][j] * v->pixel_chunk_size_in_kbyte + v->total_number_of_dcc_active_dpp[i][j] * v->meta_chunk_size) * 1024.0 / v->return_bw_per_state[i];
+                               if (v->pte_enable == dcn_bw_yes) {
+                                       v->extra_latency = v->extra_latency + v->total_number_of_active_dpp[i][j] * v->pte_chunk_size * 1024.0 / v->return_bw_per_state[i];
+                               }
+                               if (v->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one == dcn_bw_yes) {
+                                       v->maximum_vstartup = v->vtotal[k] - v->vactive[k] - 1.0;
+                               }
+                               else {
+                                       v->maximum_vstartup = v->v_sync_plus_back_porch[k] - 1.0;
+                               }
+
+                               do {
+                                       v->line_times_for_prefetch[k] = v->maximum_vstartup - v->urgent_latency / (v->htotal[k] / v->pixel_clock[k]) - (v->time_calc + v->time_setup) / (v->htotal[k] / v->pixel_clock[k]) - (v->dst_y_after_scaler + v->dst_x_after_scaler / v->htotal[k]);
+                                       v->line_times_for_prefetch[k] =dcn_bw_floor2(4.0 * (v->line_times_for_prefetch[k] + 0.125), 1.0) / 4;
+                                       v->prefetch_bw[k] = (v->meta_pte_bytes_per_frame[k] + 2.0 * v->meta_row_bytes[k] + 2.0 * v->dpte_bytes_per_row[k] + v->prefetch_lines_y[k] * v->swath_width_yper_state[i][j][k] *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) + v->prefetch_lines_c[k] * v->swath_width_yper_state[i][j][k] / 2.0 *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0)) / (v->line_times_for_prefetch[k] * v->htotal[k] / v->pixel_clock[k]);
+
+                                       if (v->pte_enable == dcn_bw_yes && v->dcc_enable[k] == dcn_bw_yes) {
+                                               v->time_for_meta_pte_without_immediate_flip = dcn_bw_max3(
+                                                               v->meta_pte_bytes_frame[k] / v->prefetch_bw[k],
+                                                               v->extra_latency,
+                                                               v->htotal[k] / v->pixel_clock[k] / 4.0);
+                                       } else {
+                                               v->time_for_meta_pte_without_immediate_flip = v->htotal[k] / v->pixel_clock[k] / 4.0;
+                                       }
+
+                                       if (v->pte_enable == dcn_bw_yes || v->dcc_enable[k] == dcn_bw_yes) {
+                                               v->time_for_meta_and_dpte_row_without_immediate_flip = dcn_bw_max3((
+                                                               v->meta_row_bytes[k] + v->dpte_bytes_per_row[k]) / v->prefetch_bw[k],
+                                                               v->htotal[k] / v->pixel_clock[k] - v->time_for_meta_pte_without_immediate_flip,
+                                                               v->extra_latency);
+                                       } else {
+                                               v->time_for_meta_and_dpte_row_without_immediate_flip = dcn_bw_max2(
+                                                               v->htotal[k] / v->pixel_clock[k] - v->time_for_meta_pte_without_immediate_flip,
+                                                               v->extra_latency - v->time_for_meta_pte_with_immediate_flip);
+                                       }
+
+                                       v->lines_for_meta_pte_without_immediate_flip[k] =dcn_bw_floor2(4.0 * (v->time_for_meta_pte_without_immediate_flip / (v->htotal[k] / v->pixel_clock[k]) + 0.125), 1.0) / 4;
+                                       v->lines_for_meta_and_dpte_row_without_immediate_flip[k] =dcn_bw_floor2(4.0 * (v->time_for_meta_and_dpte_row_without_immediate_flip / (v->htotal[k] / v->pixel_clock[k]) + 0.125), 1.0) / 4;
+                                       v->maximum_vstartup = v->maximum_vstartup - 1;
+
+                                       if (v->lines_for_meta_pte_without_immediate_flip[k] < 32.0 && v->lines_for_meta_and_dpte_row_without_immediate_flip[k] < 16.0)
+                                               break;
+
+                               } while(1);
+                       }
+                       v->bw_available_for_immediate_flip = v->return_bw_per_state[i];
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               v->bw_available_for_immediate_flip = v->bw_available_for_immediate_flip -dcn_bw_max2(v->read_bandwidth[k], v->prefetch_bw[k]);
+                       }
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               v->total_immediate_flip_bytes[k] = 0.0;
+                               if ((v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
+                                       v->total_immediate_flip_bytes[k] = v->total_immediate_flip_bytes[k] + v->meta_pte_bytes_per_frame[k] + v->meta_row_bytes[k] + v->dpte_bytes_per_row[k];
+                               }
+                       }
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               if (v->pte_enable == dcn_bw_yes && v->dcc_enable[k] == dcn_bw_yes) {
+                                       v->time_for_meta_pte_with_immediate_flip =dcn_bw_max5(v->meta_pte_bytes_per_frame[k] / v->prefetch_bw[k], v->meta_pte_bytes_per_frame[k] * v->total_immediate_flip_bytes[k] / (v->bw_available_for_immediate_flip * (v->meta_pte_bytes_per_frame[k] + v->meta_row_bytes[k] + v->dpte_bytes_per_row[k])), v->extra_latency, v->urgent_latency, v->htotal[k] / v->pixel_clock[k] / 4.0);
+                               }
+                               else {
+                                       v->time_for_meta_pte_with_immediate_flip = v->htotal[k] / v->pixel_clock[k] / 4.0;
+                               }
+                               if (v->pte_enable == dcn_bw_yes || v->dcc_enable[k] == dcn_bw_yes) {
+                                       v->time_for_meta_and_dpte_row_with_immediate_flip =dcn_bw_max5((v->meta_row_bytes[k] + v->dpte_bytes_per_row[k]) / v->prefetch_bw[k], (v->meta_row_bytes[k] + v->dpte_bytes_per_row[k]) * v->total_immediate_flip_bytes[k] / (v->bw_available_for_immediate_flip * (v->meta_pte_bytes_per_frame[k] + v->meta_row_bytes[k] + v->dpte_bytes_per_row[k])), v->htotal[k] / v->pixel_clock[k] - v->time_for_meta_pte_with_immediate_flip, v->extra_latency, 2.0 * v->urgent_latency);
+                               }
+                               else {
+                                       v->time_for_meta_and_dpte_row_with_immediate_flip =dcn_bw_max2(v->htotal[k] / v->pixel_clock[k] - v->time_for_meta_pte_with_immediate_flip, v->extra_latency - v->time_for_meta_pte_with_immediate_flip);
+                               }
+                               v->lines_for_meta_pte_with_immediate_flip[k] =dcn_bw_floor2(4.0 * (v->time_for_meta_pte_with_immediate_flip / (v->htotal[k] / v->pixel_clock[k]) + 0.125), 1.0) / 4;
+                               v->lines_for_meta_and_dpte_row_with_immediate_flip[k] =dcn_bw_floor2(4.0 * (v->time_for_meta_and_dpte_row_with_immediate_flip / (v->htotal[k] / v->pixel_clock[k]) + 0.125), 1.0) / 4;
+                               v->line_times_to_request_prefetch_pixel_data_with_immediate_flip = v->line_times_for_prefetch[k] - v->lines_for_meta_pte_with_immediate_flip[k] - v->lines_for_meta_and_dpte_row_with_immediate_flip[k];
+                               v->line_times_to_request_prefetch_pixel_data_without_immediate_flip = v->line_times_for_prefetch[k] - v->lines_for_meta_pte_without_immediate_flip[k] - v->lines_for_meta_and_dpte_row_without_immediate_flip[k];
+                               if (v->line_times_to_request_prefetch_pixel_data_with_immediate_flip > 0.0) {
+                                       v->v_ratio_pre_ywith_immediate_flip[i][j][k] = v->prefetch_lines_y[k] / v->line_times_to_request_prefetch_pixel_data_with_immediate_flip;
+                                       if ((v->swath_height_yper_state[i][j][k] > 4.0)) {
+                                               if (v->line_times_to_request_prefetch_pixel_data_with_immediate_flip - (v->prefill_y[k] - 3.0) / 2.0 > 0.0) {
+                                                       v->v_ratio_pre_ywith_immediate_flip[i][j][k] =dcn_bw_max2(v->v_ratio_pre_ywith_immediate_flip[i][j][k], (v->max_num_sw_y[k] * v->swath_height_yper_state[i][j][k]) / (v->line_times_to_request_prefetch_pixel_data_with_immediate_flip - (v->prefill_y[k] - 3.0) / 2.0));
+                                               }
+                                               else {
+                                                       v->v_ratio_pre_ywith_immediate_flip[i][j][k] = 999999.0;
+                                               }
+                                       }
+                                       v->v_ratio_pre_cwith_immediate_flip[i][j][k] = v->prefetch_lines_c[k] / v->line_times_to_request_prefetch_pixel_data_with_immediate_flip;
+                                       if ((v->swath_height_cper_state[i][j][k] > 4.0)) {
+                                               if (v->line_times_to_request_prefetch_pixel_data_with_immediate_flip - (v->prefill_c[k] - 3.0) / 2.0 > 0.0) {
+                                                       v->v_ratio_pre_cwith_immediate_flip[i][j][k] =dcn_bw_max2(v->v_ratio_pre_cwith_immediate_flip[i][j][k], (v->max_num_sw_c[k] * v->swath_height_cper_state[i][j][k]) / (v->line_times_to_request_prefetch_pixel_data_with_immediate_flip - (v->prefill_c[k] - 3.0) / 2.0));
+                                               }
+                                               else {
+                                                       v->v_ratio_pre_cwith_immediate_flip[i][j][k] = 999999.0;
+                                               }
+                                       }
+                                       v->required_prefetch_pixel_data_bw_with_immediate_flip[i][j][k] = v->no_of_dpp[i][j][k] * (v->prefetch_lines_y[k] / v->line_times_to_request_prefetch_pixel_data_with_immediate_flip *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) + v->prefetch_lines_c[k] / v->line_times_to_request_prefetch_pixel_data_with_immediate_flip *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 2.0) * v->swath_width_yper_state[i][j][k] / (v->htotal[k] / v->pixel_clock[k]);
+                               }
+                               else {
+                                       v->v_ratio_pre_ywith_immediate_flip[i][j][k] = 999999.0;
+                                       v->v_ratio_pre_cwith_immediate_flip[i][j][k] = 999999.0;
+                                       v->required_prefetch_pixel_data_bw_with_immediate_flip[i][j][k] = 999999.0;
+                               }
+                               if (v->line_times_to_request_prefetch_pixel_data_without_immediate_flip > 0.0) {
+                                       v->v_ratio_pre_ywithout_immediate_flip[i][j][k] = v->prefetch_lines_y[k] / v->line_times_to_request_prefetch_pixel_data_without_immediate_flip;
+                                       if ((v->swath_height_yper_state[i][j][k] > 4.0)) {
+                                               if (v->line_times_to_request_prefetch_pixel_data_without_immediate_flip - (v->prefill_y[k] - 3.0) / 2.0 > 0.0) {
+                                                       v->v_ratio_pre_ywithout_immediate_flip[i][j][k] =dcn_bw_max2(v->v_ratio_pre_ywithout_immediate_flip[i][j][k], (v->max_num_sw_y[k] * v->swath_height_yper_state[i][j][k]) / (v->line_times_to_request_prefetch_pixel_data_without_immediate_flip - (v->prefill_y[k] - 3.0) / 2.0));
+                                               }
+                                               else {
+                                                       v->v_ratio_pre_ywithout_immediate_flip[i][j][k] = 999999.0;
+                                               }
+                                       }
+                                       v->v_ratio_pre_cwithout_immediate_flip[i][j][k] = v->prefetch_lines_c[k] / v->line_times_to_request_prefetch_pixel_data_without_immediate_flip;
+                                       if ((v->swath_height_cper_state[i][j][k] > 4.0)) {
+                                               if (v->line_times_to_request_prefetch_pixel_data_without_immediate_flip - (v->prefill_c[k] - 3.0) / 2.0 > 0.0) {
+                                                       v->v_ratio_pre_cwithout_immediate_flip[i][j][k] =dcn_bw_max2(v->v_ratio_pre_cwithout_immediate_flip[i][j][k], (v->max_num_sw_c[k] * v->swath_height_cper_state[i][j][k]) / (v->line_times_to_request_prefetch_pixel_data_without_immediate_flip - (v->prefill_c[k] - 3.0) / 2.0));
+                                               }
+                                               else {
+                                                       v->v_ratio_pre_cwithout_immediate_flip[i][j][k] = 999999.0;
+                                               }
+                                       }
+                                       v->required_prefetch_pixel_data_bw_without_immediate_flip[i][j][k] = v->no_of_dpp[i][j][k] * (v->prefetch_lines_y[k] / v->line_times_to_request_prefetch_pixel_data_without_immediate_flip *dcn_bw_ceil2(v->byte_per_pixel_in_dety[k], 1.0) + v->prefetch_lines_c[k] / v->line_times_to_request_prefetch_pixel_data_without_immediate_flip *dcn_bw_ceil2(v->byte_per_pixel_in_detc[k], 2.0) / 2.0) * v->swath_width_yper_state[i][j][k] / (v->htotal[k] / v->pixel_clock[k]);
+                               }
+                               else {
+                                       v->v_ratio_pre_ywithout_immediate_flip[i][j][k] = 999999.0;
+                                       v->v_ratio_pre_cwithout_immediate_flip[i][j][k] = 999999.0;
+                                       v->required_prefetch_pixel_data_bw_without_immediate_flip[i][j][k] = 999999.0;
+                               }
+                       }
+                       v->maximum_read_bandwidth_with_prefetch_with_immediate_flip = 0.0;
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               if ((v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
+                                       v->maximum_read_bandwidth_with_prefetch_with_immediate_flip = v->maximum_read_bandwidth_with_prefetch_with_immediate_flip +dcn_bw_max2(v->read_bandwidth[k], v->required_prefetch_pixel_data_bw_with_immediate_flip[i][j][k]) +dcn_bw_max2(v->meta_pte_bytes_per_frame[k] / (v->lines_for_meta_pte_with_immediate_flip[k] * v->htotal[k] / v->pixel_clock[k]), (v->meta_row_bytes[k] + v->dpte_bytes_per_row[k]) / (v->lines_for_meta_and_dpte_row_with_immediate_flip[k] * v->htotal[k] / v->pixel_clock[k]));
+                               }
+                               else {
+                                       v->maximum_read_bandwidth_with_prefetch_with_immediate_flip = v->maximum_read_bandwidth_with_prefetch_with_immediate_flip +dcn_bw_max2(v->read_bandwidth[k], v->required_prefetch_pixel_data_bw_without_immediate_flip[i][j][k]);
+                               }
+                       }
+                       v->maximum_read_bandwidth_with_prefetch_without_immediate_flip = 0.0;
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               v->maximum_read_bandwidth_with_prefetch_without_immediate_flip = v->maximum_read_bandwidth_with_prefetch_without_immediate_flip +dcn_bw_max2(v->read_bandwidth[k], v->required_prefetch_pixel_data_bw_without_immediate_flip[i][j][k]);
+                       }
+                       v->prefetch_supported_with_immediate_flip[i][j] = dcn_bw_yes;
+                       if (v->maximum_read_bandwidth_with_prefetch_with_immediate_flip > v->return_bw_per_state[i]) {
+                               v->prefetch_supported_with_immediate_flip[i][j] = dcn_bw_no;
+                       }
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               if (v->line_times_for_prefetch[k] < 2.0 || v->lines_for_meta_pte_with_immediate_flip[k] >= 8.0 || v->lines_for_meta_and_dpte_row_with_immediate_flip[k] >= 16.0) {
+                                       v->prefetch_supported_with_immediate_flip[i][j] = dcn_bw_no;
+                               }
+                       }
+                       v->prefetch_supported_without_immediate_flip[i][j] = dcn_bw_yes;
+                       if (v->maximum_read_bandwidth_with_prefetch_without_immediate_flip > v->return_bw_per_state[i]) {
+                               v->prefetch_supported_without_immediate_flip[i][j] = dcn_bw_no;
+                       }
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               if (v->line_times_for_prefetch[k] < 2.0 || v->lines_for_meta_pte_without_immediate_flip[k] >= 8.0 || v->lines_for_meta_and_dpte_row_without_immediate_flip[k] >= 16.0) {
+                                       v->prefetch_supported_without_immediate_flip[i][j] = dcn_bw_no;
+                               }
+                       }
+               }
+       }
+       for (i = 0; i <= number_of_states_plus_one; i++) {
+               for (j = 0; j <= 1; j++) {
+                       v->v_ratio_in_prefetch_supported_with_immediate_flip[i][j] = dcn_bw_yes;
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               if ((((v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10) && (v->v_ratio_pre_ywith_immediate_flip[i][j][k] > 4.0 || v->v_ratio_pre_cwith_immediate_flip[i][j][k] > 4.0)) || ((v->source_pixel_format[k] == dcn_bw_yuv420_sub_8 || v->source_pixel_format[k] == dcn_bw_yuv420_sub_10) && (v->v_ratio_pre_ywithout_immediate_flip[i][j][k] > 4.0 || v->v_ratio_pre_cwithout_immediate_flip[i][j][k] > 4.0)))) {
+                                       v->v_ratio_in_prefetch_supported_with_immediate_flip[i][j] = dcn_bw_no;
+                               }
+                       }
+                       v->v_ratio_in_prefetch_supported_without_immediate_flip[i][j] = dcn_bw_yes;
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               if ((v->v_ratio_pre_ywithout_immediate_flip[i][j][k] > 4.0 || v->v_ratio_pre_cwithout_immediate_flip[i][j][k] > 4.0)) {
+                                       v->v_ratio_in_prefetch_supported_without_immediate_flip[i][j] = dcn_bw_no;
+                               }
+                       }
+               }
+       }
+       /*mode support, voltage state and soc configuration*/
+
+       for (i = number_of_states_plus_one; i >= 0; i--) {
+               for (j = 0; j <= 1; j++) {
+                       if (v->scale_ratio_support == dcn_bw_yes && v->source_format_pixel_and_scan_support == dcn_bw_yes && v->viewport_size_support == dcn_bw_yes && v->bandwidth_support[i] == dcn_bw_yes && v->dio_support[i] == dcn_bw_yes && v->urgent_latency_support[i][j] == dcn_bw_yes && v->rob_support[i] == dcn_bw_yes && v->dispclk_dppclk_support[i][j] == dcn_bw_yes && v->total_available_pipes_support[i][j] == dcn_bw_yes && v->total_available_writeback_support == dcn_bw_yes && v->writeback_latency_support == dcn_bw_yes) {
+                               if (v->prefetch_supported_with_immediate_flip[i][j] == dcn_bw_yes && v->v_ratio_in_prefetch_supported_with_immediate_flip[i][j] == dcn_bw_yes) {
+                                       v->mode_support_with_immediate_flip[i][j] = dcn_bw_yes;
+                               }
+                               else {
+                                       v->mode_support_with_immediate_flip[i][j] = dcn_bw_no;
+                               }
+                               if (v->prefetch_supported_without_immediate_flip[i][j] == dcn_bw_yes && v->v_ratio_in_prefetch_supported_without_immediate_flip[i][j] == dcn_bw_yes) {
+                                       v->mode_support_without_immediate_flip[i][j] = dcn_bw_yes;
+                               }
+                               else {
+                                       v->mode_support_without_immediate_flip[i][j] = dcn_bw_no;
+                               }
+                       }
+                       else {
+                               v->mode_support_with_immediate_flip[i][j] = dcn_bw_no;
+                               v->mode_support_without_immediate_flip[i][j] = dcn_bw_no;
+                       }
+               }
+       }
+       for (i = number_of_states_plus_one; i >= 0; i--) {
+               if ((i == number_of_states_plus_one || v->mode_support_with_immediate_flip[i][1] == dcn_bw_yes || v->mode_support_with_immediate_flip[i][0] == dcn_bw_yes) && i >= v->voltage_override_level) {
+                       v->voltage_level_with_immediate_flip = i;
+               }
+       }
+       for (i = number_of_states_plus_one; i >= 0; i--) {
+               if ((i == number_of_states_plus_one || v->mode_support_without_immediate_flip[i][1] == dcn_bw_yes || v->mode_support_without_immediate_flip[i][0] == dcn_bw_yes) && i >= v->voltage_override_level) {
+                       v->voltage_level_without_immediate_flip = i;
+               }
+       }
+       if (v->voltage_level_with_immediate_flip == number_of_states_plus_one) {
+               v->immediate_flip_supported = dcn_bw_no;
+               v->voltage_level = v->voltage_level_without_immediate_flip;
+       }
+       else {
+               v->immediate_flip_supported = dcn_bw_yes;
+               v->voltage_level = v->voltage_level_with_immediate_flip;
+       }
+       v->dcfclk = v->dcfclk_per_state[v->voltage_level];
+       v->fabric_and_dram_bandwidth = v->fabric_and_dram_bandwidth_per_state[v->voltage_level];
+       for (j = 0; j <= 1; j++) {
+               v->required_dispclk_per_ratio[j] = v->required_dispclk[v->voltage_level][j];
+               for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                       v->dpp_per_plane_per_ratio[j][k] = v->no_of_dpp[v->voltage_level][j][k];
+               }
+               v->dispclk_dppclk_support_per_ratio[j] = v->dispclk_dppclk_support[v->voltage_level][j];
+       }
+       v->max_phyclk = v->phyclk_per_state[v->voltage_level];
+}
+void display_pipe_configuration(struct dcn_bw_internal_vars *v)
+{
+       int j;
+       int k;
+       /*display pipe configuration*/
+
+       for (j = 0; j <= 1; j++) {
+               v->total_number_of_active_dpp_per_ratio[j] = 0.0;
+               for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                       v->total_number_of_active_dpp_per_ratio[j] = v->total_number_of_active_dpp_per_ratio[j] + v->dpp_per_plane_per_ratio[j][k];
+               }
+       }
+       if ((v->dispclk_dppclk_support_per_ratio[0] == dcn_bw_yes && v->dispclk_dppclk_support_per_ratio[1] == dcn_bw_no) || (v->dispclk_dppclk_support_per_ratio[0] == v->dispclk_dppclk_support_per_ratio[1] && (v->total_number_of_active_dpp_per_ratio[0] < v->total_number_of_active_dpp_per_ratio[1] || (((v->total_number_of_active_dpp_per_ratio[0] == v->total_number_of_active_dpp_per_ratio[1]) && v->required_dispclk_per_ratio[0] <= 0.5 * v->required_dispclk_per_ratio[1]))))) {
+               v->dispclk_dppclk_ratio = 1;
+               v->final_error_message = v->error_message[0];
+       }
+       else {
+               v->dispclk_dppclk_ratio = 2;
+               v->final_error_message = v->error_message[1];
+       }
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               v->dpp_per_plane[k] = v->dpp_per_plane_per_ratio[v->dispclk_dppclk_ratio - 1][k];
+       }
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
+                       v->byte_per_pix_dety = 8.0;
+                       v->byte_per_pix_detc = 0.0;
+               }
+               else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_32) {
+                       v->byte_per_pix_dety = 4.0;
+                       v->byte_per_pix_detc = 0.0;
+               }
+               else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_16) {
+                       v->byte_per_pix_dety = 2.0;
+                       v->byte_per_pix_detc = 0.0;
+               }
+               else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
+                       v->byte_per_pix_dety = 1.0;
+                       v->byte_per_pix_detc = 2.0;
+               }
+               else {
+                       v->byte_per_pix_dety = 4.0f / 3.0f;
+                       v->byte_per_pix_detc = 8.0f / 3.0f;
+               }
+               if ((v->source_pixel_format[k] == dcn_bw_rgb_sub_64 || v->source_pixel_format[k] == dcn_bw_rgb_sub_32 || v->source_pixel_format[k] == dcn_bw_rgb_sub_16)) {
+                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                               v->read256_bytes_block_height_y = 1.0;
+                       }
+                       else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
+                               v->read256_bytes_block_height_y = 4.0;
+                       }
+                       else {
+                               v->read256_bytes_block_height_y = 8.0;
+                       }
+                       v->read256_bytes_block_width_y = 256.0 /dcn_bw_ceil2(v->byte_per_pix_dety, 1.0) / v->read256_bytes_block_height_y;
+                       v->read256_bytes_block_height_c = 0.0;
+                       v->read256_bytes_block_width_c = 0.0;
+               }
+               else {
+                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                               v->read256_bytes_block_height_y = 1.0;
+                               v->read256_bytes_block_height_c = 1.0;
+                       }
+                       else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
+                               v->read256_bytes_block_height_y = 16.0;
+                               v->read256_bytes_block_height_c = 8.0;
+                       }
+                       else {
+                               v->read256_bytes_block_height_y = 8.0;
+                               v->read256_bytes_block_height_c = 8.0;
+                       }
+                       v->read256_bytes_block_width_y = 256.0 /dcn_bw_ceil2(v->byte_per_pix_dety, 1.0) / v->read256_bytes_block_height_y;
+                       v->read256_bytes_block_width_c = 256.0 /dcn_bw_ceil2(v->byte_per_pix_detc, 2.0) / v->read256_bytes_block_height_c;
+               }
+               if (v->source_scan[k] == dcn_bw_hor) {
+                       v->maximum_swath_height_y = v->read256_bytes_block_height_y;
+                       v->maximum_swath_height_c = v->read256_bytes_block_height_c;
+               }
+               else {
+                       v->maximum_swath_height_y = v->read256_bytes_block_width_y;
+                       v->maximum_swath_height_c = v->read256_bytes_block_width_c;
+               }
+               if ((v->source_pixel_format[k] == dcn_bw_rgb_sub_64 || v->source_pixel_format[k] == dcn_bw_rgb_sub_32 || v->source_pixel_format[k] == dcn_bw_rgb_sub_16)) {
+                       if (v->source_surface_mode[k] == dcn_bw_sw_linear || (v->source_pixel_format[k] == dcn_bw_rgb_sub_64 && (v->source_surface_mode[k] == dcn_bw_sw_4_kb_s || v->source_surface_mode[k] == dcn_bw_sw_4_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_var_s || v->source_surface_mode[k] == dcn_bw_sw_var_s_x) && v->source_scan[k] == dcn_bw_hor)) {
+                               v->minimum_swath_height_y = v->maximum_swath_height_y;
+                       }
+                       else {
+                               v->minimum_swath_height_y = v->maximum_swath_height_y / 2.0;
+                       }
+                       v->minimum_swath_height_c = v->maximum_swath_height_c;
+               }
+               else {
+                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                               v->minimum_swath_height_y = v->maximum_swath_height_y;
+                               v->minimum_swath_height_c = v->maximum_swath_height_c;
+                       }
+                       else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8 && v->source_scan[k] == dcn_bw_hor) {
+                               v->minimum_swath_height_y = v->maximum_swath_height_y / 2.0;
+                               if (v->bug_forcing_luma_and_chroma_request_to_same_size_fixed == dcn_bw_yes) {
+                                       v->minimum_swath_height_c = v->maximum_swath_height_c;
+                               }
+                               else {
+                                       v->minimum_swath_height_c = v->maximum_swath_height_c / 2.0;
+                               }
+                       }
+                       else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10 && v->source_scan[k] == dcn_bw_hor) {
+                               v->minimum_swath_height_c = v->maximum_swath_height_c / 2.0;
+                               if (v->bug_forcing_luma_and_chroma_request_to_same_size_fixed == dcn_bw_yes) {
+                                       v->minimum_swath_height_y = v->maximum_swath_height_y;
+                               }
+                               else {
+                                       v->minimum_swath_height_y = v->maximum_swath_height_y / 2.0;
+                               }
+                       }
+                       else {
+                               v->minimum_swath_height_y = v->maximum_swath_height_y;
+                               v->minimum_swath_height_c = v->maximum_swath_height_c;
+                       }
+               }
+               if (v->source_scan[k] == dcn_bw_hor) {
+                       v->swath_width = v->viewport_width[k] / v->dpp_per_plane[k];
+               }
+               else {
+                       v->swath_width = v->viewport_height[k] / v->dpp_per_plane[k];
+               }
+               v->swath_width_granularity_y = 256.0 /dcn_bw_ceil2(v->byte_per_pix_dety, 1.0) / v->maximum_swath_height_y;
+               v->rounded_up_max_swath_size_bytes_y = (dcn_bw_ceil2(v->swath_width - 1.0, v->swath_width_granularity_y) + v->swath_width_granularity_y) * v->byte_per_pix_dety * v->maximum_swath_height_y;
+               if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10) {
+                       v->rounded_up_max_swath_size_bytes_y =dcn_bw_ceil2(v->rounded_up_max_swath_size_bytes_y, 256.0) + 256;
+               }
+               if (v->maximum_swath_height_c > 0.0) {
+                       v->swath_width_granularity_c = 256.0 /dcn_bw_ceil2(v->byte_per_pix_detc, 2.0) / v->maximum_swath_height_c;
+               }
+               v->rounded_up_max_swath_size_bytes_c = (dcn_bw_ceil2(v->swath_width / 2.0 - 1.0, v->swath_width_granularity_c) + v->swath_width_granularity_c) * v->byte_per_pix_detc * v->maximum_swath_height_c;
+               if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10) {
+                       v->rounded_up_max_swath_size_bytes_c =dcn_bw_ceil2(v->rounded_up_max_swath_size_bytes_c, 256.0) + 256;
+               }
+               if (v->rounded_up_max_swath_size_bytes_y + v->rounded_up_max_swath_size_bytes_c <= v->det_buffer_size_in_kbyte * 1024.0 / 2.0) {
+                       v->swath_height_y[k] = v->maximum_swath_height_y;
+                       v->swath_height_c[k] = v->maximum_swath_height_c;
+               }
+               else {
+                       v->swath_height_y[k] = v->minimum_swath_height_y;
+                       v->swath_height_c[k] = v->minimum_swath_height_c;
+               }
+               if (v->swath_height_c[k] == 0.0) {
+                       v->det_buffer_size_y[k] = v->det_buffer_size_in_kbyte * 1024.0;
+                       v->det_buffer_size_c[k] = 0.0;
+               }
+               else if (v->swath_height_y[k] <= v->swath_height_c[k]) {
+                       v->det_buffer_size_y[k] = v->det_buffer_size_in_kbyte * 1024.0 / 2.0;
+                       v->det_buffer_size_c[k] = v->det_buffer_size_in_kbyte * 1024.0 / 2.0;
+               }
+               else {
+                       v->det_buffer_size_y[k] = v->det_buffer_size_in_kbyte * 1024.0 * 2.0 / 3.0;
+                       v->det_buffer_size_c[k] = v->det_buffer_size_in_kbyte * 1024.0 / 3.0;
+               }
+       }
+}
+void dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(struct dcn_bw_internal_vars *v)
+{
+       int k;
+       /*dispclk and dppclk calculation*/
+
+       v->dispclk_with_ramping = 0.0;
+       v->dispclk_without_ramping = 0.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->h_ratio[k] > 1.0) {
+                       v->pscl_throughput[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput * v->h_ratio[k] /dcn_bw_ceil2(v->htaps[k] / 6.0, 1.0));
+               }
+               else {
+                       v->pscl_throughput[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput);
+               }
+               v->dppclk_using_single_dpp_luma = v->pixel_clock[k] *dcn_bw_max3(v->vtaps[k] / 6.0 *dcn_bw_min2(1.0, v->h_ratio[k]), v->h_ratio[k] * v->v_ratio[k] / v->pscl_throughput[k], 1.0);
+               if ((v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
+                       v->pscl_throughput_chroma[k] = 0.0;
+                       v->dppclk_using_single_dpp = v->dppclk_using_single_dpp_luma;
+               }
+               else {
+                       if (v->h_ratio[k] > 1.0) {
+                               v->pscl_throughput_chroma[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput * v->h_ratio[k] / 2.0 /dcn_bw_ceil2(v->hta_pschroma[k] / 6.0, 1.0));
+                       }
+                       else {
+                               v->pscl_throughput_chroma[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput);
+                       }
+                       v->dppclk_using_single_dpp_chroma = v->pixel_clock[k] *dcn_bw_max3(v->vta_pschroma[k] / 6.0 *dcn_bw_min2(1.0, v->h_ratio[k] / 2.0), v->h_ratio[k] * v->v_ratio[k] / 4.0 / v->pscl_throughput_chroma[k], 1.0);
+                       v->dppclk_using_single_dpp =dcn_bw_max2(v->dppclk_using_single_dpp_luma, v->dppclk_using_single_dpp_chroma);
+               }
+               if (v->odm_capable == dcn_bw_yes) {
+                       v->dispclk_with_ramping =dcn_bw_max2(v->dispclk_with_ramping,dcn_bw_max2(v->dppclk_using_single_dpp / v->dpp_per_plane[k] * v->dispclk_dppclk_ratio, v->pixel_clock[k] / v->dpp_per_plane[k]) * (1.0 + v->downspreading / 100.0) * (1.0 + v->dispclk_ramping_margin / 100.0));
+                       v->dispclk_without_ramping =dcn_bw_max2(v->dispclk_without_ramping,dcn_bw_max2(v->dppclk_using_single_dpp / v->dpp_per_plane[k] * v->dispclk_dppclk_ratio, v->pixel_clock[k] / v->dpp_per_plane[k]) * (1.0 + v->downspreading / 100.0));
+               }
+               else {
+                       v->dispclk_with_ramping =dcn_bw_max2(v->dispclk_with_ramping,dcn_bw_max2(v->dppclk_using_single_dpp / v->dpp_per_plane[k] * v->dispclk_dppclk_ratio, v->pixel_clock[k]) * (1.0 + v->downspreading / 100.0) * (1.0 + v->dispclk_ramping_margin / 100.0));
+                       v->dispclk_without_ramping =dcn_bw_max2(v->dispclk_without_ramping,dcn_bw_max2(v->dppclk_using_single_dpp / v->dpp_per_plane[k] * v->dispclk_dppclk_ratio, v->pixel_clock[k]) * (1.0 + v->downspreading / 100.0));
+               }
+       }
+       if (v->dispclk_without_ramping > v->max_dispclk[number_of_states]) {
+               v->dispclk = v->dispclk_without_ramping;
+       }
+       else if (v->dispclk_with_ramping > v->max_dispclk[number_of_states]) {
+               v->dispclk = v->max_dispclk[number_of_states];
+       }
+       else {
+               v->dispclk = v->dispclk_with_ramping;
+       }
+       v->dppclk = v->dispclk / v->dispclk_dppclk_ratio;
+       /*urgent watermark*/
+
+       v->return_bandwidth_to_dcn =dcn_bw_min2(v->return_bus_width * v->dcfclk, v->fabric_and_dram_bandwidth * 1000.0 * v->percent_of_ideal_drambw_received_after_urg_latency / 100.0);
+       v->dcc_enabled_any_plane = dcn_bw_no;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->dcc_enable[k] == dcn_bw_yes) {
+                       v->dcc_enabled_any_plane = dcn_bw_yes;
+               }
+       }
+       v->return_bw = v->return_bandwidth_to_dcn;
+       if (v->dcc_enabled_any_plane == dcn_bw_yes && v->return_bandwidth_to_dcn > v->dcfclk * v->return_bus_width / 4.0) {
+               v->return_bw =dcn_bw_min2(v->return_bw, v->return_bandwidth_to_dcn * 4.0 * (1.0 - v->urgent_latency / ((v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 / (v->return_bandwidth_to_dcn - v->dcfclk * v->return_bus_width / 4.0) + v->urgent_latency)));
+       }
+       v->critical_compression = 2.0 * v->return_bus_width * v->dcfclk * v->urgent_latency / (v->return_bandwidth_to_dcn * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0);
+       if (v->dcc_enabled_any_plane == dcn_bw_yes && v->critical_compression > 1.0 && v->critical_compression < 4.0) {
+               v->return_bw =dcn_bw_min2(v->return_bw, dcn_bw_pow(4.0 * v->return_bandwidth_to_dcn * (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 * v->return_bus_width * v->dcfclk * v->urgent_latency / (v->return_bandwidth_to_dcn * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0), 2));
+       }
+       v->return_bandwidth_to_dcn =dcn_bw_min2(v->return_bus_width * v->dcfclk, v->fabric_and_dram_bandwidth * 1000.0);
+       if (v->dcc_enabled_any_plane == dcn_bw_yes && v->return_bandwidth_to_dcn > v->dcfclk * v->return_bus_width / 4.0) {
+               v->return_bw =dcn_bw_min2(v->return_bw, v->return_bandwidth_to_dcn * 4.0 * (1.0 - v->urgent_latency / ((v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 / (v->return_bandwidth_to_dcn - v->dcfclk * v->return_bus_width / 4.0) + v->urgent_latency)));
+       }
+       v->critical_compression = 2.0 * v->return_bus_width * v->dcfclk * v->urgent_latency / (v->return_bandwidth_to_dcn * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0);
+       if (v->dcc_enabled_any_plane == dcn_bw_yes && v->critical_compression > 1.0 && v->critical_compression < 4.0) {
+               v->return_bw =dcn_bw_min2(v->return_bw, dcn_bw_pow(4.0 * v->return_bandwidth_to_dcn * (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0 * v->return_bus_width * v->dcfclk * v->urgent_latency / (v->return_bandwidth_to_dcn * v->urgent_latency + (v->rob_buffer_size_in_kbyte - v->pixel_chunk_size_in_kbyte) * 1024.0), 2));
+       }
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->source_scan[k] == dcn_bw_hor) {
+                       v->swath_width_y[k] = v->viewport_width[k] / v->dpp_per_plane[k];
+               }
+               else {
+                       v->swath_width_y[k] = v->viewport_height[k] / v->dpp_per_plane[k];
+               }
+       }
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
+                       v->byte_per_pixel_dety[k] = 8.0;
+                       v->byte_per_pixel_detc[k] = 0.0;
+               }
+               else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_32) {
+                       v->byte_per_pixel_dety[k] = 4.0;
+                       v->byte_per_pixel_detc[k] = 0.0;
+               }
+               else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_16) {
+                       v->byte_per_pixel_dety[k] = 2.0;
+                       v->byte_per_pixel_detc[k] = 0.0;
+               }
+               else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
+                       v->byte_per_pixel_dety[k] = 1.0;
+                       v->byte_per_pixel_detc[k] = 2.0;
+               }
+               else {
+                       v->byte_per_pixel_dety[k] = 4.0f / 3.0f;
+                       v->byte_per_pixel_detc[k] = 8.0f / 3.0f;
+               }
+       }
+       v->total_data_read_bandwidth = 0.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               v->read_bandwidth_plane_luma[k] = v->swath_width_y[k] * v->dpp_per_plane[k] *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / (v->htotal[k] / v->pixel_clock[k]) * v->v_ratio[k];
+               v->read_bandwidth_plane_chroma[k] = v->swath_width_y[k] / 2.0 * v->dpp_per_plane[k] *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / (v->htotal[k] / v->pixel_clock[k]) * v->v_ratio[k] / 2.0;
+               v->total_data_read_bandwidth = v->total_data_read_bandwidth + v->read_bandwidth_plane_luma[k] + v->read_bandwidth_plane_chroma[k];
+       }
+       v->total_active_dpp = 0.0;
+       v->total_dcc_active_dpp = 0.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               v->total_active_dpp = v->total_active_dpp + v->dpp_per_plane[k];
+               if (v->dcc_enable[k] == dcn_bw_yes) {
+                       v->total_dcc_active_dpp = v->total_dcc_active_dpp + v->dpp_per_plane[k];
+               }
+       }
+       v->urgent_round_trip_and_out_of_order_latency = (v->round_trip_ping_latency_cycles + 32.0) / v->dcfclk + v->urgent_out_of_order_return_per_channel * v->number_of_channels / v->return_bw;
+       v->last_pixel_of_line_extra_watermark = 0.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->v_ratio[k] <= 1.0) {
+                       v->display_pipe_line_delivery_time_luma[k] = v->swath_width_y[k] * v->dpp_per_plane[k] / v->h_ratio[k] / v->pixel_clock[k];
+               }
+               else {
+                       v->display_pipe_line_delivery_time_luma[k] = v->swath_width_y[k] / v->pscl_throughput[k] / v->dppclk;
+               }
+               v->data_fabric_line_delivery_time_luma = v->swath_width_y[k] * v->swath_height_y[k] *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / (v->return_bw * v->read_bandwidth_plane_luma[k] / v->dpp_per_plane[k] / v->total_data_read_bandwidth);
+               v->last_pixel_of_line_extra_watermark =dcn_bw_max2(v->last_pixel_of_line_extra_watermark, v->data_fabric_line_delivery_time_luma - v->display_pipe_line_delivery_time_luma[k]);
+               if (v->byte_per_pixel_detc[k] == 0.0) {
+                       v->display_pipe_line_delivery_time_chroma[k] = 0.0;
+               }
+               else {
+                       if (v->v_ratio[k] / 2.0 <= 1.0) {
+                               v->display_pipe_line_delivery_time_chroma[k] = v->swath_width_y[k] / 2.0 * v->dpp_per_plane[k] / (v->h_ratio[k] / 2.0) / v->pixel_clock[k];
+                       }
+                       else {
+                               v->display_pipe_line_delivery_time_chroma[k] = v->swath_width_y[k] / 2.0 / v->pscl_throughput_chroma[k] / v->dppclk;
+                       }
+                       v->data_fabric_line_delivery_time_chroma = v->swath_width_y[k] / 2.0 * v->swath_height_c[k] *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / (v->return_bw * v->read_bandwidth_plane_chroma[k] / v->dpp_per_plane[k] / v->total_data_read_bandwidth);
+                       v->last_pixel_of_line_extra_watermark =dcn_bw_max2(v->last_pixel_of_line_extra_watermark, v->data_fabric_line_delivery_time_chroma - v->display_pipe_line_delivery_time_chroma[k]);
+               }
+       }
+       v->urgent_extra_latency = v->urgent_round_trip_and_out_of_order_latency + (v->total_active_dpp * v->pixel_chunk_size_in_kbyte + v->total_dcc_active_dpp * v->meta_chunk_size) * 1024.0 / v->return_bw;
+       if (v->pte_enable == dcn_bw_yes) {
+               v->urgent_extra_latency = v->urgent_extra_latency + v->total_active_dpp * v->pte_chunk_size * 1024.0 / v->return_bw;
+       }
+       v->urgent_watermark = v->urgent_latency + v->last_pixel_of_line_extra_watermark + v->urgent_extra_latency;
+       v->ptemeta_urgent_watermark = v->urgent_watermark + 2.0 * v->urgent_latency;
+       /*nb p-state/dram clock change watermark*/
+
+       v->dram_clock_change_watermark = v->dram_clock_change_latency + v->urgent_watermark;
+       v->total_active_writeback = 0.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->output[k] == dcn_bw_writeback) {
+                       v->total_active_writeback = v->total_active_writeback + 1.0;
+               }
+       }
+       if (v->total_active_writeback <= 1.0) {
+               v->writeback_dram_clock_change_watermark = v->dram_clock_change_latency + v->write_back_latency;
+       }
+       else {
+               v->writeback_dram_clock_change_watermark = v->dram_clock_change_latency + v->write_back_latency + v->writeback_chunk_size * 1024.0 / 32.0 / v->socclk;
+       }
+       /*stutter efficiency*/
+
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               v->lines_in_dety[k] = v->det_buffer_size_y[k] / v->byte_per_pixel_dety[k] / v->swath_width_y[k];
+               v->lines_in_dety_rounded_down_to_swath[k] =dcn_bw_floor2(v->lines_in_dety[k], v->swath_height_y[k]);
+               v->full_det_buffering_time_y[k] = v->lines_in_dety_rounded_down_to_swath[k] * (v->htotal[k] / v->pixel_clock[k]) / v->v_ratio[k];
+               if (v->byte_per_pixel_detc[k] > 0.0) {
+                       v->lines_in_detc[k] = v->det_buffer_size_c[k] / v->byte_per_pixel_detc[k] / (v->swath_width_y[k] / 2.0);
+                       v->lines_in_detc_rounded_down_to_swath[k] =dcn_bw_floor2(v->lines_in_detc[k], v->swath_height_c[k]);
+                       v->full_det_buffering_time_c[k] = v->lines_in_detc_rounded_down_to_swath[k] * (v->htotal[k] / v->pixel_clock[k]) / (v->v_ratio[k] / 2.0);
+               }
+               else {
+                       v->lines_in_detc[k] = 0.0;
+                       v->lines_in_detc_rounded_down_to_swath[k] = 0.0;
+                       v->full_det_buffering_time_c[k] = 999999.0;
+               }
+       }
+       v->min_full_det_buffering_time = 999999.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->full_det_buffering_time_y[k] < v->min_full_det_buffering_time) {
+                       v->min_full_det_buffering_time = v->full_det_buffering_time_y[k];
+                       v->frame_time_for_min_full_det_buffering_time = v->vtotal[k] * v->htotal[k] / v->pixel_clock[k];
+               }
+               if (v->full_det_buffering_time_c[k] < v->min_full_det_buffering_time) {
+                       v->min_full_det_buffering_time = v->full_det_buffering_time_c[k];
+                       v->frame_time_for_min_full_det_buffering_time = v->vtotal[k] * v->htotal[k] / v->pixel_clock[k];
+               }
+       }
+       v->average_read_bandwidth_gbyte_per_second = 0.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->dcc_enable[k] == dcn_bw_yes) {
+                       v->average_read_bandwidth_gbyte_per_second = v->average_read_bandwidth_gbyte_per_second + v->read_bandwidth_plane_luma[k] / v->dcc_rate[k] / 1000.0 + v->read_bandwidth_plane_chroma[k] / v->dcc_rate[k] / 1000.0;
+               }
+               else {
+                       v->average_read_bandwidth_gbyte_per_second = v->average_read_bandwidth_gbyte_per_second + v->read_bandwidth_plane_luma[k] / 1000.0 + v->read_bandwidth_plane_chroma[k] / 1000.0;
+               }
+               if (v->dcc_enable[k] == dcn_bw_yes) {
+                       v->average_read_bandwidth_gbyte_per_second = v->average_read_bandwidth_gbyte_per_second + v->read_bandwidth_plane_luma[k] / 1000.0 / 256.0 + v->read_bandwidth_plane_chroma[k] / 1000.0 / 256.0;
+               }
+               if (v->pte_enable == dcn_bw_yes) {
+                       v->average_read_bandwidth_gbyte_per_second = v->average_read_bandwidth_gbyte_per_second + v->read_bandwidth_plane_luma[k] / 1000.0 / 512.0 + v->read_bandwidth_plane_chroma[k] / 1000.0 / 512.0;
+               }
+       }
+       v->part_of_burst_that_fits_in_rob =dcn_bw_min2(v->min_full_det_buffering_time * v->total_data_read_bandwidth, v->rob_buffer_size_in_kbyte * 1024.0 * v->total_data_read_bandwidth / (v->average_read_bandwidth_gbyte_per_second * 1000.0));
+       v->stutter_burst_time = v->part_of_burst_that_fits_in_rob * (v->average_read_bandwidth_gbyte_per_second * 1000.0) / v->total_data_read_bandwidth / v->return_bw + (v->min_full_det_buffering_time * v->total_data_read_bandwidth - v->part_of_burst_that_fits_in_rob) / (v->dcfclk * 64.0);
+       if (v->total_active_writeback == 0.0) {
+               v->stutter_efficiency_not_including_vblank = (1.0 - (v->sr_exit_time + v->stutter_burst_time) / v->min_full_det_buffering_time) * 100.0;
+       }
+       else {
+               v->stutter_efficiency_not_including_vblank = 0.0;
+       }
+       v->smallest_vblank = 999999.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->synchronized_vblank == dcn_bw_yes || v->number_of_active_planes == 1) {
+                       v->v_blank_time = (v->vtotal[k] - v->vactive[k]) * v->htotal[k] / v->pixel_clock[k];
+               }
+               else {
+                       v->v_blank_time = 0.0;
+               }
+               v->smallest_vblank =dcn_bw_min2(v->smallest_vblank, v->v_blank_time);
+       }
+       v->stutter_efficiency = (v->stutter_efficiency_not_including_vblank / 100.0 * (v->frame_time_for_min_full_det_buffering_time - v->smallest_vblank) + v->smallest_vblank) / v->frame_time_for_min_full_det_buffering_time * 100.0;
+       /*dcfclk deep sleep*/
+
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->byte_per_pixel_detc[k] > 0.0) {
+                       v->dcfclk_deep_sleep_per_plane[k] =dcn_bw_max2(1.1 * v->swath_width_y[k] *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / 32.0 / v->display_pipe_line_delivery_time_luma[k], 1.1 * v->swath_width_y[k] / 2.0 *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / 32.0 / v->display_pipe_line_delivery_time_chroma[k]);
+               }
+               else {
+                       v->dcfclk_deep_sleep_per_plane[k] = 1.1 * v->swath_width_y[k] *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / 64.0 / v->display_pipe_line_delivery_time_luma[k];
+               }
+               v->dcfclk_deep_sleep_per_plane[k] =dcn_bw_max2(v->dcfclk_deep_sleep_per_plane[k], v->pixel_clock[k] / 16.0);
+       }
+       v->dcf_clk_deep_sleep = 8.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               v->dcf_clk_deep_sleep =dcn_bw_max2(v->dcf_clk_deep_sleep, v->dcfclk_deep_sleep_per_plane[k]);
+       }
+       /*stutter watermark*/
+
+       v->stutter_exit_watermark = v->sr_exit_time + v->last_pixel_of_line_extra_watermark + v->urgent_extra_latency + 10.0 / v->dcf_clk_deep_sleep;
+       v->stutter_enter_plus_exit_watermark = v->sr_enter_plus_exit_time + v->last_pixel_of_line_extra_watermark + v->urgent_extra_latency;
+       /*urgent latency supported*/
+
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               v->effective_det_plus_lb_lines_luma =dcn_bw_floor2(v->lines_in_dety[k] +dcn_bw_min2(v->lines_in_dety[k] * v->dppclk * v->byte_per_pixel_dety[k] * v->pscl_throughput[k] / (v->return_bw / v->dpp_per_plane[k]), v->effective_lb_latency_hiding_source_lines_luma), v->swath_height_y[k]);
+               v->urgent_latency_support_us_luma = v->effective_det_plus_lb_lines_luma * (v->htotal[k] / v->pixel_clock[k]) / v->v_ratio[k] - v->effective_det_plus_lb_lines_luma * v->swath_width_y[k] * v->byte_per_pixel_dety[k] / (v->return_bw / v->dpp_per_plane[k]);
+               if (v->byte_per_pixel_detc[k] > 0.0) {
+                       v->effective_det_plus_lb_lines_chroma =dcn_bw_floor2(v->lines_in_detc[k] +dcn_bw_min2(v->lines_in_detc[k] * v->dppclk * v->byte_per_pixel_detc[k] * v->pscl_throughput_chroma[k] / (v->return_bw / v->dpp_per_plane[k]), v->effective_lb_latency_hiding_source_lines_chroma), v->swath_height_c[k]);
+                       v->urgent_latency_support_us_chroma = v->effective_det_plus_lb_lines_chroma * (v->htotal[k] / v->pixel_clock[k]) / (v->v_ratio[k] / 2.0) - v->effective_det_plus_lb_lines_chroma * (v->swath_width_y[k] / 2.0) * v->byte_per_pixel_detc[k] / (v->return_bw / v->dpp_per_plane[k]);
+                       v->urgent_latency_support_us[k] =dcn_bw_min2(v->urgent_latency_support_us_luma, v->urgent_latency_support_us_chroma);
+               }
+               else {
+                       v->urgent_latency_support_us[k] = v->urgent_latency_support_us_luma;
+               }
+       }
+       v->min_urgent_latency_support_us = 999999.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               v->min_urgent_latency_support_us =dcn_bw_min2(v->min_urgent_latency_support_us, v->urgent_latency_support_us[k]);
+       }
+       /*non-urgent latency tolerance*/
+
+       v->non_urgent_latency_tolerance = v->min_urgent_latency_support_us - v->urgent_watermark;
+       /*prefetch*/
+
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if ((v->source_pixel_format[k] == dcn_bw_rgb_sub_64 || v->source_pixel_format[k] == dcn_bw_rgb_sub_32 || v->source_pixel_format[k] == dcn_bw_rgb_sub_16)) {
+                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                               v->block_height256_bytes_y = 1.0;
+                       }
+                       else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
+                               v->block_height256_bytes_y = 4.0;
+                       }
+                       else {
+                               v->block_height256_bytes_y = 8.0;
+                       }
+                       v->block_height256_bytes_c = 0.0;
+               }
+               else {
+                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                               v->block_height256_bytes_y = 1.0;
+                               v->block_height256_bytes_c = 1.0;
+                       }
+                       else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
+                               v->block_height256_bytes_y = 16.0;
+                               v->block_height256_bytes_c = 8.0;
+                       }
+                       else {
+                               v->block_height256_bytes_y = 8.0;
+                               v->block_height256_bytes_c = 8.0;
+                       }
+               }
+               if (v->dcc_enable[k] == dcn_bw_yes) {
+                       v->meta_request_width_y = 64.0 * 256.0 /dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / (8.0 * v->block_height256_bytes_y);
+                       v->meta_surf_width_y =dcn_bw_ceil2(v->swath_width_y[k] - 1.0, v->meta_request_width_y) + v->meta_request_width_y;
+                       v->meta_surf_height_y =dcn_bw_ceil2(v->viewport_height[k] - 1.0, 8.0 * v->block_height256_bytes_y) + 8.0 * v->block_height256_bytes_y;
+                       if (v->pte_enable == dcn_bw_yes) {
+                               v->meta_pte_bytes_frame_y = (dcn_bw_ceil2((v->meta_surf_width_y * v->meta_surf_height_y *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / 256.0 - 4096.0) / 8.0 / 4096.0, 1.0) + 1) * 64.0;
+                       }
+                       else {
+                               v->meta_pte_bytes_frame_y = 0.0;
+                       }
+                       if (v->source_scan[k] == dcn_bw_hor) {
+                               v->meta_row_byte_y = v->meta_surf_width_y * 8.0 * v->block_height256_bytes_y *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / 256.0;
+                       }
+                       else {
+                               v->meta_row_byte_y = v->meta_surf_height_y * v->meta_request_width_y *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / 256.0;
+                       }
+               }
+               else {
+                       v->meta_pte_bytes_frame_y = 0.0;
+                       v->meta_row_byte_y = 0.0;
+               }
+               if (v->pte_enable == dcn_bw_yes) {
+                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                               v->macro_tile_size_byte_y = 256.0;
+                               v->macro_tile_height_y = 1.0;
+                       }
+                       else if (v->source_surface_mode[k] == dcn_bw_sw_4_kb_s || v->source_surface_mode[k] == dcn_bw_sw_4_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d_x) {
+                               v->macro_tile_size_byte_y = 4096.0;
+                               v->macro_tile_height_y = 4.0 * v->block_height256_bytes_y;
+                       }
+                       else if (v->source_surface_mode[k] == dcn_bw_sw_64_kb_s || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_x) {
+                               v->macro_tile_size_byte_y = 64.0 * 1024;
+                               v->macro_tile_height_y = 16.0 * v->block_height256_bytes_y;
+                       }
+                       else {
+                               v->macro_tile_size_byte_y = 256.0 * 1024;
+                               v->macro_tile_height_y = 32.0 * v->block_height256_bytes_y;
+                       }
+                       if (v->macro_tile_size_byte_y <= 65536.0) {
+                               v->pixel_pte_req_height_y = v->macro_tile_height_y;
+                       }
+                       else {
+                               v->pixel_pte_req_height_y = 16.0 * v->block_height256_bytes_y;
+                       }
+                       v->pixel_pte_req_width_y = 4096.0 /dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / v->pixel_pte_req_height_y * 8;
+                       if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                               v->pixel_pte_bytes_per_row_y = 64.0 * (dcn_bw_ceil2((v->swath_width_y[k] *dcn_bw_min2(128.0, dcn_bw_pow(2.0,dcn_bw_floor2(dcn_bw_log(v->pte_buffer_size_in_requests * v->pixel_pte_req_width_y / v->swath_width_y[k], 2.0), 1.0))) - 1.0) / v->pixel_pte_req_width_y, 1.0) + 1);
+                       }
+                       else if (v->source_scan[k] == dcn_bw_hor) {
+                               v->pixel_pte_bytes_per_row_y = 64.0 * (dcn_bw_ceil2((v->swath_width_y[k] - 1.0) / v->pixel_pte_req_width_y, 1.0) + 1);
+                       }
+                       else {
+                               v->pixel_pte_bytes_per_row_y = 64.0 * (dcn_bw_ceil2((v->viewport_height[k] - 1.0) / v->pixel_pte_req_height_y, 1.0) + 1);
+                       }
+               }
+               else {
+                       v->pixel_pte_bytes_per_row_y = 0.0;
+               }
+               if ((v->source_pixel_format[k] != dcn_bw_rgb_sub_64 && v->source_pixel_format[k] != dcn_bw_rgb_sub_32 && v->source_pixel_format[k] != dcn_bw_rgb_sub_16)) {
+                       if (v->dcc_enable[k] == dcn_bw_yes) {
+                               v->meta_request_width_c = 64.0 * 256.0 /dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / (8.0 * v->block_height256_bytes_c);
+                               v->meta_surf_width_c =dcn_bw_ceil2(v->swath_width_y[k] / 2.0 - 1.0, v->meta_request_width_c) + v->meta_request_width_c;
+                               v->meta_surf_height_c =dcn_bw_ceil2(v->viewport_height[k] / 2.0 - 1.0, 8.0 * v->block_height256_bytes_c) + 8.0 * v->block_height256_bytes_c;
+                               if (v->pte_enable == dcn_bw_yes) {
+                                       v->meta_pte_bytes_frame_c = (dcn_bw_ceil2((v->meta_surf_width_c * v->meta_surf_height_c *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / 256.0 - 4096.0) / 8.0 / 4096.0, 1.0) + 1) * 64.0;
+                               }
+                               else {
+                                       v->meta_pte_bytes_frame_c = 0.0;
+                               }
+                               if (v->source_scan[k] == dcn_bw_hor) {
+                                       v->meta_row_byte_c = v->meta_surf_width_c * 8.0 * v->block_height256_bytes_c *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / 256.0;
+                               }
+                               else {
+                                       v->meta_row_byte_c = v->meta_surf_height_c * v->meta_request_width_c *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / 256.0;
+                               }
+                       }
+                       else {
+                               v->meta_pte_bytes_frame_c = 0.0;
+                               v->meta_row_byte_c = 0.0;
+                       }
+                       if (v->pte_enable == dcn_bw_yes) {
+                               if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                                       v->macro_tile_size_bytes_c = 256.0;
+                                       v->macro_tile_height_c = 1.0;
+                               }
+                               else if (v->source_surface_mode[k] == dcn_bw_sw_4_kb_s || v->source_surface_mode[k] == dcn_bw_sw_4_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d || v->source_surface_mode[k] == dcn_bw_sw_4_kb_d_x) {
+                                       v->macro_tile_size_bytes_c = 4096.0;
+                                       v->macro_tile_height_c = 4.0 * v->block_height256_bytes_c;
+                               }
+                               else if (v->source_surface_mode[k] == dcn_bw_sw_64_kb_s || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_s_x || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_t || v->source_surface_mode[k] == dcn_bw_sw_64_kb_d_x) {
+                                       v->macro_tile_size_bytes_c = 64.0 * 1024;
+                                       v->macro_tile_height_c = 16.0 * v->block_height256_bytes_c;
+                               }
+                               else {
+                                       v->macro_tile_size_bytes_c = 256.0 * 1024;
+                                       v->macro_tile_height_c = 32.0 * v->block_height256_bytes_c;
+                               }
+                               if (v->macro_tile_size_bytes_c <= 65536.0) {
+                                       v->pixel_pte_req_height_c = v->macro_tile_height_c;
+                               }
+                               else {
+                                       v->pixel_pte_req_height_c = 16.0 * v->block_height256_bytes_c;
+                               }
+                               v->pixel_pte_req_width_c = 4096.0 /dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / v->pixel_pte_req_height_c * 8;
+                               if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
+                                       v->pixel_pte_bytes_per_row_c = 64.0 * (dcn_bw_ceil2((v->swath_width_y[k] / 2.0 * dcn_bw_min2(128.0, dcn_bw_pow(2.0,dcn_bw_floor2(dcn_bw_log(v->pte_buffer_size_in_requests * v->pixel_pte_req_width_c / (v->swath_width_y[k] / 2.0), 2.0), 1.0))) - 1.0) / v->pixel_pte_req_width_c, 1.0) + 1);
+                               }
+                               else if (v->source_scan[k] == dcn_bw_hor) {
+                                       v->pixel_pte_bytes_per_row_c = 64.0 * (dcn_bw_ceil2((v->swath_width_y[k] / 2.0 - 1.0) / v->pixel_pte_req_width_c, 1.0) + 1);
+                               }
+                               else {
+                                       v->pixel_pte_bytes_per_row_c = 64.0 * (dcn_bw_ceil2((v->viewport_height[k] / 2.0 - 1.0) / v->pixel_pte_req_height_c, 1.0) + 1);
+                               }
+                       }
+                       else {
+                               v->pixel_pte_bytes_per_row_c = 0.0;
+                       }
+               }
+               else {
+                       v->pixel_pte_bytes_per_row_c = 0.0;
+                       v->meta_pte_bytes_frame_c = 0.0;
+                       v->meta_row_byte_c = 0.0;
+               }
+               v->pixel_pte_bytes_per_row[k] = v->pixel_pte_bytes_per_row_y + v->pixel_pte_bytes_per_row_c;
+               v->meta_pte_bytes_frame[k] = v->meta_pte_bytes_frame_y + v->meta_pte_bytes_frame_c;
+               v->meta_row_byte[k] = v->meta_row_byte_y + v->meta_row_byte_c;
+               v->v_init_pre_fill_y[k] =dcn_bw_floor2((v->v_ratio[k] + v->vtaps[k] + 1.0 + v->interlace_output[k] * 0.5 * v->v_ratio[k]) / 2.0, 1.0);
+               v->max_num_swath_y[k] =dcn_bw_ceil2((v->v_init_pre_fill_y[k] - 1.0) / v->swath_height_y[k], 1.0) + 1;
+               if (v->v_init_pre_fill_y[k] > 1.0) {
+                       v->max_partial_swath_y =dcn_bw_mod((v->v_init_pre_fill_y[k] - 2.0), v->swath_height_y[k]);
+               }
+               else {
+                       v->max_partial_swath_y =dcn_bw_mod((v->v_init_pre_fill_y[k] + v->swath_height_y[k] - 2.0), v->swath_height_y[k]);
+               }
+               v->max_partial_swath_y =dcn_bw_max2(1.0, v->max_partial_swath_y);
+               v->prefetch_source_lines_y[k] = v->max_num_swath_y[k] * v->swath_height_y[k] + v->max_partial_swath_y;
+               if ((v->source_pixel_format[k] != dcn_bw_rgb_sub_64 && v->source_pixel_format[k] != dcn_bw_rgb_sub_32 && v->source_pixel_format[k] != dcn_bw_rgb_sub_16)) {
+                       v->v_init_pre_fill_c[k] =dcn_bw_floor2((v->v_ratio[k] / 2.0 + v->vtaps[k] + 1.0 + v->interlace_output[k] * 0.5 * v->v_ratio[k] / 2.0) / 2.0, 1.0);
+                       v->max_num_swath_c[k] =dcn_bw_ceil2((v->v_init_pre_fill_c[k] - 1.0) / v->swath_height_c[k], 1.0) + 1;
+                       if (v->v_init_pre_fill_c[k] > 1.0) {
+                               v->max_partial_swath_c =dcn_bw_mod((v->v_init_pre_fill_c[k] - 2.0), v->swath_height_c[k]);
+                       }
+                       else {
+                               v->max_partial_swath_c =dcn_bw_mod((v->v_init_pre_fill_c[k] + v->swath_height_c[k] - 2.0), v->swath_height_c[k]);
+                       }
+                       v->max_partial_swath_c =dcn_bw_max2(1.0, v->max_partial_swath_c);
+               }
+               else {
+                       v->max_num_swath_c[k] = 0.0;
+                       v->max_partial_swath_c = 0.0;
+               }
+               v->prefetch_source_lines_c[k] = v->max_num_swath_c[k] * v->swath_height_c[k] + v->max_partial_swath_c;
+       }
+       v->t_calc = 24.0 / v->dcf_clk_deep_sleep;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one == dcn_bw_yes) {
+                       v->max_vstartup_lines[k] = v->vtotal[k] - v->vactive[k] - 1.0;
+               }
+               else {
+                       v->max_vstartup_lines[k] = v->v_sync_plus_back_porch[k] - 1.0;
+               }
+       }
+       v->next_prefetch_mode = 0.0;
+       do {
+               v->v_startup_lines = 13.0;
+               do {
+                       v->planes_with_room_to_increase_vstartup_prefetch_bw_less_than_active_bw = dcn_bw_yes;
+                       v->planes_with_room_to_increase_vstartup_vratio_prefetch_more_than4 = dcn_bw_no;
+                       v->planes_with_room_to_increase_vstartup_destination_line_times_for_prefetch_less_than2 = dcn_bw_no;
+                       v->v_ratio_prefetch_more_than4 = dcn_bw_no;
+                       v->destination_line_times_for_prefetch_less_than2 = dcn_bw_no;
+                       v->prefetch_mode = v->next_prefetch_mode;
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               v->dstx_after_scaler = 90.0 * v->pixel_clock[k] / v->dppclk + 42.0 * v->pixel_clock[k] / v->dispclk;
+                               if (v->dpp_per_plane[k] > 1.0) {
+                                       v->dstx_after_scaler = v->dstx_after_scaler + v->scaler_rec_out_width[k] / 2.0;
+                               }
+                               if (v->output_format[k] == dcn_bw_420) {
+                                       v->dsty_after_scaler = 1.0;
+                               }
+                               else {
+                                       v->dsty_after_scaler = 0.0;
+                               }
+                               v->v_update_offset_pix[k] = dcn_bw_ceil2(v->htotal[k] / 4.0, 1.0);
+                               v->total_repeater_delay_time = v->max_inter_dcn_tile_repeaters * (2.0 / v->dppclk + 3.0 / v->dispclk);
+                               v->v_update_width_pix[k] = (14.0 / v->dcf_clk_deep_sleep + 12.0 / v->dppclk + v->total_repeater_delay_time) * v->pixel_clock[k];
+                               v->v_ready_offset_pix[k] = dcn_bw_max2(150.0 / v->dppclk, v->total_repeater_delay_time + 20.0 / v->dcf_clk_deep_sleep + 10.0 / v->dppclk) * v->pixel_clock[k];
+                               v->t_setup = (v->v_update_offset_pix[k] + v->v_update_width_pix[k] + v->v_ready_offset_pix[k]) / v->pixel_clock[k];
+                               v->v_startup[k] =dcn_bw_min2(v->v_startup_lines, v->max_vstartup_lines[k]);
+                               if (v->prefetch_mode == 0.0) {
+                                       v->t_wait =dcn_bw_max3(v->dram_clock_change_latency + v->urgent_latency, v->sr_enter_plus_exit_time, v->urgent_latency);
+                               }
+                               else if (v->prefetch_mode == 1.0) {
+                                       v->t_wait =dcn_bw_max2(v->sr_enter_plus_exit_time, v->urgent_latency);
+                               }
+                               else {
+                                       v->t_wait = v->urgent_latency;
+                               }
+                               v->destination_lines_for_prefetch[k] =dcn_bw_floor2(4.0 * (v->v_startup[k] - v->t_wait / (v->htotal[k] / v->pixel_clock[k]) - (v->t_calc + v->t_setup) / (v->htotal[k] / v->pixel_clock[k]) - (v->dsty_after_scaler + v->dstx_after_scaler / v->htotal[k]) + 0.125), 1.0) / 4;
+                               if (v->destination_lines_for_prefetch[k] > 0.0) {
+                                       v->prefetch_bandwidth[k] = (v->meta_pte_bytes_frame[k] + 2.0 * v->meta_row_byte[k] + 2.0 * v->pixel_pte_bytes_per_row[k] + v->prefetch_source_lines_y[k] * v->swath_width_y[k] *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) + v->prefetch_source_lines_c[k] * v->swath_width_y[k] / 2.0 *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0)) / (v->destination_lines_for_prefetch[k] * v->htotal[k] / v->pixel_clock[k]);
+                               }
+                               else {
+                                       v->prefetch_bandwidth[k] = 999999.0;
+                               }
+                       }
+                       v->bandwidth_available_for_immediate_flip = v->return_bw;
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               v->bandwidth_available_for_immediate_flip = v->bandwidth_available_for_immediate_flip -dcn_bw_max2(v->read_bandwidth_plane_luma[k] + v->read_bandwidth_plane_chroma[k], v->prefetch_bandwidth[k]);
+                       }
+                       v->tot_immediate_flip_bytes = 0.0;
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               if (v->immediate_flip_supported == dcn_bw_yes && (v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
+                                       v->tot_immediate_flip_bytes = v->tot_immediate_flip_bytes + v->meta_pte_bytes_frame[k] + v->meta_row_byte[k] + v->pixel_pte_bytes_per_row[k];
+                               }
+                       }
+                       v->max_rd_bandwidth = 0.0;
+                       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+                               if (v->pte_enable == dcn_bw_yes && v->dcc_enable[k] == dcn_bw_yes) {
+                                       if (v->immediate_flip_supported == dcn_bw_yes && (v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
+                                               v->time_for_fetching_meta_pte =dcn_bw_max5(v->meta_pte_bytes_frame[k] / v->prefetch_bandwidth[k], v->meta_pte_bytes_frame[k] * v->tot_immediate_flip_bytes / (v->bandwidth_available_for_immediate_flip * (v->meta_pte_bytes_frame[k] + v->meta_row_byte[k] + v->pixel_pte_bytes_per_row[k])), v->urgent_extra_latency, v->urgent_latency, v->htotal[k] / v->pixel_clock[k] / 4.0);
+                                       }
+                                       else {
+                                               v->time_for_fetching_meta_pte =dcn_bw_max3(v->meta_pte_bytes_frame[k] / v->prefetch_bandwidth[k], v->urgent_extra_latency, v->htotal[k] / v->pixel_clock[k] / 4.0);
+                                       }
+                               }
+                               else {
+                                       v->time_for_fetching_meta_pte = v->htotal[k] / v->pixel_clock[k] / 4.0;
+                               }
+                               v->destination_lines_to_request_vm_inv_blank[k] =dcn_bw_floor2(4.0 * (v->time_for_fetching_meta_pte / (v->htotal[k] / v->pixel_clock[k]) + 0.125), 1.0) / 4;
+                               if ((v->pte_enable == dcn_bw_yes || v->dcc_enable[k] == dcn_bw_yes)) {
+                                       if (v->immediate_flip_supported == dcn_bw_yes && (v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
+                                               v->time_for_fetching_row_in_vblank =dcn_bw_max5((v->meta_row_byte[k] + v->pixel_pte_bytes_per_row[k]) / v->prefetch_bandwidth[k], (v->meta_row_byte[k] + v->pixel_pte_bytes_per_row[k]) * v->tot_immediate_flip_bytes / (v->bandwidth_available_for_immediate_flip * (v->meta_pte_bytes_frame[k] + v->meta_row_byte[k] + v->pixel_pte_bytes_per_row[k])), v->urgent_extra_latency, 2.0 * v->urgent_latency, v->htotal[k] / v->pixel_clock[k] - v->time_for_fetching_meta_pte);
+                                       }
+                                       else {
+                                               v->time_for_fetching_row_in_vblank =dcn_bw_max3((v->meta_row_byte[k] + v->pixel_pte_bytes_per_row[k]) / v->prefetch_bandwidth[k], v->urgent_extra_latency, v->htotal[k] / v->pixel_clock[k] - v->time_for_fetching_meta_pte);
+                                       }
+                               }
+                               else {
+                                       v->time_for_fetching_row_in_vblank =dcn_bw_max2(v->urgent_extra_latency - v->time_for_fetching_meta_pte, v->htotal[k] / v->pixel_clock[k] - v->time_for_fetching_meta_pte);
+                               }
+                               v->destination_lines_to_request_row_in_vblank[k] =dcn_bw_floor2(4.0 * (v->time_for_fetching_row_in_vblank / (v->htotal[k] / v->pixel_clock[k]) + 0.125), 1.0) / 4;
+                               v->lines_to_request_prefetch_pixel_data = v->destination_lines_for_prefetch[k] - v->destination_lines_to_request_vm_inv_blank[k] - v->destination_lines_to_request_row_in_vblank[k];
+                               if (v->lines_to_request_prefetch_pixel_data > 0.0) {
+                                       v->v_ratio_prefetch_y[k] = v->prefetch_source_lines_y[k] / v->lines_to_request_prefetch_pixel_data;
+                                       if ((v->swath_height_y[k] > 4.0)) {
+                                               if (v->lines_to_request_prefetch_pixel_data > (v->v_init_pre_fill_y[k] - 3.0) / 2.0) {
+                                                       v->v_ratio_prefetch_y[k] =dcn_bw_max2(v->v_ratio_prefetch_y[k], v->max_num_swath_y[k] * v->swath_height_y[k] / (v->lines_to_request_prefetch_pixel_data - (v->v_init_pre_fill_y[k] - 3.0) / 2.0));
+                                               }
+                                               else {
+                                                       v->v_ratio_prefetch_y[k] = 999999.0;
+                                               }
+                                       }
+                               }
+                               else {
+                                       v->v_ratio_prefetch_y[k] = 999999.0;
+                               }
+                               v->v_ratio_prefetch_y[k] =dcn_bw_max2(v->v_ratio_prefetch_y[k], 1.0);
+                               if (v->lines_to_request_prefetch_pixel_data > 0.0) {
+                                       v->v_ratio_prefetch_c[k] = v->prefetch_source_lines_c[k] / v->lines_to_request_prefetch_pixel_data;
+                                       if ((v->swath_height_c[k] > 4.0)) {
+                                               if (v->lines_to_request_prefetch_pixel_data > (v->v_init_pre_fill_c[k] - 3.0) / 2.0) {
+                                                       v->v_ratio_prefetch_c[k] =dcn_bw_max2(v->v_ratio_prefetch_c[k], v->max_num_swath_c[k] * v->swath_height_c[k] / (v->lines_to_request_prefetch_pixel_data - (v->v_init_pre_fill_c[k] - 3.0) / 2.0));
+                                               }
+                                               else {
+                                                       v->v_ratio_prefetch_c[k] = 999999.0;
+                                               }
+                                       }
+                               }
+                               else {
+                                       v->v_ratio_prefetch_c[k] = 999999.0;
+                               }
+                               v->v_ratio_prefetch_c[k] =dcn_bw_max2(v->v_ratio_prefetch_c[k], 1.0);
+                               if (v->lines_to_request_prefetch_pixel_data > 0.0) {
+                                       v->required_prefetch_pix_data_bw = v->dpp_per_plane[k] * (v->prefetch_source_lines_y[k] / v->lines_to_request_prefetch_pixel_data *dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) + v->prefetch_source_lines_c[k] / v->lines_to_request_prefetch_pixel_data *dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / 2.0) * v->swath_width_y[k] / (v->htotal[k] / v->pixel_clock[k]);
+                               }
+                               else {
+                                       v->required_prefetch_pix_data_bw = 999999.0;
+                               }
+                               v->max_rd_bandwidth = v->max_rd_bandwidth +dcn_bw_max2(v->read_bandwidth_plane_luma[k] + v->read_bandwidth_plane_chroma[k], v->required_prefetch_pix_data_bw);
+                               if (v->immediate_flip_supported == dcn_bw_yes && (v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
+                                       v->max_rd_bandwidth = v->max_rd_bandwidth +dcn_bw_max2(v->meta_pte_bytes_frame[k] / (v->destination_lines_to_request_vm_inv_blank[k] * v->htotal[k] / v->pixel_clock[k]), (v->meta_row_byte[k] + v->pixel_pte_bytes_per_row[k]) / (v->destination_lines_to_request_row_in_vblank[k] * v->htotal[k] / v->pixel_clock[k]));
+                               }
+                               if (v->v_ratio_prefetch_y[k] > 4.0 || v->v_ratio_prefetch_c[k] > 4.0) {
+                                       v->v_ratio_prefetch_more_than4 = dcn_bw_yes;
+                               }
+                               if (v->destination_lines_for_prefetch[k] < 2.0) {
+                                       v->destination_line_times_for_prefetch_less_than2 = dcn_bw_yes;
+                               }
+                               if (v->max_vstartup_lines[k] > v->v_startup_lines) {
+                                       if (v->required_prefetch_pix_data_bw > (v->read_bandwidth_plane_luma[k] + v->read_bandwidth_plane_chroma[k])) {
+                                               v->planes_with_room_to_increase_vstartup_prefetch_bw_less_than_active_bw = dcn_bw_no;
+                                       }
+                                       if (v->v_ratio_prefetch_y[k] > 4.0 || v->v_ratio_prefetch_c[k] > 4.0) {
+                                               v->planes_with_room_to_increase_vstartup_vratio_prefetch_more_than4 = dcn_bw_yes;
+                                       }
+                                       if (v->destination_lines_for_prefetch[k] < 2.0) {
+                                               v->planes_with_room_to_increase_vstartup_destination_line_times_for_prefetch_less_than2 = dcn_bw_yes;
+                                       }
+                               }
+                       }
+                       if (v->max_rd_bandwidth <= v->return_bw && v->v_ratio_prefetch_more_than4 == dcn_bw_no && v->destination_line_times_for_prefetch_less_than2 == dcn_bw_no) {
+                               v->prefetch_mode_supported = dcn_bw_yes;
+                       }
+                       else {
+                               v->prefetch_mode_supported = dcn_bw_no;
+                       }
+                       v->v_startup_lines = v->v_startup_lines + 1.0;
+               } while (!(v->prefetch_mode_supported == dcn_bw_yes || (v->planes_with_room_to_increase_vstartup_prefetch_bw_less_than_active_bw == dcn_bw_yes && v->planes_with_room_to_increase_vstartup_vratio_prefetch_more_than4 == dcn_bw_no && v->planes_with_room_to_increase_vstartup_destination_line_times_for_prefetch_less_than2 == dcn_bw_no)));
+               v->next_prefetch_mode = v->next_prefetch_mode + 1.0;
+       } while (!(v->prefetch_mode_supported == dcn_bw_yes || v->prefetch_mode == 2.0));
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->v_ratio_prefetch_y[k] <= 1.0) {
+                       v->display_pipe_line_delivery_time_luma_prefetch[k] = v->swath_width_y[k] * v->dpp_per_plane[k] / v->h_ratio[k] / v->pixel_clock[k];
+               }
+               else {
+                       v->display_pipe_line_delivery_time_luma_prefetch[k] = v->swath_width_y[k] / v->pscl_throughput[k] / v->dppclk;
+               }
+               if (v->byte_per_pixel_detc[k] == 0.0) {
+                       v->display_pipe_line_delivery_time_chroma_prefetch[k] = 0.0;
+               }
+               else {
+                       if (v->v_ratio_prefetch_c[k] <= 1.0) {
+                               v->display_pipe_line_delivery_time_chroma_prefetch[k] = v->swath_width_y[k] * v->dpp_per_plane[k] / v->h_ratio[k] / v->pixel_clock[k];
+                       }
+                       else {
+                               v->display_pipe_line_delivery_time_chroma_prefetch[k] = v->swath_width_y[k] / v->pscl_throughput[k] / v->dppclk;
+                       }
+               }
+       }
+       /*min ttuv_blank*/
+
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->prefetch_mode == 0.0) {
+                       v->allow_dram_clock_change_during_vblank[k] = dcn_bw_yes;
+                       v->allow_dram_self_refresh_during_vblank[k] = dcn_bw_yes;
+                       v->min_ttuv_blank[k] = v->t_calc +dcn_bw_max3(v->dram_clock_change_watermark, v->stutter_enter_plus_exit_watermark, v->urgent_watermark);
+               }
+               else if (v->prefetch_mode == 1.0) {
+                       v->allow_dram_clock_change_during_vblank[k] = dcn_bw_no;
+                       v->allow_dram_self_refresh_during_vblank[k] = dcn_bw_yes;
+                       v->min_ttuv_blank[k] = v->t_calc +dcn_bw_max2(v->stutter_enter_plus_exit_watermark, v->urgent_watermark);
+               }
+               else {
+                       v->allow_dram_clock_change_during_vblank[k] = dcn_bw_no;
+                       v->allow_dram_self_refresh_during_vblank[k] = dcn_bw_no;
+                       v->min_ttuv_blank[k] = v->t_calc + v->urgent_watermark;
+               }
+       }
+       /*nb p-state/dram clock change support*/
+
+       v->active_dp_ps = 0.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               v->active_dp_ps = v->active_dp_ps + v->dpp_per_plane[k];
+       }
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               v->lb_latency_hiding_source_lines_y =dcn_bw_min2(v->max_line_buffer_lines,dcn_bw_floor2(v->line_buffer_size / v->lb_bit_per_pixel[k] / (v->swath_width_y[k] /dcn_bw_max2(v->h_ratio[k], 1.0)), 1.0)) - (v->vtaps[k] - 1.0);
+               v->lb_latency_hiding_source_lines_c =dcn_bw_min2(v->max_line_buffer_lines,dcn_bw_floor2(v->line_buffer_size / v->lb_bit_per_pixel[k] / (v->swath_width_y[k] / 2.0 /dcn_bw_max2(v->h_ratio[k] / 2.0, 1.0)), 1.0)) - (v->vta_pschroma[k] - 1.0);
+               v->effective_lb_latency_hiding_y = v->lb_latency_hiding_source_lines_y / v->v_ratio[k] * (v->htotal[k] / v->pixel_clock[k]);
+               v->effective_lb_latency_hiding_c = v->lb_latency_hiding_source_lines_c / (v->v_ratio[k] / 2.0) * (v->htotal[k] / v->pixel_clock[k]);
+               if (v->swath_width_y[k] > 2.0 * v->dpp_output_buffer_pixels) {
+                       v->dpp_output_buffer_lines_y = v->dpp_output_buffer_pixels / v->swath_width_y[k];
+               }
+               else if (v->swath_width_y[k] > v->dpp_output_buffer_pixels) {
+                       v->dpp_output_buffer_lines_y = 0.5;
+               }
+               else {
+                       v->dpp_output_buffer_lines_y = 1.0;
+               }
+               if (v->swath_width_y[k] / 2.0 > 2.0 * v->dpp_output_buffer_pixels) {
+                       v->dpp_output_buffer_lines_c = v->dpp_output_buffer_pixels / (v->swath_width_y[k] / 2.0);
+               }
+               else if (v->swath_width_y[k] / 2.0 > v->dpp_output_buffer_pixels) {
+                       v->dpp_output_buffer_lines_c = 0.5;
+               }
+               else {
+                       v->dpp_output_buffer_lines_c = 1.0;
+               }
+               v->dppopp_buffering_y = (v->htotal[k] / v->pixel_clock[k]) * (v->dpp_output_buffer_lines_y + v->opp_output_buffer_lines);
+               v->max_det_buffering_time_y = v->full_det_buffering_time_y[k] + (v->lines_in_dety[k] - v->lines_in_dety_rounded_down_to_swath[k]) / v->swath_height_y[k] * (v->htotal[k] / v->pixel_clock[k]);
+               v->active_dram_clock_change_latency_margin_y = v->dppopp_buffering_y + v->effective_lb_latency_hiding_y + v->max_det_buffering_time_y - v->dram_clock_change_watermark;
+               if (v->active_dp_ps > 1.0) {
+                       v->active_dram_clock_change_latency_margin_y = v->active_dram_clock_change_latency_margin_y - (1.0 - 1.0 / (v->active_dp_ps - 1.0)) * v->swath_height_y[k] * (v->htotal[k] / v->pixel_clock[k]);
+               }
+               if (v->byte_per_pixel_detc[k] > 0.0) {
+                       v->dppopp_buffering_c = (v->htotal[k] / v->pixel_clock[k]) * (v->dpp_output_buffer_lines_c + v->opp_output_buffer_lines);
+                       v->max_det_buffering_time_c = v->full_det_buffering_time_c[k] + (v->lines_in_detc[k] - v->lines_in_detc_rounded_down_to_swath[k]) / v->swath_height_c[k] * (v->htotal[k] / v->pixel_clock[k]);
+                       v->active_dram_clock_change_latency_margin_c = v->dppopp_buffering_c + v->effective_lb_latency_hiding_c + v->max_det_buffering_time_c - v->dram_clock_change_watermark;
+                       if (v->active_dp_ps > 1.0) {
+                               v->active_dram_clock_change_latency_margin_c = v->active_dram_clock_change_latency_margin_c - (1.0 - 1.0 / (v->active_dp_ps - 1.0)) * v->swath_height_c[k] * (v->htotal[k] / v->pixel_clock[k]);
+                       }
+                       v->active_dram_clock_change_latency_margin[k] =dcn_bw_min2(v->active_dram_clock_change_latency_margin_y, v->active_dram_clock_change_latency_margin_c);
+               }
+               else {
+                       v->active_dram_clock_change_latency_margin[k] = v->active_dram_clock_change_latency_margin_y;
+               }
+               if (v->output_format[k] == dcn_bw_444) {
+                       v->writeback_dram_clock_change_latency_margin = (v->writeback_luma_buffer_size + v->writeback_chroma_buffer_size) * 1024.0 / (v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) * 4.0) - v->writeback_dram_clock_change_watermark;
+               }
+               else {
+                       v->writeback_dram_clock_change_latency_margin =dcn_bw_min2(v->writeback_luma_buffer_size, 2.0 * v->writeback_chroma_buffer_size) * 1024.0 / (v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k])) - v->writeback_dram_clock_change_watermark;
+               }
+               if (v->output[k] == dcn_bw_writeback) {
+                       v->active_dram_clock_change_latency_margin[k] =dcn_bw_min2(v->active_dram_clock_change_latency_margin[k], v->writeback_dram_clock_change_latency_margin);
+               }
+       }
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->allow_dram_clock_change_during_vblank[k] == dcn_bw_yes) {
+                       v->v_blank_dram_clock_change_latency_margin[k] = (v->vtotal[k] - v->scaler_recout_height[k]) * (v->htotal[k] / v->pixel_clock[k]) -dcn_bw_max2(v->dram_clock_change_watermark, v->writeback_dram_clock_change_watermark);
+               }
+               else {
+                       v->v_blank_dram_clock_change_latency_margin[k] = 0.0;
+               }
+       }
+       v->min_active_dram_clock_change_margin = 999999.0;
+       v->v_blank_of_min_active_dram_clock_change_margin = 999999.0;
+       v->second_min_active_dram_clock_change_margin = 999999.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->active_dram_clock_change_latency_margin[k] < v->min_active_dram_clock_change_margin) {
+                       v->second_min_active_dram_clock_change_margin = v->min_active_dram_clock_change_margin;
+                       v->min_active_dram_clock_change_margin = v->active_dram_clock_change_latency_margin[k];
+                       v->v_blank_of_min_active_dram_clock_change_margin = v->v_blank_dram_clock_change_latency_margin[k];
+               }
+               else if (v->active_dram_clock_change_latency_margin[k] < v->second_min_active_dram_clock_change_margin) {
+                       v->second_min_active_dram_clock_change_margin = v->active_dram_clock_change_latency_margin[k];
+               }
+       }
+       v->min_vblank_dram_clock_change_margin = 999999.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->min_vblank_dram_clock_change_margin > v->v_blank_dram_clock_change_latency_margin[k]) {
+                       v->min_vblank_dram_clock_change_margin = v->v_blank_dram_clock_change_latency_margin[k];
+               }
+       }
+       if (v->synchronized_vblank == dcn_bw_yes || v->number_of_active_planes == 1) {
+               v->dram_clock_change_margin =dcn_bw_max2(v->min_active_dram_clock_change_margin, v->min_vblank_dram_clock_change_margin);
+       }
+       else if (v->v_blank_of_min_active_dram_clock_change_margin > v->min_active_dram_clock_change_margin) {
+               v->dram_clock_change_margin =dcn_bw_min2(v->second_min_active_dram_clock_change_margin, v->v_blank_of_min_active_dram_clock_change_margin);
+       }
+       else {
+               v->dram_clock_change_margin = v->min_active_dram_clock_change_margin;
+       }
+       if (v->min_active_dram_clock_change_margin > 0.0) {
+               v->dram_clock_change_support = dcn_bw_supported_in_v_active;
+       }
+       else if (v->dram_clock_change_margin > 0.0) {
+               v->dram_clock_change_support = dcn_bw_supported_in_v_blank;
+       }
+       else {
+               v->dram_clock_change_support = dcn_bw_not_supported;
+       }
+       /*maximum bandwidth used*/
+
+       v->wr_bandwidth = 0.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->output[k] == dcn_bw_writeback && v->output_format[k] == dcn_bw_444) {
+                       v->wr_bandwidth = v->wr_bandwidth + v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) * 4.0;
+               }
+               else if (v->output[k] == dcn_bw_writeback) {
+                       v->wr_bandwidth = v->wr_bandwidth + v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) * 1.5;
+               }
+       }
+       v->max_used_bw = v->max_rd_bandwidth + v->wr_bandwidth;
+}
diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_auto.h b/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_auto.h
new file mode 100644 (file)
index 0000000..ce35de7
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2017 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
+#ifndef _DCN_CALC_AUTO_H_
+#define _DCN_CALC_AUTO_H_
+
+#include "dc.h"
+#include "dcn_calcs.h"
+
+void scaler_settings_calculation(struct dcn_bw_internal_vars *v);
+void mode_support_and_system_configuration(struct dcn_bw_internal_vars *v);
+void display_pipe_configuration(struct dcn_bw_internal_vars *v);
+void dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(
+               struct dcn_bw_internal_vars *v);
+
+#endif /* _DCN_CALC_AUTO_H_ */
diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c b/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c
new file mode 100644 (file)
index 0000000..07d18e7
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2017 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
+#include "dcn_calc_math.h"
+
+#define isNaN(number) ((number) != (number))
+
+/*
+ * NOTE:
+ *   This file is gcc-parseable HW gospel, coming straight from HW engineers.
+ *
+ * It doesn't adhere to Linux kernel style and sometimes will do things in odd
+ * ways. Unless there is something clearly wrong with it the code should
+ * remain as-is as it provides us with a guarantee from HW that it is correct.
+ */
+
+float dcn_bw_mod(const float arg1, const float arg2)
+{
+       if (isNaN(arg1))
+               return arg2;
+       if (isNaN(arg2))
+               return arg1;
+       return arg1 - arg1 * ((int) (arg1 / arg2));
+}
+
+float dcn_bw_min2(const float arg1, const float arg2)
+{
+       if (isNaN(arg1))
+               return arg2;
+       if (isNaN(arg2))
+               return arg1;
+       return arg1 < arg2 ? arg1 : arg2;
+}
+
+unsigned int dcn_bw_max(const unsigned int arg1, const unsigned int arg2)
+{
+       return arg1 > arg2 ? arg1 : arg2;
+}
+float dcn_bw_max2(const float arg1, const float arg2)
+{
+       if (isNaN(arg1))
+               return arg2;
+       if (isNaN(arg2))
+               return arg1;
+       return arg1 > arg2 ? arg1 : arg2;
+}
+
+float dcn_bw_floor2(const float arg, const float significance)
+{
+       if (significance == 0)
+               return 0;
+       return ((int) (arg / significance)) * significance;
+}
+float dcn_bw_floor(const float arg)
+{
+       return ((int) (arg));
+}
+
+float dcn_bw_ceil(const float arg)
+{
+       float flr = dcn_bw_floor2(arg, 1);
+
+       return flr + 0.00001 >= arg ? arg : flr + 1;
+}
+
+float dcn_bw_ceil2(const float arg, const float significance)
+{
+       float flr = dcn_bw_floor2(arg, significance);
+       if (significance == 0)
+               return 0;
+       return flr + 0.00001 >= arg ? arg : flr + significance;
+}
+
+float dcn_bw_max3(float v1, float v2, float v3)
+{
+       return v3 > dcn_bw_max2(v1, v2) ? v3 : dcn_bw_max2(v1, v2);
+}
+
+float dcn_bw_max5(float v1, float v2, float v3, float v4, float v5)
+{
+       return dcn_bw_max3(v1, v2, v3) > dcn_bw_max2(v4, v5) ? dcn_bw_max3(v1, v2, v3) : dcn_bw_max2(v4, v5);
+}
+
+float dcn_bw_pow(float a, float exp)
+{
+       float temp;
+       /*ASSERT(exp == (int)exp);*/
+       if ((int)exp == 0)
+               return 1;
+       temp = dcn_bw_pow(a, (int)(exp / 2));
+       if (((int)exp % 2) == 0) {
+               return temp * temp;
+       } else {
+               if ((int)exp > 0)
+                       return a * temp * temp;
+               else
+                       return (temp * temp) / a;
+       }
+}
+
+double dcn_bw_fabs(double a)
+{
+       if (a > 0)
+               return (a);
+       else
+               return (-a);
+}
+
+
+float dcn_bw_log(float a, float b)
+{
+       int * const exp_ptr = (int *)(&a);
+       int x = *exp_ptr;
+       const int log_2 = ((x >> 23) & 255) - 128;
+       x &= ~(255 << 23);
+       x += 127 << 23;
+       *exp_ptr = x;
+
+       a = ((-1.0f / 3) * a + 2) * a - 2.0f / 3;
+
+       if (b > 2.00001 || b < 1.99999)
+               return (a + log_2) / dcn_bw_log(b, 2);
+       else
+               return (a + log_2);
+}
diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calcs.c b/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calcs.c
new file mode 100644 (file)
index 0000000..ec19678
--- /dev/null
@@ -0,0 +1,1808 @@
+/*
+ * Copyright 2017 Advanced Micro Devices, Inc.
+ * Copyright 2019 Raptor Engineering, LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
+#include "dm_services.h"
+#include "dc.h"
+#include "dcn_calcs.h"
+#include "dcn_calc_auto.h"
+#include "dal_asic_id.h"
+#include "resource.h"
+#include "dcn10/dcn10_resource.h"
+#include "dcn10/dcn10_hubbub.h"
+#include "dml/dml1_display_rq_dlg_calc.h"
+
+#include "dcn_calc_math.h"
+
+#define DC_LOGGER \
+       dc->ctx->logger
+
+#define WM_SET_COUNT 4
+#define WM_A 0
+#define WM_B 1
+#define WM_C 2
+#define WM_D 3
+
+/*
+ * NOTE:
+ *   This file is gcc-parseable HW gospel, coming straight from HW engineers.
+ *
+ * It doesn't adhere to Linux kernel style and sometimes will do things in odd
+ * ways. Unless there is something clearly wrong with it the code should
+ * remain as-is as it provides us with a guarantee from HW that it is correct.
+ */
+
+/* Defaults from spreadsheet rev#247.
+ * RV2 delta: dram_clock_change_latency, max_num_dpp
+ */
+const struct dcn_soc_bounding_box dcn10_soc_defaults = {
+               /* latencies */
+               .sr_exit_time = 17, /*us*/
+               .sr_enter_plus_exit_time = 19, /*us*/
+               .urgent_latency = 4, /*us*/
+               .dram_clock_change_latency = 17, /*us*/
+               .write_back_latency = 12, /*us*/
+               .percent_of_ideal_drambw_received_after_urg_latency = 80, /*%*/
+
+               /* below default clocks derived from STA target base on
+                * slow-slow corner + 10% margin with voltages aligned to FCLK.
+                *
+                * Use these value if fused value doesn't make sense as earlier
+                * part don't have correct value fused */
+               /* default DCF CLK DPM on RV*/
+               .dcfclkv_max0p9 = 655,  /* MHz, = 3600/5.5 */
+               .dcfclkv_nom0p8 = 626,  /* MHz, = 3600/5.75 */
+               .dcfclkv_mid0p72 = 600, /* MHz, = 3600/6, bypass */
+               .dcfclkv_min0p65 = 300, /* MHz, = 3600/12, bypass */
+
+               /* default DISP CLK voltage state on RV */
+               .max_dispclk_vmax0p9 = 1108,    /* MHz, = 3600/3.25 */
+               .max_dispclk_vnom0p8 = 1029,    /* MHz, = 3600/3.5 */
+               .max_dispclk_vmid0p72 = 960,    /* MHz, = 3600/3.75 */
+               .max_dispclk_vmin0p65 = 626,    /* MHz, = 3600/5.75 */
+
+               /* default DPP CLK voltage state on RV */
+               .max_dppclk_vmax0p9 = 720,      /* MHz, = 3600/5 */
+               .max_dppclk_vnom0p8 = 686,      /* MHz, = 3600/5.25 */
+               .max_dppclk_vmid0p72 = 626,     /* MHz, = 3600/5.75 */
+               .max_dppclk_vmin0p65 = 400,     /* MHz, = 3600/9 */
+
+               /* default PHY CLK voltage state on RV */
+               .phyclkv_max0p9 = 900, /*MHz*/
+               .phyclkv_nom0p8 = 847, /*MHz*/
+               .phyclkv_mid0p72 = 800, /*MHz*/
+               .phyclkv_min0p65 = 600, /*MHz*/
+
+               /* BW depend on FCLK, MCLK, # of channels */
+               /* dual channel BW */
+               .fabric_and_dram_bandwidth_vmax0p9 = 38.4f, /*GB/s*/
+               .fabric_and_dram_bandwidth_vnom0p8 = 34.133f, /*GB/s*/
+               .fabric_and_dram_bandwidth_vmid0p72 = 29.866f, /*GB/s*/
+               .fabric_and_dram_bandwidth_vmin0p65 = 12.8f, /*GB/s*/
+               /* single channel BW
+               .fabric_and_dram_bandwidth_vmax0p9 = 19.2f,
+               .fabric_and_dram_bandwidth_vnom0p8 = 17.066f,
+               .fabric_and_dram_bandwidth_vmid0p72 = 14.933f,
+               .fabric_and_dram_bandwidth_vmin0p65 = 12.8f,
+               */
+
+               .number_of_channels = 2,
+
+               .socclk = 208, /*MHz*/
+               .downspreading = 0.5f, /*%*/
+               .round_trip_ping_latency_cycles = 128, /*DCFCLK Cycles*/
+               .urgent_out_of_order_return_per_channel = 256, /*bytes*/
+               .vmm_page_size = 4096, /*bytes*/
+               .return_bus_width = 64, /*bytes*/
+               .max_request_size = 256, /*bytes*/
+
+               /* Depends on user class (client vs embedded, workstation, etc) */
+               .percent_disp_bw_limit = 0.3f /*%*/
+};
+
+const struct dcn_ip_params dcn10_ip_defaults = {
+               .rob_buffer_size_in_kbyte = 64,
+               .det_buffer_size_in_kbyte = 164,
+               .dpp_output_buffer_pixels = 2560,
+               .opp_output_buffer_lines = 1,
+               .pixel_chunk_size_in_kbyte = 8,
+               .pte_enable = dcn_bw_yes,
+               .pte_chunk_size = 2, /*kbytes*/
+               .meta_chunk_size = 2, /*kbytes*/
+               .writeback_chunk_size = 2, /*kbytes*/
+               .odm_capability = dcn_bw_no,
+               .dsc_capability = dcn_bw_no,
+               .line_buffer_size = 589824, /*bit*/
+               .max_line_buffer_lines = 12,
+               .is_line_buffer_bpp_fixed = dcn_bw_no,
+               .line_buffer_fixed_bpp = dcn_bw_na,
+               .writeback_luma_buffer_size = 12, /*kbytes*/
+               .writeback_chroma_buffer_size = 8, /*kbytes*/
+               .max_num_dpp = 4,
+               .max_num_writeback = 2,
+               .max_dchub_topscl_throughput = 4, /*pixels/dppclk*/
+               .max_pscl_tolb_throughput = 2, /*pixels/dppclk*/
+               .max_lb_tovscl_throughput = 4, /*pixels/dppclk*/
+               .max_vscl_tohscl_throughput = 4, /*pixels/dppclk*/
+               .max_hscl_ratio = 4,
+               .max_vscl_ratio = 4,
+               .max_hscl_taps = 8,
+               .max_vscl_taps = 8,
+               .pte_buffer_size_in_requests = 42,
+               .dispclk_ramping_margin = 1, /*%*/
+               .under_scan_factor = 1.11f,
+               .max_inter_dcn_tile_repeaters = 8,
+               .can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one = dcn_bw_no,
+               .bug_forcing_luma_and_chroma_request_to_same_size_fixed = dcn_bw_no,
+               .dcfclk_cstate_latency = 10 /*TODO clone of something else? sr_enter_plus_exit_time?*/
+};
+
+static enum dcn_bw_defs tl_sw_mode_to_bw_defs(enum swizzle_mode_values sw_mode)
+{
+       switch (sw_mode) {
+       case DC_SW_LINEAR:
+               return dcn_bw_sw_linear;
+       case DC_SW_4KB_S:
+               return dcn_bw_sw_4_kb_s;
+       case DC_SW_4KB_D:
+               return dcn_bw_sw_4_kb_d;
+       case DC_SW_64KB_S:
+               return dcn_bw_sw_64_kb_s;
+       case DC_SW_64KB_D:
+               return dcn_bw_sw_64_kb_d;
+       case DC_SW_VAR_S:
+               return dcn_bw_sw_var_s;
+       case DC_SW_VAR_D:
+               return dcn_bw_sw_var_d;
+       case DC_SW_64KB_S_T:
+               return dcn_bw_sw_64_kb_s_t;
+       case DC_SW_64KB_D_T:
+               return dcn_bw_sw_64_kb_d_t;
+       case DC_SW_4KB_S_X:
+               return dcn_bw_sw_4_kb_s_x;
+       case DC_SW_4KB_D_X:
+               return dcn_bw_sw_4_kb_d_x;
+       case DC_SW_64KB_S_X:
+               return dcn_bw_sw_64_kb_s_x;
+       case DC_SW_64KB_D_X:
+               return dcn_bw_sw_64_kb_d_x;
+       case DC_SW_VAR_S_X:
+               return dcn_bw_sw_var_s_x;
+       case DC_SW_VAR_D_X:
+               return dcn_bw_sw_var_d_x;
+       case DC_SW_256B_S:
+       case DC_SW_256_D:
+       case DC_SW_256_R:
+       case DC_SW_4KB_R:
+       case DC_SW_64KB_R:
+       case DC_SW_VAR_R:
+       case DC_SW_4KB_R_X:
+       case DC_SW_64KB_R_X:
+       case DC_SW_VAR_R_X:
+       default:
+               BREAK_TO_DEBUGGER(); /*not in formula*/
+               return dcn_bw_sw_4_kb_s;
+       }
+}
+
+static int tl_lb_bpp_to_int(enum lb_pixel_depth depth)
+{
+       switch (depth) {
+       case LB_PIXEL_DEPTH_18BPP:
+               return 18;
+       case LB_PIXEL_DEPTH_24BPP:
+               return 24;
+       case LB_PIXEL_DEPTH_30BPP:
+               return 30;
+       case LB_PIXEL_DEPTH_36BPP:
+               return 36;
+       default:
+               return 30;
+       }
+}
+
+static enum dcn_bw_defs tl_pixel_format_to_bw_defs(enum surface_pixel_format format)
+{
+       switch (format) {
+       case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555:
+       case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
+               return dcn_bw_rgb_sub_16;
+       case SURFACE_PIXEL_FORMAT_GRPH_ARGB8888:
+       case SURFACE_PIXEL_FORMAT_GRPH_ABGR8888:
+       case SURFACE_PIXEL_FORMAT_GRPH_ARGB2101010:
+       case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010:
+       case SURFACE_PIXEL_FORMAT_GRPH_ABGR2101010_XR_BIAS:
+               return dcn_bw_rgb_sub_32;
+       case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
+       case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616:
+       case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F:
+       case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
+               return dcn_bw_rgb_sub_64;
+       case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
+       case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb:
+               return dcn_bw_yuv420_sub_8;
+       case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
+       case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
+               return dcn_bw_yuv420_sub_10;
+       default:
+               return dcn_bw_rgb_sub_32;
+       }
+}
+
+enum source_macro_tile_size swizzle_mode_to_macro_tile_size(enum swizzle_mode_values sw_mode)
+{
+       switch (sw_mode) {
+       /* for 4/8/16 high tiles */
+       case DC_SW_LINEAR:
+               return dm_4k_tile;
+       case DC_SW_4KB_S:
+       case DC_SW_4KB_S_X:
+               return dm_4k_tile;
+       case DC_SW_64KB_S:
+       case DC_SW_64KB_S_X:
+       case DC_SW_64KB_S_T:
+               return dm_64k_tile;
+       case DC_SW_VAR_S:
+       case DC_SW_VAR_S_X:
+               return dm_256k_tile;
+
+       /* For 64bpp 2 high tiles */
+       case DC_SW_4KB_D:
+       case DC_SW_4KB_D_X:
+               return dm_4k_tile;
+       case DC_SW_64KB_D:
+       case DC_SW_64KB_D_X:
+       case DC_SW_64KB_D_T:
+               return dm_64k_tile;
+       case DC_SW_VAR_D:
+       case DC_SW_VAR_D_X:
+               return dm_256k_tile;
+
+       case DC_SW_4KB_R:
+       case DC_SW_4KB_R_X:
+               return dm_4k_tile;
+       case DC_SW_64KB_R:
+       case DC_SW_64KB_R_X:
+               return dm_64k_tile;
+       case DC_SW_VAR_R:
+       case DC_SW_VAR_R_X:
+               return dm_256k_tile;
+
+       /* Unsupported swizzle modes for dcn */
+       case DC_SW_256B_S:
+       default:
+               ASSERT(0); /* Not supported */
+               return 0;
+       }
+}
+
+static void pipe_ctx_to_e2e_pipe_params (
+               const struct pipe_ctx *pipe,
+               struct _vcs_dpi_display_pipe_params_st *input)
+{
+       input->src.is_hsplit = false;
+
+       /* stereo can never be split */
+       if (pipe->plane_state->stereo_format == PLANE_STEREO_FORMAT_SIDE_BY_SIDE ||
+           pipe->plane_state->stereo_format == PLANE_STEREO_FORMAT_TOP_AND_BOTTOM) {
+               /* reset the split group if it was already considered split. */
+               input->src.hsplit_grp = pipe->pipe_idx;
+       } else if (pipe->top_pipe != NULL && pipe->top_pipe->plane_state == pipe->plane_state) {
+               input->src.is_hsplit = true;
+       } else if (pipe->bottom_pipe != NULL && pipe->bottom_pipe->plane_state == pipe->plane_state) {
+               input->src.is_hsplit = true;
+       }
+
+       if (pipe->plane_res.dpp->ctx->dc->debug.optimized_watermark) {
+               /*
+                * this method requires us to always re-calculate watermark when dcc change
+                * between flip.
+                */
+               input->src.dcc = pipe->plane_state->dcc.enable ? 1 : 0;
+       } else {
+               /*
+                * allow us to disable dcc on the fly without re-calculating WM
+                *
+                * extra overhead for DCC is quite small.  for 1080p WM without
+                * DCC is only 0.417us lower (urgent goes from 6.979us to 6.562us)
+                */
+               unsigned int bpe;
+
+               input->src.dcc = pipe->plane_res.dpp->ctx->dc->res_pool->hubbub->funcs->
+                       dcc_support_pixel_format(pipe->plane_state->format, &bpe) ? 1 : 0;
+       }
+       input->src.dcc_rate            = 1;
+       input->src.meta_pitch          = pipe->plane_state->dcc.meta_pitch;
+       input->src.source_scan         = dm_horz;
+       input->src.sw_mode             = pipe->plane_state->tiling_info.gfx9.swizzle;
+
+       input->src.viewport_width      = pipe->plane_res.scl_data.viewport.width;
+       input->src.viewport_height     = pipe->plane_res.scl_data.viewport.height;
+       input->src.data_pitch          = pipe->plane_res.scl_data.viewport.width;
+       input->src.data_pitch_c        = pipe->plane_res.scl_data.viewport.width;
+       input->src.cur0_src_width      = 128; /* TODO: Cursor calcs, not curently stored */
+       input->src.cur0_bpp            = 32;
+
+       input->src.macro_tile_size = swizzle_mode_to_macro_tile_size(pipe->plane_state->tiling_info.gfx9.swizzle);
+
+       switch (pipe->plane_state->rotation) {
+       case ROTATION_ANGLE_0:
+       case ROTATION_ANGLE_180:
+               input->src.source_scan = dm_horz;
+               break;
+       case ROTATION_ANGLE_90:
+       case ROTATION_ANGLE_270:
+               input->src.source_scan = dm_vert;
+               break;
+       default:
+               ASSERT(0); /* Not supported */
+               break;
+       }
+
+       /* TODO: Fix pixel format mappings */
+       switch (pipe->plane_state->format) {
+       case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
+       case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb:
+               input->src.source_format = dm_420_8;
+               input->src.viewport_width_c    = input->src.viewport_width / 2;
+               input->src.viewport_height_c   = input->src.viewport_height / 2;
+               break;
+       case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
+       case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
+               input->src.source_format = dm_420_10;
+               input->src.viewport_width_c    = input->src.viewport_width / 2;
+               input->src.viewport_height_c   = input->src.viewport_height / 2;
+               break;
+       case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
+       case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616:
+       case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F:
+       case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
+               input->src.source_format = dm_444_64;
+               input->src.viewport_width_c    = input->src.viewport_width;
+               input->src.viewport_height_c   = input->src.viewport_height;
+               break;
+       case SURFACE_PIXEL_FORMAT_GRPH_RGBE_ALPHA:
+               input->src.source_format = dm_rgbe_alpha;
+               input->src.viewport_width_c    = input->src.viewport_width;
+               input->src.viewport_height_c   = input->src.viewport_height;
+               break;
+       default:
+               input->src.source_format = dm_444_32;
+               input->src.viewport_width_c    = input->src.viewport_width;
+               input->src.viewport_height_c   = input->src.viewport_height;
+               break;
+       }
+
+       input->scale_taps.htaps                = pipe->plane_res.scl_data.taps.h_taps;
+       input->scale_ratio_depth.hscl_ratio    = pipe->plane_res.scl_data.ratios.horz.value/4294967296.0;
+       input->scale_ratio_depth.vscl_ratio    = pipe->plane_res.scl_data.ratios.vert.value/4294967296.0;
+       input->scale_ratio_depth.vinit =  pipe->plane_res.scl_data.inits.v.value/4294967296.0;
+       if (input->scale_ratio_depth.vinit < 1.0)
+                       input->scale_ratio_depth.vinit = 1;
+       input->scale_taps.vtaps = pipe->plane_res.scl_data.taps.v_taps;
+       input->scale_taps.vtaps_c = pipe->plane_res.scl_data.taps.v_taps_c;
+       input->scale_taps.htaps_c              = pipe->plane_res.scl_data.taps.h_taps_c;
+       input->scale_ratio_depth.hscl_ratio_c  = pipe->plane_res.scl_data.ratios.horz_c.value/4294967296.0;
+       input->scale_ratio_depth.vscl_ratio_c  = pipe->plane_res.scl_data.ratios.vert_c.value/4294967296.0;
+       input->scale_ratio_depth.vinit_c       = pipe->plane_res.scl_data.inits.v_c.value/4294967296.0;
+       if (input->scale_ratio_depth.vinit_c < 1.0)
+                       input->scale_ratio_depth.vinit_c = 1;
+       switch (pipe->plane_res.scl_data.lb_params.depth) {
+       case LB_PIXEL_DEPTH_30BPP:
+               input->scale_ratio_depth.lb_depth = 30; break;
+       case LB_PIXEL_DEPTH_36BPP:
+               input->scale_ratio_depth.lb_depth = 36; break;
+       default:
+               input->scale_ratio_depth.lb_depth = 24; break;
+       }
+
+
+       input->dest.vactive        = pipe->stream->timing.v_addressable + pipe->stream->timing.v_border_top
+                       + pipe->stream->timing.v_border_bottom;
+
+       input->dest.recout_width   = pipe->plane_res.scl_data.recout.width;
+       input->dest.recout_height  = pipe->plane_res.scl_data.recout.height;
+
+       input->dest.full_recout_width   = pipe->plane_res.scl_data.recout.width;
+       input->dest.full_recout_height  = pipe->plane_res.scl_data.recout.height;
+
+       input->dest.htotal         = pipe->stream->timing.h_total;
+       input->dest.hblank_start   = input->dest.htotal - pipe->stream->timing.h_front_porch;
+       input->dest.hblank_end     = input->dest.hblank_start
+                       - pipe->stream->timing.h_addressable
+                       - pipe->stream->timing.h_border_left
+                       - pipe->stream->timing.h_border_right;
+
+       input->dest.vtotal         = pipe->stream->timing.v_total;
+       input->dest.vblank_start   = input->dest.vtotal - pipe->stream->timing.v_front_porch;
+       input->dest.vblank_end     = input->dest.vblank_start
+                       - pipe->stream->timing.v_addressable
+                       - pipe->stream->timing.v_border_bottom
+                       - pipe->stream->timing.v_border_top;
+       input->dest.pixel_rate_mhz = pipe->stream->timing.pix_clk_100hz/10000.0;
+       input->dest.vstartup_start = pipe->pipe_dlg_param.vstartup_start;
+       input->dest.vupdate_offset = pipe->pipe_dlg_param.vupdate_offset;
+       input->dest.vupdate_offset = pipe->pipe_dlg_param.vupdate_offset;
+       input->dest.vupdate_width = pipe->pipe_dlg_param.vupdate_width;
+
+}
+
+static void dcn_bw_calc_rq_dlg_ttu(
+               const struct dc *dc,
+               const struct dcn_bw_internal_vars *v,
+               struct pipe_ctx *pipe,
+               int in_idx)
+{
+       struct display_mode_lib *dml = (struct display_mode_lib *)(&dc->dml);
+       struct _vcs_dpi_display_dlg_regs_st *dlg_regs = &pipe->dlg_regs;
+       struct _vcs_dpi_display_ttu_regs_st *ttu_regs = &pipe->ttu_regs;
+       struct _vcs_dpi_display_rq_regs_st *rq_regs = &pipe->rq_regs;
+       struct _vcs_dpi_display_rq_params_st *rq_param = &pipe->dml_rq_param;
+       struct _vcs_dpi_display_dlg_sys_params_st *dlg_sys_param = &pipe->dml_dlg_sys_param;
+       struct _vcs_dpi_display_e2e_pipe_params_st *input = &pipe->dml_input;
+       float total_active_bw = 0;
+       float total_prefetch_bw = 0;
+       int total_flip_bytes = 0;
+       int i;
+
+       memset(dlg_regs, 0, sizeof(*dlg_regs));
+       memset(ttu_regs, 0, sizeof(*ttu_regs));
+       memset(rq_regs, 0, sizeof(*rq_regs));
+       memset(rq_param, 0, sizeof(*rq_param));
+       memset(dlg_sys_param, 0, sizeof(*dlg_sys_param));
+       memset(input, 0, sizeof(*input));
+
+       for (i = 0; i < number_of_planes; i++) {
+               total_active_bw += v->read_bandwidth[i];
+               total_prefetch_bw += v->prefetch_bandwidth[i];
+               total_flip_bytes += v->total_immediate_flip_bytes[i];
+       }
+       dlg_sys_param->total_flip_bw = v->return_bw - dcn_bw_max2(total_active_bw, total_prefetch_bw);
+       if (dlg_sys_param->total_flip_bw < 0.0)
+               dlg_sys_param->total_flip_bw = 0;
+
+       dlg_sys_param->t_mclk_wm_us = v->dram_clock_change_watermark;
+       dlg_sys_param->t_sr_wm_us = v->stutter_enter_plus_exit_watermark;
+       dlg_sys_param->t_urg_wm_us = v->urgent_watermark;
+       dlg_sys_param->t_extra_us = v->urgent_extra_latency;
+       dlg_sys_param->deepsleep_dcfclk_mhz = v->dcf_clk_deep_sleep;
+       dlg_sys_param->total_flip_bytes = total_flip_bytes;
+
+       pipe_ctx_to_e2e_pipe_params(pipe, &input->pipe);
+       input->clks_cfg.dcfclk_mhz = v->dcfclk;
+       input->clks_cfg.dispclk_mhz = v->dispclk;
+       input->clks_cfg.dppclk_mhz = v->dppclk;
+       input->clks_cfg.refclk_mhz = dc->res_pool->ref_clocks.dchub_ref_clock_inKhz / 1000.0;
+       input->clks_cfg.socclk_mhz = v->socclk;
+       input->clks_cfg.voltage = v->voltage_level;
+//     dc->dml.logger = pool->base.logger;
+       input->dout.output_format = (v->output_format[in_idx] == dcn_bw_420) ? dm_420 : dm_444;
+       input->dout.output_type  = (v->output[in_idx] == dcn_bw_hdmi) ? dm_hdmi : dm_dp;
+       //input[in_idx].dout.output_standard;
+
+       /*todo: soc->sr_enter_plus_exit_time??*/
+       dlg_sys_param->t_srx_delay_us = dc->dcn_ip->dcfclk_cstate_latency / v->dcf_clk_deep_sleep;
+
+       dml1_rq_dlg_get_rq_params(dml, rq_param, &input->pipe.src);
+       dml1_extract_rq_regs(dml, rq_regs, rq_param);
+       dml1_rq_dlg_get_dlg_params(
+                       dml,
+                       dlg_regs,
+                       ttu_regs,
+                       &rq_param->dlg,
+                       dlg_sys_param,
+                       input,
+                       true,
+                       true,
+                       v->pte_enable == dcn_bw_yes,
+                       pipe->plane_state->flip_immediate);
+}
+
+static void split_stream_across_pipes(
+               struct resource_context *res_ctx,
+               const struct resource_pool *pool,
+               struct pipe_ctx *primary_pipe,
+               struct pipe_ctx *secondary_pipe)
+{
+       int pipe_idx = secondary_pipe->pipe_idx;
+
+       if (!primary_pipe->plane_state)
+               return;
+
+       *secondary_pipe = *primary_pipe;
+
+       secondary_pipe->pipe_idx = pipe_idx;
+       secondary_pipe->plane_res.mi = pool->mis[secondary_pipe->pipe_idx];
+       secondary_pipe->plane_res.hubp = pool->hubps[secondary_pipe->pipe_idx];
+       secondary_pipe->plane_res.ipp = pool->ipps[secondary_pipe->pipe_idx];
+       secondary_pipe->plane_res.xfm = pool->transforms[secondary_pipe->pipe_idx];
+       secondary_pipe->plane_res.dpp = pool->dpps[secondary_pipe->pipe_idx];
+       secondary_pipe->plane_res.mpcc_inst = pool->dpps[secondary_pipe->pipe_idx]->inst;
+       if (primary_pipe->bottom_pipe) {
+               ASSERT(primary_pipe->bottom_pipe != secondary_pipe);
+               secondary_pipe->bottom_pipe = primary_pipe->bottom_pipe;
+               secondary_pipe->bottom_pipe->top_pipe = secondary_pipe;
+       }
+       primary_pipe->bottom_pipe = secondary_pipe;
+       secondary_pipe->top_pipe = primary_pipe;
+
+       resource_build_scaling_params(primary_pipe);
+       resource_build_scaling_params(secondary_pipe);
+}
+
+#if 0
+static void calc_wm_sets_and_perf_params(
+               struct dc_state *context,
+               struct dcn_bw_internal_vars *v)
+{
+       /* Calculate set A last to keep internal var state consistent for required config */
+       if (v->voltage_level < 2) {
+               v->fabric_and_dram_bandwidth_per_state[1] = v->fabric_and_dram_bandwidth_vnom0p8;
+               v->fabric_and_dram_bandwidth_per_state[0] = v->fabric_and_dram_bandwidth_vnom0p8;
+               v->fabric_and_dram_bandwidth = v->fabric_and_dram_bandwidth_vnom0p8;
+               dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(v);
+
+               context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_exit_ns =
+                       v->stutter_exit_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_enter_plus_exit_ns =
+                               v->stutter_enter_plus_exit_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.pstate_change_ns =
+                               v->dram_clock_change_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.b.pte_meta_urgent_ns = v->ptemeta_urgent_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.b.urgent_ns = v->urgent_watermark * 1000;
+
+               v->dcfclk_per_state[1] = v->dcfclkv_nom0p8;
+               v->dcfclk_per_state[0] = v->dcfclkv_nom0p8;
+               v->dcfclk = v->dcfclkv_nom0p8;
+               dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(v);
+
+               context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_exit_ns =
+                       v->stutter_exit_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_enter_plus_exit_ns =
+                               v->stutter_enter_plus_exit_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.pstate_change_ns =
+                               v->dram_clock_change_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.c.pte_meta_urgent_ns = v->ptemeta_urgent_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.c.urgent_ns = v->urgent_watermark * 1000;
+       }
+
+       if (v->voltage_level < 3) {
+               v->fabric_and_dram_bandwidth_per_state[2] = v->fabric_and_dram_bandwidth_vmax0p9;
+               v->fabric_and_dram_bandwidth_per_state[1] = v->fabric_and_dram_bandwidth_vmax0p9;
+               v->fabric_and_dram_bandwidth_per_state[0] = v->fabric_and_dram_bandwidth_vmax0p9;
+               v->fabric_and_dram_bandwidth = v->fabric_and_dram_bandwidth_vmax0p9;
+               v->dcfclk_per_state[2] = v->dcfclkv_max0p9;
+               v->dcfclk_per_state[1] = v->dcfclkv_max0p9;
+               v->dcfclk_per_state[0] = v->dcfclkv_max0p9;
+               v->dcfclk = v->dcfclkv_max0p9;
+               dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(v);
+
+               context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_exit_ns =
+                       v->stutter_exit_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_enter_plus_exit_ns =
+                               v->stutter_enter_plus_exit_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.pstate_change_ns =
+                               v->dram_clock_change_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.d.pte_meta_urgent_ns = v->ptemeta_urgent_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.d.urgent_ns = v->urgent_watermark * 1000;
+       }
+
+       v->fabric_and_dram_bandwidth_per_state[2] = v->fabric_and_dram_bandwidth_vnom0p8;
+       v->fabric_and_dram_bandwidth_per_state[1] = v->fabric_and_dram_bandwidth_vmid0p72;
+       v->fabric_and_dram_bandwidth_per_state[0] = v->fabric_and_dram_bandwidth_vmin0p65;
+       v->fabric_and_dram_bandwidth = v->fabric_and_dram_bandwidth_per_state[v->voltage_level];
+       v->dcfclk_per_state[2] = v->dcfclkv_nom0p8;
+       v->dcfclk_per_state[1] = v->dcfclkv_mid0p72;
+       v->dcfclk_per_state[0] = v->dcfclkv_min0p65;
+       v->dcfclk = v->dcfclk_per_state[v->voltage_level];
+       dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(v);
+
+       context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_exit_ns =
+               v->stutter_exit_watermark * 1000;
+       context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_enter_plus_exit_ns =
+                       v->stutter_enter_plus_exit_watermark * 1000;
+       context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.pstate_change_ns =
+                       v->dram_clock_change_watermark * 1000;
+       context->bw_ctx.bw.dcn.watermarks.a.pte_meta_urgent_ns = v->ptemeta_urgent_watermark * 1000;
+       context->bw_ctx.bw.dcn.watermarks.a.urgent_ns = v->urgent_watermark * 1000;
+       if (v->voltage_level >= 2) {
+               context->bw_ctx.bw.dcn.watermarks.b = context->bw_ctx.bw.dcn.watermarks.a;
+               context->bw_ctx.bw.dcn.watermarks.c = context->bw_ctx.bw.dcn.watermarks.a;
+       }
+       if (v->voltage_level >= 3)
+               context->bw_ctx.bw.dcn.watermarks.d = context->bw_ctx.bw.dcn.watermarks.a;
+}
+#endif
+
+static bool dcn_bw_apply_registry_override(struct dc *dc)
+{
+       bool updated = false;
+
+       DC_FP_START();
+       if ((int)(dc->dcn_soc->sr_exit_time * 1000) != dc->debug.sr_exit_time_ns
+                       && dc->debug.sr_exit_time_ns) {
+               updated = true;
+               dc->dcn_soc->sr_exit_time = dc->debug.sr_exit_time_ns / 1000.0;
+       }
+
+       if ((int)(dc->dcn_soc->sr_enter_plus_exit_time * 1000)
+                               != dc->debug.sr_enter_plus_exit_time_ns
+                       && dc->debug.sr_enter_plus_exit_time_ns) {
+               updated = true;
+               dc->dcn_soc->sr_enter_plus_exit_time =
+                               dc->debug.sr_enter_plus_exit_time_ns / 1000.0;
+       }
+
+       if ((int)(dc->dcn_soc->urgent_latency * 1000) != dc->debug.urgent_latency_ns
+                       && dc->debug.urgent_latency_ns) {
+               updated = true;
+               dc->dcn_soc->urgent_latency = dc->debug.urgent_latency_ns / 1000.0;
+       }
+
+       if ((int)(dc->dcn_soc->percent_of_ideal_drambw_received_after_urg_latency * 1000)
+                               != dc->debug.percent_of_ideal_drambw
+                       && dc->debug.percent_of_ideal_drambw) {
+               updated = true;
+               dc->dcn_soc->percent_of_ideal_drambw_received_after_urg_latency =
+                               dc->debug.percent_of_ideal_drambw;
+       }
+
+       if ((int)(dc->dcn_soc->dram_clock_change_latency * 1000)
+                               != dc->debug.dram_clock_change_latency_ns
+                       && dc->debug.dram_clock_change_latency_ns) {
+               updated = true;
+               dc->dcn_soc->dram_clock_change_latency =
+                               dc->debug.dram_clock_change_latency_ns / 1000.0;
+       }
+       DC_FP_END();
+
+       return updated;
+}
+
+static void hack_disable_optional_pipe_split(struct dcn_bw_internal_vars *v)
+{
+       /*
+        * disable optional pipe split by lower dispclk bounding box
+        * at DPM0
+        */
+       v->max_dispclk[0] = v->max_dppclk_vmin0p65;
+}
+
+static void hack_force_pipe_split(struct dcn_bw_internal_vars *v,
+               unsigned int pixel_rate_100hz)
+{
+       float pixel_rate_mhz = pixel_rate_100hz / 10000;
+
+       /*
+        * force enabling pipe split by lower dpp clock for DPM0 to just
+        * below the specify pixel_rate, so bw calc would split pipe.
+        */
+       if (pixel_rate_mhz < v->max_dppclk[0])
+               v->max_dppclk[0] = pixel_rate_mhz;
+}
+
+static void hack_bounding_box(struct dcn_bw_internal_vars *v,
+               struct dc_debug_options *dbg,
+               struct dc_state *context)
+{
+       int i;
+
+       for (i = 0; i < MAX_PIPES; i++) {
+               struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
+
+               /**
+                * Workaround for avoiding pipe-split in cases where we'd split
+                * planes that are too small, resulting in splits that aren't
+                * valid for the scaler.
+                */
+               if (pipe->plane_state &&
+                   (pipe->plane_state->dst_rect.width <= 16 ||
+                    pipe->plane_state->dst_rect.height <= 16 ||
+                    pipe->plane_state->src_rect.width <= 16 ||
+                    pipe->plane_state->src_rect.height <= 16)) {
+                       hack_disable_optional_pipe_split(v);
+                       return;
+               }
+       }
+
+       if (dbg->pipe_split_policy == MPC_SPLIT_AVOID)
+               hack_disable_optional_pipe_split(v);
+
+       if (dbg->pipe_split_policy == MPC_SPLIT_AVOID_MULT_DISP &&
+               context->stream_count >= 2)
+               hack_disable_optional_pipe_split(v);
+
+       if (context->stream_count == 1 &&
+                       dbg->force_single_disp_pipe_split)
+               hack_force_pipe_split(v, context->streams[0]->timing.pix_clk_100hz);
+}
+
+static unsigned int get_highest_allowed_voltage_level(uint32_t chip_family,
+                                                     uint32_t hw_internal_rev,
+                                                     uint32_t pci_revision_id)
+{
+       /* for low power RV2 variants, the highest voltage level we want is 0 */
+       if ((chip_family == FAMILY_RV) &&
+            ASICREV_IS_RAVEN2(hw_internal_rev))
+               switch (pci_revision_id) {
+               case PRID_DALI_DE:
+               case PRID_DALI_DF:
+               case PRID_DALI_E3:
+               case PRID_DALI_E4:
+               case PRID_POLLOCK_94:
+               case PRID_POLLOCK_95:
+               case PRID_POLLOCK_E9:
+               case PRID_POLLOCK_EA:
+               case PRID_POLLOCK_EB:
+                       return 0;
+               default:
+                       break;
+               }
+
+       /* we are ok with all levels */
+       return 4;
+}
+
+bool dcn10_validate_bandwidth(
+               struct dc *dc,
+               struct dc_state *context,
+               bool fast_validate)
+{
+       /*
+        * we want a breakdown of the various stages of validation, which the
+        * perf_trace macro doesn't support
+        */
+       BW_VAL_TRACE_SETUP();
+
+       const struct resource_pool *pool = dc->res_pool;
+       struct dcn_bw_internal_vars *v = &context->dcn_bw_vars;
+       int i, input_idx, k;
+       int vesa_sync_start, asic_blank_end, asic_blank_start;
+       bool bw_limit_pass;
+       float bw_limit;
+
+       PERFORMANCE_TRACE_START();
+
+       BW_VAL_TRACE_COUNT();
+
+       if (dcn_bw_apply_registry_override(dc))
+               dcn_bw_sync_calcs_and_dml(dc);
+
+       memset(v, 0, sizeof(*v));
+       DC_FP_START();
+
+       v->sr_exit_time = dc->dcn_soc->sr_exit_time;
+       v->sr_enter_plus_exit_time = dc->dcn_soc->sr_enter_plus_exit_time;
+       v->urgent_latency = dc->dcn_soc->urgent_latency;
+       v->write_back_latency = dc->dcn_soc->write_back_latency;
+       v->percent_of_ideal_drambw_received_after_urg_latency =
+                       dc->dcn_soc->percent_of_ideal_drambw_received_after_urg_latency;
+
+       v->dcfclkv_min0p65 = dc->dcn_soc->dcfclkv_min0p65;
+       v->dcfclkv_mid0p72 = dc->dcn_soc->dcfclkv_mid0p72;
+       v->dcfclkv_nom0p8 = dc->dcn_soc->dcfclkv_nom0p8;
+       v->dcfclkv_max0p9 = dc->dcn_soc->dcfclkv_max0p9;
+
+       v->max_dispclk_vmin0p65 = dc->dcn_soc->max_dispclk_vmin0p65;
+       v->max_dispclk_vmid0p72 = dc->dcn_soc->max_dispclk_vmid0p72;
+       v->max_dispclk_vnom0p8 = dc->dcn_soc->max_dispclk_vnom0p8;
+       v->max_dispclk_vmax0p9 = dc->dcn_soc->max_dispclk_vmax0p9;
+
+       v->max_dppclk_vmin0p65 = dc->dcn_soc->max_dppclk_vmin0p65;
+       v->max_dppclk_vmid0p72 = dc->dcn_soc->max_dppclk_vmid0p72;
+       v->max_dppclk_vnom0p8 = dc->dcn_soc->max_dppclk_vnom0p8;
+       v->max_dppclk_vmax0p9 = dc->dcn_soc->max_dppclk_vmax0p9;
+
+       v->socclk = dc->dcn_soc->socclk;
+
+       v->fabric_and_dram_bandwidth_vmin0p65 = dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65;
+       v->fabric_and_dram_bandwidth_vmid0p72 = dc->dcn_soc->fabric_and_dram_bandwidth_vmid0p72;
+       v->fabric_and_dram_bandwidth_vnom0p8 = dc->dcn_soc->fabric_and_dram_bandwidth_vnom0p8;
+       v->fabric_and_dram_bandwidth_vmax0p9 = dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9;
+
+       v->phyclkv_min0p65 = dc->dcn_soc->phyclkv_min0p65;
+       v->phyclkv_mid0p72 = dc->dcn_soc->phyclkv_mid0p72;
+       v->phyclkv_nom0p8 = dc->dcn_soc->phyclkv_nom0p8;
+       v->phyclkv_max0p9 = dc->dcn_soc->phyclkv_max0p9;
+
+       v->downspreading = dc->dcn_soc->downspreading;
+       v->round_trip_ping_latency_cycles = dc->dcn_soc->round_trip_ping_latency_cycles;
+       v->urgent_out_of_order_return_per_channel = dc->dcn_soc->urgent_out_of_order_return_per_channel;
+       v->number_of_channels = dc->dcn_soc->number_of_channels;
+       v->vmm_page_size = dc->dcn_soc->vmm_page_size;
+       v->dram_clock_change_latency = dc->dcn_soc->dram_clock_change_latency;
+       v->return_bus_width = dc->dcn_soc->return_bus_width;
+
+       v->rob_buffer_size_in_kbyte = dc->dcn_ip->rob_buffer_size_in_kbyte;
+       v->det_buffer_size_in_kbyte = dc->dcn_ip->det_buffer_size_in_kbyte;
+       v->dpp_output_buffer_pixels = dc->dcn_ip->dpp_output_buffer_pixels;
+       v->opp_output_buffer_lines = dc->dcn_ip->opp_output_buffer_lines;
+       v->pixel_chunk_size_in_kbyte = dc->dcn_ip->pixel_chunk_size_in_kbyte;
+       v->pte_enable = dc->dcn_ip->pte_enable;
+       v->pte_chunk_size = dc->dcn_ip->pte_chunk_size;
+       v->meta_chunk_size = dc->dcn_ip->meta_chunk_size;
+       v->writeback_chunk_size = dc->dcn_ip->writeback_chunk_size;
+       v->odm_capability = dc->dcn_ip->odm_capability;
+       v->dsc_capability = dc->dcn_ip->dsc_capability;
+       v->line_buffer_size = dc->dcn_ip->line_buffer_size;
+       v->is_line_buffer_bpp_fixed = dc->dcn_ip->is_line_buffer_bpp_fixed;
+       v->line_buffer_fixed_bpp = dc->dcn_ip->line_buffer_fixed_bpp;
+       v->max_line_buffer_lines = dc->dcn_ip->max_line_buffer_lines;
+       v->writeback_luma_buffer_size = dc->dcn_ip->writeback_luma_buffer_size;
+       v->writeback_chroma_buffer_size = dc->dcn_ip->writeback_chroma_buffer_size;
+       v->max_num_dpp = dc->dcn_ip->max_num_dpp;
+       v->max_num_writeback = dc->dcn_ip->max_num_writeback;
+       v->max_dchub_topscl_throughput = dc->dcn_ip->max_dchub_topscl_throughput;
+       v->max_pscl_tolb_throughput = dc->dcn_ip->max_pscl_tolb_throughput;
+       v->max_lb_tovscl_throughput = dc->dcn_ip->max_lb_tovscl_throughput;
+       v->max_vscl_tohscl_throughput = dc->dcn_ip->max_vscl_tohscl_throughput;
+       v->max_hscl_ratio = dc->dcn_ip->max_hscl_ratio;
+       v->max_vscl_ratio = dc->dcn_ip->max_vscl_ratio;
+       v->max_hscl_taps = dc->dcn_ip->max_hscl_taps;
+       v->max_vscl_taps = dc->dcn_ip->max_vscl_taps;
+       v->under_scan_factor = dc->dcn_ip->under_scan_factor;
+       v->pte_buffer_size_in_requests = dc->dcn_ip->pte_buffer_size_in_requests;
+       v->dispclk_ramping_margin = dc->dcn_ip->dispclk_ramping_margin;
+       v->max_inter_dcn_tile_repeaters = dc->dcn_ip->max_inter_dcn_tile_repeaters;
+       v->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one =
+                       dc->dcn_ip->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one;
+       v->bug_forcing_luma_and_chroma_request_to_same_size_fixed =
+                       dc->dcn_ip->bug_forcing_luma_and_chroma_request_to_same_size_fixed;
+
+       v->voltage[5] = dcn_bw_no_support;
+       v->voltage[4] = dcn_bw_v_max0p9;
+       v->voltage[3] = dcn_bw_v_max0p9;
+       v->voltage[2] = dcn_bw_v_nom0p8;
+       v->voltage[1] = dcn_bw_v_mid0p72;
+       v->voltage[0] = dcn_bw_v_min0p65;
+       v->fabric_and_dram_bandwidth_per_state[5] = v->fabric_and_dram_bandwidth_vmax0p9;
+       v->fabric_and_dram_bandwidth_per_state[4] = v->fabric_and_dram_bandwidth_vmax0p9;
+       v->fabric_and_dram_bandwidth_per_state[3] = v->fabric_and_dram_bandwidth_vmax0p9;
+       v->fabric_and_dram_bandwidth_per_state[2] = v->fabric_and_dram_bandwidth_vnom0p8;
+       v->fabric_and_dram_bandwidth_per_state[1] = v->fabric_and_dram_bandwidth_vmid0p72;
+       v->fabric_and_dram_bandwidth_per_state[0] = v->fabric_and_dram_bandwidth_vmin0p65;
+       v->dcfclk_per_state[5] = v->dcfclkv_max0p9;
+       v->dcfclk_per_state[4] = v->dcfclkv_max0p9;
+       v->dcfclk_per_state[3] = v->dcfclkv_max0p9;
+       v->dcfclk_per_state[2] = v->dcfclkv_nom0p8;
+       v->dcfclk_per_state[1] = v->dcfclkv_mid0p72;
+       v->dcfclk_per_state[0] = v->dcfclkv_min0p65;
+       v->max_dispclk[5] = v->max_dispclk_vmax0p9;
+       v->max_dispclk[4] = v->max_dispclk_vmax0p9;
+       v->max_dispclk[3] = v->max_dispclk_vmax0p9;
+       v->max_dispclk[2] = v->max_dispclk_vnom0p8;
+       v->max_dispclk[1] = v->max_dispclk_vmid0p72;
+       v->max_dispclk[0] = v->max_dispclk_vmin0p65;
+       v->max_dppclk[5] = v->max_dppclk_vmax0p9;
+       v->max_dppclk[4] = v->max_dppclk_vmax0p9;
+       v->max_dppclk[3] = v->max_dppclk_vmax0p9;
+       v->max_dppclk[2] = v->max_dppclk_vnom0p8;
+       v->max_dppclk[1] = v->max_dppclk_vmid0p72;
+       v->max_dppclk[0] = v->max_dppclk_vmin0p65;
+       v->phyclk_per_state[5] = v->phyclkv_max0p9;
+       v->phyclk_per_state[4] = v->phyclkv_max0p9;
+       v->phyclk_per_state[3] = v->phyclkv_max0p9;
+       v->phyclk_per_state[2] = v->phyclkv_nom0p8;
+       v->phyclk_per_state[1] = v->phyclkv_mid0p72;
+       v->phyclk_per_state[0] = v->phyclkv_min0p65;
+       v->synchronized_vblank = dcn_bw_no;
+       v->ta_pscalculation = dcn_bw_override;
+       v->allow_different_hratio_vratio = dcn_bw_yes;
+
+       for (i = 0, input_idx = 0; i < pool->pipe_count; i++) {
+               struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
+
+               if (!pipe->stream)
+                       continue;
+               /* skip all but first of split pipes */
+               if (pipe->top_pipe && pipe->top_pipe->plane_state == pipe->plane_state)
+                       continue;
+
+               v->underscan_output[input_idx] = false; /* taken care of in recout already*/
+               v->interlace_output[input_idx] = false;
+
+               v->htotal[input_idx] = pipe->stream->timing.h_total;
+               v->vtotal[input_idx] = pipe->stream->timing.v_total;
+               v->vactive[input_idx] = pipe->stream->timing.v_addressable +
+                               pipe->stream->timing.v_border_top + pipe->stream->timing.v_border_bottom;
+               v->v_sync_plus_back_porch[input_idx] = pipe->stream->timing.v_total
+                               - v->vactive[input_idx]
+                               - pipe->stream->timing.v_front_porch;
+               v->pixel_clock[input_idx] = pipe->stream->timing.pix_clk_100hz/10000.0;
+               if (pipe->stream->timing.timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING)
+                       v->pixel_clock[input_idx] *= 2;
+               if (!pipe->plane_state) {
+                       v->dcc_enable[input_idx] = dcn_bw_yes;
+                       v->source_pixel_format[input_idx] = dcn_bw_rgb_sub_32;
+                       v->source_surface_mode[input_idx] = dcn_bw_sw_4_kb_s;
+                       v->lb_bit_per_pixel[input_idx] = 30;
+                       v->viewport_width[input_idx] = pipe->stream->timing.h_addressable;
+                       v->viewport_height[input_idx] = pipe->stream->timing.v_addressable;
+                       /*
+                        * for cases where we have no plane, we want to validate up to 1080p
+                        * source size because here we are only interested in if the output
+                        * timing is supported or not. if we cannot support native resolution
+                        * of the high res display, we still want to support lower res up scale
+                        * to native
+                        */
+                       if (v->viewport_width[input_idx] > 1920)
+                               v->viewport_width[input_idx] = 1920;
+                       if (v->viewport_height[input_idx] > 1080)
+                               v->viewport_height[input_idx] = 1080;
+                       v->scaler_rec_out_width[input_idx] = v->viewport_width[input_idx];
+                       v->scaler_recout_height[input_idx] = v->viewport_height[input_idx];
+                       v->override_hta_ps[input_idx] = 1;
+                       v->override_vta_ps[input_idx] = 1;
+                       v->override_hta_pschroma[input_idx] = 1;
+                       v->override_vta_pschroma[input_idx] = 1;
+                       v->source_scan[input_idx] = dcn_bw_hor;
+
+               } else {
+                       v->viewport_height[input_idx] =  pipe->plane_res.scl_data.viewport.height;
+                       v->viewport_width[input_idx] = pipe->plane_res.scl_data.viewport.width;
+                       v->scaler_rec_out_width[input_idx] = pipe->plane_res.scl_data.recout.width;
+                       v->scaler_recout_height[input_idx] = pipe->plane_res.scl_data.recout.height;
+                       if (pipe->bottom_pipe && pipe->bottom_pipe->plane_state == pipe->plane_state) {
+                               if (pipe->plane_state->rotation % 2 == 0) {
+                                       int viewport_end = pipe->plane_res.scl_data.viewport.width
+                                                       + pipe->plane_res.scl_data.viewport.x;
+                                       int viewport_b_end = pipe->bottom_pipe->plane_res.scl_data.viewport.width
+                                                       + pipe->bottom_pipe->plane_res.scl_data.viewport.x;
+
+                                       if (viewport_end > viewport_b_end)
+                                               v->viewport_width[input_idx] = viewport_end
+                                                       - pipe->bottom_pipe->plane_res.scl_data.viewport.x;
+                                       else
+                                               v->viewport_width[input_idx] = viewport_b_end
+                                                                       - pipe->plane_res.scl_data.viewport.x;
+                               } else  {
+                                       int viewport_end = pipe->plane_res.scl_data.viewport.height
+                                               + pipe->plane_res.scl_data.viewport.y;
+                                       int viewport_b_end = pipe->bottom_pipe->plane_res.scl_data.viewport.height
+                                               + pipe->bottom_pipe->plane_res.scl_data.viewport.y;
+
+                                       if (viewport_end > viewport_b_end)
+                                               v->viewport_height[input_idx] = viewport_end
+                                                       - pipe->bottom_pipe->plane_res.scl_data.viewport.y;
+                                       else
+                                               v->viewport_height[input_idx] = viewport_b_end
+                                                                       - pipe->plane_res.scl_data.viewport.y;
+                               }
+                               v->scaler_rec_out_width[input_idx] = pipe->plane_res.scl_data.recout.width
+                                               + pipe->bottom_pipe->plane_res.scl_data.recout.width;
+                       }
+
+                       if (pipe->plane_state->rotation % 2 == 0) {
+                               ASSERT(pipe->plane_res.scl_data.ratios.horz.value != dc_fixpt_one.value
+                                       || v->scaler_rec_out_width[input_idx] == v->viewport_width[input_idx]);
+                               ASSERT(pipe->plane_res.scl_data.ratios.vert.value != dc_fixpt_one.value
+                                       || v->scaler_recout_height[input_idx] == v->viewport_height[input_idx]);
+                       } else {
+                               ASSERT(pipe->plane_res.scl_data.ratios.horz.value != dc_fixpt_one.value
+                                       || v->scaler_recout_height[input_idx] == v->viewport_width[input_idx]);
+                               ASSERT(pipe->plane_res.scl_data.ratios.vert.value != dc_fixpt_one.value
+                                       || v->scaler_rec_out_width[input_idx] == v->viewport_height[input_idx]);
+                       }
+
+                       if (dc->debug.optimized_watermark) {
+                               /*
+                                * this method requires us to always re-calculate watermark when dcc change
+                                * between flip.
+                                */
+                               v->dcc_enable[input_idx] = pipe->plane_state->dcc.enable ? dcn_bw_yes : dcn_bw_no;
+                       } else {
+                               /*
+                                * allow us to disable dcc on the fly without re-calculating WM
+                                *
+                                * extra overhead for DCC is quite small.  for 1080p WM without
+                                * DCC is only 0.417us lower (urgent goes from 6.979us to 6.562us)
+                                */
+                               unsigned int bpe;
+
+                               v->dcc_enable[input_idx] = dc->res_pool->hubbub->funcs->dcc_support_pixel_format(
+                                               pipe->plane_state->format, &bpe) ? dcn_bw_yes : dcn_bw_no;
+                       }
+
+                       v->source_pixel_format[input_idx] = tl_pixel_format_to_bw_defs(
+                                       pipe->plane_state->format);
+                       v->source_surface_mode[input_idx] = tl_sw_mode_to_bw_defs(
+                                       pipe->plane_state->tiling_info.gfx9.swizzle);
+                       v->lb_bit_per_pixel[input_idx] = tl_lb_bpp_to_int(pipe->plane_res.scl_data.lb_params.depth);
+                       v->override_hta_ps[input_idx] = pipe->plane_res.scl_data.taps.h_taps;
+                       v->override_vta_ps[input_idx] = pipe->plane_res.scl_data.taps.v_taps;
+                       v->override_hta_pschroma[input_idx] = pipe->plane_res.scl_data.taps.h_taps_c;
+                       v->override_vta_pschroma[input_idx] = pipe->plane_res.scl_data.taps.v_taps_c;
+                       /*
+                        * Spreadsheet doesn't handle taps_c is one properly,
+                        * need to force Chroma to always be scaled to pass
+                        * bandwidth validation.
+                        */
+                       if (v->override_hta_pschroma[input_idx] == 1)
+                               v->override_hta_pschroma[input_idx] = 2;
+                       if (v->override_vta_pschroma[input_idx] == 1)
+                               v->override_vta_pschroma[input_idx] = 2;
+                       v->source_scan[input_idx] = (pipe->plane_state->rotation % 2) ? dcn_bw_vert : dcn_bw_hor;
+               }
+               if (v->is_line_buffer_bpp_fixed == dcn_bw_yes)
+                       v->lb_bit_per_pixel[input_idx] = v->line_buffer_fixed_bpp;
+               v->dcc_rate[input_idx] = 1; /*TODO: Worst case? does this change?*/
+               v->output_format[input_idx] = pipe->stream->timing.pixel_encoding ==
+                               PIXEL_ENCODING_YCBCR420 ? dcn_bw_420 : dcn_bw_444;
+               v->output[input_idx] = pipe->stream->signal ==
+                               SIGNAL_TYPE_HDMI_TYPE_A ? dcn_bw_hdmi : dcn_bw_dp;
+               v->output_deep_color[input_idx] = dcn_bw_encoder_8bpc;
+               if (v->output[input_idx] == dcn_bw_hdmi) {
+                       switch (pipe->stream->timing.display_color_depth) {
+                       case COLOR_DEPTH_101010:
+                               v->output_deep_color[input_idx] = dcn_bw_encoder_10bpc;
+                               break;
+                       case COLOR_DEPTH_121212:
+                               v->output_deep_color[input_idx]  = dcn_bw_encoder_12bpc;
+                               break;
+                       case COLOR_DEPTH_161616:
+                               v->output_deep_color[input_idx]  = dcn_bw_encoder_16bpc;
+                               break;
+                       default:
+                               break;
+                       }
+               }
+
+               input_idx++;
+       }
+       v->number_of_active_planes = input_idx;
+
+       scaler_settings_calculation(v);
+
+       hack_bounding_box(v, &dc->debug, context);
+
+       mode_support_and_system_configuration(v);
+
+       /* Unhack dppclk: dont bother with trying to pipe split if we cannot maintain dpm0 */
+       if (v->voltage_level != 0
+                       && context->stream_count == 1
+                       && dc->debug.force_single_disp_pipe_split) {
+               v->max_dppclk[0] = v->max_dppclk_vmin0p65;
+               mode_support_and_system_configuration(v);
+       }
+
+       if (v->voltage_level == 0 &&
+                       (dc->debug.sr_exit_time_dpm0_ns
+                               || dc->debug.sr_enter_plus_exit_time_dpm0_ns)) {
+
+               if (dc->debug.sr_enter_plus_exit_time_dpm0_ns)
+                       v->sr_enter_plus_exit_time =
+                               dc->debug.sr_enter_plus_exit_time_dpm0_ns / 1000.0f;
+               if (dc->debug.sr_exit_time_dpm0_ns)
+                       v->sr_exit_time =  dc->debug.sr_exit_time_dpm0_ns / 1000.0f;
+               context->bw_ctx.dml.soc.sr_enter_plus_exit_time_us = v->sr_enter_plus_exit_time;
+               context->bw_ctx.dml.soc.sr_exit_time_us = v->sr_exit_time;
+               mode_support_and_system_configuration(v);
+       }
+
+       display_pipe_configuration(v);
+
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->source_scan[k] == dcn_bw_hor)
+                       v->swath_width_y[k] = v->viewport_width[k] / v->dpp_per_plane[k];
+               else
+                       v->swath_width_y[k] = v->viewport_height[k] / v->dpp_per_plane[k];
+       }
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
+                       v->byte_per_pixel_dety[k] = 8.0;
+                       v->byte_per_pixel_detc[k] = 0.0;
+               } else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_32) {
+                       v->byte_per_pixel_dety[k] = 4.0;
+                       v->byte_per_pixel_detc[k] = 0.0;
+               } else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_16) {
+                       v->byte_per_pixel_dety[k] = 2.0;
+                       v->byte_per_pixel_detc[k] = 0.0;
+               } else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
+                       v->byte_per_pixel_dety[k] = 1.0;
+                       v->byte_per_pixel_detc[k] = 2.0;
+               } else {
+                       v->byte_per_pixel_dety[k] = 4.0f / 3.0f;
+                       v->byte_per_pixel_detc[k] = 8.0f / 3.0f;
+               }
+       }
+
+       v->total_data_read_bandwidth = 0.0;
+       for (k = 0; k <= v->number_of_active_planes - 1; k++) {
+               v->read_bandwidth_plane_luma[k] = v->swath_width_y[k] * v->dpp_per_plane[k] *
+                               dcn_bw_ceil2(v->byte_per_pixel_dety[k], 1.0) / (v->htotal[k] / v->pixel_clock[k]) * v->v_ratio[k];
+               v->read_bandwidth_plane_chroma[k] = v->swath_width_y[k] / 2.0 * v->dpp_per_plane[k] *
+                               dcn_bw_ceil2(v->byte_per_pixel_detc[k], 2.0) / (v->htotal[k] / v->pixel_clock[k]) * v->v_ratio[k] / 2.0;
+               v->total_data_read_bandwidth = v->total_data_read_bandwidth +
+                               v->read_bandwidth_plane_luma[k] + v->read_bandwidth_plane_chroma[k];
+       }
+
+       BW_VAL_TRACE_END_VOLTAGE_LEVEL();
+
+       if (v->voltage_level != number_of_states_plus_one && !fast_validate) {
+               float bw_consumed = v->total_bandwidth_consumed_gbyte_per_second;
+
+               if (bw_consumed < v->fabric_and_dram_bandwidth_vmin0p65)
+                       bw_consumed = v->fabric_and_dram_bandwidth_vmin0p65;
+               else if (bw_consumed < v->fabric_and_dram_bandwidth_vmid0p72)
+                       bw_consumed = v->fabric_and_dram_bandwidth_vmid0p72;
+               else if (bw_consumed < v->fabric_and_dram_bandwidth_vnom0p8)
+                       bw_consumed = v->fabric_and_dram_bandwidth_vnom0p8;
+               else
+                       bw_consumed = v->fabric_and_dram_bandwidth_vmax0p9;
+
+               if (bw_consumed < v->fabric_and_dram_bandwidth)
+                       if (dc->debug.voltage_align_fclk)
+                               bw_consumed = v->fabric_and_dram_bandwidth;
+
+               display_pipe_configuration(v);
+               /*calc_wm_sets_and_perf_params(context, v);*/
+               /* Only 1 set is used by dcn since no noticeable
+                * performance improvement was measured and due to hw bug DEGVIDCN10-254
+                */
+               dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(v);
+
+               context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_exit_ns =
+                       v->stutter_exit_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_enter_plus_exit_ns =
+                               v->stutter_enter_plus_exit_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.pstate_change_ns =
+                               v->dram_clock_change_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.a.pte_meta_urgent_ns = v->ptemeta_urgent_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.a.urgent_ns = v->urgent_watermark * 1000;
+               context->bw_ctx.bw.dcn.watermarks.b = context->bw_ctx.bw.dcn.watermarks.a;
+               context->bw_ctx.bw.dcn.watermarks.c = context->bw_ctx.bw.dcn.watermarks.a;
+               context->bw_ctx.bw.dcn.watermarks.d = context->bw_ctx.bw.dcn.watermarks.a;
+
+               context->bw_ctx.bw.dcn.clk.fclk_khz = (int)(bw_consumed * 1000000 /
+                               (ddr4_dram_factor_single_Channel * v->number_of_channels));
+               if (bw_consumed == v->fabric_and_dram_bandwidth_vmin0p65)
+                       context->bw_ctx.bw.dcn.clk.fclk_khz = (int)(bw_consumed * 1000000 / 32);
+
+               context->bw_ctx.bw.dcn.clk.dcfclk_deep_sleep_khz = (int)(v->dcf_clk_deep_sleep * 1000);
+               context->bw_ctx.bw.dcn.clk.dcfclk_khz = (int)(v->dcfclk * 1000);
+
+               context->bw_ctx.bw.dcn.clk.dispclk_khz = (int)(v->dispclk * 1000);
+               if (dc->debug.max_disp_clk == true)
+                       context->bw_ctx.bw.dcn.clk.dispclk_khz = (int)(dc->dcn_soc->max_dispclk_vmax0p9 * 1000);
+
+               if (context->bw_ctx.bw.dcn.clk.dispclk_khz <
+                               dc->debug.min_disp_clk_khz) {
+                       context->bw_ctx.bw.dcn.clk.dispclk_khz =
+                                       dc->debug.min_disp_clk_khz;
+               }
+
+               context->bw_ctx.bw.dcn.clk.dppclk_khz = context->bw_ctx.bw.dcn.clk.dispclk_khz /
+                               v->dispclk_dppclk_ratio;
+               context->bw_ctx.bw.dcn.clk.phyclk_khz = v->phyclk_per_state[v->voltage_level];
+               switch (v->voltage_level) {
+               case 0:
+                       context->bw_ctx.bw.dcn.clk.max_supported_dppclk_khz =
+                                       (int)(dc->dcn_soc->max_dppclk_vmin0p65 * 1000);
+                       break;
+               case 1:
+                       context->bw_ctx.bw.dcn.clk.max_supported_dppclk_khz =
+                                       (int)(dc->dcn_soc->max_dppclk_vmid0p72 * 1000);
+                       break;
+               case 2:
+                       context->bw_ctx.bw.dcn.clk.max_supported_dppclk_khz =
+                                       (int)(dc->dcn_soc->max_dppclk_vnom0p8 * 1000);
+                       break;
+               default:
+                       context->bw_ctx.bw.dcn.clk.max_supported_dppclk_khz =
+                                       (int)(dc->dcn_soc->max_dppclk_vmax0p9 * 1000);
+                       break;
+               }
+
+               BW_VAL_TRACE_END_WATERMARKS();
+
+               for (i = 0, input_idx = 0; i < pool->pipe_count; i++) {
+                       struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
+
+                       /* skip inactive pipe */
+                       if (!pipe->stream)
+                               continue;
+                       /* skip all but first of split pipes */
+                       if (pipe->top_pipe && pipe->top_pipe->plane_state == pipe->plane_state)
+                               continue;
+
+                       pipe->pipe_dlg_param.vupdate_width = v->v_update_width_pix[input_idx];
+                       pipe->pipe_dlg_param.vupdate_offset = v->v_update_offset_pix[input_idx];
+                       pipe->pipe_dlg_param.vready_offset = v->v_ready_offset_pix[input_idx];
+                       pipe->pipe_dlg_param.vstartup_start = v->v_startup[input_idx];
+
+                       pipe->pipe_dlg_param.htotal = pipe->stream->timing.h_total;
+                       pipe->pipe_dlg_param.vtotal = pipe->stream->timing.v_total;
+                       vesa_sync_start = pipe->stream->timing.v_addressable +
+                                               pipe->stream->timing.v_border_bottom +
+                                               pipe->stream->timing.v_front_porch;
+
+                       asic_blank_end = (pipe->stream->timing.v_total -
+                                               vesa_sync_start -
+                                               pipe->stream->timing.v_border_top)
+                       * (pipe->stream->timing.flags.INTERLACE ? 1 : 0);
+
+                       asic_blank_start = asic_blank_end +
+                                               (pipe->stream->timing.v_border_top +
+                                               pipe->stream->timing.v_addressable +
+                                               pipe->stream->timing.v_border_bottom)
+                       * (pipe->stream->timing.flags.INTERLACE ? 1 : 0);
+
+                       pipe->pipe_dlg_param.vblank_start = asic_blank_start;
+                       pipe->pipe_dlg_param.vblank_end = asic_blank_end;
+
+                       if (pipe->plane_state) {
+                               struct pipe_ctx *hsplit_pipe = pipe->bottom_pipe;
+
+                               pipe->plane_state->update_flags.bits.full_update = 1;
+
+                               if (v->dpp_per_plane[input_idx] == 2 ||
+                                       ((pipe->stream->view_format ==
+                                         VIEW_3D_FORMAT_SIDE_BY_SIDE ||
+                                         pipe->stream->view_format ==
+                                         VIEW_3D_FORMAT_TOP_AND_BOTTOM) &&
+                                       (pipe->stream->timing.timing_3d_format ==
+                                        TIMING_3D_FORMAT_TOP_AND_BOTTOM ||
+                                        pipe->stream->timing.timing_3d_format ==
+                                        TIMING_3D_FORMAT_SIDE_BY_SIDE))) {
+                                       if (hsplit_pipe && hsplit_pipe->plane_state == pipe->plane_state) {
+                                               /* update previously split pipe */
+                                               hsplit_pipe->pipe_dlg_param.vupdate_width = v->v_update_width_pix[input_idx];
+                                               hsplit_pipe->pipe_dlg_param.vupdate_offset = v->v_update_offset_pix[input_idx];
+                                               hsplit_pipe->pipe_dlg_param.vready_offset = v->v_ready_offset_pix[input_idx];
+                                               hsplit_pipe->pipe_dlg_param.vstartup_start = v->v_startup[input_idx];
+
+                                               hsplit_pipe->pipe_dlg_param.htotal = pipe->stream->timing.h_total;
+                                               hsplit_pipe->pipe_dlg_param.vtotal = pipe->stream->timing.v_total;
+                                               hsplit_pipe->pipe_dlg_param.vblank_start = pipe->pipe_dlg_param.vblank_start;
+                                               hsplit_pipe->pipe_dlg_param.vblank_end = pipe->pipe_dlg_param.vblank_end;
+                                       } else {
+                                               /* pipe not split previously needs split */
+                                               hsplit_pipe = find_idle_secondary_pipe(&context->res_ctx, pool, pipe);
+                                               ASSERT(hsplit_pipe);
+                                               split_stream_across_pipes(&context->res_ctx, pool, pipe, hsplit_pipe);
+                                       }
+
+                                       dcn_bw_calc_rq_dlg_ttu(dc, v, hsplit_pipe, input_idx);
+                               } else if (hsplit_pipe && hsplit_pipe->plane_state == pipe->plane_state) {
+                                       /* merge previously split pipe */
+                                       pipe->bottom_pipe = hsplit_pipe->bottom_pipe;
+                                       if (hsplit_pipe->bottom_pipe)
+                                               hsplit_pipe->bottom_pipe->top_pipe = pipe;
+                                       hsplit_pipe->plane_state = NULL;
+                                       hsplit_pipe->stream = NULL;
+                                       hsplit_pipe->top_pipe = NULL;
+                                       hsplit_pipe->bottom_pipe = NULL;
+                                       /* Clear plane_res and stream_res */
+                                       memset(&hsplit_pipe->plane_res, 0, sizeof(hsplit_pipe->plane_res));
+                                       memset(&hsplit_pipe->stream_res, 0, sizeof(hsplit_pipe->stream_res));
+                                       resource_build_scaling_params(pipe);
+                               }
+                               /* for now important to do this after pipe split for building e2e params */
+                               dcn_bw_calc_rq_dlg_ttu(dc, v, pipe, input_idx);
+                       }
+
+                       input_idx++;
+               }
+       } else if (v->voltage_level == number_of_states_plus_one) {
+               BW_VAL_TRACE_SKIP(fail);
+       } else if (fast_validate) {
+               BW_VAL_TRACE_SKIP(fast);
+       }
+
+       if (v->voltage_level == 0) {
+               context->bw_ctx.dml.soc.sr_enter_plus_exit_time_us =
+                               dc->dcn_soc->sr_enter_plus_exit_time;
+               context->bw_ctx.dml.soc.sr_exit_time_us = dc->dcn_soc->sr_exit_time;
+       }
+
+       /*
+        * BW limit is set to prevent display from impacting other system functions
+        */
+
+       bw_limit = dc->dcn_soc->percent_disp_bw_limit * v->fabric_and_dram_bandwidth_vmax0p9;
+       bw_limit_pass = (v->total_data_read_bandwidth / 1000.0) < bw_limit;
+
+       DC_FP_END();
+
+       PERFORMANCE_TRACE_END();
+       BW_VAL_TRACE_FINISH();
+
+       if (bw_limit_pass && v->voltage_level <= get_highest_allowed_voltage_level(
+                                                       dc->ctx->asic_id.chip_family,
+                                                       dc->ctx->asic_id.hw_internal_rev,
+                                                       dc->ctx->asic_id.pci_revision_id))
+               return true;
+       else
+               return false;
+}
+
+static unsigned int dcn_find_normalized_clock_vdd_Level(
+       const struct dc *dc,
+       enum dm_pp_clock_type clocks_type,
+       int clocks_in_khz)
+{
+       int vdd_level = dcn_bw_v_min0p65;
+
+       if (clocks_in_khz == 0)/*todo some clock not in the considerations*/
+               return vdd_level;
+
+       switch (clocks_type) {
+       case DM_PP_CLOCK_TYPE_DISPLAY_CLK:
+               if (clocks_in_khz > dc->dcn_soc->max_dispclk_vmax0p9*1000) {
+                       vdd_level = dcn_bw_v_max0p91;
+                       BREAK_TO_DEBUGGER();
+               } else if (clocks_in_khz > dc->dcn_soc->max_dispclk_vnom0p8*1000) {
+                       vdd_level = dcn_bw_v_max0p9;
+               } else if (clocks_in_khz > dc->dcn_soc->max_dispclk_vmid0p72*1000) {
+                       vdd_level = dcn_bw_v_nom0p8;
+               } else if (clocks_in_khz > dc->dcn_soc->max_dispclk_vmin0p65*1000) {
+                       vdd_level = dcn_bw_v_mid0p72;
+               } else
+                       vdd_level = dcn_bw_v_min0p65;
+               break;
+       case DM_PP_CLOCK_TYPE_DISPLAYPHYCLK:
+               if (clocks_in_khz > dc->dcn_soc->phyclkv_max0p9*1000) {
+                       vdd_level = dcn_bw_v_max0p91;
+                       BREAK_TO_DEBUGGER();
+               } else if (clocks_in_khz > dc->dcn_soc->phyclkv_nom0p8*1000) {
+                       vdd_level = dcn_bw_v_max0p9;
+               } else if (clocks_in_khz > dc->dcn_soc->phyclkv_mid0p72*1000) {
+                       vdd_level = dcn_bw_v_nom0p8;
+               } else if (clocks_in_khz > dc->dcn_soc->phyclkv_min0p65*1000) {
+                       vdd_level = dcn_bw_v_mid0p72;
+               } else
+                       vdd_level = dcn_bw_v_min0p65;
+               break;
+
+       case DM_PP_CLOCK_TYPE_DPPCLK:
+               if (clocks_in_khz > dc->dcn_soc->max_dppclk_vmax0p9*1000) {
+                       vdd_level = dcn_bw_v_max0p91;
+                       BREAK_TO_DEBUGGER();
+               } else if (clocks_in_khz > dc->dcn_soc->max_dppclk_vnom0p8*1000) {
+                       vdd_level = dcn_bw_v_max0p9;
+               } else if (clocks_in_khz > dc->dcn_soc->max_dppclk_vmid0p72*1000) {
+                       vdd_level = dcn_bw_v_nom0p8;
+               } else if (clocks_in_khz > dc->dcn_soc->max_dppclk_vmin0p65*1000) {
+                       vdd_level = dcn_bw_v_mid0p72;
+               } else
+                       vdd_level = dcn_bw_v_min0p65;
+               break;
+
+       case DM_PP_CLOCK_TYPE_MEMORY_CLK:
+               {
+                       unsigned factor = (ddr4_dram_factor_single_Channel * dc->dcn_soc->number_of_channels);
+
+                       if (clocks_in_khz > dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9*1000000/factor) {
+                               vdd_level = dcn_bw_v_max0p91;
+                               BREAK_TO_DEBUGGER();
+                       } else if (clocks_in_khz > dc->dcn_soc->fabric_and_dram_bandwidth_vnom0p8*1000000/factor) {
+                               vdd_level = dcn_bw_v_max0p9;
+                       } else if (clocks_in_khz > dc->dcn_soc->fabric_and_dram_bandwidth_vmid0p72*1000000/factor) {
+                               vdd_level = dcn_bw_v_nom0p8;
+                       } else if (clocks_in_khz > dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65*1000000/factor) {
+                               vdd_level = dcn_bw_v_mid0p72;
+                       } else
+                               vdd_level = dcn_bw_v_min0p65;
+               }
+               break;
+
+       case DM_PP_CLOCK_TYPE_DCFCLK:
+               if (clocks_in_khz > dc->dcn_soc->dcfclkv_max0p9*1000) {
+                       vdd_level = dcn_bw_v_max0p91;
+                       BREAK_TO_DEBUGGER();
+               } else if (clocks_in_khz > dc->dcn_soc->dcfclkv_nom0p8*1000) {
+                       vdd_level = dcn_bw_v_max0p9;
+               } else if (clocks_in_khz > dc->dcn_soc->dcfclkv_mid0p72*1000) {
+                       vdd_level = dcn_bw_v_nom0p8;
+               } else if (clocks_in_khz > dc->dcn_soc->dcfclkv_min0p65*1000) {
+                       vdd_level = dcn_bw_v_mid0p72;
+               } else
+                       vdd_level = dcn_bw_v_min0p65;
+               break;
+
+       default:
+                break;
+       }
+       return vdd_level;
+}
+
+unsigned int dcn_find_dcfclk_suits_all(
+       const struct dc *dc,
+       struct dc_clocks *clocks)
+{
+       unsigned vdd_level, vdd_level_temp;
+       unsigned dcf_clk;
+
+       /*find a common supported voltage level*/
+       vdd_level = dcn_find_normalized_clock_vdd_Level(
+               dc, DM_PP_CLOCK_TYPE_DISPLAY_CLK, clocks->dispclk_khz);
+       vdd_level_temp = dcn_find_normalized_clock_vdd_Level(
+               dc, DM_PP_CLOCK_TYPE_DISPLAYPHYCLK, clocks->phyclk_khz);
+
+       vdd_level = dcn_bw_max(vdd_level, vdd_level_temp);
+       vdd_level_temp = dcn_find_normalized_clock_vdd_Level(
+               dc, DM_PP_CLOCK_TYPE_DPPCLK, clocks->dppclk_khz);
+       vdd_level = dcn_bw_max(vdd_level, vdd_level_temp);
+
+       vdd_level_temp = dcn_find_normalized_clock_vdd_Level(
+               dc, DM_PP_CLOCK_TYPE_MEMORY_CLK, clocks->fclk_khz);
+       vdd_level = dcn_bw_max(vdd_level, vdd_level_temp);
+       vdd_level_temp = dcn_find_normalized_clock_vdd_Level(
+               dc, DM_PP_CLOCK_TYPE_DCFCLK, clocks->dcfclk_khz);
+
+       /*find that level conresponding dcfclk*/
+       vdd_level = dcn_bw_max(vdd_level, vdd_level_temp);
+       if (vdd_level == dcn_bw_v_max0p91) {
+               BREAK_TO_DEBUGGER();
+               dcf_clk = dc->dcn_soc->dcfclkv_max0p9*1000;
+       } else if (vdd_level == dcn_bw_v_max0p9)
+               dcf_clk =  dc->dcn_soc->dcfclkv_max0p9*1000;
+       else if (vdd_level == dcn_bw_v_nom0p8)
+               dcf_clk =  dc->dcn_soc->dcfclkv_nom0p8*1000;
+       else if (vdd_level == dcn_bw_v_mid0p72)
+               dcf_clk =  dc->dcn_soc->dcfclkv_mid0p72*1000;
+       else
+               dcf_clk =  dc->dcn_soc->dcfclkv_min0p65*1000;
+
+       DC_LOG_BANDWIDTH_CALCS("\tdcf_clk for voltage = %d\n", dcf_clk);
+       return dcf_clk;
+}
+
+static bool verify_clock_values(struct dm_pp_clock_levels_with_voltage *clks)
+{
+       int i;
+
+       if (clks->num_levels == 0)
+               return false;
+
+       for (i = 0; i < clks->num_levels; i++)
+               /* Ensure that the result is sane */
+               if (clks->data[i].clocks_in_khz == 0)
+                       return false;
+
+       return true;
+}
+
+void dcn_bw_update_from_pplib(struct dc *dc)
+{
+       struct dc_context *ctx = dc->ctx;
+       struct dm_pp_clock_levels_with_voltage fclks = {0}, dcfclks = {0};
+       bool res;
+       unsigned vmin0p65_idx, vmid0p72_idx, vnom0p8_idx, vmax0p9_idx;
+
+       /* TODO: This is not the proper way to obtain fabric_and_dram_bandwidth, should be min(fclk, memclk) */
+       res = dm_pp_get_clock_levels_by_type_with_voltage(
+                       ctx, DM_PP_CLOCK_TYPE_FCLK, &fclks);
+
+       DC_FP_START();
+
+       if (res)
+               res = verify_clock_values(&fclks);
+
+       if (res) {
+               ASSERT(fclks.num_levels);
+
+               vmin0p65_idx = 0;
+               vmid0p72_idx = fclks.num_levels -
+                       (fclks.num_levels > 2 ? 3 : (fclks.num_levels > 1 ? 2 : 1));
+               vnom0p8_idx = fclks.num_levels - (fclks.num_levels > 1 ? 2 : 1);
+               vmax0p9_idx = fclks.num_levels - 1;
+
+               dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65 =
+                       32 * (fclks.data[vmin0p65_idx].clocks_in_khz / 1000.0) / 1000.0;
+               dc->dcn_soc->fabric_and_dram_bandwidth_vmid0p72 =
+                       dc->dcn_soc->number_of_channels *
+                       (fclks.data[vmid0p72_idx].clocks_in_khz / 1000.0)
+                       * ddr4_dram_factor_single_Channel / 1000.0;
+               dc->dcn_soc->fabric_and_dram_bandwidth_vnom0p8 =
+                       dc->dcn_soc->number_of_channels *
+                       (fclks.data[vnom0p8_idx].clocks_in_khz / 1000.0)
+                       * ddr4_dram_factor_single_Channel / 1000.0;
+               dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9 =
+                       dc->dcn_soc->number_of_channels *
+                       (fclks.data[vmax0p9_idx].clocks_in_khz / 1000.0)
+                       * ddr4_dram_factor_single_Channel / 1000.0;
+       } else
+               BREAK_TO_DEBUGGER();
+
+       DC_FP_END();
+
+       res = dm_pp_get_clock_levels_by_type_with_voltage(
+                       ctx, DM_PP_CLOCK_TYPE_DCFCLK, &dcfclks);
+
+       DC_FP_START();
+
+       if (res)
+               res = verify_clock_values(&dcfclks);
+
+       if (res && dcfclks.num_levels >= 3) {
+               dc->dcn_soc->dcfclkv_min0p65 = dcfclks.data[0].clocks_in_khz / 1000.0;
+               dc->dcn_soc->dcfclkv_mid0p72 = dcfclks.data[dcfclks.num_levels - 3].clocks_in_khz / 1000.0;
+               dc->dcn_soc->dcfclkv_nom0p8 = dcfclks.data[dcfclks.num_levels - 2].clocks_in_khz / 1000.0;
+               dc->dcn_soc->dcfclkv_max0p9 = dcfclks.data[dcfclks.num_levels - 1].clocks_in_khz / 1000.0;
+       } else
+               BREAK_TO_DEBUGGER();
+
+       DC_FP_END();
+}
+
+void dcn_bw_notify_pplib_of_wm_ranges(struct dc *dc)
+{
+       struct pp_smu_funcs_rv *pp = NULL;
+       struct pp_smu_wm_range_sets ranges = {0};
+       int min_fclk_khz, min_dcfclk_khz, socclk_khz;
+       const int overdrive = 5000000; /* 5 GHz to cover Overdrive */
+
+       if (dc->res_pool->pp_smu)
+               pp = &dc->res_pool->pp_smu->rv_funcs;
+       if (!pp || !pp->set_wm_ranges)
+               return;
+
+       DC_FP_START();
+       min_fclk_khz = dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65 * 1000000 / 32;
+       min_dcfclk_khz = dc->dcn_soc->dcfclkv_min0p65 * 1000;
+       socclk_khz = dc->dcn_soc->socclk * 1000;
+       DC_FP_END();
+
+       /* Now notify PPLib/SMU about which Watermarks sets they should select
+        * depending on DPM state they are in. And update BW MGR GFX Engine and
+        * Memory clock member variables for Watermarks calculations for each
+        * Watermark Set. Only one watermark set for dcn1 due to hw bug DEGVIDCN10-254.
+        */
+       /* SOCCLK does not affect anytihng but writeback for DCN so for now we dont
+        * care what the value is, hence min to overdrive level
+        */
+       ranges.num_reader_wm_sets = WM_SET_COUNT;
+       ranges.num_writer_wm_sets = WM_SET_COUNT;
+       ranges.reader_wm_sets[0].wm_inst = WM_A;
+       ranges.reader_wm_sets[0].min_drain_clk_mhz = min_dcfclk_khz / 1000;
+       ranges.reader_wm_sets[0].max_drain_clk_mhz = overdrive / 1000;
+       ranges.reader_wm_sets[0].min_fill_clk_mhz = min_fclk_khz / 1000;
+       ranges.reader_wm_sets[0].max_fill_clk_mhz = overdrive / 1000;
+       ranges.writer_wm_sets[0].wm_inst = WM_A;
+       ranges.writer_wm_sets[0].min_fill_clk_mhz = socclk_khz / 1000;
+       ranges.writer_wm_sets[0].max_fill_clk_mhz = overdrive / 1000;
+       ranges.writer_wm_sets[0].min_drain_clk_mhz = min_fclk_khz / 1000;
+       ranges.writer_wm_sets[0].max_drain_clk_mhz = overdrive / 1000;
+
+       if (dc->debug.pplib_wm_report_mode == WM_REPORT_OVERRIDE) {
+               ranges.reader_wm_sets[0].wm_inst = WM_A;
+               ranges.reader_wm_sets[0].min_drain_clk_mhz = 300;
+               ranges.reader_wm_sets[0].max_drain_clk_mhz = 5000;
+               ranges.reader_wm_sets[0].min_fill_clk_mhz = 800;
+               ranges.reader_wm_sets[0].max_fill_clk_mhz = 5000;
+               ranges.writer_wm_sets[0].wm_inst = WM_A;
+               ranges.writer_wm_sets[0].min_fill_clk_mhz = 200;
+               ranges.writer_wm_sets[0].max_fill_clk_mhz = 5000;
+               ranges.writer_wm_sets[0].min_drain_clk_mhz = 800;
+               ranges.writer_wm_sets[0].max_drain_clk_mhz = 5000;
+       }
+
+       ranges.reader_wm_sets[1] = ranges.writer_wm_sets[0];
+       ranges.reader_wm_sets[1].wm_inst = WM_B;
+
+       ranges.reader_wm_sets[2] = ranges.writer_wm_sets[0];
+       ranges.reader_wm_sets[2].wm_inst = WM_C;
+
+       ranges.reader_wm_sets[3] = ranges.writer_wm_sets[0];
+       ranges.reader_wm_sets[3].wm_inst = WM_D;
+
+       /* Notify PP Lib/SMU which Watermarks to use for which clock ranges */
+       pp->set_wm_ranges(&pp->pp_smu, &ranges);
+}
+
+void dcn_bw_sync_calcs_and_dml(struct dc *dc)
+{
+       DC_FP_START();
+       DC_LOG_BANDWIDTH_CALCS("sr_exit_time: %f ns\n"
+                       "sr_enter_plus_exit_time: %f ns\n"
+                       "urgent_latency: %f ns\n"
+                       "write_back_latency: %f ns\n"
+                       "percent_of_ideal_drambw_received_after_urg_latency: %f %%\n"
+                       "max_request_size: %d bytes\n"
+                       "dcfclkv_max0p9: %f kHz\n"
+                       "dcfclkv_nom0p8: %f kHz\n"
+                       "dcfclkv_mid0p72: %f kHz\n"
+                       "dcfclkv_min0p65: %f kHz\n"
+                       "max_dispclk_vmax0p9: %f kHz\n"
+                       "max_dispclk_vnom0p8: %f kHz\n"
+                       "max_dispclk_vmid0p72: %f kHz\n"
+                       "max_dispclk_vmin0p65: %f kHz\n"
+                       "max_dppclk_vmax0p9: %f kHz\n"
+                       "max_dppclk_vnom0p8: %f kHz\n"
+                       "max_dppclk_vmid0p72: %f kHz\n"
+                       "max_dppclk_vmin0p65: %f kHz\n"
+                       "socclk: %f kHz\n"
+                       "fabric_and_dram_bandwidth_vmax0p9: %f MB/s\n"
+                       "fabric_and_dram_bandwidth_vnom0p8: %f MB/s\n"
+                       "fabric_and_dram_bandwidth_vmid0p72: %f MB/s\n"
+                       "fabric_and_dram_bandwidth_vmin0p65: %f MB/s\n"
+                       "phyclkv_max0p9: %f kHz\n"
+                       "phyclkv_nom0p8: %f kHz\n"
+                       "phyclkv_mid0p72: %f kHz\n"
+                       "phyclkv_min0p65: %f kHz\n"
+                       "downspreading: %f %%\n"
+                       "round_trip_ping_latency_cycles: %d DCFCLK Cycles\n"
+                       "urgent_out_of_order_return_per_channel: %d Bytes\n"
+                       "number_of_channels: %d\n"
+                       "vmm_page_size: %d Bytes\n"
+                       "dram_clock_change_latency: %f ns\n"
+                       "return_bus_width: %d Bytes\n",
+                       dc->dcn_soc->sr_exit_time * 1000,
+                       dc->dcn_soc->sr_enter_plus_exit_time * 1000,
+                       dc->dcn_soc->urgent_latency * 1000,
+                       dc->dcn_soc->write_back_latency * 1000,
+                       dc->dcn_soc->percent_of_ideal_drambw_received_after_urg_latency,
+                       dc->dcn_soc->max_request_size,
+                       dc->dcn_soc->dcfclkv_max0p9 * 1000,
+                       dc->dcn_soc->dcfclkv_nom0p8 * 1000,
+                       dc->dcn_soc->dcfclkv_mid0p72 * 1000,
+                       dc->dcn_soc->dcfclkv_min0p65 * 1000,
+                       dc->dcn_soc->max_dispclk_vmax0p9 * 1000,
+                       dc->dcn_soc->max_dispclk_vnom0p8 * 1000,
+                       dc->dcn_soc->max_dispclk_vmid0p72 * 1000,
+                       dc->dcn_soc->max_dispclk_vmin0p65 * 1000,
+                       dc->dcn_soc->max_dppclk_vmax0p9 * 1000,
+                       dc->dcn_soc->max_dppclk_vnom0p8 * 1000,
+                       dc->dcn_soc->max_dppclk_vmid0p72 * 1000,
+                       dc->dcn_soc->max_dppclk_vmin0p65 * 1000,
+                       dc->dcn_soc->socclk * 1000,
+                       dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9 * 1000,
+                       dc->dcn_soc->fabric_and_dram_bandwidth_vnom0p8 * 1000,
+                       dc->dcn_soc->fabric_and_dram_bandwidth_vmid0p72 * 1000,
+                       dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65 * 1000,
+                       dc->dcn_soc->phyclkv_max0p9 * 1000,
+                       dc->dcn_soc->phyclkv_nom0p8 * 1000,
+                       dc->dcn_soc->phyclkv_mid0p72 * 1000,
+                       dc->dcn_soc->phyclkv_min0p65 * 1000,
+                       dc->dcn_soc->downspreading * 100,
+                       dc->dcn_soc->round_trip_ping_latency_cycles,
+                       dc->dcn_soc->urgent_out_of_order_return_per_channel,
+                       dc->dcn_soc->number_of_channels,
+                       dc->dcn_soc->vmm_page_size,
+                       dc->dcn_soc->dram_clock_change_latency * 1000,
+                       dc->dcn_soc->return_bus_width);
+       DC_LOG_BANDWIDTH_CALCS("rob_buffer_size_in_kbyte: %f\n"
+                       "det_buffer_size_in_kbyte: %f\n"
+                       "dpp_output_buffer_pixels: %f\n"
+                       "opp_output_buffer_lines: %f\n"
+                       "pixel_chunk_size_in_kbyte: %f\n"
+                       "pte_enable: %d\n"
+                       "pte_chunk_size: %d kbytes\n"
+                       "meta_chunk_size: %d kbytes\n"
+                       "writeback_chunk_size: %d kbytes\n"
+                       "odm_capability: %d\n"
+                       "dsc_capability: %d\n"
+                       "line_buffer_size: %d bits\n"
+                       "max_line_buffer_lines: %d\n"
+                       "is_line_buffer_bpp_fixed: %d\n"
+                       "line_buffer_fixed_bpp: %d\n"
+                       "writeback_luma_buffer_size: %d kbytes\n"
+                       "writeback_chroma_buffer_size: %d kbytes\n"
+                       "max_num_dpp: %d\n"
+                       "max_num_writeback: %d\n"
+                       "max_dchub_topscl_throughput: %d pixels/dppclk\n"
+                       "max_pscl_tolb_throughput: %d pixels/dppclk\n"
+                       "max_lb_tovscl_throughput: %d pixels/dppclk\n"
+                       "max_vscl_tohscl_throughput: %d pixels/dppclk\n"
+                       "max_hscl_ratio: %f\n"
+                       "max_vscl_ratio: %f\n"
+                       "max_hscl_taps: %d\n"
+                       "max_vscl_taps: %d\n"
+                       "pte_buffer_size_in_requests: %d\n"
+                       "dispclk_ramping_margin: %f %%\n"
+                       "under_scan_factor: %f %%\n"
+                       "max_inter_dcn_tile_repeaters: %d\n"
+                       "can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one: %d\n"
+                       "bug_forcing_luma_and_chroma_request_to_same_size_fixed: %d\n"
+                       "dcfclk_cstate_latency: %d\n",
+                       dc->dcn_ip->rob_buffer_size_in_kbyte,
+                       dc->dcn_ip->det_buffer_size_in_kbyte,
+                       dc->dcn_ip->dpp_output_buffer_pixels,
+                       dc->dcn_ip->opp_output_buffer_lines,
+                       dc->dcn_ip->pixel_chunk_size_in_kbyte,
+                       dc->dcn_ip->pte_enable,
+                       dc->dcn_ip->pte_chunk_size,
+                       dc->dcn_ip->meta_chunk_size,
+                       dc->dcn_ip->writeback_chunk_size,
+                       dc->dcn_ip->odm_capability,
+                       dc->dcn_ip->dsc_capability,
+                       dc->dcn_ip->line_buffer_size,
+                       dc->dcn_ip->max_line_buffer_lines,
+                       dc->dcn_ip->is_line_buffer_bpp_fixed,
+                       dc->dcn_ip->line_buffer_fixed_bpp,
+                       dc->dcn_ip->writeback_luma_buffer_size,
+                       dc->dcn_ip->writeback_chroma_buffer_size,
+                       dc->dcn_ip->max_num_dpp,
+                       dc->dcn_ip->max_num_writeback,
+                       dc->dcn_ip->max_dchub_topscl_throughput,
+                       dc->dcn_ip->max_pscl_tolb_throughput,
+                       dc->dcn_ip->max_lb_tovscl_throughput,
+                       dc->dcn_ip->max_vscl_tohscl_throughput,
+                       dc->dcn_ip->max_hscl_ratio,
+                       dc->dcn_ip->max_vscl_ratio,
+                       dc->dcn_ip->max_hscl_taps,
+                       dc->dcn_ip->max_vscl_taps,
+                       dc->dcn_ip->pte_buffer_size_in_requests,
+                       dc->dcn_ip->dispclk_ramping_margin,
+                       dc->dcn_ip->under_scan_factor * 100,
+                       dc->dcn_ip->max_inter_dcn_tile_repeaters,
+                       dc->dcn_ip->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one,
+                       dc->dcn_ip->bug_forcing_luma_and_chroma_request_to_same_size_fixed,
+                       dc->dcn_ip->dcfclk_cstate_latency);
+
+       dc->dml.soc.sr_exit_time_us = dc->dcn_soc->sr_exit_time;
+       dc->dml.soc.sr_enter_plus_exit_time_us = dc->dcn_soc->sr_enter_plus_exit_time;
+       dc->dml.soc.urgent_latency_us = dc->dcn_soc->urgent_latency;
+       dc->dml.soc.writeback_latency_us = dc->dcn_soc->write_back_latency;
+       dc->dml.soc.ideal_dram_bw_after_urgent_percent =
+                       dc->dcn_soc->percent_of_ideal_drambw_received_after_urg_latency;
+       dc->dml.soc.max_request_size_bytes = dc->dcn_soc->max_request_size;
+       dc->dml.soc.downspread_percent = dc->dcn_soc->downspreading;
+       dc->dml.soc.round_trip_ping_latency_dcfclk_cycles =
+                       dc->dcn_soc->round_trip_ping_latency_cycles;
+       dc->dml.soc.urgent_out_of_order_return_per_channel_bytes =
+                       dc->dcn_soc->urgent_out_of_order_return_per_channel;
+       dc->dml.soc.num_chans = dc->dcn_soc->number_of_channels;
+       dc->dml.soc.vmm_page_size_bytes = dc->dcn_soc->vmm_page_size;
+       dc->dml.soc.dram_clock_change_latency_us = dc->dcn_soc->dram_clock_change_latency;
+       dc->dml.soc.return_bus_width_bytes = dc->dcn_soc->return_bus_width;
+
+       dc->dml.ip.rob_buffer_size_kbytes = dc->dcn_ip->rob_buffer_size_in_kbyte;
+       dc->dml.ip.det_buffer_size_kbytes = dc->dcn_ip->det_buffer_size_in_kbyte;
+       dc->dml.ip.dpp_output_buffer_pixels = dc->dcn_ip->dpp_output_buffer_pixels;
+       dc->dml.ip.opp_output_buffer_lines = dc->dcn_ip->opp_output_buffer_lines;
+       dc->dml.ip.pixel_chunk_size_kbytes = dc->dcn_ip->pixel_chunk_size_in_kbyte;
+       dc->dml.ip.pte_enable = dc->dcn_ip->pte_enable == dcn_bw_yes;
+       dc->dml.ip.pte_chunk_size_kbytes = dc->dcn_ip->pte_chunk_size;
+       dc->dml.ip.meta_chunk_size_kbytes = dc->dcn_ip->meta_chunk_size;
+       dc->dml.ip.writeback_chunk_size_kbytes = dc->dcn_ip->writeback_chunk_size;
+       dc->dml.ip.line_buffer_size_bits = dc->dcn_ip->line_buffer_size;
+       dc->dml.ip.max_line_buffer_lines = dc->dcn_ip->max_line_buffer_lines;
+       dc->dml.ip.IsLineBufferBppFixed = dc->dcn_ip->is_line_buffer_bpp_fixed == dcn_bw_yes;
+       dc->dml.ip.LineBufferFixedBpp = dc->dcn_ip->line_buffer_fixed_bpp;
+       dc->dml.ip.writeback_luma_buffer_size_kbytes = dc->dcn_ip->writeback_luma_buffer_size;
+       dc->dml.ip.writeback_chroma_buffer_size_kbytes = dc->dcn_ip->writeback_chroma_buffer_size;
+       dc->dml.ip.max_num_dpp = dc->dcn_ip->max_num_dpp;
+       dc->dml.ip.max_num_wb = dc->dcn_ip->max_num_writeback;
+       dc->dml.ip.max_dchub_pscl_bw_pix_per_clk = dc->dcn_ip->max_dchub_topscl_throughput;
+       dc->dml.ip.max_pscl_lb_bw_pix_per_clk = dc->dcn_ip->max_pscl_tolb_throughput;
+       dc->dml.ip.max_lb_vscl_bw_pix_per_clk = dc->dcn_ip->max_lb_tovscl_throughput;
+       dc->dml.ip.max_vscl_hscl_bw_pix_per_clk = dc->dcn_ip->max_vscl_tohscl_throughput;
+       dc->dml.ip.max_hscl_ratio = dc->dcn_ip->max_hscl_ratio;
+       dc->dml.ip.max_vscl_ratio = dc->dcn_ip->max_vscl_ratio;
+       dc->dml.ip.max_hscl_taps = dc->dcn_ip->max_hscl_taps;
+       dc->dml.ip.max_vscl_taps = dc->dcn_ip->max_vscl_taps;
+       /*pte_buffer_size_in_requests missing in dml*/
+       dc->dml.ip.dispclk_ramp_margin_percent = dc->dcn_ip->dispclk_ramping_margin;
+       dc->dml.ip.underscan_factor = dc->dcn_ip->under_scan_factor;
+       dc->dml.ip.max_inter_dcn_tile_repeaters = dc->dcn_ip->max_inter_dcn_tile_repeaters;
+       dc->dml.ip.can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one =
+               dc->dcn_ip->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one == dcn_bw_yes;
+       dc->dml.ip.bug_forcing_LC_req_same_size_fixed =
+               dc->dcn_ip->bug_forcing_luma_and_chroma_request_to_same_size_fixed == dcn_bw_yes;
+       dc->dml.ip.dcfclk_cstate_latency = dc->dcn_ip->dcfclk_cstate_latency;
+       DC_FP_END();
+}