2 * Copyright 2022 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
26 // header file of functions being implemented
27 #include "dcn32_resource.h"
28 #include "dcn20/dcn20_resource.h"
29 #include "dml/dcn32/display_mode_vba_util_32.h"
30 #include "dml/dcn32/dcn32_fpu.h"
32 static bool is_dual_plane(enum surface_pixel_format format)
34 return format >= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN || format == SURFACE_PIXEL_FORMAT_GRPH_RGBE_ALPHA;
38 uint32_t dcn32_helper_mall_bytes_to_ways(
40 uint32_t total_size_in_mall_bytes)
42 uint32_t cache_lines_used, lines_per_way, total_cache_lines, num_ways;
44 /* add 2 lines for worst case alignment */
45 cache_lines_used = total_size_in_mall_bytes / dc->caps.cache_line_size + 2;
47 total_cache_lines = dc->caps.max_cab_allocation_bytes / dc->caps.cache_line_size;
48 lines_per_way = total_cache_lines / dc->caps.cache_num_ways;
49 num_ways = cache_lines_used / lines_per_way;
50 if (cache_lines_used % lines_per_way > 0)
56 uint32_t dcn32_helper_calculate_mall_bytes_for_cursor(
58 struct pipe_ctx *pipe_ctx,
59 bool ignore_cursor_buf)
61 struct hubp *hubp = pipe_ctx->plane_res.hubp;
62 uint32_t cursor_size = hubp->curs_attr.pitch * hubp->curs_attr.height;
63 uint32_t cursor_mall_size_bytes = 0;
65 switch (pipe_ctx->stream->cursor_attributes.color_format) {
66 case CURSOR_MODE_MONO:
69 case CURSOR_MODE_COLOR_1BIT_AND:
70 case CURSOR_MODE_COLOR_PRE_MULTIPLIED_ALPHA:
71 case CURSOR_MODE_COLOR_UN_PRE_MULTIPLIED_ALPHA:
75 case CURSOR_MODE_COLOR_64BIT_FP_PRE_MULTIPLIED:
76 case CURSOR_MODE_COLOR_64BIT_FP_UN_PRE_MULTIPLIED:
81 /* only count if cursor is enabled, and if additional allocation needed outside of the
84 if (pipe_ctx->stream->cursor_position.enable && (ignore_cursor_buf ||
85 cursor_size > 16384)) {
86 /* cursor_num_mblk = CEILING(num_cursors*cursor_width*cursor_width*cursor_Bpe/mblk_bytes, 1)
87 * Note: add 1 mblk in case of cursor misalignment
89 cursor_mall_size_bytes = ((cursor_size + DCN3_2_MALL_MBLK_SIZE_BYTES - 1) /
90 DCN3_2_MALL_MBLK_SIZE_BYTES + 1) * DCN3_2_MALL_MBLK_SIZE_BYTES;
93 return cursor_mall_size_bytes;
97 * dcn32_helper_calculate_num_ways_for_subvp(): Calculate number of ways needed for SubVP
99 * Gets total allocation required for the phantom viewport calculated by DML in bytes and
100 * converts to number of cache ways.
102 * @dc: current dc state
103 * @context: new dc state
105 * Return: number of ways required for SubVP
107 uint32_t dcn32_helper_calculate_num_ways_for_subvp(
109 struct dc_state *context)
111 if (context->bw_ctx.bw.dcn.mall_subvp_size_bytes > 0) {
112 if (dc->debug.force_subvp_num_ways) {
113 return dc->debug.force_subvp_num_ways;
115 return dcn32_helper_mall_bytes_to_ways(dc, context->bw_ctx.bw.dcn.mall_subvp_size_bytes);
122 void dcn32_merge_pipes_for_subvp(struct dc *dc,
123 struct dc_state *context)
127 /* merge pipes if necessary */
128 for (i = 0; i < dc->res_pool->pipe_count; i++) {
129 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
131 // For now merge all pipes for SubVP since pipe split case isn't supported yet
133 /* if ODM merge we ignore mpc tree, mpo pipes will have their own flags */
134 if (pipe->prev_odm_pipe) {
135 /*split off odm pipe*/
136 pipe->prev_odm_pipe->next_odm_pipe = pipe->next_odm_pipe;
137 if (pipe->next_odm_pipe)
138 pipe->next_odm_pipe->prev_odm_pipe = pipe->prev_odm_pipe;
140 pipe->bottom_pipe = NULL;
141 pipe->next_odm_pipe = NULL;
142 pipe->plane_state = NULL;
144 pipe->top_pipe = NULL;
145 pipe->prev_odm_pipe = NULL;
146 if (pipe->stream_res.dsc)
147 dcn20_release_dsc(&context->res_ctx, dc->res_pool, &pipe->stream_res.dsc);
148 memset(&pipe->plane_res, 0, sizeof(pipe->plane_res));
149 memset(&pipe->stream_res, 0, sizeof(pipe->stream_res));
150 } else if (pipe->top_pipe && pipe->top_pipe->plane_state == pipe->plane_state) {
151 struct pipe_ctx *top_pipe = pipe->top_pipe;
152 struct pipe_ctx *bottom_pipe = pipe->bottom_pipe;
154 top_pipe->bottom_pipe = bottom_pipe;
156 bottom_pipe->top_pipe = top_pipe;
158 pipe->top_pipe = NULL;
159 pipe->bottom_pipe = NULL;
160 pipe->plane_state = NULL;
162 memset(&pipe->plane_res, 0, sizeof(pipe->plane_res));
163 memset(&pipe->stream_res, 0, sizeof(pipe->stream_res));
168 bool dcn32_all_pipes_have_stream_and_plane(struct dc *dc,
169 struct dc_state *context)
173 for (i = 0; i < dc->res_pool->pipe_count; i++) {
174 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
179 if (!pipe->plane_state)
185 bool dcn32_subvp_in_use(struct dc *dc,
186 struct dc_state *context)
190 for (i = 0; i < dc->res_pool->pipe_count; i++) {
191 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
193 if (pipe->stream && pipe->stream->mall_stream_config.type != SUBVP_NONE)
199 bool dcn32_mpo_in_use(struct dc_state *context)
203 for (i = 0; i < context->stream_count; i++) {
204 if (context->stream_status[i].plane_count > 1)
211 bool dcn32_any_surfaces_rotated(struct dc *dc, struct dc_state *context)
215 for (i = 0; i < dc->res_pool->pipe_count; i++) {
216 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
221 if (pipe->plane_state && pipe->plane_state->rotation != ROTATION_ANGLE_0)
227 bool dcn32_is_center_timing(struct pipe_ctx *pipe)
229 bool is_center_timing = false;
232 if (pipe->stream->timing.v_addressable != pipe->stream->dst.height ||
233 pipe->stream->timing.v_addressable != pipe->stream->src.height) {
234 is_center_timing = true;
238 if (pipe->plane_state) {
239 if (pipe->stream->timing.v_addressable != pipe->plane_state->dst_rect.height &&
240 pipe->stream->timing.v_addressable != pipe->plane_state->src_rect.height) {
241 is_center_timing = true;
245 return is_center_timing;
248 bool dcn32_is_psr_capable(struct pipe_ctx *pipe)
250 bool psr_capable = false;
252 if (pipe->stream && pipe->stream->link->psr_settings.psr_version != DC_PSR_VERSION_UNSUPPORTED) {
259 * dcn32_determine_det_override(): Determine DET allocation for each pipe
261 * This function determines how much DET to allocate for each pipe. The total number of
262 * DET segments will be split equally among each of the streams, and after that the DET
263 * segments per stream will be split equally among the planes for the given stream.
265 * If there is a plane that's driven by more than 1 pipe (i.e. pipe split), then the
266 * number of DET for that given plane will be split among the pipes driving that plane.
269 * High level algorithm:
270 * 1. Split total DET among number of streams
271 * 2. For each stream, split DET among the planes
272 * 3. For each plane, check if there is a pipe split. If yes, split the DET allocation
274 * 4. Assign the DET override to the DML pipes.
276 * @dc: Current DC state
277 * @context: New DC state to be programmed
278 * @pipes: Array of DML pipes
282 void dcn32_determine_det_override(struct dc *dc,
283 struct dc_state *context,
284 display_e2e_pipe_params_st *pipes)
287 uint8_t pipe_plane_count, stream_segments, plane_segments, pipe_segments[MAX_PIPES] = {0};
288 uint8_t pipe_counted[MAX_PIPES] = {0};
289 uint8_t pipe_cnt = 0;
290 struct dc_plane_state *current_plane = NULL;
291 uint8_t stream_count = 0;
293 for (i = 0; i < context->stream_count; i++) {
294 /* Don't count SubVP streams for DET allocation */
295 if (context->streams[i]->mall_stream_config.type != SUBVP_PHANTOM)
299 if (stream_count > 0) {
300 stream_segments = 18 / stream_count;
301 for (i = 0; i < context->stream_count; i++) {
302 if (context->streams[i]->mall_stream_config.type == SUBVP_PHANTOM)
305 if (context->stream_status[i].plane_count > 0)
306 plane_segments = stream_segments / context->stream_status[i].plane_count;
308 plane_segments = stream_segments;
309 for (j = 0; j < dc->res_pool->pipe_count; j++) {
310 pipe_plane_count = 0;
311 if (context->res_ctx.pipe_ctx[j].stream == context->streams[i] &&
312 pipe_counted[j] != 1) {
313 /* Note: pipe_plane_count indicates the number of pipes to be used for a
314 * given plane. e.g. pipe_plane_count = 1 means single pipe (i.e. not split),
315 * pipe_plane_count = 2 means 2:1 split, etc.
319 current_plane = context->res_ctx.pipe_ctx[j].plane_state;
320 for (k = 0; k < dc->res_pool->pipe_count; k++) {
321 if (k != j && context->res_ctx.pipe_ctx[k].stream == context->streams[i] &&
322 context->res_ctx.pipe_ctx[k].plane_state == current_plane) {
328 pipe_segments[j] = plane_segments / pipe_plane_count;
329 for (k = 0; k < dc->res_pool->pipe_count; k++) {
330 if (k != j && context->res_ctx.pipe_ctx[k].stream == context->streams[i] &&
331 context->res_ctx.pipe_ctx[k].plane_state == current_plane) {
332 pipe_segments[k] = plane_segments / pipe_plane_count;
339 for (i = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; i++) {
340 if (!context->res_ctx.pipe_ctx[i].stream)
342 pipes[pipe_cnt].pipe.src.det_size_override = pipe_segments[i] * DCN3_2_DET_SEG_SIZE;
346 for (i = 0; i < dc->res_pool->pipe_count; i++)
347 pipes[i].pipe.src.det_size_override = 4 * DCN3_2_DET_SEG_SIZE; //DCN3_2_DEFAULT_DET_SIZE
351 void dcn32_set_det_allocations(struct dc *dc, struct dc_state *context,
352 display_e2e_pipe_params_st *pipes)
355 struct resource_context *res_ctx = &context->res_ctx;
356 struct pipe_ctx *pipe;
357 bool disable_unbounded_requesting = dc->debug.disable_z9_mpc || dc->debug.disable_unbounded_requesting;
359 for (i = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; i++) {
361 if (!res_ctx->pipe_ctx[i].stream)
364 pipe = &res_ctx->pipe_ctx[i];
368 /* For DET allocation, we don't want to use DML policy (not optimal for utilizing all
369 * the DET available for each pipe). Use the DET override input to maintain our driver
373 pipes[0].pipe.src.det_size_override = DCN3_2_MAX_DET_SIZE;
374 if (pipe->plane_state && !disable_unbounded_requesting && pipe->plane_state->tiling_info.gfx9.swizzle != DC_SW_LINEAR) {
375 if (!is_dual_plane(pipe->plane_state->format)) {
376 pipes[0].pipe.src.det_size_override = DCN3_2_DEFAULT_DET_SIZE;
377 pipes[0].pipe.src.unbounded_req_mode = true;
378 if (pipe->plane_state->src_rect.width >= 5120 &&
379 pipe->plane_state->src_rect.height >= 2880)
380 pipes[0].pipe.src.det_size_override = 320; // 5K or higher
384 dcn32_determine_det_override(dc, context, pipes);
388 * dcn32_save_mall_state(): Save MALL (SubVP) state for fast validation cases
390 * This function saves the MALL (SubVP) case for fast validation cases. For fast validation,
391 * there are situations where a shallow copy of the dc->current_state is created for the
392 * validation. In this case we want to save and restore the mall config because we always
393 * teardown subvp at the beginning of validation (and don't attempt to add it back if it's
394 * fast validation). If we don't restore the subvp config in cases of fast validation +
395 * shallow copy of the dc->current_state, the dc->current_state will have a partially
396 * removed subvp state when we did not intend to remove it.
398 * NOTE: This function ONLY works if the streams are not moved to a different pipe in the
399 * validation. We don't expect this to happen in fast_validation=1 cases.
401 * @dc: Current DC state
402 * @context: New DC state to be programmed
403 * @temp_config: struct used to cache the existing MALL state
407 void dcn32_save_mall_state(struct dc *dc,
408 struct dc_state *context,
409 struct mall_temp_config *temp_config)
413 for (i = 0; i < dc->res_pool->pipe_count; i++) {
414 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
417 temp_config->mall_stream_config[i] = pipe->stream->mall_stream_config;
419 if (pipe->plane_state)
420 temp_config->is_phantom_plane[i] = pipe->plane_state->is_phantom;
425 * dcn32_restore_mall_state(): Restore MALL (SubVP) state for fast validation cases
427 * Restore the MALL state based on the previously saved state from dcn32_save_mall_state
429 * @dc: Current DC state
430 * @context: New DC state to be programmed, restore MALL state into here
431 * @temp_config: struct that has the cached MALL state
435 void dcn32_restore_mall_state(struct dc *dc,
436 struct dc_state *context,
437 struct mall_temp_config *temp_config)
441 for (i = 0; i < dc->res_pool->pipe_count; i++) {
442 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
445 pipe->stream->mall_stream_config = temp_config->mall_stream_config[i];
447 if (pipe->plane_state)
448 pipe->plane_state->is_phantom = temp_config->is_phantom_plane[i];
452 #define MAX_STRETCHED_V_BLANK 1000 // in micro-seconds (must ensure to match value in FW)
454 * Scaling factor for v_blank stretch calculations considering timing in
455 * micro-seconds and pixel clock in 100hz.
456 * Note: the parenthesis are necessary to ensure the correct order of
457 * operation where V_SCALE is used.
459 #define V_SCALE (10000 / MAX_STRETCHED_V_BLANK)
461 static int get_frame_rate_at_max_stretch_100hz(
462 struct dc_stream_state *fpo_candidate_stream,
463 uint32_t fpo_vactive_margin_us)
465 struct dc_crtc_timing *timing = NULL;
466 uint32_t sec_per_100_lines;
467 uint32_t max_v_blank;
468 uint32_t curr_v_blank;
469 uint32_t v_stretch_max;
470 uint32_t stretched_frame_pix_cnt;
471 uint32_t scaled_stretched_frame_pix_cnt;
472 uint32_t scaled_refresh_rate;
475 if (fpo_candidate_stream == NULL)
478 /* check if refresh rate at least 120hz */
479 timing = &fpo_candidate_stream->timing;
483 v_scale = 10000 / (MAX_STRETCHED_V_BLANK + fpo_vactive_margin_us);
485 sec_per_100_lines = timing->pix_clk_100hz / timing->h_total + 1;
486 max_v_blank = sec_per_100_lines / v_scale + 1;
487 curr_v_blank = timing->v_total - timing->v_addressable;
488 v_stretch_max = (max_v_blank > curr_v_blank) ? (max_v_blank - curr_v_blank) : (0);
489 stretched_frame_pix_cnt = (v_stretch_max + timing->v_total) * timing->h_total;
490 scaled_stretched_frame_pix_cnt = stretched_frame_pix_cnt / 10000;
491 scaled_refresh_rate = (timing->pix_clk_100hz) / scaled_stretched_frame_pix_cnt + 1;
493 return scaled_refresh_rate;
497 static bool is_refresh_rate_support_mclk_switch_using_fw_based_vblank_stretch(
498 struct dc_stream_state *fpo_candidate_stream, uint32_t fpo_vactive_margin_us)
500 int refresh_rate_max_stretch_100hz;
501 int min_refresh_100hz;
503 if (fpo_candidate_stream == NULL)
506 refresh_rate_max_stretch_100hz = get_frame_rate_at_max_stretch_100hz(fpo_candidate_stream, fpo_vactive_margin_us);
507 min_refresh_100hz = fpo_candidate_stream->timing.min_refresh_in_uhz / 10000;
509 if (refresh_rate_max_stretch_100hz < min_refresh_100hz)
515 static int get_refresh_rate(struct dc_stream_state *fpo_candidate_stream)
517 int refresh_rate = 0;
519 struct dc_crtc_timing *timing = NULL;
521 if (fpo_candidate_stream == NULL)
524 /* check if refresh rate at least 120hz */
525 timing = &fpo_candidate_stream->timing;
529 h_v_total = timing->h_total * timing->v_total;
533 refresh_rate = ((timing->pix_clk_100hz * 100) / (h_v_total)) + 1;
538 * dcn32_can_support_mclk_switch_using_fw_based_vblank_stretch() - Determines if config can
541 * @dc: current dc state
542 * @context: new dc state
544 * Return: Pointer to FPO stream candidate if config can support FPO, otherwise NULL
546 struct dc_stream_state *dcn32_can_support_mclk_switch_using_fw_based_vblank_stretch(struct dc *dc, const struct dc_state *context)
548 int refresh_rate = 0;
549 const int minimum_refreshrate_supported = 120;
550 struct dc_stream_state *fpo_candidate_stream = NULL;
551 bool is_fpo_vactive = false;
552 uint32_t fpo_vactive_margin_us = 0;
557 if (dc->debug.disable_fams)
560 if (!dc->caps.dmub_caps.mclk_sw)
563 if (context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching_shut_down)
566 /* For FPO we can support up to 2 display configs if:
567 * - first display uses FPO
568 * - Second display switches in VACTIVE */
569 if (context->stream_count > 2)
571 else if (context->stream_count == 2) {
573 dcn32_assign_fpo_vactive_candidate(dc, context, &fpo_candidate_stream);
577 is_fpo_vactive = dcn32_find_vactive_pipe(dc, context, dc->debug.fpo_vactive_min_active_margin_us);
579 if (!is_fpo_vactive || dc->debug.disable_fpo_vactive)
582 fpo_candidate_stream = context->streams[0];
584 if (!fpo_candidate_stream)
587 if (fpo_candidate_stream->sink->edid_caps.panel_patch.disable_fams)
590 refresh_rate = get_refresh_rate(fpo_candidate_stream);
591 if (refresh_rate < minimum_refreshrate_supported)
594 fpo_vactive_margin_us = is_fpo_vactive ? dc->debug.fpo_vactive_margin_us : 0; // For now hardcode the FPO + Vactive stretch margin to be 2000us
595 if (!is_refresh_rate_support_mclk_switch_using_fw_based_vblank_stretch(fpo_candidate_stream, fpo_vactive_margin_us))
598 if (!fpo_candidate_stream->allow_freesync)
601 if (fpo_candidate_stream->vrr_active_variable && dc->debug.disable_fams_gaming)
604 return fpo_candidate_stream;
607 bool dcn32_check_native_scaling_for_res(struct pipe_ctx *pipe, unsigned int width, unsigned int height)
609 bool is_native_scaling = false;
611 if (pipe->stream->timing.h_addressable == width &&
612 pipe->stream->timing.v_addressable == height &&
613 pipe->plane_state->src_rect.width == width &&
614 pipe->plane_state->src_rect.height == height &&
615 pipe->plane_state->dst_rect.width == width &&
616 pipe->plane_state->dst_rect.height == height)
617 is_native_scaling = true;
619 return is_native_scaling;
623 * dcn32_subvp_drr_admissable() - Determine if SubVP + DRR config is admissible
625 * @dc: Current DC state
626 * @context: New DC state to be programmed
628 * SubVP + DRR is admissible under the following conditions:
629 * - Config must have 2 displays (i.e., 2 non-phantom master pipes)
630 * - One display is SubVP
631 * - Other display must have Freesync enabled
632 * - The potential DRR display must not be PSR capable
634 * Return: True if admissible, false otherwise
636 bool dcn32_subvp_drr_admissable(struct dc *dc, struct dc_state *context)
640 uint8_t subvp_count = 0;
641 uint8_t non_subvp_pipes = 0;
642 bool drr_pipe_found = false;
643 bool drr_psr_capable = false;
644 uint64_t refresh_rate = 0;
646 for (i = 0; i < dc->res_pool->pipe_count; i++) {
647 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
652 if (pipe->plane_state && !pipe->top_pipe) {
653 if (pipe->stream->mall_stream_config.type == SUBVP_MAIN) {
656 refresh_rate = (pipe->stream->timing.pix_clk_100hz * (uint64_t)100 +
657 pipe->stream->timing.v_total * pipe->stream->timing.h_total - (uint64_t)1);
658 refresh_rate = div_u64(refresh_rate, pipe->stream->timing.v_total);
659 refresh_rate = div_u64(refresh_rate, pipe->stream->timing.h_total);
661 if (pipe->stream->mall_stream_config.type == SUBVP_NONE) {
663 drr_psr_capable = (drr_psr_capable || dcn32_is_psr_capable(pipe));
664 if (pipe->stream->ignore_msa_timing_param &&
665 (pipe->stream->allow_freesync || pipe->stream->vrr_active_variable)) {
666 drr_pipe_found = true;
672 if (subvp_count == 1 && non_subvp_pipes == 1 && drr_pipe_found && !drr_psr_capable &&
673 ((uint32_t)refresh_rate < 120))
680 * dcn32_subvp_vblank_admissable() - Determine if SubVP + Vblank config is admissible
682 * @dc: Current DC state
683 * @context: New DC state to be programmed
684 * @vlevel: Voltage level calculated by DML
686 * SubVP + Vblank is admissible under the following conditions:
687 * - Config must have 2 displays (i.e., 2 non-phantom master pipes)
688 * - One display is SubVP
689 * - Other display must not have Freesync capability
690 * - DML must have output DRAM clock change support as SubVP + Vblank
691 * - The potential vblank display must not be PSR capable
693 * Return: True if admissible, false otherwise
695 bool dcn32_subvp_vblank_admissable(struct dc *dc, struct dc_state *context, int vlevel)
699 uint8_t subvp_count = 0;
700 uint8_t non_subvp_pipes = 0;
701 bool drr_pipe_found = false;
702 struct vba_vars_st *vba = &context->bw_ctx.dml.vba;
703 bool vblank_psr_capable = false;
704 uint64_t refresh_rate = 0;
706 for (i = 0; i < dc->res_pool->pipe_count; i++) {
707 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
712 if (pipe->plane_state && !pipe->top_pipe) {
713 if (pipe->stream->mall_stream_config.type == SUBVP_MAIN) {
716 refresh_rate = (pipe->stream->timing.pix_clk_100hz * (uint64_t)100 +
717 pipe->stream->timing.v_total * pipe->stream->timing.h_total - (uint64_t)1);
718 refresh_rate = div_u64(refresh_rate, pipe->stream->timing.v_total);
719 refresh_rate = div_u64(refresh_rate, pipe->stream->timing.h_total);
721 if (pipe->stream->mall_stream_config.type == SUBVP_NONE) {
723 vblank_psr_capable = (vblank_psr_capable || dcn32_is_psr_capable(pipe));
724 if (pipe->stream->ignore_msa_timing_param &&
725 (pipe->stream->allow_freesync || pipe->stream->vrr_active_variable)) {
726 drr_pipe_found = true;
732 if (subvp_count == 1 && non_subvp_pipes == 1 && !drr_pipe_found && !vblank_psr_capable &&
733 ((uint32_t)refresh_rate < 120) &&
734 vba->DRAMClockChangeSupport[vlevel][vba->maxMpcComb] == dm_dram_clock_change_vblank_w_mall_sub_vp)