From patchwork Wed Jan 18 08:59:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18128 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 C128FC3240 for ; Wed, 18 Jan 2023 09:01:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6435F625F1; Wed, 18 Jan 2023 10:01:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674032480; bh=aPx61EyK5426KHTbbJ5ftutp6M7sRBs01qIVaRATqP8=; 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=vJb0mZ1SNcAYwmrHnfXvimDs+e/aiThWgWXtUgBplaiEAh5kLkFHG3JOh7aaLhjV0 f7a6CHk5vf4Jgk25qciujvq+3xePfw6QWohcOtLr/dU0fAAaa3asvDr/ZBzVWDKgv6 3WgEFx9L6FwZC1fpDy5BS/PtQCDmOSH/ffgcQU5YYYx9TUuC8q4Yazg72O1p+Gt9Wb xm+1OTCrxk4xKNS6qpss9jyRiFSSEhaEACE2df7B/Y+fxSKwGQv7Jp61M8HbQCRqxH qhiRLOK1arEBy/FmIaavTppAjpG7dx6XSQl6p+Zke/indaruY3E32sqirk2yEE5ooi MRXf4/tB6ZzVQ== Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 91A7B625E8 for ; Wed, 18 Jan 2023 10:01:17 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="miHWQt7Z"; dkim-atps=neutral Received: by mail-wr1-x432.google.com with SMTP id h16so33173492wrz.12 for ; Wed, 18 Jan 2023 01:01:17 -0800 (PST) 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=gYE4rAs6mWLRRzePAtTOx6PsgAWDmX1Qry7rwDpq1OM=; b=miHWQt7Zsk8yHx90JiUjQ8voLApwX+n/hWexy8RIanyNhyCswyq4qcKxSL6M5+70+x zJbMYCd8dm2UvvveNonnEqMVFN3qLQg9UfimuLs8GKe5SArXCO64bryv1gkqRuwH40wN LJ8eB/7HfSR8DB84SfA5oCrXU/Gqahe4wS50svQSMPDjhI89WrA+XjvA29or7yuFevJh 1yLo7pWx8mSJNlEHoi1a+MKaNgtILpUUYxCHi6rzcn5XaI9/6veG5mgsoLhQlQHjGpnq 2v0bxD+tP0sSF1L1socmDnajN11LBp/Ng55EFmCiP2alSp12Zd+JoiN9oY3aV7JWBEkR p1Pg== 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=gYE4rAs6mWLRRzePAtTOx6PsgAWDmX1Qry7rwDpq1OM=; b=d6EnffcGdsBGEYCTqIeOAe/ypsu1jnY/+y9OuYXVvzoM92DffwqwZaHRS9/yk3Hwgb KJdEAj8GAPtasZ+5Yk9Oif6Z6fSou4ixoP9wt6qpaat5H4ygfHQMydi+pbIp+bBNhw4S Qj9gb8AFUNsoV7ssmTrXd69Chv6sU9Gxz4hNADgnWncrNwPpBZ+4rYbmjtf9InECb3yW wYyG/mROrGhgt7GEqRfsodC1yYfw2QaD9d2c6xYyT4AmnFg3KrovzqdrF/NOaF1D9RQP GWXkHKbtVcMJo52Yp+/N1c4nqPQo9GkWQVLTmJetdxWpdNnyItEltj/dg4fFZ0Cvd6gV gmtA== X-Gm-Message-State: AFqh2krUDwaCinMb8Enr0G/5ikp7h8KDsHlqhjubXlNxpE4TppXk8kFf DcuKOq5SWUED5DKHyqSDhuLhCSX/ITuLywWO29s= X-Google-Smtp-Source: AMrXdXvzvgs25OtnEvrUI/qNxVBnmkLZL3+64D37NALOdgrdL6+1o5WVkr34JD4DjeqwvvdsrSMLEA== X-Received: by 2002:a5d:59c7:0:b0:293:1868:3a14 with SMTP id v7-20020a5d59c7000000b0029318683a14mr1943695wry.0.1674032476825; Wed, 18 Jan 2023 01:01:16 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:01:16 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Jan 2023 08:59:43 +0000 Message-Id: <20230118085953.7027-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118085953.7027-1-naush@raspberrypi.com> References: <20230118085953.7027-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 02/12] 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 Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/internal/pipeline_handler.h | 3 + src/libcamera/pipeline_handler.cpp | 60 +++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index ec4f662d7399..4c4dfe62a680 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -65,6 +65,9 @@ public: bool completeBuffer(Request *request, FrameBuffer *buffer); void completeRequest(Request *request); + std::string configurationFile(const std::string &subdir, + const std::string &name) const; + const char *name() const { return name_; } protected: diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index cfade4908118..a515ad5ecffb 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 @@ -534,6 +535,65 @@ void PipelineHandler::completeRequest(Request *request) } } +/** + * \brief Retrieve the absolute path to a platform configuration file + * \param[in] subdir The pipeline handler specific subdirectory name + * \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//data/ + * 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 &subdir, + const std::string &name) const +{ + std::string confPath; + 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 pipeline handler. + */ + std::string confDir = root + "src/libcamera/pipeline/"; + confPath = confDir + subdir + "/data/" + name; + + LOG(Pipeline, Info) + << "libcamera is not installed. Loading platform configuration file from '" + << confPath << "'"; + + 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. */ + confPath = std::string(LIBCAMERA_DATA_DIR) + + "/pipeline/" + subdir + '/' + name; + ret = stat(confPath.c_str(), &statbuf); + if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG) + return confPath; + } + + LOG(Pipeline, Error) + << "Configuration file '" << confPath + << "' not found for pipeline handler '" << PipelineHandler::name() << "'"; + + return std::string(); +} + /** * \brief Register a camera to the camera manager and pipeline handler * \param[in] camera The camera to be added