libcamera: v4l2_controls: Index V4L2ControlInfoMap by ControlId *

To bring the libcamera and V4L2 control info maps closer, index the
latter by ControlId * like the former. As V4L2ControlInfoMap is widely
indexed by V4L2 numerical IDs, add accessors based on numerical IDs.

This allows complete removal of the ControId pointer from the
V4L2ControlInfo, as the ControId is accessible as the key when iterating
over the map. A handful of users have to be modified to adapt to the
change.

The controlInfo argument from V4L2Device::updateControls() can also be
removed as it itsn't used anymore.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Laurent Pinchart
2019-10-13 23:34:29 +03:00
parent f24f77e7f5
commit 6d2411fcb7
6 changed files with 92 additions and 49 deletions
+25 -15
View File
@@ -28,31 +28,41 @@ public:
class V4L2ControlInfo
{
public:
V4L2ControlInfo(const V4L2ControlId &id,
const struct v4l2_query_ext_ctrl &ctrl);
V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl);
const ControlId &id() const { return *id_; }
const ControlRange &range() const { return range_; }
private:
const V4L2ControlId *id_;
ControlRange range_;
};
class V4L2ControlInfoMap : private std::map<unsigned int, V4L2ControlInfo>
class V4L2ControlInfoMap : private std::map<const ControlId *, V4L2ControlInfo>
{
public:
V4L2ControlInfoMap &operator=(std::map<unsigned int, V4L2ControlInfo> &&info);
V4L2ControlInfoMap &operator=(std::map<const ControlId *, V4L2ControlInfo> &&info);
using std::map<unsigned int, V4L2ControlInfo>::begin;
using std::map<unsigned int, V4L2ControlInfo>::cbegin;
using std::map<unsigned int, V4L2ControlInfo>::end;
using std::map<unsigned int, V4L2ControlInfo>::cend;
using std::map<unsigned int, V4L2ControlInfo>::at;
using std::map<unsigned int, V4L2ControlInfo>::empty;
using std::map<unsigned int, V4L2ControlInfo>::size;
using std::map<unsigned int, V4L2ControlInfo>::count;
using std::map<unsigned int, V4L2ControlInfo>::find;
using std::map<const ControlId *, V4L2ControlInfo>::key_type;
using std::map<const ControlId *, V4L2ControlInfo>::mapped_type;
using std::map<const ControlId *, V4L2ControlInfo>::value_type;
using std::map<const ControlId *, V4L2ControlInfo>::size_type;
using std::map<const ControlId *, V4L2ControlInfo>::iterator;
using std::map<const ControlId *, V4L2ControlInfo>::const_iterator;
using std::map<const ControlId *, V4L2ControlInfo>::begin;
using std::map<const ControlId *, V4L2ControlInfo>::cbegin;
using std::map<const ControlId *, V4L2ControlInfo>::end;
using std::map<const ControlId *, V4L2ControlInfo>::cend;
using std::map<const ControlId *, V4L2ControlInfo>::at;
using std::map<const ControlId *, V4L2ControlInfo>::empty;
using std::map<const ControlId *, V4L2ControlInfo>::size;
using std::map<const ControlId *, V4L2ControlInfo>::count;
using std::map<const ControlId *, V4L2ControlInfo>::find;
mapped_type &at(unsigned int key);
const mapped_type &at(unsigned int key) const;
size_type count(unsigned int key) const;
iterator find(unsigned int key);
const_iterator find(unsigned int key) const;
const ControlIdMap &idmap() const { return idmap_; }
-1
View File
@@ -45,7 +45,6 @@ protected:
private:
void listControls();
void updateControls(ControlList *ctrls,
const V4L2ControlInfo **controlInfo,
const struct v4l2_ext_control *v4l2Ctrls,
unsigned int count);