Patch Detail
Show a patch.
GET /api/patches/1496/?format=api
{ "id": 1496, "url": "https://patchwork.libcamera.org/api/patches/1496/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1496/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20190621161401.28337-4-kieran.bingham@ideasonboard.com>", "date": "2019-06-21T16:13:55", "name": "[libcamera-devel,RFC,v2,3/9] libcamera: controls: Introduce Control structures", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "c0b3bf1209978dec6d0defce3ae1d6c0b0d946ba", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/1496/mbox/", "series": [ { "id": 370, "url": "https://patchwork.libcamera.org/api/series/370/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=370", "date": "2019-06-21T16:13:52", "name": "Libcamera Controls", "version": 2, "mbox": "https://patchwork.libcamera.org/series/370/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1496/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1496/checks/", "tags": {}, "headers": { "Return-Path": "<kieran.bingham@ideasonboard.com>", "Received": [ "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 339E5615BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 21 Jun 2019 18:14:07 +0200 (CEST)", "from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D1D34E04;\n\tFri, 21 Jun 2019 18:14:06 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1561133647;\n\tbh=65KJEfpWcjVvfIS/Pk6jQPpsXi7LZ+0Rix04nCSgklo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=A0N+/YWX4mwoLq/1zSrJyasBL7VVfjrRlkgEfi7l0zT+frqnEmzT5+gVzG16ZzF4h\n\t7903Kbgbjo1s0AnBNhD68anC72WHzNlAwvaz+M5sZI8Na37KrbPAeOhlQU5m64elOM\n\t6/GxmjkN9r5C/aJUtXqteuBOtt1eD/R6v5SIJXzM=", "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>", "Date": "Fri, 21 Jun 2019 17:13:55 +0100", "Message-Id": "<20190621161401.28337-4-kieran.bingham@ideasonboard.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20190621161401.28337-1-kieran.bingham@ideasonboard.com>", "References": "<20190621161401.28337-1-kieran.bingham@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC PATCH v2 3/9] libcamera: controls: Introduce\n\tControl structures", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.23", "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": "Fri, 21 Jun 2019 16:14:07 -0000" }, "content": "ControlIdentifiers declare the types of a control, and map their names,\nand the ControlInfo class allows runtime state to be represented.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n include/libcamera/controls.h | 58 ++++++++++++\n include/libcamera/meson.build | 1 +\n src/libcamera/controls.cpp | 160 ++++++++++++++++++++++++++++++++++\n src/libcamera/meson.build | 1 +\n 4 files changed, 220 insertions(+)\n create mode 100644 include/libcamera/controls.h\n create mode 100644 src/libcamera/controls.cpp", "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nnew file mode 100644\nindex 000000000000..95198d41c4cf\n--- /dev/null\n+++ b/include/libcamera/controls.h\n@@ -0,0 +1,58 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * controls.h - Control handling\n+ */\n+#ifndef __LIBCAMERA_CONTROLS_H__\n+#define __LIBCAMERA_CONTROLS_H__\n+\n+#include <libcamera/value.h>\n+\n+namespace libcamera {\n+\n+enum ControlId : uint32_t {\n+\t/* IPA Controls */\n+\tIpaAwbEnable,\n+\n+\t/* Manual Controls */\n+\tManualBrightness,\n+\tManualExposure,\n+\tManualGain,\n+};\n+\n+struct ControlIdentifier {\n+\tControlId id;\n+\tconst char *name;\n+\tValueType type;\n+};\n+\n+class ControlInfo\n+{\n+public:\n+\tControlInfo(ControlId id, Value min = 0, Value max = 0);\n+\n+\tControlId id() const { return ident_->id; }\n+\tconst char *name() const { return ident_->name; }\n+\tValueType type() const { return ident_->type; }\n+\n+\tconst Value &min() { return min_; }\n+\tconst Value &max() { return min_; }\n+\n+\tstd::string toString() const;\n+\n+\tbool operator==(const ControlInfo &rhs) const { return id() == rhs.id(); }\n+\tbool operator==(const ControlId rhs) const { return id() == rhs; }\n+\n+private:\n+\tstruct ControlIdentifier const *ident_;\n+\tValue min_;\n+\tValue max_;\n+\n+};\n+\n+std::ostream &operator<<(std::ostream &stream, const ControlInfo &value);\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_CONTROLS_H__ */\ndiff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex eb2211ae1fc3..06e3feebd23d 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -1,5 +1,6 @@\n libcamera_api = files([\n 'buffer.h',\n+ 'controls.h',\n 'camera.h',\n 'camera_manager.h',\n 'event_dispatcher.h',\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nnew file mode 100644\nindex 000000000000..b1be46ddb55e\n--- /dev/null\n+++ b/src/libcamera/controls.cpp\n@@ -0,0 +1,160 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * controls.cpp - Control handling\n+ */\n+\n+#include <limits.h>\n+#include <sstream>\n+#include <string>\n+\n+#include <libcamera/controls.h>\n+\n+#include \"log.h\"\n+#include \"utils.h\"\n+\n+/**\n+ * \\file controls.h\n+ * \\brief Describes control framework and controls supported by a camera\n+ */\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(Controls)\n+\n+/**\n+ * \\enum ControlId\n+ * Control Identifiers\n+ * \\var IpaAwbEnable\n+ * bool: Enables or disables the AWB\n+ * \\var ManualExposure\n+ * Manually control the exposure time in milli-seconds\n+ * \\var ManualGain\n+ * Controls the value of the manual gain setting\n+ */\n+\n+/**\n+ * \\struct ControlIdentifier\n+ * Defines a Control with a unique ID, a name, and a type.\n+ * \\var ControlIdentifier::id\n+ * The unique ID for a control\n+ * \\var ControlIdentifier::name\n+ * The string representation of the control\n+ * \\var ControlIdentifier::type\n+ * The ValueType required to represent the control value\n+ */\n+\n+/*\n+ * Two sets of tables are generated for the static control definitions.\n+ *\n+ * An enum to declare the ID (in controls.h), and a type to establish its\n+ * representation.\n+ *\n+ * Todo: Automate the generation of both tables from a single input table.\n+ * Todo: Consider if this should be a static std::map created at init instead.\n+ */\n+static const struct ControlIdentifier ControlTypes[] = {\n+#define CONTROL_TYPE(_id, _type) { _id, #_id, _type }\n+\n+\tCONTROL_TYPE(IpaAwbEnable,\t\tValueBool),\n+\tCONTROL_TYPE(ManualBrightness,\t\tValueInteger),\n+\tCONTROL_TYPE(ManualExposure,\t\tValueInteger),\n+\tCONTROL_TYPE(ManualGain,\t\tValueInteger),\n+\n+#undef CONTROL_TYPE\n+};\n+\n+static struct ControlIdentifier const *FindControlType(ControlId id)\n+{\n+\tstruct ControlIdentifier const *ident;\n+\n+\tfor (ident = ControlTypes;\n+\t ident != &ControlTypes[ARRAY_SIZE(ControlTypes)];\n+\t ++ident) {\n+\t\tif (ident->id == id)\n+\t\t\treturn ident;\n+\t}\n+\n+\tLOG(Controls, Fatal) << \"Failed to find a ControlType.\";\n+\n+\t/* Unreachable. */\n+\treturn nullptr;\n+}\n+\n+/**\n+ * \\class ControlInfo\n+ * \\brief Describes the information and capabilities of a Control\n+ */\n+\n+/**\n+ * \\brief Construct a ControlInfo with minimum and maximum range parameters.\n+ */\n+ControlInfo::ControlInfo(ControlId id, Value min, Value max)\n+\t: ident_(FindControlType(id)), min_(min), max_(max)\n+{\n+}\n+\n+/**\n+ * \\fn ControlInfo::id()\n+ * \\brief Return the ID of the control information descriptor\n+ * \\return the ControlId\n+ */\n+\n+/**\n+ * \\fn ControlInfo::name()\n+ * \\brief Return the string name of the control information descriptor\n+ * \\return A string name for the Control\n+ */\n+\n+/**\n+ * \\fn ControlInfo::type()\n+ * \\brief Return the ValueType of the control information descriptor\n+ * \\return the ControlId\n+ */\n+\n+/**\n+ * \\fn ControlInfo::min()\n+ * \\brief Reports the minimum value of the control\n+ * \\return a Value with the minimum setting for the control\n+ */\n+\n+/**\n+ * \\fn ControlInfo::max()\n+ * \\brief Reports the maximum value of the control\n+ * \\return a Value with the maximum setting for the control\n+ */\n+\n+/**\n+ * \\brief Provide a string representation of the ControlInfo\n+ */\n+std::string ControlInfo::toString() const\n+{\n+\tstd::stringstream ss;\n+\n+\tss << \"Control: \" << name()\n+\t << \" : Min(\" << min_ << \") Max(\" << max_ << \")\";\n+\n+\treturn ss.str();\n+}\n+\n+/**\n+ * \\fn ControlInfo::operator==(const ControlInfo &rhs) const\n+ * \\brief Establish equivalence of ControlInfo. Only the IDs are considered.\n+ */\n+\n+/**\n+ * \\fn ControlInfo::operator==(const ControlId rhs) const\n+ * \\brief Establish equivalence of ControlInfo, against a ControlID.\n+ */\n+\n+/**\n+ * \\brief Provide a string stream representation of the ControlInfo \\a info to\n+ * the \\a stream.\n+ */\n+std::ostream &operator<<(std::ostream &stream, const ControlInfo &info)\n+{\n+\treturn stream << info.toString();\n+}\n+\n+} /* namespace libcamera */\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 8e68373118df..e2c07d79bfb5 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -3,6 +3,7 @@ libcamera_sources = files([\n 'camera.cpp',\n 'camera_manager.cpp',\n 'camera_sensor.cpp',\n+ 'controls.cpp',\n 'device_enumerator.cpp',\n 'device_enumerator_sysfs.cpp',\n 'event_dispatcher.cpp',\n", "prefixes": [ "libcamera-devel", "RFC", "v2", "3/9" ] }