From patchwork Fri Jun 17 09:23:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16260 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 233BEC3275 for ; Fri, 17 Jun 2022 09:23:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 817796563F; Fri, 17 Jun 2022 11:23:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655457835; bh=FQFXdW7nDJSKSdWEgiUdNjbWp1y2fsSHP4XjiKtcO6I=; 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=TUgypEjx4zWgyXKVUK2I8pp05ffPHSo94793izgUOnGUAF0vSSUWWosiBxNNbQOzp ReYxbhaXR69E8QJbmdy9Q2TB2R8NuuJEP5VgxdIlXXQJH94lfH/d5KStwcFNFu222y Fm79lrn6Avvs6JUJK8wdzmQMDZ5eqW4EHtM9ACRrauB2jar58cvQ8hqC0sqFcMtT+2 ZRbEPFY3Bmbvhzb/+qxBp5yMgIz5FaSbhH3kHBgWGtG7LqBdl1JWwMCP53URK4TBn2 b6zB9si1lhTSOk62bsGYEDutP/+USFv/v8WNWO0VfadnmQJP/1luPkTuRkqfAO8NYb rL26bca0diIGw== Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3327065634 for ; Fri, 17 Jun 2022 11:23:51 +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="gcYQkw3B"; dkim-atps=neutral Received: by mail-wr1-x42b.google.com with SMTP id i10so1219229wrc.0 for ; Fri, 17 Jun 2022 02:23:51 -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=ZaWFERh5kZkXWV7gm5/ucEQrlW7cCM22c2YHwQhMeTE=; b=gcYQkw3BEgJIVfUYK3GjgrBTtaom/QIgTJNL3OCPxG1gXD8Dpt1TrPLIfJ78KQSfzt McRe/cDhxy5Gm2e5q8GLczWTOp+pBJL8jupAjYQnaGAxBcC72YFwtaJdsfriVkOIZWXi 9yGXh3uIen5LtakLpeTV4gTX7euj+osqYI830OpL3ot0ZDF/cBLZxQzuO1M9f5x5nG1/ N9u9RKz5exLo+eN+O+j53BoMkSfkWimauoLEuWwAVpcvJFF0Vb9y3HVDvX+9AH4aZA8E eqfgOnBRVOnS0/Dd3LtiCC1PLR8QZsfE4mLleOWPcBpAQvdFIUgIUFEA34d9Ku4TWBal benw== 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=ZaWFERh5kZkXWV7gm5/ucEQrlW7cCM22c2YHwQhMeTE=; b=1RPF+jgDRBw+6heac8U451hLsBEZ8AJ8zx1dbHBTMCl3lnUlrFSszH9V6x3oB3RLzT gsohyvguDIuMVsyoVhBaPlboGYsliTyRKbYSipHricAVN/m2vCi46R7ZorCWCJSX0hxi i8MANe+6PQayg995lHVasyNgCs1Tu+gaLPzc5J4l2W3Ky7dUmMkC7ZLKwEKIYIf4C2e7 e2omuQYqA5IK2L3JgyMgjb8+SxDfZxW9IlAJroV13fR2SvSlAZCZvm4YrlYZoqhYayC1 bkPLk40keRwaInXwO5x6D4HfYEtoddOIy3WIlTSWmrWB5I/cO+TyjXth3J9ZufSrLaNw E7Dw== X-Gm-Message-State: AJIora8GHhifITAiGlWA19G/sU5HRXWqHvWvHo3i2XZnJHx/KKy2xLMS MjqM8BVBIuXpspNv6N6IKjE6/V1I6Kh1Kg== X-Google-Smtp-Source: AGRyM1uO1IAV+PVG3Ywk4fuaIQ+ADrhWnjJFu8KsJGSLx7EggcQpNlsZdCL8hlWvnISWnnyImTfoYg== X-Received: by 2002:adf:e3cf:0:b0:219:e523:905f with SMTP id k15-20020adfe3cf000000b00219e523905fmr8336807wrm.240.1655457830245; Fri, 17 Jun 2022 02:23:50 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 02:23:49 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 17 Jun 2022 11:23:13 +0200 Message-Id: <20220617092315.120781-4-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 3/5] ipa: rkisp1: Add Yaml tuning 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 tuning 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 Reviewed-by: Laurent Pinchart Reviewed-by: Paul Elder --- src/ipa/rkisp1/rkisp1.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 61a3bab9..5eb23669 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -24,6 +25,7 @@ #include #include "libcamera/internal/mapped_framebuffer.h" +#include "libcamera/internal/yaml_parser.h" #include "algorithms/agc.h" #include "algorithms/algorithm.h" @@ -61,6 +63,7 @@ public: private: void setControls(unsigned int frame); void prepareMetadata(unsigned int frame, unsigned int aeState); + int parseConfigurationFile(File &file); std::map buffers_; std::map mappedBuffers_; @@ -126,6 +129,37 @@ 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 file(settings.configurationFile.c_str()); + if (!file.open(File::OpenModeFlag::ReadOnly)) { + int ret = file.error(); + LOG(IPARkISP1, Error) + << "Failed to open configuration file " + << settings.configurationFile << ": " << strerror(-ret); + return ret; + } + + return parseConfigurationFile(file); +} + +int IPARkISP1::parseConfigurationFile(File &file) +{ + std::unique_ptr root = YamlParser::parse(file); + if (!root) + return -EINVAL; + + const YamlObject &algoObject = (*root)["algorithms"]; + + if (!algoObject["algorithms"].isDictionary()) + return -EINVAL; + + /* Allow each algo to get parameters from configuration file. */ + for (auto const &algo : algorithms_) { + int ret = algo->init(context_, algoObject); + if (ret) + return ret; + } + return 0; }