Patch Detail
Show a patch.
GET /api/patches/22575/?format=api
{ "id": 22575, "url": "https://patchwork.libcamera.org/api/patches/22575/?format=api", "web_url": "https://patchwork.libcamera.org/patch/22575/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20250114182143.1773762-15-pobrn@protonmail.com>", "date": "2025-01-14T18:22:56", "name": "[RFC,v2,14/16] apps: lc-compliance: Support multiple streams in helpers", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "41a19fc6d7b41d03585b3211d5a651095424be5f", "submitter": { "id": 133, "url": "https://patchwork.libcamera.org/api/people/133/?format=api", "name": "Pőcze Barnabás", "email": "pobrn@protonmail.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/22575/mbox/", "series": [ { "id": 4951, "url": "https://patchwork.libcamera.org/api/series/4951/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4951", "date": "2025-01-14T18:21:46", "name": "apps: lc-compliance: Multi-stream tests", "version": 2, "mbox": "https://patchwork.libcamera.org/series/4951/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/22575/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/22575/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 A7DDBC3304\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 14 Jan 2025 18:23:02 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5204A6855D;\n\tTue, 14 Jan 2025 19:23:02 +0100 (CET)", "from mail-4322.protonmail.ch (mail-4322.protonmail.ch\n\t[185.70.43.22])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6199268521\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 14 Jan 2025 19:23:01 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=protonmail.com header.i=@protonmail.com\n\theader.b=\"ZYWdK5Oq\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;\n\ts=protonmail3; t=1736878980; x=1737138180;\n\tbh=0jgw0oHmttS1F984ihn3jien+MTBhFzi/r9j8a3qC1E=;\n\th=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References:\n\tFeedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID:\n\tMessage-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post;\n\tb=ZYWdK5OqRGM5XemR3AXN7dCXW6m3YYWQo+jsuUV5JP+cn0YpjALVSi+jipd9W+wsn\n\tfK5elcwbwBCarnhImu3F0pCWQb+/1pXxq0GKXQdgRJxq3LdtwLRwE4kplX9QsOq8O1\n\tRpFeQpFgzsvifzVbtTsYGRsjOw8PKokt3QVI37z0q6FK3EaT4ixXFCm+PbhSoNiHQ5\n\t/GkLpswPDaHr559B/5OHrhY23E0RG4uOWfAdBtn4wqsicNd+CO199OZkt+zE0Vpt6f\n\tI49IzPrAPYIGeQBdt2HCEsKycOe5XpashW5p6frpR7I//8LhUwNeN18VZyxfbxs36C\n\tCRUB5v/VHwZ+w==", "Date": "Tue, 14 Jan 2025 18:22:56 +0000", "To": "libcamera-devel@lists.libcamera.org", "From": "=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <pobrn@protonmail.com>", "Cc": "Jacopo Mondi <jacopo.mondi@ideasonboard.com>", "Subject": "[RFC PATCH v2 14/16] apps: lc-compliance: Support multiple streams\n\tin helpers", "Message-ID": "<20250114182143.1773762-15-pobrn@protonmail.com>", "In-Reply-To": "<20250114182143.1773762-1-pobrn@protonmail.com>", "References": "<20250114182143.1773762-1-pobrn@protonmail.com>", "Feedback-ID": "20568564:user:proton", "X-Pm-Message-ID": "670339bc1091abef1cd1c4c165e587de1f14abba", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=utf-8", "Content-Transfer-Encoding": "quoted-printable", "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": "Prepare to add a test suite for capture operations with multiple\nstreams.\n\nModify the Capture helper class to support multiple roles and streams\nin the configure() and capture() operations.\n\nMulti-stream support will be added in next patches.\n\nCo-developed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nSigned-off-by: Barnabás Pőcze <pobrn@protonmail.com>\n---\n src/apps/lc-compliance/helpers/capture.cpp | 77 +++++++++++++++----\n src/apps/lc-compliance/helpers/capture.h | 2 +-\n src/apps/lc-compliance/tests/capture_test.cpp | 6 +-\n 3 files changed, 66 insertions(+), 19 deletions(-)", "diff": "diff --git a/src/apps/lc-compliance/helpers/capture.cpp b/src/apps/lc-compliance/helpers/capture.cpp\nindex 77e87c9e4..dbaff4138 100644\n--- a/src/apps/lc-compliance/helpers/capture.cpp\n+++ b/src/apps/lc-compliance/helpers/capture.cpp\n@@ -24,13 +24,31 @@ Capture::~Capture()\n \tstop();\n }\n \n-void Capture::configure(StreamRole role)\n+void Capture::configure(libcamera::Span<const libcamera::StreamRole> roles)\n {\n-\tconfig_ = camera_->generateConfiguration({ role });\n+\tassert(!roles.empty());\n+\n+\tconfig_ = camera_->generateConfiguration(roles);\n \n \tif (!config_)\n \t\tGTEST_SKIP() << \"Role not supported by camera\";\n \n+\tASSERT_EQ(config_->size(), roles.size()) << \"Unexpected number of streams in configuration\";\n+\n+\t/*\n+\t * Set the buffers count to the largest value across all streams.\n+\t * \\todo: Should all streams from a Camera have the same buffer count ?\n+\t */\n+\tauto largest =\n+\t\tstd::max_element(config_->begin(), config_->end(),\n+\t\t\t\t [](const StreamConfiguration &l, const StreamConfiguration &r)\n+\t\t\t\t { return l.bufferCount < r.bufferCount; });\n+\n+\tassert(largest != config_->end());\n+\n+\tfor (auto &cfg : *config_)\n+\t\tcfg.bufferCount = largest->bufferCount;\n+\n \tif (config_->validate() != CameraConfiguration::Valid) {\n \t\tconfig_.reset();\n \t\tFAIL() << \"Configuration not valid\";\n@@ -76,20 +94,36 @@ void Capture::prepareRequests(std::optional<unsigned int> queueLimit)\n \tassert(config_);\n \tassert(requests_.empty());\n \n-\tStream *stream = config_->at(0).stream();\n-\tconst std::vector<std::unique_ptr<FrameBuffer>> &buffers = allocator_.buffers(stream);\n+\tstd::size_t maxBuffers = 0;\n+\n+\tfor (const auto &cfg : *config_) {\n+\t\tconst auto &buffers = allocator_.buffers(cfg.stream());\n+\t\tASSERT_FALSE(buffers.empty()) << \"Zero buffers allocated for stream\";\n+\n+\t\tmaxBuffers = std::max(maxBuffers, buffers.size());\n+\t}\n \n \t/* No point in testing less requests then the camera depth. */\n-\tif (queueLimit && *queueLimit < buffers.size()) {\n-\t\tGTEST_SKIP() << \"Camera needs \" << buffers.size()\n+\tif (queueLimit && *queueLimit < maxBuffers) {\n+\t\tGTEST_SKIP() << \"Camera needs \" << maxBuffers\n \t\t\t << \" requests, can't test only \" << *queueLimit;\n \t}\n \n-\tfor (const std::unique_ptr<FrameBuffer> &buffer : buffers) {\n-\t\tstd::unique_ptr<Request> request = camera_->createRequest();\n+\tfor (std::size_t i = 0; i < maxBuffers; i++) {\n+\t\tstd::unique_ptr<Request> request = camera_->createRequest(i);\n \t\tASSERT_TRUE(request) << \"Can't create request\";\n \n-\t\tASSERT_EQ(request->addBuffer(stream, buffer.get()), 0) << \"Can't set buffer for request\";\n+\t\tfor (const auto &cfg : *config_) {\n+\t\t\tStream *stream = cfg.stream();\n+\t\t\tconst auto &buffers = allocator_.buffers(stream);\n+\t\t\tassert(!buffers.empty());\n+\n+\t\t\tif (i >= buffers.size())\n+\t\t\t\tcontinue;\n+\n+\t\t\tASSERT_EQ(request->addBuffer(stream, buffers[i].get()), 0)\n+\t\t\t\t<< \"Can't add buffer to request\";\n+\t\t}\n \n \t\trequests_.push_back(std::move(request));\n \t}\n@@ -125,11 +159,19 @@ void Capture::requestComplete(Request *request)\n \n void Capture::start()\n {\n-\tStream *stream = config_->at(0).stream();\n-\tint count = allocator_.allocate(stream);\n+\tassert(config_);\n+\tassert(!config_->empty());\n+\tassert(!allocator_.allocated());\n+\n+\tfor (const auto &cfg : *config_) {\n+\t\tStream *stream = cfg.stream();\n+\t\tint count = allocator_.allocate(stream);\n+\n+\t\tASSERT_GE(count, 0) << \"Failed to allocate buffers\";\n+\t\tEXPECT_EQ(count, cfg.bufferCount) << \"Allocated less buffers than expected\";\n+\t}\n \n-\tASSERT_GE(count, 0) << \"Failed to allocate buffers\";\n-\tEXPECT_EQ(count, config_->at(0).bufferCount) << \"Allocated less buffers than expected\";\n+\tASSERT_TRUE(allocator_.allocated());\n \n \tcamera_->requestCompleted.connect(this, &Capture::requestComplete);\n \n@@ -145,7 +187,12 @@ void Capture::stop()\n \n \tcamera_->requestCompleted.disconnect(this);\n \n-\tStream *stream = config_->at(0).stream();\n \trequests_.clear();\n-\tallocator_.free(stream);\n+\n+\tfor (const auto &cfg : *config_) {\n+\t\tint ret = allocator_.free(cfg.stream());\n+\t\tEXPECT_EQ(ret, 0) << \"Failed to free buffers associated with stream\";\n+\t}\n+\n+\tEXPECT_FALSE(allocator_.allocated());\n }\ndiff --git a/src/apps/lc-compliance/helpers/capture.h b/src/apps/lc-compliance/helpers/capture.h\nindex 173421fd2..391184ad6 100644\n--- a/src/apps/lc-compliance/helpers/capture.h\n+++ b/src/apps/lc-compliance/helpers/capture.h\n@@ -20,7 +20,7 @@ public:\n \tCapture(std::shared_ptr<libcamera::Camera> camera);\n \t~Capture();\n \n-\tvoid configure(libcamera::StreamRole role);\n+\tvoid configure(libcamera::Span<const libcamera::StreamRole> roles);\n \tvoid run(unsigned int captureLimit, std::optional<unsigned int> queueLimit = {});\n \n private:\ndiff --git a/src/apps/lc-compliance/tests/capture_test.cpp b/src/apps/lc-compliance/tests/capture_test.cpp\nindex 93bed48f0..147e17019 100644\n--- a/src/apps/lc-compliance/tests/capture_test.cpp\n+++ b/src/apps/lc-compliance/tests/capture_test.cpp\n@@ -89,7 +89,7 @@ TEST_P(SingleStream, Capture)\n \n \tCapture capture(camera_);\n \n-\tcapture.configure(role);\n+\tcapture.configure(std::array{ role });\n \n \tcapture.run(numRequests, numRequests);\n }\n@@ -108,7 +108,7 @@ TEST_P(SingleStream, CaptureStartStop)\n \n \tCapture capture(camera_);\n \n-\tcapture.configure(role);\n+\tcapture.configure(std::array{ role });\n \n \tfor (unsigned int starts = 0; starts < numRepeats; starts++)\n \t\tcapture.run(numRequests, numRequests);\n@@ -127,7 +127,7 @@ TEST_P(SingleStream, UnbalancedStop)\n \n \tCapture capture(camera_);\n \n-\tcapture.configure(role);\n+\tcapture.configure(std::array{ role });\n \n \tcapture.run(numRequests);\n }\n", "prefixes": [ "RFC", "v2", "14/16" ] }