Loading...
Searching...
No Matches
ipa_manager.h
Go to the documentation of this file.
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* Image Processing Algorithm module manager
*/
#pragma once
#include <memory>
#include <stdint.h>
#include <vector>
#include <libcamera/base/log.h>
#include <libcamera/ipa/ipa_interface.h>
#include <libcamera/ipa/ipa_module_info.h>
#include "libcamera/internal/camera_manager.h"
#include "libcamera/internal/global_configuration.h"
#include "libcamera/internal/ipa_module.h"
#include "libcamera/internal/pipeline_handler.h"
#include "libcamera/internal/pub_key.h"
namespace libcamera {
LOG_DECLARE_CATEGORY(IPAManager)
class IPAManager
{
public:
IPAManager(const GlobalConfiguration &configuration);
~IPAManager();
template<typename T>
static std::unique_ptr<T> createIPA(PipelineHandler *pipe,
uint32_t minVersion,
uint32_t maxVersion)
{
CameraManager *cm = pipe->cameraManager();
IPAManager *self = cm->_d()->ipaManager();
IPAModule *m = self->module(pipe, minVersion, maxVersion);
if (!m)
return nullptr;
const GlobalConfiguration &configuration = cm->_d()->configuration();
auto proxy = [&]() -> std::unique_ptr<T> {
if (self->isSignatureValid(m))
return std::make_unique<typename T::Threaded>(m, configuration);
else
return std::make_unique<typename T::Isolated>(m, configuration);
}();
if (!proxy->isValid()) {
LOG(IPAManager, Error) << "Failed to load proxy";
return nullptr;
}
return proxy;
}
#if HAVE_IPA_PUBKEY
static const PubKey &pubKey()
{
return pubKey_;
}
#endif
private:
void parseDir(const char *libDir, unsigned int maxDepth,
std::vector<std::string> &files);
unsigned int addDir(const char *libDir, unsigned int maxDepth = 0);
IPAModule *module(PipelineHandler *pipe, uint32_t minVersion,
uint32_t maxVersion);
bool isSignatureValid(IPAModule *ipa) const;
std::vector<std::unique_ptr<IPAModule>> modules_;
#if HAVE_IPA_PUBKEY
static const uint8_t publicKeyData_[];
static const PubKey pubKey_;
bool forceIsolation_;
#endif
};
} /* namespace libcamera */
libcamera::CameraManager
Provide access and manage all cameras in the system.
Definition camera_manager.h:25
libcamera::Extensible::_d
const T * _d() const
Retrieve the private data instance.
Definition class.h:94
libcamera::GlobalConfiguration
Support for global libcamera configuration.
Definition global_configuration.h:22
libcamera::IPAManager
Manager for IPA modules.
Definition ipa_manager.h:30
libcamera::IPAManager::IPAManager
IPAManager(const GlobalConfiguration &configuration)
Construct an IPAManager instance.
Definition ipa_manager.cpp:107
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:36
libcamera::IPAManager::pubKey
static const PubKey & pubKey()
Retrieve the IPA module signing public key.
Definition ipa_manager.h:64
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:34
libcamera::PipelineHandler::cameraManager
CameraManager * cameraManager() const
Retrieve the CameraManager that this pipeline handler belongs to.
Definition pipeline_handler.h:71
libcamera::PubKey
Public key wrapper for signature verification.
Definition pub_key.h:23
camera_manager.h
Internal camera manager support.
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:51
LOG
#define LOG(category, severity)
Log a message.
Definition log.h:129
libcamera::ipa
The IPA (Image Processing Algorithm) namespace.
Definition af.cpp:58
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.