libcamera  v0.0.0+100-debian/0_git20200629+e7aa92a-8-9-g77f5237c-dirty (2021-05-05T16:20:29+01:00)
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 #ifndef __LIBCAMERA_INTERNAL_IPA_MANAGER_H__
8 #define __LIBCAMERA_INTERNAL_IPA_MANAGER_H__
9 
10 #include <stdint.h>
11 #include <vector>
12 
15 
17 #include "libcamera/internal/log.h"
20 
21 namespace libcamera {
22 
23 LOG_DECLARE_CATEGORY(IPAManager)
24 
26 {
27 public:
28  IPAManager();
29  ~IPAManager();
30 
31  template<typename T>
32  static std::unique_ptr<T> createIPA(PipelineHandler *pipe,
33  uint32_t maxVersion,
34  uint32_t minVersion)
35  {
36  IPAModule *m = nullptr;
37 
38  for (IPAModule *module : self_->modules_) {
39  if (module->match(pipe, minVersion, maxVersion)) {
40  m = module;
41  break;
42  }
43  }
44 
45  if (!m)
46  return nullptr;
47 
48  std::unique_ptr<T> proxy = std::make_unique<T>(m, !self_->isSignatureValid(m));
49  if (!proxy->isValid()) {
50  LOG(IPAManager, Error) << "Failed to load proxy";
51  return nullptr;
52  }
53 
54  return proxy;
55  }
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  bool isSignatureValid(IPAModule *ipa) const;
65 
66  std::vector<IPAModule *> modules_;
67 
68 #if HAVE_IPA_PUBKEY
69  static const uint8_t publicKeyData_[];
70  static const PubKey pubKey_;
71 #endif
72 };
73 
74 } /* namespace libcamera */
75 
76 #endif /* __LIBCAMERA_INTERNAL_IPA_MANAGER_H__ */
Public key signature verification.
#define LOG(category, severity)
Log a message.
Image Processing Algorithm interface.
Top-level libcamera namespace.
Definition: bound_method.h:15
Manager for IPA modules.
Definition: ipa_manager.h:25
Image Processing Algorithm module information.
static std::unique_ptr< T > createIPA(PipelineHandler *pipe, uint32_t maxVersion, uint32_t minVersion)
Create an IPA proxy that matches a given pipeline handler.
Definition: ipa_manager.h:32
#define LOG_DECLARE_CATEGORY(name)
Declare a category of log messages.
Wrapper around IPA module shared object.
Definition: ipa_module.h:22
Create and manage cameras based on a set of media devices.
Definition: pipeline_handler.h:57
Image Processing Algorithm module.
bool match(PipelineHandler *pipe, uint32_t minVersion, uint32_t maxVersion) const
Verify if the IPA module matches a given pipeline handler.
Definition: ipa_module.cpp:472
Public key wrapper for signature verification.
Definition: pub_key.h:20
Logging infrastructure.
Create pipelines and cameras from a set of media devices.