[{"id":23423,"web_url":"https://patchwork.libcamera.org/comment/23423/","msgid":"<Yqr6WlkprUwmc3J6@pendragon.ideasonboard.com>","date":"2022-06-16T09:39:38","subject":"Re: [libcamera-devel] [PATCH v2 5/5] ipa: rkisp1: add support of\n\tBlack Level Correction default values","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Florian,\n\nThank you for the patch.\n\nOn Thu, Jun 16, 2022 at 10:07:44AM +0200, Florian Sylvestre via libcamera-devel wrote:\n> Get default values for Black Level Correction algorithm form Yaml\n\ns/form Yaml/from the YAML/\n\n> tuning file.\n> \n> Signed-off-by: Florian Sylvestre <fsylvestre@baylibre.com>\n> ---\n>  src/ipa/rkisp1/algorithms/blc.cpp | 71 +++++++++++++++++++++++++------\n>  src/ipa/rkisp1/algorithms/blc.h   |  8 ++++\n>  2 files changed, 66 insertions(+), 13 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp\n> index 0c5948ff..d11160d3 100644\n> --- a/src/ipa/rkisp1/algorithms/blc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/blc.cpp\n> @@ -7,6 +7,10 @@\n>  \n>  #include \"blc.h\"\n>  \n> +#include <libcamera/base/log.h>\n> +\n> +#include \"libcamera/internal/yaml_parser.h\"\n> +\n>  /**\n>   * \\file blc.h\n>   */\n> @@ -29,6 +33,45 @@ namespace ipa::rkisp1::algorithms {\n>   * isn't currently supported.\n>   */\n>  \n> +LOG_DEFINE_CATEGORY(RkISP1Blc)\n> +\n> +/**\n> + * \\copydoc libcamera::ipa::Algorithm::init\n> + */\n> +int BlackLevelCorrection::init(IPAContext &,\n\nWe use [[maybe_unused]] instead of omitting the parameter name, as it's\nmore standard.\n\n> +\t\t\t       const YamlObject *params)\n> +{\n> +\ttuningParameters_ = false;\n\nThis should be initialized in the constructor.\n\n> +\n> +\t/* Parse property \"BlackLevelCorrection\". */\n> +\tif (!params->contains(\"BlackLevelCorrection\")) {\n> +\t\tLOG(RkISP1Blc, Debug) << \"No tuning parameters found for BlackLevelCorrection\";\n> +\t\treturn 0;\n> +\t}\n> +\n> +\tconst YamlObject &blcObject = (*params)[\"BlackLevelCorrection\"];\n> +\n> +\tif (!blcObject.isDictionary()) {\n> +\t\tLOG(RkISP1Blc, Error) << \"'BlackLevelCorrection' in tuning file is not a dictionnary\";\n> +\t\treturn -EINVAL;\n> +\t}\n> +\n> +\tblackLevelRed_ = blcObject[\"R\"].get<int16_t>(256);\n> +\tblackLevelGreenR_ = blcObject[\"Gr\"].get<int16_t>(256);\n> +\tblackLevelGreenB_ = blcObject[\"Gb\"].get<int16_t>(256);\n> +\tblackLevelBlue_ = blcObject[\"B\"].get<int16_t>(256);\n> +\n> +\ttuningParameters_ = true;\n> +\n> +\tLOG(RkISP1Blc, Debug)\n> +\t\t<< \" Read black levels red \" << blackLevelRed_\n> +\t\t<< \" green (red) \" << blackLevelGreenR_\n> +\t\t<< \" green (blue) \" << blackLevelGreenB_\n> +\t\t<< \" blue \" << blackLevelBlue_;\n\n\t\t<< \", green (red) \" << blackLevelGreenR_\n\t\t<< \", green (blue) \" << blackLevelGreenB_\n\t\t<< \", blue \" << blackLevelBlue_;\n\nwill be more readable in the log.\n\n> +\n> +\treturn 0;\n> +}\n> +\n>  /**\n>   * \\copydoc libcamera::ipa::Algorithm::prepare\n>   */\n> @@ -37,19 +80,21 @@ void BlackLevelCorrection::prepare(IPAContext &context,\n>  {\n>  \tif (context.frameContext.frameCount > 0)\n>  \t\treturn;\n> -\t/*\n> -\t * Substract fixed values taken from imx219 tuning file.\n> -\t * \\todo Use a configuration file for it ?\n> -\t */\n> -\tparams->others.bls_config.enable_auto = 0;\n> -\tparams->others.bls_config.fixed_val.r = 256;\n> -\tparams->others.bls_config.fixed_val.gr = 256;\n> -\tparams->others.bls_config.fixed_val.gb = 256;\n> -\tparams->others.bls_config.fixed_val.b = 256;\n> -\n> -\tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_BLS;\n> -\tparams->module_ens |= RKISP1_CIF_ISP_MODULE_BLS;\n> -\tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_BLS;\n> +\n> +\tif (tuningParameters_) {\n\n\tif (!tuningParameters_)\n\t\treturn;\n\nwill save you an indentation level below.\n\n> +\t\t/*\n> +\t\t* Substract fixed values taken from imx219 tuning file.\n\nWrong indentation.\n\nBut the comment isn't right anymore :-) You can thus drop it.\n\n> +\t\t*/\n> +\t\tparams->others.bls_config.enable_auto = 0;\n> +\t\tparams->others.bls_config.fixed_val.r = blackLevelRed_;\n> +\t\tparams->others.bls_config.fixed_val.gr = blackLevelGreenR_;\n> +\t\tparams->others.bls_config.fixed_val.gb = blackLevelGreenB_;\n> +\t\tparams->others.bls_config.fixed_val.b = blackLevelBlue_;\n> +\n> +\t\tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_BLS;\n> +\t\tparams->module_ens |= RKISP1_CIF_ISP_MODULE_BLS;\n> +\t\tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_BLS;\n> +\t}\n>  }\n>  \n>  } /* namespace ipa::rkisp1::algorithms */\n> diff --git a/src/ipa/rkisp1/algorithms/blc.h b/src/ipa/rkisp1/algorithms/blc.h\n> index 69874d8f..ed2e8ed9 100644\n> --- a/src/ipa/rkisp1/algorithms/blc.h\n> +++ b/src/ipa/rkisp1/algorithms/blc.h\n> @@ -23,7 +23,15 @@ public:\n>  \tBlackLevelCorrection() = default;\n>  \t~BlackLevelCorrection() = default;\n>  \n> +\tint init(IPAContext &context, const YamlObject *params) override;\n>  \tvoid prepare(IPAContext &context, rkisp1_params_cfg *params) override;\n> +\n> +private:\n> +\tbool tuningParameters_;\n> +\tint16_t blackLevelRed_;\n> +\tint16_t blackLevelGreenR_;\n> +\tint16_t blackLevelGreenB_;\n> +\tint16_t blackLevelBlue_;\n>  };\n>  \n>  } /* namespace ipa::rkisp1::algorithms */","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 49046BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 16 Jun 2022 09:39:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3581F65635;\n\tThu, 16 Jun 2022 11:39:52 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BC824601F1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 16 Jun 2022 11:39:49 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C65D7898;\n\tThu, 16 Jun 2022 11:39:48 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655372392;\n\tbh=7qpbXI+x6mRBVEf7LZL7+vw7hXvzrB4z9tUv0o0qTDU=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=IDvAMFZGHyg7mlBJTwatvrXXiWbAFLiimPzmLRlTI3l+Cd8SP9ZhkmoxRXMUwqQlV\n\tGGO/ARux2n+/uXnmCJddGBxcZ+x06ZE8qMpwXjLqXLcynnxDPjjsxLvKR/lhiVfE0t\n\tPop9/RkmJH0dh4xmzwbdNzuoB3y1cSkva+5+UfUaSTfHOmzgYVBk71/2Phb6l/yUK7\n\tc04G05FoddXG4cXCOW8n7KUqSqliO/8z6W0rcZBbw+A5SAwwCLQ1Xj32CdypC91Dqa\n\te5U2JZO3ScjbSgTlKKTbCp33XbGgghg20V5DvTvqR+8jzuj8L4mWfupNwQ2q5VVNgY\n\thLXYi85/uXmgQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655372389;\n\tbh=7qpbXI+x6mRBVEf7LZL7+vw7hXvzrB4z9tUv0o0qTDU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=J59p/EQ5vIVd/zUE69nd07yVxRtoT05WTNa6bLa1eOlONnyhKRE5gPed7wQsPDlbJ\n\tCeGTv0/kAT4wrUWBORlFNJ2NpsBYCXXBcA1o/3p0mh7CG8Isw3pY289mJOvb6xqi15\n\tEp8irbAtWHFIdZPhCv2n4M75fOZFCwx3C6d8ln14="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"J59p/EQ5\"; dkim-atps=neutral","Date":"Thu, 16 Jun 2022 12:39:38 +0300","To":"Florian Sylvestre <fsylvestre@baylibre.com>","Message-ID":"<Yqr6WlkprUwmc3J6@pendragon.ideasonboard.com>","References":"<20220616080744.548995-1-fsylvestre@baylibre.com>\n\t<20220616080744.548995-6-fsylvestre@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220616080744.548995-6-fsylvestre@baylibre.com>","Subject":"Re: [libcamera-devel] [PATCH v2 5/5] ipa: rkisp1: add support of\n\tBlack Level Correction default values","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]