From patchwork Fri Oct 14 13:18:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17596 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 29A12C0DA4 for ; Fri, 14 Oct 2022 13:18:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1E0D462DC0; Fri, 14 Oct 2022 15:18:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665753535; bh=pJFkucVB9rxJO4NW4seeCPGipcgO5BSEG6Mr5Rdtppo=; 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=LGQiXr+FDRKtOYS3TfJQvA8vHqoSOx6WamsV0FSOuBqHQzbCWcuF7d45cKks85rqy Rt4H5tjMf+hg+qdVnnsCeURYvuWr3QNKYlmu6htqX9K9d0AFjgJlO0sc2jols4KYZi eUdPI4KwrAWghCX1auzvbdYrosrl90AzJeFmq5Nm0BqMMn9E+ymtETiaLla2MGKZH8 PRs5OsfbolJDygSeb7ZQSkQM/5Rg/+/yY47tlHH4NJliZI38Ds62gY2uceHiVbVEs+ sTRMBxUskbriF6QdScEJtgTn+juMUzB++gFbd9S3PDvpP3Ymgnm27aRejiNB388YdJ KI/sX+c4b6o9w== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7E05E62DB4 for ; Fri, 14 Oct 2022 15:18:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="nBjhQO89"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id b4so7572842wrs.1 for ; Fri, 14 Oct 2022 06:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; 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=eHxk+LvYm29yyPUnLCf2+9E9jltugsKim5wIoTNNHc4=; b=nBjhQO89Xyop/cq/OpQGBia/gbzcAbjElWyGbsWGQM1snTPp7JrAcPbhBgALqsMnUx F5H94UCozxaa3QpMbH+o9KKrp2znAJHxqKZcsFRRlRda73+MY6AIrDVyq7JZ+5xxzF5j ua1bqYoYg0fkvnWI++teMzdGJeXwogfIFP9Vlg9Y+oU7gjg/axfgUIlc8kTzUb1SV3Vh 1r3wQK8yWwKvL2lgHqmPEdLEKctwhyGsERIUwKd2Cvd9yqYEHy/vTa6GYlYieXenyXNh s1ykTUSFW73jy7cU08dLRyQ5ocB/hUJRWNzrH/1HzclL1iBythb0EbiCO6j+MJswbI43 YGDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=eHxk+LvYm29yyPUnLCf2+9E9jltugsKim5wIoTNNHc4=; b=46hjUWK/+NBGiYAuXVj0vgXj90lCgtQqfwYX9hXG+798CJsYHiZ0Eb2XDkw4i5OxMY /hTxkjSX8S9gZ9lah7mxqh9NNjc6LItIFd8r2sV1d8lrRJ+z+bCu2PnjLkuYX1BtKCU3 5CAdg2ocXw8igDoy3ju6n8kusGITmwCJFwZiMWTsz6Gy4PRA5KmxpT5nUEy8UHLgygPQ ftW0iqyM1l3rC4s4gcYTEcZD6wONDZyx5CL3V7oP0lymHyL511m/s+6LrYEPLkjQFqt2 3wdSWz0ckZ5KMVa5dEHJ3n43FQtxNdLzYylijnGRkbV6fweOZ9+xKiaqDs9MVMTInaPL idLg== X-Gm-Message-State: ACrzQf3XlCXUZV1rBBJMtaLFQN/CFCa5GgropCw3JENeouZ3A1ANNTRX cRZ1UJq05VnDRTlwQyzcRyN8XhwhuDT62Q== X-Google-Smtp-Source: AMsMyM71Fw4vxMWFuyfhDuftMGVdCKG1Pj3x6E8z5Rh0pm3ShRQS55YWl9RJpRyVhHV9Qu1GQSesCQ== X-Received: by 2002:a05:6000:1866:b0:22f:2616:5613 with SMTP id d6-20020a056000186600b0022f26165613mr3294779wri.145.1665753531836; Fri, 14 Oct 2022 06:18:51 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c001100b003c6bbe910fdsm8282458wmc.9.2022.10.14.06.18.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 06:18:50 -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 Subject: [libcamera-devel] [PATCH v1 01/10] libcamera: pipeline: Add a platform configuration file helper 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 new helper function PipelineHandler::configurationFile() that returns the full path of a named configuration file. This configuration file may be read by pipeline handlers for platform specific configuration parameters on initialisation. The mechanism for searching for the configuration file is similar to the IPA configuration file: - In the source tree if libcamera is not installed - Otherwise in standard system locations (etc and share directories). When stored in the source tree, configuration files shall be located in a 'data' subdirectory of their respective pipeline handler directory. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- include/libcamera/internal/pipeline_handler.h | 2 + src/libcamera/pipeline_handler.cpp | 57 +++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index b6139a88d421..6648975f15de 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -74,6 +74,8 @@ protected: virtual int queueRequestDevice(Camera *camera, Request *request) = 0; virtual void stopDevice(Camera *camera) = 0; + std::string configurationFile(const std::string &name) const; + CameraManager *manager_; private: diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 588a3db30e82..998dcece05f2 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -8,6 +8,7 @@ #include "libcamera/internal/pipeline_handler.h" #include +#include #include #include @@ -625,6 +626,62 @@ void PipelineHandler::disconnect() } } +/** + * \brief Retrieve the absolute path to a platform configuration file + * \param[in] name The configuration file name + * + * This function locates a named platform configuration file and returns + * its absolute path to the pipeline handler. It searches the following + * directories, in order: + * + * - If libcamera is not installed, the src/libcamera/pipeline/ directory within + * the source tree ; otherwise + * - The system data (share/libcamera/pipeline/) directory. + * + * The system directories are not searched if libcamera is not installed. + * + * \return The full path to the pipeline handler configuration file, or an empty + * string if no configuration file can be found + */ +std::string PipelineHandler::configurationFile(const std::string &name) const +{ + struct stat statbuf; + int ret; + + std::string root = utils::libcameraSourcePath(); + if (!root.empty()) { + /* + * When libcamera is used before it is installed, load + * configuration files from the source directory. The + * configuration files are then located in the 'data' + * subdirectory of the corresponding IPA module. + */ + std::string confDir = root + "src/libcamera/pipeline/data"; + + LOG(Pipeline, Info) + << "libcamera is not installed. Loading platform configuration file from '" + << confDir << "'"; + + std::string confPath = confDir + "/" + name; + ret = stat(confPath.c_str(), &statbuf); + if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG) + return confPath; + + } else { + /* Else look in the system locations. */ + std::string confPath = std::string(LIBCAMERA_DATA_DIR) + "/pipeline/" + name; + ret = stat(confPath.c_str(), &statbuf); + if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG) + return confPath; + } + + LOG(Pipeline, Error) + << "Configuration file '" << name + << "' not found for pipeline handler '" << PipelineHandler::name() << "'"; + + return std::string(); +} + /** * \var PipelineHandler::manager_ * \brief The Camera manager associated with the pipeline handler