From patchwork Fri Jan 27 15:43:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18215 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 E5B80C3242 for ; Fri, 27 Jan 2023 15:43:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9AEA862612; Fri, 27 Jan 2023 16:43:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834233; bh=LUAtUnrEzmwGTWKwtNC+GNZf02WnRv8bO7rk/b6Yt0Y=; 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=XGiHL5GRqbZFGr5agKmCrObAtXmIuXeR0JSlZX6vsEKaGT0m2vLwT43zocNQynEwM oKWiGNTDfFh3LZW6nWGbHrs2UrzEDP4NNjNdsyr1eYTemSsyvH9ID769QIjFIzea82 gSyJbXocz91V/XxzT0lNYCxhXMqPwpWvW8ZBxCnD/HYVpjdwwIPBwQhiF3Uy0Ph6rE zgRmMVYIV2zL/s4xY5eZOSEkTAwvnl8UPzzOKtSETKfUT9PZbHEyzXchT0mqVsVTkG SKVzqiGxEtH8rJabH1bSTOsE9t6b904PdE2w0QAvzs6cP2l45v+wlBkSblifGwiRI5 TbNMhfxYW5I5A== Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 80E36625E8 for ; Fri, 27 Jan 2023 16:43:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="UrRL6Iyr"; dkim-atps=neutral Received: by mail-wm1-x329.google.com with SMTP id f19-20020a1c6a13000000b003db0ef4dedcso5681788wmc.4 for ; Fri, 27 Jan 2023 07:43:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2scObb81b/oIwD4q0wu6Jc8r9Izoe6TDhaQrbOzkfu8=; b=UrRL6IyrVsoQzDnEIjQMdcflk5yemW4cHLz0L1ccej3jbBW3kOfzsVDAZ5J8wAm2tz YppcFEbwg9+MFptqJVLeEjbfIP7/lX2SHyljeIoHN3oyTr9hfX/FRJmEj51elw0/EtMW Tdc44lB2TITgGDxhFhY/YVAw+CMySeMhk9eZQpvFhMA/ksVWQ+ijY6qH5fGydZ8i97b3 uhR2Lsy5eZ7x/e9n4H2lY3/DcmIkIHpo99mZ18CHdcusN7CzHv9Ln1JZYOkWLdac1pna VbsGv14YbK469YzYjHTiz2MNXpmjDMKveoDdC/5RfxnxqsLW1pUFayX9x+hhSZw/RtDr fStw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2scObb81b/oIwD4q0wu6Jc8r9Izoe6TDhaQrbOzkfu8=; b=xTg9LkEc5LZrkJCVKmoMe93I+lMZCegq6DEz2Nfb7WOQMry6U53mpRcIrdRSX5pjYc C+Mhn6Wqhy80Brt2BnuZhWs7LW5OAPmjDR7QywDuOQ0f82vp+vqbzLOIH9rFDnFNfVCv N0BUJi9xt/k4CJSMCCaLkBtVCeCXzruqwB2a+Q9gvVMpKADH96Py/oGmdHNb5/yBfySr gAHTeB0EDWTlA3JjJvSVpKw52UC1+Tz2Fjqn5deAfU6GfdqYAdJaaRywVcocn5UxKXxG NxBOm/3l059B8Uoz4Lqq2I1CbfaWgoQ/uAti8GUZY83b+VQYyCqdWSsSuN95YUDQhG00 HMmQ== X-Gm-Message-State: AFqh2kpWslU9h+6hqg9CfMsguohXZ07ltCmrkBo+HkGRiltD4XFT+hlz /S0lNCpJWpeA6na4L0FUI3HV6qds8QZCPMHCN50= X-Google-Smtp-Source: AMrXdXvLOxvsiDqojxAw1iu/Xza5r6/KS3fJc9KEHwfHgcz3mpI90OMwL1s0iUUIROimDI/08XjXvw== X-Received: by 2002:a05:600c:540d:b0:3d9:fb59:c16b with SMTP id he13-20020a05600c540d00b003d9fb59c16bmr37122954wmb.36.1674834224748; Fri, 27 Jan 2023 07:43:44 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:44 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:22 +0000 Message-Id: <20230127154322.29019-16-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 15/15] libcamera: apps: lcc: Add stream hints test 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a new test class, MultiCaptureHints. This tests the MandatoryStream hint flag and ensures that requests are cancelled correctly if the flag is set and no buffer is provided. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham --- src/apps/lc-compliance/capture_test.cpp | 21 +++++++++++ src/apps/lc-compliance/multi_capture.cpp | 48 ++++++++++++++++++++++++ src/apps/lc-compliance/multi_capture.h | 17 +++++++++ 3 files changed, 86 insertions(+) diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp index c6a09a63248a..9239e8b5fc8a 100644 --- a/src/apps/lc-compliance/capture_test.cpp +++ b/src/apps/lc-compliance/capture_test.cpp @@ -229,6 +229,27 @@ TEST_P(MultiStream, CaptureOptional) capture.capture(numRequests, NumStreams, 1); } +/* + * Test mandatory stream hints + * + * Mark a single stream as mandatory, and don't provide a buffer for it in the + * request. This should case the queueRequest call to fail. + */ +TEST_P(MultiStream, CaptureHints) +{ + constexpr unsigned int NumStreams = 2; + + auto [roles, numRequests] = GetParam(); + + MultiCaptureHints capture0(camera_, 0); + capture0.configure({ roles.first, roles.second }); + capture0.capture(NumStreams); + + MultiCaptureHints capture1(camera_, 1); + capture1.configure({ roles.first, roles.second }); + capture1.capture(NumStreams); +} + INSTANTIATE_TEST_SUITE_P(MultiCaptureTests, MultiStream, testing::Combine(testing::ValuesIn(MULTIROLES), diff --git a/src/apps/lc-compliance/multi_capture.cpp b/src/apps/lc-compliance/multi_capture.cpp index a011dfb285c8..6aa39b7e281f 100644 --- a/src/apps/lc-compliance/multi_capture.cpp +++ b/src/apps/lc-compliance/multi_capture.cpp @@ -238,3 +238,51 @@ void MultiCaptureOptional::capture(unsigned int numRequests, unsigned int numStr ASSERT_EQ(captureCount_, captureLimit_); } + +/* MultiCaptureHints */ + +MultiCaptureHints::MultiCaptureHints(std::shared_ptr camera, + unsigned int mandatoryStream) + : MultiCaptureBase(camera), mandatoryStream_(mandatoryStream) +{ +} + +void MultiCaptureHints::capture(unsigned int numStreams) +{ + start(); + + std::vector + buffers = prepareBuffers(config_->at(0).bufferCount, numStreams); + + if (!buffers.size()) + GTEST_SKIP(); + + /* Queue a single request */ + std::unique_ptr request = camera_->createRequest(); + ASSERT_TRUE(request) << "Can't create request"; + + for (unsigned int j = 0; j < numStreams; j++) { + const FrameBufferList *bufferList = buffers[j]; + Stream *stream = config_->at(j).stream(); + + /* + * Do not add a buffer for the mandatory stream to cause a + * deliberate failure. + */ + if (j == mandatoryStream_) + continue; + + ASSERT_EQ(request->addBuffer(stream, (*bufferList)[0].get()), 0) + << "Can't set buffer for request"; + } + + ASSERT_EQ(camera_->queueRequest(request.get()), -ENOMEM) + << "queueRequest did not fail!"; + + stop(); +} + +void MultiCaptureHints::updateConfig() +{ + config_.get()->at(mandatoryStream_).hints = StreamConfiguration::Hint::MandatoryStream; +} diff --git a/src/apps/lc-compliance/multi_capture.h b/src/apps/lc-compliance/multi_capture.h index 3d92ba3d4c10..c48c16e7565d 100644 --- a/src/apps/lc-compliance/multi_capture.h +++ b/src/apps/lc-compliance/multi_capture.h @@ -68,3 +68,20 @@ public: void capture(unsigned int numRequests, unsigned int numStreams, unsigned int optionalStream); }; + +class MultiCaptureHints : public MultiCaptureBase +{ +public: + MultiCaptureHints(std::shared_ptr camera, + unsigned int mandatoryStream); + + void capture(unsigned int numStreams); + +private: + void updateConfig() override; + void requestComplete([[maybe_unused]] libcamera::Request *request) override + { + } + + unsigned int mandatoryStream_; +};