[libcamera-devel,v2,18/20] libcamera: ipu3: Calculate ImgU pipe configuration

Message ID 20200709084128.5316-19-jacopo@jmondi.org
State Superseded, archived
Delegated to: Jacopo Mondi
Headers show
Series
  • libcamera: ipu3: Rework configuration
Related show

Commit Message

Jacopo Mondi July 9, 2020, 8:41 a.m. UTC
Collect the ImgU device desired pipe configuration while assigning
streams in the pipeline handler validate() function and ask the
ImgUDevice class to calculate the pipe configuration parameters.

If the requested pipe configuration results in a non-valid
configuration, return an error from the validate() function.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/pipeline/ipu3/ipu3.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Niklas Söderlund July 9, 2020, 2:05 p.m. UTC | #1
Hi Jacopo,

Thanks for your work.

On 2020-07-09 10:41:26 +0200, Jacopo Mondi wrote:
> Collect the ImgU device desired pipe configuration while assigning
> streams in the pipeline handler validate() function and ask the
> ImgUDevice class to calculate the pipe configuration parameters.
> 
> If the requested pipe configuration results in a non-valid
> configuration, return an error from the validate() function.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

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

> ---
>  src/libcamera/pipeline/ipu3/ipu3.cpp | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index 9a6e71514c90..72261d16e9f8 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -71,6 +71,7 @@ private:
>  	IPU3CameraData *data_;
>  
>  	StreamConfiguration cio2Configuration_;
> +	ImgUDevice::PipeConfig pipeConfig_;
>  };
>  
>  class PipelineHandlerIPU3 : public PipelineHandler
> @@ -179,6 +180,9 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
>  
>  	LOG(IPU3, Debug) << "CIO2 configuration: " << cio2Configuration_.toString();
>  
> +	ImgUDevice::Pipe pipe{};
> +	pipe.input = cio2Configuration_.size;
> +
>  	/*
>  	 * Adjust the configurations if needed and assign streams while
>  	 * iterating them.
> @@ -250,11 +254,13 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
>  		    (oldCfg.size == yuvSize || outCount == 1)) {
>  			cfg.setStream(&data_->outStream_);
>  			mainOutputAvailable = false;
> +			pipe.output = cfg.size;
>  
>  			LOG(IPU3, Debug) << "Assigned " << cfg.toString()
>  					 << " to the main output";
>  		} else {
>  			cfg.setStream(&data_->vfStream_);
> +			pipe.viewfinder = cfg.size;
>  
>  			LOG(IPU3, Debug) << "Assigned " << cfg.toString()
>  					 << " to the viewfinder output";
> @@ -269,6 +275,13 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
>  		}
>  	}
>  
> +	pipeConfig_ = data_->imgu_->calculatePipeConfig(&pipe);
> +	if (pipeConfig_.isNull()) {
> +		LOG(IPU3, Error) << "Failed to calculate pipe configuration: "
> +				 << "unsupported resolutions.";
> +		return Invalid;
> +	}
> +
>  	return status;
>  }
>  
> -- 
> 2.27.0
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart July 10, 2020, 12:46 p.m. UTC | #2
Hi Jacopo,

Thank you for the patch.

On Thu, Jul 09, 2020 at 10:41:26AM +0200, Jacopo Mondi wrote:
> Collect the ImgU device desired pipe configuration while assigning
> streams in the pipeline handler validate() function and ask the
> ImgUDevice class to calculate the pipe configuration parameters.
> 
> If the requested pipe configuration results in a non-valid
> configuration, return an error from the validate() function.
> 
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

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

although I wonder if the Pipe and PipeConfig structures shouldn't be
merged, but that's a topic for another patch.

> ---
>  src/libcamera/pipeline/ipu3/ipu3.cpp | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index 9a6e71514c90..72261d16e9f8 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -71,6 +71,7 @@ private:
>  	IPU3CameraData *data_;
>  
>  	StreamConfiguration cio2Configuration_;
> +	ImgUDevice::PipeConfig pipeConfig_;
>  };
>  
>  class PipelineHandlerIPU3 : public PipelineHandler
> @@ -179,6 +180,9 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
>  
>  	LOG(IPU3, Debug) << "CIO2 configuration: " << cio2Configuration_.toString();
>  
> +	ImgUDevice::Pipe pipe{};
> +	pipe.input = cio2Configuration_.size;
> +
>  	/*
>  	 * Adjust the configurations if needed and assign streams while
>  	 * iterating them.
> @@ -250,11 +254,13 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
>  		    (oldCfg.size == yuvSize || outCount == 1)) {
>  			cfg.setStream(&data_->outStream_);
>  			mainOutputAvailable = false;
> +			pipe.output = cfg.size;
>  
>  			LOG(IPU3, Debug) << "Assigned " << cfg.toString()
>  					 << " to the main output";
>  		} else {
>  			cfg.setStream(&data_->vfStream_);
> +			pipe.viewfinder = cfg.size;
>  
>  			LOG(IPU3, Debug) << "Assigned " << cfg.toString()
>  					 << " to the viewfinder output";
> @@ -269,6 +275,13 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()
>  		}
>  	}
>  
> +	pipeConfig_ = data_->imgu_->calculatePipeConfig(&pipe);
> +	if (pipeConfig_.isNull()) {
> +		LOG(IPU3, Error) << "Failed to calculate pipe configuration: "
> +				 << "unsupported resolutions.";
> +		return Invalid;
> +	}
> +
>  	return status;
>  }
>

Patch

diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 9a6e71514c90..72261d16e9f8 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -71,6 +71,7 @@  private:
 	IPU3CameraData *data_;
 
 	StreamConfiguration cio2Configuration_;
+	ImgUDevice::PipeConfig pipeConfig_;
 };
 
 class PipelineHandlerIPU3 : public PipelineHandler
@@ -179,6 +180,9 @@  CameraConfiguration::Status IPU3CameraConfiguration::validate()
 
 	LOG(IPU3, Debug) << "CIO2 configuration: " << cio2Configuration_.toString();
 
+	ImgUDevice::Pipe pipe{};
+	pipe.input = cio2Configuration_.size;
+
 	/*
 	 * Adjust the configurations if needed and assign streams while
 	 * iterating them.
@@ -250,11 +254,13 @@  CameraConfiguration::Status IPU3CameraConfiguration::validate()
 		    (oldCfg.size == yuvSize || outCount == 1)) {
 			cfg.setStream(&data_->outStream_);
 			mainOutputAvailable = false;
+			pipe.output = cfg.size;
 
 			LOG(IPU3, Debug) << "Assigned " << cfg.toString()
 					 << " to the main output";
 		} else {
 			cfg.setStream(&data_->vfStream_);
+			pipe.viewfinder = cfg.size;
 
 			LOG(IPU3, Debug) << "Assigned " << cfg.toString()
 					 << " to the viewfinder output";
@@ -269,6 +275,13 @@  CameraConfiguration::Status IPU3CameraConfiguration::validate()
 		}
 	}
 
+	pipeConfig_ = data_->imgu_->calculatePipeConfig(&pipe);
+	if (pipeConfig_.isNull()) {
+		LOG(IPU3, Error) << "Failed to calculate pipe configuration: "
+				 << "unsupported resolutions.";
+		return Invalid;
+	}
+
 	return status;
 }