[libcamera-devel,v2,2/2] libcamera: ipu3: Do not re-queue cancelled buffers

Message ID 20190716072739.2071-3-jacopo@jmondi.org
State Accepted
Headers show
Series
  • libcamera: ipu3: fixes
Related show

Commit Message

Jacopo Mondi July 16, 2019, 7:27 a.m. UTC
When a video device is stopped all the buffers there queued are released
and their state is set to BufferCancelled.

Currently, on buffer completion, cancelled buffers are blindly re-queued
to the ImgU input or CIO2 output devices, preventing them to be
re-started succesfully in future capture sessions.

Fix that by inspecting the buffers status and skip re-queueing if
they're reported as cancelled. For the ImgU output buffer this is not
required, as cancelled request should be reported to applications in
order to report them failure of the capture operations.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/pipeline/ipu3/ipu3.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

--
2.21.0

Patch

diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index bae3072b177f..c27fe75577f5 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -927,6 +927,10 @@  int PipelineHandlerIPU3::registerCameras()
  */
 void IPU3CameraData::imguInputBufferReady(Buffer *buffer)
 {
+	/* \todo Handle buffer failures when state is set to BufferError. */
+	if (buffer->status() == Buffer::BufferCancelled)
+		return;
+
 	cio2_.output_->queueBuffer(buffer);
 }

@@ -957,6 +961,10 @@  void IPU3CameraData::imguOutputBufferReady(Buffer *buffer)
  */
 void IPU3CameraData::cio2BufferReady(Buffer *buffer)
 {
+	/* \todo Handle buffer failures when state is set to BufferError. */
+	if (buffer->status() == Buffer::BufferCancelled)
+		return;
+
 	imgu_->input_->queueBuffer(buffer);
 }