From patchwork Fri Jun 17 09:23:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16262 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 8423EC3277 for ; Fri, 17 Jun 2022 09:23:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7F50F65649; Fri, 17 Jun 2022 11:23:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655457836; bh=TloXXzm5eo2KHa8EodsfPeU+QqYB63AheceWFReMO2g=; 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=nZlYXwR4tYFH8VcbB+cLcX/q2ITVuSE0yhsQzEJODCntCq5zWLQH0PIkvc23/ktek BGDejN/lo/ZFkl+MXiv91Q8qbooCVTeiP2ArjkbMKCNap/+hWVQNXNZ6f7yzmxYEq+ 2FdS8/e9YpKSD67pajxTqgDDftscvkIR10IGPJlVttz/uWL/yg0THKkLkVelcMLc9s kgg+A0WHKRJeDKx1x3yFgSWvnZGQSbjslQ6sDuFMfdKxXeDEK1qWBExz8BVew9hiVd 5LhL2TQ7aMva+l5eCUn2qpMJQf/Ziu1f8j8kvNETJTuKNJD/r7Y16Ort8xcjacw1RQ eEPJ8B8GNcomQ== Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D34756563F for ; Fri, 17 Jun 2022 11:23:52 +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="FchiH7Xp"; dkim-atps=neutral Received: by mail-wm1-x330.google.com with SMTP id c130-20020a1c3588000000b0039c6fd897b4so4037923wma.4 for ; Fri, 17 Jun 2022 02:23:52 -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=XeKsV/YuY0fyhoiofGONCkdluUpahL9gkkVSrZ2xqrQ=; b=FchiH7XpKmvEux2rwv8t9105jqb4Yr2mUVclfaPl+wJM/pDA5+b+OKb7U73e23F0rN pXdQU4gt21KwSSXa5q1cn4OKBsodYAl03Zh2AMGW1Wwq07T4ETCVzxi12vjIt+XJGq4x OB0BI8OoCvDoHJ21DREEwetDlZngH+RqDet38NKaD3V0Ry01JbOofrQ+ZLABCUa9SyGH gu2jWW00jpGA+EoNWjWPPqEqeMtZ/t9S1I5yswU7DG6OLMpqJIv+akdU9ckR8IjvK+sF wSQKbPVPmkMUsJldaNgONXQ38qnfH3fZgand0baxkdcDt0umdKVk/DeuNsqL/gHKBwbQ xBmg== 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=XeKsV/YuY0fyhoiofGONCkdluUpahL9gkkVSrZ2xqrQ=; b=s19HfovdpPjTQit97zO+gfyWW1QMlXVjJUj7grWIjzSfYE6S/J+nn7mSt8XssznzMV hrT72Bvyfv+8cTTpdZLV2vLFFnEtlVLyrEwHqdSWT/UWvBaN5Eschl8qxahvN47eeJu/ oNZddVdDbTH4TCWE6mPjLQ7cgs3waQyO60RMI8WqH/uybHNNYij5a++fnO4QOgqbACJX xM9bDLfoYihAX4Sia8S62cTJgVs4n+gL04t07I5LD/PJKTrv6YzCCZtZze+zyZNWg3hR F5kAzoScpfWUVxFFQyMc1a03d1fCDoVIaoKqpxX9RcQgSYJ0Jq4gcax6qW9Rg3QC+6DQ TnWQ== X-Gm-Message-State: AOAM532mcHReFfL0xC8tiSAgvKblxDcQtixHQudGSPsaGFZBvgHKYImL G9noQ+8NhEjGvwVC96Q/vqNbGn5eTWN5AA== X-Google-Smtp-Source: ABdhPJxb8NPFwY8qo61pAcoKUQMCJ5nfmxPR5SaAPP/olIa6/zOSyY8JiKqnn2VZFNx2ZlysOkJWww== X-Received: by 2002:a1c:19c3:0:b0:39c:6479:3ca with SMTP id 186-20020a1c19c3000000b0039c647903camr20090483wmz.27.1655457832100; Fri, 17 Jun 2022 02:23:52 -0700 (PDT) Received: from BL087.. ([2a01:e34:eea9:e630:4718:73b:d035:3786]) by smtp.gmail.com with ESMTPSA id h81-20020a1c2154000000b0039c41686421sm7962328wmh.17.2022.06.17.02.23.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 02:23:51 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 17 Jun 2022 11:23:15 +0200 Message-Id: <20220617092315.120781-6-fsylvestre@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220617092315.120781-1-fsylvestre@baylibre.com> References: <20220617092315.120781-1-fsylvestre@baylibre.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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 tuning file. Signed-off-by: Florian Sylvestre Reviewed-by: Laurent Pinchart Reviewed-by: Paul Elder --- src/ipa/rkisp1/algorithms/blc.cpp | 62 +++++++++++++++++++++++++++---- src/ipa/rkisp1/algorithms/blc.h | 10 ++++- 2 files changed, 63 insertions(+), 9 deletions(-) diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp index 0c5948ff..aa4fe8c6 100644 --- a/src/ipa/rkisp1/algorithms/blc.cpp +++ b/src/ipa/rkisp1/algorithms/blc.cpp @@ -7,6 +7,10 @@ #include "blc.h" +#include + +#include "libcamera/internal/yaml_parser.h" + /** * \file blc.h */ @@ -29,6 +33,48 @@ namespace ipa::rkisp1::algorithms { * isn't currently supported. */ +LOG_DEFINE_CATEGORY(RkISP1Blc) + +BlackLevelCorrection::BlackLevelCorrection() + : tuningParameters_(false) +{ +} + +/** + * \copydoc libcamera::ipa::Algorithm::init + */ +int BlackLevelCorrection::init([[maybe_unused]] IPAContext &context, + const YamlObject ¶ms) +{ + /* Parse property "BlackLevelCorrection". */ + if (!params.contains("BlackLevelCorrection")) { + LOG(RkISP1Blc, Debug) << "No tuning parameters found for BlackLevelCorrection"; + return 0; + } + + const YamlObject &blcObject = params["BlackLevelCorrection"]; + + if (!blcObject.isDictionary()) { + LOG(RkISP1Blc, Error) << "'BlackLevelCorrection' in tuning file is not a dictionnary"; + return -EINVAL; + } + + blackLevelRed_ = blcObject["R"].get(256); + blackLevelGreenR_ = blcObject["Gr"].get(256); + blackLevelGreenB_ = blcObject["Gb"].get(256); + blackLevelBlue_ = blcObject["B"].get(256); + + tuningParameters_ = true; + + LOG(RkISP1Blc, Debug) + << " Read black levels red " << blackLevelRed_ + << ", green (red) " << blackLevelGreenR_ + << ", green (blue) " << blackLevelGreenB_ + << ", blue " << blackLevelBlue_; + + return 0; +} + /** * \copydoc libcamera::ipa::Algorithm::prepare */ @@ -37,15 +83,15 @@ void BlackLevelCorrection::prepare(IPAContext &context, { if (context.frameContext.frameCount > 0) return; - /* - * Substract fixed values taken from imx219 tuning file. - * \todo Use a configuration file for it ? - */ + + if (!tuningParameters_) + return; + 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..c979d327 100644 --- a/src/ipa/rkisp1/algorithms/blc.h +++ b/src/ipa/rkisp1/algorithms/blc.h @@ -20,10 +20,18 @@ namespace ipa::rkisp1::algorithms { class BlackLevelCorrection : public Algorithm { public: - BlackLevelCorrection() = default; + BlackLevelCorrection(); ~BlackLevelCorrection() = default; + int init(IPAContext &context, const YamlObject ¶ms) override; void prepare(IPAContext &context, rkisp1_params_cfg *params) override; + +private: + bool tuningParameters_; + int16_t blackLevelRed_; + int16_t blackLevelGreenR_; + int16_t blackLevelGreenB_; + int16_t blackLevelBlue_; }; } /* namespace ipa::rkisp1::algorithms */