summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2020-11-24 17:59:34 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2020-11-26 10:31:15 +0000
commitc286b00aa1eb9331c3bab2b35905dcf2e4ccde66 (patch)
tree30c79ff8934ec51551d59e3bd96cb32f5f994e0b
parent770df5ca4eab84ec1d8a683d1ace04d7d00001c6 (diff)
pipeline: raspberrypi: Fix erroneous bayer buffer requeue on buffer matching
With the recent change in the bayer/embedded buffer matching code, a condition would make the bayer buffer be requeued back to the device, even though it could potentially be queued for matching. This would cause unnecessary frame drops as sync would be lost. The fix is to ensure the bayer buffer only gets requeued if the embedded data buffer queue is not empty, i.e. the buffer truly is orphaned. Additionally, we do this test before deciding to flush any of the two queues of all their buffers. Fixes: 909882b (pipeline: raspberrypi: Rework bayer/embedded data buffer matching) Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--src/libcamera/pipeline/raspberrypi/raspberrypi.cpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index 66b483f7..6fcdf557 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -1696,8 +1696,23 @@ bool RPiCameraData::findMatchingBuffers(FrameBuffer *&bayerBuffer, FrameBuffer *
}
if (!embeddedBuffer) {
+ bool flushedBuffers = false;
+
LOG(RPI, Debug) << "Could not find matching embedded buffer";
+ if (!embeddedQueue_.empty()) {
+ /*
+ * Not found a matching embedded buffer for the bayer buffer in
+ * the front of the queue. This buffer is now orphaned, so requeue
+ * it back to the device.
+ */
+ unicam_[Unicam::Image].queueBuffer(bayerQueue_.front());
+ bayerQueue_.pop();
+ bayerRequeueCount++;
+ LOG(RPI, Warning) << "Dropping unmatched input frame in stream "
+ << unicam_[Unicam::Image].name();
+ }
+
/*
* If we have requeued all available embedded data buffers in this loop,
* then we are fully out of sync, so might as well requeue all the pending
@@ -1712,21 +1727,10 @@ bool RPiCameraData::findMatchingBuffers(FrameBuffer *&bayerBuffer, FrameBuffer *
unicam_[Unicam::Image].queueBuffer(bayerQueue_.front());
bayerQueue_.pop();
}
- return false;
+ flushedBuffers = true;
}
/*
- * Not found a matching embedded buffer for the bayer buffer in
- * the front of the queue. This buffer is now orphaned, so requeue
- * it back to the device.
- */
- unicam_[Unicam::Image].queueBuffer(bayerQueue_.front());
- bayerQueue_.pop();
- bayerRequeueCount++;
- LOG(RPI, Warning) << "Dropping unmatched input frame in stream "
- << unicam_[Unicam::Image].name();
-
- /*
* Similar to the above, if we have requeued all available bayer buffers in
* the loop, then we are fully out of sync, so might as well requeue all the
* pending embedded data buffers.
@@ -1740,11 +1744,15 @@ bool RPiCameraData::findMatchingBuffers(FrameBuffer *&bayerBuffer, FrameBuffer *
unicam_[Unicam::Embedded].queueBuffer(embeddedQueue_.front());
embeddedQueue_.pop();
}
- return false;
+ flushedBuffers = true;
}
- /* If the embedded queue has become empty, we cannot do any more. */
- if (embeddedQueue_.empty())
+ /*
+ * If the embedded queue has become empty, we cannot do any more.
+ * Similarly, if we have flushed any one of our queues, we cannot do
+ * any more. Return from here without a buffer pair.
+ */
+ if (embeddedQueue_.empty() || flushedBuffers)
return false;
} else {
/*