{"id":16229,"url":"https://patchwork.libcamera.org/api/1.1/patches/16229/?format=json","web_url":"https://patchwork.libcamera.org/patch/16229/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220616080744.548995-4-fsylvestre@baylibre.com>","date":"2022-06-16T08:07:42","name":"[libcamera-devel,v2,3/5] ipa: rkisp1: Add Yaml tuning file support","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"1c9e66708d902b38f01ef88f4f9225fd248e6142","submitter":{"id":123,"url":"https://patchwork.libcamera.org/api/1.1/people/123/?format=json","name":"Florian Sylvestre","email":"fsylvestre@baylibre.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16229/mbox/","series":[{"id":3177,"url":"https://patchwork.libcamera.org/api/1.1/series/3177/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3177","date":"2022-06-16T08:07:39","name":"Add tuning file support for rkisp1 blc algo","version":2,"mbox":"https://patchwork.libcamera.org/series/3177/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16229/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16229/checks/","tags":{},"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 CA542C3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 16 Jun 2022 08:07:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DF62565645;\n\tThu, 16 Jun 2022 10:07:56 +0200 (CEST)","from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com\n\t[IPv6:2a00:1450:4864:20::42d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 595B665637\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 16 Jun 2022 10:07:54 +0200 (CEST)","by mail-wr1-x42d.google.com with SMTP id o8so800585wro.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 16 Jun 2022 01:07:54 -0700 (PDT)","from localhost.localdomain (lfbn-nic-1-76-188.w2-15.abo.wanadoo.fr.\n\t[2.15.166.188]) by smtp.gmail.com with ESMTPSA id\n\tr15-20020adff70f000000b002185d79dc7fsm1098868wrp.75.2022.06.16.01.07.52\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 16 Jun 2022 01:07:53 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655366877;\n\tbh=vnYSNDQHOKIhU1gElZNiSQ2r48X1go8FWIhaImWyeXM=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=FnnaBRUrJ+DpqfgmEwouj6HevVf7wVhX7ghc1EXJPhOt5CQOz3ee5w8gIhG0YIzfk\n\t2pdZ8hPRSACm/cPqZZUsL9X/UfZJr0pN2u0F1kvaZ1FMnKIi3ZivlV19Rhf0XnPDku\n\tOmqiMiTrrWkoE9lxD/KLeomkwim2rRHCmdRPxe9qqIiH7vHZ4G7aXA0bt2WYj0sbuQ\n\tP9HFq0Otjht/DvpUck0HXN/2IaaFu9Oe7tAj8HnoYCCmed8NAusufDTSwh3Joa/+Gl\n\tGmGgajyZleKyI3wv306KYL/eFsC9khlwsq3jVoO0pTyOBOUQD2VXTXeaoVbaoavWMb\n\tZONHlbmPaEmIA==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20210112.gappssmtp.com; s=20210112;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=vgEEmymPeEjD8DAld95kVyKLl/rN6osiT4A3Ym5kvPg=;\n\tb=JLpjcah7lc0/BMKcX9A82ydQega8AY9LMafcoZR9ba8kwC/+bMb0SAYcTM8vz1jzSw\n\tOoCbSCpCGPtQa7dkhDRD46kVo4jQpDTVU4utbyfnydgpTdrKR6XtHITM6YYH0Tbp1xBu\n\t+iHS1Xk0fFfku77y65GW4lQLsFJDik0baEtUfHhRnJUFMDz0e2Ch/8jsKDWY6gdRnSY3\n\tf1yH3f/aBxl9NTPHI9uobdTJdgX/zTAROTIfX36D3U7s22IztxOAqklfgAs0na4JzDyv\n\tbFNw9W26V85IxDMDm+2cXxekuHP4cMEIe+VSzqLN9m7GJR0/iEgPi8Rz8msEQAKSgXQo\n\tiZVw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=baylibre-com.20210112.gappssmtp.com\n\theader.i=@baylibre-com.20210112.gappssmtp.com header.b=\"JLpjcah7\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=vgEEmymPeEjD8DAld95kVyKLl/rN6osiT4A3Ym5kvPg=;\n\tb=xPKfuRZ6gbivHHKWLqkRDHwb34wR8c1Gmucr5UWMygCr7Y/POkBlhdI2puDL/tZ7W/\n\tTkrq9i9dF2mgrBgd0t0q/hYv0RLIVY0qKdY/UelIiAFKxOJkLKXKp4ge8lYr+JT/mgG3\n\tND7u3x4rTXzCrRdTvMXcxp8FAAxkFRJ+1AjmxZZCmg9EDurBkot25VXL+4XeeqckgOpG\n\tIZrCrHcZyyTReDgWz5DV0YR/ajZwwVUcPy2+hvUwB2XnnkucFj1BanV1zrhm6tzp0ANJ\n\tynhCVWuKcS8yIYEJ1jroQp+UZumCRWK1CUcPVzglcb3nGnp4vS7pu1Lw732QZzugpzek\n\tytZw==","X-Gm-Message-State":"AJIora+thXc8pF7UXehe4xZIda9Al1TlGnUHgSjzHCBkqZ/kY3PvrOf2\n\talv4X3oZALexJco06y/eaISGap2wY5oWNg==","X-Google-Smtp-Source":"AGRyM1s6mSD0TqUVqoCTT502rF4JGbwahkXxLXWFAU2sHyIFbX0NKQOgHkg783HyzzfM0qEwKC2D3w==","X-Received":"by 2002:a05:6000:184f:b0:218:555e:6b69 with SMTP id\n\tc15-20020a056000184f00b00218555e6b69mr3459055wri.562.1655366873653; \n\tThu, 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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 3/5] ipa: rkisp1: Add Yaml tuning file\n\tsupport","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":"Florian Sylvestre via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Florian Sylvestre <fsylvestre@baylibre.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Retrieve root node in Yaml tuning file and provide to\neach algorithm this YamlObject to allow them to grab their default\nparameters by calling init() function.\n\nSigned-off-by: Florian Sylvestre <fsylvestre@baylibre.com>\n---\n src/ipa/rkisp1/algorithms/algorithm.h |  4 ++-\n src/ipa/rkisp1/rkisp1.cpp             | 35 +++++++++++++++++++++++++++\n 2 files changed, 38 insertions(+), 1 deletion(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/algorithm.h b/src/ipa/rkisp1/algorithms/algorithm.h\nindex d46c3188..5b95fd30 100644\n--- a/src/ipa/rkisp1/algorithms/algorithm.h\n+++ b/src/ipa/rkisp1/algorithms/algorithm.h\n@@ -17,9 +17,11 @@\n \n namespace libcamera {\n \n+class YamlObject;\n+\n namespace ipa::rkisp1 {\n \n-using Algorithm = libcamera::ipa::Algorithm<IPAContext, IPACameraSensorInfo, rkisp1_params_cfg, rkisp1_stat_buffer>;\n+using Algorithm = libcamera::ipa::Algorithm<IPAContext, YamlObject, IPACameraSensorInfo, rkisp1_params_cfg, rkisp1_stat_buffer>;\n \n } /* namespace ipa::rkisp1 */\n \ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 23cb95b5..6cc501a9 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -14,6 +14,7 @@\n #include <linux/rkisp1-config.h>\n #include <linux/v4l2-controls.h>\n \n+#include <libcamera/base/file.h>\n #include <libcamera/base/log.h>\n \n #include <libcamera/control_ids.h>\n@@ -24,6 +25,7 @@\n #include <libcamera/request.h>\n \n #include <libcamera/internal/mapped_framebuffer.h>\n+#include <libcamera/internal/yaml_parser.h>\n \n #include \"algorithms/agc.h\"\n #include \"algorithms/algorithm.h\"\n@@ -61,6 +63,7 @@ public:\n private:\n \tvoid setControls(unsigned int frame);\n \tvoid prepareMetadata(unsigned int frame, unsigned int aeState);\n+\tint parseConfigurationFile(File &file);\n \n \tstd::map<unsigned int, FrameBuffer> buffers_;\n \tstd::map<unsigned int, MappedFrameBuffer> mappedBuffers_;\n@@ -126,6 +129,38 @@ int IPARkISP1::init(const IPASettings &settings, unsigned int hwRevision)\n \talgorithms_.push_back(std::make_unique<algorithms::Awb>());\n \talgorithms_.push_back(std::make_unique<algorithms::BlackLevelCorrection>());\n \n+\t/* Load the tuning file for this sensor. */\n+\tFile file(settings.configurationFile.c_str());\n+\tif (!file.open(File::OpenModeFlag::ReadOnly)) {\n+\t\tint ret = file.error();\n+\t\tLOG(IPARkISP1, Error) << \"Failed to open configuration file \"\n+\t\t\t\t      << settings.configurationFile << \": \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\tint ret = parseConfigurationFile(file);\n+\tif (ret)\n+\t\treturn -EINVAL;\n+\n+\treturn 0;\n+}\n+\n+int IPARkISP1::parseConfigurationFile(File &file)\n+{\n+\tstd::unique_ptr<libcamera::YamlObject> root = YamlParser::parse(file);\n+\tif (!root)\n+\t\treturn -EINVAL;\n+\n+\tif (!root->isDictionary())\n+\t\treturn -EINVAL;\n+\n+\t/* Allow each algo to get parameters from configuration file. */\n+\tfor (auto const &algo : algorithms_) {\n+\t\tint ret = algo->init(context_, root.get());\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n \treturn 0;\n }\n \n","prefixes":["libcamera-devel","v2","3/5"]}