Loading...
Searching...
No Matches
delayed_controls.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2020, Raspberry Pi Ltd
*
* Helper to deal with controls that take effect with a delay
*/
#pragma once
#include <stdint.h>
#include <unordered_map>
#include <libcamera/base/object.h>
#include <libcamera/controls.h>
namespace libcamera {
class V4L2Device;
class DelayedControls : public Object
{
public:
struct ControlParams {
unsigned int delay;
bool priorityWrite;
};
DelayedControls(V4L2Device *device,
const std::unordered_map<uint32_t, ControlParams> &controlParams);
void reset();
bool push(const ControlList &controls);
ControlList get(uint32_t sequence);
void applyControls(uint32_t sequence);
private:
class Info : public ControlValue
{
public:
Info()
: updated(false)
{
}
Info(const ControlValue &v, bool updated_ = true)
: ControlValue(v), updated(updated_)
{
}
bool updated;
};
/* \todo Make the listSize configurable at instance creation time. */
static constexpr int listSize = 16;
class ControlRingBuffer : public std::array<Info, listSize>
{
public:
Info &operator[](unsigned int index)
{
return std::array<Info, listSize>::operator[](index % listSize);
}
const Info &operator[](unsigned int index) const
{
return std::array<Info, listSize>::operator[](index % listSize);
}
};
V4L2Device *device_;
/* \todo Evaluate if we should index on ControlId * or unsigned int */
std::unordered_map<const ControlId *, ControlParams> controlParams_;
unsigned int maxDelay_;
uint32_t queueCount_;
uint32_t writeCount_;
/* \todo Evaluate if we should index on ControlId * or unsigned int */
std::unordered_map<const ControlId *, ControlRingBuffer> values_;
};
} /* namespace libcamera */
libcamera::ControlList
Associate a list of ControlId with their values for an object.
Definition controls.h:409
libcamera::ControlValue
Abstract type representing the value of a control.
Definition controls.h:134
libcamera::DelayedControls::DelayedControls
DelayedControls(V4L2Device *device, const std::unordered_map< uint32_t, ControlParams > &controlParams)
Construct a DelayedControls instance.
Definition delayed_controls.cpp:74
libcamera::DelayedControls::get
ControlList get(uint32_t sequence)
Read back controls in effect at a sequence number.
Definition delayed_controls.cpp:203
libcamera::DelayedControls::push
bool push(const ControlList &controls)
Push a set of controls on the queue.
Definition delayed_controls.cpp:149
libcamera::DelayedControls::reset
void reset()
Reset state machine.
Definition delayed_controls.cpp:116
libcamera::DelayedControls::applyControls
void applyControls(uint32_t sequence)
Inform DelayedControls of the start of a new frame.
Definition delayed_controls.cpp:232
libcamera::Object::Object
Object(Object *parent=nullptr)
Construct an Object instance.
Definition object.cpp:69
libcamera::V4L2Device
Base class for V4L2VideoDevice and V4L2Subdevice.
Definition v4l2_device.h:34
controls.h
Framework to manage controls related to an object.
libcamera::controls
Namespace for libcamera controls.
Definition control_ids.h:22
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
object.h
Base object to support automatic signal disconnection.
libcamera::DelayedControls::ControlParams
Parameters associated with controls handled by the DelayedControls helper class.
Definition delayed_controls.h:24
libcamera::DelayedControls::ControlParams::delay
unsigned int delay
Frame delay from setting the control on a sensor device to when it is consumed during framing.
Definition delayed_controls.h:25
libcamera::DelayedControls::ControlParams::priorityWrite
bool priorityWrite
Flag to indicate that this control must be applied ahead of, and separately from the other controls.
Definition delayed_controls.h:26