summaryrefslogtreecommitdiff
path: root/src/libcamera/v4l2_device.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-10-25 23:48:45 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-11-20 21:47:33 +0200
commite89c2b22957b9faa2d9521dd8d696ed1cefc7dda (patch)
tree002950c748e59c9d6200be1cc6e7df3c82e9a4df /src/libcamera/v4l2_device.cpp
parentc27b7c103a7d0e8a6ca02b5f6e42372d1ee6993e (diff)
libcamera: controls: Index ControlList by unsigned int
In preparation for serialization, index the ControlList by unsigned int. This will allow deserializing a ControlList without requiring external information. 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.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index a2b0d891..0452f801 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -176,15 +176,15 @@ int V4L2Device::getControls(ControlList *ctrls)
unsigned int i = 0;
for (const auto &ctrl : *ctrls) {
- const ControlId *id = ctrl.first;
- const auto iter = controls_.find(id->id());
+ unsigned int id = ctrl.first;
+ const auto iter = controls_.find(id);
if (iter == controls_.end()) {
LOG(V4L2, Error)
- << "Control '" << id->name() << "' not found";
+ << "Control " << utils::hex(id) << " not found";
return -EINVAL;
}
- v4l2Ctrls[i].id = id->id();
+ v4l2Ctrls[i].id = id;
i++;
}
@@ -250,19 +250,19 @@ int V4L2Device::setControls(ControlList *ctrls)
unsigned int i = 0;
for (const auto &ctrl : *ctrls) {
- const ControlId *id = ctrl.first;
- const auto iter = controls_.find(id->id());
+ unsigned int id = ctrl.first;
+ const auto iter = controls_.find(id);
if (iter == controls_.end()) {
LOG(V4L2, Error)
- << "Control '" << id->name() << "' not found";
+ << "Control " << utils::hex(id) << " not found";
return -EINVAL;
}
- v4l2Ctrls[i].id = id->id();
+ v4l2Ctrls[i].id = id;
/* Set the v4l2_ext_control value for the write operation. */
const ControlValue &value = ctrl.second;
- switch (id->type()) {
+ switch (iter->first->type()) {
case ControlTypeInteger64:
v4l2Ctrls[i].value64 = value.get<int64_t>();
break;
@@ -403,10 +403,11 @@ void V4L2Device::updateControls(ControlList *ctrls,
break;
const struct v4l2_ext_control *v4l2Ctrl = &v4l2Ctrls[i];
- const ControlId *id = ctrl.first;
+ unsigned int id = ctrl.first;
ControlValue &value = ctrl.second;
- switch (id->type()) {
+ const auto iter = controls_.find(id);
+ switch (iter->first->type()) {
case ControlTypeInteger64:
value.set<int64_t>(v4l2Ctrl->value64);
break;