{"id":12464,"url":"https://patchwork.libcamera.org/api/patches/12464/?format=json","web_url":"https://patchwork.libcamera.org/patch/12464/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210528030531.189492-2-hiroh@chromium.org>","date":"2021-05-28T03:05:27","name":"[libcamera-devel,v6,2/6] libcamera: V4L2Device: Support v4l2 menu control","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"842e59b63169a3d2503e7d7a834ce2814c54f3d7","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12464/mbox/","series":[{"id":2089,"url":"https://patchwork.libcamera.org/api/series/2089/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2089","date":"2021-05-28T03:05:26","name":"[libcamera-devel,v6,1/6] libcamera: controls: Add sensor test pattern mode","version":6,"mbox":"https://patchwork.libcamera.org/series/2089/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12464/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12464/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 1CA15C3205\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 28 May 2021 03:05:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D126A6891E;\n\tFri, 28 May 2021 05:05:41 +0200 (CEST)","from mail-pf1-x430.google.com (mail-pf1-x430.google.com\n\t[IPv6:2607:f8b0:4864:20::430])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C558B6891D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 28 May 2021 05:05:39 +0200 (CEST)","by mail-pf1-x430.google.com with SMTP id y15so2136853pfn.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 27 May 2021 20:05:39 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:2:caec:ab3b:ea16:3d01])\n\tby smtp.gmail.com with ESMTPSA id\n\tl20sm2892051pjq.38.2021.05.27.20.05.36\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 27 May 2021 20:05:37 -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=\"acjk/D7L\"; 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=oFqBC1evGDoYaQp4OZbBwiSe0Fjh0ge5LISerDTqP00=;\n\tb=acjk/D7LLgl8i/d1XqfAxvasis026S0I3S+TlWWjdhd2ALdRVQEInMsO1iqanRizHT\n\tCUWfU3Y2CQAD2G+POeJUexCAWfFqJSI6vbOhKxRa2yjbwMUJwOdx8O3E09Ad1eN2ayi6\n\tbTcNYeRU62RdOKzSuG20Wr9VZOd4mL18PJOuo=","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=oFqBC1evGDoYaQp4OZbBwiSe0Fjh0ge5LISerDTqP00=;\n\tb=c+Uc5Ew/t5r40hJAoKLTdshWmk+a81XCdMMEBj8vdzszhsc+Mj09hOejqiLH2RsPbd\n\tpTb4tUWgr7rUw/FE3Ih49AXRYo/L/q11hBIx4CIb/09Ag17PGsJPXrBd6WbFxD3OvvhB\n\t4zlrmTlk0F/gUOgXS61d476g6RMFEyK5KbQf5H3WrplU/y2vTgEacr5y035GK59dqgES\n\thnQJTgM779BM9XNhD39pO/7zFGgbLOML1WSfkVgykTnKAIrrt5uVnQIx3+nmgS1Qb56V\n\tTSSufozkFdchS26Afmad99qlZmlN4jjbwozHGpnbpFuAqHNmIXQWt/+Ky/q4uZNnKJop\n\tys3Q==","X-Gm-Message-State":"AOAM532TQCIbkFoiFWB26Fdz5SpdcJTCXPHK39P0D6QNi48zL4gZMdWx\n\t4VE/wOkgFZsU/YpxF3ZhB2RhmW0LlPuJwg==","X-Google-Smtp-Source":"ABdhPJzeyP/3xNelM89a/stvmQdRPU/TdbUrKXmLo2jDZIoyW/yDL1lU6myfjIs3IKmNpShLKyIwVg==","X-Received":"by 2002:a62:8389:0:b029:27d:28f4:d583 with SMTP id\n\th131-20020a6283890000b029027d28f4d583mr1669540pfe.33.1622171138207; \n\tThu, 27 May 2021 20:05:38 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 28 May 2021 12:05:27 +0900","Message-Id":"<20210528030531.189492-2-hiroh@chromium.org>","X-Mailer":"git-send-email 2.32.0.rc0.204.g9fa02ecfa5-goog","In-Reply-To":"<20210528030531.189492-1-hiroh@chromium.org>","References":"<20210528030531.189492-1-hiroh@chromium.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v6 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>","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 |  2 +\n src/libcamera/v4l2_device.cpp            | 47 ++++++++++++++++++++++--\n 2 files changed, 45 insertions(+), 4 deletions(-)","diff":"diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h\nindex b82e2a14..687be9b2 100644\n--- a/include/libcamera/internal/v4l2_device.h\n+++ b/include/libcamera/internal/v4l2_device.h\n@@ -56,6 +56,8 @@ protected:\n \tint fd() const { return fd_; }\n \n private:\n+\tControlInfo v4l2MenuControlInfo(const v4l2_query_ext_ctrl &ctrl);\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 caafbc2d..032252bb 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -530,6 +530,33 @@ int V4L2Device::ioctl(unsigned long request, void *argp)\n  * \\return The V4L2 device file descriptor, -1 if the device node is not open\n  */\n \n+/**\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 indices acquired by VIDIOC_QUERYMENU.\n+ *\n+ * \\return ControlInfo for v4l2 menu ctrl.\n+ */\n+ControlInfo V4L2Device::v4l2MenuControlInfo(const v4l2_query_ext_ctrl &ctrl)\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<int32_t>(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+\treturn ControlInfo(indices);\n+}\n+\n /*\n  * \\brief List and store information about all controls supported by the\n  * V4L2 device\n@@ -539,7 +566,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@@ -550,16 +576,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\tctrlInfo = v4l2MenuControlInfo(ctrl);\n \t\t\tbreak;\n+\n \t\t/* \\todo Support other control types. */\n \t\tdefault:\n \t\t\tLOG(V4L2, Debug)\n@@ -568,10 +600,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(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(), std::move(ctrlInfo));\n \t}\n \n \tcontrols_ = std::move(ctrls);\n@@ -638,6 +673,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","v6","2/6"]}