Patch Detail
Show a patch.
GET /api/patches/14428/?format=api
{ "id": 14428, "url": "https://patchwork.libcamera.org/api/patches/14428/?format=api", "web_url": "https://patchwork.libcamera.org/patch/14428/", "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": "<20211029132343.1629-5-david.plowman@raspberrypi.com>", "date": "2021-10-29T13:23:40", "name": "[libcamera-devel,v4,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/people/42/?format=api", "name": "David Plowman", "email": "david.plowman@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/14428/mbox/", "series": [ { "id": 2682, "url": "https://patchwork.libcamera.org/api/series/2682/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2682", "date": "2021-10-29T13:23:36", "name": "Colour spaces", "version": 4, "mbox": "https://patchwork.libcamera.org/series/2682/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/14428/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/14428/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 965F6BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 29 Oct 2021 13:23:57 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4BD9160125;\n\tFri, 29 Oct 2021 15:23:57 +0200 (CEST)", "from mail-wr1-x429.google.com (mail-wr1-x429.google.com\n\t[IPv6:2a00:1450:4864:20::429])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A9C8C600B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 29 Oct 2021 15:23:49 +0200 (CEST)", "by mail-wr1-x429.google.com with SMTP id i5so8493028wrb.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 29 Oct 2021 06:23:49 -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\tl7sm111934wrf.31.2021.10.29.06.23.48\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 29 Oct 2021 06:23:48 -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=\"ocC45q5F\"; 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=ocC45q5F/IvL9+8Khthxc5N/qZocfzQ5zm2z5hYBcAIGkFK92tn5Pk9cPUkR1mXBtY\n\tt8Gmfrwb6sEXk9qfVbVXVaCiLMN98o/JtQ15lhmNn1UowCEUwfW7AsKQvIsNNrChklzP\n\tL0e+1F2PSYac1QlAkZxA2W1zruRsWIgWkkMmYHp94FHagpYnOtULviP/w0sFoUSrWL8w\n\tInULuBQbxt62jYsmi6bKzRSjx6xdcbVmHNCN2S//7p0fOyVi2IJuCjpddJnBSnvSnSa6\n\to6Q6AH+G4+M32HhIOWRrzD92aCb4/E6r/DZC1q3/cs02voL1m+egOs/Cz5ktPzTAW9bF\n\tViYw==", "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=WSNFbm+BzAW7YyPMUQcOFON3yGq89H6J8gkwyko67MMkVe0G2iknP26wUKnGYGDvMT\n\tzKIW9NkZRRSpT7VmmU06qPCakb9PhzW86OWIqmcV0/NLaZeiBPSI+DpULvSdI9Szyn6B\n\tq9s1zw9T/xvS1fVZpU/sDlxyt0Q2AtgEuIPIpthYz7s7Akqy6xCCizt0mFvrQv8kyFux\n\tfXz20CkZ0zyZPY9BUqLLuYf6OboLQFEXPOmvgSitaLLI11/Zgxzp9FdvHOXWfFTllHhx\n\tN+ct0ba6niQrTkmcS8J/8EVPc2Cy4qyZA2Af6ry6l5BqVNF7ZNIDksNKzAk3f92MoRcy\n\tY2hQ==", "X-Gm-Message-State": "AOAM533o4Lr1y66Hi89zwXIop7fmPRVHS7bzCXv9dUNmWdWfaOVkQTQG\n\t7syWYkX7bW1H5BTkR0awPH7BrEGkTqmX2A==", "X-Google-Smtp-Source": "ABdhPJwLmE4nwlQNakyRBSRFxHmEjK+rDPDC8u5xJ1NNrWS7tfw5OCWliRrM2piD9ktSHArYYK9xSA==", "X-Received": "by 2002:a5d:4845:: with SMTP id\n\tn5mr14106615wrs.251.1635513829031; \n\tFri, 29 Oct 2021 06:23:49 -0700 (PDT)", "From": "David Plowman <david.plowman@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 29 Oct 2021 14:23:40 +0100", "Message-Id": "<20211029132343.1629-5-david.plowman@raspberrypi.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20211029132343.1629-1-david.plowman@raspberrypi.com>", "References": "<20211029132343.1629-1-david.plowman@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 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", "v4", "4/7" ] }