15e141de4SHarry Wentland /*
25e141de4SHarry Wentland  * Copyright 2015-2017 Advanced Micro Devices, Inc.
35e141de4SHarry Wentland  *
45e141de4SHarry Wentland  * Permission is hereby granted, free of charge, to any person obtaining a
55e141de4SHarry Wentland  * copy of this software and associated documentation files (the "Software"),
65e141de4SHarry Wentland  * to deal in the Software without restriction, including without limitation
75e141de4SHarry Wentland  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
85e141de4SHarry Wentland  * and/or sell copies of the Software, and to permit persons to whom the
95e141de4SHarry Wentland  * Software is furnished to do so, subject to the following conditions:
105e141de4SHarry Wentland  *
115e141de4SHarry Wentland  * The above copyright notice and this permission notice shall be included in
125e141de4SHarry Wentland  * all copies or substantial portions of the Software.
135e141de4SHarry Wentland  *
145e141de4SHarry Wentland  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
155e141de4SHarry Wentland  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
165e141de4SHarry Wentland  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
175e141de4SHarry Wentland  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
185e141de4SHarry Wentland  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
195e141de4SHarry Wentland  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
205e141de4SHarry Wentland  * OTHER DEALINGS IN THE SOFTWARE.
215e141de4SHarry Wentland  *
225e141de4SHarry Wentland  * Authors: AMD
235e141de4SHarry Wentland  *
245e141de4SHarry Wentland  */
255e141de4SHarry Wentland 
265e141de4SHarry Wentland /**
275e141de4SHarry Wentland  * Bandwidth and Watermark calculations interface.
285e141de4SHarry Wentland  * (Refer to "DCEx_mode_support.xlsm" from Perforce.)
295e141de4SHarry Wentland  */
305e141de4SHarry Wentland #ifndef __DCE_CALCS_H__
315e141de4SHarry Wentland #define __DCE_CALCS_H__
325e141de4SHarry Wentland 
335e141de4SHarry Wentland #include "bw_fixed.h"
345e141de4SHarry Wentland 
355e141de4SHarry Wentland struct pipe_ctx;
36fb3466a4SBhawanpreet Lakha struct dc;
37608ac7bbSJerry Zuo struct dc_state;
389037d802SDmytro Laktyushkin struct dce_bw_output;
395e141de4SHarry Wentland 
405e141de4SHarry Wentland enum bw_calcs_version {
415e141de4SHarry Wentland 	BW_CALCS_VERSION_INVALID,
425e141de4SHarry Wentland 	BW_CALCS_VERSION_CARRIZO,
435e141de4SHarry Wentland 	BW_CALCS_VERSION_POLARIS10,
445e141de4SHarry Wentland 	BW_CALCS_VERSION_POLARIS11,
45e4b3f6f2SDmytro Laktyushkin 	BW_CALCS_VERSION_POLARIS12,
460c75d5acSJerry (Fangzhi) Zuo 	BW_CALCS_VERSION_VEGAM,
475e141de4SHarry Wentland 	BW_CALCS_VERSION_STONEY,
485e141de4SHarry Wentland 	BW_CALCS_VERSION_VEGA10
495e141de4SHarry Wentland };
505e141de4SHarry Wentland 
515e141de4SHarry Wentland /*******************************************************************************
525e141de4SHarry Wentland  * There are three types of input into Calculations:
535e141de4SHarry Wentland  * 1. per-DCE static values - these are "hardcoded" properties of the DCEIP
545e141de4SHarry Wentland  * 2. board-level values - these are generally coming from VBIOS parser
555e141de4SHarry Wentland  * 3. mode/configuration values - depending Mode, Scaling number of Displays etc.
565e141de4SHarry Wentland  ******************************************************************************/
575e141de4SHarry Wentland 
585e141de4SHarry Wentland enum bw_defines {
595e141de4SHarry Wentland 	//Common
605e141de4SHarry Wentland 	bw_def_no = 0,
615e141de4SHarry Wentland 	bw_def_none = 0,
625e141de4SHarry Wentland 	bw_def_yes = 1,
635e141de4SHarry Wentland 	bw_def_ok = 1,
645e141de4SHarry Wentland 	bw_def_high = 2,
655e141de4SHarry Wentland 	bw_def_mid = 1,
665e141de4SHarry Wentland 	bw_def_low = 0,
675e141de4SHarry Wentland 
685e141de4SHarry Wentland 	//Internal
695e141de4SHarry Wentland 	bw_defs_start = 255,
705e141de4SHarry Wentland 	bw_def_underlay422,
715e141de4SHarry Wentland 	bw_def_underlay420_luma,
725e141de4SHarry Wentland 	bw_def_underlay420_chroma,
735e141de4SHarry Wentland 	bw_def_underlay444,
745e141de4SHarry Wentland 	bw_def_graphics,
755e141de4SHarry Wentland 	bw_def_display_write_back420_luma,
765e141de4SHarry Wentland 	bw_def_display_write_back420_chroma,
775e141de4SHarry Wentland 	bw_def_portrait,
785e141de4SHarry Wentland 	bw_def_hsr_mtn_4,
795e141de4SHarry Wentland 	bw_def_hsr_mtn_h_taps,
805e141de4SHarry Wentland 	bw_def_ceiling__h_taps_div_4___meq_hsr,
815e141de4SHarry Wentland 	bw_def_invalid_linear_or_stereo_mode,
825e141de4SHarry Wentland 	bw_def_invalid_rotation_or_bpp_or_stereo,
835e141de4SHarry Wentland 	bw_def_vsr_mtn_v_taps,
845e141de4SHarry Wentland 	bw_def_vsr_mtn_4,
855e141de4SHarry Wentland 	bw_def_auto,
865e141de4SHarry Wentland 	bw_def_manual,
875e141de4SHarry Wentland 	bw_def_exceeded_allowed_maximum_sclk,
885e141de4SHarry Wentland 	bw_def_exceeded_allowed_page_close_open,
895e141de4SHarry Wentland 	bw_def_exceeded_allowed_outstanding_pte_req_queue_size,
905e141de4SHarry Wentland 	bw_def_exceeded_allowed_maximum_bw,
915e141de4SHarry Wentland 	bw_def_landscape,
925e141de4SHarry Wentland 
935e141de4SHarry Wentland 	//Panning and bezel
945e141de4SHarry Wentland 	bw_def_any_lines,
955e141de4SHarry Wentland 
965e141de4SHarry Wentland 	//Underlay mode
975e141de4SHarry Wentland 	bw_def_underlay_only,
985e141de4SHarry Wentland 	bw_def_blended,
995e141de4SHarry Wentland 	bw_def_blend,
1005e141de4SHarry Wentland 
1015e141de4SHarry Wentland 	//Stereo mode
1025e141de4SHarry Wentland 	bw_def_mono,
1035e141de4SHarry Wentland 	bw_def_side_by_side,
1045e141de4SHarry Wentland 	bw_def_top_bottom,
1055e141de4SHarry Wentland 
1065e141de4SHarry Wentland 	//Underlay surface type
1075e141de4SHarry Wentland 	bw_def_420,
1085e141de4SHarry Wentland 	bw_def_422,
1095e141de4SHarry Wentland 	bw_def_444,
1105e141de4SHarry Wentland 
1115e141de4SHarry Wentland 	//Tiling mode
1125e141de4SHarry Wentland 	bw_def_linear,
1135e141de4SHarry Wentland 	bw_def_tiled,
1145e141de4SHarry Wentland 	bw_def_array_linear_general,
1155e141de4SHarry Wentland 	bw_def_array_linear_aligned,
1165e141de4SHarry Wentland 	bw_def_rotated_micro_tiling,
1175e141de4SHarry Wentland 	bw_def_display_micro_tiling,
1185e141de4SHarry Wentland 
1195e141de4SHarry Wentland 	//Memory type
1205e141de4SHarry Wentland 	bw_def_gddr5,
1215e141de4SHarry Wentland 	bw_def_hbm,
1225e141de4SHarry Wentland 
1235e141de4SHarry Wentland 	//Voltage
1245e141de4SHarry Wentland 	bw_def_high_no_nbp_state_change,
1255e141de4SHarry Wentland 	bw_def_0_72,
1265e141de4SHarry Wentland 	bw_def_0_8,
1275e141de4SHarry Wentland 	bw_def_0_9,
1285e141de4SHarry Wentland 
1295e141de4SHarry Wentland 	bw_def_notok = -1,
1305e141de4SHarry Wentland 	bw_def_na = -1
1315e141de4SHarry Wentland };
1325e141de4SHarry Wentland 
1335e141de4SHarry Wentland struct bw_calcs_dceip {
1345e141de4SHarry Wentland 	enum bw_calcs_version version;
135e36ec859SDmytro Laktyushkin 	uint32_t percent_of_ideal_port_bw_received_after_urgent_latency;
136e36ec859SDmytro Laktyushkin 	uint32_t max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation;
137e36ec859SDmytro Laktyushkin 	uint32_t max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation;
1385e141de4SHarry Wentland 	bool large_cursor;
1395e141de4SHarry Wentland 	uint32_t cursor_max_outstanding_group_num;
1405e141de4SHarry Wentland 	bool dmif_pipe_en_fbc_chunk_tracker;
1415e141de4SHarry Wentland 	struct bw_fixed dmif_request_buffer_size;
1425e141de4SHarry Wentland 	uint32_t lines_interleaved_into_lb;
1435e141de4SHarry Wentland 	uint32_t low_power_tiling_mode;
1445e141de4SHarry Wentland 	uint32_t chunk_width;
1455e141de4SHarry Wentland 	uint32_t number_of_graphics_pipes;
1465e141de4SHarry Wentland 	uint32_t number_of_underlay_pipes;
1475e141de4SHarry Wentland 	bool display_write_back_supported;
1485e141de4SHarry Wentland 	bool argb_compression_support;
1495e141de4SHarry Wentland 	struct bw_fixed underlay_vscaler_efficiency6_bit_per_component;
1505e141de4SHarry Wentland 	struct bw_fixed underlay_vscaler_efficiency8_bit_per_component;
1515e141de4SHarry Wentland 	struct bw_fixed underlay_vscaler_efficiency10_bit_per_component;
1525e141de4SHarry Wentland 	struct bw_fixed underlay_vscaler_efficiency12_bit_per_component;
1535e141de4SHarry Wentland 	struct bw_fixed graphics_vscaler_efficiency6_bit_per_component;
1545e141de4SHarry Wentland 	struct bw_fixed graphics_vscaler_efficiency8_bit_per_component;
1555e141de4SHarry Wentland 	struct bw_fixed graphics_vscaler_efficiency10_bit_per_component;
1565e141de4SHarry Wentland 	struct bw_fixed graphics_vscaler_efficiency12_bit_per_component;
1575e141de4SHarry Wentland 	struct bw_fixed alpha_vscaler_efficiency;
1585e141de4SHarry Wentland 	uint32_t max_dmif_buffer_allocated;
1595e141de4SHarry Wentland 	uint32_t graphics_dmif_size;
1605e141de4SHarry Wentland 	uint32_t underlay_luma_dmif_size;
1615e141de4SHarry Wentland 	uint32_t underlay_chroma_dmif_size;
1625e141de4SHarry Wentland 	bool pre_downscaler_enabled;
1635e141de4SHarry Wentland 	bool underlay_downscale_prefetch_enabled;
1645e141de4SHarry Wentland 	struct bw_fixed lb_write_pixels_per_dispclk;
1655e141de4SHarry Wentland 	struct bw_fixed lb_size_per_component444;
1665e141de4SHarry Wentland 	bool graphics_lb_nodownscaling_multi_line_prefetching;
1675e141de4SHarry Wentland 	struct bw_fixed stutter_and_dram_clock_state_change_gated_before_cursor;
1685e141de4SHarry Wentland 	struct bw_fixed underlay420_luma_lb_size_per_component;
1695e141de4SHarry Wentland 	struct bw_fixed underlay420_chroma_lb_size_per_component;
1705e141de4SHarry Wentland 	struct bw_fixed underlay422_lb_size_per_component;
1715e141de4SHarry Wentland 	struct bw_fixed cursor_chunk_width;
1725e141de4SHarry Wentland 	struct bw_fixed cursor_dcp_buffer_lines;
1735e141de4SHarry Wentland 	struct bw_fixed underlay_maximum_width_efficient_for_tiling;
1745e141de4SHarry Wentland 	struct bw_fixed underlay_maximum_height_efficient_for_tiling;
1755e141de4SHarry Wentland 	struct bw_fixed peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display;
1765e141de4SHarry Wentland 	struct bw_fixed peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation;
1775e141de4SHarry Wentland 	struct bw_fixed minimum_outstanding_pte_request_limit;
1785e141de4SHarry Wentland 	struct bw_fixed maximum_total_outstanding_pte_requests_allowed_by_saw;
1795e141de4SHarry Wentland 	bool limit_excessive_outstanding_dmif_requests;
1805e141de4SHarry Wentland 	struct bw_fixed linear_mode_line_request_alternation_slice;
1815e141de4SHarry Wentland 	uint32_t scatter_gather_lines_of_pte_prefetching_in_linear_mode;
1825e141de4SHarry Wentland 	uint32_t display_write_back420_luma_mcifwr_buffer_size;
1835e141de4SHarry Wentland 	uint32_t display_write_back420_chroma_mcifwr_buffer_size;
1845e141de4SHarry Wentland 	struct bw_fixed request_efficiency;
1855e141de4SHarry Wentland 	struct bw_fixed dispclk_per_request;
1865e141de4SHarry Wentland 	struct bw_fixed dispclk_ramping_factor;
1875e141de4SHarry Wentland 	struct bw_fixed display_pipe_throughput_factor;
1885e141de4SHarry Wentland 	uint32_t scatter_gather_pte_request_rows_in_tiling_mode;
1895e141de4SHarry Wentland 	struct bw_fixed mcifwr_all_surfaces_burst_time;
1905e141de4SHarry Wentland };
1915e141de4SHarry Wentland 
1925e141de4SHarry Wentland struct bw_calcs_vbios {
1935e141de4SHarry Wentland 	enum bw_defines memory_type;
1945e141de4SHarry Wentland 	uint32_t dram_channel_width_in_bits;
1955e141de4SHarry Wentland 	uint32_t number_of_dram_channels;
1965e141de4SHarry Wentland 	uint32_t number_of_dram_banks;
1975e141de4SHarry Wentland 	struct bw_fixed low_yclk; /*m_hz*/
1985e141de4SHarry Wentland 	struct bw_fixed mid_yclk; /*m_hz*/
1995e141de4SHarry Wentland 	struct bw_fixed high_yclk; /*m_hz*/
2005e141de4SHarry Wentland 	struct bw_fixed low_sclk; /*m_hz*/
2015e141de4SHarry Wentland 	struct bw_fixed mid1_sclk; /*m_hz*/
2025e141de4SHarry Wentland 	struct bw_fixed mid2_sclk; /*m_hz*/
2035e141de4SHarry Wentland 	struct bw_fixed mid3_sclk; /*m_hz*/
2045e141de4SHarry Wentland 	struct bw_fixed mid4_sclk; /*m_hz*/
2055e141de4SHarry Wentland 	struct bw_fixed mid5_sclk; /*m_hz*/
2065e141de4SHarry Wentland 	struct bw_fixed mid6_sclk; /*m_hz*/
2075e141de4SHarry Wentland 	struct bw_fixed high_sclk; /*m_hz*/
2085e141de4SHarry Wentland 	struct bw_fixed low_voltage_max_dispclk; /*m_hz*/
2095e141de4SHarry Wentland 	struct bw_fixed mid_voltage_max_dispclk; /*m_hz*/
2105e141de4SHarry Wentland 	struct bw_fixed high_voltage_max_dispclk; /*m_hz*/
2115e141de4SHarry Wentland 	struct bw_fixed low_voltage_max_phyclk;
2125e141de4SHarry Wentland 	struct bw_fixed mid_voltage_max_phyclk;
2135e141de4SHarry Wentland 	struct bw_fixed high_voltage_max_phyclk;
2145e141de4SHarry Wentland 	struct bw_fixed data_return_bus_width;
2155e141de4SHarry Wentland 	struct bw_fixed trc;
2165e141de4SHarry Wentland 	struct bw_fixed dmifmc_urgent_latency;
2175e141de4SHarry Wentland 	struct bw_fixed stutter_self_refresh_exit_latency;
2185e141de4SHarry Wentland 	struct bw_fixed stutter_self_refresh_entry_latency;
2195e141de4SHarry Wentland 	struct bw_fixed nbp_state_change_latency;
2205e141de4SHarry Wentland 	struct bw_fixed mcifwrmc_urgent_latency;
2215e141de4SHarry Wentland 	bool scatter_gather_enable;
2225e141de4SHarry Wentland 	struct bw_fixed down_spread_percentage;
2235e141de4SHarry Wentland 	uint32_t cursor_width;
2245e141de4SHarry Wentland 	uint32_t average_compression_rate;
2255e141de4SHarry Wentland 	uint32_t number_of_request_slots_gmc_reserves_for_dmif_per_channel;
2265e141de4SHarry Wentland 	struct bw_fixed blackout_duration;
2275e141de4SHarry Wentland 	struct bw_fixed maximum_blackout_recovery_time;
2285e141de4SHarry Wentland };
2295e141de4SHarry Wentland 
2305e141de4SHarry Wentland /*******************************************************************************
2315e141de4SHarry Wentland  * Temporary data structure(s).
2325e141de4SHarry Wentland  ******************************************************************************/
2335e141de4SHarry Wentland #define maximum_number_of_surfaces 12
2345e141de4SHarry Wentland /*Units : MHz, us */
2355e141de4SHarry Wentland 
2365e141de4SHarry Wentland struct bw_calcs_data {
2375e141de4SHarry Wentland 	/* data for all displays */
238e36ec859SDmytro Laktyushkin 	bool display_synchronization_enabled;
2395e141de4SHarry Wentland 	uint32_t number_of_displays;
2405e141de4SHarry Wentland 	enum bw_defines underlay_surface_type;
2415e141de4SHarry Wentland 	enum bw_defines panning_and_bezel_adjustment;
2425e141de4SHarry Wentland 	enum bw_defines graphics_tiling_mode;
2435e141de4SHarry Wentland 	uint32_t graphics_lb_bpc;
2445e141de4SHarry Wentland 	uint32_t underlay_lb_bpc;
2455e141de4SHarry Wentland 	enum bw_defines underlay_tiling_mode;
2465e141de4SHarry Wentland 	enum bw_defines d0_underlay_mode;
2475e141de4SHarry Wentland 	bool d1_display_write_back_dwb_enable;
2485e141de4SHarry Wentland 	enum bw_defines d1_underlay_mode;
2495e141de4SHarry Wentland 
250e36ec859SDmytro Laktyushkin 	bool increase_voltage_to_support_mclk_switch;
2515e141de4SHarry Wentland 	bool cpup_state_change_enable;
2525e141de4SHarry Wentland 	bool cpuc_state_change_enable;
2535e141de4SHarry Wentland 	bool nbp_state_change_enable;
2545e141de4SHarry Wentland 	bool stutter_mode_enable;
2555e141de4SHarry Wentland 	uint32_t y_clk_level;
2565e141de4SHarry Wentland 	uint32_t sclk_level;
2575e141de4SHarry Wentland 	uint32_t number_of_underlay_surfaces;
2585e141de4SHarry Wentland 	uint32_t number_of_dram_wrchannels;
2595e141de4SHarry Wentland 	uint32_t chunk_request_delay;
2605e141de4SHarry Wentland 	uint32_t number_of_dram_channels;
2615e141de4SHarry Wentland 	enum bw_defines underlay_micro_tile_mode;
2625e141de4SHarry Wentland 	enum bw_defines graphics_micro_tile_mode;
2635e141de4SHarry Wentland 	struct bw_fixed max_phyclk;
2645e141de4SHarry Wentland 	struct bw_fixed dram_efficiency;
2655e141de4SHarry Wentland 	struct bw_fixed src_width_after_surface_type;
2665e141de4SHarry Wentland 	struct bw_fixed src_height_after_surface_type;
2675e141de4SHarry Wentland 	struct bw_fixed hsr_after_surface_type;
2685e141de4SHarry Wentland 	struct bw_fixed vsr_after_surface_type;
2695e141de4SHarry Wentland 	struct bw_fixed src_width_after_rotation;
2705e141de4SHarry Wentland 	struct bw_fixed src_height_after_rotation;
2715e141de4SHarry Wentland 	struct bw_fixed hsr_after_rotation;
2725e141de4SHarry Wentland 	struct bw_fixed vsr_after_rotation;
2735e141de4SHarry Wentland 	struct bw_fixed source_height_pixels;
2745e141de4SHarry Wentland 	struct bw_fixed hsr_after_stereo;
2755e141de4SHarry Wentland 	struct bw_fixed vsr_after_stereo;
2765e141de4SHarry Wentland 	struct bw_fixed source_width_in_lb;
2775e141de4SHarry Wentland 	struct bw_fixed lb_line_pitch;
2785e141de4SHarry Wentland 	struct bw_fixed underlay_maximum_source_efficient_for_tiling;
2795e141de4SHarry Wentland 	struct bw_fixed num_lines_at_frame_start;
2805e141de4SHarry Wentland 	struct bw_fixed min_dmif_size_in_time;
2815e141de4SHarry Wentland 	struct bw_fixed min_mcifwr_size_in_time;
2825e141de4SHarry Wentland 	struct bw_fixed total_requests_for_dmif_size;
2835e141de4SHarry Wentland 	struct bw_fixed peak_pte_request_to_eviction_ratio_limiting;
2845e141de4SHarry Wentland 	struct bw_fixed useful_pte_per_pte_request;
2855e141de4SHarry Wentland 	struct bw_fixed scatter_gather_pte_request_rows;
2865e141de4SHarry Wentland 	struct bw_fixed scatter_gather_row_height;
2875e141de4SHarry Wentland 	struct bw_fixed scatter_gather_pte_requests_in_vblank;
2885e141de4SHarry Wentland 	struct bw_fixed inefficient_linear_pitch_in_bytes;
2895e141de4SHarry Wentland 	struct bw_fixed cursor_total_data;
2905e141de4SHarry Wentland 	struct bw_fixed cursor_total_request_groups;
2915e141de4SHarry Wentland 	struct bw_fixed scatter_gather_total_pte_requests;
2925e141de4SHarry Wentland 	struct bw_fixed scatter_gather_total_pte_request_groups;
2935e141de4SHarry Wentland 	struct bw_fixed tile_width_in_pixels;
2945e141de4SHarry Wentland 	struct bw_fixed dmif_total_number_of_data_request_page_close_open;
2955e141de4SHarry Wentland 	struct bw_fixed mcifwr_total_number_of_data_request_page_close_open;
2965e141de4SHarry Wentland 	struct bw_fixed bytes_per_page_close_open;
2975e141de4SHarry Wentland 	struct bw_fixed mcifwr_total_page_close_open_time;
2985e141de4SHarry Wentland 	struct bw_fixed total_requests_for_adjusted_dmif_size;
2995e141de4SHarry Wentland 	struct bw_fixed total_dmifmc_urgent_trips;
3005e141de4SHarry Wentland 	struct bw_fixed total_dmifmc_urgent_latency;
3015e141de4SHarry Wentland 	struct bw_fixed total_display_reads_required_data;
3025e141de4SHarry Wentland 	struct bw_fixed total_display_reads_required_dram_access_data;
3035e141de4SHarry Wentland 	struct bw_fixed total_display_writes_required_data;
3045e141de4SHarry Wentland 	struct bw_fixed total_display_writes_required_dram_access_data;
3055e141de4SHarry Wentland 	struct bw_fixed display_reads_required_data;
3065e141de4SHarry Wentland 	struct bw_fixed display_reads_required_dram_access_data;
3075e141de4SHarry Wentland 	struct bw_fixed dmif_total_page_close_open_time;
3085e141de4SHarry Wentland 	struct bw_fixed min_cursor_memory_interface_buffer_size_in_time;
3095e141de4SHarry Wentland 	struct bw_fixed min_read_buffer_size_in_time;
3105e141de4SHarry Wentland 	struct bw_fixed display_reads_time_for_data_transfer;
3115e141de4SHarry Wentland 	struct bw_fixed display_writes_time_for_data_transfer;
3125e141de4SHarry Wentland 	struct bw_fixed dmif_required_dram_bandwidth;
3135e141de4SHarry Wentland 	struct bw_fixed mcifwr_required_dram_bandwidth;
3145e141de4SHarry Wentland 	struct bw_fixed required_dmifmc_urgent_latency_for_page_close_open;
3155e141de4SHarry Wentland 	struct bw_fixed required_mcifmcwr_urgent_latency;
3165e141de4SHarry Wentland 	struct bw_fixed required_dram_bandwidth_gbyte_per_second;
3175e141de4SHarry Wentland 	struct bw_fixed dram_bandwidth;
3185e141de4SHarry Wentland 	struct bw_fixed dmif_required_sclk;
3195e141de4SHarry Wentland 	struct bw_fixed mcifwr_required_sclk;
3205e141de4SHarry Wentland 	struct bw_fixed required_sclk;
3215e141de4SHarry Wentland 	struct bw_fixed downspread_factor;
3225e141de4SHarry Wentland 	struct bw_fixed v_scaler_efficiency;
3235e141de4SHarry Wentland 	struct bw_fixed scaler_limits_factor;
3245e141de4SHarry Wentland 	struct bw_fixed display_pipe_pixel_throughput;
3255e141de4SHarry Wentland 	struct bw_fixed total_dispclk_required_with_ramping;
3265e141de4SHarry Wentland 	struct bw_fixed total_dispclk_required_without_ramping;
3275e141de4SHarry Wentland 	struct bw_fixed total_read_request_bandwidth;
3285e141de4SHarry Wentland 	struct bw_fixed total_write_request_bandwidth;
3295e141de4SHarry Wentland 	struct bw_fixed dispclk_required_for_total_read_request_bandwidth;
3305e141de4SHarry Wentland 	struct bw_fixed total_dispclk_required_with_ramping_with_request_bandwidth;
3315e141de4SHarry Wentland 	struct bw_fixed total_dispclk_required_without_ramping_with_request_bandwidth;
3325e141de4SHarry Wentland 	struct bw_fixed dispclk;
3335e141de4SHarry Wentland 	struct bw_fixed blackout_recovery_time;
3345e141de4SHarry Wentland 	struct bw_fixed min_pixels_per_data_fifo_entry;
3355e141de4SHarry Wentland 	struct bw_fixed sclk_deep_sleep;
3365e141de4SHarry Wentland 	struct bw_fixed chunk_request_time;
3375e141de4SHarry Wentland 	struct bw_fixed cursor_request_time;
3385e141de4SHarry Wentland 	struct bw_fixed line_source_pixels_transfer_time;
3395e141de4SHarry Wentland 	struct bw_fixed dmifdram_access_efficiency;
3405e141de4SHarry Wentland 	struct bw_fixed mcifwrdram_access_efficiency;
3415e141de4SHarry Wentland 	struct bw_fixed total_average_bandwidth_no_compression;
3425e141de4SHarry Wentland 	struct bw_fixed total_average_bandwidth;
3435e141de4SHarry Wentland 	struct bw_fixed total_stutter_cycle_duration;
3445e141de4SHarry Wentland 	struct bw_fixed stutter_burst_time;
3455e141de4SHarry Wentland 	struct bw_fixed time_in_self_refresh;
3465e141de4SHarry Wentland 	struct bw_fixed stutter_efficiency;
3475e141de4SHarry Wentland 	struct bw_fixed worst_number_of_trips_to_memory;
3485e141de4SHarry Wentland 	struct bw_fixed immediate_flip_time;
3495e141de4SHarry Wentland 	struct bw_fixed latency_for_non_dmif_clients;
3505e141de4SHarry Wentland 	struct bw_fixed latency_for_non_mcifwr_clients;
3515e141de4SHarry Wentland 	struct bw_fixed dmifmc_urgent_latency_supported_in_high_sclk_and_yclk;
3525e141de4SHarry Wentland 	struct bw_fixed nbp_state_dram_speed_change_margin;
3535e141de4SHarry Wentland 	struct bw_fixed display_reads_time_for_data_transfer_and_urgent_latency;
3545e141de4SHarry Wentland 	struct bw_fixed dram_speed_change_margin;
3555e141de4SHarry Wentland 	struct bw_fixed min_vblank_dram_speed_change_margin;
3565e141de4SHarry Wentland 	struct bw_fixed min_stutter_refresh_duration;
3575e141de4SHarry Wentland 	uint32_t total_stutter_dmif_buffer_size;
3585e141de4SHarry Wentland 	uint32_t total_bytes_requested;
3595e141de4SHarry Wentland 	uint32_t min_stutter_dmif_buffer_size;
3605e141de4SHarry Wentland 	uint32_t num_stutter_bursts;
3615e141de4SHarry Wentland 	struct bw_fixed v_blank_nbp_state_dram_speed_change_latency_supported;
3625e141de4SHarry Wentland 	struct bw_fixed nbp_state_dram_speed_change_latency_supported;
3635e141de4SHarry Wentland 	bool fbc_en[maximum_number_of_surfaces];
3645e141de4SHarry Wentland 	bool lpt_en[maximum_number_of_surfaces];
3655e141de4SHarry Wentland 	bool displays_match_flag[maximum_number_of_surfaces];
3665e141de4SHarry Wentland 	bool use_alpha[maximum_number_of_surfaces];
3675e141de4SHarry Wentland 	bool orthogonal_rotation[maximum_number_of_surfaces];
3685e141de4SHarry Wentland 	bool enable[maximum_number_of_surfaces];
3695e141de4SHarry Wentland 	bool access_one_channel_only[maximum_number_of_surfaces];
3705e141de4SHarry Wentland 	bool scatter_gather_enable_for_pipe[maximum_number_of_surfaces];
3715e141de4SHarry Wentland 	bool interlace_mode[maximum_number_of_surfaces];
3725e141de4SHarry Wentland 	bool display_pstate_change_enable[maximum_number_of_surfaces];
3735e141de4SHarry Wentland 	bool line_buffer_prefetch[maximum_number_of_surfaces];
3745e141de4SHarry Wentland 	uint32_t bytes_per_pixel[maximum_number_of_surfaces];
3755e141de4SHarry Wentland 	uint32_t max_chunks_non_fbc_mode[maximum_number_of_surfaces];
3765e141de4SHarry Wentland 	uint32_t lb_bpc[maximum_number_of_surfaces];
3775e141de4SHarry Wentland 	uint32_t output_bpphdmi[maximum_number_of_surfaces];
3785e141de4SHarry Wentland 	uint32_t output_bppdp4_lane_hbr[maximum_number_of_surfaces];
3795e141de4SHarry Wentland 	uint32_t output_bppdp4_lane_hbr2[maximum_number_of_surfaces];
3805e141de4SHarry Wentland 	uint32_t output_bppdp4_lane_hbr3[maximum_number_of_surfaces];
3815e141de4SHarry Wentland 	enum bw_defines stereo_mode[maximum_number_of_surfaces];
3825e141de4SHarry Wentland 	struct bw_fixed dmif_buffer_transfer_time[maximum_number_of_surfaces];
3835e141de4SHarry Wentland 	struct bw_fixed displays_with_same_mode[maximum_number_of_surfaces];
3845e141de4SHarry Wentland 	struct bw_fixed stutter_dmif_buffer_size[maximum_number_of_surfaces];
3855e141de4SHarry Wentland 	struct bw_fixed stutter_refresh_duration[maximum_number_of_surfaces];
3865e141de4SHarry Wentland 	struct bw_fixed stutter_exit_watermark[maximum_number_of_surfaces];
3875e141de4SHarry Wentland 	struct bw_fixed stutter_entry_watermark[maximum_number_of_surfaces];
3885e141de4SHarry Wentland 	struct bw_fixed h_total[maximum_number_of_surfaces];
3895e141de4SHarry Wentland 	struct bw_fixed v_total[maximum_number_of_surfaces];
3905e141de4SHarry Wentland 	struct bw_fixed pixel_rate[maximum_number_of_surfaces];
3915e141de4SHarry Wentland 	struct bw_fixed src_width[maximum_number_of_surfaces];
3925e141de4SHarry Wentland 	struct bw_fixed pitch_in_pixels[maximum_number_of_surfaces];
3935e141de4SHarry Wentland 	struct bw_fixed pitch_in_pixels_after_surface_type[maximum_number_of_surfaces];
3945e141de4SHarry Wentland 	struct bw_fixed src_height[maximum_number_of_surfaces];
3955e141de4SHarry Wentland 	struct bw_fixed scale_ratio[maximum_number_of_surfaces];
3965e141de4SHarry Wentland 	struct bw_fixed h_taps[maximum_number_of_surfaces];
3975e141de4SHarry Wentland 	struct bw_fixed v_taps[maximum_number_of_surfaces];
3985e141de4SHarry Wentland 	struct bw_fixed h_scale_ratio[maximum_number_of_surfaces];
3995e141de4SHarry Wentland 	struct bw_fixed v_scale_ratio[maximum_number_of_surfaces];
4005e141de4SHarry Wentland 	struct bw_fixed rotation_angle[maximum_number_of_surfaces];
4015e141de4SHarry Wentland 	struct bw_fixed compression_rate[maximum_number_of_surfaces];
4025e141de4SHarry Wentland 	struct bw_fixed hsr[maximum_number_of_surfaces];
4035e141de4SHarry Wentland 	struct bw_fixed vsr[maximum_number_of_surfaces];
4045e141de4SHarry Wentland 	struct bw_fixed source_width_rounded_up_to_chunks[maximum_number_of_surfaces];
4055e141de4SHarry Wentland 	struct bw_fixed source_width_pixels[maximum_number_of_surfaces];
4065e141de4SHarry Wentland 	struct bw_fixed source_height_rounded_up_to_chunks[maximum_number_of_surfaces];
4075e141de4SHarry Wentland 	struct bw_fixed display_bandwidth[maximum_number_of_surfaces];
4085e141de4SHarry Wentland 	struct bw_fixed request_bandwidth[maximum_number_of_surfaces];
4095e141de4SHarry Wentland 	struct bw_fixed bytes_per_request[maximum_number_of_surfaces];
4105e141de4SHarry Wentland 	struct bw_fixed useful_bytes_per_request[maximum_number_of_surfaces];
4115e141de4SHarry Wentland 	struct bw_fixed lines_interleaved_in_mem_access[maximum_number_of_surfaces];
4125e141de4SHarry Wentland 	struct bw_fixed latency_hiding_lines[maximum_number_of_surfaces];
4135e141de4SHarry Wentland 	struct bw_fixed lb_partitions[maximum_number_of_surfaces];
4145e141de4SHarry Wentland 	struct bw_fixed lb_partitions_max[maximum_number_of_surfaces];
4155e141de4SHarry Wentland 	struct bw_fixed dispclk_required_with_ramping[maximum_number_of_surfaces];
4165e141de4SHarry Wentland 	struct bw_fixed dispclk_required_without_ramping[maximum_number_of_surfaces];
4175e141de4SHarry Wentland 	struct bw_fixed data_buffer_size[maximum_number_of_surfaces];
4185e141de4SHarry Wentland 	struct bw_fixed outstanding_chunk_request_limit[maximum_number_of_surfaces];
4195e141de4SHarry Wentland 	struct bw_fixed urgent_watermark[maximum_number_of_surfaces];
4205e141de4SHarry Wentland 	struct bw_fixed nbp_state_change_watermark[maximum_number_of_surfaces];
4215e141de4SHarry Wentland 	struct bw_fixed v_filter_init[maximum_number_of_surfaces];
4225e141de4SHarry Wentland 	struct bw_fixed stutter_cycle_duration[maximum_number_of_surfaces];
4235e141de4SHarry Wentland 	struct bw_fixed average_bandwidth[maximum_number_of_surfaces];
4245e141de4SHarry Wentland 	struct bw_fixed average_bandwidth_no_compression[maximum_number_of_surfaces];
4255e141de4SHarry Wentland 	struct bw_fixed scatter_gather_pte_request_limit[maximum_number_of_surfaces];
4265e141de4SHarry Wentland 	struct bw_fixed lb_size_per_component[maximum_number_of_surfaces];
4275e141de4SHarry Wentland 	struct bw_fixed memory_chunk_size_in_bytes[maximum_number_of_surfaces];
4285e141de4SHarry Wentland 	struct bw_fixed pipe_chunk_size_in_bytes[maximum_number_of_surfaces];
4295e141de4SHarry Wentland 	struct bw_fixed number_of_trips_to_memory_for_getting_apte_row[maximum_number_of_surfaces];
4305e141de4SHarry Wentland 	struct bw_fixed adjusted_data_buffer_size[maximum_number_of_surfaces];
4315e141de4SHarry Wentland 	struct bw_fixed adjusted_data_buffer_size_in_memory[maximum_number_of_surfaces];
4325e141de4SHarry Wentland 	struct bw_fixed pixels_per_data_fifo_entry[maximum_number_of_surfaces];
4335e141de4SHarry Wentland 	struct bw_fixed scatter_gather_pte_requests_in_row[maximum_number_of_surfaces];
4345e141de4SHarry Wentland 	struct bw_fixed pte_request_per_chunk[maximum_number_of_surfaces];
4355e141de4SHarry Wentland 	struct bw_fixed scatter_gather_page_width[maximum_number_of_surfaces];
4365e141de4SHarry Wentland 	struct bw_fixed scatter_gather_page_height[maximum_number_of_surfaces];
4375e141de4SHarry Wentland 	struct bw_fixed lb_lines_in_per_line_out_in_beginning_of_frame[maximum_number_of_surfaces];
4385e141de4SHarry Wentland 	struct bw_fixed lb_lines_in_per_line_out_in_middle_of_frame[maximum_number_of_surfaces];
4395e141de4SHarry Wentland 	struct bw_fixed cursor_width_pixels[maximum_number_of_surfaces];
4405e141de4SHarry Wentland 	struct bw_fixed minimum_latency_hiding[maximum_number_of_surfaces];
4415e141de4SHarry Wentland 	struct bw_fixed maximum_latency_hiding[maximum_number_of_surfaces];
4425e141de4SHarry Wentland 	struct bw_fixed minimum_latency_hiding_with_cursor[maximum_number_of_surfaces];
4435e141de4SHarry Wentland 	struct bw_fixed maximum_latency_hiding_with_cursor[maximum_number_of_surfaces];
4445e141de4SHarry Wentland 	struct bw_fixed src_pixels_for_first_output_pixel[maximum_number_of_surfaces];
4455e141de4SHarry Wentland 	struct bw_fixed src_pixels_for_last_output_pixel[maximum_number_of_surfaces];
4465e141de4SHarry Wentland 	struct bw_fixed src_data_for_first_output_pixel[maximum_number_of_surfaces];
4475e141de4SHarry Wentland 	struct bw_fixed src_data_for_last_output_pixel[maximum_number_of_surfaces];
4485e141de4SHarry Wentland 	struct bw_fixed active_time[maximum_number_of_surfaces];
4495e141de4SHarry Wentland 	struct bw_fixed horizontal_blank_and_chunk_granularity_factor[maximum_number_of_surfaces];
4505e141de4SHarry Wentland 	struct bw_fixed cursor_latency_hiding[maximum_number_of_surfaces];
4515e141de4SHarry Wentland 	struct bw_fixed v_blank_dram_speed_change_margin[maximum_number_of_surfaces];
4525e141de4SHarry Wentland 	uint32_t num_displays_with_margin[3][8];
4535e141de4SHarry Wentland 	struct bw_fixed dmif_burst_time[3][8];
4545e141de4SHarry Wentland 	struct bw_fixed mcifwr_burst_time[3][8];
4555e141de4SHarry Wentland 	struct bw_fixed line_source_transfer_time[maximum_number_of_surfaces][3][8];
4565e141de4SHarry Wentland 	struct bw_fixed dram_speed_change_line_source_transfer_time[maximum_number_of_surfaces][3][8];
4575e141de4SHarry Wentland 	struct bw_fixed min_dram_speed_change_margin[3][8];
4585e141de4SHarry Wentland 	struct bw_fixed dispclk_required_for_dram_speed_change[3][8];
459e36ec859SDmytro Laktyushkin 	struct bw_fixed dispclk_required_for_dram_speed_change_pipe[3][8];
4605e141de4SHarry Wentland 	struct bw_fixed blackout_duration_margin[3][8];
4615e141de4SHarry Wentland 	struct bw_fixed dispclk_required_for_blackout_duration[3][8];
4625e141de4SHarry Wentland 	struct bw_fixed dispclk_required_for_blackout_recovery[3][8];
4635e141de4SHarry Wentland 	struct bw_fixed dmif_required_sclk_for_urgent_latency[6];
4645e141de4SHarry Wentland };
4655e141de4SHarry Wentland 
4665e141de4SHarry Wentland /**
4675e141de4SHarry Wentland  * Initialize structures with data which will NOT change at runtime.
4685e141de4SHarry Wentland  */
4695e141de4SHarry Wentland void bw_calcs_init(
4705e141de4SHarry Wentland 	struct bw_calcs_dceip *bw_dceip,
4715e141de4SHarry Wentland 	struct bw_calcs_vbios *bw_vbios,
4725e141de4SHarry Wentland 	struct hw_asic_id asic_id);
4735e141de4SHarry Wentland 
4745e141de4SHarry Wentland /**
4755e141de4SHarry Wentland  * Return:
4765e141de4SHarry Wentland  *	true -	Display(s) configuration supported.
4775e141de4SHarry Wentland  *		In this case 'calcs_output' contains data for HW programming
4785e141de4SHarry Wentland  *	false - Display(s) configuration not supported (not enough bandwidth).
4795e141de4SHarry Wentland  */
4805e141de4SHarry Wentland bool bw_calcs(
4815e141de4SHarry Wentland 	struct dc_context *ctx,
4825e141de4SHarry Wentland 	const struct bw_calcs_dceip *dceip,
4835e141de4SHarry Wentland 	const struct bw_calcs_vbios *vbios,
4845e141de4SHarry Wentland 	const struct pipe_ctx *pipe,
4855e141de4SHarry Wentland 	int pipe_count,
4869037d802SDmytro Laktyushkin 	struct dce_bw_output *calcs_output);
4875e141de4SHarry Wentland 
4885e141de4SHarry Wentland #endif /* __BANDWIDTH_CALCS_H__ */
4895e141de4SHarry Wentland 
490