{"id":19188,"url":"https://patchwork.libcamera.org/api/patches/19188/?format=json","web_url":"https://patchwork.libcamera.org/patch/19188/","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":"<20231102172439.3543870-2-kieran.bingham@ideasonboard.com>","date":"2023-11-02T17:24:38","name":"[libcamera-devel,v3,1/2] libcamera: controls: Add read-only flag to ControlInfo","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"d50ea3d72ca0413387fcf0059c59605aec5f081c","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19188/mbox/","series":[{"id":4064,"url":"https://patchwork.libcamera.org/api/series/4064/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4064","date":"2023-11-02T17:24:37","name":"Add read-only flag to ControlInfo","version":3,"mbox":"https://patchwork.libcamera.org/series/4064/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19188/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19188/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 5634CC327C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Nov 2023 17:24:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DE9E561DC8;\n\tThu,  2 Nov 2023 18:24:48 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1284D61DC8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 Nov 2023 18:24:45 +0100 (CET)","from Monstersaurus.local\n\t(aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net\n\t[82.37.23.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 531E38C2;\n\tThu,  2 Nov 2023 18:24:27 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1698945888;\n\tbh=Cvj0hzouLJ5CCqPMyLcqmu0yrX3vm66hpydwrZl15FE=;\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=XcgG37zqf/HUEh+oXPxtxifnx8d2cSOXAh1nK/STDNdLuBclxFfsqltD448B4J7Ss\n\tX+KKfQLVWybJSquLGCu10r4m6siVGmxkPuy1ei3Gv3eM+UDnEcDw6bnNUQOdujug4r\n\tnXN8188DPM2/bIQy7nbcfChQUpUK+XVXPp8K6gsPa8qeT7hE0zxkrdO6+VbKCDRyiY\n\tb7GUPcWitpNyzqUs9S7oWSVZL6ll7FQkeHqaiYnKF8/S2WGKbrpDH1simeuN7K3H+/\n\t9hqdNdGYGRh4Evj5q/2N0As4J0vaP1GttRwpsMepdj5B/xvTtH0sgQg+PFsaq95tpg\n\tmuoMynRIu4Mcg==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1698945867;\n\tbh=Cvj0hzouLJ5CCqPMyLcqmu0yrX3vm66hpydwrZl15FE=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Ax3sCIR9tWeSdoH0avBXdH807RR1L+8jSJaEH3KGpXu1oMWqaWHx2b3nF41rY1X5I\n\tW/93SiPEWBZT+qB8x+LAc/FjvZCr99RFInZzmLq0HewMP1SIFXKH4I4wd394+feSNF\n\tcjmZ1jUp69kvymzUEidG9+dT8I/OY/dSYtLK9KLA="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Ax3sCIR9\"; dkim-atps=neutral","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Thu,  2 Nov 2023 17:24:38 +0000","Message-Id":"<20231102172439.3543870-2-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20231102172439.3543870-1-kieran.bingham@ideasonboard.com>","References":"<20231102172439.3543870-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 1/2] libcamera: controls: Add read-only\n\tflag to ControlInfo","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":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Naushir Patuck <naush@raspberrypi.com>\n\nAdd a read-only flag to the ControlInfo flag to indicate whether a V4L2 control\nis read-only or not. This flag only makes sense for V2L2 controls at preset, so\nonly update the ControlInfo constructor signature used by the V4L2Device class\nto set the value of the flag.\n\nAdd a ControlInfo::readOnly() member function to retrive this flag.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\nv2:\n - Initialised readOnly_ for ControlInfo(Span<>)\n - Improved documentation\n\n\n include/libcamera/controls.h  |  5 ++++-\n src/libcamera/controls.cpp    | 22 ++++++++++++++++++----\n src/libcamera/v4l2_device.cpp | 12 ++++++++----\n 3 files changed, 30 insertions(+), 9 deletions(-)","diff":"diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex cf94205577a5..488663a7ba04 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -270,7 +270,8 @@ class ControlInfo\n public:\n \texplicit ControlInfo(const ControlValue &min = {},\n \t\t\t     const ControlValue &max = {},\n-\t\t\t     const ControlValue &def = {});\n+\t\t\t     const ControlValue &def = {},\n+\t\t\t     bool readOnly = false);\n \texplicit ControlInfo(Span<const ControlValue> values,\n \t\t\t     const ControlValue &def = {});\n \texplicit ControlInfo(std::set<bool> values, bool def);\n@@ -279,6 +280,7 @@ public:\n \tconst ControlValue &min() const { return min_; }\n \tconst ControlValue &max() const { return max_; }\n \tconst ControlValue &def() const { return def_; }\n+\tbool readOnly() const { return readOnly_; }\n \tconst std::vector<ControlValue> &values() const { return values_; }\n \n \tstd::string toString() const;\n@@ -297,6 +299,7 @@ private:\n \tControlValue min_;\n \tControlValue max_;\n \tControlValue def_;\n+\tbool readOnly_;\n \tstd::vector<ControlValue> values_;\n };\n \ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex b808116c01e5..8af304bdeac9 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -484,11 +484,13 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen\n  * \\param[in] min The control minimum value\n  * \\param[in] max The control maximum value\n  * \\param[in] def The control default value\n+ * \\param[in] readOnly True if the control reports a dynamic property\n  */\n ControlInfo::ControlInfo(const ControlValue &min,\n \t\t\t const ControlValue &max,\n-\t\t\t const ControlValue &def)\n-\t: min_(min), max_(max), def_(def)\n+\t\t\t const ControlValue &def,\n+\t\t\t bool readOnly)\n+\t: min_(min), max_(max), def_(def), readOnly_(readOnly)\n {\n }\n \n@@ -508,6 +510,7 @@ ControlInfo::ControlInfo(Span<const ControlValue> values,\n \tmin_ = values.front();\n \tmax_ = values.back();\n \tdef_ = !def.isNone() ? def : values.front();\n+\treadOnly_ = false;\n \n \tvalues_.reserve(values.size());\n \tfor (const ControlValue &value : values)\n@@ -525,7 +528,8 @@ ControlInfo::ControlInfo(Span<const ControlValue> values,\n  * default value is \\a def.\n  */\n ControlInfo::ControlInfo(std::set<bool> values, bool def)\n-\t: min_(false), max_(true), def_(def), values_({ false, true })\n+\t: min_(false), max_(true), def_(def), readOnly_(false),\n+\t  values_({ false, true })\n {\n \tASSERT(values.count(def) && values.size() == 2);\n }\n@@ -538,7 +542,7 @@ ControlInfo::ControlInfo(std::set<bool> values, bool def)\n  * value. The minimum, maximum, and default values will all be \\a value.\n  */\n ControlInfo::ControlInfo(bool value)\n-\t: min_(value), max_(value), def_(value)\n+\t: min_(value), max_(value), def_(value), readOnly_(true)\n {\n \tvalues_ = { value };\n }\n@@ -571,6 +575,16 @@ ControlInfo::ControlInfo(bool value)\n  * \\return A ControlValue with the default value for the control\n  */\n \n+/**\n+ * \\fn ControlInfo::readOnly()\n+ * \\brief Identifies if a control is flagged as read-only\n+ * \\return True if the control is read-only, false otherwise\n+ *\n+ * Read-only controls may signify that the control is a volatile property and\n+ * can not be set. Adding a read-only control to a control list may cause the\n+ * list to fail when the list is submitted.\n+ */\n+\n /**\n  * \\fn ControlInfo::values()\n  * \\brief Retrieve the list of valid values\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 24d208ef77dc..8563bbd2595f 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -536,17 +536,20 @@ std::optional<ControlInfo> V4L2Device::v4l2ControlInfo(const v4l2_query_ext_ctrl\n \tcase V4L2_CTRL_TYPE_U8:\n \t\treturn ControlInfo(static_cast<uint8_t>(ctrl.minimum),\n \t\t\t\t   static_cast<uint8_t>(ctrl.maximum),\n-\t\t\t\t   static_cast<uint8_t>(ctrl.default_value));\n+\t\t\t\t   static_cast<uint8_t>(ctrl.default_value),\n+\t\t\t\t   !!(ctrl.flags & V4L2_CTRL_FLAG_READ_ONLY));\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-\t\t\t\t   static_cast<bool>(ctrl.default_value));\n+\t\t\t\t   static_cast<bool>(ctrl.default_value),\n+\t\t\t\t   !!(ctrl.flags & V4L2_CTRL_FLAG_READ_ONLY));\n \n \tcase V4L2_CTRL_TYPE_INTEGER64:\n \t\treturn ControlInfo(static_cast<int64_t>(ctrl.minimum),\n \t\t\t\t   static_cast<int64_t>(ctrl.maximum),\n-\t\t\t\t   static_cast<int64_t>(ctrl.default_value));\n+\t\t\t\t   static_cast<int64_t>(ctrl.default_value),\n+\t\t\t\t   !!(ctrl.flags & V4L2_CTRL_FLAG_READ_ONLY));\n \n \tcase V4L2_CTRL_TYPE_INTEGER_MENU:\n \tcase V4L2_CTRL_TYPE_MENU:\n@@ -555,7 +558,8 @@ std::optional<ControlInfo> V4L2Device::v4l2ControlInfo(const v4l2_query_ext_ctrl\n \tdefault:\n \t\treturn ControlInfo(static_cast<int32_t>(ctrl.minimum),\n \t\t\t\t   static_cast<int32_t>(ctrl.maximum),\n-\t\t\t\t   static_cast<int32_t>(ctrl.default_value));\n+\t\t\t\t   static_cast<int32_t>(ctrl.default_value),\n+\t\t\t\t   !!(ctrl.flags & V4L2_CTRL_FLAG_READ_ONLY));\n \t}\n }\n \n","prefixes":["libcamera-devel","v3","1/2"]}