summaryrefslogtreecommitdiff
path: root/src/libcamera/ipa_context_wrapper.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-09-28 06:41:22 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-11-20 21:48:05 +0200
commitd7e0985ce13d094608bec9b496873ae0361ea87d (patch)
treebd79ff5b373760b2dc118066a99db93f915a7311 /src/libcamera/ipa_context_wrapper.cpp
parent8162ac164755d04425499c76dfc12a3a9057f936 (diff)
ipa: Allow short-circuiting the ipa_context_ops
When an IPA module is loaded without isolation and implements the IPAInterface internally, going through ipa_context_ops is a waste of time. Add an operation to retrieve the IPAInterface, and use it directly in the IPAContextWrapper. For debugging purpose, make it possible to forcing usage of the C API by defining the LIBCAMERA_IPA_FORCE_C_API environment variable. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/libcamera/ipa_context_wrapper.cpp')
-rw-r--r--src/libcamera/ipa_context_wrapper.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/libcamera/ipa_context_wrapper.cpp b/src/libcamera/ipa_context_wrapper.cpp
index 5b1f5972..9603fdac 100644
--- a/src/libcamera/ipa_context_wrapper.cpp
+++ b/src/libcamera/ipa_context_wrapper.cpp
@@ -12,6 +12,7 @@
#include <libcamera/controls.h>
#include "byte_stream_buffer.h"
+#include "utils.h"
/**
* \file ipa_context_wrapper.h
@@ -43,11 +44,19 @@ namespace libcamera {
* with it.
*/
IPAContextWrapper::IPAContextWrapper(struct ipa_context *context)
- : ctx_(context)
+ : ctx_(context), intf_(nullptr)
{
if (!ctx_)
return;
+ bool forceCApi = !!utils::secure_getenv("LIBCAMERA_IPA_FORCE_C_API");
+
+ if (!forceCApi && ctx_ && ctx_->ops->get_interface) {
+ intf_ = reinterpret_cast<IPAInterface *>(ctx_->ops->get_interface(ctx_));
+ intf_->queueFrameAction.connect(this, &IPAContextWrapper::doQueueFrameAction);
+ return;
+ }
+
ctx_->ops->register_callbacks(ctx_, &IPAContextWrapper::callbacks_,
this);
}
@@ -62,6 +71,9 @@ IPAContextWrapper::~IPAContextWrapper()
int IPAContextWrapper::init()
{
+ if (intf_)
+ return intf_->init();
+
if (!ctx_)
return 0;
@@ -73,6 +85,9 @@ int IPAContextWrapper::init()
void IPAContextWrapper::configure(const std::map<unsigned int, IPAStream> &streamConfig,
const std::map<unsigned int, const ControlInfoMap &> &entityControls)
{
+ if (intf_)
+ return intf_->configure(streamConfig, entityControls);
+
if (!ctx_)
return;
@@ -123,6 +138,9 @@ void IPAContextWrapper::configure(const std::map<unsigned int, IPAStream> &strea
void IPAContextWrapper::mapBuffers(const std::vector<IPABuffer> &buffers)
{
+ if (intf_)
+ return intf_->mapBuffers(buffers);
+
if (!ctx_)
return;
@@ -148,6 +166,9 @@ void IPAContextWrapper::mapBuffers(const std::vector<IPABuffer> &buffers)
void IPAContextWrapper::unmapBuffers(const std::vector<unsigned int> &ids)
{
+ if (intf_)
+ return intf_->unmapBuffers(ids);
+
if (!ctx_)
return;
@@ -156,6 +177,9 @@ void IPAContextWrapper::unmapBuffers(const std::vector<unsigned int> &ids)
void IPAContextWrapper::processEvent(const IPAOperationData &data)
{
+ if (intf_)
+ return intf_->processEvent(data);
+
if (!ctx_)
return;
@@ -189,6 +213,12 @@ void IPAContextWrapper::processEvent(const IPAOperationData &data)
ctx_->ops->process_event(ctx_, &c_data);
}
+void IPAContextWrapper::doQueueFrameAction(unsigned int frame,
+ const IPAOperationData &data)
+{
+ IPAInterface::queueFrameAction.emit(frame, data);
+}
+
void IPAContextWrapper::queue_frame_action(void *ctx, unsigned int frame,
struct ipa_operation_data &data)
{
@@ -205,7 +235,7 @@ void IPAContextWrapper::queue_frame_action(void *ctx, unsigned int frame,
opData.controls.push_back(_this->serializer_.deserialize<ControlList>(b));
}
- _this->queueFrameAction.emit(frame, opData);
+ _this->doQueueFrameAction(frame, opData);
}
#ifndef __DOXYGEN__