From patchwork Fri Feb 3 09:44:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18253 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 80EFAC329E for ; Fri, 3 Feb 2023 09:44:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4C21E625E7; Fri, 3 Feb 2023 10:44:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675417476; 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=YX0wsH50eSYajFSMDeVPNpptcJ/hDT8Inc8RHe50iuKle7wERddBctm3DNT+drVsr qZBnGRDV7QlkZO9RKtpTOETfQ2VWwAaLfQvq94OHWVQ/gDepCHg/Mfp2axS5Cj3+pw FTO0dsR9XghRbFxGmB01CqZV6DModCQgdxB2KJ8urFZwBjCVHA2B4Rrm3RefdKZ4is dQ/woWwBc30VfBYraJzvo+HQ4T/+czOUQMF6KpVGedSRUyP57jYYoJ1qAwmAweWTlc OwI1gkG3t+TqCFaJMgaZmxVtxZiR4DeCHZlvrc1MtR0Y+LUS4gBxbq7diU0n/BxGk1 /iEP7BOTE6dTA== Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8878E625E6 for ; Fri, 3 Feb 2023 10:44:32 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="IhBsMNSB"; dkim-atps=neutral Received: by mail-wr1-x436.google.com with SMTP id h12so4087732wrv.10 for ; Fri, 03 Feb 2023 01:44:32 -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=IhBsMNSBmLOOMY83FeBaj89LiAj3w36TPSpEPEOevAtDUi94ZmZ2sCXhfg6AXfx5f2 D6AMCSGKz7H8Og3wl3rMWi8TnNKyHJl0y2aUngjV3dnjX2VzK9hPIHxy6Pje/uZury+0 /dQYkRyBbINv/L++V0cnxGBjdRfmP1WN/fh6QFFDGH637JtBqa8JMWWz4FJFjAkqp5GA EeGp9obqhcTD/mWYVK6qaNEyf6fxh3EKTVggaNE++iAPHs8+5gz8VMcvvtuzkBhG1n3g o5KHS+tiSadTK+RFQhqMzWFZEaECX7sCsziuNRfxMEkkY5CM4ob4j6nOfe6Ru4/c06U5 ly6g== 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=qAvHwzQ/t2ynhfUpn+DEjXQRHTs5t9hi81j3Z1qikExDy9sLGBWXdGXe/hQY/Z6vSs 5uL7rhnt0XkfgRafJ1jBZn66jh3vhgzJxiY328wo8RZ3RrHrAw3U8+CpvudOEqzjVHfc c5t3jdbMka+l1qCZxn2If5LgU4x6hCpQrCX5aEOMtMGOF5zppFvDXAelGxYYTpVbzG3P 3VR/Lt+RjyVoG+bpmqgruL7HacKbjL453tsqK11uzKl/beP1X2gm2D8dBXQwZ7VR7s7i HfYwgX51zbOPzxr4t1fKcm0Fycp3A9W1fcIkEx9b+BnSscOhx9ijIkXbEPZ/v87iz+mf lr6g== X-Gm-Message-State: AO0yUKXaMrfn5bwR2FSWKcmbwIaimWpyeuCSxFcxifkkwusme71xmvVo gtlEiwf+sbd4hnEy6sighflEcp6CG7rFWPAum6ZXvw== X-Google-Smtp-Source: AK7set8olCrDn/zhPCQqPR2VQRy1Q981eRT292dxOoeL3SxnTkWaLU4gvLcmyfuVnRzGuV6HKN89xg== X-Received: by 2002:a05:6000:2ce:b0:2bf:f805:5220 with SMTP id o14-20020a05600002ce00b002bff8055220mr11171656wry.43.1675417471860; Fri, 03 Feb 2023 01:44:31 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f17-20020a5d50d1000000b002bfe266d710sm1562503wrt.90.2023.02.03.01.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 01:44:31 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 3 Feb 2023 09:44:24 +0000 Message-Id: <20230203094424.25243-9-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230203094424.25243-1-naush@raspberrypi.com> References: <20230203094424.25243-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 8/8] 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 --- 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_; +};