From patchwork Wed Dec 28 22:29:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 18069 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 AAF07C3226 for ; Wed, 28 Dec 2022 22:30:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 67222625EC; Wed, 28 Dec 2022 23:30:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1672266641; bh=0Ty1h03QfLcxojEN+CbLhHIvt/SjBcyEsZ0W/uCgrXs=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=lgUl7EbiMbbEMsdsK4Foi/2ql82qGLcMngwkNpdr4E222aAAz+wzl9XvpG22fI4aq Rm94lx1PbLt7QwzzjBSpy4j/4i1qeX5KUc4XjTvw7kpyVJxA7J/0qKMGGjfb0LBBXn le1tlx3J6J2AADKcCRh8BceNy8QYDYTlW1X7akhOSK5OOIJrCywbqrhCFxmFvGByy5 tVjiSAvvLho/6kw7dE8ihR6BNwMp1YxBJatEk20rK59KkV9IDSz2EmPk0c01Tyl2Hx eKR7RYQdiYVAzXMitM4KePvPNuh4ufwA+KUL06f0i9tav8xdKyJ5hUDc62JpVJtj1e umuDRQ8k8dU7g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 907CD625ED for ; Wed, 28 Dec 2022 23:30:33 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PbO5Vh58"; dkim-atps=neutral Received: from pyrite.mediacom.info (unknown [IPv6:2604:2d80:ad8a:9000:1bf9:855b:22de:3645]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6BCE2109; Wed, 28 Dec 2022 23:30:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1672266633; bh=0Ty1h03QfLcxojEN+CbLhHIvt/SjBcyEsZ0W/uCgrXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PbO5Vh58kutGGrUTOQsGgtwrExIlDT+8RXva8TRwfan4fhorojLk6MBNMHCwITMPE NNpgI6WY2SbLHad7omrTCYKMbY845MqE47dLRugU3cNttFq1ptA+0fv+Mwbhn/MXoT aazdez6FqHIQbfWN11+cfVnbhFQWcYQTvkA2wGWc= To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Dec 2022 16:29:57 -0600 Message-Id: <20221228223003.2265712-14-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221228223003.2265712-1-paul.elder@ideasonboard.com> References: <20221228223003.2265712-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v10 13/19] lc-compliance: Move buffer allocation to separate function 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: , X-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: NĂ­colas F. R. A. Prado Move buffer allocation to its own function and with an optional count argument so tests can specify how many buffers to allocate. When count is omitted, allocate MinimumRequests buffers. Signed-off-by: NĂ­colas F. R. A. Prado Reviewed-by: Paul Elder Signed-off-by: Paul Elder --- Changes in v9: - rebased Changes in v8: - Made SimpleCapture::allocateBuffers() a single function with an optional parameter Changes in v5: - New --- src/apps/lc-compliance/capture_test.cpp | 8 +++++++- src/apps/lc-compliance/simple_capture.cpp | 16 ++++++++++------ src/apps/lc-compliance/simple_capture.h | 1 + 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp index 1dcfcf92..923395cf 100644 --- a/src/apps/lc-compliance/capture_test.cpp +++ b/src/apps/lc-compliance/capture_test.cpp @@ -87,6 +87,8 @@ TEST_P(SingleStream, Capture) capture.configure(role); + capture.allocateBuffers(); + capture.capture(numRequests); } @@ -106,8 +108,10 @@ TEST_P(SingleStream, CaptureStartStop) capture.configure(role); - for (unsigned int starts = 0; starts < numRepeats; starts++) + for (unsigned int starts = 0; starts < numRepeats; starts++) { + capture.allocateBuffers(); capture.capture(numRequests); + } } /* @@ -125,6 +129,8 @@ TEST_P(SingleStream, UnbalancedStop) capture.configure(role); + capture.allocateBuffers(); + capture.capture(numRequests); } diff --git a/src/apps/lc-compliance/simple_capture.cpp b/src/apps/lc-compliance/simple_capture.cpp index be495986..1e3e816a 100644 --- a/src/apps/lc-compliance/simple_capture.cpp +++ b/src/apps/lc-compliance/simple_capture.cpp @@ -44,16 +44,20 @@ void SimpleCapture::configure(StreamRole role) } } -void SimpleCapture::start() +void SimpleCapture::allocateBuffers(unsigned int count) { - unsigned int bufferCount = - camera_->properties().get(properties::MinimumRequests).value(); + if (!count) + count = camera_->properties().get(properties::MinimumRequests).value(); + Stream *stream = config_->at(0).stream(); - int count = allocator_->allocate(stream, bufferCount); + int allocatedCount = allocator_->allocate(stream, count); - ASSERT_GE(count, 0) << "Failed to allocate buffers"; - EXPECT_EQ(count, bufferCount) << "Allocated less buffers than expected"; + ASSERT_GE(allocatedCount, 0) << "Failed to allocate buffers"; + EXPECT_EQ(allocatedCount, count) << "Allocated less buffers than expected"; +} +void SimpleCapture::start() +{ camera_->requestCompleted.connect(this, &SimpleCapture::requestComplete); ASSERT_EQ(camera_->start(), 0) << "Failed to start camera"; diff --git a/src/apps/lc-compliance/simple_capture.h b/src/apps/lc-compliance/simple_capture.h index 2911d601..b3091547 100644 --- a/src/apps/lc-compliance/simple_capture.h +++ b/src/apps/lc-compliance/simple_capture.h @@ -17,6 +17,7 @@ class SimpleCapture { public: void configure(libcamera::StreamRole role); + void allocateBuffers(unsigned int count = 0); protected: SimpleCapture(std::shared_ptr camera);