{"id":17596,"url":"https://patchwork.libcamera.org/api/patches/17596/?format=json","web_url":"https://patchwork.libcamera.org/patch/17596/","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":"<20221014131846.27169-2-naush@raspberrypi.com>","date":"2022-10-14T13:18:37","name":"[libcamera-devel,v1,01/10] libcamera: pipeline: Add a platform configuration file helper","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"b8e70fa88747d3dbea2ce8f25dea1ffb476ac9f5","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17596/mbox/","series":[{"id":3555,"url":"https://patchwork.libcamera.org/api/series/3555/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3555","date":"2022-10-14T13:18:37","name":"Raspberry Pi: Platform configuration and buffer allocation improvements","version":1,"mbox":"https://patchwork.libcamera.org/series/3555/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17596/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17596/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 29A12C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Oct 2022 13:18:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1E0D462DC0;\n\tFri, 14 Oct 2022 15:18:55 +0200 (CEST)","from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com\n\t[IPv6:2a00:1450:4864:20::42d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7E05E62DB4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Oct 2022 15:18:52 +0200 (CEST)","by mail-wr1-x42d.google.com with SMTP id b4so7572842wrs.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Oct 2022 06:18:52 -0700 (PDT)","from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tg17-20020a05600c001100b003c6bbe910fdsm8282458wmc.9.2022.10.14.06.18.50\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 14 Oct 2022 06:18:50 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1665753535;\n\tbh=pJFkucVB9rxJO4NW4seeCPGipcgO5BSEG6Mr5Rdtppo=;\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=LGQiXr+FDRKtOYS3TfJQvA8vHqoSOx6WamsV0FSOuBqHQzbCWcuF7d45cKks85rqy\n\tRt4H5tjMf+hg+qdVnnsCeURYvuWr3QNKYlmu6htqX9K9d0AFjgJlO0sc2jols4KYZi\n\teUdPI4KwrAWghCX1auzvbdYrosrl90AzJeFmq5Nm0BqMMn9E+ymtETiaLla2MGKZH8\n\tPRs5OsfbolJDygSeb7ZQSkQM/5Rg/+/yY47tlHH4NJliZI38Ds62gY2uceHiVbVEs+\n\tsTRMBxUskbriF6QdScEJtgTn+juMUzB++gFbd9S3PDvpP3Ymgnm27aRejiNB388YdJ\n\tKI/sX+c4b6o9w==","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=eHxk+LvYm29yyPUnLCf2+9E9jltugsKim5wIoTNNHc4=;\n\tb=nBjhQO89Xyop/cq/OpQGBia/gbzcAbjElWyGbsWGQM1snTPp7JrAcPbhBgALqsMnUx\n\tF5H94UCozxaa3QpMbH+o9KKrp2znAJHxqKZcsFRRlRda73+MY6AIrDVyq7JZ+5xxzF5j\n\tua1bqYoYg0fkvnWI++teMzdGJeXwogfIFP9Vlg9Y+oU7gjg/axfgUIlc8kTzUb1SV3Vh\n\t1r3wQK8yWwKvL2lgHqmPEdLEKctwhyGsERIUwKd2Cvd9yqYEHy/vTa6GYlYieXenyXNh\n\ts1ykTUSFW73jy7cU08dLRyQ5ocB/hUJRWNzrH/1HzclL1iBythb0EbiCO6j+MJswbI43\n\tYGDw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"nBjhQO89\"; 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=eHxk+LvYm29yyPUnLCf2+9E9jltugsKim5wIoTNNHc4=;\n\tb=46hjUWK/+NBGiYAuXVj0vgXj90lCgtQqfwYX9hXG+798CJsYHiZ0Eb2XDkw4i5OxMY\n\t/hTxkjSX8S9gZ9lah7mxqh9NNjc6LItIFd8r2sV1d8lrRJ+z+bCu2PnjLkuYX1BtKCU3\n\t5CAdg2ocXw8igDoy3ju6n8kusGITmwCJFwZiMWTsz6Gy4PRA5KmxpT5nUEy8UHLgygPQ\n\tftW0iqyM1l3rC4s4gcYTEcZD6wONDZyx5CL3V7oP0lymHyL511m/s+6LrYEPLkjQFqt2\n\t3wdSWz0ckZ5KMVa5dEHJ3n43FQtxNdLzYylijnGRkbV6fweOZ9+xKiaqDs9MVMTInaPL\n\tidLg==","X-Gm-Message-State":"ACrzQf3XlCXUZV1rBBJMtaLFQN/CFCa5GgropCw3JENeouZ3A1ANNTRX\n\tcRZ1UJq05VnDRTlwQyzcRyN8XhwhuDT62Q==","X-Google-Smtp-Source":"AMsMyM71Fw4vxMWFuyfhDuftMGVdCKG1Pj3x6E8z5Rh0pm3ShRQS55YWl9RJpRyVhHV9Qu1GQSesCQ==","X-Received":"by 2002:a05:6000:1866:b0:22f:2616:5613 with SMTP id\n\td6-20020a056000186600b0022f26165613mr3294779wri.145.1665753531836; \n\tFri, 14 Oct 2022 06:18:51 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 14 Oct 2022 14:18:37 +0100","Message-Id":"<20221014131846.27169-2-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20221014131846.27169-1-naush@raspberrypi.com>","References":"<20221014131846.27169-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 01/10] 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>\n---\n include/libcamera/internal/pipeline_handler.h |  2 +\n src/libcamera/pipeline_handler.cpp            | 57 +++++++++++++++++++\n 2 files changed, 59 insertions(+)","diff":"diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\nindex b6139a88d421..6648975f15de 100644\n--- a/include/libcamera/internal/pipeline_handler.h\n+++ b/include/libcamera/internal/pipeline_handler.h\n@@ -74,6 +74,8 @@ protected:\n \tvirtual int queueRequestDevice(Camera *camera, Request *request) = 0;\n \tvirtual void stopDevice(Camera *camera) = 0;\n \n+\tstd::string configurationFile(const std::string &name) const;\n+\n \tCameraManager *manager_;\n \n private:\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 588a3db30e82..998dcece05f2 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@@ -625,6 +626,62 @@ void PipelineHandler::disconnect()\n \t}\n }\n \n+/**\n+ * \\brief Retrieve the absolute path to a platform configuration file\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/ directory within\n+ *   the source tree ; otherwise\n+ * - The system data (share/libcamera/pipeline/) 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 &name) const\n+{\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 IPA module.\n+\t\t */\n+\t\tstd::string confDir = root + \"src/libcamera/pipeline/data\";\n+\n+\t\tLOG(Pipeline, Info)\n+\t\t\t<< \"libcamera is not installed. Loading platform configuration file from '\"\n+\t\t\t<< confDir << \"'\";\n+\n+\t\tstd::string confPath = confDir + \"/\" + name;\n+\t\tret = stat(confPath.c_str(), &statbuf);\n+\t\tif (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG)\n+\t\t\treturn confPath;\n+\n+\t} else {\n+\t\t/* Else look in the system locations. */\n+\t\tstd::string confPath = std::string(LIBCAMERA_DATA_DIR) + \"/pipeline/\" + name;\n+\t\tret = stat(confPath.c_str(), &statbuf);\n+\t\tif (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG)\n+\t\t\treturn confPath;\n+\t}\n+\n+\tLOG(Pipeline, Error)\n+\t\t<< \"Configuration file '\" << name\n+\t\t<< \"' not found for pipeline handler '\" << PipelineHandler::name() << \"'\";\n+\n+\treturn std::string();\n+}\n+\n /**\n  * \\var PipelineHandler::manager_\n  * \\brief The Camera manager associated with the pipeline handler\n","prefixes":["libcamera-devel","v1","01/10"]}