Patch Detail
Show a patch.
GET /api/1.1/patches/14197/?format=api
{ "id": 14197, "url": "https://patchwork.libcamera.org/api/1.1/patches/14197/?format=api", "web_url": "https://patchwork.libcamera.org/patch/14197/", "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": "<20211020110825.12902-5-david.plowman@raspberrypi.com>", "date": "2021-10-20T11:08:22", "name": "[libcamera-devel,v3,4/7] libcamera: Support passing ColorSpaces to V4L2 video devices", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "a6e77c51d2d546d68f539eaba947eba86cefda42", "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/14197/mbox/", "series": [ { "id": 2641, "url": "https://patchwork.libcamera.org/api/1.1/series/2641/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2641", "date": "2021-10-20T11:08:18", "name": "Colour spaces", "version": 3, "mbox": "https://patchwork.libcamera.org/series/2641/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/14197/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/14197/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 1F2E3C324E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 20 Oct 2021 11:08:36 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3A93868F6D;\n\tWed, 20 Oct 2021 13:08:34 +0200 (CEST)", "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 8767768F60\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Oct 2021 13:08:30 +0200 (CEST)", "by mail-wm1-x334.google.com with SMTP id\n\to24-20020a05600c511800b0030d9da600aeso9268614wms.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Oct 2021 04:08:30 -0700 (PDT)", "from pi4-davidp.pitowers.org\n\t([2a00:1098:3142:14:1ce1:9965:4328:89c4])\n\tby smtp.gmail.com with ESMTPSA id\n\tf20sm1929654wmq.38.2021.10.20.04.08.29\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 20 Oct 2021 04:08:29 -0700 (PDT)" ], "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=\"kkqQDXkN\"; 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=PmSettw5PZPQKCMg1GXcyVLAY5F5dDI8K7YMj39hOXU=;\n\tb=kkqQDXkNoNzRKqzd3EONW9P2UpV4v4fxDeapviwEre0wn72lSOi+CfQAveTU3jym0B\n\tsLfY8a3WP57s66oARuBTxMFNkyztaucQNdB1ynMk0BYNIMNFnguFn8rJMYTZuvFwWCvq\n\tGcC2iY3/bnr/N+v2waHSs73+CSTA8hnv5s0n/LS3sKcv6N2MSvDstXSCheQixDcnkuLE\n\t8ACwBLzGImnDxOpVVrW73uIhKIFx/eDixLevYiv7GIzzkbGF1L0/j7zs5TauYqzdoiWf\n\twXnBz/JqtJr3gPy/uwsVXKJzVjTSk0Oke/pIArSTDQT1YSR66VjdqRPPNMcf+jxuw8iY\n\tk/BA==", "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=PmSettw5PZPQKCMg1GXcyVLAY5F5dDI8K7YMj39hOXU=;\n\tb=SgXYDcjzDKZfhPXfiQZGr2f7ruEpesl0pOAEzLB16W9CO/wFYyQALM+x0TNRHiYktb\n\tEEC7uoA96Vl/t5iPwypB4QY2TIbWC5u123oydnYgyBcESO7a9INIqkqnhoTzs6inIECn\n\to8mLg0o4yOqUKWKHtix60vj0Ot5yZZfE+ybU6JBCwQiPgy8mA+32vP8NgkkD4absYUbF\n\t1nemmokYN19yT8Zan8k39hVQCEAr3M3NYd38q5eAlDR5bEvH3XUXa4k1MO8iPyAKzNbA\n\t00tgmSmX8K4fOI7udj4KuBJiiCitWy2S+v+8gcT2CiDbZLVf8BkmVrIS0I0bSweip4q/\n\tqNHg==", "X-Gm-Message-State": "AOAM530j3chXhpKmk+le5nzKQisMd1ScRdogXwyVMAXTfTbjbF6g3CA9\n\txiDRpHRRsiYVVOrEnEp0tpL8hDcrXFQseg==", "X-Google-Smtp-Source": "ABdhPJzDBxB+yRm43whssvSG72Ab49iOxzXVLJ0IBo0n/kirXlsReck+Kyp52NY8XnNs6BJvn2ieFg==", "X-Received": "by 2002:a1c:cc09:: with SMTP id\n\th9mr13084187wmb.191.1634728109947; \n\tWed, 20 Oct 2021 04:08:29 -0700 (PDT)", "From": "David Plowman <david.plowman@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 20 Oct 2021 12:08:22 +0100", "Message-Id": "<20211020110825.12902-5-david.plowman@raspberrypi.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20211020110825.12902-1-david.plowman@raspberrypi.com>", "References": "<20211020110825.12902-1-david.plowman@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 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 | 69 +++++++++++++++++--\n 2 files changed, 66 insertions(+), 5 deletions(-)", "diff": "diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex efe34d47..34cc9cdd 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@@ -163,6 +164,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 ba5f88cd..9e57e257 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -364,11 +364,6 @@ bool V4L2BufferCache::Entry::operator==(const FrameBuffer &buffer) const\n * \\brief The plane line stride (in bytes)\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@@ -377,6 +372,23 @@ bool V4L2BufferCache::Entry::operator==(const FrameBuffer &buffer) const\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::colorSpace\n+ * \\brief The color space of the pixels\n+ *\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 * \\var V4L2DeviceFormat::planes\n * \\brief The per-plane memory size information\n@@ -873,6 +885,12 @@ int V4L2VideoDevice::getFormatMultiplane(V4L2DeviceFormat *format)\n \tformat->fourcc = V4L2PixelFormat(pix->pixelformat);\n \tformat->planesCount = pix->num_planes;\n \n+\tformat->colorSpace = v4l2ToColorSpace(*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@@ -887,6 +905,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@@ -894,6 +917,12 @@ int V4L2VideoDevice::trySetFormatMultiplane(V4L2DeviceFormat *format, bool set)\n \tpix->num_planes = format->planesCount;\n \tpix->field = V4L2_FIELD_NONE;\n \n+\tret = colorSpaceToV4l2(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@@ -922,6 +951,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 = v4l2ToColorSpace(*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@@ -945,6 +980,12 @@ int V4L2VideoDevice::getFormatSingleplane(V4L2DeviceFormat *format)\n \tformat->planes[0].bpl = pix->bytesperline;\n \tformat->planes[0].size = pix->sizeimage;\n \n+\tformat->colorSpace = v4l2ToColorSpace(*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@@ -954,12 +995,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 = colorSpaceToV4l2(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@@ -979,6 +1032,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 = v4l2ToColorSpace(*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", "v3", "4/7" ] }