libcamera v0.1.0+127-8e215127-dirty (2023-12-02T01:06:12+00:00)
Supporting cameras in Linux since 2019
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 * delayed_controls.h - 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
13#include <libcamera/controls.h>
14
15namespace libcamera {
16
17class V4L2Device;
18
20{
21public:
23 unsigned int delay;
25 };
26
28 const std::unordered_map<uint32_t, ControlParams> &controlParams);
29
30 void reset();
31
32 bool push(const ControlList &controls);
33 ControlList get(uint32_t sequence);
34
35 void applyControls(uint32_t sequence);
36
37private:
38 class Info : public ControlValue
39 {
40 public:
41 Info()
42 : updated(false)
43 {
44 }
45
46 Info(const ControlValue &v, bool updated_ = true)
47 : ControlValue(v), updated(updated_)
48 {
49 }
50
51 bool updated;
52 };
53
54 /* \todo Make the listSize configurable at instance creation time. */
55 static constexpr int listSize = 16;
56 class ControlRingBuffer : public std::array<Info, listSize>
57 {
58 public:
59 Info &operator[](unsigned int index)
60 {
61 return std::array<Info, listSize>::operator[](index % listSize);
62 }
63
64 const Info &operator[](unsigned int index) const
65 {
66 return std::array<Info, listSize>::operator[](index % listSize);
67 }
68 };
69
70 V4L2Device *device_;
71 /* \todo Evaluate if we should index on ControlId * or unsigned int */
72 std::unordered_map<const ControlId *, ControlParams> controlParams_;
73 unsigned int maxDelay_;
74
75 uint32_t queueCount_;
76 uint32_t writeCount_;
77 /* \todo Evaluate if we should index on ControlId * or unsigned int */
78 std::unordered_map<const ControlId *, ControlRingBuffer> values_;
79};
80
81} /* namespace libcamera */
Associate a list of ControlId with their values for an object.
Definition: controls.h:350
Abstract type representing the value of a control.
Definition: controls.h:97
Helper to deal with controls that take effect with a delay.
Definition: delayed_controls.h:20
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
Base class for V4L2VideoDevice and V4L2Subdevice.
Definition: v4l2_device.h:32
Framework to manage controls related to an object.
const ControlIdMap controls
List of all supported libcamera controls.
Definition: controls_ids.cpp:1400
Top-level libcamera namespace.
Definition: backtrace.h:17
Parameters associated with controls handled by the DelayedControls helper class.
Definition: delayed_controls.h:22
unsigned int delay
Frame delay from setting the control on a sensor device to when it is consumed during framing.
Definition: delayed_controls.h:23
bool priorityWrite
Flag to indicate that this control must be applied ahead of, and separately from the other controls.
Definition: delayed_controls.h:24