{"id":2328,"url":"https://patchwork.libcamera.org/api/1.1/patches/2328/?format=json","web_url":"https://patchwork.libcamera.org/patch/2328/","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":"<20191119164421.68983-5-jacopo@jmondi.org>","date":"2019-11-19T16:44:19","name":"[libcamera-devel,RFC,4/6] libcamera: controls: Add default to ControlRange","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"4d97760a2c2191d37414738394b94fe4f06ec2e9","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2328/mbox/","series":[{"id":571,"url":"https://patchwork.libcamera.org/api/1.1/series/571/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=571","date":"2019-11-19T16:44:15","name":"Collect Camera properties","version":1,"mbox":"https://patchwork.libcamera.org/series/571/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2328/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2328/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net\n\t[217.70.183.200])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F3CBD61507\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Nov 2019 17:42:27 +0100 (CET)","from uno.lan (93-34-114-233.ip49.fastwebnet.it [93.34.114.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 7BA0C20008;\n\tTue, 19 Nov 2019 16:42:27 +0000 (UTC)"],"X-Originating-IP":"93.34.114.233","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 19 Nov 2019 17:44:19 +0100","Message-Id":"<20191119164421.68983-5-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.23.0","In-Reply-To":"<20191119164421.68983-1-jacopo@jmondi.org>","References":"<20191119164421.68983-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC 4/6] libcamera: controls: Add default to\n\tControlRange","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>","X-List-Received-Date":"Tue, 19 Nov 2019 16:42:28 -0000"},"content":"Augment the the ControlRange class to store the control default value.\n\nThis is particularly relevant for v4l2 controls used to create\nCamera properties, which are constructed using immutable video device\nproperties, whose value won't change at runtime.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n include/libcamera/controls.h |  7 ++++++-\n src/libcamera/controls.cpp   | 17 +++++++++++++++--\n 2 files changed, 21 insertions(+), 3 deletions(-)","diff":"diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex baca684444a7..8669830af3c7 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -114,10 +114,12 @@ class ControlRange\n {\n public:\n \texplicit ControlRange(const ControlValue &min = 0,\n-\t\t\t      const ControlValue &max = 0);\n+\t\t\t      const ControlValue &max = 0,\n+\t\t\t      const ControlValue &defaultValue = 0);\n \n \tconst ControlValue &min() const { return min_; }\n \tconst ControlValue &max() const { return max_; }\n+\tconst ControlValue &defaultValue() const { return defaultValue_; }\n \n \tstd::string toString() const;\n \n@@ -130,6 +132,9 @@ public:\n \t\treturn !(*this == other);\n \t}\n \n+protected:\n+\tControlValue defaultValue_;\n+\n private:\n \tControlValue min_;\n \tControlValue max_;\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex c488b2e4eb3f..4745ac4c95a7 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -353,14 +353,21 @@ Control<int64_t>::Control(unsigned int id, const char *name)\n  * pipeline handlers to describe the controls they support.\n  */\n \n+/**\n+ * \\var ControlRange::defaultValue_\n+ * \\brief The control default value\n+ */\n+\n /**\n  * \\brief Construct a ControlRange with minimum and maximum range parameters\n  * \\param[in] min The control minimum value\n  * \\param[in] max The control maximum value\n+ * \\param[in] defaultValue The control default value\n  */\n ControlRange::ControlRange(const ControlValue &min,\n-\t\t\t   const ControlValue &max)\n-\t: min_(min), max_(max)\n+\t\t\t   const ControlValue &max,\n+\t\t\t   const ControlValue &defaultValue)\n+\t: defaultValue_(defaultValue), min_(min), max_(max)\n {\n }\n \n@@ -376,6 +383,12 @@ ControlRange::ControlRange(const ControlValue &min,\n  * \\return A ControlValue with the maximum value for the control\n  */\n \n+/**\n+ * \\fn ControlRange::defaultValue()\n+ * \\brief Retrieve the default value of the control\n+ * \\return A ControlValue with the default value for the control\n+ */\n+\n /**\n  * \\brief Provide a string representation of the ControlRange\n  */\n","prefixes":["libcamera-devel","RFC","4/6"]}