From patchwork Thu Mar 31 12:10:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 15587 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 20F01C0F1B for ; Thu, 31 Mar 2022 12:10:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5D6D365633; Thu, 31 Mar 2022 14:10:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1648728637; bh=dQbyEU8Tg//Vd5MSvuB+KFOCDPU0vQinXy7nXX+LugU=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=pQj5KbuHHByB/v/oaMADDvJMeg99dQQu7N7F9QqvvxALmkRAin657Zj66e6tv7BPy y2BZ8AFsqyK76ksOpihE4HPBLVIbiOEnaoWEbjF+v4kG3PcmIA/w7VZypyu3Sakjic JTjBo0lLm80Slv08+oEwxKTmX+tZj6tG5zZ96slhSRq9IgnVf0A5R40AxEBIq0FQF+ wkHHwh8nWweVM4XiKYsImupb1UuT7A1TGvnKSCVWTevjQiCdAk7KmJCTc9OZemFrVd Fg8Q+oBECA0LXszwBRTmuLVjVk1aotpLOZqp0LwrIfAD0t/AuzdpQjcsH1js/nJ5tw v0BfwXIkyQDiQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9150C6559A for ; Thu, 31 Mar 2022 14:10:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="DFzyrnJi"; dkim-atps=neutral Received: from Monstersaurus.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 27C2F59D; Thu, 31 Mar 2022 14:10:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1648728635; bh=dQbyEU8Tg//Vd5MSvuB+KFOCDPU0vQinXy7nXX+LugU=; h=From:To:Cc:Subject:Date:From; b=DFzyrnJicf0RntxHUAok6SoW1vrpqp3QKQY04EQL811TwnoKzaphC3fv4BavjRAnm YW0WevONkLGxjSckSkwS2Ek+9rEqGAjs208Ic1t6SzjkClFREr/OAY4K2yyK40Kz8t kzWsvLOwUHwzqOEkwv/RWerYovyEJw7OEQGqPbeI= To: libcamera devel Date: Thu, 31 Mar 2022 13:10:32 +0100 Message-Id: <20220331121032.2150025-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] ipa: ipu3: af: enforce grid size restrictions X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Provide enforcement of the selection of the block_{width,height}_log2 parameters to the capabilities of the hardware. While this selection is currently hardcoded to the minimum, providing the restriction now allows for further dynamic sizing in the future and documents the restrictions directly in code, making use of the already existing constants. Signed-off-by: Kieran Bingham Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- Note, this is kept separate from my other AF improvement series, as it can be applied independantly - but due to a compilation failure if kAfMinGridBlockWidth, kAfMaxGridBlockWidth kAfMinGridBlockHeight, and kAfMaxGridBlockHeight are not used, this patch must be applied before that series can be integrated. src/ipa/ipu3/algorithms/af.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp index 6c25d02ec7f0..abfaad6164f1 100644 --- a/src/ipa/ipu3/algorithms/af.cpp +++ b/src/ipa/ipu3/algorithms/af.cpp @@ -139,6 +139,22 @@ int Af::configure(IPAContext &context, const IPAConfigInfo &configInfo) grid.height = kAfMinGridHeight; grid.block_width_log2 = kAfMinGridBlockWidth; grid.block_height_log2 = kAfMinGridBlockHeight; + + /* + * \todo - while this clamping code is effectively a no-op, it satisfies + * the compiler that the definitions regarding the hardware restrictions + * are used, and paves the way to support dynamic grid sizing in the + * future. While the block_{width,height}_log2 remain assigned to the + * minimum, this code should be optimized out by the compiler. + */ + grid.block_width_log2 = std::clamp(grid.block_width_log2, + kAfMinGridBlockWidth, + kAfMaxGridBlockWidth); + + grid.block_height_log2 = std::clamp(grid.block_height_log2, + kAfMinGridBlockHeight, + kAfMaxGridBlockHeight); + grid.height_per_slice = kAfDefaultHeightPerSlice; /* Position the AF grid in the center of the BDS output. */