libcamera v0.7.0+1-4ceceb68
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#include "libcamera/internal/global_configuration.h"
24
25namespace libcamera {
26
27LOG_DECLARE_CATEGORY(IPAManager)
28
30{
31public:
32 IPAManager(const GlobalConfiguration &configuration);
34
35 template<typename T>
36 static std::unique_ptr<T> createIPA(PipelineHandler *pipe,
37 uint32_t minVersion,
38 uint32_t maxVersion)
39 {
40 CameraManager *cm = pipe->cameraManager();
41 IPAManager *self = cm->_d()->ipaManager();
42 IPAModule *m = self->module(pipe, minVersion, maxVersion);
43 if (!m)
44 return nullptr;
45
46 const GlobalConfiguration &configuration = cm->_d()->configuration();
47
48 auto proxy = [&]() -> std::unique_ptr<T> {
49 if (self->isSignatureValid(m))
50 return std::make_unique<typename T::Threaded>(m, configuration);
51 else
52 return std::make_unique<typename T::Isolated>(m, configuration);
53 }();
54
55 if (!proxy->isValid()) {
56 LOG(IPAManager, Error) << "Failed to load proxy";
57 return nullptr;
58 }
59
60 return proxy;
61 }
62
63#if HAVE_IPA_PUBKEY
64 static const PubKey &pubKey()
65 {
66 return pubKey_;
67 }
68#endif
69
70private:
71 void parseDir(const char *libDir, unsigned int maxDepth,
72 std::vector<std::string> &files);
73 unsigned int addDir(const char *libDir, unsigned int maxDepth = 0);
74
75 IPAModule *module(PipelineHandler *pipe, uint32_t minVersion,
76 uint32_t maxVersion);
77
78 bool isSignatureValid(IPAModule *ipa) const;
79
80 std::vector<std::unique_ptr<IPAModule>> modules_;
81
82#if HAVE_IPA_PUBKEY
83 static const uint8_t publicKeyData_[];
84 static const PubKey pubKey_;
85 bool forceIsolation_;
86#endif
87};
88
89} /* namespace libcamera */
Provide access and manage all cameras in the system.
Definition camera_manager.h:25
const T * _d() const
Retrieve the private data instance.
Definition class.h:94
Support for global libcamera configuration.
Definition global_configuration.h:22
Manager for IPA modules.
Definition ipa_manager.h:30
static const PubKey & pubKey()
Retrieve the IPA module signing public key.
Definition ipa_manager.h:64
static 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:36
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:34
CameraManager * cameraManager() const
Retrieve the CameraManager that this pipeline handler belongs to.
Definition pipeline_handler.h:71
Public key wrapper for signature verification.
Definition pub_key.h:23
Internal camera manager support.
Image Processing Algorithm interface.
Image Processing Algorithm module.
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
Top-level libcamera namespace.
Definition backtrace.h:17
Create pipelines and cameras from a set of media devices.
Public key signature verification.