libcamera v0.5.2
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 <stdint.h>
11#include <unordered_map>
12
14
15#include <libcamera/controls.h>
16
17namespace libcamera {
18
19class V4L2Device;
20
21class DelayedControls : public Object
22{
23public:
25 unsigned int delay;
27 };
28
30 const std::unordered_map<uint32_t, ControlParams> &controlParams);
31
32 void reset();
33
34 bool push(const ControlList &controls);
35 ControlList get(uint32_t sequence);
36
37 void applyControls(uint32_t sequence);
38
39private:
40 class Info : public ControlValue
41 {
42 public:
43 Info()
44 : updated(false)
45 {
46 }
47
48 Info(const ControlValue &v, bool updated_ = true)
49 : ControlValue(v), updated(updated_)
50 {
51 }
52
53 bool updated;
54 };
55
56 /* \todo Make the listSize configurable at instance creation time. */
57 static constexpr int listSize = 16;
58 class ControlRingBuffer : public std::array<Info, listSize>
59 {
60 public:
61 Info &operator[](unsigned int index)
62 {
63 return std::array<Info, listSize>::operator[](index % listSize);
64 }
65
66 const Info &operator[](unsigned int index) const
67 {
68 return std::array<Info, listSize>::operator[](index % listSize);
69 }
70 };
71
72 V4L2Device *device_;
73 /* \todo Evaluate if we should index on ControlId * or unsigned int */
74 std::unordered_map<const ControlId *, ControlParams> controlParams_;
75 unsigned int maxDelay_;
76
77 uint32_t queueCount_;
78 uint32_t writeCount_;
79 /* \todo Evaluate if we should index on ControlId * or unsigned int */
80 std::unordered_map<const ControlId *, ControlRingBuffer> values_;
81};
82
83} /* namespace libcamera */
Associate a list of ControlId with their values for an object.
Definition controls.h:411
Abstract type representing the value of a control.
Definition controls.h:134
DelayedControls(V4L2Device *device, const std::unordered_map< uint32_t, ControlParams > &controlParams)
Construct a DelayedControls instance.
Definition delayed_controls.cpp:74
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
Object(Object *parent=nullptr)
Construct an Object instance.
Definition object.cpp:69
Base class for V4L2VideoDevice and V4L2Subdevice.
Definition v4l2_device.h:33
Framework to manage controls related to an object.
Namespace for libcamera controls.
Definition control_ids.h:21
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:24
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
bool priorityWrite
Flag to indicate that this control must be applied ahead of, and separately from the other controls.
Definition delayed_controls.h:26