summaryrefslogtreecommitdiff
path: root/src/libcamera/v4l2_device.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-10-13 23:34:29 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-10-15 22:33:29 +0300
commit6d2411fcb7483c7fee98824cafd1fabac3d75071 (patch)
tree07b38791f2786a70e452b0379d029b6570c4d378 /src/libcamera/v4l2_device.cpp
parentf24f77e7f506b6134e2636be27db7227c5052a26 (diff)
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>
Diffstat (limited to 'src/libcamera/v4l2_device.cpp')
-rw-r--r--src/libcamera/v4l2_device.cpp25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index 144a60b4..4bb7d595 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -171,7 +171,6 @@ int V4L2Device::getControls(ControlList *ctrls)
if (count == 0)
return 0;
- const V4L2ControlInfo *controlInfo[count];
struct v4l2_ext_control v4l2Ctrls[count];
memset(v4l2Ctrls, 0, sizeof(v4l2Ctrls));
@@ -185,10 +184,7 @@ int V4L2Device::getControls(ControlList *ctrls)
return -EINVAL;
}
- const V4L2ControlInfo *info = &iter->second;
- controlInfo[i] = info;
v4l2Ctrls[i].id = id->id();
-
i++;
}
@@ -215,7 +211,7 @@ int V4L2Device::getControls(ControlList *ctrls)
ret = errorIdx;
}
- updateControls(ctrls, controlInfo, v4l2Ctrls, count);
+ updateControls(ctrls, v4l2Ctrls, count);
return ret;
}
@@ -249,7 +245,6 @@ int V4L2Device::setControls(ControlList *ctrls)
if (count == 0)
return 0;
- const V4L2ControlInfo *controlInfo[count];
struct v4l2_ext_control v4l2Ctrls[count];
memset(v4l2Ctrls, 0, sizeof(v4l2Ctrls));
@@ -263,13 +258,11 @@ int V4L2Device::setControls(ControlList *ctrls)
return -EINVAL;
}
- const V4L2ControlInfo *info = &iter->second;
- controlInfo[i] = info;
v4l2Ctrls[i].id = id->id();
/* Set the v4l2_ext_control value for the write operation. */
const ControlValue &value = ctrl.second;
- switch (info->id().type()) {
+ switch (id->type()) {
case ControlTypeInteger64:
v4l2Ctrls[i].value64 = value.get<int64_t>();
break;
@@ -308,7 +301,7 @@ int V4L2Device::setControls(ControlList *ctrls)
ret = errorIdx;
}
- updateControls(ctrls, controlInfo, v4l2Ctrls, count);
+ updateControls(ctrls, v4l2Ctrls, count);
return ret;
}
@@ -349,7 +342,7 @@ int V4L2Device::ioctl(unsigned long request, void *argp)
*/
void V4L2Device::listControls()
{
- std::map<unsigned int, V4L2ControlInfo> ctrls;
+ std::map<const ControlId *, V4L2ControlInfo> ctrls;
struct v4l2_query_ext_ctrl ctrl = {};
/* \todo Add support for menu and compound controls. */
@@ -388,8 +381,8 @@ void V4L2Device::listControls()
controlIds_.emplace_back(utils::make_unique<V4L2ControlId>(ctrl));
ctrls.emplace(std::piecewise_construct,
- std::forward_as_tuple(ctrl.id),
- std::forward_as_tuple(*controlIds_.back().get(), ctrl));
+ std::forward_as_tuple(controlIds_.back().get()),
+ std::forward_as_tuple(ctrl));
}
controls_ = std::move(ctrls);
@@ -399,12 +392,10 @@ void V4L2Device::listControls()
* \brief Update the value of the first \a count V4L2 controls in \a ctrls using
* values in \a v4l2Ctrls
* \param[inout] ctrls List of V4L2 controls to update
- * \param[in] controlInfo List of V4L2 control information
* \param[in] v4l2Ctrls List of V4L2 extended controls as returned by the driver
* \param[in] count The number of controls to update
*/
void V4L2Device::updateControls(ControlList *ctrls,
- const V4L2ControlInfo **controlInfo,
const struct v4l2_ext_control *v4l2Ctrls,
unsigned int count)
{
@@ -414,10 +405,10 @@ void V4L2Device::updateControls(ControlList *ctrls,
break;
const struct v4l2_ext_control *v4l2Ctrl = &v4l2Ctrls[i];
- const V4L2ControlInfo *info = controlInfo[i];
+ const ControlId *id = ctrl.first;
ControlValue &value = ctrl.second;
- switch (info->id().type()) {
+ switch (id->type()) {
case ControlTypeInteger64:
value.set<int64_t>(v4l2Ctrl->value64);
break;