From patchwork Thu Jun 3 12:43:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 12492 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1C310C3206 for ; Thu, 3 Jun 2021 12:43:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6720C602A3; Thu, 3 Jun 2021 14:43:52 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="YYhJeeFB"; dkim-atps=neutral Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 09540602A2 for ; Thu, 3 Jun 2021 14:43:50 +0200 (CEST) Received: by mail-wm1-x334.google.com with SMTP id p13-20020a05600c358db029019f44afc845so3617040wmq.3 for ; Thu, 03 Jun 2021 05:43:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fItYp3tedsJj/+S2GxhJhw0m6xSsIwR2UaIlCLahRuI=; b=YYhJeeFBWib/s2glQx+TobzA60ycWeE1ZyodaCH0MYhimhJs2Ioz5ACMtNgSbeoLch Xf2leGhgjUPJAjO8v7InZLwLqSVroVsrbmBlVqVk/1nmvUcNIfkmnVdk1LrOGotBuo7B bHm+y+5Lpxh4BlqnXttGg7d3AkQuDMo+BEsvsshpfChtXTkCHP4mIVzA07t7ydOVchHc f9Wq00Vol8niyiwywhids+PL6fYZ8woLf5v3vcfym1eOb+5v/RWUwj66XZ7hyGa12qGZ kkcVi2ot2hD+l1ucqmq8aGW2yoY4zPNIXyCZKEO6nY9Fmur5rrOlaCjUcyCF0kD6K9m+ 3u+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fItYp3tedsJj/+S2GxhJhw0m6xSsIwR2UaIlCLahRuI=; b=mvdeZTyEdxt+4LS773u7mnpN4lePFHOydzl5vLPXeKSAbgBJfn7dW3NbXGF+Ynml3X iu8lSIHNwpZJDwXcJg8eoGneAOW8m9028PKhRpLhszaa9asD7NRXbQEd7hOogsSLy0tz O0Ka5BabT5KasFWIhxZ8VpXQT+qd19HVNDRP8VgaSB6QpC6NYs14AHBJNcqpV00NoXGl Dn2aQEGKN5Y9n3z2E3wddRnTsWbTtVgkambFXY85OSHTtQM7R4JtELBxfjjnAWOKX2tL rZdTqz9Nl8n1qAOkDSd7aDyd+Fj47+KW1bN21aj57dB1Z3OnClMjjgGO8CCVy4GWX0Z7 Vqng== X-Gm-Message-State: AOAM531e2eqSlSsIt+vikABM+VByzn38wmTvR47eRRJ6JNTvEWNDH3Zs OqRSFHEICX0KN/uQdpdp7niFwMlBnnwJow== X-Google-Smtp-Source: ABdhPJykrOSMvd9VLCn+2nR1RLWEybcUcjnXBXZrN6dKIBy9HwKjWpV3KYs4DLOr6f31I3InHU1p9g== X-Received: by 2002:a7b:cf2e:: with SMTP id m14mr18421240wmg.111.1622724230118; Thu, 03 Jun 2021 05:43:50 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:bd6e:fb37:8844:f274]) by smtp.gmail.com with ESMTPSA id a77sm3588358wmd.14.2021.06.03.05.43.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 05:43:49 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Thu, 3 Jun 2021 13:43:45 +0100 Message-Id: <20210603124345.2492885-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] pipeline: raspberrypi: Simplify RPiCameraData::clearIncompleteRequests() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Tested-by: David Plowman Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- .../pipeline/raspberrypi/raspberrypi.cpp | 46 ++++--------------- 1 file changed, 8 insertions(+), 38 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index a65b4568256c..887f8d0f7404 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_ = {}; @@ -1477,49 +1479,17 @@ 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 pipeline. */ 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);