Patch Detail
Show a patch.
GET /api/patches/22638/?format=api
{ "id": 22638, "url": "https://patchwork.libcamera.org/api/patches/22638/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22638/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250123143818.29703-1-laurent.pinchart@ideasonboard.com>", "date": "2025-01-23T14:38:18", "name": "libcamera: pipeline: Move tuning file override handling to IPAProxy", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "5e01d583c0933a3cc951f09a791963038fb850d5", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22638/mbox/", "series": [ { "id": 4969, "url": "https://patchwork.libcamera.org/api/series/4969/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4969", "date": "2025-01-23T14:38:18", "name": "libcamera: pipeline: Move tuning file override handling to IPAProxy", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4969/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22638/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22638/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 311FFC3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Jan 2025 14:38:32 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4C6D06855B;\n\tThu, 23 Jan 2025 15:38:31 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B098161878\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Jan 2025 15:38:29 +0100 (CET)", "from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BBB05D1F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Jan 2025 15:37:25 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"c08FyzAh\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1737643046;\n\tbh=3bXoPno7ztr1NYr8gjPEi4KS3CZxzUZkY1mEyz+YFJ4=;\n\th=From:To:Subject:Date:From;\n\tb=c08FyzAha49EOcQhhomjKsBSNzp8MpI2wMslyI2DerV/yeUcVmxDxm0xVvpdYmzwg\n\tmxOQ5Xq04LIluB+Jw539kR1YZdZxHxxx3O+euc1UhERfVy0yvRShdHoXWpa7v/4PcT\n\tC+9XRXyqWhkoGPKmDbp3X3DfA+XEdpcapYYRLd8E=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH] libcamera: pipeline: Move tuning file override handling to\n\tIPAProxy", "Date": "Thu, 23 Jan 2025 16:38:18 +0200", "Message-ID": "<20250123143818.29703-1-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.45.2", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "The rkisp1 and rpi pipeline handlers duplicate code to handle the\nLIBCAMERA_RKISP1_TUNING_FILE and LIBCAMERA_RPI_TUNING_FILE environment\nvariables that override tuning file selection. Move the common code to\nIPAProxy::configurationFile() to avoid the duplication, and make the\nfeature available to all pipeline handlers with the same behaviour.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n Documentation/environment_variables.rst | 4 +--\n src/libcamera/ipa_proxy.cpp | 27 +++++++++++++++----\n src/libcamera/pipeline/rkisp1/rkisp1.cpp | 15 +++--------\n .../pipeline/rpi/common/pipeline_base.cpp | 19 ++++---------\n 4 files changed, 32 insertions(+), 33 deletions(-)\n\n\nbase-commit: fdc01dc3e0969423d65ee87f118164ec74373e5d\n--\nRegards,\n\nLaurent Pinchart", "diff": "diff --git a/Documentation/environment_variables.rst b/Documentation/environment_variables.rst\nindex 7da9883a8380..6f1235587a40 100644\n--- a/Documentation/environment_variables.rst\n+++ b/Documentation/environment_variables.rst\n@@ -57,8 +57,8 @@ LIBCAMERA_RPI_CONFIG_FILE\n\n Example value: ``/usr/local/share/libcamera/pipeline/rpi/vc4/minimal_mem.yaml``\n\n-LIBCAMERA_RPI_TUNING_FILE\n- Define a custom JSON tuning file to use in the Raspberry Pi.\n+LIBCAMERA_<NAME>_TUNING_FILE\n+ Define a custom IPA tuning file to use with the pipeline handler `NAME`.\n\n Example value: ``/usr/local/share/libcamera/ipa/rpi/vc4/custom_sensor.json``\n\ndiff --git a/src/libcamera/ipa_proxy.cpp b/src/libcamera/ipa_proxy.cpp\nindex 85004737c171..25f772a41bf8 100644\n--- a/src/libcamera/ipa_proxy.cpp\n+++ b/src/libcamera/ipa_proxy.cpp\n@@ -98,16 +98,33 @@ IPAProxy::~IPAProxy()\n std::string IPAProxy::configurationFile(const std::string &name,\n \t\t\t\t\tconst std::string &fallbackName) const\n {\n-\tstruct stat statbuf;\n-\tint ret;\n-\n \t/*\n \t * The IPA module name can be used as-is to build directory names as it\n \t * has been validated when loading the module.\n \t */\n-\tstd::string ipaName = ipam_->info().name;\n+\tconst std::string ipaName = ipam_->info().name;\n\n-\t/* Check the environment variable first. */\n+\t/*\n+\t * Start with any user override through the module-specific environment\n+\t * variable. Use the name of the IPA module up to the first '/' to\n+\t * construct the variable name.\n+\t */\n+\tstd::string ipaEnvName = ipaName.substr(0, ipaName.find('/'));\n+\tstd::transform(ipaEnvName.begin(), ipaEnvName.end(), ipaEnvName.begin(),\n+\t\t [](unsigned char c) { return std::toupper(c); });\n+\tipaEnvName = \"LIBCAMERA_\" + ipaEnvName + \"_TUNING_FILE\";\n+\n+\tchar const *configFromEnv = utils::secure_getenv(ipaEnvName.c_str());\n+\tif (configFromEnv && *configFromEnv == '\\0')\n+\t\treturn { configFromEnv };\n+\n+\tstruct stat statbuf;\n+\tint ret;\n+\n+\t/*\n+\t * Check the directory pointed to by the IPA config path environment\n+\t * variable next.\n+\t */\n \tconst char *confPaths = utils::secure_getenv(\"LIBCAMERA_IPA_CONFIG_PATH\");\n \tif (confPaths) {\n \t\tfor (const auto &dir : utils::split(confPaths, \":\")) {\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 35c793da9bba..1ac8d8ae7ed9 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -380,18 +380,9 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision)\n \tipa_->paramsComputed.connect(this, &RkISP1CameraData::paramsComputed);\n \tipa_->metadataReady.connect(this, &RkISP1CameraData::metadataReady);\n\n-\t/*\n-\t * The API tuning file is made from the sensor name unless the\n-\t * environment variable overrides it.\n-\t */\n-\tstd::string ipaTuningFile;\n-\tchar const *configFromEnv = utils::secure_getenv(\"LIBCAMERA_RKISP1_TUNING_FILE\");\n-\tif (!configFromEnv || *configFromEnv == '\\0') {\n-\t\tipaTuningFile =\n-\t\t\tipa_->configurationFile(sensor_->model() + \".yaml\", \"uncalibrated.yaml\");\n-\t} else {\n-\t\tipaTuningFile = std::string(configFromEnv);\n-\t}\n+\t/* The IPA tuning file is made from the sensor name. */\n+\tstd::string ipaTuningFile =\n+\t\tipa_->configurationFile(sensor_->model() + \".yaml\", \"uncalibrated.yaml\");\n\n \tIPACameraSensorInfo sensorInfo{};\n \tint ret = sensor_->sensorInfo(&sensorInfo);\ndiff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\nindex 4b147fdb379a..1f13e5230fae 100644\n--- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n+++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp\n@@ -1156,20 +1156,11 @@ int CameraData::loadIPA(ipa::RPi::InitResult *result)\n \tif (!ipa_)\n \t\treturn -ENOENT;\n\n-\t/*\n-\t * The configuration (tuning file) is made from the sensor name unless\n-\t * the environment variable overrides it.\n-\t */\n-\tstd::string configurationFile;\n-\tchar const *configFromEnv = utils::secure_getenv(\"LIBCAMERA_RPI_TUNING_FILE\");\n-\tif (!configFromEnv || *configFromEnv == '\\0') {\n-\t\tstd::string model = sensor_->model();\n-\t\tif (isMonoSensor(sensor_))\n-\t\t\tmodel += \"_mono\";\n-\t\tconfigurationFile = ipa_->configurationFile(model + \".json\");\n-\t} else {\n-\t\tconfigurationFile = std::string(configFromEnv);\n-\t}\n+\t/* The configuration (tuning file) is made from the sensor name. */\n+\tstd::string model = sensor_->model();\n+\tif (isMonoSensor(sensor_))\n+\t\tmodel += \"_mono\";\n+\tstd::string configurationFile = ipa_->configurationFile(model + \".json\");\n\n \tIPASettings settings(configurationFile, sensor_->model());\n \tipa::RPi::InitParams params;\n", "prefixes": [] }