Patch Detail
Show a patch.
GET /api/1.1/patches/18207/?format=api
{ "id": 18207, "url": "https://patchwork.libcamera.org/api/1.1/patches/18207/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18207/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "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-8-naush@raspberrypi.com>", "date": "2023-01-27T15:43:14", "name": "[libcamera-devel,v6,07/15] pipeline: raspberrypi: Read config parameters from a file", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "3b3abb41b8821ec33985203db16d5ae7a8e4499c", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18207/mbox/", "series": [ { "id": 3728, "url": "https://patchwork.libcamera.org/api/1.1/series/3728/?format=api", "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/18207/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18207/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 DB633C3297\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 Jan 2023 15:43:46 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 56DEE62608;\n\tFri, 27 Jan 2023 16:43:46 +0100 (CET)", "from mail-wm1-x329.google.com (mail-wm1-x329.google.com\n\t[IPv6:2a00:1450:4864:20::329])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4A8CC61EF9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Jan 2023 16:43:40 +0100 (CET)", "by mail-wm1-x329.google.com with SMTP id j17so3774960wms.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Jan 2023 07:43:40 -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.39\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 27 Jan 2023 07:43:39 -0800 (PST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1674834226;\n\tbh=/5OUM1/xRqXPdDagWUAFW17IXHeqW1pka9Exg+IwItU=;\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=avPnl92JgsBajeVKCQQUp/QZyLIZwKmQt1QZIClMNBaXpHBoAR9gvFOKH3sGPQPk6\n\tts15pwQIG51RoBaAcHfG2v8ZSWFhRpf8/MxsCLcnEKwaZvEZRIw1EVsjIcPRpt/NUG\n\tXhbx8JWOl3bZmsEM+6wFpxRRQU1sblTPYsQsTqL0KRfCauYl9C067uAIvNWAPtxwAk\n\t8Hiel5ErROK5/p7sGZf3vmjQoKcZSYzysPgo6c2KX42FBRdbmNxtKkrcNfRolzizyZ\n\tJTDI/N55Wvp8KEsRJYjDQ37fesqba5beCKyfnqfKHIMv6/E0qcHsFeWw4dScUalest\n\tKnSOS1p/dRMVw==", "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=E6dHlkOnJMQJvyJm8IaDqSUyf4r2Yg8uomKDc/nSU+s=;\n\tb=a9n94iy0MEoEPY2hhySvXgI8sph+Vl3eCzOW17jxM34oFCOb7nbNgQyZuLqstZo6UD\n\tAmAWS2RiaLwXfMxrZP0tB3oaWACsKA2WU2sonDY0cRTQ8qUmhhQHIuY9gO+lQPbtAQXd\n\tANmImXJEv9pDXawPQdizgvZUcexlnO2WvTj5XVypKLsR8smWxgMF8DJqr13IRtWlpGiG\n\t/l4YOKSy/b5ZtE65NbkYYhoCqsGQIq/Zet2ROpOtknRt1avUu6ED1HUfI/b0pNR6xr2x\n\trA235VZktlJzJA60l/rGESOUueXfZTkFpm59akUFUI9DEaYaq2XxZGdUFiVulhSjY6na\n\tP6gg==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"a9n94iy0\"; 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=E6dHlkOnJMQJvyJm8IaDqSUyf4r2Yg8uomKDc/nSU+s=;\n\tb=INMxRm2ROqFjK8pqAEzdmePhJqwyjsCypzSqyyo+3KTQXv0vQetSkgrVMVrdItinnn\n\ttpsa9juz24E16Z5QEsBiFQS01OTjCTnhtUnPl/u6G68W200vAOFtZUjB8yVGJUVaKbXU\n\tfiDoSBJXT7kDlCkaw71bU+PxsY+sOMobaycSUYMknuZSMj0/Yij1d+jNVCvdT23q4umw\n\t8RfNB2CzLPXoTbdTDqrfuYyDsPI5jIXOFQ9lTS1g+pjtlc7OH9HbqRVDUBFecTdsGhSZ\n\tPGtjt+PHzYslM1Co0joAxAqGPy1sPnYLAjH5mX6wFtvd/Oswp07pBGMsLilRupIZM1K9\n\tqVug==", "X-Gm-Message-State": "AFqh2kq0vqykjjBduWOGwDWZGaW2PPDKXU22vJaleV+VUS+nCTIvYK6s\n\t3g+Nrh55H9LPa+DFUaW8xrULqCIcNFaO0C6sVG8=", "X-Google-Smtp-Source": "AMrXdXv5roefk4Zi+s+gIbQRgSK3gZQXqGrDsNDQmirGcsQfvTJL4QV454AW493PegC5aj424HwR6A==", "X-Received": "by 2002:a05:600c:3ac8:b0:3da:270b:ba6b with SMTP id\n\td8-20020a05600c3ac800b003da270bba6bmr41411738wms.41.1674834219684; \n\tFri, 27 Jan 2023 07:43:39 -0800 (PST)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 27 Jan 2023 15:43:14 +0000", "Message-Id": "<20230127154322.29019-8-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 07/15] pipeline: raspberrypi: Read\n\tconfig parameters from a file", "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 the ability to read the platform configuration parameters from a\nconfig file provided by the user through the LIBCAMERA_RPI_CONFIG_FILE\nenvironment variable. Use the PipelineHandler::configurationFile()\nhelper to determine the full path of the file.\n\nProvide an example configuration file named example.yaml. Currently two\nparameters are available through the json file:\n\n\"min_unicam_buffers\" The minimum number of internal Unicam buffers to\nallocate.\n\n\"min_total_unicam_buffers\" The minimum number of internal + external\nUnicam buffers that must be allocated.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n---\n Documentation/environment_variables.rst | 5 +++\n .../pipeline/raspberrypi/data/example.yaml | 32 +++++++++++++\n .../pipeline/raspberrypi/data/meson.build | 8 ++++\n .../pipeline/raspberrypi/meson.build | 2 +\n .../pipeline/raspberrypi/raspberrypi.cpp | 45 +++++++++++++++++++\n 5 files changed, 92 insertions(+)\n create mode 100644 src/libcamera/pipeline/raspberrypi/data/example.yaml\n create mode 100644 src/libcamera/pipeline/raspberrypi/data/meson.build", "diff": "diff --git a/Documentation/environment_variables.rst b/Documentation/environment_variables.rst\nindex f092cbbd29c5..ceeb251a2ac0 100644\n--- a/Documentation/environment_variables.rst\n+++ b/Documentation/environment_variables.rst\n@@ -37,6 +37,11 @@ LIBCAMERA_IPA_MODULE_PATH\n \n Example value: ``${HOME}/.libcamera/lib:/opt/libcamera/vendor/lib``\n \n+LIBCAMERA_RPI_CONFIG_FILE\n+ Define a custom configuration file to use in the Raspberry Pi pipeline handler.\n+\n+ Example value: ``/usr/local/share/libcamera/pipeline/raspberrypi/minimal_mem.yaml``\n+\n Further details\n ---------------\n \ndiff --git a/src/libcamera/pipeline/raspberrypi/data/example.yaml b/src/libcamera/pipeline/raspberrypi/data/example.yaml\nnew file mode 100644\nindex 000000000000..4662136e0be0\n--- /dev/null\n+++ b/src/libcamera/pipeline/raspberrypi/data/example.yaml\n@@ -0,0 +1,32 @@\n+{\n+ \"version\": 1.0,\n+ \"target\": \"bcm2835\",\n+\n+ \"pipeline_handler\":\n+ {\n+ # The minimum number of internal buffers to be allocated for\n+ # Unicam. This value must be greater than 0, but less than or\n+ # equal to min_total_unicam_buffers.\n+ #\n+ # A larger number of internal buffers can reduce the occurrence\n+ # of frame drops during high CPU loads, but might also cause\n+ # additional latency in the system.\n+ #\n+ # Note that the pipeline handler might override this value and\n+ # not allocate any internal buffers if it knows they will never\n+ # be used. For example if the RAW stream is marked as mandatory\n+ # and there are no dropped frames signalled for algorithm\n+ # convergence.\n+ #\n+ # \"min_unicam_buffers\": 2,\n+\n+ # The minimum total (internal + external) buffer count used for\n+ # Unicam. The number of internal buffers allocated for Unicam is\n+ # given by:\n+ #\n+ # internal buffer count = max(min_unicam_buffers,\n+ # min_total_unicam_buffers - external buffer count)\n+ #\n+ # \"min_total_unicam_buffers\": 4\n+ }\n+}\ndiff --git a/src/libcamera/pipeline/raspberrypi/data/meson.build b/src/libcamera/pipeline/raspberrypi/data/meson.build\nnew file mode 100644\nindex 000000000000..1c70433bbcbc\n--- /dev/null\n+++ b/src/libcamera/pipeline/raspberrypi/data/meson.build\n@@ -0,0 +1,8 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+conf_files = files([\n+ 'example.yaml',\n+])\n+\n+install_data(conf_files,\n+ install_dir : pipeline_data_dir / 'raspberrypi')\ndiff --git a/src/libcamera/pipeline/raspberrypi/meson.build b/src/libcamera/pipeline/raspberrypi/meson.build\nindex 6064a3f00122..59e8fb18c555 100644\n--- a/src/libcamera/pipeline/raspberrypi/meson.build\n+++ b/src/libcamera/pipeline/raspberrypi/meson.build\n@@ -6,3 +6,5 @@ libcamera_sources += files([\n 'raspberrypi.cpp',\n 'rpi_stream.cpp',\n ])\n+\n+subdir('data')\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 44b1727678c7..83e82bd2880d 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -14,6 +14,7 @@\n #include <unordered_set>\n #include <utility>\n \n+#include <libcamera/base/file.h>\n #include <libcamera/base/shared_fd.h>\n #include <libcamera/base/utils.h>\n \n@@ -39,6 +40,7 @@\n #include \"libcamera/internal/media_device.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n #include \"libcamera/internal/v4l2_videodevice.h\"\n+#include \"libcamera/internal/yaml_parser.h\"\n \n #include \"delayed_controls.h\"\n #include \"dma_heaps.h\"\n@@ -1154,6 +1156,7 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request)\n \t\t\t */\n \t\t\tstream->setExternalBuffer(buffer);\n \t\t}\n+\n \t\t/*\n \t\t * If no buffer is provided by the request for this stream, we\n \t\t * queue a nullptr to the stream to signify that it must use an\n@@ -1687,6 +1690,48 @@ int RPiCameraData::loadPipelineConfiguration()\n \t\t.minTotalUnicamBuffers = 4,\n \t};\n \n+\tchar const *configFromEnv = utils::secure_getenv(\"LIBCAMERA_RPI_CONFIG_FILE\");\n+\tif (!configFromEnv || *configFromEnv == '\\0')\n+\t\treturn 0;\n+\n+\tstd::string filename = std::string(configFromEnv);\n+\tFile file(filename);\n+\n+\tif (!file.open(File::OpenModeFlag::ReadOnly)) {\n+\t\tLOG(RPI, Error) << \"Failed to open configuration file '\" << filename << \"'\";\n+\t\treturn -EIO;\n+\t}\n+\n+\tLOG(RPI, Info) << \"Using configuration file '\" << filename << \"'\";\n+\n+\tstd::unique_ptr<YamlObject> root = YamlParser::parse(file);\n+\tif (!root) {\n+\t\tLOG(RPI, Warning) << \"Failed to parse configuration file, using defaults\";\n+\t\treturn 0;\n+\t}\n+\n+\tstd::optional<double> ver = (*root)[\"version\"].get<double>();\n+\tif (!ver || *ver != 1.0) {\n+\t\tLOG(RPI, Error) << \"Unexpected configuration file version reported\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tconst YamlObject &phConfig = (*root)[\"pipeline_handler\"];\n+\tconfig_.minUnicamBuffers =\n+\t\tphConfig[\"min_unicam_buffers\"].get<unsigned int>(config_.minUnicamBuffers);\n+\tconfig_.minTotalUnicamBuffers =\n+\t\tphConfig[\"min_total_unicam_buffers\"].get<unsigned int>(config_.minTotalUnicamBuffers);\n+\n+\tif (config_.minTotalUnicamBuffers < config_.minUnicamBuffers) {\n+\t\tLOG(RPI, Error) << \"Invalid configuration: min_total_unicam_buffers must be >= min_unicam_buffers\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (config_.minTotalUnicamBuffers < 1) {\n+\t\tLOG(RPI, Error) << \"Invalid configuration: min_total_unicam_buffers must be >= 1\";\n+\t\treturn -EINVAL;\n+\t}\n+\n \treturn 0;\n }\n \n", "prefixes": [ "libcamera-devel", "v6", "07/15" ] }