drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dcn_calc_auto.c:1176:6: warning: stack frame size of 2576 bytes in function 'dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   2023a53bdf41b7646b1d384b6816af06309f73a5
commit: d0a3ac549f389c1511a4df0d7638536305205d20 ubsan: enable for all*config builds
date:   4 months ago
config: powerpc64-randconfig-r011-20210404 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 30df6d5d6a8537d3ec7d8fe4299289a4c5a74d5c)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install powerpc64 cross compiling tool for clang build
        # apt-get install binutils-powerpc64-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d0a3ac549f389c1511a4df0d7638536305205d20
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout d0a3ac549f389c1511a4df0d7638536305205d20
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

   drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dcn_calc_auto.c:121:6: warning: stack frame size of 5552 bytes in function 'mode_support_and_system_configuration' [-Wframe-larger-than=]
   void mode_support_and_system_configuration(struct dcn_bw_internal_vars *v)
        ^
>> drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dcn_calc_auto.c:1176:6: warning: stack frame size of 2576 bytes in function 'dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation' [-Wframe-larger-than=]
   void dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(struct dcn_bw_internal_vars *v)
        ^
   2 warnings generated.


vim +/dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation +1176 drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dcn_calc_auto.c

5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   120  
74c49c7ac14f3a Harry Wentland     2017-05-08   121  void mode_support_and_system_configuration(struct dcn_bw_internal_vars *v)
74c49c7ac14f3a Harry Wentland     2017-05-08   122  {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   123  	int i;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   124  	int j;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   125  	int k;
74c49c7ac14f3a Harry Wentland     2017-05-08   126  	/*mode support, voltage state and soc configuration*/
74c49c7ac14f3a Harry Wentland     2017-05-08   127  
74c49c7ac14f3a Harry Wentland     2017-05-08   128  	/*scale ratio support check*/
74c49c7ac14f3a Harry Wentland     2017-05-08   129  
74c49c7ac14f3a Harry Wentland     2017-05-08   130  	v->scale_ratio_support = dcn_bw_yes;
74c49c7ac14f3a Harry Wentland     2017-05-08   131  	for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   132  		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]))) {
74c49c7ac14f3a Harry Wentland     2017-05-08   133  			v->scale_ratio_support = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   134  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   135  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   136  	/*source format, pixel format and scan support check*/
74c49c7ac14f3a Harry Wentland     2017-05-08   137  
74c49c7ac14f3a Harry Wentland     2017-05-08   138  	v->source_format_pixel_and_scan_support = dcn_bw_yes;
74c49c7ac14f3a Harry Wentland     2017-05-08   139  	for (k = 0; k <= v->number_of_active_planes - 1; k++) {
afa80d64d20ac1 Dmytro Laktyushkin 2017-06-21   140  		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)) {
74c49c7ac14f3a Harry Wentland     2017-05-08   141  			v->source_format_pixel_and_scan_support = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   142  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   143  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   144  	/*bandwidth support check*/
74c49c7ac14f3a Harry Wentland     2017-05-08   145  
74c49c7ac14f3a Harry Wentland     2017-05-08   146  	for (k = 0; k <= v->number_of_active_planes - 1; k++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   147  		if (v->source_scan[k] == dcn_bw_hor) {
74c49c7ac14f3a Harry Wentland     2017-05-08   148  			v->swath_width_ysingle_dpp[k] = v->viewport_width[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   149  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   150  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08   151  			v->swath_width_ysingle_dpp[k] = v->viewport_height[k];
74c49c7ac14f3a Harry Wentland     2017-05-08   152  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   153  		if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
74c49c7ac14f3a Harry Wentland     2017-05-08   154  			v->byte_per_pixel_in_dety[k] = 8.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   155  			v->byte_per_pixel_in_detc[k] = 0.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   156  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   157  		else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_32) {
74c49c7ac14f3a Harry Wentland     2017-05-08   158  			v->byte_per_pixel_in_dety[k] = 4.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   159  			v->byte_per_pixel_in_detc[k] = 0.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   160  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   161  		else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_16) {
74c49c7ac14f3a Harry Wentland     2017-05-08   162  			v->byte_per_pixel_in_dety[k] = 2.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   163  			v->byte_per_pixel_in_detc[k] = 0.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   164  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   165  		else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
74c49c7ac14f3a Harry Wentland     2017-05-08   166  			v->byte_per_pixel_in_dety[k] = 1.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   167  			v->byte_per_pixel_in_detc[k] = 2.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   168  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   169  		else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   170  			v->byte_per_pixel_in_dety[k] = 4.0f / 3.0f;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   171  			v->byte_per_pixel_in_detc[k] = 8.0f / 3.0f;
74c49c7ac14f3a Harry Wentland     2017-05-08   172  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   173  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   174  	v->total_read_bandwidth_consumed_gbyte_per_second = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   175  	for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   176  		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]);
74c49c7ac14f3a Harry Wentland     2017-05-08   177  		if (v->dcc_enable[k] == dcn_bw_yes) {
74c49c7ac14f3a Harry Wentland     2017-05-08   178  			v->read_bandwidth[k] = v->read_bandwidth[k] * (1 + 1 / 256);
74c49c7ac14f3a Harry Wentland     2017-05-08   179  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   180  		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)) {
74c49c7ac14f3a Harry Wentland     2017-05-08   181  			v->read_bandwidth[k] = v->read_bandwidth[k] * (1 + 1 / 64);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   182  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   183  		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)) {
74c49c7ac14f3a Harry Wentland     2017-05-08   184  			v->read_bandwidth[k] = v->read_bandwidth[k] * (1 + 1 / 256);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   185  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   186  		else if (v->pte_enable == dcn_bw_yes) {
74c49c7ac14f3a Harry Wentland     2017-05-08   187  			v->read_bandwidth[k] = v->read_bandwidth[k] * (1 + 1 / 512);
74c49c7ac14f3a Harry Wentland     2017-05-08   188  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   189  		v->total_read_bandwidth_consumed_gbyte_per_second = v->total_read_bandwidth_consumed_gbyte_per_second + v->read_bandwidth[k] / 1000.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   190  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   191  	v->total_write_bandwidth_consumed_gbyte_per_second = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   192  	for (k = 0; k <= v->number_of_active_planes - 1; k++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   193  		if (v->output[k] == dcn_bw_writeback && v->output_format[k] == dcn_bw_444) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   194  			v->write_bandwidth[k] = v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) * 4.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   195  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   196  		else if (v->output[k] == dcn_bw_writeback) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   197  			v->write_bandwidth[k] = v->scaler_rec_out_width[k] / (v->htotal[k] / v->pixel_clock[k]) * 1.5;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   198  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   199  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08   200  			v->write_bandwidth[k] = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   201  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   202  		v->total_write_bandwidth_consumed_gbyte_per_second = v->total_write_bandwidth_consumed_gbyte_per_second + v->write_bandwidth[k] / 1000.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   203  	}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   204  	v->total_bandwidth_consumed_gbyte_per_second = v->total_read_bandwidth_consumed_gbyte_per_second + v->total_write_bandwidth_consumed_gbyte_per_second;
74c49c7ac14f3a Harry Wentland     2017-05-08   205  	v->dcc_enabled_in_any_plane = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   206  	for (k = 0; k <= v->number_of_active_planes - 1; k++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   207  		if (v->dcc_enable[k] == dcn_bw_yes) {
74c49c7ac14f3a Harry Wentland     2017-05-08   208  			v->dcc_enabled_in_any_plane = dcn_bw_yes;
74c49c7ac14f3a Harry Wentland     2017-05-08   209  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   210  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   211  	for (i = 0; i <= number_of_states_plus_one; i++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   212  		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);
74c49c7ac14f3a Harry Wentland     2017-05-08   213  		v->return_bw_per_state[i] = v->return_bw_todcn_per_state;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   214  		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) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   215  			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)));
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   216  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   217  		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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   218  		if (v->dcc_enabled_in_any_plane == dcn_bw_yes && v->critical_point > 1.0 && v->critical_point < 4.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   219  			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));
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   220  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   221  		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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   222  		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) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   223  			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)));
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   224  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   225  		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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   226  		if (v->dcc_enabled_in_any_plane == dcn_bw_yes && v->critical_point > 1.0 && v->critical_point < 4.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   227  			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));
74c49c7ac14f3a Harry Wentland     2017-05-08   228  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   229  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   230  	for (i = 0; i <= number_of_states_plus_one; i++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   231  		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)) {
74c49c7ac14f3a Harry Wentland     2017-05-08   232  			v->bandwidth_support[i] = dcn_bw_yes;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   233  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   234  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08   235  			v->bandwidth_support[i] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   236  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   237  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   238  	/*writeback latency support check*/
74c49c7ac14f3a Harry Wentland     2017-05-08   239  
74c49c7ac14f3a Harry Wentland     2017-05-08   240  	v->writeback_latency_support = dcn_bw_yes;
74c49c7ac14f3a Harry Wentland     2017-05-08   241  	for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   242  		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) {
74c49c7ac14f3a Harry Wentland     2017-05-08   243  			v->writeback_latency_support = dcn_bw_no;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   244  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   245  		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) {
74c49c7ac14f3a Harry Wentland     2017-05-08   246  			v->writeback_latency_support = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   247  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   248  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   249  	/*re-ordering buffer support check*/
74c49c7ac14f3a Harry Wentland     2017-05-08   250  
74c49c7ac14f3a Harry Wentland     2017-05-08   251  	for (i = 0; i <= number_of_states_plus_one; i++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   252  		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];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   253  		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]) {
74c49c7ac14f3a Harry Wentland     2017-05-08   254  			v->rob_support[i] = dcn_bw_yes;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   255  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   256  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08   257  			v->rob_support[i] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   258  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   259  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   260  	/*display io support check*/
74c49c7ac14f3a Harry Wentland     2017-05-08   261  
74c49c7ac14f3a Harry Wentland     2017-05-08   262  	for (k = 0; k <= v->number_of_active_planes - 1; k++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   263  		if (v->output[k] == dcn_bw_dp && v->dsc_capability == dcn_bw_yes) {
74c49c7ac14f3a Harry Wentland     2017-05-08   264  			if (v->output_format[k] == dcn_bw_420) {
74c49c7ac14f3a Harry Wentland     2017-05-08   265  				v->required_output_bw = v->pixel_clock[k] / 2.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   266  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   267  			else {
74c49c7ac14f3a Harry Wentland     2017-05-08   268  				v->required_output_bw = v->pixel_clock[k];
74c49c7ac14f3a Harry Wentland     2017-05-08   269  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   270  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   271  		else if (v->output_format[k] == dcn_bw_420) {
74c49c7ac14f3a Harry Wentland     2017-05-08   272  			v->required_output_bw = v->pixel_clock[k] * 3.0 / 2.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   273  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   274  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08   275  			v->required_output_bw = v->pixel_clock[k] * 3.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   276  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   277  		if (v->output[k] == dcn_bw_hdmi) {
6dd28867b1f964 Charlene Liu       2017-07-31   278  			v->required_phyclk[k] = v->required_output_bw;
6dd28867b1f964 Charlene Liu       2017-07-31   279  			switch (v->output_deep_color[k]) {
6dd28867b1f964 Charlene Liu       2017-07-31   280  			case dcn_bw_encoder_10bpc:
6dd28867b1f964 Charlene Liu       2017-07-31   281  				v->required_phyclk[k] =  v->required_phyclk[k] * 5.0 / 4;
6dd28867b1f964 Charlene Liu       2017-07-31   282  			break;
6dd28867b1f964 Charlene Liu       2017-07-31   283  			case dcn_bw_encoder_12bpc:
6dd28867b1f964 Charlene Liu       2017-07-31   284  				v->required_phyclk[k] =  v->required_phyclk[k] * 3.0 / 2;
6dd28867b1f964 Charlene Liu       2017-07-31   285  				break;
6dd28867b1f964 Charlene Liu       2017-07-31   286  			default:
6dd28867b1f964 Charlene Liu       2017-07-31   287  				break;
6dd28867b1f964 Charlene Liu       2017-07-31   288  			}
f0f8b2db570bf3 Charlene Liu       2017-07-31   289  			v->required_phyclk[k] = v->required_phyclk[k] / 3.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   290  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   291  		else if (v->output[k] == dcn_bw_dp) {
74c49c7ac14f3a Harry Wentland     2017-05-08   292  			v->required_phyclk[k] = v->required_output_bw / 4.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   293  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   294  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08   295  			v->required_phyclk[k] = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   296  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   297  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   298  	for (i = 0; i <= number_of_states_plus_one; i++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   299  		v->dio_support[i] = dcn_bw_yes;
74c49c7ac14f3a Harry Wentland     2017-05-08   300  		for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   301  			if (v->required_phyclk[k] > v->phyclk_per_state[i] || (v->output[k] == dcn_bw_hdmi && v->required_phyclk[k] > 600.0)) {
74c49c7ac14f3a Harry Wentland     2017-05-08   302  				v->dio_support[i] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   303  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   304  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   305  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   306  	/*total available writeback support check*/
74c49c7ac14f3a Harry Wentland     2017-05-08   307  
74c49c7ac14f3a Harry Wentland     2017-05-08   308  	v->total_number_of_active_writeback = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   309  	for (k = 0; k <= v->number_of_active_planes - 1; k++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   310  		if (v->output[k] == dcn_bw_writeback) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   311  			v->total_number_of_active_writeback = v->total_number_of_active_writeback + 1.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   312  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   313  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   314  	if (v->total_number_of_active_writeback <= v->max_num_writeback) {
74c49c7ac14f3a Harry Wentland     2017-05-08   315  		v->total_available_writeback_support = dcn_bw_yes;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   316  	}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   317  	else {
74c49c7ac14f3a Harry Wentland     2017-05-08   318  		v->total_available_writeback_support = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   319  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   320  	/*maximum dispclk/dppclk support check*/
74c49c7ac14f3a Harry Wentland     2017-05-08   321  
74c49c7ac14f3a Harry Wentland     2017-05-08   322  	for (k = 0; k <= v->number_of_active_planes - 1; k++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   323  		if (v->h_ratio[k] > 1.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   324  			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));
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   325  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   326  		else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   327  			v->pscl_factor[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput);
74c49c7ac14f3a Harry Wentland     2017-05-08   328  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   329  		if (v->byte_per_pixel_in_detc[k] == 0.0) {
74c49c7ac14f3a Harry Wentland     2017-05-08   330  			v->pscl_factor_chroma[k] = 0.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   331  			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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   332  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   333  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08   334  			if (v->h_ratio[k] / 2.0 > 1.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   335  				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));
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   336  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   337  			else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   338  				v->pscl_factor_chroma[k] =dcn_bw_min2(v->max_dchub_topscl_throughput, v->max_pscl_tolb_throughput);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   339  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   340  			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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   341  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   342  	}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   343  	for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   344  		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)) {
74c49c7ac14f3a Harry Wentland     2017-05-08   345  			if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
74c49c7ac14f3a Harry Wentland     2017-05-08   346  				v->read256_block_height_y[k] = 1.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   347  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   348  			else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
74c49c7ac14f3a Harry Wentland     2017-05-08   349  				v->read256_block_height_y[k] = 4.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   350  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   351  			else {
74c49c7ac14f3a Harry Wentland     2017-05-08   352  				v->read256_block_height_y[k] = 8.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   353  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   354  			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];
74c49c7ac14f3a Harry Wentland     2017-05-08   355  			v->read256_block_height_c[k] = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   356  			v->read256_block_width_c[k] = 0.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   357  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   358  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08   359  			if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
74c49c7ac14f3a Harry Wentland     2017-05-08   360  				v->read256_block_height_y[k] = 1.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   361  				v->read256_block_height_c[k] = 1.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   362  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   363  			else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
74c49c7ac14f3a Harry Wentland     2017-05-08   364  				v->read256_block_height_y[k] = 16.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   365  				v->read256_block_height_c[k] = 8.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   366  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   367  			else {
74c49c7ac14f3a Harry Wentland     2017-05-08   368  				v->read256_block_height_y[k] = 8.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   369  				v->read256_block_height_c[k] = 8.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   370  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   371  			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];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   372  			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];
74c49c7ac14f3a Harry Wentland     2017-05-08   373  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   374  		if (v->source_scan[k] == dcn_bw_hor) {
74c49c7ac14f3a Harry Wentland     2017-05-08   375  			v->max_swath_height_y[k] = v->read256_block_height_y[k];
74c49c7ac14f3a Harry Wentland     2017-05-08   376  			v->max_swath_height_c[k] = v->read256_block_height_c[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   377  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   378  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08   379  			v->max_swath_height_y[k] = v->read256_block_width_y[k];
74c49c7ac14f3a Harry Wentland     2017-05-08   380  			v->max_swath_height_c[k] = v->read256_block_width_c[k];
74c49c7ac14f3a Harry Wentland     2017-05-08   381  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   382  		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)) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   383  			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)) {
74c49c7ac14f3a Harry Wentland     2017-05-08   384  				v->min_swath_height_y[k] = v->max_swath_height_y[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   385  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   386  			else {
74c49c7ac14f3a Harry Wentland     2017-05-08   387  				v->min_swath_height_y[k] = v->max_swath_height_y[k] / 2.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   388  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   389  			v->min_swath_height_c[k] = v->max_swath_height_c[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   390  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   391  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08   392  			if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
74c49c7ac14f3a Harry Wentland     2017-05-08   393  				v->min_swath_height_y[k] = v->max_swath_height_y[k];
74c49c7ac14f3a Harry Wentland     2017-05-08   394  				v->min_swath_height_c[k] = v->max_swath_height_c[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   395  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   396  			else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8 && v->source_scan[k] == dcn_bw_hor) {
74c49c7ac14f3a Harry Wentland     2017-05-08   397  				v->min_swath_height_y[k] = v->max_swath_height_y[k] / 2.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   398  				if (v->bug_forcing_luma_and_chroma_request_to_same_size_fixed == dcn_bw_yes) {
74c49c7ac14f3a Harry Wentland     2017-05-08   399  					v->min_swath_height_c[k] = v->max_swath_height_c[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   400  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   401  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08   402  					v->min_swath_height_c[k] = v->max_swath_height_c[k] / 2.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   403  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   404  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   405  			else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10 && v->source_scan[k] == dcn_bw_hor) {
74c49c7ac14f3a Harry Wentland     2017-05-08   406  				v->min_swath_height_c[k] = v->max_swath_height_c[k] / 2.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   407  				if (v->bug_forcing_luma_and_chroma_request_to_same_size_fixed == dcn_bw_yes) {
74c49c7ac14f3a Harry Wentland     2017-05-08   408  					v->min_swath_height_y[k] = v->max_swath_height_y[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   409  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   410  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08   411  					v->min_swath_height_y[k] = v->max_swath_height_y[k] / 2.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   412  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   413  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   414  			else {
74c49c7ac14f3a Harry Wentland     2017-05-08   415  				v->min_swath_height_y[k] = v->max_swath_height_y[k];
74c49c7ac14f3a Harry Wentland     2017-05-08   416  				v->min_swath_height_c[k] = v->max_swath_height_c[k];
74c49c7ac14f3a Harry Wentland     2017-05-08   417  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   418  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   419  		if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
74c49c7ac14f3a Harry Wentland     2017-05-08   420  			v->maximum_swath_width = 8192.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   421  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   422  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08   423  			v->maximum_swath_width = 5120.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   424  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   425  		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);
74c49c7ac14f3a Harry Wentland     2017-05-08   426  		if (v->byte_per_pixel_in_detc[k] == 0.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   427  			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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   428  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   429  		else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   430  			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));
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   431  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   432  		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);
74c49c7ac14f3a Harry Wentland     2017-05-08   433  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   434  	for (i = 0; i <= number_of_states_plus_one; i++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   435  		for (j = 0; j <= 1; j++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   436  			v->total_number_of_active_dpp[i][j] = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   437  			v->required_dispclk[i][j] = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   438  			v->dispclk_dppclk_support[i][j] = dcn_bw_yes;
74c49c7ac14f3a Harry Wentland     2017-05-08   439  			for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   440  				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);
74c49c7ac14f3a Harry Wentland     2017-05-08   441  				if (v->odm_capability == dcn_bw_yes) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   442  					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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   443  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   444  				else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   445  					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);
74c49c7ac14f3a Harry Wentland     2017-05-08   446  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   447  				if (i < number_of_states) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   448  					v->min_dispclk_using_single_dpp = v->min_dispclk_using_single_dpp * (1.0 + v->dispclk_ramping_margin / 100.0);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   449  					v->min_dispclk_using_dual_dpp = v->min_dispclk_using_dual_dpp * (1.0 + v->dispclk_ramping_margin / 100.0);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   450  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   451  				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) {
74c49c7ac14f3a Harry Wentland     2017-05-08   452  					v->no_of_dpp[i][j][k] = 1.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   453  					v->required_dispclk[i][j] =dcn_bw_max2(v->required_dispclk[i][j], v->min_dispclk_using_single_dpp);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   454  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   455  				else if (v->min_dispclk_using_dual_dpp <=dcn_bw_min2(v->max_dispclk[i], (j + 1) * v->max_dppclk[i])) {
74c49c7ac14f3a Harry Wentland     2017-05-08   456  					v->no_of_dpp[i][j][k] = 2.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   457  					v->required_dispclk[i][j] =dcn_bw_max2(v->required_dispclk[i][j], v->min_dispclk_using_dual_dpp);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   458  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   459  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08   460  					v->no_of_dpp[i][j][k] = 2.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   461  					v->required_dispclk[i][j] =dcn_bw_max2(v->required_dispclk[i][j], v->min_dispclk_using_dual_dpp);
74c49c7ac14f3a Harry Wentland     2017-05-08   462  					v->dispclk_dppclk_support[i][j] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   463  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   464  				v->total_number_of_active_dpp[i][j] = v->total_number_of_active_dpp[i][j] + v->no_of_dpp[i][j][k];
74c49c7ac14f3a Harry Wentland     2017-05-08   465  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   466  			if (v->total_number_of_active_dpp[i][j] > v->max_num_dpp) {
74c49c7ac14f3a Harry Wentland     2017-05-08   467  				v->total_number_of_active_dpp[i][j] = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   468  				v->required_dispclk[i][j] = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   469  				v->dispclk_dppclk_support[i][j] = dcn_bw_yes;
74c49c7ac14f3a Harry Wentland     2017-05-08   470  				for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   471  					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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   472  					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);
74c49c7ac14f3a Harry Wentland     2017-05-08   473  					if (i < number_of_states) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   474  						v->min_dispclk_using_single_dpp = v->min_dispclk_using_single_dpp * (1.0 + v->dispclk_ramping_margin / 100.0);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   475  						v->min_dispclk_using_dual_dpp = v->min_dispclk_using_dual_dpp * (1.0 + v->dispclk_ramping_margin / 100.0);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   476  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   477  					if (v->number_of_dpp_required_for_det_and_lb_size[k] <= 1.0) {
74c49c7ac14f3a Harry Wentland     2017-05-08   478  						v->no_of_dpp[i][j][k] = 1.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   479  						v->required_dispclk[i][j] =dcn_bw_max2(v->required_dispclk[i][j], v->min_dispclk_using_single_dpp);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   480  						if (v->min_dispclk_using_single_dpp >dcn_bw_min2(v->max_dispclk[i], (j + 1) * v->max_dppclk[i])) {
74c49c7ac14f3a Harry Wentland     2017-05-08   481  							v->dispclk_dppclk_support[i][j] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   482  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   483  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   484  					else {
74c49c7ac14f3a Harry Wentland     2017-05-08   485  						v->no_of_dpp[i][j][k] = 2.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   486  						v->required_dispclk[i][j] =dcn_bw_max2(v->required_dispclk[i][j], v->min_dispclk_using_dual_dpp);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   487  						if (v->min_dispclk_using_dual_dpp >dcn_bw_min2(v->max_dispclk[i], (j + 1) * v->max_dppclk[i])) {
74c49c7ac14f3a Harry Wentland     2017-05-08   488  							v->dispclk_dppclk_support[i][j] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   489  						}
74c49c7ac14f3a Harry Wentland     2017-05-08   490  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   491  					v->total_number_of_active_dpp[i][j] = v->total_number_of_active_dpp[i][j] + v->no_of_dpp[i][j][k];
74c49c7ac14f3a Harry Wentland     2017-05-08   492  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   493  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   494  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   495  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   496  	/*viewport size check*/
74c49c7ac14f3a Harry Wentland     2017-05-08   497  
74c49c7ac14f3a Harry Wentland     2017-05-08   498  	v->viewport_size_support = dcn_bw_yes;
74c49c7ac14f3a Harry Wentland     2017-05-08   499  	for (k = 0; k <= v->number_of_active_planes - 1; k++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   500  		if (v->number_of_dpp_required_for_det_and_lb_size[k] > 2.0) {
74c49c7ac14f3a Harry Wentland     2017-05-08   501  			v->viewport_size_support = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   502  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   503  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   504  	/*total available pipes support check*/
74c49c7ac14f3a Harry Wentland     2017-05-08   505  
74c49c7ac14f3a Harry Wentland     2017-05-08   506  	for (i = 0; i <= number_of_states_plus_one; i++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   507  		for (j = 0; j <= 1; j++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   508  			if (v->total_number_of_active_dpp[i][j] <= v->max_num_dpp) {
74c49c7ac14f3a Harry Wentland     2017-05-08   509  				v->total_available_pipes_support[i][j] = dcn_bw_yes;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   510  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   511  			else {
74c49c7ac14f3a Harry Wentland     2017-05-08   512  				v->total_available_pipes_support[i][j] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   513  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   514  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   515  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   516  	/*urgent latency support check*/
74c49c7ac14f3a Harry Wentland     2017-05-08   517  
74c49c7ac14f3a Harry Wentland     2017-05-08   518  	for (k = 0; k <= v->number_of_active_planes - 1; k++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   519  		for (i = 0; i <= number_of_states_plus_one; i++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   520  			for (j = 0; j <= 1; j++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   521  				v->swath_width_yper_state[i][j][k] = v->swath_width_ysingle_dpp[k] / v->no_of_dpp[i][j][k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   522  				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];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   523  				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];
74c49c7ac14f3a Harry Wentland     2017-05-08   524  				if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   525  					v->rounded_up_max_swath_size_bytes_y =dcn_bw_ceil2(v->rounded_up_max_swath_size_bytes_y, 256.0) + 256;
74c49c7ac14f3a Harry Wentland     2017-05-08   526  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   527  				if (v->max_swath_height_c[k] > 0.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   528  					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];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   529  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   530  				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];
74c49c7ac14f3a Harry Wentland     2017-05-08   531  				if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   532  					v->rounded_up_max_swath_size_bytes_c =dcn_bw_ceil2(v->rounded_up_max_swath_size_bytes_c, 256.0) + 256;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   533  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   534  				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) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   535  					v->swath_height_yper_state[i][j][k] = v->max_swath_height_y[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   536  					v->swath_height_cper_state[i][j][k] = v->max_swath_height_c[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   537  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   538  				else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   539  					v->swath_height_yper_state[i][j][k] = v->min_swath_height_y[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   540  					v->swath_height_cper_state[i][j][k] = v->min_swath_height_c[k];
74c49c7ac14f3a Harry Wentland     2017-05-08   541  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   542  				if (v->byte_per_pixel_in_detc[k] == 0.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   543  					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];
74c49c7ac14f3a Harry Wentland     2017-05-08   544  					v->lines_in_det_chroma = 0.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   545  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   546  				else if (v->swath_height_yper_state[i][j][k] <= v->swath_height_cper_state[i][j][k]) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   547  					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];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   548  					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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   549  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   550  				else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   551  					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];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   552  					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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   553  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   554  				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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   555  				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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   556  				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]);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   557  				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]);
74c49c7ac14f3a Harry Wentland     2017-05-08   558  				if (v->byte_per_pixel_in_detc[k] == 0.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   559  					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]);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   560  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   561  				else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   562  					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]));
74c49c7ac14f3a Harry Wentland     2017-05-08   563  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   564  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   565  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   566  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   567  	for (i = 0; i <= number_of_states_plus_one; i++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   568  		for (j = 0; j <= 1; j++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   569  			v->urgent_latency_support[i][j] = dcn_bw_yes;
74c49c7ac14f3a Harry Wentland     2017-05-08   570  			for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   571  				if (v->urgent_latency_support_us_per_state[i][j][k] < v->urgent_latency / 1.0) {
74c49c7ac14f3a Harry Wentland     2017-05-08   572  					v->urgent_latency_support[i][j] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   573  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   574  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   575  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   576  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   577  	/*prefetch check*/
74c49c7ac14f3a Harry Wentland     2017-05-08   578  
74c49c7ac14f3a Harry Wentland     2017-05-08   579  	for (i = 0; i <= number_of_states_plus_one; i++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   580  		for (j = 0; j <= 1; j++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   581  			v->total_number_of_dcc_active_dpp[i][j] = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   582  			for (k = 0; k <= v->number_of_active_planes - 1; k++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   583  				if (v->dcc_enable[k] == dcn_bw_yes) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   584  					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];
74c49c7ac14f3a Harry Wentland     2017-05-08   585  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   586  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   587  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   588  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   589  	for (i = 0; i <= number_of_states_plus_one; i++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   590  		for (j = 0; j <= 1; j++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   591  			v->projected_dcfclk_deep_sleep = 8.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   592  			for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   593  				v->projected_dcfclk_deep_sleep =dcn_bw_max2(v->projected_dcfclk_deep_sleep, v->pixel_clock[k] / 16.0);
74c49c7ac14f3a Harry Wentland     2017-05-08   594  				if (v->byte_per_pixel_in_detc[k] == 0.0) {
74c49c7ac14f3a Harry Wentland     2017-05-08   595  					if (v->v_ratio[k] <= 1.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   596  						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]);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   597  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   598  					else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   599  						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));
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   600  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   601  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   602  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08   603  					if (v->v_ratio[k] <= 1.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   604  						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]);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   605  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   606  					else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   607  						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));
74c49c7ac14f3a Harry Wentland     2017-05-08   608  					}
74c49c7ac14f3a Harry Wentland     2017-05-08   609  					if (v->v_ratio[k] / 2.0 <= 1.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   610  						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]);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   611  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   612  					else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   613  						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));
74c49c7ac14f3a Harry Wentland     2017-05-08   614  					}
74c49c7ac14f3a Harry Wentland     2017-05-08   615  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   616  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   617  			for (k = 0; k <= v->number_of_active_planes - 1; k++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   618  				if (v->dcc_enable[k] == dcn_bw_yes) {
74c49c7ac14f3a Harry Wentland     2017-05-08   619  					v->meta_req_height_y = 8.0 * v->read256_block_height_y[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   620  					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;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   621  					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;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   622  					v->meta_surface_height_y =dcn_bw_ceil2(v->viewport_height[k] - 1.0, v->meta_req_height_y) + v->meta_req_height_y;
74c49c7ac14f3a Harry Wentland     2017-05-08   623  					if (v->pte_enable == dcn_bw_yes) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   624  						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;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   625  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   626  					else {
74c49c7ac14f3a Harry Wentland     2017-05-08   627  						v->meta_pte_bytes_per_frame_y = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   628  					}
74c49c7ac14f3a Harry Wentland     2017-05-08   629  					if (v->source_scan[k] == dcn_bw_hor) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   630  						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;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   631  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   632  					else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   633  						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;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   634  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   635  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   636  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08   637  					v->meta_pte_bytes_per_frame_y = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   638  					v->meta_row_bytes_y = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   639  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   640  				if (v->pte_enable == dcn_bw_yes) {
74c49c7ac14f3a Harry Wentland     2017-05-08   641  					if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
74c49c7ac14f3a Harry Wentland     2017-05-08   642  						v->macro_tile_block_size_bytes_y = 256.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   643  						v->macro_tile_block_height_y = 1.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   644  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   645  					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) {
74c49c7ac14f3a Harry Wentland     2017-05-08   646  						v->macro_tile_block_size_bytes_y = 4096.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   647  						v->macro_tile_block_height_y = 4.0 * v->read256_block_height_y[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   648  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   649  					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) {
74c49c7ac14f3a Harry Wentland     2017-05-08   650  						v->macro_tile_block_size_bytes_y = 64.0 * 1024;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   651  						v->macro_tile_block_height_y = 16.0 * v->read256_block_height_y[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   652  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   653  					else {
74c49c7ac14f3a Harry Wentland     2017-05-08   654  						v->macro_tile_block_size_bytes_y = 256.0 * 1024;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   655  						v->macro_tile_block_height_y = 32.0 * v->read256_block_height_y[k];
74c49c7ac14f3a Harry Wentland     2017-05-08   656  					}
74c49c7ac14f3a Harry Wentland     2017-05-08   657  					if (v->macro_tile_block_size_bytes_y <= 65536.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   658  						v->data_pte_req_height_y = v->macro_tile_block_height_y;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   659  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   660  					else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   661  						v->data_pte_req_height_y = 16.0 * v->read256_block_height_y[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   662  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   663  					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;
74c49c7ac14f3a Harry Wentland     2017-05-08   664  					if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   665  						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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   666  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   667  					else if (v->source_scan[k] == dcn_bw_hor) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   668  						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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   669  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   670  					else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   671  						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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   672  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   673  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   674  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08   675  					v->dpte_bytes_per_row_y = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   676  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   677  				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)) {
74c49c7ac14f3a Harry Wentland     2017-05-08   678  					if (v->dcc_enable[k] == dcn_bw_yes) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   679  						v->meta_req_height_c = 8.0 * v->read256_block_height_c[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   680  						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;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   681  						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;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   682  						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;
74c49c7ac14f3a Harry Wentland     2017-05-08   683  						if (v->pte_enable == dcn_bw_yes) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   684  							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;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   685  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   686  						else {
74c49c7ac14f3a Harry Wentland     2017-05-08   687  							v->meta_pte_bytes_per_frame_c = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   688  						}
74c49c7ac14f3a Harry Wentland     2017-05-08   689  						if (v->source_scan[k] == dcn_bw_hor) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   690  							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;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   691  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   692  						else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   693  							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;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   694  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   695  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   696  					else {
74c49c7ac14f3a Harry Wentland     2017-05-08   697  						v->meta_pte_bytes_per_frame_c = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   698  						v->meta_row_bytes_c = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   699  					}
74c49c7ac14f3a Harry Wentland     2017-05-08   700  					if (v->pte_enable == dcn_bw_yes) {
74c49c7ac14f3a Harry Wentland     2017-05-08   701  						if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
74c49c7ac14f3a Harry Wentland     2017-05-08   702  							v->macro_tile_block_size_bytes_c = 256.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   703  							v->macro_tile_block_height_c = 1.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   704  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   705  						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) {
74c49c7ac14f3a Harry Wentland     2017-05-08   706  							v->macro_tile_block_size_bytes_c = 4096.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   707  							v->macro_tile_block_height_c = 4.0 * v->read256_block_height_c[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   708  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   709  						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) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   710  							v->macro_tile_block_size_bytes_c = 64.0 * 1024;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   711  							v->macro_tile_block_height_c = 16.0 * v->read256_block_height_c[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   712  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   713  						else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   714  							v->macro_tile_block_size_bytes_c = 256.0 * 1024;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   715  							v->macro_tile_block_height_c = 32.0 * v->read256_block_height_c[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   716  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   717  						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;
74c49c7ac14f3a Harry Wentland     2017-05-08   718  						if (v->macro_tile_block_size_bytes_c <= 65536.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   719  							v->data_pte_req_height_c = v->macro_tile_block_height_c;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   720  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   721  						else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   722  							v->data_pte_req_height_c = 16.0 * v->read256_block_height_c[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   723  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   724  						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;
74c49c7ac14f3a Harry Wentland     2017-05-08   725  						if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   726  							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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   727  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   728  						else if (v->source_scan[k] == dcn_bw_hor) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   729  							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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   730  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   731  						else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   732  							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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   733  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   734  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   735  					else {
74c49c7ac14f3a Harry Wentland     2017-05-08   736  						v->dpte_bytes_per_row_c = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   737  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   738  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   739  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08   740  					v->dpte_bytes_per_row_c = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   741  					v->meta_pte_bytes_per_frame_c = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   742  					v->meta_row_bytes_c = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   743  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   744  				v->dpte_bytes_per_row[k] = v->dpte_bytes_per_row_y + v->dpte_bytes_per_row_c;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   745  				v->meta_pte_bytes_per_frame[k] = v->meta_pte_bytes_per_frame_y + v->meta_pte_bytes_per_frame_c;
74c49c7ac14f3a Harry Wentland     2017-05-08   746  				v->meta_row_bytes[k] = v->meta_row_bytes_y + v->meta_row_bytes_c;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   747  				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;
74c49c7ac14f3a Harry Wentland     2017-05-08   748  				v->prefill_y[k] =dcn_bw_floor2(v->v_init_y, 1.0);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   749  				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;
74c49c7ac14f3a Harry Wentland     2017-05-08   750  				if (v->prefill_y[k] > 1.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   751  					v->max_partial_sw_y =dcn_bw_mod((v->prefill_y[k] - 2.0), v->swath_height_yper_state[i][j][k]);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   752  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   753  				else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   754  					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]);
74c49c7ac14f3a Harry Wentland     2017-05-08   755  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   756  				v->max_partial_sw_y =dcn_bw_max2(1.0, v->max_partial_sw_y);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   757  				v->prefetch_lines_y[k] = v->max_num_sw_y[k] * v->swath_height_yper_state[i][j][k] + v->max_partial_sw_y;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   758  				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)) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   759  					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;
74c49c7ac14f3a Harry Wentland     2017-05-08   760  					v->prefill_c[k] =dcn_bw_floor2(v->v_init_c, 1.0);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   761  					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;
74c49c7ac14f3a Harry Wentland     2017-05-08   762  					if (v->prefill_c[k] > 1.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   763  						v->max_partial_sw_c =dcn_bw_mod((v->prefill_c[k] - 2.0), v->swath_height_cper_state[i][j][k]);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   764  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   765  					else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   766  						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]);
74c49c7ac14f3a Harry Wentland     2017-05-08   767  					}
74c49c7ac14f3a Harry Wentland     2017-05-08   768  					v->max_partial_sw_c =dcn_bw_max2(1.0, v->max_partial_sw_c);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   769  					v->prefetch_lines_c[k] = v->max_num_sw_c[k] * v->swath_height_cper_state[i][j][k] + v->max_partial_sw_c;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   770  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   771  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08   772  					v->prefetch_lines_c[k] = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   773  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   774  				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];
74c49c7ac14f3a Harry Wentland     2017-05-08   775  				if (v->no_of_dpp[i][j][k] > 1.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   776  					v->dst_x_after_scaler = v->dst_x_after_scaler + v->scaler_rec_out_width[k] / 2.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   777  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   778  				if (v->output_format[k] == dcn_bw_420) {
74c49c7ac14f3a Harry Wentland     2017-05-08   779  					v->dst_y_after_scaler = 1.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   780  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   781  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08   782  					v->dst_y_after_scaler = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   783  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   784  				v->time_calc = 24.0 / v->projected_dcfclk_deep_sleep;
2961fef7058dcd Dmytro Laktyushkin 2017-12-04   785  				v->v_update_offset[k][j] = dcn_bw_ceil2(v->htotal[k] / 4.0, 1.0);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   786  				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]);
2961fef7058dcd Dmytro Laktyushkin 2017-12-04   787  				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];
2961fef7058dcd Dmytro Laktyushkin 2017-12-04   788  				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];
2961fef7058dcd Dmytro Laktyushkin 2017-12-04   789  				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];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   790  				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];
74c49c7ac14f3a Harry Wentland     2017-05-08   791  				if (v->pte_enable == dcn_bw_yes) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   792  					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];
74c49c7ac14f3a Harry Wentland     2017-05-08   793  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   794  				if (v->can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one == dcn_bw_yes) {
74c49c7ac14f3a Harry Wentland     2017-05-08   795  					v->maximum_vstartup = v->vtotal[k] - v->vactive[k] - 1.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   796  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   797  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08   798  					v->maximum_vstartup = v->v_sync_plus_back_porch[k] - 1.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   799  				}
987741af33e5b8 Eric Yang          2018-11-21   800  
987741af33e5b8 Eric Yang          2018-11-21   801  				do {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   802  					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]);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   803  					v->line_times_for_prefetch[k] =dcn_bw_floor2(4.0 * (v->line_times_for_prefetch[k] + 0.125), 1.0) / 4;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   804  					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]);
987741af33e5b8 Eric Yang          2018-11-21   805  
987741af33e5b8 Eric Yang          2018-11-21   806  					if (v->pte_enable == dcn_bw_yes && v->dcc_enable[k] == dcn_bw_yes) {
987741af33e5b8 Eric Yang          2018-11-21   807  						v->time_for_meta_pte_without_immediate_flip = dcn_bw_max3(
4a673157b8d1e4 Michael Strauss    2020-05-08   808  								v->meta_pte_bytes_frame[k] / v->prefetch_bw[k],
987741af33e5b8 Eric Yang          2018-11-21   809  								v->extra_latency,
987741af33e5b8 Eric Yang          2018-11-21   810  								v->htotal[k] / v->pixel_clock[k] / 4.0);
987741af33e5b8 Eric Yang          2018-11-21   811  					} else {
987741af33e5b8 Eric Yang          2018-11-21   812  						v->time_for_meta_pte_without_immediate_flip = v->htotal[k] / v->pixel_clock[k] / 4.0;
987741af33e5b8 Eric Yang          2018-11-21   813  					}
987741af33e5b8 Eric Yang          2018-11-21   814  
987741af33e5b8 Eric Yang          2018-11-21   815  					if (v->pte_enable == dcn_bw_yes || v->dcc_enable[k] == dcn_bw_yes) {
987741af33e5b8 Eric Yang          2018-11-21   816  						v->time_for_meta_and_dpte_row_without_immediate_flip = dcn_bw_max3((
4a673157b8d1e4 Michael Strauss    2020-05-08   817  								v->meta_row_bytes[k] + v->dpte_bytes_per_row[k]) / v->prefetch_bw[k],
987741af33e5b8 Eric Yang          2018-11-21   818  								v->htotal[k] / v->pixel_clock[k] - v->time_for_meta_pte_without_immediate_flip,
987741af33e5b8 Eric Yang          2018-11-21   819  								v->extra_latency);
987741af33e5b8 Eric Yang          2018-11-21   820  					} else {
987741af33e5b8 Eric Yang          2018-11-21   821  						v->time_for_meta_and_dpte_row_without_immediate_flip = dcn_bw_max2(
987741af33e5b8 Eric Yang          2018-11-21   822  								v->htotal[k] / v->pixel_clock[k] - v->time_for_meta_pte_without_immediate_flip,
987741af33e5b8 Eric Yang          2018-11-21   823  								v->extra_latency - v->time_for_meta_pte_with_immediate_flip);
987741af33e5b8 Eric Yang          2018-11-21   824  					}
987741af33e5b8 Eric Yang          2018-11-21   825  
987741af33e5b8 Eric Yang          2018-11-21   826  					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;
987741af33e5b8 Eric Yang          2018-11-21   827  					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;
987741af33e5b8 Eric Yang          2018-11-21   828  					v->maximum_vstartup = v->maximum_vstartup - 1;
987741af33e5b8 Eric Yang          2018-11-21   829  
4a673157b8d1e4 Michael Strauss    2020-05-08   830  					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)
987741af33e5b8 Eric Yang          2018-11-21   831  						break;
987741af33e5b8 Eric Yang          2018-11-21   832  
987741af33e5b8 Eric Yang          2018-11-21   833  				} while(1);
74c49c7ac14f3a Harry Wentland     2017-05-08   834  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   835  			v->bw_available_for_immediate_flip = v->return_bw_per_state[i];
74c49c7ac14f3a Harry Wentland     2017-05-08   836  			for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   837  				v->bw_available_for_immediate_flip = v->bw_available_for_immediate_flip -dcn_bw_max2(v->read_bandwidth[k], v->prefetch_bw[k]);
74c49c7ac14f3a Harry Wentland     2017-05-08   838  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   839  			for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   840  				v->total_immediate_flip_bytes[k] = 0.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   841  				if ((v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   842  					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];
74c49c7ac14f3a Harry Wentland     2017-05-08   843  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   844  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   845  			for (k = 0; k <= v->number_of_active_planes - 1; k++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   846  				if (v->pte_enable == dcn_bw_yes && v->dcc_enable[k] == dcn_bw_yes) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   847  					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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   848  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   849  				else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   850  					v->time_for_meta_pte_with_immediate_flip = v->htotal[k] / v->pixel_clock[k] / 4.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   851  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   852  				if (v->pte_enable == dcn_bw_yes || v->dcc_enable[k] == dcn_bw_yes) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   853  					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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   854  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   855  				else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   856  					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);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   857  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   858  				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;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   859  				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;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   860  				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];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   861  				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];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   862  				if (v->line_times_to_request_prefetch_pixel_data_with_immediate_flip > 0.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   863  					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;
74c49c7ac14f3a Harry Wentland     2017-05-08   864  					if ((v->swath_height_yper_state[i][j][k] > 4.0)) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   865  						if (v->line_times_to_request_prefetch_pixel_data_with_immediate_flip - (v->prefill_y[k] - 3.0) / 2.0 > 0.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   866  							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));
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   867  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   868  						else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   869  							v->v_ratio_pre_ywith_immediate_flip[i][j][k] = 999999.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   870  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   871  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   872  					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;
74c49c7ac14f3a Harry Wentland     2017-05-08   873  					if ((v->swath_height_cper_state[i][j][k] > 4.0)) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   874  						if (v->line_times_to_request_prefetch_pixel_data_with_immediate_flip - (v->prefill_c[k] - 3.0) / 2.0 > 0.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   875  							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));
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   876  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   877  						else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   878  							v->v_ratio_pre_cwith_immediate_flip[i][j][k] = 999999.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   879  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   880  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   881  					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]);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   882  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   883  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08   884  					v->v_ratio_pre_ywith_immediate_flip[i][j][k] = 999999.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   885  					v->v_ratio_pre_cwith_immediate_flip[i][j][k] = 999999.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   886  					v->required_prefetch_pixel_data_bw_with_immediate_flip[i][j][k] = 999999.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   887  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   888  				if (v->line_times_to_request_prefetch_pixel_data_without_immediate_flip > 0.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   889  					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;
74c49c7ac14f3a Harry Wentland     2017-05-08   890  					if ((v->swath_height_yper_state[i][j][k] > 4.0)) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   891  						if (v->line_times_to_request_prefetch_pixel_data_without_immediate_flip - (v->prefill_y[k] - 3.0) / 2.0 > 0.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   892  							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));
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   893  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   894  						else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   895  							v->v_ratio_pre_ywithout_immediate_flip[i][j][k] = 999999.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   896  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   897  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   898  					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;
74c49c7ac14f3a Harry Wentland     2017-05-08   899  					if ((v->swath_height_cper_state[i][j][k] > 4.0)) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   900  						if (v->line_times_to_request_prefetch_pixel_data_without_immediate_flip - (v->prefill_c[k] - 3.0) / 2.0 > 0.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   901  							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));
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   902  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   903  						else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   904  							v->v_ratio_pre_cwithout_immediate_flip[i][j][k] = 999999.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   905  						}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   906  					}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   907  					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]);
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   908  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   909  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08   910  					v->v_ratio_pre_ywithout_immediate_flip[i][j][k] = 999999.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   911  					v->v_ratio_pre_cwithout_immediate_flip[i][j][k] = 999999.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   912  					v->required_prefetch_pixel_data_bw_without_immediate_flip[i][j][k] = 999999.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   913  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   914  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   915  			v->maximum_read_bandwidth_with_prefetch_with_immediate_flip = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   916  			for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   917  				if ((v->source_pixel_format[k] != dcn_bw_yuv420_sub_8 && v->source_pixel_format[k] != dcn_bw_yuv420_sub_10)) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   918  					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]));
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   919  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   920  				else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   921  					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]);
74c49c7ac14f3a Harry Wentland     2017-05-08   922  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   923  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   924  			v->maximum_read_bandwidth_with_prefetch_without_immediate_flip = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08   925  			for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   926  				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]);
74c49c7ac14f3a Harry Wentland     2017-05-08   927  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   928  			v->prefetch_supported_with_immediate_flip[i][j] = dcn_bw_yes;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   929  			if (v->maximum_read_bandwidth_with_prefetch_with_immediate_flip > v->return_bw_per_state[i]) {
74c49c7ac14f3a Harry Wentland     2017-05-08   930  				v->prefetch_supported_with_immediate_flip[i][j] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   931  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   932  			for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   933  				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) {
74c49c7ac14f3a Harry Wentland     2017-05-08   934  					v->prefetch_supported_with_immediate_flip[i][j] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   935  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   936  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   937  			v->prefetch_supported_without_immediate_flip[i][j] = dcn_bw_yes;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   938  			if (v->maximum_read_bandwidth_with_prefetch_without_immediate_flip > v->return_bw_per_state[i]) {
74c49c7ac14f3a Harry Wentland     2017-05-08   939  				v->prefetch_supported_without_immediate_flip[i][j] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   940  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   941  			for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   942  				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) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   943  					v->prefetch_supported_without_immediate_flip[i][j] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   944  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   945  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   946  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   947  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   948  	for (i = 0; i <= number_of_states_plus_one; i++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   949  		for (j = 0; j <= 1; j++) {
74c49c7ac14f3a Harry Wentland     2017-05-08   950  			v->v_ratio_in_prefetch_supported_with_immediate_flip[i][j] = dcn_bw_yes;
74c49c7ac14f3a Harry Wentland     2017-05-08   951  			for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   952  				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)))) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   953  					v->v_ratio_in_prefetch_supported_with_immediate_flip[i][j] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   954  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   955  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   956  			v->v_ratio_in_prefetch_supported_without_immediate_flip[i][j] = dcn_bw_yes;
74c49c7ac14f3a Harry Wentland     2017-05-08   957  			for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   958  				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)) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   959  					v->v_ratio_in_prefetch_supported_without_immediate_flip[i][j] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   960  				}
74c49c7ac14f3a Harry Wentland     2017-05-08   961  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   962  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   963  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   964  	/*mode support, voltage state and soc configuration*/
74c49c7ac14f3a Harry Wentland     2017-05-08   965  
74c49c7ac14f3a Harry Wentland     2017-05-08   966  	for (i = number_of_states_plus_one; i >= 0; i--) {
74c49c7ac14f3a Harry Wentland     2017-05-08   967  		for (j = 0; j <= 1; j++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   968  			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) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   969  				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) {
74c49c7ac14f3a Harry Wentland     2017-05-08   970  					v->mode_support_with_immediate_flip[i][j] = dcn_bw_yes;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   971  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   972  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08   973  					v->mode_support_with_immediate_flip[i][j] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   974  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   975  				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) {
74c49c7ac14f3a Harry Wentland     2017-05-08   976  					v->mode_support_without_immediate_flip[i][j] = dcn_bw_yes;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   977  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   978  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08   979  					v->mode_support_without_immediate_flip[i][j] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   980  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   981  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   982  			else {
74c49c7ac14f3a Harry Wentland     2017-05-08   983  				v->mode_support_with_immediate_flip[i][j] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   984  				v->mode_support_without_immediate_flip[i][j] = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08   985  			}
74c49c7ac14f3a Harry Wentland     2017-05-08   986  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   987  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   988  	for (i = number_of_states_plus_one; i >= 0; i--) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   989  		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) {
74c49c7ac14f3a Harry Wentland     2017-05-08   990  			v->voltage_level_with_immediate_flip = i;
74c49c7ac14f3a Harry Wentland     2017-05-08   991  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   992  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   993  	for (i = number_of_states_plus_one; i >= 0; i--) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15   994  		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) {
74c49c7ac14f3a Harry Wentland     2017-05-08   995  			v->voltage_level_without_immediate_flip = i;
74c49c7ac14f3a Harry Wentland     2017-05-08   996  		}
74c49c7ac14f3a Harry Wentland     2017-05-08   997  	}
74c49c7ac14f3a Harry Wentland     2017-05-08   998  	if (v->voltage_level_with_immediate_flip == number_of_states_plus_one) {
74c49c7ac14f3a Harry Wentland     2017-05-08   999  		v->immediate_flip_supported = dcn_bw_no;
74c49c7ac14f3a Harry Wentland     2017-05-08  1000  		v->voltage_level = v->voltage_level_without_immediate_flip;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1001  	}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1002  	else {
74c49c7ac14f3a Harry Wentland     2017-05-08  1003  		v->immediate_flip_supported = dcn_bw_yes;
74c49c7ac14f3a Harry Wentland     2017-05-08  1004  		v->voltage_level = v->voltage_level_with_immediate_flip;
74c49c7ac14f3a Harry Wentland     2017-05-08  1005  	}
74c49c7ac14f3a Harry Wentland     2017-05-08  1006  	v->dcfclk = v->dcfclk_per_state[v->voltage_level];
74c49c7ac14f3a Harry Wentland     2017-05-08  1007  	v->fabric_and_dram_bandwidth = v->fabric_and_dram_bandwidth_per_state[v->voltage_level];
74c49c7ac14f3a Harry Wentland     2017-05-08  1008  	for (j = 0; j <= 1; j++) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1009  		v->required_dispclk_per_ratio[j] = v->required_dispclk[v->voltage_level][j];
74c49c7ac14f3a Harry Wentland     2017-05-08  1010  		for (k = 0; k <= v->number_of_active_planes - 1; k++) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1011  			v->dpp_per_plane_per_ratio[j][k] = v->no_of_dpp[v->voltage_level][j][k];
74c49c7ac14f3a Harry Wentland     2017-05-08  1012  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1013  		v->dispclk_dppclk_support_per_ratio[j] = v->dispclk_dppclk_support[v->voltage_level][j];
74c49c7ac14f3a Harry Wentland     2017-05-08  1014  	}
74c49c7ac14f3a Harry Wentland     2017-05-08  1015  	v->max_phyclk = v->phyclk_per_state[v->voltage_level];
74c49c7ac14f3a Harry Wentland     2017-05-08  1016  }
74c49c7ac14f3a Harry Wentland     2017-05-08  1017  void display_pipe_configuration(struct dcn_bw_internal_vars *v)
74c49c7ac14f3a Harry Wentland     2017-05-08  1018  {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1019  	int j;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1020  	int k;
74c49c7ac14f3a Harry Wentland     2017-05-08  1021  	/*display pipe configuration*/
74c49c7ac14f3a Harry Wentland     2017-05-08  1022  
74c49c7ac14f3a Harry Wentland     2017-05-08  1023  	for (j = 0; j <= 1; j++) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1024  		v->total_number_of_active_dpp_per_ratio[j] = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1025  		for (k = 0; k <= v->number_of_active_planes - 1; k++) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1026  			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];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1027  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1028  	}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1029  	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]))))) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1030  		v->dispclk_dppclk_ratio = 1;
74c49c7ac14f3a Harry Wentland     2017-05-08  1031  		v->final_error_message = v->error_message[0];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1032  	}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1033  	else {
74c49c7ac14f3a Harry Wentland     2017-05-08  1034  		v->dispclk_dppclk_ratio = 2;
74c49c7ac14f3a Harry Wentland     2017-05-08  1035  		v->final_error_message = v->error_message[1];
74c49c7ac14f3a Harry Wentland     2017-05-08  1036  	}
74c49c7ac14f3a Harry Wentland     2017-05-08  1037  	for (k = 0; k <= v->number_of_active_planes - 1; k++) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1038  		v->dpp_per_plane[k] = v->dpp_per_plane_per_ratio[v->dispclk_dppclk_ratio - 1][k];
74c49c7ac14f3a Harry Wentland     2017-05-08  1039  	}
74c49c7ac14f3a Harry Wentland     2017-05-08  1040  	for (k = 0; k <= v->number_of_active_planes - 1; k++) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1041  		if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1042  			v->byte_per_pix_dety = 8.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1043  			v->byte_per_pix_detc = 0.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1044  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1045  		else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_32) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1046  			v->byte_per_pix_dety = 4.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1047  			v->byte_per_pix_detc = 0.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1048  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1049  		else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_16) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1050  			v->byte_per_pix_dety = 2.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1051  			v->byte_per_pix_detc = 0.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1052  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1053  		else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1054  			v->byte_per_pix_dety = 1.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1055  			v->byte_per_pix_detc = 2.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1056  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1057  		else {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1058  			v->byte_per_pix_dety = 4.0f / 3.0f;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1059  			v->byte_per_pix_detc = 8.0f / 3.0f;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1060  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1061  		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)) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1062  			if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1063  				v->read256_bytes_block_height_y = 1.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1064  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1065  			else if (v->source_pixel_format[k] == dcn_bw_rgb_sub_64) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1066  				v->read256_bytes_block_height_y = 4.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1067  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1068  			else {
74c49c7ac14f3a Harry Wentland     2017-05-08  1069  				v->read256_bytes_block_height_y = 8.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1070  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1071  			v->read256_bytes_block_width_y = 256.0 /dcn_bw_ceil2(v->byte_per_pix_dety, 1.0) / v->read256_bytes_block_height_y;
74c49c7ac14f3a Harry Wentland     2017-05-08  1072  			v->read256_bytes_block_height_c = 0.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1073  			v->read256_bytes_block_width_c = 0.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1074  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1075  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08  1076  			if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1077  				v->read256_bytes_block_height_y = 1.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1078  				v->read256_bytes_block_height_c = 1.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1079  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1080  			else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1081  				v->read256_bytes_block_height_y = 16.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1082  				v->read256_bytes_block_height_c = 8.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1083  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1084  			else {
74c49c7ac14f3a Harry Wentland     2017-05-08  1085  				v->read256_bytes_block_height_y = 8.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1086  				v->read256_bytes_block_height_c = 8.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1087  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1088  			v->read256_bytes_block_width_y = 256.0 /dcn_bw_ceil2(v->byte_per_pix_dety, 1.0) / v->read256_bytes_block_height_y;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1089  			v->read256_bytes_block_width_c = 256.0 /dcn_bw_ceil2(v->byte_per_pix_detc, 2.0) / v->read256_bytes_block_height_c;
74c49c7ac14f3a Harry Wentland     2017-05-08  1090  		}
74c49c7ac14f3a Harry Wentland     2017-05-08  1091  		if (v->source_scan[k] == dcn_bw_hor) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1092  			v->maximum_swath_height_y = v->read256_bytes_block_height_y;
74c49c7ac14f3a Harry Wentland     2017-05-08  1093  			v->maximum_swath_height_c = v->read256_bytes_block_height_c;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1094  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1095  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08  1096  			v->maximum_swath_height_y = v->read256_bytes_block_width_y;
74c49c7ac14f3a Harry Wentland     2017-05-08  1097  			v->maximum_swath_height_c = v->read256_bytes_block_width_c;
74c49c7ac14f3a Harry Wentland     2017-05-08  1098  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1099  		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)) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1100  			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)) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1101  				v->minimum_swath_height_y = v->maximum_swath_height_y;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1102  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1103  			else {
74c49c7ac14f3a Harry Wentland     2017-05-08  1104  				v->minimum_swath_height_y = v->maximum_swath_height_y / 2.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1105  			}
74c49c7ac14f3a Harry Wentland     2017-05-08  1106  			v->minimum_swath_height_c = v->maximum_swath_height_c;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1107  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1108  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08  1109  			if (v->source_surface_mode[k] == dcn_bw_sw_linear) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1110  				v->minimum_swath_height_y = v->maximum_swath_height_y;
74c49c7ac14f3a Harry Wentland     2017-05-08  1111  				v->minimum_swath_height_c = v->maximum_swath_height_c;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1112  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1113  			else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_8 && v->source_scan[k] == dcn_bw_hor) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1114  				v->minimum_swath_height_y = v->maximum_swath_height_y / 2.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1115  				if (v->bug_forcing_luma_and_chroma_request_to_same_size_fixed == dcn_bw_yes) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1116  					v->minimum_swath_height_c = v->maximum_swath_height_c;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1117  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1118  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08  1119  					v->minimum_swath_height_c = v->maximum_swath_height_c / 2.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1120  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1121  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1122  			else if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10 && v->source_scan[k] == dcn_bw_hor) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1123  				v->minimum_swath_height_c = v->maximum_swath_height_c / 2.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1124  				if (v->bug_forcing_luma_and_chroma_request_to_same_size_fixed == dcn_bw_yes) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1125  					v->minimum_swath_height_y = v->maximum_swath_height_y;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1126  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1127  				else {
74c49c7ac14f3a Harry Wentland     2017-05-08  1128  					v->minimum_swath_height_y = v->maximum_swath_height_y / 2.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1129  				}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1130  			}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1131  			else {
74c49c7ac14f3a Harry Wentland     2017-05-08  1132  				v->minimum_swath_height_y = v->maximum_swath_height_y;
74c49c7ac14f3a Harry Wentland     2017-05-08  1133  				v->minimum_swath_height_c = v->maximum_swath_height_c;
74c49c7ac14f3a Harry Wentland     2017-05-08  1134  			}
74c49c7ac14f3a Harry Wentland     2017-05-08  1135  		}
74c49c7ac14f3a Harry Wentland     2017-05-08  1136  		if (v->source_scan[k] == dcn_bw_hor) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1137  			v->swath_width = v->viewport_width[k] / v->dpp_per_plane[k];
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1138  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1139  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08  1140  			v->swath_width = v->viewport_height[k] / v->dpp_per_plane[k];
74c49c7ac14f3a Harry Wentland     2017-05-08  1141  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1142  		v->swath_width_granularity_y = 256.0 /dcn_bw_ceil2(v->byte_per_pix_dety, 1.0) / v->maximum_swath_height_y;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1143  		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;
74c49c7ac14f3a Harry Wentland     2017-05-08  1144  		if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1145  			v->rounded_up_max_swath_size_bytes_y =dcn_bw_ceil2(v->rounded_up_max_swath_size_bytes_y, 256.0) + 256;
74c49c7ac14f3a Harry Wentland     2017-05-08  1146  		}
74c49c7ac14f3a Harry Wentland     2017-05-08  1147  		if (v->maximum_swath_height_c > 0.0) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1148  			v->swath_width_granularity_c = 256.0 /dcn_bw_ceil2(v->byte_per_pix_detc, 2.0) / v->maximum_swath_height_c;
74c49c7ac14f3a Harry Wentland     2017-05-08  1149  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1150  		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;
74c49c7ac14f3a Harry Wentland     2017-05-08  1151  		if (v->source_pixel_format[k] == dcn_bw_yuv420_sub_10) {
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1152  			v->rounded_up_max_swath_size_bytes_c =dcn_bw_ceil2(v->rounded_up_max_swath_size_bytes_c, 256.0) + 256;
74c49c7ac14f3a Harry Wentland     2017-05-08  1153  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1154  		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) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1155  			v->swath_height_y[k] = v->maximum_swath_height_y;
74c49c7ac14f3a Harry Wentland     2017-05-08  1156  			v->swath_height_c[k] = v->maximum_swath_height_c;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1157  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1158  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08  1159  			v->swath_height_y[k] = v->minimum_swath_height_y;
74c49c7ac14f3a Harry Wentland     2017-05-08  1160  			v->swath_height_c[k] = v->minimum_swath_height_c;
74c49c7ac14f3a Harry Wentland     2017-05-08  1161  		}
74c49c7ac14f3a Harry Wentland     2017-05-08  1162  		if (v->swath_height_c[k] == 0.0) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1163  			v->det_buffer_size_y[k] = v->det_buffer_size_in_kbyte * 1024.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1164  			v->det_buffer_size_c[k] = 0.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1165  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1166  		else if (v->swath_height_y[k] <= v->swath_height_c[k]) {
74c49c7ac14f3a Harry Wentland     2017-05-08  1167  			v->det_buffer_size_y[k] = v->det_buffer_size_in_kbyte * 1024.0 / 2.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1168  			v->det_buffer_size_c[k] = v->det_buffer_size_in_kbyte * 1024.0 / 2.0;
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1169  		}
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15  1170  		else {
74c49c7ac14f3a Harry Wentland     2017-05-08  1171  			v->det_buffer_size_y[k] = v->det_buffer_size_in_kbyte * 1024.0 * 2.0 / 3.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1172  			v->det_buffer_size_c[k] = v->det_buffer_size_in_kbyte * 1024.0 / 3.0;
74c49c7ac14f3a Harry Wentland     2017-05-08  1173  		}
74c49c7ac14f3a Harry Wentland     2017-05-08  1174  	}
74c49c7ac14f3a Harry Wentland     2017-05-08  1175  }
5634fb6078dd9b Dmytro Laktyushkin 2017-06-15 @1176  void dispclkdppclkdcfclk_deep_sleep_prefetch_parameters_watermarks_and_performance_calculation(struct dcn_bw_internal_vars *v)

:::::: The code at line 1176 was first introduced by commit
:::::: 5634fb6078dd9b9f794e93eef2fef52150cdc827 drm/amd/display: dcn bw_calc_auto update rev 247 to 250

:::::: TO: Dmytro Laktyushkin <Dmytro.Laktyushkin@xxxxxxx>
:::::: CC: Alex Deucher <alexander.deucher@xxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux