drm/amd/display: fix check for identity ratio

[Why]
IDENTITY_RATIO check uses 2 bits for integer, which only allows
 checking downscale ratios up to 3.  But we support up to 6x
 downscale

[How]
Update IDENTITY_RATIO to check 3 bits for integer
Add ASSERT to catch if we downscale more than 6x

Signed-off-by: Samson Tam <Samson.Tam@amd.com>
Reviewed-by: Jun Lei <jun.lei@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Samson Tam 2025-01-21 11:01:47 -05:00 committed by Alex Deucher
parent 26873260d3
commit 0d30046476

View File

@ -8,7 +8,7 @@
#include "dc_spl_isharp_filters.h"
#include "spl_debug.h"
#define IDENTITY_RATIO(ratio) (spl_fixpt_u2d19(ratio) == (1 << 19))
#define IDENTITY_RATIO(ratio) (spl_fixpt_u3d19(ratio) == (1 << 19))
#define MIN_VIEWPORT_SIZE 12
static bool spl_is_yuv420(enum spl_pixel_format format)
@ -887,6 +887,8 @@ static bool spl_get_isharp_en(struct spl_in *spl_in,
static void spl_get_taps_non_adaptive_scaler(
struct spl_scratch *spl_scratch, const struct spl_taps *in_taps)
{
bool check_max_downscale = false;
if (in_taps->h_taps == 0) {
if (spl_fixpt_ceil(spl_scratch->scl_data.ratios.horz) > 1)
spl_scratch->scl_data.taps.h_taps = spl_min(2 * spl_fixpt_ceil(
@ -926,6 +928,23 @@ static void spl_get_taps_non_adaptive_scaler(
else
spl_scratch->scl_data.taps.h_taps_c = in_taps->h_taps_c;
/*
* Max downscale supported is 6.0x. Add ASSERT to catch if go beyond that
*/
check_max_downscale = spl_fixpt_le(spl_scratch->scl_data.ratios.horz,
spl_fixpt_from_fraction(6, 1));
SPL_ASSERT(check_max_downscale);
check_max_downscale = spl_fixpt_le(spl_scratch->scl_data.ratios.vert,
spl_fixpt_from_fraction(6, 1));
SPL_ASSERT(check_max_downscale);
check_max_downscale = spl_fixpt_le(spl_scratch->scl_data.ratios.horz_c,
spl_fixpt_from_fraction(6, 1));
SPL_ASSERT(check_max_downscale);
check_max_downscale = spl_fixpt_le(spl_scratch->scl_data.ratios.vert_c,
spl_fixpt_from_fraction(6, 1));
SPL_ASSERT(check_max_downscale);
if (IDENTITY_RATIO(spl_scratch->scl_data.ratios.horz))
spl_scratch->scl_data.taps.h_taps = 1;
if (IDENTITY_RATIO(spl_scratch->scl_data.ratios.vert))