diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-03-01 22:02:37 +0200 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-03-20 16:47:45 +0200 |
commit | e5a9e6e9cd3e12efe9ce078171fbe67d7d41a771 (patch) | |
tree | c73bc72211ca61c44eda396151b466d4a7a8c1ab /src | |
parent | 73b7ba9da5fe7b1aec62af091ad36403cd3505c4 (diff) |
libcamera: controls: Rename ControlRange to ControlInfo
To prepare for storage of additional information in the ControlRange
structure, rename it to ControlInfo.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/control_serializer.cpp | 33 | ||||
-rw-r--r-- | src/libcamera/controls.cpp | 40 | ||||
-rw-r--r-- | src/libcamera/include/control_serializer.h | 6 | ||||
-rw-r--r-- | src/libcamera/include/v4l2_controls.h | 4 | ||||
-rw-r--r-- | src/libcamera/ipa_controls.cpp | 38 | ||||
-rw-r--r-- | src/libcamera/pipeline/uvcvideo.cpp | 4 | ||||
-rw-r--r-- | src/libcamera/pipeline/vimc.cpp | 4 | ||||
-rw-r--r-- | src/libcamera/v4l2_controls.cpp | 30 | ||||
-rw-r--r-- | src/libcamera/v4l2_device.cpp | 2 |
9 files changed, 80 insertions, 81 deletions
diff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp index dcc63d20..eef875f4 100644 --- a/src/libcamera/control_serializer.cpp +++ b/src/libcamera/control_serializer.cpp @@ -99,9 +99,9 @@ size_t ControlSerializer::binarySize(const ControlValue &value) return value.data().size_bytes(); } -size_t ControlSerializer::binarySize(const ControlRange &range) +size_t ControlSerializer::binarySize(const ControlInfo &info) { - return binarySize(range.min()) + binarySize(range.max()); + return binarySize(info.min()) + binarySize(info.max()); } /** @@ -116,7 +116,7 @@ size_t ControlSerializer::binarySize(const ControlRange &range) size_t ControlSerializer::binarySize(const ControlInfoMap &infoMap) { size_t size = sizeof(struct ipa_controls_header) - + infoMap.size() * sizeof(struct ipa_control_range_entry); + + infoMap.size() * sizeof(struct ipa_control_info_entry); for (const auto &ctrl : infoMap) size += binarySize(ctrl.second); @@ -150,11 +150,10 @@ void ControlSerializer::store(const ControlValue &value, buffer.write(value.data()); } -void ControlSerializer::store(const ControlRange &range, - ByteStreamBuffer &buffer) +void ControlSerializer::store(const ControlInfo &info, ByteStreamBuffer &buffer) { - store(range.min(), buffer); - store(range.max(), buffer); + store(info.min(), buffer); + store(info.max(), buffer); } /** @@ -176,7 +175,7 @@ int ControlSerializer::serialize(const ControlInfoMap &infoMap, { /* Compute entries and data required sizes. */ size_t entriesSize = infoMap.size() - * sizeof(struct ipa_control_range_entry); + * sizeof(struct ipa_control_info_entry); size_t valuesSize = 0; for (const auto &ctrl : infoMap) valuesSize += binarySize(ctrl.second); @@ -200,15 +199,15 @@ int ControlSerializer::serialize(const ControlInfoMap &infoMap, for (const auto &ctrl : infoMap) { const ControlId *id = ctrl.first; - const ControlRange &range = ctrl.second; + const ControlInfo &info = ctrl.second; - struct ipa_control_range_entry entry; + struct ipa_control_info_entry entry; entry.id = id->id(); entry.type = id->type(); entry.offset = values.offset(); entries.write(&entry); - store(range, values); + store(info, values); } if (buffer.overflow()) @@ -343,13 +342,13 @@ ControlValue ControlSerializer::loadControlValue(ControlType type, return ControlValue(); } -ControlRange ControlSerializer::loadControlRange(ControlType type, - ByteStreamBuffer &b) +ControlInfo ControlSerializer::loadControlInfo(ControlType type, + ByteStreamBuffer &b) { ControlValue min = loadControlValue(type, b); ControlValue max = loadControlValue(type, b); - return ControlRange(min, max); + return ControlInfo(min, max); } /** @@ -397,7 +396,7 @@ ControlInfoMap ControlSerializer::deserialize<ControlInfoMap>(ByteStreamBuffer & ControlInfoMap::Map ctrls; for (unsigned int i = 0; i < hdr->entries; ++i) { - const struct ipa_control_range_entry *entry = + const struct ipa_control_info_entry *entry = entries.read<decltype(*entry)>(); if (!entry) { LOG(Serializer, Error) << "Out of data"; @@ -419,9 +418,9 @@ ControlInfoMap ControlSerializer::deserialize<ControlInfoMap>(ByteStreamBuffer & return {}; } - /* Create and store the ControlRange. */ + /* Create and store the ControlInfo. */ ctrls.emplace(controlIds_.back().get(), - loadControlRange(type, values)); + loadControlInfo(type, values)); } /* diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 833a436c..53649fe8 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -414,50 +414,50 @@ void ControlValue::set(ControlType type, bool isArray, const void *data, */ /** - * \class ControlRange + * \class ControlInfo * \brief Describe the limits of valid values for a Control * - * The ControlRange expresses the constraints on valid values for a control. + * The ControlInfo expresses the constraints on valid values for a control. * The constraints depend on the object the control applies to, and are * constant for the lifetime of that object. They are typically constructed by * pipeline handlers to describe the controls they support. */ /** - * \brief Construct a ControlRange with minimum and maximum range parameters + * \brief Construct a ControlInfo with minimum and maximum range parameters * \param[in] min The control minimum value * \param[in] max The control maximum value * \param[in] def The control default value */ -ControlRange::ControlRange(const ControlValue &min, - const ControlValue &max, - const ControlValue &def) +ControlInfo::ControlInfo(const ControlValue &min, + const ControlValue &max, + const ControlValue &def) : min_(min), max_(max), def_(def) { } /** - * \fn ControlRange::min() + * \fn ControlInfo::min() * \brief Retrieve the minimum value of the control * \return A ControlValue with the minimum value for the control */ /** - * \fn ControlRange::max() + * \fn ControlInfo::max() * \brief Retrieve the maximum value of the control * \return A ControlValue with the maximum value for the control */ /** - * \fn ControlRange::def() + * \fn ControlInfo::def() * \brief Retrieve the default value of the control * \return A ControlValue with the default value for the control */ /** - * \brief Provide a string representation of the ControlRange + * \brief Provide a string representation of the ControlInfo */ -std::string ControlRange::toString() const +std::string ControlInfo::toString() const { std::stringstream ss; @@ -467,15 +467,15 @@ std::string ControlRange::toString() const } /** - * \fn bool ControlRange::operator==() - * \brief Compare ControlRange instances for equality - * \return True if the ranges have identical min and max, false otherwise + * \fn bool ControlInfo::operator==() + * \brief Compare ControlInfo instances for equality + * \return True if the constraints have identical min and max, false otherwise */ /** - * \fn bool ControlRange::operator!=() - * \brief Compare ControlRange instances for non equality - * \return False if the ranges have identical min and max, true otherwise + * \fn bool ControlInfo::operator!=() + * \brief Compare ControlInfo instances for non equality + * \return True if the constraints have different min and max, false otherwise */ /** @@ -489,10 +489,10 @@ std::string ControlRange::toString() const /** * \class ControlInfoMap - * \brief A map of ControlId to ControlRange + * \brief A map of ControlId to ControlInfo * * The ControlInfoMap class describes controls supported by an object as an - * unsorted map of ControlId pointers to ControlRange instances. Unlike the + * unsorted map of ControlId pointers to ControlInfo instances. Unlike the * standard std::unsorted_map<> class, it is designed the be immutable once * constructed, and thus only exposes the read accessors of the * std::unsorted_map<> base class. @@ -656,7 +656,7 @@ void ControlInfoMap::generateIdmap() if (ctrl.first->type() != ctrl.second.min().type()) { LOG(Controls, Error) << "Control " << utils::hex(ctrl.first->id()) - << " type and range type mismatch"; + << " type and info type mismatch"; idmap_.clear(); clear(); return; diff --git a/src/libcamera/include/control_serializer.h b/src/libcamera/include/control_serializer.h index 026e6234..70aa28fd 100644 --- a/src/libcamera/include/control_serializer.h +++ b/src/libcamera/include/control_serializer.h @@ -35,17 +35,17 @@ public: private: static size_t binarySize(const ControlValue &value); - static size_t binarySize(const ControlRange &range); + static size_t binarySize(const ControlInfo &info); static void store(const ControlValue &value, ByteStreamBuffer &buffer); - static void store(const ControlRange &range, ByteStreamBuffer &buffer); + static void store(const ControlInfo &info, ByteStreamBuffer &buffer); template<typename T> ControlValue loadControlValue(ByteStreamBuffer &buffer, bool isArray, unsigned int count); ControlValue loadControlValue(ControlType type, ByteStreamBuffer &buffer, bool isArray = false, unsigned int count = 1); - ControlRange loadControlRange(ControlType type, ByteStreamBuffer &buffer); + ControlInfo loadControlInfo(ControlType type, ByteStreamBuffer &buffer); unsigned int serial_; std::vector<std::unique_ptr<ControlId>> controlIds_; diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h index 882546a8..cffe9efd 100644 --- a/src/libcamera/include/v4l2_controls.h +++ b/src/libcamera/include/v4l2_controls.h @@ -20,10 +20,10 @@ public: V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl); }; -class V4L2ControlRange : public ControlRange +class V4L2ControlInfo : public ControlInfo { public: - V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl); + V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl); }; } /* namespace libcamera */ diff --git a/src/libcamera/ipa_controls.cpp b/src/libcamera/ipa_controls.cpp index da4724b1..b1d14190 100644 --- a/src/libcamera/ipa_controls.cpp +++ b/src/libcamera/ipa_controls.cpp @@ -18,7 +18,7 @@ * transfer them through the IPA C interface and IPA IPC transports. * * A control packet contains a list of entries, each of them describing a single - * control range or control value. The packet starts with a fixed-size header + * control info or control value. The packet starts with a fixed-size header * described by the ipa_controls_header structure, followed by an array of * fixed-size entries. Each entry is associated with data, stored either * directly in the entry, or in a data section after the entries array. @@ -79,19 +79,19 @@ * | | | | | * \ | | | | * +-------------------------+ | | - * / | ipa_control_range_entry | | hdr.data_offset | + * / | ipa_control_info_entry | | hdr.data_offset | * | | #0 | | | * Control | +-------------------------+ | | - * range | | ... | | | + * info | | ... | | | * entries | +-------------------------+ | | - * | | ipa_control_range_entry | | hdr.size | + * | | ipa_control_info_entry | | hdr.size | * \ | #hdr.entries - 1 | | | * +-------------------------+ | | * | empty space (optional) | | | * +-------------------------+ <--´ . | * / | ... | | entry[n].offset | * Data | | ... | | | - * section | | range data for entry #n | <-----´ | + * section | | info data for entry #n | <-----´ | * \ | ... | | * +-------------------------+ | * | empty space (optional) | | @@ -100,8 +100,8 @@ * * The packet header is identical to the ControlList packet header. * - * Entries are described by the ipa_control_range_entry structure. They contain - * the numerical ID and type of the control. The control range data is stored + * Entries are described by the ipa_control_info_entry structure. They contain + * the numerical ID and type of the control. The control info data is stored * in the data section as described by the following diagram. * * ~~~~ @@ -117,10 +117,10 @@ * ~~~~ * * The minimum and maximum value are stored in the platform's native data - * format. The ipa_control_range_entry::offset field stores the offset from the - * beginning of the data section to the range data. + * format. The ipa_control_info_entry::offset field stores the offset from the + * beginning of the data section to the info data. * - * Range data in the data section shall be stored in the same order as the + * Info data in the data section shall be stored in the same order as the * entries array, shall be aligned to a multiple of 8 bytes, and shall be * contiguous in memory. * @@ -178,18 +178,18 @@ static_assert(sizeof(ipa_control_value_entry) == 16, "Invalid ABI size change for struct ipa_control_value_entry"); /** - * \struct ipa_control_range_entry - * \brief Description of a serialized ControlRange entry - * \var ipa_control_range_entry::id + * \struct ipa_control_info_entry + * \brief Description of a serialized ControlInfo entry + * \var ipa_control_info_entry::id * The numerical ID of the control - * \var ipa_control_range_entry::type + * \var ipa_control_info_entry::type * The type of the control (defined by enum ControlType) - * \var ipa_control_range_entry::offset + * \var ipa_control_info_entry::offset * The offset in bytes from the beginning of the data section to the control - * range data (shall be a multiple of 8 bytes) - * \var ipa_control_range_entry::padding + * info data (shall be a multiple of 8 bytes) + * \var ipa_control_info_entry::padding * Padding bytes (shall be set to 0) */ -static_assert(sizeof(ipa_control_range_entry) == 16, - "Invalid ABI size change for struct ipa_control_range_entry"); +static_assert(sizeof(ipa_control_info_entry) == 16, + "Invalid ABI size change for struct ipa_control_info_entry"); diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp index 15c8baef..ffbddf27 100644 --- a/src/libcamera/pipeline/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo.cpp @@ -350,7 +350,7 @@ int UVCCameraData::init(MediaEntity *entity) ControlInfoMap::Map ctrls; for (const auto &ctrl : controls) { - const ControlRange &range = ctrl.second; + const ControlInfo &info = ctrl.second; const ControlId *id; switch (ctrl.first->id()) { @@ -373,7 +373,7 @@ int UVCCameraData::init(MediaEntity *entity) continue; } - ctrls.emplace(id, range); + ctrls.emplace(id, info); } controlInfo_ = std::move(ctrls); diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 50cab8af..b04a9726 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -426,7 +426,7 @@ int VimcCameraData::init(MediaDevice *media) ControlInfoMap::Map ctrls; for (const auto &ctrl : controls) { - const ControlRange &range = ctrl.second; + const ControlInfo &info = ctrl.second; const ControlId *id; switch (ctrl.first->id()) { @@ -443,7 +443,7 @@ int VimcCameraData::init(MediaDevice *media) continue; } - ctrls.emplace(id, range); + ctrls.emplace(id, info); } controlInfo_ = std::move(ctrls); diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp index 7446c388..4861f977 100644 --- a/src/libcamera/v4l2_controls.cpp +++ b/src/libcamera/v4l2_controls.cpp @@ -104,37 +104,37 @@ V4L2ControlId::V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl) } /** - * \class V4L2ControlRange - * \brief Convenience specialisation of ControlRange for V4L2 controls + * \class V4L2ControlInfo + * \brief Convenience specialisation of ControlInfo for V4L2 controls * - * The V4L2ControlRange class is a specialisation of the ControlRange for V4L2 + * The V4L2ControlInfo class is a specialisation of the ControlInfo for V4L2 * controls. It offers a convenience constructor from a struct - * v4l2_query_ext_ctrl, and is otherwise equivalent to the ControlRange class. + * v4l2_query_ext_ctrl, and is otherwise equivalent to the ControlInfo class. */ /** - * \brief Construct a V4L2ControlRange from a struct v4l2_query_ext_ctrl + * \brief Construct a V4L2ControlInfo from a struct v4l2_query_ext_ctrl * \param[in] ctrl The struct v4l2_query_ext_ctrl as returned by the kernel */ -V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl) +V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl) { switch (ctrl.type) { case V4L2_CTRL_TYPE_BOOLEAN: - ControlRange::operator=(ControlRange(static_cast<bool>(ctrl.minimum), - static_cast<bool>(ctrl.maximum), - static_cast<bool>(ctrl.default_value))); + ControlInfo::operator=(ControlInfo(static_cast<bool>(ctrl.minimum), + static_cast<bool>(ctrl.maximum), + static_cast<bool>(ctrl.default_value))); break; case V4L2_CTRL_TYPE_INTEGER64: - ControlRange::operator=(ControlRange(static_cast<int64_t>(ctrl.minimum), - static_cast<int64_t>(ctrl.maximum), - static_cast<int64_t>(ctrl.default_value))); + ControlInfo::operator=(ControlInfo(static_cast<int64_t>(ctrl.minimum), + static_cast<int64_t>(ctrl.maximum), + static_cast<int64_t>(ctrl.default_value))); break; default: - ControlRange::operator=(ControlRange(static_cast<int32_t>(ctrl.minimum), - static_cast<int32_t>(ctrl.maximum), - static_cast<int32_t>(ctrl.default_value))); + ControlInfo::operator=(ControlInfo(static_cast<int32_t>(ctrl.minimum), + static_cast<int32_t>(ctrl.maximum), + static_cast<int32_t>(ctrl.default_value))); break; } } diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 475572bb..179476e9 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -381,7 +381,7 @@ void V4L2Device::listControls() } controlIds_.emplace_back(std::make_unique<V4L2ControlId>(ctrl)); - ctrls.emplace(controlIds_.back().get(), V4L2ControlRange(ctrl)); + ctrls.emplace(controlIds_.back().get(), V4L2ControlInfo(ctrl)); } controls_ = std::move(ctrls); |