Show a patch.

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

{
    "id": 14610,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/14610/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14610/",
    "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": "<20211115161205.24335-5-david.plowman@raspberrypi.com>",
    "date": "2021-11-15T16:12:02",
    "name": "[libcamera-devel,v5,4/7] libcamera: Support passing ColorSpaces to V4L2 video devices",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "99f912e6377bc8e54c18349f7bac7f3b0d8351d9",
    "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/14610/mbox/",
    "series": [
        {
            "id": 2719,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2719/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2719",
            "date": "2021-11-15T16:11:58",
            "name": "Colour spaces",
            "version": 5,
            "mbox": "https://patchwork.libcamera.org/series/2719/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14610/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14610/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 8B57AC324E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 15 Nov 2021 16:13:08 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 111066036C;\n\tMon, 15 Nov 2021 17:13:08 +0100 (CET)",
            "from mail-wm1-x334.google.com (mail-wm1-x334.google.com\n\t[IPv6:2a00:1450:4864:20::334])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1DCA260378\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 15 Nov 2021 17:13:01 +0100 (CET)",
            "by mail-wm1-x334.google.com with SMTP id\n\tr9-20020a7bc089000000b00332f4abf43fso177805wmh.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 15 Nov 2021 08:13:01 -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\tj40sm16315615wms.16.2021.11.15.08.12.59\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 15 Nov 2021 08:13:00 -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=\"mvdIQrCX\"; 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=3jzpKNdq0T31XWyv1nf4OXskRk3Z5TSZ2eDhnU9oflA=;\n\tb=mvdIQrCXL/yZe6pnmvRy+iXbwl1nl/NTwTjw2kn3QgD2ZskZFRwtUqO/BhyRxX3nz+\n\tYdG0KtpTKCyCmG3qaIuPOMR0c6IJsW9bCRi2QT+tYbePTKyWl7VlZx+ap3PmN2+jX6LN\n\t+pa4D2fojI8xNFvV9HA9D3iVk6pBShkH6Sd1v8JjlHSy2WtYEYYI9Iy34BS2ZheSEMiA\n\tMNSDnoF/BXqIFvbUe4GLhiNtNbnxPEkBdE7KVkhrx4NL8yX3XrT+RCeCsAWMUo6vtvPE\n\tflphFKNGsVCBOHpiReNwwPCgWZvmYsDS+3ndT0fKd63/9XUPNVZJf/f6he8ZTDVs+rqQ\n\t3qzg==",
        "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=3jzpKNdq0T31XWyv1nf4OXskRk3Z5TSZ2eDhnU9oflA=;\n\tb=2OiwbLc8Bx+kH9cnRlEyDwXW6hwCvxfCqFOq15aP3xyYL9hGA2miiASrtIN/Jlgmq0\n\tq1PLPTzZM2he+ZSmlbqk68WND7Inzlg0M+gdqZf0WFSh0FLproJ/pNsbFwvRlRa//jod\n\tFVS4xWfLg9pvDGHBR0jMe7VVeXVmkIx/9ixYuVmjUs5gAaKRdD4282ItmePoPWLYaBA7\n\tWuLSF69FBm05fQ5tMMKIWFNF5zabrEihk1pGbFygGE4gBL5Uj1/cK0l2qhJ+W1Al8AkH\n\t04nrsK1kfUe27DCPBQEdt3iWDNZTz19GZEw+O75IJ8/vCgtInjLjFaIsri4pgA8cpWCq\n\tcDRQ==",
        "X-Gm-Message-State": "AOAM530yvoZuLoERFe/pDd4b0pkg7g4w0yM5+oUrPU+3cpfSpU/RrAdH\n\tBX4Zxme5mK14xF1sYOi6yz7u7w==",
        "X-Google-Smtp-Source": "ABdhPJypEF3n80Zva1HokmHj0j/FgyLvwk0y2/wqcaHgmKpDGLy1STTNgLkpYFUyz88RRSQcmS1hMw==",
        "X-Received": "by 2002:a7b:c102:: with SMTP id\n\tw2mr60289070wmi.151.1636992780675; \n\tMon, 15 Nov 2021 08:13:00 -0800 (PST)",
        "From": "David Plowman <david.plowman@raspberrypi.com>",
        "To": "hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com,\n\tkieran.bingham@ideasonboard.com, jacopo@jmondi.org, tfiga@google.com, \n\tnaush@raspberrypi.com, libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 15 Nov 2021 16:12:02 +0000",
        "Message-Id": "<20211115161205.24335-5-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20211115161205.24335-1-david.plowman@raspberrypi.com>",
        "References": "<20211115161205.24335-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v5 4/7] libcamera: Support passing\n\tColorSpaces to V4L2 video devices",
        "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 V4L2VideoDevice.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n include/libcamera/internal/v4l2_videodevice.h |  2 +\n src/libcamera/v4l2_videodevice.cpp            | 67 +++++++++++++++++--\n 2 files changed, 65 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex a1c458e4..6ca749c1 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -20,6 +20,7 @@\n #include <libcamera/base/log.h>\n #include <libcamera/base/signal.h>\n \n+#include <libcamera/color_space.h>\n #include <libcamera/framebuffer.h>\n #include <libcamera/geometry.h>\n #include <libcamera/pixel_format.h>\n@@ -167,6 +168,7 @@ public:\n \n \tV4L2PixelFormat fourcc;\n \tSize size;\n+\tColorSpace colorSpace;\n \n \tstd::array<Plane, 3> planes;\n \tunsigned int planesCount = 0;\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 4f04212d..ccf3d28c 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -370,17 +370,29 @@ bool V4L2BufferCache::Entry::operator==(const FrameBuffer &buffer) const\n  * \\brief The plane line stride (in bytes)\n  */\n \n+/**\n+ * \\var V4L2DeviceFormat::fourcc\n+ * \\brief The fourcc code describing the pixel encoding scheme\n+ *\n+ * The fourcc code, as defined by the V4L2 API with the V4L2_PIX_FMT_* macros,\n+ * that identifies the image format pixel encoding scheme.\n+ */\n+\n /**\n  * \\var V4L2DeviceFormat::size\n  * \\brief The image size in pixels\n  */\n \n /**\n- * \\var V4L2DeviceFormat::fourcc\n- * \\brief The fourcc code describing the pixel encoding scheme\n+ * \\var V4L2DeviceFormat::colorSpace\n+ * \\brief The color space of the pixels\n  *\n- * The fourcc code, as defined by the V4L2 API with the V4L2_PIX_FMT_* macros,\n- * that identifies the image format pixel encoding scheme.\n+ * When setting or trying a format, passing in \"Undefined\" fields in the\n+ * ColorSpace is not permitted because the driver will then make an\n+ * arbitrary choice of its own. Choices made by the driver will be\n+ * passed back in the normal way, though note that \"Undefined\" values can\n+ * be returned if the device has chosen something that the ColorSpace\n+ * class cannot represent.\n  */\n \n /**\n@@ -879,6 +891,12 @@ int V4L2VideoDevice::getFormatMultiplane(V4L2DeviceFormat *format)\n \tformat->fourcc = V4L2PixelFormat(pix->pixelformat);\n \tformat->planesCount = pix->num_planes;\n \n+\tformat->colorSpace = toColorSpace(*pix);\n+\tif (!format->colorSpace.isFullyDefined())\n+\t\tLOG(V4L2, Warning)\n+\t\t\t<< \"Retrieved undefined color space: \"\n+\t\t\t<< format->colorSpace.toString();\n+\n \tfor (unsigned int i = 0; i < format->planesCount; ++i) {\n \t\tformat->planes[i].bpl = pix->plane_fmt[i].bytesperline;\n \t\tformat->planes[i].size = pix->plane_fmt[i].sizeimage;\n@@ -893,6 +911,11 @@ int V4L2VideoDevice::trySetFormatMultiplane(V4L2DeviceFormat *format, bool set)\n \tstruct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;\n \tint ret;\n \n+\tif (!format->colorSpace.isFullyDefined())\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Trying to set undefined color space: \"\n+\t\t\t<< format->colorSpace.toString();\n+\n \tv4l2Format.type = bufferType_;\n \tpix->width = format->size.width;\n \tpix->height = format->size.height;\n@@ -900,6 +923,12 @@ int V4L2VideoDevice::trySetFormatMultiplane(V4L2DeviceFormat *format, bool set)\n \tpix->num_planes = format->planesCount;\n \tpix->field = V4L2_FIELD_NONE;\n \n+\tret = fromColorSpace(format->colorSpace, *pix);\n+\tif (ret < 0)\n+\t\tLOG(V4L2, Warning)\n+\t\t\t<< \"Setting color space unrecognised by V4L2: \"\n+\t\t\t<< format->colorSpace.toString();\n+\n \tASSERT(pix->num_planes <= std::size(pix->plane_fmt));\n \n \tfor (unsigned int i = 0; i < pix->num_planes; ++i) {\n@@ -928,6 +957,12 @@ int V4L2VideoDevice::trySetFormatMultiplane(V4L2DeviceFormat *format, bool set)\n \t\tformat->planes[i].size = pix->plane_fmt[i].sizeimage;\n \t}\n \n+\tformat->colorSpace = toColorSpace(*pix);\n+\tif (!format->colorSpace.isFullyDefined())\n+\t\tLOG(V4L2, Warning)\n+\t\t\t<< \"Undefined color space has been set: \"\n+\t\t\t<< format->colorSpace.toString();\n+\n \treturn 0;\n }\n \n@@ -951,6 +986,12 @@ int V4L2VideoDevice::getFormatSingleplane(V4L2DeviceFormat *format)\n \tformat->planes[0].bpl = pix->bytesperline;\n \tformat->planes[0].size = pix->sizeimage;\n \n+\tformat->colorSpace = toColorSpace(*pix);\n+\tif (!format->colorSpace.isFullyDefined())\n+\t\tLOG(V4L2, Warning)\n+\t\t\t<< \"Retrieved undefined color space: \"\n+\t\t\t<< format->colorSpace.toString();\n+\n \treturn 0;\n }\n \n@@ -960,12 +1001,24 @@ int V4L2VideoDevice::trySetFormatSingleplane(V4L2DeviceFormat *format, bool set)\n \tstruct v4l2_pix_format *pix = &v4l2Format.fmt.pix;\n \tint ret;\n \n+\tif (!format->colorSpace.isFullyDefined())\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Trying to set undefined color space: \"\n+\t\t\t<< format->colorSpace.toString();\n+\n \tv4l2Format.type = bufferType_;\n \tpix->width = format->size.width;\n \tpix->height = format->size.height;\n \tpix->pixelformat = format->fourcc;\n \tpix->bytesperline = format->planes[0].bpl;\n \tpix->field = V4L2_FIELD_NONE;\n+\n+\tret = fromColorSpace(format->colorSpace, *pix);\n+\tif (ret < 0)\n+\t\tLOG(V4L2, Warning)\n+\t\t\t<< \"Set color space unrecognised by V4L2: \"\n+\t\t\t<< format->colorSpace.toString();\n+\n \tret = ioctl(set ? VIDIOC_S_FMT : VIDIOC_TRY_FMT, &v4l2Format);\n \tif (ret) {\n \t\tLOG(V4L2, Error)\n@@ -985,6 +1038,12 @@ int V4L2VideoDevice::trySetFormatSingleplane(V4L2DeviceFormat *format, bool set)\n \tformat->planes[0].bpl = pix->bytesperline;\n \tformat->planes[0].size = pix->sizeimage;\n \n+\tformat->colorSpace = toColorSpace(*pix);\n+\tif (!format->colorSpace.isFullyDefined())\n+\t\tLOG(V4L2, Warning)\n+\t\t\t<< \"Undefined color space has been set: \"\n+\t\t\t<< format->colorSpace.toString();\n+\n \treturn 0;\n }\n \n",
    "prefixes": [
        "libcamera-devel",
        "v5",
        "4/7"
    ]
}