libcamera v0.7.2+1-aebe4861-nvm
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
23LOG_DECLARE_CATEGORY(IPAManager)
24
25class CameraManager;
26class GlobalConfiguration;
27class IPAModule;
28
30{
31public:
32 IPAManager(const CameraManager &cm);
34
35 template<typename T>
36 std::unique_ptr<T> createIPA(const char *name, uint32_t minVersion,
37 uint32_t maxVersion)
38 {
39 IPAModule *m = module(name, minVersion, maxVersion);
40 if (!m)
41 return nullptr;
42
43 auto proxy = [&]() -> std::unique_ptr<T> {
44 if (isSignatureValid(m))
45 return std::make_unique<typename T::Threaded>(m, cm_);
46 else
47 return std::make_unique<typename T::Isolated>(m, cm_);
48 }();
49
50 if (!proxy->isValid()) {
51 LOG(IPAManager, Error) << "Failed to load proxy";
52 return nullptr;
53 }
54
55 return proxy;
56 }
57
58#if HAVE_IPA_PUBKEY
59 static const PubKey &pubKey()
60 {
61 return pubKey_;
62 }
63#endif
64
65private:
66 void parseDir(const char *libDir, unsigned int maxDepth,
67 std::vector<std::string> &files);
68 unsigned int addDir(const char *libDir, unsigned int maxDepth = 0);
69
70 IPAModule *module(const char *name, uint32_t minVersion,
71 uint32_t maxVersion);
72
73 bool isSignatureValid(IPAModule *ipa) const;
74
75 const CameraManager &cm_;
76 std::vector<std::unique_ptr<IPAModule>> modules_;
77
78#if HAVE_IPA_PUBKEY
79 static const uint8_t publicKeyData_[];
80 static const PubKey pubKey_;
81 bool forceIsolation_;
82#endif
83};
84
85} /* namespace libcamera */
Provide access and manage all cameras in the system.
Definition camera_manager.h:25
Manager for IPA modules.
Definition ipa_manager.h:30
static const PubKey & pubKey()
Retrieve the IPA module signing public key.
Definition ipa_manager.h:59
std::unique_ptr< T > createIPA(const char *name, uint32_t minVersion, uint32_t maxVersion)
Create an IPA proxy that matches a given pipeline handler.
Definition ipa_manager.h:36
Wrapper around IPA module shared object.
Definition ipa_module.h:22
Public key wrapper for signature verification.
Definition pub_key.h:22
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:155
Top-level libcamera namespace.
Definition backtrace.h:17
Public key signature verification.