[libcamera-devel] [PATCH 2/2] libcamera: camera: Unmap buffers before release

Kieran Bingham kieran.bingham at ideasonboard.com
Tue Mar 5 00:25:30 CET 2019


Before buffers can be released back to V4L2 all mappings must be unmapped.
Ensure that buffers are released correctly by destroying the buffer pool
contents before freeing the resources on the stream.

Signed-off-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
---
 src/libcamera/camera.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index 8e17085bfb50..875e1e46c89c 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -488,8 +488,13 @@ int Camera::freeBuffers()
 		if (!stream->bufferPool().count())
 			continue;
 
-		pipe_->freeBuffers(this, stream);
+		/*
+		 * Destroy Buffers will empty the pool, and unmap any existing
+		 * memory mapping. This needs to be done before releasing
+		 * buffers back to the V4L2Device through freeBuffers().
+		 */
 		stream->bufferPool().destroyBuffers();
+		pipe_->freeBuffers(this, stream);
 	}
 
 	state_ = CameraConfigured;
-- 
2.19.1



More information about the libcamera-devel mailing list