Show a patch.

GET /api/1.1/patches/26029/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 26029,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/26029/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/26029/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20260129082814.1777779-2-paul.elder@ideasonboard.com>",
    "date": "2026-01-29T08:28:07",
    "name": "[v6,1/8] libcamera: ipa_manager: Factor out .so file searching",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "e989c30a48858bc46894252c4c9b8629297220c9",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/1.1/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/26029/mbox/",
    "series": [
        {
            "id": 5753,
            "url": "https://patchwork.libcamera.org/api/1.1/series/5753/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=5753",
            "date": "2026-01-29T08:28:06",
            "name": "Add Layers support",
            "version": 6,
            "mbox": "https://patchwork.libcamera.org/series/5753/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/26029/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/26029/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 6D8BEC3226\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 29 Jan 2026 08:28:29 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C1A1261FD5;\n\tThu, 29 Jan 2026 09:28:28 +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 1769E61FC5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 29 Jan 2026 09:28:26 +0100 (CET)",
            "from neptunite.flets-east.jp (unknown\n\t[IPv6:2404:7a81:160:2100:2eea:f891:1bd7:2691])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 99B121661;\n\tThu, 29 Jan 2026 09:27:47 +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=\"D9CcUl1v\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1769675268;\n\tbh=NIy/w9Kpz3z+X2wA2llmgDi4mv7PpC3Pl9bOqQmyXVg=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=D9CcUl1vhQnTGF+rAuyJDj3Y33r/Wnxn9nQY4aB911HJ9YhQ5RdamNmEECE4tMQbm\n\t5BdD0DXHL0lp6UryDgucYz4vPAM4clYIuddbE1tWV3z8FwYeVVTOOMBOSXgJ7i8J3b\n\tQ7Km+YUPAUEZ4OCY2f9YH38bVamo63YGfeZxgopI=",
        "From": "Paul Elder <paul.elder@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Paul Elder <paul.elder@ideasonboard.com>",
        "Subject": "[PATCH v6 1/8] libcamera: ipa_manager: Factor out .so file searching",
        "Date": "Thu, 29 Jan 2026 17:28:07 +0900",
        "Message-ID": "<20260129082814.1777779-2-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.47.2",
        "In-Reply-To": "<20260129082814.1777779-1-paul.elder@ideasonboard.com>",
        "References": "<20260129082814.1777779-1-paul.elder@ideasonboard.com>",
        "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": "In the near future we will add support for layers/shoes on top of\nlibcamera, which will need to search for shared object files similar to\nhow IPAManager does. To avoid code duplication, move this code out of\nIPAManager into internal utils.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nNo change in v6\n\nNo change in v5\n\nNo change in v4\n\nChanges in v3:\n- rename addDir to findSharedObjects\n- make parseDir static\n\nNo change in v2\n---\n include/libcamera/internal/ipa_manager.h |   4 -\n include/libcamera/internal/meson.build   |   1 +\n include/libcamera/internal/utils.h       |  23 +++++\n src/libcamera/ipa_manager.cpp            | 107 ++++-------------------\n src/libcamera/meson.build                |   1 +\n src/libcamera/utils.cpp                  | 107 +++++++++++++++++++++++\n 6 files changed, 151 insertions(+), 92 deletions(-)\n create mode 100644 include/libcamera/internal/utils.h\n create mode 100644 src/libcamera/utils.cpp",
    "diff": "diff --git a/include/libcamera/internal/ipa_manager.h b/include/libcamera/internal/ipa_manager.h\nindex f8ce780169e6..dcfcf8d69da5 100644\n--- a/include/libcamera/internal/ipa_manager.h\n+++ b/include/libcamera/internal/ipa_manager.h\n@@ -68,10 +68,6 @@ public:\n #endif\n \n private:\n-\tvoid parseDir(const char *libDir, unsigned int maxDepth,\n-\t\t      std::vector<std::string> &files);\n-\tunsigned int addDir(const char *libDir, unsigned int maxDepth = 0);\n-\n \tIPAModule *module(PipelineHandler *pipe, uint32_t minVersion,\n \t\t\t  uint32_t maxVersion);\n \ndiff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build\nindex 4d2a09bd7041..ed145a6dd7cd 100644\n--- a/include/libcamera/internal/meson.build\n+++ b/include/libcamera/internal/meson.build\n@@ -43,6 +43,7 @@ libcamera_internal_headers = files([\n     'shared_mem_object.h',\n     'source_paths.h',\n     'sysfs.h',\n+    'utils.h',\n     'v4l2_device.h',\n     'v4l2_pixelformat.h',\n     'v4l2_request.h',\ndiff --git a/include/libcamera/internal/utils.h b/include/libcamera/internal/utils.h\nnew file mode 100644\nindex 000000000000..5b7957b5d77e\n--- /dev/null\n+++ b/include/libcamera/internal/utils.h\n@@ -0,0 +1,23 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * Miscellaneous utility functions\n+ */\n+\n+#pragma once\n+\n+#include <functional>\n+#include <string>\n+#include <vector>\n+\n+namespace libcamera {\n+\n+namespace utils {\n+\n+unsigned int findSharedObjects(const char *libDir, unsigned int maxDepth,\n+\t\t\t       std::function<int(const std::string &)> func);\n+\n+} /* namespace utils */\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp\nindex 35171d097136..244a8ee67f05 100644\n--- a/src/libcamera/ipa_manager.cpp\n+++ b/src/libcamera/ipa_manager.cpp\n@@ -8,7 +8,7 @@\n #include \"libcamera/internal/ipa_manager.h\"\n \n #include <algorithm>\n-#include <dirent.h>\n+#include <functional>\n #include <string.h>\n #include <string>\n #include <sys/types.h>\n@@ -22,6 +22,7 @@\n #include \"libcamera/internal/ipa_module.h\"\n #include \"libcamera/internal/ipa_proxy.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n+#include \"libcamera/internal/utils.h\"\n \n /**\n  * \\file ipa_manager.h\n@@ -118,6 +119,20 @@ IPAManager::IPAManager(const GlobalConfiguration &configuration)\n \n \tunsigned int ipaCount = 0;\n \n+\tauto &modules = modules_;\n+\tstd::function<int(const std::string &)> soHandler =\n+\t[&modules](const std::string &file) {\n+\t\tauto ipaModule = std::make_unique<IPAModule>(file);\n+\t\tif (!ipaModule->isValid())\n+\t\t\treturn 0;\n+\n+\t\tLOG(IPAManager, Debug) << \"Loaded IPA module '\" << file << \"'\";\n+\n+\t\tmodules.push_back(std::move(ipaModule));\n+\n+\t\treturn 1;\n+\t};\n+\n \t/* User-specified paths take precedence. */\n \tconst auto modulePaths =\n \t\tconfiguration.envListOption(\n@@ -127,7 +142,7 @@ IPAManager::IPAManager(const GlobalConfiguration &configuration)\n \t\tif (dir.empty())\n \t\t\tcontinue;\n \n-\t\tipaCount += addDir(dir.c_str());\n+\t\tipaCount += utils::findSharedObjects(dir.c_str(), 0, soHandler);\n \t}\n \n \tif (!modulePaths.empty() && !ipaCount)\n@@ -148,11 +163,11 @@ IPAManager::IPAManager(const GlobalConfiguration &configuration)\n \t\t\t<< \"libcamera is not installed. Adding '\"\n \t\t\t<< ipaBuildPath << \"' to the IPA search path\";\n \n-\t\tipaCount += addDir(ipaBuildPath.c_str(), maxDepth);\n+\t\tipaCount += utils::findSharedObjects(ipaBuildPath.c_str(), maxDepth, soHandler);\n \t}\n \n \t/* Finally try to load IPAs from the installed system path. */\n-\tipaCount += addDir(IPA_MODULE_DIR);\n+\tipaCount += utils::findSharedObjects(IPA_MODULE_DIR, 0, soHandler);\n \n \tif (!ipaCount)\n \t\tLOG(IPAManager, Warning)\n@@ -161,90 +176,6 @@ IPAManager::IPAManager(const GlobalConfiguration &configuration)\n \n IPAManager::~IPAManager() = default;\n \n-/**\n- * \\brief Identify shared library objects within a directory\n- * \\param[in] libDir The directory to search for shared objects\n- * \\param[in] maxDepth The maximum depth of sub-directories to parse\n- * \\param[out] files A vector of paths to shared object library files\n- *\n- * Search a directory for .so files, allowing recursion down to sub-directories\n- * no further than the depth specified by \\a maxDepth.\n- *\n- * Discovered shared objects are added to the \\a files vector.\n- */\n-void IPAManager::parseDir(const char *libDir, unsigned int maxDepth,\n-\t\t\t  std::vector<std::string> &files)\n-{\n-\tstruct dirent *ent;\n-\tDIR *dir;\n-\n-\tdir = opendir(libDir);\n-\tif (!dir)\n-\t\treturn;\n-\n-\twhile ((ent = readdir(dir)) != nullptr) {\n-\t\tif (ent->d_type == DT_DIR && maxDepth) {\n-\t\t\tif (strcmp(ent->d_name, \".\") == 0 ||\n-\t\t\t    strcmp(ent->d_name, \"..\") == 0)\n-\t\t\t\tcontinue;\n-\n-\t\t\tstd::string subdir = std::string(libDir) + \"/\" + ent->d_name;\n-\n-\t\t\t/* Recursion is limited to maxDepth. */\n-\t\t\tparseDir(subdir.c_str(), maxDepth - 1, files);\n-\n-\t\t\tcontinue;\n-\t\t}\n-\n-\t\tint offset = strlen(ent->d_name) - 3;\n-\t\tif (offset < 0)\n-\t\t\tcontinue;\n-\t\tif (strcmp(&ent->d_name[offset], \".so\"))\n-\t\t\tcontinue;\n-\n-\t\tfiles.push_back(std::string(libDir) + \"/\" + ent->d_name);\n-\t}\n-\n-\tclosedir(dir);\n-}\n-\n-/**\n- * \\brief Load IPA modules from a directory\n- * \\param[in] libDir The directory to search for IPA modules\n- * \\param[in] maxDepth The maximum depth of sub-directories to search\n- *\n- * This function tries to create an IPAModule instance for every shared object\n- * found in \\a libDir, and skips invalid IPA modules.\n- *\n- * Sub-directories are searched up to a depth of \\a maxDepth. A \\a maxDepth\n- * value of 0 only searches the directory specified in \\a libDir.\n- *\n- * \\return Number of modules loaded by this call\n- */\n-unsigned int IPAManager::addDir(const char *libDir, unsigned int maxDepth)\n-{\n-\tstd::vector<std::string> files;\n-\n-\tparseDir(libDir, maxDepth, files);\n-\n-\t/* Ensure a stable ordering of modules. */\n-\tstd::sort(files.begin(), files.end());\n-\n-\tunsigned int count = 0;\n-\tfor (const std::string &file : files) {\n-\t\tauto ipaModule = std::make_unique<IPAModule>(file);\n-\t\tif (!ipaModule->isValid())\n-\t\t\tcontinue;\n-\n-\t\tLOG(IPAManager, Debug) << \"Loaded IPA module '\" << file << \"'\";\n-\n-\t\tmodules_.push_back(std::move(ipaModule));\n-\t\tcount++;\n-\t}\n-\n-\treturn count;\n-}\n-\n /**\n  * \\brief Retrieve an IPA module that matches a given pipeline handler\n  * \\param[in] pipe The pipeline handler\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex d15943586300..186d5c48ccd5 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -52,6 +52,7 @@ libcamera_internal_sources = files([\n     'shared_mem_object.cpp',\n     'source_paths.cpp',\n     'sysfs.cpp',\n+    'utils.cpp',\n     'v4l2_device.cpp',\n     'v4l2_pixelformat.cpp',\n     'v4l2_request.cpp',\ndiff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp\nnew file mode 100644\nindex 000000000000..2ce62f236cea\n--- /dev/null\n+++ b/src/libcamera/utils.cpp\n@@ -0,0 +1,107 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * Miscellaneous utility functions (internal)\n+ */\n+\n+#include \"libcamera/internal/utils.h\"\n+\n+#include <algorithm>\n+#include <dirent.h>\n+#include <functional>\n+#include <string.h>\n+#include <string>\n+#include <sys/types.h>\n+#include <vector>\n+\n+/**\n+ * \\file internal/utils.h\n+ * \\brief Miscellaneous utility functions (internal)\n+ */\n+\n+namespace libcamera {\n+\n+namespace utils {\n+\n+/**\n+ * \\brief Identify shared library objects within a directory\n+ * \\param[in] libDir The directory to search for shared objects\n+ * \\param[in] maxDepth The maximum depth of sub-directories to parse\n+ * \\param[out] files A vector of paths to shared object library files\n+ *\n+ * Search a directory for .so files, allowing recursion down to sub-directories\n+ * no further than the depth specified by \\a maxDepth.\n+ *\n+ * Discovered shared objects are added to the \\a files vector.\n+ */\n+static void parseDir(const char *libDir, unsigned int maxDepth,\n+\t\t     std::vector<std::string> &files)\n+{\n+\tstruct dirent *ent;\n+\tDIR *dir;\n+\n+\tdir = opendir(libDir);\n+\tif (!dir)\n+\t\treturn;\n+\n+\twhile ((ent = readdir(dir)) != nullptr) {\n+\t\tif (ent->d_type == DT_DIR && maxDepth) {\n+\t\t\tif (strcmp(ent->d_name, \".\") == 0 ||\n+\t\t\t    strcmp(ent->d_name, \"..\") == 0)\n+\t\t\t\tcontinue;\n+\n+\t\t\tstd::string subdir = std::string(libDir) + \"/\" + ent->d_name;\n+\n+\t\t\t/* Recursion is limited to maxDepth. */\n+\t\t\tparseDir(subdir.c_str(), maxDepth - 1, files);\n+\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tint offset = strlen(ent->d_name) - 3;\n+\t\tif (offset < 0)\n+\t\t\tcontinue;\n+\t\tif (strcmp(&ent->d_name[offset], \".so\"))\n+\t\t\tcontinue;\n+\n+\t\tfiles.push_back(std::string(libDir) + \"/\" + ent->d_name);\n+\t}\n+\n+\tclosedir(dir);\n+}\n+\n+/**\n+ * \\brief Execute some function on shared object files from a directory\n+ * \\param[in] libDir The directory to search for shared objects\n+ * \\param[in] maxDepth The maximum depth of sub-directories to search\n+ * \\param[in] func The function to execute on every shared object\n+ *\n+ * This function tries to execute the given function \\a func for every shared\n+ * object found in \\a libDir.\n+ *\n+ * Sub-directories are searched up to a depth of \\a maxDepth. A \\a maxDepth\n+ * value of 0 only searches the directory specified in \\a libDir.\n+ *\n+ * \\return Number of shared objects loaded by this call\n+ */\n+unsigned int findSharedObjects(const char *libDir, unsigned int maxDepth,\n+\t\t\t       std::function<int(const std::string &)> func)\n+{\n+\tstd::vector<std::string> files;\n+\n+\tparseDir(libDir, maxDepth, files);\n+\n+\t/* Ensure a stable ordering of modules. */\n+\tstd::sort(files.begin(), files.end());\n+\n+\tunsigned int count = 0;\n+\tfor (const std::string &file : files)\n+\t\tcount += func(file);\n+\n+\treturn count;\n+}\n+\n+} /* namespace utils */\n+\n+} /* namespace libcamera */\n",
    "prefixes": [
        "v6",
        "1/8"
    ]
}