libcamera  v0.2.0+85-1c5830a9
Supporting cameras in Linux since 2019
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 
17 
21 
22 namespace libcamera {
23 
24 LOG_DECLARE_CATEGORY(IPAManager)
25 
27 {
28 public:
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 
57 private:
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 */
Public key signature verification.
#define LOG(category, severity)
Log a message.
Image Processing Algorithm interface.
Top-level libcamera namespace.
Definition: backtrace.h:17
Manager for IPA modules.
Definition: ipa_manager.h:26
Image Processing Algorithm module information.
static const PubKey & pubKey()
Retrieve the IPA module signing public key.
Definition: ipa_manager.h:51
#define LOG_DECLARE_CATEGORY(name)
Declare a category of log messages.
Wrapper around IPA module shared object.
Definition: ipa_module.h:23
Create and manage cameras based on a set of media devices.
Definition: pipeline_handler.h:37
Image Processing Algorithm module.
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
Public key wrapper for signature verification.
Definition: pub_key.h:22
Logging infrastructure.
Create pipelines and cameras from a set of media devices.