{"id":15672,"url":"https://patchwork.libcamera.org/api/1.1/patches/15672/?format=json","web_url":"https://patchwork.libcamera.org/patch/15672/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20220414074342.7455-2-hpa@redhat.com>","date":"2022-04-14T07:43:38","name":"[libcamera-devel,RFC,v1,1/5] libcamera: v4l2_device: VIDIOC_QUERYCTRL call to fetch device attributes","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"fedd5a28ea0023244d9820a0a6d1d5ccb90c6a1c","submitter":{"id":105,"url":"https://patchwork.libcamera.org/api/1.1/people/105/?format=json","name":"Kate Hsuan","email":"hpa@redhat.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15672/mbox/","series":[{"id":3052,"url":"https://patchwork.libcamera.org/api/1.1/series/3052/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3052","date":"2022-04-14T07:43:37","name":"Enabling AF algorithm to get the VCM attributes from the device driver","version":1,"mbox":"https://patchwork.libcamera.org/series/3052/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15672/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15672/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 8C37EC3260\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Apr 2022 07:44:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 00D746564C;\n\tThu, 14 Apr 2022 09:44:08 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1E28965645\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Apr 2022 09:44:07 +0200 (CEST)","from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com\n\t[66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n\tus-mta-453-CIYn7r2HO0eu6ru3OwQXbA-1; Thu, 14 Apr 2022 03:44:04 -0400","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mimecast-mx02.redhat.com (Postfix) with ESMTPS id 87A983C02B60\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Apr 2022 07:44:04 +0000 (UTC)","from fedora.rhtw.internal (unknown [10.39.193.169])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id DC0E9111E3EA;\n\tThu, 14 Apr 2022 07:44:02 +0000 (UTC)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1649922248;\n\tbh=PyW+bGU1SmxQjx/hYyZl+q7hgY6meSbOypmRASKhcy8=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=Vwf9xFkj0LW8prHUfJyfW5I8KUN9T4Col5cJgTTGBfakuNvu3ACjkq2ArTv+p8hVl\n\tkzia3HYQVT5OlEplLlv2hW/9dCOQ1RYWY3Exf0QUwtUIYX/70MCwmainjuGIXP1Y+A\n\tYOuauJKy+pUzPFihS5lBCsFg2PSyGhtYLhs22t4LZ03bhhPcdJYAeEQq/qug+m3i2E\n\twvwP8aojaXh7kjd8kq2v950lLYK7o/3NIZALom0RxdJcRNv1HIQeGCYT43yQ6UlZie\n\tGPur+lOmoVqhKRVk2dnTCJt42dN4vXk3WWPVYqGiunNQ0ohan50noXF74oXVAcjdD+\n\tnUu3oBrt+aImQ==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1649922245;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=tC/C2lez66xZ9LADfw7zvXSambvgPNfB4konHKWScS8=;\n\tb=OEMK4Plp7dPmQUqcno9bfQoLriMWypO6qlkm4IQKpGRdKVy3QWfULhk8uI/7sBKO0ou4JY\n\tBVwr8yN2DcAd2NBk64WYPyFpuqfb+4c6womvdzDWiFya27s9lRU8fvXCPsAXVSq7HarFFC\n\t6NImy/P4BXx0WVFAGl82DOTZNfeJaP8="],"Authentication-Results":["lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"OEMK4Plp\"; \n\tdkim-atps=neutral","relay.mimecast.com;\n\tauth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hpa@redhat.com"],"X-MC-Unique":"CIYn7r2HO0eu6ru3OwQXbA-1","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Thu, 14 Apr 2022 15:43:38 +0800","Message-Id":"<20220414074342.7455-2-hpa@redhat.com>","In-Reply-To":"<20220414074342.7455-1-hpa@redhat.com>","References":"<20220414074342.7455-1-hpa@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 2.78 on 10.11.54.3","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Transfer-Encoding":"8bit","Content-Type":"text/plain; charset=\"US-ASCII\"; x-default=true","Subject":"[libcamera-devel] [RFC v1 1/5] libcamera: v4l2_device:\n\tVIDIOC_QUERYCTRL call to fetch device attributes","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>","From":"Kate Hsuan via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Kate Hsuan <hpa@redhat.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"VIDIOC_QUERYCTRL can be used to get the device attributes. It can be used\nto get the attributes for a given control list and store them in it.\nFianlly, the maximum capacity of the device can be found in the control\nlist.\n\nSigned-off-by: Kate Hsuan<hpa@redhat.com>\n---\n include/libcamera/internal/v4l2_device.h |  2 ++\n src/libcamera/v4l2_device.cpp            | 37 ++++++++++++++++++++++++\n 2 files changed, 39 insertions(+)","diff":"diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h\nindex a52a5f2c..d93a72a0 100644\n--- a/include/libcamera/internal/v4l2_device.h\n+++ b/include/libcamera/internal/v4l2_device.h\n@@ -37,6 +37,8 @@ public:\n \tControlList getControls(const std::vector<uint32_t> &ids);\n \tint setControls(ControlList *ctrls);\n \n+\tint getAttributes(ControlList *ctrls);\n+\n \tconst struct v4l2_query_ext_ctrl *controlInfo(uint32_t id) const;\n \n \tconst std::string &deviceNode() const { return deviceNode_; }\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 3fc8438f..eda429be 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -364,6 +364,43 @@ int V4L2Device::setControls(ControlList *ctrls)\n \treturn ret;\n }\n \n+/**\n+ * \\brief Get capacity for a given control list\n+ *\n+ * This function will get device maximum capacity through VIDIOC_QUERYCTRL and\n+ * store the maximum value to the \\a ctrls. If a non-support control is found,\n+ * it will return -EINVAL.\n+ *\n+ * \\param ctrls The list of controls  to get the capacity\n+ * \\return 0 or non-zero on success or a empty control list\n+ * \\retval -EINVAL One of the control is not supported or not accessible\n+ */\n+int V4L2Device::getAttributes(ControlList *ctrls)\n+{\n+\tint ret = 0;\n+\tif (ctrls->empty())\n+\t\treturn 0;\n+\n+\tstruct v4l2_queryctrl query_ctrl;\n+\tfor (auto [ctrl, i] = std::pair(ctrls->begin(), 0u); i < ctrls->size(); ctrl++, i++) {\n+\t\tconst unsigned int id = ctrl->first;\n+\t\tconst auto iter = controls_.find(id);\n+\t\tif (iter == controls_.end()) {\n+\t\t\tLOG(V4L2, Error)\n+\t\t\t\t<< \"Control \" << utils::hex(id) << \" not found\";\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tmemset(&query_ctrl, 0, sizeof(struct v4l2_queryctrl));\n+\t\tquery_ctrl.id = id;\n+\t\tquery_ctrl.type = V4L2_CTRL_TYPE_INTEGER;\n+\t\tret = ioctl(VIDIOC_QUERYCTRL, &query_ctrl);\n+\t\tctrls->set(id, query_ctrl.maximum);\n+\t}\n+\n+\treturn ret;\n+}\n+\n /**\n  * \\brief Retrieve the v4l2_query_ext_ctrl information for the given control\n  * \\param[in] id The V4L2 control id\n","prefixes":["libcamera-devel","RFC","v1","1/5"]}