libcamera: v4l2_device: Replace V4L2ControlList with ControlList
The V4L2Device class uses V4L2ControlList as a controls container for the getControls() and setControls() operations. Having a distinct container from ControlList will makes the IPA API more complex, as it needs to explicitly transport both types of lists. This will become even more painful when implementing serialisation and deserialisation. To simplify the IPA API and ease the implementation of serialisation and deserialisation, replace usage of V4L2ControlList with ControlList in the V4L2Device (and thus CameraSensor) API. The V4L2ControlList class becomes a thin wrapper around ControlList that slightly simplifies the creation of control lists for V4L2 controls, and may be removed in the future. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Tested-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
@@ -13,11 +13,12 @@
|
||||
#include <libcamera/geometry.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "v4l2_controls.h"
|
||||
|
||||
namespace libcamera {
|
||||
|
||||
class ControlList;
|
||||
class MediaEntity;
|
||||
class V4L2ControlInfoMap;
|
||||
class V4L2Subdevice;
|
||||
|
||||
struct V4L2SubdeviceFormat;
|
||||
@@ -43,8 +44,8 @@ public:
|
||||
int setFormat(V4L2SubdeviceFormat *format);
|
||||
|
||||
const V4L2ControlInfoMap &controls() const;
|
||||
int getControls(V4L2ControlList *ctrls);
|
||||
int setControls(V4L2ControlList *ctrls);
|
||||
int getControls(ControlList *ctrls);
|
||||
int setControls(ControlList *ctrls);
|
||||
|
||||
protected:
|
||||
std::string logPrefix() const;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <linux/v4l2-controls.h>
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include <libcamera/controls.h>
|
||||
@@ -57,47 +56,20 @@ public:
|
||||
using std::map<unsigned int, V4L2ControlInfo>::size;
|
||||
using std::map<unsigned int, V4L2ControlInfo>::count;
|
||||
using std::map<unsigned int, V4L2ControlInfo>::find;
|
||||
|
||||
const ControlIdMap &idmap() const { return idmap_; }
|
||||
|
||||
private:
|
||||
ControlIdMap idmap_;
|
||||
};
|
||||
|
||||
class V4L2Control
|
||||
class V4L2ControlList : public ControlList
|
||||
{
|
||||
public:
|
||||
V4L2Control(unsigned int id, const ControlValue &value = ControlValue())
|
||||
: id_(id), value_(value)
|
||||
V4L2ControlList(const V4L2ControlInfoMap &info)
|
||||
: ControlList(info.idmap())
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int id() const { return id_; }
|
||||
const ControlValue &value() const { return value_; }
|
||||
ControlValue &value() { return value_; }
|
||||
|
||||
private:
|
||||
unsigned int id_;
|
||||
ControlValue value_;
|
||||
};
|
||||
|
||||
class V4L2ControlList
|
||||
{
|
||||
public:
|
||||
using iterator = std::vector<V4L2Control>::iterator;
|
||||
using const_iterator = std::vector<V4L2Control>::const_iterator;
|
||||
|
||||
iterator begin() { return controls_.begin(); }
|
||||
const_iterator begin() const { return controls_.begin(); }
|
||||
iterator end() { return controls_.end(); }
|
||||
const_iterator end() const { return controls_.end(); }
|
||||
|
||||
bool empty() const { return controls_.empty(); }
|
||||
std::size_t size() const { return controls_.size(); }
|
||||
|
||||
void clear() { controls_.clear(); }
|
||||
void add(unsigned int id, int64_t value = 0);
|
||||
|
||||
V4L2Control *getByIndex(unsigned int index);
|
||||
V4L2Control *operator[](unsigned int id);
|
||||
|
||||
private:
|
||||
std::vector<V4L2Control> controls_;
|
||||
};
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
||||
@@ -25,8 +25,8 @@ public:
|
||||
|
||||
const V4L2ControlInfoMap &controls() const { return controls_; }
|
||||
|
||||
int getControls(V4L2ControlList *ctrls);
|
||||
int setControls(V4L2ControlList *ctrls);
|
||||
int getControls(ControlList *ctrls);
|
||||
int setControls(ControlList *ctrls);
|
||||
|
||||
const std::string &deviceNode() const { return deviceNode_; }
|
||||
|
||||
@@ -43,7 +43,7 @@ protected:
|
||||
|
||||
private:
|
||||
void listControls();
|
||||
void updateControls(V4L2ControlList *ctrls,
|
||||
void updateControls(ControlList *ctrls,
|
||||
const V4L2ControlInfo **controlInfo,
|
||||
const struct v4l2_ext_control *v4l2Ctrls,
|
||||
unsigned int count);
|
||||
|
||||
Reference in New Issue
Block a user