Show a patch.

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

{
    "id": 14630,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14630/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14630/",
    "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": "<20211118151933.15627-6-david.plowman@raspberrypi.com>",
    "date": "2021-11-18T15:19:31",
    "name": "[libcamera-devel,v6,5/7] libcamera: Support passing ColorSpaces to V4L2 subdevices",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "1eeaa2ac47b5baf9b06f3c70b91828ade0a6acae",
    "submitter": {
        "id": 42,
        "url": "https://patchwork.libcamera.org/api/1.1/people/42/?format=api",
        "name": "David Plowman",
        "email": "david.plowman@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/14630/mbox/",
    "series": [
        {
            "id": 2726,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2726/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2726",
            "date": "2021-11-18T15:19:26",
            "name": "Colour spaces",
            "version": 6,
            "mbox": "https://patchwork.libcamera.org/series/2726/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14630/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14630/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 95BECC324E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Nov 2021 15:20:36 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 382C9603B5;\n\tThu, 18 Nov 2021 16:20:36 +0100 (CET)",
            "from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com\n\t[IPv6:2a00:1450:4864:20::42d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 824BD60233\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Nov 2021 16:20:29 +0100 (CET)",
            "by mail-wr1-x42d.google.com with SMTP id s13so12280860wrb.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Nov 2021 07:20:29 -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\tp12sm147367wro.33.2021.11.18.07.20.28\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 18 Nov 2021 07:20:28 -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=\"ACkt+fUo\"; 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=H7T104lkfLZPMGxIBUsm1hoLba7o7e864GWa57cAV/Y=;\n\tb=ACkt+fUokvvQHsIy9uFUbhdWJcz3M0oP4GJ8FiQLtjs1vNld/6bXsoHMJaEHDYKwHM\n\t7UGHJ/Q2e2BijL4jCrahi25TfKk2qcPLa/HVcMAZqpIyRJ8vfm8ALpZo5WeIJsj2cank\n\tq6SPjRu3uSp2DzqPRf4PrwvPTl7Xblm+MKv0RsVp+4HoOW4gMOnBpIbWf3ZsvxfxDriZ\n\tFvnpSbyJIpHrHE3k/tM8sgufybZdsInbcXgC9C9gRFkVkTxX6VXOd7npazenpjBd9W0G\n\t1b84KpEzjYsoTv6iB4W5Hw+KbAlQTEYQwHpyZuGme6fySCqh1E7keik7pnzHvEnGhc1F\n\tlc9A==",
        "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=H7T104lkfLZPMGxIBUsm1hoLba7o7e864GWa57cAV/Y=;\n\tb=7cBbDZTsxUrkyvbWU//JuZG6qDD2BCpma1fmgTnhDQnGFYD7gccEJjoiW5m9q31oE8\n\tFjXam2qeh2yhNKdhQz3TDNc2rhEwgEjMtP30GCtCskUbvBHzqBqLyxXKrHKVUYFEtZWm\n\t9sosyR39zDax3YJAFtYmG23feavrNuCjSGEF7K24TClFiuM7j6ptrdaq7QXTg6uAsaPs\n\tY7tAdqc6ek/5lVhuhw9sjQIKSYQpXAGqn4k4trS4F/o+U6QpQCpLW6njyxvwnVyshcma\n\tybMsBY+1V6Ddnp2GqWrqSKb9m29ecim75h+ueAUWb9W+2UY7NK/+82pK7uQglWLE2N1E\n\tR6xQ==",
        "X-Gm-Message-State": "AOAM530MmTReJo6cnSyUj9mrjMIeHnnbIvBIwFSvzGPPZ+MqZf3ujjFa\n\tGdxsMDPNg7XQAgVtJbNc+NxrNw==",
        "X-Google-Smtp-Source": "ABdhPJy/9UgkTFGEUY085nCQBqw+HVOEPD7eaAkbIvZ4PMj+/CulRzgev3pKsRc2wCSBMmvQEwgbuQ==",
        "X-Received": "by 2002:adf:f947:: with SMTP id\n\tq7mr31423192wrr.260.1637248829175; \n\tThu, 18 Nov 2021 07:20:29 -0800 (PST)",
        "From": "David Plowman <david.plowman@raspberrypi.com>",
        "To": "laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com,\n\thverkuil-cisco@xs4all.nl, tfiga@google.com, jacopo@jmondi.org,\n\tnaush@raspberrypi.com, libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 18 Nov 2021 15:19:31 +0000",
        "Message-Id": "<20211118151933.15627-6-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20211118151933.15627-1-david.plowman@raspberrypi.com>",
        "References": "<20211118151933.15627-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v6 5/7] libcamera: Support passing\n\tColorSpaces to V4L2 subdevices",
        "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": "The ColorSpace from the StreamConfiguration is now handled\nappropriately in the V4L2Subdevice.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n include/libcamera/internal/v4l2_subdevice.h |  2 ++\n src/libcamera/camera_sensor.cpp             |  1 +\n src/libcamera/v4l2_subdevice.cpp            | 35 ++++++++++++++++++++-\n 3 files changed, 37 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\nindex 97b89fb9..a6a0a870 100644\n--- a/include/libcamera/internal/v4l2_subdevice.h\n+++ b/include/libcamera/internal/v4l2_subdevice.h\n@@ -14,6 +14,7 @@\n #include <libcamera/base/class.h>\n #include <libcamera/base/log.h>\n \n+#include <libcamera/color_space.h>\n #include <libcamera/geometry.h>\n \n #include \"libcamera/internal/formats.h\"\n@@ -27,6 +28,7 @@ class MediaDevice;\n struct V4L2SubdeviceFormat {\n \tuint32_t mbus_code;\n \tSize size;\n+\tstd::optional<ColorSpace> colorSpace;\n \n \tconst std::string toString() const;\n \tuint8_t bitsPerPixel() const;\ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 9fdb8c09..6fcd1c1d 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -613,6 +613,7 @@ V4L2SubdeviceFormat CameraSensor::getFormat(const std::vector<unsigned int> &mbu\n \tV4L2SubdeviceFormat format{\n \t\t.mbus_code = bestCode,\n \t\t.size = *bestSize,\n+\t\t.colorSpace = ColorSpace::Raw,\n \t};\n \n \treturn format;\ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex 023e2328..b60ab69a 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -168,6 +168,16 @@ const std::map<uint32_t, V4L2SubdeviceFormatInfo> formatInfoMap = {\n  * \\brief The image size in pixels\n  */\n \n+/**\n+ * \\var V4L2SubdeviceFormat::colorSpace\n+ * \\brief The color space of the pixels\n+ *\n+ * The color space of the image. When setting the format this may be\n+ * unset, in which case the driver gets to use its default color space.\n+ * After being set, this value should contain the color space that the\n+ * was actually used.\n+ */\n+\n /**\n  * \\brief Assemble and return a string describing the format\n  * \\return A string describing the V4L2SubdeviceFormat\n@@ -400,6 +410,16 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n \tformat->size.height = subdevFmt.format.height;\n \tformat->mbus_code = subdevFmt.format.code;\n \n+\tformat->colorSpace = toColorSpace(subdevFmt.format);\n+\t/*\n+\t * This warning can be ignored on metadata pads. These are normally\n+\t * pads other than zero.\n+\t * \\todo find a way to detect metadata pads and ignore them\n+\t */\n+\tif (!format->colorSpace)\n+\t\tLOG(V4L2, Warning)\n+\t\t\t<< \"Retrieved unrecognised color space on pad \" << pad;\n+\n \treturn 0;\n }\n \n@@ -418,6 +438,9 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n \t\t\t     Whence whence)\n {\n+\tif (!format->colorSpace)\n+\t\tLOG(V4L2, Error) << \"Setting an undefined color space\";\n+\n \tstruct v4l2_subdev_format subdevFmt = {};\n \tsubdevFmt.which = whence == ActiveFormat ? V4L2_SUBDEV_FORMAT_ACTIVE\n \t\t\t: V4L2_SUBDEV_FORMAT_TRY;\n@@ -427,7 +450,13 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n \tsubdevFmt.format.code = format->mbus_code;\n \tsubdevFmt.format.field = V4L2_FIELD_NONE;\n \n-\tint ret = ioctl(VIDIOC_SUBDEV_S_FMT, &subdevFmt);\n+\tint ret = fromColorSpace(format->colorSpace, subdevFmt.format);\n+\tif (ret < 0)\n+\t\tLOG(V4L2, Warning)\n+\t\t\t<< \"Setting color space unrecognised by V4L2: \"\n+\t\t\t<< ColorSpace::toString(format->colorSpace);\n+\n+\tret = ioctl(VIDIOC_SUBDEV_S_FMT, &subdevFmt);\n \tif (ret) {\n \t\tLOG(V4L2, Error)\n \t\t\t<< \"Unable to set format on pad \" << pad\n@@ -439,6 +468,10 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n \tformat->size.height = subdevFmt.format.height;\n \tformat->mbus_code = subdevFmt.format.code;\n \n+\tformat->colorSpace = toColorSpace(subdevFmt.format);\n+\tif (!format->colorSpace)\n+\t\tLOG(V4L2, Warning) << \"Unrecognised color space has been set\";\n+\n \treturn 0;\n }\n \n",
    "prefixes": [
        "libcamera-devel",
        "v6",
        "5/7"
    ]
}