From patchwork Wed Apr 26 13:10:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18550 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 D9B82BDCBD for ; Wed, 26 Apr 2023 13:13:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 89D33627E9; Wed, 26 Apr 2023 15:13:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1682514795; bh=1gxU4JwyGxJEnRQ9vp8hr7LGZOljBhaDc83/JCtpisc=; 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=sW28jg7HQpQZVQS8uz0A9zBQuXyJm4naxHYN4OXsm5hBsiYA3/M+XthoCLkfqVqFp vznAXqG7F4V0Xvao99TfVaOfEvlrpNJMlOSwVLfipYNl94GOlzuCbojmOvd698TFEv h/hz9NlOvs8TaxKOUbkInfGIkL0i4Zyoh6XPBbnaSZgpR7nKdKSouAyb0iHjZSra21 BeBfQed9D8oTqvOllJo8YConbWg0bvEUn+5gSIzlri5I4xDvvCwp4UwzIVwi8f1ekJ pct287blQWY3V7+trFfg3qnIYW6BPleJfJEHfCJuiG1wjwxxA4VRfpOeNajqMl8VlN VY5nZkptdD9lQ== Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3C611627D6 for ; Wed, 26 Apr 2023 15:13:13 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="SdZyXWEQ"; dkim-atps=neutral Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f1957e80a2so151866845e9.1 for ; Wed, 26 Apr 2023 06:13:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1682514792; x=1685106792; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zoLEOeoTgZgHTXVqtppZR4khc2YZ0Sk1+YlJyvlS/vE=; b=SdZyXWEQxYZ9bf8rlVCTSw+k533PHWSpzPhKMiRy4p32Ffbc/CKZj1YgXOwU4TVY7+ rv3E03zLQmtl8HG60mXrEeYTN9S6qBlv1yB1EfIqYgk2vuXa40bUpAW0S466Q4/lSjoI fHvmP3mM5L+7f0gymwrHnvszD7/oQhSxl9ViBNYW39H9z8AGbc/YaVduzUveIZXnU2Hw SI80+HyiyGOPKI+tIcZ9N8gdd0/vBLJaNAS71ZPfHp3WX0xSkipok+zFSB4kiidpLxKd AVVc1hnTDxCPZt+5rji2Kw7l3R9ML90hYoXibQyn4hP71n8cjxuJd0k+deVbWOYGxUxx qXbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682514792; x=1685106792; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zoLEOeoTgZgHTXVqtppZR4khc2YZ0Sk1+YlJyvlS/vE=; b=SlXIZLo2uSQZatTxkh12hG36Skjxt8tj1Mo4v0zs+UCTqkFOCTslfid1Hm/c5s7NDW f6csl1QlIgV31AehJK/rzLU4UFg/Qp7zKbi9hnfvv/zLYTjz0pFxMcOP1fh296CY+SeS BJGAeiPrjRMrb6BtFAXfiRd/IYBJNvmCs9q1C86C6uQpql3qITeMERBUvHLjqAhCS+kx /A6EF+4nALsbZTy4J0SNdtsixV7WbWuZePCY41eo1blCieQaOejtn6U0KCypulEUWy8C HIzHAhXNn88GDbLFoOedKds5Y0cUy4JzobOvGhkrhRHZXTTYJTKEXV8ZBsGWr35I6zoM fLaQ== X-Gm-Message-State: AC+VfDyI8Qx0RvcfYKL8/3VQ+3MLz7EalzlLtyOhN4+oQMqnRTGj3Iek WbwN2LQI5hoDxZqSpyNXqGdMxClhUmHk7alf/z7Reg== X-Google-Smtp-Source: ACHHUZ4EeLACQa/Bu23AV9U5bi8RIVNBwmFqzuysn9VDe3XI2uWIiqt5tsRF/iuPs0fmuHeQGFb18A== X-Received: by 2002:a05:600c:916:b0:3f1:7371:86bb with SMTP id m22-20020a05600c091600b003f1737186bbmr1603930wmp.20.1682514792647; Wed, 26 Apr 2023 06:13:12 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id k5-20020adff5c5000000b002f103ca90cdsm15780949wrp.101.2023.04.26.06.13.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Apr 2023 06:13:11 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 26 Apr 2023 14:10:46 +0100 Message-Id: <20230426131057.21550-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230426131057.21550-1-naush@raspberrypi.com> References: <20230426131057.21550-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 02/13] libcamera: ipa_proxy: Allow a prefix for the configuration file 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a prefix parameter to IPAProxy::configurationFile(). This prefix is added to the search path when locating IPA configuration files in the system directories. For example, the system directories etc/libcamera/ipa// and share/libcamera/ipa// will be used to search for the IPA configuration files. Signed-off-by: Naushir Patuck Reviewed-by: Jacopo Mondi --- include/libcamera/internal/ipa_proxy.h | 3 ++- src/libcamera/ipa_proxy.cpp | 11 +++++++---- src/libcamera/pipeline/ipu3/ipu3.cpp | 4 ++-- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 2 +- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 4 ++-- src/libcamera/pipeline/vimc/vimc.cpp | 2 +- test/ipa/ipa_interface_test.cpp | 2 +- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/include/libcamera/internal/ipa_proxy.h b/include/libcamera/internal/ipa_proxy.h index 781c8b623605..4ec357425fd3 100644 --- a/include/libcamera/internal/ipa_proxy.h +++ b/include/libcamera/internal/ipa_proxy.h @@ -31,7 +31,8 @@ public: bool isValid() const { return valid_; } - std::string configurationFile(const std::string &file) const; + std::string configurationFile(const std::string &file, + const std::string &prefix) const; protected: std::string resolvePath(const std::string &file) const; diff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp index 3f2cc6b89f60..4a27b0a993fa 100644 --- a/src/libcamera/ipa_proxy.cpp +++ b/src/libcamera/ipa_proxy.cpp @@ -72,6 +72,7 @@ IPAProxy::~IPAProxy() /** * \brief Retrieve the absolute path to an IPA configuration file * \param[in] name The configuration file name + * \param[in] prefix The configuration directory prefix when searching system paths * * This function locates the configuration file for an IPA and returns its * absolute path. It searches the following directories, in order: @@ -80,8 +81,8 @@ IPAProxy::~IPAProxy() * environment variable ; or * - If libcamera is not installed, the src/ipa/ directory within the source * tree ; otherwise - * - The system sysconf (etc/libcamera/ipa) and the data (share/libcamera/ipa/) - * directories. + * - The system sysconf (etc/libcamera/ipa//) and the data + * (share/libcamera/ipa//) directories. * * The system directories are not searched if libcamera is not installed. * @@ -92,7 +93,8 @@ IPAProxy::~IPAProxy() * \return The full path to the IPA configuration file, or an empty string if * no configuration file can be found */ -std::string IPAProxy::configurationFile(const std::string &name) const +std::string IPAProxy::configurationFile(const std::string &name, + const std::string &prefix) const { struct stat statbuf; int ret; @@ -139,7 +141,8 @@ std::string IPAProxy::configurationFile(const std::string &name) const } else { /* Else look in the system locations. */ for (const auto &dir : utils::split(IPA_CONFIG_DIR, ":")) { - std::string confPath = dir + "/" + ipaName + "/" + name; + std::string confPath = dir + "/" + prefix + "/" + + ipaName + "/" + name; ret = stat(confPath.c_str(), &statbuf); if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG) return confPath; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 355cb0cb76b8..a48d7e78d25e 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -1186,9 +1186,9 @@ int IPU3CameraData::loadIPA() * The API tuning file is made from the sensor name. If the tuning file * isn't found, fall back to the 'uncalibrated' file. */ - std::string ipaTuningFile = ipa_->configurationFile(sensor->model() + ".yaml"); + std::string ipaTuningFile = ipa_->configurationFile(sensor->model() + ".yaml", ""); if (ipaTuningFile.empty()) - ipaTuningFile = ipa_->configurationFile("uncalibrated.yaml"); + ipaTuningFile = ipa_->configurationFile("uncalibrated.yaml", ""); ret = ipa_->init(IPASettings{ ipaTuningFile, sensor->model() }, sensorInfo, sensor->controls(), &ipaControls_); diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 0060044143cc..a4fff28bf198 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1668,7 +1668,7 @@ int RPiCameraData::loadIPA(ipa::RPi::IPAInitResult *result) std::string model = sensor_->model(); if (isMonoSensor(sensor_)) model += "_mono"; - configurationFile = ipa_->configurationFile(model + ".json"); + configurationFile = ipa_->configurationFile(model + ".json", ""); } else { configurationFile = std::string(configFromEnv); } diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 8a30fe061d04..e338cdee2a2d 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -349,13 +349,13 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision) std::string ipaTuningFile; char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RKISP1_TUNING_FILE"); if (!configFromEnv || *configFromEnv == '\0') { - ipaTuningFile = ipa_->configurationFile(sensor_->model() + ".yaml"); + ipaTuningFile = ipa_->configurationFile(sensor_->model() + ".yaml", ""); /* * If the tuning file isn't found, fall back to the * 'uncalibrated' configuration file. */ if (ipaTuningFile.empty()) - ipaTuningFile = ipa_->configurationFile("uncalibrated.yaml"); + ipaTuningFile = ipa_->configurationFile("uncalibrated.yaml", ""); } else { ipaTuningFile = std::string(configFromEnv); } diff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp index 204f5ad73f6d..5fbabcc5763d 100644 --- a/src/libcamera/pipeline/vimc/vimc.cpp +++ b/src/libcamera/pipeline/vimc/vimc.cpp @@ -472,7 +472,7 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator) data->ipa_->paramsBufferReady.connect(data.get(), &VimcCameraData::paramsBufferReady); - std::string conf = data->ipa_->configurationFile("vimc.conf"); + std::string conf = data->ipa_->configurationFile("vimc.conf", ""); Flags inFlags = ipa::vimc::TestFlag::Flag2; Flags outFlags; data->ipa_->init(IPASettings{ conf, data->sensor_->model() }, diff --git a/test/ipa/ipa_interface_test.cpp b/test/ipa/ipa_interface_test.cpp index 051ef96e7ed2..b25de222b9b4 100644 --- a/test/ipa/ipa_interface_test.cpp +++ b/test/ipa/ipa_interface_test.cpp @@ -105,7 +105,7 @@ protected: } /* Test initialization of IPA module. */ - std::string conf = ipa_->configurationFile("vimc.conf"); + std::string conf = ipa_->configurationFile("vimc.conf", ""); Flags inFlags; Flags outFlags; int ret = ipa_->init(IPASettings{ conf, "vimc" },