From patchwork Mon May 23 09:24:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16001 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 617EFBD160 for ; Mon, 23 May 2022 09:24:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1586A65665; Mon, 23 May 2022 11:24:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653297887; bh=cUEB+NwwZLYKyjLZOzZxvMQapwWS39paO/S54zNivfg=; 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=tGKrBJIKZ9bEsT0mB9EyVthoHpm90eUgii4MKDytJ7Koi7JhFEWw4FvSljbCZQX/Y o5yg55kybGjxITag7akNbOXyR5nIcZh1wIiWBknS+lrGD46YiNj+iS0IHkKn19nyyM XJiholTPIyOq+lCQW85ZvF07LPqPaD0pm9hBIJgQamFfuYsIKq779kx7VGHzs3dwVF q0K4n8eJkUpoHpKxGuSsHNc20J4TDVVHK14/xObLSQivyk6ho15DLx8LZZAB6Eaa9F tyahbIepatsuNATVWru0m4bSyQX7hxNeus8V3C/WDxnC2JFM6srYu+yIxXP3vhgSoG b6wH4apbJL8LQ== Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 04E4A6565E for ; Mon, 23 May 2022 11:24:45 +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="AMINoZDi"; dkim-atps=neutral Received: by mail-wr1-x435.google.com with SMTP id h14so20424211wrc.6 for ; Mon, 23 May 2022 02:24:45 -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=c87SE8ICoMPP/SKr7cW6b2KTo2OKSmdf4bbsdFw7VKQ=; b=AMINoZDifmeUtxSJyk5XyPShUHIn2kgihOMb0AxQxpJ1xP7LVaovODx7GXuKCdXkBZ DmddGjWnr1F6mgTgLXlckXpAL6g5+jTydGRs/NI9DcrDbId//8e2Z721lN/XNmiHWuVw qlJUnLoueHG9sEWEYOvffUU47jRh8rFL40wVFc+ykCrwT2eOkjzPFSPhRARA63HDVYSg tAQknMMBOjcNkPkIUlYFVpRH7KH/rW1QpfaddwxnihGbnkkDYXtr/YYw5ssdx6iRafKT pWveHlvizAQpZVxVV213yRWvXgSFIWDQEDZ44yStem2vftKcbykZleVVI22vFwhM2sDI PG4A== 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=c87SE8ICoMPP/SKr7cW6b2KTo2OKSmdf4bbsdFw7VKQ=; b=i1GRHSHj9mquxojTbcKPqJNu4m4P+bXkjnliPY8XxGAHL1oUifaHptvLoxeZPljRcd KW0iTegdlstbn/RMiA/a1s9wwCQ8PwIjrLxV7Xuq4JkN5kkULrz+KL3mSOnnu53U6t7G SFGSf8LLZuhVLZ69d6slaO/7jcVHoQpQ6gGzBnErWQ42CgFUM37LZzkYfBoGQBXoK1wS oGWR1U+nrzxbvBCyhPFnaue2rITnKbqfY8a+4n4EFiSHG3YvOQQMBtlsUxBP9WyNWCVP xgQlfk/XAWeRuc/YDEGAqN2NkAJoWxor7k+22TRIE+YDYdyr2fFpeMQENf6UqBT2p7R9 Leeg== X-Gm-Message-State: AOAM533kny7t+Nk9djAnPHHJryYdk+CCMlzq87n434aUhu1Fi1rQo8Iv 1ob8NCEI3+WCZdNFP8MSWoejVN6/d5uhYg== X-Google-Smtp-Source: ABdhPJxSXAq8EDVhF5k8Hj4OFcdR079KOc+sg0GZXB1LICqfdA4NnFlMsjfk6CgT8sqDGudaGm0TMA== X-Received: by 2002:a5d:4a82:0:b0:20d:3b9:740e with SMTP id o2-20020a5d4a82000000b0020d03b9740emr17725049wrq.718.1653297884534; Mon, 23 May 2022 02:24:44 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 02:24:44 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 23 May 2022 11:24:31 +0200 Message-Id: <20220523092435.475510-2-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 1/5] pipeline: rkisp1: Support sensor tuning file 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" Allow the usage of a Yaml configuration file that is either defined by the sensor name (sensor_name.yaml) or defined by LIBCAMERA_RKISP1_TUNING_FILE environment variable. Signed-off-by: Florian Sylvestre Reviewed-by: Laurent Pinchart Reviewed-by: Paul Elder --- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 4b3d2cf7..865c4ab0 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -322,7 +322,18 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision) ipa_->paramsBufferReady.connect(this, &RkISP1CameraData::paramFilled); ipa_->metadataReady.connect(this, &RkISP1CameraData::metadataReady); - int ret = ipa_->init(IPASettings{ "", sensor_->model() }, hwRevision); + /* + * The configuration (tuning file) is made from the sensor name unless + * the environment variable overrides it. + */ + std::string configurationFile; + char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RKISP1_TUNING_FILE"); + if (!configFromEnv || *configFromEnv == '\0') + configurationFile = ipa_->configurationFile(sensor_->model() + ".yaml"); + else + configurationFile = std::string(configFromEnv); + + int ret = ipa_->init({ configurationFile, sensor_->model() }, hwRevision); if (ret < 0) { LOG(RkISP1, Error) << "IPA initialization failure"; return ret; From patchwork Mon May 23 09:24:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16002 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 BC644BD160 for ; Mon, 23 May 2022 09:24:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D46A86566D; Mon, 23 May 2022 11:24:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653297890; bh=IOYq8ESWic3swOVBQrSCimHXwEZ4ZyhdhnWaNpOd7O0=; 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=eUht9LQh0yQd0IHsz8EuYqYjFSstBEe5VZVN0trJ0OzqXZHevaqwYFnKwZw46d6xv dNivQDafWqd5obwxmP1r8IaNptaH3Jgzbj081JakV/hJNBUsHymLjure2T96Gcheog jXysvtOjMdlJN/LtxQSAsUSC/Yeijds3Nca/16t+G1FzJAOoYXbNM73rhZq9x7flSL bnRTLqWPopa8TgCth1YWoslSHBwm/2SIBvgEC2rPQohELCrNM1dLN48klm5mKw/AA8 VcE6slrX8cA3sLWrwgU6VY9v7HvLLGwUUBd/B9sH95u5tZapJbxSFTUzibAnw3QGTg Cvg+is85iByeQ== Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 130666565E for ; Mon, 23 May 2022 11:24:46 +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="LyCRfCJZ"; dkim-atps=neutral Received: by mail-wm1-x32f.google.com with SMTP id o9so666937wmd.0 for ; Mon, 23 May 2022 02:24:46 -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=1DvUzTGwqBhOBuZt/0h7g+g5MxcYSFWLZ7UT0nopWWY=; b=LyCRfCJZ4x5EG/uHg5coLvLEkn0ElJkntmN7gLvlk6bOEushXqMHxV8vmdFtF6RFly gF3VUqQJP0hOif97qbIPEi8iX++dayyef9RjidVCseFk0RTpGBg7wUnMMxMzAiD2CjVx hX/r850NvFKJe5E+fko+YX0SE4noEXaVA/aUjuuuA1PBjbgm46cUnPhJYcAEtoy5wjO8 uC0OU/zFqejzynUlUCoooJ9QQUi5eJMs06sgNePl0I6G/58vR4yAXpR1EJOtcdDCsuCF zcMfQU46RBiKnGcq+hiN3hnxKFw83DmZwa/qG+Fp6/ikaeteWG+A/IMuEDBcI2viCjqz JmmQ== 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=1DvUzTGwqBhOBuZt/0h7g+g5MxcYSFWLZ7UT0nopWWY=; b=sKC/01pG2TBbgtjI2QWK30PVGrG98q2FJ5xEKLgWyp40Hb9BJNLInIAFEbEOAwW6Tu Y0IEy7qYq2RM5X0+muaQO7zh9tOskONJud8FqmL0G0JBRlAdHLOy5d8dU0nRDTDsE6y+ NGZ4rRx3umNiGkzy8048iwfZ7j06Gd+nuEdIWgwCMkHc3Wz+80C5EzP0l/N0wyYZRHSd txYbxayx2q6uRJ7eo/3tWf6u63oXefy8uxQ55gLygv3SvAiULGQZVhHheMJsScZz6/Lm CkRr4NFDbE6w3K6/7K8oadJx7xVwt9o4YaP8sS3jmdZyLqTt3KQ0ODuTfXNeBvKhBmH4 pSpg== X-Gm-Message-State: AOAM533jyDjvQkEK/m/Yw99v5uOwA62XrLpUdS5nE9luRmdCcbcZXSai Am4VSeM5NeO9SwDV4DDWML3iOJae1qCYFQ== X-Google-Smtp-Source: ABdhPJxtsmjeaLCV5Yi/Ni5cZOoTaWivdnwW7xR9SWVilNj4+QThHyardifQDHQoCJ46Dlfp6QKJew== X-Received: by 2002:a05:600c:4fd2:b0:397:4c02:958f with SMTP id o18-20020a05600c4fd200b003974c02958fmr3550495wmq.180.1653297885369; Mon, 23 May 2022 02:24:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 02:24:44 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 23 May 2022 11:24:32 +0200 Message-Id: <20220523092435.475510-3-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 2/5] ipa: libipa: Add init() function to the Algorithm class 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 the init() function that will be called during algorithm initialization to provide each algorithm the list of algorithms tuning data. Each algorithm will be responsible to grab their corresponding parameters. Signed-off-by: Florian Sylvestre Reviewed-by: Paul Elder --- src/ipa/libipa/algorithm.cpp | 15 +++++++++++++++ src/ipa/libipa/algorithm.h | 10 +++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp index 398d5372..269a4beb 100644 --- a/src/ipa/libipa/algorithm.cpp +++ b/src/ipa/libipa/algorithm.cpp @@ -29,6 +29,21 @@ namespace ipa { * to manage algorithms regardless of their specific type. */ +/** + * \fn Algorithm::init() + * \brief Configure the Algorithm with default parameters + * \param[in] context The shared IPA context + * \param[in] params The initial parameters used to tune algorithms + * + * This function is called once before the camera is running to get default + * algorithm parameters. + * + * Algorithms are responsible to read the parameters given and extract their + * parameter configuration. + * + * \return 0 if successful, an error code otherwise + */ + /** * \fn Algorithm::configure() * \brief Configure the Algorithm given an IPAConfigInfo diff --git a/src/ipa/libipa/algorithm.h b/src/ipa/libipa/algorithm.h index 766aee5d..f5be1caf 100644 --- a/src/ipa/libipa/algorithm.h +++ b/src/ipa/libipa/algorithm.h @@ -10,12 +10,20 @@ namespace libcamera { namespace ipa { -template +template + class Algorithm { public: virtual ~Algorithm() {} + virtual int init([[maybe_unused]] Context &context, + [[maybe_unused]] const TuningData *params) + { + return 0; + } + virtual int configure([[maybe_unused]] Context &context, [[maybe_unused]] const Config &configInfo) { From patchwork Mon May 23 09:24:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16003 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 0F673C3256 for ; Mon, 23 May 2022 09:24:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A8BBA65666; Mon, 23 May 2022 11:24:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653297891; bh=kZxk0NVbb8Hm0WltkUCI26czoTpAsmKnSvlffhi7O/Q=; 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=TNnZxyGfpGPKp1gG5jcT8Rp58K66U/TXMLn1KvSJBKh9FZZU7Is5pwM0o6EgXl9Vg F+OcuwwwR2gqAnWafVABtcaa844Pn6368a7bUcIqxkMvi9EM8cO390vSHMC3NHkQgB KR9HpQtcJHI3+LAqfy+E1PAHKvoxd9PHjBIkJ4ni20UpjnFyAYq0JHxAgdNpcE6za+ V3AJtZBucUVkYjZB4Dzsn+goBZZOD4vJXT+SFDFMwZ1lRcbj3dIWWtDaIjPcrldLP2 wvIoWb74tTHnKWK4nEnMxP2PjD4fpWDtFpgKn3wzxz2ePjnB8zW7sRZ/ia2NOCr9Qr HNzDH8CEUHkCw== Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E5E0465669 for ; Mon, 23 May 2022 11:24:46 +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="WI3WSQfS"; dkim-atps=neutral Received: by mail-wm1-x336.google.com with SMTP id 184-20020a1c02c1000000b003974edd7c56so1860wmc.2 for ; Mon, 23 May 2022 02:24:46 -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=Q8q1+OAMp24LB9fLgpAqDcjnJp128nBRCd8CXPkDeQY=; b=WI3WSQfSyy/LPlpVejZ/ucoYvulAcUbIr6Ui4Lw0YNfPLYi4MWXAt1ZU7Pk/16PAQe zPOow1DZO2+Q5DkRRCuEEhx1kzsmqD/YV+7mvSgQIBW1K9hO0JGGqHLgKBLS9IdkGE2k b0bmRETBQzk1+6OgmiKgoGRCVLqSTo+N+EonxwQtowoQjmTmaHuQYrRof4BZGAIYF263 VrFTgrbc6pF5FwNEOJWTWB1gONjYMH0oVH7Qog4wTOQBi/a91JcDTLY0PPgkNy+/gANy YVWfKEt6kNFdjfFqjHsWs3x+2nodMO+TsWDpM+lgNJvD1ezG0rhP7zZkXjSwD7rQZOZu aS+w== 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=Q8q1+OAMp24LB9fLgpAqDcjnJp128nBRCd8CXPkDeQY=; b=caibQbfzqeMyiMNMNw4+vk9qAwKo/StadyYLYJ8OvUNbiUw+O9kDSC3p++fgH2gOax gmvw7praOQmDW/0youQ0vraJ9Dv82rbvFR1CUe241Xj2SvPRr+07ppXSVoh64EzWMKFq BazJPjp6pRCJwNkwobGDfifWJwqShJD19H0hKNl1bnnK7i9JNxn57fpdLh0jQ1pdyuYc IDsvGexy2BmQWkxc5xNHIg0xR7WKwPHARyCtjV+HL+7ioP84+8POp2qIOSNi5IM87RC9 EX7yKs+vIoRLo3cPh5mS/beSNtLMc9inU8mLSQeX6GGkniQ0vuQTd9zYg0uoznX6a2pq Dagw== X-Gm-Message-State: AOAM531aMEHaONGHqfaJQoJhA/r/oEQZBkMiu39j4E0IQH7DB6vqW1TZ AneGV3xYnIvrM4BOEgSVqAkkHe515KQ7Qw== X-Google-Smtp-Source: ABdhPJwuA2lzpok6fo92bnZ1O0OavHAYw2cai5+1orD5bVVhGia53CaqUGwaDd/+yoif+cQQhj/YPg== X-Received: by 2002:a05:600c:3d19:b0:396:f904:753e with SMTP id bh25-20020a05600c3d1900b00396f904753emr18723499wmb.178.1653297886198; Mon, 23 May 2022 02:24:46 -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.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 02:24:45 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 23 May 2022 11:24:33 +0200 Message-Id: <20220523092435.475510-4-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 3/5] ipa: rkisp1: Add Yaml configuration file support 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" Retrieve root node in Yaml configuration file and provide to each algorithm this YamlObject to allow them to grab their default parameters by calling init() function. Signed-off-by: Florian Sylvestre --- src/ipa/rkisp1/algorithms/algorithm.h | 4 ++- src/ipa/rkisp1/rkisp1.cpp | 36 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/ipa/rkisp1/algorithms/algorithm.h b/src/ipa/rkisp1/algorithms/algorithm.h index d46c3188..5b95fd30 100644 --- a/src/ipa/rkisp1/algorithms/algorithm.h +++ b/src/ipa/rkisp1/algorithms/algorithm.h @@ -17,9 +17,11 @@ namespace libcamera { +class YamlObject; + namespace ipa::rkisp1 { -using Algorithm = libcamera::ipa::Algorithm; +using Algorithm = libcamera::ipa::Algorithm; } /* namespace ipa::rkisp1 */ diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 23cb95b5..c44514c2 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -24,6 +24,7 @@ #include #include +#include #include "algorithms/agc.h" #include "algorithms/algorithm.h" @@ -61,6 +62,7 @@ public: private: void setControls(unsigned int frame); void prepareMetadata(unsigned int frame, unsigned int aeState); + int parseConfigurationFile(FILE *fh); std::map buffers_; std::map mappedBuffers_; @@ -126,6 +128,40 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision) algorithms_.push_back(std::make_unique()); algorithms_.push_back(std::make_unique()); + /* Load the tuning file for this sensor. */ + FILE *fh = fopen(settings.configurationFile.c_str(), "r"); + if (!fh) { + int ret = -errno; + LOG(IPARkISP1, Error) << "Failed to open configuration file " + << settings.configurationFile << ": " << strerror(-ret); + return ret; + } + + int ret = parseConfigurationFile(fh); + + fclose(fh); + if (ret) + return -EINVAL; + + return 0; +} + +int IPARkISP1::parseConfigurationFile(FILE *fh) +{ + std::unique_ptr root = YamlParser::parse(fh); + if (!root) + return -EINVAL; + + if (!root->isDictionary()) + return -EINVAL; + + /* Allow each algo to get parameters from configuration file. */ + for (auto const &algo : algorithms_) { + int ret = algo->init(context_, root.get()); + if (ret) + return ret; + } + return 0; } From patchwork Mon May 23 09:24:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16004 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 D7029BD160 for ; Mon, 23 May 2022 09:24:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7BD5965669; Mon, 23 May 2022 11:24:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653297892; bh=A30TSfEQWAvmMgeWpCg8k0fmAFMQVfN919s2hep5/tA=; 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=Mp9tfT0vDJ+tSI5QGZTVQowyI9586zvAsP2Nnj5ymNnZPLM2Yx8k0JqVzv9m/yCzK kNCWMa15FFc8adfHBYvP+nxS+CePUP0tFve7ACdh6A4QjfcMKNuqwYIoap1EsBRh+9 j3fVOTu7IkqGZ0ZsW4Ns3nT1JySmt+SIUsl6M94OstKAufODNQp2iDhmm9LpQnynxd btQrEM5AfujYk1xRnGGDRq0Nkbm7QDwabY31vYrSvFZpB0U6QMPANCQobkZvBw6EtD +F2I6xrqVF+py5hai9rv8BISghVN4NBv4+Po5aOb5B/YZfcKQkpdx0vpAUEJiYruxW a+WEsCdYH+s4g== Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8DF716565E for ; Mon, 23 May 2022 11:24:47 +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="ace4ONp5"; dkim-atps=neutral Received: by mail-wr1-x42f.google.com with SMTP id f2so20452972wrc.0 for ; Mon, 23 May 2022 02:24:47 -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=lJfZdZg2a8ZwVKJYUOeGes9Vy/2r6KIGjKy4QIP7/ko=; b=ace4ONp5zYihIw6KYyEpMVl9S+9zcgj9XAB8opVcolZymE41qMW2uqNC6OsshDC+z6 e0Wt1vxEULCJzjvgKiBUs1rgXoGMifllcJa0fIUNlCw3SSawNrRJapvsY+FHu0YaM2mM moxz5JggBxoxJQ0Q3Bu6kZD20QsmMqhNcCrZoSf/ZLoDSSAuxSdSnta5cu+ZDc6O48ac E8fc3Ahat+EjIkXQL8ZJ1vveqYxIp0Hfx4PBpBAAktzPT7wb2v6sv5Rfqc8g9lwQNfEP 4zspocYZ7HYjXPjqG3FCqTbPC4Z+xNdJndZ0f+inp92D2mqzMjKPaunMc9a7KacSXZeu V9Xw== 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=lJfZdZg2a8ZwVKJYUOeGes9Vy/2r6KIGjKy4QIP7/ko=; b=eo8pZGJJRDDoyoUHefAM5J1UgohLzevhxUNBXO6d0uzoFqFWJ1QFPjHFvZRmStli0F pqzdZ+EPSHYGhV8Pzwj7pGs5LDcl0yAKbSC7f2k8EKt7u87oE5f0ogg7Sgdh2engnbK3 AHGYz6tGEDEu0bCvt4AoQHrdPdfGz2GGoPJ9FG/tSrhO5FU2cDiVvJXCSkrtRhgjgVSp IFuI8V17TJ4nuWdRD6DNqn1tow2aLgxNuPKpo2QyKElx8xCLZOoF2mpTuxEfHoud0XgD 4sOACh04CXm0o/roQX90zYC6QGuVmEBYN4O9Zh1pFb8pztvsXezhhmg6R6FLNDBxVvwA NrKw== X-Gm-Message-State: AOAM531lMZufd7Cgg0+GjZmtYxOPTW/DjX2ToNXyhAX0HokwB7d60SCg JZel0Fnp82p5aIcUrBVYYGYLVok3wQ00TA== X-Google-Smtp-Source: ABdhPJw2hqVx3Qyl33Ri8zOzvMgYV3mwT8G860xEDmxSVNkX3j2BB/3zkaWVzETITOfb+Zv1xYTqmA== X-Received: by 2002:adf:fdce:0:b0:20e:609d:b4c4 with SMTP id i14-20020adffdce000000b0020e609db4c4mr18081879wrs.664.1653297886993; Mon, 23 May 2022 02:24:46 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 02:24:46 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 23 May 2022 11:24:34 +0200 Message-Id: <20220523092435.475510-5-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 4/5] ipa: rkisp1: Add ov5640 configuration file 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 the ov5640 tuning file containing default values for 'black level correction' algorithm. Signed-off-by: Florian Sylvestre Reviewed-by: Laurent Pinchart Reviewed-by: Paul Elder --- src/ipa/rkisp1/data/meson.build | 8 ++++++++ src/ipa/rkisp1/data/ov5640.yaml | 8 ++++++++ src/ipa/rkisp1/meson.build | 1 + 3 files changed, 17 insertions(+) create mode 100644 src/ipa/rkisp1/data/meson.build create mode 100644 src/ipa/rkisp1/data/ov5640.yaml diff --git a/src/ipa/rkisp1/data/meson.build b/src/ipa/rkisp1/data/meson.build new file mode 100644 index 00000000..2656bb2e --- /dev/null +++ b/src/ipa/rkisp1/data/meson.build @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: CC0-1.0 + +conf_files = files([ + 'ov5640.yaml', +]) + +install_data(conf_files, + install_dir : ipa_data_dir / 'rkisp1') diff --git a/src/ipa/rkisp1/data/ov5640.yaml b/src/ipa/rkisp1/data/ov5640.yaml new file mode 100644 index 00000000..d8e56463 --- /dev/null +++ b/src/ipa/rkisp1/data/ov5640.yaml @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: CC0-1.0 +--- +BlackLevelCorrection: + R: 256 + Gr: 256 + Gb: 256 + B: 256 +... diff --git a/src/ipa/rkisp1/meson.build b/src/ipa/rkisp1/meson.build index 8c822fbb..ccb84b27 100644 --- a/src/ipa/rkisp1/meson.build +++ b/src/ipa/rkisp1/meson.build @@ -1,6 +1,7 @@ # SPDX-License-Identifier: CC0-1.0 subdir('algorithms') +subdir('data') ipa_name = 'ipa_rkisp1' 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 */