[COMMON] media: scaler: modify minimum size check condition.
authorwoncheon.an <woncheon.an@samsung.com>
Wed, 1 Feb 2017 11:35:41 +0000 (20:35 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:22:16 +0000 (20:22 +0300)
There's possibility that intermediate frame size violate to
minimum input size during 2nd operation. but previous code
can't check about minumum size restirction if ratio conditional sentence is false
So intermediate frame size check codes are moved backward

Change-Id: Icf0d01571037dc5f4c95c1acc66db1704370c9d1
Signed-off-by: woncheon.an <woncheon.an@samsung.com>
drivers/media/platform/exynos/scaler/scaler-core.c

index fcc201035f3b8390a0d63be419b694be2c46c4bb..baa4ebac731d1211bdd5cb1aa2892d791e9bd7a3 100644 (file)
@@ -1342,42 +1342,34 @@ static int sc_prepare_2nd_scaling(struct sc_ctx *ctx,
                return -ENOMEM;
 
        limit = &sc->variant->limit_input;
-       if (*v_ratio > SCALE_RATIO_CONST(4, 1)) {
+       if (*v_ratio > SCALE_RATIO_CONST(4, 1))
                crop.height = ((src_height + 7) / 8) * 2;
-               if (crop.height < limit->min_h) {
-                       if (SCALE_RATIO(limit->min_h,
-                                               ctx->d_frame.crop.height) >
-                                       SCALE_RATIO_CONST(4, 1)) {
-                               dev_err(sc->dev,
-                                               "Failed height scale down %d -> %d\n",
-                                               src_height,
-                                               ctx->d_frame.crop.height);
-
-                               free_intermediate_frame(ctx);
-                               return -EINVAL;
-                       }
 
-                       crop.height = limit->min_h;
+       if (crop.height < limit->min_h) {
+               if (SCALE_RATIO(limit->min_h, ctx->d_frame.crop.height)
+                                               > SCALE_RATIO_CONST(4, 1)) {
+                       dev_err(sc->dev, "Failed height scale down %d -> %d\n",
+                               src_height, ctx->d_frame.crop.height);
+
+                       free_intermediate_frame(ctx);
+                       return -EINVAL;
                }
+               crop.height = limit->min_h;
        }
 
-       if (*h_ratio > SCALE_RATIO_CONST(4, 1)) {
+       if (*h_ratio > SCALE_RATIO_CONST(4, 1))
                crop.width = ((src_width + 7) / 8) * 2;
-               if (crop.width < limit->min_w) {
-                       if (SCALE_RATIO(limit->min_w,
-                                               ctx->d_frame.crop.width) >
-                                       SCALE_RATIO_CONST(4, 1)) {
-                               dev_err(sc->dev,
-                                               "Failed width scale down %d -> %d\n",
-                                               src_width,
-                                               ctx->d_frame.crop.width);
-
-                               free_intermediate_frame(ctx);
-                               return -EINVAL;
-                       }
 
-                       crop.width = limit->min_w;
+       if (crop.width < limit->min_w) {
+               if (SCALE_RATIO(limit->min_w, ctx->d_frame.crop.width)
+                                               > SCALE_RATIO_CONST(4, 1)) {
+                       dev_err(sc->dev, "Failed width scale down %d -> %d\n",
+                               src_width, ctx->d_frame.crop.width);
+
+                       free_intermediate_frame(ctx);
+                       return -EINVAL;
                }
+               crop.width = limit->min_w;
        }
 
        if (*v_ratio < SCALE_RATIO_CONST(1, 8)) {