libcamera  v0.0.2
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 private:
51  static IPAManager *self_;
52 
53  void parseDir(const char *libDir, unsigned int maxDepth,
54  std::vector<std::string> &files);
55  unsigned int addDir(const char *libDir, unsigned int maxDepth = 0);
56 
57  IPAModule *module(PipelineHandler *pipe, uint32_t minVersion,
58  uint32_t maxVersion);
59 
60  bool isSignatureValid(IPAModule *ipa) const;
61 
62  std::vector<IPAModule *> modules_;
63 
64 #if HAVE_IPA_PUBKEY
65  static const uint8_t publicKeyData_[];
66  static const PubKey pubKey_;
67 #endif
68 };
69 
70 } /* namespace libcamera */
Manager for IPA modules.
Definition: ipa_manager.h:27
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
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:39
Public key wrapper for signature verification.
Definition: pub_key.h:23
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.
#define LOG(category, severity)
Log a message.
Top-level libcamera namespace.
Definition: backtrace.h:17
Create pipelines and cameras from a set of media devices.
Public key signature verification.