Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amd/display: Include scaling factor for SubVP command

[Description]
For SubVP scaling cases, we must include the scaling
info as part of the cmd. This is required when converting
OTG line to HUBP line for the MALL_START_LINE programming.

Reviewed-by: Jun Lei <Jun.Lei@amd.com>
Acked-by: Brian Chang <Brian.Chang@amd.com>
Signed-off-by: Alvin Lee <Alvin.Lee2@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Alvin Lee and committed by
Alex Deucher
fbe43dcd 385bf5a8

+36 -1
+21
drivers/gpu/drm/amd/display/dc/basics/conversion.c
··· 100 100 matrix[i] = (uint16_t)reg_value; 101 101 } 102 102 } 103 + 104 + static uint32_t find_gcd(uint32_t a, uint32_t b) 105 + { 106 + uint32_t remainder = 0; 107 + while (b != 0) { 108 + remainder = a % b; 109 + a = b; 110 + b = remainder; 111 + } 112 + return a; 113 + } 114 + 115 + void reduce_fraction(uint32_t num, uint32_t den, 116 + uint32_t *out_num, uint32_t *out_den) 117 + { 118 + uint32_t gcd = 0; 119 + 120 + gcd = find_gcd(num, den); 121 + *out_num = num / gcd; 122 + *out_den = den / gcd; 123 + }
+3
drivers/gpu/drm/amd/display/dc/basics/conversion.h
··· 38 38 struct fixed31_32 *flt, 39 39 uint32_t buffer_size); 40 40 41 + void reduce_fraction(uint32_t num, uint32_t den, 42 + uint32_t *out_num, uint32_t *out_den); 43 + 41 44 static inline unsigned int log_2(unsigned int num) 42 45 { 43 46 return ilog2(num);
+11
drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
··· 29 29 #include "dm_helpers.h" 30 30 #include "dc_hw_types.h" 31 31 #include "core_types.h" 32 + #include "../basics/conversion.h" 32 33 33 34 #define CTX dc_dmub_srv->ctx 34 35 #define DC_LOGGER CTX->logger ··· 601 600 &cmd->fw_assisted_mclk_switch_v2.config_data.pipe_data[cmd_pipe_index]; 602 601 struct dc_crtc_timing *main_timing = &subvp_pipe->stream->timing; 603 602 struct dc_crtc_timing *phantom_timing = &subvp_pipe->stream->mall_stream_config.paired_stream->timing; 603 + uint32_t out_num, out_den; 604 604 605 605 pipe_data->mode = SUBVP; 606 606 pipe_data->pipe_config.subvp_data.pix_clk_100hz = subvp_pipe->stream->timing.pix_clk_100hz; ··· 614 612 pipe_data->pipe_config.subvp_data.mall_region_lines = phantom_timing->v_addressable; 615 613 pipe_data->pipe_config.subvp_data.main_pipe_index = subvp_pipe->pipe_idx; 616 614 pipe_data->pipe_config.subvp_data.is_drr = subvp_pipe->stream->ignore_msa_timing_param; 615 + 616 + /* Calculate the scaling factor from the src and dst height. 617 + * e.g. If 3840x2160 being downscaled to 1920x1080, the scaling factor is 1/2. 618 + * Reduce the fraction 1080/2160 = 1/2 for the "scaling factor" 619 + */ 620 + reduce_fraction(subvp_pipe->stream->src.height, subvp_pipe->stream->dst.height, &out_num, &out_den); 621 + // TODO: Uncomment below lines once DMCUB include headers are promoted 622 + //pipe_data->pipe_config.subvp_data.scale_factor_numerator = out_num; 623 + //pipe_data->pipe_config.subvp_data.scale_factor_denominator = out_den; 617 624 618 625 // Prefetch lines is equal to VACTIVE + BP + VSYNC 619 626 pipe_data->pipe_config.subvp_data.prefetch_lines =
+1 -1
drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c
··· 1664 1664 dc->caps.subvp_prefetch_end_to_mall_start_us = 15; 1665 1665 dc->caps.subvp_swath_height_margin_lines = 16; 1666 1666 dc->caps.subvp_pstate_allow_width_us = 20; 1667 - 1667 + dc->caps.subvp_vertical_int_margin_us = 30; 1668 1668 dc->caps.max_slave_planes = 1; 1669 1669 dc->caps.max_slave_yuv_planes = 1; 1670 1670 dc->caps.max_slave_rgb_planes = 1;