1 // SPDX-License-Identifier: MIT
3 * Copyright 2021 Advanced Micro Devices, Inc.
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
29 #include "dc_link_dp.h"
31 #include "dcn20/dcn20_resource.h"
32 #include "dcn21/dcn21_resource.h"
34 #include "dcn20_fpu.h"
36 #define DC_LOGGER_INIT(logger)
39 #define MAX(X, Y) ((X) > (Y) ? (X) : (Y))
42 #define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
46 #define LPDDR_MEM_RETRAIN_LATENCY 4.977 /* Number obtained from LPDDR4 Training Counter Requirement doc */
49 * DOC: DCN2x FPU manipulation Overview
51 * The DCN architecture relies on FPU operations, which require special
52 * compilation flags and the use of kernel_fpu_begin/end functions; ideally, we
53 * want to avoid spreading FPU access across multiple files. With this idea in
54 * mind, this file aims to centralize all DCN20 and DCN2.1 (DCN2x) functions
55 * that require FPU access in a single place. Code in this file follows the
56 * following code pattern:
58 * 1. Functions that use FPU operations should be isolated in static functions.
59 * 2. The FPU functions should have the noinline attribute to ensure anything
60 * that deals with FP register is contained within this call.
61 * 3. All function that needs to be accessed outside this file requires a
62 * public interface that not uses any FPU reference.
63 * 4. Developers **must not** use DC_FP_START/END in this file, but they need
64 * to ensure that the caller invokes it before access any function available
65 * in this file. For this reason, public functions in this file must invoke
66 * dc_assert_fp_enabled();
68 * Let's expand a little bit more the idea in the code pattern. To fully
69 * isolate FPU operations in a single place, we must avoid situations where
70 * compilers spill FP values to registers due to FP enable in a specific C
71 * file. Note that even if we isolate all FPU functions in a single file and
72 * call its interface from other files, the compiler might enable the use of
73 * FPU before we call DC_FP_START. Nevertheless, it is the programmer's
74 * responsibility to invoke DC_FP_START/END in the correct place. To highlight
75 * situations where developers forgot to use the FP protection before calling
76 * the DC FPU interface functions, we introduce a helper that checks if the
77 * function is invoked under FP protection. If not, it will trigger a kernel
81 struct _vcs_dpi_ip_params_st dcn2_0_ip = {
85 .gpuvm_max_page_table_levels = 4,
86 .hostvm_max_page_table_levels = 4,
87 .hostvm_cached_page_table_levels = 0,
88 .pte_group_size_bytes = 2048,
90 .rob_buffer_size_kbytes = 168,
91 .det_buffer_size_kbytes = 164,
92 .dpte_buffer_size_in_pte_reqs_luma = 84,
93 .pde_proc_buffer_size_64k_reqs = 48,
94 .dpp_output_buffer_pixels = 2560,
95 .opp_output_buffer_lines = 1,
96 .pixel_chunk_size_kbytes = 8,
97 .pte_chunk_size_kbytes = 2,
98 .meta_chunk_size_kbytes = 2,
99 .writeback_chunk_size_kbytes = 2,
100 .line_buffer_size_bits = 789504,
101 .is_line_buffer_bpp_fixed = 0,
102 .line_buffer_fixed_bpp = 0,
103 .dcc_supported = true,
104 .max_line_buffer_lines = 12,
105 .writeback_luma_buffer_size_kbytes = 12,
106 .writeback_chroma_buffer_size_kbytes = 8,
107 .writeback_chroma_line_buffer_width_pixels = 4,
108 .writeback_max_hscl_ratio = 1,
109 .writeback_max_vscl_ratio = 1,
110 .writeback_min_hscl_ratio = 1,
111 .writeback_min_vscl_ratio = 1,
112 .writeback_max_hscl_taps = 12,
113 .writeback_max_vscl_taps = 12,
114 .writeback_line_buffer_luma_buffer_size = 0,
115 .writeback_line_buffer_chroma_buffer_size = 14643,
116 .cursor_buffer_size = 8,
117 .cursor_chunk_size = 2,
121 .max_dchub_pscl_bw_pix_per_clk = 4,
122 .max_pscl_lb_bw_pix_per_clk = 2,
123 .max_lb_vscl_bw_pix_per_clk = 4,
124 .max_vscl_hscl_bw_pix_per_clk = 4,
131 .dispclk_ramp_margin_percent = 1,
132 .underscan_factor = 1.10,
133 .min_vblank_lines = 32, //
134 .dppclk_delay_subtotal = 77, //
135 .dppclk_delay_scl_lb_only = 16,
136 .dppclk_delay_scl = 50,
137 .dppclk_delay_cnvc_formatter = 8,
138 .dppclk_delay_cnvc_cursor = 6,
139 .dispclk_delay_subtotal = 87, //
140 .dcfclk_cstate_latency = 10, // SRExitTime
141 .max_inter_dcn_tile_repeaters = 8,
142 .xfc_supported = true,
143 .xfc_fill_bw_overhead_percent = 10.0,
144 .xfc_fill_constant_bytes = 0,
145 .number_of_cursors = 1,
148 struct _vcs_dpi_ip_params_st dcn2_0_nv14_ip = {
152 .gpuvm_max_page_table_levels = 4,
153 .hostvm_max_page_table_levels = 4,
154 .hostvm_cached_page_table_levels = 0,
156 .rob_buffer_size_kbytes = 168,
157 .det_buffer_size_kbytes = 164,
158 .dpte_buffer_size_in_pte_reqs_luma = 84,
159 .dpte_buffer_size_in_pte_reqs_chroma = 42,//todo
160 .dpp_output_buffer_pixels = 2560,
161 .opp_output_buffer_lines = 1,
162 .pixel_chunk_size_kbytes = 8,
164 .max_page_table_levels = 4,
165 .pte_chunk_size_kbytes = 2,
166 .meta_chunk_size_kbytes = 2,
167 .writeback_chunk_size_kbytes = 2,
168 .line_buffer_size_bits = 789504,
169 .is_line_buffer_bpp_fixed = 0,
170 .line_buffer_fixed_bpp = 0,
171 .dcc_supported = true,
172 .max_line_buffer_lines = 12,
173 .writeback_luma_buffer_size_kbytes = 12,
174 .writeback_chroma_buffer_size_kbytes = 8,
175 .writeback_chroma_line_buffer_width_pixels = 4,
176 .writeback_max_hscl_ratio = 1,
177 .writeback_max_vscl_ratio = 1,
178 .writeback_min_hscl_ratio = 1,
179 .writeback_min_vscl_ratio = 1,
180 .writeback_max_hscl_taps = 12,
181 .writeback_max_vscl_taps = 12,
182 .writeback_line_buffer_luma_buffer_size = 0,
183 .writeback_line_buffer_chroma_buffer_size = 14643,
184 .cursor_buffer_size = 8,
185 .cursor_chunk_size = 2,
189 .max_dchub_pscl_bw_pix_per_clk = 4,
190 .max_pscl_lb_bw_pix_per_clk = 2,
191 .max_lb_vscl_bw_pix_per_clk = 4,
192 .max_vscl_hscl_bw_pix_per_clk = 4,
199 .dispclk_ramp_margin_percent = 1,
200 .underscan_factor = 1.10,
201 .min_vblank_lines = 32, //
202 .dppclk_delay_subtotal = 77, //
203 .dppclk_delay_scl_lb_only = 16,
204 .dppclk_delay_scl = 50,
205 .dppclk_delay_cnvc_formatter = 8,
206 .dppclk_delay_cnvc_cursor = 6,
207 .dispclk_delay_subtotal = 87, //
208 .dcfclk_cstate_latency = 10, // SRExitTime
209 .max_inter_dcn_tile_repeaters = 8,
210 .xfc_supported = true,
211 .xfc_fill_bw_overhead_percent = 10.0,
212 .xfc_fill_constant_bytes = 0,
214 .number_of_cursors = 1,
217 struct _vcs_dpi_soc_bounding_box_st dcn2_0_soc = {
218 /* Defaults that get patched on driver load from firmware. */
223 .fabricclk_mhz = 560.0,
224 .dispclk_mhz = 513.0,
229 .dram_speed_mts = 8960.0,
234 .fabricclk_mhz = 694.0,
235 .dispclk_mhz = 642.0,
240 .dram_speed_mts = 11104.0,
245 .fabricclk_mhz = 875.0,
246 .dispclk_mhz = 734.0,
251 .dram_speed_mts = 14000.0,
255 .dcfclk_mhz = 1000.0,
256 .fabricclk_mhz = 1000.0,
257 .dispclk_mhz = 1100.0,
258 .dppclk_mhz = 1100.0,
260 .socclk_mhz = 1000.0,
262 .dram_speed_mts = 16000.0,
266 .dcfclk_mhz = 1200.0,
267 .fabricclk_mhz = 1200.0,
268 .dispclk_mhz = 1284.0,
269 .dppclk_mhz = 1284.0,
271 .socclk_mhz = 1200.0,
273 .dram_speed_mts = 16000.0,
275 /*Extra state, no dispclk ramping*/
278 .dcfclk_mhz = 1200.0,
279 .fabricclk_mhz = 1200.0,
280 .dispclk_mhz = 1284.0,
281 .dppclk_mhz = 1284.0,
283 .socclk_mhz = 1200.0,
285 .dram_speed_mts = 16000.0,
289 .sr_exit_time_us = 8.6,
290 .sr_enter_plus_exit_time_us = 10.9,
291 .urgent_latency_us = 4.0,
292 .urgent_latency_pixel_data_only_us = 4.0,
293 .urgent_latency_pixel_mixed_with_vm_data_us = 4.0,
294 .urgent_latency_vm_data_only_us = 4.0,
295 .urgent_out_of_order_return_per_channel_pixel_only_bytes = 4096,
296 .urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 4096,
297 .urgent_out_of_order_return_per_channel_vm_only_bytes = 4096,
298 .pct_ideal_dram_sdp_bw_after_urgent_pixel_only = 40.0,
299 .pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm = 40.0,
300 .pct_ideal_dram_sdp_bw_after_urgent_vm_only = 40.0,
301 .max_avg_sdp_bw_use_normal_percent = 40.0,
302 .max_avg_dram_bw_use_normal_percent = 40.0,
303 .writeback_latency_us = 12.0,
304 .ideal_dram_bw_after_urgent_percent = 40.0,
305 .max_request_size_bytes = 256,
306 .dram_channel_width_bytes = 2,
307 .fabric_datapath_to_dcn_data_return_bytes = 64,
308 .dcn_downspread_percent = 0.5,
309 .downspread_percent = 0.38,
310 .dram_page_open_time_ns = 50.0,
311 .dram_rw_turnaround_time_ns = 17.5,
312 .dram_return_buffer_per_channel_bytes = 8192,
313 .round_trip_ping_latency_dcfclk_cycles = 131,
314 .urgent_out_of_order_return_per_channel_bytes = 256,
315 .channel_interleave_bytes = 256,
318 .vmm_page_size_bytes = 4096,
319 .dram_clock_change_latency_us = 404.0,
320 .dummy_pstate_latency_us = 5.0,
321 .writeback_dram_clock_change_latency_us = 23.0,
322 .return_bus_width_bytes = 64,
323 .dispclk_dppclk_vco_speed_mhz = 3850,
324 .xfc_bus_transport_time_us = 20,
325 .xfc_xbuf_latency_tolerance_us = 4,
326 .use_urgent_burst_bw = 0
329 struct _vcs_dpi_soc_bounding_box_st dcn2_0_nv14_soc = {
334 .fabricclk_mhz = 560.0,
335 .dispclk_mhz = 513.0,
340 .dram_speed_mts = 8960.0,
345 .fabricclk_mhz = 694.0,
346 .dispclk_mhz = 642.0,
351 .dram_speed_mts = 11104.0,
356 .fabricclk_mhz = 875.0,
357 .dispclk_mhz = 734.0,
362 .dram_speed_mts = 14000.0,
366 .dcfclk_mhz = 1000.0,
367 .fabricclk_mhz = 1000.0,
368 .dispclk_mhz = 1100.0,
369 .dppclk_mhz = 1100.0,
371 .socclk_mhz = 1000.0,
373 .dram_speed_mts = 16000.0,
377 .dcfclk_mhz = 1200.0,
378 .fabricclk_mhz = 1200.0,
379 .dispclk_mhz = 1284.0,
380 .dppclk_mhz = 1284.0,
382 .socclk_mhz = 1200.0,
384 .dram_speed_mts = 16000.0,
386 /*Extra state, no dispclk ramping*/
389 .dcfclk_mhz = 1200.0,
390 .fabricclk_mhz = 1200.0,
391 .dispclk_mhz = 1284.0,
392 .dppclk_mhz = 1284.0,
394 .socclk_mhz = 1200.0,
396 .dram_speed_mts = 16000.0,
400 .sr_exit_time_us = 11.6,
401 .sr_enter_plus_exit_time_us = 13.9,
402 .urgent_latency_us = 4.0,
403 .urgent_latency_pixel_data_only_us = 4.0,
404 .urgent_latency_pixel_mixed_with_vm_data_us = 4.0,
405 .urgent_latency_vm_data_only_us = 4.0,
406 .urgent_out_of_order_return_per_channel_pixel_only_bytes = 4096,
407 .urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 4096,
408 .urgent_out_of_order_return_per_channel_vm_only_bytes = 4096,
409 .pct_ideal_dram_sdp_bw_after_urgent_pixel_only = 40.0,
410 .pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm = 40.0,
411 .pct_ideal_dram_sdp_bw_after_urgent_vm_only = 40.0,
412 .max_avg_sdp_bw_use_normal_percent = 40.0,
413 .max_avg_dram_bw_use_normal_percent = 40.0,
414 .writeback_latency_us = 12.0,
415 .ideal_dram_bw_after_urgent_percent = 40.0,
416 .max_request_size_bytes = 256,
417 .dram_channel_width_bytes = 2,
418 .fabric_datapath_to_dcn_data_return_bytes = 64,
419 .dcn_downspread_percent = 0.5,
420 .downspread_percent = 0.38,
421 .dram_page_open_time_ns = 50.0,
422 .dram_rw_turnaround_time_ns = 17.5,
423 .dram_return_buffer_per_channel_bytes = 8192,
424 .round_trip_ping_latency_dcfclk_cycles = 131,
425 .urgent_out_of_order_return_per_channel_bytes = 256,
426 .channel_interleave_bytes = 256,
429 .vmm_page_size_bytes = 4096,
430 .dram_clock_change_latency_us = 404.0,
431 .dummy_pstate_latency_us = 5.0,
432 .writeback_dram_clock_change_latency_us = 23.0,
433 .return_bus_width_bytes = 64,
434 .dispclk_dppclk_vco_speed_mhz = 3850,
435 .xfc_bus_transport_time_us = 20,
436 .xfc_xbuf_latency_tolerance_us = 4,
437 .use_urgent_burst_bw = 0
440 struct _vcs_dpi_soc_bounding_box_st dcn2_0_nv12_soc = { 0 };
442 struct _vcs_dpi_ip_params_st dcn2_1_ip = {
446 .gpuvm_max_page_table_levels = 1,
447 .hostvm_max_page_table_levels = 4,
448 .hostvm_cached_page_table_levels = 2,
450 .rob_buffer_size_kbytes = 168,
451 .det_buffer_size_kbytes = 164,
452 .dpte_buffer_size_in_pte_reqs_luma = 44,
453 .dpte_buffer_size_in_pte_reqs_chroma = 42,//todo
454 .dpp_output_buffer_pixels = 2560,
455 .opp_output_buffer_lines = 1,
456 .pixel_chunk_size_kbytes = 8,
458 .max_page_table_levels = 4,
459 .pte_chunk_size_kbytes = 2,
460 .meta_chunk_size_kbytes = 2,
461 .min_meta_chunk_size_bytes = 256,
462 .writeback_chunk_size_kbytes = 2,
463 .line_buffer_size_bits = 789504,
464 .is_line_buffer_bpp_fixed = 0,
465 .line_buffer_fixed_bpp = 0,
466 .dcc_supported = true,
467 .max_line_buffer_lines = 12,
468 .writeback_luma_buffer_size_kbytes = 12,
469 .writeback_chroma_buffer_size_kbytes = 8,
470 .writeback_chroma_line_buffer_width_pixels = 4,
471 .writeback_max_hscl_ratio = 1,
472 .writeback_max_vscl_ratio = 1,
473 .writeback_min_hscl_ratio = 1,
474 .writeback_min_vscl_ratio = 1,
475 .writeback_max_hscl_taps = 12,
476 .writeback_max_vscl_taps = 12,
477 .writeback_line_buffer_luma_buffer_size = 0,
478 .writeback_line_buffer_chroma_buffer_size = 14643,
479 .cursor_buffer_size = 8,
480 .cursor_chunk_size = 2,
484 .max_dchub_pscl_bw_pix_per_clk = 4,
485 .max_pscl_lb_bw_pix_per_clk = 2,
486 .max_lb_vscl_bw_pix_per_clk = 4,
487 .max_vscl_hscl_bw_pix_per_clk = 4,
494 .dispclk_ramp_margin_percent = 1,
495 .underscan_factor = 1.10,
496 .min_vblank_lines = 32, //
497 .dppclk_delay_subtotal = 77, //
498 .dppclk_delay_scl_lb_only = 16,
499 .dppclk_delay_scl = 50,
500 .dppclk_delay_cnvc_formatter = 8,
501 .dppclk_delay_cnvc_cursor = 6,
502 .dispclk_delay_subtotal = 87, //
503 .dcfclk_cstate_latency = 10, // SRExitTime
504 .max_inter_dcn_tile_repeaters = 8,
506 .xfc_supported = false,
507 .xfc_fill_bw_overhead_percent = 10.0,
508 .xfc_fill_constant_bytes = 0,
510 .number_of_cursors = 1,
513 struct _vcs_dpi_soc_bounding_box_st dcn2_1_soc = {
518 .fabricclk_mhz = 400.0,
519 .dispclk_mhz = 600.0,
520 .dppclk_mhz = 400.00,
523 .dscclk_mhz = 205.67,
524 .dram_speed_mts = 1600.0,
528 .dcfclk_mhz = 464.52,
529 .fabricclk_mhz = 800.0,
530 .dispclk_mhz = 654.55,
531 .dppclk_mhz = 626.09,
534 .dscclk_mhz = 205.67,
535 .dram_speed_mts = 1600.0,
539 .dcfclk_mhz = 514.29,
540 .fabricclk_mhz = 933.0,
541 .dispclk_mhz = 757.89,
542 .dppclk_mhz = 685.71,
545 .dscclk_mhz = 287.67,
546 .dram_speed_mts = 1866.0,
550 .dcfclk_mhz = 576.00,
551 .fabricclk_mhz = 1067.0,
552 .dispclk_mhz = 847.06,
553 .dppclk_mhz = 757.89,
556 .dscclk_mhz = 318.334,
557 .dram_speed_mts = 2134.0,
561 .dcfclk_mhz = 626.09,
562 .fabricclk_mhz = 1200.0,
563 .dispclk_mhz = 900.00,
564 .dppclk_mhz = 847.06,
568 .dram_speed_mts = 2400.0,
572 .dcfclk_mhz = 685.71,
573 .fabricclk_mhz = 1333.0,
574 .dispclk_mhz = 1028.57,
575 .dppclk_mhz = 960.00,
578 .dscclk_mhz = 287.67,
579 .dram_speed_mts = 2666.0,
583 .dcfclk_mhz = 757.89,
584 .fabricclk_mhz = 1467.0,
585 .dispclk_mhz = 1107.69,
586 .dppclk_mhz = 1028.57,
589 .dscclk_mhz = 318.334,
590 .dram_speed_mts = 3200.0,
594 .dcfclk_mhz = 847.06,
595 .fabricclk_mhz = 1600.0,
596 .dispclk_mhz = 1395.0,
597 .dppclk_mhz = 1285.00,
598 .phyclk_mhz = 1325.0,
601 .dram_speed_mts = 4266.0,
603 /*Extra state, no dispclk ramping*/
606 .dcfclk_mhz = 847.06,
607 .fabricclk_mhz = 1600.0,
608 .dispclk_mhz = 1395.0,
609 .dppclk_mhz = 1285.0,
610 .phyclk_mhz = 1325.0,
613 .dram_speed_mts = 4266.0,
618 .sr_exit_time_us = 12.5,
619 .sr_enter_plus_exit_time_us = 17.0,
620 .urgent_latency_us = 4.0,
621 .urgent_latency_pixel_data_only_us = 4.0,
622 .urgent_latency_pixel_mixed_with_vm_data_us = 4.0,
623 .urgent_latency_vm_data_only_us = 4.0,
624 .urgent_out_of_order_return_per_channel_pixel_only_bytes = 4096,
625 .urgent_out_of_order_return_per_channel_pixel_and_vm_bytes = 4096,
626 .urgent_out_of_order_return_per_channel_vm_only_bytes = 4096,
627 .pct_ideal_dram_sdp_bw_after_urgent_pixel_only = 80.0,
628 .pct_ideal_dram_sdp_bw_after_urgent_pixel_and_vm = 75.0,
629 .pct_ideal_dram_sdp_bw_after_urgent_vm_only = 40.0,
630 .max_avg_sdp_bw_use_normal_percent = 60.0,
631 .max_avg_dram_bw_use_normal_percent = 100.0,
632 .writeback_latency_us = 12.0,
633 .max_request_size_bytes = 256,
634 .dram_channel_width_bytes = 4,
635 .fabric_datapath_to_dcn_data_return_bytes = 32,
636 .dcn_downspread_percent = 0.5,
637 .downspread_percent = 0.38,
638 .dram_page_open_time_ns = 50.0,
639 .dram_rw_turnaround_time_ns = 17.5,
640 .dram_return_buffer_per_channel_bytes = 8192,
641 .round_trip_ping_latency_dcfclk_cycles = 128,
642 .urgent_out_of_order_return_per_channel_bytes = 4096,
643 .channel_interleave_bytes = 256,
646 .vmm_page_size_bytes = 4096,
647 .dram_clock_change_latency_us = 23.84,
648 .return_bus_width_bytes = 64,
649 .dispclk_dppclk_vco_speed_mhz = 3600,
650 .xfc_bus_transport_time_us = 4,
651 .xfc_xbuf_latency_tolerance_us = 4,
652 .use_urgent_burst_bw = 1,
656 struct wm_table ddr4_wm_table_gs = {
660 .wm_type = WM_TYPE_PSTATE_CHG,
661 .pstate_latency_us = 11.72,
662 .sr_exit_time_us = 7.09,
663 .sr_enter_plus_exit_time_us = 8.14,
668 .wm_type = WM_TYPE_PSTATE_CHG,
669 .pstate_latency_us = 11.72,
670 .sr_exit_time_us = 10.12,
671 .sr_enter_plus_exit_time_us = 11.48,
676 .wm_type = WM_TYPE_PSTATE_CHG,
677 .pstate_latency_us = 11.72,
678 .sr_exit_time_us = 10.12,
679 .sr_enter_plus_exit_time_us = 11.48,
684 .wm_type = WM_TYPE_PSTATE_CHG,
685 .pstate_latency_us = 11.72,
686 .sr_exit_time_us = 10.12,
687 .sr_enter_plus_exit_time_us = 11.48,
693 struct wm_table lpddr4_wm_table_gs = {
697 .wm_type = WM_TYPE_PSTATE_CHG,
698 .pstate_latency_us = 11.65333,
699 .sr_exit_time_us = 5.32,
700 .sr_enter_plus_exit_time_us = 6.38,
705 .wm_type = WM_TYPE_PSTATE_CHG,
706 .pstate_latency_us = 11.65333,
707 .sr_exit_time_us = 9.82,
708 .sr_enter_plus_exit_time_us = 11.196,
713 .wm_type = WM_TYPE_PSTATE_CHG,
714 .pstate_latency_us = 11.65333,
715 .sr_exit_time_us = 9.89,
716 .sr_enter_plus_exit_time_us = 11.24,
721 .wm_type = WM_TYPE_PSTATE_CHG,
722 .pstate_latency_us = 11.65333,
723 .sr_exit_time_us = 9.748,
724 .sr_enter_plus_exit_time_us = 11.102,
730 struct wm_table lpddr4_wm_table_with_disabled_ppt = {
734 .wm_type = WM_TYPE_PSTATE_CHG,
735 .pstate_latency_us = 11.65333,
736 .sr_exit_time_us = 8.32,
737 .sr_enter_plus_exit_time_us = 9.38,
742 .wm_type = WM_TYPE_PSTATE_CHG,
743 .pstate_latency_us = 11.65333,
744 .sr_exit_time_us = 9.82,
745 .sr_enter_plus_exit_time_us = 11.196,
750 .wm_type = WM_TYPE_PSTATE_CHG,
751 .pstate_latency_us = 11.65333,
752 .sr_exit_time_us = 9.89,
753 .sr_enter_plus_exit_time_us = 11.24,
758 .wm_type = WM_TYPE_PSTATE_CHG,
759 .pstate_latency_us = 11.65333,
760 .sr_exit_time_us = 9.748,
761 .sr_enter_plus_exit_time_us = 11.102,
767 struct wm_table ddr4_wm_table_rn = {
771 .wm_type = WM_TYPE_PSTATE_CHG,
772 .pstate_latency_us = 11.72,
773 .sr_exit_time_us = 11.90,
774 .sr_enter_plus_exit_time_us = 12.80,
779 .wm_type = WM_TYPE_PSTATE_CHG,
780 .pstate_latency_us = 11.72,
781 .sr_exit_time_us = 13.18,
782 .sr_enter_plus_exit_time_us = 14.30,
787 .wm_type = WM_TYPE_PSTATE_CHG,
788 .pstate_latency_us = 11.72,
789 .sr_exit_time_us = 13.18,
790 .sr_enter_plus_exit_time_us = 14.30,
795 .wm_type = WM_TYPE_PSTATE_CHG,
796 .pstate_latency_us = 11.72,
797 .sr_exit_time_us = 13.18,
798 .sr_enter_plus_exit_time_us = 14.30,
804 struct wm_table ddr4_1R_wm_table_rn = {
808 .wm_type = WM_TYPE_PSTATE_CHG,
809 .pstate_latency_us = 11.72,
810 .sr_exit_time_us = 13.90,
811 .sr_enter_plus_exit_time_us = 14.80,
816 .wm_type = WM_TYPE_PSTATE_CHG,
817 .pstate_latency_us = 11.72,
818 .sr_exit_time_us = 13.90,
819 .sr_enter_plus_exit_time_us = 14.80,
824 .wm_type = WM_TYPE_PSTATE_CHG,
825 .pstate_latency_us = 11.72,
826 .sr_exit_time_us = 13.90,
827 .sr_enter_plus_exit_time_us = 14.80,
832 .wm_type = WM_TYPE_PSTATE_CHG,
833 .pstate_latency_us = 11.72,
834 .sr_exit_time_us = 13.90,
835 .sr_enter_plus_exit_time_us = 14.80,
841 struct wm_table lpddr4_wm_table_rn = {
845 .wm_type = WM_TYPE_PSTATE_CHG,
846 .pstate_latency_us = 11.65333,
847 .sr_exit_time_us = 7.32,
848 .sr_enter_plus_exit_time_us = 8.38,
853 .wm_type = WM_TYPE_PSTATE_CHG,
854 .pstate_latency_us = 11.65333,
855 .sr_exit_time_us = 9.82,
856 .sr_enter_plus_exit_time_us = 11.196,
861 .wm_type = WM_TYPE_PSTATE_CHG,
862 .pstate_latency_us = 11.65333,
863 .sr_exit_time_us = 9.89,
864 .sr_enter_plus_exit_time_us = 11.24,
869 .wm_type = WM_TYPE_PSTATE_CHG,
870 .pstate_latency_us = 11.65333,
871 .sr_exit_time_us = 9.748,
872 .sr_enter_plus_exit_time_us = 11.102,
878 void dcn20_populate_dml_writeback_from_context(struct dc *dc,
879 struct resource_context *res_ctx,
880 display_e2e_pipe_params_st *pipes)
884 dc_assert_fp_enabled();
886 for (i = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; i++) {
887 struct dc_writeback_info *wb_info = &res_ctx->pipe_ctx[i].stream->writeback_info[0];
889 if (!res_ctx->pipe_ctx[i].stream)
892 /* Set writeback information */
893 pipes[pipe_cnt].dout.wb_enable = (wb_info->wb_enabled == true) ? 1 : 0;
894 pipes[pipe_cnt].dout.num_active_wb++;
895 pipes[pipe_cnt].dout.wb.wb_src_height = wb_info->dwb_params.cnv_params.crop_height;
896 pipes[pipe_cnt].dout.wb.wb_src_width = wb_info->dwb_params.cnv_params.crop_width;
897 pipes[pipe_cnt].dout.wb.wb_dst_width = wb_info->dwb_params.dest_width;
898 pipes[pipe_cnt].dout.wb.wb_dst_height = wb_info->dwb_params.dest_height;
899 pipes[pipe_cnt].dout.wb.wb_htaps_luma = 1;
900 pipes[pipe_cnt].dout.wb.wb_vtaps_luma = 1;
901 pipes[pipe_cnt].dout.wb.wb_htaps_chroma = wb_info->dwb_params.scaler_taps.h_taps_c;
902 pipes[pipe_cnt].dout.wb.wb_vtaps_chroma = wb_info->dwb_params.scaler_taps.v_taps_c;
903 pipes[pipe_cnt].dout.wb.wb_hratio = 1.0;
904 pipes[pipe_cnt].dout.wb.wb_vratio = 1.0;
905 if (wb_info->dwb_params.out_format == dwb_scaler_mode_yuv420) {
906 if (wb_info->dwb_params.output_depth == DWB_OUTPUT_PIXEL_DEPTH_8BPC)
907 pipes[pipe_cnt].dout.wb.wb_pixel_format = dm_420_8;
909 pipes[pipe_cnt].dout.wb.wb_pixel_format = dm_420_10;
911 pipes[pipe_cnt].dout.wb.wb_pixel_format = dm_444_32;
918 void dcn20_fpu_set_wb_arb_params(struct mcif_arb_params *wb_arb_params,
919 struct dc_state *context,
920 display_e2e_pipe_params_st *pipes,
925 dc_assert_fp_enabled();
927 for (k = 0; k < sizeof(wb_arb_params->cli_watermark)/sizeof(wb_arb_params->cli_watermark[0]); k++) {
928 wb_arb_params->cli_watermark[k] = get_wm_writeback_urgent(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
929 wb_arb_params->pstate_watermark[k] = get_wm_writeback_dram_clock_change(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
931 wb_arb_params->time_per_pixel = 16.0 * 1000 / (context->res_ctx.pipe_ctx[i].stream->phy_pix_clk / 1000); /* 4 bit fraction, ms */
934 static bool is_dtbclk_required(struct dc *dc, struct dc_state *context)
937 for (i = 0; i < dc->res_pool->pipe_count; i++) {
938 if (!context->res_ctx.pipe_ctx[i].stream)
940 if (is_dp_128b_132b_signal(&context->res_ctx.pipe_ctx[i]))
946 static enum dcn_zstate_support_state decide_zstate_support(struct dc *dc, struct dc_state *context)
950 unsigned int optimized_min_dst_y_next_start_us;
953 optimized_min_dst_y_next_start_us = 0;
954 for (i = 0; i < dc->res_pool->pipe_count; i++) {
955 if (context->res_ctx.pipe_ctx[i].plane_state)
960 * Z9 and Z10 allowed cases:
961 * 1. 0 Planes enabled
962 * 2. single eDP, on link 0, 1 plane and stutter period > 5ms
964 * 1. single eDP, on link 0, 1 plane and stutter period >= 5ms
965 * Zstate not allowed cases:
968 if (plane_count == 0)
969 return DCN_ZSTATE_SUPPORT_ALLOW;
970 else if (context->stream_count == 1 && context->streams[0]->signal == SIGNAL_TYPE_EDP) {
971 struct dc_link *link = context->streams[0]->sink->link;
972 struct dc_stream_status *stream_status = &context->stream_status[0];
974 if (dc_extended_blank_supported(dc)) {
975 for (i = 0; i < dc->res_pool->pipe_count; i++) {
976 if (context->res_ctx.pipe_ctx[i].stream == context->streams[0]
977 && context->res_ctx.pipe_ctx[i].stream->adjust.v_total_min == context->res_ctx.pipe_ctx[i].stream->adjust.v_total_max
978 && context->res_ctx.pipe_ctx[i].stream->adjust.v_total_min > context->res_ctx.pipe_ctx[i].stream->timing.v_total) {
979 optimized_min_dst_y_next_start_us =
980 context->res_ctx.pipe_ctx[i].dlg_regs.optimized_min_dst_y_next_start_us;
985 /* zstate only supported on PWRSEQ0 and when there's <2 planes*/
986 if (link->link_index != 0 || stream_status->plane_count > 1)
987 return DCN_ZSTATE_SUPPORT_DISALLOW;
989 if (context->bw_ctx.dml.vba.StutterPeriod > 5000.0 || optimized_min_dst_y_next_start_us > 5000)
990 return DCN_ZSTATE_SUPPORT_ALLOW;
991 else if (link->psr_settings.psr_version == DC_PSR_VERSION_1 && !dc->debug.disable_psr)
992 return DCN_ZSTATE_SUPPORT_ALLOW_Z10_ONLY;
994 return DCN_ZSTATE_SUPPORT_DISALLOW;
996 return DCN_ZSTATE_SUPPORT_DISALLOW;
999 void dcn20_calculate_dlg_params(
1000 struct dc *dc, struct dc_state *context,
1001 display_e2e_pipe_params_st *pipes,
1007 dc_assert_fp_enabled();
1009 /* Writeback MCIF_WB arbitration parameters */
1010 dc->res_pool->funcs->set_mcif_arb_params(dc, context, pipes, pipe_cnt);
1012 context->bw_ctx.bw.dcn.clk.dispclk_khz = context->bw_ctx.dml.vba.DISPCLK * 1000;
1013 context->bw_ctx.bw.dcn.clk.dcfclk_khz = context->bw_ctx.dml.vba.DCFCLK * 1000;
1014 context->bw_ctx.bw.dcn.clk.socclk_khz = context->bw_ctx.dml.vba.SOCCLK * 1000;
1015 context->bw_ctx.bw.dcn.clk.dramclk_khz = context->bw_ctx.dml.vba.DRAMSpeed * 1000 / 16;
1017 if (dc->debug.min_dram_clk_khz > context->bw_ctx.bw.dcn.clk.dramclk_khz)
1018 context->bw_ctx.bw.dcn.clk.dramclk_khz = dc->debug.min_dram_clk_khz;
1020 context->bw_ctx.bw.dcn.clk.dcfclk_deep_sleep_khz = context->bw_ctx.dml.vba.DCFCLKDeepSleep * 1000;
1021 context->bw_ctx.bw.dcn.clk.fclk_khz = context->bw_ctx.dml.vba.FabricClock * 1000;
1022 context->bw_ctx.bw.dcn.clk.p_state_change_support =
1023 context->bw_ctx.dml.vba.DRAMClockChangeSupport[vlevel][context->bw_ctx.dml.vba.maxMpcComb]
1024 != dm_dram_clock_change_unsupported;
1026 /* Pstate change might not be supported by hardware, but it might be
1027 * possible with firmware driven vertical blank stretching.
1029 context->bw_ctx.bw.dcn.clk.p_state_change_support |= context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching;
1031 context->bw_ctx.bw.dcn.clk.dppclk_khz = 0;
1033 context->bw_ctx.bw.dcn.clk.dtbclk_en = is_dtbclk_required(dc, context);
1035 if (context->bw_ctx.bw.dcn.clk.dispclk_khz < dc->debug.min_disp_clk_khz)
1036 context->bw_ctx.bw.dcn.clk.dispclk_khz = dc->debug.min_disp_clk_khz;
1038 for (i = 0, pipe_idx = 0; i < dc->res_pool->pipe_count; i++) {
1039 if (!context->res_ctx.pipe_ctx[i].stream)
1041 pipes[pipe_idx].pipe.dest.vstartup_start = get_vstartup(&context->bw_ctx.dml, pipes, pipe_cnt, pipe_idx);
1042 pipes[pipe_idx].pipe.dest.vupdate_offset = get_vupdate_offset(&context->bw_ctx.dml, pipes, pipe_cnt, pipe_idx);
1043 pipes[pipe_idx].pipe.dest.vupdate_width = get_vupdate_width(&context->bw_ctx.dml, pipes, pipe_cnt, pipe_idx);
1044 pipes[pipe_idx].pipe.dest.vready_offset = get_vready_offset(&context->bw_ctx.dml, pipes, pipe_cnt, pipe_idx);
1045 if (context->res_ctx.pipe_ctx[i].stream->mall_stream_config.type == SUBVP_PHANTOM) {
1046 // Phantom pipe requires that DET_SIZE = 0 and no unbounded requests
1047 context->res_ctx.pipe_ctx[i].det_buffer_size_kb = 0;
1048 context->res_ctx.pipe_ctx[i].unbounded_req = false;
1050 context->res_ctx.pipe_ctx[i].det_buffer_size_kb = context->bw_ctx.dml.ip.det_buffer_size_kbytes;
1051 context->res_ctx.pipe_ctx[i].unbounded_req = pipes[pipe_idx].pipe.src.unbounded_req_mode;
1053 if (context->bw_ctx.bw.dcn.clk.dppclk_khz < pipes[pipe_idx].clks_cfg.dppclk_mhz * 1000)
1054 context->bw_ctx.bw.dcn.clk.dppclk_khz = pipes[pipe_idx].clks_cfg.dppclk_mhz * 1000;
1055 context->res_ctx.pipe_ctx[i].plane_res.bw.dppclk_khz =
1056 pipes[pipe_idx].clks_cfg.dppclk_mhz * 1000;
1057 context->res_ctx.pipe_ctx[i].pipe_dlg_param = pipes[pipe_idx].pipe.dest;
1060 /*save a original dppclock copy*/
1061 context->bw_ctx.bw.dcn.clk.bw_dppclk_khz = context->bw_ctx.bw.dcn.clk.dppclk_khz;
1062 context->bw_ctx.bw.dcn.clk.bw_dispclk_khz = context->bw_ctx.bw.dcn.clk.dispclk_khz;
1063 context->bw_ctx.bw.dcn.clk.max_supported_dppclk_khz = context->bw_ctx.dml.soc.clock_limits[vlevel].dppclk_mhz * 1000;
1064 context->bw_ctx.bw.dcn.clk.max_supported_dispclk_khz = context->bw_ctx.dml.soc.clock_limits[vlevel].dispclk_mhz * 1000;
1066 context->bw_ctx.bw.dcn.compbuf_size_kb = context->bw_ctx.dml.ip.config_return_buffer_size_in_kbytes
1067 - context->bw_ctx.dml.ip.det_buffer_size_kbytes * pipe_idx;
1069 for (i = 0, pipe_idx = 0; i < dc->res_pool->pipe_count; i++) {
1070 bool cstate_en = context->bw_ctx.dml.vba.PrefetchMode[vlevel][context->bw_ctx.dml.vba.maxMpcComb] != 2;
1072 if (!context->res_ctx.pipe_ctx[i].stream)
1075 if (dc->ctx->dce_version == DCN_VERSION_2_01)
1078 context->bw_ctx.dml.funcs.rq_dlg_get_dlg_reg(&context->bw_ctx.dml,
1079 &context->res_ctx.pipe_ctx[i].dlg_regs,
1080 &context->res_ctx.pipe_ctx[i].ttu_regs,
1085 context->bw_ctx.bw.dcn.clk.p_state_change_support,
1086 false, false, true);
1088 context->bw_ctx.dml.funcs.rq_dlg_get_rq_reg(&context->bw_ctx.dml,
1089 &context->res_ctx.pipe_ctx[i].rq_regs,
1090 &pipes[pipe_idx].pipe);
1093 context->bw_ctx.bw.dcn.clk.zstate_support = decide_zstate_support(dc, context);
1096 static void swizzle_to_dml_params(
1097 enum swizzle_mode_values swizzle,
1098 unsigned int *sw_mode)
1102 *sw_mode = dm_sw_linear;
1105 *sw_mode = dm_sw_4kb_s;
1108 *sw_mode = dm_sw_4kb_s_x;
1111 *sw_mode = dm_sw_4kb_d;
1114 *sw_mode = dm_sw_4kb_d_x;
1117 *sw_mode = dm_sw_64kb_s;
1119 case DC_SW_64KB_S_X:
1120 *sw_mode = dm_sw_64kb_s_x;
1122 case DC_SW_64KB_S_T:
1123 *sw_mode = dm_sw_64kb_s_t;
1126 *sw_mode = dm_sw_64kb_d;
1128 case DC_SW_64KB_D_X:
1129 *sw_mode = dm_sw_64kb_d_x;
1131 case DC_SW_64KB_D_T:
1132 *sw_mode = dm_sw_64kb_d_t;
1134 case DC_SW_64KB_R_X:
1135 *sw_mode = dm_sw_64kb_r_x;
1138 *sw_mode = dm_sw_var_s;
1141 *sw_mode = dm_sw_var_s_x;
1144 *sw_mode = dm_sw_var_d;
1147 *sw_mode = dm_sw_var_d_x;
1150 *sw_mode = dm_sw_var_r_x;
1153 ASSERT(0); /* Not supported */
1158 int dcn20_populate_dml_pipes_from_context(
1160 struct dc_state *context,
1161 display_e2e_pipe_params_st *pipes,
1165 bool synchronized_vblank = true;
1166 struct resource_context *res_ctx = &context->res_ctx;
1168 dc_assert_fp_enabled();
1170 for (i = 0, pipe_cnt = -1; i < dc->res_pool->pipe_count; i++) {
1171 if (!res_ctx->pipe_ctx[i].stream)
1179 if (res_ctx->pipe_ctx[pipe_cnt].stream == res_ctx->pipe_ctx[i].stream)
1182 if (dc->debug.disable_timing_sync ||
1183 (!resource_are_streams_timing_synchronizable(
1184 res_ctx->pipe_ctx[pipe_cnt].stream,
1185 res_ctx->pipe_ctx[i].stream) &&
1186 !resource_are_vblanks_synchronizable(
1187 res_ctx->pipe_ctx[pipe_cnt].stream,
1188 res_ctx->pipe_ctx[i].stream))) {
1189 synchronized_vblank = false;
1194 for (i = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; i++) {
1195 struct dc_crtc_timing *timing = &res_ctx->pipe_ctx[i].stream->timing;
1196 unsigned int v_total;
1197 unsigned int front_porch;
1199 struct audio_check aud_check = {0};
1201 if (!res_ctx->pipe_ctx[i].stream)
1204 v_total = timing->v_total;
1205 front_porch = timing->v_front_porch;
1208 pipes[pipe_cnt].pipe.src.dynamic_metadata_enable = 0;
1209 pipes[pipe_cnt].pipe.src.dcc = 0;
1210 pipes[pipe_cnt].pipe.src.vm = 0;*/
1212 pipes[pipe_cnt].clks_cfg.refclk_mhz = dc->res_pool->ref_clocks.dchub_ref_clock_inKhz / 1000.0;
1214 pipes[pipe_cnt].dout.dsc_enable = res_ctx->pipe_ctx[i].stream->timing.flags.DSC;
1215 /* todo: rotation?*/
1216 pipes[pipe_cnt].dout.dsc_slices = res_ctx->pipe_ctx[i].stream->timing.dsc_cfg.num_slices_h;
1217 if (res_ctx->pipe_ctx[i].stream->use_dynamic_meta) {
1218 pipes[pipe_cnt].pipe.src.dynamic_metadata_enable = true;
1220 pipes[pipe_cnt].pipe.src.dynamic_metadata_lines_before_active =
1221 (v_total - timing->v_addressable
1222 - timing->v_border_top - timing->v_border_bottom) / 2;
1223 /* 36 bytes dp, 32 hdmi */
1224 pipes[pipe_cnt].pipe.src.dynamic_metadata_xmit_bytes =
1225 dc_is_dp_signal(res_ctx->pipe_ctx[i].stream->signal) ? 36 : 32;
1227 pipes[pipe_cnt].pipe.src.dcc = false;
1228 pipes[pipe_cnt].pipe.src.dcc_rate = 1;
1229 pipes[pipe_cnt].pipe.dest.synchronized_vblank_all_planes = synchronized_vblank;
1230 pipes[pipe_cnt].pipe.dest.hblank_start = timing->h_total - timing->h_front_porch;
1231 pipes[pipe_cnt].pipe.dest.hblank_end = pipes[pipe_cnt].pipe.dest.hblank_start
1232 - timing->h_addressable
1233 - timing->h_border_left
1234 - timing->h_border_right;
1235 pipes[pipe_cnt].pipe.dest.vblank_start = v_total - front_porch;
1236 pipes[pipe_cnt].pipe.dest.vblank_end = pipes[pipe_cnt].pipe.dest.vblank_start
1237 - timing->v_addressable
1238 - timing->v_border_top
1239 - timing->v_border_bottom;
1240 pipes[pipe_cnt].pipe.dest.htotal = timing->h_total;
1241 pipes[pipe_cnt].pipe.dest.vtotal = v_total;
1242 pipes[pipe_cnt].pipe.dest.hactive =
1243 timing->h_addressable + timing->h_border_left + timing->h_border_right;
1244 pipes[pipe_cnt].pipe.dest.vactive =
1245 timing->v_addressable + timing->v_border_top + timing->v_border_bottom;
1246 pipes[pipe_cnt].pipe.dest.interlaced = timing->flags.INTERLACE;
1247 pipes[pipe_cnt].pipe.dest.pixel_rate_mhz = timing->pix_clk_100hz/10000.0;
1248 if (timing->timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING)
1249 pipes[pipe_cnt].pipe.dest.pixel_rate_mhz *= 2;
1250 pipes[pipe_cnt].pipe.dest.otg_inst = res_ctx->pipe_ctx[i].stream_res.tg->inst;
1251 pipes[pipe_cnt].dout.dp_lanes = 4;
1252 if (res_ctx->pipe_ctx[i].stream->link)
1253 pipes[pipe_cnt].dout.dp_rate = dm_dp_rate_na;
1254 pipes[pipe_cnt].dout.is_virtual = 0;
1255 pipes[pipe_cnt].pipe.dest.vtotal_min = res_ctx->pipe_ctx[i].stream->adjust.v_total_min;
1256 pipes[pipe_cnt].pipe.dest.vtotal_max = res_ctx->pipe_ctx[i].stream->adjust.v_total_max;
1257 switch (get_num_odm_splits(&res_ctx->pipe_ctx[i])) {
1259 pipes[pipe_cnt].pipe.dest.odm_combine = dm_odm_combine_mode_2to1;
1262 pipes[pipe_cnt].pipe.dest.odm_combine = dm_odm_combine_mode_4to1;
1265 pipes[pipe_cnt].pipe.dest.odm_combine = dm_odm_combine_mode_disabled;
1267 pipes[pipe_cnt].pipe.src.hsplit_grp = res_ctx->pipe_ctx[i].pipe_idx;
1268 if (res_ctx->pipe_ctx[i].top_pipe && res_ctx->pipe_ctx[i].top_pipe->plane_state
1269 == res_ctx->pipe_ctx[i].plane_state) {
1270 struct pipe_ctx *first_pipe = res_ctx->pipe_ctx[i].top_pipe;
1273 while (first_pipe->top_pipe && first_pipe->top_pipe->plane_state
1274 == res_ctx->pipe_ctx[i].plane_state) {
1275 first_pipe = first_pipe->top_pipe;
1278 /* Treat 4to1 mpc combine as an mpo of 2 2-to-1 combines */
1280 pipes[pipe_cnt].pipe.src.hsplit_grp = first_pipe->pipe_idx;
1281 else if (split_idx == 1)
1282 pipes[pipe_cnt].pipe.src.hsplit_grp = res_ctx->pipe_ctx[i].pipe_idx;
1283 else if (split_idx == 2)
1284 pipes[pipe_cnt].pipe.src.hsplit_grp = res_ctx->pipe_ctx[i].top_pipe->pipe_idx;
1285 } else if (res_ctx->pipe_ctx[i].prev_odm_pipe) {
1286 struct pipe_ctx *first_pipe = res_ctx->pipe_ctx[i].prev_odm_pipe;
1288 while (first_pipe->prev_odm_pipe)
1289 first_pipe = first_pipe->prev_odm_pipe;
1290 pipes[pipe_cnt].pipe.src.hsplit_grp = first_pipe->pipe_idx;
1293 switch (res_ctx->pipe_ctx[i].stream->signal) {
1294 case SIGNAL_TYPE_DISPLAY_PORT_MST:
1295 case SIGNAL_TYPE_DISPLAY_PORT:
1296 pipes[pipe_cnt].dout.output_type = dm_dp;
1298 case SIGNAL_TYPE_EDP:
1299 pipes[pipe_cnt].dout.output_type = dm_edp;
1301 case SIGNAL_TYPE_HDMI_TYPE_A:
1302 case SIGNAL_TYPE_DVI_SINGLE_LINK:
1303 case SIGNAL_TYPE_DVI_DUAL_LINK:
1304 pipes[pipe_cnt].dout.output_type = dm_hdmi;
1307 /* In case there is no signal, set dp with 4 lanes to allow max config */
1308 pipes[pipe_cnt].dout.is_virtual = 1;
1309 pipes[pipe_cnt].dout.output_type = dm_dp;
1310 pipes[pipe_cnt].dout.dp_lanes = 4;
1311 pipes[pipe_cnt].dout.dp_rate = dm_dp_rate_hbr2;
1314 switch (res_ctx->pipe_ctx[i].stream->timing.display_color_depth) {
1315 case COLOR_DEPTH_666:
1318 case COLOR_DEPTH_888:
1321 case COLOR_DEPTH_101010:
1324 case COLOR_DEPTH_121212:
1327 case COLOR_DEPTH_141414:
1330 case COLOR_DEPTH_161616:
1333 case COLOR_DEPTH_999:
1336 case COLOR_DEPTH_111111:
1344 switch (res_ctx->pipe_ctx[i].stream->timing.pixel_encoding) {
1345 case PIXEL_ENCODING_RGB:
1346 case PIXEL_ENCODING_YCBCR444:
1347 pipes[pipe_cnt].dout.output_format = dm_444;
1348 pipes[pipe_cnt].dout.output_bpp = output_bpc * 3;
1350 case PIXEL_ENCODING_YCBCR420:
1351 pipes[pipe_cnt].dout.output_format = dm_420;
1352 pipes[pipe_cnt].dout.output_bpp = (output_bpc * 3.0) / 2;
1354 case PIXEL_ENCODING_YCBCR422:
1355 if (res_ctx->pipe_ctx[i].stream->timing.flags.DSC &&
1356 !res_ctx->pipe_ctx[i].stream->timing.dsc_cfg.ycbcr422_simple)
1357 pipes[pipe_cnt].dout.output_format = dm_n422;
1359 pipes[pipe_cnt].dout.output_format = dm_s422;
1360 pipes[pipe_cnt].dout.output_bpp = output_bpc * 2;
1363 pipes[pipe_cnt].dout.output_format = dm_444;
1364 pipes[pipe_cnt].dout.output_bpp = output_bpc * 3;
1367 if (res_ctx->pipe_ctx[i].stream->timing.flags.DSC)
1368 pipes[pipe_cnt].dout.output_bpp = res_ctx->pipe_ctx[i].stream->timing.dsc_cfg.bits_per_pixel / 16.0;
1370 /* todo: default max for now, until there is logic reflecting this in dc*/
1371 pipes[pipe_cnt].dout.dsc_input_bpc = 12;
1372 /*fill up the audio sample rate (unit in kHz)*/
1373 get_audio_check(&res_ctx->pipe_ctx[i].stream->audio_info, &aud_check);
1374 pipes[pipe_cnt].dout.max_audio_sample_rate = aud_check.max_audiosample_rate / 1000;
1376 * For graphic plane, cursor number is 1, nv12 is 0
1377 * bw calculations due to cursor on/off
1379 if (res_ctx->pipe_ctx[i].plane_state &&
1380 (res_ctx->pipe_ctx[i].plane_state->address.type == PLN_ADDR_TYPE_VIDEO_PROGRESSIVE ||
1381 res_ctx->pipe_ctx[i].stream->mall_stream_config.type == SUBVP_PHANTOM))
1382 pipes[pipe_cnt].pipe.src.num_cursors = 0;
1384 pipes[pipe_cnt].pipe.src.num_cursors = dc->dml.ip.number_of_cursors;
1386 pipes[pipe_cnt].pipe.src.cur0_src_width = 256;
1387 pipes[pipe_cnt].pipe.src.cur0_bpp = dm_cur_32bit;
1389 if (!res_ctx->pipe_ctx[i].plane_state) {
1390 pipes[pipe_cnt].pipe.src.is_hsplit = pipes[pipe_cnt].pipe.dest.odm_combine != dm_odm_combine_mode_disabled;
1391 pipes[pipe_cnt].pipe.src.source_scan = dm_horz;
1392 pipes[pipe_cnt].pipe.src.source_rotation = dm_rotation_0;
1393 pipes[pipe_cnt].pipe.src.sw_mode = dm_sw_4kb_s;
1394 pipes[pipe_cnt].pipe.src.macro_tile_size = dm_64k_tile;
1395 pipes[pipe_cnt].pipe.src.viewport_width = timing->h_addressable;
1396 if (pipes[pipe_cnt].pipe.src.viewport_width > 1920)
1397 pipes[pipe_cnt].pipe.src.viewport_width = 1920;
1398 pipes[pipe_cnt].pipe.src.viewport_height = timing->v_addressable;
1399 if (pipes[pipe_cnt].pipe.src.viewport_height > 1080)
1400 pipes[pipe_cnt].pipe.src.viewport_height = 1080;
1401 pipes[pipe_cnt].pipe.src.surface_height_y = pipes[pipe_cnt].pipe.src.viewport_height;
1402 pipes[pipe_cnt].pipe.src.surface_width_y = pipes[pipe_cnt].pipe.src.viewport_width;
1403 pipes[pipe_cnt].pipe.src.surface_height_c = pipes[pipe_cnt].pipe.src.viewport_height;
1404 pipes[pipe_cnt].pipe.src.surface_width_c = pipes[pipe_cnt].pipe.src.viewport_width;
1405 pipes[pipe_cnt].pipe.src.data_pitch = ((pipes[pipe_cnt].pipe.src.viewport_width + 255) / 256) * 256;
1406 pipes[pipe_cnt].pipe.src.source_format = dm_444_32;
1407 pipes[pipe_cnt].pipe.dest.recout_width = pipes[pipe_cnt].pipe.src.viewport_width; /*vp_width/hratio*/
1408 pipes[pipe_cnt].pipe.dest.recout_height = pipes[pipe_cnt].pipe.src.viewport_height; /*vp_height/vratio*/
1409 pipes[pipe_cnt].pipe.dest.full_recout_width = pipes[pipe_cnt].pipe.dest.recout_width; /*when is_hsplit != 1*/
1410 pipes[pipe_cnt].pipe.dest.full_recout_height = pipes[pipe_cnt].pipe.dest.recout_height; /*when is_hsplit != 1*/
1411 pipes[pipe_cnt].pipe.scale_ratio_depth.lb_depth = dm_lb_16;
1412 pipes[pipe_cnt].pipe.scale_ratio_depth.hscl_ratio = 1.0;
1413 pipes[pipe_cnt].pipe.scale_ratio_depth.vscl_ratio = 1.0;
1414 pipes[pipe_cnt].pipe.scale_ratio_depth.scl_enable = 0; /*Lb only or Full scl*/
1415 pipes[pipe_cnt].pipe.scale_taps.htaps = 1;
1416 pipes[pipe_cnt].pipe.scale_taps.vtaps = 1;
1417 pipes[pipe_cnt].pipe.dest.vtotal_min = v_total;
1418 pipes[pipe_cnt].pipe.dest.vtotal_max = v_total;
1420 if (pipes[pipe_cnt].pipe.dest.odm_combine == dm_odm_combine_mode_2to1) {
1421 pipes[pipe_cnt].pipe.src.viewport_width /= 2;
1422 pipes[pipe_cnt].pipe.dest.recout_width /= 2;
1423 } else if (pipes[pipe_cnt].pipe.dest.odm_combine == dm_odm_combine_mode_4to1) {
1424 pipes[pipe_cnt].pipe.src.viewport_width /= 4;
1425 pipes[pipe_cnt].pipe.dest.recout_width /= 4;
1428 struct dc_plane_state *pln = res_ctx->pipe_ctx[i].plane_state;
1429 struct scaler_data *scl = &res_ctx->pipe_ctx[i].plane_res.scl_data;
1431 pipes[pipe_cnt].pipe.src.immediate_flip = pln->flip_immediate;
1432 pipes[pipe_cnt].pipe.src.is_hsplit = (res_ctx->pipe_ctx[i].bottom_pipe && res_ctx->pipe_ctx[i].bottom_pipe->plane_state == pln)
1433 || (res_ctx->pipe_ctx[i].top_pipe && res_ctx->pipe_ctx[i].top_pipe->plane_state == pln)
1434 || pipes[pipe_cnt].pipe.dest.odm_combine != dm_odm_combine_mode_disabled;
1436 /* stereo is not split */
1437 if (pln->stereo_format == PLANE_STEREO_FORMAT_SIDE_BY_SIDE ||
1438 pln->stereo_format == PLANE_STEREO_FORMAT_TOP_AND_BOTTOM) {
1439 pipes[pipe_cnt].pipe.src.is_hsplit = false;
1440 pipes[pipe_cnt].pipe.src.hsplit_grp = res_ctx->pipe_ctx[i].pipe_idx;
1443 pipes[pipe_cnt].pipe.src.source_scan = pln->rotation == ROTATION_ANGLE_90
1444 || pln->rotation == ROTATION_ANGLE_270 ? dm_vert : dm_horz;
1445 switch (pln->rotation) {
1446 case ROTATION_ANGLE_0:
1447 pipes[pipe_cnt].pipe.src.source_rotation = dm_rotation_0;
1449 case ROTATION_ANGLE_90:
1450 pipes[pipe_cnt].pipe.src.source_rotation = dm_rotation_90;
1452 case ROTATION_ANGLE_180:
1453 pipes[pipe_cnt].pipe.src.source_rotation = dm_rotation_180;
1455 case ROTATION_ANGLE_270:
1456 pipes[pipe_cnt].pipe.src.source_rotation = dm_rotation_270;
1461 pipes[pipe_cnt].pipe.src.viewport_y_y = scl->viewport.y;
1462 pipes[pipe_cnt].pipe.src.viewport_y_c = scl->viewport_c.y;
1463 pipes[pipe_cnt].pipe.src.viewport_x_y = scl->viewport.x;
1464 pipes[pipe_cnt].pipe.src.viewport_x_c = scl->viewport_c.x;
1465 pipes[pipe_cnt].pipe.src.viewport_width = scl->viewport.width;
1466 pipes[pipe_cnt].pipe.src.viewport_width_c = scl->viewport_c.width;
1467 pipes[pipe_cnt].pipe.src.viewport_height = scl->viewport.height;
1468 pipes[pipe_cnt].pipe.src.viewport_height_c = scl->viewport_c.height;
1469 pipes[pipe_cnt].pipe.src.viewport_width_max = pln->src_rect.width;
1470 pipes[pipe_cnt].pipe.src.viewport_height_max = pln->src_rect.height;
1471 pipes[pipe_cnt].pipe.src.surface_width_y = pln->plane_size.surface_size.width;
1472 pipes[pipe_cnt].pipe.src.surface_height_y = pln->plane_size.surface_size.height;
1473 pipes[pipe_cnt].pipe.src.surface_width_c = pln->plane_size.chroma_size.width;
1474 pipes[pipe_cnt].pipe.src.surface_height_c = pln->plane_size.chroma_size.height;
1475 if (pln->format == SURFACE_PIXEL_FORMAT_GRPH_RGBE_ALPHA
1476 || pln->format >= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN) {
1477 pipes[pipe_cnt].pipe.src.data_pitch = pln->plane_size.surface_pitch;
1478 pipes[pipe_cnt].pipe.src.data_pitch_c = pln->plane_size.chroma_pitch;
1479 pipes[pipe_cnt].pipe.src.meta_pitch = pln->dcc.meta_pitch;
1480 pipes[pipe_cnt].pipe.src.meta_pitch_c = pln->dcc.meta_pitch_c;
1482 pipes[pipe_cnt].pipe.src.data_pitch = pln->plane_size.surface_pitch;
1483 pipes[pipe_cnt].pipe.src.meta_pitch = pln->dcc.meta_pitch;
1485 pipes[pipe_cnt].pipe.src.dcc = pln->dcc.enable;
1486 pipes[pipe_cnt].pipe.dest.recout_width = scl->recout.width;
1487 pipes[pipe_cnt].pipe.dest.recout_height = scl->recout.height;
1488 pipes[pipe_cnt].pipe.dest.full_recout_height = scl->recout.height;
1489 pipes[pipe_cnt].pipe.dest.full_recout_width = scl->recout.width;
1490 if (pipes[pipe_cnt].pipe.dest.odm_combine == dm_odm_combine_mode_2to1)
1491 pipes[pipe_cnt].pipe.dest.full_recout_width *= 2;
1492 else if (pipes[pipe_cnt].pipe.dest.odm_combine == dm_odm_combine_mode_4to1)
1493 pipes[pipe_cnt].pipe.dest.full_recout_width *= 4;
1495 struct pipe_ctx *split_pipe = res_ctx->pipe_ctx[i].bottom_pipe;
1497 while (split_pipe && split_pipe->plane_state == pln) {
1498 pipes[pipe_cnt].pipe.dest.full_recout_width += split_pipe->plane_res.scl_data.recout.width;
1499 split_pipe = split_pipe->bottom_pipe;
1501 split_pipe = res_ctx->pipe_ctx[i].top_pipe;
1502 while (split_pipe && split_pipe->plane_state == pln) {
1503 pipes[pipe_cnt].pipe.dest.full_recout_width += split_pipe->plane_res.scl_data.recout.width;
1504 split_pipe = split_pipe->top_pipe;
1508 pipes[pipe_cnt].pipe.scale_ratio_depth.lb_depth = dm_lb_16;
1509 pipes[pipe_cnt].pipe.scale_ratio_depth.hscl_ratio = (double) scl->ratios.horz.value / (1ULL<<32);
1510 pipes[pipe_cnt].pipe.scale_ratio_depth.hscl_ratio_c = (double) scl->ratios.horz_c.value / (1ULL<<32);
1511 pipes[pipe_cnt].pipe.scale_ratio_depth.vscl_ratio = (double) scl->ratios.vert.value / (1ULL<<32);
1512 pipes[pipe_cnt].pipe.scale_ratio_depth.vscl_ratio_c = (double) scl->ratios.vert_c.value / (1ULL<<32);
1513 pipes[pipe_cnt].pipe.scale_ratio_depth.scl_enable =
1514 scl->ratios.vert.value != dc_fixpt_one.value
1515 || scl->ratios.horz.value != dc_fixpt_one.value
1516 || scl->ratios.vert_c.value != dc_fixpt_one.value
1517 || scl->ratios.horz_c.value != dc_fixpt_one.value /*Lb only or Full scl*/
1518 || dc->debug.always_scale; /*support always scale*/
1519 pipes[pipe_cnt].pipe.scale_taps.htaps = scl->taps.h_taps;
1520 pipes[pipe_cnt].pipe.scale_taps.htaps_c = scl->taps.h_taps_c;
1521 pipes[pipe_cnt].pipe.scale_taps.vtaps = scl->taps.v_taps;
1522 pipes[pipe_cnt].pipe.scale_taps.vtaps_c = scl->taps.v_taps_c;
1524 pipes[pipe_cnt].pipe.src.macro_tile_size =
1525 swizzle_mode_to_macro_tile_size(pln->tiling_info.gfx9.swizzle);
1526 swizzle_to_dml_params(pln->tiling_info.gfx9.swizzle,
1527 &pipes[pipe_cnt].pipe.src.sw_mode);
1529 switch (pln->format) {
1530 case SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr:
1531 case SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb:
1532 pipes[pipe_cnt].pipe.src.source_format = dm_420_8;
1534 case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCbCr:
1535 case SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb:
1536 pipes[pipe_cnt].pipe.src.source_format = dm_420_10;
1538 case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616:
1539 case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616:
1540 case SURFACE_PIXEL_FORMAT_GRPH_ARGB16161616F:
1541 case SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F:
1542 pipes[pipe_cnt].pipe.src.source_format = dm_444_64;
1544 case SURFACE_PIXEL_FORMAT_GRPH_ARGB1555:
1545 case SURFACE_PIXEL_FORMAT_GRPH_RGB565:
1546 pipes[pipe_cnt].pipe.src.source_format = dm_444_16;
1548 case SURFACE_PIXEL_FORMAT_GRPH_PALETA_256_COLORS:
1549 pipes[pipe_cnt].pipe.src.source_format = dm_444_8;
1551 case SURFACE_PIXEL_FORMAT_GRPH_RGBE_ALPHA:
1552 pipes[pipe_cnt].pipe.src.source_format = dm_rgbe_alpha;
1555 pipes[pipe_cnt].pipe.src.source_format = dm_444_32;
1563 /* populate writeback information */
1564 dc->res_pool->funcs->populate_dml_writeback_from_context(dc, res_ctx, pipes);
1569 void dcn20_calculate_wm(
1570 struct dc *dc, struct dc_state *context,
1571 display_e2e_pipe_params_st *pipes,
1573 int *pipe_split_from,
1577 int pipe_cnt, i, pipe_idx;
1579 dc_assert_fp_enabled();
1581 for (i = 0, pipe_idx = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; i++) {
1582 if (!context->res_ctx.pipe_ctx[i].stream)
1585 pipes[pipe_cnt].clks_cfg.refclk_mhz = dc->res_pool->ref_clocks.dchub_ref_clock_inKhz / 1000.0;
1586 pipes[pipe_cnt].clks_cfg.dispclk_mhz = context->bw_ctx.dml.vba.RequiredDISPCLK[vlevel][context->bw_ctx.dml.vba.maxMpcComb];
1588 if (pipe_split_from[i] < 0) {
1589 pipes[pipe_cnt].clks_cfg.dppclk_mhz =
1590 context->bw_ctx.dml.vba.RequiredDPPCLK[vlevel][context->bw_ctx.dml.vba.maxMpcComb][pipe_idx];
1591 if (context->bw_ctx.dml.vba.BlendingAndTiming[pipe_idx] == pipe_idx)
1592 pipes[pipe_cnt].pipe.dest.odm_combine =
1593 context->bw_ctx.dml.vba.ODMCombineEnabled[pipe_idx];
1595 pipes[pipe_cnt].pipe.dest.odm_combine = 0;
1598 pipes[pipe_cnt].clks_cfg.dppclk_mhz =
1599 context->bw_ctx.dml.vba.RequiredDPPCLK[vlevel][context->bw_ctx.dml.vba.maxMpcComb][pipe_split_from[i]];
1600 if (context->bw_ctx.dml.vba.BlendingAndTiming[pipe_split_from[i]] == pipe_split_from[i])
1601 pipes[pipe_cnt].pipe.dest.odm_combine =
1602 context->bw_ctx.dml.vba.ODMCombineEnabled[pipe_split_from[i]];
1604 pipes[pipe_cnt].pipe.dest.odm_combine = 0;
1607 if (dc->config.forced_clocks) {
1608 pipes[pipe_cnt].clks_cfg.dispclk_mhz = context->bw_ctx.dml.soc.clock_limits[0].dispclk_mhz;
1609 pipes[pipe_cnt].clks_cfg.dppclk_mhz = context->bw_ctx.dml.soc.clock_limits[0].dppclk_mhz;
1611 if (dc->debug.min_disp_clk_khz > pipes[pipe_cnt].clks_cfg.dispclk_mhz * 1000)
1612 pipes[pipe_cnt].clks_cfg.dispclk_mhz = dc->debug.min_disp_clk_khz / 1000.0;
1613 if (dc->debug.min_dpp_clk_khz > pipes[pipe_cnt].clks_cfg.dppclk_mhz * 1000)
1614 pipes[pipe_cnt].clks_cfg.dppclk_mhz = dc->debug.min_dpp_clk_khz / 1000.0;
1619 if (pipe_cnt != pipe_idx) {
1620 if (dc->res_pool->funcs->populate_dml_pipes)
1621 pipe_cnt = dc->res_pool->funcs->populate_dml_pipes(dc,
1622 context, pipes, fast_validate);
1624 pipe_cnt = dcn20_populate_dml_pipes_from_context(dc,
1625 context, pipes, fast_validate);
1628 *out_pipe_cnt = pipe_cnt;
1630 pipes[0].clks_cfg.voltage = vlevel;
1631 pipes[0].clks_cfg.dcfclk_mhz = context->bw_ctx.dml.soc.clock_limits[vlevel].dcfclk_mhz;
1632 pipes[0].clks_cfg.socclk_mhz = context->bw_ctx.dml.soc.clock_limits[vlevel].socclk_mhz;
1634 /* only pipe 0 is read for voltage and dcf/soc clocks */
1636 pipes[0].clks_cfg.voltage = 1;
1637 pipes[0].clks_cfg.dcfclk_mhz = context->bw_ctx.dml.soc.clock_limits[1].dcfclk_mhz;
1638 pipes[0].clks_cfg.socclk_mhz = context->bw_ctx.dml.soc.clock_limits[1].socclk_mhz;
1640 context->bw_ctx.bw.dcn.watermarks.b.urgent_ns = get_wm_urgent(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1641 context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1642 context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1643 context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.pstate_change_ns = get_wm_dram_clock_change(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1644 context->bw_ctx.bw.dcn.watermarks.b.pte_meta_urgent_ns = get_wm_memory_trip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1645 context->bw_ctx.bw.dcn.watermarks.b.frac_urg_bw_nom = get_fraction_of_urgent_bandwidth(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1646 context->bw_ctx.bw.dcn.watermarks.b.frac_urg_bw_flip = get_fraction_of_urgent_bandwidth_imm_flip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1647 context->bw_ctx.bw.dcn.watermarks.b.urgent_latency_ns = get_urgent_latency(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1650 pipes[0].clks_cfg.voltage = 2;
1651 pipes[0].clks_cfg.dcfclk_mhz = context->bw_ctx.dml.soc.clock_limits[2].dcfclk_mhz;
1652 pipes[0].clks_cfg.socclk_mhz = context->bw_ctx.dml.soc.clock_limits[2].socclk_mhz;
1654 context->bw_ctx.bw.dcn.watermarks.c.urgent_ns = get_wm_urgent(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1655 context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1656 context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1657 context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.pstate_change_ns = get_wm_dram_clock_change(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1658 context->bw_ctx.bw.dcn.watermarks.c.pte_meta_urgent_ns = get_wm_memory_trip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1659 context->bw_ctx.bw.dcn.watermarks.c.frac_urg_bw_nom = get_fraction_of_urgent_bandwidth(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1660 context->bw_ctx.bw.dcn.watermarks.c.frac_urg_bw_flip = get_fraction_of_urgent_bandwidth_imm_flip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1663 pipes[0].clks_cfg.voltage = 3;
1664 pipes[0].clks_cfg.dcfclk_mhz = context->bw_ctx.dml.soc.clock_limits[2].dcfclk_mhz;
1665 pipes[0].clks_cfg.socclk_mhz = context->bw_ctx.dml.soc.clock_limits[2].socclk_mhz;
1667 context->bw_ctx.bw.dcn.watermarks.d.urgent_ns = get_wm_urgent(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1668 context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1669 context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1670 context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.pstate_change_ns = get_wm_dram_clock_change(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1671 context->bw_ctx.bw.dcn.watermarks.d.pte_meta_urgent_ns = get_wm_memory_trip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1672 context->bw_ctx.bw.dcn.watermarks.d.frac_urg_bw_nom = get_fraction_of_urgent_bandwidth(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1673 context->bw_ctx.bw.dcn.watermarks.d.frac_urg_bw_flip = get_fraction_of_urgent_bandwidth_imm_flip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1675 pipes[0].clks_cfg.voltage = vlevel;
1676 pipes[0].clks_cfg.dcfclk_mhz = context->bw_ctx.dml.soc.clock_limits[vlevel].dcfclk_mhz;
1677 pipes[0].clks_cfg.socclk_mhz = context->bw_ctx.dml.soc.clock_limits[vlevel].socclk_mhz;
1678 context->bw_ctx.bw.dcn.watermarks.a.urgent_ns = get_wm_urgent(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1679 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1680 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1681 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.pstate_change_ns = get_wm_dram_clock_change(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1682 context->bw_ctx.bw.dcn.watermarks.a.pte_meta_urgent_ns = get_wm_memory_trip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1683 context->bw_ctx.bw.dcn.watermarks.a.frac_urg_bw_nom = get_fraction_of_urgent_bandwidth(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1684 context->bw_ctx.bw.dcn.watermarks.a.frac_urg_bw_flip = get_fraction_of_urgent_bandwidth_imm_flip(&context->bw_ctx.dml, pipes, pipe_cnt) * 1000;
1687 void dcn20_update_bounding_box(struct dc *dc, struct _vcs_dpi_soc_bounding_box_st *bb,
1688 struct pp_smu_nv_clock_table *max_clocks, unsigned int *uclk_states, unsigned int num_states)
1690 int num_calculated_states = 0;
1694 dc_assert_fp_enabled();
1696 if (num_states == 0)
1699 memset(bb->clock_limits, 0, sizeof(bb->clock_limits));
1701 if (dc->bb_overrides.min_dcfclk_mhz > 0) {
1702 min_dcfclk = dc->bb_overrides.min_dcfclk_mhz;
1704 if (ASICREV_IS_NAVI12_P(dc->ctx->asic_id.hw_internal_rev))
1707 // Accounting for SOC/DCF relationship, we can go as high as
1712 for (i = 0; i < num_states; i++) {
1713 int min_fclk_required_by_uclk;
1714 bb->clock_limits[i].state = i;
1715 bb->clock_limits[i].dram_speed_mts = uclk_states[i] * 16 / 1000;
1717 // FCLK:UCLK ratio is 1.08
1718 min_fclk_required_by_uclk = div_u64(((unsigned long long)uclk_states[i]) * 1080,
1721 bb->clock_limits[i].fabricclk_mhz = (min_fclk_required_by_uclk < min_dcfclk) ?
1722 min_dcfclk : min_fclk_required_by_uclk;
1724 bb->clock_limits[i].socclk_mhz = (bb->clock_limits[i].fabricclk_mhz > max_clocks->socClockInKhz / 1000) ?
1725 max_clocks->socClockInKhz / 1000 : bb->clock_limits[i].fabricclk_mhz;
1727 bb->clock_limits[i].dcfclk_mhz = (bb->clock_limits[i].fabricclk_mhz > max_clocks->dcfClockInKhz / 1000) ?
1728 max_clocks->dcfClockInKhz / 1000 : bb->clock_limits[i].fabricclk_mhz;
1730 bb->clock_limits[i].dispclk_mhz = max_clocks->displayClockInKhz / 1000;
1731 bb->clock_limits[i].dppclk_mhz = max_clocks->displayClockInKhz / 1000;
1732 bb->clock_limits[i].dscclk_mhz = max_clocks->displayClockInKhz / (1000 * 3);
1734 bb->clock_limits[i].phyclk_mhz = max_clocks->phyClockInKhz / 1000;
1736 num_calculated_states++;
1739 bb->clock_limits[num_calculated_states - 1].socclk_mhz = max_clocks->socClockInKhz / 1000;
1740 bb->clock_limits[num_calculated_states - 1].fabricclk_mhz = max_clocks->socClockInKhz / 1000;
1741 bb->clock_limits[num_calculated_states - 1].dcfclk_mhz = max_clocks->dcfClockInKhz / 1000;
1743 bb->num_states = num_calculated_states;
1745 // Duplicate the last state, DML always an extra state identical to max state to work
1746 memcpy(&bb->clock_limits[num_calculated_states], &bb->clock_limits[num_calculated_states - 1], sizeof(struct _vcs_dpi_voltage_scaling_st));
1747 bb->clock_limits[num_calculated_states].state = bb->num_states;
1750 void dcn20_cap_soc_clocks(
1751 struct _vcs_dpi_soc_bounding_box_st *bb,
1752 struct pp_smu_nv_clock_table max_clocks)
1756 dc_assert_fp_enabled();
1758 // First pass - cap all clocks higher than the reported max
1759 for (i = 0; i < bb->num_states; i++) {
1760 if ((bb->clock_limits[i].dcfclk_mhz > (max_clocks.dcfClockInKhz / 1000))
1761 && max_clocks.dcfClockInKhz != 0)
1762 bb->clock_limits[i].dcfclk_mhz = (max_clocks.dcfClockInKhz / 1000);
1764 if ((bb->clock_limits[i].dram_speed_mts > (max_clocks.uClockInKhz / 1000) * 16)
1765 && max_clocks.uClockInKhz != 0)
1766 bb->clock_limits[i].dram_speed_mts = (max_clocks.uClockInKhz / 1000) * 16;
1768 if ((bb->clock_limits[i].fabricclk_mhz > (max_clocks.fabricClockInKhz / 1000))
1769 && max_clocks.fabricClockInKhz != 0)
1770 bb->clock_limits[i].fabricclk_mhz = (max_clocks.fabricClockInKhz / 1000);
1772 if ((bb->clock_limits[i].dispclk_mhz > (max_clocks.displayClockInKhz / 1000))
1773 && max_clocks.displayClockInKhz != 0)
1774 bb->clock_limits[i].dispclk_mhz = (max_clocks.displayClockInKhz / 1000);
1776 if ((bb->clock_limits[i].dppclk_mhz > (max_clocks.dppClockInKhz / 1000))
1777 && max_clocks.dppClockInKhz != 0)
1778 bb->clock_limits[i].dppclk_mhz = (max_clocks.dppClockInKhz / 1000);
1780 if ((bb->clock_limits[i].phyclk_mhz > (max_clocks.phyClockInKhz / 1000))
1781 && max_clocks.phyClockInKhz != 0)
1782 bb->clock_limits[i].phyclk_mhz = (max_clocks.phyClockInKhz / 1000);
1784 if ((bb->clock_limits[i].socclk_mhz > (max_clocks.socClockInKhz / 1000))
1785 && max_clocks.socClockInKhz != 0)
1786 bb->clock_limits[i].socclk_mhz = (max_clocks.socClockInKhz / 1000);
1788 if ((bb->clock_limits[i].dscclk_mhz > (max_clocks.dscClockInKhz / 1000))
1789 && max_clocks.dscClockInKhz != 0)
1790 bb->clock_limits[i].dscclk_mhz = (max_clocks.dscClockInKhz / 1000);
1793 // Second pass - remove all duplicate clock states
1794 for (i = bb->num_states - 1; i > 1; i--) {
1795 bool duplicate = true;
1797 if (bb->clock_limits[i-1].dcfclk_mhz != bb->clock_limits[i].dcfclk_mhz)
1799 if (bb->clock_limits[i-1].dispclk_mhz != bb->clock_limits[i].dispclk_mhz)
1801 if (bb->clock_limits[i-1].dppclk_mhz != bb->clock_limits[i].dppclk_mhz)
1803 if (bb->clock_limits[i-1].dram_speed_mts != bb->clock_limits[i].dram_speed_mts)
1805 if (bb->clock_limits[i-1].dscclk_mhz != bb->clock_limits[i].dscclk_mhz)
1807 if (bb->clock_limits[i-1].fabricclk_mhz != bb->clock_limits[i].fabricclk_mhz)
1809 if (bb->clock_limits[i-1].phyclk_mhz != bb->clock_limits[i].phyclk_mhz)
1811 if (bb->clock_limits[i-1].socclk_mhz != bb->clock_limits[i].socclk_mhz)
1819 void dcn20_patch_bounding_box(struct dc *dc, struct _vcs_dpi_soc_bounding_box_st *bb)
1821 dc_assert_fp_enabled();
1823 if ((int)(bb->sr_exit_time_us * 1000) != dc->bb_overrides.sr_exit_time_ns
1824 && dc->bb_overrides.sr_exit_time_ns) {
1825 bb->sr_exit_time_us = dc->bb_overrides.sr_exit_time_ns / 1000.0;
1828 if ((int)(bb->sr_enter_plus_exit_time_us * 1000)
1829 != dc->bb_overrides.sr_enter_plus_exit_time_ns
1830 && dc->bb_overrides.sr_enter_plus_exit_time_ns) {
1831 bb->sr_enter_plus_exit_time_us =
1832 dc->bb_overrides.sr_enter_plus_exit_time_ns / 1000.0;
1835 if ((int)(bb->urgent_latency_us * 1000) != dc->bb_overrides.urgent_latency_ns
1836 && dc->bb_overrides.urgent_latency_ns) {
1837 bb->urgent_latency_us = dc->bb_overrides.urgent_latency_ns / 1000.0;
1840 if ((int)(bb->dram_clock_change_latency_us * 1000)
1841 != dc->bb_overrides.dram_clock_change_latency_ns
1842 && dc->bb_overrides.dram_clock_change_latency_ns) {
1843 bb->dram_clock_change_latency_us =
1844 dc->bb_overrides.dram_clock_change_latency_ns / 1000.0;
1847 if ((int)(bb->dummy_pstate_latency_us * 1000)
1848 != dc->bb_overrides.dummy_clock_change_latency_ns
1849 && dc->bb_overrides.dummy_clock_change_latency_ns) {
1850 bb->dummy_pstate_latency_us =
1851 dc->bb_overrides.dummy_clock_change_latency_ns / 1000.0;
1855 static bool dcn20_validate_bandwidth_internal(struct dc *dc, struct dc_state *context,
1860 BW_VAL_TRACE_SETUP();
1863 int pipe_split_from[MAX_PIPES];
1865 display_e2e_pipe_params_st *pipes = kzalloc(dc->res_pool->pipe_count * sizeof(display_e2e_pipe_params_st), GFP_ATOMIC);
1866 DC_LOGGER_INIT(dc->ctx->logger);
1868 BW_VAL_TRACE_COUNT();
1870 out = dcn20_fast_validate_bw(dc, context, pipes, &pipe_cnt, pipe_split_from, &vlevel, fast_validate);
1878 BW_VAL_TRACE_END_VOLTAGE_LEVEL();
1880 if (fast_validate) {
1881 BW_VAL_TRACE_SKIP(fast);
1885 dcn20_calculate_wm(dc, context, pipes, &pipe_cnt, pipe_split_from, vlevel, fast_validate);
1886 dcn20_calculate_dlg_params(dc, context, pipes, pipe_cnt, vlevel);
1888 BW_VAL_TRACE_END_WATERMARKS();
1893 DC_LOG_WARNING("Mode Validation Warning: %s failed validation.\n",
1894 dml_get_status_message(context->bw_ctx.dml.vba.ValidationStatus[context->bw_ctx.dml.vba.soc.num_states]));
1896 BW_VAL_TRACE_SKIP(fail);
1902 BW_VAL_TRACE_FINISH();
1907 bool dcn20_validate_bandwidth_fp(struct dc *dc,
1908 struct dc_state *context,
1911 bool voltage_supported = false;
1912 bool full_pstate_supported = false;
1913 bool dummy_pstate_supported = false;
1914 double p_state_latency_us;
1916 dc_assert_fp_enabled();
1918 p_state_latency_us = context->bw_ctx.dml.soc.dram_clock_change_latency_us;
1919 context->bw_ctx.dml.soc.disable_dram_clock_change_vactive_support =
1920 dc->debug.disable_dram_clock_change_vactive_support;
1921 context->bw_ctx.dml.soc.allow_dram_clock_one_display_vactive =
1922 dc->debug.enable_dram_clock_change_one_display_vactive;
1924 /*Unsafe due to current pipe merge and split logic*/
1925 ASSERT(context != dc->current_state);
1927 if (fast_validate) {
1928 return dcn20_validate_bandwidth_internal(dc, context, true);
1931 // Best case, we support full UCLK switch latency
1932 voltage_supported = dcn20_validate_bandwidth_internal(dc, context, false);
1933 full_pstate_supported = context->bw_ctx.bw.dcn.clk.p_state_change_support;
1935 if (context->bw_ctx.dml.soc.dummy_pstate_latency_us == 0 ||
1936 (voltage_supported && full_pstate_supported)) {
1937 context->bw_ctx.bw.dcn.clk.p_state_change_support = full_pstate_supported;
1938 goto restore_dml_state;
1941 // Fallback: Try to only support G6 temperature read latency
1942 context->bw_ctx.dml.soc.dram_clock_change_latency_us = context->bw_ctx.dml.soc.dummy_pstate_latency_us;
1944 voltage_supported = dcn20_validate_bandwidth_internal(dc, context, false);
1945 dummy_pstate_supported = context->bw_ctx.bw.dcn.clk.p_state_change_support;
1947 if (voltage_supported && (dummy_pstate_supported || !(context->stream_count))) {
1948 context->bw_ctx.bw.dcn.clk.p_state_change_support = false;
1949 goto restore_dml_state;
1952 // ERROR: fallback is supposed to always work.
1956 context->bw_ctx.dml.soc.dram_clock_change_latency_us = p_state_latency_us;
1957 return voltage_supported;
1960 void dcn20_fpu_set_wm_ranges(int i,
1961 struct pp_smu_wm_range_sets *ranges,
1962 struct _vcs_dpi_soc_bounding_box_st *loaded_bb)
1964 dc_assert_fp_enabled();
1966 ranges->reader_wm_sets[i].min_fill_clk_mhz = (i > 0) ? (loaded_bb->clock_limits[i - 1].dram_speed_mts / 16) + 1 : 0;
1967 ranges->reader_wm_sets[i].max_fill_clk_mhz = loaded_bb->clock_limits[i].dram_speed_mts / 16;
1970 void dcn20_fpu_adjust_dppclk(struct vba_vars_st *v,
1974 bool is_validating_bw)
1976 dc_assert_fp_enabled();
1978 if (is_validating_bw)
1979 v->RequiredDPPCLK[vlevel][max_mpc_comb][pipe_idx] *= 2;
1981 v->RequiredDPPCLK[vlevel][max_mpc_comb][pipe_idx] /= 2;
1984 int dcn21_populate_dml_pipes_from_context(struct dc *dc,
1985 struct dc_state *context,
1986 display_e2e_pipe_params_st *pipes,
1992 dc_assert_fp_enabled();
1994 pipe_cnt = dcn20_populate_dml_pipes_from_context(dc, context, pipes, fast_validate);
1996 for (i = 0; i < pipe_cnt; i++) {
1998 pipes[i].pipe.src.hostvm = dc->res_pool->hubbub->riommu_active;
1999 pipes[i].pipe.src.gpuvm = 1;
2005 static void patch_bounding_box(struct dc *dc, struct _vcs_dpi_soc_bounding_box_st *bb)
2009 if (dc->bb_overrides.sr_exit_time_ns) {
2010 for (i = 0; i < WM_SET_COUNT; i++) {
2011 dc->clk_mgr->bw_params->wm_table.entries[i].sr_exit_time_us =
2012 dc->bb_overrides.sr_exit_time_ns / 1000.0;
2016 if (dc->bb_overrides.sr_enter_plus_exit_time_ns) {
2017 for (i = 0; i < WM_SET_COUNT; i++) {
2018 dc->clk_mgr->bw_params->wm_table.entries[i].sr_enter_plus_exit_time_us =
2019 dc->bb_overrides.sr_enter_plus_exit_time_ns / 1000.0;
2023 if (dc->bb_overrides.urgent_latency_ns) {
2024 bb->urgent_latency_us = dc->bb_overrides.urgent_latency_ns / 1000.0;
2027 if (dc->bb_overrides.dram_clock_change_latency_ns) {
2028 for (i = 0; i < WM_SET_COUNT; i++) {
2029 dc->clk_mgr->bw_params->wm_table.entries[i].pstate_latency_us =
2030 dc->bb_overrides.dram_clock_change_latency_ns / 1000.0;
2035 static void calculate_wm_set_for_vlevel(int vlevel,
2036 struct wm_range_table_entry *table_entry,
2037 struct dcn_watermarks *wm_set,
2038 struct display_mode_lib *dml,
2039 display_e2e_pipe_params_st *pipes,
2042 double dram_clock_change_latency_cached = dml->soc.dram_clock_change_latency_us;
2044 ASSERT(vlevel < dml->soc.num_states);
2045 /* only pipe 0 is read for voltage and dcf/soc clocks */
2046 pipes[0].clks_cfg.voltage = vlevel;
2047 pipes[0].clks_cfg.dcfclk_mhz = dml->soc.clock_limits[vlevel].dcfclk_mhz;
2048 pipes[0].clks_cfg.socclk_mhz = dml->soc.clock_limits[vlevel].socclk_mhz;
2050 dml->soc.dram_clock_change_latency_us = table_entry->pstate_latency_us;
2051 dml->soc.sr_exit_time_us = table_entry->sr_exit_time_us;
2052 dml->soc.sr_enter_plus_exit_time_us = table_entry->sr_enter_plus_exit_time_us;
2054 wm_set->urgent_ns = get_wm_urgent(dml, pipes, pipe_cnt) * 1000;
2055 wm_set->cstate_pstate.cstate_enter_plus_exit_ns = get_wm_stutter_enter_exit(dml, pipes, pipe_cnt) * 1000;
2056 wm_set->cstate_pstate.cstate_exit_ns = get_wm_stutter_exit(dml, pipes, pipe_cnt) * 1000;
2057 wm_set->cstate_pstate.pstate_change_ns = get_wm_dram_clock_change(dml, pipes, pipe_cnt) * 1000;
2058 wm_set->pte_meta_urgent_ns = get_wm_memory_trip(dml, pipes, pipe_cnt) * 1000;
2059 wm_set->frac_urg_bw_nom = get_fraction_of_urgent_bandwidth(dml, pipes, pipe_cnt) * 1000;
2060 wm_set->frac_urg_bw_flip = get_fraction_of_urgent_bandwidth_imm_flip(dml, pipes, pipe_cnt) * 1000;
2061 wm_set->urgent_latency_ns = get_urgent_latency(dml, pipes, pipe_cnt) * 1000;
2062 dml->soc.dram_clock_change_latency_us = dram_clock_change_latency_cached;
2065 static void dcn21_calculate_wm(struct dc *dc, struct dc_state *context,
2066 display_e2e_pipe_params_st *pipes,
2068 int *pipe_split_from,
2072 int pipe_cnt, i, pipe_idx;
2073 int vlevel, vlevel_max;
2074 struct wm_range_table_entry *table_entry;
2075 struct clk_bw_params *bw_params = dc->clk_mgr->bw_params;
2079 patch_bounding_box(dc, &context->bw_ctx.dml.soc);
2081 for (i = 0, pipe_idx = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; i++) {
2082 if (!context->res_ctx.pipe_ctx[i].stream)
2085 pipes[pipe_cnt].clks_cfg.refclk_mhz = dc->res_pool->ref_clocks.dchub_ref_clock_inKhz / 1000.0;
2086 pipes[pipe_cnt].clks_cfg.dispclk_mhz = context->bw_ctx.dml.vba.RequiredDISPCLK[vlevel_req][context->bw_ctx.dml.vba.maxMpcComb];
2088 if (pipe_split_from[i] < 0) {
2089 pipes[pipe_cnt].clks_cfg.dppclk_mhz =
2090 context->bw_ctx.dml.vba.RequiredDPPCLK[vlevel_req][context->bw_ctx.dml.vba.maxMpcComb][pipe_idx];
2091 if (context->bw_ctx.dml.vba.BlendingAndTiming[pipe_idx] == pipe_idx)
2092 pipes[pipe_cnt].pipe.dest.odm_combine =
2093 context->bw_ctx.dml.vba.ODMCombineEnablePerState[vlevel_req][pipe_idx];
2095 pipes[pipe_cnt].pipe.dest.odm_combine = 0;
2098 pipes[pipe_cnt].clks_cfg.dppclk_mhz =
2099 context->bw_ctx.dml.vba.RequiredDPPCLK[vlevel_req][context->bw_ctx.dml.vba.maxMpcComb][pipe_split_from[i]];
2100 if (context->bw_ctx.dml.vba.BlendingAndTiming[pipe_split_from[i]] == pipe_split_from[i])
2101 pipes[pipe_cnt].pipe.dest.odm_combine =
2102 context->bw_ctx.dml.vba.ODMCombineEnablePerState[vlevel_req][pipe_split_from[i]];
2104 pipes[pipe_cnt].pipe.dest.odm_combine = 0;
2109 if (pipe_cnt != pipe_idx) {
2110 if (dc->res_pool->funcs->populate_dml_pipes)
2111 pipe_cnt = dc->res_pool->funcs->populate_dml_pipes(dc,
2112 context, pipes, fast_validate);
2114 pipe_cnt = dcn21_populate_dml_pipes_from_context(dc,
2115 context, pipes, fast_validate);
2118 *out_pipe_cnt = pipe_cnt;
2120 vlevel_max = bw_params->clk_table.num_entries - 1;
2124 table_entry = &bw_params->wm_table.entries[WM_D];
2125 if (table_entry->wm_type == WM_TYPE_RETRAINING)
2128 vlevel = vlevel_max;
2129 calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.watermarks.d,
2130 &context->bw_ctx.dml, pipes, pipe_cnt);
2132 table_entry = &bw_params->wm_table.entries[WM_C];
2133 vlevel = MIN(MAX(vlevel_req, 3), vlevel_max);
2134 calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.watermarks.c,
2135 &context->bw_ctx.dml, pipes, pipe_cnt);
2137 table_entry = &bw_params->wm_table.entries[WM_B];
2138 vlevel = MIN(MAX(vlevel_req, 2), vlevel_max);
2139 calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.watermarks.b,
2140 &context->bw_ctx.dml, pipes, pipe_cnt);
2143 table_entry = &bw_params->wm_table.entries[WM_A];
2144 vlevel = MIN(vlevel_req, vlevel_max);
2145 calculate_wm_set_for_vlevel(vlevel, table_entry, &context->bw_ctx.bw.dcn.watermarks.a,
2146 &context->bw_ctx.dml, pipes, pipe_cnt);
2149 bool dcn21_validate_bandwidth_fp(struct dc *dc,
2150 struct dc_state *context,
2155 BW_VAL_TRACE_SETUP();
2158 int pipe_split_from[MAX_PIPES];
2160 display_e2e_pipe_params_st *pipes = kzalloc(dc->res_pool->pipe_count * sizeof(display_e2e_pipe_params_st), GFP_ATOMIC);
2161 DC_LOGGER_INIT(dc->ctx->logger);
2163 BW_VAL_TRACE_COUNT();
2165 dc_assert_fp_enabled();
2167 /*Unsafe due to current pipe merge and split logic*/
2168 ASSERT(context != dc->current_state);
2170 out = dcn21_fast_validate_bw(dc, context, pipes, &pipe_cnt, pipe_split_from, &vlevel, fast_validate);
2178 BW_VAL_TRACE_END_VOLTAGE_LEVEL();
2180 if (fast_validate) {
2181 BW_VAL_TRACE_SKIP(fast);
2185 dcn21_calculate_wm(dc, context, pipes, &pipe_cnt, pipe_split_from, vlevel, fast_validate);
2186 dcn20_calculate_dlg_params(dc, context, pipes, pipe_cnt, vlevel);
2188 BW_VAL_TRACE_END_WATERMARKS();
2193 DC_LOG_WARNING("Mode Validation Warning: %s failed validation.\n",
2194 dml_get_status_message(context->bw_ctx.dml.vba.ValidationStatus[context->bw_ctx.dml.vba.soc.num_states]));
2196 BW_VAL_TRACE_SKIP(fail);
2202 BW_VAL_TRACE_FINISH();
2207 static struct _vcs_dpi_voltage_scaling_st construct_low_pstate_lvl(struct clk_limit_table *clk_table, unsigned int high_voltage_lvl)
2209 struct _vcs_dpi_voltage_scaling_st low_pstate_lvl;
2212 low_pstate_lvl.state = 1;
2213 low_pstate_lvl.dcfclk_mhz = clk_table->entries[0].dcfclk_mhz;
2214 low_pstate_lvl.fabricclk_mhz = clk_table->entries[0].fclk_mhz;
2215 low_pstate_lvl.socclk_mhz = clk_table->entries[0].socclk_mhz;
2216 low_pstate_lvl.dram_speed_mts = clk_table->entries[0].memclk_mhz * 2;
2218 low_pstate_lvl.dispclk_mhz = dcn2_1_soc.clock_limits[high_voltage_lvl].dispclk_mhz;
2219 low_pstate_lvl.dppclk_mhz = dcn2_1_soc.clock_limits[high_voltage_lvl].dppclk_mhz;
2220 low_pstate_lvl.dram_bw_per_chan_gbps = dcn2_1_soc.clock_limits[high_voltage_lvl].dram_bw_per_chan_gbps;
2221 low_pstate_lvl.dscclk_mhz = dcn2_1_soc.clock_limits[high_voltage_lvl].dscclk_mhz;
2222 low_pstate_lvl.dtbclk_mhz = dcn2_1_soc.clock_limits[high_voltage_lvl].dtbclk_mhz;
2223 low_pstate_lvl.phyclk_d18_mhz = dcn2_1_soc.clock_limits[high_voltage_lvl].phyclk_d18_mhz;
2224 low_pstate_lvl.phyclk_mhz = dcn2_1_soc.clock_limits[high_voltage_lvl].phyclk_mhz;
2226 for (i = clk_table->num_entries; i > 1; i--)
2227 clk_table->entries[i] = clk_table->entries[i-1];
2228 clk_table->entries[1] = clk_table->entries[0];
2229 clk_table->num_entries++;
2231 return low_pstate_lvl;
2234 void dcn21_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_params)
2236 struct dcn21_resource_pool *pool = TO_DCN21_RES_POOL(dc->res_pool);
2237 struct clk_limit_table *clk_table = &bw_params->clk_table;
2238 unsigned int i, closest_clk_lvl = 0, k = 0;
2241 dc_assert_fp_enabled();
2243 dcn2_1_ip.max_num_otg = pool->base.res_cap->num_timing_generator;
2244 dcn2_1_ip.max_num_dpp = pool->base.pipe_count;
2245 dcn2_1_soc.num_chans = bw_params->num_channels;
2247 ASSERT(clk_table->num_entries);
2248 /* Copy dcn2_1_soc.clock_limits to clock_limits to avoid copying over null states later */
2249 memcpy(&dcn2_1_soc._clock_tmp, &dcn2_1_soc.clock_limits,
2250 sizeof(dcn2_1_soc.clock_limits));
2252 for (i = 0; i < clk_table->num_entries; i++) {
2254 for (closest_clk_lvl = 0, j = dcn2_1_soc.num_states - 1; j >= 0; j--) {
2255 if ((unsigned int) dcn2_1_soc.clock_limits[j].dcfclk_mhz <= clk_table->entries[i].dcfclk_mhz) {
2256 closest_clk_lvl = j;
2261 /* clk_table[1] is reserved for min DF PState. skip here to fill in later. */
2265 dcn2_1_soc._clock_tmp[k].state = k;
2266 dcn2_1_soc._clock_tmp[k].dcfclk_mhz = clk_table->entries[i].dcfclk_mhz;
2267 dcn2_1_soc._clock_tmp[k].fabricclk_mhz = clk_table->entries[i].fclk_mhz;
2268 dcn2_1_soc._clock_tmp[k].socclk_mhz = clk_table->entries[i].socclk_mhz;
2269 dcn2_1_soc._clock_tmp[k].dram_speed_mts = clk_table->entries[i].memclk_mhz * 2;
2271 dcn2_1_soc._clock_tmp[k].dispclk_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].dispclk_mhz;
2272 dcn2_1_soc._clock_tmp[k].dppclk_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].dppclk_mhz;
2273 dcn2_1_soc._clock_tmp[k].dram_bw_per_chan_gbps = dcn2_1_soc.clock_limits[closest_clk_lvl].dram_bw_per_chan_gbps;
2274 dcn2_1_soc._clock_tmp[k].dscclk_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].dscclk_mhz;
2275 dcn2_1_soc._clock_tmp[k].dtbclk_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].dtbclk_mhz;
2276 dcn2_1_soc._clock_tmp[k].phyclk_d18_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].phyclk_d18_mhz;
2277 dcn2_1_soc._clock_tmp[k].phyclk_mhz = dcn2_1_soc.clock_limits[closest_clk_lvl].phyclk_mhz;
2282 memcpy(&dcn2_1_soc.clock_limits, &dcn2_1_soc._clock_tmp,
2283 sizeof(dcn2_1_soc.clock_limits));
2285 if (clk_table->num_entries) {
2286 dcn2_1_soc.num_states = clk_table->num_entries + 1;
2287 /* fill in min DF PState */
2288 dcn2_1_soc.clock_limits[1] = construct_low_pstate_lvl(clk_table, closest_clk_lvl);
2289 /* duplicate last level */
2290 dcn2_1_soc.clock_limits[dcn2_1_soc.num_states] = dcn2_1_soc.clock_limits[dcn2_1_soc.num_states - 1];
2291 dcn2_1_soc.clock_limits[dcn2_1_soc.num_states].state = dcn2_1_soc.num_states;
2294 dml_init_instance(&dc->dml, &dcn2_1_soc, &dcn2_1_ip, DML_PROJECT_DCN21);
2297 void dcn21_clk_mgr_set_bw_params_wm_table(struct clk_bw_params *bw_params)
2299 dc_assert_fp_enabled();
2301 bw_params->wm_table.entries[WM_D].pstate_latency_us = LPDDR_MEM_RETRAIN_LATENCY;
2302 bw_params->wm_table.entries[WM_D].wm_inst = WM_D;
2303 bw_params->wm_table.entries[WM_D].wm_type = WM_TYPE_RETRAINING;
2304 bw_params->wm_table.entries[WM_D].valid = true;
2307 void dcn201_populate_dml_writeback_from_context_fpu(struct dc *dc,
2308 struct resource_context *res_ctx,
2309 display_e2e_pipe_params_st *pipes)
2312 double max_calc_writeback_dispclk;
2313 double writeback_dispclk;
2314 struct writeback_st dout_wb;
2316 dc_assert_fp_enabled();
2318 for (i = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; i++) {
2319 struct dc_stream_state *stream = res_ctx->pipe_ctx[i].stream;
2323 max_calc_writeback_dispclk = 0;
2325 /* Set writeback information */
2326 pipes[pipe_cnt].dout.wb_enable = 0;
2327 pipes[pipe_cnt].dout.num_active_wb = 0;
2328 for (j = 0; j < stream->num_wb_info; j++) {
2329 struct dc_writeback_info *wb_info = &stream->writeback_info[j];
2331 if (wb_info->wb_enabled && wb_info->writeback_source_plane &&
2332 (wb_info->writeback_source_plane == res_ctx->pipe_ctx[i].plane_state)) {
2333 pipes[pipe_cnt].dout.wb_enable = 1;
2334 pipes[pipe_cnt].dout.num_active_wb++;
2335 dout_wb.wb_src_height = wb_info->dwb_params.cnv_params.crop_en ?
2336 wb_info->dwb_params.cnv_params.crop_height :
2337 wb_info->dwb_params.cnv_params.src_height;
2338 dout_wb.wb_src_width = wb_info->dwb_params.cnv_params.crop_en ?
2339 wb_info->dwb_params.cnv_params.crop_width :
2340 wb_info->dwb_params.cnv_params.src_width;
2341 dout_wb.wb_dst_width = wb_info->dwb_params.dest_width;
2342 dout_wb.wb_dst_height = wb_info->dwb_params.dest_height;
2343 dout_wb.wb_htaps_luma = wb_info->dwb_params.scaler_taps.h_taps;
2344 dout_wb.wb_vtaps_luma = wb_info->dwb_params.scaler_taps.v_taps;
2345 dout_wb.wb_htaps_chroma = wb_info->dwb_params.scaler_taps.h_taps_c;
2346 dout_wb.wb_vtaps_chroma = wb_info->dwb_params.scaler_taps.v_taps_c;
2347 dout_wb.wb_hratio = wb_info->dwb_params.cnv_params.crop_en ?
2348 (double)wb_info->dwb_params.cnv_params.crop_width /
2349 (double)wb_info->dwb_params.dest_width :
2350 (double)wb_info->dwb_params.cnv_params.src_width /
2351 (double)wb_info->dwb_params.dest_width;
2352 dout_wb.wb_vratio = wb_info->dwb_params.cnv_params.crop_en ?
2353 (double)wb_info->dwb_params.cnv_params.crop_height /
2354 (double)wb_info->dwb_params.dest_height :
2355 (double)wb_info->dwb_params.cnv_params.src_height /
2356 (double)wb_info->dwb_params.dest_height;
2357 if (wb_info->dwb_params.out_format == dwb_scaler_mode_yuv420) {
2358 if (wb_info->dwb_params.output_depth == DWB_OUTPUT_PIXEL_DEPTH_8BPC)
2359 dout_wb.wb_pixel_format = dm_420_8;
2361 dout_wb.wb_pixel_format = dm_420_10;
2363 dout_wb.wb_pixel_format = dm_444_32;
2365 /* Workaround for cases where multiple writebacks are connected to same plane
2366 * In which case, need to compute worst case and set the associated writeback parameters
2367 * This workaround is necessary due to DML computation assuming only 1 set of writeback
2368 * parameters per pipe */
2369 writeback_dispclk = CalculateWriteBackDISPCLK(
2370 dout_wb.wb_pixel_format,
2371 pipes[pipe_cnt].pipe.dest.pixel_rate_mhz,
2374 dout_wb.wb_htaps_luma,
2375 dout_wb.wb_vtaps_luma,
2376 dout_wb.wb_htaps_chroma,
2377 dout_wb.wb_vtaps_chroma,
2378 dout_wb.wb_dst_width,
2379 pipes[pipe_cnt].pipe.dest.htotal,
2382 if (writeback_dispclk > max_calc_writeback_dispclk) {
2383 max_calc_writeback_dispclk = writeback_dispclk;
2384 pipes[pipe_cnt].dout.wb = dout_wb;