Patch Detail
Show a patch.
GET /api/1.1/patches/13159/?format=api
{ "id": 13159, "url": "https://patchwork.libcamera.org/api/1.1/patches/13159/?format=api", "web_url": "https://patchwork.libcamera.org/patch/13159/", "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": "<20210730103536.81117-2-paul.elder@ideasonboard.com>", "date": "2021-07-30T10:35:28", "name": "[libcamera-devel,v6,1/9] controls: Add boolean constructors for ControlInfo", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "e6b16c7adf1561fc2466f86d0d0ee714da8aa8ba", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/1.1/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/13159/mbox/", "series": [ { "id": 2291, "url": "https://patchwork.libcamera.org/api/1.1/series/2291/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2291", "date": "2021-07-30T10:35:27", "name": "android: Support capability and hardware level detection", "version": 6, "mbox": "https://patchwork.libcamera.org/series/2291/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/13159/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/13159/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 B293CC322E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 30 Jul 2021 10:35:50 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4B822687C7;\n\tFri, 30 Jul 2021 12:35:50 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E8A60687BE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 30 Jul 2021 12:35:47 +0200 (CEST)", "from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1F7E889B;\n\tFri, 30 Jul 2021 12:35:45 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"qywHmL/T\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1627641347;\n\tbh=zL1wz+rIzrWVBDAY+/Ru+xswsnvC4n3Rs+ivWWh6PzA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=qywHmL/TfbhtIxePBZc+8Lm1VQmD5TSRAOfTKfWG+UmnmrX19nBMBeRoAap9NdIQa\n\tKARA1aLzlA9hnlMEMyTHdckqzYhRbw7At1+cO0j6CK4913vRT7zDMlWDkcCymmln30\n\tTaCKFfuqOCsS4BAMKOd9glPeFB7o70BTfi5kKlR4=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 30 Jul 2021 19:35:28 +0900", "Message-Id": "<20210730103536.81117-2-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20210730103536.81117-1-paul.elder@ideasonboard.com>", "References": "<20210730103536.81117-1-paul.elder@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v6 1/9] controls: Add boolean constructors\n\tfor 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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "It would be convenient to be able to iterate over available boolean\nvalues, for example for controls that designate if some function can be\nenabled/disabled. The current min/max/def constructor is insufficient,\nas .values() is empty, so the values cannot be easily iterated over, and\ncreating a Span of booleans does not work for the values constructor.\n\nAdd new constructors to ControlInfo that takes a set of booleans (if\nboth booleans are valid values) plus a default, and another that takes\nonly one boolean (if only one boolean is a valid value).\n\nUpdate the ControlInfo test accordingly.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\n---\nChanges in v5:\n- break away the single-value one to a different constructor\n\nChanges in v2:\n- use set instead of span of bools\n- add assertion to make sure that the default is a valid value\n- update the test\n---\n include/libcamera/controls.h | 3 +++\n src/libcamera/controls.cpp | 29 +++++++++++++++++++++++++++++\n test/controls/control_info.cpp | 33 +++++++++++++++++++++++++++++++++\n 3 files changed, 65 insertions(+)", "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 1bc958a4..de733bd8 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -9,6 +9,7 @@\n #define __LIBCAMERA_CONTROLS_H__\n \n #include <assert.h>\n+#include <set>\n #include <stdint.h>\n #include <string>\n #include <unordered_map>\n@@ -272,6 +273,8 @@ public:\n \t\t\t const ControlValue &def = 0);\n \texplicit ControlInfo(Span<const ControlValue> values,\n \t\t\t const ControlValue &def = {});\n+\texplicit ControlInfo(std::set<bool> values, bool def);\n+\texplicit ControlInfo(bool value);\n \n \tconst ControlValue &min() const { return min_; }\n \tconst ControlValue &max() const { return max_; }\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex 78109f41..283472c5 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -514,6 +514,35 @@ ControlInfo::ControlInfo(Span<const ControlValue> values,\n \t\tvalues_.push_back(value);\n }\n \n+/**\n+ * \\brief Construct a boolean ControlInfo with both boolean values\n+ * \\param[in] values The control valid boolean values (both true and false)\n+ * \\param[in] def The control default boolean value\n+ *\n+ * Construct a ControlInfo for a boolean control, where both true and false are\n+ * valid values. \\a values must be { false, true } (the order is irrelevant).\n+ * The minimum value will always be false, and the maximum always true. The\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+{\n+\tassert(values.count(def) && values.size() == 2);\n+}\n+\n+/**\n+ * \\brief Construct a boolean ControlInfo with only one valid value\n+ * \\param[in] value The control valid boolean value\n+ *\n+ * Construct a ControlInfo for a boolean control, where there is only valid\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+{\n+\tvalues_ = { value };\n+}\n+\n /**\n * \\fn ControlInfo::min()\n * \\brief Retrieve the minimum value of the control\ndiff --git a/test/controls/control_info.cpp b/test/controls/control_info.cpp\nindex 1e05e131..2827473b 100644\n--- a/test/controls/control_info.cpp\n+++ b/test/controls/control_info.cpp\n@@ -44,6 +44,39 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\t/*\n+\t\t * Test information retrieval from a control with boolean\n+\t\t * values.\n+\t\t */\n+\t\tControlInfo aeEnable({ false, true }, false);\n+\n+\t\tif (aeEnable.min().get<bool>() != false ||\n+\t\t aeEnable.def().get<bool>() != false ||\n+\t\t aeEnable.max().get<bool>() != true) {\n+\t\t\tcout << \"Invalid control range for AeEnable\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (aeEnable.values()[0].get<bool>() != false ||\n+\t\t aeEnable.values()[1].get<bool>() != true) {\n+\t\t\tcout << \"Invalid control values for AeEnable\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tControlInfo awbEnable(true);\n+\n+\t\tif (awbEnable.min().get<bool>() != true ||\n+\t\t awbEnable.def().get<bool>() != true ||\n+\t\t awbEnable.max().get<bool>() != true) {\n+\t\t\tcout << \"Invalid control range for AwbEnable\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (awbEnable.values()[0].get<bool>() != true) {\n+\t\t\tcout << \"Invalid control values for AwbEnable\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\treturn TestPass;\n \t}\n };\n", "prefixes": [ "libcamera-devel", "v6", "1/9" ] }