From patchwork Tue Feb 1 09:27:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15316 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 3EF58BDCBF for ; Tue, 1 Feb 2022 09:27:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1F00E609C9; Tue, 1 Feb 2022 10:27:45 +0100 (CET) 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="XARsyupg"; dkim-atps=neutral Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EA1C1609AF for ; Tue, 1 Feb 2022 10:27:43 +0100 (CET) Received: by mail-wm1-x32b.google.com with SMTP id bg21-20020a05600c3c9500b0035283e7a012so1170924wmb.0 for ; Tue, 01 Feb 2022 01:27:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6kvCDzXi5pnFVeXHFb5Scom2T7rg5KBUgg4cl0s/rtA=; b=XARsyupgE758gp3mz69PRfBpy8F9g2nsP/g+5ncLaPMcXUGpvtElIC2UOFSWzQEQyi E33qh2/nxZ9OYpiwuhFTnPxkNna0EzOvayh1fuA20ExJuc7YQCNPZbyojT9jC2K0tGA+ sZdTw1cBf2DBp0sVEMuJ6gItTTr1QZI5dQyIzPp+67VCjeL7hf8+zaIDi+vgTj2pueU3 SymoUIZer17bQj0BbHgNN3jTLTEPFpn0yglgQqhpNfI/ZwQOVLUcvVjbh+gG3WZjAiH0 jINKY2CEYIpK2CDwti5v4JtWnRyKfnPC75H30h0poPIrVrXyzq/JRp8Snc7xrQOMfm4h DKcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6kvCDzXi5pnFVeXHFb5Scom2T7rg5KBUgg4cl0s/rtA=; b=Ry6A0xSwLrbeWVq/R2h8kSDFUTO2pGxk5cHe45P/gg5P0SLMGGW1XI9KEyjPBlgJ/B OMFaqP6Fg/kms/HVUrNTE4VQcV5GxOzFDfxl/e/lfqnCBycPgNTxdw3HEQcK+Tf7y+Wl l8XHWNYOWTssbPVON+T+UNxNcq1y9MuoNJ/0lcbnq43RxVqy9DK185aMbwB24qwdy6YX 7uLIZgOInEhDV7rBsCVoBBmoEEJlG/TLj4wyxWVW9m8rcRPsSc7ut1x4ADgtW5h2+E2u mL/Vuz6qtxWSRYF9jDlIwjYY4cuXPuPp3yv/UcBZ5OBBmiHcySjzo5EqBDvr3aFW3Vz8 WK6Q== X-Gm-Message-State: AOAM531oX65DaqsG4YXFUekk2XCaqzxOJsDclqrGLUz59NBjMUBYqBfS IB0xLMrUvfGNQ6Gq/HEdFyRFuW0sZsgL4w== X-Google-Smtp-Source: ABdhPJw5GxNer8IQZNL7427b6nTVylfJpdw5MyYTpEovXTl+3Fqd35pFY2olNhtxEsgjhrG4/7Jr8w== X-Received: by 2002:a05:600c:1e8b:: with SMTP id be11mr962279wmb.96.1643707663415; Tue, 01 Feb 2022 01:27:43 -0800 (PST) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:4d5c:b154:41bf:e0bf]) by smtp.gmail.com with ESMTPSA id i6sm13841964wrw.8.2022.02.01.01.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Feb 2022 01:27:42 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 1 Feb 2022 09:27:38 +0000 Message-Id: <20220201092738.804028-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220201092738.804028-1-naush@raspberrypi.com> References: <20220201092738.804028-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/2] pipeline: raspberrypi: Fix the buffer count calculation for the ISP input stream 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" The ISP input stream currently only allocates a single slot in the V4L2VideoDevice cache as it follows the number of buffers allocated for use. However, this is wrong as the ISP input stream imports buffers from Unicam image stream. As a consequence of this, only one cache slot was used during runtime for the ISP input stream, and if multiple buffers were to be queued simultaneously, the queue operation would return a failure. Fix this by passing the same number of RAW buffers available from the Unicam image stream. Additionally, double this count in the cases where buffers could be allocated externally from the application. Bug: https://github.com/raspberrypi/libcamera-apps/issues/236 https://github.com/raspberrypi/libcamera-apps/issues/238 https://github.com/raspberrypi/libcamera-apps/issues/240 Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 8 ++++++++ src/libcamera/pipeline/raspberrypi/rpi_stream.cpp | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 6a46e6bc89fa..49af56edc1f9 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1382,6 +1382,14 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * minimise frame drops. */ numBuffers = std::max(2, minBuffers - numRawBuffers); + } else if (stream == &data->isp_[Isp::Input]) { + /* + * ISP input buffers are imported from Unicam, so follow + * similar logic as above to count all the RAW buffers + * available. + */ + numBuffers = numRawBuffers + std::max(2, minBuffers - numRawBuffers); + } else if (stream == &data->unicam_[Unicam::Embedded]) { /* * Embedded data buffers are (currently) for internal use, diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp index a4159e20b068..a421ad09ba50 100644 --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp @@ -111,11 +111,12 @@ int Stream::prepareBuffers(unsigned int count) * If this is an external stream, we must allocate slots for buffers that * might be externally allocated. We have no indication of how many buffers * may be used, so this might overallocate slots in the buffer cache. + * Similarly, if this stream is only importing buffers, we do the same. * * \todo Find a better heuristic, or, even better, an exact solution to * this issue. */ - if (isExternal()) + if (isExternal() || importOnly_) count = count * 2; return dev_->importBuffers(count);