Skip to content

Commit

Permalink
drm/amd/display: fix check for identity ratio
Browse files Browse the repository at this point in the history
[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>
  • Loading branch information
Samson Tam authored and Alex Deucher committed Feb 25, 2025
1 parent 2687326 commit 0d30046
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion drivers/gpu/drm/amd/display/dc/sspl/dc_spl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 0d30046

Please sign in to comment.