{"id":16260,"url":"https://patchwork.libcamera.org/api/patches/16260/?format=json","web_url":"https://patchwork.libcamera.org/patch/16260/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20220617092315.120781-4-fsylvestre@baylibre.com>","date":"2022-06-17T09:23:13","name":"[libcamera-devel,v3,3/5] ipa: rkisp1: Add Yaml tuning file support","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"2cd4a5d574e87c7beb539d6d67ae2089f8baf6a1","submitter":{"id":123,"url":"https://patchwork.libcamera.org/api/people/123/?format=json","name":"Florian Sylvestre","email":"fsylvestre@baylibre.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16260/mbox/","series":[{"id":3186,"url":"https://patchwork.libcamera.org/api/series/3186/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3186","date":"2022-06-17T09:23:10","name":"Add tuning file support for rkisp1 blc algo","version":3,"mbox":"https://patchwork.libcamera.org/series/3186/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16260/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16260/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 233BEC3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 17 Jun 2022 09:23:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 817796563F;\n\tFri, 17 Jun 2022 11:23:55 +0200 (CEST)","from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com\n\t[IPv6:2a00:1450:4864:20::42b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3327065634\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Jun 2022 11:23:51 +0200 (CEST)","by mail-wr1-x42b.google.com with SMTP id i10so1219229wrc.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 17 Jun 2022 02:23:51 -0700 (PDT)","from BL087.. ([2a01:e34:eea9:e630:4718:73b:d035:3786])\n\tby smtp.gmail.com with ESMTPSA id\n\th81-20020a1c2154000000b0039c41686421sm7962328wmh.17.2022.06.17.02.23.49\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 17 Jun 2022 02:23:49 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655457835;\n\tbh=FQFXdW7nDJSKSdWEgiUdNjbWp1y2fsSHP4XjiKtcO6I=;\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=TUgypEjx4zWgyXKVUK2I8pp05ffPHSo94793izgUOnGUAF0vSSUWWosiBxNNbQOzp\n\tReYxbhaXR69E8QJbmdy9Q2TB2R8NuuJEP5VgxdIlXXQJH94lfH/d5KStwcFNFu222y\n\tFm79lrn6Avvs6JUJK8wdzmQMDZ5eqW4EHtM9ACRrauB2jar58cvQ8hqC0sqFcMtT+2\n\tZRbEPFY3Bmbvhzb/+qxBp5yMgIz5FaSbhH3kHBgWGtG7LqBdl1JWwMCP53URK4TBn2\n\tb6zB9si1lhTSOk62bsGYEDutP/+USFv/v8WNWO0VfadnmQJP/1luPkTuRkqfAO8NYb\n\trL26bca0diIGw==","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=ZaWFERh5kZkXWV7gm5/ucEQrlW7cCM22c2YHwQhMeTE=;\n\tb=gcYQkw3BEgJIVfUYK3GjgrBTtaom/QIgTJNL3OCPxG1gXD8Dpt1TrPLIfJ78KQSfzt\n\tMcRe/cDhxy5Gm2e5q8GLczWTOp+pBJL8jupAjYQnaGAxBcC72YFwtaJdsfriVkOIZWXi\n\t9yGXh3uIen5LtakLpeTV4gTX7euj+osqYI830OpL3ot0ZDF/cBLZxQzuO1M9f5x5nG1/\n\tN9u9RKz5exLo+eN+O+j53BoMkSfkWimauoLEuWwAVpcvJFF0Vb9y3HVDvX+9AH4aZA8E\n\teqfgOnBRVOnS0/Dd3LtiCC1PLR8QZsfE4mLleOWPcBpAQvdFIUgIUFEA34d9Ku4TWBal\n\tbenw=="],"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=\"gcYQkw3B\"; \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=ZaWFERh5kZkXWV7gm5/ucEQrlW7cCM22c2YHwQhMeTE=;\n\tb=1RPF+jgDRBw+6heac8U451hLsBEZ8AJ8zx1dbHBTMCl3lnUlrFSszH9V6x3oB3RLzT\n\tgsohyvguDIuMVsyoVhBaPlboGYsliTyRKbYSipHricAVN/m2vCi46R7ZorCWCJSX0hxi\n\ti8MANe+6PQayg995lHVasyNgCs1Tu+gaLPzc5J4l2W3Ky7dUmMkC7ZLKwEKIYIf4C2e7\n\te2omuQYqA5IK2L3JgyMgjb8+SxDfZxW9IlAJroV13fR2SvSlAZCZvm4YrlYZoqhYayC1\n\tbkPLk40keRwaInXwO5x6D4HfYEtoddOIy3WIlTSWmrWB5I/cO+TyjXth3J9ZufSrLaNw\n\tE7Dw==","X-Gm-Message-State":"AJIora8GHhifITAiGlWA19G/sU5HRXWqHvWvHo3i2XZnJHx/KKy2xLMS\n\tMjqM8BVBIuXpspNv6N6IKjE6/V1I6Kh1Kg==","X-Google-Smtp-Source":"AGRyM1uO1IAV+PVG3Ywk4fuaIQ+ADrhWnjJFu8KsJGSLx7EggcQpNlsZdCL8hlWvnISWnnyImTfoYg==","X-Received":"by 2002:adf:e3cf:0:b0:219:e523:905f with SMTP id\n\tk15-20020adfe3cf000000b00219e523905fmr8336807wrm.240.1655457830245; \n\tFri, 17 Jun 2022 02:23:50 -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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 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>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n src/ipa/rkisp1/rkisp1.cpp | 34 ++++++++++++++++++++++++++++++++++\n 1 file changed, 34 insertions(+)","diff":"diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 61a3bab9..5eb23669 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,37 @@ 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)\n+\t\t\t<< \"Failed to open configuration file \"\n+\t\t\t<< settings.configurationFile << \": \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\treturn parseConfigurationFile(file);\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+\tconst YamlObject &algoObject = (*root)[\"algorithms\"];\n+\n+\tif (!algoObject[\"algorithms\"].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_, algoObject);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n \treturn 0;\n }\n \n","prefixes":["libcamera-devel","v3","3/5"]}