From patchwork Thu Aug 4 14:12: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: 16968 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 9B945C3272 for ; Thu, 4 Aug 2022 14:12:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 410CB6332F; Thu, 4 Aug 2022 16:12:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659622356; bh=Z8enGdwh8QvFKXJjbPxTGArPxMbzZaH3mArrLRmY19o=; 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=llaRRLlrIqJqjfWnwk5HfD8TnmKQ4dpqgvFGusqTkIgKlDKp7jwVC3wb+hx8hdFFd HXFFVrHZqM52FZNNIly98ssQV7x2KU8gk/4GK7o333Q15Kwtqtd6aKrLNw1JJSdhXo yxghqIAC2jk5UNSs419cBgpQJN7Snxda9fVJJdBydn4zmmPu2f4kwyD23/uDXNm9+A /JPE8T1k8WZYd+zwcgifWMAx+mQ5xdW+1sYd1F9RXacoKl3oEY4kL0skMdJRmazGm8 Sr392KaYFWSEVexta0SYCwteKih7/S+O39XSsKrFIZuVa6q0TDVANirhs/uCSXy60r udJq0uOGALsjA== Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9342B6330D for ; Thu, 4 Aug 2022 16:12: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="5x2zuZd9"; dkim-atps=neutral Received: by mail-wr1-x436.google.com with SMTP id bv3so11510724wrb.5 for ; Thu, 04 Aug 2022 07:12:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KiE3kzDMQPEGN7jLQ2xZUp7u49vuV8YvBM6aut3iZoc=; b=5x2zuZd9UR2edOcY9LlULZ5Wk72YCBo5UEAw0jzUWxNn1FSA5itSUd8Z3HJGhQVoTg egzzK6Xkmnxd5XQmBbgeklja+ryVIPGrCCsb70gK53cd9jQbpGnz9x+Vpj5KkaWxqltI 4DF8BPSCc1MGPtN6QNVX3NDDjqIit3pPv2EblXdVGzr1m1WJkwH2FcaGJHgms5D1PcRR xaPDIcNzy12eDW/0EDA9mO1gorbl5MJGTNlqQczZMPUtMoi5hGBj5Xfyev0GPtaINWCg J9XcIwN3kGa78WGorUBQfxKXKx42WGUIHXRVzGY/shyLwU67KA+daQUJvy3Gp8KewXFV 2p3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KiE3kzDMQPEGN7jLQ2xZUp7u49vuV8YvBM6aut3iZoc=; b=DvgJag+Z7ReKSCzJn/ONSG2fngqXz12QP/tRxwWuAiCqkOFJcjYUwFGiQXO/wH71pv VxU/1xBDAjJ0HpyEP43l6FVTboRT9vrZ0+ikUSLeVsDRpBvcU2wZzNLkDxFV0Idbfm0S LgswzqfNNOtOGTbpajg98/ikcbwCtfcdJW2BRWo6m6bWcWaA7caIeV1h90coe374YvZb rJqPcYDpaPfxVUGc8GollTQ7Hx2968ZuQL9wcan0JiZoYuNaaEmSrtaLcZ0BKzsYBtfZ 68THcYUU2mkyH3pu+Mhuav2YtfCeaky3BZrNRj8CpN4AIvAkjAxz0Z/sDDLEwV3UwRd/ 4K/Q== X-Gm-Message-State: ACgBeo1EvuJ887mV/i9+Ae6XdD45ZQtE96PUnxtZ4sjyIbEFjYbtYNT/ wOu6+QJRXVLHraIu7qRSH7Sc55hFbKTIIzoP X-Google-Smtp-Source: AA6agR5kzn0IjP9Vdoo1SIby8+4QGxgOjalBKzVCWBUyRDF/Kt/KiO7ElWDr5sy5XW18DAw6oUxi2Q== X-Received: by 2002:adf:ce0e:0:b0:220:7eed:3ce3 with SMTP id p14-20020adfce0e000000b002207eed3ce3mr1523835wrn.148.1659622353904; Thu, 04 Aug 2022 07:12:33 -0700 (PDT) Received: from BL087.. ([2a01:e34:eea9:e630:d073:c231:2c43:c9cf]) by smtp.gmail.com with ESMTPSA id i5-20020a05600c2d8500b003a325bd8517sm1616948wmg.5.2022.08.04.07.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 07:12:32 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 4 Aug 2022 16:12:26 +0200 Message-Id: <20220804141228.417211-2-fsylvestre@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220804141228.417211-1-fsylvestre@baylibre.com> References: <20220804141228.417211-1-fsylvestre@baylibre.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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..d833b8c7 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 AWB is enabled */ /** 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 Thu Aug 4 14:12: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: 16969 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 305E7C3272 for ; Thu, 4 Aug 2022 14:12:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DA15963311; Thu, 4 Aug 2022 16:12:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659622357; bh=GNwC3zjC1jCNOZKzZo0kO93iDmDcuxMvGGrXpi0gDqE=; 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=V0z3sLekBZzWfr3U3KQqvnyPPaW2wvDjfNSThJiK2QUNJsJe8RFl8XlWs01//Bv9Q IAU2atd4kFNvWrXf3RFaw4eUuX6C++2JDL66HI7Y+JCQShuG98ne8Qg9Y+XZ3Xxpd8 www4dAFrhxqDxYoyUyZjLjHSI1Uo5Uh73s11MavwIPB5RF/cXhuw1jMfuLM4I8y31c WOiu/UnEzZE4Ia8hHZdTAmhzGDVcK4kYzbCJQVPH6PkvfLzi3H7GBoM2WXzTbsMkiU I+LKTvd3q9QFKQ9fQ0mGXmwgVOe9AVRTN+2Vtc0ca75+STfClymdjWTQIQGagGBajt G0gMMU5f/10ww== Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6EF986330D for ; Thu, 4 Aug 2022 16:12:35 +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="lYCzCnWg"; dkim-atps=neutral Received: by mail-wr1-x432.google.com with SMTP id l4so25437739wrm.13 for ; Thu, 04 Aug 2022 07:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m8Kr0OoSI6uJhezdGMoEJR2sU/9PmcsvdeHRShlwbJ0=; b=lYCzCnWgsQFbGEnpEAJR7sWEhnOl+rwwIWH1weLcHwGU6DmQNSBLLLJCqcbwlrSdAW YZx1taCxQv9j80XjAiq8f6S1tN5S2pHevPrN1rjTf5VyGh2vAS9d84EVCMG3iZACTPcS d1FHFtScotlGE6DvdBY8J2NHZ7WevpqdH9vrp8kT89DPNSVNGZnyDnmT0qGS5OSnXVMW S9Q7aYH1ZoZBoH4mEZWnzEzYh0D1mgrxSzYZJod0k1QLvfdNE5shyJPuDI5VQTpvSaUd m2ZdF4noyAFL951x2mgVuvVtLxUelJYrArWjDtxAv7t2oO33SzHpDalMYYIS7XiwGmIf emLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m8Kr0OoSI6uJhezdGMoEJR2sU/9PmcsvdeHRShlwbJ0=; b=D6bDkgtwRRqr3matyPgRXahiXFdpmhDFgo1a1q6HCBFs1QroW3bVzGKTw8zkDxuFZy iwLCpT6+pgnqvhi0si8ZMpDHPiTMI0T1dz8bggt5xhs6AW8TeySKq5t1XhvbFqZ5kVEY 3MmcpKZShhVmIOyysPvHpUMj0XkRNVnIDRJygOZETkk/0MToqeRnyeVP7tii0q0pO40d a8XafGsT5qeSjNCpb3NSRAC5YQCRnLgGYjKfbxwcB8X6gWbOdkB7663+NiyS6T2efbf+ YyG93sRqDdeFuqps8wfrliuOEajBH/rhJIW5c0uQGEzmYuGJqq+wihg6k8lVLsEJnEfK /Dzg== X-Gm-Message-State: ACgBeo3sJwH62mQJ7UyOaJMY5nWzNTBcI9P2IIhMEW3zTe3QemXAv3si 7PbuDkJbVbA+hHxLb+5TuEStq/GEsVFZ6/it X-Google-Smtp-Source: AA6agR4nFcc1M/7r3E9k/xTnXBr52WPwHMYmVRX1uQMxr/+PJoJKYOJdNNTU2yYF/56ljzO5chxMBg== X-Received: by 2002:a5d:6d8f:0:b0:21d:b7d0:a913 with SMTP id l15-20020a5d6d8f000000b0021db7d0a913mr1548327wrs.462.1659622354877; Thu, 04 Aug 2022 07:12:34 -0700 (PDT) Received: from BL087.. ([2a01:e34:eea9:e630:d073:c231:2c43:c9cf]) by smtp.gmail.com with ESMTPSA id i5-20020a05600c2d8500b003a325bd8517sm1616948wmg.5.2022.08.04.07.12.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 07:12:34 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 4 Aug 2022 16:12:27 +0200 Message-Id: <20220804141228.417211-3-fsylvestre@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220804141228.417211-1-fsylvestre@baylibre.com> References: <20220804141228.417211-1-fsylvestre@baylibre.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 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 | 9 +++++++++ src/ipa/rkisp1/ipa_context.h | 4 ++++ 4 files changed, 24 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 d833b8c7..c90bf992 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -92,6 +92,15 @@ namespace libcamera::ipa::rkisp1 { * \brief Indicates if AWB is enabled */ +/** + * \var IPASessionConfiguration::lsc + * \brief Lens Shading Correction configuration of the IPA + * + * \var IPASessionConfiguration::lsc.enabled + * \brief Indicates if LSC is enabled + * + */ + /** * \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 Thu Aug 4 14:12:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16970 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 E97A0C3275 for ; Thu, 4 Aug 2022 14:12:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 502156332E; Thu, 4 Aug 2022 16:12:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659622358; bh=wH7rzW/+BaraxMFQKRklQha3CW/AjxAjszhiAJZf6BU=; 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=oLUEWID4DjyES1lWaWiL9sgBfHDyQXxUJbuY+JAQ0eYgdBQoKpiM/VrAD3M8tMOnL MYNq3Zb6+flb0Y2lcHhv9uuyaeX1nXcOkitlTreD83Hy+CMgzX6rCi7APhj4zNmT2N n0JjCqgxgbdx7tbMzvAVzY6845rhDxSFJaxWFj0vf1ANE+ozYNl/1sKGD8A5l6/dT2 geLm6TVoO7NxDbmnNPN55QB39NLfcmlqq4cV66dqnvLVNq4Tl4Fhv2dlo5lfuTN+82 HKeqBxwMPgl+8EkBnRX2jUw4e6hnIk3C1ahhYpYp70CRJqDIuDMd//bSpvCKb9pcyD KiaSfQ3Tcmqew== 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 91EBB63311 for ; Thu, 4 Aug 2022 16:12:36 +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="IwVVk9Us"; dkim-atps=neutral Received: by mail-wr1-x431.google.com with SMTP id p10so21214863wru.8 for ; Thu, 04 Aug 2022 07:12:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LsRyEh2w4YzccXRhjaKZLslt8FZlM+HdwBZkHR+63HY=; b=IwVVk9UsJfGXg9TV1Ja9Sn96ZZskmW6B59FEr+20LyxqHMbQmDzsWUmafEMByIhFsg TYfC82dpP0xsroIGwdm7haAdETyVOI9t5vyj1dzTjFpBdUqDa+ttDRbPhdsqLTm2g2Q0 Nb4mOrPNx7BXrin9CwUTLfuYt9Ef6Q3oK7pV1OeV1g9dOEhZqWd/7Wj9wNB5vRj8jtyF FKIHsfs1cusrS6w90PZVleQMPJ+LdFdcvm5BarIWvXst9twFo1Zwo8YlVhS6NJzC5xeb 3niCZbrDe2mmUzTEvrKirDBJKfhrnqa69clI9OEj3GsplXViFn7vgMuXN18wKa/Lib9N FVBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LsRyEh2w4YzccXRhjaKZLslt8FZlM+HdwBZkHR+63HY=; b=4ePAI6Ch0fxKYpnipvPC03EE/BsmFlGvCo4Hh8SarjhVVIAbzMQOXnwE4L/L+swVN0 Hdo2RhZlSR3ds0FGf1oRmsYp3xQ5k6zkg2vtBEbfBWp7O/Lga0vUYopjR1yCNQR20H2l ZOc6FtiY1ss8bTwNvFI8o1j0DliuX8Aa4WXRldDCsqOaVJk3cy+H9MgEPBhB4cxmWb4+ EC8v0SRsSJTBoZEpLUbArMDBwwXmX15opq2bCiiRhXba0KgzKuurM2FCVNIuFas54Rn0 qgZBEi75t+u5yWToxUHRaGvHVGVdLSulfHekpSsmAkJRQdRWj2330m2OGqpyhj7K2huD swnw== X-Gm-Message-State: ACgBeo0geC6CjhZc+xyfWMJkd5Qy21s8v1g3cLUPFY6SN2xZIK+VF8h+ Eu7PnYSKYhKGURWOGn7QkiH77ARYCgiw8j1s X-Google-Smtp-Source: AA6agR6Gh5zYc1EooS24X68XxRXucusrNlPJi2C8tW053yp/VpHoxK7uEVDOFijYkrPBoXAgD5xM0A== X-Received: by 2002:a5d:430d:0:b0:210:2ce0:e2a9 with SMTP id h13-20020a5d430d000000b002102ce0e2a9mr1576171wrq.627.1659622355684; Thu, 04 Aug 2022 07:12:35 -0700 (PDT) Received: from BL087.. ([2a01:e34:eea9:e630:d073:c231:2c43:c9cf]) by smtp.gmail.com with ESMTPSA id i5-20020a05600c2d8500b003a325bd8517sm1616948wmg.5.2022.08.04.07.12.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 07:12:35 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 4 Aug 2022 16:12:28 +0200 Message-Id: <20220804141228.417211-4-fsylvestre@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220804141228.417211-1-fsylvestre@baylibre.com> References: <20220804141228.417211-1-fsylvestre@baylibre.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] ipa: rkisp1: Add support of De-noise 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 De-noise pre-filter algorithm is a bilateral filter which combines a range filter and a domain filter. The De-noise pre-filter is applied before demosaicing. Signed-off-by: Florian Sylvestre --- src/ipa/rkisp1/algorithms/dpf.cpp | 279 ++++++++++++++++++++++++++ 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, 343 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..d99bb728 --- /dev/null +++ b/src/ipa/rkisp1/algorithms/dpf.cpp @@ -0,0 +1,279 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2021-2022, Ideas On Board + * + * dpf.cpp - RkISP1 De-noise 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 De-noise Pre-Filter control + * + * The De-noise pre-filter algorithm is a bilateral filter which combines a + * range filter and a domain filter. The De-noise pre-filter is applied before + * demosaicing. + */ + +LOG_DEFINE_CATEGORY(RkISP1Dpf) + +Dpf::Dpf() + : initialized_(false), config_({}), strength_config_({}) +{ +} + +/** + * \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"]; + if (!dFObject.isDictionary()) { + LOG(RkISP1Dpf, Error) + << "Issue while parsing 'DomainFilter' in tuning " + << "file: entry must be a dictionary"; + return -EINVAL; + } + + /* + * 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; + } + + for (unsigned int i = 0; i < values.size(); ++i) { + config_.g_flt.spatial_coeff[i] = std::round(values[i] * 16); + } + + 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; + + for (unsigned int i = 0; i < values.size(); ++i) { + config_.rb_flt.spatial_coeff[i] = std::round(values[i] * 16); + } + + 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["RangeFilter"]; + if (!rFObject.isDictionary()) { + LOG(RkISP1Dpf, Error) + << "Issue while parsing 'RangeFilter' in tuning " + << "file: entry must be a dictionary"; + return -EINVAL; + } + + 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; + } + + for (unsigned int i = 0; i < values.size(); ++i) { + config_.nll.coeff[i] = std::round(values[i] * 1024); + } + + std::string scaleMode = rFObject["scale-mode"].get(""); + if (scaleMode != "linear" && scaleMode != "logarithmic") { + LOG(RkISP1Dpf, Error) + << "Invalid 'RangeFilter:scale-mode': expected " + << "'linear' or 'logarithmic' value, got " + << scaleMode; + return -EINVAL; + } + + config_.nll.scale_mode = scaleMode == "linear" + ? RKISP1_CIF_ISP_NLL_SCALE_LINEAR + : RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC; + + const YamlObject &fSObject = tuningData["FilterStrength"]; + if (!fSObject.isDictionary()) { + LOG(RkISP1Dpf, Error) + << "Issue while parsing 'FilterStrength' in tuning " + << "file: entry must be a dictionary"; + return -EINVAL; + } + + strength_config_.r = fSObject["r"].get(64); + strength_config_.g = fSObject["g"].get(64); + strength_config_.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; + 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; + + if ((context.frameContext.frameCount > 0) && (!dpf.updateParams)) + return; + + if (!initialized_) + return; + + /* + * We must copy the static configuration each time we modify a + * parameter in the config because the strucure is zeroed between each + * call. + */ + dpf_config = config_; + dpf_strength_config = strength_config_; + + if (dpf.updateParams) { + if (!dpf.denoise || (!awb.enabled && !lsc.enabled)) { + dpf_config.gain.mode = + RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED; + } else if (awb.enabled && lsc.enabled) { + dpf_config.gain.mode = + RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS; + } else if (awb.enabled) { + dpf_config.gain.mode = + RKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS; + } else { /* lsc.enabled only */ + dpf_config.gain.mode = + RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS; + } + } + + dpf.updateParams = false; + + uint32_t flags = RKISP1_CIF_ISP_MODULE_DPF | + RKISP1_CIF_ISP_MODULE_DPF_STRENGTH; + params->module_en_update |= flags; + params->module_ens |= flags; + params->module_cfg_update |= flags; +} + +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..c8b8419a --- /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 De-noise 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 strength_config_; +}; + +} /* namespace ipa::rkisp1::algorithms */ +} /* namespace libcamera */ diff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build index e48974b4..e1492dd5 100644 --- a/src/ipa/rkisp1/algorithms/meson.build +++ b/src/ipa/rkisp1/algorithms/meson.build @@ -5,6 +5,7 @@ rkisp1_ipa_algorithms = files([ 'awb.cpp', 'blc.cpp', 'cproc.cpp', + 'dpf.cpp', 'dpcc.cpp', 'filter.cpp', 'gsl.cpp', diff --git a/src/ipa/rkisp1/data/ov5640.yaml b/src/ipa/rkisp1/data/ov5640.yaml index 93d7d1e7..69c6ad97 100644 --- a/src/ipa/rkisp1/data/ov5640.yaml +++ b/src/ipa/rkisp1/data/ov5640.yaml @@ -11,6 +11,17 @@ algorithms: Gb: 256 B: 256 - ColorProcessing: + - Dpf: + DomainFilter: + g: [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] + rb: [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] + RangeFilter: + coeff: [ 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999, 0.999 ] + scale-mode: "linear" + FilterStrength: + r: 64 + g: 64 + b: 64 - GammaSensorLinearization: x-intervals: [ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ] y: diff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp index c90bf992..3b92e95e 100644 --- a/src/ipa/rkisp1/ipa_context.cpp +++ b/src/ipa/rkisp1/ipa_context.cpp @@ -165,6 +165,17 @@ namespace libcamera::ipa::rkisp1 { * \brief Indicates if ISP parameters need to be updated */ +/** + * \var IPAFrameContext::dpf + * \brief Context for the De-noise Pre-Filter algorithm + * + * \var IPAFrameContext::dpf.denoise + * \brief Indicates if de-noise 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;