[libcamera-devel] [PATCH v4 08/31] libcamera: ipu3: Implement camera start/stop

Jacopo Mondi jacopo at jmondi.org
Wed Mar 20 17:30:32 CET 2019


Start and stop video devices in the pipeline.

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

diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 2975c218f6c9..994c95692dd4 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -334,12 +334,52 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera, Stream *stream)
 int PipelineHandlerIPU3::start(Camera *camera)
 {
 	IPU3CameraData *data = cameraData(camera);
-	V4L2Device *cio2 = data->cio2.output;
 	int ret;
 
-	ret = cio2->streamOn();
+	/*
+	 * Enqueue all available buffers to the CIO2 unit to start frame
+	 * capture. Start ImgU video devices and queue buffers to the output
+	 * ones at queueRequest() time.
+	 */
+	for (Buffer &buffer : data->cio2.pool.buffers()) {
+		ret = data->cio2.output->queueBuffer(&buffer);
+		if (ret)
+			return ret;
+	}
+
+	ret = data->cio2.output->streamOn();
 	if (ret) {
-		LOG(IPU3, Info) << "Failed to start camera " << camera->name();
+		LOG(IPU3, Error) << "Failed to start CIO2";
+		stop(camera);
+		return ret;
+	}
+
+	/* Start the ImgU video devices. */
+	ret = data->imgu->output->streamOn();
+	if (ret) {
+		LOG(IPU3, Error) << "Failed to start ImgU output";
+		stop(camera);
+		return ret;
+	}
+
+	ret = data->imgu->viewfinder->streamOn();
+	if (ret) {
+		LOG(IPU3, Error) << "Failed to start ImgU viewfinder";
+		stop(camera);
+		return ret;
+	}
+
+	ret = data->imgu->stat->streamOn();
+	if (ret) {
+		LOG(IPU3, Error) << "Failed to start ImgU stat";
+		stop(camera);
+		return ret;
+	}
+
+	ret = data->imgu->input->streamOn();
+	if (ret) {
+		LOG(IPU3, Error) << "Failed to start ImgU input";
+		stop(camera);
 		return ret;
 	}
 
@@ -349,10 +389,12 @@ int PipelineHandlerIPU3::start(Camera *camera)
 void PipelineHandlerIPU3::stop(Camera *camera)
 {
 	IPU3CameraData *data = cameraData(camera);
-	V4L2Device *cio2 = data->cio2.output;
 
-	if (cio2->streamOff())
-		LOG(IPU3, Info) << "Failed to stop camera " << camera->name();
+	data->cio2.output->streamOff();
+	data->imgu->output->streamOff();
+	data->imgu->viewfinder->streamOff();
+	data->imgu->stat->streamOff();
+	data->imgu->input->streamOff();
 
 	PipelineHandler::stop(camera);
 }
-- 
2.21.0



More information about the libcamera-devel mailing list