]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/display: fix check for identity ratio
authorSamson Tam <Samson.Tam@amd.com>
Tue, 21 Jan 2025 16:01:47 +0000 (11:01 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 25 Feb 2025 16:44:02 +0000 (11:44 -0500)
[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>
drivers/gpu/drm/amd/display/dc/sspl/dc_spl.c

index 3d85732cc0f57490464ef7acb870ce8756531d62..047f05ab01810200ddb7f785cb0779661d2b3489 100644 (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))