From patchwork Wed Aug 14 11:54:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Zabel X-Patchwork-Id: 11093807 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BEA401398 for ; Wed, 14 Aug 2019 11:55:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC207287CB for ; Wed, 14 Aug 2019 11:55:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0871287D1; Wed, 14 Aug 2019 11:55:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4D137287CB for ; Wed, 14 Aug 2019 11:55:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 913A76E152; Wed, 14 Aug 2019 11:54:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by gabe.freedesktop.org (Postfix) with ESMTPS id 483CD899BB for ; Wed, 14 Aug 2019 11:54:57 +0000 (UTC) Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28] helo=dude02.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1hxrrj-00036w-FF; Wed, 14 Aug 2019 13:54:55 +0200 From: Philipp Zabel To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/7] gpu: ipu-v3: image-convert: limit input seam position to hardware requirements Date: Wed, 14 Aug 2019 13:54:40 +0200 Message-Id: <20190814115444.13024-3-p.zabel@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190814115444.13024-1-p.zabel@pengutronix.de> References: <20190814115444.13024-1-p.zabel@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel@pengutronix.de, Steve Longerbeam Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Limit the input seam position to an interval that guarantees the tile size does not exceed 1024 pixels after the IC downsizing section and that space is left for the next tile. Signed-off-by: Philipp Zabel --- drivers/gpu/ipu-v3/ipu-image-convert.c | 30 ++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-image-convert.c b/drivers/gpu/ipu-v3/ipu-image-convert.c index 4ac7377cfe5c..9f631a0c39ea 100644 --- a/drivers/gpu/ipu-v3/ipu-image-convert.c +++ b/drivers/gpu/ipu-v3/ipu-image-convert.c @@ -481,12 +481,23 @@ static void find_best_seam(struct ipu_image_convert_ctx *ctx, unsigned int min_diff = UINT_MAX; unsigned int out_start; unsigned int out_end; + unsigned int in_start; + unsigned int in_end; /* Start within 1024 pixels of the right / bottom edge */ 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 + 1); + /* + * Limit input seam position to make sure that the downsized input tile + * to the right or bottom does not exceed 1024 pixels. + */ + in_start = max_t(int, index * in_align, + in_edge - (1024 << downsize_coeff)); + in_end = min_t(unsigned int, in_edge, + index * (1024 << downsize_coeff) + 1); + /* * Output tiles must start at a multiple of 8 bytes horizontally and * possibly at an even line horizontally depending on the pixel format. @@ -496,6 +507,7 @@ static void find_best_seam(struct ipu_image_convert_ctx *ctx, for (out_pos = out_start; out_pos < out_end; out_pos += out_align) { unsigned int in_pos; unsigned int in_pos_aligned; + unsigned int in_pos_rounded; unsigned int abs_diff; /* @@ -516,9 +528,16 @@ static void find_best_seam(struct ipu_image_convert_ctx *ctx, * start the input tile at, 19.13 fixed point. */ in_pos_aligned = round_closest(in_pos, 8192U * in_align); + /* Convert 19.13 fixed point to integer */ + in_pos_rounded = in_pos_aligned / 8192U; + + if (in_pos_rounded < in_start) + continue; + if (in_pos_rounded >= in_end) + break; if ((in_burst > 1) && - (in_edge - in_pos_aligned / 8192U) % in_burst) + (in_edge - in_pos_rounded) % in_burst) continue; if (in_pos < in_pos_aligned) @@ -527,19 +546,18 @@ static void find_best_seam(struct ipu_image_convert_ctx *ctx, abs_diff = in_pos - in_pos_aligned; if (abs_diff < min_diff) { - in_seam = in_pos_aligned; + in_seam = in_pos_rounded; out_seam = out_pos; min_diff = abs_diff; } } *_out_seam = out_seam; - /* Convert 19.13 fixed point to integer seam position */ - *_in_seam = DIV_ROUND_CLOSEST(in_seam, 8192U); + *_in_seam = in_seam; - dev_dbg(dev, "%s: out_seam %u(%u) in [%u, %u], in_seam %u(%u) diff %u.%03u\n", + dev_dbg(dev, "%s: out_seam %u(%u) in [%u, %u], in_seam %u(%u) in [%u, %u] diff %u.%03u\n", __func__, out_seam, out_align, out_start, out_end, - *_in_seam, in_align, min_diff / 8192, + in_seam, in_align, in_start, in_end, min_diff / 8192, DIV_ROUND_CLOSEST(min_diff % 8192 * 1000, 8192)); }