{"id":18202,"url":"https://patchwork.libcamera.org/api/1.1/patches/18202/?format=json","web_url":"https://patchwork.libcamera.org/patch/18202/","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":"<20230127154322.29019-3-naush@raspberrypi.com>","date":"2023-01-27T15:43:09","name":"[libcamera-devel,v6,02/15] libcamera: pipeline: Add a platform configuration file helper","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"c5a491f3581d7d33d4de451665ac09f289c09657","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18202/mbox/","series":[{"id":3728,"url":"https://patchwork.libcamera.org/api/1.1/series/3728/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3728","date":"2023-01-27T15:43:07","name":"[libcamera-devel,v6,01/15] libcamera: stream: Add stream hints to StreamConfiguration","version":6,"mbox":"https://patchwork.libcamera.org/series/3728/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18202/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18202/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 DFA2DBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 Jan 2023 15:43:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D459F625EE;\n\tFri, 27 Jan 2023 16:43:39 +0100 (CET)","from mail-wm1-x336.google.com (mail-wm1-x336.google.com\n\t[IPv6:2a00:1450:4864:20::336])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3FFD961EFA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Jan 2023 16:43:37 +0100 (CET)","by mail-wm1-x336.google.com with SMTP id k16so3747561wms.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Jan 2023 07:43:37 -0800 (PST)","from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\th18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.36\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 27 Jan 2023 07:43:36 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1674834219;\n\tbh=MfmJvw88lgHQVnelEqUJ4gx08aFdQMY340f3rWJzFOs=;\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=Yp6HxVVrNrnTVY/pL4o7+Q6kk2QjBR/pvMl/on0S8Jn7QxRVxyMU0uIPhdGCnWwBh\n\tITV89XcvwlR/DvwSgepNWHL/qo4HS1fPbcaH7MR5tHOxPzwPWumF9LeNOTFSip4AJa\n\t/heU/bUYt8g6r+N/vBSqwYm4bFELw/UsNfX22OXh0ymgI+o8EecnsLjB7XP5aW1GPq\n\tDvjrk4digzmKAfL1s+4TtGXa+bGdHiHoJdlge7EZRuhrxjs047D0hVOe50DHiHxCK0\n\tqO+RrGJYLx6VS1NC5h4xFgB4ahHcZ1gmn2mnXmN1UWbw5Atsk4bai+ucwl/J4bpNVT\n\tjR8qV+QxGWA+A==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=qg+Vovpm8IQXQFF1XiND9m99lJ0nfk2ofAAVcmswMfM=;\n\tb=S4iRAzH3jrPcocHmUeObkuojnJPeXPAesDgmyAJcfXmzFa2NyI6WqkyhRPrx6DaIT0\n\taVHCMgqt+apB34+NJpjCdS6kQICSzCfN1STprTMfxnKc2l6rWCWfiPB2jQtjQ0gawpvb\n\tx94YKvxS2XxvQ+tM8fGlJnjarChXBsD4zvdVGosa3h2eDxMkrcSgN0+FscGYFSjjMQql\n\tb5RbOBDiiUNwhII/NOEi4ktr/teXPm5wcgwZXzPaELyGL8C7yWFEvOlq5ziPQW24KmVO\n\tK7OwfReTM+qRU/dfXQtuO0ur3E1yuwtxgb/cqCM44jaA+zsdr/UNN5Mh5UaFfsBazyQh\n\tas8A=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"S4iRAzH3\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=qg+Vovpm8IQXQFF1XiND9m99lJ0nfk2ofAAVcmswMfM=;\n\tb=B8V1VoxVIyYipowBX47czGmi5vXZncui1NAVpTq79lfKl7jHD80qNz9A9otjzsfHN/\n\t+bQpgcmu8eN3bM0rL0+qB8E1To9nL3LSkoXkNI3v3tT5/QBTsLMVME6tJBljy05srvvb\n\t25KMaytm+0w5dTHD8UzJ0DGYQLUB3SgKTuC1mJWRk8kruCToim+SfYHqBROygCQSPT4P\n\tIVUiwQsLQEtmn5U0CXusxhwmW1WopoJzLz/avynKh77JeUabNqbC+z+B/tNZq5Pa+qR3\n\t3sbifid+zLMfBH9RFd9nTwHtXOT7GpNqB4W6LA02caVG40JqXLuWTHvqlNvp8ZAnz8G+\n\thjHg==","X-Gm-Message-State":"AFqh2kqTKKP0r0OhCGtS2DA0tU9A9tO2hFmtDqWpMBTOmqBBrf/Zd1ir\n\tAyQsTvRBtb7slUDHh4P4h1n8jbI0ryYAByP6i3U=","X-Google-Smtp-Source":"AMrXdXsspt+LX0+VLrE0D9IbxQ04g+PsqmFsUNxwecF8uxY6LH8Py9dXjLvMCU5weFTrGSyNjZ0pDg==","X-Received":"by 2002:a05:600c:3412:b0:3d6:e790:c9a0 with SMTP id\n\ty18-20020a05600c341200b003d6e790c9a0mr41633639wmp.10.1674834216641; \n\tFri, 27 Jan 2023 07:43:36 -0800 (PST)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 27 Jan 2023 15:43:09 +0000","Message-Id":"<20230127154322.29019-3-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20230127154322.29019-1-naush@raspberrypi.com>","References":"<20230127154322.29019-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v6 02/15] libcamera: pipeline: Add a\n\tplatform configuration file helper","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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Add a new helper function PipelineHandler::configurationFile() that returns\nthe full path of a named configuration file. This configuration file may be read\nby pipeline handlers for platform specific configuration parameters on\ninitialisation.\n\nThe mechanism for searching for the configuration file is similar to the IPA\nconfiguration file:\n\n- In the source tree if libcamera is not installed\n- Otherwise in standard system locations (etc and share directories).\n\nWhen stored in the source tree, configuration files shall be located in a 'data'\nsubdirectory of their respective pipeline handler directory.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/pipeline_handler.h |  3 +\n src/libcamera/pipeline_handler.cpp            | 57 +++++++++++++++++++\n 2 files changed, 60 insertions(+)","diff":"diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\nindex ec4f662d7399..4c4dfe62a680 100644\n--- a/include/libcamera/internal/pipeline_handler.h\n+++ b/include/libcamera/internal/pipeline_handler.h\n@@ -65,6 +65,9 @@ public:\n \tbool completeBuffer(Request *request, FrameBuffer *buffer);\n \tvoid completeRequest(Request *request);\n \n+\tstd::string configurationFile(const std::string &subdir,\n+\t\t\t\t      const std::string &name) const;\n+\n \tconst char *name() const { return name_; }\n \n protected:\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex cfade4908118..f72613b8e515 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -8,6 +8,7 @@\n #include \"libcamera/internal/pipeline_handler.h\"\n \n #include <chrono>\n+#include <sys/stat.h>\n #include <sys/sysmacros.h>\n \n #include <libcamera/base/log.h>\n@@ -534,6 +535,62 @@ void PipelineHandler::completeRequest(Request *request)\n \t}\n }\n \n+/**\n+ * \\brief Retrieve the absolute path to a platform configuration file\n+ * \\param[in] subdir The pipeline handler specific subdirectory name\n+ * \\param[in] name The configuration file name\n+ *\n+ * This function locates a named platform configuration file and returns\n+ * its absolute path to the pipeline handler. It searches the following\n+ * directories, in order:\n+ *\n+ * - If libcamera is not installed, the src/libcamera/pipeline/\\<subdir\\>/data/\n+ *   directory within the source tree ; otherwise\n+ * - The system data (share/libcamera/pipeline/\\<subdir\\>) directory.\n+ *\n+ * The system directories are not searched if libcamera is not installed.\n+ *\n+ * \\return The full path to the pipeline handler configuration file, or an empty\n+ * string if no configuration file can be found\n+ */\n+std::string PipelineHandler::configurationFile(const std::string &subdir,\n+\t\t\t\t\t       const std::string &name) const\n+{\n+\tstd::string confPath;\n+\tstruct stat statbuf;\n+\tint ret;\n+\n+\tstd::string root = utils::libcameraSourcePath();\n+\tif (!root.empty()) {\n+\t\t/*\n+\t\t * When libcamera is used before it is installed, load\n+\t\t * configuration files from the source directory. The\n+\t\t * configuration files are then located in the 'data'\n+\t\t * subdirectory of the corresponding pipeline handler.\n+\t\t */\n+\t\tstd::string confDir = root + \"src/libcamera/pipeline/\";\n+\t\tconfPath = confDir + subdir + \"/data/\" + name;\n+\n+\t\tLOG(Pipeline, Info)\n+\t\t\t<< \"libcamera is not installed. Loading platform configuration file from '\"\n+\t\t\t<< confPath << \"'\";\n+\t} else {\n+\t\t/* Else look in the system locations. */\n+\t\tconfPath = std::string(LIBCAMERA_DATA_DIR)\n+\t\t\t\t+ \"/pipeline/\" + subdir + '/' + name;\n+\t}\n+\n+\tret = stat(confPath.c_str(), &statbuf);\n+\tif (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG)\n+\t\treturn confPath;\n+\n+\tLOG(Pipeline, Error)\n+\t\t<< \"Configuration file '\" << confPath\n+\t\t<< \"' not found for pipeline handler '\" << PipelineHandler::name() << \"'\";\n+\n+\treturn std::string();\n+}\n+\n /**\n  * \\brief Register a camera to the camera manager and pipeline handler\n  * \\param[in] camera The camera to be added\n","prefixes":["libcamera-devel","v6","02/15"]}