libcamera v0.7.2+1-aebe4861-nvm
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 <span>
12#include <stdint.h>
13
14#include <linux/media/v4l2-isp.h>
15
16namespace libcamera {
17
18namespace ipa {
19
21{
22public:
23 V4L2StatsBase(std::span<uint8_t> data, unsigned int version);
24
25 std::span<const uint8_t> block(unsigned int blockType, size_t blockSize) const;
26 constexpr explicit operator bool()
27 {
28 return valid_;
29 }
30
31private:
32 std::map<uint16_t, std::span<const uint8_t>> cache_;
33 std::span<uint8_t> data_;
34 bool valid_;
35};
36
37template<typename Traits>
39{
40public:
41 static_assert(std::is_same_v<std::underlying_type_t<typename Traits::id_type>, uint16_t>);
42
43 V4L2Stats(std::span<uint8_t> data, unsigned int version)
44 : V4L2StatsBase(data, version)
45 {
46 }
47
48 template<typename Traits::id_type Id>
49 const typename Traits::template id_to_details<Id>::type *
50 block() const
51 {
52 using Details = typename Traits::template id_to_details<Id>;
53
54 using Type = typename Details::type;
55 constexpr auto kernelId = Details::blockType;
56
57 auto data = V4L2StatsBase::block(kernelId, sizeof(Type));
58
59 return data.size() > 0 ?
60 reinterpret_cast<const Type *>(data.data()) : nullptr;
61 }
62};
63
64} /* namespace ipa */
65
66} /* namespace libcamera */
Base class for V4L2Stats.
Definition v4l2_stats.h:21
std::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:39
V4L2Stats(std::span< uint8_t > data, unsigned int version)
Construct an instance of V4L2Stats.
Definition v4l2_stats.h:43
const Traits::template id_to_details< Id >::type * block() const
Retrieve a pointer to an ISP statistics block.
Definition v4l2_stats.h:50
Top-level libcamera namespace.
Definition backtrace.h:17