{"id":23643,"url":"https://patchwork.libcamera.org/api/patches/23643/?format=json","web_url":"https://patchwork.libcamera.org/patch/23643/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20250624122830.726987-2-barnabas.pocze@ideasonboard.com>","date":"2025-06-24T12:28:30","name":"[RFC,v1,2/2] apps: lc-compliance: Allocate buffers when configuring","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"0748854f37b7c84d351587bb6d520deb849ce231","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23643/mbox/","series":[{"id":5244,"url":"https://patchwork.libcamera.org/api/series/5244/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5244","date":"2025-06-24T12:28:29","name":"[RFC,v1,1/2] apps: lc-compliance: Commit camera configuration last","version":1,"mbox":"https://patchwork.libcamera.org/series/5244/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23643/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23643/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 CC591C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 24 Jun 2025 12:28:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5BB8E68DF3;\n\tTue, 24 Jun 2025 14:28:38 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6333668DE2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Jun 2025 14:28:34 +0200 (CEST)","from pb-laptop.local (185.221.143.107.nat.pool.zt.hu\n\t[185.221.143.107])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D21C2C72\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Jun 2025 14:28:16 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"UVTZks48\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750768096;\n\tbh=S3dau1QvY+vK+dVFmDxpZjqW9StgVIdJ+docSzXpvb0=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=UVTZks48V7zhWEt3J30ql1EphYAzitQIxsLAabu9rmluFpKRGNtcGpT41S8xYYAoU\n\tywTt5LWzcaj2viFYegk/b7WmqLBNzU+GLuIMfgIp2Fy8WslwIqmsKd28XFrN1OB7oM\n\t0oPDSyfD7pjdTUggymamo4+5BwHxqTW0uM7CkwXQ=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[RFC PATCH v1 2/2] apps: lc-compliance: Allocate buffers when\n\tconfiguring","Date":"Tue, 24 Jun 2025 14:28:30 +0200","Message-ID":"<20250624122830.726987-2-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.50.0","In-Reply-To":"<20250624122830.726987-1-barnabas.pocze@ideasonboard.com>","References":"<20250624122830.726987-1-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","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":"Most pipeline handlers release buffers when a camera is stopped. However,\nthe raspberry pi pipelines do not do that. Hence they are incompatible\nwith the current model and all \"CaptureStartStop\" tests fail because\nlc-compliance allocates buffers before starting and releases them after\nstopping. Fix this by allocating buffers after the camera is configured,\nand do not release them after stopping.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/apps/lc-compliance/helpers/capture.cpp | 28 +++++++++++++++++-----\n src/apps/lc-compliance/helpers/capture.h   |  1 +\n 2 files changed, 23 insertions(+), 6 deletions(-)","diff":"diff --git a/src/apps/lc-compliance/helpers/capture.cpp b/src/apps/lc-compliance/helpers/capture.cpp\nindex d076e964a..df0ad00ac 100644\n--- a/src/apps/lc-compliance/helpers/capture.cpp\n+++ b/src/apps/lc-compliance/helpers/capture.cpp\n@@ -21,6 +21,7 @@ Capture::Capture(std::shared_ptr<Camera> camera)\n Capture::~Capture()\n {\n \tstop();\n+\tunconfigure();\n }\n \n void Capture::configure(libcamera::Span<const libcamera::StreamRole> roles)\n@@ -50,6 +51,20 @@ void Capture::configure(libcamera::Span<const libcamera::StreamRole> roles)\n \tASSERT_EQ(config->validate(), CameraConfiguration::Valid);\n \tASSERT_EQ(camera_->configure(config.get()), 0);\n \n+\tconst auto bufferCount = config->at(0).bufferCount;\n+\n+\tfor (const auto &cfg : *config) {\n+\t\tStream *stream = cfg.stream();\n+\n+\t\tASSERT_GE(allocator_.allocate(stream), 0)\n+\t\t\t<< \"Failed to allocate buffers\";\n+\n+\t\tASSERT_EQ(allocator_.buffers(stream).size(), bufferCount)\n+\t\t\t<< \"Mismatching buffer count\";\n+\t}\n+\n+\tASSERT_TRUE(allocator_.allocated());\n+\n \tconfig_ = std::move(config);\n }\n \n@@ -112,7 +127,7 @@ 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 \tconst auto bufferCount = config_->at(0).bufferCount;\n@@ -132,9 +147,6 @@ void Capture::start()\n \tfor (const auto &cfg : *config_) {\n \t\tStream *stream = cfg.stream();\n \n-\t\tint count = allocator_.allocate(stream);\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 \n@@ -144,8 +156,6 @@ void Capture::start()\n \t\t}\n \t}\n \n-\tASSERT_TRUE(allocator_.allocated());\n-\n \tcamera_->requestCompleted.connect(this, &Capture::requestComplete);\n \n \tASSERT_EQ(camera_->start(), 0) << \"Failed to start camera\";\n@@ -161,6 +171,12 @@ void Capture::stop()\n \tcamera_->requestCompleted.disconnect(this);\n \n \trequests_.clear();\n+}\n+\n+void Capture::unconfigure()\n+{\n+\tif (!config_ || !allocator_.allocated())\n+\t\treturn;\n \n \tfor (const auto &cfg : *config_) {\n \t\tEXPECT_EQ(allocator_.free(cfg.stream()), 0)\ndiff --git a/src/apps/lc-compliance/helpers/capture.h b/src/apps/lc-compliance/helpers/capture.h\nindex ea01c11c1..41ce4e5a6 100644\n--- a/src/apps/lc-compliance/helpers/capture.h\n+++ b/src/apps/lc-compliance/helpers/capture.h\n@@ -28,6 +28,7 @@ private:\n \n \tvoid start();\n \tvoid stop();\n+\tvoid unconfigure();\n \n \tint queueRequest(libcamera::Request *request);\n \tvoid requestComplete(libcamera::Request *request);\n","prefixes":["RFC","v1","2/2"]}