1 /* SPDX-License-Identifier: MIT */ 2 /* 3 * Copyright 2023 Advanced Micro Devices, Inc. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 * OTHER DEALINGS IN THE SOFTWARE. 22 * 23 * Authors: AMD 24 * 25 */ 26 27 #include "display_mode_core.h" 28 #include "dml2_internal_types.h" 29 #include "dml2_translation_helper.h" 30 31 #define NUM_DCFCLK_STAS 5 32 #define NUM_DCFCLK_STAS_NEW 8 33 34 void dml2_init_ip_params(struct dml2_context *dml2, const struct dc *in_dc, struct ip_params_st *out) 35 { 36 (void)in_dc; 37 switch (dml2->v20.dml_core_ctx.project) { 38 case dml_project_dcn32: 39 case dml_project_dcn321: 40 default: 41 // Hardcoded values for DCN32x 42 out->vblank_nom_default_us = 600; 43 out->rob_buffer_size_kbytes = 128; 44 out->config_return_buffer_size_in_kbytes = 1280; 45 out->config_return_buffer_segment_size_in_kbytes = 64; 46 out->compressed_buffer_segment_size_in_kbytes = 64; 47 out->meta_fifo_size_in_kentries = 22; 48 out->zero_size_buffer_entries = 512; 49 out->dpte_buffer_size_in_pte_reqs_luma = 68; 50 out->dpte_buffer_size_in_pte_reqs_chroma = 36; 51 out->dcc_meta_buffer_size_bytes = 6272; 52 out->gpuvm_max_page_table_levels = 4; 53 out->hostvm_max_page_table_levels = 0; 54 out->pixel_chunk_size_kbytes = 8; 55 //out->alpha_pixel_chunk_size_kbytes; 56 out->min_pixel_chunk_size_bytes = 1024; 57 out->meta_chunk_size_kbytes = 2; 58 out->min_meta_chunk_size_bytes = 256; 59 out->writeback_chunk_size_kbytes = 8; 60 out->line_buffer_size_bits = 1171920; 61 out->max_line_buffer_lines = 32; 62 out->writeback_interface_buffer_size_kbytes = 90; 63 //Number of pipes after DCN Pipe harvesting 64 out->max_num_dpp = dml2->config.dcn_pipe_count; 65 out->max_num_otg = dml2->config.dcn_pipe_count; 66 out->max_num_wb = 1; 67 out->max_dchub_pscl_bw_pix_per_clk = 4; 68 out->max_pscl_lb_bw_pix_per_clk = 2; 69 out->max_lb_vscl_bw_pix_per_clk = 4; 70 out->max_vscl_hscl_bw_pix_per_clk = 4; 71 out->max_hscl_ratio = 6; 72 out->max_vscl_ratio = 6; 73 out->max_hscl_taps = 8; 74 out->max_vscl_taps = 8; 75 out->dispclk_ramp_margin_percent = 1; 76 out->dppclk_delay_subtotal = 47; 77 out->dppclk_delay_scl = 50; 78 out->dppclk_delay_scl_lb_only = 16; 79 out->dppclk_delay_cnvc_formatter = 28; 80 out->dppclk_delay_cnvc_cursor = 6; 81 out->cursor_buffer_size = 16; 82 out->cursor_chunk_size = 2; 83 out->dispclk_delay_subtotal = 125; 84 out->max_inter_dcn_tile_repeaters = 8; 85 out->writeback_max_hscl_ratio = 1; 86 out->writeback_max_vscl_ratio = 1; 87 out->writeback_min_hscl_ratio = 1; 88 out->writeback_min_vscl_ratio = 1; 89 out->writeback_max_hscl_taps = 1; 90 out->writeback_max_vscl_taps = 1; 91 out->writeback_line_buffer_buffer_size = 0; 92 out->num_dsc = 4; 93 out->maximum_dsc_bits_per_component = 12; 94 out->maximum_pixels_per_line_per_dsc_unit = 6016; 95 out->dsc422_native_support = true; 96 out->dcc_supported = true; 97 out->ptoi_supported = false; 98 99 out->gpuvm_enable = false; 100 out->hostvm_enable = false; 101 out->cursor_64bpp_support = false; 102 out->dynamic_metadata_vm_enabled = false; 103 104 out->max_num_hdmi_frl_outputs = 1; 105 out->max_num_dp2p0_outputs = 2; 106 out->max_num_dp2p0_streams = 4; 107 break; 108 109 case dml_project_dcn35: 110 case dml_project_dcn351: 111 case dml_project_dcn36: 112 out->rob_buffer_size_kbytes = 64; 113 out->config_return_buffer_size_in_kbytes = 1792; 114 out->compressed_buffer_segment_size_in_kbytes = 64; 115 out->meta_fifo_size_in_kentries = 32; 116 out->zero_size_buffer_entries = 512; 117 out->pixel_chunk_size_kbytes = 8; 118 out->alpha_pixel_chunk_size_kbytes = 4; 119 out->min_pixel_chunk_size_bytes = 1024; 120 out->meta_chunk_size_kbytes = 2; 121 out->min_meta_chunk_size_bytes = 256; 122 out->writeback_chunk_size_kbytes = 8; 123 out->dpte_buffer_size_in_pte_reqs_luma = 68; 124 out->dpte_buffer_size_in_pte_reqs_chroma = 36; 125 out->dcc_meta_buffer_size_bytes = 6272; 126 out->gpuvm_enable = 1; 127 out->hostvm_enable = 1; 128 out->gpuvm_max_page_table_levels = 1; 129 out->hostvm_max_page_table_levels = 2; 130 out->num_dsc = 4; 131 out->maximum_dsc_bits_per_component = 12; 132 out->maximum_pixels_per_line_per_dsc_unit = 6016; 133 out->dsc422_native_support = 1; 134 out->line_buffer_size_bits = 986880; 135 out->dcc_supported = 1; 136 out->max_line_buffer_lines = 32; 137 out->writeback_interface_buffer_size_kbytes = 90; 138 out->max_num_dpp = 4; 139 out->max_num_otg = 4; 140 out->max_num_hdmi_frl_outputs = 1; 141 out->max_num_dp2p0_outputs = 2; 142 out->max_num_dp2p0_streams = 4; 143 out->max_num_wb = 1; 144 145 out->max_dchub_pscl_bw_pix_per_clk = 4; 146 out->max_pscl_lb_bw_pix_per_clk = 2; 147 out->max_lb_vscl_bw_pix_per_clk = 4; 148 out->max_vscl_hscl_bw_pix_per_clk = 4; 149 out->max_hscl_ratio = 6; 150 out->max_vscl_ratio = 6; 151 out->max_hscl_taps = 8; 152 out->max_vscl_taps = 8; 153 out->dispclk_ramp_margin_percent = 1.11; 154 155 out->dppclk_delay_subtotal = 47; 156 out->dppclk_delay_scl = 50; 157 out->dppclk_delay_scl_lb_only = 16; 158 out->dppclk_delay_cnvc_formatter = 28; 159 out->dppclk_delay_cnvc_cursor = 6; 160 out->dispclk_delay_subtotal = 125; 161 162 out->dynamic_metadata_vm_enabled = false; 163 out->max_inter_dcn_tile_repeaters = 8; 164 out->cursor_buffer_size = 16; // kBytes 165 out->cursor_chunk_size = 2; // kBytes 166 167 out->writeback_line_buffer_buffer_size = 0; 168 out->writeback_max_hscl_ratio = 1; 169 out->writeback_max_vscl_ratio = 1; 170 out->writeback_min_hscl_ratio = 1; 171 out->writeback_min_vscl_ratio = 1; 172 out->writeback_max_hscl_taps = 1; 173 out->writeback_max_vscl_taps = 1; 174 out->ptoi_supported = 0; 175 176 out->vblank_nom_default_us = 668; /*not in dml, but in programming guide, hard coded in dml2_translate_ip_params*/ 177 out->config_return_buffer_segment_size_in_kbytes = 64; /*required, but not exist,, hard coded in dml2_translate_ip_params*/ 178 break; 179 180 case dml_project_dcn401: 181 // Hardcoded values for DCN4m 182 out->vblank_nom_default_us = 668; //600; 183 out->rob_buffer_size_kbytes = 192; //128; 184 out->config_return_buffer_size_in_kbytes = 1344; //1280; 185 out->config_return_buffer_segment_size_in_kbytes = 64; 186 out->compressed_buffer_segment_size_in_kbytes = 64; 187 out->meta_fifo_size_in_kentries = 22; 188 out->dpte_buffer_size_in_pte_reqs_luma = 68; 189 out->dpte_buffer_size_in_pte_reqs_chroma = 36; 190 out->gpuvm_max_page_table_levels = 4; 191 out->pixel_chunk_size_kbytes = 8; 192 out->alpha_pixel_chunk_size_kbytes = 4; 193 out->min_pixel_chunk_size_bytes = 1024; 194 out->writeback_chunk_size_kbytes = 8; 195 out->line_buffer_size_bits = 1171920; 196 out->max_line_buffer_lines = 32; 197 out->writeback_interface_buffer_size_kbytes = 90; 198 //Number of pipes after DCN Pipe harvesting 199 out->max_num_dpp = dml2->config.dcn_pipe_count; 200 out->max_num_otg = dml2->config.dcn_pipe_count; 201 out->max_num_wb = 1; 202 out->max_dchub_pscl_bw_pix_per_clk = 4; 203 out->max_pscl_lb_bw_pix_per_clk = 2; 204 out->max_lb_vscl_bw_pix_per_clk = 4; 205 out->max_vscl_hscl_bw_pix_per_clk = 4; 206 out->max_hscl_ratio = 6; 207 out->max_vscl_ratio = 6; 208 out->max_hscl_taps = 8; 209 out->max_vscl_taps = 8; 210 out->dispclk_ramp_margin_percent = 1; 211 out->dppclk_delay_subtotal = 47; 212 out->dppclk_delay_scl = 50; 213 out->dppclk_delay_scl_lb_only = 16; 214 out->dppclk_delay_cnvc_formatter = 28; 215 out->dppclk_delay_cnvc_cursor = 6; 216 out->dispclk_delay_subtotal = 125; 217 out->cursor_buffer_size = 24; //16 218 out->cursor_chunk_size = 2; 219 out->max_inter_dcn_tile_repeaters = 8; 220 out->writeback_max_hscl_ratio = 1; 221 out->writeback_max_vscl_ratio = 1; 222 out->writeback_min_hscl_ratio = 1; 223 out->writeback_min_vscl_ratio = 1; 224 out->writeback_max_hscl_taps = 1; 225 out->writeback_max_vscl_taps = 1; 226 out->writeback_line_buffer_buffer_size = 0; 227 out->num_dsc = 4; 228 out->maximum_dsc_bits_per_component = 12; 229 out->maximum_pixels_per_line_per_dsc_unit = 5760; 230 out->dsc422_native_support = true; 231 out->dcc_supported = true; 232 out->ptoi_supported = false; 233 234 out->gpuvm_enable = false; 235 out->hostvm_enable = false; 236 out->cursor_64bpp_support = true; //false; 237 out->dynamic_metadata_vm_enabled = false; 238 239 out->max_num_hdmi_frl_outputs = 1; 240 out->max_num_dp2p0_outputs = 4; //2; 241 out->max_num_dp2p0_streams = 4; 242 break; 243 } 244 } 245 246 void dml2_init_socbb_params(struct dml2_context *dml2, const struct dc *in_dc, struct soc_bounding_box_st *out) 247 { 248 (void)in_dc; 249 out->dprefclk_mhz = dml2->config.bbox_overrides.dprefclk_mhz; 250 out->xtalclk_mhz = dml2->config.bbox_overrides.xtalclk_mhz; 251 out->pcierefclk_mhz = 100; 252 out->refclk_mhz = dml2->config.bbox_overrides.dchub_refclk_mhz; 253 254 out->max_outstanding_reqs = 512; 255 out->pct_ideal_sdp_bw_after_urgent = 100; 256 out->pct_ideal_fabric_bw_after_urgent = 67; 257 out->pct_ideal_dram_bw_after_urgent_pixel_only = 20; 258 out->pct_ideal_dram_bw_after_urgent_pixel_and_vm = 60; 259 out->pct_ideal_dram_bw_after_urgent_vm_only = 30; 260 out->pct_ideal_dram_bw_after_urgent_strobe = 67; 261 out->max_avg_sdp_bw_use_normal_percent = 80; 262 out->max_avg_fabric_bw_use_normal_percent = 60; 263 out->max_avg_dram_bw_use_normal_percent = 15; 264 out->max_avg_dram_bw_use_normal_strobe_percent = 50; 265 266 out->urgent_out_of_order_return_per_channel_pixel_only_bytes = 4096; 267 out->urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 4096; 268 out->urgent_out_of_order_return_per_channel_vm_only_bytes = 4096; 269 out->return_bus_width_bytes = 64; 270 out->dram_channel_width_bytes = 2; 271 out->fabric_datapath_to_dcn_data_return_bytes = 64; 272 out->hostvm_min_page_size_kbytes = 0; 273 out->gpuvm_min_page_size_kbytes = 256; 274 out->phy_downspread_percent = 0.38; 275 out->dcn_downspread_percent = 0.5; 276 out->dispclk_dppclk_vco_speed_mhz = dml2->config.bbox_overrides.disp_pll_vco_speed_mhz; 277 out->mall_allocated_for_dcn_mbytes = dml2->config.mall_cfg.max_cab_allocation_bytes / 1048576; // 64 or 32 MB; 278 279 out->do_urgent_latency_adjustment = true; 280 281 switch (dml2->v20.dml_core_ctx.project) { 282 283 case dml_project_dcn32: 284 default: 285 out->num_chans = 24; 286 out->round_trip_ping_latency_dcfclk_cycles = 263; 287 out->smn_latency_us = 2; 288 break; 289 290 case dml_project_dcn321: 291 out->num_chans = 8; 292 out->round_trip_ping_latency_dcfclk_cycles = 207; 293 out->smn_latency_us = 0; 294 break; 295 296 case dml_project_dcn35: 297 case dml_project_dcn351: 298 case dml_project_dcn36: 299 out->num_chans = 4; 300 out->round_trip_ping_latency_dcfclk_cycles = 106; 301 out->smn_latency_us = 2; 302 out->dispclk_dppclk_vco_speed_mhz = 3600; 303 out->pct_ideal_dram_bw_after_urgent_pixel_only = 65.0; 304 break; 305 306 307 case dml_project_dcn401: 308 out->pct_ideal_fabric_bw_after_urgent = 76; //67; 309 out->max_avg_sdp_bw_use_normal_percent = 75; //80; 310 out->max_avg_fabric_bw_use_normal_percent = 57; //60; 311 312 out->urgent_out_of_order_return_per_channel_pixel_only_bytes = 0; //4096; 313 out->urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 0; //4096; 314 out->urgent_out_of_order_return_per_channel_vm_only_bytes = 0; //4096; 315 316 out->num_chans = 16; 317 out->round_trip_ping_latency_dcfclk_cycles = 1000; //263; 318 out->smn_latency_us = 0; //2 us 319 out->mall_allocated_for_dcn_mbytes = dml2->config.mall_cfg.max_cab_allocation_bytes / 1048576; // 64; 320 break; 321 } 322 /* ---Overrides if available--- */ 323 if (dml2->config.bbox_overrides.dram_num_chan) 324 out->num_chans = dml2->config.bbox_overrides.dram_num_chan; 325 326 if (dml2->config.bbox_overrides.dram_chanel_width_bytes) 327 out->dram_channel_width_bytes = dml2->config.bbox_overrides.dram_chanel_width_bytes; 328 } 329 330 void dml2_init_soc_states(struct dml2_context *dml2, const struct dc *in_dc, 331 const struct soc_bounding_box_st *in_bbox, struct soc_states_st *out) 332 { 333 (void)in_dc; 334 struct dml2_policy_build_synthetic_soc_states_scratch *s = &dml2->v20.scratch.create_scratch.build_synthetic_socbb_scratch; 335 struct dml2_policy_build_synthetic_soc_states_params *p = &dml2->v20.scratch.build_synthetic_socbb_params; 336 int dcfclk_stas_mhz[NUM_DCFCLK_STAS] = {0}; 337 int dcfclk_stas_mhz_new[NUM_DCFCLK_STAS_NEW] = {0}; 338 unsigned int dml_project = dml2->v20.dml_core_ctx.project; 339 340 unsigned int i = 0; 341 unsigned int transactions_per_mem_clock = 16; // project specific, depends on used Memory type 342 343 if (dml_project == dml_project_dcn351) { 344 p->dcfclk_stas_mhz = dcfclk_stas_mhz_new; 345 p->num_dcfclk_stas = NUM_DCFCLK_STAS_NEW; 346 } else { 347 p->dcfclk_stas_mhz = dcfclk_stas_mhz; 348 p->num_dcfclk_stas = NUM_DCFCLK_STAS; 349 } 350 351 p->in_bbox = in_bbox; 352 p->out_states = out; 353 p->in_states = &dml2->v20.scratch.create_scratch.in_states; 354 355 356 /* Initial hardcoded values */ 357 switch (dml2->v20.dml_core_ctx.project) { 358 359 case dml_project_dcn32: 360 default: 361 p->in_states->num_states = 2; 362 transactions_per_mem_clock = 16; 363 p->in_states->state_array[0].socclk_mhz = 620.0; 364 p->in_states->state_array[0].dscclk_mhz = 716.667; 365 p->in_states->state_array[0].phyclk_mhz = 810; 366 p->in_states->state_array[0].phyclk_d18_mhz = 667; 367 p->in_states->state_array[0].phyclk_d32_mhz = 625; 368 p->in_states->state_array[0].dtbclk_mhz = 1564.0; 369 p->in_states->state_array[0].fabricclk_mhz = 450.0; 370 p->in_states->state_array[0].dcfclk_mhz = 300.0; 371 p->in_states->state_array[0].dispclk_mhz = 2150.0; 372 p->in_states->state_array[0].dppclk_mhz = 2150.0; 373 p->in_states->state_array[0].dram_speed_mts = 100 * transactions_per_mem_clock; 374 375 p->in_states->state_array[0].urgent_latency_pixel_data_only_us = 4; 376 p->in_states->state_array[0].urgent_latency_pixel_mixed_with_vm_data_us = 0; 377 p->in_states->state_array[0].urgent_latency_vm_data_only_us = 0; 378 p->in_states->state_array[0].writeback_latency_us = 12; 379 p->in_states->state_array[0].urgent_latency_adjustment_fabric_clock_component_us = 1; 380 p->in_states->state_array[0].urgent_latency_adjustment_fabric_clock_reference_mhz = 3000; 381 p->in_states->state_array[0].sr_exit_z8_time_us = 0; 382 p->in_states->state_array[0].sr_enter_plus_exit_z8_time_us = 0; 383 p->in_states->state_array[0].dram_clock_change_latency_us = 400; 384 p->in_states->state_array[0].use_ideal_dram_bw_strobe = true; 385 p->in_states->state_array[0].sr_exit_time_us = 42.97; 386 p->in_states->state_array[0].sr_enter_plus_exit_time_us = 49.94; 387 p->in_states->state_array[0].fclk_change_latency_us = 20; 388 p->in_states->state_array[0].usr_retraining_latency_us = 2; 389 390 p->in_states->state_array[1].socclk_mhz = 1200.0; 391 p->in_states->state_array[1].fabricclk_mhz = 2500.0; 392 p->in_states->state_array[1].dcfclk_mhz = 1564.0; 393 p->in_states->state_array[1].dram_speed_mts = 1125 * transactions_per_mem_clock; 394 break; 395 396 case dml_project_dcn321: 397 p->in_states->num_states = 2; 398 transactions_per_mem_clock = 16; 399 p->in_states->state_array[0].socclk_mhz = 582.0; 400 p->in_states->state_array[0].dscclk_mhz = 573.333; 401 p->in_states->state_array[0].phyclk_mhz = 810; 402 p->in_states->state_array[0].phyclk_d18_mhz = 667; 403 p->in_states->state_array[0].phyclk_d32_mhz = 313; 404 p->in_states->state_array[0].dtbclk_mhz = 1564.0; 405 p->in_states->state_array[0].fabricclk_mhz = 450.0; 406 p->in_states->state_array[0].dcfclk_mhz = 300.0; 407 p->in_states->state_array[0].dispclk_mhz = 1720.0; 408 p->in_states->state_array[0].dppclk_mhz = 1720.0; 409 p->in_states->state_array[0].dram_speed_mts = 100 * transactions_per_mem_clock; 410 411 p->in_states->state_array[0].urgent_latency_pixel_data_only_us = 4; 412 p->in_states->state_array[0].urgent_latency_pixel_mixed_with_vm_data_us = 0; 413 p->in_states->state_array[0].urgent_latency_vm_data_only_us = 0; 414 p->in_states->state_array[0].writeback_latency_us = 12; 415 p->in_states->state_array[0].urgent_latency_adjustment_fabric_clock_component_us = 1; 416 p->in_states->state_array[0].urgent_latency_adjustment_fabric_clock_reference_mhz = 3000; 417 p->in_states->state_array[0].sr_exit_z8_time_us = 0; 418 p->in_states->state_array[0].sr_enter_plus_exit_z8_time_us = 0; 419 p->in_states->state_array[0].dram_clock_change_latency_us = 400; 420 p->in_states->state_array[0].use_ideal_dram_bw_strobe = true; 421 p->in_states->state_array[0].sr_exit_time_us = 19.95; 422 p->in_states->state_array[0].sr_enter_plus_exit_time_us = 24.36; 423 p->in_states->state_array[0].fclk_change_latency_us = 7; 424 p->in_states->state_array[0].usr_retraining_latency_us = 0; 425 426 p->in_states->state_array[1].socclk_mhz = 1200.0; 427 p->in_states->state_array[1].fabricclk_mhz = 2250.0; 428 p->in_states->state_array[1].dcfclk_mhz = 1434.0; 429 p->in_states->state_array[1].dram_speed_mts = 1000 * transactions_per_mem_clock; 430 break; 431 432 433 case dml_project_dcn401: 434 p->in_states->num_states = 2; 435 transactions_per_mem_clock = 16; 436 p->in_states->state_array[0].socclk_mhz = 300; //620.0; 437 p->in_states->state_array[0].dscclk_mhz = 666.667; //716.667; 438 p->in_states->state_array[0].phyclk_mhz = 810; 439 p->in_states->state_array[0].phyclk_d18_mhz = 667; 440 p->in_states->state_array[0].phyclk_d32_mhz = 625; 441 p->in_states->state_array[0].dtbclk_mhz = 2000; //1564.0; 442 p->in_states->state_array[0].fabricclk_mhz = 300; //450.0; 443 p->in_states->state_array[0].dcfclk_mhz = 200; //300.0; 444 p->in_states->state_array[0].dispclk_mhz = 2000; //2150.0; 445 p->in_states->state_array[0].dppclk_mhz = 2000; //2150.0; 446 p->in_states->state_array[0].dram_speed_mts = 97 * transactions_per_mem_clock; //100 * 447 448 p->in_states->state_array[0].urgent_latency_pixel_data_only_us = 4; 449 p->in_states->state_array[0].urgent_latency_pixel_mixed_with_vm_data_us = 0; 450 p->in_states->state_array[0].urgent_latency_vm_data_only_us = 0; 451 p->in_states->state_array[0].writeback_latency_us = 12; 452 p->in_states->state_array[0].urgent_latency_adjustment_fabric_clock_component_us = 1; 453 p->in_states->state_array[0].urgent_latency_adjustment_fabric_clock_reference_mhz = 1000; //3000; 454 p->in_states->state_array[0].sr_exit_z8_time_us = 0; 455 p->in_states->state_array[0].sr_enter_plus_exit_z8_time_us = 0; 456 p->in_states->state_array[0].dram_clock_change_latency_us = 400; 457 p->in_states->state_array[0].use_ideal_dram_bw_strobe = true; 458 p->in_states->state_array[0].sr_exit_time_us = 15.70; //42.97; 459 p->in_states->state_array[0].sr_enter_plus_exit_time_us = 20.20; //49.94; 460 p->in_states->state_array[0].fclk_change_latency_us = 0; //20; 461 p->in_states->state_array[0].usr_retraining_latency_us = 0; //2; 462 463 p->in_states->state_array[1].socclk_mhz = 1600; //1200.0; 464 p->in_states->state_array[1].fabricclk_mhz = 2500; //2500.0; 465 p->in_states->state_array[1].dcfclk_mhz = 1800; //1564.0; 466 p->in_states->state_array[1].dram_speed_mts = 1125 * transactions_per_mem_clock; 467 break; 468 } 469 470 /* Override from passed values, if available */ 471 for (i = 0; i < p->in_states->num_states; i++) { 472 if (dml2->config.bbox_overrides.sr_exit_latency_us) { 473 p->in_states->state_array[i].sr_exit_time_us = 474 dml2->config.bbox_overrides.sr_exit_latency_us; 475 } 476 477 if (dml2->config.bbox_overrides.sr_enter_plus_exit_latency_us) { 478 p->in_states->state_array[i].sr_enter_plus_exit_time_us = 479 dml2->config.bbox_overrides.sr_enter_plus_exit_latency_us; 480 } 481 482 if (dml2->config.bbox_overrides.sr_exit_z8_time_us) { 483 p->in_states->state_array[i].sr_exit_z8_time_us = 484 dml2->config.bbox_overrides.sr_exit_z8_time_us; 485 } 486 487 if (dml2->config.bbox_overrides.sr_enter_plus_exit_z8_time_us) { 488 p->in_states->state_array[i].sr_enter_plus_exit_z8_time_us = 489 dml2->config.bbox_overrides.sr_enter_plus_exit_z8_time_us; 490 } 491 492 if (dml2->config.bbox_overrides.urgent_latency_us) { 493 p->in_states->state_array[i].urgent_latency_pixel_data_only_us = 494 dml2->config.bbox_overrides.urgent_latency_us; 495 } 496 497 if (dml2->config.bbox_overrides.dram_clock_change_latency_us) { 498 p->in_states->state_array[i].dram_clock_change_latency_us = 499 dml2->config.bbox_overrides.dram_clock_change_latency_us; 500 } 501 502 if (dml2->config.bbox_overrides.fclk_change_latency_us) { 503 p->in_states->state_array[i].fclk_change_latency_us = 504 dml2->config.bbox_overrides.fclk_change_latency_us; 505 } 506 } 507 508 /* DCFCLK stas values are project specific */ 509 if ((dml2->v20.dml_core_ctx.project == dml_project_dcn32) || 510 (dml2->v20.dml_core_ctx.project == dml_project_dcn321)) { 511 p->dcfclk_stas_mhz[0] = (int)p->in_states->state_array[0].dcfclk_mhz; 512 p->dcfclk_stas_mhz[1] = 615; 513 p->dcfclk_stas_mhz[2] = 906; 514 p->dcfclk_stas_mhz[3] = 1324; 515 p->dcfclk_stas_mhz[4] = (int)p->in_states->state_array[1].dcfclk_mhz; 516 } else if (dml2->v20.dml_core_ctx.project != dml_project_dcn35 && 517 dml2->v20.dml_core_ctx.project != dml_project_dcn36 && 518 dml2->v20.dml_core_ctx.project != dml_project_dcn351) { 519 p->dcfclk_stas_mhz[0] = 300; 520 p->dcfclk_stas_mhz[1] = 615; 521 p->dcfclk_stas_mhz[2] = 906; 522 p->dcfclk_stas_mhz[3] = 1324; 523 p->dcfclk_stas_mhz[4] = 1500; 524 } 525 /* Copy clocks tables entries, if available */ 526 if (dml2->config.bbox_overrides.clks_table.num_states) { 527 p->in_states->num_states = dml2->config.bbox_overrides.clks_table.num_states; 528 for (i = 0; i < dml2->config.bbox_overrides.clks_table.num_entries_per_clk.num_dcfclk_levels; i++) { 529 p->in_states->state_array[i].dcfclk_mhz = dml2->config.bbox_overrides.clks_table.clk_entries[i].dcfclk_mhz; 530 } 531 532 p->dcfclk_stas_mhz[0] = dml2->config.bbox_overrides.clks_table.clk_entries[0].dcfclk_mhz; 533 if (i > 1) 534 p->dcfclk_stas_mhz[4] = dml2->config.bbox_overrides.clks_table.clk_entries[i-1].dcfclk_mhz; 535 536 for (i = 0; i < dml2->config.bbox_overrides.clks_table.num_entries_per_clk.num_fclk_levels; i++) { 537 p->in_states->state_array[i].fabricclk_mhz = 538 dml2->config.bbox_overrides.clks_table.clk_entries[i].fclk_mhz; 539 } 540 541 for (i = 0; i < dml2->config.bbox_overrides.clks_table.num_entries_per_clk.num_memclk_levels; i++) { 542 p->in_states->state_array[i].dram_speed_mts = 543 dml2->config.bbox_overrides.clks_table.clk_entries[i].memclk_mhz * transactions_per_mem_clock; 544 } 545 546 for (i = 0; i < dml2->config.bbox_overrides.clks_table.num_entries_per_clk.num_socclk_levels; i++) { 547 p->in_states->state_array[i].socclk_mhz = 548 dml2->config.bbox_overrides.clks_table.clk_entries[i].socclk_mhz; 549 } 550 551 for (i = 0; i < dml2->config.bbox_overrides.clks_table.num_entries_per_clk.num_dtbclk_levels; i++) { 552 if (dml2->config.bbox_overrides.clks_table.clk_entries[i].dtbclk_mhz > 0) 553 p->in_states->state_array[i].dtbclk_mhz = 554 dml2->config.bbox_overrides.clks_table.clk_entries[i].dtbclk_mhz; 555 } 556 557 for (i = 0; i < dml2->config.bbox_overrides.clks_table.num_entries_per_clk.num_dispclk_levels; i++) { 558 p->in_states->state_array[i].dispclk_mhz = 559 dml2->config.bbox_overrides.clks_table.clk_entries[i].dispclk_mhz; 560 p->in_states->state_array[i].dppclk_mhz = 561 dml2->config.bbox_overrides.clks_table.clk_entries[i].dppclk_mhz; 562 } 563 } 564 565 if (dml2->v20.dml_core_ctx.project == dml_project_dcn35 || 566 dml2->v20.dml_core_ctx.project == dml_project_dcn36 || 567 dml2->v20.dml_core_ctx.project == dml_project_dcn351) { 568 int max_dcfclk_mhz = 0, max_dispclk_mhz = 0, max_dppclk_mhz = 0, max_phyclk_mhz = 0, 569 max_dtbclk_mhz = 0, max_fclk_mhz = 0, max_uclk_mhz = 0, max_socclk_mhz = 0; 570 571 for (i = 0; i < p->in_states->num_states; i++) { 572 if (p->in_states->state_array[i].dcfclk_mhz > max_dcfclk_mhz) 573 max_dcfclk_mhz = (int)p->in_states->state_array[i].dcfclk_mhz; 574 if (p->in_states->state_array[i].fabricclk_mhz > max_fclk_mhz) 575 max_fclk_mhz = (int)p->in_states->state_array[i].fabricclk_mhz; 576 if (p->in_states->state_array[i].socclk_mhz > max_socclk_mhz) 577 max_socclk_mhz = (int)p->in_states->state_array[i].socclk_mhz; 578 if (p->in_states->state_array[i].dram_speed_mts > max_uclk_mhz) 579 max_uclk_mhz = (int)p->in_states->state_array[i].dram_speed_mts; 580 if (p->in_states->state_array[i].dispclk_mhz > max_dispclk_mhz) 581 max_dispclk_mhz = (int)p->in_states->state_array[i].dispclk_mhz; 582 if (p->in_states->state_array[i].dppclk_mhz > max_dppclk_mhz) 583 max_dppclk_mhz = (int)p->in_states->state_array[i].dppclk_mhz; 584 if (p->in_states->state_array[i].phyclk_mhz > max_phyclk_mhz) 585 max_phyclk_mhz = (int)p->in_states->state_array[i].phyclk_mhz; 586 if (p->in_states->state_array[i].dtbclk_mhz > max_dtbclk_mhz) 587 max_dtbclk_mhz = (int)p->in_states->state_array[i].dtbclk_mhz; 588 } 589 590 for (i = 0; i < p->in_states->num_states; i++) { 591 /* Independent states - including base (unlisted) parameters from state 0. */ 592 p->out_states->state_array[i] = p->in_states->state_array[0]; 593 594 p->out_states->state_array[i].dispclk_mhz = max_dispclk_mhz; 595 p->out_states->state_array[i].dppclk_mhz = max_dppclk_mhz; 596 p->out_states->state_array[i].dtbclk_mhz = max_dtbclk_mhz; 597 p->out_states->state_array[i].phyclk_mhz = max_phyclk_mhz; 598 599 p->out_states->state_array[i].dscclk_mhz = max_dispclk_mhz / 3.0; 600 p->out_states->state_array[i].phyclk_mhz = max_phyclk_mhz; 601 p->out_states->state_array[i].dtbclk_mhz = max_dtbclk_mhz; 602 603 /* Dependent states. */ 604 p->out_states->state_array[i].dram_speed_mts = p->in_states->state_array[i].dram_speed_mts; 605 p->out_states->state_array[i].fabricclk_mhz = p->in_states->state_array[i].fabricclk_mhz; 606 p->out_states->state_array[i].socclk_mhz = p->in_states->state_array[i].socclk_mhz; 607 p->out_states->state_array[i].dcfclk_mhz = p->in_states->state_array[i].dcfclk_mhz; 608 } 609 610 p->out_states->num_states = p->in_states->num_states; 611 } else { 612 dml2_policy_build_synthetic_soc_states(s, p); 613 } 614 } 615 616 void dml2_translate_ip_params(const struct dc *in, struct ip_params_st *out) 617 { 618 const struct _vcs_dpi_ip_params_st *in_ip_params = &in->dml.ip; 619 /* Copy over the IP params tp dml2_ctx */ 620 out->compressed_buffer_segment_size_in_kbytes = in_ip_params->compressed_buffer_segment_size_in_kbytes; 621 out->config_return_buffer_size_in_kbytes = in_ip_params->config_return_buffer_size_in_kbytes; 622 out->cursor_buffer_size = in_ip_params->cursor_buffer_size; 623 out->cursor_chunk_size = in_ip_params->cursor_chunk_size; 624 out->dcc_meta_buffer_size_bytes = in_ip_params->dcc_meta_buffer_size_bytes; 625 out->dcc_supported = in_ip_params->dcc_supported; 626 out->dispclk_delay_subtotal = in_ip_params->dispclk_delay_subtotal; 627 out->dispclk_ramp_margin_percent = in_ip_params->dispclk_ramp_margin_percent; 628 out->dppclk_delay_cnvc_cursor = in_ip_params->dppclk_delay_cnvc_cursor; 629 out->dppclk_delay_cnvc_formatter = in_ip_params->dppclk_delay_cnvc_formatter; 630 out->dppclk_delay_scl = in_ip_params->dppclk_delay_scl; 631 out->dppclk_delay_scl_lb_only = in_ip_params->dppclk_delay_scl_lb_only; 632 out->dppclk_delay_subtotal = in_ip_params->dppclk_delay_subtotal; 633 out->dpte_buffer_size_in_pte_reqs_chroma = in_ip_params->dpte_buffer_size_in_pte_reqs_chroma; 634 out->dpte_buffer_size_in_pte_reqs_luma = in_ip_params->dpte_buffer_size_in_pte_reqs_luma; 635 out->dsc422_native_support = in_ip_params->dsc422_native_support; 636 out->dynamic_metadata_vm_enabled = in_ip_params->dynamic_metadata_vm_enabled; 637 out->gpuvm_enable = in_ip_params->gpuvm_enable; 638 out->gpuvm_max_page_table_levels = in_ip_params->gpuvm_max_page_table_levels; 639 out->hostvm_enable = in_ip_params->hostvm_enable; 640 out->hostvm_max_page_table_levels = in_ip_params->hostvm_max_page_table_levels; 641 out->line_buffer_size_bits = in_ip_params->line_buffer_size_bits; 642 out->maximum_dsc_bits_per_component = in_ip_params->maximum_dsc_bits_per_component; 643 out->maximum_pixels_per_line_per_dsc_unit = in_ip_params->maximum_pixels_per_line_per_dsc_unit; 644 out->max_dchub_pscl_bw_pix_per_clk = in_ip_params->max_dchub_pscl_bw_pix_per_clk; 645 out->max_hscl_ratio = in_ip_params->max_hscl_ratio; 646 out->max_hscl_taps = in_ip_params->max_hscl_taps; 647 out->max_inter_dcn_tile_repeaters = in_ip_params->max_inter_dcn_tile_repeaters; 648 out->max_lb_vscl_bw_pix_per_clk = in_ip_params->max_lb_vscl_bw_pix_per_clk; 649 out->max_line_buffer_lines = in_ip_params->max_line_buffer_lines; 650 out->max_num_dp2p0_outputs = in_ip_params->max_num_dp2p0_outputs; 651 out->max_num_dp2p0_streams = in_ip_params->max_num_dp2p0_streams; 652 out->max_num_dpp = in_ip_params->max_num_dpp; 653 out->max_num_hdmi_frl_outputs = in_ip_params->max_num_hdmi_frl_outputs; 654 out->max_num_otg = in_ip_params->max_num_otg; 655 out->max_num_wb = in_ip_params->max_num_wb; 656 out->max_pscl_lb_bw_pix_per_clk = in_ip_params->max_pscl_lb_bw_pix_per_clk; 657 out->max_vscl_hscl_bw_pix_per_clk = in_ip_params->max_vscl_hscl_bw_pix_per_clk; 658 out->max_vscl_ratio = in_ip_params->max_vscl_ratio; 659 out->max_vscl_taps = in_ip_params->max_vscl_taps; 660 out->meta_chunk_size_kbytes = in_ip_params->meta_chunk_size_kbytes; 661 out->meta_fifo_size_in_kentries = in_ip_params->meta_fifo_size_in_kentries; 662 out->min_meta_chunk_size_bytes = in_ip_params->min_meta_chunk_size_bytes; 663 out->min_pixel_chunk_size_bytes = in_ip_params->min_pixel_chunk_size_bytes; 664 out->num_dsc = in_ip_params->num_dsc; 665 out->pixel_chunk_size_kbytes = in_ip_params->pixel_chunk_size_kbytes; 666 out->ptoi_supported = in_ip_params->ptoi_supported; 667 out->rob_buffer_size_kbytes = in_ip_params->rob_buffer_size_kbytes; 668 out->writeback_chunk_size_kbytes = in_ip_params->writeback_chunk_size_kbytes; 669 out->writeback_interface_buffer_size_kbytes = in_ip_params->writeback_interface_buffer_size_kbytes; 670 out->writeback_line_buffer_buffer_size = in_ip_params->writeback_line_buffer_buffer_size; 671 out->writeback_max_hscl_ratio = in_ip_params->writeback_max_hscl_ratio; 672 out->writeback_max_hscl_taps = in_ip_params->writeback_max_hscl_taps; 673 out->writeback_max_vscl_ratio = in_ip_params->writeback_max_vscl_ratio; 674 out->writeback_max_vscl_taps = in_ip_params->writeback_max_vscl_taps; 675 out->writeback_min_hscl_ratio = in_ip_params->writeback_min_hscl_ratio; 676 out->writeback_min_vscl_ratio = in_ip_params->writeback_min_vscl_ratio; 677 out->zero_size_buffer_entries = in_ip_params->zero_size_buffer_entries; 678 679 /* As per hardcoded reference / discussions */ 680 out->config_return_buffer_segment_size_in_kbytes = 64; 681 //out->vblank_nom_default_us = 600; 682 out->vblank_nom_default_us = in_ip_params->VBlankNomDefaultUS; 683 } 684 685 void dml2_translate_socbb_params(const struct dc *in, struct soc_bounding_box_st *out) 686 { 687 const struct _vcs_dpi_soc_bounding_box_st *in_soc_params = &in->dml.soc; 688 /* Copy over the SOCBB params to dml2_ctx */ 689 out->dispclk_dppclk_vco_speed_mhz = in_soc_params->dispclk_dppclk_vco_speed_mhz; 690 out->do_urgent_latency_adjustment = in_soc_params->do_urgent_latency_adjustment; 691 out->dram_channel_width_bytes = (dml_uint_t)in_soc_params->dram_channel_width_bytes; 692 out->fabric_datapath_to_dcn_data_return_bytes = (dml_uint_t)in_soc_params->fabric_datapath_to_dcn_data_return_bytes; 693 out->gpuvm_min_page_size_kbytes = in_soc_params->gpuvm_min_page_size_bytes / 1024; 694 out->hostvm_min_page_size_kbytes = in_soc_params->hostvm_min_page_size_bytes / 1024; 695 out->mall_allocated_for_dcn_mbytes = (dml_uint_t)in_soc_params->mall_allocated_for_dcn_mbytes; 696 out->max_avg_dram_bw_use_normal_percent = in_soc_params->max_avg_dram_bw_use_normal_percent; 697 out->max_avg_fabric_bw_use_normal_percent = in_soc_params->max_avg_fabric_bw_use_normal_percent; 698 out->max_avg_dram_bw_use_normal_strobe_percent = in_soc_params->max_avg_dram_bw_use_normal_strobe_percent; 699 out->max_avg_sdp_bw_use_normal_percent = in_soc_params->max_avg_sdp_bw_use_normal_percent; 700 out->max_outstanding_reqs = in_soc_params->max_request_size_bytes; 701 out->num_chans = in_soc_params->num_chans; 702 out->pct_ideal_dram_bw_after_urgent_strobe = in_soc_params->pct_ideal_dram_bw_after_urgent_strobe; 703 out->pct_ideal_dram_bw_after_urgent_vm_only = in_soc_params->pct_ideal_dram_sdp_bw_after_urgent_vm_only; 704 out->pct_ideal_fabric_bw_after_urgent = in_soc_params->pct_ideal_fabric_bw_after_urgent; 705 out->pct_ideal_sdp_bw_after_urgent = in_soc_params->pct_ideal_sdp_bw_after_urgent; 706 out->phy_downspread_percent = in_soc_params->downspread_percent; 707 out->refclk_mhz = 50; // As per hardcoded reference. 708 out->return_bus_width_bytes = in_soc_params->return_bus_width_bytes; 709 out->round_trip_ping_latency_dcfclk_cycles = in_soc_params->round_trip_ping_latency_dcfclk_cycles; 710 out->smn_latency_us = in_soc_params->smn_latency_us; 711 out->urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = in_soc_params->urgent_out_of_order_return_per_channel_pixel_and_vm_bytes; 712 out->urgent_out_of_order_return_per_channel_pixel_only_bytes = in_soc_params->urgent_out_of_order_return_per_channel_pixel_only_bytes; 713 out->urgent_out_of_order_return_per_channel_vm_only_bytes = in_soc_params->urgent_out_of_order_return_per_channel_vm_only_bytes; 714 out->pct_ideal_dram_bw_after_urgent_pixel_and_vm = in_soc_params->pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm; 715 out->pct_ideal_dram_bw_after_urgent_pixel_only = in_soc_params->pct_ideal_dram_sdp_bw_after_urgent_pixel_only; 716 out->dcn_downspread_percent = in_soc_params->dcn_downspread_percent; 717 } 718 719 void dml2_translate_soc_states(const struct dc *dc, struct soc_states_st *out, int num_states) 720 { 721 unsigned int i = 0; 722 out->num_states = num_states; 723 724 for (i = 0; i < out->num_states; i++) { 725 out->state_array[i].dcfclk_mhz = dc->dml.soc.clock_limits[i].dcfclk_mhz; 726 out->state_array[i].dispclk_mhz = dc->dml.soc.clock_limits[i].dispclk_mhz; 727 out->state_array[i].dppclk_mhz = dc->dml.soc.clock_limits[i].dppclk_mhz; 728 out->state_array[i].dram_speed_mts = dc->dml.soc.clock_limits[i].dram_speed_mts; 729 out->state_array[i].dtbclk_mhz = dc->dml.soc.clock_limits[i].dtbclk_mhz; 730 out->state_array[i].socclk_mhz = dc->dml.soc.clock_limits[i].socclk_mhz; 731 out->state_array[i].fabricclk_mhz = dc->dml.soc.clock_limits[i].fabricclk_mhz; 732 out->state_array[i].dscclk_mhz = dc->dml.soc.clock_limits[i].dscclk_mhz; 733 out->state_array[i].phyclk_d18_mhz = dc->dml.soc.clock_limits[i].phyclk_d18_mhz; 734 out->state_array[i].phyclk_d32_mhz = dc->dml.soc.clock_limits[i].phyclk_d32_mhz; 735 out->state_array[i].phyclk_mhz = dc->dml.soc.clock_limits[i].phyclk_mhz; 736 out->state_array[i].sr_enter_plus_exit_time_us = dc->dml.soc.sr_enter_plus_exit_time_us; 737 out->state_array[i].sr_exit_time_us = dc->dml.soc.sr_exit_time_us; 738 out->state_array[i].fclk_change_latency_us = dc->dml.soc.fclk_change_latency_us; 739 out->state_array[i].dram_clock_change_latency_us = dc->dml.soc.dram_clock_change_latency_us; 740 out->state_array[i].usr_retraining_latency_us = dc->dml.soc.usr_retraining_latency_us; 741 out->state_array[i].writeback_latency_us = dc->dml.soc.writeback_latency_us; 742 /* Driver initialized values for these are different than the spreadsheet. Use the 743 * spreadsheet ones for now. We need to decided which ones to use. 744 */ 745 out->state_array[i].sr_exit_z8_time_us = dc->dml.soc.sr_exit_z8_time_us; 746 out->state_array[i].sr_enter_plus_exit_z8_time_us = dc->dml.soc.sr_enter_plus_exit_z8_time_us; 747 //out->state_array[i].sr_exit_z8_time_us = 5.20; 748 //out->state_array[i].sr_enter_plus_exit_z8_time_us = 9.60; 749 out->state_array[i].use_ideal_dram_bw_strobe = true; 750 out->state_array[i].urgent_latency_pixel_data_only_us = dc->dml.soc.urgent_latency_pixel_data_only_us; 751 out->state_array[i].urgent_latency_pixel_mixed_with_vm_data_us = dc->dml.soc.urgent_latency_pixel_mixed_with_vm_data_us; 752 out->state_array[i].urgent_latency_vm_data_only_us = dc->dml.soc.urgent_latency_vm_data_only_us; 753 out->state_array[i].urgent_latency_adjustment_fabric_clock_component_us = dc->dml.soc.urgent_latency_adjustment_fabric_clock_component_us; 754 out->state_array[i].urgent_latency_adjustment_fabric_clock_reference_mhz = dc->dml.soc.urgent_latency_adjustment_fabric_clock_reference_mhz; 755 } 756 } 757 758 static void populate_dml_timing_cfg_from_stream_state(struct dml_timing_cfg_st *out, unsigned int location, const struct dc_stream_state *in) 759 { 760 dml_uint_t hblank_start, vblank_start; 761 762 out->HActive[location] = in->timing.h_addressable + in->timing.h_border_left + in->timing.h_border_right; 763 out->VActive[location] = in->timing.v_addressable + in->timing.v_border_bottom + in->timing.v_border_top; 764 out->RefreshRate[location] = ((in->timing.pix_clk_100hz * 100) / in->timing.h_total) / in->timing.v_total; 765 out->VFrontPorch[location] = in->timing.v_front_porch; 766 out->PixelClock[location] = in->timing.pix_clk_100hz / 10000.00; 767 if (in->timing.timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING) 768 out->PixelClock[location] *= 2; 769 out->HTotal[location] = in->timing.h_total; 770 out->VTotal[location] = in->timing.v_total; 771 out->Interlace[location] = (in->timing.flags.INTERLACE != 0); 772 hblank_start = in->timing.h_total - in->timing.h_front_porch; 773 out->HBlankEnd[location] = hblank_start 774 - in->timing.h_addressable 775 - in->timing.h_border_left 776 - in->timing.h_border_right; 777 vblank_start = in->timing.v_total - in->timing.v_front_porch; 778 out->VBlankEnd[location] = vblank_start 779 - in->timing.v_addressable 780 - in->timing.v_border_top 781 - in->timing.v_border_bottom; 782 out->DRRDisplay[location] = false; 783 } 784 785 static void populate_dml_output_cfg_from_stream_state(struct dml_output_cfg_st *out, unsigned int location, 786 const struct dc_stream_state *in, const struct pipe_ctx *pipe, struct dml2_context *dml2) 787 { 788 (void)pipe; 789 unsigned int output_bpc; 790 791 out->DSCEnable[location] = (enum dml_dsc_enable)in->timing.flags.DSC; 792 out->OutputLinkDPLanes[location] = 4; // As per code in dcn20_resource.c 793 out->DSCInputBitPerComponent[location] = 12; // As per code in dcn20_resource.c 794 out->DSCSlices[location] = in->timing.dsc_cfg.num_slices_h; 795 796 switch (in->signal) { 797 case SIGNAL_TYPE_DISPLAY_PORT_MST: 798 case SIGNAL_TYPE_DISPLAY_PORT: 799 out->OutputEncoder[location] = dml_dp; 800 if (location < MAX_HPO_DP2_ENCODERS && dml2->v20.scratch.hpo_stream_to_link_encoder_mapping[location] != -1) 801 out->OutputEncoder[dml2->v20.scratch.hpo_stream_to_link_encoder_mapping[location]] = dml_dp2p0; 802 break; 803 case SIGNAL_TYPE_EDP: 804 out->OutputEncoder[location] = dml_edp; 805 break; 806 case SIGNAL_TYPE_HDMI_TYPE_A: 807 case SIGNAL_TYPE_DVI_SINGLE_LINK: 808 case SIGNAL_TYPE_DVI_DUAL_LINK: 809 out->OutputEncoder[location] = dml_hdmi; 810 break; 811 case SIGNAL_TYPE_HDMI_FRL: 812 out->OutputEncoder[location] = dml_hdmifrl; 813 break; 814 default: 815 out->OutputEncoder[location] = dml_dp; 816 } 817 818 switch (in->timing.display_color_depth) { 819 case COLOR_DEPTH_666: 820 output_bpc = 6; 821 break; 822 case COLOR_DEPTH_888: 823 output_bpc = 8; 824 break; 825 case COLOR_DEPTH_101010: 826 output_bpc = 10; 827 break; 828 case COLOR_DEPTH_121212: 829 output_bpc = 12; 830 break; 831 case COLOR_DEPTH_141414: 832 output_bpc = 14; 833 break; 834 case COLOR_DEPTH_161616: 835 output_bpc = 16; 836 break; 837 case COLOR_DEPTH_999: 838 output_bpc = 9; 839 break; 840 case COLOR_DEPTH_111111: 841 output_bpc = 11; 842 break; 843 default: 844 output_bpc = 8; 845 break; 846 } 847 848 switch (in->timing.pixel_encoding) { 849 case PIXEL_ENCODING_RGB: 850 case PIXEL_ENCODING_YCBCR444: 851 out->OutputFormat[location] = dml_444; 852 out->OutputBpp[location] = (dml_float_t)output_bpc * 3; 853 break; 854 case PIXEL_ENCODING_YCBCR420: 855 out->OutputFormat[location] = dml_420; 856 out->OutputBpp[location] = (output_bpc * 3.0) / 2; 857 break; 858 case PIXEL_ENCODING_YCBCR422: 859 if (in->timing.flags.DSC && !in->timing.dsc_cfg.ycbcr422_simple) 860 out->OutputFormat[location] = dml_n422; 861 else 862 out->OutputFormat[location] = dml_s422; 863 out->OutputBpp[location] = (dml_float_t)output_bpc * 2; 864 break; 865 default: 866 out->OutputFormat[location] = dml_444; 867 out->OutputBpp[location] = (dml_float_t)output_bpc * 3; 868 break; 869 } 870 871 if (in->timing.flags.DSC) { 872 out->OutputBpp[location] = in->timing.dsc_cfg.bits_per_pixel / 16.0; 873 } 874 875 // This has been false throughout DCN32x development. If needed we can change this later on. 876 out->OutputMultistreamEn[location] = false; 877 878 switch (in->signal) { 879 case SIGNAL_TYPE_NONE: 880 case SIGNAL_TYPE_DVI_SINGLE_LINK: 881 case SIGNAL_TYPE_DVI_DUAL_LINK: 882 case SIGNAL_TYPE_HDMI_TYPE_A: 883 case SIGNAL_TYPE_LVDS: 884 case SIGNAL_TYPE_RGB: 885 case SIGNAL_TYPE_DISPLAY_PORT: 886 case SIGNAL_TYPE_DISPLAY_PORT_MST: 887 case SIGNAL_TYPE_EDP: 888 case SIGNAL_TYPE_VIRTUAL: 889 case SIGNAL_TYPE_HDMI_FRL: 890 default: 891 out->OutputLinkDPRate[location] = dml_dp_rate_na; 892 break; 893 } 894 895 out->PixelClockBackEnd[location] = in->timing.pix_clk_100hz / 10000.00; 896 897 out->AudioSampleLayout[location] = in->audio_info.modes->sample_size; 898 out->AudioSampleRate[location] = in->audio_info.modes->max_bit_rate; 899 900 out->OutputDisabled[location] = true; 901 } 902 903 static void populate_dummy_dml_surface_cfg(struct dml_surface_cfg_st *out, unsigned int location, const struct dc_stream_state *in) 904 { 905 out->SurfaceWidthY[location] = in->timing.h_addressable; 906 out->SurfaceHeightY[location] = in->timing.v_addressable; 907 out->SurfaceWidthC[location] = in->timing.h_addressable; 908 out->SurfaceHeightC[location] = in->timing.v_addressable; 909 out->PitchY[location] = ((out->SurfaceWidthY[location] + 127) / 128) * 128; 910 out->PitchC[location] = 1; 911 out->DCCEnable[location] = false; 912 out->DCCMetaPitchY[location] = 0; 913 out->DCCMetaPitchC[location] = 0; 914 out->DCCRateLuma[location] = 1.0; 915 out->DCCRateChroma[location] = 1.0; 916 out->DCCFractionOfZeroSizeRequestsLuma[location] = 0; 917 out->DCCFractionOfZeroSizeRequestsChroma[location] = 0; 918 out->SurfaceTiling[location] = dml_sw_64kb_r_x; 919 out->SourcePixelFormat[location] = dml_444_32; 920 } 921 922 static void populate_dml_surface_cfg_from_plane_state(enum dml_project_id dml2_project, struct dml_surface_cfg_st *out, unsigned int location, const struct dc_plane_state *in) 923 { 924 out->PitchY[location] = in->plane_size.surface_pitch; 925 out->SurfaceHeightY[location] = in->plane_size.surface_size.height; 926 out->SurfaceWidthY[location] = in->plane_size.surface_size.width; 927 out->SurfaceHeightC[location] = in->plane_size.chroma_size.height; 928 out->SurfaceWidthC[location] = in->plane_size.chroma_size.width; 929 out->PitchC[location] = in->plane_size.chroma_pitch; 930 out->DCCEnable[location] = in->dcc.enable; 931 out->DCCMetaPitchY[location] = in->dcc.meta_pitch; 932 out->DCCMetaPitchC[location] = in->dcc.meta_pitch_c; 933 out->DCCRateLuma[location] = 1.0; 934 out->DCCRateChroma[location] = 1.0; 935 out->DCCFractionOfZeroSizeRequestsLuma[location] = in->dcc.independent_64b_blks; 936 out->DCCFractionOfZeroSizeRequestsChroma[location] = in->dcc.independent_64b_blks_c; 937 938 switch (dml2_project) { 939 default: 940 out->SurfaceTiling[location] = (enum dml_swizzle_mode)in->tiling_info.gfx9.swizzle; 941 break; 942 case dml_project_dcn401: 943 // Temporary use gfx11 swizzle in dml, until proper dml for DCN4x is integrated/implemented 944 switch (in->tiling_info.gfx_addr3.swizzle) { 945 case DC_ADDR3_SW_4KB_2D: 946 case DC_ADDR3_SW_64KB_2D: 947 case DC_ADDR3_SW_256KB_2D: 948 default: 949 out->SurfaceTiling[location] = dml_sw_64kb_r_x; 950 break; 951 case DC_ADDR3_SW_LINEAR: 952 out->SurfaceTiling[location] = dml_sw_linear; 953 break; 954 } 955 } 956 957 switch (in->format) { 958 case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr: 959 case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb: 960 out->SourcePixelFormat[location] = dml_420_8; 961 break; 962 case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr: 963 case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb: 964 out->SourcePixelFormat[location] = dml_420_10; 965 break; 966 case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616: 967 case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616: 968 case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F: 969 case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F: 970 out->SourcePixelFormat[location] = dml_444_64; 971 break; 972 case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555: 973 case SURFACE_PIXEL_FORMAT_GRPH_RGB565: 974 out->SourcePixelFormat[location] = dml_444_16; 975 break; 976 case SURFACE_PIXEL_FORMAT_GRPH_PALETA_256_COLORS: 977 out->SourcePixelFormat[location] = dml_444_8; 978 break; 979 case SURFACE_PIXEL_FORMAT_GRPH_RGBE_ALPHA: 980 out->SourcePixelFormat[location] = dml_rgbe_alpha; 981 break; 982 default: 983 out->SourcePixelFormat[location] = dml_444_32; 984 break; 985 } 986 } 987 988 static struct scaler_data *get_scaler_data_for_plane( 989 const struct dc_plane_state *in, 990 struct dc_state *context) 991 { 992 int i; 993 struct pipe_ctx *temp_pipe = &context->res_ctx.temp_pipe; 994 995 memset(temp_pipe, 0, sizeof(struct pipe_ctx)); 996 997 for (i = 0; i < MAX_PIPES; i++) { 998 const struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i]; 999 1000 if (pipe->plane_state == in && !pipe->prev_odm_pipe) { 1001 temp_pipe->stream = pipe->stream; 1002 temp_pipe->plane_state = pipe->plane_state; 1003 temp_pipe->plane_res.scl_data.taps = pipe->plane_res.scl_data.taps; 1004 temp_pipe->stream_res = pipe->stream_res; 1005 resource_build_scaling_params(temp_pipe); 1006 break; 1007 } 1008 } 1009 1010 ASSERT(i < MAX_PIPES); 1011 return &temp_pipe->plane_res.scl_data; 1012 } 1013 1014 static void populate_dummy_dml_plane_cfg(struct dml_plane_cfg_st *out, unsigned int location, 1015 const struct dc_stream_state *in, 1016 const struct soc_bounding_box_st *soc) 1017 { 1018 dml_uint_t width, height; 1019 1020 if (in->timing.h_addressable > 3840) 1021 width = 3840; 1022 else 1023 width = in->timing.h_addressable; // 4K max 1024 1025 if (in->timing.v_addressable > 2160) 1026 height = 2160; 1027 else 1028 height = in->timing.v_addressable; // 4K max 1029 1030 out->CursorBPP[location] = dml_cur_32bit; 1031 out->CursorWidth[location] = 256; 1032 1033 out->GPUVMMinPageSizeKBytes[location] = soc->gpuvm_min_page_size_kbytes; 1034 1035 out->ViewportWidth[location] = width; 1036 out->ViewportHeight[location] = height; 1037 out->ViewportStationary[location] = false; 1038 out->ViewportWidthChroma[location] = 0; 1039 out->ViewportHeightChroma[location] = 0; 1040 out->ViewportXStart[location] = 0; 1041 out->ViewportXStartC[location] = 0; 1042 out->ViewportYStart[location] = 0; 1043 out->ViewportYStartC[location] = 0; 1044 1045 out->ScalerEnabled[location] = false; 1046 out->HRatio[location] = 1.0; 1047 out->VRatio[location] = 1.0; 1048 out->HRatioChroma[location] = 0; 1049 out->VRatioChroma[location] = 0; 1050 out->HTaps[location] = 1; 1051 out->VTaps[location] = 1; 1052 out->HTapsChroma[location] = 0; 1053 out->VTapsChroma[location] = 0; 1054 out->SourceScan[location] = dml_rotation_0; 1055 out->ScalerRecoutWidth[location] = width; 1056 1057 out->LBBitPerPixel[location] = 57; 1058 1059 out->DynamicMetadataEnable[location] = false; 1060 1061 out->NumberOfCursors[location] = 1; 1062 out->UseMALLForStaticScreen[location] = dml_use_mall_static_screen_disable; 1063 out->UseMALLForPStateChange[location] = dml_use_mall_pstate_change_disable; 1064 1065 out->DETSizeOverride[location] = 256; 1066 1067 out->ScalerEnabled[location] = false; 1068 } 1069 1070 static void populate_dml_plane_cfg_from_plane_state(struct dml_plane_cfg_st *out, unsigned int location, 1071 const struct dc_plane_state *in, struct dc_state *context, 1072 const struct soc_bounding_box_st *soc) 1073 { 1074 struct scaler_data *scaler_data = get_scaler_data_for_plane(in, context); 1075 1076 out->CursorBPP[location] = dml_cur_32bit; 1077 out->CursorWidth[location] = 256; 1078 1079 out->GPUVMMinPageSizeKBytes[location] = soc->gpuvm_min_page_size_kbytes; 1080 1081 out->ViewportWidth[location] = scaler_data->viewport.width; 1082 out->ViewportHeight[location] = scaler_data->viewport.height; 1083 out->ViewportWidthChroma[location] = scaler_data->viewport_c.width; 1084 out->ViewportHeightChroma[location] = scaler_data->viewport_c.height; 1085 out->ViewportXStart[location] = scaler_data->viewport.x; 1086 out->ViewportYStart[location] = scaler_data->viewport.y; 1087 out->ViewportXStartC[location] = scaler_data->viewport_c.x; 1088 out->ViewportYStartC[location] = scaler_data->viewport_c.y; 1089 out->ViewportStationary[location] = false; 1090 1091 out->ScalerEnabled[location] = scaler_data->ratios.horz.value != dc_fixpt_one.value || 1092 scaler_data->ratios.horz_c.value != dc_fixpt_one.value || 1093 scaler_data->ratios.vert.value != dc_fixpt_one.value || 1094 scaler_data->ratios.vert_c.value != dc_fixpt_one.value; 1095 1096 /* Current driver code base uses LBBitPerPixel as 57. There is a discrepancy 1097 * from the HW/DML teams about this value. Initialize LBBitPerPixel with the 1098 * value current used in Navi3x . 1099 */ 1100 1101 out->LBBitPerPixel[location] = 57; 1102 1103 if (out->ScalerEnabled[location] == false) { 1104 out->HRatio[location] = 1; 1105 out->HRatioChroma[location] = 1; 1106 out->VRatio[location] = 1; 1107 out->VRatioChroma[location] = 1; 1108 } else { 1109 /* Follow the original dml_wrapper.c code direction to fix scaling issues */ 1110 out->HRatio[location] = (dml_float_t)scaler_data->ratios.horz.value / (1ULL << 32); 1111 out->HRatioChroma[location] = (dml_float_t)scaler_data->ratios.horz_c.value / (1ULL << 32); 1112 out->VRatio[location] = (dml_float_t)scaler_data->ratios.vert.value / (1ULL << 32); 1113 out->VRatioChroma[location] = (dml_float_t)scaler_data->ratios.vert_c.value / (1ULL << 32); 1114 } 1115 1116 if (!scaler_data->taps.h_taps) { 1117 out->HTaps[location] = 1; 1118 out->HTapsChroma[location] = 1; 1119 } else { 1120 out->HTaps[location] = scaler_data->taps.h_taps; 1121 out->HTapsChroma[location] = scaler_data->taps.h_taps_c; 1122 } 1123 if (!scaler_data->taps.v_taps) { 1124 out->VTaps[location] = 1; 1125 out->VTapsChroma[location] = 1; 1126 } else { 1127 out->VTaps[location] = scaler_data->taps.v_taps; 1128 out->VTapsChroma[location] = scaler_data->taps.v_taps_c; 1129 } 1130 1131 out->SourceScan[location] = (enum dml_rotation_angle)in->rotation; 1132 out->ScalerRecoutWidth[location] = in->dst_rect.width; 1133 1134 out->DynamicMetadataEnable[location] = false; 1135 out->DynamicMetadataLinesBeforeActiveRequired[location] = 0; 1136 out->DynamicMetadataTransmittedBytes[location] = 0; 1137 1138 out->NumberOfCursors[location] = 1; 1139 } 1140 1141 static unsigned int map_stream_to_dml_display_cfg(const struct dml2_context *dml2, 1142 const struct dc_stream_state *stream, const struct dml_display_cfg_st *dml_dispcfg) 1143 { 1144 (void)dml_dispcfg; 1145 int i = 0; 1146 int location = -1; 1147 1148 for (i = 0; i < __DML2_WRAPPER_MAX_STREAMS_PLANES__; i++) { 1149 if (dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_stream_id_valid[i] && dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_stream_id[i] == stream->stream_id) { 1150 location = i; 1151 break; 1152 } 1153 } 1154 1155 return location; 1156 } 1157 1158 static bool get_plane_id(struct dml2_context *dml2, const struct dc_state *context, const struct dc_plane_state *plane, 1159 unsigned int stream_id, unsigned int plane_index, unsigned int *plane_id) 1160 { 1161 int i, j; 1162 bool is_plane_duplicate = dml2->v20.scratch.plane_duplicate_exists; 1163 1164 if (!plane_id) 1165 return false; 1166 1167 for (i = 0; i < context->stream_count; i++) { 1168 if (context->streams[i]->stream_id == stream_id) { 1169 for (j = 0; j < context->stream_status[i].plane_count; j++) { 1170 if (context->stream_status[i].plane_states[j] == plane && 1171 (!is_plane_duplicate || (j == plane_index))) { 1172 *plane_id = (i << 16) | j; 1173 return true; 1174 } 1175 } 1176 } 1177 } 1178 1179 return false; 1180 } 1181 1182 static unsigned int map_plane_to_dml_display_cfg(const struct dml2_context *dml2, const struct dc_plane_state *plane, 1183 const struct dc_state *context, const struct dml_display_cfg_st *dml_dispcfg, unsigned int stream_id, int plane_index) 1184 { 1185 (void)dml_dispcfg; 1186 unsigned int plane_id; 1187 unsigned int i = 0; 1188 unsigned int location = UINT_MAX; 1189 1190 if (!get_plane_id(context->bw_ctx.dml2, context, plane, stream_id, plane_index, &plane_id)) { 1191 ASSERT(false); 1192 return UINT_MAX; 1193 } 1194 1195 for (i = 0; i < __DML2_WRAPPER_MAX_STREAMS_PLANES__; i++) { 1196 if (dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_plane_id_valid[i] && dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_plane_id[i] == plane_id) { 1197 location = i; 1198 break; 1199 } 1200 } 1201 1202 return location; 1203 } 1204 1205 static void dml2_populate_pipe_to_plane_index_mapping(struct dml2_context *dml2, struct dc_state *state) 1206 { 1207 unsigned int i; 1208 unsigned int pipe_index = 0; 1209 unsigned int plane_index = 0; 1210 struct dml2_dml_to_dc_pipe_mapping *dml_to_dc_pipe_mapping = &dml2->v20.scratch.dml_to_dc_pipe_mapping; 1211 1212 for (i = 0; i < __DML2_WRAPPER_MAX_STREAMS_PLANES__; i++) { 1213 dml_to_dc_pipe_mapping->dml_pipe_idx_to_plane_index_valid[i] = false; 1214 dml_to_dc_pipe_mapping->dml_pipe_idx_to_plane_index[i] = 0; 1215 } 1216 1217 for (i = 0; i < __DML2_WRAPPER_MAX_STREAMS_PLANES__; i++) { 1218 struct pipe_ctx *pipe = &state->res_ctx.pipe_ctx[i]; 1219 1220 if (!pipe || !pipe->stream || !pipe->plane_state) 1221 continue; 1222 1223 while (pipe) { 1224 pipe_index = pipe->pipe_idx; 1225 1226 if (pipe->stream && dml_to_dc_pipe_mapping->dml_pipe_idx_to_plane_index_valid[pipe_index] == false) { 1227 dml_to_dc_pipe_mapping->dml_pipe_idx_to_plane_index[pipe_index] = plane_index; 1228 plane_index++; 1229 dml_to_dc_pipe_mapping->dml_pipe_idx_to_plane_index_valid[pipe_index] = true; 1230 } 1231 1232 pipe = pipe->bottom_pipe; 1233 } 1234 1235 plane_index = 0; 1236 } 1237 } 1238 1239 static void populate_dml_writeback_cfg_from_stream_state(struct dml_writeback_cfg_st *out, 1240 unsigned int location, const struct dc_stream_state *in) 1241 { 1242 if (in->num_wb_info > 0) { 1243 for (int i = 0; i < __DML_NUM_DMB__; i++) { 1244 const struct dc_writeback_info *wb_info = &in->writeback_info[i]; 1245 /*current dml support 1 dwb per stream, limitation*/ 1246 if (wb_info->wb_enabled) { 1247 out->WritebackEnable[location] = wb_info->wb_enabled; 1248 out->ActiveWritebacksPerSurface[location] = wb_info->dwb_params.cnv_params.src_width; 1249 out->WritebackDestinationWidth[location] = wb_info->dwb_params.dest_width; 1250 out->WritebackDestinationHeight[location] = wb_info->dwb_params.dest_height; 1251 1252 out->WritebackSourceWidth[location] = wb_info->dwb_params.cnv_params.crop_en ? 1253 wb_info->dwb_params.cnv_params.crop_width : 1254 wb_info->dwb_params.cnv_params.src_width; 1255 1256 out->WritebackSourceHeight[location] = wb_info->dwb_params.cnv_params.crop_en ? 1257 wb_info->dwb_params.cnv_params.crop_height : 1258 wb_info->dwb_params.cnv_params.src_height; 1259 /*current design does not have chroma scaling, need to follow up*/ 1260 out->WritebackHTaps[location] = wb_info->dwb_params.scaler_taps.h_taps > 0 ? 1261 wb_info->dwb_params.scaler_taps.h_taps : 1; 1262 out->WritebackVTaps[location] = wb_info->dwb_params.scaler_taps.v_taps > 0 ? 1263 wb_info->dwb_params.scaler_taps.v_taps : 1; 1264 1265 out->WritebackHRatio[location] = wb_info->dwb_params.cnv_params.crop_en ? 1266 (double)wb_info->dwb_params.cnv_params.crop_width / 1267 (double)wb_info->dwb_params.dest_width : 1268 (double)wb_info->dwb_params.cnv_params.src_width / 1269 (double)wb_info->dwb_params.dest_width; 1270 out->WritebackVRatio[location] = wb_info->dwb_params.cnv_params.crop_en ? 1271 (double)wb_info->dwb_params.cnv_params.crop_height / 1272 (double)wb_info->dwb_params.dest_height : 1273 (double)wb_info->dwb_params.cnv_params.src_height / 1274 (double)wb_info->dwb_params.dest_height; 1275 } 1276 } 1277 } 1278 } 1279 1280 static void dml2_map_hpo_stream_encoder_to_hpo_link_encoder_index(struct dml2_context *dml2, struct dc_state *context) 1281 { 1282 int i; 1283 struct pipe_ctx *current_pipe_context; 1284 1285 /* Scratch gets reset to zero in dml, but link encoder instance can be zero, so reset to -1 */ 1286 for (i = 0; i < MAX_HPO_DP2_ENCODERS; i++) { 1287 dml2->v20.scratch.hpo_stream_to_link_encoder_mapping[i] = -1; 1288 } 1289 1290 /* If an HPO stream encoder is allocated to a pipe, get the instance of it's allocated HPO Link encoder */ 1291 for (i = 0; i < MAX_PIPES; i++) { 1292 current_pipe_context = &context->res_ctx.pipe_ctx[i]; 1293 if (current_pipe_context->stream && 1294 current_pipe_context->stream_res.hpo_dp_stream_enc && 1295 current_pipe_context->link_res.hpo_dp_link_enc && 1296 dc_is_dp_signal(current_pipe_context->stream->signal)) { 1297 dml2->v20.scratch.hpo_stream_to_link_encoder_mapping[current_pipe_context->stream_res.hpo_dp_stream_enc->inst] = 1298 current_pipe_context->link_res.hpo_dp_link_enc->inst; 1299 } 1300 } 1301 } 1302 1303 void map_dc_state_into_dml_display_cfg(struct dml2_context *dml2, struct dc_state *context, struct dml_display_cfg_st *dml_dispcfg) 1304 { 1305 int i = 0, j = 0, k = 0; 1306 int disp_cfg_stream_location, disp_cfg_plane_location; 1307 enum mall_stream_type stream_mall_type; 1308 struct pipe_ctx *current_pipe_context; 1309 1310 for (i = 0; i < __DML2_WRAPPER_MAX_STREAMS_PLANES__; i++) { 1311 dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_stream_id_valid[i] = false; 1312 dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_plane_id_valid[i] = false; 1313 dml2->v20.scratch.dml_to_dc_pipe_mapping.dml_pipe_idx_to_stream_id_valid[i] = false; 1314 dml2->v20.scratch.dml_to_dc_pipe_mapping.dml_pipe_idx_to_plane_id_valid[i] = false; 1315 } 1316 1317 //Generally these are set by referencing our latest BB/IP params in dcn32_resource.c file 1318 dml_dispcfg->plane.GPUVMEnable = dml2->v20.dml_core_ctx.ip.gpuvm_enable; 1319 dml_dispcfg->plane.GPUVMMaxPageTableLevels = dml2->v20.dml_core_ctx.ip.gpuvm_max_page_table_levels; 1320 dml_dispcfg->plane.HostVMEnable = dml2->v20.dml_core_ctx.ip.hostvm_enable; 1321 dml_dispcfg->plane.HostVMMaxPageTableLevels = dml2->v20.dml_core_ctx.ip.hostvm_max_page_table_levels; 1322 if (dml2->v20.dml_core_ctx.ip.hostvm_enable) 1323 dml2->v20.dml_core_ctx.policy.AllowForPStateChangeOrStutterInVBlankFinal = dml_prefetch_support_uclk_fclk_and_stutter; 1324 1325 dml2_populate_pipe_to_plane_index_mapping(dml2, context); 1326 dml2_map_hpo_stream_encoder_to_hpo_link_encoder_index(dml2, context); 1327 1328 for (i = 0; i < context->stream_count; i++) { 1329 current_pipe_context = NULL; 1330 for (k = 0; k < MAX_PIPES; k++) { 1331 /* find one pipe allocated to this stream for the purpose of getting 1332 info about the link later */ 1333 if (context->streams[i] == context->res_ctx.pipe_ctx[k].stream) { 1334 current_pipe_context = &context->res_ctx.pipe_ctx[k]; 1335 break; 1336 } 1337 } 1338 disp_cfg_stream_location = map_stream_to_dml_display_cfg(dml2, context->streams[i], dml_dispcfg); 1339 stream_mall_type = dc_state_get_stream_subvp_type(context, context->streams[i]); 1340 1341 if (disp_cfg_stream_location < 0) 1342 disp_cfg_stream_location = dml_dispcfg->num_timings++; 1343 1344 ASSERT(disp_cfg_stream_location >= 0 && disp_cfg_stream_location < __DML2_WRAPPER_MAX_STREAMS_PLANES__); 1345 1346 populate_dml_timing_cfg_from_stream_state(&dml_dispcfg->timing, disp_cfg_stream_location, context->streams[i]); 1347 populate_dml_output_cfg_from_stream_state(&dml_dispcfg->output, disp_cfg_stream_location, context->streams[i], current_pipe_context, dml2); 1348 /*Call site for populate_dml_writeback_cfg_from_stream_state*/ 1349 populate_dml_writeback_cfg_from_stream_state(&dml_dispcfg->writeback, 1350 disp_cfg_stream_location, context->streams[i]); 1351 1352 switch (context->streams[i]->debug.force_odm_combine_segments) { 1353 case 2: 1354 dml2->v20.dml_core_ctx.policy.ODMUse[disp_cfg_stream_location] = dml_odm_use_policy_combine_2to1; 1355 break; 1356 case 4: 1357 dml2->v20.dml_core_ctx.policy.ODMUse[disp_cfg_stream_location] = dml_odm_use_policy_combine_4to1; 1358 break; 1359 default: 1360 break; 1361 } 1362 1363 dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_stream_id[disp_cfg_stream_location] = context->streams[i]->stream_id; 1364 dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_stream_id_valid[disp_cfg_stream_location] = true; 1365 1366 if (context->stream_status[i].plane_count == 0) { 1367 disp_cfg_plane_location = dml_dispcfg->num_surfaces++; 1368 1369 populate_dummy_dml_surface_cfg(&dml_dispcfg->surface, disp_cfg_plane_location, context->streams[i]); 1370 populate_dummy_dml_plane_cfg(&dml_dispcfg->plane, disp_cfg_plane_location, 1371 context->streams[i], &dml2->v20.dml_core_ctx.soc); 1372 1373 dml_dispcfg->plane.BlendingAndTiming[disp_cfg_plane_location] = disp_cfg_stream_location; 1374 1375 dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_plane_id_valid[disp_cfg_plane_location] = true; 1376 } else { 1377 for (j = 0; j < context->stream_status[i].plane_count; j++) { 1378 disp_cfg_plane_location = map_plane_to_dml_display_cfg(dml2, 1379 context->stream_status[i].plane_states[j], context, dml_dispcfg, context->streams[i]->stream_id, j); 1380 1381 if (disp_cfg_plane_location < 0) 1382 disp_cfg_plane_location = dml_dispcfg->num_surfaces++; 1383 1384 ASSERT(disp_cfg_plane_location >= 0 && disp_cfg_plane_location < __DML2_WRAPPER_MAX_STREAMS_PLANES__); 1385 1386 populate_dml_surface_cfg_from_plane_state(dml2->v20.dml_core_ctx.project, &dml_dispcfg->surface, disp_cfg_plane_location, context->stream_status[i].plane_states[j]); 1387 populate_dml_plane_cfg_from_plane_state( 1388 &dml_dispcfg->plane, disp_cfg_plane_location, 1389 context->stream_status[i].plane_states[j], context, 1390 &dml2->v20.dml_core_ctx.soc); 1391 1392 if (stream_mall_type == SUBVP_MAIN) { 1393 dml_dispcfg->plane.UseMALLForPStateChange[disp_cfg_plane_location] = dml_use_mall_pstate_change_sub_viewport; 1394 dml_dispcfg->plane.UseMALLForStaticScreen[disp_cfg_plane_location] = dml_use_mall_static_screen_optimize; 1395 } else if (stream_mall_type == SUBVP_PHANTOM) { 1396 dml_dispcfg->plane.UseMALLForPStateChange[disp_cfg_plane_location] = dml_use_mall_pstate_change_phantom_pipe; 1397 dml_dispcfg->plane.UseMALLForStaticScreen[disp_cfg_plane_location] = dml_use_mall_static_screen_disable; 1398 dml2->v20.dml_core_ctx.policy.ImmediateFlipRequirement[disp_cfg_plane_location] = dml_immediate_flip_not_required; 1399 } else { 1400 dml_dispcfg->plane.UseMALLForPStateChange[disp_cfg_plane_location] = dml_use_mall_pstate_change_disable; 1401 dml_dispcfg->plane.UseMALLForStaticScreen[disp_cfg_plane_location] = dml_use_mall_static_screen_optimize; 1402 } 1403 1404 dml_dispcfg->plane.BlendingAndTiming[disp_cfg_plane_location] = disp_cfg_stream_location; 1405 1406 if (get_plane_id(dml2, context, context->stream_status[i].plane_states[j], context->streams[i]->stream_id, j, 1407 &dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_plane_id[disp_cfg_plane_location])) 1408 dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_plane_id_valid[disp_cfg_plane_location] = true; 1409 1410 if (j >= 1) { 1411 populate_dml_timing_cfg_from_stream_state(&dml_dispcfg->timing, disp_cfg_plane_location, context->streams[i]); 1412 populate_dml_output_cfg_from_stream_state(&dml_dispcfg->output, disp_cfg_plane_location, context->streams[i], current_pipe_context, dml2); 1413 switch (context->streams[i]->debug.force_odm_combine_segments) { 1414 case 2: 1415 dml2->v20.dml_core_ctx.policy.ODMUse[disp_cfg_plane_location] = dml_odm_use_policy_combine_2to1; 1416 break; 1417 case 4: 1418 dml2->v20.dml_core_ctx.policy.ODMUse[disp_cfg_plane_location] = dml_odm_use_policy_combine_4to1; 1419 break; 1420 default: 1421 break; 1422 } 1423 1424 if (stream_mall_type == SUBVP_MAIN) 1425 dml_dispcfg->plane.UseMALLForPStateChange[disp_cfg_plane_location] = dml_use_mall_pstate_change_sub_viewport; 1426 else if (stream_mall_type == SUBVP_PHANTOM) 1427 dml_dispcfg->plane.UseMALLForPStateChange[disp_cfg_plane_location] = dml_use_mall_pstate_change_phantom_pipe; 1428 1429 dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_stream_id[disp_cfg_plane_location] = context->streams[i]->stream_id; 1430 dml2->v20.scratch.dml_to_dc_pipe_mapping.disp_cfg_to_stream_id_valid[disp_cfg_plane_location] = true; 1431 1432 dml_dispcfg->num_timings++; 1433 } 1434 } 1435 } 1436 } 1437 } 1438 1439 void dml2_update_pipe_ctx_dchub_regs(struct _vcs_dpi_dml_display_rq_regs_st *rq_regs, 1440 struct _vcs_dpi_dml_display_dlg_regs_st *disp_dlg_regs, 1441 struct _vcs_dpi_dml_display_ttu_regs_st *disp_ttu_regs, 1442 struct pipe_ctx *out) 1443 { 1444 memset(&out->rq_regs, 0, sizeof(out->rq_regs)); 1445 out->rq_regs.rq_regs_l.chunk_size = rq_regs->rq_regs_l.chunk_size; 1446 out->rq_regs.rq_regs_l.min_chunk_size = rq_regs->rq_regs_l.min_chunk_size; 1447 out->rq_regs.rq_regs_l.meta_chunk_size = rq_regs->rq_regs_l.meta_chunk_size; 1448 out->rq_regs.rq_regs_l.min_meta_chunk_size = rq_regs->rq_regs_l.min_meta_chunk_size; 1449 out->rq_regs.rq_regs_l.dpte_group_size = rq_regs->rq_regs_l.dpte_group_size; 1450 out->rq_regs.rq_regs_l.mpte_group_size = rq_regs->rq_regs_l.mpte_group_size; 1451 out->rq_regs.rq_regs_l.swath_height = rq_regs->rq_regs_l.swath_height; 1452 out->rq_regs.rq_regs_l.pte_row_height_linear = rq_regs->rq_regs_l.pte_row_height_linear; 1453 1454 out->rq_regs.rq_regs_c.chunk_size = rq_regs->rq_regs_c.chunk_size; 1455 out->rq_regs.rq_regs_c.min_chunk_size = rq_regs->rq_regs_c.min_chunk_size; 1456 out->rq_regs.rq_regs_c.meta_chunk_size = rq_regs->rq_regs_c.meta_chunk_size; 1457 out->rq_regs.rq_regs_c.min_meta_chunk_size = rq_regs->rq_regs_c.min_meta_chunk_size; 1458 out->rq_regs.rq_regs_c.dpte_group_size = rq_regs->rq_regs_c.dpte_group_size; 1459 out->rq_regs.rq_regs_c.mpte_group_size = rq_regs->rq_regs_c.mpte_group_size; 1460 out->rq_regs.rq_regs_c.swath_height = rq_regs->rq_regs_c.swath_height; 1461 out->rq_regs.rq_regs_c.pte_row_height_linear = rq_regs->rq_regs_c.pte_row_height_linear; 1462 1463 out->rq_regs.drq_expansion_mode = rq_regs->drq_expansion_mode; 1464 out->rq_regs.prq_expansion_mode = rq_regs->prq_expansion_mode; 1465 out->rq_regs.mrq_expansion_mode = rq_regs->mrq_expansion_mode; 1466 out->rq_regs.crq_expansion_mode = rq_regs->crq_expansion_mode; 1467 out->rq_regs.plane1_base_address = rq_regs->plane1_base_address; 1468 1469 memset(&out->dlg_regs, 0, sizeof(out->dlg_regs)); 1470 out->dlg_regs.refcyc_h_blank_end = disp_dlg_regs->refcyc_h_blank_end; 1471 out->dlg_regs.dlg_vblank_end = disp_dlg_regs->dlg_vblank_end; 1472 out->dlg_regs.min_dst_y_next_start = disp_dlg_regs->min_dst_y_next_start; 1473 out->dlg_regs.refcyc_per_htotal = disp_dlg_regs->refcyc_per_htotal; 1474 out->dlg_regs.refcyc_x_after_scaler = disp_dlg_regs->refcyc_x_after_scaler; 1475 out->dlg_regs.dst_y_after_scaler = disp_dlg_regs->dst_y_after_scaler; 1476 out->dlg_regs.dst_y_prefetch = disp_dlg_regs->dst_y_prefetch; 1477 out->dlg_regs.dst_y_per_vm_vblank = disp_dlg_regs->dst_y_per_vm_vblank; 1478 out->dlg_regs.dst_y_per_row_vblank = disp_dlg_regs->dst_y_per_row_vblank; 1479 out->dlg_regs.dst_y_per_vm_flip = disp_dlg_regs->dst_y_per_vm_flip; 1480 out->dlg_regs.dst_y_per_row_flip = disp_dlg_regs->dst_y_per_row_flip; 1481 out->dlg_regs.ref_freq_to_pix_freq = disp_dlg_regs->ref_freq_to_pix_freq; 1482 out->dlg_regs.vratio_prefetch = disp_dlg_regs->vratio_prefetch; 1483 out->dlg_regs.vratio_prefetch_c = disp_dlg_regs->vratio_prefetch_c; 1484 out->dlg_regs.refcyc_per_pte_group_vblank_l = disp_dlg_regs->refcyc_per_pte_group_vblank_l; 1485 out->dlg_regs.refcyc_per_pte_group_vblank_c = disp_dlg_regs->refcyc_per_pte_group_vblank_c; 1486 out->dlg_regs.refcyc_per_meta_chunk_vblank_l = disp_dlg_regs->refcyc_per_meta_chunk_vblank_l; 1487 out->dlg_regs.refcyc_per_meta_chunk_vblank_c = disp_dlg_regs->refcyc_per_meta_chunk_vblank_c; 1488 out->dlg_regs.refcyc_per_pte_group_flip_l = disp_dlg_regs->refcyc_per_pte_group_flip_l; 1489 out->dlg_regs.refcyc_per_pte_group_flip_c = disp_dlg_regs->refcyc_per_pte_group_flip_c; 1490 out->dlg_regs.refcyc_per_meta_chunk_flip_l = disp_dlg_regs->refcyc_per_meta_chunk_flip_l; 1491 out->dlg_regs.refcyc_per_meta_chunk_flip_c = disp_dlg_regs->refcyc_per_meta_chunk_flip_c; 1492 out->dlg_regs.dst_y_per_pte_row_nom_l = disp_dlg_regs->dst_y_per_pte_row_nom_l; 1493 out->dlg_regs.dst_y_per_pte_row_nom_c = disp_dlg_regs->dst_y_per_pte_row_nom_c; 1494 out->dlg_regs.refcyc_per_pte_group_nom_l = disp_dlg_regs->refcyc_per_pte_group_nom_l; 1495 out->dlg_regs.refcyc_per_pte_group_nom_c = disp_dlg_regs->refcyc_per_pte_group_nom_c; 1496 out->dlg_regs.dst_y_per_meta_row_nom_l = disp_dlg_regs->dst_y_per_meta_row_nom_l; 1497 out->dlg_regs.dst_y_per_meta_row_nom_c = disp_dlg_regs->dst_y_per_meta_row_nom_c; 1498 out->dlg_regs.refcyc_per_meta_chunk_nom_l = disp_dlg_regs->refcyc_per_meta_chunk_nom_l; 1499 out->dlg_regs.refcyc_per_meta_chunk_nom_c = disp_dlg_regs->refcyc_per_meta_chunk_nom_c; 1500 out->dlg_regs.refcyc_per_line_delivery_pre_l = disp_dlg_regs->refcyc_per_line_delivery_pre_l; 1501 out->dlg_regs.refcyc_per_line_delivery_pre_c = disp_dlg_regs->refcyc_per_line_delivery_pre_c; 1502 out->dlg_regs.refcyc_per_line_delivery_l = disp_dlg_regs->refcyc_per_line_delivery_l; 1503 out->dlg_regs.refcyc_per_line_delivery_c = disp_dlg_regs->refcyc_per_line_delivery_c; 1504 out->dlg_regs.refcyc_per_vm_group_vblank = disp_dlg_regs->refcyc_per_vm_group_vblank; 1505 out->dlg_regs.refcyc_per_vm_group_flip = disp_dlg_regs->refcyc_per_vm_group_flip; 1506 out->dlg_regs.refcyc_per_vm_req_vblank = disp_dlg_regs->refcyc_per_vm_req_vblank; 1507 out->dlg_regs.refcyc_per_vm_req_flip = disp_dlg_regs->refcyc_per_vm_req_flip; 1508 out->dlg_regs.dst_y_offset_cur0 = disp_dlg_regs->dst_y_offset_cur0; 1509 out->dlg_regs.chunk_hdl_adjust_cur0 = disp_dlg_regs->chunk_hdl_adjust_cur0; 1510 out->dlg_regs.dst_y_offset_cur1 = disp_dlg_regs->dst_y_offset_cur1; 1511 out->dlg_regs.chunk_hdl_adjust_cur1 = disp_dlg_regs->chunk_hdl_adjust_cur1; 1512 out->dlg_regs.vready_after_vcount0 = disp_dlg_regs->vready_after_vcount0; 1513 out->dlg_regs.dst_y_delta_drq_limit = disp_dlg_regs->dst_y_delta_drq_limit; 1514 out->dlg_regs.refcyc_per_vm_dmdata = disp_dlg_regs->refcyc_per_vm_dmdata; 1515 out->dlg_regs.dmdata_dl_delta = disp_dlg_regs->dmdata_dl_delta; 1516 1517 memset(&out->ttu_regs, 0, sizeof(out->ttu_regs)); 1518 out->ttu_regs.qos_level_low_wm = disp_ttu_regs->qos_level_low_wm; 1519 out->ttu_regs.qos_level_high_wm = disp_ttu_regs->qos_level_high_wm; 1520 out->ttu_regs.min_ttu_vblank = disp_ttu_regs->min_ttu_vblank; 1521 out->ttu_regs.qos_level_flip = disp_ttu_regs->qos_level_flip; 1522 out->ttu_regs.refcyc_per_req_delivery_l = disp_ttu_regs->refcyc_per_req_delivery_l; 1523 out->ttu_regs.refcyc_per_req_delivery_c = disp_ttu_regs->refcyc_per_req_delivery_c; 1524 out->ttu_regs.refcyc_per_req_delivery_cur0 = disp_ttu_regs->refcyc_per_req_delivery_cur0; 1525 out->ttu_regs.refcyc_per_req_delivery_cur1 = disp_ttu_regs->refcyc_per_req_delivery_cur1; 1526 out->ttu_regs.refcyc_per_req_delivery_pre_l = disp_ttu_regs->refcyc_per_req_delivery_pre_l; 1527 out->ttu_regs.refcyc_per_req_delivery_pre_c = disp_ttu_regs->refcyc_per_req_delivery_pre_c; 1528 out->ttu_regs.refcyc_per_req_delivery_pre_cur0 = disp_ttu_regs->refcyc_per_req_delivery_pre_cur0; 1529 out->ttu_regs.refcyc_per_req_delivery_pre_cur1 = disp_ttu_regs->refcyc_per_req_delivery_pre_cur1; 1530 out->ttu_regs.qos_level_fixed_l = disp_ttu_regs->qos_level_fixed_l; 1531 out->ttu_regs.qos_level_fixed_c = disp_ttu_regs->qos_level_fixed_c; 1532 out->ttu_regs.qos_level_fixed_cur0 = disp_ttu_regs->qos_level_fixed_cur0; 1533 out->ttu_regs.qos_level_fixed_cur1 = disp_ttu_regs->qos_level_fixed_cur1; 1534 out->ttu_regs.qos_ramp_disable_l = disp_ttu_regs->qos_ramp_disable_l; 1535 out->ttu_regs.qos_ramp_disable_c = disp_ttu_regs->qos_ramp_disable_c; 1536 out->ttu_regs.qos_ramp_disable_cur0 = disp_ttu_regs->qos_ramp_disable_cur0; 1537 out->ttu_regs.qos_ramp_disable_cur1 = disp_ttu_regs->qos_ramp_disable_cur1; 1538 } 1539