{"id":23284,"url":"https://patchwork.libcamera.org/api/1.1/patches/23284/?format=json","web_url":"https://patchwork.libcamera.org/patch/23284/","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":"<20250428090413.38234-13-s.pueschel@pengutronix.de>","date":"2025-04-28T09:02:37","name":"[v11,12/19] lc-compliance: Move buffer allocation to separate function","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"bdfa1fced7376fb027b3efdb4dc8a58e65e89332","submitter":{"id":225,"url":"https://patchwork.libcamera.org/api/1.1/people/225/?format=json","name":"Sven Püschel","email":"s.pueschel@pengutronix.de"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23284/mbox/","series":[{"id":5148,"url":"https://patchwork.libcamera.org/api/1.1/series/5148/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5148","date":"2025-04-28T09:02:25","name":"lc-compliance: Add test to queue more requests than hardware depth","version":11,"mbox":"https://patchwork.libcamera.org/series/5148/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23284/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23284/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 055DCC3325\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Apr 2025 09:05:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2037968B2A;\n\tMon, 28 Apr 2025 11:05:31 +0200 (CEST)","from metis.whiteo.stw.pengutronix.de\n\t(metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D52F68B25\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Apr 2025 11:05:08 +0200 (CEST)","from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77]\n\thelo=peter.guest.stw.pengutronix.de)\n\tby metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92)\n\t(envelope-from <s.pueschel@pengutronix.de>)\n\tid 1u9KQF-0001au-Oz; Mon, 28 Apr 2025 11:05:07 +0200"],"From":"=?utf-8?q?Sven_P=C3=BCschel?= <s.pueschel@pengutronix.de>","To":"libcamera-devel@lists.libcamera.org","Cc":"=?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= <nfraprado@collabora.com>,\n\tPaul Elder <paul.elder@ideasonboard.com>, =?utf-8?q?Sven_P=C3=BCschel?=\n\t<s.pueschel@pengutronix.de>","Subject":"[PATCH v11 12/19] lc-compliance: Move buffer allocation to separate\n\tfunction","Date":"Mon, 28 Apr 2025 11:02:37 +0200","Message-ID":"<20250428090413.38234-13-s.pueschel@pengutronix.de>","X-Mailer":"git-send-email 2.49.0","In-Reply-To":"<20250428090413.38234-1-s.pueschel@pengutronix.de>","References":"<20250428090413.38234-1-s.pueschel@pengutronix.de>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-SA-Exim-Connect-IP":"2a0a:edc0:0:900:1d::77","X-SA-Exim-Mail-From":"s.pueschel@pengutronix.de","X-SA-Exim-Scanned":"No (on metis.whiteo.stw.pengutronix.de);\n\tSAEximRunCond expanded to false","X-PTX-Original-Recipient":"libcamera-devel@lists.libcamera.org","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":"From: Nícolas F. R. A. Prado <nfraprado@collabora.com>\n\nMove buffer allocation to its own function and with an optional count\nargument so tests can specify how many buffers to allocate. When count\nis omitted, allocate MinimumRequests buffers.\n\nSigned-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nSigned-off-by: Sven Püschel <s.pueschel@pengutronix.de>\n\n---\nChanges in v11:\n- adapted to support multiple streams\n- added requestCount_ member to pass allocated count to start()\n- added assert to allocateBuffers\n\nChanges in v9:\n- rebased\n\nChanges in v8:\n- Made SimpleCapture::allocateBuffers() a single function with an optional parameter\n\nChanges in v5:\n- New\n---\n src/apps/lc-compliance/helpers/capture.cpp    | 36 ++++++++++++-------\n src/apps/lc-compliance/helpers/capture.h      |  2 ++\n src/apps/lc-compliance/tests/capture_test.cpp |  8 ++++-\n 3 files changed, 33 insertions(+), 13 deletions(-)","diff":"diff --git a/src/apps/lc-compliance/helpers/capture.cpp b/src/apps/lc-compliance/helpers/capture.cpp\nindex 5e8b5df6..1e232dd1 100644\n--- a/src/apps/lc-compliance/helpers/capture.cpp\n+++ b/src/apps/lc-compliance/helpers/capture.cpp\n@@ -44,6 +44,24 @@ void Capture::configure(libcamera::Span<const libcamera::StreamRole> roles)\n \t}\n }\n \n+void Capture::allocateBuffers(unsigned int count)\n+{\n+\tassert(!allocator_.allocated());\n+\n+\tif (!count)\n+\t\tcount = camera_->properties().get(properties::MinimumRequests).value();\n+\n+\tfor (const auto &cfg : *config_) {\n+\t\tStream *stream = cfg.stream();\n+\n+\t\tint allocatedCount = allocator_.allocate(stream, count);\n+\t\tASSERT_GE(allocatedCount, 0) << \"Failed to allocate buffers\";\n+\t\tEXPECT_EQ(allocatedCount, count) << \"Allocated less buffers than expected\";\n+\t}\n+\n+\trequestCount_ = count;\n+}\n+\n void Capture::run(unsigned int captureLimit, std::optional<unsigned int> queueLimit)\n {\n \tassert(!queueLimit || captureLimit <= *queueLimit);\n@@ -103,19 +121,16 @@ void Capture::start()\n {\n \tassert(config_);\n \tassert(!config_->empty());\n-\tassert(!allocator_.allocated());\n+\tassert(allocator_.allocated());\n \tassert(requests_.empty());\n \n-\tunsigned int bufferCount =\n-\t\tcamera_->properties().get(properties::MinimumRequests).value();\n-\n \t/* No point in testing less requests then the camera depth. */\n-\tif (queueLimit_ && *queueLimit_ < bufferCount) {\n-\t\tGTEST_SKIP() << \"Camera needs \" << bufferCount\n+\tif (queueLimit_ && *queueLimit_ < requestCount_) {\n+\t\tGTEST_SKIP() << \"Camera needs \" << requestCount_\n \t\t\t     << \" requests, can't test only \" << *queueLimit_;\n \t}\n \n-\tfor (std::size_t i = 0; i < bufferCount; i++) {\n+\tfor (std::size_t i = 0; i < requestCount_; i++) {\n \t\tstd::unique_ptr<Request> request = camera_->createRequest();\n \t\tASSERT_TRUE(request) << \"Can't create request\";\n \t\trequests_.push_back(std::move(request));\n@@ -124,13 +139,10 @@ void Capture::start()\n \tfor (const auto &cfg : *config_) {\n \t\tStream *stream = cfg.stream();\n \n-\t\tint count = allocator_.allocate(stream, bufferCount);\n-\t\tASSERT_GE(count, 0) << \"Failed to allocate buffers\";\n-\n \t\tconst auto &buffers = allocator_.buffers(stream);\n-\t\tASSERT_EQ(buffers.size(), bufferCount) << \"Mismatching buffer count\";\n+\t\tASSERT_EQ(buffers.size(), requestCount_) << \"Mismatching buffer count\";\n \n-\t\tfor (std::size_t i = 0; i < bufferCount; i++) {\n+\t\tfor (std::size_t i = 0; i < requestCount_; i++) {\n \t\t\tASSERT_EQ(requests_[i]->addBuffer(stream, buffers[i].get()), 0)\n \t\t\t\t<< \"Failed to add buffer to request\";\n \t\t}\ndiff --git a/src/apps/lc-compliance/helpers/capture.h b/src/apps/lc-compliance/helpers/capture.h\nindex ea01c11c..2a14a721 100644\n--- a/src/apps/lc-compliance/helpers/capture.h\n+++ b/src/apps/lc-compliance/helpers/capture.h\n@@ -21,6 +21,7 @@ public:\n \t~Capture();\n \n \tvoid configure(libcamera::Span<const libcamera::StreamRole> roles);\n+\tvoid allocateBuffers(unsigned int count = 0);\n \tvoid run(unsigned int captureLimit, std::optional<unsigned int> queueLimit = {});\n \n private:\n@@ -42,4 +43,5 @@ private:\n \tstd::optional<unsigned int> queueLimit_;\n \tunsigned int captureCount_ = 0;\n \tunsigned int queueCount_ = 0;\n+\tunsigned int requestCount_ = 0;\n };\ndiff --git a/src/apps/lc-compliance/tests/capture_test.cpp b/src/apps/lc-compliance/tests/capture_test.cpp\nindex d02caa8a..9fb82a2b 100644\n--- a/src/apps/lc-compliance/tests/capture_test.cpp\n+++ b/src/apps/lc-compliance/tests/capture_test.cpp\n@@ -83,6 +83,8 @@ TEST_P(SimpleCapture, Capture)\n \n \tcapture.configure(roles);\n \n+\tcapture.allocateBuffers();\n+\n \tcapture.run(numRequests, numRequests);\n }\n \n@@ -102,8 +104,10 @@ TEST_P(SimpleCapture, CaptureStartStop)\n \n \tcapture.configure(roles);\n \n-\tfor (unsigned int starts = 0; starts < numRepeats; starts++)\n+\tfor (unsigned int starts = 0; starts < numRepeats; starts++) {\n+\t\tcapture.allocateBuffers();\n \t\tcapture.run(numRequests, numRequests);\n+\t}\n }\n \n /*\n@@ -121,6 +125,8 @@ TEST_P(SimpleCapture, UnbalancedStop)\n \n \tcapture.configure(roles);\n \n+\tcapture.allocateBuffers();\n+\n \tcapture.run(numRequests);\n }\n \n","prefixes":["v11","12/19"]}