libcamera v0.7.2+1-7a25b42d-nvm
Supporting cameras in Linux since 2019
Loading...
Searching...
No Matches
delayed_controls.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2020, Raspberry Pi Ltd
4 *
5 * Helper to deal with controls that take effect with a delay
6 */
7
8#pragma once
9
10#include <array>
11#include <stdint.h>
12#include <unordered_map>
13
15
16#include <libcamera/controls.h>
17
18namespace libcamera {
19
20class V4L2Device;
21
22class DelayedControls : public Object
23{
24public:
26 unsigned int delay;
28 };
29
31 const std::unordered_map<uint32_t, ControlParams> &controlParams);
32
33 void reset();
34
35 bool push(const ControlList &controls);
36 ControlList get(uint32_t sequence);
37
38 void applyControls(uint32_t sequence);
39
40private:
41 class Info : public ControlValue
42 {
43 public:
44 Info()
45 : updated(false)
46 {
47 }
48
49 Info(const ControlValue &v, bool updated_ = true)
50 : ControlValue(v), updated(updated_)
51 {
52 }
53
54 bool updated;
55 };
56
57 /* \todo Make the listSize configurable at instance creation time. */
58 static constexpr int listSize = 16;
59 class ControlRingBuffer : public std::array<Info, listSize>
60 {
61 public:
62 Info &operator[](unsigned int index)
63 {
64 return std::array<Info, listSize>::operator[](index % listSize);
65 }
66
67 const Info &operator[](unsigned int index) const
68 {
69 return std::array<Info, listSize>::operator[](index % listSize);
70 }
71 };
72
73 V4L2Device *device_;
74 /* \todo Evaluate if we should index on ControlId * or unsigned int */
75 std::unordered_map<const ControlId *, ControlParams> controlParams_;
76 unsigned int maxDelay_;
77
78 uint32_t queueCount_;
79 uint32_t writeCount_;
80 /* \todo Evaluate if we should index on ControlId * or unsigned int */
81 std::unordered_map<const ControlId *, ControlRingBuffer> values_;
82};
83
84} /* namespace libcamera */
Associate a list of ControlId with their values for an object.
Definition controls.h:453
Abstract type representing the value of a control.
Definition controls.h:143
Helper to deal with controls that take effect with a delay.
Definition delayed_controls.h:23
ControlList get(uint32_t sequence)
Read back controls in effect at a sequence number.
Definition delayed_controls.cpp:203
bool push(const ControlList &controls)
Push a set of controls on the queue.
Definition delayed_controls.cpp:149
void reset()
Reset state machine.
Definition delayed_controls.cpp:116
void applyControls(uint32_t sequence)
Inform DelayedControls of the start of a new frame.
Definition delayed_controls.cpp:232
Base object to support automatic signal disconnection.
Definition object.h:27
Base class for V4L2VideoDevice and V4L2Subdevice.
Definition v4l2_device.h:34
Framework to manage controls related to an object.
Top-level libcamera namespace.
Definition backtrace.h:17
Base object to support automatic signal disconnection.
Parameters associated with controls handled by the DelayedControls helper class.
Definition delayed_controls.h:25
unsigned int delay
Frame delay from setting the control on a sensor device to when it is consumed during framing.
Definition delayed_controls.h:26
bool priorityWrite
Flag to indicate that this control must be applied ahead of, and separately from the other controls.
Definition delayed_controls.h:27