From patchwork Tue Aug 9 14:46:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17043 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 E0784C3275 for ; Tue, 9 Aug 2022 14:46:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D810161FAA; Tue, 9 Aug 2022 16:46:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660056391; bh=IqgwJzWwZmG+4h3hxWE+ufUyPyrffDUg3JgClKRlfzM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=KYhG3QCrreUe3EJr4Q2r9jEIXTppTkKR4rqZq/DyZwGyViFEuNYlUnfxutspH5YdW 3NjF9oZf8YnGIXXUfX9a5zq3ZmfPy8RHqEUR4t5q4zjt7X50asWppr24tbEd/6fCTL BQWWR6jtpAoz4GZmcpJ4k4Al+Vbh1JQtYVnwTcHq7hYRUCWD+fvTugOossbAyGaeaI LNeMx5xVxT3rjSJsVdViETh0Z/GSDexpg2/emOcV5lCFChNHjrwC/A9KjTOLwUBfIQ RKIz+ZdYyb12V1gvTxUvUQyljh62PvXeFccqPf9RAC1D9M5KxlkXqaam6Qged95jzh xAvew/IcJKr/A== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CEEA663326 for ; Tue, 9 Aug 2022 16:46:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VkAhZr/D"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 656FC481 for ; Tue, 9 Aug 2022 16:46:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1660056390; bh=IqgwJzWwZmG+4h3hxWE+ufUyPyrffDUg3JgClKRlfzM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=VkAhZr/Dr9QZHlEDiTHCEGGMnaAdA4JW0g/a9XPldE1fXrqqIjrprgFAA4QNJRnsX zc96VZcIBOpsckkWmmMU6UW57sUxqBz45bq2ALDrtH+Lq8X0NpP2+Q5AHA0wNx97C7 gOGY4B/lo+chzYDw/rCIn5qZOOw88WDA/M5iEGOU= To: libcamera-devel@lists.libcamera.org Date: Tue, 9 Aug 2022 17:46:14 +0300 Message-Id: <20220809144617.27983-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220809144617.27983-1-laurent.pinchart@ideasonboard.com> References: <20220809144617.27983-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/4] pipeline: ipu3: Support IPA tuning file 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: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Pass the path name of the YAML IPA tuning file to the IPA module. The file name is derived from the sensor name ("${sensor_name}.yaml"), with a fallback to "uncalibrated.yaml". Signed-off-by: Laurent Pinchart --- Changes since v1: - Drop LIBCAMERA_IPU3_TUNING_FILE --- src/libcamera/pipeline/ipu3/ipu3.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 4fe52f74a68c..9df2460323c1 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -1243,8 +1243,16 @@ int IPU3CameraData::loadIPA() if (ret) return ret; - ret = ipa_->init(IPASettings{ "", sensor->model() }, sensorInfo, - sensor->controls(), &ipaControls_); + /* + * The API tuning file is made from the sensor name. If the tuning file + * isn't found, fall back to the 'uncalibrated' file. + */ + std::string ipaTuningFile = ipa_->configurationFile(sensor->model() + ".yaml"); + if (ipaTuningFile.empty()) + ipaTuningFile = ipa_->configurationFile("uncalibrated.yaml"); + + ret = ipa_->init(IPASettings{ ipaTuningFile, sensor->model() }, + sensorInfo, sensor->controls(), &ipaControls_); if (ret) { LOG(IPU3, Error) << "Failed to initialise the IPU3 IPA"; return ret; From patchwork Tue Aug 9 14:46:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17044 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 779B2C3272 for ; Tue, 9 Aug 2022 14:46:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 38C066332F; Tue, 9 Aug 2022 16:46:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660056394; bh=47dO1xA4hg1ZJQ5JNWCpcZ5KS2f00jub9Vrwrj0cn5E=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=DN8jeZeO/PWaWJyTxm8SskWlMgOIpVH2IcXQxhFaiqDNY4zyuq9LIfm6JnDiaTSuT XaiR3F/ejgzaRdr3k/A8Lm0juDySYhzR2UVqSB8IzKGIM6Un4doJPKb8K3ETADXieP wSi3ukcRbLmGv0nQUloJS5opaA0e8erfo2EwCaaI2r3BZM80FF+EYpqlPrWtTYdJWb +z0xLXjwZga5qR62Wkp6MV0tsDV7MeXV/f1qsmyctI4lBIM20NyBjwvv+5qIzdlpTb RqgwrSs9i/5nTCUs/LMrJ4aXDnPOAdVABr4aNdXX1DVs8tNw7cq+OoPhxGYTNPkscW 8wnLmWd6RUfag== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2B8F56332F for ; Tue, 9 Aug 2022 16:46:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="hB6xQsl8"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9AB6B481 for ; Tue, 9 Aug 2022 16:46:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1660056391; bh=47dO1xA4hg1ZJQ5JNWCpcZ5KS2f00jub9Vrwrj0cn5E=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hB6xQsl8jvRxICo/y7NwKzt55uQprVhuDnEK6LX/x7gXa7NeBKP9fBVIi477EV31G KCU+fggKbpmbpktk0IJejBqToVh8AAG9JO/wnqeBaI1g7nixUYbF+IX/kV/gTnUCQ5 p2xC75vYFl77NZIlhC08WRdWv5aD8RBvsGpSP+8s= To: libcamera-devel@lists.libcamera.org Date: Tue, 9 Aug 2022 17:46:15 +0300 Message-Id: <20220809144617.27983-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220809144617.27983-1-laurent.pinchart@ideasonboard.com> References: <20220809144617.27983-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/4] ipa: ipu3: Add an uncalibrated.yaml tuning data file 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: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a tuning data file for uncalibrated sensors, picked by the pipeline handler when no sensor-specific tuning file is available. The file lists the 5 algorithms currently instantiated by the IPA module. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- Changes since v1: - Use YAML 1.1 --- src/ipa/ipu3/data/meson.build | 8 ++++++++ src/ipa/ipu3/data/uncalibrated.yaml | 11 +++++++++++ src/ipa/ipu3/meson.build | 1 + 3 files changed, 20 insertions(+) create mode 100644 src/ipa/ipu3/data/meson.build create mode 100644 src/ipa/ipu3/data/uncalibrated.yaml diff --git a/src/ipa/ipu3/data/meson.build b/src/ipa/ipu3/data/meson.build new file mode 100644 index 000000000000..1f50b6301f77 --- /dev/null +++ b/src/ipa/ipu3/data/meson.build @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: CC0-1.0 + +conf_files = files([ + 'uncalibrated.yaml', +]) + +install_data(conf_files, + install_dir : ipa_data_dir / 'ipu3') diff --git a/src/ipa/ipu3/data/uncalibrated.yaml b/src/ipa/ipu3/data/uncalibrated.yaml new file mode 100644 index 000000000000..794ab3edbb77 --- /dev/null +++ b/src/ipa/ipu3/data/uncalibrated.yaml @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: CC0-1.0 +%YAML 1.1 +--- +version: 1 +algorithms: + - Af: + - Agc: + - Awb: + - BlackLevelCorrection: + - ToneMapping: +... diff --git a/src/ipa/ipu3/meson.build b/src/ipa/ipu3/meson.build index 3194111a5bad..658e7c9bc366 100644 --- a/src/ipa/ipu3/meson.build +++ b/src/ipa/ipu3/meson.build @@ -1,6 +1,7 @@ # SPDX-License-Identifier: CC0-1.0 subdir('algorithms') +subdir('data') ipa_name = 'ipa_ipu3' From patchwork Tue Aug 9 14:46:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17045 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 DFBFCC3272 for ; Tue, 9 Aug 2022 14:46:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9D3C563332; Tue, 9 Aug 2022 16:46:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660056395; bh=cB0sNuJW9kaQRqnBRrtSb7A7iSpFwIN8aH/WgHsezXo=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=y6V5ZnexLTD+6Pri7WPP55WuHoQzZlYWWopvdwHBLn9J6I+8xouDKWwVX+Idgl2kV RCy9WCNinIPnJILr2pBOEHRfC/2JzCOdn7gEjT25IVaawyc5KP+VScrGsUY6VeWLuA cAnseHQ80P/uVqU4VK+7K81DsLNI8edUcbgTILvEvO9PnNIxP6Bmz57Ux8yb+YJ9g8 nwnW+BiFeuqwd7LWixJf+4QrhSEDyfA4iWOrYx0+DXAYL0p3KeErMP8suG12ZpnqEq m17stx4zAV6tSSWIF4WFtNoMj1wMxzkuIu2RutqjbvYadP3U2+Liw4UKq0fg1PpQl9 IceshhpfBolCQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4505963328 for ; Tue, 9 Aug 2022 16:46:33 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RZJET2NX"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D0573481 for ; Tue, 9 Aug 2022 16:46:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1660056393; bh=cB0sNuJW9kaQRqnBRrtSb7A7iSpFwIN8aH/WgHsezXo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=RZJET2NX4KZJANq9wWibn7soaElZpK9bfyf/AnCjM0zhsVfXbRrRTVyjY7I/MxVXQ 6sbFer73p48XGeZWAX4CjNHa6+O7XLzilsrzUisWLsV4avyOd4Zro8Ss96yfQnaYm6 PImxmqhcVvoMuT1eTTVdR7GKV8PlZmi3IZ3Pb4d8= To: libcamera-devel@lists.libcamera.org Date: Tue, 9 Aug 2022 17:46:16 +0300 Message-Id: <20220809144617.27983-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220809144617.27983-1-laurent.pinchart@ideasonboard.com> References: <20220809144617.27983-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/4] ipa: ipu3: Register algorithms 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: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" To prepare for dynamic instantiation of algorithms from the tuning file, register the algorithms with the Module class. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/ipa/ipu3/algorithms/af.cpp | 2 ++ src/ipa/ipu3/algorithms/agc.cpp | 2 ++ src/ipa/ipu3/algorithms/awb.cpp | 2 ++ src/ipa/ipu3/algorithms/blc.cpp | 2 ++ src/ipa/ipu3/algorithms/tone_mapping.cpp | 2 ++ 5 files changed, 10 insertions(+) diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp index d07521a090ac..4835a0345931 100644 --- a/src/ipa/ipu3/algorithms/af.cpp +++ b/src/ipa/ipu3/algorithms/af.cpp @@ -450,6 +450,8 @@ void Af::process(IPAContext &context, [[maybe_unused]] IPAFrameContext *frameCon } } +REGISTER_IPA_ALGORITHM(Af, "Af") + } /* namespace ipa::ipu3::algorithms */ } /* namespace libcamera */ diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp index 5bc64ae52214..ed4809d98007 100644 --- a/src/ipa/ipu3/algorithms/agc.cpp +++ b/src/ipa/ipu3/algorithms/agc.cpp @@ -363,6 +363,8 @@ void Agc::process(IPAContext &context, [[maybe_unused]] IPAFrameContext *frameCo frameCount_++; } +REGISTER_IPA_ALGORITHM(Agc, "Agc") + } /* namespace ipa::ipu3::algorithms */ } /* namespace libcamera */ diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp index 704267222a31..b658ee546b87 100644 --- a/src/ipa/ipu3/algorithms/awb.cpp +++ b/src/ipa/ipu3/algorithms/awb.cpp @@ -483,6 +483,8 @@ void Awb::prepare(IPAContext &context, ipu3_uapi_params *params) params->use.acc_ccm = 1; } +REGISTER_IPA_ALGORITHM(Awb, "Awb") + } /* namespace ipa::ipu3::algorithms */ } /* namespace libcamera */ diff --git a/src/ipa/ipu3/algorithms/blc.cpp b/src/ipa/ipu3/algorithms/blc.cpp index 78ab7bff549f..c561aa858b96 100644 --- a/src/ipa/ipu3/algorithms/blc.cpp +++ b/src/ipa/ipu3/algorithms/blc.cpp @@ -62,6 +62,8 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context, params->use.obgrid_param = 1; } +REGISTER_IPA_ALGORITHM(BlackLevelCorrection, "BlackLevelCorrection") + } /* namespace ipa::ipu3::algorithms */ } /* namespace libcamera */ diff --git a/src/ipa/ipu3/algorithms/tone_mapping.cpp b/src/ipa/ipu3/algorithms/tone_mapping.cpp index f86e79b24a67..49a5558b6faa 100644 --- a/src/ipa/ipu3/algorithms/tone_mapping.cpp +++ b/src/ipa/ipu3/algorithms/tone_mapping.cpp @@ -105,6 +105,8 @@ void ToneMapping::process(IPAContext &context, [[maybe_unused]] IPAFrameContext context.activeState.toneMapping.gamma = gamma_; } +REGISTER_IPA_ALGORITHM(ToneMapping, "ToneMapping") + } /* namespace ipa::ipu3::algorithms */ } /* namespace libcamera */ From patchwork Tue Aug 9 14:46:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17046 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 49261C3275 for ; Tue, 9 Aug 2022 14:46:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0726E63328; Tue, 9 Aug 2022 16:46:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660056396; bh=5tLNzpV1RqRYJ0NUMR8N1xeVEQv0hHXKB2bxVhlVEoo=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=RjdJaX3K5F83/QpvPDRE9PP1Fp3RKI2w19lng8c9PfTpD9zCEPmwcurtMxKap3nKg 8WU+MW9PtJyvaYB04xvW0MXXOW8abz0W1IkRYmUq1/yTPGUxFRgEHwRO5Dg8PMivJs A5JMUf5O/budkdQm3rRNKHQKa/7crHTD+pkiEh5Hm7mODmwhShskMoJMP4m86Pr9w9 eQU7Rw1ARIYyy1Yck0NOY/EJdzvpieUk3sOuPBJPCYZRBq6D/yySyk7JDb1/uXbIch OZ4xOUmt04ebOV1Oru0mEu9dyDX8Zg42ZxZySTu0awHWbsGlvt5L9LVixdNohbPVlS 8xRHBESOOx30w== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 921CA63328 for ; Tue, 9 Aug 2022 16:46:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="idyZ9tMU"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2B822481 for ; Tue, 9 Aug 2022 16:46:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1660056394; bh=5tLNzpV1RqRYJ0NUMR8N1xeVEQv0hHXKB2bxVhlVEoo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=idyZ9tMUdEbv6xHDTbsFvmeFbVYw+5pMPpB4UrouycjS3rhto+eoG/78IXDBHjrZv uxwoWpsQtD6BMNt6pRm0DliKkppbZXdvX8xLAGP5CWdYNSrhHLp+KPU+S5VjlOOAOf f3CtQ/dKAMzp5/i7owPtITa9h9Oh/ZCoiHze+aa8= To: libcamera-devel@lists.libcamera.org Date: Tue, 9 Aug 2022 17:46:17 +0300 Message-Id: <20220809144617.27983-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220809144617.27983-1-laurent.pinchart@ideasonboard.com> References: <20220809144617.27983-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/4] ipa: ipu3: Add YAML tuning file support 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: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Replace the manual instantiation of algorithms with an automatic mechanism based on a tuning data file, provided by the Module base class. This brings the IPU3 IPA module in line with the RkISP1 IPA module. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/ipa/ipu3/ipu3.cpp | 70 ++++++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 18 deletions(-) diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 2f6bb672f7bb..e37b2fa0f30e 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -29,6 +30,7 @@ #include #include "libcamera/internal/mapped_framebuffer.h" +#include "libcamera/internal/yaml_parser.h" #include "algorithms/af.h" #include "algorithms/agc.h" @@ -71,7 +73,7 @@ namespace ipa::ipu3 { * * At initialisation time, a CameraSensorHelper is instantiated to support * camera-specific calculations, while the default controls are computed, and - * the algorithms are constructed and placed in an ordered list. + * the algorithms are instantiated from the tuning data file. * * The IPU3 ImgU operates with a grid layout to divide the overall frame into * rectangular cells of pixels. When the IPA is configured, we determine the @@ -92,12 +94,14 @@ namespace ipa::ipu3 { * fillParamsBuffer() call. * * The individual algorithms are split into modular components that are called - * iteratively to allow them to process statistics from the ImgU in a defined - * order. + * iteratively to allow them to process statistics from the ImgU in the order + * defined in the tuning data file. * - * The current implementation supports three core algorithms: - * - Automatic white balance (AWB) + * The current implementation supports five core algorithms: + * + * - Auto focus (AF) * - Automatic gain and exposure control (AGC) + * - Automatic white balance (AWB) * - Black level correction (BLC) * - Tone mapping (Gamma) * @@ -128,7 +132,7 @@ namespace ipa::ipu3 { * sensor-specific tuning to adapt for Black Level compensation (BLC), Lens * shading correction (SHD) and Color correction (CCM). */ -class IPAIPU3 : public IPAIPU3Interface +class IPAIPU3 : public IPAIPU3Interface, public Module { public: int init(const IPASettings &settings, @@ -150,6 +154,10 @@ public: void processStatsBuffer(const uint32_t frame, const int64_t frameTimestamp, const uint32_t bufferId, const ControlList &sensorControls) override; + +protected: + std::string logPrefix() const override; + private: void updateControls(const IPACameraSensorInfo &sensorInfo, const ControlInfoMap &sensorControls, @@ -171,13 +179,15 @@ private: /* Interface to the Camera Helper */ std::unique_ptr camHelper_; - /* Maintain the algorithms used by the IPA */ - std::list> algorithms_; - /* Local parameter storage */ struct IPAContext context_; }; +std::string IPAIPU3::logPrefix() const +{ + return "ipu3"; +} + /** * \brief Compute IPASessionConfiguration using the sensor information and the * sensor V4L2 controls @@ -316,12 +326,36 @@ int IPAIPU3::init(const IPASettings &settings, context_.configuration = {}; context_.configuration.sensor.lineDuration = sensorInfo.lineLength * 1.0s / sensorInfo.pixelRate; - /* Construct our Algorithms */ - algorithms_.push_back(std::make_unique()); - algorithms_.push_back(std::make_unique()); - algorithms_.push_back(std::make_unique()); - algorithms_.push_back(std::make_unique()); - algorithms_.push_back(std::make_unique()); + /* Load the tuning data file. */ + File file(settings.configurationFile.c_str()); + if (!file.open(File::OpenModeFlag::ReadOnly)) { + int ret = file.error(); + LOG(IPAIPU3, Error) + << "Failed to open configuration file " + << settings.configurationFile << ": " << strerror(-ret); + return ret; + } + + std::unique_ptr data = YamlParser::parse(file); + if (!data) + return -EINVAL; + + unsigned int version = (*data)["version"].get(0); + if (version != 1) { + LOG(IPAIPU3, Error) + << "Invalid tuning file version " << version; + return -EINVAL; + } + + if (!data->contains("algorithms")) { + LOG(IPAIPU3, Error) + << "Tuning file doesn't contain any algorithm"; + return -EINVAL; + } + + int ret = createAlgorithms(context_, (*data)["algorithms"]); + if (ret) + return ret; /* Initialize controls. */ updateControls(sensorInfo, sensorControls, ipaControls); @@ -470,7 +504,7 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo, /* Update the IPASessionConfiguration using the sensor settings. */ updateSessionConfiguration(sensorCtrls_); - for (auto const &algo : algorithms_) { + for (auto const &algo : algorithms()) { int ret = algo->configure(context_, configInfo); if (ret) return ret; @@ -538,7 +572,7 @@ void IPAIPU3::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId) */ params->use = {}; - for (auto const &algo : algorithms_) + for (auto const &algo : algorithms()) algo->prepare(context_, params); paramsBufferReady.emit(frame); @@ -581,7 +615,7 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame, int32_t vBlank = context_.configuration.sensor.defVBlank; ControlList ctrls(controls::controls); - for (auto const &algo : algorithms_) + for (auto const &algo : algorithms()) algo->process(context_, &frameContext, stats); setControls(frame);