From patchwork Fri Aug 5 12:40:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16972 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 1B2F7BE173 for ; Fri, 5 Aug 2022 12:40:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9ECD863330; Fri, 5 Aug 2022 14:40:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659703234; bh=jA1/7M/RCBjreSLkpxhny7j2mPWk69IyCShtV2DVL3A=; 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=1XCi0lzyFHf7x8H5AUMy6UxrPK7R0wBa/j9NZLqYAKwAIV/V/mrwyYlSt043iWU6+ kBKoy5scODh0AHarIiLoS1HdrpoyjZMlDNTPCZ1pehAKAriAlJ9EU2KAX4rA0lcwc0 ABrq0PeWUBEtyGLaOvg/pleaHFh14c1ljN3DdKxPYPW9TKh3mYdKrZjOJF2VDerFhF 9rA0jnKOWBRRuUsnnA4IJws78N3mEQgWAVsgBE0ON2f9w+eF1lGLqWOBy3GBkXm0K6 Gf2STPjbHVtnYaWGsh4UyRBUGx3QaRTP41iU+UCQy4c2C0z6F49jIdMqkTmwr5qgjv qiG4t2HxveGPA== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4ADD263313 for ; Fri, 5 Aug 2022 14:40:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="hM1x823g"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id n185so1361189wmn.4 for ; Fri, 05 Aug 2022 05:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=CYikZf9gDAhn+XN0urxGrNKw7RUkr01ALRPdrjmuwMs=; b=hM1x823gxTdPx3ligq7XY5tbwkKcMZDEajKec2qr/cJ2K5KXXMnI+qZZQtMiDq+Qc4 sRZX/Z/uOccAH6DHbNlQ//JZwyeq0Do9WY+J4EuDhjz7fLYEl9bCqhH6aNzcKDKST7s3 pBarNhtmkP/F4Ay6ze0+ZZ+fPxb+6MTDhwiHLs/NIPpBdZNPGjRJKRHx2rZhLPdVuQE9 a/rX1okL1csVibF1n+/pIJd4OfKpZpPEr8/Tn+oEJO4X4YP74hY4ed5feKn43guIghJC eOSgsSYNsw0q2OsEHaVQ1eWDUpaWKU+XJMeORJ+vJ86qSoKjpmeqtBiUUbt10kzbytk7 V3SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=CYikZf9gDAhn+XN0urxGrNKw7RUkr01ALRPdrjmuwMs=; b=h0ZTNx++LwIPwFrPnesEdEQEknulvwIx7Cs5bq05iNXMhjA6sVBMfU6HRaWNG+sJJZ rQsgg+94IdDxE5ttx9xv6C+WHt2khm+poDD1Cc3XskF9U5KlQ3fHPYo/ea0AuxyxcxD4 0zCK3Ht9Zx86DzQDT8T6F3IeefDUxPy5fYza6mlRndPgVusbmA4c4i1Xg/xVbZjn5VeN SD/Dn9agqFoZ4G5LLa2d4JP75bATJXHjsPuzmjB2t1sfGRqKpixHAC34pHXj71oTZU6Z DoF1KbeiiUhAM1fP9BUHLnwoxADomlA2+opVP+CyeLrlpKaS+SrEfIiUhFeaGz754jgy 7B5A== X-Gm-Message-State: ACgBeo0irz/AjfSkZw9y5u1/t0B6wnc0CQSMCf634/l1unr+2eTDTklM Kzw8/qNrNN7s44W66WGVEUnu8r25Z8OtNs7r X-Google-Smtp-Source: AA6agR7drcaVXTgMRQ/Bln4lAcP0UpARPl00GdS5Nzs/V3dwzIaYSPySbyi73IuvB1Vax5yTvram9Q== X-Received: by 2002:a05:600c:5120:b0:3a3:2ae4:fb20 with SMTP id o32-20020a05600c512000b003a32ae4fb20mr4454951wms.81.1659703231600; Fri, 05 Aug 2022 05:40:31 -0700 (PDT) Received: from BL087.. ([2a01:e34:eea9:e630:997d:fb84:b99a:cc47]) by smtp.gmail.com with ESMTPSA id w13-20020adff9cd000000b0021db7b0162esm3869206wrr.105.2022.08.05.05.40.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 05:40:31 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 5 Aug 2022 14:40:25 +0200 Message-Id: <20220805124027.530212-2-fsylvestre@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220805124027.530212-1-fsylvestre@baylibre.com> References: <20220805124027.530212-1-fsylvestre@baylibre.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/3] ipa: rkisp1: Add enable field for AWB algorithm in IPA context 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: Florian Sylvestre via libcamera-devel From: Florian Sylvestre Reply-To: Florian Sylvestre Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add an enable variable in the awb struct in IPASessionConfiguration which indicates if the awb algorithm has been configured. This will allow other algorithms to retrieve this information. Signed-off-by: Florian Sylvestre Reviewed-by: Laurent Pinchart --- src/ipa/rkisp1/algorithms/awb.cpp | 2 ++ src/ipa/rkisp1/ipa_context.cpp | 3 +++ src/ipa/rkisp1/ipa_context.h | 1 + 3 files changed, 6 insertions(+) diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index 9f00364d..d1328f01 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -48,6 +48,8 @@ int Awb::configure(IPAContext &context, context.configuration.awb.measureWindow.h_size = 3 * configInfo.outputSize.width / 4; context.configuration.awb.measureWindow.v_size = 3 * configInfo.outputSize.height / 4; + context.configuration.awb.enabled = true; + return 0; } diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index ef8bb8e9..23a63f8c 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -87,6 +87,9 @@ namespace libcamera::ipa::rkisp1 { * * \var IPASessionConfiguration::awb.measureWindow * \brief AWB measure window + * + * \var IPASessionConfiguration::awb.enabled + * \brief Indicates if the AWB hardware is enabled to apply colour gains */ /** diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index 2bdb6a81..7f7b3e4d 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -29,6 +29,7 @@ struct IPASessionConfiguration { struct { struct rkisp1_cif_isp_window measureWindow; + bool enabled; } awb; struct { From patchwork Fri Aug 5 12:40:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16973 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 5EFE0BE173 for ; Fri, 5 Aug 2022 12:40:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 29ECA6332F; Fri, 5 Aug 2022 14:40:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659703236; bh=GYn7Od6k2DG4KI5EiH7VP9qw22z7yuc5GJu28+wJWqU=; 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=gD8vomin8GJZwyXmqp2YsdlV0lfWSdnj1ahxs+uuC2ta9qXCbM42pPChFRSc7tWxw PQyTqpoyFPqUXcerAEgX0yNxnRz1UCUYCai33oFa+QECW2KP1WoReUH7zkByba5Lqu IKDPd3WC5selGwsm9Qj/3aPJpMd0gXAGdY9HlUbrB62Y8DnwxdwcfelliXqPeT6gTD DEjHMDakwCdLn8cotK6k/0z400s6CPBz15oSvlesP9x2V7flr6Dsz0HHaC885jQyVL bgVNFTS/RySlpnnsmQsQup8DI58bNKHXY6iUnTXdJwE0yy02lcJG+wp5YjPpOXtmiy B9bmkhV8G1MVQ== Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 702C76332E for ; Fri, 5 Aug 2022 14:40:33 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="UEjy7l6y"; dkim-atps=neutral Received: by mail-wr1-x431.google.com with SMTP id bv3so3124917wrb.5 for ; Fri, 05 Aug 2022 05:40:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=0RUI5YjPJg66gmG507iTjF1fm00NL7pDQWiNs6V9UYE=; b=UEjy7l6yKGAQ2amn8yS9gtFQqALDRRhmg1OHqFf9hUucEi+v03TDZURBpwrg4XiDEw Mc9cQZMAXOC3qMQBQ7Fg1NhKiXLQP+Z7puhiYKFgx5L+P2CdywJ9vasDJ5IOD04Ou34E aHVWo84kftJV3aUg0RccAMnyrG5fnce2xX7IC2JFJVxTveIHcAfSeOJZeHXqzUVACo/H g+3yikjBTgLahgaEfDupIiaHkmMMrHfq+ZIHwgMt3mdGcuOsRP6NHoGIL6LCzmVtEALC A3xAuMxs6/yTArGVezwm45xPYmIlepgD+LVrpskXdrvHiIlK8YNYuSb53rD2DvrIp/fr z1kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=0RUI5YjPJg66gmG507iTjF1fm00NL7pDQWiNs6V9UYE=; b=yL4OM4pe4xycmmsvdVlgowRH6xlGQKl9Z+fEndmjibCsWQQSIwkn4N/9CpFd04XF1u W6WviLJG5xkkmKhN0yUdMLF+5q1RdGl1i1xX6yTrdY8Cl3BywwAtMXSZw9p2hlG4iJSx X2De9D4a9DWBLTp4Rc6k+OKSLDdDqszHlb7CuJGKxyJETdWhyjQj7iJLplZAN60qkfXV HDSmI4tujIpGNN593ThT5E2WPoZqfyKdnnoLsFt10G/qQ/+aV6icSsd0Aht1U8MBtd49 FumOKrHUhHDKx+DFZHjb2M/mSZtQebxMqU3iKDSQlSwllH9pkuRGkAhDUYLDRiUtpBqi xS9Q== X-Gm-Message-State: ACgBeo0WtRBlx3LVlAbyA6klIYyECTNGHFsnX6VH0DkmCpkzKKeQl/u/ YZsxQHLfp36u+H/6ZMiA3ek0W/3aXibJbFNQ X-Google-Smtp-Source: AA6agR4f6eadDKXlLr4a9RUQ78gyKLyYQO+HGq4462ufbxl8rKRJ+tBl31OMQkE+pHOR/ef0EJj8IQ== X-Received: by 2002:adf:ef07:0:b0:220:785d:38f9 with SMTP id e7-20020adfef07000000b00220785d38f9mr4070593wro.586.1659703232623; Fri, 05 Aug 2022 05:40:32 -0700 (PDT) Received: from BL087.. ([2a01:e34:eea9:e630:997d:fb84:b99a:cc47]) by smtp.gmail.com with ESMTPSA id w13-20020adff9cd000000b0021db7b0162esm3869206wrr.105.2022.08.05.05.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 05:40:32 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 5 Aug 2022 14:40:26 +0200 Message-Id: <20220805124027.530212-3-fsylvestre@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220805124027.530212-1-fsylvestre@baylibre.com> References: <20220805124027.530212-1-fsylvestre@baylibre.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/3] ipa: rkisp1: Add enable field for LSC algorithm in IPA context 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: Florian Sylvestre via libcamera-devel From: Florian Sylvestre Reply-To: Florian Sylvestre Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add an enable variable in the lsc struct in IPASessionConfiguration which indicates if the lsc algorithm has been configured. This will allow other algorithms to retrieve this information. Signed-off-by: Florian Sylvestre Reviewed-by: Laurent Pinchart --- src/ipa/rkisp1/algorithms/lsc.cpp | 10 ++++++++++ src/ipa/rkisp1/algorithms/lsc.h | 1 + src/ipa/rkisp1/ipa_context.cpp | 8 ++++++++ src/ipa/rkisp1/ipa_context.h | 4 ++++ 4 files changed, 23 insertions(+) diff --git a/src/ipa/rkisp1/algorithms/lsc.cpp b/src/ipa/rkisp1/algorithms/lsc.cpp index 05c8c0da..da287ac7 100644 --- a/src/ipa/rkisp1/algorithms/lsc.cpp +++ b/src/ipa/rkisp1/algorithms/lsc.cpp @@ -119,6 +119,16 @@ int LensShadingCorrection::init([[maybe_unused]] IPAContext &context, return 0; } +/** + * \copydoc libcamera::ipa::Algorithm::configure + */ +int LensShadingCorrection::configure(IPAContext &context, + [[maybe_unused]] const IPACameraSensorInfo &configInfo) +{ + context.configuration.lsc.enabled = initialized_; + return 0; +} + /** * \copydoc libcamera::ipa::Algorithm::prepare */ diff --git a/src/ipa/rkisp1/algorithms/lsc.h b/src/ipa/rkisp1/algorithms/lsc.h index fdb2ec1d..f68602c0 100644 --- a/src/ipa/rkisp1/algorithms/lsc.h +++ b/src/ipa/rkisp1/algorithms/lsc.h @@ -20,6 +20,7 @@ public: ~LensShadingCorrection() = default; int init(IPAContext &context, const YamlObject &tuningData) override; + int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override; void prepare(IPAContext &context, rkisp1_params_cfg *params) override; private: diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index 23a63f8c..1338ae40 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -92,6 +92,14 @@ namespace libcamera::ipa::rkisp1 { * \brief Indicates if the AWB hardware is enabled to apply colour gains */ +/** + * \var IPASessionConfiguration::lsc + * \brief Lens Shading Correction configuration of the IPA + * + * \var IPASessionConfiguration::lsc.enabled + * \brief Indicates if the LSC hardware is enabled to apply LSC algorithm + */ + /** * \var IPASessionConfiguration::sensor * \brief Sensor-specific configuration of the IPA diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index 7f7b3e4d..0cd6aadb 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -32,6 +32,10 @@ struct IPASessionConfiguration { bool enabled; } awb; + struct { + bool enabled; + } lsc; + struct { utils::Duration lineDuration; Size size; From patchwork Fri Aug 5 12:40:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16974 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 D3B62BE173 for ; Fri, 5 Aug 2022 12:40:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 90C476332E; Fri, 5 Aug 2022 14:40:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659703238; bh=3RGOHjWSDrE8oQoAgiqDRnMtuwlQ0w5dlWa9xdi3Rgs=; 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=3hU0yHFuD8kwDyPyixTAIAdRqnwFnw8cQmpcrsrNFSts/gOns7CxS4y83FJfBlNMo ku7Hv9nZWZ2ezpobLV3is1hLI8cljDlaYjmcHOzN+TuMJv18f6sufFMgiKDltg/xGm 2rh2KBO1Y4JkAsWtao+Ab5zYjYzZt1m6FNpqXl3B+aWzmNDr2f7jifqtRzpI45K6G/ G4zx7sqi+wfVTGulbEppx6iLvzyGlxj1oR2cVGTtUCfC5UKgp8D+TgBfb3bMDZJZso DWErNYWja0i1n15SRVVEZqIm3E9H9o8mbGEX/taX7ds/Rv+4p5uxCES4bXgrfTbEUL oIiX073IKbTwg== Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4405F6332B for ; Fri, 5 Aug 2022 14:40:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="2rZWHzsl"; dkim-atps=neutral Received: by mail-wr1-x42f.google.com with SMTP id q30so3084236wra.11 for ; Fri, 05 Aug 2022 05:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=H67sYjTQwAKkCoO0SVF02iDcZeih/Y2Dg8X1+CxPPAo=; b=2rZWHzslfeXIPOaDGxXIQZYYW0AeLOsSpg9ldv9IjV8rgkmz9guqQzs3lTTz4xKR+R mxVd4F7V7ubZlU7DUuR9tgV3hF7Gw2NnHV8DdoXKsEeG3n903iyHG0tOWJ4e9uVpI6n5 FNSi285PV4WXHrm4BgA+Cxobwg7qchFG9W241XAHj3DA7KWOd8C6sN0tfQf9UzKNLxh6 K+6mLQ3UHQQluIfu1HZlGbYHZnqjMq3/Auk15h331BGZ80K7flCYE7KKFwhct2Qc4UT5 RRAsmmv5B6ENIafjCW+2ccu1hUsw4aB7Gsk53k+XUewSC3FDXXKEBuwEA8ZaN8Tg7rYV eG2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=H67sYjTQwAKkCoO0SVF02iDcZeih/Y2Dg8X1+CxPPAo=; b=DIxVoiqL46SY2RiwPCE5jyrWLXxzmybrQCa7XRpXdhaSJRD9xDkEvw1N7MoYed09bJ 299xZg4Gt2xjjPHX37edPacSJVHPtmtnZaxrvQwOvboyEJpN6nv98U1jF40kXBx5f9Md dbKPqGmsBeTAmZzM0az5ItsxVkBzKsRDa8H8k/d1UmyJuuFtmXVQUyOM6HNW2mrOl3CQ THFAP7HTOmCS91NZCkRiqjdjZ9pT9hKtQdPDZq2QhjPoapCNBNPmbpvvk0K1Lv+H+EAC SWdVsRFQB2+l+pHwUjuxUYf8zDNFPEP+IBCwTOqKN7NpLVyzge4Le1BnARkMsNyFYkus xdOQ== X-Gm-Message-State: ACgBeo1vhGCof+1Jn7bCUtZI7QCxtLUrQFxNxbzysiYeiWRVFAcFd5mf vw+ro/LejjddHlRSm7AwVvs1C2XfLMFl2gav X-Google-Smtp-Source: AA6agR40pzxVOm0eUGvvZYUsr49ZBofyZxcyP+elCw0bredlkJIrnuuTne3Me3zlte/9aYoP/FyeJg== X-Received: by 2002:a5d:4b8d:0:b0:21f:cf60:c9e6 with SMTP id b13-20020a5d4b8d000000b0021fcf60c9e6mr4181623wrt.707.1659703233587; Fri, 05 Aug 2022 05:40:33 -0700 (PDT) Received: from BL087.. ([2a01:e34:eea9:e630:997d:fb84:b99a:cc47]) by smtp.gmail.com with ESMTPSA id w13-20020adff9cd000000b0021db7b0162esm3869206wrr.105.2022.08.05.05.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 05:40:33 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 5 Aug 2022 14:40:27 +0200 Message-Id: <20220805124027.530212-4-fsylvestre@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220805124027.530212-1-fsylvestre@baylibre.com> References: <20220805124027.530212-1-fsylvestre@baylibre.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/3] ipa: rkisp1: Add support of Denoise Pre-Filter control 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: Florian Sylvestre via libcamera-devel From: Florian Sylvestre Reply-To: Florian Sylvestre Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The denoise pre-filter algorithm is a bilateral filter which combines a range filter and a domain filter. The denoise pre-filter is applied before demosaicing. Signed-off-by: Florian Sylvestre Reviewed-by: Laurent Pinchart --- src/ipa/rkisp1/algorithms/dpf.cpp | 253 ++++++++++++++++++++++++++ src/ipa/rkisp1/algorithms/dpf.h | 36 ++++ src/ipa/rkisp1/algorithms/meson.build | 1 + src/ipa/rkisp1/data/ov5640.yaml | 11 ++ src/ipa/rkisp1/ipa_context.cpp | 11 ++ src/ipa/rkisp1/ipa_context.h | 5 + 6 files changed, 317 insertions(+) create mode 100644 src/ipa/rkisp1/algorithms/dpf.cpp create mode 100644 src/ipa/rkisp1/algorithms/dpf.h diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp new file mode 100644 index 00000000..07dc20d3 --- /dev/null +++ b/src/ipa/rkisp1/algorithms/dpf.cpp @@ -0,0 +1,253 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021-2022, Ideas On Board + * + * dpf.cpp - RkISP1 Denoise Pre-Filter control + */ + +#include "dpf.h" + +#include + +#include + +#include +#include "linux/rkisp1-config.h" + +/** + * \file dpf.h + */ + +namespace libcamera { + +namespace ipa::rkisp1::algorithms { + +/** + * \class Dpf + * \brief RkISP1 Denoise Pre-Filter control + * + * The denoise pre-filter algorithm is a bilateral filter which combines a + * range filter and a domain filter. The denoise pre-filter is applied before + * demosaicing. + */ + +LOG_DEFINE_CATEGORY(RkISP1Dpf) + +Dpf::Dpf() + : initialized_(false), config_({}), strengthConfig_({}) +{ +} + +/** + * \copydoc libcamera::ipa::Algorithm::init + */ +int Dpf::init([[maybe_unused]] IPAContext &context, + const YamlObject &tuningData) +{ + std::vector values; + + /* + * The domain kernel is configured with a 9x9 kernel for the green + * pixels, and a 13x9 or 9x9 kernel for red and blue pixels. + */ + const YamlObject &dFObject = tuningData["DomainFilter"]; + + /* + * For the green component, we have the 9x9 kernel specified + * as 6 coefficients: + * Y + * ^ + * 4 | 6 5 4 5 6 + * 3 | 5 3 3 5 + * 2 | 5 3 2 3 5 + * 1 | 3 1 1 3 + * 0 - 4 2 0 2 4 + * -1 | 3 1 1 3 + * -2 | 5 3 2 3 5 + * -3 | 5 3 3 5 + * -4 | 6 5 4 5 6 + * +---------|--------> X + * -4....-1 0 1 2 3 4 + */ + values = dFObject["g"].getList().value_or(utils::defopt); + if (values.size() != RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS) { + LOG(RkISP1Dpf, Error) + << "Invalid 'DomainFilter:g': expected " + << RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS + << " elements, got " << values.size(); + return -EINVAL; + } + + std::copy_n(values.begin(), values.size(), + std::begin(config_.g_flt.spatial_coeff)); + + config_.g_flt.gr_enable = true; + config_.g_flt.gb_enable = true; + + /* + * For the red and blue components, we have the 13x9 kernel specified + * as 6 coefficients: + * + * Y + * ^ + * 4 | 6 5 4 3 4 5 6 + * | + * 2 | 5 4 2 1 2 4 5 + * | + * 0 - 5 3 1 0 1 3 5 + * | + * -2 | 5 4 2 1 2 4 5 + * | + * -4 | 6 5 4 3 4 5 6 + * +-------------|------------> X + * -6 -4 -2 0 2 4 6 + * + * For a 9x9 kernel, columns -6 and 6 are dropped, so coefficient + * number 6 is not used. + */ + values = dFObject["rb"].getList().value_or(utils::defopt); + if (values.size() != RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS && + values.size() != RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS - 1) { + LOG(RkISP1Dpf, Error) + << "Invalid 'DomainFilter:rb': expected " + << RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS - 1 + << " or " << RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS + << " elements, got " << values.size(); + return -EINVAL; + } + + config_.rb_flt.fltsize = values.size() == RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS + ? RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9 + : RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9; + + std::copy_n(values.begin(), values.size(), + std::begin(config_.rb_flt.spatial_coeff)); + + config_.rb_flt.r_enable = true; + config_.rb_flt.b_enable = true; + + /* + * The range kernel is configured with a noise level lookup table (NLL) + * which stores a piecewise linear function that characterizes the + * sensor noise profile as a noise level function curve (NLF). + */ + const YamlObject &rFObject = tuningData["NoiseLevelFunction"]; + + values = rFObject["coeff"].getList().value_or(utils::defopt); + if (values.size() != RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS) { + LOG(RkISP1Dpf, Error) + << "Invalid 'RangeFilter:coeff': expected " + << RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS + << " elements, got " << values.size(); + return -EINVAL; + } + + std::copy_n(values.begin(), values.size(), + std::begin(config_.nll.coeff)); + + std::string scaleMode = rFObject["scale-mode"].get(""); + if (scaleMode == "linear") { + config_.nll.scale_mode = RKISP1_CIF_ISP_NLL_SCALE_LINEAR; + } else if (scaleMode == "logarithmic") { + config_.nll.scale_mode = RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC; + } else { + LOG(RkISP1Dpf, Error) + << "Invalid 'RangeFilter:scale-mode': expected " + << "'linear' or 'logarithmic' value, got " + << scaleMode; + return -EINVAL; + } + + const YamlObject &fSObject = tuningData["FilterStrength"]; + + strengthConfig_.r = fSObject["r"].get(64); + strengthConfig_.g = fSObject["g"].get(64); + strengthConfig_.b = fSObject["b"].get(64); + + initialized_ = true; + + return 0; +} + +/** + * \copydoc libcamera::ipa::Algorithm::queueRequest + */ +void Dpf::queueRequest(IPAContext &context, + [[maybe_unused]] const uint32_t frame, + const ControlList &controls) +{ + auto &dpf = context.frameContext.dpf; + + const auto &denoise = controls.get(controls::draft::NoiseReductionMode); + if (denoise) { + LOG(RkISP1Dpf, Debug) << "Set denoise to " << *denoise; + + switch (*denoise) { + case controls::draft::NoiseReductionModeOff: + dpf.denoise = false; + dpf.updateParams = true; + break; + case controls::draft::NoiseReductionModeMinimal: + case controls::draft::NoiseReductionModeHighQuality: + case controls::draft::NoiseReductionModeFast: + dpf.denoise = true; + dpf.updateParams = true; + break; + default: + LOG(RkISP1Dpf, Error) + << "Unsupported denoise value " + << *denoise; + } + } +} + +/** + * \copydoc libcamera::ipa::Algorithm::prepare + */ +void Dpf::prepare(IPAContext &context, rkisp1_params_cfg *params) +{ + auto &dpf = context.frameContext.dpf; + + if (context.frameContext.frameCount > 0 && !dpf.updateParams) + return; + + if (!initialized_) + return; + + auto &awb = context.configuration.awb; + auto &lsc = context.configuration.lsc; + auto &dpf_config = params->others.dpf_config; + auto &dpf_strength_config = params->others.dpf_strength_config; + auto &mode = dpf_config.gain.mode; + + if (context.frameContext.frameCount == 0) { + dpf_config = config_; + dpf_strength_config = strengthConfig_; + + if (awb.enabled && lsc.enabled) + mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS; + else if (awb.enabled) + mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS; + else if (lsc.enabled) + mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS; + else + mode = RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED; + + params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_DPF | + RKISP1_CIF_ISP_MODULE_DPF_STRENGTH; + } + + if (dpf.updateParams) { + params->module_en_update |= RKISP1_CIF_ISP_MODULE_DPF; + if (dpf.denoise) + params->module_ens |= RKISP1_CIF_ISP_MODULE_DPF; + + dpf.updateParams = false; + } +} + +REGISTER_IPA_ALGORITHM(Dpf, "Dpf") + +} /* namespace ipa::rkisp1::algorithms */ + +} /* namespace libcamera */ diff --git a/src/ipa/rkisp1/algorithms/dpf.h b/src/ipa/rkisp1/algorithms/dpf.h new file mode 100644 index 00000000..128ebd5e --- /dev/null +++ b/src/ipa/rkisp1/algorithms/dpf.h @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021-2022, Ideas On Board + * + * dpf.h - RkISP1 Denoise Pre-Filter control + */ + +#pragma once + +#include + +#include "algorithm.h" + +namespace libcamera { + +namespace ipa::rkisp1::algorithms { + +class Dpf : public Algorithm +{ +public: + Dpf(); + ~Dpf() = default; + + int init(IPAContext &context, const YamlObject &tuningData) override; + void queueRequest(IPAContext &context, const uint32_t frame, + const ControlList &controls) override; + void prepare(IPAContext &context, rkisp1_params_cfg *params) override; + +private: + bool initialized_; + struct rkisp1_cif_isp_dpf_config config_; + struct rkisp1_cif_isp_dpf_strength_config strengthConfig_; +}; + +} /* namespace ipa::rkisp1::algorithms */ +} /* namespace libcamera */ diff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build index e48974b4..93a48329 100644 --- a/src/ipa/rkisp1/algorithms/meson.build +++ b/src/ipa/rkisp1/algorithms/meson.build @@ -6,6 +6,7 @@ rkisp1_ipa_algorithms = files([ 'blc.cpp', 'cproc.cpp', 'dpcc.cpp', + 'dpf.cpp', 'filter.cpp', 'gsl.cpp', 'lsc.cpp', diff --git a/src/ipa/rkisp1/data/ov5640.yaml b/src/ipa/rkisp1/data/ov5640.yaml index 93d7d1e7..e251abd4 100644 --- a/src/ipa/rkisp1/data/ov5640.yaml +++ b/src/ipa/rkisp1/data/ov5640.yaml @@ -156,5 +156,16 @@ algorithms: rnd-offsets: green: 2 red-blue: 2 + - Dpf: + DomainFilter: + g: [ 16, 16, 16, 16, 16, 16 ] + rb: [ 16, 16, 16, 16, 16, 16 ] + NoiseLevelFunction: + coeff: [ 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023 ] + scale-mode: "linear" + FilterStrength: + r: 64 + g: 64 + b: 64 - Filter: ... diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index 1338ae40..70001d32 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -164,6 +164,17 @@ namespace libcamera::ipa::rkisp1 { * \brief Indicates if ISP parameters need to be updated */ +/** + * \var IPAFrameContext::dpf + * \brief Context for the Denoise Pre-Filter algorithm + * + * \var IPAFrameContext::dpf.denoise + * \brief Indicates if denoise is activated + * + * \var IPAFrameContext::dpf.updateParams + * \brief Indicates if ISP parameters need to be updated + */ + /** * \var IPAFrameContext::filter * \brief Context for the Filter algorithm diff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h index 0cd6aadb..3a743ac3 100644 --- a/src/ipa/rkisp1/ipa_context.h +++ b/src/ipa/rkisp1/ipa_context.h @@ -69,6 +69,11 @@ struct IPAFrameContext { bool updateParams; } cproc; + struct { + bool denoise; + bool updateParams; + } dpf; + struct { uint8_t denoise; uint8_t sharpness;