IPA proxies are created with a call to IPAManager::createIPA(), which is a static member function. This requires a complicated dance in the createIPA() function to retrieve the IPAManager instance through the camera manager, itself retrieved from the pipeline handler. Simplify the code by turning IPAManager::createIPA() into a non-static member function, and providing a wrapper in the PipelineHandler class to keep instantiation of IPA proxies easy in pipeline handlers. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>
87 lines
1.8 KiB
C++
87 lines
1.8 KiB
C++
/* 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/pub_key.h"
|
|
|
|
namespace libcamera {
|
|
|
|
LOG_DECLARE_CATEGORY(IPAManager)
|
|
|
|
class GlobalConfiguration;
|
|
class IPAModule;
|
|
class PipelineHandler;
|
|
|
|
class IPAManager
|
|
{
|
|
public:
|
|
IPAManager(const GlobalConfiguration &configuration);
|
|
~IPAManager();
|
|
|
|
template<typename T>
|
|
std::unique_ptr<T> createIPA(PipelineHandler *pipe, uint32_t minVersion,
|
|
uint32_t maxVersion)
|
|
{
|
|
IPAModule *m = module(pipe, minVersion, maxVersion);
|
|
if (!m)
|
|
return nullptr;
|
|
|
|
auto proxy = [&]() -> std::unique_ptr<T> {
|
|
if (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;
|
|
|
|
const GlobalConfiguration &configuration_;
|
|
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 */
|