summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2020-03-04 14:14:36 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-03-23 16:45:21 +0200
commit0aa8e0977591ed0868262ca910ab12c46a46d39c (patch)
tree8c00054a5311ccd0ac602ecfebb3ea44d706e90e /src
parent2c6e6fbc961aaa345355fd92603e770b0221f0c4 (diff)
libcamera: v4l2_device: Support writing array U8 controls
Add support to write array controls of type V4L2_CTRL_TYPE_U8. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/v4l2_device.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index 7eded67c..2139e98b 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -250,7 +250,7 @@ int V4L2Device::setControls(ControlList *ctrls)
memset(v4l2Ctrls, 0, sizeof(v4l2Ctrls));
unsigned int i = 0;
- for (const auto &ctrl : *ctrls) {
+ for (auto &ctrl : *ctrls) {
unsigned int id = ctrl.first;
const auto iter = controls_.find(id);
if (iter == controls_.end()) {
@@ -262,16 +262,29 @@ int V4L2Device::setControls(ControlList *ctrls)
v4l2Ctrls[i].id = id;
/* Set the v4l2_ext_control value for the write operation. */
- const ControlValue &value = ctrl.second;
+ ControlValue &value = ctrl.second;
switch (iter->first->type()) {
case ControlTypeInteger64:
v4l2Ctrls[i].value64 = value.get<int64_t>();
break;
+
+ case ControlTypeByte: {
+ if (!value.isArray()) {
+ LOG(V4L2, Error)
+ << "Control " << utils::hex(id)
+ << " requires an array value";
+ return -EINVAL;
+ }
+
+ Span<uint8_t> data = value.data();
+ v4l2Ctrls[i].p_u8 = data.data();
+ v4l2Ctrls[i].size = data.size();
+
+ break;
+ }
+
default:
- /*
- * \todo To be changed when support for string and
- * compound controls will be added.
- */
+ /* \todo To be changed to support strings. */
v4l2Ctrls[i].value = value.get<int32_t>();
break;
}
@@ -414,6 +427,14 @@ void V4L2Device::updateControls(ControlList *ctrls,
case ControlTypeInteger64:
value.set<int64_t>(v4l2Ctrl->value64);
break;
+
+ case ControlTypeByte:
+ /*
+ * No action required, the VIDIOC_[GS]_EXT_CTRLS ioctl
+ * accessed the ControlValue storage directly.
+ */
+ break;
+
default:
/*
* \todo To be changed when support for string and