libcamera: include/libcamera/internal/ipa_manager.h Source File

libcamera v0.1.0 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 * ipa_manager.h - Image Processing Algorithm module manager
6 */
7
8#pragma once
9
10#include <stdint.h>
11#include <vector>
12
13#include <libcamera/base/log.h>
14
15#include <libcamera/ipa/ipa_interface.h>
16#include <libcamera/ipa/ipa_module_info.h>
17
18#include "libcamera/internal/ipa_module.h"
19#include "libcamera/internal/pipeline_handler.h"
20#include "libcamera/internal/pub_key.h"
21
22namespace libcamera {
23
24 LOG_DECLARE_CATEGORY(IPAManager)
25
26class IPAManager
27{
28public:
29 IPAManager();
30 ~IPAManager();
31
32 template<typename T>
33 static std::unique_ptr<T> createIPA(PipelineHandler *pipe,
34 uint32_t minVersion,
35 uint32_t maxVersion)
36 {
37 IPAModule *m = self_->module(pipe, minVersion, maxVersion);
38 if (!m)
39 return nullptr;
40
41 std::unique_ptr<T> proxy = std::make_unique<T>(m, !self_->isSignatureValid(m));
42 if (!proxy->isValid()) {
43 LOG(IPAManager, Error) << "Failed to load proxy";
44 return nullptr;
45 }
46
47 return proxy;
48 }
49
50#if HAVE_IPA_PUBKEY
51 static const PubKey &pubKey()
52 {
53 return pubKey_;
54 }
55#endif
56
57private:
58 static IPAManager *self_;
59
60 void parseDir(const char *libDir, unsigned int maxDepth,
61 std::vector<std::string> &files);
62 unsigned int addDir(const char *libDir, unsigned int maxDepth = 0);
63
64 IPAModule *module(PipelineHandler *pipe, uint32_t minVersion,
65 uint32_t maxVersion);
66
67 bool isSignatureValid(IPAModule *ipa) const;
68
69 std::vector<IPAModule *> modules_;
70
71#if HAVE_IPA_PUBKEY
72 static const uint8_t publicKeyData_[];
73 static const PubKey pubKey_;
74#endif
75};
76
77} /* namespace libcamera */
libcamera::IPAManager
Manager for IPA modules.
Definition ipa_manager.h:27
libcamera::IPAManager::pubKey
static const PubKey & pubKey()
Retrieve the IPA module signing public key.
Definition ipa_manager.h:51
libcamera::IPAManager::createIPA
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:33
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:39
libcamera::PubKey
Public key wrapper for signature verification.
Definition pub_key.h:23
ipa_interface.h
Image Processing Algorithm interface.
ipa_module.h
Image Processing Algorithm module.
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:47
LOG
#define LOG(category, severity)
Log a message.
Definition log.h:122
libcamera
Top-level libcamera namespace.
Definition backtrace.h:17
pipeline_handler.h
Create pipelines and cameras from a set of media devices.
pub_key.h
Public key signature verification.