[libcamera-devel] [PATCH] libcamera: pipeline: rkisp1: configure IPA from configure method instead of start method

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Feb 15 04:42:13 CET 2021


Hi Dafna,

Thank you for the patch.

On Fri, Feb 12, 2021 at 08:05:57PM +0100, Dafna Hirschfeld wrote:
> Currently the call to the configure method of rkisp1 IPA
> is called upon the 'start' of the pipeline. This should be done
> in the 'configure' method instead.
> 
> Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld at collabora.com>
> ---
>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 63 ++++++++++++------------
>  1 file changed, 31 insertions(+), 32 deletions(-)
> 
> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> index e85979a7..f15efa9f 100644
> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
> @@ -607,11 +607,24 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)
>  		<< "ISP output pad configured with " << format.toString()
>  		<< " crop " << rect.toString();
>  
> +	std::map<unsigned int, IPAStream> streamConfig;
> +
>  	for (const StreamConfiguration &cfg : *config) {
> -		if (cfg.stream() == &data->mainPathStream_)
> +		if (cfg.stream() == &data->mainPathStream_) {
>  			ret = mainPath_.configure(cfg, format);
> -		else
> +			if (data->mainPath_->isEnabled())

I think you can drop this check. isEnabled() will return true if
PipelineHandlerRkISP1::initLinks() has enabled the path with
setEnabled(), which is done when cfg.stream() == &data->mainPathStream_.

This being said, I think there's a bug in the pipeline handler as links
are never reset, but that's out of scope for this patch.

> +				streamConfig[0] = {
> +					.pixelFormat = cfg.pixelFormat,
> +					.size = cfg.size,
> +				};
> +		} else {
>  			ret = selfPath_.configure(cfg, format);
> +			if (data->selfPath_->isEnabled())

Same here.

> +				streamConfig[1] = {
> +					.pixelFormat = cfg.pixelFormat,
> +					.size = cfg.size,
> +				};
> +		}
>  
>  		if (ret)
>  			return ret;
> @@ -629,6 +642,22 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)
>  	if (ret)
>  		return ret;
>  
> +	/* Inform IPA of stream configuration and sensor controls. */
> +	CameraSensorInfo sensorInfo = {};
> +	ret = data->sensor_->sensorInfo(&sensorInfo);
> +	if (ret) {
> +		/* \todo Turn this in an hard failure. */
> +		LOG(RkISP1, Warning) << "Camera sensor information not available";
> +		sensorInfo = {};
> +		ret = 0;
> +	}
> +
> +	std::map<unsigned int, const ControlInfoMap &> entityControls;
> +	entityControls.emplace(0, data->sensor_->controls());
> +
> +	IPAOperationData ipaConfig;
> +	data->ipa_->configure(sensorInfo, streamConfig, entityControls, ipaConfig, nullptr);

This could be wrapped to shorten the line.

With these issues addressed,

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

> +
>  	return 0;
>  }
>  
> @@ -759,8 +788,6 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] ControlList *c
>  		return ret;
>  	}
>  
> -	std::map<unsigned int, IPAStream> streamConfig;
> -
>  	if (data->mainPath_->isEnabled()) {
>  		ret = mainPath_.start();
>  		if (ret) {
> @@ -770,11 +797,6 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] ControlList *c
>  			freeBuffers(camera);
>  			return ret;
>  		}
> -
> -		streamConfig[0] = {
> -			.pixelFormat = data->mainPathStream_.configuration().pixelFormat,
> -			.size = data->mainPathStream_.configuration().size,
> -		};
>  	}
>  
>  	if (data->selfPath_->isEnabled()) {
> @@ -787,34 +809,11 @@ int PipelineHandlerRkISP1::start(Camera *camera, [[maybe_unused]] ControlList *c
>  			freeBuffers(camera);
>  			return ret;
>  		}
> -
> -		streamConfig[1] = {
> -			.pixelFormat = data->selfPathStream_.configuration().pixelFormat,
> -			.size = data->selfPathStream_.configuration().size,
> -		};
>  	}
>  
>  	isp_->setFrameStartEnabled(true);
>  
>  	activeCamera_ = camera;
> -
> -	/* Inform IPA of stream configuration and sensor controls. */
> -	CameraSensorInfo sensorInfo = {};
> -	ret = data->sensor_->sensorInfo(&sensorInfo);
> -	if (ret) {
> -		/* \todo Turn this in an hard failure. */
> -		LOG(RkISP1, Warning) << "Camera sensor information not available";
> -		sensorInfo = {};
> -		ret = 0;
> -	}
> -
> -	std::map<unsigned int, const ControlInfoMap &> entityControls;
> -	entityControls.emplace(0, data->sensor_->controls());
> -
> -	IPAOperationData ipaConfig;
> -	data->ipa_->configure(sensorInfo, streamConfig, entityControls,
> -			      ipaConfig, nullptr);
> -
>  	return ret;
>  }
>  

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list