[libcamera-devel,v3,1/3] libcamera: ipu3: Move Imgu configuration to IPU3CameraData
diff mbox series

Message ID 20210316144711.40778-2-jeanmichel.hautbois@ideasonboard.com
State Not Applicable
Headers show
Series
  • Prepare IPU3 pipeline to pass BDS to IPA
Related show

Commit Message

Jean-Michel Hautbois March 16, 2021, 2:47 p.m. UTC
The IPU3 IPA needs to know the BayerDownScaler (BDS) configuration to
calculate the statistics grids.
This patch makes it possible for PipelineHandlerIPU3::start() to access
the BDS configuration and later pass the rectangle to the IPU3 IPA
configure method.

Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
---
v3:
- remove bds argument which is in a separate patch
- split in two patches ipa configure moving
v2:
- move pipe configuration calculation from validate to configure
- move ipa configuration from start to configure
---
 src/libcamera/pipeline/ipu3/ipu3.cpp | 38 +++++++++++++---------------
 1 file changed, 18 insertions(+), 20 deletions(-)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 2ea13ec9..65657dcc 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -97,11 +97,14 @@  public:
 	Status validate() override;
 
 	const StreamConfiguration &cio2Format() const { return cio2Configuration_; }
-	const ImgUDevice::PipeConfig imguConfig() const { return pipeConfig_; }
 
 	/* Cache the combinedTransform_ that will be applied to the sensor */
 	Transform combinedTransform_;
 
+	/* Store the pipe configuration */
+	ImgUDevice::PipeConfig pipeConfig_;
+	ImgUDevice::Pipe pipe_;
+
 private:
 	/*
 	 * The IPU3CameraData instance is guaranteed to be valid as long as the
@@ -111,7 +114,6 @@  private:
 	const IPU3CameraData *data_;
 
 	StreamConfiguration cio2Configuration_;
-	ImgUDevice::PipeConfig pipeConfig_;
 };
 
 class PipelineHandlerIPU3 : public PipelineHandler
@@ -170,6 +172,7 @@  IPU3CameraConfiguration::IPU3CameraConfiguration(IPU3CameraData *data)
 CameraConfiguration::Status IPU3CameraConfiguration::validate()
 {
 	Status status = Valid;
+	pipe_ = {};
 
 	if (config_.empty())
 		return Invalid;
@@ -272,8 +275,7 @@  CameraConfiguration::Status IPU3CameraConfiguration::validate()
 
 	LOG(IPU3, Debug) << "CIO2 configuration: " << cio2Configuration_.toString();
 
-	ImgUDevice::Pipe pipe{};
-	pipe.input = cio2Configuration_.size;
+	pipe_.input = cio2Configuration_.size;
 
 	/*
 	 * Adjust the configurations if needed and assign streams while
@@ -349,15 +351,15 @@  CameraConfiguration::Status IPU3CameraConfiguration::validate()
 				cfg->setStream(const_cast<Stream *>(&data_->outStream_));
 				mainOutputAvailable = false;
 
-				pipe.main = cfg->size;
+				pipe_.main = cfg->size;
 				if (yuvCount == 1)
-					pipe.viewfinder = pipe.main;
+					pipe_.viewfinder = pipe_.main;
 
 				LOG(IPU3, Debug) << "Assigned " << cfg->toString()
 						 << " to the main output";
 			} else {
 				cfg->setStream(const_cast<Stream *>(&data_->vfStream_));
-				pipe.viewfinder = cfg->size;
+				pipe_.viewfinder = cfg->size;
 
 				LOG(IPU3, Debug) << "Assigned " << cfg->toString()
 						 << " to the viewfinder output";
@@ -373,16 +375,6 @@  CameraConfiguration::Status IPU3CameraConfiguration::validate()
 		}
 	}
 
-	/* Only compute the ImgU configuration if a YUV stream has been requested. */
-	if (yuvCount) {
-		pipeConfig_ = data_->imgu_->calculatePipeConfig(&pipe);
-		if (pipeConfig_.isNull()) {
-			LOG(IPU3, Error) << "Failed to calculate pipe configuration: "
-					 << "unsupported resolutions.";
-			return Invalid;
-		}
-	}
-
 	return status;
 }
 
@@ -576,11 +568,17 @@  int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c)
 	 * stream has been requested: return here to skip the ImgU configuration
 	 * part.
 	 */
-	ImgUDevice::PipeConfig imguConfig = config->imguConfig();
-	if (imguConfig.isNull())
+	if (config->pipe_.main.isNull() && config->pipe_.viewfinder.isNull())
 		return 0;
 
-	ret = imgu->configure(imguConfig, &cio2Format);
+	config->pipeConfig_ = imgu->calculatePipeConfig(&config->pipe_);
+	if (config->pipeConfig_.isNull()) {
+		LOG(IPU3, Error) << "Failed to calculate pipe configuration: "
+				 << "unsupported resolutions.";
+		return CameraConfiguration::Invalid;
+	}
+
+	ret = imgu->configure(config->pipeConfig_, &cio2Format);
 	if (ret)
 		return ret;