libcamera v0.7.2+rpt20260817
Supporting cameras in Linux since 2019
Loading...
Searching...
No Matches
v4l2_stats.h
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2026, Ideas On Board
4 *
5 * V4L2 ISP Statistics
6 */
7
8#pragma once
9
10#include <map>
11#include <stdint.h>
12
13#include <linux/media/v4l2-isp.h>
14
15#include <libcamera/base/span.h>
16
17namespace libcamera {
18
19namespace ipa {
20
22{
23public:
24 V4L2StatsBase(Span<uint8_t> data, unsigned int version);
25
26 Span<const uint8_t> block(unsigned int blockType, size_t blockSize) const;
27 constexpr explicit operator bool()
28 {
29 return valid_;
30 }
31
32private:
33 std::map<uint16_t, Span<const uint8_t>> cache_;
34 Span<uint8_t> data_;
35 bool valid_;
36};
37
38template<typename Traits>
40{
41public:
42 static_assert(std::is_same_v<std::underlying_type_t<typename Traits::id_type>, uint16_t>);
43
44 V4L2Stats(Span<uint8_t> data, unsigned int version)
45 : V4L2StatsBase(data, version)
46 {
47 }
48
49 template<typename Traits::id_type Id>
50 const typename Traits::template id_to_details<Id>::type *
51 block() const
52 {
53 using Details = typename Traits::template id_to_details<Id>;
54
55 using Type = typename Details::type;
56 constexpr auto kernelId = Details::blockType;
57
58 auto data = V4L2StatsBase::block(kernelId, sizeof(Type));
59
60 return data.size() > 0 ?
61 reinterpret_cast<const Type *>(data.data()) : nullptr;
62 }
63};
64
65} /* namespace ipa */
66
67} /* namespace libcamera */
Base class for V4L2Stats.
Definition v4l2_stats.h:22
Span< const uint8_t > block(unsigned int blockType, size_t blockSize) const
Retrieve an ISP statistics block and return a reference to it.
Definition v4l2_stats.cpp:122
Helper class that represents an ISP statistics buffer.
Definition v4l2_stats.h:40
V4L2Stats(Span< uint8_t > data, unsigned int version)
Construct an instance of V4L2Stats.
Definition v4l2_stats.h:44
const Traits::template id_to_details< Id >::type * block() const
Retrieve a pointer to an ISP statistics block.
Definition v4l2_stats.h:51
Top-level libcamera namespace.
Definition backtrace.h:17