[{"id":26025,"web_url":"https://patchwork.libcamera.org/comment/26025/","msgid":"<CAEmqJPqyx28SJWtr_2LHUxK8K5kdxfwQOo8Tj8Y+Oi8cduT4FQ@mail.gmail.com>","date":"2022-12-08T10:35:04","subject":"Re: [libcamera-devel] [PATCH v3 02/13] libcamera: pipeline: Add a\n\tplatform configuration file helper","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi,\n\nI should note that  PipelineHandler::configurationFile() is not actually\nused in\nthis series any more since we now only optionally load a config file if one\nis\nset in the environment variable.  So this commit could possibly be dropped\nif we\nprefer.  However, I do think it has benefits to leave it in if the config\nfile\nwas mandatory for other pipeline handlers.\n\nThanks,\nNaush\n\nOn Tue, 6 Dec 2022 at 13:55, Naushir Patuck <naush@raspberrypi.com> wrote:\n\n> Add a new helper function PipelineHandler::configurationFile() that returns\n> the full path of a named configuration file. This configuration file may\n> be read\n> by pipeline handlers for platform specific configuration parameters on\n> initialisation.\n>\n> The mechanism for searching for the configuration file is similar to the\n> IPA\n> configuration file:\n>\n> - In the source tree if libcamera is not installed\n> - Otherwise in standard system locations (etc and share directories).\n>\n> When stored in the source tree, configuration files shall be located in a\n> 'data'\n> subdirectory of their respective pipeline handler directory.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  include/libcamera/internal/pipeline_handler.h |  3 +\n>  src/libcamera/pipeline_handler.cpp            | 60 +++++++++++++++++++\n>  2 files changed, 63 insertions(+)\n>\n> diff --git a/include/libcamera/internal/pipeline_handler.h\n> b/include/libcamera/internal/pipeline_handler.h\n> index 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>         bool completeBuffer(Request *request, FrameBuffer *buffer);\n>         void completeRequest(Request *request);\n>\n> +       std::string configurationFile(const std::string &subdir,\n> +                                     const std::string &name) const;\n> +\n>         const char *name() const { return name_; }\n>\n>  protected:\n> diff --git a/src/libcamera/pipeline_handler.cpp\n> b/src/libcamera/pipeline_handler.cpp\n> index cfade4908118..a515ad5ecffb 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,65 @@ void PipelineHandler::completeRequest(Request\n> *request)\n>         }\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\n> 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\n> an empty\n> + * string if no configuration file can be found\n> + */\n> +std::string PipelineHandler::configurationFile(const std::string &subdir,\n> +                                              const std::string &name)\n> const\n> +{\n> +       std::string confPath;\n> +       struct stat statbuf;\n> +       int ret;\n> +\n> +       std::string root = utils::libcameraSourcePath();\n> +       if (!root.empty()) {\n> +               /*\n> +                * When libcamera is used before it is installed, load\n> +                * configuration files from the source directory. The\n> +                * configuration files are then located in the 'data'\n> +                * subdirectory of the corresponding pipeline handler.\n> +                */\n> +               std::string confDir = root + \"src/libcamera/pipeline/\";\n> +               confPath = confDir + subdir + \"/data/\" + name;\n> +\n> +               LOG(Pipeline, Info)\n> +                       << \"libcamera is not installed. Loading platform\n> configuration file from '\"\n> +                       << confPath << \"'\";\n> +\n> +               ret = stat(confPath.c_str(), &statbuf);\n> +               if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG)\n> +                       return confPath;\n> +       } else {\n> +               /* Else look in the system locations. */\n> +               confPath = std::string(LIBCAMERA_DATA_DIR)\n> +                               + \"/pipeline/\" + subdir + '/' + name;\n> +               ret = stat(confPath.c_str(), &statbuf);\n> +               if (ret == 0 && (statbuf.st_mode & S_IFMT) == S_IFREG)\n> +                       return confPath;\n> +       }\n> +\n> +       LOG(Pipeline, Error)\n> +               << \"Configuration file '\" << confPath\n> +               << \"' not found for pipeline handler '\" <<\n> PipelineHandler::name() << \"'\";\n> +\n> +       return 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> --\n> 2.25.1\n>\n>","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 7F31ABE08B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  8 Dec 2022 10:35:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DD36C63340;\n\tThu,  8 Dec 2022 11:35:22 +0100 (CET)","from mail-il1-x131.google.com (mail-il1-x131.google.com\n\t[IPv6:2607:f8b0:4864:20::131])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9F35D61F1F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  8 Dec 2022 11:35:20 +0100 (CET)","by mail-il1-x131.google.com with SMTP id o13so454873ilc.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 08 Dec 2022 02:35:20 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1670495722;\n\tbh=lK9fEOXQFNlflLRMhwjq0FSBqKJ6gefS9XC76HsGsbk=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=Db41R1R7iWODZynbn9k7l7c1NKvro9x7fNQcpmzUHkuXZxHXE6AvT0bM03mzYLQFk\n\tz3Uhp1rWYTo+BNOXUhLXDRSLPtgKKjaED4C30uGEU7Up+4vAxjzTnh1hutqNKkyL27\n\tHFJBIOLJoUC3yoZr0Elu83Mh++QHUAcaXQNQLtssJjj9ifAnooTFoyS+Vi4XxMYgql\n\tvpp/Hs4IGzY3X/AkphhhA7SvTXEI6wmPYyiuhpswuyO4jnibAWmjs3c3THpfAyGQWn\n\tYGUuTnje5g5W+KDqRR787QfkbTttsEttOxunTFP22ELH9aFHO2VkMC+qWDZsmLcz0m\n\tnmsABUUzZxpnQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=yNCWg3+IPEBNtb+kEN85pVBczZ2MXiOHWIsK+7ZUgt4=;\n\tb=SbBHIe842HzC/f2JJMA99ShRhLGG5eQC7TTHZ2zKcdTb5azarzS6slIF6wqB2AumXk\n\tG3QxBe69MefTXnBhTzfIHuMIBliCoDo5K+ffwqm5XauHn+ZgxByVAqTE7LNyOYyPxoPo\n\t1QGRJn/Tg+w9ABJvz1WRQJg+iSJeEyfgJTJo7jmQDer3UeEUx/bmeRjVtw0/ilychKC9\n\tOsj51SalgvJo97L3S+T9mTF02bh38Qdwr3MGLH9mGLzILNEGe7cSnA3PgnuclwSFzehM\n\tF1XpJIy2GZnJ/h6JvYiRj0b/FAUIB7zVceKUzbWhGOI6rXh5uxAJsSs5MbKXphR1RZ90\n\tzd1g=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"SbBHIe84\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=yNCWg3+IPEBNtb+kEN85pVBczZ2MXiOHWIsK+7ZUgt4=;\n\tb=DtHB0a9QJ2qIuUvxWDC/4zCV6W8P0i0mkqKY2T+opETUPe4P+K0i5a8JflfNKSB1vn\n\teFaODWmrzBfgQM1N9+VFd7lahijwaNTD4lfV4fr5x4v3PPGtQM/U9ad9HAbIrmXz2yRO\n\tMfqD5IRzfTJQuaJttIrZ9Lk7d9jC9mnu/errQANiepaVQ0DZe4aJ0DTJqeMSuJHkV/Xa\n\t10Rk06dffrtpyh2tLaNtvhEuw/vccaZwcuI3/RN38fBqQ8qFm9AUT3svucHACUGFu+1W\n\tMNZMEfCzLK9/3mxMzU/m4pxToKFj1zdBNH21Y7uzHVhU+ZoQLazcPcFLD7w34rlwK9sg\n\tTKIg==","X-Gm-Message-State":"ANoB5pmkljcAuTW4Hf7do78QNM1O4ed9sZFIKUJAfuDRZDmlyb2xq6Ma\n\tlLDqUq3Rx97+H52hdE2ctUah8upA74flQb2P02LCNuI8pY4K8w==","X-Google-Smtp-Source":"AA0mqf7aM3Gjul/d4WdySUb8j+PnwBvkELt4RU2accREW0SvuF0RjAQ6p54RLmIY4hmwTHCPCygAgYyEmnUPEfB02yY=","X-Received":"by 2002:a92:c212:0:b0:303:7011:85d3 with SMTP id\n\tj18-20020a92c212000000b00303701185d3mr5965315ilo.181.1670495719127;\n\tThu, 08 Dec 2022 02:35:19 -0800 (PST)","MIME-Version":"1.0","References":"<20221206135459.25521-1-naush@raspberrypi.com>\n\t<20221206135459.25521-3-naush@raspberrypi.com>","In-Reply-To":"<20221206135459.25521-3-naush@raspberrypi.com>","Date":"Thu, 8 Dec 2022 10:35:04 +0000","Message-ID":"<CAEmqJPqyx28SJWtr_2LHUxK8K5kdxfwQOo8Tj8Y+Oi8cduT4FQ@mail.gmail.com>","To":"libcamera-devel@lists.libcamera.org","Content-Type":"multipart/alternative; boundary=\"000000000000f018e405ef4e9767\"","Subject":"Re: [libcamera-devel] [PATCH v3 02/13] 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>"}}]