Blob Blame History Raw
From 82c3e948cc0fe7e01b39d437f7a58b197ebb422d Mon Sep 17 00:00:00 2001
From: Philipp Zabel <p.zabel@pengutronix.de>
Date: Tue, 13 Aug 2019 14:30:25 +0200
Subject: gpu: ipu-v3: image-convert: fix output seam valid interval
Git-commit: 82c3e948cc0fe7e01b39d437f7a58b197ebb422d
Patch-mainline: v5.4-rc1
References: bsc#1152489

This fixes a failure to determine any seam if the output size is
exactly 1024 multiplied by the number of tiles in a given direction.
In that case an empty interval out_start == out_end is being passed
to find_best_seam, which looks for a seam out_start <= x < out_end.

Also reduce the interval for all but the left column / top row, to
avoid returning position 0 as best fit.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
---
 drivers/gpu/ipu-v3/ipu-image-convert.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/ipu-v3/ipu-image-convert.c b/drivers/gpu/ipu-v3/ipu-image-convert.c
index 75850fd0db7e..40d450886e1d 100644
--- a/drivers/gpu/ipu-v3/ipu-image-convert.c
+++ b/drivers/gpu/ipu-v3/ipu-image-convert.c
@@ -489,9 +489,9 @@ static void find_best_seam(struct ipu_image_convert_ctx *ctx,
 	unsigned int out_end;
 
 	/* Start within 1024 pixels of the right / bottom edge */
-	out_start = max_t(int, 0, out_edge - 1024);
+	out_start = max_t(int, index * out_align, out_edge - 1024);
 	/* End before having to add more columns to the left / rows above */
-	out_end = min_t(unsigned int, out_edge, index * 1024);
+	out_end = min_t(unsigned int, out_edge, index * 1024 + 1);
 
 	/*
 	 * Output tiles must start at a multiple of 8 bytes horizontally and
-- 
2.28.0