From patchwork Mon May 23 09:24:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16005 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 82463C326D for ; Mon, 23 May 2022 09:24:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0884765665; Mon, 23 May 2022 11:24:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653297893; bh=pF+0FartIekw3vlykOdO3tItB/+BHQEi9mxCGtiusy8=; 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=ltxhor3UlBLsKVP8NWLQyxggAK40VWzYoN4mxHkvhjGF3r0p++ukFtert3vBUpqeh WSLOGv6DNJitJWSe9YRFWpW1zyazbzBs5pncc18tWrAJhw/8TfmQgG3+ROSD4dEVlk n0i49k95jXrV9Mxeisu/Nsdj1fzbWKu25aMmdvDVWdgZ47TSbtmgoax3auCvsAAlU8 IGX0bCykkKMfFdM+NZ7J/wrdAW7S2EX2M0H7hIq5qje1Hzkmo+NiZyqiejPdlKnZJM S0FNbV0oMYpQGNlFvG89+Zr9jVry20y9nvAvxBQ6V1+jTsosAkEEMFatKfGZvkmTnO wh5H0+mkJHJeA== Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6692F65664 for ; Mon, 23 May 2022 11:24:48 +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="hygYUBvW"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id i20-20020a05600c355400b0039456976dcaso7084265wmq.1 for ; Mon, 23 May 2022 02:24:48 -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=BWYAGTM46cpY4F7Zs7rdKi3eRfvDuDKFa5PryrP+6TE=; b=hygYUBvW+GiKzi+sM+S2wJRed+uDyzag66XysxkuVjsNbyDJZRaIr3eFjZTMuG0z2U MsataPnh8aboWE+cp+fVid1h3iTsUOCFFkDTO1tpd7s3Wl1YTOJh+0HGXWKvJ1AC8haQ XE/he1BjiFeWExhDhd7cBkgZDrfJBi3twoFe39Nm822k5WNn+hIdHqZoOE/G0NTRwrdB Ex2diQBhq7ExVwW+zm06da/+F27yTi91N10VJOdoGDZcuWlxM4KtuBVALJhxW6xKGKA0 /fvQRTzzpQTpvvfu02S5/hvUhlOq3NO4QjbZ6Wab0iW94MVMtQMELn5ljL6oB6ioyJDs RWSA== 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=BWYAGTM46cpY4F7Zs7rdKi3eRfvDuDKFa5PryrP+6TE=; b=KxJ+XCEgNbg0txso3V+tGyiL7neOceyj2axu5eiaiXrSBKJTLS0SxCzf5X2/00uoet mz2jkHnN5hiDKeirMAfO3wus7JKe1r7mT20Vo9RFJyeLeSfoahAPaY7J5DtREJpcze81 ELgwWJ4xhCs/zG0Mpy6Pc5zlwb54rua0y1yShBQsshRozrz57mL1EP6dRfrZyN5wUTfz lSdpgd+O9+43krn99t495TFCDbN8E40NhhVRCVc44XDQGxTTZEVgCAXEtbbm6MTtJb7j bDJ9AtB6MLyLOQyXL5S6Ed8ZpfwP6FENCOHennlfeVCicD3Y3JyiFym5ox2XuTqxRnaR AUZw== X-Gm-Message-State: AOAM532TwbeIbxiqHNP320ladZl7AIPOt4n1iR5cxqSD2jMRCwf/9lK2 YXVhd5AnUTAAAlK1y7Eh9BOo1lIbfWBkUg== X-Google-Smtp-Source: ABdhPJxbIgq0PI1P4NMDNZ6WtwOxKXPtAj4SzqnlGdb8rAawGiwso3sN4jx5nw4MNF6V6z/++ZEZhw== X-Received: by 2002:a05:600c:1d9d:b0:397:3dc1:5249 with SMTP id p29-20020a05600c1d9d00b003973dc15249mr11531437wms.144.1653297887787; Mon, 23 May 2022 02:24:47 -0700 (PDT) Received: from BL087.. ([2a01:e34:eea9:e630:1bc6:bcdb:60b7:f1d3]) by smtp.gmail.com with ESMTPSA id w22-20020a1cf616000000b003942a244eebsm8034250wmc.48.2022.05.23.02.24.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 02:24:47 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 23 May 2022 11:24:35 +0200 Message-Id: <20220523092435.475510-6-fsylvestre@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220523092435.475510-1-fsylvestre@baylibre.com> References: <20220523092435.475510-1-fsylvestre@baylibre.com> MIME-Version: 1.0 Subject: [libcamera-devel] [libcamera-devel 5/5] ipa: rkisp1: add support of Black Level Correction default values 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" Get default values for Black Level Correction algorithm form Yaml configuration file. Signed-off-by: Florian Sylvestre --- src/ipa/rkisp1/algorithms/blc.cpp | 46 ++++++++++++++++++++++++++++--- src/ipa/rkisp1/algorithms/blc.h | 9 ++++++ 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp index 0c5948ff..177bc22e 100644 --- a/src/ipa/rkisp1/algorithms/blc.cpp +++ b/src/ipa/rkisp1/algorithms/blc.cpp @@ -7,6 +7,10 @@ #include "blc.h" +#include + +#include + /** * \file blc.h */ @@ -29,6 +33,40 @@ namespace ipa::rkisp1::algorithms { * isn't currently supported. */ +LOG_DEFINE_CATEGORY(RkISP1Blc) + +/** + * \copydoc libcamera::ipa::Algorithm::init + */ +int BlackLevelCorrection::init(IPAContext &context, + const YamlObject *params) +{ + if (context.frameContext.frameCount > 0) + return -EBUSY; + + /* Parse property "BlackLevelCorrection" */ + if (!params->contains("BlackLevelCorrection")) + return -EINVAL; + + const YamlObject &blcObject = (*params)["BlackLevelCorrection"]; + + if (!blcObject.isDictionary()) + return -EINVAL; + + blackLevelRed_ = blcObject["R"].get(256); + blackLevelGreenR_ = blcObject["Gr"].get(256); + blackLevelGreenB_ = blcObject["Gb"].get(256); + blackLevelBlue_ = blcObject["B"].get(256); + + LOG(RkISP1Blc, Debug) + << " Read black levels red " << blackLevelRed_ + << " green (red) " << blackLevelGreenR_ + << " green (blue) " << blackLevelGreenB_ + << " blue " << blackLevelBlue_; + + return 0; +} + /** * \copydoc libcamera::ipa::Algorithm::prepare */ @@ -42,10 +80,10 @@ void BlackLevelCorrection::prepare(IPAContext &context, * \todo Use a configuration file for it ? */ params->others.bls_config.enable_auto = 0; - params->others.bls_config.fixed_val.r = 256; - params->others.bls_config.fixed_val.gr = 256; - params->others.bls_config.fixed_val.gb = 256; - params->others.bls_config.fixed_val.b = 256; + params->others.bls_config.fixed_val.r = blackLevelRed_; + params->others.bls_config.fixed_val.gr = blackLevelGreenR_; + params->others.bls_config.fixed_val.gb = blackLevelGreenB_; + params->others.bls_config.fixed_val.b = blackLevelBlue_; params->module_en_update |= RKISP1_CIF_ISP_MODULE_BLS; params->module_ens |= RKISP1_CIF_ISP_MODULE_BLS; diff --git a/src/ipa/rkisp1/algorithms/blc.h b/src/ipa/rkisp1/algorithms/blc.h index 69874d8f..2f6e2d82 100644 --- a/src/ipa/rkisp1/algorithms/blc.h +++ b/src/ipa/rkisp1/algorithms/blc.h @@ -13,6 +13,8 @@ namespace libcamera { +class YamlObject; + struct IPACameraSensorInfo; namespace ipa::rkisp1::algorithms { @@ -23,7 +25,14 @@ public: BlackLevelCorrection() = default; ~BlackLevelCorrection() = default; + int init(IPAContext &context, const YamlObject *params) override; void prepare(IPAContext &context, rkisp1_params_cfg *params) override; + +private: + int16_t blackLevelRed_; + int16_t blackLevelGreenR_; + int16_t blackLevelGreenB_; + int16_t blackLevelBlue_; }; } /* namespace ipa::rkisp1::algorithms */