mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 15:29:45 +03:00
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>
This commit is contained in:
parent
73b7ba9da5
commit
e5a9e6e9cd
15 changed files with 100 additions and 101 deletions
|
@ -33,7 +33,7 @@ struct ipa_control_value_entry {
|
||||||
uint32_t padding[1];
|
uint32_t padding[1];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ipa_control_range_entry {
|
struct ipa_control_info_entry {
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
|
|
|
@ -229,12 +229,12 @@ private:
|
||||||
Control &operator=(const Control &) = delete;
|
Control &operator=(const Control &) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ControlRange
|
class ControlInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ControlRange(const ControlValue &min = 0,
|
explicit ControlInfo(const ControlValue &min = 0,
|
||||||
const ControlValue &max = 0,
|
const ControlValue &max = 0,
|
||||||
const ControlValue &def = 0);
|
const ControlValue &def = 0);
|
||||||
|
|
||||||
const ControlValue &min() const { return min_; }
|
const ControlValue &min() const { return min_; }
|
||||||
const ControlValue &max() const { return max_; }
|
const ControlValue &max() const { return max_; }
|
||||||
|
@ -242,12 +242,12 @@ public:
|
||||||
|
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
|
|
||||||
bool operator==(const ControlRange &other) const
|
bool operator==(const ControlInfo &other) const
|
||||||
{
|
{
|
||||||
return min_ == other.min_ && max_ == other.max_;
|
return min_ == other.min_ && max_ == other.max_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const ControlRange &other) const
|
bool operator!=(const ControlInfo &other) const
|
||||||
{
|
{
|
||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
|
@ -260,10 +260,10 @@ private:
|
||||||
|
|
||||||
using ControlIdMap = std::unordered_map<unsigned int, const ControlId *>;
|
using ControlIdMap = std::unordered_map<unsigned int, const ControlId *>;
|
||||||
|
|
||||||
class ControlInfoMap : private std::unordered_map<const ControlId *, ControlRange>
|
class ControlInfoMap : private std::unordered_map<const ControlId *, ControlInfo>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using Map = std::unordered_map<const ControlId *, ControlRange>;
|
using Map = std::unordered_map<const ControlId *, ControlInfo>;
|
||||||
|
|
||||||
ControlInfoMap() = default;
|
ControlInfoMap() = default;
|
||||||
ControlInfoMap(const ControlInfoMap &other) = default;
|
ControlInfoMap(const ControlInfoMap &other) = default;
|
||||||
|
|
|
@ -99,9 +99,9 @@ size_t ControlSerializer::binarySize(const ControlValue &value)
|
||||||
return value.data().size_bytes();
|
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 ControlSerializer::binarySize(const ControlInfoMap &infoMap)
|
||||||
{
|
{
|
||||||
size_t size = sizeof(struct ipa_controls_header)
|
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)
|
for (const auto &ctrl : infoMap)
|
||||||
size += binarySize(ctrl.second);
|
size += binarySize(ctrl.second);
|
||||||
|
@ -150,11 +150,10 @@ void ControlSerializer::store(const ControlValue &value,
|
||||||
buffer.write(value.data());
|
buffer.write(value.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ControlSerializer::store(const ControlRange &range,
|
void ControlSerializer::store(const ControlInfo &info, ByteStreamBuffer &buffer)
|
||||||
ByteStreamBuffer &buffer)
|
|
||||||
{
|
{
|
||||||
store(range.min(), buffer);
|
store(info.min(), buffer);
|
||||||
store(range.max(), buffer);
|
store(info.max(), buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -176,7 +175,7 @@ int ControlSerializer::serialize(const ControlInfoMap &infoMap,
|
||||||
{
|
{
|
||||||
/* Compute entries and data required sizes. */
|
/* Compute entries and data required sizes. */
|
||||||
size_t entriesSize = infoMap.size()
|
size_t entriesSize = infoMap.size()
|
||||||
* sizeof(struct ipa_control_range_entry);
|
* sizeof(struct ipa_control_info_entry);
|
||||||
size_t valuesSize = 0;
|
size_t valuesSize = 0;
|
||||||
for (const auto &ctrl : infoMap)
|
for (const auto &ctrl : infoMap)
|
||||||
valuesSize += binarySize(ctrl.second);
|
valuesSize += binarySize(ctrl.second);
|
||||||
|
@ -200,15 +199,15 @@ int ControlSerializer::serialize(const ControlInfoMap &infoMap,
|
||||||
|
|
||||||
for (const auto &ctrl : infoMap) {
|
for (const auto &ctrl : infoMap) {
|
||||||
const ControlId *id = ctrl.first;
|
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.id = id->id();
|
||||||
entry.type = id->type();
|
entry.type = id->type();
|
||||||
entry.offset = values.offset();
|
entry.offset = values.offset();
|
||||||
entries.write(&entry);
|
entries.write(&entry);
|
||||||
|
|
||||||
store(range, values);
|
store(info, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer.overflow())
|
if (buffer.overflow())
|
||||||
|
@ -343,13 +342,13 @@ ControlValue ControlSerializer::loadControlValue(ControlType type,
|
||||||
return ControlValue();
|
return ControlValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlRange ControlSerializer::loadControlRange(ControlType type,
|
ControlInfo ControlSerializer::loadControlInfo(ControlType type,
|
||||||
ByteStreamBuffer &b)
|
ByteStreamBuffer &b)
|
||||||
{
|
{
|
||||||
ControlValue min = loadControlValue(type, b);
|
ControlValue min = loadControlValue(type, b);
|
||||||
ControlValue max = 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;
|
ControlInfoMap::Map ctrls;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < hdr->entries; ++i) {
|
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)>();
|
entries.read<decltype(*entry)>();
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
LOG(Serializer, Error) << "Out of data";
|
LOG(Serializer, Error) << "Out of data";
|
||||||
|
@ -419,9 +418,9 @@ ControlInfoMap ControlSerializer::deserialize<ControlInfoMap>(ByteStreamBuffer &
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create and store the ControlRange. */
|
/* Create and store the ControlInfo. */
|
||||||
ctrls.emplace(controlIds_.back().get(),
|
ctrls.emplace(controlIds_.back().get(),
|
||||||
loadControlRange(type, values));
|
loadControlInfo(type, values));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -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
|
* \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
|
* The constraints depend on the object the control applies to, and are
|
||||||
* constant for the lifetime of that object. They are typically constructed by
|
* constant for the lifetime of that object. They are typically constructed by
|
||||||
* pipeline handlers to describe the controls they support.
|
* 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] min The control minimum value
|
||||||
* \param[in] max The control maximum value
|
* \param[in] max The control maximum value
|
||||||
* \param[in] def The control default value
|
* \param[in] def The control default value
|
||||||
*/
|
*/
|
||||||
ControlRange::ControlRange(const ControlValue &min,
|
ControlInfo::ControlInfo(const ControlValue &min,
|
||||||
const ControlValue &max,
|
const ControlValue &max,
|
||||||
const ControlValue &def)
|
const ControlValue &def)
|
||||||
: min_(min), max_(max), def_(def)
|
: min_(min), max_(max), def_(def)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \fn ControlRange::min()
|
* \fn ControlInfo::min()
|
||||||
* \brief Retrieve the minimum value of the control
|
* \brief Retrieve the minimum value of the control
|
||||||
* \return A ControlValue with the minimum value for 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
|
* \brief Retrieve the maximum value of the control
|
||||||
* \return A ControlValue with the maximum value for 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
|
* \brief Retrieve the default value of the control
|
||||||
* \return A ControlValue with the default value for 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;
|
std::stringstream ss;
|
||||||
|
|
||||||
|
@ -467,15 +467,15 @@ std::string ControlRange::toString() const
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \fn bool ControlRange::operator==()
|
* \fn bool ControlInfo::operator==()
|
||||||
* \brief Compare ControlRange instances for equality
|
* \brief Compare ControlInfo instances for equality
|
||||||
* \return True if the ranges have identical min and max, false otherwise
|
* \return True if the constraints have identical min and max, false otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \fn bool ControlRange::operator!=()
|
* \fn bool ControlInfo::operator!=()
|
||||||
* \brief Compare ControlRange instances for non equality
|
* \brief Compare ControlInfo instances for non equality
|
||||||
* \return False if the ranges have identical min and max, true otherwise
|
* \return True if the constraints have different min and max, false otherwise
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -489,10 +489,10 @@ std::string ControlRange::toString() const
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class ControlInfoMap
|
* \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
|
* 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
|
* standard std::unsorted_map<> class, it is designed the be immutable once
|
||||||
* constructed, and thus only exposes the read accessors of the
|
* constructed, and thus only exposes the read accessors of the
|
||||||
* std::unsorted_map<> base class.
|
* std::unsorted_map<> base class.
|
||||||
|
@ -656,7 +656,7 @@ void ControlInfoMap::generateIdmap()
|
||||||
if (ctrl.first->type() != ctrl.second.min().type()) {
|
if (ctrl.first->type() != ctrl.second.min().type()) {
|
||||||
LOG(Controls, Error)
|
LOG(Controls, Error)
|
||||||
<< "Control " << utils::hex(ctrl.first->id())
|
<< "Control " << utils::hex(ctrl.first->id())
|
||||||
<< " type and range type mismatch";
|
<< " type and info type mismatch";
|
||||||
idmap_.clear();
|
idmap_.clear();
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -35,17 +35,17 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static size_t binarySize(const ControlValue &value);
|
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 ControlValue &value, ByteStreamBuffer &buffer);
|
||||||
static void store(const ControlRange &range, ByteStreamBuffer &buffer);
|
static void store(const ControlInfo &info, ByteStreamBuffer &buffer);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ControlValue loadControlValue(ByteStreamBuffer &buffer, bool isArray,
|
ControlValue loadControlValue(ByteStreamBuffer &buffer, bool isArray,
|
||||||
unsigned int count);
|
unsigned int count);
|
||||||
ControlValue loadControlValue(ControlType type, ByteStreamBuffer &buffer,
|
ControlValue loadControlValue(ControlType type, ByteStreamBuffer &buffer,
|
||||||
bool isArray = false, unsigned int count = 1);
|
bool isArray = false, unsigned int count = 1);
|
||||||
ControlRange loadControlRange(ControlType type, ByteStreamBuffer &buffer);
|
ControlInfo loadControlInfo(ControlType type, ByteStreamBuffer &buffer);
|
||||||
|
|
||||||
unsigned int serial_;
|
unsigned int serial_;
|
||||||
std::vector<std::unique_ptr<ControlId>> controlIds_;
|
std::vector<std::unique_ptr<ControlId>> controlIds_;
|
||||||
|
|
|
@ -20,10 +20,10 @@ public:
|
||||||
V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl);
|
V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
class V4L2ControlRange : public ControlRange
|
class V4L2ControlInfo : public ControlInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl);
|
V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace libcamera */
|
} /* namespace libcamera */
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* transfer them through the IPA C interface and IPA IPC transports.
|
* 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
|
* 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
|
* described by the ipa_controls_header structure, followed by an array of
|
||||||
* fixed-size entries. Each entry is associated with data, stored either
|
* fixed-size entries. Each entry is associated with data, stored either
|
||||||
* directly in the entry, or in a data section after the entries array.
|
* 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 | | |
|
* | | #0 | | |
|
||||||
* Control | +-------------------------+ | |
|
* Control | +-------------------------+ | |
|
||||||
* range | | ... | | |
|
* info | | ... | | |
|
||||||
* entries | +-------------------------+ | |
|
* entries | +-------------------------+ | |
|
||||||
* | | ipa_control_range_entry | | hdr.size |
|
* | | ipa_control_info_entry | | hdr.size |
|
||||||
* \ | #hdr.entries - 1 | | |
|
* \ | #hdr.entries - 1 | | |
|
||||||
* +-------------------------+ | |
|
* +-------------------------+ | |
|
||||||
* | empty space (optional) | | |
|
* | empty space (optional) | | |
|
||||||
* +-------------------------+ <--´ . |
|
* +-------------------------+ <--´ . |
|
||||||
* / | ... | | entry[n].offset |
|
* / | ... | | entry[n].offset |
|
||||||
* Data | | ... | | |
|
* Data | | ... | | |
|
||||||
* section | | range data for entry #n | <-----´ |
|
* section | | info data for entry #n | <-----´ |
|
||||||
* \ | ... | |
|
* \ | ... | |
|
||||||
* +-------------------------+ |
|
* +-------------------------+ |
|
||||||
* | empty space (optional) | |
|
* | empty space (optional) | |
|
||||||
|
@ -100,8 +100,8 @@
|
||||||
*
|
*
|
||||||
* The packet header is identical to the ControlList packet header.
|
* The packet header is identical to the ControlList packet header.
|
||||||
*
|
*
|
||||||
* Entries are described by the ipa_control_range_entry structure. They contain
|
* Entries are described by the ipa_control_info_entry structure. They contain
|
||||||
* the numerical ID and type of the control. The control range data is stored
|
* the numerical ID and type of the control. The control info data is stored
|
||||||
* in the data section as described by the following diagram.
|
* 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
|
* 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
|
* format. The ipa_control_info_entry::offset field stores the offset from the
|
||||||
* beginning of the data section to the range data.
|
* 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
|
* entries array, shall be aligned to a multiple of 8 bytes, and shall be
|
||||||
* contiguous in memory.
|
* 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");
|
"Invalid ABI size change for struct ipa_control_value_entry");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \struct ipa_control_range_entry
|
* \struct ipa_control_info_entry
|
||||||
* \brief Description of a serialized ControlRange entry
|
* \brief Description of a serialized ControlInfo entry
|
||||||
* \var ipa_control_range_entry::id
|
* \var ipa_control_info_entry::id
|
||||||
* The numerical ID of the control
|
* 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)
|
* 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
|
* The offset in bytes from the beginning of the data section to the control
|
||||||
* range data (shall be a multiple of 8 bytes)
|
* info data (shall be a multiple of 8 bytes)
|
||||||
* \var ipa_control_range_entry::padding
|
* \var ipa_control_info_entry::padding
|
||||||
* Padding bytes (shall be set to 0)
|
* Padding bytes (shall be set to 0)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static_assert(sizeof(ipa_control_range_entry) == 16,
|
static_assert(sizeof(ipa_control_info_entry) == 16,
|
||||||
"Invalid ABI size change for struct ipa_control_range_entry");
|
"Invalid ABI size change for struct ipa_control_info_entry");
|
||||||
|
|
|
@ -350,7 +350,7 @@ int UVCCameraData::init(MediaEntity *entity)
|
||||||
ControlInfoMap::Map ctrls;
|
ControlInfoMap::Map ctrls;
|
||||||
|
|
||||||
for (const auto &ctrl : controls) {
|
for (const auto &ctrl : controls) {
|
||||||
const ControlRange &range = ctrl.second;
|
const ControlInfo &info = ctrl.second;
|
||||||
const ControlId *id;
|
const ControlId *id;
|
||||||
|
|
||||||
switch (ctrl.first->id()) {
|
switch (ctrl.first->id()) {
|
||||||
|
@ -373,7 +373,7 @@ int UVCCameraData::init(MediaEntity *entity)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrls.emplace(id, range);
|
ctrls.emplace(id, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
controlInfo_ = std::move(ctrls);
|
controlInfo_ = std::move(ctrls);
|
||||||
|
|
|
@ -426,7 +426,7 @@ int VimcCameraData::init(MediaDevice *media)
|
||||||
ControlInfoMap::Map ctrls;
|
ControlInfoMap::Map ctrls;
|
||||||
|
|
||||||
for (const auto &ctrl : controls) {
|
for (const auto &ctrl : controls) {
|
||||||
const ControlRange &range = ctrl.second;
|
const ControlInfo &info = ctrl.second;
|
||||||
const ControlId *id;
|
const ControlId *id;
|
||||||
|
|
||||||
switch (ctrl.first->id()) {
|
switch (ctrl.first->id()) {
|
||||||
|
@ -443,7 +443,7 @@ int VimcCameraData::init(MediaDevice *media)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrls.emplace(id, range);
|
ctrls.emplace(id, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
controlInfo_ = std::move(ctrls);
|
controlInfo_ = std::move(ctrls);
|
||||||
|
|
|
@ -104,37 +104,37 @@ V4L2ControlId::V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class V4L2ControlRange
|
* \class V4L2ControlInfo
|
||||||
* \brief Convenience specialisation of ControlRange for V4L2 controls
|
* \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
|
* 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
|
* \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) {
|
switch (ctrl.type) {
|
||||||
case V4L2_CTRL_TYPE_BOOLEAN:
|
case V4L2_CTRL_TYPE_BOOLEAN:
|
||||||
ControlRange::operator=(ControlRange(static_cast<bool>(ctrl.minimum),
|
ControlInfo::operator=(ControlInfo(static_cast<bool>(ctrl.minimum),
|
||||||
static_cast<bool>(ctrl.maximum),
|
static_cast<bool>(ctrl.maximum),
|
||||||
static_cast<bool>(ctrl.default_value)));
|
static_cast<bool>(ctrl.default_value)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case V4L2_CTRL_TYPE_INTEGER64:
|
case V4L2_CTRL_TYPE_INTEGER64:
|
||||||
ControlRange::operator=(ControlRange(static_cast<int64_t>(ctrl.minimum),
|
ControlInfo::operator=(ControlInfo(static_cast<int64_t>(ctrl.minimum),
|
||||||
static_cast<int64_t>(ctrl.maximum),
|
static_cast<int64_t>(ctrl.maximum),
|
||||||
static_cast<int64_t>(ctrl.default_value)));
|
static_cast<int64_t>(ctrl.default_value)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ControlRange::operator=(ControlRange(static_cast<int32_t>(ctrl.minimum),
|
ControlInfo::operator=(ControlInfo(static_cast<int32_t>(ctrl.minimum),
|
||||||
static_cast<int32_t>(ctrl.maximum),
|
static_cast<int32_t>(ctrl.maximum),
|
||||||
static_cast<int32_t>(ctrl.default_value)));
|
static_cast<int32_t>(ctrl.default_value)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,7 +381,7 @@ void V4L2Device::listControls()
|
||||||
}
|
}
|
||||||
|
|
||||||
controlIds_.emplace_back(std::make_unique<V4L2ControlId>(ctrl));
|
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);
|
controls_ = std::move(ctrls);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2019, Google Inc.
|
* Copyright (C) 2019, Google Inc.
|
||||||
*
|
*
|
||||||
* control_range.cpp - ControlRange tests
|
* control_info.cpp - ControlInfo tests
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace libcamera;
|
using namespace libcamera;
|
||||||
|
|
||||||
class ControlRangeTest : public Test
|
class ControlInfoTest : public Test
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
int run()
|
int run()
|
||||||
|
@ -24,7 +24,7 @@ protected:
|
||||||
* Test information retrieval from a range with no minimum and
|
* Test information retrieval from a range with no minimum and
|
||||||
* maximum.
|
* maximum.
|
||||||
*/
|
*/
|
||||||
ControlRange brightness;
|
ControlInfo brightness;
|
||||||
|
|
||||||
if (brightness.min().get<int32_t>() != 0 ||
|
if (brightness.min().get<int32_t>() != 0 ||
|
||||||
brightness.max().get<int32_t>() != 0) {
|
brightness.max().get<int32_t>() != 0) {
|
||||||
|
@ -36,7 +36,7 @@ protected:
|
||||||
* Test information retrieval from a control with a minimum and
|
* Test information retrieval from a control with a minimum and
|
||||||
* a maximum value.
|
* a maximum value.
|
||||||
*/
|
*/
|
||||||
ControlRange contrast(10, 200);
|
ControlInfo contrast(10, 200);
|
||||||
|
|
||||||
if (contrast.min().get<int32_t>() != 10 ||
|
if (contrast.min().get<int32_t>() != 10 ||
|
||||||
contrast.max().get<int32_t>() != 200) {
|
contrast.max().get<int32_t>() != 200) {
|
||||||
|
@ -48,4 +48,4 @@ protected:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_REGISTER(ControlRangeTest)
|
TEST_REGISTER(ControlInfoTest)
|
|
@ -1,7 +1,7 @@
|
||||||
control_tests = [
|
control_tests = [
|
||||||
|
[ 'control_info', 'control_info.cpp' ],
|
||||||
[ 'control_info_map', 'control_info_map.cpp' ],
|
[ 'control_info_map', 'control_info_map.cpp' ],
|
||||||
[ 'control_list', 'control_list.cpp' ],
|
[ 'control_list', 'control_list.cpp' ],
|
||||||
[ 'control_range', 'control_range.cpp' ],
|
|
||||||
[ 'control_value', 'control_value.cpp' ],
|
[ 'control_value', 'control_value.cpp' ],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ using namespace libcamera;
|
||||||
|
|
||||||
bool SerializationTest::equals(const ControlInfoMap &lhs, const ControlInfoMap &rhs)
|
bool SerializationTest::equals(const ControlInfoMap &lhs, const ControlInfoMap &rhs)
|
||||||
{
|
{
|
||||||
std::map<unsigned int, ControlRange> rlhs;
|
std::map<unsigned int, ControlInfo> rlhs;
|
||||||
std::transform(lhs.begin(), lhs.end(), std::inserter(rlhs, rlhs.end()),
|
std::transform(lhs.begin(), lhs.end(), std::inserter(rlhs, rlhs.end()),
|
||||||
[](const ControlInfoMap::value_type &v)
|
[](const ControlInfoMap::value_type &v)
|
||||||
-> decltype(rlhs)::value_type
|
-> decltype(rlhs)::value_type
|
||||||
|
@ -30,7 +30,7 @@ bool SerializationTest::equals(const ControlInfoMap &lhs, const ControlInfoMap &
|
||||||
return { v.first->id(), v.second };
|
return { v.first->id(), v.second };
|
||||||
});
|
});
|
||||||
|
|
||||||
std::map<unsigned int, ControlRange> rrhs;
|
std::map<unsigned int, ControlInfo> rrhs;
|
||||||
std::transform(rhs.begin(), rhs.end(), std::inserter(rrhs, rrhs.end()),
|
std::transform(rhs.begin(), rhs.end(), std::inserter(rrhs, rrhs.end()),
|
||||||
[](const ControlInfoMap::value_type &v)
|
[](const ControlInfoMap::value_type &v)
|
||||||
-> decltype(rrhs)::value_type
|
-> decltype(rrhs)::value_type
|
||||||
|
|
|
@ -41,9 +41,9 @@ protected:
|
||||||
return TestFail;
|
return TestFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ControlRange &brightness = infoMap.find(V4L2_CID_BRIGHTNESS)->second;
|
const ControlInfo &brightness = infoMap.find(V4L2_CID_BRIGHTNESS)->second;
|
||||||
const ControlRange &contrast = infoMap.find(V4L2_CID_CONTRAST)->second;
|
const ControlInfo &contrast = infoMap.find(V4L2_CID_CONTRAST)->second;
|
||||||
const ControlRange &saturation = infoMap.find(V4L2_CID_SATURATION)->second;
|
const ControlInfo &saturation = infoMap.find(V4L2_CID_SATURATION)->second;
|
||||||
|
|
||||||
/* Test getting controls. */
|
/* Test getting controls. */
|
||||||
ControlList ctrls(infoMap);
|
ControlList ctrls(infoMap);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue