From patchwork Thu Jun 16 08:07:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Sylvestre X-Patchwork-Id: 16229 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 CA542C3275 for ; Thu, 16 Jun 2022 08:07:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DF62565645; Thu, 16 Jun 2022 10:07:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1655366877; bh=vnYSNDQHOKIhU1gElZNiSQ2r48X1go8FWIhaImWyeXM=; 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=FnnaBRUrJ+DpqfgmEwouj6HevVf7wVhX7ghc1EXJPhOt5CQOz3ee5w8gIhG0YIzfk 2pdZ8hPRSACm/cPqZZUsL9X/UfZJr0pN2u0F1kvaZ1FMnKIi3ZivlV19Rhf0XnPDku OmqiMiTrrWkoE9lxD/KLeomkwim2rRHCmdRPxe9qqIiH7vHZ4G7aXA0bt2WYj0sbuQ P9HFq0Otjht/DvpUck0HXN/2IaaFu9Oe7tAj8HnoYCCmed8NAusufDTSwh3Joa/+Gl GmGgajyZleKyI3wv306KYL/eFsC9khlwsq3jVoO0pTyOBOUQD2VXTXeaoVbaoavWMb ZONHlbmPaEmIA== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 595B665637 for ; Thu, 16 Jun 2022 10:07:54 +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="JLpjcah7"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id o8so800585wro.3 for ; Thu, 16 Jun 2022 01:07:54 -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=vgEEmymPeEjD8DAld95kVyKLl/rN6osiT4A3Ym5kvPg=; b=JLpjcah7lc0/BMKcX9A82ydQega8AY9LMafcoZR9ba8kwC/+bMb0SAYcTM8vz1jzSw OoCbSCpCGPtQa7dkhDRD46kVo4jQpDTVU4utbyfnydgpTdrKR6XtHITM6YYH0Tbp1xBu +iHS1Xk0fFfku77y65GW4lQLsFJDik0baEtUfHhRnJUFMDz0e2Ch/8jsKDWY6gdRnSY3 f1yH3f/aBxl9NTPHI9uobdTJdgX/zTAROTIfX36D3U7s22IztxOAqklfgAs0na4JzDyv bFNw9W26V85IxDMDm+2cXxekuHP4cMEIe+VSzqLN9m7GJR0/iEgPi8Rz8msEQAKSgXQo iZVw== 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=vgEEmymPeEjD8DAld95kVyKLl/rN6osiT4A3Ym5kvPg=; b=xPKfuRZ6gbivHHKWLqkRDHwb34wR8c1Gmucr5UWMygCr7Y/POkBlhdI2puDL/tZ7W/ Tkrq9i9dF2mgrBgd0t0q/hYv0RLIVY0qKdY/UelIiAFKxOJkLKXKp4ge8lYr+JT/mgG3 ND7u3x4rTXzCrRdTvMXcxp8FAAxkFRJ+1AjmxZZCmg9EDurBkot25VXL+4XeeqckgOpG IZrCrHcZyyTReDgWz5DV0YR/ajZwwVUcPy2+hvUwB2XnnkucFj1BanV1zrhm6tzp0ANJ ynhCVWuKcS8yIYEJ1jroQp+UZumCRWK1CUcPVzglcb3nGnp4vS7pu1Lw732QZzugpzek ytZw== X-Gm-Message-State: AJIora+thXc8pF7UXehe4xZIda9Al1TlGnUHgSjzHCBkqZ/kY3PvrOf2 alv4X3oZALexJco06y/eaISGap2wY5oWNg== X-Google-Smtp-Source: AGRyM1s6mSD0TqUVqoCTT502rF4JGbwahkXxLXWFAU2sHyIFbX0NKQOgHkg783HyzzfM0qEwKC2D3w== X-Received: by 2002:a05:6000:184f:b0:218:555e:6b69 with SMTP id c15-20020a056000184f00b00218555e6b69mr3459055wri.562.1655366873653; Thu, 16 Jun 2022 01:07:53 -0700 (PDT) Received: from localhost.localdomain (lfbn-nic-1-76-188.w2-15.abo.wanadoo.fr. [2.15.166.188]) by smtp.gmail.com with ESMTPSA id r15-20020adff70f000000b002185d79dc7fsm1098868wrp.75.2022.06.16.01.07.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 01:07:53 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 16 Jun 2022 10:07:42 +0200 Message-Id: <20220616080744.548995-4-fsylvestre@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220616080744.548995-1-fsylvestre@baylibre.com> References: <20220616080744.548995-1-fsylvestre@baylibre.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 --- src/ipa/rkisp1/algorithms/algorithm.h | 4 ++- src/ipa/rkisp1/rkisp1.cpp | 35 +++++++++++++++++++++++++++ 2 files changed, 38 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..6cc501a9 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 +#include #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,38 @@ 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; + } + + int ret = parseConfigurationFile(file); + if (ret) + return -EINVAL; + + return 0; +} + +int IPARkISP1::parseConfigurationFile(File &file) +{ + std::unique_ptr root = YamlParser::parse(file); + 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; }