summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2021-06-03 13:43:45 +0100
committerJacopo Mondi <jacopo@jmondi.org>2021-06-23 16:20:48 +0200
commitd372aaa10ddb0ab405c4054a0a407921127f2100 (patch)
tree09c008286d4cb11df206cb314cefb897471770e9
parent4bb81dfcc4a7d2134986bb64b733c41388b8060d (diff)
pipeline: raspberrypi: Simplify RPiCameraData::clearIncompleteRequests()
With the addition of FrameBuffer::cancel(), the logic to clear and return pending requests can be simplified by not having to queue all the request buffers to the device before calling streamOff(). Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
-rw-r--r--src/libcamera/pipeline/raspberrypi/raspberrypi.cpp46
1 files changed, 8 insertions, 38 deletions
diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
index a65b4568..4e26a193 100644
--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
@@ -884,7 +884,9 @@ void PipelineHandlerRPi::stop(Camera *camera)
/* Disable SOF event generation. */
data->unicam_[Unicam::Image].dev()->setFrameStartEnabled(false);
- /* This also stops the streams. */
+ for (auto const stream : data->streams_)
+ stream->dev()->streamOff();
+
data->clearIncompleteRequests();
data->bayerQueue_ = {};
data->embeddedQueue_ = {};
@@ -1478,48 +1480,16 @@ void RPiCameraData::ispOutputDequeue(FrameBuffer *buffer)
void RPiCameraData::clearIncompleteRequests()
{
/*
- * Queue up any buffers passed in the request.
- * This is needed because streamOff() will then mark the buffers as
- * cancelled.
- */
- for (auto const request : requestQueue_) {
- for (auto const stream : streams_) {
- if (!stream->isExternal())
- continue;
-
- FrameBuffer *buffer = request->findBuffer(stream);
- if (buffer)
- stream->queueBuffer(buffer);
- }
- }
-
- /* Stop all streams. */
- for (auto const stream : streams_)
- stream->dev()->streamOff();
-
- /*
* All outstanding requests (and associated buffers) must be returned
- * back to the pipeline. The buffers would have been marked as
- * cancelled by the call to streamOff() earlier.
+ * back to the application.
*/
while (!requestQueue_.empty()) {
Request *request = requestQueue_.front();
- /*
- * A request could be partially complete,
- * i.e. we have returned some buffers, but still waiting
- * for others or waiting for metadata.
- */
- for (auto const stream : streams_) {
- if (!stream->isExternal())
- continue;
- FrameBuffer *buffer = request->findBuffer(stream);
- /*
- * Has the buffer already been handed back to the
- * request? If not, do so now.
- */
- if (buffer && buffer->request())
- pipe_->completeBuffer(request, buffer);
+ for (auto &b : request->buffers()) {
+ FrameBuffer *buffer = b.second;
+ buffer->cancel();
+ pipe_->completeBuffer(request, buffer);
}
pipe_->completeRequest(request);