[libcamera-devel,v3,1/5] pipeline: rkisp1: Support IPA tuning file
diff mbox series

Message ID 20220617092315.120781-2-fsylvestre@baylibre.com
State Accepted
Headers show
Series
  • Add tuning file support for rkisp1 blc algo
Related show

Commit Message

Florian Sylvestre June 17, 2022, 9:23 a.m. UTC
Allow the usage of a YAML IPA tuning file that is either defined by
the sensor name (sensor_name.yaml) or defined by
LIBCAMERA_RKISP1_TUNING_FILE environment variable.

Signed-off-by: Florian Sylvestre <fsylvestre@baylibre.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
---
 src/libcamera/pipeline/rkisp1/rkisp1.cpp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart June 17, 2022, 5:19 p.m. UTC | #1
Hi Florian,

Thank you for the patch.

On Fri, Jun 17, 2022 at 11:23:11AM +0200, Florian Sylvestre wrote:
> Allow the usage of a YAML IPA tuning file that is either defined by
> the sensor name (sensor_name.yaml) or defined by
> LIBCAMERA_RKISP1_TUNING_FILE environment variable.
> 
> Signed-off-by: Florian Sylvestre <fsylvestre@baylibre.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
> ---
>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> index 4b3d2cf7..59ded513 100644
> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> @@ -322,7 +322,18 @@ int RkISP1CameraData::loadIPA(unsigned int hwRevision)
>  	ipa_->paramsBufferReady.connect(this, &RkISP1CameraData::paramFilled);
>  	ipa_->metadataReady.connect(this, &RkISP1CameraData::metadataReady);
>  
> -	int ret = ipa_->init(IPASettings{ "", sensor_->model() }, hwRevision);
> +	/*
> +	 * The API tuning file is made from the sensor name unless
> +	 * the environment variable overrides it.
> +	 */
> +	std::string ipaTunigFile;

s/ipaTunigFile/ipaTuningFile/

> +	char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RKISP1_TUNING_FILE");
> +	if (!configFromEnv || *configFromEnv == '\0')
> +		ipaTunigFile = ipa_->configurationFile(sensor_->model() + ".yaml");
> +	else
> +		ipaTunigFile = std::string(configFromEnv);
> +
> +	int ret = ipa_->init({ ipaTunigFile, sensor_->model() }, hwRevision);
>  	if (ret < 0) {
>  		LOG(RkISP1, Error) << "IPA initialization failure";
>  		return ret;

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index 4b3d2cf7..59ded513 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -322,7 +322,18 @@  int RkISP1CameraData::loadIPA(unsigned int hwRevision)
 	ipa_->paramsBufferReady.connect(this, &RkISP1CameraData::paramFilled);
 	ipa_->metadataReady.connect(this, &RkISP1CameraData::metadataReady);
 
-	int ret = ipa_->init(IPASettings{ "", sensor_->model() }, hwRevision);
+	/*
+	 * The API tuning file is made from the sensor name unless
+	 * the environment variable overrides it.
+	 */
+	std::string ipaTunigFile;
+	char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RKISP1_TUNING_FILE");
+	if (!configFromEnv || *configFromEnv == '\0')
+		ipaTunigFile = ipa_->configurationFile(sensor_->model() + ".yaml");
+	else
+		ipaTunigFile = std::string(configFromEnv);
+
+	int ret = ipa_->init({ ipaTunigFile, sensor_->model() }, hwRevision);
 	if (ret < 0) {
 		LOG(RkISP1, Error) << "IPA initialization failure";
 		return ret;