[libcamera-devel,v2,07/14] libcamera: ipu3: Implement camera start/stop

Message ID 20190312121242.2253-8-jacopo@jmondi.org
State Accepted
Headers show
Series
  • libcamera: ipu3: ImgU support
Related show

Commit Message

Jacopo Mondi March 12, 2019, 12:12 p.m. UTC
Start and stop video devices in the pipeline.

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

Patch

diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index 3502c39f5e31..363b24ceead2 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -338,12 +338,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;
 	}
 
@@ -353,10 +393,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);
 }