libcamera v0.7.1
Supporting cameras in Linux since 2019
Loading...
Searching...
No Matches
ipa_manager.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2/*
3 * Copyright (C) 2019, Google Inc.
4 *
5 * Image Processing Algorithm module manager
6 */
7
8#pragma once
9
10#include <memory>
11#include <stdint.h>
12#include <vector>
13
14#include <libcamera/base/log.h>
15
18
20
21namespace libcamera {
22
24
25class CameraManager;
27class IPAModule;
28class PipelineHandler;
29
31{
32public:
33 IPAManager(const CameraManager &cm);
35
36 template<typename T>
37 std::unique_ptr<T> createIPA(PipelineHandler *pipe, uint32_t minVersion,
38 uint32_t maxVersion)
39 {
40 IPAModule *m = module(pipe, minVersion, maxVersion);
41 if (!m)
42 return nullptr;
43
44 auto proxy = [&]() -> std::unique_ptr<T> {
45 if (isSignatureValid(m))
46 return std::make_unique<typename T::Threaded>(m, cm_);
47 else
48 return std::make_unique<typename T::Isolated>(m, cm_);
49 }();
50
51 if (!proxy->isValid()) {
52 LOG(IPAManager, Error) << "Failed to load proxy";
53 return nullptr;
54 }
55
56 return proxy;
57 }
58
59#if HAVE_IPA_PUBKEY
60 static const PubKey &pubKey()
61 {
62 return pubKey_;
63 }
64#endif
65
66private:
67 void parseDir(const char *libDir, unsigned int maxDepth,
68 std::vector<std::string> &files);
69 unsigned int addDir(const char *libDir, unsigned int maxDepth = 0);
70
71 IPAModule *module(PipelineHandler *pipe, uint32_t minVersion,
72 uint32_t maxVersion);
73
74 bool isSignatureValid(IPAModule *ipa) const;
75
76 const CameraManager &cm_;
77 std::vector<std::unique_ptr<IPAModule>> modules_;
78
79#if HAVE_IPA_PUBKEY
80 static const uint8_t publicKeyData_[];
81 static const PubKey pubKey_;
82 bool forceIsolation_;
83#endif
84};
85
86} /* namespace libcamera */
Provide access and manage all cameras in the system.
Definition camera_manager.h:25
Support for global libcamera configuration.
Definition global_configuration.h:23
Manager for IPA modules.
Definition ipa_manager.h:31
std::unique_ptr< T > createIPA(PipelineHandler *pipe, uint32_t minVersion, uint32_t maxVersion)
Create an IPA proxy that matches a given pipeline handler.
Definition ipa_manager.h:37
IPAManager(const CameraManager &cm)
Construct an IPAManager instance.
Definition ipa_manager.cpp:108
static const PubKey & pubKey()
Retrieve the IPA module signing public key.
Definition ipa_manager.h:60
Wrapper around IPA module shared object.
Definition ipa_module.h:24
Create and manage cameras based on a set of media devices.
Definition pipeline_handler.h:36
Public key wrapper for signature verification.
Definition pub_key.h:23
Image Processing Algorithm interface.
Image Processing Algorithm module information.
Logging infrastructure.
#define LOG_DECLARE_CATEGORY(name)
Declare a category of log messages.
Definition log.h:51
#define LOG(category, severity)
Log a message.
Definition log.h:129
The IPA (Image Processing Algorithm) namespace.
Definition af.cpp:58
Top-level libcamera namespace.
Definition backtrace.h:17
Public key signature verification.