From patchwork Fri Dec 16 12:29:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 18026 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 62E38C31E9 for ; Fri, 16 Dec 2022 12:30:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 23AAA633AE; Fri, 16 Dec 2022 13:30:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1671193825; 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=k75Idlki8MsdhBwYgOS95vPP0AL/ldPW5v2c/kdqEbPRn30QAzlxIb6md/Zlg4iT9 d+Pi6PXiwXriqpyuNT5WXpMaPL6auI9voS5k+UDZuX2fDWviY28ofRaI9z03A+dsfT 7lPW1GOhxYk4Zr36qm+q1cKijAPPDRX0no1qATt18tz8BgbvfSXQ90FPWCdQatJ62F 3naWwtK0q2bAWLdjsayOAM1inz//xRkegDW9hT+bJVYt3lqIENB4OSI2Uo9idnQWa7 20R+xn9z9MypxSxRqL3WQzoYS1Iuom2R2K8+Q10kY+u9kATbNL1BkTExAKeZL8KRtj C0XzftGsbwGgg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ECD7C633A3 for ; Fri, 16 Dec 2022 13:30:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="roU6xCpS"; dkim-atps=neutral Received: from pyrite.tail37cf.ts.net (h175-177-042-159.catv02.itscom.jp [175.177.42.159]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8361DA31; Fri, 16 Dec 2022 13:30:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1671193822; bh=0Ty1h03QfLcxojEN+CbLhHIvt/SjBcyEsZ0W/uCgrXs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=roU6xCpSa43zNDirhoWadzjVKra42t+f7A/3SXlONZ+mkprDpxxK+ALp5agb0m1wn MJufmp7fxgpBoPfq2BOBeOGwO7w63hqpEueq2YM+hGxaEEocX7MX/83CvGF7err2BZ 4dbSFTROF4k8LOJIJY4g7fGX+GMOkrrapqTsYP0k= To: libcamera-devel@lists.libcamera.org Date: Fri, 16 Dec 2022 21:29:33 +0900 Message-Id: <20221216122939.256534-13-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221216122939.256534-1-paul.elder@ideasonboard.com> References: <20221216122939.256534-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v9 12/18] 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);