Show a patch.

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

{
    "id": 12201,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/12201/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/12201/",
    "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": "<20210506075449.1761752-3-hiroh@chromium.org>",
    "date": "2021-05-06T07:54:45",
    "name": "[libcamera-devel,v4,2/6] libcamera: V4L2Device: Support v4l2 menu control",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "dcfe5a6978100064dd1f2463513aa2d3eac94170",
    "submitter": {
        "id": 63,
        "url": "https://patchwork.libcamera.org/api/1.1/people/63/?format=api",
        "name": "Hirokazu Honda",
        "email": "hiroh@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/12201/mbox/",
    "series": [
        {
            "id": 2001,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2001/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2001",
            "date": "2021-05-06T07:54:43",
            "name": "[libcamera-devel,v4,1/6] libcamera: controls: Add sensor test pattern mode",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/2001/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/12201/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/12201/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 66A38BDE7F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  6 May 2021 07:55:03 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0739568922;\n\tThu,  6 May 2021 09:55:03 +0200 (CEST)",
            "from mail-pg1-x533.google.com (mail-pg1-x533.google.com\n\t[IPv6:2607:f8b0:4864:20::533])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 89A3068920\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  6 May 2021 09:55:00 +0200 (CEST)",
            "by mail-pg1-x533.google.com with SMTP id y30so4148951pgl.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 06 May 2021 00:55:00 -0700 (PDT)",
            "from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:2:ede4:ae0e:d4a4:c0d3])\n\tby smtp.gmail.com with ESMTPSA id\n\tf201sm1355546pfa.133.2021.05.06.00.54.57\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 06 May 2021 00:54:58 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"m1ZaEHBe\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=vm6DZPElqUWcJh+QMJO2afXSbmkGZ/M93CLmkyHXhNY=;\n\tb=m1ZaEHBeu1VZS3yo0iRyFdisSTo1QExcRSyGjdvvufR9JMIqthLXf3eXoaQk+Ob+h/\n\tQ2lGmkOqmXy+GFpcFaN139eGvFkubwBKw/BcqVC2gQIACpjWT/N2zOSW1RL8KYgC3hd1\n\t9bHldDfZxp6bFXfKg8lcvDPcGWrYe9x4gowps=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\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=vm6DZPElqUWcJh+QMJO2afXSbmkGZ/M93CLmkyHXhNY=;\n\tb=Ug6BcZymk76RnvKw7U2G0CGO37mg3rEioF+KVFFnHG8+tVKVOZ/vX8wVd7PTnBSi/g\n\tS+dW/Gf8uxRO2VZeYf1QVgGPNAIi5u4b0TTXZj2MP9BEWTt1KCNnkf9StTmU9AhTBb51\n\t21+K/L6hsTyC3wiQtvzlqjrcxHN+0dRsriQtlU+lgT7MJEUpnSscaAdUbsGtbfDbQuhR\n\tgrqB+LatkRJOlQi0zg8fdXrt/W4M93Nw2xKUh4Ocf7uOcYdTBvWY9U49PEGu/vNdRKSo\n\tgj5YJEIg4GismrJEg+MvOT32hjXjuUSLkWBGTi8KM21DO30FOPapDF6lrFGpzYohIXFd\n\t4/zA==",
        "X-Gm-Message-State": "AOAM5325OSaMizDcgVnw3tB8k5/LUfF8Os3JZ5oLlJ2CF1knPWDEDkUO\n\tLVykFFw7atucaKPiNbmggSjSDL3bzgXoBA==",
        "X-Google-Smtp-Source": "ABdhPJzY+MGgdFk2ondpyNAAUe5+VkcnL/sylVGx7LNESWkVvSVZEMFyWi9J+dCjE2UkXoFyUDmI9A==",
        "X-Received": "by 2002:a62:75c3:0:b029:27c:d30f:66a6 with SMTP id\n\tq186-20020a6275c30000b029027cd30f66a6mr3399930pfc.0.1620287698837; \n\tThu, 06 May 2021 00:54:58 -0700 (PDT)",
        "From": "Hirokazu Honda <hiroh@chromium.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu,  6 May 2021 16:54:45 +0900",
        "Message-Id": "<20210506075449.1761752-3-hiroh@chromium.org>",
        "X-Mailer": "git-send-email 2.31.1.607.g51e8a6a459-goog",
        "In-Reply-To": "<20210506075449.1761752-1-hiroh@chromium.org>",
        "References": "<20210506075449.1761752-1-hiroh@chromium.org>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v4 2/6] libcamera: V4L2Device: Support\n\tv4l2 menu control",
        "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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "This adds a support of v4l2 menu. The control info for v4l2 menu\ncontains indices without names and 64bit values of querymenu.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n include/libcamera/internal/v4l2_device.h |  3 ++\n src/libcamera/v4l2_device.cpp            | 65 +++++++++++++++++++++---\n 2 files changed, 61 insertions(+), 7 deletions(-)",
    "diff": "diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h\nindex 087f07e7..c7a2539c 100644\n--- a/include/libcamera/internal/v4l2_device.h\n+++ b/include/libcamera/internal/v4l2_device.h\n@@ -54,6 +54,9 @@ protected:\n \tint fd() const { return fd_; }\n \n private:\n+\tbool createControlInfoForMenu(const v4l2_query_ext_ctrl &ctrl,\n+\t\t\t\t      ControlInfo &ctrlInfo);\n+\n \tvoid listControls();\n \tvoid updateControls(ControlList *ctrls,\n \t\t\t    Span<const v4l2_ext_control> v4l2Ctrls);\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 397029ac..7056c71a 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -452,6 +452,7 @@ int V4L2Device::ioctl(unsigned long request, void *argp)\n \treturn 0;\n }\n \n+\n /**\n  * \\fn V4L2Device::deviceNode()\n  * \\brief Retrieve the device node path\n@@ -459,10 +460,47 @@ int V4L2Device::ioctl(unsigned long request, void *argp)\n  */\n \n /**\n- * \\fn V4L2Device::fd()\n- * \\brief Retrieve the V4L2 device file descriptor\n- * \\return The V4L2 device file descriptor, -1 if the device node is not open\n+ * \\brief Create ControlInfo for v4l2 menu ctrl.\n+ * \\param[in] ctrl The v4l2_query_ext_ctrl that represents a menu\n+ * \\param[out] ctrlInfo The created controlInfo\n+ *\n+ * The created ControlInfo contains not only values and also extra values, which\n+ * are indices and name/value acquired by VIDIOC_QUERYMENU, respectively. The\n+ * extra values contains std::string if the type of \\a ctrl is\n+ * V4L2_CTRL_TYPE_MENU or int64_t otherwise.\n+ *\n+ * \\return True on success or false otherwise\n  */\n+bool V4L2Device::createControlInfoForMenu(const v4l2_query_ext_ctrl &ctrl,\n+\t\t\t\t\t  ControlInfo &ctrlInfo)\n+{\n+\tASSERT(ctrl.type == V4L2_CTRL_TYPE_MENU ||\n+\t       ctrl.type == V4L2_CTRL_TYPE_INTEGER_MENU);\n+\n+\tstd::vector<ControlValue> indices;\n+\tv4l2_querymenu menu;\n+\tmemset(&menu, 0, sizeof(menu));\n+\tmenu.id = ctrl.id;\n+\n+\tfor (menu.index = ctrl.minimum;\n+\t     static_cast<int>(menu.index) <= ctrl.maximum; menu.index++) {\n+\t\tif (ioctl(VIDIOC_QUERYMENU, &menu) != 0)\n+\t\t\tcontinue;\n+\n+\t\tindices.emplace_back(static_cast<int32_t>(menu.index));\n+\t}\n+\n+\tif (indices.empty()) {\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"No applicable value: \" << utils::hex(ctrl.id);\n+\n+\t\treturn false;\n+\t}\n+\n+\tctrlInfo = ControlInfo(indices);\n+\n+\treturn true;\n+}\n \n /*\n  * \\brief List and store information about all controls supported by the\n@@ -473,7 +511,6 @@ void V4L2Device::listControls()\n \tControlInfoMap::Map ctrls;\n \tstruct v4l2_query_ext_ctrl ctrl = {};\n \n-\t/* \\todo Add support for menu controls. */\n \twhile (1) {\n \t\tctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL |\n \t\t\t   V4L2_CTRL_FLAG_NEXT_COMPOUND;\n@@ -484,15 +521,22 @@ void V4L2Device::listControls()\n \t\t    ctrl.flags & V4L2_CTRL_FLAG_DISABLED)\n \t\t\tcontinue;\n \n+\t\tControlInfo ctrlInfo;\n \t\tswitch (ctrl.type) {\n \t\tcase V4L2_CTRL_TYPE_INTEGER:\n \t\tcase V4L2_CTRL_TYPE_BOOLEAN:\n-\t\tcase V4L2_CTRL_TYPE_MENU:\n \t\tcase V4L2_CTRL_TYPE_BUTTON:\n \t\tcase V4L2_CTRL_TYPE_INTEGER64:\n \t\tcase V4L2_CTRL_TYPE_BITMASK:\n-\t\tcase V4L2_CTRL_TYPE_INTEGER_MENU:\n \t\tcase V4L2_CTRL_TYPE_U8:\n+\t\t\tctrlInfo = V4L2ControlInfo(ctrl);\n+\t\t\tbreak;\n+\n+\t\tcase V4L2_CTRL_TYPE_INTEGER_MENU:\n+\t\tcase V4L2_CTRL_TYPE_MENU:\n+\t\t\tif (!createControlInfoForMenu(ctrl, ctrlInfo))\n+\t\t\t\tcontinue;\n+\n \t\t\tbreak;\n \t\t/* \\todo Support other control types. */\n \t\tdefault:\n@@ -502,10 +546,13 @@ void V4L2Device::listControls()\n \t\t\tcontinue;\n \t\t}\n \n+\t\tLOG(V4L2, Debug) << \"Control: \" << ctrl.name\n+\t\t\t\t << \" (\" << utils::hex(ctrl.id) << \")\";\n+\n \t\tcontrolIds_.emplace_back(std::make_unique<V4L2ControlId>(ctrl));\n \t\tcontrolInfo_.emplace(ctrl.id, ctrl);\n \n-\t\tctrls.emplace(controlIds_.back().get(), V4L2ControlInfo(ctrl));\n+\t\tctrls.emplace(controlIds_.back().get(), ctrlInfo);\n \t}\n \n \tcontrols_ = std::move(ctrls);\n@@ -535,6 +582,10 @@ void V4L2Device::updateControls(ControlList *ctrls,\n \t\t\tvalue.set<int64_t>(v4l2Ctrl->value64);\n \t\t\tbreak;\n \n+\t\tcase ControlTypeInteger32:\n+\t\t\tvalue.set<int32_t>(v4l2Ctrl->value);\n+\t\t\tbreak;\n+\n \t\tcase ControlTypeByte:\n \t\t\t/*\n \t\t\t * No action required, the VIDIOC_[GS]_EXT_CTRLS ioctl\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "2/6"
    ]
}