[libcamera-devel,v2,09/14] libcamera: ipu3: Implement buffer release

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

Commit Message

Jacopo Mondi March 12, 2019, 12:12 p.m. UTC
Release buffers on all video devices in the pipeline.

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

Patch

diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index ad866346e13c..badde4839f99 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -157,6 +157,7 @@  private:
 	void registerCameras();
 
 	ImgUDevice imgus_[IPU3_IMGU_COUNT];
+
 	std::shared_ptr<MediaDevice> cio2MediaDev_;
 	std::shared_ptr<MediaDevice> imguMediaDev_;
 };
@@ -362,13 +363,32 @@  int PipelineHandlerIPU3::allocateBuffers(Camera *camera, Stream *stream)
 int PipelineHandlerIPU3::freeBuffers(Camera *camera, Stream *stream)
 {
 	IPU3CameraData *data = cameraData(camera);
+	V4L2Device *viewfinder = data->imgu->viewfinder;
+	V4L2Device *output = data->imgu->output;
+	V4L2Device *input = data->imgu->input;
 	V4L2Device *cio2 = data->cio2.output;
+	V4L2Device *stat = data->imgu->stat;
+	int ret;
 
-	int ret = cio2->releaseBuffers();
-	if (ret) {
-		LOG(IPU3, Error) << "Failed to release memory";
-		return ret;
-	}
+	ret = output->releaseBuffers();
+	if (ret)
+		LOG(IPU3, Error) << "Failed to release ImgU output memory";
+
+	ret = stat->releaseBuffers();
+	if (ret)
+		LOG(IPU3, Error) << "Failed to release ImgU stat memory";
+
+	ret = viewfinder->releaseBuffers();
+	if (ret)
+		LOG(IPU3, Error) << "Failed to release ImgU viewfinder memory";
+
+	ret = input->releaseBuffers();
+	if (ret)
+		LOG(IPU3, Error) << "Failed to release ImgU input memory";
+
+	ret = cio2->releaseBuffers();
+	if (ret)
+		LOG(IPU3, Error) << "Failed to release CIO2 memory";
 
 	return 0;
 }