From 6d7a66dc4eb1a406010733aed63a2a3d37ce7508 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>
Date: Thu, 26 Mar 2020 14:47:22 +0100
Subject: libcamera: pipeline: rkisp1: Call IPA start() and stop()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Call the IPA start()/stop() functions before/after the camera is
started. This makes sure the IPA functions properly once thread
management is moved into the start/stop interface.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/pipeline/rkisp1/rkisp1.cpp | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index 47edf1dc..f4226436 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -779,10 +779,19 @@ int PipelineHandlerRkISP1::start(Camera *camera)
 	if (ret)
 		return ret;
 
+	ret = data->ipa_->start();
+	if (ret) {
+		freeBuffers(camera);
+		LOG(RkISP1, Error)
+			<< "Failed to start IPA " << camera->name();
+		return ret;
+	}
+
 	data->frame_ = 0;
 
 	ret = param_->streamOn();
 	if (ret) {
+		data->ipa_->stop();
 		freeBuffers(camera);
 		LOG(RkISP1, Error)
 			<< "Failed to start parameters " << camera->name();
@@ -792,6 +801,7 @@ int PipelineHandlerRkISP1::start(Camera *camera)
 	ret = stat_->streamOn();
 	if (ret) {
 		param_->streamOff();
+		data->ipa_->stop();
 		freeBuffers(camera);
 		LOG(RkISP1, Error)
 			<< "Failed to start statistics " << camera->name();
@@ -802,6 +812,7 @@ int PipelineHandlerRkISP1::start(Camera *camera)
 	if (ret) {
 		param_->streamOff();
 		stat_->streamOff();
+		data->ipa_->stop();
 		freeBuffers(camera);
 
 		LOG(RkISP1, Error)
@@ -845,6 +856,8 @@ void PipelineHandlerRkISP1::stop(Camera *camera)
 		LOG(RkISP1, Warning)
 			<< "Failed to stop parameters " << camera->name();
 
+	data->ipa_->stop();
+
 	data->timeline_.reset();
 
 	data->frameInfo_.clear();
-- 
cgit v1.2.1