[libcamera-devel,RFC,5/7] libcamera: v4l2_device: add function to get a list of volatile control ids
diff mbox series

Message ID 20230202111252.3366729-6-matthias.fend@emfend.at
State New
Headers show
Series
  • add support for more complex optics
Related show

Commit Message

Matthias Fend Feb. 2, 2023, 11:12 a.m. UTC
This method returns all IDs of the v4l2 controls that are marked as
volatile.

Signed-off-by: Matthias Fend <matthias.fend@emfend.at>
---
 include/libcamera/internal/v4l2_device.h |  1 +
 src/libcamera/v4l2_device.cpp            | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

Patch
diff mbox series

diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h
index 50d4adbc..1c1de64a 100644
--- a/include/libcamera/internal/v4l2_device.h
+++ b/include/libcamera/internal/v4l2_device.h
@@ -36,6 +36,7 @@  public:
 
 	const ControlInfoMap &controls() const { return controls_; }
 
+	std::vector<uint32_t> getVolatileControlIds();
 	ControlList getControls(const std::vector<uint32_t> &ids);
 	int setControls(ControlList *ctrls);
 
diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index 57a88d96..6605d36c 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -147,6 +147,21 @@  void V4L2Device::close()
 	fd_.reset();
 }
 
+std::vector<uint32_t> V4L2Device::getVolatileControlIds()
+{
+	std::vector<uint32_t> ids;
+
+	for (auto &[controlId, controlInfo] : controls_) {
+		uint32_t id = controlId->id();
+		const struct v4l2_query_ext_ctrl &info = controlInfo_[id];
+
+		if (info.flags & V4L2_CTRL_FLAG_VOLATILE)
+			ids.push_back(id);
+	}
+
+	return ids;
+}
+
 /**
  * \fn V4L2Device::isOpen()
  * \brief Check if the V4L2 device node is open