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>
This commit is contained in:
Naushir Patuck 2021-06-03 13:43:45 +01:00 committed by Jacopo Mondi
parent 4bb81dfcc4
commit d372aaa10d

View file

@ -884,7 +884,9 @@ void PipelineHandlerRPi::stop(Camera *camera)
/* Disable SOF event generation. */ /* Disable SOF event generation. */
data->unicam_[Unicam::Image].dev()->setFrameStartEnabled(false); data->unicam_[Unicam::Image].dev()->setFrameStartEnabled(false);
/* This also stops the streams. */ for (auto const stream : data->streams_)
stream->dev()->streamOff();
data->clearIncompleteRequests(); data->clearIncompleteRequests();
data->bayerQueue_ = {}; data->bayerQueue_ = {};
data->embeddedQueue_ = {}; data->embeddedQueue_ = {};
@ -1477,49 +1479,17 @@ void RPiCameraData::ispOutputDequeue(FrameBuffer *buffer)
void RPiCameraData::clearIncompleteRequests() 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 * All outstanding requests (and associated buffers) must be returned
* back to the pipeline. The buffers would have been marked as * back to the application.
* cancelled by the call to streamOff() earlier.
*/ */
while (!requestQueue_.empty()) { while (!requestQueue_.empty()) {
Request *request = requestQueue_.front(); 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); for (auto &b : request->buffers()) {
/* FrameBuffer *buffer = b.second;
* Has the buffer already been handed back to the buffer->cancel();
* request? If not, do so now. pipe_->completeBuffer(request, buffer);
*/
if (buffer && buffer->request())
pipe_->completeBuffer(request, buffer);
} }
pipe_->completeRequest(request); pipe_->completeRequest(request);