[{"id":23468,"web_url":"https://patchwork.libcamera.org/comment/23468/","msgid":"<Yqy7hs+PMCov1LrA@pendragon.ideasonboard.com>","date":"2022-06-17T17:36:06","subject":"Re: [libcamera-devel] [PATCH v3 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 Fri, Jun 17, 2022 at 11:23:15AM +0200, Florian Sylvestre wrote:\n> Get default values for Black Level Correction algorithm form YAML\n\ns/form/from/\n\nI notice you have picked only part of the suggested spelling corrections\nfrom previous reviews in multiple occasions. Is there a way I could\nexpress them more clearly to make sure they are correctly understood ?\n\n> tuning file.\n> \n> Signed-off-by: Florian Sylvestre <fsylvestre@baylibre.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n>  src/ipa/rkisp1/algorithms/blc.cpp | 62 +++++++++++++++++++++++++++----\n>  src/ipa/rkisp1/algorithms/blc.h   | 10 ++++-\n>  2 files changed, 63 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/blc.cpp b/src/ipa/rkisp1/algorithms/blc.cpp\n> index 0c5948ff..aa4fe8c6 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,48 @@ namespace ipa::rkisp1::algorithms {\n>   * isn't currently supported.\n>   */\n>  \n> +LOG_DEFINE_CATEGORY(RkISP1Blc)\n> +\n> +BlackLevelCorrection::BlackLevelCorrection()\n> +\t: tuningParameters_(false)\n> +{\n> +}\n> +\n> +/**\n> + * \\copydoc libcamera::ipa::Algorithm::init\n> + */\n> +int BlackLevelCorrection::init([[maybe_unused]] IPAContext &context,\n> +\t\t\t       const YamlObject &params)\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> +\treturn 0;\n> +}\n> +\n>  /**\n>   * \\copydoc libcamera::ipa::Algorithm::prepare\n>   */\n> @@ -37,15 +83,15 @@ 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> +\n> +\tif (!tuningParameters_)\n> +\t\treturn;\n> +\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> +\tparams->others.bls_config.fixed_val.r = blackLevelRed_;\n> +\tparams->others.bls_config.fixed_val.gr = blackLevelGreenR_;\n> +\tparams->others.bls_config.fixed_val.gb = blackLevelGreenB_;\n> +\tparams->others.bls_config.fixed_val.b = blackLevelBlue_;\n>  \n>  \tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_BLS;\n>  \tparams->module_ens |= RKISP1_CIF_ISP_MODULE_BLS;\n> diff --git a/src/ipa/rkisp1/algorithms/blc.h b/src/ipa/rkisp1/algorithms/blc.h\n> index 69874d8f..c979d327 100644\n> --- a/src/ipa/rkisp1/algorithms/blc.h\n> +++ b/src/ipa/rkisp1/algorithms/blc.h\n> @@ -20,10 +20,18 @@ namespace ipa::rkisp1::algorithms {\n>  class BlackLevelCorrection : public Algorithm\n>  {\n>  public:\n> -\tBlackLevelCorrection() = default;\n> +\tBlackLevelCorrection();\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 AF4C2BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 17 Jun 2022 17:36:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A2E2765635;\n\tFri, 17 Jun 2022 19:36:20 +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 D6F8F65632\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Jun 2022 19:36:18 +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 65466982;\n\tFri, 17 Jun 2022 19:36:18 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655487380;\n\tbh=pKNwMUy77KJgff+zPg7s8lRe2mWu/7px8lOT3A+kACc=;\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=f8D21r6J5wuR6uyvc7UW55BSUsHAfKC0A5ISsEwj+gcxgRqc3y6bBgLXJVLoAMAqE\n\tpEvsoXSwCj2xQRsgFGaC6zPiPPA3d7CBQE4F8EHKWcLJVmvUKCGEZk0dLDP/ueZy1q\n\tO+XYe2BXRFbH6LspiSdoJFmxvwk/uWFYi0iNZYfOZgnDZtI+ZnLiAdwCdHWayInRHK\n\t/csbDTXceRH0c3sI7Z4GSsKxIsyvkE5/zs7Y4GcNlIeCLya+OEdXOYhXt+M9SKqT6L\n\tBB7g2nOLS8l8i8vblSEi9g6pyvXTN7DcrIkgb2tdA0yrkjLh+ndeoWPx6bxEg8AZ/t\n\tac/1JejiYPPYg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655487378;\n\tbh=pKNwMUy77KJgff+zPg7s8lRe2mWu/7px8lOT3A+kACc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Cz9AVeMYMU4HqkpMJx+RUvJc0pJNM+5UDMlfWz30V5RwSbj9vh99YefJHtzHzINtW\n\tLf94VjVEz8AtEQGTRHhDsYLeT8HY8w3DCewyzCin9tc18ASmolkTIBqTYMtfcZ27XR\n\t6JjGqLA7OVJjktSan3uk9ALFT4qfEVxtIeVWZ9UA="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Cz9AVeMY\"; dkim-atps=neutral","Date":"Fri, 17 Jun 2022 20:36:06 +0300","To":"Florian Sylvestre <fsylvestre@baylibre.com>","Message-ID":"<Yqy7hs+PMCov1LrA@pendragon.ideasonboard.com>","References":"<20220617092315.120781-1-fsylvestre@baylibre.com>\n\t<20220617092315.120781-6-fsylvestre@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220617092315.120781-6-fsylvestre@baylibre.com>","Subject":"Re: [libcamera-devel] [PATCH v3 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>"}}]