From: Samson Tam <samson....@amd.com>

[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....@amd.com>
Reviewed-by: Jun Lei <jun....@amd.com>
---
 drivers/gpu/drm/amd/display/dc/sspl/dc_spl.c | 21 +++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/sspl/dc_spl.c 
b/drivers/gpu/drm/amd/display/dc/sspl/dc_spl.c
index 3d85732cc0f5..047f05ab0181 100644
--- a/drivers/gpu/drm/amd/display/dc/sspl/dc_spl.c
+++ b/drivers/gpu/drm/amd/display/dc/sspl/dc_spl.c
@@ -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))
-- 
2.34.1

Reply via email to