[{"id":2678,"web_url":"https://patchwork.libcamera.org/comment/2678/","msgid":"<f09688b6-07cf-e356-4ed2-51b06f92cf6f@ideasonboard.com>","date":"2019-09-20T11:01:31","subject":"Re: [libcamera-devel] [PATCH 2/5] libcamera: controls: Use DataType\n\tand DataValue","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn 18/09/2019 11:34, Jacopo Mondi wrote:\n> Replace the use of ControlValue with DataValue and make ControlInfo a\n> DataInfo derived class to maximize the code reuse with V4L2Control which\n> will be modified in the next patch.\n> \n> Remove the now unused control_value test, replaced in the previous patch\n> by data_value test.\n\nI think my only worry in this patch is the removal of the operator==\noverrides.\n\nEverything else looks good ...\n\n\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  include/libcamera/controls.h        |  77 ++-------\n>  src/libcamera/controls.cpp          | 237 ++--------------------------\n>  src/libcamera/gen-controls.awk      |   2 +-\n>  src/libcamera/pipeline/uvcvideo.cpp |   2 +-\n>  src/libcamera/pipeline/vimc.cpp     |   2 +-\n>  test/controls/control_info.cpp      |   4 +-\n>  test/controls/control_value.cpp     |  69 --------\n>  test/controls/meson.build           |   1 -\n>  8 files changed, 26 insertions(+), 368 deletions(-)\n>  delete mode 100644 test/controls/control_value.cpp\n> \n> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n> index fbb3a62274c6..e46cd8a78679 100644\n> --- a/include/libcamera/controls.h\n> +++ b/include/libcamera/controls.h\n> @@ -13,98 +13,39 @@\n>  #include <unordered_map>\n> \n>  #include <libcamera/control_ids.h>\n> +#include <libcamera/data_value.h>\n> \n>  namespace libcamera {\n> \n>  class Camera;\n> \n> -enum ControlValueType {\n> -\tControlValueNone,\n> -\tControlValueBool,\n> -\tControlValueInteger,\n> -\tControlValueInteger64,\n> -};\n> -\n> -class ControlValue\n> -{\n> -public:\n> -\tControlValue();\n> -\tControlValue(bool value);\n> -\tControlValue(int value);\n> -\tControlValue(int64_t value);\n> -\n> -\tControlValueType type() const { return type_; };\n> -\tbool isNone() const { return type_ == ControlValueNone; };\n> -\n> -\tvoid set(bool value);\n> -\tvoid set(int value);\n> -\tvoid set(int64_t value);\n> -\n> -\tbool getBool() const;\n> -\tint getInt() const;\n> -\tint64_t getInt64() const;\n> -\n> -\tstd::string toString() const;\n> -\n> -private:\n> -\tControlValueType type_;\n> -\n> -\tunion {\n> -\t\tbool bool_;\n> -\t\tint integer_;\n> -\t\tint64_t integer64_;\n> -\t};\n> -};\n> -\n>  struct ControlIdentifier {\n>  \tControlId id;\n>  \tconst char *name;\n> -\tControlValueType type;\n> +\tDataType type;\n>  };\n> \n> -class ControlInfo\n> +class ControlInfo : public DataInfo\n>  {\n>  public:\n> -\texplicit ControlInfo(ControlId id, const ControlValue &min = 0,\n> -\t\t\t     const ControlValue &max = 0);\n> -\n> +\texplicit ControlInfo(ControlId id, const DataValue &min = 0,\n> +\t\t\t     const DataValue &max = 0);\n>  \tControlId id() const { return ident_->id; }\n>  \tconst char *name() const { return ident_->name; }\n> -\tControlValueType type() const { return ident_->type; }\n> -\n> -\tconst ControlValue &min() const { return min_; }\n> -\tconst ControlValue &max() const { return max_; }\n> +\tDataType type() const { return ident_->type; }\n> \n>  \tstd::string toString() const;\n> \n>  private:\n>  \tconst struct ControlIdentifier *ident_;\n> -\tControlValue min_;\n> -\tControlValue max_;\n>  };\n> \n> -bool operator==(const ControlInfo &lhs, const ControlInfo &rhs);\n> -bool operator==(const ControlId &lhs, const ControlInfo &rhs);\n> -bool operator==(const ControlInfo &lhs, const ControlId &rhs);\n> -static inline bool operator!=(const ControlInfo &lhs, const ControlInfo &rhs)\n> -{\n> -\treturn !(lhs == rhs);\n> -}\n> -static inline bool operator!=(const ControlId &lhs, const ControlInfo &rhs)\n> -{\n> -\treturn !(lhs == rhs);\n> -}\n> -static inline bool operator!=(const ControlInfo &lhs, const ControlId &rhs)\n> -{\n> -\treturn !(lhs == rhs);\n> -}\n> -\n\nDo we need /make use of these operator overrides, and are they now\nprovided by the DataInfo ?\n\nI'm sure I recall them being used for matching somewhere... perhaps\nthat's handled differently now.\n\n\n>  using ControlInfoMap = std::unordered_map<ControlId, ControlInfo>;\n> \n>  class ControlList\n>  {\n>  private:\n> -\tusing ControlListMap = std::unordered_map<const ControlInfo *, ControlValue>;\n> +\tusing ControlListMap = std::unordered_map<const ControlInfo *, DataValue>;\n> \n>  public:\n>  \tControlList(Camera *camera);\n> @@ -123,8 +64,8 @@ public:\n>  \tstd::size_t size() const { return controls_.size(); }\n>  \tvoid clear() { controls_.clear(); }\n> \n> -\tControlValue &operator[](ControlId id);\n> -\tControlValue &operator[](const ControlInfo *info) { return controls_[info]; }\n> +\tDataValue &operator[](ControlId id);\n> +\tDataValue &operator[](const ControlInfo *info) { return controls_[info]; }\n> \n>  \tvoid update(const ControlList &list);\n> \n> diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\n> index 727fdbd9450d..2d8adde5688e 100644\n> --- a/src/libcamera/controls.cpp\n> +++ b/src/libcamera/controls.cpp\n> @@ -24,163 +24,6 @@ namespace libcamera {\n> \n>  LOG_DEFINE_CATEGORY(Controls)\n> \n> -/**\n> - * \\enum ControlValueType\n> - * \\brief Define the data type of value represented by a ControlValue\n> - * \\var ControlValueNone\n> - * Identifies an unset control value\n> - * \\var ControlValueBool\n> - * Identifies controls storing a boolean value\n> - * \\var ControlValueInteger\n> - * Identifies controls storing an integer value\n> - * \\var ControlValueInteger64\n> - * Identifies controls storing a 64-bit integer value\n> - */\n> -\n> -/**\n> - * \\class ControlValue\n> - * \\brief Abstract type representing the value of a control\n> - */\n> -\n> -/**\n> - * \\brief Construct an empty ControlValue.\n> - */\n> -ControlValue::ControlValue()\n> -\t: type_(ControlValueNone)\n> -{\n> -}\n> -\n> -/**\n> - * \\brief Construct a Boolean ControlValue\n> - * \\param[in] value Boolean value to store\n> - */\n> -ControlValue::ControlValue(bool value)\n> -\t: type_(ControlValueBool), bool_(value)\n> -{\n> -}\n> -\n> -/**\n> - * \\brief Construct an integer ControlValue\n> - * \\param[in] value Integer value to store\n> - */\n> -ControlValue::ControlValue(int value)\n> -\t: type_(ControlValueInteger), integer_(value)\n> -{\n> -}\n> -\n> -/**\n> - * \\brief Construct a 64 bit integer ControlValue\n> - * \\param[in] value Integer value to store\n> - */\n> -ControlValue::ControlValue(int64_t value)\n> -\t: type_(ControlValueInteger64), integer64_(value)\n> -{\n> -}\n> -\n> -/**\n> - * \\fn ControlValue::type()\n> - * \\brief Retrieve the data type of the value\n> - * \\return The value data type\n> - */\n> -\n> -/**\n> - * \\fn ControlValue::isNone()\n> - * \\brief Determine if the value is not initialised\n> - * \\return True if the value type is ControlValueNone, false otherwise\n> - */\n> -\n> -/**\n> - * \\brief Set the value with a boolean\n> - * \\param[in] value Boolean value to store\n> - */\n> -void ControlValue::set(bool value)\n> -{\n> -\ttype_ = ControlValueBool;\n> -\tbool_ = value;\n> -}\n> -\n> -/**\n> - * \\brief Set the value with an integer\n> - * \\param[in] value Integer value to store\n> - */\n> -void ControlValue::set(int value)\n> -{\n> -\ttype_ = ControlValueInteger;\n> -\tinteger_ = value;\n> -}\n> -\n> -/**\n> - * \\brief Set the value with a 64 bit integer\n> - * \\param[in] value 64 bit integer value to store\n> - */\n> -void ControlValue::set(int64_t value)\n> -{\n> -\ttype_ = ControlValueInteger64;\n> -\tinteger64_ = value;\n> -}\n> -\n> -/**\n> - * \\brief Get the boolean value\n> - *\n> - * The value type must be Boolean.\n> - *\n> - * \\return The boolean value\n> - */\n> -bool ControlValue::getBool() const\n> -{\n> -\tASSERT(type_ == ControlValueBool);\n> -\n> -\treturn bool_;\n> -}\n> -\n> -/**\n> - * \\brief Get the integer value\n> - *\n> - * The value type must be Integer or Integer64.\n> - *\n> - * \\return The integer value\n> - */\n> -int ControlValue::getInt() const\n> -{\n> -\tASSERT(type_ == ControlValueInteger || type_ == ControlValueInteger64);\n> -\n> -\treturn integer_;\n> -}\n> -\n> -/**\n> - * \\brief Get the 64-bit integer value\n> - *\n> - * The value type must be Integer or Integer64.\n> - *\n> - * \\return The 64-bit integer value\n> - */\n> -int64_t ControlValue::getInt64() const\n> -{\n> -\tASSERT(type_ == ControlValueInteger || type_ == ControlValueInteger64);\n> -\n> -\treturn integer64_;\n> -}\n> -\n> -/**\n> - * \\brief Assemble and return a string describing the value\n> - * \\return A string describing the ControlValue\n> - */\n> -std::string ControlValue::toString() const\n> -{\n> -\tswitch (type_) {\n> -\tcase ControlValueNone:\n> -\t\treturn \"<None>\";\n> -\tcase ControlValueBool:\n> -\t\treturn bool_ ? \"True\" : \"False\";\n> -\tcase ControlValueInteger:\n> -\t\treturn std::to_string(integer_);\n> -\tcase ControlValueInteger64:\n> -\t\treturn std::to_string(integer64_);\n> -\t}\n> -\n> -\treturn \"<ValueType Error>\";\n> -}\n> -\n>  /**\n>   * \\enum ControlId\n>   * \\brief Numerical control ID\n> @@ -269,9 +112,9 @@ extern const std::unordered_map<ControlId, ControlIdentifier> controlTypes;\n>   * \\param[in] min The control minimum value\n>   * \\param[in] max The control maximum value\n>   */\n> -ControlInfo::ControlInfo(ControlId id, const ControlValue &min,\n> -\t\t\t const ControlValue &max)\n> -\t: min_(min), max_(max)\n> +ControlInfo::ControlInfo(ControlId id, const DataValue &min,\n> +\t\t\t const DataValue &max)\n> +\t: DataInfo(min, max)\n>  {\n>  \tauto iter = controlTypes.find(id);\n>  \tif (iter == controlTypes.end()) {\n> @@ -296,79 +139,23 @@ ControlInfo::ControlInfo(ControlId id, const ControlValue &min,\n> \n>  /**\n>   * \\fn ControlInfo::type()\n> - * \\brief Retrieve the control data type\n> - * \\return The control data type\n> - */\n> -\n> -/**\n> - * \\fn ControlInfo::min()\n> - * \\brief Retrieve the minimum value of the control\n> - * \\return A ControlValue with the minimum value for the control\n> - */\n> -\n> -/**\n> - * \\fn ControlInfo::max()\n> - * \\brief Retrieve the maximum value of the control\n> - * \\return A ControlValue with the maximum value for the control\n> + * \\brief Retrieve the control designated type\n> + * \\return The control type\n\nIs it inaccurate to leave this as \"Retrieve the control data type\"?\nIsn't that what is returned?\n\n>   */\n> \n>  /**\n>   * \\brief Provide a string representation of the ControlInfo\n> + * \\return The control name\n>   */\n>  std::string ControlInfo::toString() const\n>  {\n>  \tstd::stringstream ss;\n> \n> -\tss << name() << \"[\" << min_.toString() << \"..\" << max_.toString() << \"]\";\n> +\tss << name() << \"[\" << min().toString() << \"..\" << max().toString() << \"]\";\n> \n>  \treturn ss.str();\n>  }\n> \n> -/**\n> - * \\brief Compare control information for equality\n> - * \\param[in] lhs Left-hand side control information\n> - * \\param[in] rhs Right-hand side control information\n> - *\n> - * Control information is compared based on the ID only, as a camera may not\n> - * have two separate controls with the same ID.\n> - *\n> - * \\return True if \\a lhs and \\a rhs are equal, false otherwise\n> - */\n> -bool operator==(const ControlInfo &lhs, const ControlInfo &rhs)\n> -{\n> -\treturn lhs.id() == rhs.id();\n> -}\n> -\n> -/**\n> - * \\brief Compare control ID and information for equality\n> - * \\param[in] lhs Left-hand side control identifier\n> - * \\param[in] rhs Right-hand side control information\n> - *\n> - * Control information is compared based on the ID only, as a camera may not\n> - * have two separate controls with the same ID.\n> - *\n> - * \\return True if \\a lhs and \\a rhs are equal, false otherwise\n> - */\n> -bool operator==(const ControlId &lhs, const ControlInfo &rhs)\n> -{\n> -\treturn lhs == rhs.id();\n> -}\n> -\n> -/**\n> - * \\brief Compare control information and ID for equality\n> - * \\param[in] lhs Left-hand side control information\n> - * \\param[in] rhs Right-hand side control identifier\n> - *\n> - * Control information is compared based on the ID only, as a camera may not\n> - * have two separate controls with the same ID.\n> - *\n> - * \\return True if \\a lhs and \\a rhs are equal, false otherwise\n> - */\n> -bool operator==(const ControlInfo &lhs, const ControlId &rhs)\n> -{\n> -\treturn lhs.id() == rhs;\n> -}\n> -\n\nI'm quite a bit scared seeing those operator== removals in this patch.\nHave you run all the tests on this patch?\n\nDo they still function (i.e. maintain bisect-ability) at this point?\n\nI wonder if we even had anything testing this specific part in fact.\n\n\n\n>  /**\n>   * \\typedef ControlInfoMap\n>   * \\brief A map of ControlId to ControlInfo\n> @@ -378,7 +165,7 @@ bool operator==(const ControlInfo &lhs, const ControlId &rhs)\n>   * \\class ControlList\n>   * \\brief Associate a list of ControlId with their values for a camera\n>   *\n> - * A ControlList wraps a map of ControlId to ControlValue and provide\n> + * A ControlList wraps a map of ControlId to DataValue and provide\n>   * additional validation against the control information exposed by a Camera.\n>   *\n>   * A list is only valid for as long as the camera it refers to is valid. After\n> @@ -474,7 +261,7 @@ bool ControlList::contains(const ControlInfo *info) const\n>  /**\n>   * \\fn ControlList::size()\n>   * \\brief Retrieve the number of controls in the list\n> - * \\return The number of Control entries stored in the list\n> + * \\return The number of DataValue entries stored in the list\n>   */\n> \n>  /**\n> @@ -494,7 +281,7 @@ bool ControlList::contains(const ControlInfo *info) const\n>   *\n>   * \\return A reference to the value of the control identified by \\a id\n>   */\n> -ControlValue &ControlList::operator[](ControlId id)\n> +DataValue &ControlList::operator[](ControlId id)\n>  {\n>  \tconst ControlInfoMap &controls = camera_->controls();\n>  \tconst auto iter = controls.find(id);\n> @@ -503,7 +290,7 @@ ControlValue &ControlList::operator[](ControlId id)\n>  \t\t\t<< \"Camera \" << camera_->name()\n>  \t\t\t<< \" does not support control \" << id;\n> \n> -\t\tstatic ControlValue empty;\n> +\t\tstatic DataValue empty;\n>  \t\treturn empty;\n>  \t}\n> \n> @@ -543,7 +330,7 @@ void ControlList::update(const ControlList &other)\n> \n>  \tfor (auto it : other) {\n>  \t\tconst ControlInfo *info = it.first;\n> -\t\tconst ControlValue &value = it.second;\n> +\t\tconst DataValue &value = it.second;\n> \n>  \t\tcontrols_[info] = value;\n>  \t}\n> diff --git a/src/libcamera/gen-controls.awk b/src/libcamera/gen-controls.awk\n> index f3d068123012..abeb0218546b 100755\n> --- a/src/libcamera/gen-controls.awk\n> +++ b/src/libcamera/gen-controls.awk\n> @@ -92,7 +92,7 @@ function GenerateTable(file) {\n>  \tprint \"extern const std::unordered_map<ControlId, ControlIdentifier>\" > file\n>  \tprint \"controlTypes {\" > file\n>  \tfor (i=1; i <= id; ++i) {\n> -\t\tprintf \"\\t{ %s, { %s, \\\"%s\\\", ControlValue%s } },\\n\", names[i], names[i], names[i], types[i] > file\n> +\t\tprintf \"\\t{ %s, { %s, \\\"%s\\\", DataType%s } },\\n\", names[i], names[i], names[i], types[i] > file\n>  \t}\n>  \tprint \"};\" > file\n>  \tExitNameSpace(file)\n> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> index 8965210550d2..dd253f94ca3d 100644\n> --- a/src/libcamera/pipeline/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo.cpp\n> @@ -231,7 +231,7 @@ int PipelineHandlerUVC::processControls(UVCCameraData *data, Request *request)\n> \n>  \tfor (auto it : request->controls()) {\n>  \t\tconst ControlInfo *ci = it.first;\n> -\t\tControlValue &value = it.second;\n> +\t\tDataValue &value = it.second;\n> \n>  \t\tswitch (ci->id()) {\n>  \t\tcase Brightness:\n> diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\n> index f26a91f86ec1..3df239bdb277 100644\n> --- a/src/libcamera/pipeline/vimc.cpp\n> +++ b/src/libcamera/pipeline/vimc.cpp\n> @@ -284,7 +284,7 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)\n> \n>  \tfor (auto it : request->controls()) {\n>  \t\tconst ControlInfo *ci = it.first;\n> -\t\tControlValue &value = it.second;\n> +\t\tDataValue &value = it.second;\n> \n>  \t\tswitch (ci->id()) {\n>  \t\tcase Brightness:\n> diff --git a/test/controls/control_info.cpp b/test/controls/control_info.cpp\n> index aa3a65b1e5ef..c3f9b85580a7 100644\n> --- a/test/controls/control_info.cpp\n> +++ b/test/controls/control_info.cpp\n> @@ -26,7 +26,7 @@ protected:\n>  \t\tControlInfo info(Brightness);\n> \n>  \t\tif (info.id() != Brightness ||\n> -\t\t    info.type() != ControlValueInteger ||\n> +\t\t    info.type() != DataTypeInteger ||\n>  \t\t    info.name() != std::string(\"Brightness\")) {\n>  \t\t\tcout << \"Invalid control identification for Brightness\" << endl;\n>  \t\t\treturn TestFail;\n> @@ -44,7 +44,7 @@ protected:\n>  \t\tinfo = ControlInfo(Contrast, 10, 200);\n> \n>  \t\tif (info.id() != Contrast ||\n> -\t\t    info.type() != ControlValueInteger ||\n> +\t\t    info.type() != DataTypeInteger ||\n>  \t\t    info.name() != std::string(\"Contrast\")) {\n>  \t\t\tcout << \"Invalid control identification for Contrast\" << endl;\n>  \t\t\treturn TestFail;\n> diff --git a/test/controls/control_value.cpp b/test/controls/control_value.cpp\n> deleted file mode 100644\n> index 778efe5c115f..000000000000\n> --- a/test/controls/control_value.cpp\n> +++ /dev/null\n> @@ -1,69 +0,0 @@\n> -/* SPDX-License-Identifier: GPL-2.0-or-later */\n> -/*\n> - * Copyright (C) 2019, Google Inc.\n> - *\n> - * control_value.cpp - ControlValue tests\n> - */\n> -\n> -#include <iostream>\n> -\n> -#include <libcamera/controls.h>\n> -\n> -#include \"test.h\"\n> -\n> -using namespace std;\n> -using namespace libcamera;\n> -\n> -class ControlValueTest : public Test\n> -{\n> -protected:\n> -\tint run()\n> -\t{\n> -\t\tControlValue integer(1234);\n> -\t\tControlValue boolean(true);\n> -\n> -\t\t/* Just a string conversion output test... no validation */\n> -\t\tcout << \"Int: \" << integer.toString()\n> -\t\t     << \" Bool: \" << boolean.toString()\n> -\t\t     << endl;\n> -\n> -\t\tif (integer.getInt() != 1234) {\n> -\t\t\tcerr << \"Failed to get Integer\" << endl;\n> -\t\t\treturn TestFail;\n> -\t\t}\n> -\n> -\t\tif (boolean.getBool() != true) {\n> -\t\t\tcerr << \"Failed to get Boolean\" << endl;\n> -\t\t\treturn TestFail;\n> -\t\t}\n> -\n> -\t\t/* Test an uninitialised value, and updating it. */\n> -\n> -\t\tControlValue value;\n> -\t\tif (!value.isNone()) {\n> -\t\t\tcerr << \"Empty value is non-null\" << endl;\n> -\t\t\treturn TestFail;\n> -\t\t}\n> -\n> -\t\tvalue.set(true);\n> -\t\tif (value.isNone()) {\n> -\t\t\tcerr << \"Failed to set an empty object\" << endl;\n> -\t\t\treturn TestFail;\n> -\t\t}\n> -\n> -\t\tif (value.getBool() != true) {\n> -\t\t\tcerr << \"Failed to get Booleans\" << endl;\n> -\t\t\treturn TestFail;\n> -\t\t}\n> -\n> -\t\tvalue.set(10);\n> -\t\tif (value.getInt() != 10) {\n> -\t\t\tcerr << \"Failed to get Integer\" << endl;\n> -\t\t\treturn TestFail;\n> -\t\t}\n> -\n> -\t\treturn TestPass;\n> -\t}\n> -};\n> -\n> -TEST_REGISTER(ControlValueTest)\n> diff --git a/test/controls/meson.build b/test/controls/meson.build\n> index f4fc7b947dd9..9070be85718b 100644\n> --- a/test/controls/meson.build\n> +++ b/test/controls/meson.build\n> @@ -1,7 +1,6 @@\n>  control_tests = [\n>      [ 'control_info',   'control_info.cpp' ],\n>      [ 'control_list',   'control_list.cpp' ],\n> -    [ 'control_value',  'control_value.cpp' ],\n>  ]\n> \n>  foreach t : control_tests\n> --\n> 2.23.0\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel\n>","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 4A8FB60BED\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Sep 2019 13:01:35 +0200 (CEST)","from [192.168.0.20]\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 A51992F9;\n\tFri, 20 Sep 2019 13:01:34 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1568977294;\n\tbh=mRMxxvdDyf1y6/bwxwFE3/IwBGAXiBbU/Xbc2Q8R7ZA=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=YAJWyOqOy9lPiUrFc6H09qaJnF8ayVbEDNDprGJ40j/A4Ubxf6puW8wU9wQlPG9d5\n\tdZVvgzdodnvhRNqP0fNp2eFAUoni0wBujw2//5Jk2trwG7zDF97wKmFrQY9IBinQDL\n\tKlzx++fsrIUVQeaj4k3oJ8AnxV9rEu8cFN0codR8=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Jacopo Mondi <jacopo@jmondi.org>, libcamera-devel@lists.libcamera.org","References":"<20190918103424.14536-1-jacopo@jmondi.org>\n\t<20190918103424.14536-3-jacopo@jmondi.org>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Openpgp":"preference=signencrypt","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\t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","Organization":"Ideas on Board","Message-ID":"<f09688b6-07cf-e356-4ed2-51b06f92cf6f@ideasonboard.com>","Date":"Fri, 20 Sep 2019 12:01:31 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.8.0","MIME-Version":"1.0","In-Reply-To":"<20190918103424.14536-3-jacopo@jmondi.org>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH 2/5] libcamera: controls: Use DataType\n\tand DataValue","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, 20 Sep 2019 11:01:35 -0000"}},{"id":2683,"web_url":"https://patchwork.libcamera.org/comment/2683/","msgid":"<20190923110602.34mx76lxf4teq2m5@uno.localdomain>","date":"2019-09-23T11:06:02","subject":"Re: [libcamera-devel] [PATCH 2/5] libcamera: controls: Use DataType\n\tand DataValue","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Kieran,\n\nOn Fri, Sep 20, 2019 at 12:01:31PM +0100, Kieran Bingham wrote:\n> Hi Jacopo,\n>\n> On 18/09/2019 11:34, Jacopo Mondi wrote:\n> > Replace the use of ControlValue with DataValue and make ControlInfo a\n> > DataInfo derived class to maximize the code reuse with V4L2Control which\n> > will be modified in the next patch.\n> >\n> > Remove the now unused control_value test, replaced in the previous patch\n> > by data_value test.\n>\n> I think my only worry in this patch is the removal of the operator==\n> overrides.\n\nThey're not used anywhere in the code\n\n>\n> Everything else looks good ...\n>\n>\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  include/libcamera/controls.h        |  77 ++-------\n> >  src/libcamera/controls.cpp          | 237 ++--------------------------\n> >  src/libcamera/gen-controls.awk      |   2 +-\n> >  src/libcamera/pipeline/uvcvideo.cpp |   2 +-\n> >  src/libcamera/pipeline/vimc.cpp     |   2 +-\n> >  test/controls/control_info.cpp      |   4 +-\n> >  test/controls/control_value.cpp     |  69 --------\n> >  test/controls/meson.build           |   1 -\n> >  8 files changed, 26 insertions(+), 368 deletions(-)\n> >  delete mode 100644 test/controls/control_value.cpp\n> >\n> > diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n> > index fbb3a62274c6..e46cd8a78679 100644\n> > --- a/include/libcamera/controls.h\n> > +++ b/include/libcamera/controls.h\n> > @@ -13,98 +13,39 @@\n> >  #include <unordered_map>\n> >\n> >  #include <libcamera/control_ids.h>\n> > +#include <libcamera/data_value.h>\n> >\n> >  namespace libcamera {\n> >\n> >  class Camera;\n> >\n> > -enum ControlValueType {\n> > -\tControlValueNone,\n> > -\tControlValueBool,\n> > -\tControlValueInteger,\n> > -\tControlValueInteger64,\n> > -};\n> > -\n> > -class ControlValue\n> > -{\n> > -public:\n> > -\tControlValue();\n> > -\tControlValue(bool value);\n> > -\tControlValue(int value);\n> > -\tControlValue(int64_t value);\n> > -\n> > -\tControlValueType type() const { return type_; };\n> > -\tbool isNone() const { return type_ == ControlValueNone; };\n> > -\n> > -\tvoid set(bool value);\n> > -\tvoid set(int value);\n> > -\tvoid set(int64_t value);\n> > -\n> > -\tbool getBool() const;\n> > -\tint getInt() const;\n> > -\tint64_t getInt64() const;\n> > -\n> > -\tstd::string toString() const;\n> > -\n> > -private:\n> > -\tControlValueType type_;\n> > -\n> > -\tunion {\n> > -\t\tbool bool_;\n> > -\t\tint integer_;\n> > -\t\tint64_t integer64_;\n> > -\t};\n> > -};\n> > -\n> >  struct ControlIdentifier {\n> >  \tControlId id;\n> >  \tconst char *name;\n> > -\tControlValueType type;\n> > +\tDataType type;\n> >  };\n> >\n> > -class ControlInfo\n> > +class ControlInfo : public DataInfo\n> >  {\n> >  public:\n> > -\texplicit ControlInfo(ControlId id, const ControlValue &min = 0,\n> > -\t\t\t     const ControlValue &max = 0);\n> > -\n> > +\texplicit ControlInfo(ControlId id, const DataValue &min = 0,\n> > +\t\t\t     const DataValue &max = 0);\n> >  \tControlId id() const { return ident_->id; }\n> >  \tconst char *name() const { return ident_->name; }\n> > -\tControlValueType type() const { return ident_->type; }\n> > -\n> > -\tconst ControlValue &min() const { return min_; }\n> > -\tconst ControlValue &max() const { return max_; }\n> > +\tDataType type() const { return ident_->type; }\n> >\n> >  \tstd::string toString() const;\n> >\n> >  private:\n> >  \tconst struct ControlIdentifier *ident_;\n> > -\tControlValue min_;\n> > -\tControlValue max_;\n> >  };\n> >\n> > -bool operator==(const ControlInfo &lhs, const ControlInfo &rhs);\n> > -bool operator==(const ControlId &lhs, const ControlInfo &rhs);\n> > -bool operator==(const ControlInfo &lhs, const ControlId &rhs);\n> > -static inline bool operator!=(const ControlInfo &lhs, const ControlInfo &rhs)\n> > -{\n> > -\treturn !(lhs == rhs);\n> > -}\n> > -static inline bool operator!=(const ControlId &lhs, const ControlInfo &rhs)\n> > -{\n> > -\treturn !(lhs == rhs);\n> > -}\n> > -static inline bool operator!=(const ControlInfo &lhs, const ControlId &rhs)\n> > -{\n> > -\treturn !(lhs == rhs);\n> > -}\n> > -\n>\n> Do we need /make use of these operator overrides, and are they now\n> provided by the DataInfo ?\n>\n> I'm sure I recall them being used for matching somewhere... perhaps\n> that's handled differently now.\n>\n>\n> >  using ControlInfoMap = std::unordered_map<ControlId, ControlInfo>;\n> >\n> >  class ControlList\n> >  {\n> >  private:\n> > -\tusing ControlListMap = std::unordered_map<const ControlInfo *, ControlValue>;\n> > +\tusing ControlListMap = std::unordered_map<const ControlInfo *, DataValue>;\n> >\n> >  public:\n> >  \tControlList(Camera *camera);\n> > @@ -123,8 +64,8 @@ public:\n> >  \tstd::size_t size() const { return controls_.size(); }\n> >  \tvoid clear() { controls_.clear(); }\n> >\n> > -\tControlValue &operator[](ControlId id);\n> > -\tControlValue &operator[](const ControlInfo *info) { return controls_[info]; }\n> > +\tDataValue &operator[](ControlId id);\n> > +\tDataValue &operator[](const ControlInfo *info) { return controls_[info]; }\n> >\n> >  \tvoid update(const ControlList &list);\n> >\n> > diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\n> > index 727fdbd9450d..2d8adde5688e 100644\n> > --- a/src/libcamera/controls.cpp\n> > +++ b/src/libcamera/controls.cpp\n> > @@ -24,163 +24,6 @@ namespace libcamera {\n> >\n> >  LOG_DEFINE_CATEGORY(Controls)\n> >\n> > -/**\n> > - * \\enum ControlValueType\n> > - * \\brief Define the data type of value represented by a ControlValue\n> > - * \\var ControlValueNone\n> > - * Identifies an unset control value\n> > - * \\var ControlValueBool\n> > - * Identifies controls storing a boolean value\n> > - * \\var ControlValueInteger\n> > - * Identifies controls storing an integer value\n> > - * \\var ControlValueInteger64\n> > - * Identifies controls storing a 64-bit integer value\n> > - */\n> > -\n> > -/**\n> > - * \\class ControlValue\n> > - * \\brief Abstract type representing the value of a control\n> > - */\n> > -\n> > -/**\n> > - * \\brief Construct an empty ControlValue.\n> > - */\n> > -ControlValue::ControlValue()\n> > -\t: type_(ControlValueNone)\n> > -{\n> > -}\n> > -\n> > -/**\n> > - * \\brief Construct a Boolean ControlValue\n> > - * \\param[in] value Boolean value to store\n> > - */\n> > -ControlValue::ControlValue(bool value)\n> > -\t: type_(ControlValueBool), bool_(value)\n> > -{\n> > -}\n> > -\n> > -/**\n> > - * \\brief Construct an integer ControlValue\n> > - * \\param[in] value Integer value to store\n> > - */\n> > -ControlValue::ControlValue(int value)\n> > -\t: type_(ControlValueInteger), integer_(value)\n> > -{\n> > -}\n> > -\n> > -/**\n> > - * \\brief Construct a 64 bit integer ControlValue\n> > - * \\param[in] value Integer value to store\n> > - */\n> > -ControlValue::ControlValue(int64_t value)\n> > -\t: type_(ControlValueInteger64), integer64_(value)\n> > -{\n> > -}\n> > -\n> > -/**\n> > - * \\fn ControlValue::type()\n> > - * \\brief Retrieve the data type of the value\n> > - * \\return The value data type\n> > - */\n> > -\n> > -/**\n> > - * \\fn ControlValue::isNone()\n> > - * \\brief Determine if the value is not initialised\n> > - * \\return True if the value type is ControlValueNone, false otherwise\n> > - */\n> > -\n> > -/**\n> > - * \\brief Set the value with a boolean\n> > - * \\param[in] value Boolean value to store\n> > - */\n> > -void ControlValue::set(bool value)\n> > -{\n> > -\ttype_ = ControlValueBool;\n> > -\tbool_ = value;\n> > -}\n> > -\n> > -/**\n> > - * \\brief Set the value with an integer\n> > - * \\param[in] value Integer value to store\n> > - */\n> > -void ControlValue::set(int value)\n> > -{\n> > -\ttype_ = ControlValueInteger;\n> > -\tinteger_ = value;\n> > -}\n> > -\n> > -/**\n> > - * \\brief Set the value with a 64 bit integer\n> > - * \\param[in] value 64 bit integer value to store\n> > - */\n> > -void ControlValue::set(int64_t value)\n> > -{\n> > -\ttype_ = ControlValueInteger64;\n> > -\tinteger64_ = value;\n> > -}\n> > -\n> > -/**\n> > - * \\brief Get the boolean value\n> > - *\n> > - * The value type must be Boolean.\n> > - *\n> > - * \\return The boolean value\n> > - */\n> > -bool ControlValue::getBool() const\n> > -{\n> > -\tASSERT(type_ == ControlValueBool);\n> > -\n> > -\treturn bool_;\n> > -}\n> > -\n> > -/**\n> > - * \\brief Get the integer value\n> > - *\n> > - * The value type must be Integer or Integer64.\n> > - *\n> > - * \\return The integer value\n> > - */\n> > -int ControlValue::getInt() const\n> > -{\n> > -\tASSERT(type_ == ControlValueInteger || type_ == ControlValueInteger64);\n> > -\n> > -\treturn integer_;\n> > -}\n> > -\n> > -/**\n> > - * \\brief Get the 64-bit integer value\n> > - *\n> > - * The value type must be Integer or Integer64.\n> > - *\n> > - * \\return The 64-bit integer value\n> > - */\n> > -int64_t ControlValue::getInt64() const\n> > -{\n> > -\tASSERT(type_ == ControlValueInteger || type_ == ControlValueInteger64);\n> > -\n> > -\treturn integer64_;\n> > -}\n> > -\n> > -/**\n> > - * \\brief Assemble and return a string describing the value\n> > - * \\return A string describing the ControlValue\n> > - */\n> > -std::string ControlValue::toString() const\n> > -{\n> > -\tswitch (type_) {\n> > -\tcase ControlValueNone:\n> > -\t\treturn \"<None>\";\n> > -\tcase ControlValueBool:\n> > -\t\treturn bool_ ? \"True\" : \"False\";\n> > -\tcase ControlValueInteger:\n> > -\t\treturn std::to_string(integer_);\n> > -\tcase ControlValueInteger64:\n> > -\t\treturn std::to_string(integer64_);\n> > -\t}\n> > -\n> > -\treturn \"<ValueType Error>\";\n> > -}\n> > -\n> >  /**\n> >   * \\enum ControlId\n> >   * \\brief Numerical control ID\n> > @@ -269,9 +112,9 @@ extern const std::unordered_map<ControlId, ControlIdentifier> controlTypes;\n> >   * \\param[in] min The control minimum value\n> >   * \\param[in] max The control maximum value\n> >   */\n> > -ControlInfo::ControlInfo(ControlId id, const ControlValue &min,\n> > -\t\t\t const ControlValue &max)\n> > -\t: min_(min), max_(max)\n> > +ControlInfo::ControlInfo(ControlId id, const DataValue &min,\n> > +\t\t\t const DataValue &max)\n> > +\t: DataInfo(min, max)\n> >  {\n> >  \tauto iter = controlTypes.find(id);\n> >  \tif (iter == controlTypes.end()) {\n> > @@ -296,79 +139,23 @@ ControlInfo::ControlInfo(ControlId id, const ControlValue &min,\n> >\n> >  /**\n> >   * \\fn ControlInfo::type()\n> > - * \\brief Retrieve the control data type\n> > - * \\return The control data type\n> > - */\n> > -\n> > -/**\n> > - * \\fn ControlInfo::min()\n> > - * \\brief Retrieve the minimum value of the control\n> > - * \\return A ControlValue with the minimum value for the control\n> > - */\n> > -\n> > -/**\n> > - * \\fn ControlInfo::max()\n> > - * \\brief Retrieve the maximum value of the control\n> > - * \\return A ControlValue with the maximum value for the control\n> > + * \\brief Retrieve the control designated type\n> > + * \\return The control type\n>\n> Is it inaccurate to leave this as \"Retrieve the control data type\"?\n> Isn't that what is returned?\n\nYes, I chose 'designated' to convey that a control has a type assigned\n'by design'. It's redundant, I'll remove.\n\n>\n> >   */\n> >\n> >  /**\n> >   * \\brief Provide a string representation of the ControlInfo\n> > + * \\return The control name\n> >   */\n> >  std::string ControlInfo::toString() const\n> >  {\n> >  \tstd::stringstream ss;\n> >\n> > -\tss << name() << \"[\" << min_.toString() << \"..\" << max_.toString() << \"]\";\n> > +\tss << name() << \"[\" << min().toString() << \"..\" << max().toString() << \"]\";\n> >\n> >  \treturn ss.str();\n> >  }\n> >\n> > -/**\n> > - * \\brief Compare control information for equality\n> > - * \\param[in] lhs Left-hand side control information\n> > - * \\param[in] rhs Right-hand side control information\n> > - *\n> > - * Control information is compared based on the ID only, as a camera may not\n> > - * have two separate controls with the same ID.\n> > - *\n> > - * \\return True if \\a lhs and \\a rhs are equal, false otherwise\n> > - */\n> > -bool operator==(const ControlInfo &lhs, const ControlInfo &rhs)\n> > -{\n> > -\treturn lhs.id() == rhs.id();\n> > -}\n> > -\n> > -/**\n> > - * \\brief Compare control ID and information for equality\n> > - * \\param[in] lhs Left-hand side control identifier\n> > - * \\param[in] rhs Right-hand side control information\n> > - *\n> > - * Control information is compared based on the ID only, as a camera may not\n> > - * have two separate controls with the same ID.\n> > - *\n> > - * \\return True if \\a lhs and \\a rhs are equal, false otherwise\n> > - */\n> > -bool operator==(const ControlId &lhs, const ControlInfo &rhs)\n> > -{\n> > -\treturn lhs == rhs.id();\n> > -}\n> > -\n> > -/**\n> > - * \\brief Compare control information and ID for equality\n> > - * \\param[in] lhs Left-hand side control information\n> > - * \\param[in] rhs Right-hand side control identifier\n> > - *\n> > - * Control information is compared based on the ID only, as a camera may not\n> > - * have two separate controls with the same ID.\n> > - *\n> > - * \\return True if \\a lhs and \\a rhs are equal, false otherwise\n> > - */\n> > -bool operator==(const ControlInfo &lhs, const ControlId &rhs)\n> > -{\n> > -\treturn lhs.id() == rhs;\n> > -}\n> > -\n>\n> I'm quite a bit scared seeing those operator== removals in this patch.\n> Have you run all the tests on this patch?\n> Do they still function (i.e. maintain bisect-ability) at this point?\n\nof course\n\n>\n> I wonder if we even had anything testing this specific part in fact.\n\nProbably not, but I don't see them being used anywhere in the code\nbase\n\n>\n>\n>\n> >  /**\n> >   * \\typedef ControlInfoMap\n> >   * \\brief A map of ControlId to ControlInfo\n> > @@ -378,7 +165,7 @@ bool operator==(const ControlInfo &lhs, const ControlId &rhs)\n> >   * \\class ControlList\n> >   * \\brief Associate a list of ControlId with their values for a camera\n> >   *\n> > - * A ControlList wraps a map of ControlId to ControlValue and provide\n> > + * A ControlList wraps a map of ControlId to DataValue and provide\n> >   * additional validation against the control information exposed by a Camera.\n> >   *\n> >   * A list is only valid for as long as the camera it refers to is valid. After\n> > @@ -474,7 +261,7 @@ bool ControlList::contains(const ControlInfo *info) const\n> >  /**\n> >   * \\fn ControlList::size()\n> >   * \\brief Retrieve the number of controls in the list\n> > - * \\return The number of Control entries stored in the list\n> > + * \\return The number of DataValue entries stored in the list\n> >   */\n> >\n> >  /**\n> > @@ -494,7 +281,7 @@ bool ControlList::contains(const ControlInfo *info) const\n> >   *\n> >   * \\return A reference to the value of the control identified by \\a id\n> >   */\n> > -ControlValue &ControlList::operator[](ControlId id)\n> > +DataValue &ControlList::operator[](ControlId id)\n> >  {\n> >  \tconst ControlInfoMap &controls = camera_->controls();\n> >  \tconst auto iter = controls.find(id);\n> > @@ -503,7 +290,7 @@ ControlValue &ControlList::operator[](ControlId id)\n> >  \t\t\t<< \"Camera \" << camera_->name()\n> >  \t\t\t<< \" does not support control \" << id;\n> >\n> > -\t\tstatic ControlValue empty;\n> > +\t\tstatic DataValue empty;\n> >  \t\treturn empty;\n> >  \t}\n> >\n> > @@ -543,7 +330,7 @@ void ControlList::update(const ControlList &other)\n> >\n> >  \tfor (auto it : other) {\n> >  \t\tconst ControlInfo *info = it.first;\n> > -\t\tconst ControlValue &value = it.second;\n> > +\t\tconst DataValue &value = it.second;\n> >\n> >  \t\tcontrols_[info] = value;\n> >  \t}\n> > diff --git a/src/libcamera/gen-controls.awk b/src/libcamera/gen-controls.awk\n> > index f3d068123012..abeb0218546b 100755\n> > --- a/src/libcamera/gen-controls.awk\n> > +++ b/src/libcamera/gen-controls.awk\n> > @@ -92,7 +92,7 @@ function GenerateTable(file) {\n> >  \tprint \"extern const std::unordered_map<ControlId, ControlIdentifier>\" > file\n> >  \tprint \"controlTypes {\" > file\n> >  \tfor (i=1; i <= id; ++i) {\n> > -\t\tprintf \"\\t{ %s, { %s, \\\"%s\\\", ControlValue%s } },\\n\", names[i], names[i], names[i], types[i] > file\n> > +\t\tprintf \"\\t{ %s, { %s, \\\"%s\\\", DataType%s } },\\n\", names[i], names[i], names[i], types[i] > file\n> >  \t}\n> >  \tprint \"};\" > file\n> >  \tExitNameSpace(file)\n> > diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> > index 8965210550d2..dd253f94ca3d 100644\n> > --- a/src/libcamera/pipeline/uvcvideo.cpp\n> > +++ b/src/libcamera/pipeline/uvcvideo.cpp\n> > @@ -231,7 +231,7 @@ int PipelineHandlerUVC::processControls(UVCCameraData *data, Request *request)\n> >\n> >  \tfor (auto it : request->controls()) {\n> >  \t\tconst ControlInfo *ci = it.first;\n> > -\t\tControlValue &value = it.second;\n> > +\t\tDataValue &value = it.second;\n> >\n> >  \t\tswitch (ci->id()) {\n> >  \t\tcase Brightness:\n> > diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\n> > index f26a91f86ec1..3df239bdb277 100644\n> > --- a/src/libcamera/pipeline/vimc.cpp\n> > +++ b/src/libcamera/pipeline/vimc.cpp\n> > @@ -284,7 +284,7 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)\n> >\n> >  \tfor (auto it : request->controls()) {\n> >  \t\tconst ControlInfo *ci = it.first;\n> > -\t\tControlValue &value = it.second;\n> > +\t\tDataValue &value = it.second;\n> >\n> >  \t\tswitch (ci->id()) {\n> >  \t\tcase Brightness:\n> > diff --git a/test/controls/control_info.cpp b/test/controls/control_info.cpp\n> > index aa3a65b1e5ef..c3f9b85580a7 100644\n> > --- a/test/controls/control_info.cpp\n> > +++ b/test/controls/control_info.cpp\n> > @@ -26,7 +26,7 @@ protected:\n> >  \t\tControlInfo info(Brightness);\n> >\n> >  \t\tif (info.id() != Brightness ||\n> > -\t\t    info.type() != ControlValueInteger ||\n> > +\t\t    info.type() != DataTypeInteger ||\n> >  \t\t    info.name() != std::string(\"Brightness\")) {\n> >  \t\t\tcout << \"Invalid control identification for Brightness\" << endl;\n> >  \t\t\treturn TestFail;\n> > @@ -44,7 +44,7 @@ protected:\n> >  \t\tinfo = ControlInfo(Contrast, 10, 200);\n> >\n> >  \t\tif (info.id() != Contrast ||\n> > -\t\t    info.type() != ControlValueInteger ||\n> > +\t\t    info.type() != DataTypeInteger ||\n> >  \t\t    info.name() != std::string(\"Contrast\")) {\n> >  \t\t\tcout << \"Invalid control identification for Contrast\" << endl;\n> >  \t\t\treturn TestFail;\n> > diff --git a/test/controls/control_value.cpp b/test/controls/control_value.cpp\n> > deleted file mode 100644\n> > index 778efe5c115f..000000000000\n> > --- a/test/controls/control_value.cpp\n> > +++ /dev/null\n> > @@ -1,69 +0,0 @@\n> > -/* SPDX-License-Identifier: GPL-2.0-or-later */\n> > -/*\n> > - * Copyright (C) 2019, Google Inc.\n> > - *\n> > - * control_value.cpp - ControlValue tests\n> > - */\n> > -\n> > -#include <iostream>\n> > -\n> > -#include <libcamera/controls.h>\n> > -\n> > -#include \"test.h\"\n> > -\n> > -using namespace std;\n> > -using namespace libcamera;\n> > -\n> > -class ControlValueTest : public Test\n> > -{\n> > -protected:\n> > -\tint run()\n> > -\t{\n> > -\t\tControlValue integer(1234);\n> > -\t\tControlValue boolean(true);\n> > -\n> > -\t\t/* Just a string conversion output test... no validation */\n> > -\t\tcout << \"Int: \" << integer.toString()\n> > -\t\t     << \" Bool: \" << boolean.toString()\n> > -\t\t     << endl;\n> > -\n> > -\t\tif (integer.getInt() != 1234) {\n> > -\t\t\tcerr << \"Failed to get Integer\" << endl;\n> > -\t\t\treturn TestFail;\n> > -\t\t}\n> > -\n> > -\t\tif (boolean.getBool() != true) {\n> > -\t\t\tcerr << \"Failed to get Boolean\" << endl;\n> > -\t\t\treturn TestFail;\n> > -\t\t}\n> > -\n> > -\t\t/* Test an uninitialised value, and updating it. */\n> > -\n> > -\t\tControlValue value;\n> > -\t\tif (!value.isNone()) {\n> > -\t\t\tcerr << \"Empty value is non-null\" << endl;\n> > -\t\t\treturn TestFail;\n> > -\t\t}\n> > -\n> > -\t\tvalue.set(true);\n> > -\t\tif (value.isNone()) {\n> > -\t\t\tcerr << \"Failed to set an empty object\" << endl;\n> > -\t\t\treturn TestFail;\n> > -\t\t}\n> > -\n> > -\t\tif (value.getBool() != true) {\n> > -\t\t\tcerr << \"Failed to get Booleans\" << endl;\n> > -\t\t\treturn TestFail;\n> > -\t\t}\n> > -\n> > -\t\tvalue.set(10);\n> > -\t\tif (value.getInt() != 10) {\n> > -\t\t\tcerr << \"Failed to get Integer\" << endl;\n> > -\t\t\treturn TestFail;\n> > -\t\t}\n> > -\n> > -\t\treturn TestPass;\n> > -\t}\n> > -};\n> > -\n> > -TEST_REGISTER(ControlValueTest)\n> > diff --git a/test/controls/meson.build b/test/controls/meson.build\n> > index f4fc7b947dd9..9070be85718b 100644\n> > --- a/test/controls/meson.build\n> > +++ b/test/controls/meson.build\n> > @@ -1,7 +1,6 @@\n> >  control_tests = [\n> >      [ 'control_info',   'control_info.cpp' ],\n> >      [ 'control_list',   'control_list.cpp' ],\n> > -    [ 'control_value',  'control_value.cpp' ],\n> >  ]\n> >\n> >  foreach t : control_tests\n> > --\n> > 2.23.0\n> >\n> > _______________________________________________\n> > libcamera-devel mailing list\n> > libcamera-devel@lists.libcamera.org\n> > https://lists.libcamera.org/listinfo/libcamera-devel\n> >\n>\n> --\n> Regards\n> --\n> Kieran","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 41D2F60BCE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Sep 2019 13:04:23 +0200 (CEST)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 8B9091BF20F;\n\tMon, 23 Sep 2019 11:04:22 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Mon, 23 Sep 2019 13:06:02 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190923110602.34mx76lxf4teq2m5@uno.localdomain>","References":"<20190918103424.14536-1-jacopo@jmondi.org>\n\t<20190918103424.14536-3-jacopo@jmondi.org>\n\t<f09688b6-07cf-e356-4ed2-51b06f92cf6f@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"otuk5t5o7sqyhwyx\"","Content-Disposition":"inline","In-Reply-To":"<f09688b6-07cf-e356-4ed2-51b06f92cf6f@ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH 2/5] libcamera: controls: Use DataType\n\tand DataValue","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":"Mon, 23 Sep 2019 11:04:23 -0000"}}]