{"id":15316,"url":"https://patchwork.libcamera.org/api/1.1/patches/15316/?format=json","web_url":"https://patchwork.libcamera.org/patch/15316/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220201092738.804028-2-naush@raspberrypi.com>","date":"2022-02-01T09:27:38","name":"[libcamera-devel,v1,2/2] pipeline: raspberrypi: Fix the buffer count calculation for the ISP input stream","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"f0225b26e057465d531f84d61fe761dfaedc7703","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15316/mbox/","series":[{"id":2907,"url":"https://patchwork.libcamera.org/api/1.1/series/2907/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2907","date":"2022-02-01T09:27:37","name":"[libcamera-devel,v1,1/2] pipeline: raspberrypi: Fix log message","version":1,"mbox":"https://patchwork.libcamera.org/series/2907/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15316/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15316/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 3EF58BDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Feb 2022 09:27:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1F00E609C9;\n\tTue,  1 Feb 2022 10:27:45 +0100 (CET)","from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com\n\t[IPv6:2a00:1450:4864:20::32b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EA1C1609AF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Feb 2022 10:27:43 +0100 (CET)","by mail-wm1-x32b.google.com with SMTP id\n\tbg21-20020a05600c3c9500b0035283e7a012so1170924wmb.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 01 Feb 2022 01:27:43 -0800 (PST)","from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:4d5c:b154:41bf:e0bf])\n\tby smtp.gmail.com with ESMTPSA id\n\ti6sm13841964wrw.8.2022.02.01.01.27.42\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 01 Feb 2022 01:27:42 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"XARsyupg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=6kvCDzXi5pnFVeXHFb5Scom2T7rg5KBUgg4cl0s/rtA=;\n\tb=XARsyupgE758gp3mz69PRfBpy8F9g2nsP/g+5ncLaPMcXUGpvtElIC2UOFSWzQEQyi\n\tE33qh2/nxZ9OYpiwuhFTnPxkNna0EzOvayh1fuA20ExJuc7YQCNPZbyojT9jC2K0tGA+\n\tsZdTw1cBf2DBp0sVEMuJ6gItTTr1QZI5dQyIzPp+67VCjeL7hf8+zaIDi+vgTj2pueU3\n\tSymoUIZer17bQj0BbHgNN3jTLTEPFpn0yglgQqhpNfI/ZwQOVLUcvVjbh+gG3WZjAiH0\n\tjINKY2CEYIpK2CDwti5v4JtWnRyKfnPC75H30h0poPIrVrXyzq/JRp8Snc7xrQOMfm4h\n\tDKcA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=6kvCDzXi5pnFVeXHFb5Scom2T7rg5KBUgg4cl0s/rtA=;\n\tb=Ry6A0xSwLrbeWVq/R2h8kSDFUTO2pGxk5cHe45P/gg5P0SLMGGW1XI9KEyjPBlgJ/B\n\tOMFaqP6Fg/kms/HVUrNTE4VQcV5GxOzFDfxl/e/lfqnCBycPgNTxdw3HEQcK+Tf7y+Wl\n\tl8XHWNYOWTssbPVON+T+UNxNcq1y9MuoNJ/0lcbnq43RxVqy9DK185aMbwB24qwdy6YX\n\t7uLIZgOInEhDV7rBsCVoBBmoEEJlG/TLj4wyxWVW9m8rcRPsSc7ut1x4ADgtW5h2+E2u\n\tmL/Vuz6qtxWSRYF9jDlIwjYY4cuXPuPp3yv/UcBZ5OBBmiHcySjzo5EqBDvr3aFW3Vz8\n\tWK6Q==","X-Gm-Message-State":"AOAM531oX65DaqsG4YXFUekk2XCaqzxOJsDclqrGLUz59NBjMUBYqBfS\n\tIB0xLMrUvfGNQ6Gq/HEdFyRFuW0sZsgL4w==","X-Google-Smtp-Source":"ABdhPJw5GxNer8IQZNL7427b6nTVylfJpdw5MyYTpEovXTl+3Fqd35pFY2olNhtxEsgjhrG4/7Jr8w==","X-Received":"by 2002:a05:600c:1e8b:: with SMTP id\n\tbe11mr962279wmb.96.1643707663415; \n\tTue, 01 Feb 2022 01:27:43 -0800 (PST)","From":"Naushir Patuck <naush@raspberrypi.com>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 2/2] pipeline: raspberrypi: Fix the\n\tbuffer count calculation for the ISP input stream","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The ISP input stream currently only allocates a single slot in the\nV4L2VideoDevice cache as it follows the number of buffers allocated for use.\nHowever, this is wrong as the ISP input stream imports buffers from Unicam\nimage stream.  As a consequence of this, only one cache slot was used during\nruntime for the ISP input stream, and if multiple buffers were to be queued\nsimultaneously, the queue operation would return a failure.\n\nFix this by passing the same number of RAW buffers available from the Unicam\nimage stream. Additionally, double this count in the cases where buffers could\nbe allocated externally from the application.\n\nBug: https://github.com/raspberrypi/libcamera-apps/issues/236\n     https://github.com/raspberrypi/libcamera-apps/issues/238\n     https://github.com/raspberrypi/libcamera-apps/issues/240\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 8 ++++++++\n src/libcamera/pipeline/raspberrypi/rpi_stream.cpp  | 3 ++-\n 2 files changed, 10 insertions(+), 1 deletion(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 6a46e6bc89fa..49af56edc1f9 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -1382,6 +1382,14 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera)\n \t\t\t * minimise frame drops.\n \t\t\t */\n \t\t\tnumBuffers = std::max<int>(2, minBuffers - numRawBuffers);\n+\t\t} else if (stream == &data->isp_[Isp::Input]) {\n+\t\t\t/*\n+\t\t\t * ISP input buffers are imported from Unicam, so follow\n+\t\t\t * similar logic as above to count all the RAW buffers\n+\t\t\t * available.\n+\t\t\t */\n+\t\t\tnumBuffers = numRawBuffers + std::max<int>(2, minBuffers - numRawBuffers);\n+\n \t\t} else if (stream == &data->unicam_[Unicam::Embedded]) {\n \t\t\t/*\n \t\t\t * Embedded data buffers are (currently) for internal use,\ndiff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp\nindex a4159e20b068..a421ad09ba50 100644\n--- a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp\n@@ -111,11 +111,12 @@ int Stream::prepareBuffers(unsigned int count)\n \t * If this is an external stream, we must allocate slots for buffers that\n \t * might be externally allocated. We have no indication of how many buffers\n \t * may be used, so this might overallocate slots in the buffer cache.\n+\t * Similarly, if this stream is only importing buffers, we do the same.\n \t *\n \t * \\todo Find a better heuristic, or, even better, an exact solution to\n \t * this issue.\n \t */\n-\tif (isExternal())\n+\tif (isExternal() || importOnly_)\n \t\tcount = count * 2;\n \n \treturn dev_->importBuffers(count);\n","prefixes":["libcamera-devel","v1","2/2"]}