Show a patch.

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

{
    "id": 15048,
    "url": "https://patchwork.libcamera.org/api/patches/15048/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/15048/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20211206105032.13876-8-david.plowman@raspberrypi.com>",
    "date": "2021-12-06T10:50:30",
    "name": "[libcamera-devel,v9,7/8] libcamera: Add validateColorSpaces to CameraConfiguration class",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "4e3f6328b4c9d8c9ee83cdc94869b9ab99dd9cce",
    "submitter": {
        "id": 42,
        "url": "https://patchwork.libcamera.org/api/people/42/?format=api",
        "name": "David Plowman",
        "email": "david.plowman@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/15048/mbox/",
    "series": [
        {
            "id": 2817,
            "url": "https://patchwork.libcamera.org/api/series/2817/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2817",
            "date": "2021-12-06T10:50:23",
            "name": "Colour spaces",
            "version": 9,
            "mbox": "https://patchwork.libcamera.org/series/2817/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/15048/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/15048/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 BC887BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  6 Dec 2021 10:51:31 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 64AD560872;\n\tMon,  6 Dec 2021 11:51:31 +0100 (CET)",
            "from mail-wm1-x335.google.com (mail-wm1-x335.google.com\n\t[IPv6:2a00:1450:4864:20::335])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 96C2760882\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  6 Dec 2021 11:51:25 +0100 (CET)",
            "by mail-wm1-x335.google.com with SMTP id\n\taz34-20020a05600c602200b0033bf8662572so7328657wmb.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 06 Dec 2021 02:51:25 -0800 (PST)",
            "from pi4-davidp.pitowers.org\n\t([2a00:1098:3142:14:1ce1:9965:4328:89c4])\n\tby smtp.gmail.com with ESMTPSA id\n\tr7sm10878186wrq.29.2021.12.06.02.51.24\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 06 Dec 2021 02:51:24 -0800 (PST)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"QvfVYvKD\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=tv3O2cAwn+Kn6H1MBehwoCfF/wdQzrC35hxIG5RHyWI=;\n\tb=QvfVYvKD7oPnr4rLWDite3Xu2xnCv67rZV0E3i8R1CIRnjtfSzB2FbXnRiYPQW803n\n\tTIVGlDv8h9TBFruetqQDxgx7LwUyMpEsfxh4dnsMDBNqpbFirCt1jWcTm678v7TpHoPw\n\tex07iUGlFSybpP+0R9KkHwP/pUopLMXcfkcr0iiZ93qq74MRTwRevk8TW1CPJkgh5x6Z\n\trKK4LwtKYgy6wWkn9THhyBX3Tohb16vvSD5tHYY+MG18fnqKA7MbjRLJnvsYqI/Lj4iz\n\tKaK1E5Od7lTqa0p/r6zR7fLP0vjsndqCirh/mW/fIDpTX/WmygmiNEGXjbLb6yGgQZOm\n\tN7uA==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=tv3O2cAwn+Kn6H1MBehwoCfF/wdQzrC35hxIG5RHyWI=;\n\tb=NvlDk21y/0KeONqikbaKF8kYJTvH6UyNJuo2SYLPw8Fvr2FNKHapOMGKVbqMJRSty2\n\t72VwNWdtIWJFrN9DphLDogpyToNUxYL9kr40Q1Fzg/uGoM+wxFS8qtGx0UEmYtsJa1Kh\n\t7F38RwD73VVkEacwJIhQalIT551vIIvxA4Lx9zmJI77UFc3aM3ZJXaC2OGvq1LbnbVt4\n\tMyR84E1CV4ZPl+P9hWFfLzoPxzC2UpUp7NNndmkMS3KsBkggqtEMmrFsvCJClyy3ZUrd\n\ti9lrkrjojbvDmy8pTlBMloGtUKo+oOqlCkVH2c+VfbHEwi0gvX3zgdujxIUty3nuvfQs\n\tX/PA==",
        "X-Gm-Message-State": "AOAM533IS/ynXsWg6Pm+EdHLbSk1kUxBpXnsn6MB3zCpt2SxkhB08Rw+\n\tRV9s/j1h7YqYDkFKuDv20D1rKcR/3p1P4nh+",
        "X-Google-Smtp-Source": "ABdhPJyT89CBV3D6FitkSCS9gqNX/NlMSgadA9P9qpGfVWlqqOcExiMYkIHVBtKVEJpJtYfJz9j5Rw==",
        "X-Received": "by 2002:a05:600c:350a:: with SMTP id\n\th10mr22752368wmq.62.1638787885135; \n\tMon, 06 Dec 2021 02:51:25 -0800 (PST)",
        "From": "David Plowman <david.plowman@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org, naush@raspberrypi.com,\n\tjacopo@jmondi.org, tfiga@google.com, hverkuil-cisco@xs4all.nl,\n\tkieran.bingham@ideasonboard.com, laurent.pinchart@ideasonboard.com",
        "Date": "Mon,  6 Dec 2021 10:50:30 +0000",
        "Message-Id": "<20211206105032.13876-8-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20211206105032.13876-1-david.plowman@raspberrypi.com>",
        "References": "<20211206105032.13876-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v9 7/8] libcamera: Add validateColorSpaces\n\tto CameraConfiguration class",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "This method forces raw streams to have the \"raw\" color space, and also\noptionally makes all output streams to share the same color space as\nsome platforms may require this.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/camera.h |  2 ++\n src/libcamera/camera.cpp   | 59 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 61 insertions(+)",
    "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex a7759ccb..fdcb66ab 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -69,6 +69,8 @@ public:\n protected:\n \tCameraConfiguration();\n \n+\tStatus validateColorSpaces(bool shareOutputColorSpaces);\n+\n \tstd::vector<StreamConfiguration> config_;\n };\n \ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 400a7cf0..388af4f7 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -14,12 +14,14 @@\n #include <libcamera/base/log.h>\n #include <libcamera/base/thread.h>\n \n+#include <libcamera/color_space.h>\n #include <libcamera/framebuffer_allocator.h>\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n \n #include \"libcamera/internal/camera.h\"\n #include \"libcamera/internal/camera_controls.h\"\n+#include \"libcamera/internal/formats.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n \n /**\n@@ -314,6 +316,63 @@ std::size_t CameraConfiguration::size() const\n \treturn config_.size();\n }\n \n+static bool isRaw(const PixelFormat &pixFmt)\n+{\n+\tconst PixelFormatInfo &info = PixelFormatInfo::info(pixFmt);\n+\treturn info.isValid() &&\n+\t       info.colourEncoding == PixelFormatInfo::ColourEncodingRAW;\n+}\n+\n+/**\n+ * \\brief Check and update the color spaces requested for each stream\n+ * \\param[in] shareOutputColorSpaces Force all non-raw output streams to share\n+ * the same color space\n+ *\n+ * This function performs certain consistency checks on the color spaces of\n+ * the streams and may adjust them so that:\n+ *\n+ * - Any raw streams have the Raw color space\n+ * - If shareOutputColorSpaces is set, all output streams are forced to share\n+ * the same color space (this may be a constraint on some platforms).\n+ *\n+ * It is optional for a pipeline handler to use this method.\n+ *\n+ * \\return A CameraConfiguration::Status value that describes the validation\n+ * status (same as CameraConfiguration::validate).\n+ */\n+CameraConfiguration::Status CameraConfiguration::validateColorSpaces(bool shareOutputColorSpaces)\n+{\n+\tStatus status = Valid;\n+\n+\t/*\n+\t * Set all raw streams to the Raw color space, and make a note of the largest\n+\t * non-raw stream with a defined color space (if there is one).\n+\t */\n+\tint index = -1;\n+\tfor (auto [i, cfg] : utils::enumerate(config_)) {\n+\t\tif (isRaw(cfg.pixelFormat) && cfg.colorSpace != ColorSpace::Raw) {\n+\t\t\tcfg.colorSpace = ColorSpace::Raw;\n+\t\t\tstatus = Adjusted;\n+\t\t}\n+\t\telse if (cfg.colorSpace && (index == -1 || cfg.size > config_[i].size))\n+\t\t\tindex = i;\n+\t}\n+\n+\tif (index < 0 || !shareOutputColorSpaces)\n+\t\treturn status;\n+\n+\t/* Make all output color spaces the same, if requested. */\n+\tfor (auto &cfg : config_) {\n+\t\tif (!isRaw(cfg.pixelFormat) &&\n+\t\t    cfg.colorSpace != config_[index].colorSpace) {\n+\t\t\tcfg.colorSpace = config_[index].colorSpace;\n+\t\t\tstatus = Adjusted;\n+\t\t}\n+\t}\n+\n+\treturn status;\n+}\n+\n /**\n  * \\var CameraConfiguration::transform\n  * \\brief User-specified transform to be applied to the image\n",
    "prefixes": [
        "libcamera-devel",
        "v9",
        "7/8"
    ]
}