[PATCH v2 08/12] libcamera: delayed_controls: Add ctrls list parameter to reset() function
Stefan Klug
stefan.klug at ideasonboard.com
Wed Mar 13 13:12:19 CET 2024
This makes it easier for the caller. There is often this pattern
sensor_->setControls(controls);
delayedControls_->reset();
which can then be reduced to
delayedControls_->reset(controls);
Signed-off-by: Stefan Klug <stefan.klug at ideasonboard.com>
---
include/libcamera/internal/delayed_controls.h | 2 +-
src/libcamera/delayed_controls.cpp | 14 +++++++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h
index 2738e8bf..a3063400 100644
--- a/include/libcamera/internal/delayed_controls.h
+++ b/include/libcamera/internal/delayed_controls.h
@@ -27,7 +27,7 @@ public:
DelayedControls(V4L2Device *device,
const std::unordered_map<uint32_t, ControlParams> &controlParams);
- void reset();
+ void reset(ControlList *controls = nullptr);
bool push(const ControlList &controls);
bool pushForFrame(uint32_t sequence, const ControlList &controls);
diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp
index c46e54d1..ac38eb64 100644
--- a/src/libcamera/delayed_controls.cpp
+++ b/src/libcamera/delayed_controls.cpp
@@ -115,7 +115,7 @@ DelayedControls::DelayedControls(V4L2Device *device,
* Resets the state machine to a starting position based on control values
* retrieved from the device.
*/
-void DelayedControls::reset()
+void DelayedControls::reset(ControlList *ctrls)
{
queueIndex_ = 0;
/* Frames up to maxDelay_ will be based on sensor init values. */
@@ -126,6 +126,18 @@ void DelayedControls::reset()
for (auto const ¶m : controlParams_)
ids.push_back(param.first->id());
+ if (ctrls) {
+ device_->setControls(ctrls);
+
+ LOG(DelayedControls, Debug) << "reset:";
+ auto idMap = ctrls->idMap();
+ if (idMap) {
+ for (const auto &[id, value] : *ctrls) {
+ LOG(DelayedControls, Debug) << " " << idMap->at(id)->name() << " : " << value.toString();
+ }
+ }
+ }
+
ControlList controls = device_->getControls(ids);
/* Seed the control queue with the controls reported by the device. */
--
2.40.1
More information about the libcamera-devel
mailing list