From patchwork Tue Jun 24 12:28:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 23643 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 CC591C3237 for ; Tue, 24 Jun 2025 12:28:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5BB8E68DF3; Tue, 24 Jun 2025 14:28:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="UVTZks48"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6333668DE2 for ; Tue, 24 Jun 2025 14:28:34 +0200 (CEST) Received: from pb-laptop.local (185.221.143.107.nat.pool.zt.hu [185.221.143.107]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D21C2C72 for ; Tue, 24 Jun 2025 14:28:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1750768096; bh=S3dau1QvY+vK+dVFmDxpZjqW9StgVIdJ+docSzXpvb0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UVTZks48V7zhWEt3J30ql1EphYAzitQIxsLAabu9rmluFpKRGNtcGpT41S8xYYAoU ywTt5LWzcaj2viFYegk/b7WmqLBNzU+GLuIMfgIp2Fy8WslwIqmsKd28XFrN1OB7oM 0oPDSyfD7pjdTUggymamo4+5BwHxqTW0uM7CkwXQ= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 2/2] apps: lc-compliance: Allocate buffers when configuring 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 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" Most pipeline handlers release buffers when a camera is stopped. However, the raspberry pi pipelines do not do that. Hence they are incompatible with the current model and all "CaptureStartStop" tests fail because lc-compliance allocates buffers before starting and releases them after stopping. Fix this by allocating buffers after the camera is configured, and do not release them after stopping. Signed-off-by: Barnabás Pőcze --- src/apps/lc-compliance/helpers/capture.cpp | 28 +++++++++++++++++----- src/apps/lc-compliance/helpers/capture.h | 1 + 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/apps/lc-compliance/helpers/capture.cpp b/src/apps/lc-compliance/helpers/capture.cpp index d076e964a..df0ad00ac 100644 --- a/src/apps/lc-compliance/helpers/capture.cpp +++ b/src/apps/lc-compliance/helpers/capture.cpp @@ -21,6 +21,7 @@ Capture::Capture(std::shared_ptr camera) Capture::~Capture() { stop(); + unconfigure(); } void Capture::configure(libcamera::Span roles) @@ -50,6 +51,20 @@ void Capture::configure(libcamera::Span roles) ASSERT_EQ(config->validate(), CameraConfiguration::Valid); ASSERT_EQ(camera_->configure(config.get()), 0); + const auto bufferCount = config->at(0).bufferCount; + + for (const auto &cfg : *config) { + Stream *stream = cfg.stream(); + + ASSERT_GE(allocator_.allocate(stream), 0) + << "Failed to allocate buffers"; + + ASSERT_EQ(allocator_.buffers(stream).size(), bufferCount) + << "Mismatching buffer count"; + } + + ASSERT_TRUE(allocator_.allocated()); + config_ = std::move(config); } @@ -112,7 +127,7 @@ void Capture::start() { assert(config_); assert(!config_->empty()); - assert(!allocator_.allocated()); + assert(allocator_.allocated()); assert(requests_.empty()); const auto bufferCount = config_->at(0).bufferCount; @@ -132,9 +147,6 @@ void Capture::start() for (const auto &cfg : *config_) { Stream *stream = cfg.stream(); - int count = allocator_.allocate(stream); - ASSERT_GE(count, 0) << "Failed to allocate buffers"; - const auto &buffers = allocator_.buffers(stream); ASSERT_EQ(buffers.size(), bufferCount) << "Mismatching buffer count"; @@ -144,8 +156,6 @@ void Capture::start() } } - ASSERT_TRUE(allocator_.allocated()); - camera_->requestCompleted.connect(this, &Capture::requestComplete); ASSERT_EQ(camera_->start(), 0) << "Failed to start camera"; @@ -161,6 +171,12 @@ void Capture::stop() camera_->requestCompleted.disconnect(this); requests_.clear(); +} + +void Capture::unconfigure() +{ + if (!config_ || !allocator_.allocated()) + return; for (const auto &cfg : *config_) { EXPECT_EQ(allocator_.free(cfg.stream()), 0) diff --git a/src/apps/lc-compliance/helpers/capture.h b/src/apps/lc-compliance/helpers/capture.h index ea01c11c1..41ce4e5a6 100644 --- a/src/apps/lc-compliance/helpers/capture.h +++ b/src/apps/lc-compliance/helpers/capture.h @@ -28,6 +28,7 @@ private: void start(); void stop(); + void unconfigure(); int queueRequest(libcamera::Request *request); void requestComplete(libcamera::Request *request);