Show a patch.

GET /api/1.1/patches/18134/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 18134,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/18134/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/18134/",
    "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": "<20230118085953.7027-8-naush@raspberrypi.com>",
    "date": "2023-01-18T08:59:48",
    "name": "[libcamera-devel,v5,07/12] pipeline: raspberrypi: Read config parameters from a file",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "c2849df915f8a248dc7bd604590f6c8b34696a28",
    "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/18134/mbox/",
    "series": [
        {
            "id": 3713,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3713/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3713",
            "date": "2023-01-18T08:59:41",
            "name": "Raspberry Pi: Platform configuration and buffer allocation improvements",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/3713/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/18134/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/18134/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 3BEBFC3294\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 18 Jan 2023 09:01:27 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C72C9625E8;\n\tWed, 18 Jan 2023 10:01:26 +0100 (CET)",
            "from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com\n\t[IPv6:2a00:1450:4864:20::42f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BA893625F3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Jan 2023 10:01:20 +0100 (CET)",
            "by mail-wr1-x42f.google.com with SMTP id e3so23962098wru.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 18 Jan 2023 01:01:20 -0800 (PST)",
            "from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\ti6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.19\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 18 Jan 2023 01:01:19 -0800 (PST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1674032486;\n\tbh=2BVu3khsD0IidZZis0CYJfsB9vWYAIIJPnK1/awr90k=;\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=f3e7CkYa/wLAY+fXha/699TgzJf2/ZU1Z5NlAkEbMl/nuVRfmYtgYuoOQtTGcsMJx\n\t21biNK4yrvzTV+wI6jdUmijke9c0jjLjtUYKBmjV+W8fAxPbMKchetpwJXJXerlLRs\n\t7TluVtIAwSQG38+qFOyJdQl66TbwWL4ui9aAArdhpWNqPjGGkHXNk5whBds3ZBs+2t\n\tdywZhJsVN84epEYx9QrxQ1SgvbfvbXMRanvITZkumD4Pnvw70/OASIyFEDxUNGNsDr\n\tOIPAkUN6AE5pB4tCIbwqC7ZfK9qVsHVO3oCgfh82XkYNQbLPiiRzDmtNlufejaIDno\n\tUv2ysDv9Wc4ww==",
            "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=XEl4otV2Go+V21qaL70bccDWfHDHc7iqcSfag6Wgyg0=;\n\tb=lo9G4s1lzAj4ZiD8InZ/89EoDTI4Fo7rm1b3Mcy8BXPmtbGzK3VzGA654m1/reHUND\n\teYzKX17EkTxmOLR0gvNbn09jOIcBSEltX4fBPeOt3dpxXzPMXB/+q01DsKRQ5/mG4JYv\n\t9TnvSfwOW12PUeSMzV8ElO1e3vUFZSgmYcH8N+GFNswsPx7F+O14bbhonekqRTNoOHP8\n\teUsMEril0UYHrQv0c1QswWthjYyKqOPPaDjF7T6Vv0eDh3Ubbhvaw7T3aObrInJxRCMs\n\tI//YAla4y/r/6ZlQLdr6FCHFvfC3irXfXfpN980retqpPq0cQ75h09roCj/7xiU0umJj\n\tgUsA=="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"lo9G4s1l\"; 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=XEl4otV2Go+V21qaL70bccDWfHDHc7iqcSfag6Wgyg0=;\n\tb=hAFP/wRzk0pM3H71HQVpAJJpdODUWP3cV4POOwKtjAIkdPXbaJYlYOziWnNGAB/HVA\n\twGCtySN95qOwHpTsRv+/ksWalbliUMXyBA6dY23pXA2XjK3I1RcCveMBYgzva+nZTgUJ\n\tsI/Ss7vZpVcrKojEq7GH9Vpx3b8xy5cEcknOmCL5t/rKWJvwwu4k1C25wLW41fToGyLS\n\tODg7YEX+sRZuWICon1b1YHYMseikvZqwG90gQLubL1l8Mv50iHHs2aCaFAK+faOUVepM\n\tgxktAMzvvxUG91jJbGqDbSBxqW62aIAm9F3EuCfUitnPfYlY49/pu1As8+uijPs59idl\n\t+glA==",
        "X-Gm-Message-State": "AFqh2krqHtZYyODhxr5pMbc+c+O2bskFugC0NanHU5gt+cYl+CDUrW3q\n\tww+lshXG6K0unJuei9OW7izgy4BwHC4EOc905Xk=",
        "X-Google-Smtp-Source": "AMrXdXv0RhUSuTIuoAnsK21m0wa9spfyY3GyWK0KavjyJP2DbeRFw9R+6058gQrzrRjbYSaGyQrayA==",
        "X-Received": "by 2002:a05:6000:608:b0:2bd:db84:d663 with SMTP id\n\tbn8-20020a056000060800b002bddb84d663mr1729047wrb.5.1674032479875; \n\tWed, 18 Jan 2023 01:01:19 -0800 (PST)",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 18 Jan 2023 08:59:48 +0000",
        "Message-Id": "<20230118085953.7027-8-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",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v5 07/12] 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 config\nfile provided by the user through the LIBCAMERA_RPI_CONFIG_FILE environment\nvariable. Use the PipelineHandler::configurationFile() helper to determine the\nfull 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\"\nThe minimum number of internal Unicam buffers to allocate.\n\n\"min_total_unicam_buffers\"\nThe minimum number of internal + external Unicam buffers that must be allocated.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n---\n .../pipeline/raspberrypi/data/example.yaml    | 20 +++++++++\n .../pipeline/raspberrypi/data/meson.build     |  8 ++++\n .../pipeline/raspberrypi/meson.build          |  2 +\n .../pipeline/raspberrypi/raspberrypi.cpp      | 45 +++++++++++++++++++\n 4 files changed, 75 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/src/libcamera/pipeline/raspberrypi/data/example.yaml b/src/libcamera/pipeline/raspberrypi/data/example.yaml\nnew file mode 100644\nindex 000000000000..001a906af528\n--- /dev/null\n+++ b/src/libcamera/pipeline/raspberrypi/data/example.yaml\n@@ -0,0 +1,20 @@\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+                \"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+                \"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 6ed4cc2c7ba7..2b396f1db9b6 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@@ -1150,6 +1152,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@@ -1683,6 +1686,48 @@ int RPiCameraData::configurePipeline()\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, Error) << \"Failed to parse configuration file, using defaults\";\n+\t\treturn -EINVAL;\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",
        "v5",
        "07/12"
    ]
}