From patchwork Mon Feb 8 09:44:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 11185 X-Patchwork-Delegate: niklas.soderlund@ragnatech.se 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 8A8D5BD160 for ; Mon, 8 Feb 2021 09:44:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 015AE60D14; Mon, 8 Feb 2021 10:44:27 +0100 (CET) Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5465360D10 for ; Mon, 8 Feb 2021 10:44:25 +0100 (CET) X-Halon-ID: 36ddc28c-69f2-11eb-a542-005056917a89 Authorized-sender: niklas.soderlund@fsdn.se Received: from bismarck.berto.se (p4fca2458.dip0.t-ipconnect.de [79.202.36.88]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 36ddc28c-69f2-11eb-a542-005056917a89; Mon, 08 Feb 2021 10:44:23 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Feb 2021 10:44:16 +0100 Message-Id: <20210208094416.2124569-1-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] cam: Fail capture if to few Requests asked for 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" Running cam with the --capture=N option only queues N Requests to the camera. If N is less then the number of requests needed by the camera to operate cam may deadlock waiting for the camera to complete requests while the camera waits for the application to give it more buffers. Fix this by adding a check in cam to no attempt a capture session if to few requests are requested. Reported-by: Sebastian Fricke Signed-off-by: Niklas Söderlund Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/cam/capture.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp index 7b55fc6770225e2a..18aa97c7cdb55dcc 100644 --- a/src/cam/capture.cpp +++ b/src/cam/capture.cpp @@ -90,6 +90,13 @@ int Capture::capture(FrameBufferAllocator *allocator) nbuffers = std::min(nbuffers, allocated); } + if (captureLimit_ && captureLimit_ < nbuffers) { + std::cerr << "Camera requiers at least " << nbuffers + << " reqests to function, " << captureLimit_ + << " requested" << std::endl; + return -EINVAL; + } + /* * TODO: make cam tool smarter to support still capture by for * example pushing a button. For now run all streams all the time.