Patch Detail
Show a patch.
GET /api/1.1/patches/14198/?format=api
{ "id": 14198, "url": "https://patchwork.libcamera.org/api/1.1/patches/14198/?format=api", "web_url": "https://patchwork.libcamera.org/patch/14198/", "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-6-david.plowman@raspberrypi.com>", "date": "2021-10-20T11:08:23", "name": "[libcamera-devel,v3,5/7] libcamera: Support passing ColorSpaces to V4L2 subdevices", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "39d331e5f3ddc17ee1e6c1c53ee848427078436f", "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/14198/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/14198/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/14198/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 C9EFCBDB1C\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 8C4DD68F6E;\n\tWed, 20 Oct 2021 13:08:36 +0200 (CEST)", "from mail-wm1-x330.google.com (mail-wm1-x330.google.com\n\t[IPv6:2a00:1450:4864:20::330])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1175D68F57\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Oct 2021 13:08:31 +0200 (CEST)", "by mail-wm1-x330.google.com with SMTP id g39so13933242wmp.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 20 Oct 2021 04:08:31 -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.30\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 20 Oct 2021 04:08:30 -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=\"l7axcNvu\"; 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=6J3bCUodDtUau6XCsO6hTiATOA9Y8C5RyfpkX5Sa+sE=;\n\tb=l7axcNvuyqIJkluGDkXypyWd4i2QeQpaho5HxSv9RkZQ6mvQUh8gRhJH2MiFyxB4gA\n\tTrAvqS0r46/B5a6/D1zE7fjzrZ1+z5dKkDyaIcJXo9Q5ju7hSeF6/zXwpNCTf83MdDa3\n\tuENTTJgY0LGk3mmtpc5NBBNjLqUCA+9nNdXQASg6g4WuIovwG6ddBEr6uhWJ5mSKq5OB\n\t8c1dDqoFmIRDe8Th6sWBqc6IFL2uOvcnf90FansYl6w7JJjmhulzRYWhTx1m+SQT1HwF\n\ttY7t6m8C1qjvZb+K3Q46FLrQHR6BHY/0pI6qPRnnxn/gFJ2SJuiL0pisOKzJ5Gr1tely\n\tRTxQ==", "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=6J3bCUodDtUau6XCsO6hTiATOA9Y8C5RyfpkX5Sa+sE=;\n\tb=cMv0NzQc+oZRMd47oSMmfw8W3h92ZWQvIbLncHWW0/8PutNcOVUkEPHr5iPbKI8U8u\n\tvqs69QSeGyMX1mLnlSSCcvvaWDuqwi0zt1QTmjTtojvHW2x4HcD0FLyjhrnMEVRhdOi7\n\tuhyWNxqY4e8m6q7pEVy+EGsm5vBsmBtqWCpsJ0t0tPHJC8vYO1tCgolKtuOoU1xtx4cm\n\tsVpQRxOQUCR5QLrgER2LhbpGO16q/MPScgh2lXjIE0MSBpC/de2/NZRhlAMQJE2qjHwd\n\tZiXrR5eRxQqDcg8w3fdrq78tslHYn6OxWkzMYbDutn1zUju3KH4MZ86MfyIsbgeY2V2o\n\t47Yw==", "X-Gm-Message-State": "AOAM533hZ1HlGMPOxKHz/Z16/XbTRTUh7HUyrDbUV6YjV6mZk9ccl7G8\n\tYJG+Z9FVSe+cGkAXE6nz4gWXAXTXYgdbNg==", "X-Google-Smtp-Source": "ABdhPJwI2dNpUrb96EcAm67nTepnmLcFDVqJtRsHHP7uLzb3G6vWehj7KqlZvn6YZE08EsEAnYBgnw==", "X-Received": "by 2002:a05:6000:2c8:: with SMTP id\n\to8mr50591909wry.430.1634728110570; \n\tWed, 20 Oct 2021 04:08:30 -0700 (PDT)", "From": "David Plowman <david.plowman@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 20 Oct 2021 12:08:23 +0100", "Message-Id": "<20211020110825.12902-6-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 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 | 37 ++++++++++++++++++++-\n 3 files changed, 39 insertions(+), 1 deletion(-)", "diff": "diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\nindex 97b89fb9..f3ab8454 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+\tColorSpace 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..8538e66c 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -168,6 +168,18 @@ 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+ * When setting or trying a format, passing in \"Undefined\" fields in the\n+ * ColorSpace is not recommended 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+ * cannot represent.\n+ */\n+\n /**\n * \\brief Assemble and return a string describing the format\n * \\return A string describing the V4L2SubdeviceFormat\n@@ -400,6 +412,12 @@ 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 = v4l2ToColorSpace(subdevFmt.format);\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@@ -418,6 +436,11 @@ 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.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 \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 = colorSpaceToV4l2(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<< format->colorSpace.toString();\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,12 @@ 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 = v4l2ToColorSpace(subdevFmt.format);\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", "5/7" ] }