libcamera v0.7.2 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
16#include <libcamera/ipa/ipa_interface.h>
17#include <libcamera/ipa/ipa_module_info.h>
18
19#include "libcamera/internal/pub_key.h"
20
21 namespace libcamera {
22
23 LOG_DECLARE_CATEGORY(IPAManager)
24
25 class CameraManager;
26 class GlobalConfiguration;
27 class IPAModule;
28 class PipelineHandler;
29
30 class IPAManager
31{
32 public:
33 IPAManager(const CameraManager &cm);
34 ~IPAManager();
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
66 private:
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 */
libcamera::CameraManager
Provide access and manage all cameras in the system.
Definition camera_manager.h:25
libcamera::GlobalConfiguration
Support for global libcamera configuration.
Definition global_configuration.h:23
libcamera::IPAManager
Manager for IPA modules.
Definition ipa_manager.h:31
libcamera::IPAManager::createIPA
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
libcamera::IPAManager::IPAManager
IPAManager(const CameraManager &cm)
Construct an IPAManager instance.
Definition ipa_manager.cpp:108
libcamera::IPAManager::pubKey
static const PubKey & pubKey()
Retrieve the IPA module signing public key.
Definition ipa_manager.h:60
libcamera::IPAModule
Wrapper around IPA module shared object.
Definition ipa_module.h:24
libcamera::PipelineHandler
Create and manage cameras based on a set of media devices.
Definition pipeline_handler.h:36
libcamera::PubKey
Public key wrapper for signature verification.
Definition pub_key.h:23
ipa_interface.h
Image Processing Algorithm interface.
ipa_module_info.h
Image Processing Algorithm module information.
log.h
Logging infrastructure.
LOG_DECLARE_CATEGORY
#define LOG_DECLARE_CATEGORY(name)
Declare a category of log messages.
Definition log.h:51
LOG
#define LOG(category, severity)
Log a message.
Definition log.h:155
libcamera::ipa
The IPA (Image Processing Algorithm) namespace.
Definition af.cpp:58
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
pub_key.h
Public key signature verification.