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; }