[libcamera-devel,v2] ipa: Allow forcing usage of C API though environment

Message ID 20191027125922.12219-1-jacopo@jmondi.org
State Superseded
Delegated to: Jacopo Mondi
Headers show
Series
  • [libcamera-devel,v2] ipa: Allow forcing usage of C API though environment
Related show

Commit Message

Jacopo Mondi Oct. 27, 2019, 12:59 p.m. UTC
Parse the 'LIBCAMERA_IPA_FORCE_C_API' environment variable that allows
forcing the usage of the IPA C API even if it's possible to short-circuit
it through the ipa_context_ops get_interface() operation.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/ipa_context_wrapper.cpp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

--
2.23.0

Comments

Niklas Söderlund Oct. 28, 2019, 10:50 a.m. UTC | #1
Hi Jacopo,

Thanks for your patch.

On 2019-10-27 13:59:22 +0100, Jacopo Mondi wrote:
> Parse the 'LIBCAMERA_IPA_FORCE_C_API' environment variable that allows
> forcing the usage of the IPA C API even if it's possible to short-circuit
> it through the ipa_context_ops get_interface() operation.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/libcamera/ipa_context_wrapper.cpp | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/ipa_context_wrapper.cpp b/src/libcamera/ipa_context_wrapper.cpp
> index 736082e9b068..b178418eb9b8 100644
> --- a/src/libcamera/ipa_context_wrapper.cpp
> +++ b/src/libcamera/ipa_context_wrapper.cpp
> @@ -9,6 +9,8 @@
> 
>  #include <libcamera/controls.h>
> 
> +#include "utils.h"
> +
>  /**
>   * \file ipa_context_wrapper.h
>   * \brief Image Processing Algorithm context wrapper
> @@ -41,7 +43,13 @@ namespace libcamera {
>  IPAContextWrapper::IPAContextWrapper(struct ipa_context *context)
>  	: ctx_(context)
>  {
> -	if (ctx_ && ctx_->ops->get_interface) {
> +	int skipIntf = 0;
> +	const char *skipIntfEnv =
> +			utils::secure_getenv("LIBCAMERA_IPA_FORCE_C_API");
> +	if (skipIntfEnv)
> +		skipIntf = !!atoi(skipIntfEnv);
> +
> +	if (!skipIntf && ctx_ && ctx_->ops->get_interface) {
>  		intf_ = reinterpret_cast<IPAInterface *>(ctx_->ops->get_interface(ctx_));
>  		intf_->queueFrameAction.connect(this, &IPAContextWrapper::queueFrameAction);
>  	} else {
> --
> 2.23.0
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/ipa_context_wrapper.cpp b/src/libcamera/ipa_context_wrapper.cpp
index 736082e9b068..b178418eb9b8 100644
--- a/src/libcamera/ipa_context_wrapper.cpp
+++ b/src/libcamera/ipa_context_wrapper.cpp
@@ -9,6 +9,8 @@ 

 #include <libcamera/controls.h>

+#include "utils.h"
+
 /**
  * \file ipa_context_wrapper.h
  * \brief Image Processing Algorithm context wrapper
@@ -41,7 +43,13 @@  namespace libcamera {
 IPAContextWrapper::IPAContextWrapper(struct ipa_context *context)
 	: ctx_(context)
 {
-	if (ctx_ && ctx_->ops->get_interface) {
+	int skipIntf = 0;
+	const char *skipIntfEnv =
+			utils::secure_getenv("LIBCAMERA_IPA_FORCE_C_API");
+	if (skipIntfEnv)
+		skipIntf = !!atoi(skipIntfEnv);
+
+	if (!skipIntf && ctx_ && ctx_->ops->get_interface) {
 		intf_ = reinterpret_cast<IPAInterface *>(ctx_->ops->get_interface(ctx_));
 		intf_->queueFrameAction.connect(this, &IPAContextWrapper::queueFrameAction);
 	} else {