Show a patch.

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

{
    "id": 21752,
    "url": "https://patchwork.libcamera.org/api/patches/21752/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/21752/",
    "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": "<20241025053111.519449-2-chenghaoyang@chromium.org>",
    "date": "2024-10-25T05:30:13",
    "name": "[v3,1/2] libcamera: Extend u32 control type",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "44cef14929730d534bddb128811c9fb59f1ad2a9",
    "submitter": {
        "id": 117,
        "url": "https://patchwork.libcamera.org/api/people/117/?format=api",
        "name": "Cheng-Hao Yang",
        "email": "chenghaoyang@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/21752/mbox/",
    "series": [
        {
            "id": 4743,
            "url": "https://patchwork.libcamera.org/api/series/4743/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4743",
            "date": "2024-10-25T05:30:12",
            "name": "Add U16 & U32 support in controls",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/4743/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/21752/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/21752/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 AF5D6C3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 25 Oct 2024 05:31:24 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 514CA65397;\n\tFri, 25 Oct 2024 07:31:24 +0200 (CEST)",
            "from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com\n\t[IPv6:2607:f8b0:4864:20::52b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6B27B6538A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Oct 2024 07:31:20 +0200 (CEST)",
            "by mail-pg1-x52b.google.com with SMTP id\n\t41be03b00d2f7-7163489149eso1145935a12.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Oct 2024 22:31:20 -0700 (PDT)",
            "from chenghaoyang-low.c.googlers.com.com\n\t(199.211.81.34.bc.googleusercontent.com. [34.81.211.199])\n\tby smtp.gmail.com with ESMTPSA id\n\td2e1a72fcca58-72057a1fe53sm317992b3a.162.2024.10.24.22.31.16\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 24 Oct 2024 22:31:17 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"duNGtrI5\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1729834278; x=1730439078;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=hoj5EptvhU9pg9aZA081Vuc/pCfYDXASJLvTcNEnh6U=;\n\tb=duNGtrI5pF3w01DIci2rjgrt7gM8O6iy4Ek70TEXm672Yfje4wly15XhVP+y13i/qz\n\t346nSX9lYebL7IcajZG5bijhBTuhjgs+6R3+x0yYz8YyvGJSzdfPTa22CTkwhCmZsQMX\n\tp5UEHXD8A0lhoA6Kwe47TUIeqrN87kJGctcKw=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1729834278; x=1730439078;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=hoj5EptvhU9pg9aZA081Vuc/pCfYDXASJLvTcNEnh6U=;\n\tb=mma1qZDPGdGpVDjJs1EMmt7LRliCHu8zU89PlbElYg+fxjjHHC83xdnagOdDtn+qdb\n\teHoFJJT+S9qsBen679HA7kXSAoZwcWNqnYTywSchF4ei0l2D3UhZJxMcKn+be9dPcLhg\n\t/yTNMVTmyJkpI2lT87b3CNNxC4N1qUHzWU0Z4jp0/HBcYg3Ox5YUba/Mqm3Ij3I8osap\n\tOkWvBQWoCoFEd2IWIJr1pyIYqQoPDTcAJVtl9Jcmv5cRovFbzhXWYmf5nJpsxSo3c0fm\n\tUe2kIl2/OycQeEMPQlVLd9OxFmJbSD9TMli5VoEwMyr0ZSzQXHhBNkwjWzW4n8xHQCqh\n\tRNXQ==",
        "X-Gm-Message-State": "AOJu0YwKhnKjWBpbV5CoUmJomy6Rbixx/qvieSGPyOebN2jZAQaPm4m+\n\tRNzMcd0CTwI5NUF+TksRstxEEnZYwmBpUf7jKjcICNh4HVE+XV0H32hA2+miE64LJCgXYmxO39M\n\t=",
        "X-Google-Smtp-Source": "AGHT+IF/y1kftz2nRgIdOTATuTtj7rDB4A6oX5vy5qbbfsupDGQqY9qnJ6NcVTVYqO7zw88z+YTk/w==",
        "X-Received": "by 2002:a05:6a20:3813:b0:1d9:975e:2bce with SMTP id\n\tadf61e73a8af0-1d9975e2d71mr2135718637.38.1729834278146; \n\tThu, 24 Oct 2024 22:31:18 -0700 (PDT)",
        "From": "Harvey Yang <chenghaoyang@chromium.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Cc": "Yudhistira Erlandinata <yerlandinata@chromium.org>,\n\tHarvey Yang <chenghaoyang@chromium.org>",
        "Subject": "[PATCH v3 1/2] libcamera: Extend u32 control type",
        "Date": "Fri, 25 Oct 2024 05:30:13 +0000",
        "Message-ID": "<20241025053111.519449-2-chenghaoyang@chromium.org>",
        "X-Mailer": "git-send-email 2.47.0.163.g1226f6d8fa-goog",
        "In-Reply-To": "<20241025053111.519449-1-chenghaoyang@chromium.org>",
        "References": "<20241025053111.519449-1-chenghaoyang@chromium.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "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": "From: Yudhistira Erlandinata <yerlandinata@chromium.org>\n\nV4L2 Controls support a wide variety of types not yet supported by the\nControlValue type system.\n\nExtend the libcamera ControlValue types to support an explicit 32 bit\nunsigned integer type, and map that to the corresponding\nV4L2_CTRL_TYPE_U32 type within the v4l2_device support class.\n\nSigned-off-by: Yudhistira Erlandinata <yerlandinata@chromium.org>\nCo-developed-by: Harvey Yang <chenghaoyang@chromium.org>\nSigned-off-by: Harvey Yang <chenghaoyang@chromium.org>\n---\n include/libcamera/controls.h    |  7 ++++++\n src/libcamera/controls.cpp      | 12 ++++++++--\n src/libcamera/v4l2_device.cpp   | 13 +++++++++++\n test/controls/control_value.cpp | 40 +++++++++++++++++++++++++++++++++\n 4 files changed, 70 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex ca60bbaca..6da8ad2c3 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -29,6 +29,7 @@ enum ControlType {\n \tControlTypeNone,\n \tControlTypeBool,\n \tControlTypeByte,\n+\tControlTypeUnsigned32,\n \tControlTypeInteger32,\n \tControlTypeInteger64,\n \tControlTypeFloat,\n@@ -62,6 +63,12 @@ struct control_type<uint8_t> {\n \tstatic constexpr std::size_t size = 0;\n };\n \n+template<>\n+struct control_type<uint32_t> {\n+\tstatic constexpr ControlType value = ControlTypeUnsigned32;\n+\tstatic constexpr std::size_t size = 0;\n+};\n+\n template<>\n struct control_type<int32_t> {\n \tstatic constexpr ControlType value = ControlTypeInteger32;\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 62185d643..8ae295191 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -54,6 +54,7 @@ static constexpr size_t ControlValueSize[] = {\n \t[ControlTypeNone]\t\t= 0,\n \t[ControlTypeBool]\t\t= sizeof(bool),\n \t[ControlTypeByte]\t\t= sizeof(uint8_t),\n+\t[ControlTypeUnsigned32]\t\t= sizeof(uint32_t),\n \t[ControlTypeInteger32]\t\t= sizeof(int32_t),\n \t[ControlTypeInteger64]\t\t= sizeof(int64_t),\n \t[ControlTypeFloat]\t\t= sizeof(float),\n@@ -74,10 +75,12 @@ static constexpr size_t ControlValueSize[] = {\n  * The control stores a boolean value\n  * \\var ControlTypeByte\n  * The control stores a byte value as an unsigned 8-bit integer\n+ * \\var ControlTypeUnsigned32\n+ * The control stores an unsigned 32-bit integer value\n  * \\var ControlTypeInteger32\n- * The control stores a 32-bit integer value\n+ * The control stores a signed 32-bit integer value\n  * \\var ControlTypeInteger64\n- * The control stores a 64-bit integer value\n+ * The control stores a signed 64-bit integer value\n  * \\var ControlTypeFloat\n  * The control stores a 32-bit floating point value\n  * \\var ControlTypeString\n@@ -230,6 +233,11 @@ std::string ControlValue::toString() const\n \t\t\tstr += std::to_string(*value);\n \t\t\tbreak;\n \t\t}\n+\t\tcase ControlTypeUnsigned32: {\n+\t\t\tconst uint32_t *value = reinterpret_cast<const uint32_t *>(data);\n+\t\t\tstr += std::to_string(*value);\n+\t\t\tbreak;\n+\t\t}\n \t\tcase ControlTypeInteger32: {\n \t\t\tconst int32_t *value = reinterpret_cast<const int32_t *>(data);\n \t\t\tstr += std::to_string(*value);\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 68add4f2e..0ba8dcfa0 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -9,6 +9,7 @@\n \n #include <fcntl.h>\n #include <map>\n+#include <stdint.h>\n #include <stdlib.h>\n #include <string.h>\n #include <sys/ioctl.h>\n@@ -17,11 +18,14 @@\n #include <vector>\n \n #include <linux/v4l2-mediabus.h>\n+#include <linux/videodev2.h>\n \n #include <libcamera/base/event_notifier.h>\n #include <libcamera/base/log.h>\n #include <libcamera/base/utils.h>\n \n+#include <libcamera/controls.h>\n+\n #include \"libcamera/internal/formats.h\"\n #include \"libcamera/internal/sysfs.h\"\n \n@@ -488,6 +492,9 @@ ControlType V4L2Device::v4l2CtrlType(uint32_t ctrlType)\n \tcase V4L2_CTRL_TYPE_BOOLEAN:\n \t\treturn ControlTypeBool;\n \n+\tcase V4L2_CTRL_TYPE_U32:\n+\t\treturn ControlTypeUnsigned32;\n+\n \tcase V4L2_CTRL_TYPE_INTEGER:\n \t\treturn ControlTypeInteger32;\n \n@@ -536,6 +543,11 @@ std::optional<ControlInfo> V4L2Device::v4l2ControlInfo(const v4l2_query_ext_ctrl\n \t\t\t\t   static_cast<uint8_t>(ctrl.maximum),\n \t\t\t\t   static_cast<uint8_t>(ctrl.default_value));\n \n+\tcase V4L2_CTRL_TYPE_U32:\n+\t\treturn ControlInfo(static_cast<uint32_t>(ctrl.minimum),\n+\t\t\t\t   static_cast<uint32_t>(ctrl.maximum),\n+\t\t\t\t   static_cast<uint32_t>(ctrl.default_value));\n+\n \tcase V4L2_CTRL_TYPE_BOOLEAN:\n \t\treturn ControlInfo(static_cast<bool>(ctrl.minimum),\n \t\t\t\t   static_cast<bool>(ctrl.maximum),\n@@ -622,6 +634,7 @@ void V4L2Device::listControls()\n \t\tcase V4L2_CTRL_TYPE_BITMASK:\n \t\tcase V4L2_CTRL_TYPE_INTEGER_MENU:\n \t\tcase V4L2_CTRL_TYPE_U8:\n+\t\tcase V4L2_CTRL_TYPE_U32:\n \t\t\tbreak;\n \t\t/* \\todo Support other control types. */\n \t\tdefault:\ndiff --git a/test/controls/control_value.cpp b/test/controls/control_value.cpp\nindex 344107fae..6ca85b739 100644\n--- a/test/controls/control_value.cpp\n+++ b/test/controls/control_value.cpp\n@@ -109,6 +109,46 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\t/*\n+\t\t * Unsigned Integer32 type.\n+\t\t */\n+\t\tvalue.set(static_cast<uint32_t>(42));\n+\t\tif (value.isNone() || value.isArray() ||\n+\t\t    value.type() != ControlTypeUnsigned32) {\n+\t\t\tcerr << \"Control type mismatch after setting to uint32_t\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (value.get<uint32_t>() != 42) {\n+\t\t\tcerr << \"Control value mismatch after setting to uint32_t\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (value.toString() != \"42\") {\n+\t\t\tcerr << \"Control string mismatch after setting to uint32_t\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tstd::array<uint32_t, 4> uint32s{ 3, 14, 15, 9 };\n+\t\tvalue.set(Span<uint32_t>(uint32s));\n+\t\tif (value.isNone() || !value.isArray() ||\n+\t\t    value.type() != ControlTypeUnsigned32) {\n+\t\t\tcerr << \"Control type mismatch after setting to uint32_t array\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tSpan<const uint32_t> uint32sResult = value.get<Span<const uint32_t>>();\n+\t\tif (uint32s.size() != uint32sResult.size() ||\n+\t\t    !std::equal(uint32s.begin(), uint32s.end(), uint32sResult.begin())) {\n+\t\t\tcerr << \"Control value mismatch after setting to uint32_t array\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (value.toString() != \"[ 3, 14, 15, 9 ]\") {\n+\t\t\tcerr << \"Control string mismatch after setting to uint32_t array\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\t/*\n \t\t * Integer32 type.\n \t\t */\n",
    "prefixes": [
        "v3",
        "1/2"
    ]
}