@@ -32,21 +32,18 @@ private:
using V4L2ControlInfoMap = std::map<unsigned int, V4L2ControlInfo>;
-class V4L2Control
+class V4L2Control : public DataValue
{
public:
V4L2Control(unsigned int id, int value = 0)
- : id_(id), value_(value) {}
-
- DataType type() const { return value_.type(); }
- int64_t value() const { return value_.getInt64(); }
- void setValue(int64_t value) { value_ = value; }
+ : DataValue(value), id_(id)
+ {
+ }
unsigned int id() const { return id_; }
private:
unsigned int id_;
- DataValue value_;
};
class V4L2ControlList
@@ -264,7 +264,7 @@ int PipelineHandlerUVC::processControls(UVCCameraData *data, Request *request)
LOG(UVC, Debug)
<< "Setting control 0x"
<< std::hex << std::setw(8) << ctrl.id() << std::dec
- << " to " << ctrl.value();
+ << " to " << ctrl.getInt();
int ret = data->video_->setControls(&controls);
if (ret) {
@@ -308,7 +308,7 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)
LOG(VIMC, Debug)
<< "Setting control 0x"
<< std::hex << std::setw(8) << ctrl.id() << std::dec
- << " to " << ctrl.value();
+ << " to " << ctrl.getInt();
int ret = data->sensor_->setControls(&controls);
if (ret) {
@@ -103,8 +103,7 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)
* V4L2Device::setControls() and V4L2Device::getControls() operations.
*
* \todo Currently all V4L2Controls are integers. For the sake of keeping the
- * implementation as simpler as possible treat all values as int64. The value()
- * and setValue() operations use that single data type for now.
+ * implementation as simpler as possible treat all values as int64.
*/
/**
@@ -114,32 +113,6 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)
* \param value The control value
*/
-/**
- * \fn V4L2Control::type()
- * \brief Retrieve the type of the control
- * \return The control type
- */
-
-/**
- * \fn V4L2Control::value()
- * \brief Retrieve the value of the control
- *
- * This method returns the cached control value, initially set by
- * V4L2ControlList::add() and then updated when the controls are read or
- * written with V4L2Device::getControls() and V4L2Device::setControls().
- *
- * \return The V4L2 control value
- */
-
-/**
- * \fn V4L2Control::setValue()
- * \brief Set the value of the control
- * \param value The new V4L2 control value
- *
- * This method stores the control value, which will be applied to the
- * device when calling V4L2Device::setControls().
- */
-
/**
* \fn V4L2Control::id()
* \brief Retrieve the control ID this instance refers to
@@ -260,14 +260,14 @@ int V4L2Device::setControls(V4L2ControlList *ctrls)
/* Set the v4l2_ext_control value for the write operation. */
switch (ctrl->type()) {
case DataTypeInteger64:
- v4l2Ctrls[i].value64 = ctrl->value();
+ v4l2Ctrls[i].value64 = ctrl->getInt();
break;
default:
/*
* \todo To be changed when support for string and
* compound controls will be added.
*/
- v4l2Ctrls[i].value = ctrl->value();
+ v4l2Ctrls[i].value = ctrl->getInt64();
break;
}
}
@@ -386,14 +386,14 @@ void V4L2Device::updateControls(V4L2ControlList *ctrls,
switch (ctrl->type()) {
case DataTypeInteger64:
- ctrl->setValue(v4l2Ctrls[i].value64);
+ ctrl->set(static_cast<int64_t>(v4l2Ctrls[i].value64));
break;
default:
/*
* \todo To be changed when support for string and
* compound controls will be added.
*/
- ctrl->setValue(v4l2Ctrls[i].value);
+ ctrl->set(static_cast<int>(v4l2Ctrls[i].value));
break;
}
}
In order to be able to easily serialize a V4L2ControlList which contains controls, make the V4L2Control class a DataValue. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> --- src/libcamera/include/v4l2_controls.h | 11 ++++------ src/libcamera/pipeline/uvcvideo.cpp | 2 +- src/libcamera/pipeline/vimc.cpp | 2 +- src/libcamera/v4l2_controls.cpp | 29 +-------------------------- src/libcamera/v4l2_device.cpp | 8 ++++---- 5 files changed, 11 insertions(+), 41 deletions(-)