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/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"
31 #include "dc_state_priv.h"
33 static bool is_dual_plane(enum surface_pixel_format format)
35 return format >= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN || format == SURFACE_PIXEL_FORMAT_GRPH_RGBE_ALPHA;
39 uint32_t dcn32_helper_mall_bytes_to_ways(
41 uint32_t total_size_in_mall_bytes)
43 uint32_t cache_lines_used, lines_per_way, total_cache_lines, num_ways;
45 /* add 2 lines for worst case alignment */
46 cache_lines_used = total_size_in_mall_bytes / dc->caps.cache_line_size + 2;
48 total_cache_lines = dc->caps.max_cab_allocation_bytes / dc->caps.cache_line_size;
49 lines_per_way = total_cache_lines / dc->caps.cache_num_ways;
50 num_ways = cache_lines_used / lines_per_way;
51 if (cache_lines_used % lines_per_way > 0)
57 uint32_t dcn32_helper_calculate_mall_bytes_for_cursor(
59 struct pipe_ctx *pipe_ctx,
60 bool ignore_cursor_buf)
62 struct hubp *hubp = pipe_ctx->plane_res.hubp;
63 uint32_t cursor_size = hubp->curs_attr.pitch * hubp->curs_attr.height;
64 uint32_t cursor_mall_size_bytes = 0;
66 switch (pipe_ctx->stream->cursor_attributes.color_format) {
67 case CURSOR_MODE_MONO:
70 case CURSOR_MODE_COLOR_1BIT_AND:
71 case CURSOR_MODE_COLOR_PRE_MULTIPLIED_ALPHA:
72 case CURSOR_MODE_COLOR_UN_PRE_MULTIPLIED_ALPHA:
76 case CURSOR_MODE_COLOR_64BIT_FP_PRE_MULTIPLIED:
77 case CURSOR_MODE_COLOR_64BIT_FP_UN_PRE_MULTIPLIED:
82 /* only count if cursor is enabled, and if additional allocation needed outside of the
85 if (pipe_ctx->stream->cursor_position.enable && (ignore_cursor_buf ||
86 cursor_size > 16384)) {
87 /* cursor_num_mblk = CEILING(num_cursors*cursor_width*cursor_width*cursor_Bpe/mblk_bytes, 1)
88 * Note: add 1 mblk in case of cursor misalignment
90 cursor_mall_size_bytes = ((cursor_size + DCN3_2_MALL_MBLK_SIZE_BYTES - 1) /
91 DCN3_2_MALL_MBLK_SIZE_BYTES + 1) * DCN3_2_MALL_MBLK_SIZE_BYTES;
94 return cursor_mall_size_bytes;
98 * dcn32_helper_calculate_num_ways_for_subvp(): Calculate number of ways needed for SubVP
100 * Gets total allocation required for the phantom viewport calculated by DML in bytes and
101 * converts to number of cache ways.
103 * @dc: current dc state
104 * @context: new dc state
106 * Return: number of ways required for SubVP
108 uint32_t dcn32_helper_calculate_num_ways_for_subvp(
110 struct dc_state *context)
112 if (context->bw_ctx.bw.dcn.mall_subvp_size_bytes > 0) {
113 if (dc->debug.force_subvp_num_ways) {
114 return dc->debug.force_subvp_num_ways;
116 return dcn32_helper_mall_bytes_to_ways(dc, context->bw_ctx.bw.dcn.mall_subvp_size_bytes);
123 void dcn32_merge_pipes_for_subvp(struct dc *dc,
124 struct dc_state *context)
128 /* merge pipes if necessary */
129 for (i = 0; i < dc->res_pool->pipe_count; i++) {
130 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
132 // For now merge all pipes for SubVP since pipe split case isn't supported yet
134 /* if ODM merge we ignore mpc tree, mpo pipes will have their own flags */
135 if (pipe->prev_odm_pipe) {
136 /*split off odm pipe*/
137 pipe->prev_odm_pipe->next_odm_pipe = pipe->next_odm_pipe;
138 if (pipe->next_odm_pipe)
139 pipe->next_odm_pipe->prev_odm_pipe = pipe->prev_odm_pipe;
141 pipe->bottom_pipe = NULL;
142 pipe->next_odm_pipe = NULL;
143 pipe->plane_state = NULL;
145 pipe->top_pipe = NULL;
146 pipe->prev_odm_pipe = NULL;
147 if (pipe->stream_res.dsc)
148 dcn20_release_dsc(&context->res_ctx, dc->res_pool, &pipe->stream_res.dsc);
149 memset(&pipe->plane_res, 0, sizeof(pipe->plane_res));
150 memset(&pipe->stream_res, 0, sizeof(pipe->stream_res));
151 } else if (pipe->top_pipe && pipe->top_pipe->plane_state == pipe->plane_state) {
152 struct pipe_ctx *top_pipe = pipe->top_pipe;
153 struct pipe_ctx *bottom_pipe = pipe->bottom_pipe;
155 top_pipe->bottom_pipe = bottom_pipe;
157 bottom_pipe->top_pipe = top_pipe;
159 pipe->top_pipe = NULL;
160 pipe->bottom_pipe = NULL;
161 pipe->plane_state = NULL;
163 memset(&pipe->plane_res, 0, sizeof(pipe->plane_res));
164 memset(&pipe->stream_res, 0, sizeof(pipe->stream_res));
169 bool dcn32_all_pipes_have_stream_and_plane(struct dc *dc,
170 struct dc_state *context)
174 for (i = 0; i < dc->res_pool->pipe_count; i++) {
175 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
180 if (!pipe->plane_state)
186 bool dcn32_mpo_in_use(struct dc_state *context)
190 for (i = 0; i < context->stream_count; i++) {
191 if (context->stream_status[i].plane_count > 1)
198 bool dcn32_any_surfaces_rotated(struct dc *dc, struct dc_state *context)
202 for (i = 0; i < dc->res_pool->pipe_count; i++) {
203 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
208 if (pipe->plane_state && pipe->plane_state->rotation != ROTATION_ANGLE_0)
214 bool dcn32_is_center_timing(struct pipe_ctx *pipe)
216 bool is_center_timing = false;
219 if (pipe->stream->timing.v_addressable != pipe->stream->dst.height ||
220 pipe->stream->timing.v_addressable != pipe->stream->src.height) {
221 is_center_timing = true;
225 if (pipe->plane_state) {
226 if (pipe->stream->timing.v_addressable != pipe->plane_state->dst_rect.height &&
227 pipe->stream->timing.v_addressable != pipe->plane_state->src_rect.height) {
228 is_center_timing = true;
232 return is_center_timing;
235 bool dcn32_is_psr_capable(struct pipe_ctx *pipe)
237 bool psr_capable = false;
239 if (pipe->stream && pipe->stream->link->psr_settings.psr_version != DC_PSR_VERSION_UNSUPPORTED) {
245 static void override_det_for_subvp(struct dc *dc, struct dc_state *context, uint8_t pipe_segments[])
248 uint8_t fhd_count = 0;
249 uint8_t subvp_high_refresh_count = 0;
250 uint8_t stream_count = 0;
252 // Do not override if a stream has multiple planes
253 for (i = 0; i < context->stream_count; i++) {
254 if (context->stream_status[i].plane_count > 1)
257 if (dc_state_get_stream_subvp_type(context, context->streams[i]) != SUBVP_PHANTOM)
261 for (i = 0; i < dc->res_pool->pipe_count; i++) {
262 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
264 if (pipe_ctx->stream && pipe_ctx->plane_state && dc_state_get_pipe_subvp_type(context, pipe_ctx) != SUBVP_PHANTOM) {
265 if (dcn32_allow_subvp_high_refresh_rate(dc, context, pipe_ctx)) {
267 if (pipe_ctx->stream->timing.v_addressable == 1080 && pipe_ctx->stream->timing.h_addressable == 1920) {
270 subvp_high_refresh_count++;
275 if (stream_count == 2 && subvp_high_refresh_count == 2 && fhd_count == 1) {
276 for (i = 0; i < dc->res_pool->pipe_count; i++) {
277 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
279 if (pipe_ctx->stream && pipe_ctx->plane_state && dc_state_get_pipe_subvp_type(context, pipe_ctx) != SUBVP_PHANTOM) {
280 if (pipe_ctx->stream->timing.v_addressable == 1080 && pipe_ctx->stream->timing.h_addressable == 1920) {
281 if (pipe_segments[i] > 4)
282 pipe_segments[i] = 4;
290 * dcn32_determine_det_override(): Determine DET allocation for each pipe
292 * This function determines how much DET to allocate for each pipe. The total number of
293 * DET segments will be split equally among each of the streams, and after that the DET
294 * segments per stream will be split equally among the planes for the given stream.
296 * If there is a plane that's driven by more than 1 pipe (i.e. pipe split), then the
297 * number of DET for that given plane will be split among the pipes driving that plane.
300 * High level algorithm:
301 * 1. Split total DET among number of streams
302 * 2. For each stream, split DET among the planes
303 * 3. For each plane, check if there is a pipe split. If yes, split the DET allocation
305 * 4. Assign the DET override to the DML pipes.
307 * @dc: Current DC state
308 * @context: New DC state to be programmed
309 * @pipes: Array of DML pipes
313 void dcn32_determine_det_override(struct dc *dc,
314 struct dc_state *context,
315 display_e2e_pipe_params_st *pipes)
318 uint8_t pipe_plane_count, stream_segments, plane_segments, pipe_segments[MAX_PIPES] = {0};
319 uint8_t pipe_counted[MAX_PIPES] = {0};
320 uint8_t pipe_cnt = 0;
321 struct dc_plane_state *current_plane = NULL;
322 uint8_t stream_count = 0;
324 for (i = 0; i < context->stream_count; i++) {
325 /* Don't count SubVP streams for DET allocation */
326 if (dc_state_get_stream_subvp_type(context, context->streams[i]) != SUBVP_PHANTOM)
330 if (stream_count > 0) {
331 stream_segments = 18 / stream_count;
332 for (i = 0; i < context->stream_count; i++) {
333 if (dc_state_get_stream_subvp_type(context, context->streams[i]) == SUBVP_PHANTOM)
336 if (context->stream_status[i].plane_count > 0)
337 plane_segments = stream_segments / context->stream_status[i].plane_count;
339 plane_segments = stream_segments;
340 for (j = 0; j < dc->res_pool->pipe_count; j++) {
341 pipe_plane_count = 0;
342 if (context->res_ctx.pipe_ctx[j].stream == context->streams[i] &&
343 pipe_counted[j] != 1) {
344 /* Note: pipe_plane_count indicates the number of pipes to be used for a
345 * given plane. e.g. pipe_plane_count = 1 means single pipe (i.e. not split),
346 * pipe_plane_count = 2 means 2:1 split, etc.
350 current_plane = context->res_ctx.pipe_ctx[j].plane_state;
351 for (k = 0; k < dc->res_pool->pipe_count; k++) {
352 if (k != j && context->res_ctx.pipe_ctx[k].stream == context->streams[i] &&
353 context->res_ctx.pipe_ctx[k].plane_state == current_plane) {
359 pipe_segments[j] = plane_segments / pipe_plane_count;
360 for (k = 0; k < dc->res_pool->pipe_count; k++) {
361 if (k != j && context->res_ctx.pipe_ctx[k].stream == context->streams[i] &&
362 context->res_ctx.pipe_ctx[k].plane_state == current_plane) {
363 pipe_segments[k] = plane_segments / pipe_plane_count;
370 override_det_for_subvp(dc, context, pipe_segments);
371 for (i = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; i++) {
372 if (!context->res_ctx.pipe_ctx[i].stream)
374 pipes[pipe_cnt].pipe.src.det_size_override = pipe_segments[i] * DCN3_2_DET_SEG_SIZE;
378 for (i = 0; i < dc->res_pool->pipe_count; i++)
379 pipes[i].pipe.src.det_size_override = 4 * DCN3_2_DET_SEG_SIZE; //DCN3_2_DEFAULT_DET_SIZE
383 void dcn32_set_det_allocations(struct dc *dc, struct dc_state *context,
384 display_e2e_pipe_params_st *pipes)
387 struct resource_context *res_ctx = &context->res_ctx;
388 struct pipe_ctx *pipe;
389 bool disable_unbounded_requesting = dc->debug.disable_z9_mpc || dc->debug.disable_unbounded_requesting;
391 for (i = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; i++) {
393 if (!res_ctx->pipe_ctx[i].stream)
396 pipe = &res_ctx->pipe_ctx[i];
400 /* For DET allocation, we don't want to use DML policy (not optimal for utilizing all
401 * the DET available for each pipe). Use the DET override input to maintain our driver
405 pipes[0].pipe.src.det_size_override = DCN3_2_MAX_DET_SIZE;
406 if (pipe->plane_state && !disable_unbounded_requesting && pipe->plane_state->tiling_info.gfx9.swizzle != DC_SW_LINEAR) {
407 if (!is_dual_plane(pipe->plane_state->format)) {
408 pipes[0].pipe.src.det_size_override = DCN3_2_DEFAULT_DET_SIZE;
409 pipes[0].pipe.src.unbounded_req_mode = true;
410 if (pipe->plane_state->src_rect.width >= 5120 &&
411 pipe->plane_state->src_rect.height >= 2880)
412 pipes[0].pipe.src.det_size_override = 320; // 5K or higher
416 dcn32_determine_det_override(dc, context, pipes);
419 #define MAX_STRETCHED_V_BLANK 1000 // in micro-seconds (must ensure to match value in FW)
421 * Scaling factor for v_blank stretch calculations considering timing in
422 * micro-seconds and pixel clock in 100hz.
423 * Note: the parenthesis are necessary to ensure the correct order of
424 * operation where V_SCALE is used.
426 #define V_SCALE (10000 / MAX_STRETCHED_V_BLANK)
428 static int get_frame_rate_at_max_stretch_100hz(
429 struct dc_stream_state *fpo_candidate_stream,
430 uint32_t fpo_vactive_margin_us)
432 struct dc_crtc_timing *timing = NULL;
433 uint32_t sec_per_100_lines;
434 uint32_t max_v_blank;
435 uint32_t curr_v_blank;
436 uint32_t v_stretch_max;
437 uint32_t stretched_frame_pix_cnt;
438 uint32_t scaled_stretched_frame_pix_cnt;
439 uint32_t scaled_refresh_rate;
442 if (fpo_candidate_stream == NULL)
445 /* check if refresh rate at least 120hz */
446 timing = &fpo_candidate_stream->timing;
450 v_scale = 10000 / (MAX_STRETCHED_V_BLANK + fpo_vactive_margin_us);
452 sec_per_100_lines = timing->pix_clk_100hz / timing->h_total + 1;
453 max_v_blank = sec_per_100_lines / v_scale + 1;
454 curr_v_blank = timing->v_total - timing->v_addressable;
455 v_stretch_max = (max_v_blank > curr_v_blank) ? (max_v_blank - curr_v_blank) : (0);
456 stretched_frame_pix_cnt = (v_stretch_max + timing->v_total) * timing->h_total;
457 scaled_stretched_frame_pix_cnt = stretched_frame_pix_cnt / 10000;
458 scaled_refresh_rate = (timing->pix_clk_100hz) / scaled_stretched_frame_pix_cnt + 1;
460 return scaled_refresh_rate;
464 static bool is_refresh_rate_support_mclk_switch_using_fw_based_vblank_stretch(
465 struct dc_stream_state *fpo_candidate_stream, uint32_t fpo_vactive_margin_us)
467 int refresh_rate_max_stretch_100hz;
468 int min_refresh_100hz;
470 if (fpo_candidate_stream == NULL)
473 refresh_rate_max_stretch_100hz = get_frame_rate_at_max_stretch_100hz(fpo_candidate_stream, fpo_vactive_margin_us);
474 min_refresh_100hz = fpo_candidate_stream->timing.min_refresh_in_uhz / 10000;
476 if (refresh_rate_max_stretch_100hz < min_refresh_100hz)
482 static int get_refresh_rate(struct dc_stream_state *fpo_candidate_stream)
484 int refresh_rate = 0;
486 struct dc_crtc_timing *timing = NULL;
488 if (fpo_candidate_stream == NULL)
491 /* check if refresh rate at least 120hz */
492 timing = &fpo_candidate_stream->timing;
496 h_v_total = timing->h_total * timing->v_total;
500 refresh_rate = ((timing->pix_clk_100hz * 100) / (h_v_total)) + 1;
505 * dcn32_can_support_mclk_switch_using_fw_based_vblank_stretch() - Determines if config can
508 * @dc: current dc state
509 * @context: new dc state
511 * Return: Pointer to FPO stream candidate if config can support FPO, otherwise NULL
513 struct dc_stream_state *dcn32_can_support_mclk_switch_using_fw_based_vblank_stretch(struct dc *dc, struct dc_state *context)
515 int refresh_rate = 0;
516 const int minimum_refreshrate_supported = 120;
517 struct dc_stream_state *fpo_candidate_stream = NULL;
518 bool is_fpo_vactive = false;
519 uint32_t fpo_vactive_margin_us = 0;
520 struct dc_stream_status *fpo_stream_status = NULL;
525 if (dc->debug.disable_fams)
528 if (!dc->caps.dmub_caps.mclk_sw)
531 if (context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching_shut_down)
534 /* For FPO we can support up to 2 display configs if:
535 * - first display uses FPO
536 * - Second display switches in VACTIVE */
537 if (context->stream_count > 2)
539 else if (context->stream_count == 2) {
541 dcn32_assign_fpo_vactive_candidate(dc, context, &fpo_candidate_stream);
543 if (fpo_candidate_stream)
544 fpo_stream_status = dc_state_get_stream_status(context, fpo_candidate_stream);
546 is_fpo_vactive = dcn32_find_vactive_pipe(dc, context, dc->debug.fpo_vactive_min_active_margin_us);
548 if (!is_fpo_vactive || dc->debug.disable_fpo_vactive)
551 fpo_candidate_stream = context->streams[0];
552 if (fpo_candidate_stream)
553 fpo_stream_status = dc_state_get_stream_status(context, fpo_candidate_stream);
556 /* In DCN32/321, FPO uses per-pipe P-State force.
557 * If there's no planes, HUBP is power gated and
558 * therefore programming UCLK_PSTATE_FORCE does
559 * nothing (P-State will always be asserted naturally
560 * on a pipe that has HUBP power gated. Therefore we
561 * only want to enable FPO if the FPO pipe has both
562 * a stream and a plane.
564 if (!fpo_candidate_stream || !fpo_stream_status || fpo_stream_status->plane_count == 0)
567 if (fpo_candidate_stream->sink->edid_caps.panel_patch.disable_fams)
570 refresh_rate = get_refresh_rate(fpo_candidate_stream);
571 if (refresh_rate < minimum_refreshrate_supported)
574 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
575 if (!is_refresh_rate_support_mclk_switch_using_fw_based_vblank_stretch(fpo_candidate_stream, fpo_vactive_margin_us))
578 if (!fpo_candidate_stream->allow_freesync)
581 if (fpo_candidate_stream->vrr_active_variable && dc->debug.disable_fams_gaming)
584 return fpo_candidate_stream;
587 bool dcn32_check_native_scaling_for_res(struct pipe_ctx *pipe, unsigned int width, unsigned int height)
589 bool is_native_scaling = false;
591 if (pipe->stream->timing.h_addressable == width &&
592 pipe->stream->timing.v_addressable == height &&
593 pipe->plane_state->src_rect.width == width &&
594 pipe->plane_state->src_rect.height == height &&
595 pipe->plane_state->dst_rect.width == width &&
596 pipe->plane_state->dst_rect.height == height)
597 is_native_scaling = true;
599 return is_native_scaling;
603 * disallow_subvp_in_active_plus_blank() - Function to determine disallowed subvp + drr/vblank configs
605 * @pipe: subvp pipe to be used for the subvp + drr/vblank config
607 * Since subvp is being enabled on more configs (such as 1080p60), we want
608 * to explicitly block any configs that we don't want to enable. We do not
609 * want to enable any 1080p60 (SubVP) + drr / vblank configs since these
610 * are already convered by FPO.
612 * Return: True if disallowed, false otherwise
614 static bool disallow_subvp_in_active_plus_blank(struct pipe_ctx *pipe)
616 bool disallow = false;
618 if (resource_is_pipe_type(pipe, OPP_HEAD) &&
619 resource_is_pipe_type(pipe, DPP_PIPE)) {
620 if (pipe->stream->timing.v_addressable == 1080 && pipe->stream->timing.h_addressable == 1920)
627 * dcn32_subvp_drr_admissable() - Determine if SubVP + DRR config is admissible
629 * @dc: Current DC state
630 * @context: New DC state to be programmed
632 * SubVP + DRR is admissible under the following conditions:
633 * - Config must have 2 displays (i.e., 2 non-phantom master pipes)
634 * - One display is SubVP
635 * - Other display must have Freesync enabled
636 * - The potential DRR display must not be PSR capable
638 * Return: True if admissible, false otherwise
640 bool dcn32_subvp_drr_admissable(struct dc *dc, struct dc_state *context)
644 uint8_t subvp_count = 0;
645 uint8_t non_subvp_pipes = 0;
646 bool drr_pipe_found = false;
647 bool drr_psr_capable = false;
648 uint64_t refresh_rate = 0;
649 bool subvp_disallow = false;
651 for (i = 0; i < dc->res_pool->pipe_count; i++) {
652 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
653 enum mall_stream_type pipe_mall_type = dc_state_get_pipe_subvp_type(context, pipe);
655 if (resource_is_pipe_type(pipe, OPP_HEAD) &&
656 resource_is_pipe_type(pipe, DPP_PIPE)) {
657 if (pipe_mall_type == SUBVP_MAIN) {
660 subvp_disallow |= disallow_subvp_in_active_plus_blank(pipe);
661 refresh_rate = (pipe->stream->timing.pix_clk_100hz * (uint64_t)100 +
662 pipe->stream->timing.v_total * pipe->stream->timing.h_total - (uint64_t)1);
663 refresh_rate = div_u64(refresh_rate, pipe->stream->timing.v_total);
664 refresh_rate = div_u64(refresh_rate, pipe->stream->timing.h_total);
666 if (pipe_mall_type == SUBVP_NONE) {
668 drr_psr_capable = (drr_psr_capable || dcn32_is_psr_capable(pipe));
669 if (pipe->stream->ignore_msa_timing_param &&
670 (pipe->stream->allow_freesync || pipe->stream->vrr_active_variable || pipe->stream->vrr_active_fixed)) {
671 drr_pipe_found = true;
677 if (subvp_count == 1 && !subvp_disallow && non_subvp_pipes == 1 && drr_pipe_found && !drr_psr_capable &&
678 ((uint32_t)refresh_rate < 120))
685 * dcn32_subvp_vblank_admissable() - Determine if SubVP + Vblank config is admissible
687 * @dc: Current DC state
688 * @context: New DC state to be programmed
689 * @vlevel: Voltage level calculated by DML
691 * SubVP + Vblank is admissible under the following conditions:
692 * - Config must have 2 displays (i.e., 2 non-phantom master pipes)
693 * - One display is SubVP
694 * - Other display must not have Freesync capability
695 * - DML must have output DRAM clock change support as SubVP + Vblank
696 * - The potential vblank display must not be PSR capable
698 * Return: True if admissible, false otherwise
700 bool dcn32_subvp_vblank_admissable(struct dc *dc, struct dc_state *context, int vlevel)
704 uint8_t subvp_count = 0;
705 uint8_t non_subvp_pipes = 0;
706 bool drr_pipe_found = false;
707 struct vba_vars_st *vba = &context->bw_ctx.dml.vba;
708 bool vblank_psr_capable = false;
709 uint64_t refresh_rate = 0;
710 bool subvp_disallow = false;
712 for (i = 0; i < dc->res_pool->pipe_count; i++) {
713 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
714 enum mall_stream_type pipe_mall_type = dc_state_get_pipe_subvp_type(context, pipe);
716 if (resource_is_pipe_type(pipe, OPP_HEAD) &&
717 resource_is_pipe_type(pipe, DPP_PIPE)) {
718 if (pipe_mall_type == SUBVP_MAIN) {
721 subvp_disallow |= disallow_subvp_in_active_plus_blank(pipe);
722 refresh_rate = (pipe->stream->timing.pix_clk_100hz * (uint64_t)100 +
723 pipe->stream->timing.v_total * pipe->stream->timing.h_total - (uint64_t)1);
724 refresh_rate = div_u64(refresh_rate, pipe->stream->timing.v_total);
725 refresh_rate = div_u64(refresh_rate, pipe->stream->timing.h_total);
727 if (pipe_mall_type == SUBVP_NONE) {
729 vblank_psr_capable = (vblank_psr_capable || dcn32_is_psr_capable(pipe));
730 if (pipe->stream->ignore_msa_timing_param &&
731 (pipe->stream->allow_freesync || pipe->stream->vrr_active_variable || pipe->stream->vrr_active_fixed)) {
732 drr_pipe_found = true;
738 if (subvp_count == 1 && non_subvp_pipes == 1 && !drr_pipe_found && !vblank_psr_capable &&
739 ((uint32_t)refresh_rate < 120) && !subvp_disallow &&
740 vba->DRAMClockChangeSupport[vlevel][vba->maxMpcComb] == dm_dram_clock_change_vblank_w_mall_sub_vp)
746 void dcn32_update_dml_pipes_odm_policy_based_on_context(struct dc *dc, struct dc_state *context,
747 display_e2e_pipe_params_st *pipes)
750 struct resource_context *res_ctx = &context->res_ctx;
751 struct pipe_ctx *pipe = NULL;
753 for (i = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; i++) {
754 int odm_slice_count = 0;
756 if (!res_ctx->pipe_ctx[i].stream)
758 pipe = &res_ctx->pipe_ctx[i];
759 odm_slice_count = resource_get_odm_slice_count(pipe);
761 if (odm_slice_count == 1)
762 pipes[pipe_cnt].pipe.dest.odm_combine_policy = dm_odm_combine_policy_dal;
763 else if (odm_slice_count == 2)
764 pipes[pipe_cnt].pipe.dest.odm_combine_policy = dm_odm_combine_policy_2to1;
765 else if (odm_slice_count == 4)
766 pipes[pipe_cnt].pipe.dest.odm_combine_policy = dm_odm_combine_policy_4to1;